@sixb/core 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (763) hide show
  1. package/dist/actions/index.js +41 -40
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/validation.d.ts.map +1 -1
  4. package/dist/agents/errors.d.ts +1 -1
  5. package/dist/agents/errors.d.ts.map +1 -1
  6. package/dist/agents/execution.d.ts +50 -3
  7. package/dist/agents/execution.d.ts.map +1 -1
  8. package/dist/agents/ids.d.ts +2 -0
  9. package/dist/agents/ids.d.ts.map +1 -1
  10. package/dist/agents/index.d.ts +7 -5
  11. package/dist/agents/index.d.ts.map +1 -1
  12. package/dist/agents/index.js +74 -50
  13. package/dist/agents/index.js.map +1 -1
  14. package/dist/agents/model-routing.d.ts +5 -2
  15. package/dist/agents/model-routing.d.ts.map +1 -1
  16. package/dist/agents/queued-turn.d.ts +16 -0
  17. package/dist/agents/queued-turn.d.ts.map +1 -0
  18. package/dist/agents/request.d.ts +120 -1
  19. package/dist/agents/request.d.ts.map +1 -1
  20. package/dist/agents/run-after-finish.d.ts +10 -0
  21. package/dist/agents/run-after-finish.d.ts.map +1 -1
  22. package/dist/agents/run-artifacts.d.ts +0 -38
  23. package/dist/agents/run-artifacts.d.ts.map +1 -1
  24. package/dist/agents/run-events.d.ts +10 -1
  25. package/dist/agents/run-events.d.ts.map +1 -1
  26. package/dist/agents/run-session-children.d.ts.map +1 -1
  27. package/dist/agents/run-session-http.d.ts.map +1 -1
  28. package/dist/agents/run-session-serve.d.ts.map +1 -1
  29. package/dist/agents/run-session.d.ts +14 -1
  30. package/dist/agents/run-session.d.ts.map +1 -1
  31. package/dist/agents/run-turn.d.ts +9 -1
  32. package/dist/agents/run-turn.d.ts.map +1 -1
  33. package/dist/agents/streams/index.d.ts +1 -1
  34. package/dist/agents/streams/index.d.ts.map +1 -1
  35. package/dist/agents/streams/index.js +1 -1
  36. package/dist/agents/streams/internal.d.ts +2 -1
  37. package/dist/agents/streams/internal.d.ts.map +1 -1
  38. package/dist/agents/streams/internal.js +22 -2
  39. package/dist/agents/streams/internal.js.map +1 -1
  40. package/dist/agents/streams/protocol.d.ts +53 -0
  41. package/dist/agents/streams/protocol.d.ts.map +1 -1
  42. package/dist/agents/streams/steps.d.ts +24 -0
  43. package/dist/agents/streams/steps.d.ts.map +1 -0
  44. package/dist/agents/thread-access.d.ts +44 -2
  45. package/dist/agents/thread-access.d.ts.map +1 -1
  46. package/dist/agents/turn-answered.d.ts +7 -0
  47. package/dist/agents/turn-answered.d.ts.map +1 -0
  48. package/dist/agents/validation.d.ts +1 -1
  49. package/dist/agents/validation.d.ts.map +1 -1
  50. package/dist/artifacts/canvas-display.d.ts +3 -5
  51. package/dist/artifacts/canvas-display.d.ts.map +1 -1
  52. package/dist/artifacts/comments.d.ts +14 -3
  53. package/dist/artifacts/comments.d.ts.map +1 -1
  54. package/dist/artifacts/document-fill.d.ts +18 -0
  55. package/dist/artifacts/document-fill.d.ts.map +1 -0
  56. package/dist/artifacts/errors.d.ts +1 -1
  57. package/dist/artifacts/errors.d.ts.map +1 -1
  58. package/dist/artifacts/events.d.ts +3 -2
  59. package/dist/artifacts/events.d.ts.map +1 -1
  60. package/dist/artifacts/execution.d.ts +40 -4
  61. package/dist/artifacts/execution.d.ts.map +1 -1
  62. package/dist/artifacts/frames/assets.d.ts +8 -1
  63. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  64. package/dist/artifacts/frames/document-data.d.ts +98 -0
  65. package/dist/artifacts/frames/document-data.d.ts.map +1 -0
  66. package/dist/artifacts/frames/entries.d.ts +12 -7
  67. package/dist/artifacts/frames/entries.d.ts.map +1 -1
  68. package/dist/artifacts/frames/index.d.ts +2 -1
  69. package/dist/artifacts/frames/index.d.ts.map +1 -1
  70. package/dist/artifacts/frames/index.js +22 -13
  71. package/dist/artifacts/frames/index.js.map +4 -4
  72. package/dist/artifacts/frames/kit.d.ts +15 -0
  73. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  74. package/dist/artifacts/frames/protocol.d.ts +12 -1
  75. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  76. package/dist/artifacts/frames/runtime.d.ts +24 -4
  77. package/dist/artifacts/frames/runtime.d.ts.map +1 -1
  78. package/dist/artifacts/index.d.ts +3 -1
  79. package/dist/artifacts/index.d.ts.map +1 -1
  80. package/dist/artifacts/index.js +9 -3
  81. package/dist/artifacts/index.js.map +3 -3
  82. package/dist/artifacts/live/blocks.d.ts +62 -0
  83. package/dist/artifacts/live/blocks.d.ts.map +1 -0
  84. package/dist/artifacts/live/board.d.ts +6 -0
  85. package/dist/artifacts/live/board.d.ts.map +1 -1
  86. package/dist/artifacts/live/document.d.ts +12 -0
  87. package/dist/artifacts/live/document.d.ts.map +1 -1
  88. package/dist/artifacts/live/index.d.ts +2 -0
  89. package/dist/artifacts/live/index.d.ts.map +1 -1
  90. package/dist/artifacts/live/index.js +148 -44
  91. package/dist/artifacts/live/index.js.map +3 -3
  92. package/dist/artifacts/live/page.d.ts +49 -0
  93. package/dist/artifacts/live/page.d.ts.map +1 -0
  94. package/dist/artifacts/live/protocol.d.ts +5 -0
  95. package/dist/artifacts/live/protocol.d.ts.map +1 -1
  96. package/dist/artifacts/live/server.d.ts +2 -2
  97. package/dist/artifacts/live/server.d.ts.map +1 -1
  98. package/dist/artifacts/live/server.js +29 -24
  99. package/dist/artifacts/live/server.js.map +1 -1
  100. package/dist/artifacts/live/state.d.ts +4 -1
  101. package/dist/artifacts/live/state.d.ts.map +1 -1
  102. package/dist/artifacts/outline.d.ts +16 -0
  103. package/dist/artifacts/outline.d.ts.map +1 -1
  104. package/dist/artifacts/paper.d.ts +22 -0
  105. package/dist/artifacts/paper.d.ts.map +1 -0
  106. package/dist/artifacts/pdf-job.d.ts +9 -0
  107. package/dist/artifacts/pdf-job.d.ts.map +1 -0
  108. package/dist/artifacts/publish/fields.d.ts +25 -0
  109. package/dist/artifacts/publish/fields.d.ts.map +1 -0
  110. package/dist/artifacts/publish/index.d.ts +2 -1
  111. package/dist/artifacts/publish/index.d.ts.map +1 -1
  112. package/dist/artifacts/publish/index.js +32 -23
  113. package/dist/artifacts/publish/index.js.map +1 -1
  114. package/dist/artifacts/publish/merge.d.ts +7 -6
  115. package/dist/artifacts/publish/merge.d.ts.map +1 -1
  116. package/dist/artifacts/publish/pdf.d.ts +28 -0
  117. package/dist/artifacts/publish/pdf.d.ts.map +1 -0
  118. package/dist/artifacts/publish/previews.d.ts +12 -20
  119. package/dist/artifacts/publish/previews.d.ts.map +1 -1
  120. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  121. package/dist/artifacts/publish/queries.d.ts +6 -1
  122. package/dist/artifacts/publish/queries.d.ts.map +1 -1
  123. package/dist/artifacts/publish/query-answers.d.ts +5 -2
  124. package/dist/artifacts/publish/query-answers.d.ts.map +1 -1
  125. package/dist/artifacts/publish/validate/document-html.d.ts +24 -0
  126. package/dist/artifacts/publish/validate/document-html.d.ts.map +1 -0
  127. package/dist/artifacts/publish/validate/document.d.ts +5 -3
  128. package/dist/artifacts/publish/validate/document.d.ts.map +1 -1
  129. package/dist/artifacts/queries.d.ts +16 -2
  130. package/dist/artifacts/queries.d.ts.map +1 -1
  131. package/dist/artifacts/run-query.d.ts.map +1 -1
  132. package/dist/auth/index.js +6 -6
  133. package/dist/authorization/event-visibility.d.ts.map +1 -1
  134. package/dist/authorization/index.js +2 -2
  135. package/dist/blob-storage/index.js +1 -1
  136. package/dist/bootstrap/index.js +50 -48
  137. package/dist/bootstrap/index.js.map +2 -2
  138. package/dist/calendar.d.ts +55 -0
  139. package/dist/calendar.d.ts.map +1 -0
  140. package/dist/calendar.js +19 -0
  141. package/dist/calendar.js.map +9 -0
  142. package/dist/{chunk-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
  143. package/dist/chunk-0pmpwn3g.js.map +10 -0
  144. package/dist/{chunk-0k3r5kb3.js → chunk-394zjzjs.js} +20 -10
  145. package/dist/{chunk-0k3r5kb3.js.map → chunk-394zjzjs.js.map} +5 -5
  146. package/dist/{chunk-stmxh0hv.js → chunk-3neam1y5.js} +2 -2
  147. package/dist/{chunk-zeykm8my.js → chunk-3qtk0070.js} +16 -42
  148. package/dist/chunk-3qtk0070.js.map +14 -0
  149. package/dist/{chunk-p8pgnq8d.js → chunk-425ydk65.js} +5 -5
  150. package/dist/{chunk-p351afzm.js → chunk-5sswe5ej.js} +2 -2
  151. package/dist/{chunk-a6fjkcne.js → chunk-60662fyv.js} +54 -28
  152. package/dist/{chunk-a6fjkcne.js.map → chunk-60662fyv.js.map} +7 -6
  153. package/dist/{chunk-e0hnbb1m.js → chunk-61zptves.js} +1 -1
  154. package/dist/chunk-6hfbz4d0.js +98 -0
  155. package/dist/chunk-6hfbz4d0.js.map +10 -0
  156. package/dist/{chunk-3zagkr6w.js → chunk-7mhbs9yy.js} +4 -4
  157. package/dist/{chunk-3zagkr6w.js.map → chunk-7mhbs9yy.js.map} +1 -1
  158. package/dist/{chunk-gxwy4c3s.js → chunk-7r9mqpva.js} +570 -104
  159. package/dist/chunk-7r9mqpva.js.map +47 -0
  160. package/dist/{chunk-3014rfjz.js → chunk-88xeh6zx.js} +28 -8
  161. package/dist/{chunk-3014rfjz.js.map → chunk-88xeh6zx.js.map} +4 -4
  162. package/dist/{chunk-9nsjjd44.js → chunk-8tv3qd65.js} +2 -1
  163. package/dist/chunk-8tv3qd65.js.map +12 -0
  164. package/dist/chunk-90nqenq8.js +386 -0
  165. package/dist/chunk-90nqenq8.js.map +14 -0
  166. package/dist/{chunk-fe6r7yhg.js → chunk-92wrka15.js} +1 -1
  167. package/dist/{chunk-w1wq7gfr.js → chunk-9c9yknwt.js} +464 -29
  168. package/dist/{chunk-w1wq7gfr.js.map → chunk-9c9yknwt.js.map} +7 -7
  169. package/dist/{chunk-q9nkpr8k.js → chunk-9tpmfh3n.js} +1 -1
  170. package/dist/chunk-9wr3yajk.js.map +2 -2
  171. package/dist/{chunk-rtm1jq00.js → chunk-ats8y3d9.js} +1202 -246
  172. package/dist/{chunk-rtm1jq00.js.map → chunk-ats8y3d9.js.map} +16 -14
  173. package/dist/{chunk-td26wjr5.js → chunk-bcz9dxtf.js} +17 -47
  174. package/dist/chunk-bcz9dxtf.js.map +12 -0
  175. package/dist/chunk-bqr703h4.js +1799 -0
  176. package/dist/chunk-bqr703h4.js.map +13 -0
  177. package/dist/{chunk-sysnvjce.js → chunk-brhp9d97.js} +2 -2
  178. package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
  179. package/dist/{chunk-rsxb14an.js → chunk-bs1sd0e0.js} +12 -8
  180. package/dist/chunk-bs1sd0e0.js.map +18 -0
  181. package/dist/{chunk-eptrvnby.js → chunk-c29729me.js} +42 -3
  182. package/dist/chunk-c29729me.js.map +12 -0
  183. package/dist/{chunk-855w9nvw.js → chunk-cg7cygfj.js} +1 -1
  184. package/dist/chunk-dq3t5sr3.js +114 -0
  185. package/dist/chunk-dq3t5sr3.js.map +11 -0
  186. package/dist/{chunk-t24yktqr.js → chunk-dvgc56n2.js} +20 -4
  187. package/dist/{chunk-t24yktqr.js.map → chunk-dvgc56n2.js.map} +5 -5
  188. package/dist/{chunk-r2psmn42.js → chunk-eg6xqef7.js} +1 -1
  189. package/dist/{chunk-7kpqntgw.js → chunk-f05994as.js} +1 -1
  190. package/dist/{chunk-msyevpp3.js → chunk-fmgf9h5e.js} +38 -14
  191. package/dist/chunk-fmgf9h5e.js.map +22 -0
  192. package/dist/{chunk-b9qfh2ya.js → chunk-fzbhybya.js} +29 -2
  193. package/dist/chunk-fzbhybya.js.map +11 -0
  194. package/dist/{chunk-t0s7b3d1.js → chunk-gaj8djsw.js} +251 -6
  195. package/dist/chunk-gaj8djsw.js.map +13 -0
  196. package/dist/{chunk-2bn6813a.js → chunk-grt2j5vp.js} +2 -2
  197. package/dist/{chunk-s7xqfxs9.js → chunk-hkbks1xm.js} +3 -1
  198. package/dist/{chunk-s7xqfxs9.js.map → chunk-hkbks1xm.js.map} +3 -3
  199. package/dist/chunk-hn2r7z41.js.map +1 -1
  200. package/dist/{chunk-rtdrm592.js → chunk-htdzx40w.js} +2 -2
  201. package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
  202. package/dist/{chunk-yy914zfr.js → chunk-jt012fxq.js} +772 -98
  203. package/dist/chunk-jt012fxq.js.map +34 -0
  204. package/dist/{chunk-48c1z8nj.js → chunk-kft7mp7z.js} +28 -3
  205. package/dist/chunk-kft7mp7z.js.map +10 -0
  206. package/dist/chunk-mbwsgjn7.js +40 -0
  207. package/dist/chunk-mbwsgjn7.js.map +11 -0
  208. package/dist/{chunk-wa05txmk.js → chunk-n1hbwc6y.js} +51 -8
  209. package/dist/chunk-n1hbwc6y.js.map +12 -0
  210. package/dist/{chunk-n4zzaf6q.js → chunk-nxysqbt0.js} +4 -2
  211. package/dist/chunk-nxysqbt0.js.map +10 -0
  212. package/dist/{chunk-6ef4esq4.js → chunk-pqj8vff9.js} +4 -4
  213. package/dist/chunk-pvpq483h.js.map +2 -2
  214. package/dist/{chunk-mzx71snp.js → chunk-q7g9cqwt.js} +7 -2
  215. package/dist/{chunk-mzx71snp.js.map → chunk-q7g9cqwt.js.map} +3 -3
  216. package/dist/{chunk-n68vz95m.js → chunk-qbd282aa.js} +2 -2
  217. package/dist/{chunk-e91fmg6t.js → chunk-qsa7nw6f.js} +2 -1
  218. package/dist/{chunk-e91fmg6t.js.map → chunk-qsa7nw6f.js.map} +3 -3
  219. package/dist/{chunk-rsrc7vtw.js → chunk-s8xxef60.js} +240 -46
  220. package/dist/chunk-s8xxef60.js.map +50 -0
  221. package/dist/{chunk-r9rtavg9.js → chunk-t19wjmnc.js} +7 -7
  222. package/dist/{chunk-vzkxqf8h.js → chunk-tapdssb5.js} +50 -6
  223. package/dist/chunk-tapdssb5.js.map +23 -0
  224. package/dist/{chunk-dhkc9b23.js → chunk-v8a1qjzp.js} +1 -1
  225. package/dist/{chunk-hvbvq7p4.js → chunk-vs2s3p8n.js} +731 -10
  226. package/dist/chunk-vs2s3p8n.js.map +20 -0
  227. package/dist/chunk-vtjzwymr.js.map +2 -2
  228. package/dist/{chunk-8t2ynwg0.js → chunk-wzcjhv54.js} +31 -1
  229. package/dist/{chunk-8t2ynwg0.js.map → chunk-wzcjhv54.js.map} +3 -3
  230. package/dist/{chunk-8tqnsx3q.js → chunk-xavet0qs.js} +5 -3
  231. package/dist/{chunk-8tqnsx3q.js.map → chunk-xavet0qs.js.map} +3 -3
  232. package/dist/{chunk-8bns0y68.js → chunk-xf76csps.js} +5 -5
  233. package/dist/{chunk-cwdzcv37.js → chunk-xrmbhap8.js} +2 -2
  234. package/dist/{chunk-cwdzcv37.js.map → chunk-xrmbhap8.js.map} +2 -2
  235. package/dist/{chunk-f6ahf5gf.js → chunk-xxfj0rr2.js} +20 -5
  236. package/dist/chunk-xxfj0rr2.js.map +13 -0
  237. package/dist/{chunk-3hzhcfsv.js → chunk-y8fwm3z2.js} +2 -2
  238. package/dist/{chunk-3hzhcfsv.js.map → chunk-y8fwm3z2.js.map} +3 -3
  239. package/dist/{chunk-smnt672s.js → chunk-ygvay56w.js} +20 -4
  240. package/dist/chunk-ygvay56w.js.map +10 -0
  241. package/dist/{chunk-evj5jxz3.js → chunk-ykchk644.js} +63 -15
  242. package/dist/{chunk-evj5jxz3.js.map → chunk-ykchk644.js.map} +7 -7
  243. package/dist/{chunk-vepea5c3.js → chunk-ym1bqd98.js} +6 -6
  244. package/dist/{chunk-yv8hv4wq.js → chunk-z4jqb44a.js} +3 -1
  245. package/dist/chunk-z4jqb44a.js.map +10 -0
  246. package/dist/connectors/connection-handles.d.ts +9 -0
  247. package/dist/connectors/connection-handles.d.ts.map +1 -0
  248. package/dist/connectors/connections/authorizations.d.ts +9 -0
  249. package/dist/connectors/connections/authorizations.d.ts.map +1 -1
  250. package/dist/connectors/connections/capability.d.ts +11 -0
  251. package/dist/connectors/connections/capability.d.ts.map +1 -1
  252. package/dist/connectors/connections/events.d.ts +17 -0
  253. package/dist/connectors/connections/events.d.ts.map +1 -0
  254. package/dist/connectors/connections/internal.d.ts +2 -1
  255. package/dist/connectors/connections/internal.d.ts.map +1 -1
  256. package/dist/connectors/connections/internal.js +8 -4
  257. package/dist/connectors/connections/internal.js.map +1 -1
  258. package/dist/connectors/connections/runs.d.ts +3 -0
  259. package/dist/connectors/connections/runs.d.ts.map +1 -1
  260. package/dist/connectors/connections/service.d.ts +13 -1
  261. package/dist/connectors/connections/service.d.ts.map +1 -1
  262. package/dist/connectors/execution.d.ts +14 -2
  263. package/dist/connectors/execution.d.ts.map +1 -1
  264. package/dist/connectors/index.d.ts +1 -1
  265. package/dist/connectors/index.d.ts.map +1 -1
  266. package/dist/connectors/service.d.ts +5 -1
  267. package/dist/connectors/service.d.ts.map +1 -1
  268. package/dist/connectors/types.d.ts +22 -1
  269. package/dist/connectors/types.d.ts.map +1 -1
  270. package/dist/datasets/write.js +1 -1
  271. package/dist/deploy/index.d.ts +1 -1
  272. package/dist/deploy/index.d.ts.map +1 -1
  273. package/dist/deploy/internal.js +3 -2
  274. package/dist/deploy/internal.js.map +3 -3
  275. package/dist/deploy/services.d.ts.map +1 -1
  276. package/dist/deploy/types.d.ts +22 -2
  277. package/dist/deploy/types.d.ts.map +1 -1
  278. package/dist/events/definitions.d.ts +4 -0
  279. package/dist/events/definitions.d.ts.map +1 -1
  280. package/dist/events/execution.d.ts +8 -1
  281. package/dist/events/execution.d.ts.map +1 -1
  282. package/dist/events/index.d.ts +2 -2
  283. package/dist/events/index.d.ts.map +1 -1
  284. package/dist/events/index.js +3 -3
  285. package/dist/events/outbox-dispatcher.d.ts +7 -0
  286. package/dist/events/outbox-dispatcher.d.ts.map +1 -1
  287. package/dist/events/scope.d.ts +1 -0
  288. package/dist/events/scope.d.ts.map +1 -1
  289. package/dist/events/scope.js +1 -1
  290. package/dist/events/selectors/builder.d.ts +9 -1
  291. package/dist/events/selectors/builder.d.ts.map +1 -1
  292. package/dist/events/selectors/index.d.ts +2 -2
  293. package/dist/events/selectors/index.d.ts.map +1 -1
  294. package/dist/events/selectors/index.js +2 -2
  295. package/dist/events/selectors/predicate.d.ts.map +1 -1
  296. package/dist/events/selectors/types.d.ts +18 -3
  297. package/dist/events/selectors/types.d.ts.map +1 -1
  298. package/dist/events/types/artifacts.d.ts +7 -1
  299. package/dist/events/types/artifacts.d.ts.map +1 -1
  300. package/dist/events/types/connectors.d.ts +32 -0
  301. package/dist/events/types/connectors.d.ts.map +1 -0
  302. package/dist/events/types/index.d.ts +3 -1
  303. package/dist/events/types/index.d.ts.map +1 -1
  304. package/dist/events/types/syncs.d.ts +4 -0
  305. package/dist/events/types/syncs.d.ts.map +1 -1
  306. package/dist/execution/agent.js +43 -42
  307. package/dist/execution/agent.js.map +1 -1
  308. package/dist/execution/authorization.d.ts +5 -0
  309. package/dist/execution/authorization.d.ts.map +1 -1
  310. package/dist/execution/authorized-object-reader.d.ts +4 -0
  311. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  312. package/dist/execution/object-reader-ontology.d.ts +3 -0
  313. package/dist/execution/object-reader-ontology.d.ts.map +1 -1
  314. package/dist/execution/primitive.js +41 -40
  315. package/dist/execution/primitive.js.map +1 -1
  316. package/dist/execution/request.d.ts +1 -1
  317. package/dist/execution/request.d.ts.map +1 -1
  318. package/dist/execution/request.js +39 -38
  319. package/dist/execution/request.js.map +3 -3
  320. package/dist/execution/scopes.d.ts +8 -0
  321. package/dist/execution/scopes.d.ts.map +1 -1
  322. package/dist/execution/script.d.ts +7 -0
  323. package/dist/execution/script.d.ts.map +1 -0
  324. package/dist/execution/types.d.ts +16 -1
  325. package/dist/execution/types.d.ts.map +1 -1
  326. package/dist/http/api-routes.d.ts.map +1 -1
  327. package/dist/http/index.js +1 -1
  328. package/dist/index.d.ts +13 -12
  329. package/dist/index.d.ts.map +1 -1
  330. package/dist/index.js +74 -70
  331. package/dist/index.js.map +1 -1
  332. package/dist/lake-storage/index.js +1 -1
  333. package/dist/lineage/executors.d.ts +1 -1
  334. package/dist/lineage/executors.d.ts.map +1 -1
  335. package/dist/maintenance/index.js +2 -2
  336. package/dist/materialization/event-envelopes.d.ts +3 -3
  337. package/dist/materialization/event-envelopes.d.ts.map +1 -1
  338. package/dist/materialization/events.d.ts +6 -0
  339. package/dist/materialization/events.d.ts.map +1 -1
  340. package/dist/materialization/index.js +1 -1
  341. package/dist/materialization/model.d.ts +6 -0
  342. package/dist/materialization/model.d.ts.map +1 -1
  343. package/dist/materializer/index.js +24 -23
  344. package/dist/materializer/index.js.map +1 -1
  345. package/dist/materializer/projections/replace.d.ts.map +1 -1
  346. package/dist/materializer/projections/replacement-plan.d.ts +2 -0
  347. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  348. package/dist/materializer/shared/normalize.d.ts +1 -0
  349. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  350. package/dist/models/audio/runtime.d.ts.map +1 -1
  351. package/dist/models/audio/types.d.ts +19 -0
  352. package/dist/models/audio/types.d.ts.map +1 -1
  353. package/dist/models/execution/index.js +22 -21
  354. package/dist/models/execution/index.js.map +1 -1
  355. package/dist/models/index.d.ts +1 -1
  356. package/dist/models/index.d.ts.map +1 -1
  357. package/dist/objects/index.js +41 -40
  358. package/dist/objects/index.js.map +1 -1
  359. package/dist/objects/query/executor.d.ts +3 -1
  360. package/dist/objects/query/executor.d.ts.map +1 -1
  361. package/dist/objects/query/explain.d.ts +3 -1
  362. package/dist/objects/query/explain.d.ts.map +1 -1
  363. package/dist/objects/query/index.d.ts +1 -1
  364. package/dist/objects/query/index.d.ts.map +1 -1
  365. package/dist/objects/query/index.js +21 -20
  366. package/dist/objects/query/index.js.map +1 -1
  367. package/dist/objects/query/link-query-clearance.d.ts +3 -0
  368. package/dist/objects/query/link-query-clearance.d.ts.map +1 -1
  369. package/dist/objects/query/links.d.ts +1 -1
  370. package/dist/objects/query/links.d.ts.map +1 -1
  371. package/dist/objects/query/validate.d.ts +17 -0
  372. package/dist/objects/query/validate.d.ts.map +1 -1
  373. package/dist/objects/sdk/runtime-query-executor.d.ts +1 -1
  374. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
  375. package/dist/ontology/index.js +3 -3
  376. package/dist/ontology/internal.js +3 -3
  377. package/dist/pipelines/index.js +27 -26
  378. package/dist/pipelines/index.js.map +1 -1
  379. package/dist/projections/builders.d.ts +7 -1
  380. package/dist/projections/builders.d.ts.map +1 -1
  381. package/dist/projections/index.d.ts +1 -1
  382. package/dist/projections/index.d.ts.map +1 -1
  383. package/dist/projections/internal.js +22 -21
  384. package/dist/projections/internal.js.map +1 -1
  385. package/dist/projections/types.d.ts +10 -0
  386. package/dist/projections/types.d.ts.map +1 -1
  387. package/dist/projections/validation.d.ts.map +1 -1
  388. package/dist/queues/in-memory.d.ts +3 -2
  389. package/dist/queues/in-memory.d.ts.map +1 -1
  390. package/dist/queues/index.d.ts +1 -1
  391. package/dist/queues/index.d.ts.map +1 -1
  392. package/dist/queues/index.js +1 -1
  393. package/dist/queues/types.d.ts +40 -13
  394. package/dist/queues/types.d.ts.map +1 -1
  395. package/dist/runtime/host.d.ts +13 -0
  396. package/dist/runtime/host.d.ts.map +1 -1
  397. package/dist/runtime/internal.d.ts +1 -0
  398. package/dist/runtime/internal.d.ts.map +1 -1
  399. package/dist/runtime/internal.js +47 -25
  400. package/dist/runtime/internal.js.map +4 -3
  401. package/dist/runtime/locale.d.ts +0 -2
  402. package/dist/runtime/locale.d.ts.map +1 -1
  403. package/dist/runtime/resolve-definitions.d.ts +1 -1
  404. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  405. package/dist/runtime/script.d.ts +39 -0
  406. package/dist/runtime/script.d.ts.map +1 -0
  407. package/dist/runtime/sixb.d.ts +2 -2
  408. package/dist/runtime/sixb.d.ts.map +1 -1
  409. package/dist/sandboxes/auth.d.ts +26 -4
  410. package/dist/sandboxes/auth.d.ts.map +1 -1
  411. package/dist/sandboxes/index.d.ts +3 -1
  412. package/dist/sandboxes/index.d.ts.map +1 -1
  413. package/dist/sandboxes/index.js +5 -5
  414. package/dist/schedules/builders.d.ts.map +1 -1
  415. package/dist/schedules/index.js +3 -3
  416. package/dist/schedules/runtime.d.ts.map +1 -1
  417. package/dist/schedules/validation.d.ts +2 -0
  418. package/dist/schedules/validation.d.ts.map +1 -1
  419. package/dist/security/view-conditions.d.ts.map +1 -1
  420. package/dist/shares/internal.js +19 -18
  421. package/dist/shares/internal.js.map +2 -2
  422. package/dist/storage/agents/errors.d.ts +1 -1
  423. package/dist/storage/agents/errors.d.ts.map +1 -1
  424. package/dist/storage/agents/in-memory.d.ts +43 -1
  425. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  426. package/dist/storage/agents/index.d.ts +2 -2
  427. package/dist/storage/agents/index.d.ts.map +1 -1
  428. package/dist/storage/agents/provider.d.ts +54 -11
  429. package/dist/storage/agents/provider.d.ts.map +1 -1
  430. package/dist/storage/agents/provider.js +41 -5
  431. package/dist/storage/agents/provider.js.map +1 -1
  432. package/dist/storage/agents/types.d.ts +291 -3
  433. package/dist/storage/agents/types.d.ts.map +1 -1
  434. package/dist/storage/ai-cost/analytics.d.ts +3 -2
  435. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  436. package/dist/storage/ai-cost/provider.js +4 -3
  437. package/dist/storage/ai-cost/provider.js.map +1 -1
  438. package/dist/storage/ai-cost/types.d.ts +5 -1
  439. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  440. package/dist/storage/artifacts/in-memory.d.ts +7 -1
  441. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  442. package/dist/storage/artifacts/index.d.ts +1 -1
  443. package/dist/storage/artifacts/index.d.ts.map +1 -1
  444. package/dist/storage/artifacts/record.d.ts +5 -2
  445. package/dist/storage/artifacts/record.d.ts.map +1 -1
  446. package/dist/storage/artifacts/types.d.ts +41 -0
  447. package/dist/storage/artifacts/types.d.ts.map +1 -1
  448. package/dist/storage/executions/provider.d.ts +3 -3
  449. package/dist/storage/executions/provider.d.ts.map +1 -1
  450. package/dist/storage/executions/provider.js +1 -1
  451. package/dist/storage/executions/types.d.ts +6 -0
  452. package/dist/storage/executions/types.d.ts.map +1 -1
  453. package/dist/storage/executions/validation.d.ts.map +1 -1
  454. package/dist/storage/file-upload-sessions/provider.js +7 -7
  455. package/dist/storage/index.d.ts +4 -4
  456. package/dist/storage/index.d.ts.map +1 -1
  457. package/dist/storage/index.js +30 -25
  458. package/dist/storage/index.js.map +1 -1
  459. package/dist/storage/internal.d.ts +1 -1
  460. package/dist/storage/internal.d.ts.map +1 -1
  461. package/dist/storage/internal.js +12 -10
  462. package/dist/storage/internal.js.map +2 -2
  463. package/dist/storage/ontology/in-memory/replacement-plans.d.ts +2 -0
  464. package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
  465. package/dist/storage/ontology/provider.js +1 -1
  466. package/dist/storage/ontology/replacement-plans.d.ts +8 -0
  467. package/dist/storage/ontology/replacement-plans.d.ts.map +1 -1
  468. package/dist/storage/operation-scope.d.ts.map +1 -1
  469. package/dist/storage/operation-scope.js +1 -1
  470. package/dist/storage/sync-runs/idempotency.d.ts.map +1 -1
  471. package/dist/storage/sync-runs/in-memory.d.ts +2 -1
  472. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
  473. package/dist/storage/sync-runs/index.d.ts +1 -1
  474. package/dist/storage/sync-runs/index.d.ts.map +1 -1
  475. package/dist/storage/sync-runs/types.d.ts +27 -2
  476. package/dist/storage/sync-runs/types.d.ts.map +1 -1
  477. package/dist/storage/workflow-runs/provider.js +7 -7
  478. package/dist/syncs/accounts.d.ts +36 -0
  479. package/dist/syncs/accounts.d.ts.map +1 -0
  480. package/dist/syncs/builders.d.ts.map +1 -1
  481. package/dist/syncs/connections.d.ts +36 -0
  482. package/dist/syncs/connections.d.ts.map +1 -0
  483. package/dist/syncs/execution.d.ts +14 -4
  484. package/dist/syncs/execution.d.ts.map +1 -1
  485. package/dist/syncs/index.d.ts +2 -1
  486. package/dist/syncs/index.d.ts.map +1 -1
  487. package/dist/syncs/index.js +28 -27
  488. package/dist/syncs/index.js.map +1 -1
  489. package/dist/syncs/request.d.ts +16 -2
  490. package/dist/syncs/request.d.ts.map +1 -1
  491. package/dist/syncs/run-dispatch.d.ts +14 -2
  492. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  493. package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -1
  494. package/dist/testing/agent-execution.d.ts +3 -0
  495. package/dist/testing/agent-execution.d.ts.map +1 -1
  496. package/dist/testing/agent-inbox-storage-contract.d.ts +15 -0
  497. package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -0
  498. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  499. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  500. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  501. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  502. package/dist/testing/index.d.ts +1 -0
  503. package/dist/testing/index.d.ts.map +1 -1
  504. package/dist/testing/index.js +6589 -4627
  505. package/dist/testing/index.js.map +13 -12
  506. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  507. package/dist/testing/queues-contract.d.ts.map +1 -1
  508. package/dist/testing/run-claim-storage-contract.d.ts.map +1 -1
  509. package/dist/webhooks/connections.d.ts +3 -4
  510. package/dist/webhooks/connections.d.ts.map +1 -1
  511. package/dist/webhooks/index.d.ts +1 -1
  512. package/dist/webhooks/index.d.ts.map +1 -1
  513. package/dist/webhooks/internal.js +22 -54
  514. package/dist/webhooks/internal.js.map +3 -3
  515. package/dist/webhooks/types.d.ts +2 -11
  516. package/dist/webhooks/types.d.ts.map +1 -1
  517. package/dist/workers/index.js +66 -13
  518. package/dist/workers/index.js.map +4 -4
  519. package/dist/workers/queue-worker.d.ts +5 -0
  520. package/dist/workers/queue-worker.d.ts.map +1 -1
  521. package/dist/workers/queued-run-dispatch.d.ts.map +1 -1
  522. package/dist/workers/worker.d.ts +8 -0
  523. package/dist/workers/worker.d.ts.map +1 -1
  524. package/dist/workflows/index.js +50 -48
  525. package/dist/workflows/index.js.map +1 -1
  526. package/package.json +12 -1
  527. package/src/actions/validation.ts +3 -1
  528. package/src/agents/README.md +6 -2
  529. package/src/agents/children.ts +6 -0
  530. package/src/agents/errors.ts +3 -0
  531. package/src/agents/execution.ts +331 -43
  532. package/src/agents/ids.ts +5 -0
  533. package/src/agents/index.ts +22 -4
  534. package/src/agents/model-routing.ts +25 -9
  535. package/src/agents/queued-turn.ts +46 -0
  536. package/src/agents/request.ts +1444 -210
  537. package/src/agents/run-after-finish.ts +259 -2
  538. package/src/agents/run-artifacts.ts +3 -93
  539. package/src/agents/run-events.ts +256 -34
  540. package/src/agents/run-session-children.ts +13 -2
  541. package/src/agents/run-session-http.ts +9 -2
  542. package/src/agents/run-session-serve.ts +2 -8
  543. package/src/agents/run-session.ts +142 -3
  544. package/src/agents/run-turn.ts +148 -23
  545. package/src/agents/streams/index.ts +3 -0
  546. package/src/agents/streams/internal.ts +12 -0
  547. package/src/agents/streams/protocol.ts +109 -1
  548. package/src/agents/streams/steps.ts +131 -0
  549. package/src/agents/thread-access.ts +57 -2
  550. package/src/agents/turn-answered.ts +31 -0
  551. package/src/agents/validation.ts +2 -0
  552. package/src/artifacts/canvas-display.ts +4 -6
  553. package/src/artifacts/comments.ts +70 -17
  554. package/src/artifacts/document-fill.ts +103 -0
  555. package/src/artifacts/errors.ts +2 -0
  556. package/src/artifacts/events.ts +4 -1
  557. package/src/artifacts/execution.ts +265 -31
  558. package/src/artifacts/frames/assets.ts +42 -7
  559. package/src/artifacts/frames/document-data.ts +353 -0
  560. package/src/artifacts/frames/entries.ts +22 -16
  561. package/src/artifacts/frames/grants.ts +2 -2
  562. package/src/artifacts/frames/index.ts +3 -0
  563. package/src/artifacts/frames/kit.ts +102 -0
  564. package/src/artifacts/frames/protocol.ts +12 -1
  565. package/src/artifacts/frames/runtime.ts +413 -6
  566. package/src/artifacts/index.ts +3 -0
  567. package/src/artifacts/live/blocks.ts +889 -0
  568. package/src/artifacts/live/board.ts +195 -42
  569. package/src/artifacts/live/document.ts +170 -5
  570. package/src/artifacts/live/index.ts +7 -0
  571. package/src/artifacts/live/page.ts +807 -0
  572. package/src/artifacts/live/protocol.ts +5 -0
  573. package/src/artifacts/live/server.ts +2 -2
  574. package/src/artifacts/live/state.ts +9 -4
  575. package/src/artifacts/outline.ts +17 -0
  576. package/src/artifacts/paper.ts +173 -0
  577. package/src/artifacts/pdf-job.ts +11 -0
  578. package/src/artifacts/publish/fields.ts +177 -0
  579. package/src/artifacts/publish/index.ts +6 -1
  580. package/src/artifacts/publish/merge.ts +28 -15
  581. package/src/artifacts/publish/pdf.ts +82 -0
  582. package/src/artifacts/publish/previews.ts +24 -34
  583. package/src/artifacts/publish/publish.ts +26 -3
  584. package/src/artifacts/publish/queries.ts +20 -4
  585. package/src/artifacts/publish/query-answers.ts +14 -3
  586. package/src/artifacts/publish/validate/document-html.ts +245 -0
  587. package/src/artifacts/publish/validate/document.ts +34 -3
  588. package/src/artifacts/queries.ts +59 -13
  589. package/src/artifacts/run-query.ts +5 -2
  590. package/src/authorization/event-visibility.ts +13 -0
  591. package/src/calendar.ts +195 -0
  592. package/src/connectors/connection-handles.ts +71 -0
  593. package/src/connectors/connections/authorizations.ts +50 -2
  594. package/src/connectors/connections/capability.ts +40 -0
  595. package/src/connectors/connections/events.ts +57 -0
  596. package/src/connectors/connections/internal.ts +3 -0
  597. package/src/connectors/connections/runs.ts +5 -0
  598. package/src/connectors/connections/service.ts +93 -6
  599. package/src/connectors/execution.ts +35 -8
  600. package/src/connectors/index.ts +3 -0
  601. package/src/connectors/service.ts +23 -0
  602. package/src/connectors/types.ts +29 -1
  603. package/src/deploy/index.ts +1 -0
  604. package/src/deploy/services.ts +1 -0
  605. package/src/deploy/types.ts +30 -2
  606. package/src/events/definitions.ts +14 -0
  607. package/src/events/execution.ts +51 -4
  608. package/src/events/index.ts +8 -0
  609. package/src/events/outbox-dispatcher.ts +12 -2
  610. package/src/events/scope.ts +3 -0
  611. package/src/events/selectors/builder.ts +49 -0
  612. package/src/events/selectors/index.ts +5 -0
  613. package/src/events/selectors/predicate.ts +2 -0
  614. package/src/events/selectors/types.ts +30 -1
  615. package/src/events/types/artifacts.ts +7 -1
  616. package/src/events/types/connectors.ts +36 -0
  617. package/src/events/types/index.ts +7 -0
  618. package/src/events/types/syncs.ts +4 -0
  619. package/src/execution/authorization.ts +45 -0
  620. package/src/execution/authorized-object-reader.ts +33 -5
  621. package/src/execution/durable.ts +2 -0
  622. package/src/execution/object-reader-ontology.ts +6 -0
  623. package/src/execution/request.ts +1 -0
  624. package/src/execution/scopes.ts +24 -0
  625. package/src/execution/script.ts +27 -0
  626. package/src/execution/types.ts +7 -1
  627. package/src/http/api-routes.ts +33 -0
  628. package/src/index.ts +39 -4
  629. package/src/lineage/executors.ts +3 -1
  630. package/src/materialization/event-envelopes.ts +10 -5
  631. package/src/materialization/events.ts +2 -0
  632. package/src/materialization/model.ts +6 -0
  633. package/src/materializer/README.md +10 -0
  634. package/src/materializer/projections/replace.ts +42 -1
  635. package/src/materializer/projections/replacement-plan.ts +44 -4
  636. package/src/materializer/shared/normalize.ts +4 -0
  637. package/src/models/audio/runtime.ts +57 -14
  638. package/src/models/audio/types.ts +20 -0
  639. package/src/models/index.ts +1 -0
  640. package/src/objects/query/executor.ts +4 -0
  641. package/src/objects/query/explain.ts +5 -0
  642. package/src/objects/query/index.ts +1 -0
  643. package/src/objects/query/link-query-clearance.ts +4 -1
  644. package/src/objects/query/links.ts +5 -1
  645. package/src/objects/query/validate.ts +33 -1
  646. package/src/objects/sdk/runtime-query-executor.ts +7 -3
  647. package/src/projections/builders.ts +20 -0
  648. package/src/projections/index.ts +1 -0
  649. package/src/projections/registry.ts +1 -0
  650. package/src/projections/revision.ts +2 -0
  651. package/src/projections/types.ts +11 -0
  652. package/src/projections/validation.ts +6 -0
  653. package/src/queues/in-memory.ts +5 -0
  654. package/src/queues/index.ts +3 -1
  655. package/src/queues/types.ts +45 -14
  656. package/src/runtime/host.ts +125 -11
  657. package/src/runtime/internal.ts +1 -0
  658. package/src/runtime/locale.ts +0 -10
  659. package/src/runtime/resolve-definitions.ts +4 -1
  660. package/src/runtime/script.ts +62 -0
  661. package/src/runtime/sixb.ts +15 -5
  662. package/src/sandboxes/README.md +3 -1
  663. package/src/sandboxes/auth.ts +32 -4
  664. package/src/sandboxes/index.ts +15 -1
  665. package/src/schedules/builders.ts +4 -1
  666. package/src/schedules/runtime.ts +3 -0
  667. package/src/schedules/validation.ts +20 -2
  668. package/src/security/view-conditions.ts +2 -1
  669. package/src/storage/agents/errors.ts +1 -0
  670. package/src/storage/agents/in-memory.ts +500 -7
  671. package/src/storage/agents/index.ts +26 -0
  672. package/src/storage/agents/provider.ts +454 -15
  673. package/src/storage/agents/types.ts +315 -3
  674. package/src/storage/ai-cost/analytics.ts +22 -43
  675. package/src/storage/ai-cost/types.ts +5 -1
  676. package/src/storage/artifacts/in-memory.ts +52 -6
  677. package/src/storage/artifacts/index.ts +2 -0
  678. package/src/storage/artifacts/record.ts +33 -4
  679. package/src/storage/artifacts/types.ts +44 -0
  680. package/src/storage/executions/provider.ts +22 -2
  681. package/src/storage/executions/types.ts +2 -0
  682. package/src/storage/executions/validation.ts +27 -0
  683. package/src/storage/index.ts +29 -0
  684. package/src/storage/internal.ts +1 -0
  685. package/src/storage/ontology/in-memory/replacement-plans.ts +22 -0
  686. package/src/storage/ontology/replacement-plans.ts +6 -0
  687. package/src/storage/operation-scope.ts +2 -0
  688. package/src/storage/sync-runs/idempotency.ts +1 -0
  689. package/src/storage/sync-runs/in-memory.ts +43 -1
  690. package/src/storage/sync-runs/index.ts +1 -0
  691. package/src/storage/sync-runs/types.ts +30 -1
  692. package/src/syncs/accounts.ts +85 -0
  693. package/src/syncs/builders.ts +18 -1
  694. package/src/syncs/connections.ts +123 -0
  695. package/src/syncs/execution.ts +64 -22
  696. package/src/syncs/index.ts +3 -0
  697. package/src/syncs/request.ts +81 -23
  698. package/src/syncs/run-dispatch.ts +69 -7
  699. package/src/testing/agent-approval-storage-contract.ts +123 -0
  700. package/src/testing/agent-execution.ts +45 -2
  701. package/src/testing/agent-inbox-storage-contract.ts +874 -0
  702. package/src/testing/agent-storage-contract.ts +965 -103
  703. package/src/testing/ai-cost-storage-contract.ts +80 -0
  704. package/src/testing/artifact-storage-contract.ts +201 -4
  705. package/src/testing/execution-storage-contract.ts +31 -0
  706. package/src/testing/index.ts +5 -0
  707. package/src/testing/materializer-storage-contract.ts +139 -1
  708. package/src/testing/queues-contract.ts +22 -0
  709. package/src/testing/run-claim-storage-contract.ts +116 -0
  710. package/src/webhooks/connections.ts +9 -50
  711. package/src/webhooks/index.ts +0 -2
  712. package/src/webhooks/types.ts +2 -13
  713. package/src/workers/README.md +4 -1
  714. package/src/workers/lost-runs.ts +1 -0
  715. package/src/workers/queue-worker.ts +16 -5
  716. package/src/workers/queued-run-dispatch.ts +8 -1
  717. package/src/workers/worker.ts +67 -7
  718. package/dist/chunk-3z1vxzcm.js +0 -234
  719. package/dist/chunk-3z1vxzcm.js.map +0 -12
  720. package/dist/chunk-48c1z8nj.js.map +0 -10
  721. package/dist/chunk-58geavnf.js +0 -29
  722. package/dist/chunk-58geavnf.js.map +0 -10
  723. package/dist/chunk-5a4a52tq.js.map +0 -10
  724. package/dist/chunk-9nsjjd44.js.map +0 -12
  725. package/dist/chunk-b9qfh2ya.js.map +0 -11
  726. package/dist/chunk-eptrvnby.js.map +0 -12
  727. package/dist/chunk-f6ahf5gf.js.map +0 -13
  728. package/dist/chunk-gxwy4c3s.js.map +0 -47
  729. package/dist/chunk-hvbvq7p4.js.map +0 -18
  730. package/dist/chunk-m2jerfef.js +0 -474
  731. package/dist/chunk-m2jerfef.js.map +0 -11
  732. package/dist/chunk-msyevpp3.js.map +0 -22
  733. package/dist/chunk-n4zzaf6q.js.map +0 -10
  734. package/dist/chunk-rsrc7vtw.js.map +0 -49
  735. package/dist/chunk-rsxb14an.js.map +0 -18
  736. package/dist/chunk-smnt672s.js.map +0 -10
  737. package/dist/chunk-t0s7b3d1.js.map +0 -13
  738. package/dist/chunk-td26wjr5.js.map +0 -13
  739. package/dist/chunk-vzkxqf8h.js.map +0 -23
  740. package/dist/chunk-wa05txmk.js.map +0 -11
  741. package/dist/chunk-yv8hv4wq.js.map +0 -10
  742. package/dist/chunk-yy914zfr.js.map +0 -30
  743. package/dist/chunk-zeykm8my.js.map +0 -14
  744. /package/dist/{chunk-stmxh0hv.js.map → chunk-3neam1y5.js.map} +0 -0
  745. /package/dist/{chunk-p8pgnq8d.js.map → chunk-425ydk65.js.map} +0 -0
  746. /package/dist/{chunk-p351afzm.js.map → chunk-5sswe5ej.js.map} +0 -0
  747. /package/dist/{chunk-e0hnbb1m.js.map → chunk-61zptves.js.map} +0 -0
  748. /package/dist/{chunk-fe6r7yhg.js.map → chunk-92wrka15.js.map} +0 -0
  749. /package/dist/{chunk-q9nkpr8k.js.map → chunk-9tpmfh3n.js.map} +0 -0
  750. /package/dist/{chunk-sysnvjce.js.map → chunk-brhp9d97.js.map} +0 -0
  751. /package/dist/{chunk-8a8k38tz.js.map → chunk-brybqw5k.js.map} +0 -0
  752. /package/dist/{chunk-855w9nvw.js.map → chunk-cg7cygfj.js.map} +0 -0
  753. /package/dist/{chunk-r2psmn42.js.map → chunk-eg6xqef7.js.map} +0 -0
  754. /package/dist/{chunk-7kpqntgw.js.map → chunk-f05994as.js.map} +0 -0
  755. /package/dist/{chunk-2bn6813a.js.map → chunk-grt2j5vp.js.map} +0 -0
  756. /package/dist/{chunk-rtdrm592.js.map → chunk-htdzx40w.js.map} +0 -0
  757. /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
  758. /package/dist/{chunk-6ef4esq4.js.map → chunk-pqj8vff9.js.map} +0 -0
  759. /package/dist/{chunk-n68vz95m.js.map → chunk-qbd282aa.js.map} +0 -0
  760. /package/dist/{chunk-r9rtavg9.js.map → chunk-t19wjmnc.js.map} +0 -0
  761. /package/dist/{chunk-dhkc9b23.js.map → chunk-v8a1qjzp.js.map} +0 -0
  762. /package/dist/{chunk-8bns0y68.js.map → chunk-xf76csps.js.map} +0 -0
  763. /package/dist/{chunk-vepea5c3.js.map → chunk-ym1bqd98.js.map} +0 -0
@@ -1,22 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/assert-never.ts", "../src/objects/clearance-redaction.ts", "../src/objects/query/clearance-admission.ts", "../src/objects/query/link-query-clearance.ts", "../src/objects/telemetry/workload.ts", "../src/objects/authorized-ontology-view.ts", "../src/execution/object-reader-ontology.ts", "../src/objects/query/selected-read-admission.ts", "../src/execution/object-reader-clearance.ts", "../src/execution/object-reader-security.ts", "../src/execution/object-reader-users.ts", "../src/execution/unique-lookup.ts", "../src/execution/authorized-object-reader.ts"],
4
- "sourcesContent": [
5
- "/**\n * Closes a switch over a union: the call stops compiling when a new member has no case, and throws\n * if an untyped value reaches it at runtime.\n */\nexport function assertNever(_value: never, message: string): never {\n throw new Error(message)\n}\n",
6
- "import type { StoredDomainEvent } from \"../events/types\"\nimport type { ExpandedLinkValue, ExpandedObjectRow, ObjectRow } from \"../storage\"\nimport type { PropertyClearance } from \"./property-clearance\"\n\n/**\n * Omit unreadable properties from a row and the objects expanded under it, and list them in\n * `redactions`. The row is not modified: what changes is copied, the rest is shared.\n */\nexport function redactObjectRow<TRow extends ObjectRow>(\n row: TRow,\n clearance: PropertyClearance\n): TRow {\n return redactRow(row, clearance, true)\n}\n\n/**\n * {@link redactObjectRow} without the `redactions` records, for rows about to be deep-copied.\n *\n * Omitting hidden values before the copy keeps them out of it and copies each row once. The copy\n * then receives its records from {@link attachRedactions}: they are frozen and owned by the\n * clearance, so they are shared rather than copied with each row.\n */\nexport function omitHiddenProperties<TRow extends ObjectRow>(\n row: TRow,\n clearance: PropertyClearance\n): TRow {\n return redactRow(row, clearance, false)\n}\n\n/**\n * Set `redactions` on a row returned by {@link omitHiddenProperties} and since deep-copied, and on\n * the objects expanded under it. It modifies the row, so it only accepts the caller's own copy.\n */\nexport function attachRedactions(row: ObjectRow, clearance: PropertyClearance): void {\n const hidden = clearance.hiddenProperties(row.objectTypeId)\n if (hidden !== undefined) row.redactions = hidden.redactions\n\n if (row.links === undefined) return\n\n for (const value of Object.values(row.links)) {\n if (value === null) continue\n if (Array.isArray(value)) {\n for (const linked of value) attachRedactions(linked, clearance)\n } else {\n attachRedactions(value as ExpandedObjectRow, clearance)\n }\n }\n}\n\nfunction redactRow<TRow extends ObjectRow>(\n row: TRow,\n clearance: PropertyClearance,\n withRedactions: boolean\n): TRow {\n const hidden = clearance.hiddenProperties(row.objectTypeId)\n const links = row.links\n if (hidden === undefined && links === undefined) return row\n\n const redacted: TRow = { ...row }\n if (hidden !== undefined) {\n redacted.properties = withoutKeys(row.properties, hidden.ids)\n if (withRedactions) redacted.redactions = hidden.redactions\n }\n\n if (links !== undefined) {\n redacted.links = Object.fromEntries(\n Object.entries(links).map(([linkId, value]) => [\n linkId,\n redactLinkValue(value, clearance, withRedactions),\n ])\n )\n }\n return redacted\n}\n\nfunction redactLinkValue(\n value: ExpandedLinkValue,\n clearance: PropertyClearance,\n withRedactions: boolean\n): ExpandedLinkValue {\n if (value === null) return null\n if (Array.isArray(value)) {\n return value.map((row) => redactRow(row, clearance, withRedactions))\n }\n\n // Array.isArray does not narrow a readonly[] away, so assert the single-object case.\n return redactRow(value as ExpandedObjectRow, clearance, withRedactions)\n}\n\n/**\n * Omit unreadable properties from an object event, under the same contract as rows. Other events\n * carry no markable value: link properties and telemetry properties cannot be marked.\n */\nexport function redactDomainEvent(\n event: StoredDomainEvent,\n clearance: PropertyClearance\n): StoredDomainEvent {\n if (event.topic !== \"objects\") return event\n\n const hidden = clearance.hiddenProperties(event.payload.objectTypeId)\n if (hidden === undefined) return event\n\n if (event.type === \"object.deleted\") {\n return {\n ...event,\n payload: {\n ...event.payload,\n propertyChanges: withoutKeys(event.payload.propertyChanges, hidden.ids),\n redactions: hidden.redactions,\n },\n }\n }\n\n return {\n ...event,\n payload: {\n ...event.payload,\n properties: withoutKeys(event.payload.properties, hidden.ids),\n propertyChanges: withoutKeys(event.payload.propertyChanges, hidden.ids),\n redactions: hidden.redactions,\n },\n }\n}\n\n/**\n * A copy of the record's own properties without the hidden keys.\n *\n * Spreading the record and deleting the few hidden keys is several times faster than assigning\n * each kept key, and the spread defines every key as an own property, even `__proto__`.\n */\nfunction withoutKeys<TValue>(\n record: Readonly<Record<string, TValue>>,\n hidden: ReadonlySet<string>\n): Record<string, TValue> {\n const kept: Record<string, TValue> = { ...record }\n for (const key of hidden) delete kept[key]\n return kept\n}\n",
7
- "import { AuthorizationError } from \"../../authorization/errors\"\nimport { type PropertyClearance, type Unreadable, unreadableError } from \"../property-clearance\"\nimport type {\n ObjectQueryAdmissionState,\n ObjectQueryPropertyUse,\n ObjectQuerySemanticAdmission,\n} from \"./validate\"\n\n/**\n * Reject every query use of a property the reader cannot read, except projection.\n *\n * Filtering, ordering, searching, or faceting by a hidden value would reveal it through which\n * objects match and in what order. Projection only shapes the output, which is redacted anyway.\n */\nexport function createClearanceQueryAdmission(\n clearance: PropertyClearance\n): ObjectQuerySemanticAdmission {\n // Each state stands for the object types a query has reached so far. A property without an\n // explicit type is checked against all of them.\n const reachedTypes = new WeakMap<ObjectQueryAdmissionState, readonly string[]>()\n const state = (objectTypeIds: readonly string[]): ObjectQueryAdmissionState => {\n const created = Object.freeze({})\n reachedTypes.set(created, Object.freeze([...objectTypeIds]))\n return created\n }\n\n const reached = (input: ObjectQueryAdmissionState): readonly string[] => {\n const objectTypeIds = reachedTypes.get(input)\n if (!objectTypeIds) {\n throw new Error(\"[Sixb] Clearance query admission received a state it did not create.\")\n }\n return objectTypeIds\n }\n\n const empty = state([])\n\n const admission: ObjectQuerySemanticAdmission = {\n empty: () => empty,\n // An object type or link the reader cannot read is denied like one it has no view grant for.\n source: (input) => ({\n state: state(input.result.objectTypeIds),\n ...denied(unreadableTypeAmong(clearance, input.result.objectTypeIds)),\n }),\n edge: (input) => {\n // A link is keyed by its source type: the reached types going out, the result coming in.\n const sourceTypeIds =\n input.direction === \"outgoing\"\n ? reached(input.state)\n : [\n ...input.result.objectTypeIds,\n ...(input.sourceObjectTypeId ? [input.sourceObjectTypeId] : []),\n ]\n\n const link = sourceTypeIds\n .map((objectTypeId) => clearance.unreadableLink(objectTypeId, input.linkId))\n .find((unreadable) => unreadable !== undefined)\n\n return {\n state: state(input.result.objectTypeIds),\n ...denied(link ?? unreadableTypeAmong(clearance, input.result.objectTypeIds)),\n }\n },\n // A difference only returns objects of its first input.\n set: (input) =>\n input.op === \"subtract\"\n ? (input.states[0] ?? empty)\n : state([...new Set(input.states.flatMap(reached))]),\n property: (input) => {\n if (input.use === \"project\") return undefined\n\n const objectTypeIds =\n input.objectTypeId === undefined ? reached(input.state) : [input.objectTypeId]\n for (const objectTypeId of objectTypeIds) {\n const marking = clearance.missingMarking(objectTypeId, input.propertyId)\n if (marking === undefined) continue\n return new AuthorizationError(\n `clearance:marking:${marking}`,\n `[Sixb] Cannot ${PROPERTY_USE_VERBS[input.use]} '${objectTypeId}.${input.propertyId}' at '${input.path}': it requires clearance for marking '${marking}'.`\n )\n }\n\n return undefined\n },\n }\n\n return Object.freeze(admission)\n}\n\nfunction unreadableTypeAmong(\n clearance: PropertyClearance,\n objectTypeIds: readonly string[]\n): Unreadable | undefined {\n for (const objectTypeId of objectTypeIds) {\n const unreadable = clearance.unreadableType(objectTypeId)\n if (unreadable) return unreadable\n }\n return undefined\n}\n\nfunction denied(unreadable: Unreadable | undefined): { readonly denial?: Error } {\n return unreadable ? { denial: unreadableError(unreadable) } : {}\n}\n\nconst PROPERTY_USE_VERBS: Readonly<Record<ObjectQueryPropertyUse, string>> = {\n filter: \"filter by\",\n text: \"search\",\n vector: \"run a vector search over\",\n sort: \"sort by\",\n project: \"project\",\n \"expand.orderBy\": \"order expanded objects by\",\n facet: \"facet by\",\n}\n",
8
- "import type { OntologyRegistry } from \"../../ontology\"\nimport { type PropertyClearance, unreadableError } from \"../property-clearance\"\nimport type { ObjectQuery } from \"./ir\"\nimport { type ExecuteObjectQueryLinksInput, preflightObjectQueryLinks } from \"./links\"\n\n/**\n * Refuse a link query that could return a link, or an endpoint, the reader cannot read.\n *\n * A link query returns every link incident to the objects it selects, a page at a time. The page\n * cannot be filtered afterward without breaking its cursor, so what the reader cannot read is\n * refused before the page is read, from the definitions: a link that is unreadable, or that leads\n * to an unreadable object type, whether or not such a link exists.\n */\nexport function assertLinkQueryReadable(input: {\n readonly ontology: OntologyRegistry\n readonly clearance: PropertyClearance\n readonly query: ObjectQuery\n readonly request: Omit<ExecuteObjectQueryLinksInput, \"query\">\n /** Whether grants alone let the reader view the type: storage already leaves out the others. */\n readonly viewableByGrants: (objectTypeId: string) => boolean\n}): void {\n const { ontology, clearance } = input\n const { types, links } = clearance.unreadable()\n if (types.size === 0 && links.length === 0) return\n\n const preflight = preflightObjectQueryLinks(\n { ...input.request, query: input.query },\n { ontology }\n )\n\n const selected = preflight.validated.result.objectTypeIds\n const outgoing = preflight.direction !== \"incoming\"\n const incoming = preflight.direction !== \"outgoing\"\n\n const named = (linkId: string) => preflight.linkId === undefined || preflight.linkId === linkId\n const targets = (expected: string | readonly string[], objectTypeId: string) =>\n (typeof expected === \"string\" ? [expected] : expected).some((target) =>\n ontology.isValidLinkTarget(target, objectTypeId)\n )\n\n for (const link of links) {\n if (!named(link.linkId)) continue\n if (\n (outgoing && selected.includes(link.objectTypeId)) ||\n (incoming && selected.some((id) => targets(link.targetObjectTypeId, id)))\n ) {\n throw unreadableError(link)\n }\n }\n\n const sealed = [...types].filter(([id]) => input.viewableByGrants(id))\n if (sealed.length === 0) return\n\n for (const objectType of ontology.listObjectTypes()) {\n for (const link of objectType.links) {\n if (!named(link.id)) continue\n if (outgoing && selected.includes(objectType.id)) {\n const other = sealed.find(([id]) => targets(link.targetObjectTypeId, id))\n if (other) throw unreadableError(other[1])\n }\n\n const source = types.get(objectType.id)\n if (\n incoming &&\n source &&\n input.viewableByGrants(objectType.id) &&\n selected.some((id) => targets(link.targetObjectTypeId, id))\n ) {\n throw unreadableError(source)\n }\n }\n }\n}\n",
9
- "const MAX_DELEGATED_TELEMETRY_HISTORY_SERIES = 100\nconst MAX_DELEGATED_TELEMETRY_HISTORY_POINTS = 10_000\nconst DEFAULT_DELEGATED_TELEMETRY_HISTORY_LIMIT_PER_SERIES = 100\n\nexport interface TelemetryHistoryReadWorkloadInput {\n readonly seriesCount: number\n readonly limitPerSeries?: number\n}\n\nexport interface TelemetryHistoryReadAdmission {\n readonly limitPerSeries?: number\n readonly maxPointOccurrences?: number\n}\n\ntype TelemetryHistoryWorkloadMetric = \"series\" | \"points\"\n\nclass TelemetryHistoryWorkloadExceededError extends Error {\n readonly name = \"TelemetryHistoryWorkloadExceededError\"\n readonly code = \"telemetry_history_workload_exceeded\"\n\n constructor(\n readonly metric: TelemetryHistoryWorkloadMetric,\n readonly limit: number\n ) {\n super(`[Sixb] Delegated telemetry history exceeded its ${metric} limit (${limit}).`)\n }\n}\n\n/** Resolve one history request without exposing the authority that selected its policy. */\nexport function admitTelemetryHistoryReadWorkload(\n input: TelemetryHistoryReadWorkloadInput,\n delegated: boolean\n): TelemetryHistoryReadAdmission {\n const seriesCount = input.seriesCount\n const limitPerSeries = input.limitPerSeries\n if (!Number.isSafeInteger(seriesCount) || seriesCount < 0) {\n throw new Error(\"[Sixb] Telemetry history series must have a non-negative safe integer length.\")\n }\n if (\n limitPerSeries !== undefined &&\n (!Number.isSafeInteger(limitPerSeries) || limitPerSeries < 0)\n ) {\n throw new Error(\"[Sixb] Telemetry history limit must be a non-negative safe integer.\")\n }\n\n if (!delegated) {\n const admission: TelemetryHistoryReadAdmission =\n limitPerSeries === undefined ? {} : { limitPerSeries }\n return Object.freeze(admission)\n }\n if (seriesCount > MAX_DELEGATED_TELEMETRY_HISTORY_SERIES) {\n throw new TelemetryHistoryWorkloadExceededError(\n \"series\",\n MAX_DELEGATED_TELEMETRY_HISTORY_SERIES\n )\n }\n if (seriesCount === 0) {\n return Object.freeze({\n ...(limitPerSeries === undefined ? {} : { limitPerSeries }),\n maxPointOccurrences: MAX_DELEGATED_TELEMETRY_HISTORY_POINTS,\n })\n }\n\n const maxLimitPerSeries = Math.floor(MAX_DELEGATED_TELEMETRY_HISTORY_POINTS / seriesCount)\n const effectiveLimitPerSeries =\n limitPerSeries ??\n Math.min(DEFAULT_DELEGATED_TELEMETRY_HISTORY_LIMIT_PER_SERIES, maxLimitPerSeries)\n if (effectiveLimitPerSeries > maxLimitPerSeries) {\n throw new TelemetryHistoryWorkloadExceededError(\n \"points\",\n MAX_DELEGATED_TELEMETRY_HISTORY_POINTS\n )\n }\n\n return Object.freeze({\n limitPerSeries: effectiveLimitPerSeries,\n maxPointOccurrences: MAX_DELEGATED_TELEMETRY_HISTORY_POINTS,\n })\n}\n",
10
- "import {\n formatUnknownObjectTypeMessage,\n OntologyNotFoundError,\n OntologyValidationError,\n} from \"../ontology/errors\"\nimport type { OntologyDefinitionCatalog } from \"../ontology/registry\"\nimport type { ObjectTypeWithPropertyTokens } from \"../ontology/tokens\"\nimport { createLinkTokenMap, createPropertyTokenMap } from \"../ontology/tokens\"\nimport type {\n ObjectLink,\n ObjectType,\n ObjectTypeSearchMetadata,\n Property,\n PropertyQueryMetadata,\n Schema,\n ValueType,\n} from \"../ontology/types\"\nimport { snapshotVectorProfiles } from \"../ontology/vector-profiles\"\nimport type { CompiledSelectedObjectReadScope } from \"../storage/objects/types\"\n\n/** Public ontology operations that may cross an execution-bound authorization boundary. */\nexport type AuthorizedOntologyView = Pick<\n OntologyDefinitionCatalog,\n | \"listObjectTypes\"\n | \"getObjectTypeById\"\n | \"resolveObjectType\"\n | \"getValueTypesById\"\n | \"getPrimaryPropertyId\"\n | \"listSubTypes\"\n | \"isValidLinkTarget\"\n>\n\nexport type AuthorizedOntologySelection =\n | { readonly kind: \"all\" }\n | { readonly kind: \"types\"; readonly objectTypeIds: readonly string[] }\n | { readonly kind: \"selected\"; readonly scope: CompiledSelectedObjectReadScope }\n\ninterface LinkSelection {\n readonly targetObjectTypeIds: Set<string>\n readonly propertyIds: Set<string>\n}\n\ninterface SelectedSchema {\n readonly propertyIdsByObjectType: ReadonlyMap<string, ReadonlySet<string>>\n readonly linksBySourceType: ReadonlyMap<string, ReadonlyMap<string, LinkSelection>>\n}\n\n/**\n * Project inert ontology metadata from one already-captured authority.\n *\n * Query validation intentionally keeps using the complete internal registry. This view is only\n * the discovery surface returned to application code and HTTP serializers.\n */\nexport function createAuthorizedOntologyView(input: {\n readonly ontology: OntologyDefinitionCatalog\n readonly selection: AuthorizedOntologySelection\n readonly assertOutputWithinLimit?: (value: unknown) => void\n}): AuthorizedOntologyView {\n const allObjectTypes = input.ontology.listObjectTypes()\n const registeredObjectTypeIds = new Set(allObjectTypes.map((objectType) => objectType.id))\n const requestedObjectTypeIds = selectedObjectTypeIds(input.selection, allObjectTypes)\n const visibleObjectTypeIds = new Set(\n [...requestedObjectTypeIds].filter((objectTypeId) => registeredObjectTypeIds.has(objectTypeId))\n )\n const selectedSchema =\n input.selection.kind === \"selected\" ? collectSelectedSchema(input.selection.scope) : undefined\n const projectedObjectTypes: ObjectTypeWithPropertyTokens[] = []\n\n for (const objectType of allObjectTypes) {\n if (!visibleObjectTypeIds.has(objectType.id)) continue\n const propertyIds =\n selectedSchema?.propertyIdsByObjectType.get(objectType.id) ??\n new Set(objectType.properties.map((property) => property.id))\n const links = selectedSchema\n ? (selectedSchema.linksBySourceType.get(objectType.id) ?? new Map())\n : input.selection.kind === \"all\"\n ? allDeclaredLinks(objectType)\n : allVisibleLinks(input.ontology, objectType, visibleObjectTypeIds)\n projectedObjectTypes.push(\n projectObjectType({\n objectType,\n propertyIds,\n links,\n visibleObjectTypeIds,\n ontology: input.ontology,\n targetMode:\n input.selection.kind === \"all\"\n ? \"original\"\n : input.selection.kind === \"types\"\n ? \"principal\"\n : \"exact\",\n exposeContracts: input.selection.kind !== \"selected\",\n })\n )\n }\n\n const objectTypes = projectedObjectTypes\n const objectTypesById = new Map(objectTypes.map((objectType) => [objectType.id, objectType]))\n const valueTypesById =\n input.selection.kind === \"selected\"\n ? collectVisibleValueTypes(input.ontology.getValueTypesById(), objectTypes)\n : snapshotAllValueTypes(input.ontology.getValueTypesById())\n const release = <T>(value: T, budgetValue: unknown = value): T => {\n input.assertOutputWithinLimit?.(budgetValue)\n return value\n }\n const cloneObjectType = (objectType: ObjectTypeWithPropertyTokens) => structuredClone(objectType)\n const cloneValueTypes = () =>\n new Map(\n [...valueTypesById].map(([valueTypeId, valueType]) => [\n valueTypeId,\n structuredClone(valueType),\n ])\n )\n\n return Object.freeze({\n listObjectTypes: () => release(objectTypes.map(cloneObjectType)),\n getObjectTypeById: (objectTypeId: string) => {\n const objectType = objectTypesById.get(objectTypeId)\n return release(objectType ? cloneObjectType(objectType) : null)\n },\n resolveObjectType: (objectTypeId: string) => {\n const objectType = objectTypesById.get(objectTypeId)\n return objectType ? release(cloneObjectType(objectType)) : unknownObjectType(objectTypeId)\n },\n getValueTypesById: () => {\n const valueTypes = cloneValueTypes()\n return release(valueTypes, [...valueTypes.entries()])\n },\n getPrimaryPropertyId: (objectTypeId: string) => {\n const objectType = objectTypesById.get(objectTypeId)\n if (!objectType) return unknownObjectType(objectTypeId)\n const primary = objectType.properties.find((property) => property.primary)\n if (!primary) {\n throw new OntologyValidationError(\n `[Sixb] Object type '${objectTypeId}' does not expose its primary property in this execution scope.`\n )\n }\n return release(primary.id)\n },\n listSubTypes: (objectTypeId: string) => {\n const subTypes = visibleObjectTypeIds.has(objectTypeId)\n ? input.ontology\n .listSubTypes(objectTypeId)\n .filter((subTypeId) => visibleObjectTypeIds.has(subTypeId))\n : []\n return release(subTypes)\n },\n isValidLinkTarget: (expected: string | string[], actual: string) => {\n if (input.selection.kind === \"all\") {\n return release(input.ontology.isValidLinkTarget(expected, actual))\n }\n if (!visibleObjectTypeIds.has(actual)) return release(false)\n const expectedTypes = Array.isArray(expected) ? expected : [expected]\n if (input.selection.kind === \"selected\") {\n return release(\n expectedTypes.some((expectedType) => expectedType === \"*\" || expectedType === actual)\n )\n }\n return release(\n expectedTypes.some(\n (expectedType) =>\n expectedType === \"*\" ||\n (visibleObjectTypeIds.has(expectedType) &&\n input.ontology.isValidLinkTarget(expectedType, actual))\n )\n )\n },\n })\n}\n\nfunction selectedObjectTypeIds(\n selection: AuthorizedOntologySelection,\n allObjectTypes: readonly ObjectTypeWithPropertyTokens[]\n): ReadonlySet<string> {\n switch (selection.kind) {\n case \"all\":\n return new Set(allObjectTypes.map((objectType) => objectType.id))\n case \"types\":\n return new Set(selection.objectTypeIds)\n case \"selected\":\n return new Set(selection.scope.objects.map((object) => object.objectTypeId))\n }\n}\n\nfunction collectSelectedSchema(scope: CompiledSelectedObjectReadScope): SelectedSchema {\n const propertyIdsByObjectType = new Map<string, Set<string>>()\n for (const object of scope.objects) {\n const properties = propertyIdsByObjectType.get(object.objectTypeId) ?? new Set<string>()\n for (const propertyId of object.propertyIds) properties.add(propertyId)\n propertyIdsByObjectType.set(object.objectTypeId, properties)\n }\n\n const linksBySourceType = new Map<string, Map<string, LinkSelection>>()\n for (const step of scope.steps) {\n const links = linksBySourceType.get(step.sourceObjectTypeId) ?? new Map()\n const selected = links.get(step.linkId) ?? {\n targetObjectTypeIds: new Set<string>(),\n propertyIds: new Set<string>(),\n }\n selected.targetObjectTypeIds.add(step.targetObjectTypeId)\n for (const propertyId of step.propertyIds) selected.propertyIds.add(propertyId)\n links.set(step.linkId, selected)\n linksBySourceType.set(step.sourceObjectTypeId, links)\n }\n\n return { propertyIdsByObjectType, linksBySourceType }\n}\n\nfunction allDeclaredLinks(\n objectType: ObjectTypeWithPropertyTokens\n): ReadonlyMap<string, LinkSelection> {\n return new Map(\n objectType.links.map((link) => [\n link.id,\n {\n targetObjectTypeIds: new Set(\n typeof link.targetObjectTypeId === \"string\"\n ? [link.targetObjectTypeId]\n : link.targetObjectTypeId\n ),\n propertyIds: new Set(link.properties?.map((property) => property.id) ?? []),\n },\n ])\n )\n}\n\nfunction allVisibleLinks(\n ontology: OntologyDefinitionCatalog,\n objectType: ObjectTypeWithPropertyTokens,\n visibleObjectTypeIds: ReadonlySet<string>\n): ReadonlyMap<string, LinkSelection> {\n const links = new Map<string, LinkSelection>()\n for (const link of objectType.links) {\n const targetObjectTypeIds = new Set(\n [...visibleObjectTypeIds].filter((targetObjectTypeId) =>\n ontology.isValidLinkTarget(link.targetObjectTypeId, targetObjectTypeId)\n )\n )\n if (targetObjectTypeIds.size === 0) continue\n links.set(link.id, {\n targetObjectTypeIds,\n propertyIds: new Set(link.properties?.map((property) => property.id) ?? []),\n })\n }\n return links\n}\n\nfunction projectObjectType(input: {\n readonly ontology: OntologyDefinitionCatalog\n readonly objectType: ObjectTypeWithPropertyTokens\n readonly propertyIds: ReadonlySet<string>\n readonly links: ReadonlyMap<string, LinkSelection>\n readonly visibleObjectTypeIds: ReadonlySet<string>\n readonly targetMode: \"original\" | \"principal\" | \"exact\"\n readonly exposeContracts: boolean\n}): ObjectTypeWithPropertyTokens {\n const properties = input.objectType.properties\n .filter((property) => input.propertyIds.has(property.id))\n .map(snapshotProperty)\n const visiblePropertyIds = new Set(properties.map((property) => property.id))\n const links = input.objectType.links.flatMap((link): ObjectLink[] => {\n const selected = input.links.get(link.id)\n if (!selected) return []\n if (input.targetMode === \"original\") {\n return [snapshotLink(link, snapshotLinkTarget(link.targetObjectTypeId), selected.propertyIds)]\n }\n const targetObjectTypeIds = new Set(\n [...selected.targetObjectTypeIds].filter(\n (targetObjectTypeId) =>\n input.visibleObjectTypeIds.has(targetObjectTypeId) &&\n input.ontology.isValidLinkTarget(link.targetObjectTypeId, targetObjectTypeId)\n )\n )\n if (targetObjectTypeIds.size === 0) return []\n const target =\n input.targetMode === \"principal\"\n ? principalLinkTargets(link, targetObjectTypeIds, input.visibleObjectTypeIds)\n : exactLinkTargets(targetObjectTypeIds)\n return [snapshotLink(link, target, selected.propertyIds, { omitEmptyProperties: true })]\n })\n\n // Whitelist top-level metadata so future cross-ontology fields remain closed until reviewed.\n const projected: ObjectType = {\n id: input.objectType.id,\n name: input.objectType.name,\n description: input.objectType.description,\n quantityKind: input.objectType.quantityKind,\n seeAlso: input.objectType.seeAlso ? [...input.objectType.seeAlso] : undefined,\n extends:\n input.objectType.extends && input.visibleObjectTypeIds.has(input.objectType.extends)\n ? input.objectType.extends\n : undefined,\n parents: projectOptionalIds(\n input.objectType.parents,\n input.visibleObjectTypeIds,\n input.targetMode === \"original\"\n ),\n implements:\n input.exposeContracts && input.objectType.implements\n ? [...input.objectType.implements]\n : undefined,\n properties,\n links,\n search: projectSearch(input.objectType.search, visiblePropertyIds, {\n preserveEmpty: input.targetMode !== \"exact\",\n }),\n }\n const withTokens = {\n ...projected,\n p: createPropertyTokenMap(projected),\n l: createLinkTokenMap(projected),\n }\n return deepFreeze(withTokens) as ObjectTypeWithPropertyTokens\n}\n\nfunction principalLinkTargets(\n link: ObjectLink,\n allowedTargetObjectTypeIds: ReadonlySet<string>,\n visibleObjectTypeIds: ReadonlySet<string>\n): string | string[] {\n if (link.targetObjectTypeId === \"*\") return exactLinkTargets(allowedTargetObjectTypeIds)\n const declared = Array.isArray(link.targetObjectTypeId)\n ? link.targetObjectTypeId\n : [link.targetObjectTypeId]\n if (declared.every((objectTypeId) => visibleObjectTypeIds.has(objectTypeId))) {\n return snapshotLinkTarget(link.targetObjectTypeId)\n }\n return exactLinkTargets(allowedTargetObjectTypeIds)\n}\n\nfunction exactLinkTargets(targetObjectTypeIds: ReadonlySet<string>): string | string[] {\n const targets = [...targetObjectTypeIds].sort()\n return targets.length === 1 ? targets[0]! : targets\n}\n\nfunction projectOptionalIds(\n ids: readonly string[] | undefined,\n visibleObjectTypeIds: ReadonlySet<string>,\n preserveOriginal: boolean\n): string[] | undefined {\n if (!ids) return undefined\n if (preserveOriginal) return [...ids]\n const visible = ids.filter((id) => visibleObjectTypeIds.has(id))\n return visible.length > 0 ? visible : undefined\n}\n\nfunction snapshotLink(\n link: ObjectLink,\n targetObjectTypeId: string | string[],\n propertyIds: ReadonlySet<string>,\n options: { readonly omitEmptyProperties?: boolean } = {}\n): ObjectLink {\n const properties = link.properties\n ?.filter((property) => propertyIds.has(property.id))\n .map(snapshotProperty)\n return {\n id: link.id,\n name: link.name,\n description: link.description,\n targetObjectTypeId,\n cardinality: link.cardinality,\n properties: options.omitEmptyProperties && properties?.length === 0 ? undefined : properties,\n }\n}\n\nfunction snapshotLinkTarget(target: string | readonly string[]): string | string[] {\n return typeof target === \"string\" ? target : [...target]\n}\n\nfunction snapshotProperty(property: Property): Property {\n return {\n id: property.id,\n name: property.name,\n schema: snapshotSchema(property.schema),\n description: property.description,\n required: property.required,\n nullable: property.nullable,\n primary: property.primary,\n unique: property.unique,\n mode: property.mode,\n semanticType: property.semanticType,\n query: snapshotPropertyQuery(property.query),\n }\n}\n\nfunction snapshotPropertyQuery(\n query: PropertyQueryMetadata | undefined\n): PropertyQueryMetadata | undefined {\n if (!query) return undefined\n return {\n searchable: query.searchable,\n filterable: query.filterable,\n sortable: query.sortable,\n text: query.text,\n exact: query.exact,\n facet: query.facet,\n weight: query.weight,\n }\n}\n\nfunction projectSearch(\n search: ObjectTypeSearchMetadata | undefined,\n visiblePropertyIds: ReadonlySet<string>,\n options: { readonly preserveEmpty: boolean }\n): ObjectTypeSearchMetadata | undefined {\n if (!search) return undefined\n const title = search.title && visiblePropertyIds.has(search.title) ? search.title : undefined\n const selectedDefaultText = search.defaultText?.filter((propertyId) =>\n visiblePropertyIds.has(propertyId)\n )\n const selectedExact = search.exact?.filter((propertyId) => visiblePropertyIds.has(propertyId))\n const defaultText =\n options.preserveEmpty || selectedDefaultText?.length ? selectedDefaultText : undefined\n const exact = options.preserveEmpty || selectedExact?.length ? selectedExact : undefined\n const vectors =\n search.vectors === undefined\n ? undefined\n : snapshotVectorProfiles(\n Object.fromEntries(\n Object.entries(search.vectors).filter(([, profile]) =>\n profile.source.every((id) => visiblePropertyIds.has(id))\n )\n )\n )\n const projected: ObjectTypeSearchMetadata = {\n ...(vectors === undefined || Object.keys(vectors).length === 0 ? {} : { vectors }),\n ...(title === undefined ? {} : { title }),\n ...(defaultText === undefined ? {} : { defaultText }),\n ...(exact === undefined ? {} : { exact }),\n }\n return Object.keys(projected).length > 0 || options.preserveEmpty ? projected : undefined\n}\n\nfunction snapshotAllValueTypes(\n registered: ReadonlyMap<string, ValueType>\n): ReadonlyMap<string, ValueType> {\n return new Map(\n [...registered.values()].map((valueType) => {\n const snapshot = snapshotValueType(valueType)\n return [snapshot.id, snapshot] as const\n })\n )\n}\n\nfunction collectVisibleValueTypes(\n registered: ReadonlyMap<string, ValueType>,\n objectTypes: readonly ObjectTypeWithPropertyTokens[]\n): ReadonlyMap<string, ValueType> {\n const referencedIds = new Set<string>()\n const pendingSchemas: Schema[] = []\n const visitedSchemas = new Set<object>()\n for (const objectType of objectTypes) {\n for (const property of objectType.properties) pendingSchemas.push(property.schema)\n for (const link of objectType.links) {\n for (const property of link.properties ?? []) pendingSchemas.push(property.schema)\n }\n }\n\n while (pendingSchemas.length > 0) {\n const schema = pendingSchemas.pop()!\n if (typeof schema === \"string\" || visitedSchemas.has(schema)) continue\n visitedSchemas.add(schema)\n if (schema.type === \"valueTypeRef\") {\n if (!referencedIds.has(schema.valueTypeId)) {\n referencedIds.add(schema.valueTypeId)\n const valueType = registered.get(schema.valueTypeId)\n if (valueType) pendingSchemas.push(valueType.schema)\n }\n if (schema._resolved) pendingSchemas.push(schema._resolved)\n } else if (schema.type === \"object\") {\n for (const field of Object.values(schema.properties)) pendingSchemas.push(field.schema)\n } else if (schema.type === \"array\") {\n pendingSchemas.push(schema.items)\n } else if (schema.type === \"map\") {\n pendingSchemas.push(schema.valueSchema)\n }\n }\n\n return new Map(\n [...referencedIds]\n .map((valueTypeId) => registered.get(valueTypeId))\n .filter((valueType): valueType is ValueType => valueType !== undefined)\n .map((valueType) => {\n const snapshot = snapshotValueType(valueType)\n return [snapshot.id, snapshot] as const\n })\n )\n}\n\nfunction snapshotValueType(valueType: ValueType): ValueType {\n return deepFreeze({\n id: valueType.id,\n name: valueType.name,\n description: valueType.description,\n schema: snapshotSchema(valueType.schema),\n semanticType: valueType.semanticType,\n })\n}\n\nfunction snapshotSchema(schema: Schema): Schema {\n return deepFreeze(structuredClone(schema))\n}\n\nfunction deepFreeze<T>(value: T, seen: Set<object> = new Set()): T {\n if (typeof value !== \"object\" || value === null || seen.has(value)) return value\n seen.add(value)\n for (const key of Reflect.ownKeys(value)) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n if (descriptor && \"value\" in descriptor) deepFreeze(descriptor.value, seen)\n }\n return Object.freeze(value)\n}\n\nfunction unknownObjectType(objectTypeId: string): never {\n throw new OntologyNotFoundError(formatUnknownObjectTypeMessage(objectTypeId))\n}\n",
11
- "import {\n type AuthorizedOntologySelection,\n type AuthorizedOntologyView,\n createAuthorizedOntologyView,\n} from \"../objects/authorized-ontology-view\"\nimport type { OntologyRegistry } from \"../ontology\"\nimport { assertObjectReadOutputWithinLimit } from \"../storage\"\nimport type { ObjectReaderSecurity } from \"./object-reader-security\"\n\n/** The ontology a reader resolves against, and the part of it its authority may describe. */\nexport class ObjectReaderOntology {\n readonly registry: OntologyRegistry\n readonly #security: ObjectReaderSecurity\n #view?: AuthorizedOntologyView\n\n constructor(registry: OntologyRegistry, security: ObjectReaderSecurity) {\n this.registry = registry\n this.#security = security\n Object.freeze(this)\n }\n\n /** Inert metadata for the types the authority may view, built on first use. */\n view(): AuthorizedOntologyView {\n const authority = this.#security.authority\n this.#view ??= createAuthorizedOntologyView({\n ontology: this.registry,\n selection: selectionForAuthority(this.#security, this.registry),\n ...(authority.type === \"delegated\"\n ? {\n assertOutputWithinLimit: (value: unknown) =>\n assertObjectReadOutputWithinLimit(value, authority.objectRead.limits),\n }\n : {}),\n })\n return this.#view\n }\n}\n\nfunction selectionForAuthority(\n security: ObjectReaderSecurity,\n ontology: OntologyRegistry\n): AuthorizedOntologySelection {\n const authority = security.authority\n\n switch (authority.type) {\n case \"unrestricted\":\n return { kind: \"all\" }\n case \"principal\":\n return {\n kind: \"types\",\n objectTypeIds: ontology\n .listObjectTypes()\n // A type viewed through a condition is listed: the reader reads the objects it matches.\n .filter((objectType) => security.isObjectTypeGranted(objectType.id, undefined))\n .map((objectType) => objectType.id),\n }\n case \"delegated\":\n return { kind: \"selected\", scope: authority.objectRead.scope }\n }\n}\n",
12
- "import { AuthorizationError } from \"../../authorization/errors\"\nimport type {\n CompiledObjectReadObjectSelection,\n CompiledObjectReadStep,\n CompiledSelectedObjectReadScope,\n} from \"../../storage/objects/types\"\nimport type {\n ObjectQueryAdmissionState,\n ObjectQueryAdmissionTransition,\n ObjectQueryEdgeUse,\n ObjectQueryPropertyUse,\n ObjectQuerySemanticAdmission,\n} from \"./validate\"\n\nconst selectedStateBrand = Symbol(\"sixb.selected-object-query-admission-state\")\n\ninterface SelectedObjectQueryState extends ObjectQueryAdmissionState {\n readonly [selectedStateBrand]: true\n readonly selections: readonly CompiledObjectReadObjectSelection[]\n}\n\nexport interface SelectedObjectQueryAdmission extends ObjectQuerySemanticAdmission {\n /** Terminal hook for property-bearing operations outside the query IR, such as facets. */\n assertPropertySelected(input: {\n readonly state: ObjectQueryAdmissionState\n readonly propertyId: string\n readonly objectTypeId?: string\n readonly use: ObjectQueryPropertyUse\n readonly path: string\n }): void\n /** Terminal hook for the physical-link selector that sits outside `queryLinks.query`. */\n assertIncidentEdgeSelected(input: {\n readonly state: ObjectQueryAdmissionState\n readonly linkId?: string\n readonly direction: \"outgoing\" | \"incoming\" | \"both\"\n readonly path: string\n }): void\n}\n\n/**\n * Build an immutable semantic admission over one already-compiled selected reader scope.\n *\n * Object identities remain provider-owned: query admission follows exact path occurrences while\n * the selected storage relation decides which live roots and linked instances exist.\n */\nexport function createSelectedObjectQueryAdmission(\n scope: CompiledSelectedObjectReadScope\n): SelectedObjectQueryAdmission {\n const selectionByKey = new Map<string, CompiledObjectReadObjectSelection>()\n const selectionsByType = new Map<string, CompiledObjectReadObjectSelection[]>()\n const propertiesBySelection = new Map<string, ReadonlySet<string>>()\n\n for (const selection of scope.objects) {\n const key = selectionKey(selection.nodeId, selection.objectTypeId)\n selectionByKey.set(key, selection)\n propertiesBySelection.set(key, new Set(selection.propertyIds))\n const byType = selectionsByType.get(selection.objectTypeId) ?? []\n byType.push(selection)\n selectionsByType.set(selection.objectTypeId, byType)\n }\n\n const outgoing = indexSteps(scope.steps, \"outgoing\", selectionByKey)\n const incoming = indexSteps(scope.steps, \"incoming\", selectionByKey)\n const emptyState = selectedState([])\n\n const admission: SelectedObjectQueryAdmission = {\n empty: () => emptyState,\n source: (input) => {\n const selections = input.result.objectTypeIds.flatMap(\n (objectTypeId) => selectionsByType.get(objectTypeId) ?? []\n )\n const state = selectedState(selections)\n\n if (input.kind === \"refs\") {\n const missingType = [...new Set(input.refs?.map((ref) => ref.objectTypeId) ?? [])]\n .sort()\n .find((objectTypeId) => !selectionsByType.has(objectTypeId))\n if (missingType) {\n return denied(\n state,\n new AuthorizationError(\n `view:object:${missingType}`,\n `[Sixb] Delegated query cannot reference object type '${missingType}' at '${input.path}': the selected object scope does not contain that type.`\n )\n )\n }\n }\n\n if (state.selections.length > 0) return { state }\n const objectTypeId = input.objectTypeId ?? input.result.objectTypeIds[0] ?? \"unknown\"\n return denied(\n state,\n new AuthorizationError(\n `view:object:${objectTypeId}`,\n `[Sixb] Delegated query cannot start from object type '${objectTypeId}' at '${input.path}': the selected object scope does not contain that type.`\n )\n )\n },\n property: (input) =>\n propertyDenial(\n asSelectedState(input.state),\n input.propertyId,\n input.objectTypeId,\n input.use,\n input.path,\n propertiesBySelection\n ),\n edge: (input) => {\n const state = asSelectedState(input.state)\n const next = followEdge(\n state,\n input.linkId,\n input.direction,\n input.sourceObjectTypeId,\n outgoing,\n incoming,\n input.result.objectTypeIds\n )\n if (next.selections.length > 0 || state.selections.length === 0) return { state: next }\n return denied(\n next,\n edgeDenial(\n state,\n input.linkId,\n input.direction,\n input.sourceObjectTypeId,\n input.use,\n input.path\n )\n )\n },\n set: ({ op, states }) => {\n if (op === \"subtract\") return asSelectedState(states[0] ?? emptyState)\n return selectedState(states.flatMap((state) => asSelectedState(state).selections))\n },\n assertPropertySelected: (input) => {\n const denial = propertyDenial(\n asSelectedState(input.state),\n input.propertyId,\n input.objectTypeId,\n input.use,\n input.path,\n propertiesBySelection\n )\n if (denial) throw denial\n },\n assertIncidentEdgeSelected: (input) => {\n if (input.linkId === undefined) return\n const state = asSelectedState(input.state)\n const directions: readonly (\"outgoing\" | \"incoming\")[] =\n input.direction === \"both\" ? [\"outgoing\", \"incoming\"] : [input.direction]\n const next = selectedState(\n directions.flatMap(\n (direction) =>\n followEdge(state, input.linkId!, direction, undefined, outgoing, incoming).selections\n )\n )\n if (next.selections.length > 0 || state.selections.length === 0) return\n throw edgeDenial(state, input.linkId, input.direction, undefined, \"queryLinks\", input.path)\n },\n }\n\n return Object.freeze(admission)\n}\n\nfunction indexSteps(\n steps: readonly CompiledObjectReadStep[],\n direction: \"outgoing\" | \"incoming\",\n selectionByKey: ReadonlyMap<string, CompiledObjectReadObjectSelection>\n): ReadonlyMap<string, readonly CompiledObjectReadObjectSelection[]> {\n const index = new Map<string, CompiledObjectReadObjectSelection[]>()\n for (const step of steps) {\n const fromKey =\n direction === \"outgoing\"\n ? selectionKey(step.parentNodeId, step.sourceObjectTypeId)\n : selectionKey(step.nodeId, step.targetObjectTypeId)\n const toKey =\n direction === \"outgoing\"\n ? selectionKey(step.nodeId, step.targetObjectTypeId)\n : selectionKey(step.parentNodeId, step.sourceObjectTypeId)\n const target = selectionByKey.get(toKey)\n if (!selectionByKey.has(fromKey) || !target) {\n throw new Error(\"[Sixb] Compiled selected object scope contains an invalid query path step.\")\n }\n const key = edgeKey(\n direction === \"outgoing\" ? step.parentNodeId : step.nodeId,\n direction === \"outgoing\" ? step.sourceObjectTypeId : step.targetObjectTypeId,\n step.linkId\n )\n const targets = index.get(key) ?? []\n targets.push(target)\n index.set(key, targets)\n }\n return index\n}\n\nfunction followEdge(\n state: SelectedObjectQueryState,\n linkId: string,\n direction: \"outgoing\" | \"incoming\",\n sourceObjectTypeId: string | undefined,\n outgoing: ReadonlyMap<string, readonly CompiledObjectReadObjectSelection[]>,\n incoming: ReadonlyMap<string, readonly CompiledObjectReadObjectSelection[]>,\n resultObjectTypeIds?: readonly string[]\n): SelectedObjectQueryState {\n const index = direction === \"outgoing\" ? outgoing : incoming\n const resultTypes = resultObjectTypeIds ? new Set(resultObjectTypeIds) : undefined\n const selections = state.selections.flatMap((selection) => {\n const candidates = index.get(edgeKey(selection.nodeId, selection.objectTypeId, linkId)) ?? []\n return candidates.filter(\n (candidate) =>\n (resultTypes === undefined || resultTypes.has(candidate.objectTypeId)) &&\n (direction === \"outgoing\" ||\n sourceObjectTypeId === undefined ||\n candidate.objectTypeId === sourceObjectTypeId)\n )\n })\n return selectedState(selections)\n}\n\nfunction propertyDenial(\n state: SelectedObjectQueryState,\n propertyId: string,\n objectTypeId: string | undefined,\n use: ObjectQueryPropertyUse,\n path: string,\n propertiesBySelection: ReadonlyMap<string, ReadonlySet<string>>\n): AuthorizationError | undefined {\n const candidates = objectTypeId\n ? state.selections.filter((selection) => selection.objectTypeId === objectTypeId)\n : state.selections\n // A selected reader has no rows for result types absent from this provenance. Those empty\n // branches cannot observe a property and must not make includeSubtypes queries fail closed.\n if (candidates.length === 0) return undefined\n\n const missing = candidates.find(\n (selection) =>\n !propertiesBySelection\n .get(selectionKey(selection.nodeId, selection.objectTypeId))\n ?.has(propertyId)\n )\n if (!missing) return undefined\n\n const objectTypeIds = [...new Set(candidates.map((selection) => selection.objectTypeId))].sort()\n return new AuthorizationError(\n `view:object:${objectTypeIds.join(\",\")}:property:${propertyId}`,\n `[Sixb] Delegated query cannot use property '${propertyId}' for ${use} at '${path}': it is not selected on every matching read-scope path (missing on ${formatSelection(missing)}).`\n )\n}\n\nfunction edgeDenial(\n state: SelectedObjectQueryState,\n linkId: string,\n direction: \"outgoing\" | \"incoming\" | \"both\",\n sourceObjectTypeId: string | undefined,\n use: ObjectQueryEdgeUse,\n path: string\n): AuthorizationError {\n const source = sourceObjectTypeId ? `:${sourceObjectTypeId}` : \"\"\n return new AuthorizationError(\n `view:link:${direction}${source}:${linkId}`,\n `[Sixb] Delegated query cannot use ${direction} link '${linkId}' for ${use} from ${formatState(state)} at '${path}': that exact read-scope path is not selected.`\n )\n}\n\nfunction formatState(state: SelectedObjectQueryState): string {\n if (state.selections.length === 0) return \"an empty read-scope provenance\"\n return `read-scope provenance ${state.selections.map(formatSelection).join(\", \")}`\n}\n\nfunction formatSelection(selection: CompiledObjectReadObjectSelection): string {\n return `'${selection.objectTypeId}'@node ${selection.nodeId}`\n}\n\nfunction selectedState(\n selections: readonly CompiledObjectReadObjectSelection[]\n): SelectedObjectQueryState {\n const unique = new Map<string, CompiledObjectReadObjectSelection>()\n for (const selection of selections) {\n unique.set(selectionKey(selection.nodeId, selection.objectTypeId), selection)\n }\n return Object.freeze({\n [selectedStateBrand]: true as const,\n selections: Object.freeze(\n [...unique.values()].sort(\n (left, right) =>\n left.nodeId - right.nodeId || left.objectTypeId.localeCompare(right.objectTypeId)\n )\n ),\n })\n}\n\nfunction asSelectedState(state: ObjectQueryAdmissionState): SelectedObjectQueryState {\n if ((state as Partial<SelectedObjectQueryState>)[selectedStateBrand] !== true) {\n throw new Error(\"[Sixb] Object query admission state belongs to another semantic admission.\")\n }\n return state as SelectedObjectQueryState\n}\n\nfunction denied(state: SelectedObjectQueryState, denial: Error): ObjectQueryAdmissionTransition {\n return { state, denial }\n}\n\nfunction selectionKey(nodeId: number, objectTypeId: string): string {\n return JSON.stringify([nodeId, objectTypeId])\n}\n\nfunction edgeKey(nodeId: number, objectTypeId: string, linkId: string): string {\n return JSON.stringify([nodeId, objectTypeId, linkId])\n}\n",
13
- "import { type PropertyClearance, resolvePropertyClearance } from \"../objects/property-clearance\"\nimport type { OntologyRegistry } from \"../ontology\"\nimport type { AppliedMarkings } from \"../security/applied-markings\"\nimport type { EventOriginRef } from \"../security/applied-markings-contribution\"\nimport type { AppliedMarkingsSnapshot } from \"../security/applied-markings-snapshot\"\n\n/** What one read may not return; `undefined` when it reads everything. */\nexport type Clearance = PropertyClearance | undefined\n\n/**\n * What one authority cannot read: the markings the code declares, and those the dataset versions\n * projections applied add, for an authority they can affect.\n *\n * A reader they cannot affect, trusted code included, gets the code's clearance as a plain value:\n * awaiting it costs one microtask, not a refresh. Otherwise the clearance is resolved for each\n * snapshot, which rarely changes, so the last one is kept.\n */\nexport class ObjectReaderClearance {\n readonly #ontology: OntologyRegistry\n /** What the authority cannot read under the code's markings; absent when it reads everything. */\n readonly #static: Clearance\n /** The authority's clearances; absent when it is unrestricted. */\n readonly #clearances?: ReadonlySet<string>\n /** Present only when applied dataset versions can deny this authority more than the code. */\n readonly #applied?: AppliedMarkings\n #lastSnapshot?: AppliedMarkingsSnapshot\n #lastClearance: Clearance\n\n constructor(input: {\n readonly ontology: OntologyRegistry\n readonly clearances: ReadonlySet<string> | undefined\n readonly appliedMarkings?: AppliedMarkings\n }) {\n this.#ontology = input.ontology\n this.#clearances = input.clearances\n this.#static = input.clearances && resolvePropertyClearance(input.ontology, input.clearances)\n\n if (input.clearances && input.appliedMarkings?.affects(input.clearances)) {\n this.#applied = input.appliedMarkings\n }\n\n Object.freeze(this)\n }\n\n /** What the authority cannot read now. */\n current(): Clearance | Promise<Clearance> {\n const applied = this.#applied\n const clearances = this.#clearances\n if (!applied || !clearances) return this.#static\n\n return applied.current().then((snapshot) => {\n if (snapshot !== this.#lastSnapshot) {\n this.#lastClearance = resolvePropertyClearance(this.#ontology, clearances, snapshot)\n this.#lastSnapshot = snapshot\n }\n return this.#lastClearance\n })\n }\n\n /**\n * This clearance as it is now, for a reader that must not read the project's storage, such as\n * one inside a storage transaction: what applied dataset versions add is read once, here, and\n * kept. A clearance they cannot affect reads nothing and is returned as it is.\n */\n async pinned(): Promise<ObjectReaderClearance> {\n const applied = this.#applied\n if (!applied) return this\n\n const snapshot = await applied.current()\n return new ObjectReaderClearance({\n ontology: this.#ontology,\n clearances: this.#clearances,\n appliedMarkings: pinnedAppliedMarkings(applied, snapshot),\n })\n }\n\n /**\n * What the authority cannot read in an object event. Reads the event's origin version only for\n * an authority its markings affect.\n */\n forEvent(sources: EventSources): Clearance | Promise<Clearance> {\n const applied = this.#applied\n const clearances = this.#clearances\n if (!applied || !clearances) return this.#static\n\n return applied\n .current()\n .then((snapshot) =>\n sources.origin ? applied.forEventOrigin(snapshot, sources.origin) : snapshot\n )\n .then((snapshot) =>\n sources.earlier ? applied.forEarlierValues(snapshot, sources.objectTypeId) : snapshot\n )\n .then((snapshot) => resolvePropertyClearance(this.#ontology, clearances, snapshot))\n }\n}\n\n/** Applied markings that answer `snapshot` as current, and never refresh it. */\nfunction pinnedAppliedMarkings(\n applied: AppliedMarkings,\n snapshot: AppliedMarkingsSnapshot\n): AppliedMarkings {\n return {\n affects: (clearances) => applied.affects(clearances),\n current: async () => snapshot,\n invalidate: () => {},\n forEventOrigin: (current, origin) => applied.forEventOrigin(current, origin),\n forEarlierValues: (current, objectTypeId) => applied.forEarlierValues(current, objectTypeId),\n }\n}\n\n/** Where the values of an object event came from. */\nexport interface EventSources {\n readonly objectTypeId: string\n /** The projection that emitted the event, and the version it applied. */\n readonly origin?: EventOriginRef\n /**\n * Whether the event holds values from before it, which came from versions applied earlier: an\n * update or a deletion, or a record an action or a direct write took of projected values.\n */\n readonly earlier: boolean\n}\n",
14
- "import { assertAuthorized, assertRuntimeAuthorizationBound, isAllowed } from \"../authorization\"\nimport { AuthorizationError } from \"../authorization/errors\"\nimport type { AuthorizationContext } from \"../authorization/types\"\nimport { type Unreadable, unreadableError } from \"../objects/property-clearance\"\nimport type { ObjectQueryPredicate } from \"../objects/query/ir\"\nimport {\n createSelectedObjectQueryAdmission,\n type SelectedObjectQueryAdmission,\n} from \"../objects/query/selected-read-admission\"\nimport type { OntologyRegistry } from \"../ontology\"\nimport type { UserRef } from \"../ontology/user-ref\"\nimport type { AppliedMarkings } from \"../security/applied-markings\"\nimport { viewConditionReadCondition } from \"../security/visibility-keys\"\nimport type {\n CompiledConditionalObjectReadScope,\n CompiledObjectReadStep,\n ObjectLinkRow,\n} from \"../storage\"\nimport { compileConditionalObjectReadScope } from \"../storage/objects/read-scope\"\nimport type { resolveExecutionScopeAuthorization } from \"./authorization\"\nimport { type Clearance, ObjectReaderClearance } from \"./object-reader-clearance\"\nimport type { AuthorizablePrincipal, RuntimeAuthorization } from \"./types\"\n\nexport type ResolvedExecutionAuthority = ReturnType<typeof resolveExecutionScopeAuthorization>\n\nexport type RuntimeReadAuthorization = {\n readonly projectId: string\n readonly runtimeAuthorization: RuntimeAuthorization\n readonly authorization?: AuthorizationContext\n}\n\n/** What a delegated authority selected: the object types, links, and queries it may read. */\nexport interface ObjectReaderDelegation {\n readonly objectTypeIds: ReadonlySet<string>\n readonly linkDefinitions: ReadonlySet<string>\n readonly queryAdmission: SelectedObjectQueryAdmission\n}\n\n/**\n * Who reads, and what it may read: the exact execution authority, the selection a delegated one\n * carries, the conditions a principal reads some types through, and its clearance. It decides\n * whether an object type or a link is viewable.\n *\n * A type a principal views only through a condition is viewable here, and nowhere else: the\n * reader's storage shows only the objects the condition matches. A check that answers for one\n * object of such a type reads that object through the same storage.\n */\nexport class ObjectReaderSecurity {\n /** The registered authority the reader is bound to. */\n readonly authorization: RuntimeAuthorization\n readonly authority: ResolvedExecutionAuthority\n /** The authority as generic authorization checks take it. */\n readonly runtime: RuntimeReadAuthorization\n /** Present for delegated authority only. */\n readonly delegation?: ObjectReaderDelegation\n readonly clearance: ObjectReaderClearance\n /** The user `currentUser()` stands for in this reader's queries; absent when no user reads. */\n readonly requestingUser?: UserRef\n /** What the reader's storage reads through: present when a principal views a type under one. */\n readonly conditionalScope?: CompiledConditionalObjectReadScope\n /** The properties each conditioned type's condition reads, which its clearance must show. */\n readonly #conditionProperties: ReadonlyMap<string, readonly string[]>\n\n constructor(\n input: {\n readonly authorization: RuntimeAuthorization\n readonly authority: ResolvedExecutionAuthority\n readonly projectId: string\n readonly requestedBy: AuthorizablePrincipal | undefined\n } & (\n | { readonly ontology: OntologyRegistry; readonly appliedMarkings?: AppliedMarkings }\n /** A clearance resolved already, as {@link withClearance} passes it. */\n | { readonly clearance: ObjectReaderClearance }\n )\n ) {\n const authority = input.authority\n this.authorization = input.authorization\n this.authority = authority\n if (input.requestedBy?.type === \"user\") {\n this.requestingUser = Object.freeze({ type: \"user\", id: input.requestedBy.id })\n }\n this.runtime = Object.freeze({\n projectId: input.projectId,\n runtimeAuthorization: input.authorization,\n ...(authority.type === \"principal\" ? { authorization: authority.context } : {}),\n })\n\n if (authority.type === \"delegated\") {\n const scope = authority.objectRead.scope\n this.delegation = Object.freeze({\n objectTypeIds: new Set(scope.objects.map((object) => object.objectTypeId)),\n linkDefinitions: new Set(scope.steps.map(delegatedLinkDefinitionKey)),\n queryAdmission: createSelectedObjectQueryAdmission(scope),\n })\n }\n\n const conditions = authority.type === \"principal\" ? authority.context.viewConditions : undefined\n this.#conditionProperties = new Map(\n [...(conditions ?? [])].map(([objectTypeId, predicates]) => [\n objectTypeId,\n [...new Set(predicates.flatMap(propertiesReadBy))],\n ])\n )\n\n if (authority.type === \"principal\" && conditions && conditions.size > 0) {\n // A reader sees an object any of its conditions matches. In a condition, `currentUser()` is\n // the principal the grant was resolved for, when it is a user: never the user who requested\n // the execution, which an agent's service account runs for. Otherwise it is no one.\n const principal = authority.context.principal\n const grantee: UserRef | undefined =\n principal.type === \"user\" ? { type: \"user\", id: principal.id } : undefined\n\n this.conditionalScope = compileConditionalObjectReadScope({\n kind: \"conditional\",\n conditions: [...conditions].map(([objectTypeId, predicates]) =>\n viewConditionReadCondition(objectTypeId, predicates, grantee)\n ),\n })\n }\n\n this.clearance =\n \"clearance\" in input\n ? input.clearance\n : new ObjectReaderClearance({\n ontology: input.ontology,\n clearances: clearancesForAuthority(authority),\n ...(input.appliedMarkings === undefined\n ? {}\n : { appliedMarkings: input.appliedMarkings }),\n })\n\n Object.freeze(this)\n }\n\n /** The same authority, reading under `clearance`: this security's own, pinned. */\n withClearance(clearance: ObjectReaderClearance): ObjectReaderSecurity {\n return new ObjectReaderSecurity({\n authorization: this.authorization,\n authority: this.authority,\n projectId: this.runtime.projectId,\n requestedBy: this.requestingUser,\n clearance,\n })\n }\n\n assertObjectTypesViewable(objectTypeIds: readonly string[], clearance: Clearance): void {\n if (this.delegation) {\n for (const objectTypeId of new Set(objectTypeIds)) {\n if (this.delegation.objectTypeIds.has(objectTypeId)) continue\n throw new AuthorizationError(\n `delegated:object.view:${objectTypeId}`,\n `[Sixb] Delegated authorization does not select object type '${objectTypeId}'.`\n )\n }\n } else {\n this.assertObjectTypesGranted(objectTypeIds, clearance)\n }\n\n if (!clearance) return\n\n for (const objectTypeId of new Set(objectTypeIds)) {\n const unreadable = clearance.unreadableType(objectTypeId)\n if (unreadable) throw unreadableError(unreadable)\n }\n }\n\n /**\n * Refuse a type a principal holds no view grant for, before its clearance is applied to what it\n * reads. A type viewed through a condition passes while the clearance shows every property the\n * condition reads.\n */\n assertObjectTypesGranted(objectTypeIds: readonly string[], clearance: Clearance): void {\n for (const objectTypeId of new Set(objectTypeIds)) {\n if (!this.#conditionProperties.has(objectTypeId)) {\n assertAuthorized(this.runtime, { kind: \"object.view\", objectTypeId })\n continue\n }\n\n assertRuntimeAuthorizationBound(this.runtime)\n\n const unreadable = this.#unreadableCondition(objectTypeId, clearance)\n if (unreadable) throw unreadableError(unreadable)\n }\n }\n\n /** Whether the principal views this type only through a condition, which decides per object. */\n viewsThroughCondition(objectTypeId: string): boolean {\n return this.#conditionProperties.has(objectTypeId)\n }\n\n isObjectTypeGranted(objectTypeId: string, clearance: Clearance): boolean {\n if (this.delegation) return this.delegation.objectTypeIds.has(objectTypeId)\n\n if (this.#conditionProperties.has(objectTypeId)) {\n return this.#unreadableCondition(objectTypeId, clearance) === undefined\n }\n\n return isAllowed(this.runtime.authorization, { kind: \"object.view\", objectTypeId })\n }\n\n isObjectTypeViewable(objectTypeId: string, clearance: Clearance): boolean {\n if (clearance?.unreadableType(objectTypeId)) return false\n return this.isObjectTypeGranted(objectTypeId, clearance)\n }\n\n isLinkViewable(link: ObjectLinkRow, clearance: Clearance): boolean {\n if (\n !this.isObjectTypeViewable(link.sourceTypeId, clearance) ||\n !this.isObjectTypeViewable(link.targetTypeId, clearance) ||\n clearance?.unreadableLink(link.sourceTypeId, link.linkId)\n ) {\n return false\n }\n\n return this.delegation?.linkDefinitions.has(delegatedLinkDefinitionKey(link)) ?? true\n }\n\n #unreadableCondition(objectTypeId: string, clearance: Clearance): Unreadable | undefined {\n const propertyIds = this.#conditionProperties.get(objectTypeId)\n return propertyIds && unreadableConditionOf(objectTypeId, propertyIds, clearance)\n }\n}\n\n/**\n * Which objects match a condition would reveal a property the reader cannot read, so a clearance\n * that hides one, a marking applied by a dataset version included, hides the whole type.\n */\nfunction unreadableConditionOf(\n objectTypeId: string,\n propertyIds: readonly string[],\n clearance: Clearance\n): Unreadable | undefined {\n for (const propertyId of propertyIds) {\n const marking = clearance?.missingMarking(objectTypeId, propertyId)\n if (marking === undefined) continue\n\n return {\n marking,\n message: `[Sixb] Cannot read '${objectTypeId}': the condition it is viewed through reads '${objectTypeId}.${propertyId}', which requires clearance for marking '${marking}'.`,\n }\n }\n\n return undefined\n}\n\nfunction propertiesReadBy(predicate: ObjectQueryPredicate): readonly string[] {\n switch (predicate.op) {\n case \"and\":\n case \"or\":\n return predicate.items.flatMap(propertiesReadBy)\n case \"not\":\n return propertiesReadBy(predicate.item)\n case \"constant\":\n return []\n default:\n return [predicate.propertyId]\n }\n}\n\n/**\n * Unrestricted authority reads every property. A principal reads what its roles clear; delegated\n * shared access carries no clearance, so no share can expose a marked property.\n */\nfunction clearancesForAuthority(\n authority: ResolvedExecutionAuthority\n): ReadonlySet<string> | undefined {\n switch (authority.type) {\n case \"unrestricted\":\n return undefined\n case \"principal\":\n return authority.context.clearances ?? new Set()\n case \"delegated\":\n return new Set()\n }\n}\n\nfunction delegatedLinkDefinitionKey(\n input:\n | Pick<CompiledObjectReadStep, \"sourceObjectTypeId\" | \"linkId\" | \"targetObjectTypeId\">\n | Pick<ObjectLinkRow, \"sourceTypeId\" | \"linkId\" | \"targetTypeId\">\n): string {\n return \"sourceObjectTypeId\" in input\n ? JSON.stringify([input.sourceObjectTypeId, input.linkId, input.targetObjectTypeId])\n : JSON.stringify([input.sourceTypeId, input.linkId, input.targetTypeId])\n}\n",
15
- "import type { UserExpansionPlan } from \"../objects/query/user-expansions\"\nimport type { OntologyRegistry } from \"../ontology\"\nimport { isUserRef, isUserRefPropertySchema } from \"../ontology/user-ref\"\nimport type {\n AuthUserStore,\n ExpandedLinkValue,\n ObjectRow,\n ObjectRowUsers,\n UserRecord,\n} from \"../storage\"\nimport { toUserProfile } from \"../users/execution\"\n\n/** Ids read per storage call: one call for a typical page, bounded for the largest. */\nconst LOOKUP_BATCH_SIZE = 500\n\n/** One expanded property of one row, and the member ids its value holds, in stored order. */\ninterface UserSlot {\n readonly users: ObjectRowUsers\n readonly propertyId: string\n readonly many: boolean\n readonly ids: readonly string[]\n}\n\n/**\n * Attach the member profiles a query expands to the rows the reader returns.\n *\n * Every row whose type declares an expanded property gets `users`, so reading an entry never\n * throws. An entry is left out when the reader may not view the directory, and when the reader\n * cannot read the value: the rows have already lost their hidden values and carry `redactions`,\n * so a marked value is never looked up. The rows must be the reader's own copies.\n */\nexport async function attachUserProfiles(input: {\n readonly rows: readonly ObjectRow[]\n readonly plan: UserExpansionPlan\n readonly ontology: OntologyRegistry\n readonly projectId: string\n readonly canViewUsers: boolean\n readonly users: AuthUserStore | undefined\n}): Promise<void> {\n const slots: UserSlot[] = []\n collectSlots(input.rows, input.plan, input.ontology, slots)\n\n if (!input.canViewUsers) return\n\n const records = await readUsers(input, slots)\n\n for (const slot of slots) {\n slot.users[slot.propertyId] = expandedValue(slot, records)\n }\n}\n\n// An array keeps its members in order and skips ids no member has; a single reference to no\n// member, or an empty one, is `null`.\nfunction expandedValue(slot: UserSlot, records: ReadonlyMap<string, UserRecord>) {\n const profiles = slot.ids.flatMap((id) => {\n const record = records.get(id)\n return record ? [toUserProfile(record)] : []\n })\n\n return slot.many ? profiles : (profiles[0] ?? null)\n}\n\nfunction collectSlots(\n rows: readonly ObjectRow[],\n plan: UserExpansionPlan,\n ontology: OntologyRegistry,\n into: UserSlot[]\n): void {\n for (const row of rows) {\n const properties = ontology.getObjectTypeById(row.objectTypeId)?.properties ?? []\n\n for (const propertyId of plan.users) {\n const property = properties.find((candidate) => candidate.id === propertyId)\n if (!property || !isUserRefPropertySchema(property.schema)) continue\n\n row.users ??= {}\n if (row.redactions?.[propertyId]) continue\n\n into.push({\n users: row.users,\n propertyId,\n many: property.schema !== \"userRef\",\n ids: userIdsOf(row.properties[propertyId]),\n })\n }\n\n for (const link of plan.links) {\n collectSlots(linkedRows(row.links?.[link.linkId]), link.plan, ontology, into)\n }\n }\n}\n\nasync function readUsers(\n input: { readonly projectId: string; readonly users: AuthUserStore | undefined },\n slots: readonly UserSlot[]\n): Promise<ReadonlyMap<string, UserRecord>> {\n const records = new Map<string, UserRecord>()\n const ids = [...new Set(slots.flatMap((slot) => slot.ids))]\n if (!input.users || ids.length === 0) return records\n\n for (let start = 0; start < ids.length; start += LOOKUP_BATCH_SIZE) {\n const batch = ids.slice(start, start + LOOKUP_BATCH_SIZE)\n for (const record of await input.users.getByIds({ projectId: input.projectId, ids: batch })) {\n records.set(record.id, record)\n }\n }\n\n return records\n}\n\n// A single reference, or the references of an array in order. Anything else holds no member.\nfunction userIdsOf(value: unknown): string[] {\n if (isUserRef(value)) return [value.id]\n if (!Array.isArray(value)) return []\n return value.filter(isUserRef).map((ref) => ref.id)\n}\n\nfunction linkedRows(value: ExpandedLinkValue | undefined): readonly ObjectRow[] {\n if (value === undefined || value === null) return []\n if (Array.isArray(value)) return value\n return [value as ObjectRow]\n}\n",
16
- "import type { OntologyRegistry } from \"../ontology\"\nimport { OntologyValidationError } from \"../ontology/errors\"\nimport type { ObjectType, ValueType } from \"../ontology/types\"\nimport { uniqueValueKey, uniqueValueKind } from \"../ontology/unique-values\"\nimport { normalizeSchemaValue, validateSchemaValue } from \"../ontology/validation\"\n\n/**\n * The key a lookup by a unique property compares: the caller's value, validated and normalized as\n * a write would store it, so a `Date` finds the object a write gave the same date.\n */\nexport function uniqueLookupKey(\n ontology: OntologyRegistry,\n input: { readonly objectTypeId: string; readonly propertyId: string; readonly value: unknown }\n): string {\n return uniqueLookupKeyOf(\n ontology.resolveObjectType(input.objectTypeId),\n input.propertyId,\n input.value,\n ontology.getValueTypesById()\n )\n}\n\n/** {@link uniqueLookupKey} against an already resolved object type. */\nexport function uniqueLookupKeyOf(\n objectType: ObjectType,\n propertyId: string,\n value: unknown,\n valueTypesById: ReadonlyMap<string, ValueType>\n): string {\n const path = `${objectType.id}.${propertyId}`\n\n const property = objectType.properties.find((candidate) => candidate.id === propertyId)\n const kind = property?.unique ? uniqueValueKind(property.schema, valueTypesById) : undefined\n if (!property || !kind) {\n throw new OntologyValidationError(\n `[Sixb] Cannot look up '${path}' by value: getBy needs a property declared with unique: true.`\n )\n }\n\n if (value === null || value === undefined) {\n throw new OntologyValidationError(\n `[Sixb] Cannot look up '${path}' by ${String(value)}: no object holds a null or missing value.`\n )\n }\n\n validateSchemaValue(property.schema, value, path, valueTypesById)\n const key = uniqueValueKey(\n kind,\n normalizeSchemaValue(property.schema, value, path, valueTypesById)\n )\n if (key === null) {\n throw new OntologyValidationError(`[Sixb] Cannot look up '${path}' by this value.`)\n }\n return key\n}\n",
17
- "import { assertNever } from \"../assert-never\"\nimport { isRuntimeAllowed } from \"../authorization\"\nimport { AuthorizationError } from \"../authorization/errors\"\nimport type { EmbeddingModelCatalog, RerankingModelCatalog } from \"../models/catalog\"\nimport type { AuthorizedOntologyView } from \"../objects/authorized-ontology-view\"\nimport {\n attachRedactions,\n omitHiddenProperties,\n redactObjectRow,\n} from \"../objects/clearance-redaction\"\nimport { unreadableError } from \"../objects/property-clearance\"\nimport {\n countObjects,\n type ExecuteObjectCountInput,\n type ExecuteObjectCountResult,\n type ExecuteObjectExistsInput,\n type ExecuteObjectExistsResult,\n type ExecuteObjectFacetsInput,\n type ExecuteObjectFacetsResult,\n type ExecuteObjectQueryInput,\n type ExecuteObjectQueryLinksInput,\n type ExecuteObjectQueryLinksResult,\n type ExecuteObjectQueryResult,\n executeObjectQuery,\n executeObjectQueryLinks,\n existsObjects,\n facetObjects,\n} from \"../objects/query\"\nimport { createClearanceQueryAdmission } from \"../objects/query/clearance-admission\"\nimport { ObjectQueryValidationError } from \"../objects/query/errors\"\nimport { type QueryExecutorOptions, validateObjectFacetRequests } from \"../objects/query/executor\"\nimport type { ObjectQuery, ObjectQueryPredicate } from \"../objects/query/ir\"\nimport { assertLinkQueryReadable } from \"../objects/query/link-query-clearance\"\nimport { preflightObjectQueryLinks } from \"../objects/query/links\"\nimport { normalizeObjectQuery } from \"../objects/query/normalize\"\nimport { userExpansionPlan } from \"../objects/query/user-expansions\"\nimport {\n type AdmittedObjectQuery,\n composeObjectQueryAdmissions,\n type ObjectQuerySemanticAdmission,\n validateObjectQuery,\n validateObjectQueryWithAdmission,\n} from \"../objects/query/validate\"\nimport {\n admitTelemetryHistoryReadWorkload,\n type TelemetryHistoryReadAdmission,\n type TelemetryHistoryReadWorkloadInput,\n} from \"../objects/telemetry/workload\"\nimport type { OntologyRegistry } from \"../ontology\"\nimport type { AppliedMarkings } from \"../security/applied-markings\"\nimport type {\n AuthUserStore,\n LinkBatchKey,\n ObjectFacetRequest,\n ObjectLinkRow,\n ObjectReadStorage,\n ObjectRow,\n ObjectStorage,\n} from \"../storage\"\nimport { assertObjectReadOutputWithinLimit, MAX_OBJECT_READ_FACETS } from \"../storage\"\nimport { captureExecutionScope, resolveExecutionScopeAuthorization } from \"./authorization\"\nimport type { Clearance, EventSources } from \"./object-reader-clearance\"\nimport { ObjectReaderOntology } from \"./object-reader-ontology\"\nimport { ObjectReaderSecurity } from \"./object-reader-security\"\nimport { attachUserProfiles } from \"./object-reader-users\"\nimport type { ExecutionScope } from \"./types\"\nimport { uniqueLookupKey } from \"./unique-lookup\"\n\ntype GetObjectInput = Omit<Parameters<ObjectReadStorage[\"getByPrimaryId\"]>[0], \"projectId\">\ntype GetObjectsInput = Omit<Parameters<ObjectReadStorage[\"getByPrimaryIdBatch\"]>[0], \"projectId\">\n/** A caller's value, validated and keyed against the property's schema. */\ninterface GetByUniqueValueInput {\n readonly objectTypeId: string\n readonly propertyId: string\n readonly value: unknown\n}\ntype SelectObjectPropertiesInput = Parameters<ObjectReadStorage[\"selectsObjectProperties\"]>[0]\ntype CanReadObjectPropertyInput = SelectObjectPropertiesInput[\"items\"][number]\ntype CanReadObjectPropertiesBatchInput = Omit<SelectObjectPropertiesInput, \"projectId\">\ntype ListObjectsInput = Omit<Parameters<ObjectReadStorage[\"list\"]>[0], \"projectId\">\ntype ListLinksInput = Omit<Parameters<ObjectReadStorage[\"listLinks\"]>[0], \"projectId\">\ntype ListLinksBatchInput = Omit<Parameters<ObjectReadStorage[\"listLinksBatch\"]>[0], \"projectId\">\n\n/** The model catalogs semantic and reranked search use. */\ninterface ObjectReaderModels {\n readonly embedding?: EmbeddingModelCatalog\n readonly reranking?: RerankingModelCatalog\n}\n\nconst readerConstructionKey = Object.freeze({})\n\n/**\n * Core-owned object read boundary for one exact execution authority.\n *\n * The implementation class is intentionally private to this module. Its private fields make the\n * exported instance type nominal, while the construction key prevents code that discovers the\n * JavaScript constructor through an instance from manufacturing another reader.\n *\n * Its state is grouped as a project is: the ontology it resolves against, the security of the\n * authority (its delegation and clearance included), the model catalogs search uses, and the\n * storage it reads, with the member directory that expanded user properties resolve against.\n * Each group decides what belongs to it; the reader composes them.\n */\nclass AuthorizedObjectReaderImpl {\n readonly #ontology: ObjectReaderOntology\n readonly #security: ObjectReaderSecurity\n readonly #models: ObjectReaderModels\n readonly #storage: ObjectReadStorage\n readonly #users: AuthUserStore | undefined\n\n constructor(\n key: typeof readerConstructionKey,\n input: {\n readonly ontology: ObjectReaderOntology\n readonly security: ObjectReaderSecurity\n readonly models: ObjectReaderModels\n readonly storage: ObjectReadStorage\n readonly users?: AuthUserStore\n }\n ) {\n if (key !== readerConstructionKey) {\n throw new Error(\"[Sixb] AuthorizedObjectReader can only be created by Core.\")\n }\n this.#ontology = input.ontology\n this.#security = input.security\n this.#models = input.models\n this.#storage = input.storage\n this.#users = input.users\n }\n\n static assertBound(reader: AuthorizedObjectReaderImpl, scope: ExecutionScope): void {\n const capturedScope = captureExecutionScope(scope)\n resolveExecutionScopeAuthorization(reader.#security.runtime.projectId, capturedScope)\n if (capturedScope.authorization !== reader.#security.authorization) {\n throw new Error(\n \"[Sixb] AuthorizedObjectReader is not bound to this exact execution authority.\"\n )\n }\n }\n\n /** Readers of other storages, through the same authority, under the clearance it holds now. */\n static async readingFrom(\n reader: AuthorizedObjectReaderImpl\n ): Promise<(objects: ObjectStorage) => AuthorizedObjectReaderImpl> {\n const security = reader.#security.withClearance(await reader.#security.clearance.pinned())\n const ontology = new ObjectReaderOntology(reader.#ontology.registry, security)\n\n return (objects) => {\n const rebound = new AuthorizedObjectReaderImpl(readerConstructionKey, {\n ontology,\n security,\n models: reader.#models,\n storage: objectStorageForAuthority(security, objects),\n ...(reader.#users === undefined ? {} : { users: reader.#users }),\n })\n\n Object.freeze(rebound)\n return rebound\n }\n }\n\n /** What the reader cannot read now, for surfaces such as events that redact on their own. */\n static async clearance(reader: AuthorizedObjectReaderImpl): Promise<Clearance> {\n return reader.#security.clearance.current()\n }\n\n /** What the reader cannot read in an object event. */\n static eventClearance(\n reader: AuthorizedObjectReaderImpl,\n sources: EventSources\n ): Clearance | Promise<Clearance> {\n return reader.#security.clearance.forEvent(sources)\n }\n\n /** The conditions the reader views object types through, by concrete type. */\n static viewConditions(\n reader: AuthorizedObjectReaderImpl\n ): ReadonlyMap<string, ReaderViewCondition> {\n const security = reader.#security\n const conditions = security.conditionalScope?.conditions ?? []\n\n return new Map(\n conditions.map(({ objectTypeId, predicate }) => [\n objectTypeId,\n {\n predicate,\n hiddenBy: (clearance: Clearance) =>\n !security.isObjectTypeViewable(objectTypeId, clearance),\n },\n ])\n )\n }\n\n static ontologyView(reader: AuthorizedObjectReaderImpl): AuthorizedOntologyView {\n return reader.#ontology.view()\n }\n\n /** Project identity carried by this nominal reader capability. */\n get projectId(): string {\n return this.#security.runtime.projectId\n }\n\n async getByPrimaryId(input: GetObjectInput): ReturnType<ObjectReadStorage[\"getByPrimaryId\"]> {\n const request = snapshotReadValue({\n objectTypeId: input.objectTypeId,\n primaryId: input.primaryId,\n })\n const clearance = await this.#security.clearance.current()\n this.#security.assertObjectTypesViewable([request.objectTypeId], clearance)\n const row = await this.#storage.getByPrimaryId({\n ...request,\n projectId: this.#security.runtime.projectId,\n })\n return this.#detachRows(\n row && this.#omitHidden(row, clearance),\n (detached) => [detached],\n clearance\n )\n }\n\n /**\n * The object of exactly `objectTypeId` holding a unique property's value, or null. A lookup by a\n * marked property would reveal its value, so it needs the clearance a query predicate needs.\n */\n async getByUniqueValue(input: GetByUniqueValueInput): Promise<ObjectRow | null> {\n const request = snapshotReadValue({\n objectTypeId: input.objectTypeId,\n propertyId: input.propertyId,\n value: input.value,\n })\n const clearance = await this.#security.clearance.current()\n this.#security.assertObjectTypesViewable([request.objectTypeId], clearance)\n\n const valueKey = uniqueLookupKey(this.#ontology.registry, request)\n const marking = clearance?.missingMarking(request.objectTypeId, request.propertyId)\n if (marking !== undefined) {\n throw new AuthorizationError(\n `clearance:marking:${marking}`,\n `[Sixb] Cannot look up '${request.objectTypeId}.${request.propertyId}' by value: it requires clearance for marking '${marking}'.`\n )\n }\n\n const row = await this.#storage.getByUniqueValue({\n objectTypeId: request.objectTypeId,\n propertyId: request.propertyId,\n valueKey,\n projectId: this.#security.runtime.projectId,\n })\n return this.#detachRows(\n row && this.#omitHidden(row, clearance),\n (detached) => [detached],\n clearance\n )\n }\n\n async getByPrimaryIdBatch(\n input: GetObjectsInput\n ): ReturnType<ObjectReadStorage[\"getByPrimaryIdBatch\"]> {\n const request = snapshotReadValue({\n items: input.items.map((item) => ({\n objectTypeId: item.objectTypeId,\n primaryId: item.primaryId,\n })),\n })\n const clearance = await this.#security.clearance.current()\n this.#security.assertObjectTypesViewable(\n request.items.map((item) => item.objectTypeId),\n clearance\n )\n const rows = await this.#storage.getByPrimaryIdBatch({\n ...request,\n projectId: this.#security.runtime.projectId,\n })\n return this.#detachRows(\n new Map([...rows].map(([key, row]) => [key, this.#omitHidden(row, clearance)] as const)),\n (detached) => detached.values(),\n clearance\n )\n }\n\n async canReadObjectProperty(input: CanReadObjectPropertyInput): Promise<boolean> {\n const request = snapshotReadValue({\n objectTypeId: input.objectTypeId,\n primaryId: input.primaryId,\n propertyId: input.propertyId,\n })\n const clearance = await this.#security.clearance.current()\n this.#security.assertObjectTypesViewable([request.objectTypeId], clearance)\n\n if (hidesProperty(request, clearance)) return false\n const [selected] = await this.#selectsObjectProperties([request])\n return selected ?? false\n }\n\n async canReadObjectPropertiesBatch(\n input: CanReadObjectPropertiesBatchInput\n ): Promise<readonly boolean[]> {\n const request = snapshotReadValue({\n items: input.items.map((item) => ({\n objectTypeId: item.objectTypeId,\n primaryId: item.primaryId,\n propertyId: item.propertyId,\n })),\n })\n const clearance = await this.#security.clearance.current()\n this.#security.assertObjectTypesViewable(\n request.items.map((item) => item.objectTypeId),\n clearance\n )\n const selected = await this.#selectsObjectProperties(request.items)\n return request.items.map(\n (item, index) => !hidesProperty(item, clearance) && selected[index] === true\n )\n }\n\n async list(input: ListObjectsInput): ReturnType<ObjectReadStorage[\"list\"]> {\n const request = snapshotReadValue({\n objectTypeId:\n typeof input.objectTypeId === \"string\"\n ? input.objectTypeId\n : input.objectTypeId === undefined\n ? undefined\n : [...input.objectTypeId],\n primaryIdPrefix: input.primaryIdPrefix,\n primaryIdSuffix: input.primaryIdSuffix,\n updatedAfter: input.updatedAfter,\n updatedBefore: input.updatedBefore,\n createdAfter: input.createdAfter,\n createdBefore: input.createdBefore,\n limit: input.limit,\n offset: input.offset,\n orderBy: input.orderBy,\n order: input.order,\n })\n const clearance = await this.#security.clearance.current()\n const objectTypeId = this.#resolveListObjectTypes(request.objectTypeId, clearance)\n\n // An empty type selection means \"none\", never \"all\". Short-circuiting here prevents a\n // provider with different empty-array semantics from turning a principal read into a broad one.\n if (Array.isArray(objectTypeId) && objectTypeId.length === 0) {\n return { objects: [], hasMore: false, total: 0 }\n }\n\n const page = await this.#storage.list({\n ...request,\n ...(objectTypeId === undefined ? {} : { objectTypeId }),\n projectId: this.#security.runtime.projectId,\n })\n return this.#detachRows(\n { ...page, objects: page.objects.map((row) => this.#omitHidden(row, clearance)) },\n (detached) => detached.objects,\n clearance\n )\n }\n\n async listLinks(input: ListLinksInput): ReturnType<ObjectReadStorage[\"listLinks\"]> {\n const request = snapshotReadValue({\n objectTypeId: input.objectTypeId,\n objectId: input.objectId,\n linkId: input.linkId,\n direction: input.direction,\n })\n const clearance = await this.#security.clearance.current()\n this.#security.assertObjectTypesViewable([request.objectTypeId], clearance)\n const links = detachReadResult(\n await this.#storage.listLinks({\n ...request,\n projectId: this.#security.runtime.projectId,\n })\n )\n return links.filter((link) => this.#security.isLinkViewable(link, clearance))\n }\n\n async listLinksBatch(\n input: ListLinksBatchInput\n ): ReturnType<ObjectReadStorage[\"listLinksBatch\"]> {\n const request = snapshotReadValue({\n direction: input.direction,\n items: input.items.map((item) => ({\n objectTypeId: item.objectTypeId,\n objectId: item.objectId,\n linkId: item.linkId,\n })),\n })\n const clearance = await this.#security.clearance.current()\n this.#security.assertObjectTypesViewable(\n request.items.map((item) => item.objectTypeId),\n clearance\n )\n const pages = detachReadResult(\n await this.#storage.listLinksBatch({\n ...request,\n projectId: this.#security.runtime.projectId,\n })\n )\n const filtered = new Map<LinkBatchKey, ObjectLinkRow[]>()\n for (const [key, links] of pages) {\n filtered.set(\n key,\n links.filter((link) => this.#security.isLinkViewable(link, clearance))\n )\n }\n return filtered\n }\n\n async executeQuery(\n input: Omit<ExecuteObjectQueryInput, \"projectId\">\n ): Promise<ExecuteObjectQueryResult> {\n const query = snapshotAuthoredQuery(input.query)\n const includeTotal = snapshotReadValue(input.includeTotal)\n const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query\n const clearance = await this.#security.clearance.current()\n const result = await executeObjectQuery(\n {\n query: executionQuery,\n ...(includeTotal === undefined ? {} : { includeTotal }),\n projectId: this.#security.runtime.projectId,\n signal: input.signal,\n },\n this.#queryExecutorOptions(clearance)\n )\n const detached = this.#detachRows(\n { ...result, objects: result.objects.map((row) => this.#omitHidden(row, clearance)) },\n (detached) => detached.objects,\n clearance\n )\n\n await this.#attachUsers(detached.objects, query)\n return detached\n }\n\n async queryLinks(\n input: Omit<ExecuteObjectQueryLinksInput, \"projectId\">\n ): Promise<ExecuteObjectQueryLinksResult> {\n const query = snapshotAuthoredQuery(input.query)\n const request = snapshotReadValue({\n direction: input.direction,\n linkId: input.linkId,\n includeObjects: input.includeObjects,\n pageSize: input.pageSize,\n pageToken: input.pageToken,\n })\n let executionQuery = query\n const admission = this.#security.delegation?.queryAdmission\n if (admission) {\n const preflight = preflightObjectQueryLinks(\n { query, ...request, projectId: this.#security.runtime.projectId },\n { ontology: this.#ontology.registry }\n )\n const admitted = validateObjectQueryWithAdmission(\n preflight.validated.query,\n { ontology: this.#ontology.registry, normalize: false },\n admission\n )\n admission.assertIncidentEdgeSelected({\n state: admitted.admissionState,\n ...(preflight.linkId === undefined ? {} : { linkId: preflight.linkId }),\n direction: preflight.direction,\n path: \"$.linkId\",\n })\n executionQuery = admitted.query\n }\n\n const clearance = await this.#security.clearance.current()\n if (clearance) {\n assertLinkQueryReadable({\n ontology: this.#ontology.registry,\n clearance,\n query,\n request: { ...request, projectId: this.#security.runtime.projectId },\n viewableByGrants: (objectTypeId) =>\n this.#security.isObjectTypeViewable(objectTypeId, undefined),\n })\n }\n\n const result = detachReadResult(\n await executeObjectQueryLinks(\n { query: executionQuery, ...request, projectId: this.#security.runtime.projectId },\n this.#queryExecutorOptions(clearance)\n )\n )\n\n // Link pagination is computed by the provider-facing executor. Filtering afterward would make\n // its cursor and hasMore metadata describe hidden rows, so a provider contract violation must\n // fail closed instead of returning a partially filtered page.\n if (\n result.objects.some(\n (row) => !this.#security.isObjectTypeViewable(row.objectTypeId, clearance)\n ) ||\n result.links.some((link) => !this.#security.isLinkViewable(link, clearance))\n ) {\n throw new Error(\"[Sixb] Object storage returned a link page outside its authorized scope.\")\n }\n\n return {\n ...result,\n objects: result.objects.map((row) => (clearance ? redactObjectRow(row, clearance) : row)),\n }\n }\n\n async count(\n input: Omit<ExecuteObjectCountInput, \"projectId\">\n ): Promise<ExecuteObjectCountResult> {\n const query = snapshotAuthoredQuery(input.query)\n const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query\n const clearance = await this.#security.clearance.current()\n return detachReadResult(\n await countObjects(\n { query: executionQuery, projectId: this.#security.runtime.projectId },\n this.#queryExecutorOptions(clearance)\n )\n )\n }\n\n async exists(\n input: Omit<ExecuteObjectExistsInput, \"projectId\">\n ): Promise<ExecuteObjectExistsResult> {\n const query = snapshotAuthoredQuery(input.query)\n const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query\n const clearance = await this.#security.clearance.current()\n return detachReadResult(\n await existsObjects(\n { query: executionQuery, projectId: this.#security.runtime.projectId },\n this.#queryExecutorOptions(clearance)\n )\n )\n }\n\n async facet(\n input: Omit<ExecuteObjectFacetsInput, \"projectId\">\n ): Promise<ExecuteObjectFacetsResult> {\n const query = snapshotAuthoredQuery(input.query)\n const facets = snapshotFacetRequests(input.facets)\n let executionQuery = query\n let executionFacets = facets\n const admission = this.#security.delegation?.queryAdmission\n if (admission) {\n // Terminal arguments are ordinary validation errors, not an authorization oracle. Validate\n // them against the canonical result shape before raising any delegated-scope denial.\n const validated = validateObjectQuery(query, { ontology: this.#ontology.registry })\n const normalizedFacets = validateObjectFacetRequests(facets, validated.result.objectTypeIds, {\n ontology: this.#ontology.registry,\n })\n const admitted = validateObjectQueryWithAdmission(\n validated.query,\n { ontology: this.#ontology.registry, normalize: false },\n admission\n )\n normalizedFacets.forEach((facet, index) => {\n admission.assertPropertySelected({\n state: admitted.admissionState,\n propertyId: facet.propertyId,\n use: \"facet\",\n path: `$.facets[${index}].propertyId`,\n })\n })\n executionQuery = admitted.query\n executionFacets = normalizedFacets\n }\n const clearance = await this.#security.clearance.current()\n return detachReadResult(\n await facetObjects(\n {\n query: executionQuery,\n facets: executionFacets,\n projectId: this.#security.runtime.projectId,\n },\n this.#queryExecutorOptions(clearance)\n )\n )\n }\n\n /**\n * Redact the rows a write of this object type returns. An upsert returns the merged effective\n * row, which may hold marked values the writer never sent and cannot read. Resolved before the\n * write, which it refuses when the writer cannot read the type at all.\n */\n async writtenRowRedactor(\n objectTypeId: string\n ): Promise<<TRow extends ObjectRow>(row: TRow) => TRow> {\n const clearance = await this.#security.clearance.current()\n assertTargetsReadable(clearance, { objectTypeIds: [objectTypeId] })\n return (row) => (clearance ? redactObjectRow(row, clearance) : row)\n }\n\n /**\n * The check a direct write runs on each object's properties before its commit claims them. It\n * refuses a value for a unique property this authority cannot read: whether the write is refused\n * as taken would reveal which values objects hold, as a `getBy` would.\n */\n async uniqueValueWriteCheck(\n objectTypeId: string\n ): Promise<(properties: Readonly<Record<string, unknown>>) => void> {\n const clearance = await this.#security.clearance.current()\n const marked = this.#ontology.registry\n .listUniqueProperties(objectTypeId)\n .flatMap((property) => {\n const marking = clearance?.missingMarking(objectTypeId, property.propertyId)\n return marking === undefined ? [] : [{ propertyId: property.propertyId, marking }]\n })\n\n return (properties) => {\n for (const { propertyId, marking } of marked) {\n if (properties[propertyId] === undefined || properties[propertyId] === null) continue\n\n throw new AuthorizationError(\n `clearance:marking:${marking}`,\n `[Sixb] Cannot write a value to '${objectTypeId}.${propertyId}': it is unique and requires clearance for marking '${marking}'.`\n )\n }\n }\n }\n\n /**\n * Refuse a write or a request that names an object type or link this authority cannot read,\n * before any lookup: it would answer whether what it names exists, and land where the reader\n * cannot see.\n */\n async assertReadable(targets: ReadTargets): Promise<void> {\n assertTargetsReadable(await this.#security.clearance.current(), targets)\n }\n\n /**\n * Whether this reader sees only the objects of a type that a condition matches. A write or a\n * request that names such an object finds it through this reader first: one it cannot find is\n * hidden or missing, and both answer alike.\n */\n viewsThroughCondition(objectTypeId: string): boolean {\n return this.#security.viewsThroughCondition(objectTypeId)\n }\n\n /** Refuse a type this reader views neither whole nor through a condition. */\n async assertViewable(objectTypeIds: readonly string[]): Promise<void> {\n const clearance = await this.#security.clearance.current()\n this.#security.assertObjectTypesViewable(objectTypeIds, clearance)\n }\n\n /** Enforce the delegated response budget without exposing or recombining its limits. */\n assertVisibleOutputWithinLimit(value: unknown): void {\n if (this.#security.authority.type !== \"delegated\") return\n assertObjectReadOutputWithinLimit(value, this.#security.authority.objectRead.limits)\n }\n\n /** Admit adjacent telemetry work without exposing which authority policy was selected. */\n admitTelemetryHistoryRead(\n input: TelemetryHistoryReadWorkloadInput\n ): TelemetryHistoryReadAdmission {\n return admitTelemetryHistoryReadWorkload(input, this.#security.authority.type === \"delegated\")\n }\n\n #queryExecutorOptions(clearance: Clearance) {\n const admission = this.#executorAdmission(clearance)\n\n if (this.#security.authority.type === \"delegated\") {\n // The selected storage instance is the private execution capability. Passing the delegated\n // runtime token into the generic executor would either reject this admitted query or tempt a\n // forgeable bypass flag; neither is needed at this nominal boundary.\n return {\n ontology: this.#ontology.registry,\n storage: this.#storage,\n embeddingModels: this.#models.embedding,\n rerankingModels: this.#models.reranking,\n ...(admission === undefined ? {} : { admission }),\n requestingUser: this.#security.requestingUser,\n }\n }\n return {\n ontology: this.#ontology.registry,\n embeddingModels: this.#models.embedding,\n rerankingModels: this.#models.reranking,\n storage: this.#storage,\n ...this.#queryAuthorization(clearance),\n ...(admission === undefined ? {} : { admission }),\n requestingUser: this.#security.requestingUser,\n }\n }\n\n /**\n * A principal's queries read the types this reader's security grants, including those its\n * storage reads through a condition, which no view grant holds.\n */\n #queryAuthorization(\n clearance: Clearance\n ): Pick<QueryExecutorOptions, \"readableObjectTypes\" | \"runtimeAuthorization\"> {\n const runtimeAuthorization = this.#security.runtime.runtimeAuthorization\n if (this.#security.authority.type !== \"principal\") return { runtimeAuthorization }\n\n const security = this.#security\n return {\n runtimeAuthorization,\n readableObjectTypes: Object.freeze({\n assert: (objectTypeIds: readonly string[]) =>\n security.assertObjectTypesGranted(objectTypeIds, clearance),\n has: (objectTypeId: string) => security.isObjectTypeGranted(objectTypeId, clearance),\n }),\n }\n }\n\n /**\n * The executor validates the query it runs, and that validation resolves default text fields.\n * Every admission that narrows those fields must therefore apply there, not only beforehand.\n */\n #executorAdmission(clearance: Clearance): ObjectQuerySemanticAdmission | undefined {\n const admission = clearance && createClearanceQueryAdmission(clearance)\n const selected = this.#security.delegation?.queryAdmission\n\n if (selected && admission) return composeObjectQueryAdmissions(selected, admission)\n return selected ?? admission\n }\n\n /**\n * Resolve the user properties the query expands on rows already detached and redacted. Only an\n * authority that may view the directory reads profiles; a delegated one never does.\n */\n async #attachUsers(rows: readonly ObjectRow[], query: ObjectQuery): Promise<void> {\n const plan = userExpansionPlan(normalizeObjectQuery(query))\n if (!plan) return\n\n await attachUserProfiles({\n rows,\n plan,\n ontology: this.#ontology.registry,\n projectId: this.#security.runtime.projectId,\n canViewUsers: isRuntimeAllowed(this.#security.runtime, { kind: \"users.view\" }),\n users: this.#users,\n })\n }\n\n /**\n * Whether the reader's storage selects each property of its object. A delegated reader selects\n * what its share does. A principal reads a type it views through a condition object by object,\n * so a hidden object and a missing one both select nothing; it selects every other property.\n */\n async #selectsObjectProperties(\n items: readonly CanReadObjectPropertyInput[]\n ): Promise<readonly boolean[]> {\n const readsByObject = (item: CanReadObjectPropertyInput) =>\n this.#security.authority.type === \"delegated\" ||\n this.#security.viewsThroughCondition(item.objectTypeId)\n\n const checked = items.filter(readsByObject)\n const selected =\n checked.length === 0\n ? []\n : await this.#storage.selectsObjectProperties({\n projectId: this.#security.runtime.projectId,\n items: checked,\n })\n\n let next = 0\n return items.map((item) => !readsByObject(item) || selected[next++] === true)\n }\n\n #omitHidden<TRow extends ObjectRow>(row: TRow, clearance: Clearance): TRow {\n return clearance ? omitHiddenProperties(row, clearance) : row\n }\n\n /**\n * Detach a result whose rows went through {@link #omitHidden}, then list their redactions on\n * the copy. Each row is deep-copied once, and never with a hidden value.\n */\n #detachRows<TResult>(\n result: TResult,\n rows: (detached: TResult) => Iterable<ObjectRow | null>,\n clearance: Clearance\n ): TResult {\n const detached = detachReadResult(result)\n if (clearance) {\n for (const row of rows(detached)) if (row) attachRedactions(row, clearance)\n }\n\n return detached\n }\n\n #admitDelegatedQuery(query: ObjectQuery): AdmittedObjectQuery | undefined {\n const admission = this.#security.delegation?.queryAdmission\n if (!admission) return undefined\n return validateObjectQueryWithAdmission(query, { ontology: this.#ontology.registry }, admission)\n }\n\n #resolveListObjectTypes(\n requested: ListObjectsInput[\"objectTypeId\"],\n clearance: Clearance\n ): ListObjectsInput[\"objectTypeId\"] {\n if (requested !== undefined) {\n const objectTypeIds = typeof requested === \"string\" ? [requested] : [...new Set(requested)]\n for (const objectTypeId of objectTypeIds) {\n this.#ontology.registry.resolveObjectType(objectTypeId)\n }\n this.#security.assertObjectTypesViewable(objectTypeIds, clearance)\n return typeof requested === \"string\" ? requested : objectTypeIds\n }\n\n if (this.#security.authority.type === \"unrestricted\") return undefined\n return this.#ontology.registry\n .listObjectTypes()\n .map((objectType) => objectType.id)\n .filter((objectTypeId) => this.#security.isObjectTypeViewable(objectTypeId, clearance))\n }\n}\n\nObject.freeze(AuthorizedObjectReaderImpl.prototype)\nObject.freeze(AuthorizedObjectReaderImpl)\n\nexport type AuthorizedObjectReader = AuthorizedObjectReaderImpl\n\n/** Build the sole application-facing object reader for one registered execution scope. */\nexport function createAuthorizedObjectReader(input: {\n readonly scope: ExecutionScope\n readonly ontology: OntologyRegistry\n readonly embeddingModels?: EmbeddingModelCatalog\n readonly rerankingModels?: RerankingModelCatalog\n readonly objectStorage: ObjectStorage\n /** Markings of the dataset versions projections applied; the code's markings alone without. */\n readonly appliedMarkings?: AppliedMarkings\n /** The member directory expanded user properties resolve against. */\n readonly users?: AuthUserStore\n}): AuthorizedObjectReader {\n const scope = captureExecutionScope(input.scope)\n const projectId = scope.execution.projectId\n const authority = resolveExecutionScopeAuthorization(projectId, scope)\n const security = new ObjectReaderSecurity({\n authorization: scope.authorization,\n authority,\n projectId,\n ontology: input.ontology,\n ...(input.appliedMarkings === undefined ? {} : { appliedMarkings: input.appliedMarkings }),\n requestedBy: scope.execution.requestedBy,\n })\n const storage = objectStorageForAuthority(security, input.objectStorage)\n const reader = new AuthorizedObjectReaderImpl(readerConstructionKey, {\n ontology: new ObjectReaderOntology(input.ontology, security),\n security,\n models: Object.freeze({\n ...(input.embeddingModels === undefined ? {} : { embedding: input.embeddingModels }),\n ...(input.rerankingModels === undefined ? {} : { reranking: input.rerankingModels }),\n }),\n storage,\n ...(input.users === undefined ? {} : { users: input.users }),\n })\n Object.freeze(reader)\n return reader\n}\n\n/** Reject recombining an authorized reader with any other execution authority. */\nexport function assertAuthorizedObjectReaderBinding(input: {\n readonly reader: AuthorizedObjectReader\n readonly scope: ExecutionScope\n}): void {\n AuthorizedObjectReaderImpl.assertBound(input.reader, input.scope)\n}\n\n/**\n * The reader for a storage transaction's objects, so that a decision made inside it reads what\n * the transaction sees: the same authority and conditions, under the clearance it holds now.\n *\n * Resolving a clearance may read the project's storage, which a transaction's callback cannot, so\n * it is resolved here, before the transaction opens, and kept for every reader this returns.\n */\nexport function objectReadersIn(\n reader: AuthorizedObjectReader\n): Promise<(objects: ObjectStorage) => AuthorizedObjectReader> {\n return AuthorizedObjectReaderImpl.readingFrom(reader)\n}\n\n/** Return inert metadata projected from the exact authority already owned by the reader. */\nexport function getAuthorizedOntologyView(reader: AuthorizedObjectReader): AuthorizedOntologyView {\n return AuthorizedObjectReaderImpl.ontologyView(reader)\n}\n\n/**\n * What a reader resolved for this authority cannot read now. Events redact with it: an event of an\n * object type the reader cannot read is not delivered, and the others are redacted like rows.\n */\nexport function readerClearance(reader: AuthorizedObjectReader): Promise<Clearance> {\n return AuthorizedObjectReaderImpl.clearance(reader)\n}\n\n/**\n * What a reader cannot read in an object event: the current markings, with those of the versions\n * its values came from. A plain value for a reader those markings cannot affect, which reads no\n * version.\n */\nexport function readerEventClearance(\n reader: AuthorizedObjectReader,\n sources: EventSources\n): Clearance | Promise<Clearance> {\n return AuthorizedObjectReaderImpl.eventClearance(reader, sources)\n}\n\n/** A condition a reader views an object type through, for a surface that decides per object. */\nexport interface ReaderViewCondition {\n /** The condition, `currentUser()` bound, as the reader's storage reads it. */\n readonly predicate: ObjectQueryPredicate\n /**\n * Whether a clearance hides the type, or a property the condition reads: which objects match\n * would reveal it, so the reader reads no object of the type.\n */\n hiddenBy(clearance: Clearance): boolean\n}\n\n/**\n * The conditions a reader views object types through, by concrete type: empty for a reader that\n * views each type it reads whole. A type absent here is decided by its grants alone, which deny a\n * type viewed only under a condition. Events match the state they carry against these, and read\n * through the reader what they cannot decide from it.\n */\nexport function readerViewConditions(\n reader: AuthorizedObjectReader\n): ReadonlyMap<string, ReaderViewCondition> {\n return AuthorizedObjectReaderImpl.viewConditions(reader)\n}\n\n/** What a write or a request names: object types, and links by their source type. */\ninterface ReadTargets {\n readonly objectTypeIds: readonly string[]\n readonly links?: readonly { readonly objectTypeId: string; readonly linkId: string }[]\n}\n\nfunction assertTargetsReadable(clearance: Clearance, targets: ReadTargets): void {\n if (!clearance) return\n\n for (const objectTypeId of targets.objectTypeIds) {\n const unreadable = clearance.unreadableType(objectTypeId)\n if (unreadable) throw unreadableError(unreadable)\n }\n\n for (const link of targets.links ?? []) {\n const unreadable = clearance.unreadableLink(link.objectTypeId, link.linkId)\n if (unreadable) throw unreadableError(unreadable)\n }\n}\n\nfunction hidesProperty(\n item: { readonly objectTypeId: string; readonly propertyId: string },\n clearance: Clearance\n): boolean {\n return clearance?.missingMarking(item.objectTypeId, item.propertyId) !== undefined\n}\n\nfunction objectStorageForAuthority(\n security: ObjectReaderSecurity,\n objectStorage: ObjectStorage\n): ObjectReadStorage {\n const authority = security.authority\n\n switch (authority.type) {\n case \"principal\":\n return security.conditionalScope\n ? objectStorage.createConditionalReadScope({\n projectId: authority.projectId,\n scope: security.conditionalScope,\n })\n : objectStorage\n case \"unrestricted\":\n return objectStorage\n case \"delegated\":\n return objectStorage.createSelectedReadScope({\n projectId: authority.projectId,\n scope: authority.objectRead.scope,\n limits: authority.objectRead.limits,\n })\n default:\n return assertNever(\n authority,\n `[Sixb] Unsupported object reader authority '${String((authority as { type?: unknown }).type)}'.`\n )\n }\n}\n\n/**\n * Storage providers may optimize trusted reads with live references. Values crossing the\n * application-facing authorization boundary must not retain them.\n */\nfunction detachReadResult<T>(value: T): T {\n return detachReadValue(value) as T\n}\n\n/**\n * Results are plain objects, arrays, dates and primitives, which a direct copy handles several\n * times faster than structuredClone; anything else falls back to it. On a page of rows this copy\n * is the largest cost of a query after the read itself.\n */\nfunction detachReadValue(value: unknown): unknown {\n if (typeof value !== \"object\" || value === null) return value\n if (Array.isArray(value)) return value.map(detachReadValue)\n if (value instanceof Date) return new Date(value.getTime())\n if (Object.getPrototypeOf(value) !== Object.prototype) return structuredClone(value)\n\n const copy: Record<string, unknown> = {}\n for (const key of Object.keys(value)) {\n const item = detachReadValue((value as Record<string, unknown>)[key])\n // Parsed JSON can hold an own \"__proto__\" key, which assignment would turn into a prototype.\n if (key === \"__proto__\") {\n Object.defineProperty(copy, key, {\n value: item,\n enumerable: true,\n writable: true,\n configurable: true,\n })\n } else copy[key] = item\n }\n return copy\n}\n\n/** Capture caller-owned values before authorization and execution. */\nfunction snapshotReadValue<T>(value: T): T {\n return structuredClone(value)\n}\n\n/** Bound and capture facet arguments before reading any caller-owned element. */\nfunction snapshotFacetRequests(facets: readonly ObjectFacetRequest[]): ObjectFacetRequest[] {\n if (!Array.isArray(facets)) {\n throw new ObjectQueryValidationError([\n {\n path: \"$.facets\",\n code: \"invalid_facets\",\n message: \"facets must be an array\",\n },\n ])\n }\n const length = facets.length\n if (!Number.isSafeInteger(length) || length > MAX_OBJECT_READ_FACETS) {\n throw new ObjectQueryValidationError([\n {\n path: \"$.facets\",\n code: \"too_many_facets\",\n message: `facets must include at most ${MAX_OBJECT_READ_FACETS} facet requests`,\n },\n ])\n }\n\n const snapshot: ObjectFacetRequest[] = []\n for (let index = 0; index < length; index += 1) {\n const facet = facets[index]\n snapshot.push({ propertyId: facet.propertyId, limit: facet.limit })\n }\n return snapshot\n}\n\n/** Capture one serializable query before either authorization or execution sees it. */\nfunction snapshotAuthoredQuery(query: ObjectQuery): ObjectQuery {\n try {\n const snapshot = structuredClone(query)\n const pending = [snapshot]\n const seen = new Set<ObjectQuery>()\n for (const node of pending) {\n if (seen.has(node)) continue\n seen.add(node)\n if (\n node.kind === \"vector\" &&\n (typeof node.vector !== \"string\" ||\n typeof node.profile !== \"string\" ||\n \"propertyId\" in node)\n ) {\n throw new ObjectQueryValidationError([\n {\n path: \"$\",\n code: \"invalid_vector_search_input\",\n message: \"Vector search requires a named profile and search text\",\n },\n ])\n }\n if (\"input\" in node) pending.push(node.input)\n if (node.kind === \"set\") pending.push(...node.inputs)\n }\n return snapshot\n } catch (error) {\n if (error instanceof ObjectQueryValidationError) throw error\n throw new ObjectQueryValidationError([\n {\n path: \"$\",\n code: \"query_not_cloneable\",\n message: \"Object query must contain only structured-cloneable data\",\n },\n ])\n }\n}\n"
18
- ],
19
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,WAAW,CAAC,QAAe,SAAwB;AAAA,EACjE,MAAM,IAAI,MAAM,OAAO;AAAA;;;ACGlB,SAAS,eAAuC,CACrD,KACA,WACM;AAAA,EACN,OAAO,UAAU,KAAK,WAAW,IAAI;AAAA;AAUhC,SAAS,oBAA4C,CAC1D,KACA,WACM;AAAA,EACN,OAAO,UAAU,KAAK,WAAW,KAAK;AAAA;AAOjC,SAAS,g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AA;AAIT,SAAS,qBAAqB,CAAC,OAAiC;AAAA,EAC9D,IAAI;AAAA,IACF,MAAM,WAAW,gBAAgB,KAAK;AAAA,IACtC,MAAM,UAAU,CAAC,QAAQ;AAAA,IACzB,MAAM,OAAO,IAAI;AAAA,IACjB,WAAW,QAAQ,SAAS;AAAA,MAC1B,IAAI,KAAK,IAAI,IAAI;AAAA,QAAG;AAAA,MACpB,KAAK,IAAI,IAAI;AAAA,MACb,IACE,KAAK,SAAS,aACb,OAAO,KAAK,WAAW,YACtB,OAAO,KAAK,YAAY,aACxB,gBAAgB,QAClB;AAAA,QACA,MAAM,IAAI,4BAA2B;AAAA,UACnC;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,UACX;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,IAAI,WAAW;AAAA,QAAM,QAAQ,KAAK,KAAK,KAAK;AAAA,MAC5C,IAAI,KAAK,SAAS;AAAA,QAAO,QAAQ,KAAK,GAAG,KAAK,MAAM;AAAA,IACtD;AAAA,IACA,OAAO;AAAA,IACP,OAAO,OAAO;AAAA,IACd,IAAI,iBAAiB;AAAA,MAA4B,MAAM;AAAA,IACvD,MAAM,IAAI,4BAA2B;AAAA,MACnC;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF,CAAC;AAAA;AAAA;",
20
- "debugId": "0E3DAEAC9E65D53164756E2164756E21",
21
- "names": []
22
- }
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/storage/agents/types.ts"],
4
- "sourcesContent": [
5
- "import type { ActionSubject } from \"../../actions/types\"\nimport type { AgentMessage, AgentMessagePart, AgentMessageRole } from \"../../agents/message\"\nimport type { AgentReasoning } from \"../../agents/types\"\nimport type { Principal, UserPrincipal } from \"../../auth\"\nimport type { FileRef } from \"../../blob-storage/types\"\nimport type { SixbErrorCode, SixbFailure } from \"../../errors/types\"\nimport type { JsonObject, JsonValue } from \"../../json\"\nimport type {\n LanguageModelRef,\n LanguageModelTier,\n LanguageModelTierProbabilities,\n} from \"../../models\"\nimport type { ActionRunFailure, ActionRunParams } from \"../action-runs/types\"\n\n// ── agent_threads — one conversation with an agent ──────────────────────────────────────────────\n\nexport type AgentThreadStatus = \"active\" | \"archived\"\n\n/** Immutable, non-secret application input. Never store resolved env or credentials here. */\nexport type AgentThreadSandboxParams = Readonly<Record<string, JsonValue>>\n\n/** Worker-owned state, independent from the immutable application binding. */\nexport interface AgentThreadSandboxState {\n /** Exact name passed to the provider. Replacements always receive a fresh name. */\n readonly name: string\n readonly status: \"new\" | \"busy\" | \"ready\" | \"blocked\" | \"unavailable\"\n readonly sourceFingerprint?: string\n readonly initialized: boolean\n /** Durable context boundary: local files from before this reset are no longer available. */\n readonly resetAt?: string\n /** Never expires automatically: a delayed provider operation must not reach a successor. */\n readonly owner?: { readonly runId: string; readonly executionToken: string }\n}\n\nexport type TransitionAgentThreadSandboxInput = {\n readonly projectId: string\n readonly id: string\n} & (\n | {\n readonly action: \"acquire\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly sourceFingerprint: string\n }\n | {\n readonly action: \"replace\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly nextName: string\n }\n | {\n readonly action: \"settle\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly status: \"ready\" | \"blocked\" | \"unavailable\"\n readonly initialized: boolean\n }\n | {\n readonly action: \"recreate\"\n readonly expectedSandboxName: string\n readonly name: string\n }\n)\n\n/**\n * A conversation, or the thread a sub-agent works in. A sub-agent's thread is never listed, and\n * whoever reads its conversation reads it.\n */\nexport type AgentThreadKind = \"conversation\" | \"subagent\"\n\n/** Where a sub-agent's thread comes from: its conversation, the turn that spawned it, and its key. */\nexport interface AgentThreadParent {\n readonly threadId: string\n /** The turn that spawned it. Its later runs work under the turns that go on with it. */\n readonly spawnedBy: string\n readonly key: string\n}\n\n/** The computer a thread runs on, and the folder there its turns work in. */\nexport interface AgentThreadComputer {\n /** The CLI's id for the computer: a thread's turns are claimed by that computer alone. */\n readonly id: string\n /** What its owner calls the computer, such as \"Anthony's MacBook Pro\". */\n readonly name: string\n /** The absolute path its turns work in, on that computer. */\n readonly folder: string\n}\n\n/** Where a thread runs: which of its owner's computers, and the folder there. */\nexport type AgentThreadPlace = Pick<AgentThreadComputer, \"id\" | \"folder\">\n\nexport interface AgentThreadRecord {\n readonly id: string\n readonly projectId: string\n readonly kind: AgentThreadKind\n /** Set exactly on a sub-agent's thread. */\n readonly parent?: AgentThreadParent\n /** Who owns/opened the thread. Reuses the canonical auth principal (gains `agent` later for free). */\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n readonly sandboxState?: AgentThreadSandboxState\n /**\n * Where its turns run: on its owner's computer, which claims them, or, when absent, in the cloud.\n * A computer's thread takes turns from its owner alone.\n */\n readonly runsOn?: \"computer\"\n /**\n * Where on its owner's computers a computer's thread runs: set when it is created, and when its\n * owner moves it. Only that computer, open in that folder, claims its turns. A computer's thread\n * created before folders were kept has none until its owner moves it.\n */\n readonly computer?: AgentThreadComputer\n /**\n * When its turns last moved to where they run now, from a computer to the cloud or between\n * folders: the files earlier turns worked on are not here.\n */\n readonly movedAt?: Date\n readonly status: AgentThreadStatus\n /** Single-flight anchor: the id of the one run currently allowed to write, or `null` when idle. */\n readonly activeRunId: string | null\n readonly lastMessageAt?: Date\n readonly messageCount: number\n readonly createdAt: Date\n readonly updatedAt: Date\n}\n\nexport interface CreateAgentThreadInput {\n readonly id: string\n readonly projectId: string\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n readonly runsOn?: \"computer\"\n /** Where a computer's thread runs: required with `runsOn: \"computer\"`, refused without it. */\n readonly computer?: AgentThreadComputer\n readonly status?: AgentThreadStatus\n readonly createdAt?: Date\n readonly updatedAt?: Date\n}\n\n/**\n * A new thread holding a copy of another thread's finished messages. A turn still running is left\n * behind: what came from its trigger message on is not copied. Copies keep their `seq`, content,\n * author and `runId`, and get new ids. Runs are not copied, so the fork's runs, usage and cost are\n * its own; copied answers still show their run's diagnostics.\n *\n * Only the latest checkpoint the copy can use comes along, so the markers of earlier compactions\n * are not in the fork. The fork has no `lastMessageAt` until its first new message, so it sorts\n * by its creation.\n */\nexport interface ForkAgentThreadInput {\n readonly projectId: string\n /** The thread whose history is copied. */\n readonly sourceThreadId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n /** Provider name of the fork's new sandbox; given exactly when `sandboxParams` is. */\n readonly sandboxName?: string\n /**\n * The source's shared artifacts, each id mapped to its copy's: the copied messages and summary\n * name the copies instead.\n */\n readonly artifactCopies?: Readonly<Record<string, string>>\n readonly createdAt?: Date\n}\n\n/** A conversation's sub-agent threads, oldest first. */\nexport interface ListAgentThreadChildrenInput {\n readonly projectId: string\n /** The conversation. */\n readonly parentThreadId: string\n /** Only those this turn spawned. */\n readonly parentRunId?: string\n /** At most this many, 100 by default. */\n readonly limit?: number\n readonly offset?: number\n}\n\n/** Conversations only: a sub-agent's thread is read through its conversation. */\nexport interface ListAgentThreadsInput {\n readonly projectId: string\n readonly statuses?: readonly AgentThreadStatus[]\n readonly ownerPrincipal?: Principal\n /** Only the threads this user takes part in. */\n readonly participantPrincipal?: UserPrincipal\n /** Only the threads that run on this computer, in this folder, with a turn active. */\n readonly activeOnComputer?: AgentThreadPlace\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentThreadsResult {\n readonly threads: readonly AgentThreadRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_thread_participants — the users a thread's owner added to it ─────────────────────────\n\nexport interface AgentThreadParticipantRecord {\n readonly projectId: string\n readonly threadId: string\n readonly principal: UserPrincipal\n readonly addedAt: Date\n readonly addedBy: Principal\n}\n\nexport interface AddAgentThreadParticipantsInput {\n readonly projectId: string\n readonly threadId: string\n /**\n * Distinct users, checked by the caller. Someone already taking part keeps when and by whom they\n * were first added.\n */\n readonly principals: readonly UserPrincipal[]\n readonly addedBy: Principal\n /** Refused with `participant_limit`, adding no one, when the thread would hold more. */\n readonly maxParticipants: number\n readonly addedAt?: Date\n}\n\nexport interface AssignAgentThreadComputerInput {\n readonly projectId: string\n readonly id: string\n /** Where the thread's turns run from now on. */\n readonly computer: AgentThreadComputer\n /** Its `movedAt` when this changes the computer or folder of a thread that had one. */\n readonly movedAt?: Date\n}\n\nexport interface MoveAgentThreadToCloudInput {\n readonly projectId: string\n readonly id: string\n readonly movedAt?: Date\n}\n\n/** A computer's thread, now in the cloud, and its queued turn, now the cloud's to run. */\nexport interface MoveAgentThreadToCloudResult {\n readonly thread: AgentThreadRecord\n readonly queued?: ConversationAgentRunRecord\n}\n\n/**\n * An open `sixb` on its owner's computer: while it is live, the threads that run on that computer\n * in its folder are reachable there. It ends when `sixb` closes, or lapses when it stops renewing.\n */\nexport interface AgentComputerSessionRecord {\n readonly projectId: string\n /** Chosen by the computer, once per open `sixb`; unique among its owner's sessions. */\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly computer: AgentThreadComputer\n readonly expiresAt: Date\n /** Its threads' background commands, as its latest renewal reported them. */\n readonly backgroundCommands?: readonly AgentComputerBackgroundCommand[]\n /** The commands someone asked to stop: each renewal hands back those still running. */\n readonly stopRequests?: readonly AgentBackgroundCommandRef[]\n}\n\n/** How many background commands a computer session reports, and keeps stop requests for. */\nexport const AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX = 64\n\n/**\n * A background command an open `sixb` runs for one of its threads, which outlives the turn that\n * started it: the web shows how it stands between turns.\n */\nexport interface AgentComputerBackgroundCommand {\n readonly threadId: string\n /** `bg_<hex>`, as the agent's tools name it. */\n readonly id: string\n readonly command: string\n readonly status: \"running\" | \"exited\" | \"stopped\"\n readonly exitCode?: number\n /** ISO timestamps. */\n readonly startedAt: string\n readonly endedAt?: string\n}\n\n/** A background command by its start: its id comes again once `sixb` restarts. */\nexport interface AgentBackgroundCommandRef {\n readonly threadId: string\n readonly id: string\n readonly startedAt: string\n}\n\nexport interface RemoveAgentThreadParticipantInput {\n readonly projectId: string\n readonly threadId: string\n readonly principal: UserPrincipal\n}\n\nexport interface ListAgentThreadParticipantsInput {\n readonly projectId: string\n readonly threadIds: readonly string[]\n}\n\n// ── agent_runs — one loop execution (the worker job; attribution + fencing) ───────────────────\n\n/** Lifecycle shared by every durable agent execution, conversational or workflow-owned. */\nexport type AgentExecutionStatus = \"queued\" | \"running\" | \"succeeded\" | \"failed\" | \"cancelled\"\n\nexport type AgentRunStatus = AgentExecutionStatus\nexport type AgentRunKind = \"conversation\" | \"subagent\"\n\n/** Error codes an agent execution can persist and expose through its public contract. */\nexport const AGENT_RUN_FAILURE_CODES = [\n \"internal.unexpected\",\n \"runtime.cancelled\",\n \"agent.context_limit_exceeded\",\n \"agent.execution_failed\",\n \"agent.step_limit_reached\",\n \"ai.usage_limit_exceeded\",\n \"ai.usage_limit_unavailable\",\n] as const satisfies readonly [SixbErrorCode, ...SixbErrorCode[]]\n\nexport type AgentRunFailureCode = (typeof AGENT_RUN_FAILURE_CODES)[number]\n\n/**\n * Why a run ended — Sixb's provider-independent vocabulary. It includes model-loop reasons plus\n * platform-level endings such as `timeout`, `interrupted` for a turn whose worker died before\n * finishing it, `awaiting_approval` for a succeeded turn that paused on calls waiting for its\n * requester, or `awaiting_answer` for a succeeded sub-agent that paused on a question its parent\n * answers in a later turn, so reads remain typed and exhaustive. `other` and `unknown` preserve terminal state\n * when a provider adds a new reason.\n */\nexport const AGENT_RUN_FINISH_REASONS = [\n \"stop\",\n \"length\",\n \"content-filter\",\n \"tool-calls\",\n \"timeout\",\n \"interrupted\",\n \"awaiting_approval\",\n \"awaiting_answer\",\n \"error\",\n \"other\",\n \"unknown\",\n] as const\n\nexport type AgentRunFinishReason = (typeof AGENT_RUN_FINISH_REASONS)[number]\n\n/**\n * Coerce an external finish-reason string — a DB column or an SDK value — to {@link\n * AgentRunFinishReason}. An unrecognised value becomes `\"unknown\"` rather than being dropped.\n */\nexport function coerceAgentRunFinishReason(\n value: string | null | undefined\n): AgentRunFinishReason | undefined {\n if (value === null || value === undefined) {\n return undefined\n }\n return (AGENT_RUN_FINISH_REASONS as readonly string[]).includes(value)\n ? (value as AgentRunFinishReason)\n : \"unknown\"\n}\n\n/** Stable, user-facing diagnostics emitted by the platform while executing a run. */\nexport const AGENT_RUN_DIAGNOSTIC_CODES = [\"step_limit_reached\", \"output_limit_reached\"] as const\n\n/**\n * Closed on purpose, and the wire is closed with it.\n *\n * Sixb writes these codes and the generated client is what reads them, so an open union would only\n * be honest if the HTTP schema were open too — and that costs the OpenAPI enum, the client's\n * autocompletion, and the app's exhaustive `switch`. Sixb owns both ends, so a new code is a minor\n * version bump: cheap here, and a broken `switch` is better than a 500 from `z.enum`.\n */\nexport type AgentRunDiagnosticCode = (typeof AGENT_RUN_DIAGNOSTIC_CODES)[number]\nexport type AgentRunDiagnosticSeverity = \"warning\" | \"error\"\n\nexport interface AgentRunDiagnostic {\n readonly code: AgentRunDiagnosticCode\n readonly severity: AgentRunDiagnosticSeverity\n /** What the diagnostic is about: the turn as a whole. */\n readonly scope: \"run\"\n /** Sanitized, stable copy suitable for display to an end user. */\n readonly message: string\n}\n\n/**\n * Authorization state for the current queue delivery.\n *\n * `queueLeaseExpiresAt` is a persisted projection of `ClaimedQueueJob.leaseExpiresAt`, not an\n * independently managed run lease. It may only be extended from a successful queue lease renewal.\n */\nexport interface AgentRunExecution {\n readonly token: string\n readonly queueLeaseExpiresAt: Date\n}\n\ninterface AgentRunRecordBase {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly status: AgentRunStatus\n readonly modelId?: string\n /** Why the run ended (our own SDK-independent enum). */\n readonly finishReason?: AgentRunFinishReason\n /** Platform diagnostics are transcript annotations, never agent-authored message content. */\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n /** Portable failure snapshot when the run did not succeed. */\n readonly error?: SixbFailure<AgentRunFailureCode>\n /** Execution attempts: `0` while queued, `1` on first start, incremented on redelivery. */\n readonly attempt: number\n readonly execution?: AgentRunExecution\n /**\n * When someone asked a running run to stop. Its run token stops working at once, and its runner\n * learns of it at its next lease renewal if the broker's cancel never reached it.\n */\n readonly cancelRequestedAt?: Date\n readonly createdAt: Date\n readonly startedAt?: Date\n readonly completedAt?: Date\n}\n\nexport interface ConversationAgentRunRecord extends AgentRunRecordBase {\n readonly kind: \"conversation\"\n readonly threadId: string\n readonly triggerMessageId: string\n /** Immutable model selection captured at admission. Absent only on runs predating this field. */\n readonly spec?: ConversationAgentRunSpec\n}\n\n/** Immutable, serialisable model selection and requester settings for one conversational turn. */\nexport interface ConversationAgentRunSpec {\n readonly model: LanguageModelRef\n /** With tiers, the tier of the model the turn runs on. */\n readonly tier?: LanguageModelTier\n /**\n * How likely the decision model judged each tier, when Sixb picked the turn's model. Kept to\n * calibrate the thresholds the tier is picked from (`heavy` from 0.4, `light` from 0.8).\n */\n readonly tierProbabilities?: LanguageModelTierProbabilities\n readonly reasoning?: AgentReasoning\n /** Canonical IANA time zone of the requester. Absent uses the project time zone. */\n readonly timeZone?: string\n /** Canonical BCP 47 language of the requester. Absent uses the project locale. */\n readonly locale?: string\n /** What the turn may change without asking its requester. Absent on older runs: `auto`. */\n readonly approvalMode?: AgentApprovalMode\n /** Its thread's `runsOn` when it was asked for: a computer's turn never reaches the agent queue. */\n readonly runsOn?: \"computer\"\n}\n\n/** Immutable, serialisable child configuration captured before dispatch. */\nexport interface SubagentRunSpec {\n readonly model: LanguageModelRef\n /** With tiers, the tier of the model the child runs on. Absent on children admitted before it. */\n readonly tier?: LanguageModelTier\n readonly reasoning?: AgentReasoning\n /** Focused task supplied by the parent Agent. */\n readonly task: string\n /** At most this many steps per run, as its parent asked: the project's limit still applies. */\n readonly maxSteps?: number\n /** Project tools available when the child was admitted. Runtime tools are injected separately. */\n readonly toolNames: readonly string[]\n /** The parent turn's mode, copied when the child was admitted. Absent: `auto`. */\n readonly approvalMode?: AgentApprovalMode\n /** The parent turn's requester settings. Absent uses the project's. */\n readonly timeZone?: string\n readonly locale?: string\n /** Files the parent handed over, copied into the child's sandbox at these paths. */\n readonly files?: readonly SubagentRunFile[]\n}\n\n/** A file a parent and its child hand each other, stored once and copied into a sandbox. */\nexport interface SubagentRunFile {\n /** Relative, `/`-separated, without `.` or `..` segments. */\n readonly path: string\n readonly fileRef: FileRef\n}\n\n/** Durable child output returned to its parent by `wait`. */\nexport interface SubagentRunResult {\n /** Empty only for a child that paused on its held calls before it answered. */\n readonly text: string\n /** What the child wrote under `out/`, by path relative to it. */\n readonly files?: readonly SubagentRunFile[]\n /** Why none of what it wrote under `out/` came back, and what to do about it. */\n readonly filesError?: string\n /**\n * What its parent sent a paused child that it had not read: the run that continues it reads it\n * first.\n */\n readonly unread?: readonly { readonly id: string; readonly text: string }[]\n}\n\nexport interface SubagentRunRecord extends AgentRunRecordBase {\n readonly kind: \"subagent\"\n /** The child's own thread, which holds its task and its work. */\n readonly threadId: string\n /** The message of its thread that started the run. */\n readonly triggerMessageId: string\n /** The conversation turn the child runs under: its mode and cancellation. */\n readonly parentRunId: string\n /** Stable parent-selected key that makes repeated tool execution idempotent. */\n readonly spawnKey: string\n readonly spec: SubagentRunSpec\n readonly result?: SubagentRunResult\n}\n\nexport type AgentRunRecord = ConversationAgentRunRecord | SubagentRunRecord\n\nexport interface CreateAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly threadId: string\n readonly triggerMessageId: string\n readonly spec: ConversationAgentRunSpec\n readonly createdAt?: Date\n}\n\nexport interface CreateSubagentRunInput {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly parentRunId: string\n /** Current parent delivery token. New children are admitted only while that delivery owns it. */\n readonly parentExecutionToken: string\n readonly spawnKey: string\n readonly spec: SubagentRunSpec\n /**\n * The child's thread. Its first run creates it, owned by the conversation's owner; a later run\n * goes into it, and is refused while another run of the thread is active.\n */\n readonly thread: { readonly id: string; readonly create: boolean }\n /** The user message that starts the run, appended to the child's thread with the run's id. */\n readonly trigger: Pick<AppendAgentMessageInput, \"id\" | \"parts\" | \"metadata\">\n /** Internal safety bound enforced atomically across worker processes. */\n readonly maxActiveChildren: number\n readonly createdAt?: Date\n}\n\nexport interface StartAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly modelId?: string\n readonly execution: AgentRunExecution\n readonly startedAt?: Date\n /**\n * Start it only as a computer's turn, there and in that folder: one whose thread moved meanwhile\n * is refused with `invalid_state`, so it never starts where its thread no longer runs.\n */\n readonly onComputer?: AgentThreadPlace\n}\n\nexport interface FinishQueuedAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly status: \"failed\" | \"cancelled\"\n readonly error?: SixbFailure<AgentRunFailureCode>\n readonly completedAt?: Date\n}\n\nexport interface ReclaimAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly execution: AgentRunExecution\n /**\n * Take the run over only if the lease last recorded on it ran out by then, checked in the same\n * write: a renewal that lands first keeps it its runner's. Otherwise `invalid_state`.\n */\n readonly ifLapsedBy?: Date\n}\n\nexport interface ConfirmAgentRunExecutionOwnershipInput {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n /** Exact expiration returned by the queue claim or its latest successful renewal. */\n readonly queueLeaseExpiresAt: Date\n}\n\nexport interface RequestAgentRunCancelInput {\n readonly id: string\n readonly projectId: string\n readonly at?: Date\n}\n\nexport type FinishAgentRunInput =\n | {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n readonly status: \"succeeded\"\n readonly modelId?: string\n readonly finishReason?: AgentRunFinishReason\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n readonly result?: SubagentRunResult\n readonly completedAt?: Date\n }\n | {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n readonly status: \"failed\" | \"cancelled\"\n readonly modelId?: string\n /** Only a succeeded run pauses. */\n readonly finishReason?: Exclude<AgentRunFinishReason, \"awaiting_approval\" | \"awaiting_answer\">\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n readonly error?: SixbFailure<AgentRunFailureCode>\n readonly completedAt?: Date\n }\n\nexport interface ListAgentRunsInput {\n readonly projectId: string\n readonly kinds?: readonly AgentRunKind[]\n readonly threadId?: string\n readonly parentRunId?: string\n readonly statuses?: readonly AgentRunStatus[]\n /** Effective start time; runs that never started use `createdAt`. */\n readonly startedAfter?: Date\n /** Effective start time; runs that never started use `createdAt`. */\n readonly startedBefore?: Date\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n /** Leave out the turns that wait for a computer: only a worker's to run. */\n readonly excludeComputerTurns?: boolean\n}\n\nexport interface ListThreadSubagentsInput {\n readonly projectId: string\n /** The conversation whose turns spawned them. */\n readonly threadId: string\n readonly spawnKey?: string\n readonly finishReason?: AgentRunFinishReason\n /** At most this many, 100 by default. */\n readonly limit?: number\n}\n\nexport interface ListAgentRunsResult {\n readonly runs: readonly AgentRunRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_messages — one message (assistant messages inserted only once finalized) ─────────────\n\nexport type { AgentMessageRole }\n\nexport interface AgentMessageRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /**\n * The run that produced this message; `null` for user-authored messages. In a sub-agent's thread\n * every message has one, its trigger too, so a run's messages are deleted whole. A message copied\n * by a fork keeps the run that produced it, which belongs to the thread it was copied from.\n */\n readonly runId: string | null\n readonly role: AgentMessageRole\n /** Principal that authored this persisted message: caller for user messages, agent identity later for assistant messages. */\n readonly authorPrincipal?: Principal\n /** Monotonic per thread, assigned by the store. */\n readonly seq: number\n /** Structured message content — text / reasoning / step boundaries / tool calls. */\n readonly parts: readonly AgentMessagePart[]\n /** Message-level metadata (mirrors `UIMessage.metadata`). */\n readonly metadata?: JsonValue\n /** Versions the `parts` shape so it can be migrated; stamped from `AGENT_MESSAGE_CONTENT_VERSION`. */\n readonly contentVersion: number\n readonly createdAt: Date\n readonly completedAt?: Date\n}\n\n/** Append a message: a {@link AgentMessage} (role + parts + metadata) plus its storage identity. */\nexport interface AppendAgentMessageInput extends AgentMessage {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly runId: string | null\n readonly authorPrincipal?: Principal\n readonly createdAt?: Date\n readonly completedAt?: Date\n}\n\nexport interface DeleteAgentMessagesByRunInput {\n readonly projectId: string\n readonly threadId: string\n readonly runId: string\n /**\n * The run that deletes them, when one does: refused with `execution_lost` unless it still runs\n * under this token, checked in the same transaction as the delete.\n */\n readonly fence?: { readonly runId: string; readonly executionToken: string }\n}\n\nexport interface ListAgentMessagesInput {\n readonly projectId: string\n readonly threadId: string\n /** Return only messages whose per-thread sequence is greater than this retained boundary. */\n readonly afterSeq?: number\n readonly roles?: readonly AgentMessageRole[]\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentMessagesResult {\n readonly messages: readonly AgentMessageRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_context_checkpoints — append-only model-context boundaries ──────────────────────────\n\nexport type AgentContextCheckpointReason = \"threshold\" | \"overflow\"\n\n/**\n * A durable summary boundary used only when projecting a thread into model context.\n *\n * Checkpoints never replace or mutate transcript messages. Normal thread reads remain authoritative\n * and complete; the worker reads the latest checkpoint and only the retained message tail.\n */\nexport interface AgentContextCheckpointRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /** A fork's copy keeps the run that wrote the summary, in the thread it was copied from. */\n readonly createdByRunId: string\n readonly previousCheckpointId?: string\n readonly reason: AgentContextCheckpointReason\n readonly summary: string\n readonly summaryFormatVersion: 1\n readonly summarizedThroughSeq: number\n readonly observedHeadSeq: number\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n readonly summaryModelId: string\n readonly createdAt: Date\n}\n\nexport interface CreateAgentContextCheckpointInput {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly createdByRunId: string\n /** Compare-and-swap anchor. `null` means the thread must not have a prior checkpoint. */\n readonly expectedPreviousCheckpointId: string | null\n /** Compare-and-swap anchor for the complete transcript observed by the summarizer. */\n readonly expectedHeadSeq: number\n /** Current delivery token for `createdByRunId`; stale redeliveries must not write. */\n readonly executionToken: string\n readonly reason: AgentContextCheckpointReason\n readonly summary: string\n readonly summaryFormatVersion: 1\n readonly summarizedThroughSeq: number\n readonly observedHeadSeq: number\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n readonly summaryModelId: string\n readonly createdAt?: Date\n}\n\n// ── Store ───────────────────────────────────────────────────────────────────────────────────────\n\nexport interface AgentThreadStore {\n /** Atomic run-fenced transition, or explicit idle-thread recreation. */\n transitionSandbox(input: TransitionAgentThreadSandboxInput): Promise<AgentThreadSandboxState>\n create(input: CreateAgentThreadInput): Promise<AgentThreadRecord>\n /**\n * Create a thread holding a copy of another's finished history, in one transaction. The source's\n * sub-agent threads are not copied, and a sub-agent's thread is refused.\n */\n fork(input: ForkAgentThreadInput): Promise<AgentThreadRecord>\n getById(params: { projectId: string; id: string }): Promise<AgentThreadRecord | null>\n /** The threads found, in first-occurrence input order; a missing one is omitted. */\n getByIds(params: {\n readonly projectId: string\n readonly ids: readonly string[]\n }): Promise<readonly AgentThreadRecord[]>\n list(input: ListAgentThreadsInput): Promise<ListAgentThreadsResult>\n /** The sub-agents' threads of a conversation, by creation and id, all of them or one turn's. */\n listChildren(input: ListAgentThreadChildrenInput): Promise<readonly AgentThreadRecord[]>\n /**\n * Add users atomically and return every participant of the thread afterwards. A sub-agent's\n * thread has none: its readers are its conversation's.\n */\n addParticipants(\n input: AddAgentThreadParticipantsInput\n ): Promise<readonly AgentThreadParticipantRecord[]>\n /** Whether the user took part until now. */\n removeParticipant(input: RemoveAgentThreadParticipantInput): Promise<boolean>\n /**\n * Move a computer's thread to another computer or folder, and return the thread after. A cloud\n * thread runs on none, and is refused.\n */\n assignComputer(input: AssignAgentThreadComputerInput): Promise<AgentThreadRecord>\n /**\n * Move a computer's thread to the cloud, in one transaction with its queued turn, which the cloud\n * runs instead. Refused with `active_run_exists` while a turn runs on the computer, and\n * `invalid_input` for a thread already in the cloud.\n */\n moveToCloud(input: MoveAgentThreadToCloudInput): Promise<MoveAgentThreadToCloudResult>\n /** The participants of these threads, oldest first, then by user id and thread id. */\n listParticipants(\n input: ListAgentThreadParticipantsInput\n ): Promise<readonly AgentThreadParticipantRecord[]>\n}\n\nexport interface AgentRunStore {\n /**\n * Persist a queued turn and atomically claim the thread's single-flight slot. A sub-agent's\n * thread takes only child runs.\n */\n create(input: CreateAgentRunInput): Promise<ConversationAgentRunRecord>\n /**\n * Persist or replay one idempotent child run while atomically enforcing parent fan-out. In one\n * transaction it creates the child's thread or takes it (single-flight, as a conversation), then\n * appends the trigger and the run.\n */\n createSubagent(input: CreateSubagentRunInput): Promise<SubagentRunRecord>\n /** Transition a queued run to running and install the first delivery's execution token. */\n start(input: StartAgentRunInput): Promise<AgentRunRecord>\n /** Finish a queued run before execution and release the thread's single-flight slot. */\n finishQueued(input: FinishQueuedAgentRunInput): Promise<AgentRunRecord>\n /** Rotate the execution token for a redelivered running job (`attempt++`). */\n reclaim(input: ReclaimAgentRunInput): Promise<AgentRunRecord>\n /**\n * Project the queue's latest confirmed ownership expiration onto the current execution.\n * Implementations must fence by token and must never move the expiration backwards.\n */\n confirmExecutionOwnership(input: ConfirmAgentRunExecutionOwnershipInput): Promise<AgentRunRecord>\n /**\n * Record that a running run was asked to stop, keeping the first time it was. A run in any other\n * state is returned as it is: a queued one is cancelled with `finishQueued`.\n */\n requestCancel(input: RequestAgentRunCancelInput): Promise<AgentRunRecord>\n /**\n * Finalize a run and release the thread's `activeRunId`. `finishReason: \"awaiting_approval\"`\n * needs a call the run holds (see `approvals.holdsRun`). A turn that ends any other way cancels\n * its pending approvals and stops resuming on the rest; a child that fails or is cancelled\n * cancels its own pending ones.\n */\n finish(input: FinishAgentRunInput): Promise<AgentRunRecord>\n getById(params: { projectId: string; id: string }): Promise<AgentRunRecord | null>\n getByIds(params: {\n projectId: string\n ids: readonly string[]\n }): Promise<readonly AgentRunRecord[]>\n /**\n * The children of a conversation's turns, the latest turn's first, by its effective start, and\n * within a turn the latest admitted first. Read by key (one per turn) or by finish reason.\n */\n listThreadSubagents(input: ListThreadSubagentsInput): Promise<readonly SubagentRunRecord[]>\n list(input: ListAgentRunsInput): Promise<ListAgentRunsResult>\n}\n\nexport interface AgentMessageStore {\n /** Insert a message (its `parts` are the canonical content) and bump thread stats. */\n append(input: AppendAgentMessageInput): Promise<AgentMessageRecord>\n /** Delete every message produced by one run and repair the thread's message stats. */\n deleteByRunId(input: DeleteAgentMessagesByRunInput): Promise<number>\n getById(params: { projectId: string; id: string }): Promise<AgentMessageRecord | null>\n list(input: ListAgentMessagesInput): Promise<ListAgentMessagesResult>\n}\n\nexport interface AgentContextCheckpointStore {\n /**\n * Append one checkpoint after atomically validating run ownership and both transcript anchors.\n * Repeating the same payload for the same creating run is idempotent.\n */\n create(input: CreateAgentContextCheckpointInput): Promise<AgentContextCheckpointRecord>\n /** The thread's checkpoints created by the requested runs, in first-occurrence input order. */\n getByRunIds(input: {\n readonly projectId: string\n readonly threadId: string\n readonly runIds: readonly string[]\n }): Promise<readonly AgentContextCheckpointRecord[]>\n getLatest(input: {\n readonly projectId: string\n readonly threadId: string\n }): Promise<AgentContextCheckpointRecord | null>\n}\n\n// ── agent_approvals — calls of the Agent that wait for whoever asked ───────────────────────────\n\n/**\n * What the Agent may change without asking its requester: `manual` asks for every action and\n * workflow, `accept-edits` runs the actions that only change Sixb, `auto` runs everything.\n */\nexport const AGENT_APPROVAL_MODES = [\"manual\", \"accept-edits\", \"auto\"] as const\n\nexport type AgentApprovalMode = (typeof AGENT_APPROVAL_MODES)[number]\n\n/** The modes that hold some calls: the one that held a call is recorded on its approval. */\nexport const AGENT_HOLDING_APPROVAL_MODES = [\n \"manual\",\n \"accept-edits\",\n] as const satisfies readonly AgentApprovalMode[]\n\nexport type AgentHoldingApprovalMode = (typeof AGENT_HOLDING_APPROVAL_MODES)[number]\n\nexport const AGENT_APPROVAL_STATUSES = [\n \"pending\",\n \"approved\",\n \"denied\",\n \"cancelled\",\n \"superseded\",\n \"expired\",\n] as const\n\nexport type AgentApprovalStatus = (typeof AGENT_APPROVAL_STATUSES)[number]\n\n/** The statuses a pending approval is settled to without a decision. */\nexport type AgentApprovalSettledStatus = Extract<\n AgentApprovalStatus,\n \"cancelled\" | \"superseded\" | \"expired\"\n>\n\n/**\n * The held call, as it runs once approved. An action's params are normalized: what the user\n * approves is exactly what runs. Its run id is the one the Agent named, so a repeated request finds\n * the same approval and the same run.\n */\nexport type AgentApprovalCall =\n | {\n readonly kind: \"action\"\n readonly actionId: string\n readonly subject: ActionSubject\n readonly params: ActionRunParams\n readonly actionRunId: string\n /** `external` when the action has a writeback or effects: it reaches beyond Sixb. */\n readonly effect: \"ontology\" | \"external\"\n }\n | {\n readonly kind: \"workflow\"\n readonly workflowId: string\n readonly input: JsonObject\n readonly workflowRunId: string\n }\n\n/** What running an approved call gave. */\nexport type AgentApprovalOutcome =\n | {\n readonly kind: \"action-run\"\n readonly runId: string\n readonly status: \"succeeded\" | \"failed\"\n readonly error?: ActionRunFailure\n }\n | { readonly kind: \"workflow-run\"; readonly runId: string; readonly queuedAt: string }\n /** The call was refused when it ran, for example because its requester lost a grant. */\n | { readonly kind: \"error\"; readonly error: SixbFailure }\n\nexport interface AgentApprovalRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /** The conversation turn the call belongs to. */\n readonly runId: string\n /** The run that made the call: the turn itself, or one of its children. */\n readonly callerRunId: string\n /** Who asked for the turn: the only one who decides, as the call runs with their rights. */\n readonly requestedBy: Principal\n /** The mode that held the call. */\n readonly mode: AgentHoldingApprovalMode\n /** The call's run id, unique among a thread's pending, approved and denied approvals. */\n readonly callKey: string\n readonly call: AgentApprovalCall\n readonly status: AgentApprovalStatus\n readonly createdAt: Date\n readonly expiresAt: Date\n readonly decidedAt?: Date\n readonly decidedBy?: Principal\n /** Set once an approved call ran. */\n readonly outcome?: AgentApprovalOutcome\n /** The user message that told the model how the approval ended. */\n readonly reportedInMessageId?: string\n /** \"Always allow\": the mode its requester raised the turn's calls to when deciding this one. */\n readonly raisedMode?: AgentApprovalMode\n /**\n * The turn will not resume for it: stopped, its requester left, or another of its calls was set\n * aside. The thread's next message still reports it.\n */\n readonly turnStoppedAt?: Date\n /** When a process last took the approved call to run it; a stale claim can be taken again. */\n readonly executionClaimedAt?: Date\n}\n\nexport interface RequestAgentApprovalInput {\n readonly id: string\n readonly projectId: string\n readonly runId: string\n readonly callerRunId: string\n /** The caller run's current delivery token: a stale delivery holds nothing. */\n readonly executionToken: string\n readonly requestedBy: Principal\n readonly mode: AgentHoldingApprovalMode\n readonly call: AgentApprovalCall\n readonly createdAt?: Date\n readonly expiresAt: Date\n}\n\nexport interface RequestAgentApprovalResult {\n readonly approval: AgentApprovalRecord\n /** `false` when a pending, approved or denied approval of the thread had the same call key. */\n readonly created: boolean\n}\n\nexport interface DecideAgentApprovalInput {\n readonly projectId: string\n readonly id: string\n readonly decision: \"approved\" | \"denied\"\n readonly decidedBy: Principal\n readonly decidedAt?: Date\n /** With `approved`: \"Always allow\" raised the turn's mode to this one. */\n readonly raisedMode?: AgentApprovalMode\n}\n\nexport interface DecideAgentApprovalResult {\n /** The approval afterwards: `expired` when its time ran out before this decision. */\n readonly approval: AgentApprovalRecord\n /** Whether this call moved it out of `pending` with the decision. */\n readonly decided: boolean\n}\n\nexport interface SettleAgentApprovalsInput {\n readonly projectId: string\n readonly threadId: string\n readonly status: AgentApprovalSettledStatus\n}\n\n/** Stop a thread's turn, or a requester's turns there, from resuming on their calls. */\nexport interface StopAgentApprovalsInput {\n readonly projectId: string\n readonly threadId: string\n /** Only the calls of this conversation turn. */\n readonly runId?: string\n /** Only the calls this principal asked for. */\n readonly requestedBy?: Principal\n readonly stoppedAt?: Date\n}\n\nexport interface StopAgentApprovalsResult {\n /** The pending approvals it cancelled. */\n readonly cancelled: readonly AgentApprovalRecord[]\n /** How many unreported approvals it stopped, the cancelled ones included. */\n readonly stopped: number\n}\n\n/** Where a keyset listing resumes: after this approval, in the order approvals are listed. */\nexport interface AgentApprovalCursor {\n readonly createdAt: Date\n readonly id: string\n}\n\nexport interface MarkAgentApprovalsReportedInput {\n readonly projectId: string\n readonly threadId: string\n readonly ids: readonly string[]\n readonly messageId: string\n /** A resume: an approval whose turn was stopped is not marked. */\n readonly resuming?: boolean\n}\n\nexport interface ListAgentApprovalsInput {\n readonly projectId: string\n readonly threadId?: string\n readonly runId?: string\n readonly requestedBy?: Principal\n readonly statuses?: readonly AgentApprovalStatus[]\n /** `false`: only the approvals no message reported yet. */\n readonly reported?: boolean\n readonly limit?: number\n readonly offset?: number\n}\n\nexport interface ListAgentApprovalsResult {\n /** Oldest first. */\n readonly approvals: readonly AgentApprovalRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n/**\n * Held calls and their decisions. `runs.finish` settles a run's approvals in its own transaction:\n * a turn that pauses keeps them for their decision, any other ending cancels its pending ones.\n */\nexport interface AgentApprovalStore {\n /**\n * Fenced like a checkpoint: the caller run is running with `executionToken`, and is the\n * conversation turn `runId` or one of its children. Returns the thread's pending, approved or\n * denied approval with the same call key when there is one, and creates one otherwise.\n */\n request(input: RequestAgentApprovalInput): Promise<RequestAgentApprovalResult>\n /** Compare-and-swap from `pending`; `null` when no such approval exists. */\n decide(input: DecideAgentApprovalInput): Promise<DecideAgentApprovalResult | null>\n /** Record what an approved call gave, once: an approval with an outcome is returned unchanged. */\n recordOutcome(input: {\n readonly projectId: string\n readonly id: string\n readonly outcome: AgentApprovalOutcome\n }): Promise<AgentApprovalRecord>\n /** Settle the thread's pending approvals, and return the ones it settled. */\n settle(input: SettleAgentApprovalsInput): Promise<readonly AgentApprovalRecord[]>\n /** Expire the project's pending approvals whose time ran out by `now`, and return them. */\n expireDue(input: {\n readonly projectId: string\n readonly now: Date\n readonly limit?: number\n }): Promise<readonly AgentApprovalRecord[]>\n /**\n * Cancel the matching pending approvals and mark every matching one no message reported yet as\n * stopped: their turn never resumes on them.\n */\n stop(input: StopAgentApprovalsInput): Promise<StopAgentApprovalsResult>\n /** Mark the ones no message reported yet, and return their ids. */\n markReported(input: MarkAgentApprovalsReportedInput): Promise<readonly string[]>\n /**\n * Whether the run holds a call: one of its approvals, or one it made for its turn, pending, or\n * decided and not reported yet. `runs.finish` checks the same before `awaiting_approval`.\n */\n holdsRun(input: { readonly projectId: string; readonly runId: string }): Promise<boolean>\n /**\n * Take an approved call without an outcome to run it, unless another process took it after\n * `staleBefore`; its decision is its first claim. `null` when it is not there to take.\n */\n claimExecution(input: {\n readonly projectId: string\n readonly id: string\n readonly claimedAt: Date\n readonly staleBefore: Date\n }): Promise<AgentApprovalRecord | null>\n /**\n * What a repair pass works on, oldest first: approved calls without an outcome whose claim is\n * older than `claimableBefore`, and decided calls no message reported whose turn is not stopped.\n */\n listRepairable(input: {\n readonly projectId: string\n readonly claimableBefore: Date\n readonly after?: AgentApprovalCursor\n readonly limit: number\n }): Promise<readonly AgentApprovalRecord[]>\n getById(params: {\n readonly projectId: string\n readonly id: string\n }): Promise<AgentApprovalRecord | null>\n list(input: ListAgentApprovalsInput): Promise<ListAgentApprovalsResult>\n}\n\n/** Each user's approval mode: a default, and their own choice in each thread. */\nexport interface AgentApprovalModeStore {\n getDefault(input: {\n readonly projectId: string\n readonly principal: Principal\n }): Promise<AgentApprovalMode | null>\n setDefault(input: {\n readonly projectId: string\n readonly principal: Principal\n readonly mode: AgentApprovalMode\n readonly updatedAt?: Date\n }): Promise<void>\n getForThread(input: {\n readonly projectId: string\n readonly threadId: string\n readonly principal: Principal\n }): Promise<AgentApprovalMode | null>\n /**\n * `null` clears the choice: the user's turns in the thread follow their default again. Throws\n * `thread_not_found` when the thread does not exist.\n */\n setForThread(input: {\n readonly projectId: string\n readonly threadId: string\n readonly principal: Principal\n readonly mode: AgentApprovalMode | null\n readonly updatedAt?: Date\n }): Promise<void>\n}\n\n// ── Memory ──────────────────────────────────────────────────────────────────────────────────────\n\n/** One file of a memory repo, at its path from the repo root. */\nexport interface AgentMemoryFile {\n readonly path: string\n readonly contents: string\n}\n\n/** A memory repo as of its latest revision. */\nexport interface AgentMemoryRepoRecord {\n /** 0 before the first save. */\n readonly revision: number\n /** Ordered by path. */\n readonly files: readonly AgentMemoryFile[]\n}\n\n/** One change of a save: the file's new contents, or `null` to delete it. */\nexport interface AgentMemoryChange {\n readonly path: string\n readonly contents: string | null\n}\n\nexport interface SaveAgentMemoryInput {\n readonly projectId: string\n /** `user:<userId>` or `project`. */\n readonly repoId: string\n /** The revision the caller loaded. */\n readonly baseRevision: number\n readonly message: string\n readonly author: Principal\n /** The conversation the save came from, `/agents/<threadId>`. */\n readonly source?: string\n readonly changes: readonly AgentMemoryChange[]\n readonly createdAt?: Date\n}\n\nexport type SaveAgentMemoryResult =\n | { readonly saved: true; readonly revision: number }\n | {\n readonly saved: false\n /** The repo's latest revision. */\n readonly revision: number\n /** Files in `changes` that another save changed after `baseRevision`, as they are now. */\n readonly conflicts: readonly AgentMemoryChange[]\n }\n\n/** One save: who made it, why, and which paths it wrote. A revision never changes. */\nexport interface AgentMemoryRevisionRecord {\n readonly revision: number\n readonly message: string\n readonly author: Principal\n readonly source?: string\n /** Ordered by path. */\n readonly changes: readonly { readonly path: string; readonly deleted: boolean }[]\n readonly createdAt: Date\n}\n\nexport interface ListAgentMemoryRevisionsInput {\n readonly projectId: string\n readonly repoId: string\n readonly limit?: number\n readonly offset?: number\n}\n\nexport interface ListAgentMemoryRevisionsResult {\n /** Newest first. */\n readonly revisions: readonly AgentMemoryRevisionRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n/**\n * Memory repos as append-only revisions: a save inserts one revision and the files it wrote, and\n * never updates a row. Paths, sizes and who may save are decided in Core before a call reaches\n * storage.\n */\nexport interface AgentMemoryStore {\n /**\n * The repo at its latest revision, or with `asOf` at the latest revision saved by then, and with\n * `revision` at the latest up to that one: revision 0 and no files when none was. File versions\n * pruned from the history are missing from it.\n */\n get(input: {\n readonly projectId: string\n readonly repoId: string\n readonly asOf?: Date\n readonly revision?: number\n }): Promise<AgentMemoryRepoRecord>\n /**\n * In one transaction: reports a conflict when a path in `changes` was written after\n * `baseRevision`, or when the repo is behind `baseRevision` because it was deleted; otherwise\n * stores the next revision. The same transaction removes file versions older than\n * {@link AGENT_MEMORY_HISTORY_DAYS} days that are not their path's latest.\n */\n save(input: SaveAgentMemoryInput): Promise<SaveAgentMemoryResult>\n listRevisions(input: ListAgentMemoryRevisionsInput): Promise<ListAgentMemoryRevisionsResult>\n /** Deletes the repo with its history. */\n delete(input: { readonly projectId: string; readonly repoId: string }): Promise<void>\n}\n\n/** How long a file version that is not its path's latest stays in a repo's history. */\nexport const AGENT_MEMORY_HISTORY_DAYS = 90\n\n/** Each open `sixb` on its owner's computers, as a lease it renews. */\nexport interface AgentComputerSessionStore {\n /**\n * Open the session, or renew it until `expiresAt`; its computer, folder and background commands\n * are kept as given, and its stop requests as they are.\n */\n hold(input: Omit<AgentComputerSessionRecord, \"stopRequests\">): Promise<void>\n /**\n * Record that someone asked to stop one of its commands, once, keeping the newest\n * {@link AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX}. Null when the owner holds no such session.\n */\n requestStop(input: {\n readonly projectId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly command: AgentBackgroundCommandRef\n }): Promise<AgentComputerSessionRecord | null>\n /** End the owner's session; null when it is not open. */\n release(input: {\n readonly projectId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n }): Promise<AgentComputerSessionRecord | null>\n /** The owner's sessions live at `now`. */\n listLive(input: {\n readonly projectId: string\n readonly ownerPrincipal: Principal\n readonly now: Date\n }): Promise<readonly AgentComputerSessionRecord[]>\n /** Remove every session that lapsed before `now`, and return them. */\n removeLapsed(input: {\n readonly projectId: string\n readonly now: Date\n }): Promise<readonly AgentComputerSessionRecord[]>\n}\n\n// ── agent_token_rates — what each model's tokenizer measured on the project's agent runs ──────\n\n/** How many measurements a project keeps per model: its newest. */\nexport const AGENT_TOKEN_RATE_SAMPLES = 20\n\n/**\n * The band of bytes per token a measurement may show. Every tokenizer measured on agent turns\n * reads 2.1 to 4.7; a value outside is a broken measurement, and a single one would set its\n * model's rate for the whole project.\n */\nexport const AGENT_TOKEN_RATE_MIN_BYTES_PER_TOKEN = 1\nexport const AGENT_TOKEN_RATE_MAX_BYTES_PER_TOKEN = 8\n\n/**\n * One run's measurement of its model's tokenizer: the UTF-8 bytes of a request's text, as the\n * Agent's context estimator weighs them, against the text tokens the provider counted for it.\n */\nexport interface AgentTokenRateRecord {\n readonly projectId: string\n readonly providerId: string\n readonly modelId: string\n /** The agent run or workflow step that measured it: one measurement each. */\n readonly runId: string\n readonly bytes: number\n readonly tokens: number\n readonly measuredAt: Date\n}\n\n/**\n * The newest measurements of each model's bytes per token, per project. Agent runs start their\n * context estimate from them; losing them only makes the next estimates more conservative.\n */\nexport interface AgentTokenRateStore {\n /**\n * Keep a run's measurement, in place of one it recorded before, and drop the model's\n * measurements past its newest {@link AGENT_TOKEN_RATE_SAMPLES}.\n */\n record(input: AgentTokenRateRecord): Promise<void>\n /** The model's measurements, newest first: at most {@link AGENT_TOKEN_RATE_SAMPLES}. */\n listLatest(input: {\n readonly projectId: string\n readonly providerId: string\n readonly modelId: string\n }): Promise<readonly AgentTokenRateRecord[]>\n}\n\nexport interface AgentStorage {\n readonly threads: AgentThreadStore\n readonly runs: AgentRunStore\n readonly messages: AgentMessageStore\n readonly checkpoints: AgentContextCheckpointStore\n readonly memory: AgentMemoryStore\n readonly approvals: AgentApprovalStore\n readonly approvalModes: AgentApprovalModeStore\n readonly computers: AgentComputerSessionStore\n readonly tokenRates: AgentTokenRateStore\n}\n"
6
- ],
7
- "mappings": ";;AA2QO,IAAM,0CAAyC;AA6C/C,IAAM,2BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAYO,IAAM,4BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,SAAS,2BAA0B,CACxC,OACkC;AAAA,EAClC,IAAI,UAAU,QAAQ,UAAU,WAAW;AAAA,IACzC;AAAA,EACF;AAAA,EACA,OAAQ,0BAA+C,SAAS,KAAK,IAChE,QACD;AAAA;AAIC,IAAM,8BAA6B,CAAC,sBAAsB,sBAAsB;AA8gBhF,IAAM,wBAAuB,CAAC,UAAU,gBAAgB,MAAM;AAK9D,IAAM,gCAA+B;AAAA,EAC1C;AAAA,EACA;AACF;AAIO,IAAM,2BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAmXO,IAAM,4BAA4B;AAyClC,IAAM,4BAA2B;AAOjC,IAAM,wCAAuC;AAC7C,IAAM,uCAAuC;",
8
- "debugId": "FF93B7FDB906D87364756E2164756E21",
9
- "names": []
10
- }