@sixb/core 0.2.4 → 0.2.6

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 (763) hide show
  1. package/dist/actions/index.js +41 -40
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/validation.d.ts.map +1 -1
  4. package/dist/agents/errors.d.ts +1 -1
  5. package/dist/agents/errors.d.ts.map +1 -1
  6. package/dist/agents/execution.d.ts +50 -3
  7. package/dist/agents/execution.d.ts.map +1 -1
  8. package/dist/agents/ids.d.ts +2 -0
  9. package/dist/agents/ids.d.ts.map +1 -1
  10. package/dist/agents/index.d.ts +7 -5
  11. package/dist/agents/index.d.ts.map +1 -1
  12. package/dist/agents/index.js +74 -50
  13. package/dist/agents/index.js.map +1 -1
  14. package/dist/agents/model-routing.d.ts +5 -2
  15. package/dist/agents/model-routing.d.ts.map +1 -1
  16. package/dist/agents/queued-turn.d.ts +16 -0
  17. package/dist/agents/queued-turn.d.ts.map +1 -0
  18. package/dist/agents/request.d.ts +120 -1
  19. package/dist/agents/request.d.ts.map +1 -1
  20. package/dist/agents/run-after-finish.d.ts +10 -0
  21. package/dist/agents/run-after-finish.d.ts.map +1 -1
  22. package/dist/agents/run-artifacts.d.ts +0 -38
  23. package/dist/agents/run-artifacts.d.ts.map +1 -1
  24. package/dist/agents/run-events.d.ts +10 -1
  25. package/dist/agents/run-events.d.ts.map +1 -1
  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 +9 -1
  32. package/dist/agents/run-turn.d.ts.map +1 -1
  33. package/dist/agents/streams/index.d.ts +1 -1
  34. package/dist/agents/streams/index.d.ts.map +1 -1
  35. package/dist/agents/streams/index.js +1 -1
  36. package/dist/agents/streams/internal.d.ts +2 -1
  37. package/dist/agents/streams/internal.d.ts.map +1 -1
  38. package/dist/agents/streams/internal.js +22 -2
  39. package/dist/agents/streams/internal.js.map +1 -1
  40. package/dist/agents/streams/protocol.d.ts +53 -0
  41. package/dist/agents/streams/protocol.d.ts.map +1 -1
  42. package/dist/agents/streams/steps.d.ts +24 -0
  43. package/dist/agents/streams/steps.d.ts.map +1 -0
  44. package/dist/agents/thread-access.d.ts +44 -2
  45. package/dist/agents/thread-access.d.ts.map +1 -1
  46. package/dist/agents/turn-answered.d.ts +7 -0
  47. package/dist/agents/turn-answered.d.ts.map +1 -0
  48. package/dist/agents/validation.d.ts +1 -1
  49. package/dist/agents/validation.d.ts.map +1 -1
  50. package/dist/artifacts/canvas-display.d.ts +3 -5
  51. package/dist/artifacts/canvas-display.d.ts.map +1 -1
  52. package/dist/artifacts/comments.d.ts +14 -3
  53. package/dist/artifacts/comments.d.ts.map +1 -1
  54. package/dist/artifacts/document-fill.d.ts +18 -0
  55. package/dist/artifacts/document-fill.d.ts.map +1 -0
  56. package/dist/artifacts/errors.d.ts +1 -1
  57. package/dist/artifacts/errors.d.ts.map +1 -1
  58. package/dist/artifacts/events.d.ts +3 -2
  59. package/dist/artifacts/events.d.ts.map +1 -1
  60. package/dist/artifacts/execution.d.ts +40 -4
  61. package/dist/artifacts/execution.d.ts.map +1 -1
  62. package/dist/artifacts/frames/assets.d.ts +8 -1
  63. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  64. package/dist/artifacts/frames/document-data.d.ts +98 -0
  65. package/dist/artifacts/frames/document-data.d.ts.map +1 -0
  66. package/dist/artifacts/frames/entries.d.ts +12 -7
  67. package/dist/artifacts/frames/entries.d.ts.map +1 -1
  68. package/dist/artifacts/frames/index.d.ts +2 -1
  69. package/dist/artifacts/frames/index.d.ts.map +1 -1
  70. package/dist/artifacts/frames/index.js +22 -13
  71. package/dist/artifacts/frames/index.js.map +4 -4
  72. package/dist/artifacts/frames/kit.d.ts +15 -0
  73. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  74. package/dist/artifacts/frames/protocol.d.ts +12 -1
  75. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  76. package/dist/artifacts/frames/runtime.d.ts +24 -4
  77. package/dist/artifacts/frames/runtime.d.ts.map +1 -1
  78. package/dist/artifacts/index.d.ts +3 -1
  79. package/dist/artifacts/index.d.ts.map +1 -1
  80. package/dist/artifacts/index.js +9 -3
  81. package/dist/artifacts/index.js.map +3 -3
  82. package/dist/artifacts/live/blocks.d.ts +62 -0
  83. package/dist/artifacts/live/blocks.d.ts.map +1 -0
  84. package/dist/artifacts/live/board.d.ts +6 -0
  85. package/dist/artifacts/live/board.d.ts.map +1 -1
  86. package/dist/artifacts/live/document.d.ts +12 -0
  87. package/dist/artifacts/live/document.d.ts.map +1 -1
  88. package/dist/artifacts/live/index.d.ts +2 -0
  89. package/dist/artifacts/live/index.d.ts.map +1 -1
  90. package/dist/artifacts/live/index.js +148 -44
  91. package/dist/artifacts/live/index.js.map +3 -3
  92. package/dist/artifacts/live/page.d.ts +49 -0
  93. package/dist/artifacts/live/page.d.ts.map +1 -0
  94. package/dist/artifacts/live/protocol.d.ts +5 -0
  95. package/dist/artifacts/live/protocol.d.ts.map +1 -1
  96. package/dist/artifacts/live/server.d.ts +2 -2
  97. package/dist/artifacts/live/server.d.ts.map +1 -1
  98. package/dist/artifacts/live/server.js +29 -24
  99. package/dist/artifacts/live/server.js.map +1 -1
  100. package/dist/artifacts/live/state.d.ts +4 -1
  101. package/dist/artifacts/live/state.d.ts.map +1 -1
  102. package/dist/artifacts/outline.d.ts +16 -0
  103. package/dist/artifacts/outline.d.ts.map +1 -1
  104. package/dist/artifacts/paper.d.ts +22 -0
  105. package/dist/artifacts/paper.d.ts.map +1 -0
  106. package/dist/artifacts/pdf-job.d.ts +9 -0
  107. package/dist/artifacts/pdf-job.d.ts.map +1 -0
  108. package/dist/artifacts/publish/fields.d.ts +25 -0
  109. package/dist/artifacts/publish/fields.d.ts.map +1 -0
  110. package/dist/artifacts/publish/index.d.ts +2 -1
  111. package/dist/artifacts/publish/index.d.ts.map +1 -1
  112. package/dist/artifacts/publish/index.js +32 -23
  113. package/dist/artifacts/publish/index.js.map +1 -1
  114. package/dist/artifacts/publish/merge.d.ts +7 -6
  115. package/dist/artifacts/publish/merge.d.ts.map +1 -1
  116. package/dist/artifacts/publish/pdf.d.ts +28 -0
  117. package/dist/artifacts/publish/pdf.d.ts.map +1 -0
  118. package/dist/artifacts/publish/previews.d.ts +12 -20
  119. package/dist/artifacts/publish/previews.d.ts.map +1 -1
  120. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  121. package/dist/artifacts/publish/queries.d.ts +6 -1
  122. package/dist/artifacts/publish/queries.d.ts.map +1 -1
  123. package/dist/artifacts/publish/query-answers.d.ts +5 -2
  124. package/dist/artifacts/publish/query-answers.d.ts.map +1 -1
  125. package/dist/artifacts/publish/validate/document-html.d.ts +24 -0
  126. package/dist/artifacts/publish/validate/document-html.d.ts.map +1 -0
  127. package/dist/artifacts/publish/validate/document.d.ts +5 -3
  128. package/dist/artifacts/publish/validate/document.d.ts.map +1 -1
  129. package/dist/artifacts/queries.d.ts +16 -2
  130. package/dist/artifacts/queries.d.ts.map +1 -1
  131. package/dist/artifacts/run-query.d.ts.map +1 -1
  132. package/dist/auth/index.js +6 -6
  133. package/dist/authorization/event-visibility.d.ts.map +1 -1
  134. package/dist/authorization/index.js +2 -2
  135. package/dist/blob-storage/index.js +1 -1
  136. package/dist/bootstrap/index.js +50 -48
  137. package/dist/bootstrap/index.js.map +2 -2
  138. package/dist/calendar.d.ts +55 -0
  139. package/dist/calendar.d.ts.map +1 -0
  140. package/dist/calendar.js +19 -0
  141. package/dist/calendar.js.map +9 -0
  142. package/dist/{chunk-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
  143. package/dist/chunk-0pmpwn3g.js.map +10 -0
  144. package/dist/{chunk-0k3r5kb3.js → chunk-394zjzjs.js} +20 -10
  145. package/dist/{chunk-0k3r5kb3.js.map → chunk-394zjzjs.js.map} +5 -5
  146. package/dist/{chunk-stmxh0hv.js → chunk-3neam1y5.js} +2 -2
  147. package/dist/{chunk-zeykm8my.js → chunk-3qtk0070.js} +16 -42
  148. package/dist/chunk-3qtk0070.js.map +14 -0
  149. package/dist/{chunk-p8pgnq8d.js → chunk-425ydk65.js} +5 -5
  150. package/dist/{chunk-p351afzm.js → chunk-5sswe5ej.js} +2 -2
  151. package/dist/{chunk-a6fjkcne.js → chunk-60662fyv.js} +54 -28
  152. package/dist/{chunk-a6fjkcne.js.map → chunk-60662fyv.js.map} +7 -6
  153. package/dist/{chunk-e0hnbb1m.js → chunk-61zptves.js} +1 -1
  154. package/dist/chunk-6hfbz4d0.js +98 -0
  155. package/dist/chunk-6hfbz4d0.js.map +10 -0
  156. package/dist/{chunk-3zagkr6w.js → chunk-7mhbs9yy.js} +4 -4
  157. package/dist/{chunk-3zagkr6w.js.map → chunk-7mhbs9yy.js.map} +1 -1
  158. package/dist/{chunk-gxwy4c3s.js → chunk-7r9mqpva.js} +570 -104
  159. package/dist/chunk-7r9mqpva.js.map +47 -0
  160. package/dist/{chunk-3014rfjz.js → chunk-88xeh6zx.js} +28 -8
  161. package/dist/{chunk-3014rfjz.js.map → chunk-88xeh6zx.js.map} +4 -4
  162. package/dist/{chunk-9nsjjd44.js → chunk-8tv3qd65.js} +2 -1
  163. package/dist/chunk-8tv3qd65.js.map +12 -0
  164. package/dist/chunk-90nqenq8.js +386 -0
  165. package/dist/chunk-90nqenq8.js.map +14 -0
  166. package/dist/{chunk-fe6r7yhg.js → chunk-92wrka15.js} +1 -1
  167. package/dist/{chunk-w1wq7gfr.js → chunk-9c9yknwt.js} +464 -29
  168. package/dist/{chunk-w1wq7gfr.js.map → chunk-9c9yknwt.js.map} +7 -7
  169. package/dist/{chunk-q9nkpr8k.js → chunk-9tpmfh3n.js} +1 -1
  170. package/dist/chunk-9wr3yajk.js.map +2 -2
  171. package/dist/{chunk-rtm1jq00.js → chunk-ats8y3d9.js} +1202 -246
  172. package/dist/{chunk-rtm1jq00.js.map → chunk-ats8y3d9.js.map} +16 -14
  173. package/dist/{chunk-td26wjr5.js → chunk-bcz9dxtf.js} +17 -47
  174. package/dist/chunk-bcz9dxtf.js.map +12 -0
  175. package/dist/chunk-bqr703h4.js +1799 -0
  176. package/dist/chunk-bqr703h4.js.map +13 -0
  177. package/dist/{chunk-sysnvjce.js → chunk-brhp9d97.js} +2 -2
  178. package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
  179. package/dist/{chunk-rsxb14an.js → chunk-bs1sd0e0.js} +12 -8
  180. package/dist/chunk-bs1sd0e0.js.map +18 -0
  181. package/dist/{chunk-eptrvnby.js → chunk-c29729me.js} +42 -3
  182. package/dist/chunk-c29729me.js.map +12 -0
  183. package/dist/{chunk-855w9nvw.js → chunk-cg7cygfj.js} +1 -1
  184. package/dist/chunk-dq3t5sr3.js +114 -0
  185. package/dist/chunk-dq3t5sr3.js.map +11 -0
  186. package/dist/{chunk-t24yktqr.js → chunk-dvgc56n2.js} +20 -4
  187. package/dist/{chunk-t24yktqr.js.map → chunk-dvgc56n2.js.map} +5 -5
  188. package/dist/{chunk-r2psmn42.js → chunk-eg6xqef7.js} +1 -1
  189. package/dist/{chunk-7kpqntgw.js → chunk-f05994as.js} +1 -1
  190. package/dist/{chunk-msyevpp3.js → chunk-fmgf9h5e.js} +38 -14
  191. package/dist/chunk-fmgf9h5e.js.map +22 -0
  192. package/dist/{chunk-b9qfh2ya.js → chunk-fzbhybya.js} +29 -2
  193. package/dist/chunk-fzbhybya.js.map +11 -0
  194. package/dist/{chunk-t0s7b3d1.js → chunk-gaj8djsw.js} +251 -6
  195. package/dist/chunk-gaj8djsw.js.map +13 -0
  196. package/dist/{chunk-2bn6813a.js → chunk-grt2j5vp.js} +2 -2
  197. package/dist/{chunk-s7xqfxs9.js → chunk-hkbks1xm.js} +3 -1
  198. package/dist/{chunk-s7xqfxs9.js.map → chunk-hkbks1xm.js.map} +3 -3
  199. package/dist/chunk-hn2r7z41.js.map +1 -1
  200. package/dist/{chunk-rtdrm592.js → chunk-htdzx40w.js} +2 -2
  201. package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
  202. package/dist/{chunk-yy914zfr.js → chunk-jt012fxq.js} +772 -98
  203. package/dist/chunk-jt012fxq.js.map +34 -0
  204. package/dist/{chunk-48c1z8nj.js → chunk-kft7mp7z.js} +28 -3
  205. package/dist/chunk-kft7mp7z.js.map +10 -0
  206. package/dist/chunk-mbwsgjn7.js +40 -0
  207. package/dist/chunk-mbwsgjn7.js.map +11 -0
  208. package/dist/{chunk-wa05txmk.js → chunk-n1hbwc6y.js} +51 -8
  209. package/dist/chunk-n1hbwc6y.js.map +12 -0
  210. package/dist/{chunk-n4zzaf6q.js → chunk-nxysqbt0.js} +4 -2
  211. package/dist/chunk-nxysqbt0.js.map +10 -0
  212. package/dist/{chunk-6ef4esq4.js → chunk-pqj8vff9.js} +4 -4
  213. package/dist/chunk-pvpq483h.js.map +2 -2
  214. package/dist/{chunk-mzx71snp.js → chunk-q7g9cqwt.js} +7 -2
  215. package/dist/{chunk-mzx71snp.js.map → chunk-q7g9cqwt.js.map} +3 -3
  216. package/dist/{chunk-n68vz95m.js → chunk-qbd282aa.js} +2 -2
  217. package/dist/{chunk-e91fmg6t.js → chunk-qsa7nw6f.js} +2 -1
  218. package/dist/{chunk-e91fmg6t.js.map → chunk-qsa7nw6f.js.map} +3 -3
  219. package/dist/{chunk-rsrc7vtw.js → chunk-s8xxef60.js} +240 -46
  220. package/dist/chunk-s8xxef60.js.map +50 -0
  221. package/dist/{chunk-r9rtavg9.js → chunk-t19wjmnc.js} +7 -7
  222. package/dist/{chunk-vzkxqf8h.js → chunk-tapdssb5.js} +50 -6
  223. package/dist/chunk-tapdssb5.js.map +23 -0
  224. package/dist/{chunk-dhkc9b23.js → chunk-v8a1qjzp.js} +1 -1
  225. package/dist/{chunk-hvbvq7p4.js → chunk-vs2s3p8n.js} +731 -10
  226. package/dist/chunk-vs2s3p8n.js.map +20 -0
  227. package/dist/chunk-vtjzwymr.js.map +2 -2
  228. package/dist/{chunk-8t2ynwg0.js → chunk-wzcjhv54.js} +31 -1
  229. package/dist/{chunk-8t2ynwg0.js.map → chunk-wzcjhv54.js.map} +3 -3
  230. package/dist/{chunk-8tqnsx3q.js → chunk-xavet0qs.js} +5 -3
  231. package/dist/{chunk-8tqnsx3q.js.map → chunk-xavet0qs.js.map} +3 -3
  232. package/dist/{chunk-8bns0y68.js → chunk-xf76csps.js} +5 -5
  233. package/dist/{chunk-cwdzcv37.js → chunk-xrmbhap8.js} +2 -2
  234. package/dist/{chunk-cwdzcv37.js.map → chunk-xrmbhap8.js.map} +2 -2
  235. package/dist/{chunk-f6ahf5gf.js → chunk-xxfj0rr2.js} +20 -5
  236. package/dist/chunk-xxfj0rr2.js.map +13 -0
  237. package/dist/{chunk-3hzhcfsv.js → chunk-y8fwm3z2.js} +2 -2
  238. package/dist/{chunk-3hzhcfsv.js.map → chunk-y8fwm3z2.js.map} +3 -3
  239. package/dist/{chunk-smnt672s.js → chunk-ygvay56w.js} +20 -4
  240. package/dist/chunk-ygvay56w.js.map +10 -0
  241. package/dist/{chunk-evj5jxz3.js → chunk-ykchk644.js} +63 -15
  242. package/dist/{chunk-evj5jxz3.js.map → chunk-ykchk644.js.map} +7 -7
  243. package/dist/{chunk-vepea5c3.js → chunk-ym1bqd98.js} +6 -6
  244. package/dist/{chunk-yv8hv4wq.js → chunk-z4jqb44a.js} +3 -1
  245. package/dist/chunk-z4jqb44a.js.map +10 -0
  246. package/dist/connectors/connection-handles.d.ts +9 -0
  247. package/dist/connectors/connection-handles.d.ts.map +1 -0
  248. package/dist/connectors/connections/authorizations.d.ts +9 -0
  249. package/dist/connectors/connections/authorizations.d.ts.map +1 -1
  250. package/dist/connectors/connections/capability.d.ts +11 -0
  251. package/dist/connectors/connections/capability.d.ts.map +1 -1
  252. package/dist/connectors/connections/events.d.ts +17 -0
  253. package/dist/connectors/connections/events.d.ts.map +1 -0
  254. package/dist/connectors/connections/internal.d.ts +2 -1
  255. package/dist/connectors/connections/internal.d.ts.map +1 -1
  256. package/dist/connectors/connections/internal.js +8 -4
  257. package/dist/connectors/connections/internal.js.map +1 -1
  258. package/dist/connectors/connections/runs.d.ts +3 -0
  259. package/dist/connectors/connections/runs.d.ts.map +1 -1
  260. package/dist/connectors/connections/service.d.ts +13 -1
  261. package/dist/connectors/connections/service.d.ts.map +1 -1
  262. package/dist/connectors/execution.d.ts +14 -2
  263. package/dist/connectors/execution.d.ts.map +1 -1
  264. package/dist/connectors/index.d.ts +1 -1
  265. package/dist/connectors/index.d.ts.map +1 -1
  266. package/dist/connectors/service.d.ts +5 -1
  267. package/dist/connectors/service.d.ts.map +1 -1
  268. package/dist/connectors/types.d.ts +22 -1
  269. package/dist/connectors/types.d.ts.map +1 -1
  270. package/dist/datasets/write.js +1 -1
  271. package/dist/deploy/index.d.ts +1 -1
  272. package/dist/deploy/index.d.ts.map +1 -1
  273. package/dist/deploy/internal.js +3 -2
  274. package/dist/deploy/internal.js.map +3 -3
  275. package/dist/deploy/services.d.ts.map +1 -1
  276. package/dist/deploy/types.d.ts +22 -2
  277. package/dist/deploy/types.d.ts.map +1 -1
  278. package/dist/events/definitions.d.ts +4 -0
  279. package/dist/events/definitions.d.ts.map +1 -1
  280. package/dist/events/execution.d.ts +8 -1
  281. package/dist/events/execution.d.ts.map +1 -1
  282. package/dist/events/index.d.ts +2 -2
  283. package/dist/events/index.d.ts.map +1 -1
  284. package/dist/events/index.js +3 -3
  285. package/dist/events/outbox-dispatcher.d.ts +7 -0
  286. package/dist/events/outbox-dispatcher.d.ts.map +1 -1
  287. package/dist/events/scope.d.ts +1 -0
  288. package/dist/events/scope.d.ts.map +1 -1
  289. package/dist/events/scope.js +1 -1
  290. package/dist/events/selectors/builder.d.ts +9 -1
  291. package/dist/events/selectors/builder.d.ts.map +1 -1
  292. package/dist/events/selectors/index.d.ts +2 -2
  293. package/dist/events/selectors/index.d.ts.map +1 -1
  294. package/dist/events/selectors/index.js +2 -2
  295. package/dist/events/selectors/predicate.d.ts.map +1 -1
  296. package/dist/events/selectors/types.d.ts +18 -3
  297. package/dist/events/selectors/types.d.ts.map +1 -1
  298. package/dist/events/types/artifacts.d.ts +7 -1
  299. package/dist/events/types/artifacts.d.ts.map +1 -1
  300. package/dist/events/types/connectors.d.ts +32 -0
  301. package/dist/events/types/connectors.d.ts.map +1 -0
  302. package/dist/events/types/index.d.ts +3 -1
  303. package/dist/events/types/index.d.ts.map +1 -1
  304. package/dist/events/types/syncs.d.ts +4 -0
  305. package/dist/events/types/syncs.d.ts.map +1 -1
  306. package/dist/execution/agent.js +43 -42
  307. package/dist/execution/agent.js.map +1 -1
  308. package/dist/execution/authorization.d.ts +5 -0
  309. package/dist/execution/authorization.d.ts.map +1 -1
  310. package/dist/execution/authorized-object-reader.d.ts +4 -0
  311. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  312. package/dist/execution/object-reader-ontology.d.ts +3 -0
  313. package/dist/execution/object-reader-ontology.d.ts.map +1 -1
  314. package/dist/execution/primitive.js +41 -40
  315. package/dist/execution/primitive.js.map +1 -1
  316. package/dist/execution/request.d.ts +1 -1
  317. package/dist/execution/request.d.ts.map +1 -1
  318. package/dist/execution/request.js +39 -38
  319. package/dist/execution/request.js.map +3 -3
  320. package/dist/execution/scopes.d.ts +8 -0
  321. package/dist/execution/scopes.d.ts.map +1 -1
  322. package/dist/execution/script.d.ts +7 -0
  323. package/dist/execution/script.d.ts.map +1 -0
  324. package/dist/execution/types.d.ts +16 -1
  325. package/dist/execution/types.d.ts.map +1 -1
  326. package/dist/http/api-routes.d.ts.map +1 -1
  327. package/dist/http/index.js +1 -1
  328. package/dist/index.d.ts +13 -12
  329. package/dist/index.d.ts.map +1 -1
  330. package/dist/index.js +74 -70
  331. package/dist/index.js.map +1 -1
  332. package/dist/lake-storage/index.js +1 -1
  333. package/dist/lineage/executors.d.ts +1 -1
  334. package/dist/lineage/executors.d.ts.map +1 -1
  335. package/dist/maintenance/index.js +2 -2
  336. package/dist/materialization/event-envelopes.d.ts +3 -3
  337. package/dist/materialization/event-envelopes.d.ts.map +1 -1
  338. package/dist/materialization/events.d.ts +6 -0
  339. package/dist/materialization/events.d.ts.map +1 -1
  340. package/dist/materialization/index.js +1 -1
  341. package/dist/materialization/model.d.ts +6 -0
  342. package/dist/materialization/model.d.ts.map +1 -1
  343. package/dist/materializer/index.js +24 -23
  344. package/dist/materializer/index.js.map +1 -1
  345. package/dist/materializer/projections/replace.d.ts.map +1 -1
  346. package/dist/materializer/projections/replacement-plan.d.ts +2 -0
  347. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  348. package/dist/materializer/shared/normalize.d.ts +1 -0
  349. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  350. package/dist/models/audio/runtime.d.ts.map +1 -1
  351. package/dist/models/audio/types.d.ts +19 -0
  352. package/dist/models/audio/types.d.ts.map +1 -1
  353. package/dist/models/execution/index.js +22 -21
  354. package/dist/models/execution/index.js.map +1 -1
  355. package/dist/models/index.d.ts +1 -1
  356. package/dist/models/index.d.ts.map +1 -1
  357. package/dist/objects/index.js +41 -40
  358. package/dist/objects/index.js.map +1 -1
  359. package/dist/objects/query/executor.d.ts +3 -1
  360. package/dist/objects/query/executor.d.ts.map +1 -1
  361. package/dist/objects/query/explain.d.ts +3 -1
  362. package/dist/objects/query/explain.d.ts.map +1 -1
  363. package/dist/objects/query/index.d.ts +1 -1
  364. package/dist/objects/query/index.d.ts.map +1 -1
  365. package/dist/objects/query/index.js +21 -20
  366. package/dist/objects/query/index.js.map +1 -1
  367. package/dist/objects/query/link-query-clearance.d.ts +3 -0
  368. package/dist/objects/query/link-query-clearance.d.ts.map +1 -1
  369. package/dist/objects/query/links.d.ts +1 -1
  370. package/dist/objects/query/links.d.ts.map +1 -1
  371. package/dist/objects/query/validate.d.ts +17 -0
  372. package/dist/objects/query/validate.d.ts.map +1 -1
  373. package/dist/objects/sdk/runtime-query-executor.d.ts +1 -1
  374. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
  375. package/dist/ontology/index.js +3 -3
  376. package/dist/ontology/internal.js +3 -3
  377. package/dist/pipelines/index.js +27 -26
  378. package/dist/pipelines/index.js.map +1 -1
  379. package/dist/projections/builders.d.ts +7 -1
  380. package/dist/projections/builders.d.ts.map +1 -1
  381. package/dist/projections/index.d.ts +1 -1
  382. package/dist/projections/index.d.ts.map +1 -1
  383. package/dist/projections/internal.js +22 -21
  384. package/dist/projections/internal.js.map +1 -1
  385. package/dist/projections/types.d.ts +10 -0
  386. package/dist/projections/types.d.ts.map +1 -1
  387. package/dist/projections/validation.d.ts.map +1 -1
  388. package/dist/queues/in-memory.d.ts +3 -2
  389. package/dist/queues/in-memory.d.ts.map +1 -1
  390. package/dist/queues/index.d.ts +1 -1
  391. package/dist/queues/index.d.ts.map +1 -1
  392. package/dist/queues/index.js +1 -1
  393. package/dist/queues/types.d.ts +40 -13
  394. package/dist/queues/types.d.ts.map +1 -1
  395. package/dist/runtime/host.d.ts +13 -0
  396. package/dist/runtime/host.d.ts.map +1 -1
  397. package/dist/runtime/internal.d.ts +1 -0
  398. package/dist/runtime/internal.d.ts.map +1 -1
  399. package/dist/runtime/internal.js +47 -25
  400. package/dist/runtime/internal.js.map +4 -3
  401. package/dist/runtime/locale.d.ts +0 -2
  402. package/dist/runtime/locale.d.ts.map +1 -1
  403. package/dist/runtime/resolve-definitions.d.ts +1 -1
  404. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  405. package/dist/runtime/script.d.ts +39 -0
  406. package/dist/runtime/script.d.ts.map +1 -0
  407. package/dist/runtime/sixb.d.ts +2 -2
  408. package/dist/runtime/sixb.d.ts.map +1 -1
  409. package/dist/sandboxes/auth.d.ts +26 -4
  410. package/dist/sandboxes/auth.d.ts.map +1 -1
  411. package/dist/sandboxes/index.d.ts +3 -1
  412. package/dist/sandboxes/index.d.ts.map +1 -1
  413. package/dist/sandboxes/index.js +5 -5
  414. package/dist/schedules/builders.d.ts.map +1 -1
  415. package/dist/schedules/index.js +3 -3
  416. package/dist/schedules/runtime.d.ts.map +1 -1
  417. package/dist/schedules/validation.d.ts +2 -0
  418. package/dist/schedules/validation.d.ts.map +1 -1
  419. package/dist/security/view-conditions.d.ts.map +1 -1
  420. package/dist/shares/internal.js +19 -18
  421. package/dist/shares/internal.js.map +2 -2
  422. package/dist/storage/agents/errors.d.ts +1 -1
  423. package/dist/storage/agents/errors.d.ts.map +1 -1
  424. package/dist/storage/agents/in-memory.d.ts +43 -1
  425. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  426. package/dist/storage/agents/index.d.ts +2 -2
  427. package/dist/storage/agents/index.d.ts.map +1 -1
  428. package/dist/storage/agents/provider.d.ts +54 -11
  429. package/dist/storage/agents/provider.d.ts.map +1 -1
  430. package/dist/storage/agents/provider.js +41 -5
  431. package/dist/storage/agents/provider.js.map +1 -1
  432. package/dist/storage/agents/types.d.ts +291 -3
  433. package/dist/storage/agents/types.d.ts.map +1 -1
  434. package/dist/storage/ai-cost/analytics.d.ts +3 -2
  435. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  436. package/dist/storage/ai-cost/provider.js +4 -3
  437. package/dist/storage/ai-cost/provider.js.map +1 -1
  438. package/dist/storage/ai-cost/types.d.ts +5 -1
  439. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  440. package/dist/storage/artifacts/in-memory.d.ts +7 -1
  441. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  442. package/dist/storage/artifacts/index.d.ts +1 -1
  443. package/dist/storage/artifacts/index.d.ts.map +1 -1
  444. package/dist/storage/artifacts/record.d.ts +5 -2
  445. package/dist/storage/artifacts/record.d.ts.map +1 -1
  446. package/dist/storage/artifacts/types.d.ts +41 -0
  447. package/dist/storage/artifacts/types.d.ts.map +1 -1
  448. package/dist/storage/executions/provider.d.ts +3 -3
  449. package/dist/storage/executions/provider.d.ts.map +1 -1
  450. package/dist/storage/executions/provider.js +1 -1
  451. package/dist/storage/executions/types.d.ts +6 -0
  452. package/dist/storage/executions/types.d.ts.map +1 -1
  453. package/dist/storage/executions/validation.d.ts.map +1 -1
  454. package/dist/storage/file-upload-sessions/provider.js +7 -7
  455. package/dist/storage/index.d.ts +4 -4
  456. package/dist/storage/index.d.ts.map +1 -1
  457. package/dist/storage/index.js +30 -25
  458. package/dist/storage/index.js.map +1 -1
  459. package/dist/storage/internal.d.ts +1 -1
  460. package/dist/storage/internal.d.ts.map +1 -1
  461. package/dist/storage/internal.js +12 -10
  462. package/dist/storage/internal.js.map +2 -2
  463. package/dist/storage/ontology/in-memory/replacement-plans.d.ts +2 -0
  464. package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
  465. package/dist/storage/ontology/provider.js +1 -1
  466. package/dist/storage/ontology/replacement-plans.d.ts +8 -0
  467. package/dist/storage/ontology/replacement-plans.d.ts.map +1 -1
  468. package/dist/storage/operation-scope.d.ts.map +1 -1
  469. package/dist/storage/operation-scope.js +1 -1
  470. package/dist/storage/sync-runs/idempotency.d.ts.map +1 -1
  471. package/dist/storage/sync-runs/in-memory.d.ts +2 -1
  472. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
  473. package/dist/storage/sync-runs/index.d.ts +1 -1
  474. package/dist/storage/sync-runs/index.d.ts.map +1 -1
  475. package/dist/storage/sync-runs/types.d.ts +27 -2
  476. package/dist/storage/sync-runs/types.d.ts.map +1 -1
  477. package/dist/storage/workflow-runs/provider.js +7 -7
  478. package/dist/syncs/accounts.d.ts +36 -0
  479. package/dist/syncs/accounts.d.ts.map +1 -0
  480. package/dist/syncs/builders.d.ts.map +1 -1
  481. package/dist/syncs/connections.d.ts +36 -0
  482. package/dist/syncs/connections.d.ts.map +1 -0
  483. package/dist/syncs/execution.d.ts +14 -4
  484. package/dist/syncs/execution.d.ts.map +1 -1
  485. package/dist/syncs/index.d.ts +2 -1
  486. package/dist/syncs/index.d.ts.map +1 -1
  487. package/dist/syncs/index.js +28 -27
  488. package/dist/syncs/index.js.map +1 -1
  489. package/dist/syncs/request.d.ts +16 -2
  490. package/dist/syncs/request.d.ts.map +1 -1
  491. package/dist/syncs/run-dispatch.d.ts +14 -2
  492. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  493. package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -1
  494. package/dist/testing/agent-execution.d.ts +3 -0
  495. package/dist/testing/agent-execution.d.ts.map +1 -1
  496. package/dist/testing/agent-inbox-storage-contract.d.ts +15 -0
  497. package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -0
  498. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  499. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  500. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  501. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  502. package/dist/testing/index.d.ts +1 -0
  503. package/dist/testing/index.d.ts.map +1 -1
  504. package/dist/testing/index.js +6589 -4627
  505. package/dist/testing/index.js.map +13 -12
  506. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  507. package/dist/testing/queues-contract.d.ts.map +1 -1
  508. package/dist/testing/run-claim-storage-contract.d.ts.map +1 -1
  509. package/dist/webhooks/connections.d.ts +3 -4
  510. package/dist/webhooks/connections.d.ts.map +1 -1
  511. package/dist/webhooks/index.d.ts +1 -1
  512. package/dist/webhooks/index.d.ts.map +1 -1
  513. package/dist/webhooks/internal.js +22 -54
  514. package/dist/webhooks/internal.js.map +3 -3
  515. package/dist/webhooks/types.d.ts +2 -11
  516. package/dist/webhooks/types.d.ts.map +1 -1
  517. package/dist/workers/index.js +66 -13
  518. package/dist/workers/index.js.map +4 -4
  519. package/dist/workers/queue-worker.d.ts +5 -0
  520. package/dist/workers/queue-worker.d.ts.map +1 -1
  521. package/dist/workers/queued-run-dispatch.d.ts.map +1 -1
  522. package/dist/workers/worker.d.ts +8 -0
  523. package/dist/workers/worker.d.ts.map +1 -1
  524. package/dist/workflows/index.js +50 -48
  525. package/dist/workflows/index.js.map +1 -1
  526. package/package.json +12 -1
  527. package/src/actions/validation.ts +3 -1
  528. package/src/agents/README.md +6 -2
  529. package/src/agents/children.ts +6 -0
  530. package/src/agents/errors.ts +3 -0
  531. package/src/agents/execution.ts +331 -43
  532. package/src/agents/ids.ts +5 -0
  533. package/src/agents/index.ts +22 -4
  534. package/src/agents/model-routing.ts +25 -9
  535. package/src/agents/queued-turn.ts +46 -0
  536. package/src/agents/request.ts +1444 -210
  537. package/src/agents/run-after-finish.ts +259 -2
  538. package/src/agents/run-artifacts.ts +3 -93
  539. package/src/agents/run-events.ts +256 -34
  540. package/src/agents/run-session-children.ts +13 -2
  541. package/src/agents/run-session-http.ts +9 -2
  542. package/src/agents/run-session-serve.ts +2 -8
  543. package/src/agents/run-session.ts +142 -3
  544. package/src/agents/run-turn.ts +148 -23
  545. package/src/agents/streams/index.ts +3 -0
  546. package/src/agents/streams/internal.ts +12 -0
  547. package/src/agents/streams/protocol.ts +109 -1
  548. package/src/agents/streams/steps.ts +131 -0
  549. package/src/agents/thread-access.ts +57 -2
  550. package/src/agents/turn-answered.ts +31 -0
  551. package/src/agents/validation.ts +2 -0
  552. package/src/artifacts/canvas-display.ts +4 -6
  553. package/src/artifacts/comments.ts +70 -17
  554. package/src/artifacts/document-fill.ts +103 -0
  555. package/src/artifacts/errors.ts +2 -0
  556. package/src/artifacts/events.ts +4 -1
  557. package/src/artifacts/execution.ts +265 -31
  558. package/src/artifacts/frames/assets.ts +42 -7
  559. package/src/artifacts/frames/document-data.ts +353 -0
  560. package/src/artifacts/frames/entries.ts +22 -16
  561. package/src/artifacts/frames/grants.ts +2 -2
  562. package/src/artifacts/frames/index.ts +3 -0
  563. package/src/artifacts/frames/kit.ts +102 -0
  564. package/src/artifacts/frames/protocol.ts +12 -1
  565. package/src/artifacts/frames/runtime.ts +413 -6
  566. package/src/artifacts/index.ts +3 -0
  567. package/src/artifacts/live/blocks.ts +889 -0
  568. package/src/artifacts/live/board.ts +195 -42
  569. package/src/artifacts/live/document.ts +170 -5
  570. package/src/artifacts/live/index.ts +7 -0
  571. package/src/artifacts/live/page.ts +807 -0
  572. package/src/artifacts/live/protocol.ts +5 -0
  573. package/src/artifacts/live/server.ts +2 -2
  574. package/src/artifacts/live/state.ts +9 -4
  575. package/src/artifacts/outline.ts +17 -0
  576. package/src/artifacts/paper.ts +173 -0
  577. package/src/artifacts/pdf-job.ts +11 -0
  578. package/src/artifacts/publish/fields.ts +177 -0
  579. package/src/artifacts/publish/index.ts +6 -1
  580. package/src/artifacts/publish/merge.ts +28 -15
  581. package/src/artifacts/publish/pdf.ts +82 -0
  582. package/src/artifacts/publish/previews.ts +24 -34
  583. package/src/artifacts/publish/publish.ts +26 -3
  584. package/src/artifacts/publish/queries.ts +20 -4
  585. package/src/artifacts/publish/query-answers.ts +14 -3
  586. package/src/artifacts/publish/validate/document-html.ts +245 -0
  587. package/src/artifacts/publish/validate/document.ts +34 -3
  588. package/src/artifacts/queries.ts +59 -13
  589. package/src/artifacts/run-query.ts +5 -2
  590. package/src/authorization/event-visibility.ts +13 -0
  591. package/src/calendar.ts +195 -0
  592. package/src/connectors/connection-handles.ts +71 -0
  593. package/src/connectors/connections/authorizations.ts +50 -2
  594. package/src/connectors/connections/capability.ts +40 -0
  595. package/src/connectors/connections/events.ts +57 -0
  596. package/src/connectors/connections/internal.ts +3 -0
  597. package/src/connectors/connections/runs.ts +5 -0
  598. package/src/connectors/connections/service.ts +93 -6
  599. package/src/connectors/execution.ts +35 -8
  600. package/src/connectors/index.ts +3 -0
  601. package/src/connectors/service.ts +23 -0
  602. package/src/connectors/types.ts +29 -1
  603. package/src/deploy/index.ts +1 -0
  604. package/src/deploy/services.ts +1 -0
  605. package/src/deploy/types.ts +30 -2
  606. package/src/events/definitions.ts +14 -0
  607. package/src/events/execution.ts +51 -4
  608. package/src/events/index.ts +8 -0
  609. package/src/events/outbox-dispatcher.ts +12 -2
  610. package/src/events/scope.ts +3 -0
  611. package/src/events/selectors/builder.ts +49 -0
  612. package/src/events/selectors/index.ts +5 -0
  613. package/src/events/selectors/predicate.ts +2 -0
  614. package/src/events/selectors/types.ts +30 -1
  615. package/src/events/types/artifacts.ts +7 -1
  616. package/src/events/types/connectors.ts +36 -0
  617. package/src/events/types/index.ts +7 -0
  618. package/src/events/types/syncs.ts +4 -0
  619. package/src/execution/authorization.ts +45 -0
  620. package/src/execution/authorized-object-reader.ts +33 -5
  621. package/src/execution/durable.ts +2 -0
  622. package/src/execution/object-reader-ontology.ts +6 -0
  623. package/src/execution/request.ts +1 -0
  624. package/src/execution/scopes.ts +24 -0
  625. package/src/execution/script.ts +27 -0
  626. package/src/execution/types.ts +7 -1
  627. package/src/http/api-routes.ts +33 -0
  628. package/src/index.ts +39 -4
  629. package/src/lineage/executors.ts +3 -1
  630. package/src/materialization/event-envelopes.ts +10 -5
  631. package/src/materialization/events.ts +2 -0
  632. package/src/materialization/model.ts +6 -0
  633. package/src/materializer/README.md +10 -0
  634. package/src/materializer/projections/replace.ts +42 -1
  635. package/src/materializer/projections/replacement-plan.ts +44 -4
  636. package/src/materializer/shared/normalize.ts +4 -0
  637. package/src/models/audio/runtime.ts +57 -14
  638. package/src/models/audio/types.ts +20 -0
  639. package/src/models/index.ts +1 -0
  640. package/src/objects/query/executor.ts +4 -0
  641. package/src/objects/query/explain.ts +5 -0
  642. package/src/objects/query/index.ts +1 -0
  643. package/src/objects/query/link-query-clearance.ts +4 -1
  644. package/src/objects/query/links.ts +5 -1
  645. package/src/objects/query/validate.ts +33 -1
  646. package/src/objects/sdk/runtime-query-executor.ts +7 -3
  647. package/src/projections/builders.ts +20 -0
  648. package/src/projections/index.ts +1 -0
  649. package/src/projections/registry.ts +1 -0
  650. package/src/projections/revision.ts +2 -0
  651. package/src/projections/types.ts +11 -0
  652. package/src/projections/validation.ts +6 -0
  653. package/src/queues/in-memory.ts +5 -0
  654. package/src/queues/index.ts +3 -1
  655. package/src/queues/types.ts +45 -14
  656. package/src/runtime/host.ts +125 -11
  657. package/src/runtime/internal.ts +1 -0
  658. package/src/runtime/locale.ts +0 -10
  659. package/src/runtime/resolve-definitions.ts +4 -1
  660. package/src/runtime/script.ts +62 -0
  661. package/src/runtime/sixb.ts +15 -5
  662. package/src/sandboxes/README.md +3 -1
  663. package/src/sandboxes/auth.ts +32 -4
  664. package/src/sandboxes/index.ts +15 -1
  665. package/src/schedules/builders.ts +4 -1
  666. package/src/schedules/runtime.ts +3 -0
  667. package/src/schedules/validation.ts +20 -2
  668. package/src/security/view-conditions.ts +2 -1
  669. package/src/storage/agents/errors.ts +1 -0
  670. package/src/storage/agents/in-memory.ts +500 -7
  671. package/src/storage/agents/index.ts +26 -0
  672. package/src/storage/agents/provider.ts +454 -15
  673. package/src/storage/agents/types.ts +315 -3
  674. package/src/storage/ai-cost/analytics.ts +22 -43
  675. package/src/storage/ai-cost/types.ts +5 -1
  676. package/src/storage/artifacts/in-memory.ts +52 -6
  677. package/src/storage/artifacts/index.ts +2 -0
  678. package/src/storage/artifacts/record.ts +33 -4
  679. package/src/storage/artifacts/types.ts +44 -0
  680. package/src/storage/executions/provider.ts +22 -2
  681. package/src/storage/executions/types.ts +2 -0
  682. package/src/storage/executions/validation.ts +27 -0
  683. package/src/storage/index.ts +29 -0
  684. package/src/storage/internal.ts +1 -0
  685. package/src/storage/ontology/in-memory/replacement-plans.ts +22 -0
  686. package/src/storage/ontology/replacement-plans.ts +6 -0
  687. package/src/storage/operation-scope.ts +2 -0
  688. package/src/storage/sync-runs/idempotency.ts +1 -0
  689. package/src/storage/sync-runs/in-memory.ts +43 -1
  690. package/src/storage/sync-runs/index.ts +1 -0
  691. package/src/storage/sync-runs/types.ts +30 -1
  692. package/src/syncs/accounts.ts +85 -0
  693. package/src/syncs/builders.ts +18 -1
  694. package/src/syncs/connections.ts +123 -0
  695. package/src/syncs/execution.ts +64 -22
  696. package/src/syncs/index.ts +3 -0
  697. package/src/syncs/request.ts +81 -23
  698. package/src/syncs/run-dispatch.ts +69 -7
  699. package/src/testing/agent-approval-storage-contract.ts +123 -0
  700. package/src/testing/agent-execution.ts +45 -2
  701. package/src/testing/agent-inbox-storage-contract.ts +874 -0
  702. package/src/testing/agent-storage-contract.ts +965 -103
  703. package/src/testing/ai-cost-storage-contract.ts +80 -0
  704. package/src/testing/artifact-storage-contract.ts +201 -4
  705. package/src/testing/execution-storage-contract.ts +31 -0
  706. package/src/testing/index.ts +5 -0
  707. package/src/testing/materializer-storage-contract.ts +139 -1
  708. package/src/testing/queues-contract.ts +22 -0
  709. package/src/testing/run-claim-storage-contract.ts +116 -0
  710. package/src/webhooks/connections.ts +9 -50
  711. package/src/webhooks/index.ts +0 -2
  712. package/src/webhooks/types.ts +2 -13
  713. package/src/workers/README.md +4 -1
  714. package/src/workers/lost-runs.ts +1 -0
  715. package/src/workers/queue-worker.ts +16 -5
  716. package/src/workers/queued-run-dispatch.ts +8 -1
  717. package/src/workers/worker.ts +67 -7
  718. package/dist/chunk-3z1vxzcm.js +0 -234
  719. package/dist/chunk-3z1vxzcm.js.map +0 -12
  720. package/dist/chunk-48c1z8nj.js.map +0 -10
  721. package/dist/chunk-58geavnf.js +0 -29
  722. package/dist/chunk-58geavnf.js.map +0 -10
  723. package/dist/chunk-5a4a52tq.js.map +0 -10
  724. package/dist/chunk-9nsjjd44.js.map +0 -12
  725. package/dist/chunk-b9qfh2ya.js.map +0 -11
  726. package/dist/chunk-eptrvnby.js.map +0 -12
  727. package/dist/chunk-f6ahf5gf.js.map +0 -13
  728. package/dist/chunk-gxwy4c3s.js.map +0 -47
  729. package/dist/chunk-hvbvq7p4.js.map +0 -18
  730. package/dist/chunk-m2jerfef.js +0 -474
  731. package/dist/chunk-m2jerfef.js.map +0 -11
  732. package/dist/chunk-msyevpp3.js.map +0 -22
  733. package/dist/chunk-n4zzaf6q.js.map +0 -10
  734. package/dist/chunk-rsrc7vtw.js.map +0 -49
  735. package/dist/chunk-rsxb14an.js.map +0 -18
  736. package/dist/chunk-smnt672s.js.map +0 -10
  737. package/dist/chunk-t0s7b3d1.js.map +0 -13
  738. package/dist/chunk-td26wjr5.js.map +0 -13
  739. package/dist/chunk-vzkxqf8h.js.map +0 -23
  740. package/dist/chunk-wa05txmk.js.map +0 -11
  741. package/dist/chunk-yv8hv4wq.js.map +0 -10
  742. package/dist/chunk-yy914zfr.js.map +0 -30
  743. package/dist/chunk-zeykm8my.js.map +0 -14
  744. /package/dist/{chunk-stmxh0hv.js.map → chunk-3neam1y5.js.map} +0 -0
  745. /package/dist/{chunk-p8pgnq8d.js.map → chunk-425ydk65.js.map} +0 -0
  746. /package/dist/{chunk-p351afzm.js.map → chunk-5sswe5ej.js.map} +0 -0
  747. /package/dist/{chunk-e0hnbb1m.js.map → chunk-61zptves.js.map} +0 -0
  748. /package/dist/{chunk-fe6r7yhg.js.map → chunk-92wrka15.js.map} +0 -0
  749. /package/dist/{chunk-q9nkpr8k.js.map → chunk-9tpmfh3n.js.map} +0 -0
  750. /package/dist/{chunk-sysnvjce.js.map → chunk-brhp9d97.js.map} +0 -0
  751. /package/dist/{chunk-8a8k38tz.js.map → chunk-brybqw5k.js.map} +0 -0
  752. /package/dist/{chunk-855w9nvw.js.map → chunk-cg7cygfj.js.map} +0 -0
  753. /package/dist/{chunk-r2psmn42.js.map → chunk-eg6xqef7.js.map} +0 -0
  754. /package/dist/{chunk-7kpqntgw.js.map → chunk-f05994as.js.map} +0 -0
  755. /package/dist/{chunk-2bn6813a.js.map → chunk-grt2j5vp.js.map} +0 -0
  756. /package/dist/{chunk-rtdrm592.js.map → chunk-htdzx40w.js.map} +0 -0
  757. /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
  758. /package/dist/{chunk-6ef4esq4.js.map → chunk-pqj8vff9.js.map} +0 -0
  759. /package/dist/{chunk-n68vz95m.js.map → chunk-qbd282aa.js.map} +0 -0
  760. /package/dist/{chunk-r9rtavg9.js.map → chunk-t19wjmnc.js.map} +0 -0
  761. /package/dist/{chunk-dhkc9b23.js.map → chunk-v8a1qjzp.js.map} +0 -0
  762. /package/dist/{chunk-8bns0y68.js.map → chunk-xf76csps.js.map} +0 -0
  763. /package/dist/{chunk-vepea5c3.js.map → chunk-ym1bqd98.js.map} +0 -0
@@ -35,11 +35,11 @@ import {
35
35
  normalizeLinkProperties2,
36
36
  validateLinkProperties2,
37
37
  assertTelemetryProperty2
38
- } from "./chunk-3zagkr6w.js";
38
+ } from "./chunk-7mhbs9yy.js";
39
39
  import {
40
40
  isObjectRefSchema2,
41
41
  validateSchemaOrRefValue2
42
- } from "./chunk-8a8k38tz.js";
42
+ } from "./chunk-brybqw5k.js";
43
43
  import {
44
44
  ActionDefinitionError2,
45
45
  missingActionMutationMessage,
@@ -60,7 +60,7 @@ import {
60
60
  createUsersRuntime,
61
61
  SYSTEM_PRINCIPAL2,
62
62
  principalsEqual2
63
- } from "./chunk-0k3r5kb3.js";
63
+ } from "./chunk-394zjzjs.js";
64
64
  import {
65
65
  ActionValidationError2,
66
66
  SIXB_ERROR_CODES2,
@@ -97,7 +97,7 @@ import {
97
97
  canViewProjectionRun2,
98
98
  canViewPrimitiveRun2,
99
99
  canViewProjection2
100
- } from "./chunk-vzkxqf8h.js";
100
+ } from "./chunk-tapdssb5.js";
101
101
  import {
102
102
  compileSelectedObjectReadScope2
103
103
  } from "./chunk-rt9deb92.js";
@@ -107,7 +107,7 @@ import {
107
107
  resolveAgentExecutionAuthorization2,
108
108
  userCanRunAgent2,
109
109
  resolveInheritedAgentExecutionAuthorization2
110
- } from "./chunk-p351afzm.js";
110
+ } from "./chunk-5sswe5ej.js";
111
111
  import {
112
112
  ACTION_RUN_FAILURE_CODES2,
113
113
  parseActionRunFailure2
@@ -143,19 +143,27 @@ import {
143
143
  createAgentThreadSandboxName2,
144
144
  createAgentRunId2,
145
145
  createAgentMessageId2,
146
+ createAgentInboxItemId,
146
147
  AGENT_REASONING_LEVELS2,
148
+ countsAsThreadMessage2,
147
149
  movesComputerPlace2,
150
+ turnPlace2,
151
+ runPlaceKey2,
148
152
  isAgentApprovalMode2,
149
153
  agentApprovalHoldsRun2
150
- } from "./chunk-t0s7b3d1.js";
154
+ } from "./chunk-gaj8djsw.js";
155
+ import {
156
+ canonicalLocale,
157
+ canonicalTimeZone2
158
+ } from "./chunk-dq3t5sr3.js";
151
159
  import {
152
160
  actionRunRequestsEqual,
153
161
  ObjectNotFoundError2,
154
162
  ArtifactStorageError
155
- } from "./chunk-3014rfjz.js";
163
+ } from "./chunk-88xeh6zx.js";
156
164
  import {
157
165
  ExecutionStorageError2
158
- } from "./chunk-eptrvnby.js";
166
+ } from "./chunk-c29729me.js";
159
167
  import {
160
168
  objectRefKey2,
161
169
  linkRefKey2,
@@ -166,20 +174,22 @@ import {
166
174
  objectBatchKey2,
167
175
  matchesPredicate,
168
176
  WORKFLOW_RUN_FAILURE_CODES2
169
- } from "./chunk-w1wq7gfr.js";
177
+ } from "./chunk-9c9yknwt.js";
170
178
  import {
171
179
  explainObjectQuery2
172
- } from "./chunk-rsxb14an.js";
180
+ } from "./chunk-bs1sd0e0.js";
173
181
  import {
174
182
  redactDomainEvent,
175
183
  uniqueLookupKeyOf,
176
184
  assertAuthorizedObjectReaderBinding,
177
185
  getAuthorizedOntologyView,
186
+ getQueryDiscovery,
178
187
  readerClearance,
179
188
  readerEventClearance,
180
189
  readerViewConditions
181
- } from "./chunk-msyevpp3.js";
190
+ } from "./chunk-fmgf9h5e.js";
182
191
  import {
192
+ agentRunEndedShort,
183
193
  createAgentThreadAccessRule,
184
194
  assertConversationThread2,
185
195
  agentThreadViews,
@@ -190,7 +200,7 @@ import {
190
200
  transactionArtifactAccessRules,
191
201
  updatableArtifactIds,
192
202
  createArtifactsRuntime
193
- } from "./chunk-yy914zfr.js";
203
+ } from "./chunk-jt012fxq.js";
194
204
  import {
195
205
  shareSixbErrorReporter2,
196
206
  reportActionPhaseFailure2,
@@ -212,14 +222,14 @@ import {
212
222
  createActivityCaptureRuntime,
213
223
  registerActivityCaptureRuntime,
214
224
  ModelExecutionSession
215
- } from "./chunk-vepea5c3.js";
225
+ } from "./chunk-ym1bqd98.js";
216
226
  import {
217
227
  publishAgentThreadMoved2,
218
228
  publishAgentApprovalActivity,
219
229
  publishAgentRunActivity2,
220
230
  publishAgentRunCancel2,
221
231
  publishAgentRunFinished2
222
- } from "./chunk-48c1z8nj.js";
232
+ } from "./chunk-kft7mp7z.js";
223
233
  import {
224
234
  aiLimitSubjectsFromAttribution2,
225
235
  applicableAiLimitPolicyStatuses2,
@@ -235,10 +245,10 @@ import {
235
245
  } from "./chunk-8ncg20rd.js";
236
246
  import {
237
247
  registerConnectorConnectionsRuntime
238
- } from "./chunk-5a4a52tq.js";
248
+ } from "./chunk-0pmpwn3g.js";
239
249
  import {
240
250
  createConnectorRuntime
241
- } from "./chunk-wa05txmk.js";
251
+ } from "./chunk-n1hbwc6y.js";
242
252
  import {
243
253
  DatasetValidationError2
244
254
  } from "./chunk-wx7smkn2.js";
@@ -255,7 +265,7 @@ import {
255
265
  aiModelCallOutputTokenAllowance,
256
266
  ModelUsageRecordingError2,
257
267
  LanguageModelCallMeter
258
- } from "./chunk-2bn6813a.js";
268
+ } from "./chunk-grt2j5vp.js";
259
269
  import {
260
270
  createLinkScopeFingerprint2,
261
271
  normalizeJsonProperties2,
@@ -265,7 +275,15 @@ import {
265
275
  resolveEffectiveLink,
266
276
  resolveEffectiveLinkSlotMember,
267
277
  linkCardinality
268
- } from "./chunk-evj5jxz3.js";
278
+ } from "./chunk-ykchk644.js";
279
+ import {
280
+ createSyncConnections,
281
+ mayRunConnection,
282
+ visibleSyncConnectionIds,
283
+ seesConnection,
284
+ SyncValidationError2,
285
+ requestSyncRun2
286
+ } from "./chunk-90nqenq8.js";
269
287
  import {
270
288
  resolveLoggingService2
271
289
  } from "./chunk-1vg43g9q.js";
@@ -273,13 +291,15 @@ import {
273
291
  EditBatchError2,
274
292
  lowerEditBatch2
275
293
  } from "./chunk-m427qgq0.js";
276
- import {
277
- SyncValidationError2,
278
- requestSyncRun2
279
- } from "./chunk-3z1vxzcm.js";
280
294
  import {
281
295
  compileShareAccessPlan
282
- } from "./chunk-n68vz95m.js";
296
+ } from "./chunk-qbd282aa.js";
297
+ import {
298
+ requestPipelineRun2
299
+ } from "./chunk-pqj8vff9.js";
300
+ import {
301
+ PipelineError2
302
+ } from "./chunk-hke9aeen.js";
283
303
  import {
284
304
  createObjectQueryBuilder2,
285
305
  decorateObjectQueryExecutor
@@ -288,25 +308,19 @@ import {
288
308
  SandboxError2,
289
309
  sandboxCredentialIssue2,
290
310
  staticSandboxRecipe2
291
- } from "./chunk-rtdrm592.js";
311
+ } from "./chunk-htdzx40w.js";
312
+ import {
313
+ executionRecordInputFromRuntime,
314
+ ensureExecutionRecord2,
315
+ createPrimitiveExecutionRecord,
316
+ restoreTrustedPrimitiveExecutionScope
317
+ } from "./chunk-xavet0qs.js";
292
318
  import {
293
319
  resolveLanguageModel2
294
320
  } from "./chunk-3723kgba.js";
295
321
  import {
296
322
  schemaRecordToJsonSchema2
297
323
  } from "./chunk-0kgrghqx.js";
298
- import {
299
- requestPipelineRun2
300
- } from "./chunk-6ef4esq4.js";
301
- import {
302
- PipelineError2
303
- } from "./chunk-hke9aeen.js";
304
- import {
305
- executionRecordInputFromRuntime,
306
- ensureExecutionRecord2,
307
- createPrimitiveExecutionRecord,
308
- restoreTrustedPrimitiveExecutionScope
309
- } from "./chunk-8tqnsx3q.js";
310
324
  import {
311
325
  lineageColumn,
312
326
  isUnknownLineage,
@@ -338,19 +352,26 @@ import {
338
352
  } from "./chunk-m4ehq95f.js";
339
353
  import {
340
354
  eventAttribution2
341
- } from "./chunk-mzx71snp.js";
355
+ } from "./chunk-q7g9cqwt.js";
356
+ import {
357
+ isOAuthConnectorDefinition2
358
+ } from "./chunk-pvpq483h.js";
342
359
  import {
343
360
  ObjectQueryPlanningError2
344
361
  } from "./chunk-0k1h5hmr.js";
345
362
  import {
346
363
  normalizeParams
347
- } from "./chunk-stmxh0hv.js";
364
+ } from "./chunk-3neam1y5.js";
348
365
  import {
349
366
  MaterializationValidationError2,
350
367
  MaterializationObjectNotFoundError2,
351
368
  UniqueValueViolationError2,
352
369
  isMaterializationConflictError2
353
370
  } from "./chunk-y7dbmaqh.js";
371
+ import {
372
+ OntologyValidationError2,
373
+ OntologyNotFoundError2
374
+ } from "./chunk-cqr3acm1.js";
354
375
  import {
355
376
  ModelProviderError2,
356
377
  ModelStreamError2,
@@ -358,17 +379,13 @@ import {
358
379
  StructuredOutputError2,
359
380
  sameEmbeddingModel
360
381
  } from "./chunk-rtkqczbr.js";
361
- import {
362
- OntologyValidationError2,
363
- OntologyNotFoundError2
364
- } from "./chunk-cqr3acm1.js";
365
382
  import {
366
383
  AgentRequestError2,
367
384
  AgentMemoryError2
368
385
  } from "./chunk-9wr3yajk.js";
369
386
  import {
370
387
  AGENT_APPROVAL_MODES2
371
- } from "./chunk-n4zzaf6q.js";
388
+ } from "./chunk-nxysqbt0.js";
372
389
  import {
373
390
  resolveFileRefAtPath2,
374
391
  openFileRef2,
@@ -1940,10 +1957,16 @@ async function questionState(agents, conversationId, thread, runs) {
1940
1957
  const waiting = [...runs].reverse().find((run) => run.status !== "failed" && run.status !== "cancelled");
1941
1958
  if (!waiting || !isAwaitingAnswerRun2(waiting))
1942
1959
  return {};
1960
+ const { total } = await agents.messages.list({
1961
+ projectId: waiting.projectId,
1962
+ threadId: conversationId,
1963
+ limit: 1
1964
+ });
1943
1965
  const [latest] = await agents.runs.listThreadSubagents({
1944
1966
  projectId: waiting.projectId,
1945
1967
  threadId: conversationId,
1946
1968
  spawnKey: waiting.spawnKey,
1969
+ ...total > 0 ? { retainedTurnsOnly: true } : {},
1947
1970
  limit: 1
1948
1971
  });
1949
1972
  if (latest && latest.threadId !== thread.id)
@@ -2322,11 +2345,11 @@ function createTurnModelRouter(models, decision) {
2322
2345
  if (!language || language.tiers.length === 0 || !models?.decision)
2323
2346
  return;
2324
2347
  return {
2325
- async choose(text, previous) {
2348
+ async choose(text, previous, place) {
2326
2349
  const tierProbabilities = text.trim() ? await askTier(decision, text) : undefined;
2327
2350
  const tier = tierProbabilities ? tierFor(tierProbabilities) : "standard";
2328
2351
  return {
2329
- model: turnModel(language, tier, previous),
2352
+ model: turnModel(language, tier, previous, place),
2330
2353
  ...tierProbabilities ? { tierProbabilities } : {}
2331
2354
  };
2332
2355
  }
@@ -2360,9 +2383,9 @@ function tierFor(probabilities) {
2360
2383
  return "light";
2361
2384
  return "standard";
2362
2385
  }
2363
- function turnModel(language, tier, previous) {
2386
+ function turnModel(language, tier, previous, place) {
2364
2387
  const target = language.getByTier(tier);
2365
- const last = previous && previousTurn(language, previous);
2388
+ const last = previous && previousTurn(language, previous, place);
2366
2389
  if (!last)
2367
2390
  return target;
2368
2391
  const change = tierRank(target.tier ?? tier) - tierRank(last.tier);
@@ -2372,7 +2395,7 @@ function turnModel(language, tier, previous) {
2372
2395
  return last.model;
2373
2396
  return target;
2374
2397
  }
2375
- function previousTurn(language, run) {
2398
+ function previousTurn(language, run, place) {
2376
2399
  if (!run.spec)
2377
2400
  return;
2378
2401
  const model = language.getByRef(run.spec.model);
@@ -2380,7 +2403,12 @@ function previousTurn(language, run) {
2380
2403
  if (tier === undefined)
2381
2404
  return;
2382
2405
  const lastCallAt = run.completedAt ?? run.startedAt ?? run.createdAt;
2383
- return { model, tier, cacheWarm: Date.now() - lastCallAt.getTime() < PROMPT_CACHE_TTL_MS };
2406
+ const samePlace = runPlaceKey2(run.spec) === runPlaceKey2(place);
2407
+ return {
2408
+ model,
2409
+ tier,
2410
+ cacheWarm: samePlace && Date.now() - lastCallAt.getTime() < PROMPT_CACHE_TTL_MS
2411
+ };
2384
2412
  }
2385
2413
  function tierRank(tier) {
2386
2414
  return LANGUAGE_MODEL_TIERS2.indexOf(tier);
@@ -2516,32 +2544,27 @@ function invalidParticipant(message) {
2516
2544
  return new AgentRequestError2("invalid_participant", `[Sixb] ${message}`);
2517
2545
  }
2518
2546
 
2519
- // src/agents/request.ts
2520
- import { randomUUID as randomUUID5 } from "crypto";
2521
-
2522
- // src/runtime/locale.ts
2523
- var DEFAULT_PROJECT_LOCALE = "en";
2524
- var DEFAULT_PROJECT_TIME_ZONE = "UTC";
2525
- function canonicalLocale(value) {
2526
- if (typeof value !== "string")
2527
- return;
2528
- try {
2529
- const [locale] = Intl.getCanonicalLocales(value);
2530
- return locale;
2531
- } catch {
2532
- return;
2533
- }
2547
+ // src/agents/queued-turn.ts
2548
+ var queuedTurnKey = Symbol("sixb.agentQueuedTurn");
2549
+ function registerAgentQueuedTurn2(agent, start) {
2550
+ Object.defineProperty(agent, queuedTurnKey, {
2551
+ configurable: false,
2552
+ enumerable: false,
2553
+ value: start,
2554
+ writable: false
2555
+ });
2534
2556
  }
2535
- function canonicalTimeZone(value) {
2536
- if (typeof value !== "string" || value.trim() !== value || value === "")
2537
- return;
2538
- try {
2539
- return new Intl.DateTimeFormat("en-US", { timeZone: value }).resolvedOptions().timeZone;
2540
- } catch {
2541
- return;
2557
+ function startQueuedAgentTurn2(sixb, runId, options) {
2558
+ const start = sixb.agent[queuedTurnKey];
2559
+ if (!start) {
2560
+ throw new Error("[Sixb] Queued Agent messages cannot start: Sixb did not bind this SDK.");
2542
2561
  }
2562
+ return start(runId, options);
2543
2563
  }
2544
2564
 
2565
+ // src/agents/request.ts
2566
+ import { randomUUID as randomUUID5 } from "crypto";
2567
+
2545
2568
  // src/agents/context-resolution.ts
2546
2569
  async function resolveAgentContextParts2(runtime, input) {
2547
2570
  const entries = normalizeAgentContextEntries2(input);
@@ -2639,6 +2662,23 @@ function assertNoAgentSelector(input) {
2639
2662
  }
2640
2663
  }
2641
2664
 
2665
+ // src/agents/turn-answered.ts
2666
+ async function turnAnsweredEveryMessage(agents, run) {
2667
+ if (run.status !== "succeeded")
2668
+ return false;
2669
+ const { messages } = await agents.messages.list({
2670
+ projectId: run.projectId,
2671
+ threadId: run.threadId,
2672
+ roles: ["assistant"],
2673
+ order: "desc",
2674
+ limit: 1
2675
+ });
2676
+ const answer = messages[0];
2677
+ if (!answer || answer.runId !== run.id)
2678
+ return true;
2679
+ return !answer.parts.some((part) => part.type === "tool-call" && part.state === "output-available" && isJsonObject2(part.output) && part.output.status === "asked");
2680
+ }
2681
+
2642
2682
  // src/agents/request.ts
2643
2683
  async function requestAgentRun2(runtime, execution, models, input) {
2644
2684
  const authority = resolveExecutionScopeAuthorization(runtime.projectId, {
@@ -2677,18 +2717,15 @@ async function requestAgentRun2(runtime, execution, models, input) {
2677
2717
  assertComputerPlaceRequest(input.runsOn, input.computer);
2678
2718
  const runsOn = existingThread ? existingThread.runsOn : input.runsOn;
2679
2719
  const approvalMode = input.approvalMode ?? (await resolveAgentApprovalMode(agents, { projectId, principal, threadId: existingThread?.id })).approvalMode;
2680
- const selected = "router" in requested ? await routedConversationRunSpec(agents, {
2720
+ const place = turnPlace2(runsOn, existingThread ? existingThread.computer : input.computer);
2721
+ const selected = "router" in requested ? await routedConversationRunSpec({
2681
2722
  ...requested,
2682
- projectId,
2683
- threadId: existingThread?.id,
2723
+ previous: existingThread ? await latestConversationRun(agents, projectId, existingThread.id) : undefined,
2724
+ place,
2684
2725
  settings,
2685
2726
  language: models.language
2686
2727
  }) : requested;
2687
- const spec = Object.freeze({
2688
- ...selected,
2689
- approvalMode,
2690
- ...runsOn === undefined ? {} : { runsOn }
2691
- });
2728
+ const spec = Object.freeze({ ...selected, approvalMode, ...place });
2692
2729
  const createdThread = existingThread === null;
2693
2730
  const thread = existingThread ?? await createThread(agents, {
2694
2731
  projectId,
@@ -2708,113 +2745,789 @@ async function requestAgentRun2(runtime, execution, models, input) {
2708
2745
  throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
2709
2746
  }
2710
2747
  await tx.executions.create(durableExecution);
2711
- const reported = createdThread ? { parts: [], superseded: [] } : await reportAgentApprovals(agents, {
2748
+ const reported = createdThread ? { parts: [], superseded: [] } : await reportAgentApprovals(agents, {
2749
+ projectId,
2750
+ threadId: thread.id,
2751
+ messageId: triggerMessageId
2752
+ });
2753
+ superseded = reported.superseded;
2754
+ await agents.messages.append({
2755
+ id: triggerMessageId,
2756
+ projectId,
2757
+ threadId: thread.id,
2758
+ runId: null,
2759
+ role: "user",
2760
+ parts: [
2761
+ ...reported.parts,
2762
+ ...contextParts,
2763
+ ...trigger,
2764
+ ...(input.attachments ?? []).map((fileRef) => ({ type: "file", fileRef }))
2765
+ ],
2766
+ authorPrincipal: principal
2767
+ });
2768
+ return agents.runs.create({
2769
+ id: runId,
2770
+ projectId,
2771
+ executionId: durableExecution.id,
2772
+ threadId: thread.id,
2773
+ triggerMessageId,
2774
+ spec
2775
+ });
2776
+ });
2777
+ } catch (error) {
2778
+ if (error instanceof AgentStorageError2 && error.code === "active_run_exists") {
2779
+ throw new AgentRequestError2("active_run_exists", error.message);
2780
+ }
2781
+ throw error;
2782
+ }
2783
+ await announceAgentApprovals2(runtime.broker, superseded);
2784
+ await publishRunActivity(runtime, run);
2785
+ const jobId = await dispatchAgentRun(runtime, agents, runId);
2786
+ return {
2787
+ run,
2788
+ ...jobId ? { jobId } : {},
2789
+ createdThread
2790
+ };
2791
+ }
2792
+ function isEditableAgentMessage2(message) {
2793
+ if (message.role !== "user")
2794
+ return false;
2795
+ if (message.parts.some((part) => part.type === "continuation"))
2796
+ return false;
2797
+ return countsAsThreadMessage2(message);
2798
+ }
2799
+ async function editAgentMessage2(runtime, execution, models, input, blobStorage) {
2800
+ const authority = resolveExecutionScopeAuthorization(runtime.projectId, {
2801
+ execution,
2802
+ authorization: runtime.runtimeAuthorization
2803
+ });
2804
+ assertNoAgentSelector(input);
2805
+ assertAuthorized2(runtime, { kind: "agent.run" });
2806
+ assertRequestAuthorityCanRunAgent(runtime);
2807
+ const trigger = triggerParts(input);
2808
+ const selection = { model: input.model, reasoning: input.reasoning };
2809
+ const settings = requesterSettings(input);
2810
+ if (input.approvalMode !== undefined)
2811
+ assertAgentApprovalMode(input.approvalMode);
2812
+ const routed = routedTurn(models.router, selection, input);
2813
+ const requested = routed ?? await resolveConversationRunSpec({ models: models.language, selection, settings });
2814
+ assertAttachments(input.attachments);
2815
+ const contextParts = await resolveAgentContextParts2(runtime, input.context);
2816
+ const agents = requireAgentStorage(runtime);
2817
+ const projectId = runtime.projectId;
2818
+ const principal = authority.type === "principal" ? authority.context.principal : input.principal ?? SYSTEM_PRINCIPAL2;
2819
+ const thread = await agents.threads.getById({ projectId, id: input.threadId });
2820
+ if (!thread) {
2821
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found.`);
2822
+ }
2823
+ assertThreadAcceptsMessages(thread, principal);
2824
+ const target = await agents.messages.getById({ projectId, id: input.messageId });
2825
+ if (!target || target.threadId !== thread.id) {
2826
+ throw new AgentRequestError2("message_not_found", `[Sixb] Agent message '${input.messageId}' not found in thread '${thread.id}'.`);
2827
+ }
2828
+ assertEditableMessageAuthority(thread, target, principal);
2829
+ const tail = await listAllThreadMessagesFromSeq(agents, projectId, thread.id, target.seq);
2830
+ assertParticipantCanRewindTail(thread, tail, principal);
2831
+ const rewoundRuns = await listRewoundConversationRuns(agents, projectId, thread.id, tail);
2832
+ assertRewindsWholeTurns(target, tail, rewoundRuns);
2833
+ const approvalMode = input.approvalMode ?? (await resolveAgentApprovalMode(agents, { projectId, principal, threadId: thread.id })).approvalMode;
2834
+ const place = turnPlace2(thread.runsOn, thread.computer);
2835
+ const selected = "router" in requested ? await routedConversationRunSpec({
2836
+ ...requested,
2837
+ previous: await latestRetainedConversationRun(agents, projectId, thread.id, tail),
2838
+ place,
2839
+ settings,
2840
+ language: models.language
2841
+ }) : requested;
2842
+ const spec = Object.freeze({ ...selected, approvalMode, ...place });
2843
+ const edit = {
2844
+ target,
2845
+ messageId: input.nextMessageId ?? createAgentMessageId2(),
2846
+ authorPrincipal: principal,
2847
+ parts: [
2848
+ ...contextParts,
2849
+ ...trigger,
2850
+ ...(input.attachments ?? []).map((fileRef) => ({ type: "file", fileRef }))
2851
+ ]
2852
+ };
2853
+ const runId = createAgentRunId2();
2854
+ const durableExecution = await prepareDurableAgentExecution(runtime, execution, runId);
2855
+ await assertAiLimitPreflight(runtime, durableExecution);
2856
+ if (thread.activeRunId !== null) {
2857
+ const item = await deferAgentMessageEdit(runtime, execution, thread, edit, {
2858
+ spec,
2859
+ settings,
2860
+ blobStorage
2861
+ });
2862
+ return { kind: "inbox", item };
2863
+ }
2864
+ const documents = await rewoundTurnDocuments(runtime, blobStorage, rewoundRuns, tail);
2865
+ let run;
2866
+ let rewind;
2867
+ let superseded = [];
2868
+ try {
2869
+ run = await runtime.storage.transaction(async (tx) => {
2870
+ const txAgents = tx.agents;
2871
+ if (!txAgents) {
2872
+ throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
2873
+ }
2874
+ rewind = await rewindAgentThread(tx, txAgents, {
2875
+ projectId,
2876
+ thread,
2877
+ messageId: edit.target.id,
2878
+ editor: principal,
2879
+ documents
2880
+ });
2881
+ await tx.executions.create(durableExecution);
2882
+ const reported = await reportAgentApprovals(txAgents, {
2883
+ projectId,
2884
+ threadId: thread.id,
2885
+ messageId: edit.messageId
2886
+ });
2887
+ superseded = reported.superseded;
2888
+ await txAgents.messages.append({
2889
+ id: edit.messageId,
2890
+ projectId,
2891
+ threadId: thread.id,
2892
+ runId: null,
2893
+ role: "user",
2894
+ parts: [...reported.parts, ...edit.parts],
2895
+ authorPrincipal: principal
2896
+ });
2897
+ return txAgents.runs.create({
2898
+ id: runId,
2899
+ projectId,
2900
+ executionId: durableExecution.id,
2901
+ threadId: thread.id,
2902
+ triggerMessageId: edit.messageId,
2903
+ spec
2904
+ });
2905
+ });
2906
+ } catch (error) {
2907
+ if (error instanceof AgentStorageError2 && error.code === "active_run_exists") {
2908
+ throw new AgentRequestError2("active_run_exists", error.message);
2909
+ }
2910
+ throw error;
2911
+ }
2912
+ await announceAgentThreadRewind(runtime, rewind, superseded);
2913
+ await publishRunActivity(runtime, run);
2914
+ await dispatchAgentRun(runtime, agents, runId);
2915
+ return { kind: "turn", run, createdThread: false };
2916
+ }
2917
+ async function deferAgentMessageEdit(runtime, execution, thread, edit, options) {
2918
+ const { spec, settings } = options;
2919
+ const agents = requireAgentStorage(runtime);
2920
+ const projectId = runtime.projectId;
2921
+ const active = thread.activeRunId ? await agents.runs.getById({ projectId, id: thread.activeRunId }) : null;
2922
+ if (active?.kind !== "conversation") {
2923
+ throw new AgentRequestError2("active_run_exists", `[Sixb] Agent thread '${thread.id}' already has an active run '${thread.activeRunId}'.`);
2924
+ }
2925
+ if (!execution.requestedBy) {
2926
+ throw new AgentRequestError2("active_run_exists", `[Sixb] Agent thread '${thread.id}' is answering, and an edit without a signed-in sender cannot wait for it: stop the answer, then edit.`);
2927
+ }
2928
+ const mayStop = principalsEqual2(edit.authorPrincipal, thread.ownerPrincipal) || await askedForTurn(runtime, active, edit.authorPrincipal);
2929
+ if (!mayStop) {
2930
+ throw new AgentRequestError2("not_run_requester", `[Sixb] Agent thread '${thread.id}' runs a turn someone else asked for: only they or the thread's owner can stop it. Edit the message once it ends.`);
2931
+ }
2932
+ const request = await ensureExecutionRecord2(runtime.storage.executions, executionRecordInputFromRuntime({
2933
+ execution,
2934
+ runtimeAuthorization: runtime.runtimeAuthorization
2935
+ }));
2936
+ for (const waiting of await agents.inbox.list({ projectId, threadId: thread.id })) {
2937
+ if (waiting.replacesMessageId !== undefined && principalsEqual2(waiting.authorPrincipal, edit.authorPrincipal)) {
2938
+ await agents.inbox.remove({ projectId, threadId: thread.id, id: waiting.id });
2939
+ }
2940
+ }
2941
+ const { item } = await agents.inbox.enqueue({
2942
+ id: createAgentInboxItemId(),
2943
+ projectId,
2944
+ threadId: thread.id,
2945
+ messageId: edit.messageId,
2946
+ authorPrincipal: edit.authorPrincipal,
2947
+ mode: "queue",
2948
+ immediate: true,
2949
+ replacesMessageId: edit.target.id,
2950
+ parts: edit.parts,
2951
+ spec: {
2952
+ model: spec.model,
2953
+ ...spec.reasoning === undefined ? {} : { reasoning: spec.reasoning },
2954
+ approvalMode: spec.approvalMode
2955
+ },
2956
+ ...settings,
2957
+ executionId: request.id
2958
+ });
2959
+ await queueWaitingSteers(agents, projectId, thread.id, edit.authorPrincipal);
2960
+ await stopTurnBefore(runtime, execution, active, options.blobStorage);
2961
+ await startIfThreadIdle(runtime, execution, thread.id, options.blobStorage);
2962
+ return item;
2963
+ }
2964
+ async function rewindAgentThread(tx, agents, input) {
2965
+ const { projectId, thread, editor } = input;
2966
+ const target = await agents.messages.getById({ projectId, id: input.messageId });
2967
+ if (!target || target.threadId !== thread.id) {
2968
+ throw new AgentRequestError2("message_not_found", `[Sixb] Agent message '${input.messageId}' not found in thread '${thread.id}'.`);
2969
+ }
2970
+ assertEditableMessageAuthority(thread, target, editor);
2971
+ const tail = await listAllThreadMessagesFromSeq(agents, projectId, thread.id, target.seq);
2972
+ assertParticipantCanRewindTail(thread, tail, editor);
2973
+ const rewoundRuns = await listRewoundConversationRuns(agents, projectId, thread.id, tail);
2974
+ assertRewindsWholeTurns(target, tail, rewoundRuns);
2975
+ const restored = new Map;
2976
+ if (tx.artifacts) {
2977
+ for (const { run, later } of oldestFirst(rewoundRuns, tail)) {
2978
+ const trigger = tail.find((message) => message.id === run.triggerMessageId);
2979
+ const undone = await tx.artifacts.undoTurnWrites({
2980
+ projectId,
2981
+ turnRunId: run.id,
2982
+ laterTurnRunIds: later,
2983
+ documents: input.documents.get(run.id) ?? {},
2984
+ ...trigger?.authorPrincipal ? { requester: trigger.authorPrincipal } : {}
2985
+ });
2986
+ for (const entry of undone.restored)
2987
+ restored.set(entry.artifact.id, entry.version);
2988
+ for (const deletedId of undone.deleted)
2989
+ restored.delete(deletedId);
2990
+ }
2991
+ }
2992
+ const approvals = await agents.approvals.rewind({
2993
+ projectId,
2994
+ threadId: thread.id,
2995
+ runIds: rewoundRuns.map((run) => run.id),
2996
+ clearedMessageIds: tail.map((message) => message.id)
2997
+ });
2998
+ await agents.checkpoints.deleteAfterSeq({
2999
+ projectId,
3000
+ threadId: thread.id,
3001
+ afterSeq: target.seq - 1
3002
+ });
3003
+ await agents.messages.deleteFromSeq({ projectId, threadId: thread.id, fromSeq: target.seq });
3004
+ await queueWaitingSteers(agents, projectId, thread.id, editor);
3005
+ return { restoredVersions: [...restored.values()], cancelledApprovals: approvals.cancelled };
3006
+ }
3007
+ async function queueWaitingSteers(agents, projectId, threadId, editor) {
3008
+ const waiting = await agents.inbox.list({ projectId, threadId, includeClaimed: false });
3009
+ for (const item of waiting) {
3010
+ if (item.mode !== "steer" || item.immediate)
3011
+ continue;
3012
+ if (!principalsEqual2(item.authorPrincipal, editor))
3013
+ continue;
3014
+ try {
3015
+ await agents.inbox.update({ projectId, threadId, id: item.id, mode: "queue" });
3016
+ } catch (error) {
3017
+ if (error instanceof AgentStorageError2 && error.code === "invalid_state")
3018
+ continue;
3019
+ throw error;
3020
+ }
3021
+ }
3022
+ }
3023
+ async function rewoundTurnDocuments(runtime, blobStorage, rewoundRuns, tail) {
3024
+ const documents = new Map;
3025
+ const artifacts = runtime.storage.artifacts;
3026
+ if (!artifacts || !blobStorage)
3027
+ return documents;
3028
+ for (const { run, later } of oldestFirst(rewoundRuns, tail)) {
3029
+ documents.set(run.id, await undoneTurnDocuments({ projectId: runtime.projectId, storage: artifacts, blobStorage }, run.id, later));
3030
+ }
3031
+ return documents;
3032
+ }
3033
+ function oldestFirst(rewoundRuns, tail) {
3034
+ const seqOf = new Map(tail.map((message) => [message.id, message.seq]));
3035
+ const started = (run) => (run.startedAt ?? run.createdAt).getTime();
3036
+ const ordered = [...rewoundRuns].sort((left, right) => (seqOf.get(left.triggerMessageId) ?? 0) - (seqOf.get(right.triggerMessageId) ?? 0) || started(left) - started(right) || left.attempt - right.attempt);
3037
+ return ordered.map((run, index) => ({
3038
+ run,
3039
+ later: ordered.slice(index + 1).map((each) => each.id)
3040
+ }));
3041
+ }
3042
+ async function announceAgentThreadRewind(runtime, rewind, superseded) {
3043
+ await announceArtifactUpdates(runtime.events, rewind?.restoredVersions ?? []);
3044
+ await announceAgentApprovals2(runtime.broker, [
3045
+ ...rewind?.cancelledApprovals ?? [],
3046
+ ...superseded
3047
+ ]);
3048
+ }
3049
+ function assertEditableMessageAuthority(_thread, target, principal) {
3050
+ if (!isEditableAgentMessage2(target)) {
3051
+ throw new AgentRequestError2("message_not_editable", `[Sixb] Only user-authored messages can be edited.`);
3052
+ }
3053
+ if (principal.type === "user" && (!target.authorPrincipal || !principalsEqual2(target.authorPrincipal, principal))) {
3054
+ throw new AgentRequestError2("not_message_author", `[Sixb] Only the author of message '${target.id}' can edit it.`);
3055
+ }
3056
+ }
3057
+ function assertParticipantCanRewindTail(thread, tail, principal) {
3058
+ if (principal.type !== "user" || principalsEqual2(principal, thread.ownerPrincipal))
3059
+ return;
3060
+ const erasesOthers = tail.some((message) => message.role === "user" && countsAsThreadMessage2(message) && message.authorPrincipal !== undefined && !principalsEqual2(message.authorPrincipal, principal));
3061
+ if (erasesOthers) {
3062
+ throw new AgentRequestError2("not_thread_owner", "[Sixb] Only the thread's owner can rewind past another person's messages.");
3063
+ }
3064
+ }
3065
+ function assertRewindsWholeTurns(target, tail, rewoundRuns) {
3066
+ const removed = new Set(tail.map((message) => message.id));
3067
+ const cut = rewoundRuns.find((run) => !removed.has(run.triggerMessageId));
3068
+ if (!cut)
3069
+ return;
3070
+ throw new AgentRequestError2("message_not_editable", `[Sixb] Agent message '${target.id}' came in while the Agent was answering message '${cut.triggerMessageId}': edit that message instead.`);
3071
+ }
3072
+ async function listAllThreadMessagesFromSeq(agents, projectId, threadId, fromSeq) {
3073
+ const messages = [];
3074
+ const afterSeq = fromSeq - 1;
3075
+ for (;; ) {
3076
+ const page = await agents.messages.list({
3077
+ projectId,
3078
+ threadId,
3079
+ afterSeq,
3080
+ order: "asc",
3081
+ limit: 200,
3082
+ offset: messages.length
3083
+ });
3084
+ messages.push(...page.messages);
3085
+ if (!page.hasMore || page.messages.length === 0)
3086
+ return messages;
3087
+ }
3088
+ }
3089
+ async function listRewoundConversationRuns(agents, projectId, threadId, tail) {
3090
+ const removedMessageIds = new Set(tail.map((message) => message.id));
3091
+ const removedRunIds = new Set(tail.flatMap((message) => message.runId === null ? [] : [message.runId]));
3092
+ const found = [];
3093
+ for (let offset = 0;; ) {
3094
+ const page = await agents.runs.list({
3095
+ projectId,
3096
+ threadId,
3097
+ kinds: ["conversation"],
3098
+ order: "desc",
3099
+ limit: 100,
3100
+ offset
3101
+ });
3102
+ for (const run of page.runs) {
3103
+ if (run.kind === "conversation" && (removedMessageIds.has(run.triggerMessageId) || removedRunIds.has(run.id))) {
3104
+ found.push(run);
3105
+ }
3106
+ }
3107
+ offset += page.runs.length;
3108
+ if (!page.hasMore || page.runs.length === 0)
3109
+ return found;
3110
+ }
3111
+ }
3112
+ async function latestRetainedConversationRun(agents, projectId, threadId, tail) {
3113
+ const notRetained = new Set(tail.map((message) => message.id));
3114
+ for (let offset = 0;; ) {
3115
+ const page = await agents.runs.list({
3116
+ projectId,
3117
+ threadId,
3118
+ kinds: ["conversation"],
3119
+ order: "desc",
3120
+ limit: 50,
3121
+ offset
3122
+ });
3123
+ for (const run of page.runs) {
3124
+ if (run.kind !== "conversation" || notRetained.has(run.triggerMessageId))
3125
+ continue;
3126
+ if (await agents.messages.getById({ projectId, id: run.triggerMessageId }))
3127
+ return run;
3128
+ notRetained.add(run.triggerMessageId);
3129
+ }
3130
+ offset += page.runs.length;
3131
+ if (!page.hasMore || page.runs.length === 0)
3132
+ return;
3133
+ }
3134
+ }
3135
+ function isRetryableAgentRun2(run) {
3136
+ return run.status === "failed" || run.status === "cancelled" && run.finishReason === "interrupted";
3137
+ }
3138
+ async function retryAgentRun2(runtime, execution, models, failedRun, blobStorage) {
3139
+ const authority = resolveExecutionScopeAuthorization(runtime.projectId, {
3140
+ execution,
3141
+ authorization: runtime.runtimeAuthorization
3142
+ });
3143
+ assertAuthorized2(runtime, { kind: "agent.run" });
3144
+ assertRequestAuthorityCanRunAgent(runtime);
3145
+ if (!isRetryableAgentRun2(failedRun)) {
3146
+ throw new AgentRequestError2("run_not_retryable", `[Sixb] Only failed or interrupted Agent runs can be retried.`);
3147
+ }
3148
+ const agents = requireAgentStorage(runtime);
3149
+ const thread = await agents.threads.getById({
3150
+ projectId: runtime.projectId,
3151
+ id: failedRun.threadId
3152
+ });
3153
+ if (!thread) {
3154
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${failedRun.threadId}' was not found.`);
3155
+ }
3156
+ assertSandboxExecutionAvailable(thread);
3157
+ if (authority.type === "principal" && thread.runsOn === "computer" && !principalsEqual2(authority.context.principal, thread.ownerPrincipal)) {
3158
+ throw new AgentRequestError2("not_thread_owner", `[Sixb] Agent thread '${thread.id}' runs on its owner's computer, as them: only its owner can retry a turn in it.`);
3159
+ }
3160
+ const runId = createAgentRunId2();
3161
+ const durableExecution = await prepareDurableAgentExecution(runtime, execution, runId);
3162
+ await assertAiLimitPreflight(runtime, durableExecution);
3163
+ const artifacts = runtime.storage.artifacts;
3164
+ const documents = artifacts && blobStorage ? await undoneTurnDocuments({ projectId: runtime.projectId, storage: artifacts, blobStorage }, failedRun.id) : {};
3165
+ const { run, undone } = await runtime.storage.transaction(async (tx) => {
3166
+ const agents = tx.agents;
3167
+ if (!agents) {
3168
+ throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
3169
+ }
3170
+ await agents.messages.deleteByRunId({
3171
+ projectId: runtime.projectId,
3172
+ threadId: failedRun.threadId,
3173
+ runId: failedRun.id
3174
+ });
3175
+ const trigger = await agents.messages.getById({
3176
+ projectId: runtime.projectId,
3177
+ id: failedRun.triggerMessageId
3178
+ });
3179
+ const requester = trigger?.authorPrincipal;
3180
+ const undone = await tx.artifacts?.undoTurnWrites({
3181
+ projectId: runtime.projectId,
3182
+ turnRunId: failedRun.id,
3183
+ documents,
3184
+ ...requester ? { requester } : {}
3185
+ });
3186
+ await tx.executions.create(durableExecution);
3187
+ const run = await agents.runs.create({
3188
+ id: runId,
3189
+ projectId: runtime.projectId,
3190
+ executionId: durableExecution.id,
3191
+ threadId: failedRun.threadId,
3192
+ triggerMessageId: failedRun.triggerMessageId,
3193
+ spec: inPlace(thread, failedRun.spec ?? await resolveConversationRunSpec({ models, selection: {}, settings: {} }))
3194
+ });
3195
+ return { run, undone };
3196
+ });
3197
+ await announceArtifactUpdates(runtime.events, (undone?.restored ?? []).map(({ version }) => version));
3198
+ await publishRunActivity(runtime, run);
3199
+ const jobId = await dispatchAgentRun(runtime, agents, runId);
3200
+ return { run, ...jobId ? { jobId } : {}, createdThread: false };
3201
+ }
3202
+ var AGENT_MESSAGE_DELIVERIES2 = ["auto", "steer", "queue", "send_now"];
3203
+ async function sendAgentMessage2(runtime, execution, models, input, blobStorage) {
3204
+ const delivery = input.delivery ?? "auto";
3205
+ const agents = requireAgentStorage(runtime);
3206
+ const projectId = runtime.projectId;
3207
+ const thread = await agents.threads.getById({ projectId, id: input.threadId });
3208
+ if (!thread) {
3209
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' was not found.`);
3210
+ }
3211
+ assertConversationThread2(thread);
3212
+ const startTurn = async () => {
3213
+ const { delivery: _delivery, ...request } = input;
3214
+ const result = await requestAgentRun2(runtime, execution, models, request);
3215
+ return { kind: "turn", run: result.run, createdThread: result.createdThread };
3216
+ };
3217
+ const activeId = thread.activeRunId;
3218
+ if (delivery === "auto" || activeId === null)
3219
+ return startTurn();
3220
+ const active = await agents.runs.getById({ projectId, id: activeId });
3221
+ const requester = active ? (await runtime.storage.executions.getById({ projectId, id: active.executionId }))?.requestedBy : undefined;
3222
+ const principal = messageAuthor(runtime, execution);
3223
+ const requesterOfTurn = requester !== undefined && principalsEqual2(requester, principal);
3224
+ if (!requesterOfTurn && delivery !== "queue") {
3225
+ throw new AgentRequestError2("not_run_requester", `[Sixb] Agent thread '${thread.id}' runs a turn someone else asked for: only they can steer it or send now. Queue the message for your own turn.`);
3226
+ }
3227
+ const settings = requesterSettings(input);
3228
+ const contextParts = await resolveAgentContextParts2(runtime, input.context);
3229
+ const trigger = deliveredParts(input, delivery);
3230
+ const spec = {
3231
+ ...input.model === undefined ? {} : { model: input.model },
3232
+ ...input.reasoning === undefined ? {} : { reasoning: input.reasoning },
3233
+ ...input.approvalMode === undefined ? {} : { approvalMode: input.approvalMode }
3234
+ };
3235
+ assertRequestAuthorityCanRunAgent(runtime);
3236
+ const request = await ensureExecutionRecord2(runtime.storage.executions, executionRecordInputFromRuntime({
3237
+ execution,
3238
+ runtimeAuthorization: runtime.runtimeAuthorization
3239
+ }));
3240
+ const { item } = await agents.inbox.enqueue({
3241
+ id: createAgentInboxItemId(),
3242
+ projectId,
3243
+ threadId: thread.id,
3244
+ messageId: input.messageId ?? createAgentMessageId2(),
3245
+ authorPrincipal: principal,
3246
+ mode: delivery === "steer" ? "steer" : "queue",
3247
+ parts: [...contextParts, ...trigger],
3248
+ ...Object.keys(spec).length === 0 ? {} : { spec },
3249
+ ...settings,
3250
+ ...delivery === "send_now" ? { immediate: true } : {},
3251
+ executionId: request.id
3252
+ });
3253
+ if (delivery === "send_now") {
3254
+ await stopTurnBefore(runtime, execution, active, blobStorage);
3255
+ }
3256
+ await startIfThreadIdle(runtime, execution, thread.id, blobStorage);
3257
+ return { kind: "inbox", item };
3258
+ }
3259
+ async function promoteAgentInboxItem2(runtime, execution, input, blobStorage) {
3260
+ const agents = requireAgentStorage(runtime);
3261
+ const projectId = runtime.projectId;
3262
+ const thread = await agents.threads.getById({ projectId, id: input.threadId });
3263
+ if (!thread) {
3264
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' was not found.`);
3265
+ }
3266
+ assertConversationThread2(thread);
3267
+ const item = await agents.inbox.getById({ projectId, id: input.itemId });
3268
+ if (!item || item.threadId !== thread.id) {
3269
+ throw new AgentRequestError2("invalid_message", `[Sixb] Agent inbox item '${input.itemId}' is not waiting in thread '${thread.id}'.`);
3270
+ }
3271
+ const principal = messageAuthor(runtime, execution);
3272
+ if (!principalsEqual2(item.authorPrincipal, principal)) {
3273
+ throw new AgentRequestError2("not_run_requester", `[Sixb] Agent inbox item '${item.id}' was sent by someone else: only they can change it.`);
3274
+ }
3275
+ const active = thread.activeRunId ? await agents.runs.getById({ projectId, id: thread.activeRunId }) : null;
3276
+ const delivery = input.delivery ?? item.mode;
3277
+ const turn = active?.kind === "conversation" ? active : null;
3278
+ if ((delivery === "steer" || input.immediate === true) && turn) {
3279
+ if (!await askedForTurn(runtime, turn, principal)) {
3280
+ throw new AgentRequestError2("not_run_requester", `[Sixb] Agent thread '${thread.id}' runs a turn someone else asked for: only they can steer it or send now. Keep the message queued for your own turn.`);
3281
+ }
3282
+ }
3283
+ const spec = {
3284
+ ...input.model === undefined ? {} : { model: input.model },
3285
+ ...input.reasoning === undefined ? {} : { reasoning: input.reasoning },
3286
+ ...input.approvalMode === undefined ? {} : { approvalMode: input.approvalMode }
3287
+ };
3288
+ const updated = await agents.inbox.update({
3289
+ projectId,
3290
+ threadId: thread.id,
3291
+ id: item.id,
3292
+ ...input.delivery === undefined ? {} : { mode: input.delivery },
3293
+ ...input.text === undefined ? {} : {
3294
+ parts: [
3295
+ { type: "text", text: input.text },
3296
+ ...item.parts.filter((part) => part.type !== "text")
3297
+ ]
3298
+ },
3299
+ ...Object.keys(spec).length === 0 ? {} : { spec: { ...item.spec, ...spec } },
3300
+ ...input.immediate === true ? { immediate: true } : {}
3301
+ });
3302
+ if (!updated) {
3303
+ throw new AgentRequestError2("invalid_message", `[Sixb] Agent inbox item '${item.id}' is no longer waiting in thread '${thread.id}'.`);
3304
+ }
3305
+ if (input.immediate === true && turn) {
3306
+ await stopTurnBefore(runtime, execution, turn, blobStorage);
3307
+ }
3308
+ await startIfThreadIdle(runtime, execution, thread.id, blobStorage);
3309
+ return updated;
3310
+ }
3311
+ async function withdrawAgentInboxItem2(runtime, execution, input) {
3312
+ const agents = requireAgentStorage(runtime);
3313
+ const projectId = runtime.projectId;
3314
+ const thread = await agents.threads.getById({ projectId, id: input.threadId });
3315
+ if (!thread) {
3316
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' was not found.`);
3317
+ }
3318
+ assertConversationThread2(thread);
3319
+ const item = await agents.inbox.getById({ projectId, id: input.itemId });
3320
+ if (!item || item.threadId !== thread.id) {
3321
+ throw new AgentRequestError2("invalid_message", `[Sixb] Agent inbox item '${input.itemId}' is not waiting in thread '${thread.id}'.`);
3322
+ }
3323
+ if (!principalsEqual2(item.authorPrincipal, messageAuthor(runtime, execution))) {
3324
+ throw new AgentRequestError2("not_run_requester", `[Sixb] Agent inbox item '${item.id}' was sent by someone else: only they can withdraw it.`);
3325
+ }
3326
+ const removed = await agents.inbox.remove({ projectId, threadId: thread.id, id: item.id });
3327
+ if (!removed) {
3328
+ throw new AgentRequestError2("invalid_message", `[Sixb] Agent inbox item '${item.id}' is no longer waiting in thread '${thread.id}': a turn read it.`);
3329
+ }
3330
+ }
3331
+ function messageAuthor(runtime, execution) {
3332
+ const authority = resolveExecutionScopeAuthorization(runtime.projectId, {
3333
+ execution,
3334
+ authorization: runtime.runtimeAuthorization
3335
+ });
3336
+ return authority.type === "principal" ? authority.context.principal : SYSTEM_PRINCIPAL2;
3337
+ }
3338
+ async function askedForTurn(runtime, run, principal) {
3339
+ const requester = (await runtime.storage.executions.getById({ projectId: runtime.projectId, id: run.executionId }))?.requestedBy;
3340
+ return requester !== undefined && principalsEqual2(requester, principal);
3341
+ }
3342
+ async function stopTurnBefore(runtime, execution, active, blobStorage) {
3343
+ if (active.status === "running") {
3344
+ await cancelAgentRun(runtime, active);
3345
+ return;
3346
+ }
3347
+ await cancelAgentRun(runtime, active).catch(() => {
3348
+ return;
3349
+ });
3350
+ await startQueuedAgentTurnFromInbox2(runtime, execution, active, { onlyImmediate: true }, blobStorage);
3351
+ }
3352
+ async function startIfThreadIdle(runtime, execution, threadId, blobStorage) {
3353
+ const agents = requireAgentStorage(runtime);
3354
+ const projectId = runtime.projectId;
3355
+ try {
3356
+ const thread = await agents.threads.getById({ projectId, id: threadId });
3357
+ if (!thread || thread.activeRunId !== null)
3358
+ return;
3359
+ const {
3360
+ runs: [last]
3361
+ } = await agents.runs.list({
3362
+ projectId,
3363
+ threadId,
3364
+ kinds: ["conversation"],
3365
+ order: "desc",
3366
+ limit: 1
3367
+ });
3368
+ if (last?.kind !== "conversation")
3369
+ return;
3370
+ const onlyImmediate = isAwaitingApprovalRun2(last) || !await turnAnsweredEveryMessage(agents, last);
3371
+ await startQueuedAgentTurnFromInbox2(runtime, execution, last, { onlyImmediate }, blobStorage);
3372
+ } catch (error) {
3373
+ console.error(`[Sixb] Could not start what waits in Agent thread '${threadId}'; the repair pass retries.`, error);
3374
+ }
3375
+ }
3376
+ function deliveredParts(input, delivery) {
3377
+ if (delivery === "steer" && (input.attachments?.length ?? 0) > 0) {
3378
+ throw new AgentRequestError2("invalid_attachment", "[Sixb] A message that steers a running turn carries no file: queue it for the next turn instead.");
3379
+ }
3380
+ assertAttachments(input.attachments);
3381
+ const text = typeof input.text === "string" && input.text.trim().length > 0 ? [{ type: "text", text: input.text }] : [];
3382
+ const files = (input.attachments ?? []).map((fileRef) => ({ type: "file", fileRef }));
3383
+ if (text.length === 0 && files.length === 0) {
3384
+ throw new AgentRequestError2("invalid_message", "[Sixb] An Agent message needs text or attachments.");
3385
+ }
3386
+ return [...text, ...files];
3387
+ }
3388
+ async function startQueuedAgentTurnFromInbox2(runtime, execution, finishedRun, input, blobStorage) {
3389
+ resolveExecutionScopeAuthorization(runtime.projectId, {
3390
+ execution,
3391
+ authorization: runtime.runtimeAuthorization
3392
+ });
3393
+ assertAuthorized2(runtime, { kind: "agent.run" });
3394
+ assertRequestAuthorityCanRunAgent(runtime);
3395
+ const agents = requireAgentStorage(runtime);
3396
+ const projectId = runtime.projectId;
3397
+ const kept = finishedRun.spec;
3398
+ if (!kept)
3399
+ return { status: "closed" };
3400
+ const thread = await agents.threads.getById({ projectId, id: finishedRun.threadId });
3401
+ if (!thread)
3402
+ return { status: "closed" };
3403
+ assertSandboxExecutionAvailable(thread);
3404
+ const principal = execution.requestedBy;
3405
+ if (!principal)
3406
+ return { status: "closed" };
3407
+ if (thread.runsOn === "computer" && !principalsEqual2(principal, thread.ownerPrincipal)) {
3408
+ return { status: "closed" };
3409
+ }
3410
+ const runId = createAgentRunId2();
3411
+ const durableExecution = await prepareResumedExecution(runtime, execution, runId);
3412
+ await assertAiLimitPreflight(runtime, durableExecution);
3413
+ const documents = await waitingEditDocuments(runtime, blobStorage, thread, principal);
3414
+ let started;
3415
+ let rewind;
3416
+ let dropped;
3417
+ let superseded = [];
3418
+ try {
3419
+ started = await runtime.storage.transaction(async (tx) => {
3420
+ const agents = tx.agents;
3421
+ if (!agents) {
3422
+ throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
3423
+ }
3424
+ const item = await agents.inbox.takeNextQueued({
3425
+ projectId,
3426
+ threadId: thread.id,
3427
+ onlyImmediate: input.onlyImmediate,
3428
+ authorPrincipal: principal
3429
+ });
3430
+ if (!item)
3431
+ return null;
3432
+ if (item.replacesMessageId !== undefined) {
3433
+ try {
3434
+ rewind = await rewindAgentThread(tx, agents, {
3435
+ projectId,
3436
+ thread,
3437
+ messageId: item.replacesMessageId,
3438
+ editor: item.authorPrincipal,
3439
+ documents
3440
+ });
3441
+ } catch (error) {
3442
+ if (!(error instanceof AgentRequestError2))
3443
+ throw error;
3444
+ dropped = { item, reason: error };
3445
+ return null;
3446
+ }
3447
+ }
3448
+ const inherited = await resolveAgentApprovalMode(agents, {
3449
+ projectId,
3450
+ principal,
3451
+ threadId: thread.id
3452
+ });
3453
+ const approvalMode = item.spec?.approvalMode ?? inherited.approvalMode;
3454
+ const spec = queuedConversationRunSpec(thread, kept, item, approvalMode);
3455
+ await tx.executions.create(durableExecution);
3456
+ const reported = await reportAgentApprovals(agents, {
2712
3457
  projectId,
2713
3458
  threadId: thread.id,
2714
- messageId: triggerMessageId
3459
+ messageId: item.messageId
2715
3460
  });
2716
3461
  superseded = reported.superseded;
2717
3462
  await agents.messages.append({
2718
- id: triggerMessageId,
3463
+ id: item.messageId,
2719
3464
  projectId,
2720
3465
  threadId: thread.id,
2721
3466
  runId: null,
2722
3467
  role: "user",
2723
- parts: [
2724
- ...reported.parts,
2725
- ...contextParts,
2726
- ...trigger,
2727
- ...(input.attachments ?? []).map((fileRef) => ({ type: "file", fileRef }))
2728
- ],
2729
- authorPrincipal: principal
3468
+ parts: [...reported.parts, ...item.parts],
3469
+ authorPrincipal: item.authorPrincipal,
3470
+ createdAt: item.createdAt,
3471
+ ...item.timeZone === undefined && item.locale === undefined ? {} : {
3472
+ metadata: {
3473
+ ...item.timeZone === undefined ? {} : { timeZone: item.timeZone },
3474
+ ...item.locale === undefined ? {} : { locale: item.locale }
3475
+ }
3476
+ }
2730
3477
  });
2731
3478
  return agents.runs.create({
2732
3479
  id: runId,
2733
3480
  projectId,
2734
3481
  executionId: durableExecution.id,
2735
3482
  threadId: thread.id,
2736
- triggerMessageId,
3483
+ triggerMessageId: item.messageId,
2737
3484
  spec
2738
3485
  });
2739
3486
  });
2740
3487
  } catch (error) {
2741
3488
  if (error instanceof AgentStorageError2 && error.code === "active_run_exists") {
2742
- throw new AgentRequestError2("active_run_exists", error.message);
3489
+ return { status: "closed" };
2743
3490
  }
2744
3491
  throw error;
2745
3492
  }
2746
- await announceAgentApprovals2(runtime.broker, superseded);
2747
- await publishRunActivity(runtime, run);
2748
- const jobId = await dispatchAgentRun(runtime, agents, runId);
2749
- return {
2750
- run,
2751
- ...jobId ? { jobId } : {},
2752
- createdThread
2753
- };
2754
- }
2755
- function isRetryableAgentRun2(run) {
2756
- return run.status === "failed" || run.status === "cancelled" && run.finishReason === "interrupted";
2757
- }
2758
- async function retryAgentRun2(runtime, execution, models, failedRun, blobStorage) {
2759
- resolveExecutionScopeAuthorization(runtime.projectId, {
2760
- execution,
2761
- authorization: runtime.runtimeAuthorization
2762
- });
2763
- assertAuthorized2(runtime, { kind: "agent.run" });
2764
- assertRequestAuthorityCanRunAgent(runtime);
2765
- if (!isRetryableAgentRun2(failedRun)) {
2766
- throw new AgentRequestError2("run_not_retryable", `[Sixb] Only failed or interrupted Agent runs can be retried.`);
3493
+ if (dropped) {
3494
+ console.warn(`[Sixb] Dropped the edit of Agent message '${dropped.item.replacesMessageId}' waiting in thread '${thread.id}': it no longer applies.`, dropped.reason);
2767
3495
  }
3496
+ if (!started)
3497
+ return { status: "nothing" };
3498
+ await announceAgentThreadRewind(runtime, rewind, superseded);
3499
+ await publishRunActivity(runtime, started);
3500
+ await dispatchAgentRun(runtime, agents, runId);
3501
+ return { status: "started", run: started };
3502
+ }
3503
+ async function waitingEditDocuments(runtime, blobStorage, thread, principal) {
3504
+ if (!runtime.storage.artifacts || !blobStorage)
3505
+ return new Map;
2768
3506
  const agents = requireAgentStorage(runtime);
2769
- const thread = await agents.threads.getById({
2770
- projectId: runtime.projectId,
2771
- id: failedRun.threadId
2772
- });
2773
- if (!thread) {
2774
- throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${failedRun.threadId}' was not found.`);
2775
- }
2776
- assertSandboxExecutionAvailable(thread);
2777
- const runId = createAgentRunId2();
2778
- const durableExecution = await prepareDurableAgentExecution(runtime, execution, runId);
2779
- await assertAiLimitPreflight(runtime, durableExecution);
2780
- const artifacts = runtime.storage.artifacts;
2781
- const documents = artifacts && blobStorage ? await undoneTurnDocuments({ projectId: runtime.projectId, storage: artifacts, blobStorage }, failedRun.id) : {};
2782
- const { run, undone } = await runtime.storage.transaction(async (tx) => {
2783
- const agents = tx.agents;
2784
- if (!agents) {
2785
- throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
2786
- }
2787
- await agents.messages.deleteByRunId({
2788
- projectId: runtime.projectId,
2789
- threadId: failedRun.threadId,
2790
- runId: failedRun.id
2791
- });
2792
- const trigger = await agents.messages.getById({
2793
- projectId: runtime.projectId,
2794
- id: failedRun.triggerMessageId
2795
- });
2796
- const requester = trigger?.authorPrincipal;
2797
- const undone = await tx.artifacts?.undoTurnWrites({
2798
- projectId: runtime.projectId,
2799
- turnRunId: failedRun.id,
2800
- documents,
2801
- ...requester ? { requester } : {}
2802
- });
2803
- await tx.executions.create(durableExecution);
2804
- const run = await agents.runs.create({
2805
- id: runId,
2806
- projectId: runtime.projectId,
2807
- executionId: durableExecution.id,
2808
- threadId: failedRun.threadId,
2809
- triggerMessageId: failedRun.triggerMessageId,
2810
- spec: inPlace(thread, failedRun.spec ?? await resolveConversationRunSpec({ models, selection: {}, settings: {} }))
2811
- });
2812
- return { run, undone };
3507
+ const projectId = runtime.projectId;
3508
+ const waiting = await agents.inbox.list({ projectId, threadId: thread.id, includeClaimed: false });
3509
+ const next = waiting.filter((item) => item.immediate && principalsEqual2(item.authorPrincipal, principal)).sort((left, right) => left.seq - right.seq)[0];
3510
+ if (next?.replacesMessageId === undefined)
3511
+ return new Map;
3512
+ const target = await agents.messages.getById({ projectId, id: next.replacesMessageId });
3513
+ if (!target || target.threadId !== thread.id)
3514
+ return new Map;
3515
+ const tail = await listAllThreadMessagesFromSeq(agents, projectId, thread.id, target.seq);
3516
+ const rewoundRuns = await listRewoundConversationRuns(agents, projectId, thread.id, tail);
3517
+ return rewoundTurnDocuments(runtime, blobStorage, rewoundRuns, tail);
3518
+ }
3519
+ function queuedConversationRunSpec(thread, kept, item, approvalMode) {
3520
+ const model = item.spec?.model ?? kept.model;
3521
+ const reasoning = item.spec?.reasoning ?? (item.replacesMessageId === undefined ? kept.reasoning : undefined);
3522
+ const timeZone = item.timeZone ?? kept.timeZone;
3523
+ const locale = item.locale ?? kept.locale;
3524
+ return inPlace(thread, {
3525
+ model,
3526
+ ...reasoning === undefined ? {} : { reasoning },
3527
+ ...timeZone === undefined ? {} : { timeZone },
3528
+ ...locale === undefined ? {} : { locale },
3529
+ approvalMode
2813
3530
  });
2814
- await announceArtifactUpdates(runtime.events, (undone?.restored ?? []).map(({ version }) => version));
2815
- await publishRunActivity(runtime, run);
2816
- const jobId = await dispatchAgentRun(runtime, agents, runId);
2817
- return { run, ...jobId ? { jobId } : {}, createdThread: false };
2818
3531
  }
2819
3532
  async function resumeAgentTurn(runtime, execution, models, pausedRun, input) {
2820
3533
  const authority = resolveExecutionScopeAuthorization(runtime.projectId, {
@@ -2916,8 +3629,8 @@ async function prepareResumedExecution(runtime, execution, runId) {
2916
3629
  return createInheritedAgentExecutionRecord2({ id: `exec_${randomUUID5()}`, parent, runId });
2917
3630
  }
2918
3631
  function inPlace(thread, spec) {
2919
- const { runsOn: _runsOn, ...rest } = spec;
2920
- return Object.freeze(thread.runsOn === undefined ? rest : { ...rest, runsOn: thread.runsOn });
3632
+ const { runsOn: _runsOn, computer: _computer, ...rest } = spec;
3633
+ return Object.freeze({ ...rest, ...turnPlace2(thread.runsOn, thread.computer) });
2921
3634
  }
2922
3635
  async function resumedConversationRunSpec(models, paused, approvalMode) {
2923
3636
  const kept = paused && models?.getByRef(paused.model) ? paused : await resolveConversationRunSpec({
@@ -2953,9 +3666,8 @@ function routedTurn(router, selection, input) {
2953
3666
  return;
2954
3667
  return { router, text: input.text ?? "" };
2955
3668
  }
2956
- async function routedConversationRunSpec(agents, input) {
2957
- const previous = input.threadId ? await latestConversationRun(agents, input.projectId, input.threadId) : undefined;
2958
- const choice = await input.router.choose(input.text, previous);
3669
+ async function routedConversationRunSpec(input) {
3670
+ const choice = await input.router.choose(input.text, input.previous, input.place);
2959
3671
  return resolveConversationRunSpec({
2960
3672
  models: input.language,
2961
3673
  selection: { model: choice.model },
@@ -2995,18 +3707,21 @@ function assertAttachments(attachments) {
2995
3707
  }
2996
3708
  }
2997
3709
  function assertThreadAcceptsRun(thread, principal) {
3710
+ assertThreadAcceptsMessages(thread, principal);
3711
+ if (thread.activeRunId !== null) {
3712
+ throw new AgentRequestError2("active_run_exists", `[Sixb] Agent thread '${thread.id}' already has an active run '${thread.activeRunId}'.`);
3713
+ }
3714
+ }
3715
+ function assertThreadAcceptsMessages(thread, principal) {
2998
3716
  assertConversationThread2(thread);
2999
3717
  assertSandboxExecutionAvailable(thread);
3000
3718
  if (thread.runsOn === "computer" && !principalsEqual2(principal, thread.ownerPrincipal)) {
3001
3719
  throw new AgentRequestError2("not_thread_owner", `[Sixb] Agent thread '${thread.id}' runs on its owner's computer, as them: only its owner can message it. Shared with you, it is yours to read and follow.`);
3002
3720
  }
3003
- if (thread.activeRunId !== null) {
3004
- throw new AgentRequestError2("active_run_exists", `[Sixb] Agent thread '${thread.id}' already has an active run '${thread.activeRunId}'.`);
3005
- }
3006
3721
  }
3007
3722
  function assertSandboxExecutionAvailable(thread) {
3008
- if (thread.sandboxState && !["new", "ready"].includes(thread.sandboxState.status)) {
3009
- throw new AgentRequestError2("sandbox_execution_unavailable", "[Sixb] Sandbox recovery is required before another run. Reload the thread and explicitly recreate it to start fresh.");
3723
+ if (thread.runsOn !== "computer" && thread.sandboxState && !["new", "ready"].includes(thread.sandboxState.status)) {
3724
+ throw new AgentRequestError2("sandbox_execution_unavailable", "[Sixb] Sandbox recovery is required before another run. Reload the thread, then resume its previous sandbox or recreate it to start fresh.");
3010
3725
  }
3011
3726
  }
3012
3727
  async function assertAiLimitPreflight(runtime, execution) {
@@ -3055,7 +3770,7 @@ async function resolveConversationRunSpec(input) {
3055
3770
  });
3056
3771
  }
3057
3772
  function requesterSettings(input) {
3058
- const timeZone = requestedSetting("timeZone", input.timeZone, canonicalTimeZone, "an IANA time zone");
3773
+ const timeZone = requestedSetting("timeZone", input.timeZone, canonicalTimeZone2, "an IANA time zone");
3059
3774
  const locale = requestedSetting("locale", input.locale, canonicalLocale, "a BCP 47 language tag");
3060
3775
  return {
3061
3776
  ...timeZone === undefined ? {} : { timeZone },
@@ -3398,6 +4113,20 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3398
4113
  return refused;
3399
4114
  }
3400
4115
  };
4116
+ const startQueuedTurn = async (runId, options) => {
4117
+ const agents = requireAgents();
4118
+ const run = await agents.runs.getById({ projectId: runtime.projectId, id: runId });
4119
+ if (run?.kind !== "conversation")
4120
+ return { status: "closed" };
4121
+ try {
4122
+ if (!await rule.read(run.threadId))
4123
+ return { status: "closed" };
4124
+ return await startQueuedAgentTurnFromInbox2(runtime, execution, run, options, blobStorage);
4125
+ } catch (error) {
4126
+ console.error(`[Sixb] Could not start a queued message of Agent run '${run.id}'.`, error);
4127
+ return { status: "closed" };
4128
+ }
4129
+ };
3401
4130
  const preferences = {
3402
4131
  get: async () => {
3403
4132
  const { approvalMode, approvalModeSource } = await defaultAgentApprovalMode(requireAgents(), {
@@ -3420,16 +4149,72 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3420
4149
  return preferences.get();
3421
4150
  }
3422
4151
  };
3423
- const ownedComputerThread = async (threadId) => {
4152
+ const readViewer = () => principal.type === "user" ? principal : undefined;
4153
+ const lastRunView = async (run) => {
4154
+ const view = {
4155
+ id: run.id,
4156
+ status: run.status,
4157
+ ...run.finishReason === undefined ? {} : { finishReason: run.finishReason },
4158
+ ...run.error === undefined ? {} : { errorCode: run.error.code },
4159
+ ...run.completedAt === undefined ? {} : { completedAt: run.completedAt }
4160
+ };
4161
+ if (!agentRunEndedShort(run))
4162
+ return view;
4163
+ const execution = await runtime.storage.executions.getById({
4164
+ projectId: runtime.projectId,
4165
+ id: run.executionId
4166
+ });
4167
+ if (!execution?.requestedBy)
4168
+ return view;
4169
+ return { ...view, requestedBy: structuredClone(execution.requestedBy) };
4170
+ };
4171
+ const withThreadState = async (threads, viewer) => {
4172
+ const agents = runtime.storage.agents;
4173
+ if (!viewer || !agents || threads.length === 0)
4174
+ return threads;
4175
+ const threadIds = threads.map((thread) => thread.id);
4176
+ const [reads, runs] = await Promise.all([
4177
+ agents.reads.list({ projectId: runtime.projectId, threadIds, principal: viewer }),
4178
+ agents.runs.latestByThread({ projectId: runtime.projectId, threadIds })
4179
+ ]);
4180
+ const lastRuns = await Promise.all(runs.map(lastRunView));
4181
+ const readOf = new Map(reads.map((read) => [read.threadId, read]));
4182
+ const runOf = new Map(runs.map((run, index) => [run.threadId, lastRuns[index]]));
4183
+ return threads.map((thread) => {
4184
+ const read = readOf.get(thread.id);
4185
+ const lastRun = runOf.get(thread.id);
4186
+ return {
4187
+ ...thread,
4188
+ ...read === undefined ? {} : { read },
4189
+ ...lastRun === undefined ? {} : { lastRun }
4190
+ };
4191
+ });
4192
+ };
4193
+ const recoverSandbox = async (threadId, choice, transition) => {
4194
+ const readable = await rule.read(threadId);
4195
+ if (!readable)
4196
+ throw new AgentRequestError2("thread_not_found", "[Sixb] Agent thread not found.");
4197
+ assertConversationThread2(readable.thread);
4198
+ if (readable.access !== "owner") {
4199
+ throw new AgentRequestError2("not_thread_owner", `[Sixb] Only the owner of Agent thread '${threadId}' can ${choice} its sandbox.`);
4200
+ }
4201
+ const storage = runtime.storage.agents;
4202
+ if (!storage) {
4203
+ throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
4204
+ }
4205
+ const thread = readable.thread;
4206
+ const sandboxState = await transition(storage);
4207
+ const [view] = await withThreadState(await agentThreadViews(runtime, [{ ...thread, sandboxState }]), readViewer());
4208
+ return view ?? thread;
4209
+ };
4210
+ const ownedMovableThread = async (threadId) => {
3424
4211
  const readable = await rule.read(threadId);
3425
4212
  if (!readable)
3426
4213
  throw new AgentRequestError2("thread_not_found", "[Sixb] Agent thread not found.");
4214
+ assertConversationThread2(readable.thread);
3427
4215
  if (readable.access !== "owner") {
3428
4216
  throw new AgentRequestError2("not_thread_owner", `[Sixb] Only the owner of Agent thread '${threadId}' moves it.`);
3429
4217
  }
3430
- if (readable.thread.runsOn !== "computer") {
3431
- throw new AgentRequestError2("invalid_message", `[Sixb] Agent thread '${threadId}' runs in the cloud, on no computer.`);
3432
- }
3433
4218
  return readable.thread;
3434
4219
  };
3435
4220
  const moveThread = (thread, moves, move) => runtime.storage.transaction(async (tx) => {
@@ -3438,7 +4223,7 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3438
4223
  throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
3439
4224
  }
3440
4225
  const moved = await move(agents).catch((error) => {
3441
- throw error instanceof AgentStorageError2 && error.code === "active_run_exists" ? new AgentRequestError2("active_run_exists", "[Sixb] A turn is running on the computer: stop it, or let it end, first.") : error;
4226
+ throw error instanceof AgentStorageError2 && error.code === "active_run_exists" ? new AgentRequestError2("active_run_exists", thread.runsOn === "computer" ? "[Sixb] A turn is running on the computer: stop it, or let it end, first." : "[Sixb] A turn is running in the cloud: stop it, or let it end, first.") : error;
3442
4227
  });
3443
4228
  if (moves && await threadHoldsPausedTurn(agents, thread)) {
3444
4229
  throw new AgentRequestError2("active_run_exists", "[Sixb] A turn is waiting for your approval: answer or stop it first.");
@@ -3460,44 +4245,38 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3460
4245
  approvals,
3461
4246
  preferences,
3462
4247
  threads: {
3463
- recreateSandbox: async (threadId, input) => {
3464
- const readable = await rule.read(threadId);
3465
- if (!readable)
3466
- throw new AgentRequestError2("thread_not_found", "[Sixb] Agent thread not found.");
3467
- assertConversationThread2(readable.thread);
3468
- if (readable.access !== "owner") {
3469
- throw new AgentRequestError2("not_thread_owner", `[Sixb] Only the owner of Agent thread '${threadId}' can recreate its sandbox.`);
3470
- }
3471
- const thread = readable.thread;
3472
- const storage = runtime.storage.agents;
3473
- if (!storage)
3474
- throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
3475
- const sandboxState = await storage.threads.transitionSandbox({
3476
- projectId: runtime.projectId,
3477
- id: threadId,
3478
- action: "recreate",
3479
- expectedSandboxName: input.expectedSandboxName,
3480
- name: createAgentThreadSandboxName2(runtime.projectId, threadId)
3481
- });
3482
- const [view] = await agentThreadViews(runtime, [{ ...thread, sandboxState }]);
3483
- return view ?? thread;
3484
- },
4248
+ recreateSandbox: (threadId, input) => recoverSandbox(threadId, "recreate", (storage) => storage.threads.transitionSandbox({
4249
+ projectId: runtime.projectId,
4250
+ id: threadId,
4251
+ action: "recreate",
4252
+ expectedSandboxName: input.expectedSandboxName,
4253
+ name: createAgentThreadSandboxName2(runtime.projectId, threadId)
4254
+ })),
4255
+ restoreSandbox: (threadId, input) => recoverSandbox(threadId, "restore", (storage) => storage.threads.transitionSandbox({
4256
+ projectId: runtime.projectId,
4257
+ id: threadId,
4258
+ action: "restore",
4259
+ name: input.expectedSandboxName
4260
+ })),
3485
4261
  moveToComputer: async (threadId, computer) => {
3486
- const thread = await ownedComputerThread(threadId);
4262
+ const thread = await ownedMovableThread(threadId);
3487
4263
  const moves = movesComputerPlace2(thread, computer);
3488
4264
  const moved = await moveThread(thread, moves, (agents) => agents.threads.assignComputer({ projectId: runtime.projectId, id: threadId, computer }));
3489
4265
  if (moves)
3490
4266
  await announceThreadMoved(thread);
3491
- const [view] = await agentThreadViews(runtime, [moved]);
4267
+ const [view] = await withThreadState(await agentThreadViews(runtime, [moved]), readViewer());
3492
4268
  return view ?? moved;
3493
4269
  },
3494
4270
  moveToCloud: async (threadId) => {
3495
- const thread = await ownedComputerThread(threadId);
4271
+ const thread = await ownedMovableThread(threadId);
4272
+ if (thread.runsOn !== "computer") {
4273
+ throw new AgentRequestError2("invalid_message", `[Sixb] Agent thread '${threadId}' runs in the cloud, on no computer.`);
4274
+ }
3496
4275
  const { thread: moved, queued } = await moveThread(thread, true, (agents) => agents.threads.moveToCloud({ projectId: runtime.projectId, id: threadId }));
3497
4276
  if (queued)
3498
4277
  await dispatchAgentRun(runtime, requireAgents(), queued.id);
3499
4278
  await announceThreadMoved(thread);
3500
- const [view] = await agentThreadViews(runtime, [moved]);
4279
+ const [view] = await withThreadState(await agentThreadViews(runtime, [moved]), readViewer());
3501
4280
  return view ?? moved;
3502
4281
  },
3503
4282
  create: async (input) => {
@@ -3530,7 +4309,8 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3530
4309
  ...input.runsOn === undefined ? {} : { runsOn: input.runsOn },
3531
4310
  ...input.computer === undefined ? {} : { computer: input.computer }
3532
4311
  });
3533
- return { ...created, participants: [] };
4312
+ const [view] = await withThreadState([{ ...created, participants: [] }], readViewer());
4313
+ return view ?? { ...created, participants: [] };
3534
4314
  },
3535
4315
  listChildren: async (threadId, { runId } = {}) => {
3536
4316
  const thread = await getVisibleThreadRecord(threadId);
@@ -3561,10 +4341,36 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3561
4341
  ownerPrincipal: principal,
3562
4342
  sandbox
3563
4343
  });
3564
- const [view] = await agentThreadViews(runtime, [fork]);
4344
+ const [view] = await withThreadState(await agentThreadViews(runtime, [fork]), readViewer());
3565
4345
  return view ?? { ...fork, participants: [] };
3566
4346
  },
3567
- getById: getVisibleThreadRecord,
4347
+ getById: async (threadId) => {
4348
+ const thread = await getVisibleThreadRecord(threadId);
4349
+ if (!thread)
4350
+ return null;
4351
+ const [view] = await withThreadState([thread], readViewer());
4352
+ return view ?? null;
4353
+ },
4354
+ markRead: async (threadId, input = {}) => {
4355
+ const readable = await rule.read(threadId);
4356
+ if (!readable) {
4357
+ throw new AgentRequestError2("thread_not_found", "[Sixb] Agent thread not found.");
4358
+ }
4359
+ assertConversationThread2(readable.thread);
4360
+ const reader = settingsPrincipal();
4361
+ if (reader.type !== "user") {
4362
+ throw new AgentRequestError2("agent_not_found", "[Sixb] The project Agent is unavailable.");
4363
+ }
4364
+ if (input.throughMessageId !== undefined && input.throughMessageId.trim().length === 0) {
4365
+ throw new AgentRequestError2("invalid_message", "[Sixb] 'throughMessageId' must name a message of the thread.");
4366
+ }
4367
+ return requireAgents().reads.mark({
4368
+ projectId: runtime.projectId,
4369
+ threadId,
4370
+ principal: reader,
4371
+ ...input.throughMessageId === undefined ? {} : { throughMessageId: input.throughMessageId }
4372
+ });
4373
+ },
3568
4374
  list: async ({ sharedWithMe, ...input } = {}) => {
3569
4375
  assertNoAgentSelector(input);
3570
4376
  const none = { threads: [], hasMore: false, total: 0 };
@@ -3581,7 +4387,8 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3581
4387
  projectId: runtime.projectId,
3582
4388
  ...sharedWithMe && caller?.type === "user" ? { participantPrincipal: caller } : { ownerPrincipal: caller }
3583
4389
  });
3584
- return { ...result, threads: await agentThreadViews(runtime, result.threads) };
4390
+ const views = await agentThreadViews(runtime, result.threads);
4391
+ return { ...result, threads: await withThreadState(views, readViewer()) };
3585
4392
  },
3586
4393
  participants: {
3587
4394
  add: (threadId, users) => addAgentThreadParticipants(runtime, rule, security, threadId, users),
@@ -3590,7 +4397,44 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3590
4397
  getApprovalMode: getThreadApprovalMode,
3591
4398
  setApprovalMode: setThreadApprovalMode
3592
4399
  },
4400
+ inbox: {
4401
+ list: async (threadId) => {
4402
+ const thread = await getVisibleThreadRecord(threadId);
4403
+ if (!thread) {
4404
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${threadId}' not found.`);
4405
+ }
4406
+ return requireAgents().inbox.list({
4407
+ projectId: runtime.projectId,
4408
+ threadId: thread.id,
4409
+ includeClaimed: false
4410
+ });
4411
+ },
4412
+ update: async (threadId, itemId, input) => {
4413
+ if (!await getVisibleThreadRecord(threadId)) {
4414
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${threadId}' not found.`);
4415
+ }
4416
+ return promoteAgentInboxItem2(runtime, execution, { ...input, threadId, itemId }, blobStorage);
4417
+ },
4418
+ remove: async (threadId, itemId) => {
4419
+ if (!await getVisibleThreadRecord(threadId)) {
4420
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${threadId}' not found.`);
4421
+ }
4422
+ await withdrawAgentInboxItem2(runtime, execution, { threadId, itemId });
4423
+ }
4424
+ },
3593
4425
  runs: {
4426
+ send: async (input) => {
4427
+ assertNoAgentSelector(input);
4428
+ if (!getAgent()) {
4429
+ throw new AgentRequestError2("agent_not_found", "[Sixb] The project Agent is unavailable.");
4430
+ }
4431
+ assertAuthorized2(runtime, { kind: "agent.run" });
4432
+ if (!await getVisibleThreadRecord(input.threadId)) {
4433
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found.`);
4434
+ }
4435
+ const result = await sendAgentMessage2(runtime, execution, turnModels, input, blobStorage);
4436
+ return result.kind === "turn" ? { ...result, run: await attachRunView(runtime, result.run) } : result;
4437
+ },
3594
4438
  request: async (input) => {
3595
4439
  assertNoAgentSelector(input);
3596
4440
  const agent = getAgent();
@@ -3607,6 +4451,19 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3607
4451
  });
3608
4452
  return { ...result, run: await attachRunView(runtime, result.run) };
3609
4453
  },
4454
+ editMessage: async (input) => {
4455
+ assertNoAgentSelector(input);
4456
+ const agent = getAgent();
4457
+ if (!agent) {
4458
+ throw new AgentRequestError2("agent_not_found", "[Sixb] The project Agent is unavailable.");
4459
+ }
4460
+ assertAuthorized2(runtime, { kind: "agent.run" });
4461
+ if (!await getVisibleThreadRecord(input.threadId)) {
4462
+ throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found.`);
4463
+ }
4464
+ const result = await editAgentMessage2(runtime, execution, turnModels, { ...input, principal }, blobStorage);
4465
+ return result.kind === "turn" ? { ...result, run: await attachRunView(runtime, result.run) } : result;
4466
+ },
3610
4467
  retry: async (runId) => {
3611
4468
  const failedRun = await getControllableRun(runId, "retry");
3612
4469
  const agent = getAgent();
@@ -3637,6 +4494,7 @@ function createAgentRuntime(runtime, execution, models, decision, sandbox, secur
3637
4494
  observed: createObservedAgentThreadsRuntime(runtime)
3638
4495
  };
3639
4496
  registerAgentTurnResume(agentRuntime, resumeDecidedTurn);
4497
+ registerAgentQueuedTurn2(agentRuntime, startQueuedTurn);
3640
4498
  return agentRuntime;
3641
4499
  }
3642
4500
  function createObservedAgentThreadsRuntime(runtime) {
@@ -4308,7 +5166,7 @@ function lastState(changes) {
4308
5166
  }
4309
5167
 
4310
5168
  // src/events/execution.ts
4311
- function createEventsRuntime(runtime) {
5169
+ function createEventsRuntime(runtime, access) {
4312
5170
  const authority = resolveRuntimeAuthorizationForProject(runtime);
4313
5171
  const history = {
4314
5172
  existing: async (objects) => {
@@ -4326,12 +5184,14 @@ function createEventsRuntime(runtime) {
4326
5184
  return [];
4327
5185
  case "delegated": {
4328
5186
  const readable = await readableArtifactEvents(runtime, events);
4329
- return events.filter((event) => readable.has(event));
5187
+ const link = authority.delegation?.grantId;
5188
+ return events.filter((event) => readable.has(event) && (event.type !== "artifact.commented" || link !== undefined && event.payload.shareGrantId === link));
4330
5189
  }
4331
5190
  case "unrestricted":
4332
5191
  return events;
4333
5192
  case "principal": {
4334
- const shown = await visibleByGrants(authority.context, events);
5193
+ const granted = await visibleByGrants(authority.context, events);
5194
+ const shown = await withoutHiddenSyncRuns(granted, access);
4335
5195
  if (!events.some((event) => event.topic === "artifacts"))
4336
5196
  return shown;
4337
5197
  const readable = await readableArtifactEvents(runtime, events);
@@ -4432,6 +5292,20 @@ async function readableArtifactEvents(runtime, events) {
4432
5292
  }
4433
5293
  return shown;
4434
5294
  }
5295
+ async function withoutHiddenSyncRuns(events, access) {
5296
+ const connectionOf = (event) => event.topic === "syncs" ? event.payload.connectionId : undefined;
5297
+ const syncIds = new Set(events.flatMap((event) => event.topic === "syncs" && connectionOf(event) !== undefined ? [event.payload.syncId] : []));
5298
+ if (syncIds.size === 0)
5299
+ return events;
5300
+ const visible = await access.visibleSyncConnectionIds([...syncIds]);
5301
+ if (visible === undefined)
5302
+ return events;
5303
+ const shown = new Set(visible);
5304
+ return events.filter((event) => {
5305
+ const connectionId = connectionOf(event);
5306
+ return connectionId === undefined || shown.has(connectionId);
5307
+ });
5308
+ }
4435
5309
  async function eventClearances(reader, events, clearance) {
4436
5310
  const kinds = new Map;
4437
5311
  for (const event of events) {
@@ -6865,17 +7739,38 @@ function createAudioRuntime(runtime, execution, catalog, session, blobs) {
6865
7739
  }
6866
7740
  const event = await recordTranscription(accounting, model, callId, result ?? {});
6867
7741
  signal.throwIfAborted();
6868
- if (typeof result?.output?.text !== "string") {
6869
- throw new TranscriptionModelResponseError2("[SixbModels] Invalid transcription response.", model.providerId, model.modelId, result ?? {});
6870
- }
6871
- return {
6872
- output: { text: result.output.text },
6873
- usage: event.usage,
6874
- cost: event.cost,
6875
- callId
6876
- };
6877
- }
6878
- };
7742
+ const output = transcriptOutput(result, model);
7743
+ return { output, usage: event.usage, cost: event.cost, callId };
7744
+ }
7745
+ };
7746
+ }
7747
+ function transcriptOutput(result, model) {
7748
+ const refuse = () => new TranscriptionModelResponseError2("[SixbModels] Invalid transcription response.", model.providerId, model.modelId, result ?? {});
7749
+ const output = result?.output;
7750
+ if (typeof output?.text !== "string")
7751
+ throw refuse();
7752
+ const words = output.words;
7753
+ if (words === undefined)
7754
+ return { text: output.text };
7755
+ if (!Array.isArray(words))
7756
+ throw refuse();
7757
+ const timed = [];
7758
+ for (const word of words) {
7759
+ const entry = word;
7760
+ if (typeof entry?.text !== "string" || !entry.text || !isMillisecond(entry.startMs) || !isMillisecond(entry.endMs) || entry.endMs < entry.startMs || entry.speaker !== undefined && (typeof entry.speaker !== "string" || !entry.speaker)) {
7761
+ throw refuse();
7762
+ }
7763
+ timed.push({
7764
+ text: entry.text,
7765
+ startMs: entry.startMs,
7766
+ endMs: entry.endMs,
7767
+ ...entry.speaker === undefined ? {} : { speaker: entry.speaker }
7768
+ });
7769
+ }
7770
+ return timed.length ? { text: output.text, words: timed } : { text: output.text };
7771
+ }
7772
+ function isMillisecond(value) {
7773
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
6879
7774
  }
6880
7775
  function prepareAudio(input, blobs) {
6881
7776
  if (typeof input === "object" && input !== null && "data" in input) {
@@ -8442,6 +9337,7 @@ function executorRunKey(executor) {
8442
9337
  return `agent-run:${executor.runId}`;
8443
9338
  case "request":
8444
9339
  case "kernel":
9340
+ case "script":
8445
9341
  return;
8446
9342
  }
8447
9343
  }
@@ -8464,6 +9360,7 @@ async function canViewExecutorRun(reader, projections, executor) {
8464
9360
  switch (executor.type) {
8465
9361
  case "request":
8466
9362
  case "kernel":
9363
+ case "script":
8467
9364
  return true;
8468
9365
  case "agent":
8469
9366
  return canViewAgentRun(reader, executor.runId);
@@ -9000,6 +9897,7 @@ function resolveLinkContext2(objCtx, linkId) {
9000
9897
  // src/objects/sdk/runtime-query-executor.ts
9001
9898
  function createRuntimeQueryExecutor(params) {
9002
9899
  const { ontology, objectReader } = params;
9900
+ const discovery = getQueryDiscovery(objectReader);
9003
9901
  return {
9004
9902
  async list(query, options) {
9005
9903
  try {
@@ -9034,10 +9932,10 @@ function createRuntimeQueryExecutor(params) {
9034
9932
  };
9035
9933
  },
9036
9934
  validate(query) {
9037
- return validateObjectQuery2(query, { ontology, normalize: false });
9935
+ return validateObjectQuery2(query, { ontology, discovery, normalize: false });
9038
9936
  },
9039
9937
  explain(query) {
9040
- return explainObjectQuery2(query, { ontology, normalize: false });
9938
+ return explainObjectQuery2(query, { ontology, discovery, normalize: false });
9041
9939
  }
9042
9940
  };
9043
9941
  }
@@ -9904,26 +10802,70 @@ function storageFailure(operation, cause) {
9904
10802
  });
9905
10803
  }
9906
10804
 
10805
+ // src/syncs/accounts.ts
10806
+ function createSyncAccountsRuntime(input) {
10807
+ const { runtime, execution, connections } = input;
10808
+ const latestByConnection = (syncIds, connectionIds) => runtime.storage.syncRuns ? runtime.storage.syncRuns.listLatestByConnection({
10809
+ projectId: runtime.projectId,
10810
+ syncIds,
10811
+ ...connectionIds === undefined ? {} : { connectionIds }
10812
+ }).then(({ runs }) => runs) : Promise.resolve([]);
10813
+ return {
10814
+ async list(connectorId) {
10815
+ const syncs = input.syncs().filter((sync) => sync.connector.id === connectorId && input.runnable(sync.id));
10816
+ const connector = syncs[0]?.connector;
10817
+ if (!connections || !connector || !isOAuthConnectorDefinition2(connector))
10818
+ return [];
10819
+ const accounts = (await connections.list(connector)).filter((connection) => mayRunConnection(runtime, execution, connection));
10820
+ const runs = await latestByConnection(syncs.map(({ id }) => id), accounts.map(({ id }) => id));
10821
+ return accounts.map((connection) => ({
10822
+ connection,
10823
+ latestRuns: runs.filter((run) => run.connectionId === connection.id)
10824
+ }));
10825
+ },
10826
+ async latestRuns(connectorId, connectionId) {
10827
+ const syncs = input.syncs().filter((sync) => sync.connector.id === connectorId);
10828
+ const connector = syncs[0]?.connector;
10829
+ if (!connections || !connector || !isOAuthConnectorDefinition2(connector))
10830
+ return [];
10831
+ const connection = (await connections.list(connector)).find(({ id }) => id === connectionId);
10832
+ if (!connection || !seesConnection(runtime, execution, connection))
10833
+ return [];
10834
+ return latestByConnection(syncs.map(({ id }) => id), [connection.id]);
10835
+ }
10836
+ };
10837
+ }
10838
+
9907
10839
  // src/syncs/execution.ts
9908
- function createSyncsRuntime(runtime, execution, source) {
10840
+ function createSyncsRuntime(runtime, execution, source, connections) {
9909
10841
  const authority = resolveRuntimeAuthorizationForProject(runtime);
9910
10842
  const allowed = (syncId) => isRuntimeAllowed2(runtime, { kind: "sync.run", syncId });
9911
10843
  const visibleIds = () => source.list().filter((sync) => allowed(sync.id)).map((sync) => sync.id);
9912
10844
  const historyFilterIds = () => authority.type === "unrestricted" ? undefined : authority.type === "principal" ? visibleIds() : [];
10845
+ const getById = (syncId) => {
10846
+ if (authority.type === "denied" || authority.type === "delegated")
10847
+ return null;
10848
+ const sync = source.getById(syncId);
10849
+ return sync && allowed(syncId) ? sync : null;
10850
+ };
10851
+ const visibleConnectionIds = (syncs) => visibleSyncConnectionIds(runtime, execution, syncs, connections);
9913
10852
  return {
9914
10853
  list: () => authority.type === "denied" || authority.type === "delegated" ? [] : source.list().filter((sync) => allowed(sync.id)),
9915
- getById: (syncId) => {
9916
- if (authority.type === "denied" || authority.type === "delegated")
9917
- return null;
9918
- const sync = source.getById(syncId);
9919
- return sync && allowed(syncId) ? sync : null;
9920
- },
10854
+ getById,
10855
+ accounts: createSyncAccountsRuntime({
10856
+ runtime,
10857
+ execution,
10858
+ syncs: () => source.list(),
10859
+ runnable: getById,
10860
+ ...connections === undefined ? {} : { connections }
10861
+ }),
9921
10862
  request: async (input) => {
9922
10863
  assertAuthorized2(runtime, { kind: "sync.run", syncId: input.syncId });
9923
10864
  const sync = source.getById(input.syncId);
9924
10865
  if (!sync)
9925
10866
  throw new SyncValidationError2(`[Sixb] Unknown sync '${input.syncId}'`);
9926
- return requestSyncRun2(runtime, execution, sync, input);
10867
+ const { syncId: _syncId, ...options } = input;
10868
+ return requestSyncRun2(runtime, execution, sync, options, connections);
9927
10869
  },
9928
10870
  runs: {
9929
10871
  getById: async (runId) => {
@@ -9933,30 +10875,41 @@ function createSyncsRuntime(runtime, execution, source) {
9933
10875
  projectId: runtime.projectId,
9934
10876
  id: runId
9935
10877
  }) ?? null;
9936
- return run && allowed(run.syncId) ? run : null;
10878
+ if (!run || !allowed(run.syncId))
10879
+ return null;
10880
+ const visible = await visibleConnectionIds([source.getById(run.syncId)]);
10881
+ const hidden = run.connectionId !== undefined && visible?.includes(run.connectionId) === false;
10882
+ return hidden ? null : run;
9937
10883
  },
9938
- list: (input = {}) => {
10884
+ list: async (input = {}) => {
9939
10885
  if (authority.type === "denied" || authority.type === "delegated") {
9940
- return Promise.resolve({ runs: [], hasMore: false, total: 0 });
10886
+ return { runs: [], hasMore: false, total: 0 };
9941
10887
  }
9942
10888
  const storage = runtime.storage.syncRuns;
9943
10889
  if (!storage)
9944
- return Promise.resolve({ runs: [], hasMore: false, total: 0 });
10890
+ return { runs: [], hasMore: false, total: 0 };
10891
+ const syncs = input.syncId === undefined ? source.list().filter((sync) => allowed(sync.id)) : [getById(input.syncId)];
10892
+ const visible = await visibleConnectionIds(syncs);
9945
10893
  return storage.list({
9946
10894
  ...input,
9947
10895
  syncIds: historyFilterIds(),
10896
+ ...visible === undefined ? {} : { visibleConnectionIds: visible },
9948
10897
  projectId: runtime.projectId
9949
10898
  });
9950
10899
  },
9951
- listLatest: (syncIds) => {
9952
- if (authority.type === "denied" || authority.type === "delegated") {
9953
- return Promise.resolve({ runs: [] });
9954
- }
10900
+ listLatest: async (syncIds) => {
10901
+ if (authority.type === "denied" || authority.type === "delegated")
10902
+ return { runs: [] };
9955
10903
  const storage = runtime.storage.syncRuns;
9956
- if (!storage || syncIds.length === 0)
9957
- return Promise.resolve({ runs: [] });
9958
10904
  const allowedIds = syncIds.filter(allowed);
9959
- return allowedIds.length === 0 ? Promise.resolve({ runs: [] }) : storage.listLatestBySyncIds({ projectId: runtime.projectId, syncIds: allowedIds });
10905
+ if (!storage || allowedIds.length === 0)
10906
+ return { runs: [] };
10907
+ const visible = await visibleConnectionIds(allowedIds.map((syncId) => source.getById(syncId)));
10908
+ return storage.listLatestBySyncIds({
10909
+ projectId: runtime.projectId,
10910
+ syncIds: allowedIds,
10911
+ ...visible === undefined ? {} : { visibleConnectionIds: visible }
10912
+ });
9960
10913
  }
9961
10914
  }
9962
10915
  };
@@ -10190,6 +11143,7 @@ function isBoundSixb(value) {
10190
11143
  }
10191
11144
  function createExecutionFacades(runtime, execution, dependencies) {
10192
11145
  const actions = createActionsRuntime(runtime, execution);
11146
+ const syncConnections = createSyncConnections(dependencies.connectorService);
10193
11147
  const workflows = createWorkflowsRuntime(runtime, execution, dependencies.definitions.workflows);
10194
11148
  const session = runtime.modelExecution ?? new ModelExecutionSession(runtime, execution);
10195
11149
  const agent = createAgentRuntime(runtime, execution, dependencies.definitions.models, createDecisionRuntime(runtime, execution, dependencies.definitions.models, session, "agent.run"), dependencies.sandbox, dependencies.definitions.security, dependencies.blobStorage);
@@ -10201,13 +11155,13 @@ function createExecutionFacades(runtime, execution, dependencies) {
10201
11155
  actions,
10202
11156
  datasets: createDatasetsRuntime(runtime, execution, dependencies.definitions.datasets, dependencies.lakeStorage, dependencies.blobStorage, dependencies.datasetVersionMarkings, dependencies.datasetIngest),
10203
11157
  workflows,
10204
- syncs: createSyncsRuntime(runtime, execution, dependencies.definitions.syncs),
11158
+ syncs: createSyncsRuntime(runtime, execution, dependencies.definitions.syncs, syncConnections),
10205
11159
  pipelines: createPipelinesRuntime(runtime, execution, dependencies.definitions.pipelines),
10206
11160
  projections: createProjectionsRuntime(runtime, dependencies.definitions.projections),
10207
11161
  rules: createRulesRuntime(runtime, dependencies.definitions.rules),
10208
11162
  agent,
10209
11163
  artifacts: createArtifactsRuntime(runtime, dependencies.blobStorage, {
10210
- rendersBoardPreviews: dependencies.rendersBoardPreviews
11164
+ rendersInSandboxes: dependencies.rendersInSandboxes
10211
11165
  }),
10212
11166
  models: createModelsRuntime(runtime, execution, dependencies.definitions.models, session, {
10213
11167
  canViewActionRun: async (id) => await actions.runs.getById(id) !== null,
@@ -10215,7 +11169,9 @@ function createExecutionFacades(runtime, execution, dependencies) {
10215
11169
  canViewAgentRun: async (id) => await agent.runs.getById(id) !== null
10216
11170
  }, dependencies.blobStorage),
10217
11171
  aiUsage: createAiUsageRuntime(runtime, dependencies.definitions.security),
10218
- events: createEventsRuntime(runtime),
11172
+ events: createEventsRuntime(runtime, {
11173
+ visibleSyncConnectionIds: (syncIds) => visibleSyncConnectionIds(runtime, execution, syncIds.map((syncId) => dependencies.definitions.syncs.getById(syncId)), syncConnections)
11174
+ }),
10219
11175
  logs: createLogsRuntime(runtime, dependencies.logging),
10220
11176
  activity: createActivityRuntime(runtime, dependencies.activity),
10221
11177
  schedules: createSchedulesRuntime(runtime, dependencies.definitions.schedules),
@@ -11933,6 +12889,6 @@ function snapshotActionRequest(input) {
11933
12889
  ...onRequested === undefined ? {} : { onRequested }
11934
12890
  };
11935
12891
  }
11936
- export { defineAction2, param2, optional2, ActionRegistry2, bindRequestClient, bindModelExecutionAttempt, canInheritAgentRequestAuthorization2, createAgentExecutionRecord2, createInheritedAgentExecutionRecord2, bindDurableAgentExecution2, bindAgentRunRequestExecution2, bindAgentModelExecution2, restoreAgentExecutionScope2, assertAgentExecutionRecord2, resumeDecidedAgentTurn2, agentRunApprovalMode2, holdAgentApprovalCall2, approvalCallSummary2, listChildApprovalsAwaiting2, isAwaitingApprovalRun2, isPausedSubagentRun2, AGENT_APPROVAL_EXECUTION_LEASE_MS2, turnResumeReadiness2, turnPausesOnHeldCalls2, hasActiveChildren2, listTurnApprovals2, stopAgentTurn2, announceAgentApprovals2, agentApprovalCallers2, AgentRunScopeError2, resolveAgentRunExecutionScope2, createAgentApprovalExecutor, registerAgentApprovalExecutor, getAgentApprovalExecutor2, requestAgentRunCancel2, cancelQueuedRun, AGENT_QUESTION_LIMITS2, agentQuestionsText2, isChildAskTool2, isAwaitingAnswerRun2, deferredChildQuestion2, listSubagentThreadRuns2, subagentSandboxFiles2, assertTurnModelRouting, DEFAULT_PROJECT_LOCALE, DEFAULT_PROJECT_TIME_ZONE, canonicalLocale, canonicalTimeZone, resolveAgentContextParts2, agentRunQueueJobId2, workflowAgentNodeQueueJobId2, dispatchQueuedAgentRuns2, assertNoAgentDefinitions, requestAgentRun2, isRetryableAgentRun2, retryAgentRun2, WorkflowDefinitionError2, WorkflowValidationError2, assertNonEmpty, isStepDefinition2, isAgentStepDefinition2, isInterventionDefinition2, isWorkflowDefinition2, validateWorkflowDefinition2, validateWorkflowsAtStartup2, validateWorkflowAgentStepGroupReferences2, validateWorkflowInput2, validateWorkflowStepInput2, validateWorkflowStepOutput2, validateWorkflowInterventionInput2, validateWorkflowInterventionResponse2, validateWorkflowInterventionDefaultResponse2, assertAgentStepSandbox, validateWorkflowAgentStepInput2, validateWorkflowAgentStepOutput2, snapshotWorkflowAgentStepInput2, snapshotWorkflowAgentStepOutput2, snapshotWorkflowInput2, snapshotWorkflowStepInput2, snapshotWorkflowStepOutput2, snapshotWorkflowInterventionInput2, snapshotWorkflowInterventionResponse2, snapshotWorkflowInterventionDefaultResponse2, snapshotWorkflowActionInput2, WorkflowRunDispatcher2, requestWorkflowRun2, prepareBoundActionRequest2, prepareBoundWorkflowRequest2, runModelLoop2, requestAction2, ObjectError2, removeLink2, upsertLink2, upsertLinkBatch2, deleteObject2, restoreObject2, upsertObject2, upsertObjectBatch2, writeTelemetryBatch2, appendTelemetryBatch2, getTelemetryHistoryBatch2, requireLinkDefinition2, resolveObjectContext2, resolveLinkContext2, createObjectSet2, exports_service, ShareError2, createBoundSixb, isBoundSixb, bindDurablePrimitiveExecution2, ACTION_RUN_DRAIN_TIMEOUT_MS2, ActionRunExecutor, registerActionRunExecutor, drainActionRuns2, requestAction3 };
12892
+ export { defineAction2, param2, optional2, ActionRegistry2, bindRequestClient, bindModelExecutionAttempt, canInheritAgentRequestAuthorization2, createAgentExecutionRecord2, createInheritedAgentExecutionRecord2, bindDurableAgentExecution2, bindAgentRunRequestExecution2, bindAgentModelExecution2, restoreAgentExecutionScope2, assertAgentExecutionRecord2, resumeDecidedAgentTurn2, agentRunApprovalMode2, holdAgentApprovalCall2, approvalCallSummary2, listChildApprovalsAwaiting2, isAwaitingApprovalRun2, isPausedSubagentRun2, AGENT_APPROVAL_EXECUTION_LEASE_MS2, turnResumeReadiness2, turnPausesOnHeldCalls2, hasActiveChildren2, listTurnApprovals2, stopAgentTurn2, announceAgentApprovals2, agentApprovalCallers2, AgentRunScopeError2, resolveAgentRunExecutionScope2, createAgentApprovalExecutor, registerAgentApprovalExecutor, getAgentApprovalExecutor2, requestAgentRunCancel2, cancelQueuedRun, AGENT_QUESTION_LIMITS2, agentQuestionsText2, isChildAskTool2, isAwaitingAnswerRun2, deferredChildQuestion2, listSubagentThreadRuns2, subagentSandboxFiles2, assertTurnModelRouting, registerAgentQueuedTurn2, startQueuedAgentTurn2, resolveAgentContextParts2, agentRunQueueJobId2, workflowAgentNodeQueueJobId2, dispatchQueuedAgentRuns2, assertNoAgentDefinitions, turnAnsweredEveryMessage, requestAgentRun2, isEditableAgentMessage2, editAgentMessage2, isRetryableAgentRun2, retryAgentRun2, AGENT_MESSAGE_DELIVERIES2, sendAgentMessage2, promoteAgentInboxItem2, withdrawAgentInboxItem2, startQueuedAgentTurnFromInbox2, WorkflowDefinitionError2, WorkflowValidationError2, assertNonEmpty, isStepDefinition2, isAgentStepDefinition2, isInterventionDefinition2, isWorkflowDefinition2, validateWorkflowDefinition2, validateWorkflowsAtStartup2, validateWorkflowAgentStepGroupReferences2, validateWorkflowInput2, validateWorkflowStepInput2, validateWorkflowStepOutput2, validateWorkflowInterventionInput2, validateWorkflowInterventionResponse2, validateWorkflowInterventionDefaultResponse2, assertAgentStepSandbox, validateWorkflowAgentStepInput2, validateWorkflowAgentStepOutput2, snapshotWorkflowAgentStepInput2, snapshotWorkflowAgentStepOutput2, snapshotWorkflowInput2, snapshotWorkflowStepInput2, snapshotWorkflowStepOutput2, snapshotWorkflowInterventionInput2, snapshotWorkflowInterventionResponse2, snapshotWorkflowInterventionDefaultResponse2, snapshotWorkflowActionInput2, WorkflowRunDispatcher2, requestWorkflowRun2, prepareBoundActionRequest2, prepareBoundWorkflowRequest2, runModelLoop2, requestAction2, ObjectError2, removeLink2, upsertLink2, upsertLinkBatch2, deleteObject2, restoreObject2, upsertObject2, upsertObjectBatch2, writeTelemetryBatch2, appendTelemetryBatch2, getTelemetryHistoryBatch2, requireLinkDefinition2, resolveObjectContext2, resolveLinkContext2, createObjectSet2, exports_service, ShareError2, createBoundSixb, isBoundSixb, bindDurablePrimitiveExecution2, ACTION_RUN_DRAIN_TIMEOUT_MS2, ActionRunExecutor, registerActionRunExecutor, drainActionRuns2, requestAction3 };
11937
12893
 
11938
- //# debugId=F3ECA7E87867ECD264756E2164756E21
12894
+ //# debugId=6AB827512C16B65C64756E2164756E21