@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,46 +1,95 @@
1
- import { principalsEqual, SYSTEM_PRINCIPAL } from "../auth"
2
- import { assertAuthorized, isRuntimeAllowed } from "../authorization"
1
+ import { principalsEqual, type UserPrincipal } from "../auth"
2
+ import { AuthorizationError, assertAuthorized, isRuntimeAllowed } from "../authorization"
3
+ import { isSixbError } from "../errors/internal"
3
4
  import type { AuthorizablePrincipal, ExecutionContext } from "../execution"
5
+ import { canInheritAgentRequestAuthorization } from "../execution/agent"
4
6
  import { resolveRuntimeAuthorizationForProject } from "../execution/authorization"
5
- import type { ModelCatalog } from "../models"
6
- import { resolveExecutionCosts } from "../runtime/ai-cost"
7
- import { resolveExecutionUsage } from "../runtime/ai-usage"
7
+ import type { DecisionModelsRuntime, ModelCatalog } from "../models"
8
8
  import type { SixbDependencies } from "../runtime/sixb"
9
9
  import type { SixbRuntimeContext } from "../runtime/types"
10
+ import type { SecurityDefinitionCatalog } from "../security"
10
11
  import type {
12
+ AgentApprovalMode,
13
+ AgentApprovalRecord,
14
+ AgentRunRecord,
15
+ AgentStorage,
11
16
  AgentThreadRecord,
12
17
  ConversationAgentRunRecord,
18
+ ListAgentApprovalsInput,
19
+ ListAgentApprovalsResult,
13
20
  ListAgentRunsInput,
14
21
  ListAgentRunsResult,
15
22
  ListAgentThreadsInput,
16
23
  ListAgentThreadsResult,
24
+ SubagentRunRecord,
17
25
  } from "../storage/agents"
18
26
  import type { AiCostSummary } from "../storage/ai-cost"
19
27
  import type { AiModelCallUsage } from "../storage/ai-usage"
28
+ import { resolveTurnAccounting } from "./accounting"
29
+ import { type AgentApprovalResume, registerAgentTurnResume } from "./approval-continuation"
30
+ import { getAgentApprovalExecutor } from "./approval-executor"
31
+ import {
32
+ agentRunApprovalMode,
33
+ approvalModeAllows,
34
+ assertAgentApprovalMode,
35
+ decideAgentApproval,
36
+ defaultAgentApprovalMode,
37
+ isAwaitingApprovalRun,
38
+ leastApprovalModeAllowing,
39
+ listTurnApprovals,
40
+ type ResolvedAgentApprovalMode,
41
+ resolveAgentApprovalMode,
42
+ resumedApprovalMode,
43
+ stopAgentTurn,
44
+ } from "./approvals"
45
+ import { cancelAgentRun } from "./cancel"
46
+ import {
47
+ type AgentChildView,
48
+ cancelAgentChildRun,
49
+ listAgentChildren,
50
+ readAgentChild,
51
+ } from "./children"
20
52
  import { AgentRequestError } from "./errors"
53
+ import { forkAgentThread } from "./fork"
21
54
  import { createAgentThreadId, createAgentThreadSandboxName } from "./ids"
55
+ import { type AgentMemoryRuntime, createAgentMemoryRuntime } from "./memory-execution"
56
+ import { createTurnModelRouter } from "./model-routing"
57
+ import {
58
+ type AgentThreadParticipantInput,
59
+ addAgentThreadParticipants,
60
+ removeAgentThreadParticipant,
61
+ } from "./participants"
22
62
  import {
23
63
  type RequestAgentRunInput,
24
64
  type RequestAgentRunResult,
25
65
  requestAgentRun,
66
+ resumeAgentTurn,
26
67
  retryAgentRun,
27
68
  } from "./request"
28
69
  import { assertNoAgentSelector } from "./retired-config"
29
70
  import { normalizeSandboxBinding } from "./sandbox"
71
+ import { listSubagentThreadRuns } from "./subagent-runs"
72
+ import {
73
+ type AgentThreadView,
74
+ agentThreadViews,
75
+ assertConversationThread,
76
+ createAgentThreadAccessRule,
77
+ } from "./thread-access"
30
78
  import type { AgentDescriptor } from "./types"
31
79
 
32
80
  export type ExecutionAgentRequestInput = Omit<RequestAgentRunInput, "principal">
33
81
 
34
- /** Execution ownership tokens never leave the storage/worker boundary. */
35
- function publicThread(thread: AgentThreadRecord): AgentThreadRecord {
36
- if (!thread.sandboxState) return thread
37
- const { name, status, initialized } = thread.sandboxState
38
- return { ...thread, sandboxState: { name, status, initialized } }
39
- }
40
82
  export type ListExecutionAgentThreadsInput = Omit<
41
83
  ListAgentThreadsInput,
42
- "projectId" | "ownerPrincipal"
43
- >
84
+ "projectId" | "ownerPrincipal" | "participantPrincipal"
85
+ > & {
86
+ /** The threads other users added the caller to, instead of the caller's own. */
87
+ readonly sharedWithMe?: boolean
88
+ }
89
+
90
+ export interface ListAgentThreadViewsResult extends Omit<ListAgentThreadsResult, "threads"> {
91
+ readonly threads: readonly AgentThreadView[]
92
+ }
44
93
 
45
94
  export type CreateExecutionAgentThreadInput<
46
95
  TParams extends Record<string, unknown> = Record<string, unknown>,
@@ -52,32 +101,208 @@ export type CreateExecutionAgentThreadInput<
52
101
 
53
102
  export type AgentThreadsRuntime<TParams extends Record<string, unknown> = Record<string, unknown>> =
54
103
  {
55
- /** Start fresh after uncertain recovery; never deletes the previous sandbox. */
104
+ /** Start fresh after uncertain recovery; never deletes the previous sandbox. Owner only. */
56
105
  recreateSandbox(
57
106
  threadId: string,
58
107
  input: { readonly expectedSandboxName: string }
59
- ): Promise<AgentThreadRecord>
60
- create(input: CreateExecutionAgentThreadInput<TParams>): Promise<AgentThreadRecord>
61
- getById(threadId: string): Promise<AgentThreadRecord | null>
62
- list(input?: ListExecutionAgentThreadsInput): Promise<ListAgentThreadsResult>
108
+ ): Promise<AgentThreadView>
109
+ create(input: CreateExecutionAgentThreadInput<TParams>): Promise<AgentThreadView>
110
+ /**
111
+ * Copy a thread of the caller's, or one shared with them, into a new one the caller owns alone,
112
+ * with a new sandbox. A turn still running is not copied.
113
+ */
114
+ fork(threadId: string): Promise<AgentThreadView>
115
+ /** A thread the caller owns or takes part in. */
116
+ getById(threadId: string): Promise<AgentThreadView | null>
117
+ /** The caller's own threads, or with `sharedWithMe` the ones other users added it to. */
118
+ list(input?: ListExecutionAgentThreadsInput): Promise<ListAgentThreadViewsResult>
119
+ /**
120
+ * The sub-agents a conversation's turns spawned, oldest first, each the thread it works in with
121
+ * every run it took; `null` when the caller cannot read the conversation. `runId` keeps those
122
+ * one turn spawned. A sub-agent is visible exactly when its conversation is.
123
+ */
124
+ listChildren(
125
+ threadId: string,
126
+ input?: ListAgentChildrenInput
127
+ ): Promise<AgentChildListResult | null>
128
+ /** The sub-agent that works in a thread, read as `listChildren` lists it. */
129
+ getChild(threadId: string): Promise<AgentChildView | null>
130
+ /** Who else reads the conversation and talks in it. */
131
+ readonly participants: AgentThreadParticipantsRuntime
132
+ /**
133
+ * The caller's mode in a thread they read, and where it comes from: their choice there, else
134
+ * their default, else the fallback.
135
+ */
136
+ getApprovalMode(threadId: string): Promise<ResolvedAgentApprovalMode | null>
137
+ /**
138
+ * Choose the caller's own mode for their next turns in a thread; `null` follows their default
139
+ * again. Others keep theirs.
140
+ */
141
+ setApprovalMode(
142
+ threadId: string,
143
+ mode: AgentApprovalMode | null
144
+ ): Promise<ResolvedAgentApprovalMode>
145
+ }
146
+
147
+ /**
148
+ * The calls the Agent held for approval. Whoever reads a thread reads its approvals; only whoever
149
+ * asked for the turn decides, since the call runs with their rights.
150
+ */
151
+ export interface AgentApprovalsRuntime {
152
+ /**
153
+ * A thread's approvals, oldest first; without `threadId`, the caller's own in the threads they
154
+ * can open.
155
+ */
156
+ list(input?: ListExecutionAgentApprovalsInput): Promise<ListAgentApprovalsResult>
157
+ getById(approvalId: string): Promise<AgentApprovalRecord | null>
158
+ /**
159
+ * Approve or deny a pending call. An approved call runs now, and the approval comes back with its
160
+ * outcome. Once every call the turn held is decided, the turn resumes: `run` is the turn that
161
+ * continues it, and the model reads how each call ended. `always` also sets the caller's mode in
162
+ * the thread to the least that runs such a call without asking, and approves the turn's other
163
+ * calls that mode runs.
164
+ */
165
+ decide(
166
+ approvalId: string,
167
+ input: DecideExecutionAgentApprovalInput
168
+ ): Promise<AgentApprovalDecision>
169
+ }
170
+
171
+ export interface AgentApprovalDecision {
172
+ readonly approval: AgentApprovalRecord
173
+ /** The turn that resumed the paused one, when this decision was its last. */
174
+ readonly run?: ConversationAgentRunView
175
+ /**
176
+ * Present when the paused turn could not resume: the decision and the call's outcome stand.
177
+ * `retrying`: Sixb resumes it once it can, for example when an AI limit resets; otherwise the
178
+ * thread's next message tells the model how its calls ended.
179
+ */
180
+ readonly resume?: {
181
+ readonly status: "refused"
182
+ readonly code: string
183
+ readonly message: string
184
+ readonly retrying: boolean
63
185
  }
186
+ }
187
+
188
+ export type ListExecutionAgentApprovalsInput = Omit<
189
+ ListAgentApprovalsInput,
190
+ "projectId" | "requestedBy" | "reported"
191
+ >
192
+
193
+ export interface DecideExecutionAgentApprovalInput {
194
+ readonly decision: "approve" | "deny"
195
+ readonly always?: boolean
196
+ }
197
+
198
+ /** The caller's own Agent settings. */
199
+ export interface AgentPreferences {
200
+ /** The mode of the caller's turns in threads where they chose none. */
201
+ readonly approvalMode: AgentApprovalMode
202
+ /** `fallback` until the caller chooses a default. */
203
+ readonly approvalModeSource: "default" | "fallback"
204
+ }
205
+
206
+ export interface AgentPreferencesRuntime {
207
+ get(): Promise<AgentPreferences>
208
+ update(input: { readonly approvalMode?: AgentApprovalMode }): Promise<AgentPreferences>
209
+ }
210
+
211
+ /**
212
+ * Participants read the whole conversation, its files and its live stream, and send messages that
213
+ * run with their own rights. Nothing checks what they may see: the conversation holds what the
214
+ * Agent read with the rights of whoever asked.
215
+ */
216
+ export interface AgentThreadParticipantsRuntime {
217
+ /**
218
+ * Add active users of the project, by id or by email; only the thread's owner can. Someone
219
+ * already taking part keeps when and by whom they were added. Returns the thread with every
220
+ * participant.
221
+ */
222
+ add(threadId: string, users: readonly AgentThreadParticipantInput[]): Promise<AgentThreadView>
223
+ /**
224
+ * The owner removes anyone; a participant removes only themself, to leave. Removing someone who
225
+ * does not take part changes nothing.
226
+ */
227
+ remove(threadId: string, user: UserPrincipal): Promise<void>
228
+ }
229
+
230
+ /**
231
+ * Any user's conversation, read-only, for a caller with `can.observe(agent.threads)`. Nothing here
232
+ * checks who owns or takes part in a thread, and nothing writes: those stay on `threads` and `runs`.
233
+ */
234
+ export interface ObservedAgentThreadsRuntime {
235
+ /** Throws an `AuthorizationError` without `can.observe(agent.threads)`. */
236
+ getById(threadId: string): Promise<AgentThreadView | null>
237
+ /** The thread's conversation runs; `null` when the thread does not exist. */
238
+ listRuns(
239
+ threadId: string,
240
+ input?: Omit<ListAgentRunsInput, "projectId" | "threadId">
241
+ ): Promise<AgentRunListResult | null>
242
+ /** The sub-agents the thread's turns spawned; `null` when the thread is not a conversation. */
243
+ listChildren(
244
+ threadId: string,
245
+ input?: ListAgentChildrenInput
246
+ ): Promise<AgentChildListResult | null>
247
+ /** The sub-agent that works in a thread; `null` when it is not a sub-agent's. */
248
+ getChild(threadId: string): Promise<AgentChildView | null>
249
+ }
64
250
 
65
251
  export interface AgentRunsRuntime {
66
252
  request(input: ExecutionAgentRequestInput): Promise<ExecutionAgentRunResult>
253
+ /**
254
+ * Retry a failed or interrupted turn; only whoever asked for it can, as it runs with their rights.
255
+ * A sub-agent's run is never retried: its turn decides whether to spawn it again.
256
+ */
67
257
  retry(runId: string): Promise<ExecutionAgentRunResult>
258
+ /**
259
+ * Stop a turn; whoever asked for it, or the thread's owner, can. A queued turn is cancelled when
260
+ * this returns; a running one is still running, with the stop signal sent to its worker. A turn
261
+ * paused for approval stays as it ended, with its held calls cancelled: it never resumes. A
262
+ * sub-agent's run stops as its turn would: whoever asked for that turn, or the conversation's
263
+ * owner, can, and its parent's `wait_agent` reads that it was stopped.
264
+ */
265
+ cancel(runId: string): Promise<AgentRunView>
266
+ /** A turn, or a sub-agent's run, read through its thread. */
68
267
  getById(runId: string): Promise<AgentRunView | null>
268
+ /** A conversation's turns, or the runs of a sub-agent's thread. */
69
269
  listForThread(
70
270
  threadId: string,
71
271
  input?: Omit<ListAgentRunsInput, "projectId" | "threadId">
72
272
  ): Promise<AgentRunListResult | null>
73
273
  }
74
274
 
75
- /** Execution-facing run view with provenance resolved from the immutable execution ledger. */
76
- export interface AgentRunView extends ConversationAgentRunRecord {
275
+ export interface ListAgentChildrenInput {
276
+ /** Only those this turn of the conversation spawned. */
277
+ readonly runId?: string
278
+ }
279
+
280
+ export interface AgentChildListResult {
281
+ /** Oldest first. */
282
+ readonly children: readonly AgentChildView[]
283
+ }
284
+
285
+ /**
286
+ * Execution-facing run view with provenance resolved from the immutable execution ledger: a
287
+ * conversation turn, or a sub-agent's run.
288
+ */
289
+ export type AgentRunView = ConversationAgentRunView | SubagentRunView
290
+
291
+ /** A conversation turn's view: what a request, a retry or a resume returns. */
292
+ export type ConversationAgentRunView = ConversationAgentRunRecord & AgentRunViewFields
293
+
294
+ /** A sub-agent's run, read through its thread. */
295
+ export type SubagentRunView = SubagentRunRecord & AgentRunViewFields
296
+
297
+ interface AgentRunViewFields {
77
298
  readonly requestedBy?: AuthorizablePrincipal
78
- /** Derived from the model-call ledger; never persisted on the Agent run row. */
299
+ /**
300
+ * Derived from the model-call ledger; never persisted on the Agent run row. Covers the turn and
301
+ * everything below its execution: its children and what its tools ran, including what a workflow
302
+ * it started spends after the turn ends, as Activity counts it.
303
+ */
79
304
  readonly usage?: AiModelCallUsage
80
- /** Preferred valuation; omitted when there are no calls or cost storage is unavailable. */
305
+ /** Preferred valuation of the same calls; omitted without calls or cost storage. */
81
306
  readonly cost?: AiCostSummary
82
307
  }
83
308
 
@@ -86,7 +311,7 @@ export interface AgentRunListResult extends Omit<ListAgentRunsResult, "runs"> {
86
311
  }
87
312
 
88
313
  export interface ExecutionAgentRunResult extends Omit<RequestAgentRunResult, "run"> {
89
- readonly run: AgentRunView
314
+ readonly run: ConversationAgentRunView
90
315
  }
91
316
 
92
317
  export type AgentRuntime<TParams extends Record<string, unknown> = Record<string, unknown>> = {
@@ -94,6 +319,11 @@ export type AgentRuntime<TParams extends Record<string, unknown> = Record<string
94
319
  get(): AgentDescriptor | null
95
320
  readonly threads: AgentThreadsRuntime<TParams>
96
321
  readonly runs: AgentRunsRuntime
322
+ /** Other users' conversations, read-only, with `can.observe(agent.threads)`. */
323
+ readonly observed: ObservedAgentThreadsRuntime
324
+ readonly memory: AgentMemoryRuntime
325
+ readonly approvals: AgentApprovalsRuntime
326
+ readonly preferences: AgentPreferencesRuntime
97
327
  }
98
328
 
99
329
  export function createAgentRuntime<
@@ -101,25 +331,22 @@ export function createAgentRuntime<
101
331
  >(
102
332
  runtime: SixbRuntimeContext,
103
333
  execution: ExecutionContext,
104
- models?: ModelCatalog,
105
- sandbox?: SixbDependencies["sandbox"]
334
+ models: ModelCatalog | undefined,
335
+ decision: DecisionModelsRuntime,
336
+ sandbox: SixbDependencies["sandbox"] | undefined,
337
+ security: SecurityDefinitionCatalog
106
338
  ): AgentRuntime<TParams> {
107
339
  const authority = resolveRuntimeAuthorizationForProject(runtime)
108
- const principal = authority.type === "principal" ? authority.context.principal : SYSTEM_PRINCIPAL
340
+ const turnModels = {
341
+ language: models?.language,
342
+ router: createTurnModelRouter(models, decision),
343
+ }
344
+ const rule = createAgentThreadAccessRule(runtime, authority)
345
+ const principal = rule.caller
109
346
  const allowed = () => isRuntimeAllowed(runtime, { kind: "agent.run" })
110
347
 
111
- const getVisibleThreadRecord = async (threadId: string): Promise<AgentThreadRecord | null> => {
112
- if (authority.type === "denied" || authority.type === "delegated") return null
113
- const thread =
114
- (await runtime.storage.agents?.threads.getById({
115
- projectId: runtime.projectId,
116
- id: threadId,
117
- })) ?? null
118
- if (!thread || !allowed()) return null
119
- return authority.type === "principal" && !principalsEqual(principal, thread.ownerPrincipal)
120
- ? null
121
- : publicThread(thread)
122
- }
348
+ const getVisibleThreadRecord = async (threadId: string): Promise<AgentThreadView | null> =>
349
+ (await rule.read(threadId))?.thread ?? null
123
350
 
124
351
  const getAgent = (): AgentDescriptor | null => {
125
352
  if (authority.type === "denied" || authority.type === "delegated") return null
@@ -131,14 +358,15 @@ export function createAgentRuntime<
131
358
  }
132
359
  }
133
360
 
134
- const getVisibleRunRecord = async (runId: string): Promise<ConversationAgentRunRecord | null> => {
361
+ /** A turn, or a sub-agent's run, when the caller reads its thread. */
362
+ const getVisibleRunRecord = async (runId: string): Promise<AgentRunRecord | null> => {
135
363
  if (authority.type === "denied" || authority.type === "delegated") return null
136
364
  const run =
137
365
  (await runtime.storage.agents?.runs.getById({
138
366
  projectId: runtime.projectId,
139
367
  id: runId,
140
368
  })) ?? null
141
- if (!run || run.kind !== "conversation") return null
369
+ if (!run) return null
142
370
  const thread = await getVisibleThreadRecord(run.threadId)
143
371
  return thread ? run : null
144
372
  }
@@ -148,13 +376,349 @@ export function createAgentRuntime<
148
376
  return run ? attachRunView(runtime, run) : null
149
377
  }
150
378
 
151
- return {
379
+ /**
380
+ * A turn the caller may stop or retry. Whoever asked for it may do both; the thread's owner may
381
+ * also stop any turn, but retrying one would run it again with the owner's rights on someone
382
+ * else's words. Code without a caller acts on every turn.
383
+ */
384
+ const getControllableRun = async (
385
+ runId: string,
386
+ action: "cancel" | "retry"
387
+ ): Promise<ConversationAgentRunRecord> => {
388
+ const run = await runtime.storage.agents?.runs.getById({
389
+ projectId: runtime.projectId,
390
+ id: runId,
391
+ })
392
+ const readable = run ? await rule.read(run.threadId) : null
393
+ if (!run || !readable) {
394
+ throw new AgentRequestError("run_not_found", `[Sixb] Agent run '${runId}' was not found.`)
395
+ }
396
+ if (run.kind !== "conversation") {
397
+ throw new AgentRequestError(
398
+ action === "retry" ? "run_not_retryable" : "run_not_found",
399
+ action === "retry"
400
+ ? `[Sixb] Agent run '${runId}' is a sub-agent's: its turn spawns it again if it needs to.`
401
+ : `[Sixb] Agent run '${runId}' was not found.`
402
+ )
403
+ }
404
+
405
+ if (authority.type !== "principal") return run
406
+ if (action === "cancel" && readable.access === "owner") return run
407
+
408
+ const execution = await runtime.storage.executions.getById({
409
+ projectId: runtime.projectId,
410
+ id: run.executionId,
411
+ })
412
+ if (execution?.requestedBy && principalsEqual(execution.requestedBy, principal)) return run
413
+
414
+ throw new AgentRequestError(
415
+ "not_run_requester",
416
+ action === "cancel"
417
+ ? `[Sixb] Only whoever asked for Agent run '${runId}', or the thread's owner, can stop it.`
418
+ : `[Sixb] Only whoever asked for Agent run '${runId}' can retry it: it runs again with their rights.`
419
+ )
420
+ }
421
+
422
+ const requireAgents = (): AgentStorage => {
423
+ const storage = runtime.storage.agents
424
+ if (!storage) {
425
+ throw new AgentRequestError("storage_unavailable", "[Sixb] Agent storage is not configured.")
426
+ }
427
+ return storage
428
+ }
429
+
430
+ /** Settings belong to whoever calls: a shared link or a delegated execution has none. */
431
+ const settingsPrincipal = () => {
432
+ if (authority.type === "denied" || authority.type === "delegated") {
433
+ throw new AgentRequestError("agent_not_found", "[Sixb] The project Agent is unavailable.")
434
+ }
435
+ return principal
436
+ }
437
+
438
+ const getVisibleApproval = async (approvalId: string): Promise<AgentApprovalRecord | null> => {
439
+ if (authority.type === "denied" || authority.type === "delegated") return null
440
+ const approval = await runtime.storage.agents?.approvals.getById({
441
+ projectId: runtime.projectId,
442
+ id: approvalId,
443
+ })
444
+ return approval && (await rule.read(approval.threadId)) ? approval : null
445
+ }
446
+
447
+ const getThreadApprovalMode = async (
448
+ threadId: string
449
+ ): Promise<ResolvedAgentApprovalMode | null> => {
450
+ const thread = await getVisibleThreadRecord(threadId)
451
+ if (!thread) return null
452
+ if (thread.kind === "subagent") {
453
+ // A child's mode is its run's, copied from the turn it works under, whoever reads it.
454
+ const latest = (
455
+ await listSubagentThreadRuns(requireAgents(), { projectId: runtime.projectId, threadId })
456
+ ).at(-1)
457
+ return latest
458
+ ? { approvalMode: agentRunApprovalMode(latest), approvalModeSource: "run" }
459
+ : null
460
+ }
461
+ return resolveAgentApprovalMode(requireAgents(), {
462
+ projectId: runtime.projectId,
463
+ principal: settingsPrincipal(),
464
+ threadId,
465
+ })
466
+ }
467
+
468
+ const setThreadApprovalMode = async (
469
+ threadId: string,
470
+ mode: AgentApprovalMode | null
471
+ ): Promise<ResolvedAgentApprovalMode> => {
472
+ if (mode !== null) assertAgentApprovalMode(mode)
473
+ const thread = await getVisibleThreadRecord(threadId)
474
+ if (!thread) {
475
+ throw new AgentRequestError(
476
+ "thread_not_found",
477
+ `[Sixb] Agent thread '${threadId}' not found.`
478
+ )
479
+ }
480
+ assertConversationThread(thread)
481
+ const agents = requireAgents()
482
+ const scope = { projectId: runtime.projectId, principal: settingsPrincipal() }
483
+ await agents.approvalModes.setForThread({ ...scope, threadId, mode })
484
+ return resolveAgentApprovalMode(agents, { ...scope, threadId })
485
+ }
486
+
487
+ /** The caller's own approvals, in the threads they can still open. */
488
+ const listOwnApprovals = async (
489
+ storage: AgentStorage,
490
+ { limit, offset = 0, ...input }: ListExecutionAgentApprovalsInput
491
+ ): Promise<ListAgentApprovalsResult> => {
492
+ const { approvals } = await storage.approvals.list({
493
+ ...input,
494
+ projectId: runtime.projectId,
495
+ requestedBy: principal,
496
+ })
497
+ const readable = new Map<string, Promise<boolean>>()
498
+ const canRead = (threadId: string) => {
499
+ const known = readable.get(threadId)
500
+ if (known) return known
501
+ const read = rule.read(threadId).then((thread) => thread !== null)
502
+ readable.set(threadId, read)
503
+ return read
504
+ }
505
+
506
+ const visible: AgentApprovalRecord[] = []
507
+ for (const approval of approvals) {
508
+ if (await canRead(approval.threadId)) visible.push(approval)
509
+ }
510
+ const end = limit === undefined ? visible.length : offset + limit
511
+ return {
512
+ approvals: visible.slice(offset, end),
513
+ hasMore: end < visible.length,
514
+ total: visible.length,
515
+ }
516
+ }
517
+
518
+ const approvals: AgentApprovalsRuntime = {
519
+ list: async (input = {}) => {
520
+ const none = { approvals: [], hasMore: false, total: 0 }
521
+ if (authority.type === "denied" || authority.type === "delegated") return none
522
+ const storage = runtime.storage.agents
523
+ if (!storage) return none
524
+
525
+ if (input.threadId === undefined) return listOwnApprovals(storage, input)
526
+ if (!(await getVisibleThreadRecord(input.threadId))) return none
527
+ return storage.approvals.list({ ...input, projectId: runtime.projectId })
528
+ },
529
+ getById: getVisibleApproval,
530
+ decide: async (approvalId, input) => {
531
+ const approval = await getVisibleApproval(approvalId)
532
+ if (!approval) {
533
+ throw new AgentRequestError(
534
+ "approval_not_found",
535
+ `[Sixb] Agent approval '${approvalId}' was not found.`
536
+ )
537
+ }
538
+
539
+ // The call runs with the deciding request's authority: it must be one a turn can inherit.
540
+ if (!canInheritAgentRequestAuthorization(runtime.runtimeAuthorization)) {
541
+ throw new AgentRequestError(
542
+ "authority_not_inheritable",
543
+ "[Sixb] Deciding on an Agent call requires an authenticated user request or disabled authorization."
544
+ )
545
+ }
546
+
547
+ // "Always allow" raises the thread's mode first: nothing has run yet if that fails.
548
+ const always = input.always === true && input.decision === "approve"
549
+ const raisedMode = always ? leastApprovalModeAllowing(approval.call) : undefined
550
+ if (raisedMode !== undefined && approval.status === "pending") {
551
+ await allowInThread(approval, raisedMode)
552
+ }
553
+
554
+ const decided = await decide(
555
+ approval,
556
+ input.decision === "approve" ? "approved" : "denied",
557
+ raisedMode
558
+ )
559
+ if (raisedMode !== undefined && decided.status === "approved") {
560
+ await approveAllowed(decided, raisedMode)
561
+ }
562
+
563
+ // The decision and the call's outcome stand from here: a resume that fails is reported.
564
+ const resume = await resumeDecidedTurn(decided.runId)
565
+ if (resume.status === "refused") return { approval: decided, resume }
566
+ if (resume.status !== "resumed") return { approval: decided }
567
+
568
+ // The resume reported it to the model.
569
+ const reported = await requireAgents().approvals.getById({
570
+ projectId: runtime.projectId,
571
+ id: decided.id,
572
+ })
573
+ return { approval: reported ?? decided, run: await attachRunView(runtime, resume.run) }
574
+ },
575
+ }
576
+
577
+ const decide = (
578
+ approval: AgentApprovalRecord,
579
+ decision: "approved" | "denied",
580
+ raisedMode?: AgentApprovalMode
581
+ ) =>
582
+ decideAgentApproval(requireAgents(), getAgentApprovalExecutor(runtime), {
583
+ approval,
584
+ decision,
585
+ decidedBy: principal,
586
+ decider: { execution, authorization: runtime.runtimeAuthorization },
587
+ ...(raisedMode === undefined ? {} : { raisedMode }),
588
+ broker: runtime.broker,
589
+ })
590
+
591
+ /**
592
+ * "Always allow": the caller's thread mode rises to the least that runs such a call, unless what
593
+ * they chose already runs it. The fallback is no choice: it would hide the raise.
594
+ */
595
+ const allowInThread = async (
596
+ approval: AgentApprovalRecord,
597
+ raised: AgentApprovalMode
598
+ ): Promise<void> => {
599
+ const current = await getThreadApprovalMode(approval.threadId)
600
+ const chosen = current?.approvalModeSource === "fallback" ? undefined : current?.approvalMode
601
+ if (chosen === undefined || !approvalModeAllows(chosen, approval.call)) {
602
+ await setThreadApprovalMode(approval.threadId, raised)
603
+ }
604
+ }
605
+
606
+ /** "Always allow" also approves the turn's other calls the raised mode runs. */
607
+ const approveAllowed = async (
608
+ approval: AgentApprovalRecord,
609
+ raised: AgentApprovalMode
610
+ ): Promise<void> => {
611
+ const { approvals: waiting } = await requireAgents().approvals.list({
612
+ projectId: runtime.projectId,
613
+ runId: approval.runId,
614
+ requestedBy: principal,
615
+ statuses: ["pending"],
616
+ })
617
+ for (const other of waiting) {
618
+ if (!approvalModeAllows(raised, other.call)) continue
619
+ try {
620
+ await decide(other, "approved", raised)
621
+ } catch (error) {
622
+ // Decided, set aside or expired meanwhile: that outcome stands.
623
+ if (!(error instanceof AgentRequestError)) throw error
624
+ }
625
+ }
626
+ }
627
+
628
+ /**
629
+ * Resume a paused turn once its requester decided on every call it held, as that requester. It
630
+ * never throws: what keeps the turn from resuming comes back as `refused`, and unless Sixb can
631
+ * try again, the turn is stopped so that the thread's next message reports its calls.
632
+ */
633
+ const resumeDecidedTurn = async (runId: string): Promise<AgentApprovalResume> => {
634
+ const agents = requireAgents()
635
+ const run = await agents.runs.getById({ projectId: runtime.projectId, id: runId })
636
+ if (run?.kind !== "conversation" || !isAwaitingApprovalRun(run)) return { status: "closed" }
637
+
638
+ const requester = (
639
+ await runtime.storage.executions.getById({
640
+ projectId: runtime.projectId,
641
+ id: run.executionId,
642
+ })
643
+ )?.requestedBy
644
+ if (authority.type === "principal" && !(requester && principalsEqual(requester, principal))) {
645
+ return { status: "closed" }
646
+ }
647
+
648
+ const stop = () => stopAgentTurn(agents, runtime.broker, run)
649
+ try {
650
+ // A requester who left the thread no longer runs turns in it.
651
+ if (!(await rule.read(run.threadId))) {
652
+ throw new AgentRequestError(
653
+ "thread_not_found",
654
+ `[Sixb] Agent thread '${run.threadId}' is no longer readable by whoever asked for its turn.`
655
+ )
656
+ }
657
+
658
+ const approvalMode = resumedApprovalMode(
659
+ agentRunApprovalMode(run),
660
+ await listTurnApprovals(agents, { projectId: runtime.projectId, runId: run.id }),
661
+ await agents.approvalModes.getForThread({
662
+ projectId: runtime.projectId,
663
+ threadId: run.threadId,
664
+ principal,
665
+ })
666
+ )
667
+ const resumed = await resumeAgentTurn(runtime, execution, models?.language, run, {
668
+ approvalMode,
669
+ principal,
670
+ })
671
+ if (resumed.status === "closed") await stop()
672
+ return resumed
673
+ } catch (error) {
674
+ const refused = refusedResume(error)
675
+ if (!refused.retrying) await stop()
676
+ return refused
677
+ }
678
+ }
679
+
680
+ const preferences: AgentPreferencesRuntime = {
681
+ get: async () => {
682
+ const { approvalMode, approvalModeSource } = await defaultAgentApprovalMode(requireAgents(), {
683
+ projectId: runtime.projectId,
684
+ principal: settingsPrincipal(),
685
+ })
686
+ return {
687
+ approvalMode,
688
+ approvalModeSource: approvalModeSource === "default" ? "default" : "fallback",
689
+ }
690
+ },
691
+ update: async (input) => {
692
+ if (input.approvalMode !== undefined) {
693
+ await requireAgents().approvalModes.setDefault({
694
+ projectId: runtime.projectId,
695
+ principal: settingsPrincipal(),
696
+ mode: assertAgentApprovalMode(input.approvalMode),
697
+ })
698
+ }
699
+ return preferences.get()
700
+ },
701
+ }
702
+
703
+ const agentRuntime: AgentRuntime<TParams> = {
152
704
  get: getAgent,
705
+ memory: createAgentMemoryRuntime(runtime),
706
+ approvals,
707
+ preferences,
153
708
  threads: {
154
709
  recreateSandbox: async (threadId, input) => {
155
- const thread = await getVisibleThreadRecord(threadId)
156
- if (!thread)
710
+ const readable = await rule.read(threadId)
711
+ if (!readable)
157
712
  throw new AgentRequestError("thread_not_found", "[Sixb] Agent thread not found.")
713
+ assertConversationThread(readable.thread)
714
+ if (readable.access !== "owner") {
715
+ throw new AgentRequestError(
716
+ "not_thread_owner",
717
+ `[Sixb] Only the owner of Agent thread '${threadId}' can recreate its sandbox.`
718
+ )
719
+ }
720
+
721
+ const thread = readable.thread
158
722
  const storage = runtime.storage.agents
159
723
  if (!storage)
160
724
  throw new AgentRequestError(
@@ -168,7 +732,8 @@ export function createAgentRuntime<
168
732
  expectedSandboxName: input.expectedSandboxName,
169
733
  name: createAgentThreadSandboxName(runtime.projectId, threadId),
170
734
  })
171
- return publicThread({ ...thread, sandboxState })
735
+ const [view] = await agentThreadViews(runtime, [{ ...thread, sandboxState }])
736
+ return view ?? thread
172
737
  },
173
738
  create: async (input) => {
174
739
  assertNoAgentSelector(input)
@@ -193,29 +758,84 @@ export function createAgentRuntime<
193
758
  input.sandbox === undefined
194
759
  ? undefined
195
760
  : normalizeSandboxBinding(sandbox?.definition, input.sandbox, runtime.ontology)
196
- return storage.threads.create({
761
+ const created = await storage.threads.create({
197
762
  ...(binding === undefined ? {} : { sandboxParams: binding }),
198
763
  id: input.id ?? createAgentThreadId(),
199
764
  projectId: runtime.projectId,
200
765
  ownerPrincipal: principal,
201
766
  ...(input.title === undefined ? {} : { title: input.title }),
202
767
  })
768
+ return { ...created, participants: [] }
769
+ },
770
+ listChildren: async (threadId, { runId } = {}) => {
771
+ const thread = await getVisibleThreadRecord(threadId)
772
+ if (thread?.kind !== "conversation") return null
773
+ return {
774
+ children: await listAgentChildren(runtime, thread, {
775
+ ...(runId === undefined ? {} : { spawnedBy: runId }),
776
+ }),
777
+ }
778
+ },
779
+ getChild: async (threadId) => {
780
+ const thread = await getVisibleThreadRecord(threadId)
781
+ const conversation = thread?.parent
782
+ ? await getVisibleThreadRecord(thread.parent.threadId)
783
+ : null
784
+ return thread && conversation ? readAgentChild(runtime, conversation, thread) : null
785
+ },
786
+ fork: async (threadId) => {
787
+ // Checked before the copy's transaction: an access removed in between can still fork once.
788
+ const readable = await rule.read(threadId)
789
+ if (!readable) {
790
+ throw new AgentRequestError(
791
+ "thread_not_found",
792
+ `[Sixb] Agent thread '${threadId}' not found.`
793
+ )
794
+ }
795
+ // A sub-agent's work is continued by its conversation, never on its own.
796
+ assertConversationThread(readable.thread)
797
+
798
+ if (!getAgent()) {
799
+ throw new AgentRequestError("agent_not_found", "[Sixb] The project Agent is unavailable.")
800
+ }
801
+
802
+ const fork = await forkAgentThread(runtime, {
803
+ source: readable.thread,
804
+ ownerPrincipal: principal,
805
+ sandbox,
806
+ })
807
+ const [view] = await agentThreadViews(runtime, [fork])
808
+ return view ?? { ...fork, participants: [] }
203
809
  },
204
810
  getById: getVisibleThreadRecord,
205
- list: async (input = {}) => {
811
+ list: async ({ sharedWithMe, ...input } = {}) => {
206
812
  assertNoAgentSelector(input)
207
- if (authority.type === "denied" || authority.type === "delegated") {
208
- return { threads: [], hasMore: false, total: 0 }
209
- }
813
+ const none = { threads: [], hasMore: false, total: 0 }
814
+ if (authority.type === "denied" || authority.type === "delegated") return none
815
+
210
816
  const storage = runtime.storage.agents
211
- if (!storage || !allowed()) return { threads: [], hasMore: false, total: 0 }
817
+ if (!storage || !allowed()) return none
818
+
819
+ // Code without a caller owns every thread, so nothing is shared with it.
820
+ const caller = authority.type === "principal" ? principal : undefined
821
+ if (sharedWithMe && caller?.type !== "user") return none
822
+
212
823
  const result = await storage.threads.list({
213
824
  ...input,
214
825
  projectId: runtime.projectId,
215
- ownerPrincipal: authority.type === "principal" ? principal : undefined,
826
+ ...(sharedWithMe && caller?.type === "user"
827
+ ? { participantPrincipal: caller }
828
+ : { ownerPrincipal: caller }),
216
829
  })
217
- return { ...result, threads: result.threads.map(publicThread) }
830
+ return { ...result, threads: await agentThreadViews(runtime, result.threads) }
218
831
  },
832
+ participants: {
833
+ add: (threadId, users) =>
834
+ addAgentThreadParticipants(runtime, rule, security, threadId, users),
835
+ remove: (threadId, user) => removeAgentThreadParticipant(runtime, rule, threadId, user),
836
+ },
837
+ getApprovalMode: getThreadApprovalMode,
838
+ setApprovalMode: setThreadApprovalMode,
219
839
  },
220
840
  runs: {
221
841
  request: async (input) => {
@@ -231,17 +851,14 @@ export function createAgentRuntime<
231
851
  `[Sixb] Agent thread '${input.threadId}' not found.`
232
852
  )
233
853
  }
234
- const result = await requestAgentRun(runtime, execution, models?.language, {
854
+ const result = await requestAgentRun(runtime, execution, turnModels, {
235
855
  ...input,
236
856
  principal,
237
857
  })
238
858
  return { ...result, run: await attachRunView(runtime, result.run) }
239
859
  },
240
860
  retry: async (runId) => {
241
- const failedRun = await getVisibleRunRecord(runId)
242
- if (!failedRun) {
243
- throw new AgentRequestError("run_not_found", `[Sixb] Agent run '${runId}' was not found.`)
244
- }
861
+ const failedRun = await getControllableRun(runId, "retry")
245
862
  const agent = getAgent()
246
863
  if (!agent) {
247
864
  throw new AgentRequestError("agent_not_found", "[Sixb] The project Agent is unavailable.")
@@ -249,43 +866,111 @@ export function createAgentRuntime<
249
866
  const result = await retryAgentRun(runtime, execution, models?.language, failedRun)
250
867
  return { ...result, run: await attachRunView(runtime, result.run) }
251
868
  },
869
+ cancel: async (runId) => {
870
+ const run = await getVisibleRunRecord(runId)
871
+ if (run?.kind !== "subagent") {
872
+ const turn = await getControllableRun(runId, "cancel")
873
+ return attachRunView(runtime, await cancelAgentRun(runtime, turn))
874
+ }
875
+
876
+ // A sub-agent's run stops as the turn it works under would.
877
+ await getControllableRun(run.parentRunId, "cancel")
878
+ return attachRunView(runtime, await cancelAgentChildRun(runtime, run))
879
+ },
252
880
  getById: getRun,
253
881
  listForThread: async (threadId, input = {}) => {
254
882
  assertNoAgentSelector(input)
255
- const storage = runtime.storage.agents
256
- if (!storage || !(await getVisibleThreadRecord(threadId))) return null
257
- const result = await storage.runs.list({
258
- ...input,
259
- projectId: runtime.projectId,
260
- threadId,
261
- })
262
- return {
263
- ...result,
264
- runs: await attachRunViews(
265
- runtime,
266
- result.runs.filter((run) => run.kind === "conversation")
267
- ),
268
- }
883
+ const thread = await getVisibleThreadRecord(threadId)
884
+ if (!thread) return null
885
+ return listThreadRuns(runtime, thread, input)
269
886
  },
270
887
  },
888
+ observed: createObservedAgentThreadsRuntime(runtime),
271
889
  }
890
+ registerAgentTurnResume(agentRuntime, resumeDecidedTurn)
891
+ return agentRuntime
272
892
  }
273
893
 
274
- async function attachRunView(
894
+ function createObservedAgentThreadsRuntime(
895
+ runtime: SixbRuntimeContext
896
+ ): ObservedAgentThreadsRuntime {
897
+ const getById = async (threadId: string): Promise<AgentThreadView | null> => {
898
+ assertAuthorized(runtime, { kind: "agentThreads.observe" })
899
+
900
+ const thread = await runtime.storage.agents?.threads.getById({
901
+ projectId: runtime.projectId,
902
+ id: threadId,
903
+ })
904
+ if (!thread) return null
905
+
906
+ const [view] = await agentThreadViews(runtime, [thread])
907
+ return view ?? null
908
+ }
909
+
910
+ return {
911
+ getById,
912
+
913
+ async listRuns(threadId, input = {}) {
914
+ assertNoAgentSelector(input)
915
+ const thread = await getById(threadId)
916
+ if (!thread) return null
917
+ return listThreadRuns(runtime, thread, input)
918
+ },
919
+
920
+ async getChild(threadId) {
921
+ const thread = await getById(threadId)
922
+ const conversation = thread?.parent ? await getById(thread.parent.threadId) : null
923
+ return thread && conversation ? readAgentChild(runtime, conversation, thread) : null
924
+ },
925
+
926
+ async listChildren(threadId, { runId } = {}) {
927
+ const thread = await getById(threadId)
928
+ if (thread?.kind !== "conversation") return null
929
+ return {
930
+ children: await listAgentChildren(runtime, thread, {
931
+ ...(runId === undefined ? {} : { spawnedBy: runId }),
932
+ }),
933
+ }
934
+ },
935
+ }
936
+ }
937
+
938
+ /**
939
+ * A thread's runs with their views: a conversation's turns, or a sub-agent's runs. Whoever calls it
940
+ * has decided who may read them.
941
+ */
942
+ async function listThreadRuns(
275
943
  runtime: SixbRuntimeContext,
276
- run: ConversationAgentRunRecord
277
- ): Promise<AgentRunView> {
944
+ thread: Pick<AgentThreadRecord, "id" | "kind">,
945
+ input: Omit<ListAgentRunsInput, "projectId" | "threadId">
946
+ ): Promise<AgentRunListResult | null> {
947
+ const storage = runtime.storage.agents
948
+ if (!storage) return null
949
+
950
+ const result = await storage.runs.list({
951
+ ...input,
952
+ projectId: runtime.projectId,
953
+ threadId: thread.id,
954
+ kinds: [thread.kind],
955
+ })
956
+ return { ...result, runs: await attachRunViews(runtime, result.runs) }
957
+ }
958
+
959
+ async function attachRunView<TRun extends AgentRunRecord>(
960
+ runtime: SixbRuntimeContext,
961
+ run: TRun
962
+ ): Promise<TRun & AgentRunViewFields> {
278
963
  const [view] = await attachRunViews(runtime, [run])
279
964
  if (!view) throw new Error(`[Sixb] Could not build Agent run '${run.id}' view.`)
280
965
  return view
281
966
  }
282
967
 
283
- async function attachRunViews(
968
+ async function attachRunViews<TRun extends AgentRunRecord>(
284
969
  runtime: SixbRuntimeContext,
285
- runs: readonly ConversationAgentRunRecord[]
286
- ): Promise<readonly AgentRunView[]> {
970
+ runs: readonly TRun[]
971
+ ): Promise<readonly (TRun & AgentRunViewFields)[]> {
287
972
  const executionIds = runs.map((run) => run.executionId)
288
- const [executions, usages, costs] = await Promise.all([
973
+ const [executions, accounting] = await Promise.all([
289
974
  Promise.all(
290
975
  runs.map((run) =>
291
976
  runtime.storage.executions.getById({
@@ -294,16 +979,7 @@ async function attachRunViews(
294
979
  })
295
980
  )
296
981
  ),
297
- resolveExecutionUsage({
298
- storage: runtime.storage.aiUsage,
299
- projectId: runtime.projectId,
300
- executionIds,
301
- }),
302
- resolveExecutionCosts({
303
- storage: runtime.storage.aiCosts,
304
- projectId: runtime.projectId,
305
- executionIds,
306
- }),
982
+ resolveTurnAccounting(runtime, executionIds),
307
983
  ])
308
984
 
309
985
  return runs.map((run, index) => {
@@ -313,8 +989,7 @@ async function attachRunViews(
313
989
  `[Sixb] Agent run '${run.id}' references missing execution '${run.executionId}'.`
314
990
  )
315
991
  }
316
- const usage = usages[index]
317
- const cost = usage === undefined ? undefined : costs[index]
992
+ const { usage, cost } = accounting[index] ?? {}
318
993
  return {
319
994
  ...run,
320
995
  ...(execution.requestedBy === undefined
@@ -325,3 +1000,26 @@ async function attachRunViews(
325
1000
  }
326
1001
  })
327
1002
  }
1003
+
1004
+ /**
1005
+ * Why a resume was refused. An AI limit, or a failure Sixb did not expect, is tried again by the
1006
+ * worker's repair pass; a lost grant, a thread left or a sandbox to recreate is not.
1007
+ */
1008
+ function refusedResume(error: unknown): Extract<AgentApprovalResume, { status: "refused" }> {
1009
+ if (error instanceof AgentRequestError) {
1010
+ return { status: "refused", code: error.code, message: error.message, retrying: false }
1011
+ }
1012
+ if (error instanceof AuthorizationError) {
1013
+ return { status: "refused", code: "forbidden", message: error.message, retrying: false }
1014
+ }
1015
+ if (isSixbError(error)) {
1016
+ return { status: "refused", code: error.code, message: error.message, retrying: true }
1017
+ }
1018
+ console.error("[Sixb] Could not resume an Agent turn after its approvals; retrying later.", error)
1019
+ return {
1020
+ status: "refused",
1021
+ code: "internal.unexpected",
1022
+ message: "[Sixb] The Agent turn could not resume. Sixb tries again.",
1023
+ retrying: true,
1024
+ }
1025
+ }