@sixb/core 0.1.21 → 0.1.22

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 (1263) hide show
  1. package/dist/actions/commit-edits.d.ts +3 -1
  2. package/dist/actions/commit-edits.d.ts.map +1 -1
  3. package/dist/actions/execution.d.ts.map +1 -1
  4. package/dist/actions/index.js +63 -59
  5. package/dist/actions/index.js.map +1 -1
  6. package/dist/actions/read-facade.d.ts +9 -1
  7. package/dist/actions/read-facade.d.ts.map +1 -1
  8. package/dist/actions/request.d.ts +15 -1
  9. package/dist/actions/request.d.ts.map +1 -1
  10. package/dist/actions/run/context.d.ts +1 -0
  11. package/dist/actions/run/context.d.ts.map +1 -1
  12. package/dist/actions/run/execute.d.ts +2 -3
  13. package/dist/actions/run/execute.d.ts.map +1 -1
  14. package/dist/actions/run/executor.d.ts +3 -0
  15. package/dist/actions/run/executor.d.ts.map +1 -1
  16. package/dist/actions/run/normalize.d.ts +2 -1
  17. package/dist/actions/run/normalize.d.ts.map +1 -1
  18. package/dist/actions/run/signals.d.ts +1 -3
  19. package/dist/actions/run/signals.d.ts.map +1 -1
  20. package/dist/actions/run/types.d.ts +16 -1
  21. package/dist/actions/run/types.d.ts.map +1 -1
  22. package/dist/actions/run-authorization.d.ts +14 -0
  23. package/dist/actions/run-authorization.d.ts.map +1 -1
  24. package/dist/actions/types/context.d.ts +17 -1
  25. package/dist/actions/types/context.d.ts.map +1 -1
  26. package/dist/actions/validators.d.ts.map +1 -1
  27. package/dist/activity/timeline.d.ts +8 -1
  28. package/dist/activity/timeline.d.ts.map +1 -1
  29. package/dist/agents/accounting.d.ts +15 -0
  30. package/dist/agents/accounting.d.ts.map +1 -0
  31. package/dist/agents/adapters.d.ts.map +1 -1
  32. package/dist/agents/agent-mail.d.ts +9 -0
  33. package/dist/agents/agent-mail.d.ts.map +1 -0
  34. package/dist/agents/api-gateway.d.ts +5 -0
  35. package/dist/agents/api-gateway.d.ts.map +1 -1
  36. package/dist/agents/approval-continuation.d.ts +23 -0
  37. package/dist/agents/approval-continuation.d.ts.map +1 -0
  38. package/dist/agents/approval-executor.d.ts +56 -0
  39. package/dist/agents/approval-executor.d.ts.map +1 -0
  40. package/dist/agents/approval-outcome.d.ts +8 -0
  41. package/dist/agents/approval-outcome.d.ts.map +1 -0
  42. package/dist/agents/approvals.d.ts +210 -0
  43. package/dist/agents/approvals.d.ts.map +1 -0
  44. package/dist/agents/authority.d.ts +10 -0
  45. package/dist/agents/authority.d.ts.map +1 -1
  46. package/dist/agents/builders.d.ts.map +1 -1
  47. package/dist/agents/cancel.d.ts +23 -0
  48. package/dist/agents/cancel.d.ts.map +1 -0
  49. package/dist/agents/child-question.d.ts +18 -0
  50. package/dist/agents/child-question.d.ts.map +1 -0
  51. package/dist/agents/children.d.ts +99 -0
  52. package/dist/agents/children.d.ts.map +1 -0
  53. package/dist/agents/context/index.js +1 -1
  54. package/dist/agents/context-compaction.d.ts.map +1 -1
  55. package/dist/agents/errors.d.ts +13 -1
  56. package/dist/agents/errors.d.ts.map +1 -1
  57. package/dist/agents/execution.d.ts +180 -14
  58. package/dist/agents/execution.d.ts.map +1 -1
  59. package/dist/agents/fork.d.ts +16 -0
  60. package/dist/agents/fork.d.ts.map +1 -0
  61. package/dist/agents/ids.d.ts +7 -0
  62. package/dist/agents/ids.d.ts.map +1 -1
  63. package/dist/agents/index.d.ts +19 -8
  64. package/dist/agents/index.d.ts.map +1 -1
  65. package/dist/agents/index.js +159 -86
  66. package/dist/agents/index.js.map +1 -1
  67. package/dist/agents/memory-execution.d.ts +57 -0
  68. package/dist/agents/memory-execution.d.ts.map +1 -0
  69. package/dist/agents/memory.d.ts +49 -0
  70. package/dist/agents/memory.d.ts.map +1 -0
  71. package/dist/agents/message.d.ts +50 -1
  72. package/dist/agents/message.d.ts.map +1 -1
  73. package/dist/agents/model-loop.d.ts +19 -0
  74. package/dist/agents/model-loop.d.ts.map +1 -1
  75. package/dist/agents/model-routing.d.ts +19 -0
  76. package/dist/agents/model-routing.d.ts.map +1 -0
  77. package/dist/agents/participants.d.ts +18 -0
  78. package/dist/agents/participants.d.ts.map +1 -0
  79. package/dist/agents/reference.d.ts.map +1 -1
  80. package/dist/agents/request.d.ts +36 -2
  81. package/dist/agents/request.d.ts.map +1 -1
  82. package/dist/agents/run-scope.d.ts +51 -0
  83. package/dist/agents/run-scope.d.ts.map +1 -0
  84. package/dist/agents/streams/index.d.ts +3 -2
  85. package/dist/agents/streams/index.d.ts.map +1 -1
  86. package/dist/agents/streams/index.js +7 -3
  87. package/dist/agents/streams/index.js.map +1 -1
  88. package/dist/agents/streams/internal.d.ts +1 -1
  89. package/dist/agents/streams/internal.d.ts.map +1 -1
  90. package/dist/agents/streams/internal.js +5 -3
  91. package/dist/agents/streams/internal.js.map +1 -1
  92. package/dist/agents/streams/protocol.d.ts +122 -3
  93. package/dist/agents/streams/protocol.d.ts.map +1 -1
  94. package/dist/agents/subagent-runs.d.ts +12 -0
  95. package/dist/agents/subagent-runs.d.ts.map +1 -0
  96. package/dist/agents/thread-access.d.ts +53 -0
  97. package/dist/agents/thread-access.d.ts.map +1 -0
  98. package/dist/agents/tool-definition.d.ts +5 -4
  99. package/dist/agents/tool-definition.d.ts.map +1 -1
  100. package/dist/agents/types.d.ts +23 -4
  101. package/dist/agents/types.d.ts.map +1 -1
  102. package/dist/agents/validation.d.ts +1 -1
  103. package/dist/agents/validation.d.ts.map +1 -1
  104. package/dist/artifacts/access.d.ts +52 -0
  105. package/dist/artifacts/access.d.ts.map +1 -0
  106. package/dist/artifacts/canvas.d.ts +92 -0
  107. package/dist/artifacts/canvas.d.ts.map +1 -0
  108. package/dist/artifacts/csv.d.ts +5 -0
  109. package/dist/artifacts/csv.d.ts.map +1 -1
  110. package/dist/artifacts/errors.d.ts +7 -2
  111. package/dist/artifacts/errors.d.ts.map +1 -1
  112. package/dist/artifacts/execution.d.ts +102 -7
  113. package/dist/artifacts/execution.d.ts.map +1 -1
  114. package/dist/artifacts/formula/check.d.ts +24 -0
  115. package/dist/artifacts/formula/check.d.ts.map +1 -0
  116. package/dist/artifacts/formula/evaluate.d.ts +32 -0
  117. package/dist/artifacts/formula/evaluate.d.ts.map +1 -0
  118. package/dist/artifacts/formula/index.d.ts +38 -0
  119. package/dist/artifacts/formula/index.d.ts.map +1 -0
  120. package/dist/artifacts/formula/parser.d.ts +67 -0
  121. package/dist/artifacts/formula/parser.d.ts.map +1 -0
  122. package/dist/artifacts/frames/assets.d.ts +11 -9
  123. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  124. package/dist/artifacts/frames/entries.d.ts +19 -0
  125. package/dist/artifacts/frames/entries.d.ts.map +1 -0
  126. package/dist/artifacts/frames/grants.d.ts +6 -6
  127. package/dist/artifacts/frames/grants.d.ts.map +1 -1
  128. package/dist/artifacts/frames/index.d.ts +4 -2
  129. package/dist/artifacts/frames/index.d.ts.map +1 -1
  130. package/dist/artifacts/frames/index.js +444 -51
  131. package/dist/artifacts/frames/index.js.map +10 -8
  132. package/dist/artifacts/frames/kit.d.ts +10 -5
  133. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  134. package/dist/artifacts/frames/probe.d.ts +16 -12
  135. package/dist/artifacts/frames/probe.d.ts.map +1 -1
  136. package/dist/artifacts/frames/protocol.d.ts +79 -10
  137. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  138. package/dist/artifacts/frames/runtime.d.ts +27 -9
  139. package/dist/artifacts/frames/runtime.d.ts.map +1 -1
  140. package/dist/artifacts/index.d.ts +11 -5
  141. package/dist/artifacts/index.d.ts.map +1 -1
  142. package/dist/artifacts/index.js +128 -6
  143. package/dist/artifacts/index.js.map +3 -3
  144. package/dist/artifacts/kinds.d.ts +1 -1
  145. package/dist/artifacts/kinds.d.ts.map +1 -1
  146. package/dist/artifacts/limits.d.ts +30 -0
  147. package/dist/artifacts/limits.d.ts.map +1 -1
  148. package/dist/artifacts/live-sheet.d.ts +65 -0
  149. package/dist/artifacts/live-sheet.d.ts.map +1 -0
  150. package/dist/artifacts/outline.d.ts +27 -1
  151. package/dist/artifacts/outline.d.ts.map +1 -1
  152. package/dist/artifacts/publish/index.d.ts +2 -0
  153. package/dist/artifacts/publish/index.d.ts.map +1 -1
  154. package/dist/artifacts/publish/index.js +59 -19
  155. package/dist/artifacts/publish/index.js.map +1 -1
  156. package/dist/artifacts/publish/publish.d.ts +43 -11
  157. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  158. package/dist/artifacts/publish/queries.d.ts +33 -0
  159. package/dist/artifacts/publish/queries.d.ts.map +1 -0
  160. package/dist/artifacts/publish/references.d.ts +6 -3
  161. package/dist/artifacts/publish/references.d.ts.map +1 -1
  162. package/dist/artifacts/publish/validate/canvas.d.ts +18 -0
  163. package/dist/artifacts/publish/validate/canvas.d.ts.map +1 -0
  164. package/dist/artifacts/publish/validate/html.d.ts +20 -0
  165. package/dist/artifacts/publish/validate/html.d.ts.map +1 -0
  166. package/dist/artifacts/publish/validate/page.d.ts +15 -0
  167. package/dist/artifacts/publish/validate/page.d.ts.map +1 -0
  168. package/dist/artifacts/publish/validate/sheet.d.ts +11 -3
  169. package/dist/artifacts/publish/validate/sheet.d.ts.map +1 -1
  170. package/dist/artifacts/publish/validate/slides.d.ts +1 -7
  171. package/dist/artifacts/publish/validate/slides.d.ts.map +1 -1
  172. package/dist/artifacts/queries.d.ts +95 -0
  173. package/dist/artifacts/queries.d.ts.map +1 -0
  174. package/dist/artifacts/resolve.d.ts +6 -0
  175. package/dist/artifacts/resolve.d.ts.map +1 -1
  176. package/dist/artifacts/run-query.d.ts +26 -0
  177. package/dist/artifacts/run-query.d.ts.map +1 -0
  178. package/dist/artifacts/serialize-query.d.ts +12 -0
  179. package/dist/artifacts/serialize-query.d.ts.map +1 -0
  180. package/dist/artifacts/sheet-rules.d.ts +26 -0
  181. package/dist/artifacts/sheet-rules.d.ts.map +1 -0
  182. package/dist/artifacts/tones.d.ts +8 -0
  183. package/dist/artifacts/tones.d.ts.map +1 -0
  184. package/dist/artifacts/workbook.d.ts +76 -5
  185. package/dist/artifacts/workbook.d.ts.map +1 -1
  186. package/dist/auth/index.d.ts +1 -1
  187. package/dist/auth/index.d.ts.map +1 -1
  188. package/dist/auth/index.js +14 -11
  189. package/dist/auth/index.js.map +1 -1
  190. package/dist/auth/member-events.d.ts +13 -0
  191. package/dist/auth/member-events.d.ts.map +1 -0
  192. package/dist/auth/profile.d.ts +11 -0
  193. package/dist/auth/profile.d.ts.map +1 -0
  194. package/dist/auth/runtime.d.ts +31 -3
  195. package/dist/auth/runtime.d.ts.map +1 -1
  196. package/dist/auth/strategy.d.ts +3 -1
  197. package/dist/auth/strategy.d.ts.map +1 -1
  198. package/dist/auth/strategy.js +7 -3
  199. package/dist/auth/strategy.js.map +1 -1
  200. package/dist/auth/types.d.ts +30 -1
  201. package/dist/auth/types.d.ts.map +1 -1
  202. package/dist/authorization/decision.d.ts +15 -0
  203. package/dist/authorization/decision.d.ts.map +1 -1
  204. package/dist/authorization/event-visibility.d.ts +5 -1
  205. package/dist/authorization/event-visibility.d.ts.map +1 -1
  206. package/dist/authorization/grant-kinds.d.ts +2 -2
  207. package/dist/authorization/grant-kinds.d.ts.map +1 -1
  208. package/dist/authorization/index.d.ts +2 -2
  209. package/dist/authorization/index.d.ts.map +1 -1
  210. package/dist/authorization/index.js +12 -7
  211. package/dist/authorization/index.js.map +1 -1
  212. package/dist/authorization/resolve.d.ts +19 -1
  213. package/dist/authorization/resolve.d.ts.map +1 -1
  214. package/dist/authorization/run-visibility.d.ts +8 -1
  215. package/dist/authorization/run-visibility.d.ts.map +1 -1
  216. package/dist/authorization/types.d.ts +14 -0
  217. package/dist/authorization/types.d.ts.map +1 -1
  218. package/dist/bootstrap/index.js +69 -65
  219. package/dist/bootstrap/index.js.map +2 -2
  220. package/dist/{chunk-ky3j490c.js → chunk-02bzjgnt.js} +6 -6
  221. package/dist/{chunk-ky3j490c.js.map → chunk-02bzjgnt.js.map} +1 -1
  222. package/dist/{chunk-mfs23znk.js → chunk-07kkp2e1.js} +1 -1
  223. package/dist/{chunk-c1rxbz5y.js → chunk-098anw4f.js} +21 -19
  224. package/dist/chunk-098anw4f.js.map +12 -0
  225. package/dist/{chunk-z58tm0hm.js → chunk-0phpbbvm.js} +3 -3
  226. package/dist/{chunk-ere85b8y.js → chunk-0xmt5p5y.js} +116 -27
  227. package/dist/chunk-0xmt5p5y.js.map +14 -0
  228. package/dist/{chunk-t6f3tdnr.js → chunk-16a9dmfy.js} +33 -2
  229. package/dist/{chunk-t6f3tdnr.js.map → chunk-16a9dmfy.js.map} +5 -4
  230. package/dist/chunk-18sk89cg.js +47 -0
  231. package/dist/chunk-18sk89cg.js.map +10 -0
  232. package/dist/{chunk-e17zdm62.js → chunk-1t6k1avb.js} +1 -1
  233. package/dist/chunk-2626mh4m.js +693 -0
  234. package/dist/chunk-2626mh4m.js.map +19 -0
  235. package/dist/{chunk-qczk96d9.js → chunk-2adz0h75.js} +13 -4
  236. package/dist/chunk-2adz0h75.js.map +11 -0
  237. package/dist/{chunk-kge7k6ey.js → chunk-2fn60nvs.js} +2 -2
  238. package/dist/{chunk-99nd4rc1.js → chunk-2gjj5dx3.js} +5 -4
  239. package/dist/{chunk-99nd4rc1.js.map → chunk-2gjj5dx3.js.map} +3 -3
  240. package/dist/{chunk-mjddfa7k.js → chunk-3fqxbn31.js} +2 -24
  241. package/dist/{chunk-mjddfa7k.js.map → chunk-3fqxbn31.js.map} +3 -4
  242. package/dist/{chunk-y0c4e6ex.js → chunk-3gbefjg5.js} +1 -1
  243. package/dist/{chunk-5hx48dnn.js → chunk-45ngkxkp.js} +52 -31
  244. package/dist/chunk-45ngkxkp.js.map +13 -0
  245. package/dist/{chunk-cy4mbddw.js → chunk-48jezz3j.js} +1 -1
  246. package/dist/{chunk-561r0yc9.js → chunk-4b26qwbg.js} +13 -13
  247. package/dist/{chunk-561r0yc9.js.map → chunk-4b26qwbg.js.map} +1 -1
  248. package/dist/{chunk-9k93ah50.js → chunk-4f3ydv7t.js} +33 -69
  249. package/dist/chunk-4f3ydv7t.js.map +10 -0
  250. package/dist/chunk-4y26vs3v.js +97 -0
  251. package/dist/chunk-4y26vs3v.js.map +10 -0
  252. package/dist/{chunk-4as3wt1c.js → chunk-4ymrcdbm.js} +7 -3
  253. package/dist/chunk-4ymrcdbm.js.map +12 -0
  254. package/dist/{chunk-hcbyfxbe.js → chunk-5grk14e5.js} +76 -2
  255. package/dist/{chunk-hcbyfxbe.js.map → chunk-5grk14e5.js.map} +4 -3
  256. package/dist/{chunk-8frc8a4j.js → chunk-65pyhyas.js} +90 -83
  257. package/dist/chunk-65pyhyas.js.map +20 -0
  258. package/dist/{chunk-hwksyjks.js → chunk-661ezhks.js} +182 -6
  259. package/dist/chunk-661ezhks.js.map +11 -0
  260. package/dist/{chunk-447a5c0p.js → chunk-6n69k945.js} +2 -2
  261. package/dist/{chunk-0bphap9y.js → chunk-6p0pastb.js} +5 -5
  262. package/dist/{chunk-9j4jw7as.js → chunk-6rrtzea3.js} +18 -5
  263. package/dist/chunk-6rrtzea3.js.map +14 -0
  264. package/dist/{chunk-431pyp2c.js → chunk-6y0mkhex.js} +2 -2
  265. package/dist/{chunk-f4pamkt9.js → chunk-73v685wb.js} +10 -10
  266. package/dist/{chunk-f4pamkt9.js.map → chunk-73v685wb.js.map} +3 -3
  267. package/dist/{chunk-akzryx9h.js → chunk-7gr4j2eq.js} +7836 -5047
  268. package/dist/chunk-7gr4j2eq.js.map +120 -0
  269. package/dist/{chunk-bk9svbcq.js → chunk-7mc2wkre.js} +386 -86
  270. package/dist/chunk-7mc2wkre.js.map +50 -0
  271. package/dist/{chunk-6rqgmkde.js → chunk-7z5p905k.js} +335 -703
  272. package/dist/chunk-7z5p905k.js.map +22 -0
  273. package/dist/{chunk-yxd3nnqt.js → chunk-9mab3dvg.js} +26 -2
  274. package/dist/chunk-9mab3dvg.js.map +11 -0
  275. package/dist/chunk-9wr3yajk.js +42 -0
  276. package/dist/chunk-9wr3yajk.js.map +10 -0
  277. package/dist/chunk-az47zep4.js +41 -0
  278. package/dist/chunk-az47zep4.js.map +10 -0
  279. package/dist/{chunk-s7jg7pmn.js → chunk-bab05bhg.js} +1 -1
  280. package/dist/{chunk-858emn8m.js → chunk-bktev1ds.js} +14 -11
  281. package/dist/{chunk-858emn8m.js.map → chunk-bktev1ds.js.map} +3 -3
  282. package/dist/{chunk-dhcv7yxc.js → chunk-c0vk1djt.js} +5 -3
  283. package/dist/chunk-c0vk1djt.js.map +11 -0
  284. package/dist/chunk-c69nj7se.js +3 -0
  285. package/dist/{chunk-7n30ybym.js.map → chunk-c69nj7se.js.map} +1 -1
  286. package/dist/{chunk-q5e5tv4b.js → chunk-c844dkwd.js} +1 -1
  287. package/dist/{chunk-g257jwnc.js → chunk-cdk3egjj.js} +17 -4
  288. package/dist/chunk-cdk3egjj.js.map +12 -0
  289. package/dist/chunk-cswhawa2.js +113 -0
  290. package/dist/chunk-cswhawa2.js.map +10 -0
  291. package/dist/{chunk-cfj9dfbb.js → chunk-d2m879s4.js} +2 -2
  292. package/dist/{chunk-arns890k.js → chunk-d7vyc7k6.js} +2 -2
  293. package/dist/chunk-d7vyc7k6.js.map +10 -0
  294. package/dist/{chunk-q7gn29y3.js → chunk-dp0cdtj2.js} +2 -2
  295. package/dist/{chunk-6x0pqh32.js → chunk-e5wf5vz0.js} +3 -1
  296. package/dist/chunk-e5wf5vz0.js.map +10 -0
  297. package/dist/{chunk-cn0fwwhy.js → chunk-efmm01gj.js} +108 -1045
  298. package/dist/chunk-efmm01gj.js.map +18 -0
  299. package/dist/{chunk-918wwnaa.js → chunk-ezne9wc9.js} +1224 -430
  300. package/dist/chunk-ezne9wc9.js.map +71 -0
  301. package/dist/{chunk-tbc1ngpd.js → chunk-fe8zwt8b.js} +58 -12
  302. package/dist/{chunk-tbc1ngpd.js.map → chunk-fe8zwt8b.js.map} +5 -4
  303. package/dist/{chunk-br3k6qbf.js → chunk-fm62y49k.js} +1 -1
  304. package/dist/{chunk-nq6gpjt7.js → chunk-fntqb7qy.js} +30 -4
  305. package/dist/{chunk-nq6gpjt7.js.map → chunk-fntqb7qy.js.map} +5 -5
  306. package/dist/{chunk-1cc1xaf3.js → chunk-fp2kq35z.js} +26 -10
  307. package/dist/{chunk-1cc1xaf3.js.map → chunk-fp2kq35z.js.map} +5 -5
  308. package/dist/{chunk-vvxtn22d.js → chunk-g663fahq.js} +2 -2
  309. package/dist/{chunk-k43ct2ke.js → chunk-gvj5cd3b.js} +16 -9
  310. package/dist/chunk-gvj5cd3b.js.map +12 -0
  311. package/dist/{chunk-rmakanzx.js → chunk-h33shhq6.js} +5 -5
  312. package/dist/{chunk-nn5xnx3s.js → chunk-h3pbv7n8.js} +1738 -38
  313. package/dist/chunk-h3pbv7n8.js.map +48 -0
  314. package/dist/chunk-hn2r7z41.js.map +1 -1
  315. package/dist/{chunk-pbcbn83d.js → chunk-hqsp2sx4.js} +54 -8
  316. package/dist/chunk-hqsp2sx4.js.map +14 -0
  317. package/dist/{chunk-d09e3rax.js → chunk-hwarjrgf.js} +1 -1
  318. package/dist/{chunk-vf57cr4t.js → chunk-hyesv9dv.js} +1 -1
  319. package/dist/chunk-hz5d43gn.js +45 -0
  320. package/dist/chunk-hz5d43gn.js.map +10 -0
  321. package/dist/{chunk-91mg3nj9.js → chunk-j936th07.js} +86 -41
  322. package/dist/chunk-j936th07.js.map +12 -0
  323. package/dist/chunk-kcqpk9w1.js +75 -0
  324. package/dist/chunk-kcqpk9w1.js.map +10 -0
  325. package/dist/{chunk-5vems3nx.js → chunk-m2nevja0.js} +2 -2
  326. package/dist/{chunk-x9v4cx1d.js → chunk-m36fw8ft.js} +1 -1
  327. package/dist/{chunk-a40ad1ft.js → chunk-mbsbxarb.js} +1 -1
  328. package/dist/chunk-mzx71snp.js +129 -0
  329. package/dist/chunk-mzx71snp.js.map +10 -0
  330. package/dist/{chunk-6aawea28.js → chunk-n8q5j6y5.js} +1 -1
  331. package/dist/{chunk-d7dnxdep.js → chunk-n9zpx9c6.js} +4 -4
  332. package/dist/{chunk-xvsc5m8n.js → chunk-npcr0228.js} +1 -1
  333. package/dist/chunk-nydf3dbe.js +663 -0
  334. package/dist/chunk-nydf3dbe.js.map +13 -0
  335. package/dist/chunk-pdt5cw8z.js +233 -0
  336. package/dist/chunk-pdt5cw8z.js.map +11 -0
  337. package/dist/{chunk-rj69qcrd.js → chunk-pgrf64hp.js} +55 -7
  338. package/dist/chunk-pgrf64hp.js.map +12 -0
  339. package/dist/{chunk-y5tah2kf.js → chunk-q4pmvkg0.js} +1 -1
  340. package/dist/chunk-qhqgp4jf.js +1418 -0
  341. package/dist/chunk-qhqgp4jf.js.map +22 -0
  342. package/dist/{chunk-48qjhh6v.js → chunk-qx00vjrj.js} +19 -60
  343. package/dist/chunk-qx00vjrj.js.map +13 -0
  344. package/dist/{chunk-5948n82c.js → chunk-r6szek0x.js} +184 -7
  345. package/dist/chunk-r6szek0x.js.map +10 -0
  346. package/dist/{chunk-v4jbb3rs.js → chunk-rap5w0x0.js} +156 -2
  347. package/dist/chunk-rap5w0x0.js.map +10 -0
  348. package/dist/{chunk-pfp1txq2.js → chunk-sgx82nnt.js} +5 -31
  349. package/dist/{chunk-pfp1txq2.js.map → chunk-sgx82nnt.js.map} +3 -4
  350. package/dist/{chunk-bkpke1sg.js → chunk-t5608tkq.js} +3 -1
  351. package/dist/{chunk-bkpke1sg.js.map → chunk-t5608tkq.js.map} +3 -3
  352. package/dist/{chunk-29yx306f.js → chunk-tdxfsg1c.js} +507 -265
  353. package/dist/chunk-tdxfsg1c.js.map +23 -0
  354. package/dist/{chunk-d5rjr8c0.js → chunk-vabga7fk.js} +1 -1
  355. package/dist/{chunk-dhdha526.js → chunk-vhbw5sqm.js} +26 -2
  356. package/dist/chunk-vhbw5sqm.js.map +10 -0
  357. package/dist/{chunk-e6k4thh5.js → chunk-vpgwq5nf.js} +98 -12
  358. package/dist/chunk-vpgwq5nf.js.map +21 -0
  359. package/dist/{chunk-61y5xs4p.js → chunk-vyt322b6.js} +69 -50
  360. package/dist/{chunk-61y5xs4p.js.map → chunk-vyt322b6.js.map} +4 -4
  361. package/dist/chunk-waqk73p1.js +2380 -0
  362. package/dist/chunk-waqk73p1.js.map +23 -0
  363. package/dist/chunk-wsc1brye.js +27 -0
  364. package/dist/chunk-wsc1brye.js.map +10 -0
  365. package/dist/{chunk-96yw3pwd.js → chunk-y7dbmaqh.js} +28 -2
  366. package/dist/chunk-y7dbmaqh.js.map +10 -0
  367. package/dist/{chunk-6vb4st8k.js → chunk-yc9ners4.js} +120 -19
  368. package/dist/{chunk-6vb4st8k.js.map → chunk-yc9ners4.js.map} +8 -8
  369. package/dist/{chunk-dvd2fp9q.js → chunk-zbc929zg.js} +28 -4
  370. package/dist/chunk-zbc929zg.js.map +13 -0
  371. package/dist/chunk-zrvhsq7f.js +37 -0
  372. package/dist/chunk-zrvhsq7f.js.map +10 -0
  373. package/dist/datasets/write.js +5 -5
  374. package/dist/error-reporting/internal.js +3 -3
  375. package/dist/errors/catalog.d.ts +26 -0
  376. package/dist/errors/catalog.d.ts.map +1 -1
  377. package/dist/errors/internal.d.ts.map +1 -1
  378. package/dist/errors/internal.js +1 -1
  379. package/dist/events/definitions.d.ts +7 -0
  380. package/dist/events/definitions.d.ts.map +1 -1
  381. package/dist/events/execution.d.ts.map +1 -1
  382. package/dist/events/index.d.ts +2 -3
  383. package/dist/events/index.d.ts.map +1 -1
  384. package/dist/events/index.js +8 -10
  385. package/dist/events/index.js.map +1 -1
  386. package/dist/events/scope.d.ts.map +1 -1
  387. package/dist/events/scope.js +1 -1
  388. package/dist/events/selectors/builder.d.ts +12 -1
  389. package/dist/events/selectors/builder.d.ts.map +1 -1
  390. package/dist/events/selectors/index.d.ts +2 -2
  391. package/dist/events/selectors/index.d.ts.map +1 -1
  392. package/dist/events/selectors/index.js +2 -2
  393. package/dist/events/selectors/types.d.ts +19 -3
  394. package/dist/events/selectors/types.d.ts.map +1 -1
  395. package/dist/events/service.d.ts +17 -2
  396. package/dist/events/service.d.ts.map +1 -1
  397. package/dist/events/types/index.d.ts +3 -1
  398. package/dist/events/types/index.d.ts.map +1 -1
  399. package/dist/events/types/users.d.ts +63 -0
  400. package/dist/events/types/users.d.ts.map +1 -0
  401. package/dist/events/view-conditions.d.ts +34 -0
  402. package/dist/events/view-conditions.d.ts.map +1 -0
  403. package/dist/execution/agent.d.ts +15 -0
  404. package/dist/execution/agent.d.ts.map +1 -1
  405. package/dist/execution/agent.js +63 -57
  406. package/dist/execution/agent.js.map +1 -1
  407. package/dist/execution/authorization.d.ts.map +1 -1
  408. package/dist/execution/authorized-object-reader.d.ts +51 -2
  409. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  410. package/dist/execution/lineage.d.ts +7 -0
  411. package/dist/execution/lineage.d.ts.map +1 -0
  412. package/dist/execution/object-reader-ontology.d.ts +2 -2
  413. package/dist/execution/object-reader-ontology.d.ts.map +1 -1
  414. package/dist/execution/object-reader-security.d.ts +24 -3
  415. package/dist/execution/object-reader-security.d.ts.map +1 -1
  416. package/dist/execution/object-reader-users.d.ts +20 -0
  417. package/dist/execution/object-reader-users.d.ts.map +1 -0
  418. package/dist/execution/preparation.d.ts +23 -0
  419. package/dist/execution/preparation.d.ts.map +1 -0
  420. package/dist/execution/primitive.js +61 -57
  421. package/dist/execution/primitive.js.map +1 -1
  422. package/dist/execution/request.d.ts +2 -1
  423. package/dist/execution/request.d.ts.map +1 -1
  424. package/dist/execution/request.js +64 -56
  425. package/dist/execution/request.js.map +3 -3
  426. package/dist/execution/unique-lookup.d.ts +14 -0
  427. package/dist/execution/unique-lookup.d.ts.map +1 -0
  428. package/dist/execution/visible-objects.d.ts +12 -0
  429. package/dist/execution/visible-objects.d.ts.map +1 -0
  430. package/dist/http/api-routes.d.ts +17 -0
  431. package/dist/http/api-routes.d.ts.map +1 -1
  432. package/dist/http/index.js +1 -1
  433. package/dist/index.d.ts +32 -15
  434. package/dist/index.d.ts.map +1 -1
  435. package/dist/index.js +137 -126
  436. package/dist/index.js.map +1 -1
  437. package/dist/lake-storage/index.js +5 -5
  438. package/dist/materialization/errors.d.ts +25 -0
  439. package/dist/materialization/errors.d.ts.map +1 -1
  440. package/dist/materialization/event-envelopes.d.ts +5 -0
  441. package/dist/materialization/event-envelopes.d.ts.map +1 -1
  442. package/dist/materialization/index.d.ts +1 -1
  443. package/dist/materialization/index.d.ts.map +1 -1
  444. package/dist/materialization/index.js +14 -8
  445. package/dist/materialization/index.js.map +1 -1
  446. package/dist/materialization/model.d.ts +20 -2
  447. package/dist/materialization/model.d.ts.map +1 -1
  448. package/dist/materializer/edits/commit.d.ts.map +1 -1
  449. package/dist/materializer/edits/load-state.d.ts +5 -1
  450. package/dist/materializer/edits/load-state.d.ts.map +1 -1
  451. package/dist/materializer/edits/plan.d.ts.map +1 -1
  452. package/dist/materializer/edits/unique-values.d.ts +47 -0
  453. package/dist/materializer/edits/unique-values.d.ts.map +1 -0
  454. package/dist/materializer/edits/working-state.d.ts +6 -1
  455. package/dist/materializer/edits/working-state.d.ts.map +1 -1
  456. package/dist/materializer/execution/work-records.d.ts +7 -1
  457. package/dist/materializer/execution/work-records.d.ts.map +1 -1
  458. package/dist/materializer/index.js +45 -41
  459. package/dist/materializer/index.js.map +1 -1
  460. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  461. package/dist/materializer/projections/source-materialization.d.ts +1 -0
  462. package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
  463. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  464. package/dist/materializer/shared/projection-run.d.ts +0 -1
  465. package/dist/materializer/shared/projection-run.d.ts.map +1 -1
  466. package/dist/materializer/telemetry/plan.d.ts.map +1 -1
  467. package/dist/models/audio/catalog.d.ts +13 -1
  468. package/dist/models/audio/catalog.d.ts.map +1 -1
  469. package/dist/models/audio/errors.d.ts +6 -1
  470. package/dist/models/audio/errors.d.ts.map +1 -1
  471. package/dist/models/audio/runtime.d.ts.map +1 -1
  472. package/dist/models/audio/speech.d.ts +8 -0
  473. package/dist/models/audio/speech.d.ts.map +1 -0
  474. package/dist/models/audio/types.d.ts +93 -0
  475. package/dist/models/audio/types.d.ts.map +1 -1
  476. package/dist/models/calls.d.ts +27 -0
  477. package/dist/models/calls.d.ts.map +1 -0
  478. package/dist/models/catalog-index.d.ts +7 -4
  479. package/dist/models/catalog-index.d.ts.map +1 -1
  480. package/dist/models/catalog.d.ts +55 -3
  481. package/dist/models/catalog.d.ts.map +1 -1
  482. package/dist/models/decision/runtime.d.ts +6 -1
  483. package/dist/models/decision/runtime.d.ts.map +1 -1
  484. package/dist/models/decision/validation.d.ts +4 -1
  485. package/dist/models/decision/validation.d.ts.map +1 -1
  486. package/dist/models/definitions.d.ts +23 -1
  487. package/dist/models/definitions.d.ts.map +1 -1
  488. package/dist/models/events.d.ts +12 -1
  489. package/dist/models/events.d.ts.map +1 -1
  490. package/dist/models/execution/binding.d.ts +3 -1
  491. package/dist/models/execution/binding.d.ts.map +1 -1
  492. package/dist/models/execution/index.d.ts +1 -0
  493. package/dist/models/execution/index.d.ts.map +1 -1
  494. package/dist/models/execution/index.js +44 -34
  495. package/dist/models/execution/index.js.map +1 -1
  496. package/dist/models/execution/model-call-accounting.d.ts.map +1 -1
  497. package/dist/models/execution/model-call-recorder.d.ts +3 -0
  498. package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
  499. package/dist/models/execution/usage.d.ts.map +1 -1
  500. package/dist/models/execution.d.ts +4 -2
  501. package/dist/models/execution.d.ts.map +1 -1
  502. package/dist/models/generation-types.d.ts +8 -1
  503. package/dist/models/generation-types.d.ts.map +1 -1
  504. package/dist/models/image/catalog.d.ts +13 -0
  505. package/dist/models/image/catalog.d.ts.map +1 -0
  506. package/dist/models/image/errors.d.ts +8 -0
  507. package/dist/models/image/errors.d.ts.map +1 -0
  508. package/dist/models/image/runtime.d.ts +8 -0
  509. package/dist/models/image/runtime.d.ts.map +1 -0
  510. package/dist/models/image/types.d.ts +103 -0
  511. package/dist/models/image/types.d.ts.map +1 -0
  512. package/dist/models/index.d.ts +12 -8
  513. package/dist/models/index.d.ts.map +1 -1
  514. package/dist/models/index.js +17 -7
  515. package/dist/models/index.js.map +1 -1
  516. package/dist/models/input-file.d.ts +9 -0
  517. package/dist/models/input-file.d.ts.map +1 -0
  518. package/dist/models/language-model.d.ts +13 -0
  519. package/dist/models/language-model.d.ts.map +1 -1
  520. package/dist/models/pricing.d.ts +25 -10
  521. package/dist/models/pricing.d.ts.map +1 -1
  522. package/dist/models/rate-card.d.ts +44 -6
  523. package/dist/models/rate-card.d.ts.map +1 -1
  524. package/dist/objects/conditional-writes.d.ts +37 -0
  525. package/dist/objects/conditional-writes.d.ts.map +1 -0
  526. package/dist/objects/execution.d.ts +2 -0
  527. package/dist/objects/execution.d.ts.map +1 -1
  528. package/dist/objects/index.d.ts +1 -0
  529. package/dist/objects/index.d.ts.map +1 -1
  530. package/dist/objects/index.js +68 -58
  531. package/dist/objects/index.js.map +1 -1
  532. package/dist/objects/link/authorization.d.ts +3 -0
  533. package/dist/objects/link/authorization.d.ts.map +1 -1
  534. package/dist/objects/link/endpoints.d.ts +21 -2
  535. package/dist/objects/link/endpoints.d.ts.map +1 -1
  536. package/dist/objects/link/remove.d.ts.map +1 -1
  537. package/dist/objects/link/upsert-batch.d.ts.map +1 -1
  538. package/dist/objects/link/upsert.d.ts.map +1 -1
  539. package/dist/objects/materializer-adapter.d.ts +13 -4
  540. package/dist/objects/materializer-adapter.d.ts.map +1 -1
  541. package/dist/objects/object/delete.d.ts +3 -0
  542. package/dist/objects/object/delete.d.ts.map +1 -1
  543. package/dist/objects/object/upsert-batch.d.ts.map +1 -1
  544. package/dist/objects/object/upsert.d.ts.map +1 -1
  545. package/dist/objects/query/current-user.d.ts +17 -0
  546. package/dist/objects/query/current-user.d.ts.map +1 -0
  547. package/dist/objects/query/executor.d.ts +14 -0
  548. package/dist/objects/query/executor.d.ts.map +1 -1
  549. package/dist/objects/query/index.d.ts +2 -2
  550. package/dist/objects/query/index.d.ts.map +1 -1
  551. package/dist/objects/query/index.js +49 -44
  552. package/dist/objects/query/index.js.map +1 -1
  553. package/dist/objects/query/ir.d.ts +19 -1
  554. package/dist/objects/query/ir.d.ts.map +1 -1
  555. package/dist/objects/query/matches-predicate.d.ts +9 -0
  556. package/dist/objects/query/matches-predicate.d.ts.map +1 -0
  557. package/dist/objects/query/normalize.d.ts.map +1 -1
  558. package/dist/objects/query/user-expansions.d.ts +27 -0
  559. package/dist/objects/query/user-expansions.d.ts.map +1 -0
  560. package/dist/objects/query/validate.d.ts.map +1 -1
  561. package/dist/objects/runtime-batch.d.ts +3 -1
  562. package/dist/objects/runtime-batch.d.ts.map +1 -1
  563. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  564. package/dist/objects/sdk/query-executor.d.ts +6 -0
  565. package/dist/objects/sdk/query-executor.d.ts.map +1 -1
  566. package/dist/objects/serialize.d.ts +39 -0
  567. package/dist/objects/serialize.d.ts.map +1 -0
  568. package/dist/objects/unique-violation.d.ts +22 -0
  569. package/dist/objects/unique-violation.d.ts.map +1 -0
  570. package/dist/ontology/builders.d.ts +3 -1
  571. package/dist/ontology/builders.d.ts.map +1 -1
  572. package/dist/ontology/index.d.ts +2 -2
  573. package/dist/ontology/index.d.ts.map +1 -1
  574. package/dist/ontology/index.js +11 -7
  575. package/dist/ontology/index.js.map +1 -1
  576. package/dist/ontology/internal.js +7 -5
  577. package/dist/ontology/internal.js.map +3 -3
  578. package/dist/ontology/json-schema.d.ts.map +1 -1
  579. package/dist/ontology/primitives.d.ts +3 -0
  580. package/dist/ontology/primitives.d.ts.map +1 -1
  581. package/dist/ontology/registry.d.ts +6 -0
  582. package/dist/ontology/registry.d.ts.map +1 -1
  583. package/dist/ontology/types.d.ts +9 -0
  584. package/dist/ontology/types.d.ts.map +1 -1
  585. package/dist/ontology/unique-values.d.ts +26 -0
  586. package/dist/ontology/unique-values.d.ts.map +1 -0
  587. package/dist/ontology/user-ref.d.ts +23 -0
  588. package/dist/ontology/user-ref.d.ts.map +1 -1
  589. package/dist/ontology/validation/properties.d.ts.map +1 -1
  590. package/dist/ontology/validation/schema.d.ts.map +1 -1
  591. package/dist/pipelines/index.js +43 -40
  592. package/dist/pipelines/index.js.map +1 -1
  593. package/dist/projections/internal.js +36 -33
  594. package/dist/projections/internal.js.map +1 -1
  595. package/dist/projections/registry.d.ts +4 -0
  596. package/dist/projections/registry.d.ts.map +1 -1
  597. package/dist/projections/revision.d.ts +15 -0
  598. package/dist/projections/revision.d.ts.map +1 -1
  599. package/dist/projections/run-dispatch.d.ts.map +1 -1
  600. package/dist/projections/types.d.ts +2 -0
  601. package/dist/projections/types.d.ts.map +1 -1
  602. package/dist/query.d.ts +4 -2
  603. package/dist/query.d.ts.map +1 -1
  604. package/dist/query.js +2 -2
  605. package/dist/rules/execution.d.ts.map +1 -1
  606. package/dist/runtime/ai-cost.d.ts +2 -0
  607. package/dist/runtime/ai-cost.d.ts.map +1 -1
  608. package/dist/runtime/ai-usage.d.ts +7 -0
  609. package/dist/runtime/ai-usage.d.ts.map +1 -1
  610. package/dist/runtime/host.d.ts.map +1 -1
  611. package/dist/runtime/index.d.ts +1 -1
  612. package/dist/runtime/index.d.ts.map +1 -1
  613. package/dist/runtime/internal.js +42 -38
  614. package/dist/runtime/internal.js.map +1 -1
  615. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  616. package/dist/runtime/sixb.d.ts +2 -0
  617. package/dist/runtime/sixb.d.ts.map +1 -1
  618. package/dist/runtime/types.d.ts +66 -8
  619. package/dist/runtime/types.d.ts.map +1 -1
  620. package/dist/sandboxes/index.js +7 -6
  621. package/dist/sandboxes/index.js.map +1 -1
  622. package/dist/schedules/builders.d.ts.map +1 -1
  623. package/dist/schedules/index.js +3 -3
  624. package/dist/schedules/runtime.d.ts.map +1 -1
  625. package/dist/schedules/validation.d.ts.map +1 -1
  626. package/dist/security/grants.d.ts +12 -4
  627. package/dist/security/grants.d.ts.map +1 -1
  628. package/dist/security/index.d.ts +1 -1
  629. package/dist/security/index.d.ts.map +1 -1
  630. package/dist/security/internal.js +1 -1
  631. package/dist/security/project.d.ts +4 -1
  632. package/dist/security/project.d.ts.map +1 -1
  633. package/dist/security/public.js +2 -2
  634. package/dist/security/registry.d.ts +6 -0
  635. package/dist/security/registry.d.ts.map +1 -1
  636. package/dist/security/types.d.ts +47 -9
  637. package/dist/security/types.d.ts.map +1 -1
  638. package/dist/security/validation.d.ts.map +1 -1
  639. package/dist/security/view-conditions.d.ts +37 -0
  640. package/dist/security/view-conditions.d.ts.map +1 -0
  641. package/dist/shares/execution.d.ts.map +1 -1
  642. package/dist/shares/internal.js +34 -31
  643. package/dist/shares/internal.js.map +2 -2
  644. package/dist/storage/action-runs/failure.js +2 -2
  645. package/dist/storage/action-runs/provider.js +1 -1
  646. package/dist/storage/action-runs/types.d.ts +1 -1
  647. package/dist/storage/action-runs/types.d.ts.map +1 -1
  648. package/dist/storage/agents/errors.d.ts +3 -1
  649. package/dist/storage/agents/errors.d.ts.map +1 -1
  650. package/dist/storage/agents/in-memory.d.ts +120 -3
  651. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  652. package/dist/storage/agents/index.d.ts +2 -2
  653. package/dist/storage/agents/index.d.ts.map +1 -1
  654. package/dist/storage/agents/provider.d.ts +154 -4
  655. package/dist/storage/agents/provider.d.ts.map +1 -1
  656. package/dist/storage/agents/provider.js +60 -5
  657. package/dist/storage/agents/provider.js.map +1 -1
  658. package/dist/storage/agents/types.d.ts +565 -13
  659. package/dist/storage/agents/types.d.ts.map +1 -1
  660. package/dist/storage/ai-cost/analytics.d.ts +10 -1
  661. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  662. package/dist/storage/ai-cost/groups.d.ts +9 -0
  663. package/dist/storage/ai-cost/groups.d.ts.map +1 -1
  664. package/dist/storage/ai-cost/index.d.ts +1 -1
  665. package/dist/storage/ai-cost/index.d.ts.map +1 -1
  666. package/dist/storage/ai-cost/provider.d.ts +2 -1
  667. package/dist/storage/ai-cost/provider.d.ts.map +1 -1
  668. package/dist/storage/ai-cost/provider.js +11 -5
  669. package/dist/storage/ai-cost/provider.js.map +1 -1
  670. package/dist/storage/ai-cost/types.d.ts +14 -2
  671. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  672. package/dist/storage/ai-cost/validation.d.ts.map +1 -1
  673. package/dist/storage/ai-limits/enforcement.js +5 -4
  674. package/dist/storage/ai-limits/enforcement.js.map +1 -1
  675. package/dist/storage/ai-limits/provider.d.ts +1 -1
  676. package/dist/storage/ai-limits/provider.d.ts.map +1 -1
  677. package/dist/storage/ai-limits/provider.js +3 -2
  678. package/dist/storage/ai-limits/provider.js.map +1 -1
  679. package/dist/storage/ai-usage/in-memory.d.ts +5 -1
  680. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  681. package/dist/storage/ai-usage/index.d.ts +2 -2
  682. package/dist/storage/ai-usage/index.d.ts.map +1 -1
  683. package/dist/storage/ai-usage/record.d.ts +5 -1
  684. package/dist/storage/ai-usage/record.d.ts.map +1 -1
  685. package/dist/storage/ai-usage/types.d.ts +33 -0
  686. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  687. package/dist/storage/ai-usage/usage.d.ts +2 -0
  688. package/dist/storage/ai-usage/usage.d.ts.map +1 -1
  689. package/dist/storage/artifacts/errors.d.ts +12 -2
  690. package/dist/storage/artifacts/errors.d.ts.map +1 -1
  691. package/dist/storage/artifacts/in-memory.d.ts +23 -2
  692. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  693. package/dist/storage/artifacts/index.d.ts +2 -2
  694. package/dist/storage/artifacts/index.d.ts.map +1 -1
  695. package/dist/storage/artifacts/record.d.ts +19 -2
  696. package/dist/storage/artifacts/record.d.ts.map +1 -1
  697. package/dist/storage/artifacts/types.d.ts +87 -8
  698. package/dist/storage/artifacts/types.d.ts.map +1 -1
  699. package/dist/storage/auth/in-memory/auth-storage.d.ts +3 -2
  700. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  701. package/dist/storage/auth/in-memory/users.d.ts +7 -3
  702. package/dist/storage/auth/in-memory/users.d.ts.map +1 -1
  703. package/dist/storage/auth/index.d.ts +1 -1
  704. package/dist/storage/auth/index.d.ts.map +1 -1
  705. package/dist/storage/auth/types.d.ts +40 -9
  706. package/dist/storage/auth/types.d.ts.map +1 -1
  707. package/dist/storage/connector-connections/provider.js +1 -1
  708. package/dist/storage/executions/in-memory.d.ts +2 -1
  709. package/dist/storage/executions/in-memory.d.ts.map +1 -1
  710. package/dist/storage/executions/index.d.ts +1 -1
  711. package/dist/storage/executions/index.d.ts.map +1 -1
  712. package/dist/storage/executions/types.d.ts +15 -0
  713. package/dist/storage/executions/types.d.ts.map +1 -1
  714. package/dist/storage/file-upload-sessions/provider.js +15 -12
  715. package/dist/storage/file-upload-sessions/provider.js.map +1 -1
  716. package/dist/storage/index.d.ts +13 -11
  717. package/dist/storage/index.d.ts.map +1 -1
  718. package/dist/storage/index.js +50 -39
  719. package/dist/storage/index.js.map +1 -1
  720. package/dist/storage/internal.d.ts +2 -2
  721. package/dist/storage/internal.d.ts.map +1 -1
  722. package/dist/storage/internal.js +19 -8
  723. package/dist/storage/internal.js.map +1 -1
  724. package/dist/storage/migrations/migrate-storage.d.ts +4 -1
  725. package/dist/storage/migrations/migrate-storage.d.ts.map +1 -1
  726. package/dist/storage/migrations/prepare-unique-properties.d.ts +18 -0
  727. package/dist/storage/migrations/prepare-unique-properties.d.ts.map +1 -0
  728. package/dist/storage/objects/guard.d.ts +1 -1
  729. package/dist/storage/objects/guard.d.ts.map +1 -1
  730. package/dist/storage/objects/in-memory/conditional-reader.d.ts +5 -0
  731. package/dist/storage/objects/in-memory/conditional-reader.d.ts.map +1 -0
  732. package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
  733. package/dist/storage/objects/in-memory/read-scope.d.ts +3 -9
  734. package/dist/storage/objects/in-memory/read-scope.d.ts.map +1 -1
  735. package/dist/storage/objects/in-memory/read-source.d.ts +10 -1
  736. package/dist/storage/objects/in-memory/read-source.d.ts.map +1 -1
  737. package/dist/storage/objects/in-memory/scoped-reader.d.ts +14 -0
  738. package/dist/storage/objects/in-memory/scoped-reader.d.ts.map +1 -0
  739. package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -1
  740. package/dist/storage/objects/in-memory/storage.d.ts +36 -1
  741. package/dist/storage/objects/in-memory/storage.d.ts.map +1 -1
  742. package/dist/storage/objects/index.d.ts +2 -2
  743. package/dist/storage/objects/index.d.ts.map +1 -1
  744. package/dist/storage/objects/read-scope.d.ts +9 -1
  745. package/dist/storage/objects/read-scope.d.ts.map +1 -1
  746. package/dist/storage/objects/types.d.ts +64 -1
  747. package/dist/storage/objects/types.d.ts.map +1 -1
  748. package/dist/storage/ontology/in-memory/index.d.ts +2 -0
  749. package/dist/storage/ontology/in-memory/index.d.ts.map +1 -1
  750. package/dist/storage/ontology/in-memory/materializations.d.ts +1 -0
  751. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  752. package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
  753. package/dist/storage/ontology/in-memory/unique-values.d.ts +32 -0
  754. package/dist/storage/ontology/in-memory/unique-values.d.ts.map +1 -0
  755. package/dist/storage/ontology/index.d.ts +4 -1
  756. package/dist/storage/ontology/index.d.ts.map +1 -1
  757. package/dist/storage/ontology/materializations.d.ts +34 -1
  758. package/dist/storage/ontology/materializations.d.ts.map +1 -1
  759. package/dist/storage/ontology/provider-work.d.ts +15 -2
  760. package/dist/storage/ontology/provider-work.d.ts.map +1 -1
  761. package/dist/storage/ontology/provider.d.ts +1 -1
  762. package/dist/storage/ontology/provider.d.ts.map +1 -1
  763. package/dist/storage/ontology/provider.js +9 -4
  764. package/dist/storage/ontology/provider.js.map +1 -1
  765. package/dist/storage/ontology/unique-values.d.ts +54 -0
  766. package/dist/storage/ontology/unique-values.d.ts.map +1 -0
  767. package/dist/storage/operation-scope.d.ts +1 -1
  768. package/dist/storage/operation-scope.d.ts.map +1 -1
  769. package/dist/storage/operation-scope.js +1 -1
  770. package/dist/storage/projection-runs/in-memory.d.ts +0 -6
  771. package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
  772. package/dist/storage/projection-runs/provider.js +2 -2
  773. package/dist/storage/share-grants/provider.js +4 -3
  774. package/dist/storage/share-grants/provider.js.map +1 -1
  775. package/dist/storage/types.d.ts +2 -2
  776. package/dist/storage/types.d.ts.map +1 -1
  777. package/dist/storage/workflow-runs/provider.js +15 -12
  778. package/dist/storage/workflow-runs/provider.js.map +1 -1
  779. package/dist/syncs/index.js +42 -39
  780. package/dist/syncs/index.js.map +1 -1
  781. package/dist/testing/agent-approval-storage-contract.d.ts +17 -0
  782. package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -0
  783. package/dist/testing/agent-memory-storage-contract.d.ts +12 -0
  784. package/dist/testing/agent-memory-storage-contract.d.ts.map +1 -0
  785. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  786. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  787. package/dist/testing/ai-limit-storage-contract.d.ts +0 -1
  788. package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -1
  789. package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -1
  790. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  791. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  792. package/dist/testing/auth-storage-contract.d.ts +13 -0
  793. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  794. package/dist/testing/broker-contract.d.ts +5 -0
  795. package/dist/testing/broker-contract.d.ts.map +1 -1
  796. package/dist/testing/effective-storage-contract.d.ts.map +1 -1
  797. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  798. package/dist/testing/file-upload-session-storage-contract.d.ts.map +1 -1
  799. package/dist/testing/index.d.ts +9 -5
  800. package/dist/testing/index.d.ts.map +1 -1
  801. package/dist/testing/index.js +7938 -3743
  802. package/dist/testing/index.js.map +29 -25
  803. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  804. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  805. package/dist/testing/object-conditional-read-scope-contract.d.ts +11 -0
  806. package/dist/testing/object-conditional-read-scope-contract.d.ts.map +1 -0
  807. package/dist/testing/object-query-contract.d.ts +0 -2
  808. package/dist/testing/object-query-contract.d.ts.map +1 -1
  809. package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
  810. package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
  811. package/dist/testing/queues-contract.d.ts +5 -0
  812. package/dist/testing/queues-contract.d.ts.map +1 -1
  813. package/dist/testing/sandboxes-contract.d.ts.map +1 -1
  814. package/dist/testing/share-grant-storage-contract.d.ts.map +1 -1
  815. package/dist/testing/share-session-storage-contract.d.ts.map +1 -1
  816. package/dist/testing/unique-values-contract.d.ts +21 -0
  817. package/dist/testing/unique-values-contract.d.ts.map +1 -0
  818. package/dist/testing/webhook-execution.d.ts +0 -8
  819. package/dist/testing/webhook-execution.d.ts.map +1 -1
  820. package/dist/testing/webhook-run-storage-contract.d.ts.map +1 -1
  821. package/dist/users/execution.d.ts +40 -0
  822. package/dist/users/execution.d.ts.map +1 -0
  823. package/dist/users/index.d.ts +3 -0
  824. package/dist/users/index.d.ts.map +1 -0
  825. package/dist/webhooks/internal.js +34 -31
  826. package/dist/webhooks/internal.js.map +2 -2
  827. package/dist/workers/index.js +4 -6
  828. package/dist/workers/index.js.map +4 -4
  829. package/dist/workers/queue-worker.d.ts +0 -2
  830. package/dist/workers/queue-worker.d.ts.map +1 -1
  831. package/dist/workers/worker.d.ts +0 -2
  832. package/dist/workers/worker.d.ts.map +1 -1
  833. package/dist/workflows/builders.d.ts.map +1 -1
  834. package/dist/workflows/index.js +67 -63
  835. package/dist/workflows/index.js.map +1 -1
  836. package/dist/workflows/request.d.ts +12 -1
  837. package/dist/workflows/request.d.ts.map +1 -1
  838. package/dist/workflows/types.d.ts +6 -2
  839. package/dist/workflows/types.d.ts.map +1 -1
  840. package/dist/workflows/validation.d.ts.map +1 -1
  841. package/package.json +1 -1
  842. package/src/actions/commit-edits.ts +6 -1
  843. package/src/actions/execution.ts +42 -15
  844. package/src/actions/read-facade.ts +33 -0
  845. package/src/actions/request.ts +224 -71
  846. package/src/actions/run/context.ts +47 -1
  847. package/src/actions/run/execute.ts +13 -6
  848. package/src/actions/run/executor.ts +11 -2
  849. package/src/actions/run/normalize.ts +12 -2
  850. package/src/actions/run/phases.ts +2 -0
  851. package/src/actions/run/run-action.ts +12 -3
  852. package/src/actions/run/signals.ts +3 -9
  853. package/src/actions/run/types.ts +17 -1
  854. package/src/actions/run-authorization.ts +72 -0
  855. package/src/actions/types/context.ts +20 -3
  856. package/src/actions/validators.ts +19 -8
  857. package/src/activity/README.md +5 -2
  858. package/src/activity/timeline.ts +39 -78
  859. package/src/agents/accounting.ts +59 -0
  860. package/src/agents/adapters.ts +10 -0
  861. package/src/agents/agent-mail.ts +29 -0
  862. package/src/agents/api-gateway.ts +14 -3
  863. package/src/agents/approval-continuation.ts +48 -0
  864. package/src/agents/approval-executor.ts +318 -0
  865. package/src/agents/approval-outcome.ts +59 -0
  866. package/src/agents/approvals.ts +566 -0
  867. package/src/agents/authority.ts +24 -1
  868. package/src/agents/builders.ts +5 -3
  869. package/src/agents/cancel.ts +103 -0
  870. package/src/agents/child-question.ts +46 -0
  871. package/src/agents/children.ts +404 -0
  872. package/src/agents/context-compaction.ts +12 -0
  873. package/src/agents/errors.ts +31 -0
  874. package/src/agents/execution.ts +788 -90
  875. package/src/agents/fork.ts +158 -0
  876. package/src/agents/ids.ts +18 -6
  877. package/src/agents/index.ts +55 -0
  878. package/src/agents/memory-execution.ts +186 -0
  879. package/src/agents/memory.ts +178 -0
  880. package/src/agents/message.ts +57 -0
  881. package/src/agents/model-loop.ts +93 -6
  882. package/src/agents/model-routing.ts +193 -0
  883. package/src/agents/participants.ts +213 -0
  884. package/src/agents/reference.ts +2 -0
  885. package/src/agents/request.ts +398 -69
  886. package/src/agents/run-scope.ts +134 -0
  887. package/src/agents/streams/index.ts +5 -0
  888. package/src/agents/streams/internal.ts +1 -0
  889. package/src/agents/streams/protocol.ts +385 -7
  890. package/src/agents/subagent-runs.ts +41 -0
  891. package/src/agents/thread-access.ts +137 -0
  892. package/src/agents/tool-definition.ts +5 -3
  893. package/src/agents/types.ts +35 -10
  894. package/src/agents/validation.ts +2 -0
  895. package/src/artifacts/access.ts +125 -0
  896. package/src/artifacts/canvas.ts +369 -0
  897. package/src/artifacts/csv.ts +10 -0
  898. package/src/artifacts/errors.ts +12 -1
  899. package/src/artifacts/execution.ts +436 -36
  900. package/src/artifacts/formula/check.ts +171 -0
  901. package/src/artifacts/formula/evaluate.ts +288 -0
  902. package/src/artifacts/formula/index.ts +199 -0
  903. package/src/artifacts/formula/parser.ts +357 -0
  904. package/src/artifacts/frames/assets.ts +35 -19
  905. package/src/artifacts/frames/entries.ts +35 -0
  906. package/src/artifacts/frames/grants.ts +10 -9
  907. package/src/artifacts/frames/index.ts +8 -2
  908. package/src/artifacts/frames/kit.ts +191 -14
  909. package/src/artifacts/frames/probe.ts +66 -18
  910. package/src/artifacts/frames/protocol.ts +164 -10
  911. package/src/artifacts/frames/runtime.ts +273 -28
  912. package/src/artifacts/index.ts +66 -2
  913. package/src/artifacts/kinds.ts +1 -1
  914. package/src/artifacts/limits.ts +31 -0
  915. package/src/artifacts/live-sheet.ts +345 -0
  916. package/src/artifacts/outline.ts +34 -1
  917. package/src/artifacts/publish/index.ts +2 -0
  918. package/src/artifacts/publish/publish.ts +120 -34
  919. package/src/artifacts/publish/queries.ts +336 -0
  920. package/src/artifacts/publish/references.ts +18 -13
  921. package/src/artifacts/publish/validate/canvas.ts +118 -0
  922. package/src/artifacts/publish/validate/html.ts +78 -0
  923. package/src/artifacts/publish/validate/page.ts +65 -0
  924. package/src/artifacts/publish/validate/sheet.ts +115 -69
  925. package/src/artifacts/publish/validate/slides.ts +11 -63
  926. package/src/artifacts/queries.ts +512 -0
  927. package/src/artifacts/resolve.ts +20 -5
  928. package/src/artifacts/run-query.ts +212 -0
  929. package/src/artifacts/serialize-query.ts +25 -0
  930. package/src/artifacts/sheet-rules.ts +180 -0
  931. package/src/artifacts/tones.ts +20 -0
  932. package/src/artifacts/workbook.ts +374 -15
  933. package/src/auth/index.ts +4 -0
  934. package/src/auth/member-events.ts +114 -0
  935. package/src/auth/profile.ts +118 -0
  936. package/src/auth/runtime.ts +190 -9
  937. package/src/auth/strategy.ts +3 -0
  938. package/src/auth/types.ts +32 -0
  939. package/src/authorization/decision.ts +47 -0
  940. package/src/authorization/event-visibility.ts +17 -16
  941. package/src/authorization/grant-kinds.ts +32 -0
  942. package/src/authorization/index.ts +6 -1
  943. package/src/authorization/resolve.ts +58 -1
  944. package/src/authorization/run-visibility.ts +8 -1
  945. package/src/authorization/types.ts +14 -0
  946. package/src/errors/catalog.ts +26 -1
  947. package/src/errors/internal.ts +17 -8
  948. package/src/events/definitions.ts +26 -0
  949. package/src/events/execution.ts +43 -6
  950. package/src/events/index.ts +10 -1
  951. package/src/events/scope.ts +2 -0
  952. package/src/events/selectors/builder.ts +50 -0
  953. package/src/events/selectors/index.ts +4 -0
  954. package/src/events/selectors/types.ts +32 -1
  955. package/src/events/service.ts +55 -2
  956. package/src/events/types/index.ts +10 -0
  957. package/src/events/types/users.ts +73 -0
  958. package/src/events/view-conditions.ts +241 -0
  959. package/src/execution/agent.ts +25 -0
  960. package/src/execution/authorization.ts +70 -0
  961. package/src/execution/authorized-object-reader.ts +238 -32
  962. package/src/execution/lineage.ts +14 -0
  963. package/src/execution/object-reader-ontology.ts +11 -14
  964. package/src/execution/object-reader-security.ts +134 -10
  965. package/src/execution/object-reader-users.ts +122 -0
  966. package/src/execution/preparation.ts +78 -0
  967. package/src/execution/request.ts +2 -0
  968. package/src/execution/unique-lookup.ts +55 -0
  969. package/src/execution/visible-objects.ts +26 -0
  970. package/src/http/api-routes.ts +206 -7
  971. package/src/index.ts +99 -2
  972. package/src/materialization/errors.ts +37 -0
  973. package/src/materialization/event-envelopes.ts +11 -3
  974. package/src/materialization/index.ts +1 -0
  975. package/src/materialization/model.ts +24 -4
  976. package/src/materializer/README.md +7 -1
  977. package/src/materializer/edits/commit.ts +56 -12
  978. package/src/materializer/edits/load-state.ts +15 -7
  979. package/src/materializer/edits/operations.ts +12 -0
  980. package/src/materializer/edits/plan.ts +2 -0
  981. package/src/materializer/edits/unique-values.ts +255 -0
  982. package/src/materializer/edits/working-state.ts +8 -1
  983. package/src/materializer/execution/work-records.ts +47 -0
  984. package/src/materializer/projections/finish-run.ts +0 -1
  985. package/src/materializer/projections/replace.ts +1 -1
  986. package/src/materializer/projections/replacement-plan.ts +4 -1
  987. package/src/materializer/projections/source-materialization.ts +2 -1
  988. package/src/materializer/shared/normalize.ts +37 -6
  989. package/src/materializer/shared/projection-run.ts +1 -2
  990. package/src/materializer/telemetry/append.ts +14 -17
  991. package/src/materializer/telemetry/plan.ts +2 -0
  992. package/src/models/audio/catalog.ts +89 -10
  993. package/src/models/audio/errors.ts +18 -1
  994. package/src/models/audio/runtime.ts +10 -13
  995. package/src/models/audio/speech.ts +261 -0
  996. package/src/models/audio/types.ts +97 -0
  997. package/src/models/calls.ts +100 -0
  998. package/src/models/catalog-index.ts +21 -2
  999. package/src/models/catalog.ts +211 -35
  1000. package/src/models/decision/runtime.ts +21 -22
  1001. package/src/models/decision/validation.ts +4 -1
  1002. package/src/models/definitions.ts +57 -8
  1003. package/src/models/events.ts +72 -1
  1004. package/src/models/execution/README.md +34 -5
  1005. package/src/models/execution/binding.ts +3 -1
  1006. package/src/models/execution/embedding.ts +1 -0
  1007. package/src/models/execution/index.ts +5 -0
  1008. package/src/models/execution/model-call-accounting.ts +3 -1
  1009. package/src/models/execution/model-call-recorder.ts +29 -1
  1010. package/src/models/execution/usage.ts +8 -0
  1011. package/src/models/execution.ts +20 -22
  1012. package/src/models/generation-types.ts +8 -1
  1013. package/src/models/image/catalog.ts +89 -0
  1014. package/src/models/image/errors.ts +19 -0
  1015. package/src/models/image/runtime.ts +335 -0
  1016. package/src/models/image/types.ts +111 -0
  1017. package/src/models/index.ts +38 -4
  1018. package/src/models/{audio/file.ts → input-file.ts} +22 -13
  1019. package/src/models/language-model.ts +13 -0
  1020. package/src/models/pricing.ts +263 -42
  1021. package/src/models/rate-card.ts +161 -12
  1022. package/src/objects/authorized-ontology-view.ts +1 -0
  1023. package/src/objects/conditional-writes.ts +109 -0
  1024. package/src/objects/execution.ts +4 -0
  1025. package/src/objects/index.ts +8 -0
  1026. package/src/objects/link/authorization.ts +12 -3
  1027. package/src/objects/link/endpoints.ts +42 -11
  1028. package/src/objects/link/remove.ts +25 -10
  1029. package/src/objects/link/upsert-batch.ts +2 -0
  1030. package/src/objects/link/upsert.ts +18 -12
  1031. package/src/objects/materializer-adapter.ts +55 -18
  1032. package/src/objects/object/delete.ts +24 -7
  1033. package/src/objects/object/upsert-batch.ts +44 -14
  1034. package/src/objects/object/upsert.ts +23 -5
  1035. package/src/objects/query/current-user.ts +76 -0
  1036. package/src/objects/query/executor.ts +39 -103
  1037. package/src/objects/query/explain.ts +20 -7
  1038. package/src/objects/query/index.ts +2 -0
  1039. package/src/objects/query/ir.ts +20 -0
  1040. package/src/objects/query/links.ts +8 -0
  1041. package/src/objects/query/matches-predicate.ts +108 -0
  1042. package/src/objects/query/normalize.ts +50 -19
  1043. package/src/objects/query/scalar-values.ts +19 -3
  1044. package/src/objects/query/user-expansions.ts +65 -0
  1045. package/src/objects/query/validate.ts +248 -10
  1046. package/src/objects/runtime-batch.ts +8 -2
  1047. package/src/objects/sdk/object-set.ts +12 -1
  1048. package/src/objects/sdk/query-builder.ts +39 -8
  1049. package/src/objects/sdk/query-executor.ts +6 -0
  1050. package/src/objects/serialize.ts +79 -0
  1051. package/src/objects/unique-violation.ts +59 -0
  1052. package/src/objects/vectors/handle.ts +3 -3
  1053. package/src/ontology/builders.ts +3 -0
  1054. package/src/ontology/docs-markdown.ts +1 -0
  1055. package/src/ontology/index.ts +2 -2
  1056. package/src/ontology/json-schema.ts +4 -0
  1057. package/src/ontology/primitives.ts +21 -8
  1058. package/src/ontology/registry.ts +16 -0
  1059. package/src/ontology/types.ts +9 -0
  1060. package/src/ontology/unique-values.ts +84 -0
  1061. package/src/ontology/user-ref.ts +39 -0
  1062. package/src/ontology/validation/properties.ts +43 -0
  1063. package/src/ontology/validation/schema.ts +9 -1
  1064. package/src/projections/registry.ts +16 -10
  1065. package/src/projections/revision.ts +112 -45
  1066. package/src/projections/run-dispatch.ts +38 -25
  1067. package/src/projections/types.ts +2 -0
  1068. package/src/query.ts +5 -0
  1069. package/src/rules/execution.ts +43 -11
  1070. package/src/runtime/ai-cost.ts +30 -0
  1071. package/src/runtime/ai-usage.ts +32 -1
  1072. package/src/runtime/host.ts +18 -1
  1073. package/src/runtime/index.ts +2 -0
  1074. package/src/runtime/resolve-definitions.ts +3 -0
  1075. package/src/runtime/sixb.ts +35 -8
  1076. package/src/runtime/types.ts +99 -9
  1077. package/src/schedules/builders.ts +3 -1
  1078. package/src/schedules/runtime.ts +6 -0
  1079. package/src/schedules/validation.ts +23 -1
  1080. package/src/security/README.md +62 -0
  1081. package/src/security/grants.ts +155 -10
  1082. package/src/security/index.ts +3 -1
  1083. package/src/security/project.ts +6 -1
  1084. package/src/security/registry.ts +32 -7
  1085. package/src/security/types.ts +54 -9
  1086. package/src/security/validation.ts +27 -11
  1087. package/src/security/view-conditions.ts +215 -0
  1088. package/src/shares/execution.ts +43 -10
  1089. package/src/storage/action-runs/types.ts +2 -0
  1090. package/src/storage/agents/errors.ts +3 -0
  1091. package/src/storage/agents/in-memory.ts +779 -32
  1092. package/src/storage/agents/index.ts +42 -0
  1093. package/src/storage/agents/provider.ts +733 -8
  1094. package/src/storage/agents/types.ts +620 -12
  1095. package/src/storage/ai-cost/analytics.ts +60 -7
  1096. package/src/storage/ai-cost/codec.ts +6 -1
  1097. package/src/storage/ai-cost/groups.ts +44 -1
  1098. package/src/storage/ai-cost/index.ts +1 -0
  1099. package/src/storage/ai-cost/provider.ts +2 -0
  1100. package/src/storage/ai-cost/types.ts +18 -1
  1101. package/src/storage/ai-cost/validation.ts +39 -12
  1102. package/src/storage/ai-limits/provider.ts +4 -7
  1103. package/src/storage/ai-usage/in-memory.ts +28 -1
  1104. package/src/storage/ai-usage/index.ts +9 -1
  1105. package/src/storage/ai-usage/record.ts +44 -7
  1106. package/src/storage/ai-usage/types.ts +38 -0
  1107. package/src/storage/ai-usage/usage.ts +15 -1
  1108. package/src/storage/artifacts/errors.ts +13 -1
  1109. package/src/storage/artifacts/in-memory.ts +156 -8
  1110. package/src/storage/artifacts/index.ts +6 -1
  1111. package/src/storage/artifacts/record.ts +61 -1
  1112. package/src/storage/artifacts/types.ts +92 -8
  1113. package/src/storage/auth/in-memory/auth-storage.ts +27 -2
  1114. package/src/storage/auth/in-memory/users.ts +40 -6
  1115. package/src/storage/auth/index.ts +1 -0
  1116. package/src/storage/auth/types.ts +43 -7
  1117. package/src/storage/executions/in-memory.ts +32 -0
  1118. package/src/storage/executions/index.ts +2 -0
  1119. package/src/storage/executions/types.ts +17 -0
  1120. package/src/storage/index.ts +69 -1
  1121. package/src/storage/internal.ts +9 -1
  1122. package/src/storage/migrations/migrate-storage.ts +8 -1
  1123. package/src/storage/migrations/prepare-unique-properties.ts +161 -0
  1124. package/src/storage/objects/guard.ts +7 -3
  1125. package/src/storage/objects/in-memory/conditional-reader.ts +72 -0
  1126. package/src/storage/objects/in-memory/query.ts +4 -105
  1127. package/src/storage/objects/in-memory/read-scope.ts +15 -14
  1128. package/src/storage/objects/in-memory/read-source.ts +11 -1
  1129. package/src/storage/objects/in-memory/scoped-reader.ts +243 -0
  1130. package/src/storage/objects/in-memory/selected-reader.ts +6 -231
  1131. package/src/storage/objects/in-memory/storage.ts +183 -1
  1132. package/src/storage/objects/index.ts +9 -1
  1133. package/src/storage/objects/read-scope.ts +191 -0
  1134. package/src/storage/objects/types.ts +68 -1
  1135. package/src/storage/ontology/in-memory/index.ts +3 -0
  1136. package/src/storage/ontology/in-memory/materializations.ts +35 -0
  1137. package/src/storage/ontology/in-memory/replacement-plans.ts +4 -0
  1138. package/src/storage/ontology/in-memory/unique-values.ts +62 -0
  1139. package/src/storage/ontology/index.ts +10 -0
  1140. package/src/storage/ontology/materializations.ts +35 -1
  1141. package/src/storage/ontology/provider-work.ts +76 -0
  1142. package/src/storage/ontology/provider.ts +3 -0
  1143. package/src/storage/ontology/unique-values.ts +56 -0
  1144. package/src/storage/operation-scope.ts +9 -1
  1145. package/src/storage/projection-runs/in-memory.ts +3 -35
  1146. package/src/storage/types.ts +2 -0
  1147. package/src/testing/agent-approval-storage-contract.ts +1117 -0
  1148. package/src/testing/agent-memory-storage-contract.ts +400 -0
  1149. package/src/testing/agent-storage-contract.ts +1188 -33
  1150. package/src/testing/ai-cost-storage-contract.ts +31 -1
  1151. package/src/testing/ai-limit-storage-contract.ts +9 -7
  1152. package/src/testing/ai-model-call-groups-contract.ts +76 -0
  1153. package/src/testing/ai-usage-storage-contract.ts +120 -13
  1154. package/src/testing/artifact-storage-contract.ts +338 -4
  1155. package/src/testing/auth-storage-contract.ts +550 -73
  1156. package/src/testing/broker-contract.ts +28 -23
  1157. package/src/testing/effective-storage-contract.ts +3 -8
  1158. package/src/testing/execution-storage-contract.ts +53 -0
  1159. package/src/testing/file-upload-session-storage-contract.ts +12 -24
  1160. package/src/testing/index.ts +17 -4
  1161. package/src/testing/lake-storage-contract.ts +22 -28
  1162. package/src/testing/materializer-storage-contract.ts +36 -9
  1163. package/src/testing/object-conditional-read-scope-contract.ts +634 -0
  1164. package/src/testing/object-query-contract.ts +386 -186
  1165. package/src/testing/ontology-storage-contract.ts +230 -21
  1166. package/src/testing/projection-run-storage-contract.ts +8 -18
  1167. package/src/testing/queues-contract.ts +39 -70
  1168. package/src/testing/sandboxes-contract.ts +3 -14
  1169. package/src/testing/share-grant-storage-contract.ts +13 -16
  1170. package/src/testing/share-session-storage-contract.ts +4 -14
  1171. package/src/testing/unique-values-contract.ts +907 -0
  1172. package/src/testing/webhook-execution.ts +1 -1
  1173. package/src/testing/webhook-run-storage-contract.ts +6 -9
  1174. package/src/users/execution.ts +131 -0
  1175. package/src/users/index.ts +2 -0
  1176. package/src/workers/queue-worker.ts +1 -3
  1177. package/src/workers/worker.ts +1 -3
  1178. package/src/workflows/builders.ts +6 -0
  1179. package/src/workflows/request.ts +46 -8
  1180. package/src/workflows/types.ts +6 -2
  1181. package/src/workflows/validation.ts +23 -9
  1182. package/dist/chunk-29yx306f.js.map +0 -22
  1183. package/dist/chunk-3jms7je7.js +0 -14
  1184. package/dist/chunk-3jms7je7.js.map +0 -10
  1185. package/dist/chunk-3qct2mdc.js +0 -297
  1186. package/dist/chunk-3qct2mdc.js.map +0 -12
  1187. package/dist/chunk-48qjhh6v.js.map +0 -13
  1188. package/dist/chunk-4as3wt1c.js.map +0 -12
  1189. package/dist/chunk-5948n82c.js.map +0 -10
  1190. package/dist/chunk-5hx48dnn.js.map +0 -14
  1191. package/dist/chunk-6rqgmkde.js.map +0 -29
  1192. package/dist/chunk-6x0pqh32.js.map +0 -10
  1193. package/dist/chunk-7n30ybym.js +0 -3
  1194. package/dist/chunk-7n440zgt.js +0 -261
  1195. package/dist/chunk-7n440zgt.js.map +0 -12
  1196. package/dist/chunk-7q8t23v4.js +0 -467
  1197. package/dist/chunk-7q8t23v4.js.map +0 -14
  1198. package/dist/chunk-8frc8a4j.js.map +0 -20
  1199. package/dist/chunk-918wwnaa.js.map +0 -68
  1200. package/dist/chunk-91mg3nj9.js.map +0 -12
  1201. package/dist/chunk-96yw3pwd.js.map +0 -10
  1202. package/dist/chunk-9j4jw7as.js.map +0 -14
  1203. package/dist/chunk-9k93ah50.js.map +0 -11
  1204. package/dist/chunk-9kgkfg6v.js +0 -502
  1205. package/dist/chunk-9kgkfg6v.js.map +0 -14
  1206. package/dist/chunk-akzryx9h.js.map +0 -100
  1207. package/dist/chunk-arns890k.js.map +0 -10
  1208. package/dist/chunk-bk9svbcq.js.map +0 -49
  1209. package/dist/chunk-c06hmxyy.js +0 -31
  1210. package/dist/chunk-c06hmxyy.js.map +0 -10
  1211. package/dist/chunk-c1rxbz5y.js.map +0 -12
  1212. package/dist/chunk-cn0fwwhy.js.map +0 -19
  1213. package/dist/chunk-dhcv7yxc.js.map +0 -11
  1214. package/dist/chunk-dhdha526.js.map +0 -10
  1215. package/dist/chunk-dvd2fp9q.js.map +0 -13
  1216. package/dist/chunk-e6k4thh5.js.map +0 -19
  1217. package/dist/chunk-ere85b8y.js.map +0 -15
  1218. package/dist/chunk-g257jwnc.js.map +0 -12
  1219. package/dist/chunk-hwksyjks.js.map +0 -11
  1220. package/dist/chunk-k43ct2ke.js.map +0 -12
  1221. package/dist/chunk-nn5xnx3s.js.map +0 -40
  1222. package/dist/chunk-pbcbn83d.js.map +0 -14
  1223. package/dist/chunk-pqajwytd.js +0 -68
  1224. package/dist/chunk-pqajwytd.js.map +0 -11
  1225. package/dist/chunk-qczk96d9.js.map +0 -11
  1226. package/dist/chunk-rdghfsss.js +0 -39
  1227. package/dist/chunk-rdghfsss.js.map +0 -10
  1228. package/dist/chunk-rj69qcrd.js.map +0 -11
  1229. package/dist/chunk-v4jbb3rs.js.map +0 -10
  1230. package/dist/chunk-yxd3nnqt.js.map +0 -11
  1231. package/dist/events/toStoredEvent.d.ts +0 -9
  1232. package/dist/events/toStoredEvent.d.ts.map +0 -1
  1233. package/dist/models/audio/file.d.ts +0 -9
  1234. package/dist/models/audio/file.d.ts.map +0 -1
  1235. package/src/events/toStoredEvent.ts +0 -33
  1236. /package/dist/{chunk-mfs23znk.js.map → chunk-07kkp2e1.js.map} +0 -0
  1237. /package/dist/{chunk-z58tm0hm.js.map → chunk-0phpbbvm.js.map} +0 -0
  1238. /package/dist/{chunk-e17zdm62.js.map → chunk-1t6k1avb.js.map} +0 -0
  1239. /package/dist/{chunk-kge7k6ey.js.map → chunk-2fn60nvs.js.map} +0 -0
  1240. /package/dist/{chunk-y0c4e6ex.js.map → chunk-3gbefjg5.js.map} +0 -0
  1241. /package/dist/{chunk-cy4mbddw.js.map → chunk-48jezz3j.js.map} +0 -0
  1242. /package/dist/{chunk-twe4dx8p.js → chunk-5tfev0fv.js} +0 -0
  1243. /package/dist/{chunk-twe4dx8p.js.map → chunk-5tfev0fv.js.map} +0 -0
  1244. /package/dist/{chunk-447a5c0p.js.map → chunk-6n69k945.js.map} +0 -0
  1245. /package/dist/{chunk-0bphap9y.js.map → chunk-6p0pastb.js.map} +0 -0
  1246. /package/dist/{chunk-431pyp2c.js.map → chunk-6y0mkhex.js.map} +0 -0
  1247. /package/dist/{chunk-s7jg7pmn.js.map → chunk-bab05bhg.js.map} +0 -0
  1248. /package/dist/{chunk-q5e5tv4b.js.map → chunk-c844dkwd.js.map} +0 -0
  1249. /package/dist/{chunk-cfj9dfbb.js.map → chunk-d2m879s4.js.map} +0 -0
  1250. /package/dist/{chunk-q7gn29y3.js.map → chunk-dp0cdtj2.js.map} +0 -0
  1251. /package/dist/{chunk-br3k6qbf.js.map → chunk-fm62y49k.js.map} +0 -0
  1252. /package/dist/{chunk-vvxtn22d.js.map → chunk-g663fahq.js.map} +0 -0
  1253. /package/dist/{chunk-rmakanzx.js.map → chunk-h33shhq6.js.map} +0 -0
  1254. /package/dist/{chunk-d09e3rax.js.map → chunk-hwarjrgf.js.map} +0 -0
  1255. /package/dist/{chunk-vf57cr4t.js.map → chunk-hyesv9dv.js.map} +0 -0
  1256. /package/dist/{chunk-5vems3nx.js.map → chunk-m2nevja0.js.map} +0 -0
  1257. /package/dist/{chunk-x9v4cx1d.js.map → chunk-m36fw8ft.js.map} +0 -0
  1258. /package/dist/{chunk-a40ad1ft.js.map → chunk-mbsbxarb.js.map} +0 -0
  1259. /package/dist/{chunk-6aawea28.js.map → chunk-n8q5j6y5.js.map} +0 -0
  1260. /package/dist/{chunk-d7dnxdep.js.map → chunk-n9zpx9c6.js.map} +0 -0
  1261. /package/dist/{chunk-xvsc5m8n.js.map → chunk-npcr0228.js.map} +0 -0
  1262. /package/dist/{chunk-y5tah2kf.js.map → chunk-q4pmvkg0.js.map} +0 -0
  1263. /package/dist/{chunk-d5rjr8c0.js.map → chunk-vabga7fk.js.map} +0 -0
@@ -1,17 +1,25 @@
1
1
  import { describe, expect, test } from "bun:test"
2
+ import { createHash } from "node:crypto"
2
3
  import { AGENT_MESSAGE_CONTENT_VERSION } from "../agents/message"
4
+ import { projectAgentThreadModelContext } from "../agents/thread-context-projection"
3
5
  import type { Principal } from "../auth"
6
+ import type { FileRef } from "../blob-storage/types"
4
7
  import type { SixbFailure } from "../errors/types"
5
8
  import {
9
+ type AddAgentThreadParticipantsInput,
6
10
  type AgentRunExecution,
7
11
  type AgentRunFailureCode,
8
12
  type AgentStorage,
9
13
  AgentStorageError,
10
14
  type AgentStorageErrorCode,
15
+ type AgentThreadParticipantRecord,
16
+ type ConversationAgentRunSpec,
11
17
  type CreateAgentContextCheckpointInput,
12
18
  type CreateAgentRunInput,
13
19
  type CreateAgentThreadInput,
14
20
  type CreateSubagentRunInput,
21
+ type ForkAgentThreadInput,
22
+ type ListAgentThreadChildrenInput,
15
23
  type StartAgentRunInput,
16
24
  } from "../storage/agents"
17
25
  import type { AuthStorage } from "../storage/auth"
@@ -37,6 +45,7 @@ export interface AgentStorageContractSuiteOptions<
37
45
  const projectId = "project-a"
38
46
  const otherProjectId = "project-b"
39
47
  const owner: Principal = { type: "user", id: "usr_1" }
48
+ const otherUser: Principal = { type: "user", id: "usr_2" }
40
49
  const serviceAccount: Extract<Principal, { readonly type: "serviceAccount" }> = {
41
50
  type: "serviceAccount",
42
51
  id: "svc_agent_sales",
@@ -72,6 +81,30 @@ function threadInput(overrides: Partial<CreateAgentThreadInput> = {}): CreateAge
72
81
  }
73
82
  }
74
83
 
84
+ function participantsInput(
85
+ userIds: readonly string[],
86
+ addedAt = at("2026-06-23T11:00:00.000Z")
87
+ ): AddAgentThreadParticipantsInput {
88
+ return {
89
+ projectId,
90
+ threadId: "thr_1",
91
+ principals: userIds.map((id) => ({ type: "user", id })),
92
+ addedBy: owner,
93
+ maxParticipants: 10,
94
+ addedAt,
95
+ }
96
+ }
97
+
98
+ function participant(userId: string, addedAt: Date): AgentThreadParticipantRecord {
99
+ return {
100
+ projectId,
101
+ threadId: "thr_1",
102
+ principal: { type: "user", id: userId },
103
+ addedAt,
104
+ addedBy: owner,
105
+ }
106
+ }
107
+
75
108
  function execution(
76
109
  token: string,
77
110
  queueLeaseExpiresAt = at("2026-06-23T10:05:00.000Z")
@@ -103,6 +136,18 @@ function runInput(overrides: Partial<TestRunInput> = {}): TestRunInput {
103
136
  }
104
137
  }
105
138
 
139
+ /** A content-addressed reference, as blob storage returns it. */
140
+ function testFileRef(fileName: string): FileRef {
141
+ const hex = createHash("sha256").update(fileName).digest("hex")
142
+ return {
143
+ blobId: `blob_${hex}`,
144
+ digest: `sha256:${hex}`,
145
+ sizeBytes: 12,
146
+ fileName,
147
+ mediaType: "text/csv",
148
+ }
149
+ }
150
+
106
151
  function subagentInput(
107
152
  parentExecutionToken: string,
108
153
  overrides: Partial<CreateSubagentRunInput> = {}
@@ -121,7 +166,10 @@ function subagentInput(
121
166
  task: "Research the open orders.",
122
167
  toolNames: ["search_orders"],
123
168
  maxSteps: 25,
169
+ files: [{ path: "reports/orders.csv", fileRef: testFileRef("orders.csv") }],
124
170
  },
171
+ thread: { id: `thread_${id}`, create: true },
172
+ trigger: { id: `task_${id}`, parts: [{ type: "text", text: "Research the open orders." }] },
125
173
  maxActiveChildren: 4,
126
174
  createdAt: at("2026-06-23T10:01:00.000Z"),
127
175
  ...overrides,
@@ -267,6 +315,143 @@ async function prepareCheckpointCandidate(
267
315
  )
268
316
  }
269
317
 
318
+ const forkedFile = {
319
+ blobId: "blob_report",
320
+ digest: `sha256:${"a".repeat(64)}`,
321
+ sizeBytes: 12,
322
+ fileName: "report.csv",
323
+ mediaType: "text/csv",
324
+ } as const
325
+
326
+ function forkInput(overrides: Partial<ForkAgentThreadInput> = {}): ForkAgentThreadInput {
327
+ return {
328
+ projectId,
329
+ sourceThreadId: "thr_1",
330
+ id: "thr_fork",
331
+ ownerPrincipal: otherUser,
332
+ title: "Slipped deals",
333
+ createdAt: at("2026-06-23T11:00:00.000Z"),
334
+ ...overrides,
335
+ }
336
+ }
337
+
338
+ /**
339
+ * Two finished turns, then a third still running, each compacted by the run that follows:
340
+ * `checkpoint_1` (written by finished `run_2`) and `checkpoint_2` (written by running `run_3`,
341
+ * anchored on its trigger `m5`).
342
+ */
343
+ async function prepareForkSource(
344
+ storage: AgentStorage,
345
+ fixture: AgentStorageContractStorage,
346
+ /** The summary of the checkpoint the third turn writes. */
347
+ summary = "Three deals slipped; Acme waits on legal review."
348
+ ): Promise<void> {
349
+ await storage.threads.create(threadInput({ title: "Slipped deals" }))
350
+ await storage.messages.append({
351
+ id: "m1",
352
+ projectId,
353
+ threadId: "thr_1",
354
+ runId: null,
355
+ role: "user",
356
+ authorPrincipal: owner,
357
+ parts: [
358
+ { type: "text", text: "Which deals slipped?" },
359
+ { type: "file", fileRef: forkedFile },
360
+ ],
361
+ metadata: { source: "chat" },
362
+ createdAt: at("2026-06-23T10:00:01.000Z"),
363
+ })
364
+ await createAndStartRun(storage, fixture, runInput({ id: "run_1", triggerMessageId: "m1" }))
365
+ await storage.messages.append({
366
+ id: "m2",
367
+ projectId,
368
+ threadId: "thr_1",
369
+ runId: "run_1",
370
+ role: "assistant",
371
+ authorPrincipal: owner,
372
+ parts: [
373
+ { type: "step-start" },
374
+ {
375
+ type: "tool-call",
376
+ toolCallId: "call_1",
377
+ toolName: "bash",
378
+ input: { cmd: "report" },
379
+ state: "output-available",
380
+ output: { file: forkedFile },
381
+ },
382
+ { type: "text", text: "Three deals slipped." },
383
+ ],
384
+ createdAt: at("2026-06-23T10:00:02.000Z"),
385
+ completedAt: at("2026-06-23T10:00:03.000Z"),
386
+ })
387
+ await storage.runs.finish({
388
+ id: "run_1",
389
+ projectId,
390
+ executionToken: "exec_1",
391
+ status: "succeeded",
392
+ })
393
+
394
+ await storage.messages.append({
395
+ id: "m3",
396
+ projectId,
397
+ threadId: "thr_1",
398
+ runId: null,
399
+ role: "user",
400
+ authorPrincipal: owner,
401
+ parts: [{ type: "text", text: "Why did Acme slip?" }],
402
+ createdAt: at("2026-06-23T10:00:04.000Z"),
403
+ })
404
+ await createAndStartRun(
405
+ storage,
406
+ fixture,
407
+ runInput({ id: "run_2", triggerMessageId: "m3", execution: execution("exec_2") })
408
+ )
409
+ await storage.checkpoints.create(checkpointInput())
410
+ await storage.messages.append({
411
+ id: "m4",
412
+ projectId,
413
+ threadId: "thr_1",
414
+ runId: "run_2",
415
+ role: "assistant",
416
+ parts: [{ type: "text", text: "Legal review." }],
417
+ createdAt: at("2026-06-23T10:00:05.000Z"),
418
+ })
419
+ await storage.runs.finish({
420
+ id: "run_2",
421
+ projectId,
422
+ executionToken: "exec_2",
423
+ status: "succeeded",
424
+ })
425
+
426
+ await storage.messages.append({
427
+ id: "m5",
428
+ projectId,
429
+ threadId: "thr_1",
430
+ runId: null,
431
+ role: "user",
432
+ parts: [{ type: "text", text: "Draft the emails." }],
433
+ createdAt: at("2026-06-23T10:00:06.000Z"),
434
+ })
435
+ await createAndStartRun(
436
+ storage,
437
+ fixture,
438
+ runInput({ id: "run_3", triggerMessageId: "m5", execution: execution("exec_3") })
439
+ )
440
+ await storage.checkpoints.create(
441
+ checkpointInput({
442
+ id: "checkpoint_2",
443
+ createdByRunId: "run_3",
444
+ expectedPreviousCheckpointId: "checkpoint_1",
445
+ expectedHeadSeq: 5,
446
+ executionToken: "exec_3",
447
+ summary,
448
+ summarizedThroughSeq: 4,
449
+ observedHeadSeq: 5,
450
+ createdAt: at("2026-06-23T10:05:00.000Z"),
451
+ })
452
+ )
453
+ }
454
+
270
455
  /**
271
456
  * Runs the shared `AgentStorage` contract against any storage implementation.
272
457
  *
@@ -623,6 +808,200 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
623
808
  })
624
809
  })
625
810
 
811
+ // ── participants ───────────────────────────────────────────────────────────────────────────
812
+
813
+ test("adds participants once and keeps when and by whom they were first added", async () => {
814
+ await withStorage(async (storage) => {
815
+ await storage.threads.create(threadInput())
816
+
817
+ const first = await storage.threads.addParticipants(
818
+ participantsInput(["usr_cleo", "usr_bob"], at("2026-06-23T11:00:00.000Z"))
819
+ )
820
+ expect(first).toEqual([
821
+ participant("usr_bob", at("2026-06-23T11:00:00.000Z")),
822
+ participant("usr_cleo", at("2026-06-23T11:00:00.000Z")),
823
+ ])
824
+
825
+ const again = await storage.threads.addParticipants({
826
+ ...participantsInput(["usr_cleo", "usr_dan"], at("2026-06-23T12:00:00.000Z")),
827
+ addedBy: { type: "system", id: "system" },
828
+ })
829
+ expect(again).toEqual([
830
+ participant("usr_bob", at("2026-06-23T11:00:00.000Z")),
831
+ participant("usr_cleo", at("2026-06-23T11:00:00.000Z")),
832
+ {
833
+ ...participant("usr_dan", at("2026-06-23T12:00:00.000Z")),
834
+ addedBy: { type: "system", id: "system" },
835
+ },
836
+ ])
837
+
838
+ expect(
839
+ await storage.threads.listParticipants({ projectId, threadIds: ["thr_1", "thr_1"] })
840
+ ).toEqual(again)
841
+ })
842
+ })
843
+
844
+ // Regression proof: compare ids with localeCompare in compareAgentThreadParticipants; it puts
845
+ // "usr_a" before "usr_B", where PostgreSQL's "C" collation and SQLite put "usr_B" first.
846
+ test("orders participants added at once by their ids' bytes, alike everywhere", async () => {
847
+ await withStorage(async (storage) => {
848
+ await storage.threads.create(threadInput())
849
+ await storage.threads.create(threadInput({ id: "thr_2" }))
850
+ for (const threadId of ["thr_2", "thr_1"]) {
851
+ await storage.threads.addParticipants({
852
+ ...participantsInput(["usr_a", "usr_B", "usr_é"]),
853
+ threadId,
854
+ })
855
+ }
856
+
857
+ const listed = await storage.threads.listParticipants({
858
+ projectId,
859
+ threadIds: ["thr_2", "thr_1"],
860
+ })
861
+ expect(listed.map((record) => `${record.principal.id}@${record.threadId}`)).toEqual([
862
+ "usr_B@thr_1",
863
+ "usr_B@thr_2",
864
+ "usr_a@thr_1",
865
+ "usr_a@thr_2",
866
+ "usr_é@thr_1",
867
+ "usr_é@thr_2",
868
+ ])
869
+ })
870
+ })
871
+
872
+ test("lets one of several adds racing for the last place win", async () => {
873
+ // Concurrent calls rarely interleave here; the PostgreSQL suite holds a transaction open to
874
+ // prove its row lock. This checks the outcome every provider must give.
875
+ await withStorage(async (storage) => {
876
+ await storage.threads.create(threadInput())
877
+ await storage.threads.addParticipants(participantsInput(["usr_bob"]))
878
+
879
+ const racers = ["usr_cleo", "usr_dan", "usr_eve", "usr_fay", "usr_gus"]
880
+ const race = await Promise.allSettled(
881
+ racers.map((id) =>
882
+ storage.threads.addParticipants({ ...participantsInput([id]), maxParticipants: 2 })
883
+ )
884
+ )
885
+ expect(race.filter((result) => result.status === "fulfilled")).toHaveLength(1)
886
+ for (const result of race) {
887
+ if (result.status === "rejected") {
888
+ expect(result.reason).toMatchObject({ code: "participant_limit" })
889
+ }
890
+ }
891
+
892
+ expect(
893
+ await storage.threads.listParticipants({ projectId, threadIds: ["thr_1"] })
894
+ ).toHaveLength(2)
895
+ })
896
+ })
897
+
898
+ test("refuses participants past the limit, and missing threads", async () => {
899
+ await withStorage(async (storage) => {
900
+ await storage.threads.create(threadInput())
901
+ await storage.threads.addParticipants(participantsInput(["usr_bob"]))
902
+
903
+ // Regression proof: drop the limit check in participantsToAdd; the third user is added.
904
+ await expectAgentError(
905
+ storage.threads.addParticipants({
906
+ ...participantsInput(["usr_cleo", "usr_dan"]),
907
+ maxParticipants: 2,
908
+ }),
909
+ "participant_limit"
910
+ )
911
+ await expectAgentError(
912
+ storage.threads.addParticipants({ ...participantsInput(["usr_bob"]), threadId: "nope" }),
913
+ "thread_not_found"
914
+ )
915
+
916
+ // A refused add adds no one, and someone already there does not count twice.
917
+ const kept = await storage.threads.addParticipants({
918
+ ...participantsInput(["usr_bob", "usr_cleo"]),
919
+ maxParticipants: 2,
920
+ })
921
+ expect(kept.map((record) => record.principal.id)).toEqual(["usr_bob", "usr_cleo"])
922
+ })
923
+ })
924
+
925
+ test("removes a participant and lists the threads shared with a user", async () => {
926
+ await withStorage(async (storage) => {
927
+ await storage.threads.create(
928
+ threadInput({ id: "thr_a", createdAt: at("2026-06-23T10:00:00.000Z") })
929
+ )
930
+ await storage.threads.create(
931
+ threadInput({ id: "thr_b", createdAt: at("2026-06-23T10:01:00.000Z") })
932
+ )
933
+ await storage.threads.create(
934
+ threadInput({ id: "thr_c", createdAt: at("2026-06-23T10:02:00.000Z") })
935
+ )
936
+ await storage.threads.create(threadInput({ id: "thr_a", projectId: otherProjectId }))
937
+ for (const threadId of ["thr_a", "thr_c"]) {
938
+ await storage.threads.addParticipants({ ...participantsInput(["usr_bob"]), threadId })
939
+ }
940
+ await storage.threads.addParticipants({
941
+ ...participantsInput(["usr_bob"]),
942
+ projectId: otherProjectId,
943
+ threadId: "thr_a",
944
+ })
945
+
946
+ const bob = { type: "user", id: "usr_bob" } as const
947
+ const shared = await storage.threads.list({
948
+ projectId,
949
+ participantPrincipal: bob,
950
+ order: "asc",
951
+ })
952
+ expect(shared.threads.map((thread) => thread.id)).toEqual(["thr_a", "thr_c"])
953
+ expect(shared.total).toBe(2)
954
+
955
+ const page = await storage.threads.list({
956
+ projectId,
957
+ participantPrincipal: bob,
958
+ order: "desc",
959
+ limit: 1,
960
+ })
961
+ expect(page.threads.map((thread) => thread.id)).toEqual(["thr_c"])
962
+ expect(page.hasMore).toBe(true)
963
+
964
+ expect(
965
+ await storage.threads.removeParticipant({ projectId, threadId: "thr_a", principal: bob })
966
+ ).toBe(true)
967
+ expect(
968
+ await storage.threads.removeParticipant({ projectId, threadId: "thr_a", principal: bob })
969
+ ).toBe(false)
970
+ expect(
971
+ await storage.threads.removeParticipant({ projectId, threadId: "nope", principal: bob })
972
+ ).toBe(false)
973
+
974
+ const after = await storage.threads.list({ projectId, participantPrincipal: bob })
975
+ expect(after.threads.map((thread) => thread.id)).toEqual(["thr_c"])
976
+ expect(
977
+ await storage.threads.listParticipants({ projectId, threadIds: ["thr_a", "thr_b"] })
978
+ ).toEqual([])
979
+ expect(
980
+ await storage.threads.listParticipants({
981
+ projectId: otherProjectId,
982
+ threadIds: ["thr_a"],
983
+ })
984
+ ).toHaveLength(1)
985
+ })
986
+ })
987
+
988
+ test("rolls participants back with their transaction", async () => {
989
+ await withStorage(async (storage, fixture) => {
990
+ await storage.threads.create(threadInput())
991
+
992
+ await expect(
993
+ fixture.transaction(async (tx) => {
994
+ await tx.agents?.threads.addParticipants(participantsInput(["usr_bob"]))
995
+ throw new Error("rollback")
996
+ })
997
+ ).rejects.toThrow("rollback")
998
+
999
+ expect(await storage.threads.listParticipants({ projectId, threadIds: ["thr_1"] })).toEqual(
1000
+ []
1001
+ )
1002
+ })
1003
+ })
1004
+
626
1005
  // ── durable queued runs ────────────────────────────────────────────────────────────────────
627
1006
 
628
1007
  test("creates a queued run before execution and claims the thread", async () => {
@@ -662,6 +1041,37 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
662
1041
  })
663
1042
  })
664
1043
 
1044
+ test("keeps a turn's tier and the probabilities Sixb picked it from", async () => {
1045
+ await withStorage(async (storage, fixture) => {
1046
+ await storage.threads.create(threadInput())
1047
+ const spec = {
1048
+ model: { provider: "test", modelId: "large" },
1049
+ tier: "heavy" as const,
1050
+ tierProbabilities: { light: 0.05, standard: 0.25, heavy: 0.7 },
1051
+ reasoning: "high" as const,
1052
+ }
1053
+
1054
+ await createRun(storage, fixture, runInput({ id: "run_1", spec }))
1055
+ expect((await storage.runs.getById({ projectId, id: "run_1" }))?.spec).toEqual(spec)
1056
+
1057
+ // Proven by removal: drop the tier checks from assertConversationAgentRunSpec.
1058
+ for (const invalid of [
1059
+ { ...spec, tier: "medium" },
1060
+ { ...spec, tierProbabilities: { light: 0.3, standard: 0.7 } },
1061
+ { ...spec, tierProbabilities: { ...spec.tierProbabilities, heavy: 1.5 } },
1062
+ ]) {
1063
+ await expectAgentError(
1064
+ createRun(
1065
+ storage,
1066
+ fixture,
1067
+ runInput({ id: "run_2", spec: invalid as ConversationAgentRunSpec })
1068
+ ),
1069
+ "invalid_input"
1070
+ )
1071
+ }
1072
+ })
1073
+ })
1074
+
665
1075
  test("rejects a run whose durable execution does not match its Agent authority", async () => {
666
1076
  await withStorage(async (storage, fixture) => {
667
1077
  await storage.threads.create(threadInput())
@@ -737,7 +1147,7 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
737
1147
 
738
1148
  // ── durable child runs ─────────────────────────────────────────────────────────────────────
739
1149
 
740
- test("creates and exactly replays a child run without claiming a thread", async () => {
1150
+ test("creates a child's thread, its task and its run at once, and replays them exactly", async () => {
741
1151
  await withStorage(async (storage, fixture) => {
742
1152
  await createRunningParent(storage, fixture)
743
1153
  const input = subagentInput("parent_token")
@@ -746,14 +1156,51 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
746
1156
  expect(child).toMatchObject({
747
1157
  kind: "subagent",
748
1158
  id: "child_1",
1159
+ threadId: "thread_child_1",
1160
+ triggerMessageId: "task_child_1",
749
1161
  parentRunId: "parent_1",
750
1162
  spawnKey: "research-orders",
751
1163
  status: "queued",
752
1164
  attempt: 0,
753
1165
  spec: input.spec,
754
1166
  })
755
- expect(child).not.toHaveProperty("threadId")
756
- await expect(storage.runs.createSubagent(input)).resolves.toEqual(child)
1167
+ await expect(storage.threads.getById({ projectId, id: "thread_child_1" })).resolves.toEqual(
1168
+ {
1169
+ id: "thread_child_1",
1170
+ projectId,
1171
+ kind: "subagent",
1172
+ parent: { threadId: "parent_thread", spawnedBy: "parent_1", key: "research-orders" },
1173
+ ownerPrincipal: owner,
1174
+ status: "active",
1175
+ activeRunId: "child_1",
1176
+ lastMessageAt: at("2026-06-23T10:01:00.000Z"),
1177
+ messageCount: 1,
1178
+ createdAt: at("2026-06-23T10:01:00.000Z"),
1179
+ updatedAt: at("2026-06-23T10:01:00.000Z"),
1180
+ }
1181
+ )
1182
+ const task = {
1183
+ id: "task_child_1",
1184
+ projectId,
1185
+ threadId: "thread_child_1",
1186
+ runId: "child_1",
1187
+ role: "user",
1188
+ seq: 1,
1189
+ parts: [{ type: "text", text: "Research the open orders." }],
1190
+ contentVersion: AGENT_MESSAGE_CONTENT_VERSION,
1191
+ createdAt: at("2026-06-23T10:01:00.000Z"),
1192
+ }
1193
+ await expect(
1194
+ storage.messages.list({ projectId, threadId: "thread_child_1" })
1195
+ ).resolves.toMatchObject({ messages: [task], total: 1 })
1196
+
1197
+ // A replay writes nothing more, whatever trigger it brings.
1198
+ await expect(
1199
+ storage.runs.createSubagent({ ...input, trigger: { ...input.trigger, id: "other" } })
1200
+ ).resolves.toEqual(child)
1201
+ await expect(
1202
+ storage.messages.list({ projectId, threadId: "thread_child_1" })
1203
+ ).resolves.toMatchObject({ total: 1 })
757
1204
  await expectAgentError(
758
1205
  storage.runs.createSubagent({
759
1206
  ...input,
@@ -768,12 +1215,332 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
768
1215
  parentRunId: "parent_1",
769
1216
  })
770
1217
  expect(listed.runs.map((run) => run.id)).toEqual(["child_1"])
1218
+ await expect(
1219
+ storage.runs.list({ projectId, threadId: "thread_child_1" })
1220
+ ).resolves.toMatchObject({ runs: [{ id: "child_1" }], total: 1 })
771
1221
  await expect(
772
1222
  storage.runs.list({ projectId, kinds: ["conversation"] })
773
1223
  ).resolves.toMatchObject({ runs: [{ id: "parent_1" }], total: 1 })
774
1224
  await expect(
775
- storage.threads.getById({ projectId, id: "parent_thread" })
776
- ).resolves.toMatchObject({ activeRunId: "parent_1" })
1225
+ storage.threads.getById({ projectId, id: "parent_thread" })
1226
+ ).resolves.toMatchObject({ activeRunId: "parent_1", messageCount: 0 })
1227
+ })
1228
+ })
1229
+
1230
+ test("rolls a child's thread back with its run", async () => {
1231
+ await withStorage(async (storage, fixture) => {
1232
+ await createRunningParent(storage, fixture)
1233
+ const input = subagentInput("parent_token")
1234
+ await createTestAgentExecution(fixture, {
1235
+ projectId,
1236
+ runId: input.id,
1237
+ executionId: input.executionId,
1238
+ sourceExecutionId: "test_agent_execution:parent_1",
1239
+ authority: "inherited",
1240
+ })
1241
+
1242
+ const rolledBack = await fixture
1243
+ .transaction(async (tx) => {
1244
+ await tx.agents?.runs.createSubagent(input)
1245
+ throw new Error("rollback")
1246
+ })
1247
+ .catch((error: unknown) => error)
1248
+ expect(rolledBack).toMatchObject({ message: "rollback" })
1249
+
1250
+ await expect(storage.threads.getById({ projectId, id: "thread_child_1" })).resolves.toBe(
1251
+ null
1252
+ )
1253
+ await expect(storage.messages.getById({ projectId, id: "task_child_1" })).resolves.toBe(
1254
+ null
1255
+ )
1256
+ await expect(storage.runs.getById({ projectId, id: "child_1" })).resolves.toBe(null)
1257
+ })
1258
+ })
1259
+
1260
+ test("keeps a sub-agent's workspace on its thread, fenced by the thread's active run", async () => {
1261
+ // Removal proofs: require `sandboxParams` again in transitionAgentThreadSandbox, and the
1262
+ // child's acquire is refused as unconfigured; fence on `run.kind === "conversation"` again,
1263
+ // and it is refused as lost; drop `startSubagentWorkspaceAgain`, and the destroyed
1264
+ // workspace cannot be started again.
1265
+ await withStorage(async (storage, fixture) => {
1266
+ await createRunningParent(storage, fixture)
1267
+ await createSubagent(storage, fixture)
1268
+ await storage.runs.start({
1269
+ projectId,
1270
+ id: "child_1",
1271
+ execution: execution("child_token", new Date("2099-01-01")),
1272
+ })
1273
+ const acquire = {
1274
+ projectId,
1275
+ id: "thread_child_1",
1276
+ action: "acquire" as const,
1277
+ runId: "child_1",
1278
+ executionToken: "child_token",
1279
+ name: "child-workspace",
1280
+ sourceFingerprint: "b".repeat(64),
1281
+ }
1282
+
1283
+ // The turn it runs under does not own the child's thread.
1284
+ await expectAgentError(
1285
+ storage.threads.transitionSandbox({
1286
+ ...acquire,
1287
+ runId: "parent_1",
1288
+ executionToken: "parent_token",
1289
+ }),
1290
+ "execution_lost"
1291
+ )
1292
+ await expect(storage.threads.transitionSandbox(acquire)).resolves.toMatchObject({
1293
+ name: "child-workspace",
1294
+ status: "busy",
1295
+ owner: { runId: "child_1", executionToken: "child_token" },
1296
+ })
1297
+ await storage.threads.transitionSandbox({
1298
+ ...acquire,
1299
+ action: "settle",
1300
+ status: "ready",
1301
+ initialized: true,
1302
+ })
1303
+ await expect(
1304
+ storage.threads.getById({ projectId, id: "thread_child_1" })
1305
+ ).resolves.toMatchObject({
1306
+ sandboxState: { name: "child-workspace", status: "ready", initialized: true },
1307
+ })
1308
+
1309
+ // A run that destroyed it, or left it unsaved, leaves the next a fresh one to start.
1310
+ await storage.threads.transitionSandbox(acquire)
1311
+ await storage.threads.transitionSandbox({
1312
+ ...acquire,
1313
+ action: "settle",
1314
+ status: "unavailable",
1315
+ initialized: true,
1316
+ })
1317
+ await expectAgentError(storage.threads.transitionSandbox(acquire), "invalid_state")
1318
+ await expect(
1319
+ storage.threads.transitionSandbox({ ...acquire, name: "child-workspace-2" })
1320
+ ).resolves.toEqual({
1321
+ name: "child-workspace-2",
1322
+ status: "busy",
1323
+ initialized: false,
1324
+ resetAt: expect.any(String),
1325
+ sourceFingerprint: acquire.sourceFingerprint,
1326
+ owner: { runId: "child_1", executionToken: "child_token" },
1327
+ })
1328
+ })
1329
+ })
1330
+
1331
+ test("runs one child run at a time in its thread", async () => {
1332
+ // Removal proof: drop the active-run check on a child's thread; `child_2` is admitted while
1333
+ // `child_1` still runs.
1334
+ await withStorage(async (storage, fixture) => {
1335
+ await createRunningParent(storage, fixture)
1336
+ await createSubagent(storage, fixture)
1337
+ await storage.runs.start({
1338
+ projectId,
1339
+ id: "child_1",
1340
+ execution: execution("child_token"),
1341
+ })
1342
+ await storage.runs.finish({
1343
+ projectId,
1344
+ id: "parent_1",
1345
+ executionToken: "parent_token",
1346
+ status: "succeeded",
1347
+ })
1348
+ await createAndStartRun(
1349
+ storage,
1350
+ fixture,
1351
+ runInput({
1352
+ id: "parent_2",
1353
+ threadId: "parent_thread",
1354
+ triggerMessageId: "msg_user_2",
1355
+ execution: execution("parent_token_2"),
1356
+ })
1357
+ )
1358
+ const next = subagentInput("parent_token_2", {
1359
+ id: "child_2",
1360
+ parentRunId: "parent_2",
1361
+ thread: { id: "thread_child_1", create: false },
1362
+ trigger: { id: "trigger_child_2", parts: [{ type: "text", text: "Go on." }] },
1363
+ createdAt: at("2026-06-23T10:03:00.000Z"),
1364
+ })
1365
+ await createTestAgentExecution(fixture, {
1366
+ projectId,
1367
+ runId: next.id,
1368
+ executionId: next.executionId,
1369
+ sourceExecutionId: "test_agent_execution:parent_2",
1370
+ authority: "inherited",
1371
+ })
1372
+
1373
+ await expectAgentError(storage.runs.createSubagent(next), "active_run_exists")
1374
+ await expectAgentError(
1375
+ storage.runs.createSubagent({ ...next, spawnKey: "another-child" }),
1376
+ "invalid_input"
1377
+ )
1378
+ await expectAgentError(
1379
+ storage.runs.createSubagent({ ...next, thread: { id: "missing", create: false } }),
1380
+ "thread_not_found"
1381
+ )
1382
+ await expectAgentError(
1383
+ storage.runs.createSubagent({ ...next, thread: { id: "thread_child_1", create: true } }),
1384
+ "duplicate_id"
1385
+ )
1386
+
1387
+ await storage.runs.finish({
1388
+ projectId,
1389
+ id: "child_1",
1390
+ executionToken: "child_token",
1391
+ status: "succeeded",
1392
+ result: { text: "Three open orders." },
1393
+ })
1394
+ await expect(
1395
+ storage.threads.getById({ projectId, id: "thread_child_1" })
1396
+ ).resolves.toMatchObject({ activeRunId: null })
1397
+
1398
+ await expect(storage.runs.createSubagent(next)).resolves.toMatchObject({
1399
+ id: "child_2",
1400
+ threadId: "thread_child_1",
1401
+ triggerMessageId: "trigger_child_2",
1402
+ parentRunId: "parent_2",
1403
+ })
1404
+ await expect(
1405
+ storage.threads.getById({ projectId, id: "thread_child_1" })
1406
+ ).resolves.toMatchObject({
1407
+ parent: { threadId: "parent_thread", spawnedBy: "parent_1", key: "research-orders" },
1408
+ activeRunId: "child_2",
1409
+ messageCount: 2,
1410
+ lastMessageAt: at("2026-06-23T10:03:00.000Z"),
1411
+ })
1412
+ const { messages } = await storage.messages.list({ projectId, threadId: "thread_child_1" })
1413
+ expect(messages.map(({ id, seq, runId }) => ({ id, seq, runId }))).toEqual([
1414
+ { id: "task_child_1", seq: 1, runId: "child_1" },
1415
+ { id: "trigger_child_2", seq: 2, runId: "child_2" },
1416
+ ])
1417
+ })
1418
+ })
1419
+
1420
+ test("deletes a dead child run's messages whole, its trigger included", async () => {
1421
+ await withStorage(async (storage, fixture) => {
1422
+ await createRunningParent(storage, fixture)
1423
+ await createSubagent(storage, fixture)
1424
+ await storage.runs.start({ projectId, id: "child_1", execution: execution("child_token") })
1425
+ await storage.messages.append({
1426
+ id: "work_child_1",
1427
+ projectId,
1428
+ threadId: "thread_child_1",
1429
+ runId: "child_1",
1430
+ role: "assistant",
1431
+ parts: [{ type: "text", text: "Looking." }],
1432
+ createdAt: at("2026-06-23T10:02:00.000Z"),
1433
+ })
1434
+
1435
+ await expect(
1436
+ storage.messages.deleteByRunId({
1437
+ projectId,
1438
+ threadId: "thread_child_1",
1439
+ runId: "child_1",
1440
+ })
1441
+ ).resolves.toBe(2)
1442
+ await expect(
1443
+ storage.threads.getById({ projectId, id: "thread_child_1" })
1444
+ ).resolves.toMatchObject({ messageCount: 0, lastMessageAt: undefined })
1445
+ })
1446
+ })
1447
+
1448
+ test("never lists a child's thread", async () => {
1449
+ // Removal proof: drop the conversation filter from `threads.list`; the child's thread is
1450
+ // listed with its owner's conversations.
1451
+ await withStorage(async (storage, fixture) => {
1452
+ await createRunningParent(storage, fixture)
1453
+ await createSubagent(storage, fixture)
1454
+ // A participant of the conversation lists it among what is shared with them, alone.
1455
+ const reader = { type: "user", id: "usr_reader" } as const
1456
+ await storage.threads.addParticipants({
1457
+ ...participantsInput([reader.id]),
1458
+ threadId: "parent_thread",
1459
+ })
1460
+
1461
+ for (const input of [
1462
+ {},
1463
+ { ownerPrincipal: owner },
1464
+ { participantPrincipal: reader },
1465
+ { statuses: ["active" as const] },
1466
+ ]) {
1467
+ await expect(storage.threads.list({ projectId, ...input })).resolves.toMatchObject({
1468
+ threads: [{ id: "parent_thread" }],
1469
+ total: 1,
1470
+ })
1471
+ }
1472
+ })
1473
+ })
1474
+
1475
+ test("lists a conversation's sub-agent threads, oldest first, by the turn that spawned them", async () => {
1476
+ await withStorage(async (storage, fixture) => {
1477
+ await createRunningParent(storage, fixture)
1478
+ await createSubagent(storage, fixture, {
1479
+ id: "child_b",
1480
+ spawnKey: "b",
1481
+ createdAt: at("2026-06-23T10:02:00.000Z"),
1482
+ })
1483
+ await createSubagent(storage, fixture, {
1484
+ id: "child_a",
1485
+ spawnKey: "a",
1486
+ createdAt: at("2026-06-23T10:01:00.000Z"),
1487
+ })
1488
+ const children = (input: Partial<ListAgentThreadChildrenInput> = {}) =>
1489
+ storage.threads
1490
+ .listChildren({ projectId, parentThreadId: "parent_thread", ...input })
1491
+ .then((threads) => threads.map((thread) => thread.id))
1492
+
1493
+ expect(await children()).toEqual(["thread_child_a", "thread_child_b"])
1494
+ expect(await children({ parentRunId: "parent_1" })).toEqual([
1495
+ "thread_child_a",
1496
+ "thread_child_b",
1497
+ ])
1498
+ expect(await children({ parentRunId: "parent_2" })).toEqual([])
1499
+ expect(await children({ limit: 1, offset: 1 })).toEqual(["thread_child_b"])
1500
+ expect(
1501
+ await storage.threads.listChildren({ projectId, parentThreadId: "thread_child_a" })
1502
+ ).toEqual([])
1503
+ expect(
1504
+ (await storage.threads.listChildren({ projectId, parentThreadId: "parent_thread" }))[0]
1505
+ ).toMatchObject({
1506
+ kind: "subagent",
1507
+ parent: { threadId: "parent_thread", spawnedBy: "parent_1", key: "a" },
1508
+ })
1509
+ })
1510
+ })
1511
+
1512
+ test("keeps a child's thread out of what only a conversation does", async () => {
1513
+ await withStorage(async (storage, fixture) => {
1514
+ await createRunningParent(storage, fixture)
1515
+ await createSubagent(storage, fixture)
1516
+
1517
+ await expectAgentError(
1518
+ storage.threads.fork(forkInput({ sourceThreadId: "thread_child_1" })),
1519
+ "thread_not_conversation"
1520
+ )
1521
+ await expectAgentError(
1522
+ storage.threads.addParticipants({
1523
+ ...participantsInput(["usr_bob"]),
1524
+ threadId: "thread_child_1",
1525
+ }),
1526
+ "thread_not_conversation"
1527
+ )
1528
+ await expectAgentError(
1529
+ createRun(
1530
+ storage,
1531
+ fixture,
1532
+ runInput({ id: "turn_in_child", threadId: "thread_child_1" })
1533
+ ),
1534
+ "thread_not_conversation"
1535
+ )
1536
+
1537
+ // A fork of the conversation copies its messages, never its children's.
1538
+ const fork = await storage.threads.fork(forkInput({ sourceThreadId: "parent_thread" }))
1539
+ expect(fork).toMatchObject({ kind: "conversation", messageCount: 0 })
1540
+ expect(fork).not.toHaveProperty("parent")
1541
+ await expect(
1542
+ storage.threads.list({ projectId, ownerPrincipal: otherUser })
1543
+ ).resolves.toMatchObject({ threads: [{ id: "thr_fork" }], total: 1 })
777
1544
  })
778
1545
  })
779
1546
 
@@ -880,7 +1647,24 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
880
1647
  "invalid_input"
881
1648
  )
882
1649
 
883
- const result = { text: "Three open orders." }
1650
+ await expectAgentError(
1651
+ storage.runs.finish({
1652
+ projectId,
1653
+ id: "child_1",
1654
+ executionToken: "child_token",
1655
+ status: "succeeded",
1656
+ result: {
1657
+ text: "Three open orders.",
1658
+ files: [{ path: "../orders.png", fileRef: testFileRef("orders.png") }],
1659
+ },
1660
+ }),
1661
+ "invalid_input"
1662
+ )
1663
+
1664
+ const result = {
1665
+ text: "Three open orders.",
1666
+ files: [{ path: "charts/orders.png", fileRef: testFileRef("orders.png") }],
1667
+ }
884
1668
  const completed = await storage.runs.finish({
885
1669
  projectId,
886
1670
  id: "child_1",
@@ -953,32 +1737,7 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
953
1737
 
954
1738
  // ── execution reclaim ───────────────────────────────────────────────────────────────────────
955
1739
 
956
- test("reclaim rotates the execution token and bumps the attempt", async () => {
957
- await withStorage(async (storage, fixture) => {
958
- await storage.threads.create(threadInput())
959
- await createAndStartRun(storage, fixture, runInput({ id: "run_1" }))
960
-
961
- const reclaimed = await storage.runs.reclaim({
962
- projectId,
963
- id: "run_1",
964
- execution: execution("exec_2"),
965
- })
966
- expect(reclaimed).toMatchObject({ status: "running", attempt: 2 })
967
- expect(reclaimed.execution?.token).toBe("exec_2")
968
-
969
- await expectAgentError(
970
- storage.runs.finish({
971
- projectId,
972
- id: "run_1",
973
- executionToken: "exec_1",
974
- status: "succeeded",
975
- }),
976
- "execution_lost"
977
- )
978
- })
979
- })
980
-
981
- test("projects confirmed queue ownership monotonically and fences stale executions", async () => {
1740
+ test("projects confirmed queue ownership monotonically and reclaim fences stale executions", async () => {
982
1741
  await withStorage(async (storage, fixture) => {
983
1742
  await storage.threads.create(threadInput())
984
1743
  await createAndStartRun(
@@ -1008,11 +1767,22 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
1008
1767
  })
1009
1768
  expect(older.execution?.queueLeaseExpiresAt.toISOString()).toBe("2026-06-23T10:03:00.000Z")
1010
1769
 
1011
- await storage.runs.reclaim({
1770
+ const reclaimed = await storage.runs.reclaim({
1012
1771
  projectId,
1013
1772
  id: "run_1",
1014
1773
  execution: execution("exec_2", at("2026-06-23T10:04:00.000Z")),
1015
1774
  })
1775
+ expect(reclaimed).toMatchObject({ status: "running", attempt: 2 })
1776
+ expect(reclaimed.execution?.token).toBe("exec_2")
1777
+ await expectAgentError(
1778
+ storage.runs.finish({
1779
+ projectId,
1780
+ id: "run_1",
1781
+ executionToken: "exec_1",
1782
+ status: "succeeded",
1783
+ }),
1784
+ "execution_lost"
1785
+ )
1016
1786
  await expectAgentError(
1017
1787
  storage.runs.confirmExecutionOwnership({
1018
1788
  projectId,
@@ -1398,6 +2168,70 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
1398
2168
  })
1399
2169
  })
1400
2170
 
2171
+ // Guard proof: make `countsAsThreadMessage` return true; the thread, its fork and the count
2172
+ // after a run's messages go read 2, 2 and 2.
2173
+ test("counts only the messages the conversation shows", async () => {
2174
+ await withStorage(async (storage, fixture) => {
2175
+ await storage.threads.create(threadInput())
2176
+ await storage.messages.append({
2177
+ id: "msg_user_1",
2178
+ projectId,
2179
+ threadId: "thr_1",
2180
+ runId: null,
2181
+ role: "user",
2182
+ parts: [{ type: "text", text: "Mark INV-2041 paid" }],
2183
+ createdAt: at("2026-06-23T10:00:30.000Z"),
2184
+ })
2185
+ // What Sixb writes to resume a turn once its calls are decided: the chat shows none of it.
2186
+ await storage.messages.append({
2187
+ id: "msg_resume_1",
2188
+ projectId,
2189
+ threadId: "thr_1",
2190
+ runId: null,
2191
+ role: "user",
2192
+ authorPrincipal: owner,
2193
+ parts: [
2194
+ {
2195
+ type: "approval-outcome",
2196
+ approvalId: "apr_1",
2197
+ status: "approved",
2198
+ call: {
2199
+ kind: "action",
2200
+ actionId: "mark-paid",
2201
+ subject: { kind: "object", objectTypeId: "invoice", primaryId: "INV-2041" },
2202
+ },
2203
+ },
2204
+ ],
2205
+ createdAt: at("2026-06-23T10:02:00.000Z"),
2206
+ })
2207
+
2208
+ const thread = await storage.threads.getById({ projectId, id: "thr_1" })
2209
+ expect(thread).toMatchObject({ messageCount: 1 })
2210
+ // It is still the thread's latest message.
2211
+ expect(thread?.lastMessageAt?.toISOString()).toBe("2026-06-23T10:02:00.000Z")
2212
+ expect((await storage.threads.fork(forkInput())).messageCount).toBe(1)
2213
+
2214
+ await createAndStartRun(storage, fixture, runInput({ id: "run_1" }))
2215
+ await storage.messages.append({
2216
+ id: "msg_asst_1",
2217
+ projectId,
2218
+ threadId: "thr_1",
2219
+ runId: "run_1",
2220
+ role: "assistant",
2221
+ parts: [{ type: "text", text: "Marked paid." }],
2222
+ createdAt: at("2026-06-23T10:03:00.000Z"),
2223
+ })
2224
+ expect(await storage.threads.getById({ projectId, id: "thr_1" })).toMatchObject({
2225
+ messageCount: 2,
2226
+ })
2227
+
2228
+ await storage.messages.deleteByRunId({ projectId, threadId: "thr_1", runId: "run_1" })
2229
+ expect(await storage.threads.getById({ projectId, id: "thr_1" })).toMatchObject({
2230
+ messageCount: 1,
2231
+ })
2232
+ })
2233
+ })
2234
+
1401
2235
  test("lists messages with role filter, ordering, and pagination", async () => {
1402
2236
  await withStorage(async (storage, fixture) => {
1403
2237
  await storage.threads.create(threadInput())
@@ -1543,15 +2377,20 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
1543
2377
  await expect(
1544
2378
  storage.checkpoints.getByRunIds({
1545
2379
  projectId,
2380
+ threadId: "thr_1",
1546
2381
  runIds: ["run_2", "missing", "run_2"],
1547
2382
  })
1548
2383
  ).resolves.toEqual([created])
1549
2384
  await expect(
1550
2385
  storage.checkpoints.getByRunIds({
1551
2386
  projectId: otherProjectId,
2387
+ threadId: "thr_1",
1552
2388
  runIds: ["run_2"],
1553
2389
  })
1554
2390
  ).resolves.toEqual([])
2391
+ await expect(
2392
+ storage.checkpoints.getByRunIds({ projectId, threadId: "thr_2", runIds: ["run_2"] })
2393
+ ).resolves.toEqual([])
1555
2394
 
1556
2395
  const retained = await storage.messages.list({
1557
2396
  projectId,
@@ -1729,5 +2568,321 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
1729
2568
  )
1730
2569
  })
1731
2570
  })
2571
+
2572
+ test("forks the finished history into a thread its caller owns alone", async () => {
2573
+ // Removal proof: copy every message while a turn is running; `m5` lands in the fork.
2574
+ await withStorage(async (storage, fixture) => {
2575
+ await prepareForkSource(storage, fixture)
2576
+ const sourceBefore = await storage.threads.getById({ projectId, id: "thr_1" })
2577
+ const source = await storage.messages.list({ projectId, threadId: "thr_1" })
2578
+
2579
+ const fork = await storage.threads.fork(forkInput())
2580
+
2581
+ expect(fork).toEqual({
2582
+ id: "thr_fork",
2583
+ projectId,
2584
+ kind: "conversation",
2585
+ ownerPrincipal: otherUser,
2586
+ title: "Slipped deals",
2587
+ status: "active",
2588
+ activeRunId: null,
2589
+ messageCount: 4,
2590
+ createdAt: at("2026-06-23T11:00:00.000Z"),
2591
+ updatedAt: at("2026-06-23T11:00:00.000Z"),
2592
+ })
2593
+ expect(await storage.threads.getById({ projectId, id: "thr_fork" })).toEqual(fork)
2594
+
2595
+ const copied = await storage.messages.list({ projectId, threadId: "thr_fork" })
2596
+ const finished = source.messages.slice(0, 4)
2597
+ expect(copied.messages.map(({ id: _id, threadId: _threadId, ...rest }) => rest)).toEqual(
2598
+ finished.map(({ id: _id, threadId: _threadId, ...rest }) => rest)
2599
+ )
2600
+ expect(copied.messages.every((message) => message.threadId === "thr_fork")).toBe(true)
2601
+
2602
+ const copiedIds = copied.messages.map((message) => message.id)
2603
+ expect(new Set(copiedIds).size).toBe(4)
2604
+ expect(copiedIds.some((id) => source.messages.some((message) => message.id === id))).toBe(
2605
+ false
2606
+ )
2607
+
2608
+ // A fork of an old conversation sorts with what its owner just did.
2609
+ // Removal proof: give the fork the last copied message's time; it sorts after the source.
2610
+ const listed = await storage.threads.list({ projectId })
2611
+ expect(listed.threads.map((thread) => thread.id)).toEqual(["thr_fork", "thr_1"])
2612
+
2613
+ // The source keeps everything, its running turn included.
2614
+ expect(await storage.threads.getById({ projectId, id: "thr_1" })).toEqual(sourceBefore)
2615
+ expect((await storage.messages.list({ projectId, threadId: "thr_1" })).messages).toEqual(
2616
+ source.messages
2617
+ )
2618
+
2619
+ const next = await storage.messages.append({
2620
+ id: "m_fork_next",
2621
+ projectId,
2622
+ threadId: "thr_fork",
2623
+ runId: null,
2624
+ role: "user",
2625
+ parts: [{ type: "text", text: "Draft them for me." }],
2626
+ })
2627
+ expect(next.seq).toBe(5)
2628
+ expect(await storage.threads.getById({ projectId, id: "thr_fork" })).toMatchObject({
2629
+ messageCount: 5,
2630
+ lastMessageAt: next.createdAt,
2631
+ })
2632
+ })
2633
+ })
2634
+
2635
+ test("copies a failed last turn with the checkpoint it wrote", async () => {
2636
+ await withStorage(async (storage, fixture) => {
2637
+ await prepareForkSource(storage, fixture)
2638
+ await storage.runs.finish({
2639
+ id: "run_3",
2640
+ projectId,
2641
+ executionToken: "exec_3",
2642
+ status: "failed",
2643
+ })
2644
+
2645
+ const fork = await storage.threads.fork(forkInput())
2646
+
2647
+ expect(fork.messageCount).toBe(5)
2648
+ expect(
2649
+ await storage.checkpoints.getLatest({ projectId, threadId: "thr_fork" })
2650
+ ).toMatchObject({ createdByRunId: "run_3", summarizedThroughSeq: 4, observedHeadSeq: 5 })
2651
+ })
2652
+ })
2653
+
2654
+ test("forks a fork, which copies the same run's checkpoint again", async () => {
2655
+ await withStorage(async (storage, fixture) => {
2656
+ await prepareForkSource(storage, fixture)
2657
+ await storage.threads.fork(forkInput())
2658
+
2659
+ const second = await storage.threads.fork(
2660
+ forkInput({ id: "thr_fork_of_fork", sourceThreadId: "thr_fork" })
2661
+ )
2662
+
2663
+ expect(second.messageCount).toBe(4)
2664
+ const copies = await Promise.all(
2665
+ ["thr_1", "thr_fork", "thr_fork_of_fork"].map((threadId) =>
2666
+ storage.checkpoints.getByRunIds({ projectId, threadId, runIds: ["run_2"] })
2667
+ )
2668
+ )
2669
+ expect(copies.map(([checkpoint]) => checkpoint?.threadId)).toEqual([
2670
+ "thr_1",
2671
+ "thr_fork",
2672
+ "thr_fork_of_fork",
2673
+ ])
2674
+ expect(new Set(copies.map(([checkpoint]) => checkpoint?.id)).size).toBe(3)
2675
+ expect(
2676
+ await storage.checkpoints.getLatest({ projectId, threadId: "thr_fork_of_fork" })
2677
+ ).toEqual(copies[2]?.[0])
2678
+ })
2679
+ })
2680
+
2681
+ test("keeps the latest checkpoint that does not anchor on the running turn", async () => {
2682
+ // Removal proof: drop the observed-head condition when choosing the checkpoint; the fork
2683
+ // keeps `checkpoint_2`, which anchors on the running turn's message the fork does not have.
2684
+ await withStorage(async (storage, fixture) => {
2685
+ await prepareForkSource(storage, fixture)
2686
+ const [first, second] = await storage.checkpoints.getByRunIds({
2687
+ projectId,
2688
+ threadId: "thr_1",
2689
+ runIds: ["run_2", "run_3"],
2690
+ })
2691
+
2692
+ await storage.threads.fork(forkInput())
2693
+
2694
+ const kept = await storage.checkpoints.getLatest({ projectId, threadId: "thr_fork" })
2695
+ if (!kept || !first) throw new Error("Expected the fork to keep checkpoint_1.")
2696
+
2697
+ const { id: keptId, threadId: keptThreadId, previousCheckpointId, ...copied } = kept
2698
+ const { id: _firstId, threadId: _firstThreadId, ...original } = first
2699
+ expect(copied).toEqual(original)
2700
+ expect(keptId).not.toBe(first.id)
2701
+ expect(keptThreadId).toBe("thr_fork")
2702
+ expect(previousCheckpointId).toBeUndefined()
2703
+
2704
+ // The fork's projection reads the kept checkpoint and the copied tail after it.
2705
+ const tail = await storage.messages.list({
2706
+ projectId,
2707
+ threadId: "thr_fork",
2708
+ afterSeq: kept.summarizedThroughSeq,
2709
+ order: "asc",
2710
+ })
2711
+ expect(
2712
+ projectAgentThreadModelContext({ checkpoint: kept, messages: tail.messages })
2713
+ ).toHaveLength(3)
2714
+
2715
+ await expect(
2716
+ storage.checkpoints.getByRunIds({ projectId, threadId: "thr_fork", runIds: ["run_2"] })
2717
+ ).resolves.toEqual([kept])
2718
+ await expect(
2719
+ storage.checkpoints.getByRunIds({
2720
+ projectId,
2721
+ threadId: "thr_1",
2722
+ runIds: ["run_2", "run_3"],
2723
+ })
2724
+ ).resolves.toEqual([first, second])
2725
+
2726
+ // Once the turn has finished, the checkpoint it wrote anchors on copied history.
2727
+ await storage.messages.append({
2728
+ id: "m6",
2729
+ projectId,
2730
+ threadId: "thr_1",
2731
+ runId: "run_3",
2732
+ role: "assistant",
2733
+ parts: [{ type: "text", text: "Drafted." }],
2734
+ })
2735
+ await storage.runs.finish({
2736
+ id: "run_3",
2737
+ projectId,
2738
+ executionToken: "exec_3",
2739
+ status: "succeeded",
2740
+ })
2741
+ await storage.threads.fork(forkInput({ id: "thr_fork_2" }))
2742
+
2743
+ expect(
2744
+ await storage.checkpoints.getLatest({ projectId, threadId: "thr_fork_2" })
2745
+ ).toMatchObject({
2746
+ createdByRunId: "run_3",
2747
+ threadId: "thr_fork_2",
2748
+ summarizedThroughSeq: 4,
2749
+ observedHeadSeq: 5,
2750
+ })
2751
+ expect((await storage.threads.getById({ projectId, id: "thr_fork_2" }))?.messageCount).toBe(
2752
+ 6
2753
+ )
2754
+ })
2755
+ })
2756
+
2757
+ test("forks an empty thread and rejects a missing source or a taken id", async () => {
2758
+ await withStorage(async (storage) => {
2759
+ await storage.threads.create(threadInput())
2760
+
2761
+ const fork = await storage.threads.fork(forkInput({ title: undefined }))
2762
+ expect(fork).toMatchObject({ messageCount: 0, activeRunId: null })
2763
+ expect(fork.createdAt).toEqual(at("2026-06-23T11:00:00.000Z"))
2764
+ expect(fork.lastMessageAt).toBeUndefined()
2765
+ expect(fork.title).toBeUndefined()
2766
+
2767
+ await expectAgentError(storage.threads.fork(forkInput()), "duplicate_id")
2768
+ await expectAgentError(
2769
+ storage.threads.fork(forkInput({ id: "thr_other", sourceThreadId: "missing" })),
2770
+ "thread_not_found"
2771
+ )
2772
+ await expectAgentError(
2773
+ storage.threads.fork(forkInput({ id: "thr_other", projectId: otherProjectId })),
2774
+ "thread_not_found"
2775
+ )
2776
+ })
2777
+ })
2778
+
2779
+ // Regression proof: drop the remap from a provider's fork; the copy then names the source's
2780
+ // artifact, which the fork's readers may not reach.
2781
+ test("names the fork's copies of the source's artifacts in the messages it copies", async () => {
2782
+ await withStorage(async (storage) => {
2783
+ await storage.threads.create(threadInput())
2784
+ const text = "See ![Revenue](artifact:art_0000000001#chart=revenue) and art_0000000009."
2785
+ await storage.messages.append({
2786
+ id: "msg_shown",
2787
+ projectId,
2788
+ threadId: "thr_1",
2789
+ runId: null,
2790
+ role: "user",
2791
+ parts: [{ type: "text", text }],
2792
+ })
2793
+
2794
+ await storage.threads.fork(
2795
+ forkInput({ artifactCopies: { art_0000000001: "art_000000copy1" } })
2796
+ )
2797
+
2798
+ const [copy] = (await storage.messages.list({ projectId, threadId: "thr_fork" })).messages
2799
+ expect(copy?.parts).toEqual([
2800
+ {
2801
+ type: "text",
2802
+ text: "See ![Revenue](artifact:art_000000copy1#chart=revenue) and art_0000000009.",
2803
+ },
2804
+ ])
2805
+ const [source] = (await storage.messages.list({ projectId, threadId: "thr_1" })).messages
2806
+ expect(source?.parts).toEqual([{ type: "text", text }])
2807
+ })
2808
+ })
2809
+
2810
+ // Regression proof: drop the summary's remap in planAgentThreadFork; the copied checkpoint
2811
+ // then names the source's artifact.
2812
+ test("names the fork's copies in the checkpoint summary it copies", async () => {
2813
+ await withStorage(async (storage, fixture) => {
2814
+ const summary = "Drafted art_0000000001 for Acme; art_0000000009 is the source data."
2815
+ await prepareForkSource(storage, fixture, summary)
2816
+ await storage.runs.finish({
2817
+ id: "run_3",
2818
+ projectId,
2819
+ executionToken: "exec_3",
2820
+ status: "failed",
2821
+ })
2822
+
2823
+ await storage.threads.fork(
2824
+ forkInput({ artifactCopies: { art_0000000001: "art_000000copy1" } })
2825
+ )
2826
+
2827
+ expect(
2828
+ (await storage.checkpoints.getLatest({ projectId, threadId: "thr_fork" }))?.summary
2829
+ ).toBe("Drafted art_000000copy1 for Acme; art_0000000009 is the source data.")
2830
+ expect(
2831
+ (await storage.checkpoints.getLatest({ projectId, threadId: "thr_1" }))?.summary
2832
+ ).toBe(summary)
2833
+ })
2834
+ })
2835
+
2836
+ test("starts a forked workspace with a new, reset sandbox", async () => {
2837
+ await withStorage(async (storage) => {
2838
+ await storage.threads.create(threadInput({ sandboxParams: { repo: "deals" } }))
2839
+
2840
+ const fork = await storage.threads.fork(
2841
+ forkInput({ sandboxParams: { repo: "deals" }, sandboxName: "sixb-sb-fork" })
2842
+ )
2843
+ expect(fork.sandboxParams).toEqual({ repo: "deals" })
2844
+ expect(fork.sandboxState).toEqual({
2845
+ name: "sixb-sb-fork",
2846
+ status: "new",
2847
+ initialized: false,
2848
+ resetAt: "2026-06-23T11:00:00.000Z",
2849
+ })
2850
+
2851
+ await expectAgentError(
2852
+ storage.threads.fork(forkInput({ id: "thr_2", sandboxParams: { repo: "deals" } })),
2853
+ "invalid_input"
2854
+ )
2855
+ await expectAgentError(
2856
+ storage.threads.fork(forkInput({ id: "thr_2", sandboxName: "sixb-sb-fork" })),
2857
+ "invalid_input"
2858
+ )
2859
+ await expectAgentError(
2860
+ storage.threads.fork(
2861
+ forkInput({ id: "thr_2", sandboxParams: {}, sandboxName: "../invalid" })
2862
+ ),
2863
+ "invalid_input"
2864
+ )
2865
+ expect(await storage.threads.getById({ projectId, id: "thr_2" })).toBeNull()
2866
+ })
2867
+ })
2868
+
2869
+ test("rolls back a fork with its containing storage transaction", async () => {
2870
+ await withStorage(async (storage, fixture) => {
2871
+ await prepareForkSource(storage, fixture)
2872
+ const rollback = new Error("rollback fork")
2873
+
2874
+ await expect(
2875
+ fixture.transaction(async (tx) => {
2876
+ if (!tx.agents) throw new Error("Expected agent storage in transaction.")
2877
+ await tx.agents.threads.fork(forkInput())
2878
+ throw rollback
2879
+ })
2880
+ ).rejects.toBe(rollback)
2881
+
2882
+ expect(await storage.threads.getById({ projectId, id: "thr_fork" })).toBeNull()
2883
+ expect((await storage.messages.list({ projectId, threadId: "thr_fork" })).total).toBe(0)
2884
+ expect(await storage.checkpoints.getLatest({ projectId, threadId: "thr_fork" })).toBeNull()
2885
+ })
2886
+ })
1732
2887
  })
1733
2888
  }