@sixb/core 0.2.3 → 0.2.5

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 (587) hide show
  1. package/dist/actions/index.js +28 -28
  2. package/dist/agents/cancel.d.ts +1 -1
  3. package/dist/agents/cancel.d.ts.map +1 -1
  4. package/dist/agents/child-question.d.ts +35 -2
  5. package/dist/agents/child-question.d.ts.map +1 -1
  6. package/dist/agents/execution.d.ts +35 -3
  7. package/dist/agents/execution.d.ts.map +1 -1
  8. package/dist/agents/ids.d.ts +4 -0
  9. package/dist/agents/ids.d.ts.map +1 -1
  10. package/dist/agents/index.d.ts +9 -7
  11. package/dist/agents/index.d.ts.map +1 -1
  12. package/dist/agents/index.js +59 -33
  13. package/dist/agents/index.js.map +1 -1
  14. package/dist/agents/model-loop.d.ts.map +1 -1
  15. package/dist/agents/queued-turn.d.ts +16 -0
  16. package/dist/agents/queued-turn.d.ts.map +1 -0
  17. package/dist/agents/request.d.ts +79 -1
  18. package/dist/agents/request.d.ts.map +1 -1
  19. package/dist/agents/run-after-finish.d.ts +10 -0
  20. package/dist/agents/run-after-finish.d.ts.map +1 -1
  21. package/dist/agents/run-artifacts.d.ts +0 -38
  22. package/dist/agents/run-artifacts.d.ts.map +1 -1
  23. package/dist/agents/run-events.d.ts +6 -1
  24. package/dist/agents/run-events.d.ts.map +1 -1
  25. package/dist/agents/run-session-children.d.ts +9 -0
  26. package/dist/agents/run-session-children.d.ts.map +1 -1
  27. package/dist/agents/run-session-http.d.ts.map +1 -1
  28. package/dist/agents/run-session-serve.d.ts.map +1 -1
  29. package/dist/agents/run-session.d.ts +14 -1
  30. package/dist/agents/run-session.d.ts.map +1 -1
  31. package/dist/agents/run-turn.d.ts.map +1 -1
  32. package/dist/agents/streams/index.d.ts +1 -1
  33. package/dist/agents/streams/index.d.ts.map +1 -1
  34. package/dist/agents/streams/index.js +1 -1
  35. package/dist/agents/streams/internal.js +1 -1
  36. package/dist/agents/streams/protocol.d.ts +16 -0
  37. package/dist/agents/streams/protocol.d.ts.map +1 -1
  38. package/dist/agents/tool-files.d.ts +1 -1
  39. package/dist/agents/tool-files.d.ts.map +1 -1
  40. package/dist/agents/tool-input-coercion.d.ts +20 -0
  41. package/dist/agents/tool-input-coercion.d.ts.map +1 -0
  42. package/dist/agents/turn-answered.d.ts +7 -0
  43. package/dist/agents/turn-answered.d.ts.map +1 -0
  44. package/dist/agents/validation.d.ts +1 -1
  45. package/dist/agents/validation.d.ts.map +1 -1
  46. package/dist/artifacts/canvas-display.d.ts +3 -5
  47. package/dist/artifacts/canvas-display.d.ts.map +1 -1
  48. package/dist/artifacts/comments.d.ts +14 -3
  49. package/dist/artifacts/comments.d.ts.map +1 -1
  50. package/dist/artifacts/document-fill.d.ts +18 -0
  51. package/dist/artifacts/document-fill.d.ts.map +1 -0
  52. package/dist/artifacts/errors.d.ts +1 -1
  53. package/dist/artifacts/errors.d.ts.map +1 -1
  54. package/dist/artifacts/events.d.ts +3 -2
  55. package/dist/artifacts/events.d.ts.map +1 -1
  56. package/dist/artifacts/execution.d.ts +40 -4
  57. package/dist/artifacts/execution.d.ts.map +1 -1
  58. package/dist/artifacts/frames/assets.d.ts +8 -1
  59. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  60. package/dist/artifacts/frames/document-data.d.ts +98 -0
  61. package/dist/artifacts/frames/document-data.d.ts.map +1 -0
  62. package/dist/artifacts/frames/entries.d.ts +12 -7
  63. package/dist/artifacts/frames/entries.d.ts.map +1 -1
  64. package/dist/artifacts/frames/index.d.ts +2 -1
  65. package/dist/artifacts/frames/index.d.ts.map +1 -1
  66. package/dist/artifacts/frames/index.js +22 -13
  67. package/dist/artifacts/frames/index.js.map +4 -4
  68. package/dist/artifacts/frames/kit.d.ts +15 -0
  69. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  70. package/dist/artifacts/frames/protocol.d.ts +65 -3
  71. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  72. package/dist/artifacts/frames/runtime.d.ts +32 -5
  73. package/dist/artifacts/frames/runtime.d.ts.map +1 -1
  74. package/dist/artifacts/index.d.ts +4 -2
  75. package/dist/artifacts/index.d.ts.map +1 -1
  76. package/dist/artifacts/index.js +35 -3
  77. package/dist/artifacts/index.js.map +3 -3
  78. package/dist/artifacts/live/blocks.d.ts +62 -0
  79. package/dist/artifacts/live/blocks.d.ts.map +1 -0
  80. package/dist/artifacts/live/board.d.ts +6 -0
  81. package/dist/artifacts/live/board.d.ts.map +1 -1
  82. package/dist/artifacts/live/document.d.ts +12 -0
  83. package/dist/artifacts/live/document.d.ts.map +1 -1
  84. package/dist/artifacts/live/index.d.ts +2 -0
  85. package/dist/artifacts/live/index.d.ts.map +1 -1
  86. package/dist/artifacts/live/index.js +148 -44
  87. package/dist/artifacts/live/index.js.map +3 -3
  88. package/dist/artifacts/live/page.d.ts +49 -0
  89. package/dist/artifacts/live/page.d.ts.map +1 -0
  90. package/dist/artifacts/live/protocol.d.ts +5 -0
  91. package/dist/artifacts/live/protocol.d.ts.map +1 -1
  92. package/dist/artifacts/live/server.d.ts +2 -2
  93. package/dist/artifacts/live/server.d.ts.map +1 -1
  94. package/dist/artifacts/live/server.js +23 -19
  95. package/dist/artifacts/live/server.js.map +1 -1
  96. package/dist/artifacts/live/state.d.ts +4 -1
  97. package/dist/artifacts/live/state.d.ts.map +1 -1
  98. package/dist/artifacts/outline.d.ts +16 -0
  99. package/dist/artifacts/outline.d.ts.map +1 -1
  100. package/dist/artifacts/paper.d.ts +22 -0
  101. package/dist/artifacts/paper.d.ts.map +1 -0
  102. package/dist/artifacts/pdf-job.d.ts +9 -0
  103. package/dist/artifacts/pdf-job.d.ts.map +1 -0
  104. package/dist/artifacts/publish/fields.d.ts +25 -0
  105. package/dist/artifacts/publish/fields.d.ts.map +1 -0
  106. package/dist/artifacts/publish/index.d.ts +2 -1
  107. package/dist/artifacts/publish/index.d.ts.map +1 -1
  108. package/dist/artifacts/publish/index.js +26 -18
  109. package/dist/artifacts/publish/index.js.map +1 -1
  110. package/dist/artifacts/publish/merge.d.ts +5 -5
  111. package/dist/artifacts/publish/merge.d.ts.map +1 -1
  112. package/dist/artifacts/publish/pdf.d.ts +28 -0
  113. package/dist/artifacts/publish/pdf.d.ts.map +1 -0
  114. package/dist/artifacts/publish/previews.d.ts +12 -20
  115. package/dist/artifacts/publish/previews.d.ts.map +1 -1
  116. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  117. package/dist/artifacts/publish/queries.d.ts +6 -1
  118. package/dist/artifacts/publish/queries.d.ts.map +1 -1
  119. package/dist/artifacts/publish/query-answers.d.ts +5 -2
  120. package/dist/artifacts/publish/query-answers.d.ts.map +1 -1
  121. package/dist/artifacts/publish/validate/document-html.d.ts +24 -0
  122. package/dist/artifacts/publish/validate/document-html.d.ts.map +1 -0
  123. package/dist/artifacts/publish/validate/document.d.ts +5 -3
  124. package/dist/artifacts/publish/validate/document.d.ts.map +1 -1
  125. package/dist/artifacts/queries.d.ts +16 -2
  126. package/dist/artifacts/queries.d.ts.map +1 -1
  127. package/dist/auth/index.js +2 -2
  128. package/dist/authorization/event-visibility.d.ts.map +1 -1
  129. package/dist/authorization/index.js +1 -1
  130. package/dist/blob-storage/index.js +1 -1
  131. package/dist/bootstrap/index.js +38 -38
  132. package/dist/{chunk-tqa68kj7.js → chunk-0hkdtwqk.js} +5 -5
  133. package/dist/{chunk-s5n9617r.js → chunk-0mvjpgvm.js} +5 -5
  134. package/dist/{chunk-k66rp2hr.js → chunk-1yh6jgtz.js} +1 -1
  135. package/dist/{chunk-26qet7wh.js → chunk-5t9gm5tt.js} +4 -4
  136. package/dist/{chunk-a6fjkcne.js → chunk-60662fyv.js} +54 -28
  137. package/dist/{chunk-a6fjkcne.js.map → chunk-60662fyv.js.map} +7 -6
  138. package/dist/{chunk-e0hnbb1m.js → chunk-61zptves.js} +1 -1
  139. package/dist/{chunk-hkaa807g.js → chunk-68hm50qh.js} +3 -3
  140. package/dist/{chunk-9nsjjd44.js → chunk-8tv3qd65.js} +2 -1
  141. package/dist/chunk-8tv3qd65.js.map +12 -0
  142. package/dist/{chunk-fe6r7yhg.js → chunk-92wrka15.js} +1 -1
  143. package/dist/{chunk-m7b9q5dk.js → chunk-aw1z0gre.js} +4 -4
  144. package/dist/chunk-az95tsh3.js.map +2 -2
  145. package/dist/{chunk-4j0sagwv.js → chunk-b4escq4c.js} +62 -14
  146. package/dist/{chunk-4j0sagwv.js.map → chunk-b4escq4c.js.map} +7 -7
  147. package/dist/chunk-bqr703h4.js +1799 -0
  148. package/dist/chunk-bqr703h4.js.map +13 -0
  149. package/dist/{chunk-eptrvnby.js → chunk-c29729me.js} +42 -3
  150. package/dist/chunk-c29729me.js.map +12 -0
  151. package/dist/{chunk-t24yktqr.js → chunk-dvgc56n2.js} +20 -4
  152. package/dist/{chunk-t24yktqr.js.map → chunk-dvgc56n2.js.map} +5 -5
  153. package/dist/{chunk-3014rfjz.js → chunk-ewqn51gr.js} +25 -7
  154. package/dist/{chunk-3014rfjz.js.map → chunk-ewqn51gr.js.map} +3 -3
  155. package/dist/{chunk-7z5rkf0m.js → chunk-ey1p8w68.js} +175 -5
  156. package/dist/chunk-ey1p8w68.js.map +13 -0
  157. package/dist/{chunk-z0t4p2sk.js → chunk-fpf57gca.js} +350 -61
  158. package/dist/chunk-fpf57gca.js.map +47 -0
  159. package/dist/{chunk-kv0kvknv.js → chunk-fzae1jpq.js} +7 -7
  160. package/dist/{chunk-b9qfh2ya.js → chunk-fzbhybya.js} +29 -2
  161. package/dist/chunk-fzbhybya.js.map +11 -0
  162. package/dist/{chunk-2by73sm2.js → chunk-gjhrz66x.js} +225 -17
  163. package/dist/{chunk-2by73sm2.js.map → chunk-gjhrz66x.js.map} +5 -5
  164. package/dist/chunk-hn2r7z41.js.map +1 -1
  165. package/dist/{chunk-6gtxshcc.js → chunk-k29n4176.js} +6 -6
  166. package/dist/{chunk-48c1z8nj.js → chunk-k3jh8gsg.js} +10 -2
  167. package/dist/chunk-k3jh8gsg.js.map +10 -0
  168. package/dist/{chunk-w9s23r24.js → chunk-m3qx2pns.js} +751 -93
  169. package/dist/chunk-m3qx2pns.js.map +34 -0
  170. package/dist/{chunk-smnt672s.js → chunk-m9ketb51.js} +20 -4
  171. package/dist/chunk-m9ketb51.js.map +10 -0
  172. package/dist/chunk-mbwsgjn7.js +40 -0
  173. package/dist/chunk-mbwsgjn7.js.map +11 -0
  174. package/dist/{chunk-sysnvjce.js → chunk-naxjka9v.js} +2 -2
  175. package/dist/{chunk-n4zzaf6q.js → chunk-nxysqbt0.js} +4 -2
  176. package/dist/chunk-nxysqbt0.js.map +10 -0
  177. package/dist/{chunk-vzkxqf8h.js → chunk-paxabbqd.js} +49 -5
  178. package/dist/chunk-paxabbqd.js.map +23 -0
  179. package/dist/{chunk-8tqnsx3q.js → chunk-pc7kra3k.js} +5 -3
  180. package/dist/{chunk-8tqnsx3q.js.map → chunk-pc7kra3k.js.map} +3 -3
  181. package/dist/{chunk-qafng88v.js → chunk-pqvvqc65.js} +4 -4
  182. package/dist/chunk-pvpq483h.js.map +2 -2
  183. package/dist/{chunk-mzx71snp.js → chunk-q7g9cqwt.js} +7 -2
  184. package/dist/{chunk-mzx71snp.js.map → chunk-q7g9cqwt.js.map} +3 -3
  185. package/dist/{chunk-8t2ynwg0.js → chunk-q8d9p0tb.js} +24 -1
  186. package/dist/{chunk-8t2ynwg0.js.map → chunk-q8d9p0tb.js.map} +3 -3
  187. package/dist/{chunk-wa05txmk.js → chunk-qavwr628.js} +49 -5
  188. package/dist/chunk-qavwr628.js.map +12 -0
  189. package/dist/{chunk-bkmnd7zq.js → chunk-rg725hry.js} +174 -30
  190. package/dist/{chunk-bkmnd7zq.js.map → chunk-rg725hry.js.map} +9 -8
  191. package/dist/{chunk-8p7bze4c.js → chunk-s1mqyqmm.js} +3 -3
  192. package/dist/{chunk-p351afzm.js → chunk-s5pj68fa.js} +2 -2
  193. package/dist/{chunk-855w9nvw.js → chunk-vehcr9eb.js} +1 -1
  194. package/dist/{chunk-qds484t8.js → chunk-vs2s3p8n.js} +932 -21
  195. package/dist/chunk-vs2s3p8n.js.map +20 -0
  196. package/dist/chunk-vtjzwymr.js.map +2 -2
  197. package/dist/{chunk-n68vz95m.js → chunk-wqe9shx2.js} +1 -1
  198. package/dist/{chunk-0k3r5kb3.js → chunk-xcrnrpfh.js} +1 -1
  199. package/dist/{chunk-cwdzcv37.js → chunk-xrmbhap8.js} +2 -2
  200. package/dist/{chunk-cwdzcv37.js.map → chunk-xrmbhap8.js.map} +2 -2
  201. package/dist/{chunk-f6ahf5gf.js → chunk-xxfj0rr2.js} +20 -5
  202. package/dist/chunk-xxfj0rr2.js.map +13 -0
  203. package/dist/{chunk-3hzhcfsv.js → chunk-y8fwm3z2.js} +2 -2
  204. package/dist/{chunk-3hzhcfsv.js.map → chunk-y8fwm3z2.js.map} +3 -3
  205. package/dist/{chunk-e9w4mgdh.js → chunk-z1njfqqs.js} +589 -53
  206. package/dist/{chunk-e9w4mgdh.js.map → chunk-z1njfqqs.js.map} +14 -11
  207. package/dist/{chunk-yv8hv4wq.js → chunk-z4jqb44a.js} +3 -1
  208. package/dist/chunk-z4jqb44a.js.map +10 -0
  209. package/dist/{chunk-s7xqfxs9.js → chunk-zft9bzbc.js} +2 -1
  210. package/dist/{chunk-s7xqfxs9.js.map → chunk-zft9bzbc.js.map} +3 -3
  211. package/dist/{chunk-38yvdqzd.js → chunk-zxhym8tr.js} +1 -1
  212. package/dist/connectors/connection-handles.d.ts +9 -0
  213. package/dist/connectors/connection-handles.d.ts.map +1 -0
  214. package/dist/connectors/connections/authorizations.d.ts +9 -0
  215. package/dist/connectors/connections/authorizations.d.ts.map +1 -1
  216. package/dist/connectors/connections/events.d.ts +17 -0
  217. package/dist/connectors/connections/events.d.ts.map +1 -0
  218. package/dist/connectors/connections/runs.d.ts +3 -0
  219. package/dist/connectors/connections/runs.d.ts.map +1 -1
  220. package/dist/connectors/connections/service.d.ts +4 -0
  221. package/dist/connectors/connections/service.d.ts.map +1 -1
  222. package/dist/connectors/execution.d.ts +7 -1
  223. package/dist/connectors/execution.d.ts.map +1 -1
  224. package/dist/connectors/index.d.ts +1 -1
  225. package/dist/connectors/index.d.ts.map +1 -1
  226. package/dist/connectors/types.d.ts +22 -1
  227. package/dist/connectors/types.d.ts.map +1 -1
  228. package/dist/datasets/write.js +1 -1
  229. package/dist/deploy/index.d.ts +1 -1
  230. package/dist/deploy/index.d.ts.map +1 -1
  231. package/dist/deploy/internal.js +3 -2
  232. package/dist/deploy/internal.js.map +3 -3
  233. package/dist/deploy/services.d.ts.map +1 -1
  234. package/dist/deploy/types.d.ts +18 -1
  235. package/dist/deploy/types.d.ts.map +1 -1
  236. package/dist/events/definitions.d.ts +4 -0
  237. package/dist/events/definitions.d.ts.map +1 -1
  238. package/dist/events/execution.d.ts.map +1 -1
  239. package/dist/events/index.d.ts +2 -2
  240. package/dist/events/index.d.ts.map +1 -1
  241. package/dist/events/index.js +3 -3
  242. package/dist/events/outbox-dispatcher.d.ts +7 -0
  243. package/dist/events/outbox-dispatcher.d.ts.map +1 -1
  244. package/dist/events/scope.d.ts +1 -0
  245. package/dist/events/scope.d.ts.map +1 -1
  246. package/dist/events/scope.js +1 -1
  247. package/dist/events/selectors/builder.d.ts +9 -1
  248. package/dist/events/selectors/builder.d.ts.map +1 -1
  249. package/dist/events/selectors/index.d.ts +2 -2
  250. package/dist/events/selectors/index.d.ts.map +1 -1
  251. package/dist/events/selectors/index.js +2 -2
  252. package/dist/events/selectors/predicate.d.ts.map +1 -1
  253. package/dist/events/selectors/types.d.ts +18 -3
  254. package/dist/events/selectors/types.d.ts.map +1 -1
  255. package/dist/events/types/artifacts.d.ts +7 -1
  256. package/dist/events/types/artifacts.d.ts.map +1 -1
  257. package/dist/events/types/connectors.d.ts +32 -0
  258. package/dist/events/types/connectors.d.ts.map +1 -0
  259. package/dist/events/types/index.d.ts +3 -1
  260. package/dist/events/types/index.d.ts.map +1 -1
  261. package/dist/execution/agent.js +28 -28
  262. package/dist/execution/authorization.d.ts +5 -0
  263. package/dist/execution/authorization.d.ts.map +1 -1
  264. package/dist/execution/primitive.js +28 -28
  265. package/dist/execution/request.js +29 -29
  266. package/dist/execution/scopes.d.ts +8 -0
  267. package/dist/execution/scopes.d.ts.map +1 -1
  268. package/dist/execution/script.d.ts +7 -0
  269. package/dist/execution/script.d.ts.map +1 -0
  270. package/dist/execution/types.d.ts +16 -1
  271. package/dist/execution/types.d.ts.map +1 -1
  272. package/dist/http/api-routes.d.ts.map +1 -1
  273. package/dist/http/index.js +1 -1
  274. package/dist/index.d.ts +9 -8
  275. package/dist/index.d.ts.map +1 -1
  276. package/dist/index.js +46 -44
  277. package/dist/index.js.map +1 -1
  278. package/dist/lake-storage/index.js +1 -1
  279. package/dist/lineage/executors.d.ts +1 -1
  280. package/dist/lineage/executors.d.ts.map +1 -1
  281. package/dist/maintenance/index.js +1 -1
  282. package/dist/materialization/event-envelopes.d.ts +3 -3
  283. package/dist/materialization/event-envelopes.d.ts.map +1 -1
  284. package/dist/materialization/events.d.ts +6 -0
  285. package/dist/materialization/events.d.ts.map +1 -1
  286. package/dist/materialization/index.js +1 -1
  287. package/dist/materialization/model.d.ts +6 -0
  288. package/dist/materialization/model.d.ts.map +1 -1
  289. package/dist/materializer/index.js +13 -13
  290. package/dist/materializer/projections/replace.d.ts.map +1 -1
  291. package/dist/materializer/projections/replacement-plan.d.ts +2 -0
  292. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  293. package/dist/materializer/shared/normalize.d.ts +1 -0
  294. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  295. package/dist/models/execution/index.js +12 -12
  296. package/dist/models/language-model.d.ts +6 -0
  297. package/dist/models/language-model.d.ts.map +1 -1
  298. package/dist/models/tools.d.ts +2 -0
  299. package/dist/models/tools.d.ts.map +1 -1
  300. package/dist/objects/index.js +28 -28
  301. package/dist/objects/query/index.js +12 -12
  302. package/dist/pipelines/index.js +18 -18
  303. package/dist/projections/builders.d.ts +7 -1
  304. package/dist/projections/builders.d.ts.map +1 -1
  305. package/dist/projections/index.d.ts +1 -1
  306. package/dist/projections/index.d.ts.map +1 -1
  307. package/dist/projections/internal.js +13 -13
  308. package/dist/projections/types.d.ts +10 -0
  309. package/dist/projections/types.d.ts.map +1 -1
  310. package/dist/projections/validation.d.ts.map +1 -1
  311. package/dist/queues/in-memory.d.ts +2 -1
  312. package/dist/queues/in-memory.d.ts.map +1 -1
  313. package/dist/queues/index.d.ts +1 -1
  314. package/dist/queues/index.d.ts.map +1 -1
  315. package/dist/queues/index.js +1 -1
  316. package/dist/queues/types.d.ts +40 -13
  317. package/dist/queues/types.d.ts.map +1 -1
  318. package/dist/runtime/host.d.ts +13 -0
  319. package/dist/runtime/host.d.ts.map +1 -1
  320. package/dist/runtime/internal.d.ts +1 -0
  321. package/dist/runtime/internal.d.ts.map +1 -1
  322. package/dist/runtime/internal.js +39 -18
  323. package/dist/runtime/internal.js.map +4 -3
  324. package/dist/runtime/resolve-definitions.d.ts +1 -1
  325. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  326. package/dist/runtime/script.d.ts +39 -0
  327. package/dist/runtime/script.d.ts.map +1 -0
  328. package/dist/runtime/sixb.d.ts +2 -2
  329. package/dist/runtime/sixb.d.ts.map +1 -1
  330. package/dist/schedules/builders.d.ts.map +1 -1
  331. package/dist/schedules/index.js +3 -3
  332. package/dist/schedules/runtime.d.ts.map +1 -1
  333. package/dist/schedules/validation.d.ts +2 -0
  334. package/dist/schedules/validation.d.ts.map +1 -1
  335. package/dist/shares/internal.js +12 -12
  336. package/dist/storage/agents/errors.d.ts +1 -1
  337. package/dist/storage/agents/errors.d.ts.map +1 -1
  338. package/dist/storage/agents/in-memory.d.ts +26 -1
  339. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  340. package/dist/storage/agents/index.d.ts +2 -2
  341. package/dist/storage/agents/index.d.ts.map +1 -1
  342. package/dist/storage/agents/provider.d.ts +12 -3
  343. package/dist/storage/agents/provider.d.ts.map +1 -1
  344. package/dist/storage/agents/provider.js +25 -5
  345. package/dist/storage/agents/provider.js.map +1 -1
  346. package/dist/storage/agents/types.d.ts +156 -1
  347. package/dist/storage/agents/types.d.ts.map +1 -1
  348. package/dist/storage/artifacts/in-memory.d.ts +7 -1
  349. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  350. package/dist/storage/artifacts/index.d.ts +1 -1
  351. package/dist/storage/artifacts/index.d.ts.map +1 -1
  352. package/dist/storage/artifacts/record.d.ts +2 -1
  353. package/dist/storage/artifacts/record.d.ts.map +1 -1
  354. package/dist/storage/artifacts/types.d.ts +34 -0
  355. package/dist/storage/artifacts/types.d.ts.map +1 -1
  356. package/dist/storage/executions/provider.d.ts +3 -3
  357. package/dist/storage/executions/provider.d.ts.map +1 -1
  358. package/dist/storage/executions/provider.js +1 -1
  359. package/dist/storage/executions/types.d.ts +6 -0
  360. package/dist/storage/executions/types.d.ts.map +1 -1
  361. package/dist/storage/executions/validation.d.ts.map +1 -1
  362. package/dist/storage/file-upload-sessions/provider.js +3 -3
  363. package/dist/storage/index.d.ts +3 -3
  364. package/dist/storage/index.d.ts.map +1 -1
  365. package/dist/storage/index.js +18 -14
  366. package/dist/storage/index.js.map +1 -1
  367. package/dist/storage/internal.d.ts +1 -1
  368. package/dist/storage/internal.d.ts.map +1 -1
  369. package/dist/storage/internal.js +8 -6
  370. package/dist/storage/internal.js.map +2 -2
  371. package/dist/storage/ontology/in-memory/replacement-plans.d.ts +2 -0
  372. package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
  373. package/dist/storage/ontology/provider.js +1 -1
  374. package/dist/storage/ontology/replacement-plans.d.ts +8 -0
  375. package/dist/storage/ontology/replacement-plans.d.ts.map +1 -1
  376. package/dist/storage/operation-scope.d.ts.map +1 -1
  377. package/dist/storage/operation-scope.js +1 -1
  378. package/dist/storage/workflow-runs/provider.js +3 -3
  379. package/dist/syncs/index.js +19 -19
  380. package/dist/testing/agent-execution.d.ts +3 -0
  381. package/dist/testing/agent-execution.d.ts.map +1 -1
  382. package/dist/testing/agent-inbox-storage-contract.d.ts +15 -0
  383. package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -0
  384. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  385. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  386. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  387. package/dist/testing/index.d.ts +1 -0
  388. package/dist/testing/index.d.ts.map +1 -1
  389. package/dist/testing/index.js +5524 -4555
  390. package/dist/testing/index.js.map +10 -9
  391. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  392. package/dist/testing/queues-contract.d.ts.map +1 -1
  393. package/dist/webhooks/connections.d.ts +3 -4
  394. package/dist/webhooks/connections.d.ts.map +1 -1
  395. package/dist/webhooks/index.d.ts +1 -1
  396. package/dist/webhooks/index.d.ts.map +1 -1
  397. package/dist/webhooks/internal.js +16 -49
  398. package/dist/webhooks/internal.js.map +3 -3
  399. package/dist/webhooks/types.d.ts +2 -11
  400. package/dist/webhooks/types.d.ts.map +1 -1
  401. package/dist/workers/queued-run-dispatch.d.ts.map +1 -1
  402. package/dist/workflows/index.js +35 -35
  403. package/package.json +6 -1
  404. package/src/agents/README.md +6 -2
  405. package/src/agents/approval-outcome.ts +2 -2
  406. package/src/agents/cancel.ts +2 -2
  407. package/src/agents/child-question.ts +76 -8
  408. package/src/agents/execution.ts +168 -30
  409. package/src/agents/ids.ts +9 -1
  410. package/src/agents/index.ts +27 -6
  411. package/src/agents/model-loop.ts +3 -1
  412. package/src/agents/queued-turn.ts +46 -0
  413. package/src/agents/request.ts +517 -2
  414. package/src/agents/run-after-finish.ts +259 -2
  415. package/src/agents/run-artifacts.ts +3 -93
  416. package/src/agents/run-events.ts +26 -1
  417. package/src/agents/run-session-children.ts +33 -0
  418. package/src/agents/run-session-http.ts +10 -2
  419. package/src/agents/run-session-serve.ts +3 -8
  420. package/src/agents/run-session.ts +142 -3
  421. package/src/agents/run-turn.ts +8 -0
  422. package/src/agents/streams/index.ts +1 -0
  423. package/src/agents/streams/protocol.ts +41 -1
  424. package/src/agents/tool-files.ts +1 -1
  425. package/src/agents/tool-input-coercion.ts +140 -0
  426. package/src/agents/turn-answered.ts +31 -0
  427. package/src/agents/validation.ts +13 -3
  428. package/src/artifacts/canvas-display.ts +4 -6
  429. package/src/artifacts/comments.ts +70 -17
  430. package/src/artifacts/document-fill.ts +103 -0
  431. package/src/artifacts/errors.ts +2 -0
  432. package/src/artifacts/events.ts +4 -1
  433. package/src/artifacts/execution.ts +265 -31
  434. package/src/artifacts/frames/assets.ts +42 -7
  435. package/src/artifacts/frames/document-data.ts +353 -0
  436. package/src/artifacts/frames/entries.ts +22 -16
  437. package/src/artifacts/frames/grants.ts +2 -2
  438. package/src/artifacts/frames/index.ts +3 -0
  439. package/src/artifacts/frames/kit.ts +102 -0
  440. package/src/artifacts/frames/protocol.ts +96 -3
  441. package/src/artifacts/frames/runtime.ts +709 -19
  442. package/src/artifacts/index.ts +6 -0
  443. package/src/artifacts/live/blocks.ts +889 -0
  444. package/src/artifacts/live/board.ts +195 -42
  445. package/src/artifacts/live/document.ts +170 -5
  446. package/src/artifacts/live/index.ts +7 -0
  447. package/src/artifacts/live/page.ts +807 -0
  448. package/src/artifacts/live/protocol.ts +5 -0
  449. package/src/artifacts/live/server.ts +2 -2
  450. package/src/artifacts/live/state.ts +9 -4
  451. package/src/artifacts/outline.ts +17 -0
  452. package/src/artifacts/paper.ts +173 -0
  453. package/src/artifacts/pdf-job.ts +11 -0
  454. package/src/artifacts/publish/fields.ts +177 -0
  455. package/src/artifacts/publish/index.ts +6 -1
  456. package/src/artifacts/publish/merge.ts +14 -12
  457. package/src/artifacts/publish/pdf.ts +82 -0
  458. package/src/artifacts/publish/previews.ts +24 -34
  459. package/src/artifacts/publish/publish.ts +26 -3
  460. package/src/artifacts/publish/queries.ts +20 -4
  461. package/src/artifacts/publish/query-answers.ts +14 -3
  462. package/src/artifacts/publish/validate/document-html.ts +245 -0
  463. package/src/artifacts/publish/validate/document.ts +34 -3
  464. package/src/artifacts/queries.ts +59 -13
  465. package/src/authorization/event-visibility.ts +13 -0
  466. package/src/connectors/connection-handles.ts +71 -0
  467. package/src/connectors/connections/authorizations.ts +50 -2
  468. package/src/connectors/connections/events.ts +57 -0
  469. package/src/connectors/connections/runs.ts +5 -0
  470. package/src/connectors/connections/service.ts +19 -1
  471. package/src/connectors/execution.ts +30 -2
  472. package/src/connectors/index.ts +3 -0
  473. package/src/connectors/types.ts +29 -1
  474. package/src/deploy/index.ts +1 -0
  475. package/src/deploy/services.ts +1 -0
  476. package/src/deploy/types.ts +26 -1
  477. package/src/events/definitions.ts +14 -0
  478. package/src/events/execution.ts +9 -2
  479. package/src/events/index.ts +8 -0
  480. package/src/events/outbox-dispatcher.ts +12 -2
  481. package/src/events/scope.ts +3 -0
  482. package/src/events/selectors/builder.ts +49 -0
  483. package/src/events/selectors/index.ts +5 -0
  484. package/src/events/selectors/predicate.ts +2 -0
  485. package/src/events/selectors/types.ts +30 -1
  486. package/src/events/types/artifacts.ts +7 -1
  487. package/src/events/types/connectors.ts +36 -0
  488. package/src/events/types/index.ts +7 -0
  489. package/src/execution/authorization.ts +45 -0
  490. package/src/execution/durable.ts +2 -0
  491. package/src/execution/scopes.ts +24 -0
  492. package/src/execution/script.ts +27 -0
  493. package/src/execution/types.ts +7 -1
  494. package/src/http/api-routes.ts +26 -1
  495. package/src/index.ts +21 -2
  496. package/src/lineage/executors.ts +3 -1
  497. package/src/materialization/event-envelopes.ts +10 -5
  498. package/src/materialization/events.ts +2 -0
  499. package/src/materialization/model.ts +6 -0
  500. package/src/materializer/README.md +10 -0
  501. package/src/materializer/projections/replace.ts +42 -1
  502. package/src/materializer/projections/replacement-plan.ts +44 -4
  503. package/src/materializer/shared/normalize.ts +4 -0
  504. package/src/models/language-model.ts +6 -0
  505. package/src/models/tools.ts +2 -0
  506. package/src/projections/builders.ts +20 -0
  507. package/src/projections/index.ts +1 -0
  508. package/src/projections/registry.ts +1 -0
  509. package/src/projections/revision.ts +2 -0
  510. package/src/projections/types.ts +11 -0
  511. package/src/projections/validation.ts +6 -0
  512. package/src/queues/in-memory.ts +5 -0
  513. package/src/queues/index.ts +3 -1
  514. package/src/queues/types.ts +45 -14
  515. package/src/runtime/host.ts +112 -4
  516. package/src/runtime/internal.ts +1 -0
  517. package/src/runtime/resolve-definitions.ts +4 -1
  518. package/src/runtime/script.ts +62 -0
  519. package/src/runtime/sixb.ts +3 -3
  520. package/src/schedules/builders.ts +4 -1
  521. package/src/schedules/runtime.ts +3 -0
  522. package/src/schedules/validation.ts +20 -2
  523. package/src/storage/agents/errors.ts +1 -0
  524. package/src/storage/agents/in-memory.ts +229 -1
  525. package/src/storage/agents/index.ts +16 -0
  526. package/src/storage/agents/provider.ts +284 -2
  527. package/src/storage/agents/types.ts +168 -1
  528. package/src/storage/artifacts/in-memory.ts +32 -1
  529. package/src/storage/artifacts/index.ts +2 -0
  530. package/src/storage/artifacts/record.ts +25 -2
  531. package/src/storage/artifacts/types.ts +37 -0
  532. package/src/storage/executions/provider.ts +22 -2
  533. package/src/storage/executions/types.ts +2 -0
  534. package/src/storage/executions/validation.ts +27 -0
  535. package/src/storage/index.ts +18 -0
  536. package/src/storage/internal.ts +1 -0
  537. package/src/storage/ontology/in-memory/replacement-plans.ts +22 -0
  538. package/src/storage/ontology/replacement-plans.ts +6 -0
  539. package/src/storage/operation-scope.ts +1 -0
  540. package/src/testing/agent-execution.ts +45 -2
  541. package/src/testing/agent-inbox-storage-contract.ts +815 -0
  542. package/src/testing/agent-storage-contract.ts +103 -0
  543. package/src/testing/artifact-storage-contract.ts +72 -4
  544. package/src/testing/execution-storage-contract.ts +31 -0
  545. package/src/testing/index.ts +5 -0
  546. package/src/testing/materializer-storage-contract.ts +139 -1
  547. package/src/testing/queues-contract.ts +22 -0
  548. package/src/webhooks/connections.ts +9 -50
  549. package/src/webhooks/index.ts +0 -2
  550. package/src/webhooks/types.ts +2 -13
  551. package/src/workers/queued-run-dispatch.ts +8 -1
  552. package/dist/chunk-48c1z8nj.js.map +0 -10
  553. package/dist/chunk-58geavnf.js +0 -29
  554. package/dist/chunk-58geavnf.js.map +0 -10
  555. package/dist/chunk-7z5rkf0m.js.map +0 -13
  556. package/dist/chunk-9nsjjd44.js.map +0 -12
  557. package/dist/chunk-b9qfh2ya.js.map +0 -11
  558. package/dist/chunk-eptrvnby.js.map +0 -12
  559. package/dist/chunk-f6ahf5gf.js.map +0 -13
  560. package/dist/chunk-m2jerfef.js +0 -474
  561. package/dist/chunk-m2jerfef.js.map +0 -11
  562. package/dist/chunk-n4zzaf6q.js.map +0 -10
  563. package/dist/chunk-qds484t8.js.map +0 -18
  564. package/dist/chunk-smnt672s.js.map +0 -10
  565. package/dist/chunk-vzkxqf8h.js.map +0 -23
  566. package/dist/chunk-w9s23r24.js.map +0 -30
  567. package/dist/chunk-wa05txmk.js.map +0 -11
  568. package/dist/chunk-yv8hv4wq.js.map +0 -10
  569. package/dist/chunk-z0t4p2sk.js.map +0 -47
  570. /package/dist/{chunk-tqa68kj7.js.map → chunk-0hkdtwqk.js.map} +0 -0
  571. /package/dist/{chunk-s5n9617r.js.map → chunk-0mvjpgvm.js.map} +0 -0
  572. /package/dist/{chunk-k66rp2hr.js.map → chunk-1yh6jgtz.js.map} +0 -0
  573. /package/dist/{chunk-26qet7wh.js.map → chunk-5t9gm5tt.js.map} +0 -0
  574. /package/dist/{chunk-e0hnbb1m.js.map → chunk-61zptves.js.map} +0 -0
  575. /package/dist/{chunk-hkaa807g.js.map → chunk-68hm50qh.js.map} +0 -0
  576. /package/dist/{chunk-fe6r7yhg.js.map → chunk-92wrka15.js.map} +0 -0
  577. /package/dist/{chunk-m7b9q5dk.js.map → chunk-aw1z0gre.js.map} +0 -0
  578. /package/dist/{chunk-kv0kvknv.js.map → chunk-fzae1jpq.js.map} +0 -0
  579. /package/dist/{chunk-6gtxshcc.js.map → chunk-k29n4176.js.map} +0 -0
  580. /package/dist/{chunk-sysnvjce.js.map → chunk-naxjka9v.js.map} +0 -0
  581. /package/dist/{chunk-qafng88v.js.map → chunk-pqvvqc65.js.map} +0 -0
  582. /package/dist/{chunk-8p7bze4c.js.map → chunk-s1mqyqmm.js.map} +0 -0
  583. /package/dist/{chunk-p351afzm.js.map → chunk-s5pj68fa.js.map} +0 -0
  584. /package/dist/{chunk-855w9nvw.js.map → chunk-vehcr9eb.js.map} +0 -0
  585. /package/dist/{chunk-n68vz95m.js.map → chunk-wqe9shx2.js.map} +0 -0
  586. /package/dist/{chunk-0k3r5kb3.js.map → chunk-xcrnrpfh.js.map} +0 -0
  587. /package/dist/{chunk-38yvdqzd.js.map → chunk-zxhym8tr.js.map} +0 -0
@@ -1,16 +1,27 @@
1
- import { captureSixbFailure, createSixbError } from "../errors/internal"
1
+ import { type Principal, principalsEqual } from "../auth"
2
+ import { captureSixbFailure, createSixbError, isSixbError } from "../errors/internal"
2
3
  import { bindDurableAgentExecution } from "../execution/agent"
4
+ import { createPrincipalRuntimeAuthorization } from "../execution/authorization"
5
+ import type { ExecutionContext } from "../execution/types"
6
+ import { isBoundSixb, type Sixb } from "../runtime/sixb"
3
7
  import {
4
8
  AGENT_RUN_FAILURE_CODES,
9
+ type AgentInboxItemRecord,
5
10
  type AgentRunRecord,
6
11
  AgentStorageError,
7
12
  type SubagentRunRecord,
8
13
  } from "../storage/agents"
9
14
  import { resumeDecidedAgentTurn } from "./approval-continuation"
10
15
  import { isAwaitingApprovalRun } from "./approvals"
16
+ import {
17
+ type AgentExecutionAuthorization,
18
+ resolveInheritedAgentExecutionAuthorization,
19
+ } from "./authority"
11
20
  import { requestAgentRunCancel } from "./cancel"
21
+ import { startQueuedAgentTurn } from "./queued-turn"
12
22
  import { resolveAgentRunExecutionScope } from "./run-scope"
13
23
  import type { AgentRunSessionHost } from "./run-session"
24
+ import { turnAnsweredEveryMessage } from "./turn-answered"
14
25
 
15
26
  // What follows a turn's end, wherever its runner was: the worker's session does it, and so does
16
27
  // the API's for a runner that reaches it over HTTP. Best effort: a failure is logged, and a repair
@@ -29,7 +40,253 @@ export async function afterAgentRunFinished(
29
40
  ? "has finished"
30
41
  : `was ${run.status}`
31
42
  await stopActiveChildren(host, run.id, `The parent Agent run ${ended}.`)
32
- if (!isAwaitingApprovalRun(run)) return
43
+
44
+ // One read for both: a steer the turn never wrote waits again, whatever ended it, and what it
45
+ // leaves behind is what a turn that answered may start. Most turns end with an empty inbox, and
46
+ // then read nothing else and write nothing.
47
+ const inbox = await readInbox(host, run)
48
+ if (inbox?.claimed) await releaseInboxClaims(host, run.id)
49
+ if (isAwaitingApprovalRun(run)) {
50
+ await resumeDecidedTurn(host, run)
51
+ return
52
+ }
53
+ if (!inbox || inbox.waiting.length === 0) return
54
+ await startNextQueuedMessage(host, run, inbox.waiting)
55
+ }
56
+
57
+ const INBOX_REPAIR_PAGE_SIZE = 100
58
+ /** How long a turn's own end has to start what waits, before the repair pass looks at it. */
59
+ const INBOX_REPAIR_GRACE_MS = 30_000
60
+
61
+ /**
62
+ * The repair pass for thread inboxes: what a turn's end did not start, because its process stopped
63
+ * first, a read failed, or an AI limit refused it, starts by the same rules the end applies, each
64
+ * as a turn of its sender's own. Claims a finished turn left behind go back first. A message those
65
+ * rules keep waiting (one queued behind a turn that stopped, or whose sender's credential ended)
66
+ * is left alone.
67
+ */
68
+ export async function repairAgentInboxes(
69
+ host: AgentRunSessionHost,
70
+ input: { readonly now?: Date } = {}
71
+ ): Promise<void> {
72
+ // A storage without an inbox holds nothing to start.
73
+ if (typeof host.storage.agents.inbox?.listWaitingThreads !== "function") return
74
+ const createdBefore = new Date((input.now ?? new Date()).getTime() - INBOX_REPAIR_GRACE_MS)
75
+ let afterThreadId: string | undefined
76
+ for (;;) {
77
+ const threadIds = await host.storage.agents.inbox.listWaitingThreads({
78
+ projectId: host.projectId,
79
+ createdBefore,
80
+ limit: INBOX_REPAIR_PAGE_SIZE,
81
+ ...(afterThreadId === undefined ? {} : { afterThreadId }),
82
+ })
83
+ for (const threadId of threadIds) {
84
+ try {
85
+ await repairThreadInbox(host, threadId)
86
+ } catch (error) {
87
+ console.error(
88
+ `[Sixb] Could not repair the inbox of Agent thread '${threadId}'; retrying.`,
89
+ error
90
+ )
91
+ }
92
+ }
93
+ afterThreadId = threadIds.at(-1)
94
+ if (afterThreadId === undefined || threadIds.length < INBOX_REPAIR_PAGE_SIZE) return
95
+ }
96
+ }
97
+
98
+ async function repairThreadInbox(host: AgentRunSessionHost, threadId: string): Promise<void> {
99
+ const { runs } = await host.storage.agents.runs.list({
100
+ projectId: host.projectId,
101
+ threadId,
102
+ kinds: ["conversation"],
103
+ order: "desc",
104
+ limit: 1,
105
+ })
106
+ const last = runs[0]
107
+ // A turn holds the thread again, or never ran in it: its end, or its first turn, starts these.
108
+ if (!last || last.status === "queued" || last.status === "running") return
109
+
110
+ const items = await host.storage.agents.inbox.list({ projectId: host.projectId, threadId })
111
+ const holders = new Set(items.flatMap((item) => (item.claimedBy ? [item.claimedBy.runId] : [])))
112
+ for (const runId of holders) await releaseInboxClaims(host, runId)
113
+ // The approval repair resumes a paused turn, and that turn's end starts what waits.
114
+ if (isAwaitingApprovalRun(last)) return
115
+ await startNextQueuedMessage(host, last, items)
116
+ }
117
+
118
+ /**
119
+ * The thread's inbox as a finished turn leaves it: what it still holds claimed, and what a turn may
120
+ * start once those are released. Null when it cannot be read, which the repair pass catches up on.
121
+ */
122
+ async function readInbox(
123
+ host: AgentRunSessionHost,
124
+ run: AgentRunRecord
125
+ ): Promise<{
126
+ readonly claimed: boolean
127
+ readonly waiting: readonly AgentInboxItemRecord[]
128
+ } | null> {
129
+ // A storage without an inbox holds nothing to read, release or start.
130
+ const inbox = host.storage.agents.inbox
131
+ if (typeof inbox?.list !== "function") return null
132
+ try {
133
+ const items = await inbox.list({
134
+ projectId: host.projectId,
135
+ threadId: run.threadId,
136
+ includeClaimed: true,
137
+ })
138
+ const claimed = items.some((item) => item.claimedBy?.runId === run.id)
139
+ return {
140
+ claimed,
141
+ waiting: items.filter(
142
+ (item) => item.claimedBy === undefined || item.claimedBy.runId === run.id
143
+ ),
144
+ }
145
+ } catch (error) {
146
+ console.error(
147
+ `[Sixb] Could not read the inbox of Agent run '${run.id}'; repair retries it.`,
148
+ error
149
+ )
150
+ return null
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Start the next message queued for the thread: always one sent now, and a message queued for later
156
+ * only once the turn answered, so nothing runs after a turn that stopped or failed, or one that
157
+ * asked the requester a question. The turn's requester goes first, then each other author by their
158
+ * oldest message, each as a turn of their own.
159
+ */
160
+ async function startNextQueuedMessage(
161
+ host: AgentRunSessionHost,
162
+ run: AgentRunRecord,
163
+ waiting: readonly AgentInboxItemRecord[]
164
+ ): Promise<void> {
165
+ try {
166
+ const execution = await host.storage.executions.getById({
167
+ projectId: host.projectId,
168
+ id: run.executionId,
169
+ })
170
+ const requester = execution?.requestedBy
171
+ if (!requester) return
172
+
173
+ const onlyImmediate = !(await turnAnsweredEveryMessage(host.storage.agents, run))
174
+ const startable = waiting.filter((item) => !onlyImmediate || item.immediate)
175
+
176
+ for (const next of nextOfEachAuthor(startable, requester)) {
177
+ // One whose sender can no longer run turns waits for a request of theirs.
178
+ const sender = await boundSender(host, next)
179
+ if (!sender) continue
180
+
181
+ const started = await startQueuedAgentTurn(sender, run.id, { onlyImmediate })
182
+ if (started.status === "started") return
183
+ }
184
+ } catch (error) {
185
+ // Its turn is recorded: the message waits in the thread, and the repair pass catches up.
186
+ console.error(
187
+ `[Sixb] Could not start what was queued after Agent run '${run.id}'; it waits in the thread.`,
188
+ error
189
+ )
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Each author's next message, in the order a turn's end tries them: the requester's first, then
195
+ * the others by their oldest. Within an author, the one their turn takes (see `takeNextQueued`):
196
+ * sent now, then a steer, then the oldest.
197
+ */
198
+ function nextOfEachAuthor(
199
+ items: readonly AgentInboxItemRecord[],
200
+ requester: Principal
201
+ ): readonly AgentInboxItemRecord[] {
202
+ const byAuthor: AgentInboxItemRecord[][] = []
203
+ for (const item of [...items].sort((left, right) => left.seq - right.seq)) {
204
+ const own = byAuthor.find((each) =>
205
+ principalsEqual(each[0]!.authorPrincipal, item.authorPrincipal)
206
+ )
207
+ if (own) own.push(item)
208
+ else byAuthor.push([item])
209
+ }
210
+
211
+ const order = (each: readonly AgentInboxItemRecord[]) =>
212
+ principalsEqual(each[0]!.authorPrincipal, requester) ? 0 : 1
213
+ return byAuthor
214
+ .sort((left, right) => order(left) - order(right))
215
+ .map((own) => [...own].sort((left, right) => priority(left) - priority(right))[0]!)
216
+ }
217
+
218
+ function priority(item: AgentInboxItemRecord): number {
219
+ if (item.immediate) return 0
220
+ return item.mode === "steer" ? 1 : 2
221
+ }
222
+
223
+ /**
224
+ * The SDK of the request that sent the message, with its sender's grants as they are now, which the
225
+ * turn that starts it runs as a child of: what that request would have started itself. Null when
226
+ * the message names no request, or the credential it came with has ended or was revoked.
227
+ */
228
+ async function boundSender(
229
+ host: AgentRunSessionHost,
230
+ item: AgentInboxItemRecord
231
+ ): Promise<Sixb | null> {
232
+ if (item.executionId === undefined) return null
233
+ const request = await host.storage.executions.getById({
234
+ projectId: host.projectId,
235
+ id: item.executionId,
236
+ })
237
+ const ref = request?.authorizationRef
238
+ if (request?.executor.type !== "request" || ref?.type !== "principal") return null
239
+
240
+ let authorization: AgentExecutionAuthorization
241
+ try {
242
+ authorization = await resolveInheritedAgentExecutionAuthorization({
243
+ auth: host.storage.auth,
244
+ projectId: host.projectId,
245
+ authorizationRef: ref,
246
+ security: host.security,
247
+ })
248
+ } catch (error) {
249
+ if (isSixbError(error) && error.code === "agent.execution_failed") return null
250
+ throw error
251
+ }
252
+ if (authorization.type !== "principal") return null
253
+
254
+ const execution: ExecutionContext = Object.freeze({
255
+ id: request.id,
256
+ projectId: request.projectId,
257
+ ...(request.requestedBy === undefined ? {} : { requestedBy: request.requestedBy }),
258
+ executor: request.executor,
259
+ source: request.source,
260
+ correlationId: request.correlationId,
261
+ })
262
+ const sixb = host.sdk.withScope({
263
+ execution,
264
+ authorization: createPrincipalRuntimeAuthorization({
265
+ execution,
266
+ context: authorization.context,
267
+ ...(ref.credential === undefined ? {} : { credential: ref.credential }),
268
+ }),
269
+ })
270
+ if (!isBoundSixb(sixb)) {
271
+ throw new Error("[Sixb] Agent session host returned an invalid bound SDK.")
272
+ }
273
+ return sixb
274
+ }
275
+
276
+ /** Whatever a run stopped writing goes back to the thread's inbox, to be read again. */
277
+ async function releaseInboxClaims(host: AgentRunSessionHost, runId: string): Promise<void> {
278
+ try {
279
+ await host.storage.agents.inbox.releaseClaimed({ projectId: host.projectId, runId })
280
+ } catch (error) {
281
+ console.error(
282
+ `[Sixb] Could not release the inbox claims of Agent run '${runId}'; repair retries.`,
283
+ error
284
+ )
285
+ }
286
+ }
287
+
288
+ /** Resume a turn paused on calls already decided, as its requester. */
289
+ async function resumeDecidedTurn(host: AgentRunSessionHost, run: AgentRunRecord): Promise<void> {
33
290
  try {
34
291
  // As its requester, with the grants they have now: what a decision would have done.
35
292
  const scope = await resolveAgentRunExecutionScope(
@@ -1,4 +1,3 @@
1
- import { BOARD_PREVIEW_JOB } from "../artifacts/canvas-display"
2
1
  import { ArtifactRequestError } from "../artifacts/errors"
3
2
  import { announceArtifactUpdates } from "../artifacts/events"
4
3
  import {
@@ -12,19 +11,12 @@ import type { ArtifactKind } from "../artifacts/kinds"
12
11
  import { appendArtifactLive, changedBoards } from "../artifacts/live/presence"
13
12
  import { firstArtifactDocument } from "../artifacts/live/state"
14
13
  import { withMergedWrite } from "../artifacts/publish/merge"
15
- import {
16
- type BoardPreviewInput,
17
- missingBoardPreviews,
18
- type RefusedBoardPreview,
19
- storeBoardPreviews,
20
- } from "../artifacts/publish/previews"
21
14
  import {
22
15
  artifactVersionWarnings,
23
16
  type PublishedArtifact,
24
17
  prepareArtifactVersion,
25
18
  storeArtifactVersion,
26
19
  } from "../artifacts/publish/publish"
27
- import type { ArtifactThemeMode } from "../artifacts/theme"
28
20
  import { type Principal, principalsEqual } from "../auth/types"
29
21
  import type { FileRef } from "../blob-storage"
30
22
  import type { Broker } from "../broker"
@@ -78,51 +70,12 @@ export interface AgentRunArtifacts {
78
70
  * the turn's last write left it at.
79
71
  */
80
72
  turnWrites(): Promise<readonly ArtifactTurnWriteRecord[]>
81
- /**
82
- * Keeps the pictures the run took of the boards of a version it wrote, as their previews: its
83
- * requester authored the content, and the pictures show what they can see. Refuses any other
84
- * version, and one written again since. Each picture stands alone: those not kept are
85
- * returned, with why. Creating the version since leaves its content, and its pictures.
86
- */
87
- storePreviews(input: AgentRunBoardPreviews): Promise<readonly RefusedBoardPreview[]>
88
- /**
89
- * The boards of a version the run wrote still without a picture, and the modes each misses: a
90
- * board it kept as it was keeps the pictures it had. Refuses any other version, and one written
91
- * again since.
92
- */
93
- missingPreviews(input: AgentRunVersion): Promise<readonly AgentRunMissingPreview[]>
94
- }
95
-
96
- /** A version of an artifact, as one of the run's writes left its content. */
97
- export interface AgentRunVersion {
98
- readonly artifactId: string
99
- readonly version: number
100
- /** The version's `updatedAt` after the write: a content written again since has another. */
101
- readonly updatedAt: Date
102
- }
103
-
104
- /** The pictures a run took of a version's boards. */
105
- export interface AgentRunBoardPreviews extends AgentRunVersion {
106
- readonly previews: readonly BoardPreviewInput[]
107
- }
108
-
109
- /** A board of a version without a picture in these modes. */
110
- export interface AgentRunMissingPreview {
111
- readonly board: string
112
- readonly themes: readonly ArtifactThemeMode[]
113
73
  }
114
74
 
115
75
  /** A version a run publishes: of a new artifact of `kind`, or of the artifact `artifactId`. */
116
76
  export type AgentRunArtifactPublish = {
117
77
  readonly title: string
118
78
  readonly files: readonly ArtifactFile[]
119
- /**
120
- * The publisher renders the version's boards itself, as the publish tool's layout check does,
121
- * and hands their pictures over with `storePreviews`. The worker then renders only what is still
122
- * missing, after a grace period, and without the version's query answers, which the check read.
123
- * Any other publish, such as a command in the sandbox, has its queries answered at once.
124
- */
125
- readonly rendersPreviews?: boolean
126
79
  } & (
127
80
  | { readonly kind: ArtifactKind }
128
81
  | {
@@ -299,14 +252,9 @@ export function agentRunArtifacts(
299
252
  if ("artifactId" in input) await announceArtifactUpdates(host.domainEvents, [stored.version])
300
253
  if (kind === "canvas") await announceAgentBoards(host, turnRunId, before, stored.version)
301
254
 
302
- // A publisher that renders its own previews reads the query answers in its layout check, and
303
- // normally pictures every board: answering them here too would run each query twice. So its
304
- // job waits, carries none, and a board that reads one and that the check missed keeps its
305
- // outline. Every other publish has its answers read now, as its requester.
306
- await artifactPreviewRequester(reader)(
307
- stored.version,
308
- input.rendersPreviews ? { delayMs: BOARD_PREVIEW_JOB.graceMs, withoutAnswers: true } : {}
309
- )
255
+ // The render worker pictures what the boards miss, with their queries answered now, as the
256
+ // requester.
257
+ await artifactPreviewRequester(reader)(stored.version)
310
258
 
311
259
  return {
312
260
  ...stored,
@@ -318,44 +266,6 @@ export function agentRunArtifacts(
318
266
  async turnWrites() {
319
267
  return requireArtifacts(storage).listTurnWrites({ projectId, turnRunId })
320
268
  },
321
-
322
- async storePreviews({ previews, ...at }) {
323
- const [{ blobs }, version] = await Promise.all([sdk(), publishedVersion(at)])
324
- return storeBoardPreviews(
325
- { storage: requireArtifacts(storage), blobStorage: blobs },
326
- version,
327
- previews
328
- )
329
- },
330
-
331
- async missingPreviews(at) {
332
- const missing = await missingBoardPreviews(
333
- requireArtifacts(storage),
334
- await publishedVersion(at)
335
- )
336
- return missing.map(({ board, themes }) => ({ board: board.id, themes }))
337
- },
338
- }
339
-
340
- /**
341
- * Only the run that wrote a version's content pictures its boards with its author's rights, and
342
- * only while the version holds that content: the pictures are kept under its boards' render keys.
343
- * A change that leaves the content, such as creating the version, changes nothing here.
344
- */
345
- async function publishedVersion(at: AgentRunVersion): Promise<ArtifactVersionRecord> {
346
- const version = await requireArtifacts(storage).getVersion({
347
- projectId,
348
- artifactId: at.artifactId,
349
- version: at.version,
350
- })
351
- const written = at.updatedAt.getTime()
352
- if (!version || version.origin?.runId !== run.id || version.updatedAt.getTime() !== written) {
353
- throw new ArtifactRequestError(
354
- "not_allowed",
355
- `[Sixb] Version ${at.version} of artifact '${at.artifactId}' does not hold what this run wrote at ${at.updatedAt.toISOString()}.`
356
- )
357
- }
358
- return version
359
269
  }
360
270
  }
361
271
 
@@ -6,7 +6,12 @@ import type {
6
6
  AgentRunRecord,
7
7
  ConversationAgentRunRecord,
8
8
  } from "../storage/agents"
9
- import type { AgentCompactionFailureCode, AgentRunStreamEvent, ModelUiChunk } from "./streams"
9
+ import type {
10
+ AgentCompactionFailureCode,
11
+ AgentInboxReadMessage,
12
+ AgentRunStreamEvent,
13
+ ModelUiChunk,
14
+ } from "./streams"
10
15
  import {
11
16
  agentRunFinishedEvent,
12
17
  agentRunStreamDefinition,
@@ -45,6 +50,11 @@ export interface StreamSink {
45
50
  readonly chunkIndex: number
46
51
  readonly chunk: ModelUiChunk
47
52
  }): Promise<void>
53
+ /** Messages a turn read from its thread's inbox, in the stream where it read them. */
54
+ publishInboxRead(input: {
55
+ readonly run: ConversationAgentRunRecord
56
+ readonly messages: readonly AgentInboxReadMessage[]
57
+ }): Promise<void>
48
58
  publishMessageFinalized(input: {
49
59
  readonly run: ConversationAgentRunRecord
50
60
  readonly messageId: string
@@ -59,6 +69,7 @@ export const NOOP_STREAM_SINK: StreamSink = {
59
69
  async publishCompactionCompleted() {},
60
70
  async publishCompactionFailed() {},
61
71
  async publishUiChunk() {},
72
+ async publishInboxRead() {},
62
73
  async publishMessageFinalized() {},
63
74
  async publishRunFinished() {},
64
75
  }
@@ -90,6 +101,8 @@ export function isolateStreamSink(sink: StreamSink): StreamSink {
90
101
  ),
91
102
  publishUiChunk: (input) =>
92
103
  isolateStreamSinkCall(input.run.id, "ui chunk", () => sink.publishUiChunk(input)),
104
+ publishInboxRead: (input) =>
105
+ isolateStreamSinkCall(input.run.id, "inbox read", () => sink.publishInboxRead(input)),
93
106
  publishMessageFinalized: (input) =>
94
107
  isolateStreamSinkCall(input.run.id, "message finalized", () =>
95
108
  sink.publishMessageFinalized(input)
@@ -114,6 +127,7 @@ export function withAgentActivityStream(sink: StreamSink, broker: Broker): Strea
114
127
  publishCompactionCompleted: (input) => sink.publishCompactionCompleted(input),
115
128
  publishCompactionFailed: (input) => sink.publishCompactionFailed(input),
116
129
  publishUiChunk: (input) => sink.publishUiChunk(input),
130
+ publishInboxRead: (input) => sink.publishInboxRead(input),
117
131
  publishMessageFinalized: (input) => sink.publishMessageFinalized(input),
118
132
  publishRunFinished: (run) =>
119
133
  publishLifecycle([
@@ -205,6 +219,17 @@ class BrokerStreamSink implements StreamSink {
205
219
  )
206
220
  }
207
221
 
222
+ async publishInboxRead(input: {
223
+ readonly run: ConversationAgentRunRecord
224
+ readonly messages: readonly AgentInboxReadMessage[]
225
+ }): Promise<void> {
226
+ await this.publish({
227
+ ...agentRunStreamEventBase(input.run),
228
+ type: "agent.inbox.read",
229
+ messages: input.messages,
230
+ })
231
+ }
232
+
208
233
  async publishMessageFinalized(input: {
209
234
  readonly run: ConversationAgentRunRecord
210
235
  readonly messageId: string
@@ -1,3 +1,4 @@
1
+ import type { Broker } from "../broker"
1
2
  import { createInheritedAgentExecutionRecord } from "../execution/agent"
2
3
  import { ensureExecutionRecord } from "../execution/durable"
3
4
  import type { Storage } from "../storage"
@@ -13,6 +14,7 @@ import type {
13
14
  SubagentRunRecord,
14
15
  } from "../storage/agents"
15
16
  import { type AgentChildApprovalAwaiting, listChildApprovalsAwaiting } from "./approvals"
17
+ import { cancelQueuedRun, requestAgentRunCancel } from "./cancel"
16
18
  import { createSubagentExecutionId, createSubagentRunId, createSubagentThreadId } from "./ids"
17
19
  import { AgentRunRefusedError, fenced } from "./run-fence"
18
20
  import { listSubagentThreadRuns } from "./subagent-runs"
@@ -54,6 +56,12 @@ export interface AgentRunChildren {
54
56
  * so the turn can continue the child again. Refused once the turn no longer owns its run.
55
57
  */
56
58
  clearAttempt(input: { readonly threadId: string; readonly runId: string }): Promise<void>
59
+ /**
60
+ * Stop one of this turn's children: a queued one ends at once, a running one hears the cancel
61
+ * and ends at its next step. One that already ended is returned as it is. Refused for any run
62
+ * but this turn's own children.
63
+ */
64
+ cancel(runId: string): Promise<SubagentRunRecord>
57
65
  }
58
66
 
59
67
  /**
@@ -136,6 +144,8 @@ export function agentRunThreads(
136
144
  export interface AgentRunChildrenHost {
137
145
  readonly projectId: string
138
146
  readonly storage: Storage & { readonly agents: AgentStorage }
147
+ /** Where a cancel reaches the child's runner at once. */
148
+ readonly broker: Broker
139
149
  /** How many children one turn may have queued or running at once. */
140
150
  readonly maxActiveChildren?: number
141
151
  }
@@ -231,6 +241,24 @@ export function agentRunChildren(
231
241
  })
232
242
  )
233
243
  },
244
+ async cancel(runId) {
245
+ const child = await get(runId)
246
+ if (child?.kind !== "subagent" || child.parentRunId !== run.id) {
247
+ throw new AgentRunRefusedError(
248
+ `[Sixb] Agent run '${run.id}' stops only its own children, not '${runId}'.`
249
+ )
250
+ }
251
+ if (child.status === "queued") {
252
+ const queued = await cancelQueuedRun(host, agents, child)
253
+ if (queued.cancelled) return requireSubagent(queued.run)
254
+ // A worker started it meanwhile: it is stopped as a running one.
255
+ if (queued.run?.status !== "running") return requireSubagent(queued.run ?? child)
256
+ } else if (child.status !== "running") {
257
+ return child
258
+ }
259
+ await requestAgentRunCancel({ projectId, broker: host.broker, storage: agents }, child.id)
260
+ return child
261
+ },
234
262
  async clearAttempt({ threadId, runId }) {
235
263
  // Only an attempt that ended, of a child of this conversation, in that child's thread.
236
264
  const attempt = await get(runId)
@@ -256,6 +284,11 @@ export function agentRunChildren(
256
284
  }
257
285
  }
258
286
 
287
+ function requireSubagent(run: AgentRunRecord): SubagentRunRecord {
288
+ if (run.kind !== "subagent") throw new Error(`[Sixb] Agent run '${run.id}' changed kind.`)
289
+ return run
290
+ }
291
+
259
292
  function assertDelegable(
260
293
  run: AgentRunRecord,
261
294
  child: AgentChildDraft,
@@ -124,6 +124,13 @@ export function createHttpAgentRunSession<TRun extends AgentRunRecord>(
124
124
  holdsRun: () => call("heldCalls.holdsRun"),
125
125
  pausesAfterStep: () => call("heldCalls.pausesAfterStep"),
126
126
  },
127
+ inbox: {
128
+ // What streamed before the step reaches the server first: the read lands after it.
129
+ takeSteers: async (input) => {
130
+ await sink.flush()
131
+ return call("inbox.takeSteers", [input])
132
+ },
133
+ },
127
134
  children: {
128
135
  get: (runId) => call("children.get", [runId]),
129
136
  getMany: (runIds) => call("children.getMany", [runIds]),
@@ -135,6 +142,7 @@ export function createHttpAgentRunSession<TRun extends AgentRunRecord>(
135
142
  activeCount: () => call("children.activeCount"),
136
143
  spawn: (draft) => call("children.spawn", [draft]),
137
144
  clearAttempt: (attempt) => call("children.clearAttempt", [attempt]),
145
+ cancel: (runId) => call("children.cancel", [runId]),
138
146
  },
139
147
  async renewLease(leaseExpiresAt) {
140
148
  try {
@@ -179,8 +187,6 @@ export function createHttpAgentRunSession<TRun extends AgentRunRecord>(
179
187
  updatable: (artifactId) => call("artifacts.updatable", [artifactId]),
180
188
  publish: (publish) => call("artifacts.publish", [publish]),
181
189
  turnWrites: () => call("artifacts.turnWrites", []),
182
- storePreviews: (previews) => call("artifacts.storePreviews", [previews]),
183
- missingPreviews: (version) => call("artifacts.missingPreviews", [version]),
184
190
  },
185
191
  files: {
186
192
  async put(file) {
@@ -391,6 +397,8 @@ function batchedEvents(
391
397
  publishCompactionCompleted: enqueue("publishCompactionCompleted"),
392
398
  publishCompactionFailed: enqueue("publishCompactionFailed"),
393
399
  publishUiChunk: enqueue("publishUiChunk"),
400
+ // The server says what a step read, as it claims it (see inbox.takeSteers).
401
+ publishInboxRead: async () => {},
394
402
  publishMessageFinalized: enqueue("publishMessageFinalized"),
395
403
  async publishRunFinished(record) {
396
404
  await enqueue("publishRunFinished")(record)
@@ -71,6 +71,8 @@ const OPERATIONS: Readonly<Record<string, Operation>> = {
71
71
  renewLease: (session, [leaseExpiresAt]) => renew(session, capLease(leaseExpiresAt as string)),
72
72
  "heldCalls.holdsRun": (session) => session.heldCalls.holdsRun(),
73
73
  "heldCalls.pausesAfterStep": (session) => session.heldCalls.pausesAfterStep(),
74
+ "inbox.takeSteers": (session, [input]) =>
75
+ session.inbox.takeSteers(input as Parameters<AgentRunSession["inbox"]["takeSteers"]>[0]),
74
76
  "children.get": (session, [runId]) => session.children.get(runId as string),
75
77
  "children.getMany": (session, [runIds]) => session.children.getMany(runIds as string[]),
76
78
  "children.inConversation": (session, [input]) =>
@@ -89,6 +91,7 @@ const OPERATIONS: Readonly<Record<string, Operation>> = {
89
91
  session.children.clearAttempt(
90
92
  input as Parameters<AgentRunSession["children"]["clearAttempt"]>[0]
91
93
  ),
94
+ "children.cancel": (session, [runId]) => session.children.cancel(runId as string),
92
95
  "threads.message": (session, [messageId]) => session.threads.message(messageId as string),
93
96
  "threads.messages": (session, [input]) =>
94
97
  session.threads.messages(input as Parameters<AgentRunSession["threads"]["messages"]>[0]),
@@ -110,14 +113,6 @@ const OPERATIONS: Readonly<Record<string, Operation>> = {
110
113
  "artifacts.publish": (session, [input]) =>
111
114
  session.artifacts.publish(input as Parameters<AgentRunSession["artifacts"]["publish"]>[0]),
112
115
  "artifacts.turnWrites": (session) => session.artifacts.turnWrites(),
113
- "artifacts.storePreviews": (session, [input]) =>
114
- session.artifacts.storePreviews(
115
- input as Parameters<AgentRunSession["artifacts"]["storePreviews"]>[0]
116
- ),
117
- "artifacts.missingPreviews": (session, [input]) =>
118
- session.artifacts.missingPreviews(
119
- input as Parameters<AgentRunSession["artifacts"]["missingPreviews"]>[0]
120
- ),
121
116
  callTool: (session, [call, options], signal) =>
122
117
  session.callTool(call as Parameters<AgentRunSession["callTool"]>[0], {
123
118
  ...((options ?? {}) as { maxFileBytes?: number; contextDirectory?: string }),