@sixb/core 0.1.20 → 0.1.21

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 (681) hide show
  1. package/dist/actions/execution.d.ts.map +1 -1
  2. package/dist/actions/index.js +54 -47
  3. package/dist/actions/index.js.map +1 -1
  4. package/dist/actions/request.d.ts.map +1 -1
  5. package/dist/actions/run-authorization.d.ts +9 -0
  6. package/dist/actions/run-authorization.d.ts.map +1 -1
  7. package/dist/activity/connection.d.ts +62 -0
  8. package/dist/activity/connection.d.ts.map +1 -0
  9. package/dist/activity/device.d.ts +8 -0
  10. package/dist/activity/device.d.ts.map +1 -0
  11. package/dist/activity/execution.d.ts +48 -0
  12. package/dist/activity/execution.d.ts.map +1 -0
  13. package/dist/activity/service.d.ts +79 -0
  14. package/dist/activity/service.d.ts.map +1 -0
  15. package/dist/activity/shares.d.ts +24 -0
  16. package/dist/activity/shares.d.ts.map +1 -0
  17. package/dist/activity/timeline.d.ts +96 -0
  18. package/dist/activity/timeline.d.ts.map +1 -0
  19. package/dist/agents/index.d.ts +2 -1
  20. package/dist/agents/index.d.ts.map +1 -1
  21. package/dist/agents/index.js +63 -50
  22. package/dist/agents/index.js.map +1 -1
  23. package/dist/agents/request.d.ts.map +1 -1
  24. package/dist/agents/skills.d.ts.map +1 -1
  25. package/dist/agents/streams/index.js +3 -3
  26. package/dist/agents/streams/internal.js +3 -3
  27. package/dist/agents/types.d.ts +8 -8
  28. package/dist/agents/types.d.ts.map +1 -1
  29. package/dist/agents/validation.d.ts +1 -1
  30. package/dist/agents/validation.d.ts.map +1 -1
  31. package/dist/artifacts/address.d.ts +48 -0
  32. package/dist/artifacts/address.d.ts.map +1 -0
  33. package/dist/artifacts/csv.d.ts +22 -0
  34. package/dist/artifacts/csv.d.ts.map +1 -0
  35. package/dist/artifacts/errors.d.ts +11 -0
  36. package/dist/artifacts/errors.d.ts.map +1 -0
  37. package/dist/artifacts/execution.d.ts +43 -0
  38. package/dist/artifacts/execution.d.ts.map +1 -0
  39. package/dist/artifacts/frames/assets.d.ts +28 -0
  40. package/dist/artifacts/frames/assets.d.ts.map +1 -0
  41. package/dist/artifacts/frames/grants.d.ts +37 -0
  42. package/dist/artifacts/frames/grants.d.ts.map +1 -0
  43. package/dist/artifacts/frames/index.d.ts +10 -0
  44. package/dist/artifacts/frames/index.d.ts.map +1 -0
  45. package/dist/artifacts/frames/index.js +892 -0
  46. package/dist/artifacts/frames/index.js.map +14 -0
  47. package/dist/artifacts/frames/kit.d.ts +66 -0
  48. package/dist/artifacts/frames/kit.d.ts.map +1 -0
  49. package/dist/artifacts/frames/probe.d.ts +41 -0
  50. package/dist/artifacts/frames/probe.d.ts.map +1 -0
  51. package/dist/artifacts/frames/protocol.d.ts +98 -0
  52. package/dist/artifacts/frames/protocol.d.ts.map +1 -0
  53. package/dist/artifacts/frames/runtime.d.ts +13 -0
  54. package/dist/artifacts/frames/runtime.d.ts.map +1 -0
  55. package/dist/artifacts/html.d.ts +6 -0
  56. package/dist/artifacts/html.d.ts.map +1 -0
  57. package/dist/artifacts/ids.d.ts +5 -0
  58. package/dist/artifacts/ids.d.ts.map +1 -0
  59. package/dist/artifacts/index.d.ts +16 -0
  60. package/dist/artifacts/index.d.ts.map +1 -0
  61. package/dist/artifacts/index.js +125 -0
  62. package/dist/artifacts/index.js.map +10 -0
  63. package/dist/artifacts/kinds.d.ts +5 -0
  64. package/dist/artifacts/kinds.d.ts.map +1 -0
  65. package/dist/artifacts/limits.d.ts +28 -0
  66. package/dist/artifacts/limits.d.ts.map +1 -0
  67. package/dist/artifacts/outline.d.ts +44 -0
  68. package/dist/artifacts/outline.d.ts.map +1 -0
  69. package/dist/artifacts/publish/files.d.ts +15 -0
  70. package/dist/artifacts/publish/files.d.ts.map +1 -0
  71. package/dist/artifacts/publish/index.d.ts +5 -0
  72. package/dist/artifacts/publish/index.d.ts.map +1 -0
  73. package/dist/artifacts/publish/index.js +36 -0
  74. package/dist/artifacts/publish/index.js.map +9 -0
  75. package/dist/artifacts/publish/publish.d.ts +52 -0
  76. package/dist/artifacts/publish/publish.d.ts.map +1 -0
  77. package/dist/artifacts/publish/references.d.ts +27 -0
  78. package/dist/artifacts/publish/references.d.ts.map +1 -0
  79. package/dist/artifacts/publish/validate/document.d.ts +17 -0
  80. package/dist/artifacts/publish/validate/document.d.ts.map +1 -0
  81. package/dist/artifacts/publish/validate/file.d.ts +8 -0
  82. package/dist/artifacts/publish/validate/file.d.ts.map +1 -0
  83. package/dist/artifacts/publish/validate/sheet.d.ts +15 -0
  84. package/dist/artifacts/publish/validate/sheet.d.ts.map +1 -0
  85. package/dist/artifacts/publish/validate/slides.d.ts +21 -0
  86. package/dist/artifacts/publish/validate/slides.d.ts.map +1 -0
  87. package/dist/artifacts/references.d.ts +12 -0
  88. package/dist/artifacts/references.d.ts.map +1 -0
  89. package/dist/artifacts/resolve.d.ts +41 -0
  90. package/dist/artifacts/resolve.d.ts.map +1 -0
  91. package/dist/artifacts/theme.d.ts +19 -0
  92. package/dist/artifacts/theme.d.ts.map +1 -0
  93. package/dist/artifacts/warnings.d.ts +11 -0
  94. package/dist/artifacts/warnings.d.ts.map +1 -0
  95. package/dist/artifacts/workbook.d.ts +64 -0
  96. package/dist/artifacts/workbook.d.ts.map +1 -0
  97. package/dist/auth/index.js +10 -10
  98. package/dist/authorization/decision.d.ts +2 -0
  99. package/dist/authorization/decision.d.ts.map +1 -1
  100. package/dist/authorization/grant-kinds.d.ts +2 -2
  101. package/dist/authorization/grant-kinds.d.ts.map +1 -1
  102. package/dist/authorization/index.js +6 -6
  103. package/dist/blob-storage/browser.js +1 -1
  104. package/dist/blob-storage/index.js +2 -2
  105. package/dist/blob-storage/internal.d.ts +1 -1
  106. package/dist/blob-storage/internal.d.ts.map +1 -1
  107. package/dist/blob-storage/internal.js +11 -5
  108. package/dist/blob-storage/internal.js.map +1 -1
  109. package/dist/blob-storage/media-type.d.ts +12 -0
  110. package/dist/blob-storage/media-type.d.ts.map +1 -1
  111. package/dist/bootstrap/index.js +53 -47
  112. package/dist/bootstrap/index.js.map +2 -2
  113. package/dist/{chunk-xfs8x8m9.js → chunk-0bphap9y.js} +5 -5
  114. package/dist/{chunk-1zq2p6g0.js → chunk-1cc1xaf3.js} +3 -3
  115. package/dist/chunk-3jms7je7.js +14 -0
  116. package/dist/chunk-3jms7je7.js.map +10 -0
  117. package/dist/{chunk-s54c868q.js → chunk-3qct2mdc.js} +3 -13
  118. package/dist/chunk-3qct2mdc.js.map +12 -0
  119. package/dist/{chunk-t7x8dmn0.js → chunk-431pyp2c.js} +3 -3
  120. package/dist/{chunk-c85m1hyj.js → chunk-447a5c0p.js} +2 -2
  121. package/dist/chunk-48qjhh6v.js +185 -0
  122. package/dist/chunk-48qjhh6v.js.map +13 -0
  123. package/dist/{chunk-ren4kg2j.js → chunk-561r0yc9.js} +8 -8
  124. package/dist/{chunk-5e43w60z.js → chunk-5948n82c.js} +2 -2
  125. package/dist/{chunk-yzwja0mj.js → chunk-5hx48dnn.js} +2 -2
  126. package/dist/{chunk-x6m907x7.js → chunk-5vems3nx.js} +5 -6
  127. package/dist/{chunk-x6m907x7.js.map → chunk-5vems3nx.js.map} +3 -3
  128. package/dist/{chunk-0rbyz4qy.js → chunk-61y5xs4p.js} +560 -164
  129. package/dist/{chunk-0rbyz4qy.js.map → chunk-61y5xs4p.js.map} +12 -9
  130. package/dist/chunk-65abf64x.js +13 -0
  131. package/dist/chunk-65abf64x.js.map +10 -0
  132. package/dist/{chunk-z3y5kg1x.js → chunk-6eqsgvxk.js} +3 -3
  133. package/dist/{chunk-z3y5kg1x.js.map → chunk-6eqsgvxk.js.map} +2 -2
  134. package/dist/chunk-6rqgmkde.js +2028 -0
  135. package/dist/chunk-6rqgmkde.js.map +29 -0
  136. package/dist/{chunk-d0bqz29d.js → chunk-6vb4st8k.js} +8 -4
  137. package/dist/{chunk-d0bqz29d.js.map → chunk-6vb4st8k.js.map} +3 -3
  138. package/dist/chunk-7q8t23v4.js +467 -0
  139. package/dist/chunk-7q8t23v4.js.map +14 -0
  140. package/dist/{chunk-5j58wjct.js → chunk-858emn8m.js} +6 -6
  141. package/dist/{chunk-hvsb78a1.js → chunk-8frc8a4j.js} +26 -26
  142. package/dist/{chunk-hvsb78a1.js.map → chunk-8frc8a4j.js.map} +2 -2
  143. package/dist/{chunk-3zxk45er.js → chunk-8ncg20rd.js} +3 -68
  144. package/dist/{chunk-3zxk45er.js.map → chunk-8ncg20rd.js.map} +4 -5
  145. package/dist/{chunk-n33z5bjw.js → chunk-918wwnaa.js} +490 -24
  146. package/dist/{chunk-n33z5bjw.js.map → chunk-918wwnaa.js.map} +13 -11
  147. package/dist/{chunk-rrzt8jdy.js → chunk-9j4jw7as.js} +103 -110
  148. package/dist/chunk-9j4jw7as.js.map +14 -0
  149. package/dist/chunk-9kgkfg6v.js +502 -0
  150. package/dist/chunk-9kgkfg6v.js.map +14 -0
  151. package/dist/chunk-a3faa34j.js +74 -0
  152. package/dist/chunk-a3faa34j.js.map +10 -0
  153. package/dist/{chunk-6c6sn0bh.js → chunk-akzryx9h.js} +335 -1167
  154. package/dist/{chunk-6c6sn0bh.js.map → chunk-akzryx9h.js.map} +18 -24
  155. package/dist/chunk-arns890k.js +10 -0
  156. package/dist/chunk-arns890k.js.map +10 -0
  157. package/dist/{chunk-hjzdd750.js → chunk-bk9svbcq.js} +11 -11
  158. package/dist/{chunk-hjzdd750.js.map → chunk-bk9svbcq.js.map} +2 -2
  159. package/dist/{chunk-hkc3jct7.js → chunk-c06hmxyy.js} +2 -10
  160. package/dist/chunk-c06hmxyy.js.map +10 -0
  161. package/dist/{chunk-6p49a5cq.js → chunk-c1rxbz5y.js} +3 -3
  162. package/dist/chunk-cfj9dfbb.js +288 -0
  163. package/dist/chunk-cfj9dfbb.js.map +12 -0
  164. package/dist/{chunk-bx9q3cwv.js → chunk-cn0fwwhy.js} +7 -7
  165. package/dist/{chunk-bx9q3cwv.js.map → chunk-cn0fwwhy.js.map} +1 -1
  166. package/dist/{chunk-gc4ntf7d.js → chunk-cwdzcv37.js} +1 -1
  167. package/dist/{chunk-fa02jy15.js → chunk-cy4mbddw.js} +1 -1
  168. package/dist/{chunk-9w055r5b.js → chunk-d09e3rax.js} +1 -1
  169. package/dist/chunk-d5rjr8c0.js +176 -0
  170. package/dist/chunk-d5rjr8c0.js.map +12 -0
  171. package/dist/{chunk-dk8tkk5f.js → chunk-d7dnxdep.js} +3 -3
  172. package/dist/{chunk-b38szspf.js → chunk-dhcv7yxc.js} +1 -1
  173. package/dist/{chunk-b38szspf.js.map → chunk-dhcv7yxc.js.map} +1 -1
  174. package/dist/{chunk-gsjm1wms.js → chunk-dhdha526.js} +8 -2
  175. package/dist/chunk-dhdha526.js.map +10 -0
  176. package/dist/{chunk-8mx7qw3y.js → chunk-dvd2fp9q.js} +2 -2
  177. package/dist/{chunk-8mx7qw3y.js.map → chunk-dvd2fp9q.js.map} +3 -3
  178. package/dist/{chunk-way52z4h.js → chunk-e17zdm62.js} +6 -12
  179. package/dist/{chunk-way52z4h.js.map → chunk-e17zdm62.js.map} +3 -4
  180. package/dist/{chunk-tpn40322.js → chunk-e6k4thh5.js} +11 -10
  181. package/dist/{chunk-tpn40322.js.map → chunk-e6k4thh5.js.map} +3 -3
  182. package/dist/{chunk-tw03bsmb.js → chunk-eptrvnby.js} +224 -3
  183. package/dist/chunk-eptrvnby.js.map +12 -0
  184. package/dist/{chunk-es1gxsbf.js → chunk-f4pamkt9.js} +8 -10
  185. package/dist/chunk-f4pamkt9.js.map +12 -0
  186. package/dist/chunk-ff5xkv0p.js +211 -0
  187. package/dist/chunk-ff5xkv0p.js.map +10 -0
  188. package/dist/{chunk-d09tj99x.js → chunk-g257jwnc.js} +10 -4
  189. package/dist/{chunk-d09tj99x.js.map → chunk-g257jwnc.js.map} +3 -3
  190. package/dist/chunk-g5bvzyyr.js +32 -0
  191. package/dist/chunk-g5bvzyyr.js.map +10 -0
  192. package/dist/chunk-hke9aeen.js +9 -0
  193. package/dist/chunk-hke9aeen.js.map +10 -0
  194. package/dist/{chunk-1sr8ryzk.js → chunk-hwksyjks.js} +122 -1
  195. package/dist/{chunk-1sr8ryzk.js.map → chunk-hwksyjks.js.map} +3 -3
  196. package/dist/chunk-jcfw4h7m.js +9 -0
  197. package/dist/chunk-jcfw4h7m.js.map +10 -0
  198. package/dist/{chunk-k6q3n2sc.js → chunk-k43ct2ke.js} +20 -11
  199. package/dist/chunk-k43ct2ke.js.map +12 -0
  200. package/dist/{chunk-3t2hgbgd.js → chunk-kge7k6ey.js} +40 -8
  201. package/dist/chunk-kge7k6ey.js.map +15 -0
  202. package/dist/{chunk-tg2cw67r.js → chunk-ky3j490c.js} +2 -2
  203. package/dist/chunk-mjddfa7k.js +129 -0
  204. package/dist/chunk-mjddfa7k.js.map +12 -0
  205. package/dist/{chunk-vpq4shxz.js → chunk-nn5xnx3s.js} +45 -10
  206. package/dist/{chunk-vpq4shxz.js.map → chunk-nn5xnx3s.js.map} +7 -6
  207. package/dist/{chunk-0yh890a4.js → chunk-q5e5tv4b.js} +35 -7
  208. package/dist/{chunk-0yh890a4.js.map → chunk-q5e5tv4b.js.map} +3 -3
  209. package/dist/{chunk-vyf9kfqf.js → chunk-q7gn29y3.js} +1 -1
  210. package/dist/{chunk-yevzdx4y.js → chunk-rmakanzx.js} +10 -12
  211. package/dist/{chunk-yevzdx4y.js.map → chunk-rmakanzx.js.map} +3 -4
  212. package/dist/{chunk-v9xd5wzd.js → chunk-s7jg7pmn.js} +1 -1
  213. package/dist/chunk-tbc1ngpd.js +642 -0
  214. package/dist/chunk-tbc1ngpd.js.map +18 -0
  215. package/dist/chunk-twe4dx8p.js +676 -0
  216. package/dist/chunk-twe4dx8p.js.map +15 -0
  217. package/dist/{chunk-9dmt152s.js → chunk-vf57cr4t.js} +2 -2
  218. package/dist/{chunk-9ybhtmg4.js → chunk-vvxtn22d.js} +1 -1
  219. package/dist/{chunk-jhm3zsa7.js → chunk-wkv3h3q7.js} +64 -2
  220. package/dist/{chunk-jhm3zsa7.js.map → chunk-wkv3h3q7.js.map} +3 -3
  221. package/dist/chunk-x0v3jd47.js +124 -0
  222. package/dist/chunk-x0v3jd47.js.map +10 -0
  223. package/dist/{chunk-7t429e3f.js → chunk-xvsc5m8n.js} +1 -1
  224. package/dist/{chunk-z4m0yz8c.js → chunk-y5tah2kf.js} +1 -1
  225. package/dist/{chunk-fkgc1wt8.js → chunk-z58tm0hm.js} +2 -2
  226. package/dist/datasets/builders.d.ts +15 -2
  227. package/dist/datasets/builders.d.ts.map +1 -1
  228. package/dist/datasets/column-index.d.ts +7 -0
  229. package/dist/datasets/column-index.d.ts.map +1 -0
  230. package/dist/datasets/execution.d.ts +3 -2
  231. package/dist/datasets/execution.d.ts.map +1 -1
  232. package/dist/datasets/write.js +8 -8
  233. package/dist/error-reporting/internal.js +4 -4
  234. package/dist/errors/internal.d.ts +1 -0
  235. package/dist/errors/internal.d.ts.map +1 -1
  236. package/dist/errors/internal.js +7 -4
  237. package/dist/errors/internal.js.map +1 -1
  238. package/dist/events/execution.d.ts +12 -2
  239. package/dist/events/execution.d.ts.map +1 -1
  240. package/dist/events/index.js +4 -4
  241. package/dist/execution/agent.js +56 -49
  242. package/dist/execution/agent.js.map +1 -1
  243. package/dist/execution/authorized-object-reader.d.ts +52 -11
  244. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  245. package/dist/execution/object-reader-clearance.d.ts +41 -0
  246. package/dist/execution/object-reader-clearance.d.ts.map +1 -0
  247. package/dist/execution/object-reader-ontology.d.ts +12 -0
  248. package/dist/execution/object-reader-ontology.d.ts.map +1 -0
  249. package/dist/execution/object-reader-security.d.ts +45 -0
  250. package/dist/execution/object-reader-security.d.ts.map +1 -0
  251. package/dist/execution/primitive.js +54 -47
  252. package/dist/execution/primitive.js.map +1 -1
  253. package/dist/execution/request.js +48 -41
  254. package/dist/execution/request.js.map +2 -2
  255. package/dist/http/api-routes.d.ts.map +1 -1
  256. package/dist/http/index.js +1 -1
  257. package/dist/index.d.ts +20 -4
  258. package/dist/index.d.ts.map +1 -1
  259. package/dist/index.js +112 -97
  260. package/dist/index.js.map +1 -1
  261. package/dist/lake-storage/in-memory.d.ts +1 -0
  262. package/dist/lake-storage/in-memory.d.ts.map +1 -1
  263. package/dist/lake-storage/index.d.ts +6 -3
  264. package/dist/lake-storage/index.d.ts.map +1 -1
  265. package/dist/lake-storage/index.js +21 -13
  266. package/dist/lake-storage/index.js.map +1 -1
  267. package/dist/lake-storage/lineage.d.ts +94 -0
  268. package/dist/lake-storage/lineage.d.ts.map +1 -0
  269. package/dist/lake-storage/sql-transforms.d.ts +45 -0
  270. package/dist/lake-storage/sql-transforms.d.ts.map +1 -1
  271. package/dist/lake-storage/types.d.ts +55 -1
  272. package/dist/lake-storage/types.d.ts.map +1 -1
  273. package/dist/lake-storage/version-inputs.d.ts +14 -3
  274. package/dist/lake-storage/version-inputs.d.ts.map +1 -1
  275. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
  276. package/dist/materializer/index.js +31 -30
  277. package/dist/materializer/index.js.map +1 -1
  278. package/dist/models/execution/index.js +25 -24
  279. package/dist/models/execution/index.js.map +1 -1
  280. package/dist/objects/clearance-redaction.d.ts +27 -0
  281. package/dist/objects/clearance-redaction.d.ts.map +1 -0
  282. package/dist/objects/index.js +54 -47
  283. package/dist/objects/index.js.map +1 -1
  284. package/dist/objects/link/authorization.d.ts +8 -5
  285. package/dist/objects/link/authorization.d.ts.map +1 -1
  286. package/dist/objects/link/upsert-batch.d.ts.map +1 -1
  287. package/dist/objects/object/delete.d.ts.map +1 -1
  288. package/dist/objects/object/upsert-batch.d.ts.map +1 -1
  289. package/dist/objects/object/upsert.d.ts.map +1 -1
  290. package/dist/objects/property-clearance.d.ts +47 -24
  291. package/dist/objects/property-clearance.d.ts.map +1 -1
  292. package/dist/objects/query/clearance-admission.d.ts +10 -0
  293. package/dist/objects/query/clearance-admission.d.ts.map +1 -0
  294. package/dist/objects/query/index.js +29 -28
  295. package/dist/objects/query/index.js.map +1 -1
  296. package/dist/objects/query/link-query-clearance.d.ts +21 -0
  297. package/dist/objects/query/link-query-clearance.d.ts.map +1 -0
  298. package/dist/ontology/builders.d.ts.map +1 -1
  299. package/dist/ontology/docs-markdown.d.ts +1 -1
  300. package/dist/ontology/docs-markdown.d.ts.map +1 -1
  301. package/dist/ontology/index.js +7 -7
  302. package/dist/ontology/internal.js +4 -4
  303. package/dist/ontology/internal.js.map +1 -1
  304. package/dist/pipelines/index.d.ts +2 -0
  305. package/dist/pipelines/index.d.ts.map +1 -1
  306. package/dist/pipelines/index.js +47 -35
  307. package/dist/pipelines/index.js.map +1 -1
  308. package/dist/pipelines/lineage.d.ts +17 -0
  309. package/dist/pipelines/lineage.d.ts.map +1 -0
  310. package/dist/projections/internal.d.ts +2 -2
  311. package/dist/projections/internal.js +30 -29
  312. package/dist/projections/internal.js.map +1 -1
  313. package/dist/runtime/create.d.ts +3 -0
  314. package/dist/runtime/create.d.ts.map +1 -1
  315. package/dist/runtime/host.d.ts +6 -0
  316. package/dist/runtime/host.d.ts.map +1 -1
  317. package/dist/runtime/internal.d.ts +2 -0
  318. package/dist/runtime/internal.d.ts.map +1 -1
  319. package/dist/runtime/internal.js +46 -42
  320. package/dist/runtime/internal.js.map +1 -1
  321. package/dist/runtime/ontology-mutations.d.ts +2 -0
  322. package/dist/runtime/ontology-mutations.d.ts.map +1 -1
  323. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  324. package/dist/runtime/sixb.d.ts +8 -0
  325. package/dist/runtime/sixb.d.ts.map +1 -1
  326. package/dist/sandboxes/auth.d.ts +16 -0
  327. package/dist/sandboxes/auth.d.ts.map +1 -1
  328. package/dist/sandboxes/config.d.ts.map +1 -1
  329. package/dist/sandboxes/configuration.d.ts +26 -0
  330. package/dist/sandboxes/configuration.d.ts.map +1 -1
  331. package/dist/sandboxes/index.d.ts +1 -1
  332. package/dist/sandboxes/index.d.ts.map +1 -1
  333. package/dist/sandboxes/index.js +14 -13
  334. package/dist/sandboxes/index.js.map +1 -1
  335. package/dist/sandboxes/sandbox.d.ts +28 -5
  336. package/dist/sandboxes/sandbox.d.ts.map +1 -1
  337. package/dist/security/applied-markings-contribution.d.ts +58 -0
  338. package/dist/security/applied-markings-contribution.d.ts.map +1 -0
  339. package/dist/security/applied-markings-host.d.ts +10 -0
  340. package/dist/security/applied-markings-host.d.ts.map +1 -0
  341. package/dist/security/applied-markings-snapshot.d.ts +67 -0
  342. package/dist/security/applied-markings-snapshot.d.ts.map +1 -0
  343. package/dist/security/applied-markings.d.ts +73 -0
  344. package/dist/security/applied-markings.d.ts.map +1 -0
  345. package/dist/security/dataset-version-markings.d.ts +47 -0
  346. package/dist/security/dataset-version-markings.d.ts.map +1 -0
  347. package/dist/security/grants.d.ts +3 -2
  348. package/dist/security/grants.d.ts.map +1 -1
  349. package/dist/security/index.d.ts +2 -1
  350. package/dist/security/index.d.ts.map +1 -1
  351. package/dist/security/internal.d.ts +15 -0
  352. package/dist/security/internal.d.ts.map +1 -0
  353. package/dist/security/internal.js +135 -0
  354. package/dist/security/internal.js.map +10 -0
  355. package/dist/security/marking-propagation.d.ts +62 -0
  356. package/dist/security/marking-propagation.d.ts.map +1 -0
  357. package/dist/security/marking-sets.d.ts +14 -0
  358. package/dist/security/marking-sets.d.ts.map +1 -0
  359. package/dist/security/markings.d.ts +6 -3
  360. package/dist/security/markings.d.ts.map +1 -1
  361. package/dist/security/pipeline-markings.d.ts +20 -0
  362. package/dist/security/pipeline-markings.d.ts.map +1 -0
  363. package/dist/security/project.d.ts +4 -0
  364. package/dist/security/project.d.ts.map +1 -0
  365. package/dist/security/projection-markings.d.ts +71 -0
  366. package/dist/security/projection-markings.d.ts.map +1 -0
  367. package/dist/security/public.js +2 -2
  368. package/dist/security/redactions.d.ts +4 -1
  369. package/dist/security/redactions.d.ts.map +1 -1
  370. package/dist/security/types.d.ts +22 -2
  371. package/dist/security/types.d.ts.map +1 -1
  372. package/dist/security/validation.d.ts.map +1 -1
  373. package/dist/shares/internal.js +24 -23
  374. package/dist/shares/internal.js.map +2 -2
  375. package/dist/storage/action-runs/failure.js +3 -3
  376. package/dist/storage/action-runs/in-memory.d.ts +4 -0
  377. package/dist/storage/action-runs/in-memory.d.ts.map +1 -1
  378. package/dist/storage/action-runs/types.d.ts +8 -0
  379. package/dist/storage/action-runs/types.d.ts.map +1 -1
  380. package/dist/storage/activity/in-memory.d.ts +55 -0
  381. package/dist/storage/activity/in-memory.d.ts.map +1 -0
  382. package/dist/storage/activity/index.d.ts +3 -0
  383. package/dist/storage/activity/index.d.ts.map +1 -0
  384. package/dist/storage/activity/policy.d.ts +96 -0
  385. package/dist/storage/activity/policy.d.ts.map +1 -0
  386. package/dist/storage/activity/types.d.ts +191 -0
  387. package/dist/storage/activity/types.d.ts.map +1 -0
  388. package/dist/storage/agents/in-memory.d.ts +4 -0
  389. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  390. package/dist/storage/agents/provider.d.ts.map +1 -1
  391. package/dist/storage/agents/provider.js +2 -5
  392. package/dist/storage/agents/provider.js.map +1 -1
  393. package/dist/storage/agents/types.d.ts +9 -8
  394. package/dist/storage/agents/types.d.ts.map +1 -1
  395. package/dist/storage/ai-limits/enforcement.js +3 -3
  396. package/dist/storage/artifacts/errors.d.ts +8 -0
  397. package/dist/storage/artifacts/errors.d.ts.map +1 -0
  398. package/dist/storage/artifacts/in-memory.d.ts +34 -0
  399. package/dist/storage/artifacts/in-memory.d.ts.map +1 -0
  400. package/dist/storage/artifacts/index.d.ts +5 -0
  401. package/dist/storage/artifacts/index.d.ts.map +1 -0
  402. package/dist/storage/artifacts/record.d.ts +17 -0
  403. package/dist/storage/artifacts/record.d.ts.map +1 -0
  404. package/dist/storage/artifacts/types.d.ts +184 -0
  405. package/dist/storage/artifacts/types.d.ts.map +1 -0
  406. package/dist/storage/auth/in-memory/sessions.d.ts +2 -1
  407. package/dist/storage/auth/in-memory/sessions.d.ts.map +1 -1
  408. package/dist/storage/auth/index.d.ts +1 -1
  409. package/dist/storage/auth/index.d.ts.map +1 -1
  410. package/dist/storage/auth/types.d.ts +19 -0
  411. package/dist/storage/auth/types.d.ts.map +1 -1
  412. package/dist/storage/connector-connections/provider.js +2 -2
  413. package/dist/storage/executions/in-memory.d.ts +2 -1
  414. package/dist/storage/executions/in-memory.d.ts.map +1 -1
  415. package/dist/storage/executions/index.d.ts +1 -1
  416. package/dist/storage/executions/index.d.ts.map +1 -1
  417. package/dist/storage/executions/provider.d.ts +2 -0
  418. package/dist/storage/executions/provider.d.ts.map +1 -1
  419. package/dist/storage/executions/provider.js +9 -223
  420. package/dist/storage/executions/provider.js.map +3 -4
  421. package/dist/storage/executions/types.d.ts +31 -0
  422. package/dist/storage/executions/types.d.ts.map +1 -1
  423. package/dist/storage/file-upload-sessions/provider.js +11 -11
  424. package/dist/storage/in-memory/index.d.ts +8 -0
  425. package/dist/storage/in-memory/index.d.ts.map +1 -1
  426. package/dist/storage/index.d.ts +6 -4
  427. package/dist/storage/index.d.ts.map +1 -1
  428. package/dist/storage/index.js +54 -53
  429. package/dist/storage/index.js.map +1 -1
  430. package/dist/storage/internal.d.ts +3 -0
  431. package/dist/storage/internal.d.ts.map +1 -1
  432. package/dist/storage/internal.js +66 -16
  433. package/dist/storage/internal.js.map +1 -1
  434. package/dist/storage/ontology/in-memory/sources.d.ts +2 -1
  435. package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
  436. package/dist/storage/ontology/index.d.ts +1 -1
  437. package/dist/storage/ontology/index.d.ts.map +1 -1
  438. package/dist/storage/ontology/sources.d.ts +15 -0
  439. package/dist/storage/ontology/sources.d.ts.map +1 -1
  440. package/dist/storage/projection-runs/provider.js +3 -3
  441. package/dist/storage/share-grants/in-memory.d.ts +2 -1
  442. package/dist/storage/share-grants/in-memory.d.ts.map +1 -1
  443. package/dist/storage/share-grants/index.d.ts +1 -1
  444. package/dist/storage/share-grants/index.d.ts.map +1 -1
  445. package/dist/storage/share-grants/types.d.ts +6 -0
  446. package/dist/storage/share-grants/types.d.ts.map +1 -1
  447. package/dist/storage/types.d.ts +4 -0
  448. package/dist/storage/types.d.ts.map +1 -1
  449. package/dist/storage/workflow-runs/in-memory.d.ts +4 -0
  450. package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
  451. package/dist/storage/workflow-runs/provider.js +13 -12
  452. package/dist/storage/workflow-runs/provider.js.map +1 -1
  453. package/dist/storage/workflow-runs/types.d.ts +5 -0
  454. package/dist/storage/workflow-runs/types.d.ts.map +1 -1
  455. package/dist/syncs/index.js +35 -34
  456. package/dist/syncs/index.js.map +1 -1
  457. package/dist/testing/action-run-storage-contract.d.ts.map +1 -1
  458. package/dist/testing/activity-storage-contract.d.ts +14 -0
  459. package/dist/testing/activity-storage-contract.d.ts.map +1 -0
  460. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  461. package/dist/testing/artifact-storage-contract.d.ts +13 -0
  462. package/dist/testing/artifact-storage-contract.d.ts.map +1 -0
  463. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  464. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  465. package/dist/testing/index.d.ts +2 -0
  466. package/dist/testing/index.d.ts.map +1 -1
  467. package/dist/testing/index.js +4488 -3137
  468. package/dist/testing/index.js.map +14 -12
  469. package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -1
  470. package/dist/testing/lake-storage-contract.d.ts +2 -0
  471. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  472. package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
  473. package/dist/testing/share-grant-storage-contract.d.ts.map +1 -1
  474. package/dist/webhooks/internal.js +27 -26
  475. package/dist/webhooks/internal.js.map +2 -2
  476. package/dist/workers/index.js +2 -2
  477. package/dist/workflows/builders.d.ts.map +1 -1
  478. package/dist/workflows/index.js +57 -51
  479. package/dist/workflows/index.js.map +1 -1
  480. package/dist/workflows/types.d.ts +9 -0
  481. package/dist/workflows/types.d.ts.map +1 -1
  482. package/dist/workflows/validation.d.ts +7 -0
  483. package/dist/workflows/validation.d.ts.map +1 -1
  484. package/package.json +25 -1
  485. package/src/actions/execution.ts +18 -13
  486. package/src/actions/request.ts +18 -3
  487. package/src/actions/run-authorization.ts +23 -0
  488. package/src/activity/README.md +155 -0
  489. package/src/activity/connection.ts +217 -0
  490. package/src/activity/device.ts +41 -0
  491. package/src/activity/execution.ts +210 -0
  492. package/src/activity/service.ts +274 -0
  493. package/src/activity/shares.ts +62 -0
  494. package/src/activity/timeline.ts +424 -0
  495. package/src/agents/index.ts +8 -3
  496. package/src/agents/request.ts +5 -0
  497. package/src/agents/skills.ts +6 -0
  498. package/src/agents/types.ts +8 -8
  499. package/src/agents/validation.ts +2 -0
  500. package/src/artifacts/address.ts +132 -0
  501. package/src/artifacts/csv.ts +108 -0
  502. package/src/artifacts/errors.ts +21 -0
  503. package/src/artifacts/execution.ts +153 -0
  504. package/src/artifacts/frames/assets.ts +88 -0
  505. package/src/artifacts/frames/grants.ts +124 -0
  506. package/src/artifacts/frames/index.ts +15 -0
  507. package/src/artifacts/frames/kit.ts +392 -0
  508. package/src/artifacts/frames/probe.ts +309 -0
  509. package/src/artifacts/frames/protocol.ts +174 -0
  510. package/src/artifacts/frames/runtime.ts +213 -0
  511. package/src/artifacts/html.ts +25 -0
  512. package/src/artifacts/ids.ts +18 -0
  513. package/src/artifacts/index.ts +61 -0
  514. package/src/artifacts/kinds.ts +8 -0
  515. package/src/artifacts/limits.ts +27 -0
  516. package/src/artifacts/outline.ts +62 -0
  517. package/src/artifacts/publish/files.ts +87 -0
  518. package/src/artifacts/publish/index.ts +12 -0
  519. package/src/artifacts/publish/publish.ts +250 -0
  520. package/src/artifacts/publish/references.ts +130 -0
  521. package/src/artifacts/publish/validate/document.ts +114 -0
  522. package/src/artifacts/publish/validate/file.ts +19 -0
  523. package/src/artifacts/publish/validate/sheet.ts +251 -0
  524. package/src/artifacts/publish/validate/slides.ts +134 -0
  525. package/src/artifacts/references.ts +11 -0
  526. package/src/artifacts/resolve.ts +97 -0
  527. package/src/artifacts/theme.ts +116 -0
  528. package/src/artifacts/warnings.ts +10 -0
  529. package/src/artifacts/workbook.ts +315 -0
  530. package/src/authorization/decision.ts +5 -0
  531. package/src/authorization/grant-kinds.ts +14 -2
  532. package/src/blob-storage/internal.ts +1 -1
  533. package/src/blob-storage/media-type.ts +69 -0
  534. package/src/datasets/builders.ts +66 -2
  535. package/src/datasets/column-index.ts +19 -0
  536. package/src/datasets/execution.ts +23 -9
  537. package/src/errors/internal.ts +1 -0
  538. package/src/events/execution.ts +134 -21
  539. package/src/execution/authorized-object-reader.ts +270 -256
  540. package/src/execution/object-reader-clearance.ts +91 -0
  541. package/src/execution/object-reader-ontology.ts +63 -0
  542. package/src/execution/object-reader-security.ts +146 -0
  543. package/src/http/api-routes.ts +125 -0
  544. package/src/index.ts +71 -3
  545. package/src/lake-storage/in-memory.ts +26 -3
  546. package/src/lake-storage/index.ts +13 -1
  547. package/src/lake-storage/lineage.ts +385 -0
  548. package/src/lake-storage/sql-transforms.ts +45 -0
  549. package/src/lake-storage/types.ts +59 -1
  550. package/src/lake-storage/version-inputs.ts +35 -6
  551. package/src/maintenance/ontology-maintenance.ts +15 -0
  552. package/src/objects/clearance-redaction.ts +138 -0
  553. package/src/objects/link/authorization.ts +27 -7
  554. package/src/objects/link/remove.ts +2 -2
  555. package/src/objects/link/upsert-batch.ts +7 -5
  556. package/src/objects/link/upsert.ts +2 -2
  557. package/src/objects/object/delete.ts +2 -0
  558. package/src/objects/object/upsert-batch.ts +2 -4
  559. package/src/objects/object/upsert.ts +2 -3
  560. package/src/objects/property-clearance.ts +171 -152
  561. package/src/objects/query/clearance-admission.ts +112 -0
  562. package/src/objects/query/link-query-clearance.ts +73 -0
  563. package/src/ontology/builders.ts +12 -1
  564. package/src/ontology/docs-markdown.ts +1 -1
  565. package/src/pipelines/index.ts +2 -0
  566. package/src/pipelines/lineage.ts +45 -0
  567. package/src/projections/internal.ts +2 -2
  568. package/src/runtime/create.ts +4 -0
  569. package/src/runtime/host.ts +55 -0
  570. package/src/runtime/internal.ts +2 -0
  571. package/src/runtime/ontology-mutations.ts +19 -4
  572. package/src/runtime/resolve-definitions.ts +66 -3
  573. package/src/runtime/sixb.ts +18 -1
  574. package/src/sandboxes/README.md +29 -7
  575. package/src/sandboxes/auth.ts +16 -0
  576. package/src/sandboxes/config.ts +2 -7
  577. package/src/sandboxes/configuration.ts +61 -7
  578. package/src/sandboxes/index.ts +1 -0
  579. package/src/sandboxes/sandbox.ts +27 -5
  580. package/src/security/applied-markings-contribution.ts +277 -0
  581. package/src/security/applied-markings-host.ts +41 -0
  582. package/src/security/applied-markings-snapshot.ts +235 -0
  583. package/src/security/applied-markings.ts +405 -0
  584. package/src/security/dataset-version-markings.ts +163 -0
  585. package/src/security/grants.ts +39 -4
  586. package/src/security/index.ts +3 -0
  587. package/src/security/internal.ts +18 -0
  588. package/src/security/marking-propagation.ts +255 -0
  589. package/src/security/marking-sets.ts +42 -0
  590. package/src/security/markings.ts +29 -178
  591. package/src/security/pipeline-markings.ts +175 -0
  592. package/src/security/project.ts +8 -0
  593. package/src/security/projection-markings.ts +421 -0
  594. package/src/security/redactions.ts +7 -2
  595. package/src/security/types.ts +20 -2
  596. package/src/security/validation.ts +11 -4
  597. package/src/storage/action-runs/in-memory.ts +18 -0
  598. package/src/storage/action-runs/types.ts +8 -0
  599. package/src/storage/activity/in-memory.ts +374 -0
  600. package/src/storage/activity/index.ts +27 -0
  601. package/src/storage/activity/policy.ts +430 -0
  602. package/src/storage/activity/types.ts +211 -0
  603. package/src/storage/agents/in-memory.ts +10 -0
  604. package/src/storage/agents/provider.ts +2 -13
  605. package/src/storage/agents/types.ts +9 -16
  606. package/src/storage/artifacts/errors.ts +16 -0
  607. package/src/storage/artifacts/in-memory.ts +240 -0
  608. package/src/storage/artifacts/index.ts +30 -0
  609. package/src/storage/artifacts/record.ts +200 -0
  610. package/src/storage/artifacts/types.ts +209 -0
  611. package/src/storage/auth/in-memory/sessions.ts +21 -0
  612. package/src/storage/auth/index.ts +2 -0
  613. package/src/storage/auth/types.ts +18 -0
  614. package/src/storage/executions/in-memory.ts +61 -1
  615. package/src/storage/executions/index.ts +3 -0
  616. package/src/storage/executions/provider.ts +12 -0
  617. package/src/storage/executions/types.ts +30 -0
  618. package/src/storage/in-memory/index.ts +16 -0
  619. package/src/storage/index.ts +63 -0
  620. package/src/storage/internal.ts +30 -0
  621. package/src/storage/ontology/in-memory/sources.ts +23 -0
  622. package/src/storage/ontology/index.ts +2 -0
  623. package/src/storage/ontology/sources.ts +17 -0
  624. package/src/storage/share-grants/in-memory.ts +8 -0
  625. package/src/storage/share-grants/index.ts +1 -0
  626. package/src/storage/share-grants/types.ts +8 -0
  627. package/src/storage/types.ts +4 -0
  628. package/src/storage/workflow-runs/in-memory.ts +16 -0
  629. package/src/storage/workflow-runs/types.ts +5 -0
  630. package/src/testing/action-run-storage-contract.ts +25 -0
  631. package/src/testing/activity-storage-contract.ts +840 -0
  632. package/src/testing/agent-storage-contract.ts +22 -21
  633. package/src/testing/artifact-storage-contract.ts +517 -0
  634. package/src/testing/auth-storage-contract.ts +47 -0
  635. package/src/testing/execution-storage-contract.ts +147 -1
  636. package/src/testing/index.ts +9 -0
  637. package/src/testing/lake-merge-storage-contract.ts +38 -0
  638. package/src/testing/lake-storage-contract.ts +247 -2
  639. package/src/testing/materializer-storage-contract.ts +1 -0
  640. package/src/testing/ontology-storage-contract.ts +57 -2
  641. package/src/testing/share-grant-storage-contract.ts +15 -0
  642. package/src/workflows/builders.ts +14 -0
  643. package/src/workflows/types.ts +9 -0
  644. package/src/workflows/validation.ts +72 -0
  645. package/dist/chunk-1k89ecfr.js +0 -85
  646. package/dist/chunk-1k89ecfr.js.map +0 -10
  647. package/dist/chunk-3t2hgbgd.js.map +0 -15
  648. package/dist/chunk-4vyr1j8f.js +0 -128
  649. package/dist/chunk-4vyr1j8f.js.map +0 -11
  650. package/dist/chunk-9gyp8hg1.js +0 -363
  651. package/dist/chunk-9gyp8hg1.js.map +0 -14
  652. package/dist/chunk-es1gxsbf.js.map +0 -13
  653. package/dist/chunk-gsjm1wms.js.map +0 -10
  654. package/dist/chunk-hkc3jct7.js.map +0 -10
  655. package/dist/chunk-k6q3n2sc.js.map +0 -12
  656. package/dist/chunk-rrzt8jdy.js.map +0 -14
  657. package/dist/chunk-s16apyk9.js +0 -256
  658. package/dist/chunk-s16apyk9.js.map +0 -16
  659. package/dist/chunk-s54c868q.js.map +0 -12
  660. package/dist/chunk-tw03bsmb.js.map +0 -11
  661. /package/dist/{chunk-xfs8x8m9.js.map → chunk-0bphap9y.js.map} +0 -0
  662. /package/dist/{chunk-1zq2p6g0.js.map → chunk-1cc1xaf3.js.map} +0 -0
  663. /package/dist/{chunk-t7x8dmn0.js.map → chunk-431pyp2c.js.map} +0 -0
  664. /package/dist/{chunk-c85m1hyj.js.map → chunk-447a5c0p.js.map} +0 -0
  665. /package/dist/{chunk-ren4kg2j.js.map → chunk-561r0yc9.js.map} +0 -0
  666. /package/dist/{chunk-5e43w60z.js.map → chunk-5948n82c.js.map} +0 -0
  667. /package/dist/{chunk-yzwja0mj.js.map → chunk-5hx48dnn.js.map} +0 -0
  668. /package/dist/{chunk-5j58wjct.js.map → chunk-858emn8m.js.map} +0 -0
  669. /package/dist/{chunk-6p49a5cq.js.map → chunk-c1rxbz5y.js.map} +0 -0
  670. /package/dist/{chunk-gc4ntf7d.js.map → chunk-cwdzcv37.js.map} +0 -0
  671. /package/dist/{chunk-fa02jy15.js.map → chunk-cy4mbddw.js.map} +0 -0
  672. /package/dist/{chunk-9w055r5b.js.map → chunk-d09e3rax.js.map} +0 -0
  673. /package/dist/{chunk-dk8tkk5f.js.map → chunk-d7dnxdep.js.map} +0 -0
  674. /package/dist/{chunk-tg2cw67r.js.map → chunk-ky3j490c.js.map} +0 -0
  675. /package/dist/{chunk-vyf9kfqf.js.map → chunk-q7gn29y3.js.map} +0 -0
  676. /package/dist/{chunk-v9xd5wzd.js.map → chunk-s7jg7pmn.js.map} +0 -0
  677. /package/dist/{chunk-9dmt152s.js.map → chunk-vf57cr4t.js.map} +0 -0
  678. /package/dist/{chunk-9ybhtmg4.js.map → chunk-vvxtn22d.js.map} +0 -0
  679. /package/dist/{chunk-7t429e3f.js.map → chunk-xvsc5m8n.js.map} +0 -0
  680. /package/dist/{chunk-z4m0yz8c.js.map → chunk-y5tah2kf.js.map} +0 -0
  681. /package/dist/{chunk-fkgc1wt8.js.map → chunk-z58tm0hm.js.map} +0 -0
@@ -0,0 +1,2028 @@
1
+ // @bun
2
+ import {
3
+ MAX_OBJECT_READ_FACETS2,
4
+ assertObjectReadOutputWithinLimit2,
5
+ getAuthorizationRef,
6
+ captureExecutionScope,
7
+ resolveExecutionScopeAuthorization,
8
+ AuthorizationError2,
9
+ isAllowed2,
10
+ assertAuthorized2,
11
+ canViewActionRun2,
12
+ canViewWorkflowRun2
13
+ } from "./chunk-6vb4st8k.js";
14
+ import {
15
+ unreadableError,
16
+ resolvePropertyClearance
17
+ } from "./chunk-9j4jw7as.js";
18
+ import {
19
+ objectBatchKey2
20
+ } from "./chunk-918wwnaa.js";
21
+ import {
22
+ ACTIVITY_MIN_IDLE_TIMEOUT_MS,
23
+ ACTIVITY_MAX_VISIT_MS2
24
+ } from "./chunk-tbc1ngpd.js";
25
+ import {
26
+ snapshotVectorProfiles
27
+ } from "./chunk-g257jwnc.js";
28
+ import {
29
+ composeObjectQueryAdmissions,
30
+ validateObjectQuery2,
31
+ validateObjectQueryWithAdmission,
32
+ executeObjectQuery2,
33
+ countObjects2,
34
+ existsObjects2,
35
+ facetObjects2,
36
+ validateObjectFacetRequests,
37
+ preflightObjectQueryLinks,
38
+ executeObjectQueryLinks2
39
+ } from "./chunk-cn0fwwhy.js";
40
+ import {
41
+ executionRecordInputFromRuntime,
42
+ ensureExecutionRecord2
43
+ } from "./chunk-vf57cr4t.js";
44
+ import {
45
+ requireAccountingCapabilities,
46
+ createAiModelCallLimitController2,
47
+ AiModelCallRecorder2,
48
+ enqueueAiModelCallRecovery2
49
+ } from "./chunk-1cc1xaf3.js";
50
+ import {
51
+ ObjectQueryValidationError2
52
+ } from "./chunk-91mg3nj9.js";
53
+ import {
54
+ findPrimitiveParentRequestExecution
55
+ } from "./chunk-ey1nk510.js";
56
+ import {
57
+ createPropertyTokenMap2,
58
+ createLinkTokenMap2
59
+ } from "./chunk-rdghfsss.js";
60
+ import {
61
+ OntologyValidationError2,
62
+ OntologyNotFoundError2,
63
+ formatUnknownObjectTypeMessage
64
+ } from "./chunk-cqr3acm1.js";
65
+
66
+ // src/runtime/ontology-mutations.ts
67
+ var ontologyMutationRuntimeKey = Symbol("sixb.ontologyMutationRuntime");
68
+ function registerOntologyMutationRuntime2(owner, runtime) {
69
+ const registered = owner[ontologyMutationRuntimeKey];
70
+ if (registered && registered !== runtime) {
71
+ throw new Error("[Sixb] Ontology mutation runtime is already registered for this owner.");
72
+ }
73
+ Object.defineProperty(owner, ontologyMutationRuntimeKey, {
74
+ configurable: false,
75
+ enumerable: true,
76
+ value: runtime,
77
+ writable: false
78
+ });
79
+ }
80
+ function getOntologyMutationRuntime2(owner) {
81
+ const runtime = owner[ontologyMutationRuntimeKey];
82
+ if (runtime)
83
+ return runtime;
84
+ throw new Error("[Sixb] Ontology mutation runtime is not registered for this runtime context.");
85
+ }
86
+ function shareOntologyMutationRuntime2(source, target) {
87
+ registerOntologyMutationRuntime2(target, getOntologyMutationRuntime2(source));
88
+ }
89
+ function createOntologyMutationRuntime2(input) {
90
+ const applied = (work) => work.finally(() => notifyWithoutAffecting(input.onProjectionApplied));
91
+ const runtime = {
92
+ getProjectionSource: (source) => input.materializer.projections.getActive(source),
93
+ commitEdits: (command) => commitAndNotify(() => input.materializer.edits.commit(command), input.notifyCommittedFacts),
94
+ replaceProjection: (command) => applied(commitAndNotify(() => input.materializer.projections.replace(command), input.notifyCommittedFacts)),
95
+ finishProjection: (command) => applied(input.materializer.projections.finishRun(command)),
96
+ appendTelemetry: (command) => commitAndNotify(() => input.materializer.telemetry.append(command), input.notifyCommittedFacts)
97
+ };
98
+ return Object.freeze(runtime);
99
+ }
100
+ async function commitAndNotify(commit, notify) {
101
+ const result = await commit();
102
+ if (result.eventCount > 0)
103
+ notifyWithoutAffectingCommit(notify);
104
+ return result;
105
+ }
106
+ function notifyWithoutAffectingCommit(notify) {
107
+ try {
108
+ notify();
109
+ } catch (error) {
110
+ console.error("[Sixb] Failed to wake the ontology outbox dispatcher:", error);
111
+ }
112
+ }
113
+ function notifyWithoutAffecting(notify) {
114
+ try {
115
+ notify?.();
116
+ } catch (error) {
117
+ console.error("[Sixb] Failed to report an applied projection:", error);
118
+ }
119
+ }
120
+
121
+ // src/activity/device.ts
122
+ var BROWSERS = [
123
+ [/\bEdg(?:e|A|iOS)?\//, "Edge"],
124
+ [/\b(?:OPR|Opera)\//, "Opera"],
125
+ [/\bSamsungBrowser\//, "Samsung Internet"],
126
+ [/\b(?:Firefox|FxiOS)\//, "Firefox"],
127
+ [/\b(?:Chrome|Chromium|CriOS|HeadlessChrome)\//, "Chrome"],
128
+ [/\bVersion\/[\d.]+.*\bSafari\//, "Safari"]
129
+ ];
130
+ var SYSTEMS = [
131
+ [/\bWindows\b/, "Windows"],
132
+ [/\biPad\b/, "iPadOS"],
133
+ [/\b(?:iPhone|iPod)\b/, "iOS"],
134
+ [/\bAndroid\b/, "Android"],
135
+ [/\bCrOS\b/, "ChromeOS"],
136
+ [/\bMac OS X\b|\bMacintosh\b/, "macOS"],
137
+ [/\bLinux\b/, "Linux"]
138
+ ];
139
+ function describeUserAgent(userAgent) {
140
+ if (!userAgent) {
141
+ return {};
142
+ }
143
+ const browser = BROWSERS.find(([pattern]) => pattern.test(userAgent))?.[1];
144
+ const os = SYSTEMS.find(([pattern]) => pattern.test(userAgent))?.[1];
145
+ return {
146
+ ...browser === undefined ? {} : { browser },
147
+ ...os === undefined ? {} : { os }
148
+ };
149
+ }
150
+
151
+ // src/activity/connection.ts
152
+ async function readActivityConnections(runtime, service, query, now) {
153
+ const { userId, limit, before } = service.connectionsQuery(query);
154
+ const sessions = runtime.storage.auth?.sessions;
155
+ if (!sessions) {
156
+ return { connections: [] };
157
+ }
158
+ const page = await sessions.listByUserId({
159
+ projectId: runtime.projectId,
160
+ userId,
161
+ limit,
162
+ ...before === undefined ? {} : { before }
163
+ });
164
+ const visits = await service.sessionVisits({
165
+ userId,
166
+ sessionIds: page.sessions.map((session) => session.id)
167
+ });
168
+ const bySession = new Map(visits.map((entry) => [entry.sessionId, entry]));
169
+ const connections = page.sessions.map((session) => ({
170
+ ...sessionConnection(session, now),
171
+ visits: bySession.get(session.id)?.visits ?? 0,
172
+ latestVisits: bySession.get(session.id)?.latest ?? []
173
+ }));
174
+ const last = page.sessions.at(-1);
175
+ return {
176
+ connections,
177
+ ...page.hasMore && last ? { nextCursor: nextConnectionsCursor(page.sessions, last, before) } : {}
178
+ };
179
+ }
180
+ function nextConnectionsCursor(sessions, last, before) {
181
+ const { createdAt } = last;
182
+ const tied = sessions.filter((session) => session.createdAt.getTime() === createdAt.getTime());
183
+ const earlier = before && before.createdAt.getTime() === createdAt.getTime() ? before.skip : 0;
184
+ return encodeActivityConnectionsCursor({ createdAt, skip: earlier + tied.length });
185
+ }
186
+ function encodeActivityConnectionsCursor(cursor) {
187
+ return Buffer.from(JSON.stringify([cursor.createdAt.toISOString(), cursor.skip])).toString("base64url");
188
+ }
189
+ function decodeActivityConnectionsCursor(value) {
190
+ try {
191
+ const parsed = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
192
+ if (Array.isArray(parsed) && parsed.length === 2) {
193
+ const [at, skip] = parsed;
194
+ const createdAt = new Date(typeof at === "string" ? at : Number.NaN);
195
+ if (Number.isFinite(createdAt.getTime()) && Number.isSafeInteger(skip) && skip >= 0) {
196
+ return { createdAt, skip };
197
+ }
198
+ }
199
+ } catch {}
200
+ throw new Error("[Sixb] Invalid activity connections cursor.");
201
+ }
202
+ async function readActivityConnection(runtime, page, grant, now) {
203
+ const { storage, projectId } = runtime;
204
+ const { actor } = page.visit;
205
+ if (actor.type === "user") {
206
+ const session = await storage.auth?.sessions.getById({ projectId, id: page.sessionId });
207
+ return session ? sessionConnection(session, now) : undefined;
208
+ }
209
+ const session = await storage.shareSessions?.getById({ projectId, id: page.sessionId });
210
+ if (!session) {
211
+ return;
212
+ }
213
+ const revokedAt = [session.revokedAt, grant?.revokedAt].flatMap((at) => at === undefined ? [] : [at.getTime()]).sort((left, right) => left - right)[0];
214
+ const statuses = [
215
+ connectionStatus(session, now),
216
+ ...grant ? [connectionStatus(grant, now)] : []
217
+ ];
218
+ const status = statuses.includes("revoked") ? "revoked" : statuses.includes("expired") ? "expired" : "active";
219
+ return {
220
+ type: "share",
221
+ grantId: actor.grantId,
222
+ ...grant ? { definitionId: grant.definitionId } : {},
223
+ status,
224
+ createdAt: new Date(session.createdAt),
225
+ ...revokedAt === undefined ? {} : { revokedAt: new Date(revokedAt) }
226
+ };
227
+ }
228
+ function connectionStatus(session, now) {
229
+ if (session.revokedAt) {
230
+ return "revoked";
231
+ }
232
+ const expired = session.expiresAt <= now || session.absoluteExpiresAt !== undefined && session.absoluteExpiresAt <= now;
233
+ return expired ? "expired" : "active";
234
+ }
235
+ function sessionConnection(session, now) {
236
+ return {
237
+ type: "session",
238
+ device: describeUserAgent(session.userAgent),
239
+ ...session.bearer === undefined ? {} : { clientName: session.bearer.clientName },
240
+ status: connectionStatus(session, now),
241
+ createdAt: new Date(session.createdAt),
242
+ ...session.lastSeenAt === undefined ? {} : { lastSeenAt: new Date(session.lastSeenAt) },
243
+ ...session.revokedAt === undefined ? {} : { revokedAt: new Date(session.revokedAt) }
244
+ };
245
+ }
246
+
247
+ // src/activity/shares.ts
248
+ async function nameSharedVisits(runtime, visits) {
249
+ const grants = await readGrants(runtime, visits);
250
+ return visits.map((visit) => withShare(visit, grants));
251
+ }
252
+ async function nameSharedVisit(runtime, visit) {
253
+ const grants = await readGrants(runtime, [visit]);
254
+ const grant = visit.actor.type === "share" ? grants.get(visit.actor.grantId) : undefined;
255
+ return { visit: withShare(visit, grants), ...grant === undefined ? {} : { grant } };
256
+ }
257
+ async function readGrants(runtime, visits) {
258
+ const ids = visits.flatMap((visit) => visit.actor.type === "share" ? [visit.actor.grantId] : []);
259
+ if (ids.length === 0 || !runtime.storage.shareGrants) {
260
+ return new Map;
261
+ }
262
+ const grants = await runtime.storage.shareGrants.getByIds({ projectId: runtime.projectId, ids });
263
+ return new Map(grants.map((grant) => [grant.id, grant]));
264
+ }
265
+ function withShare(visit, grants) {
266
+ const { actor } = visit;
267
+ const grant = actor.type === "share" ? grants.get(actor.grantId) : undefined;
268
+ if (actor.type !== "share" || grant === undefined) {
269
+ return visit;
270
+ }
271
+ return { ...visit, actor: { ...actor, definitionId: grant.definitionId } };
272
+ }
273
+
274
+ // src/assert-never.ts
275
+ function assertNever(_value, message) {
276
+ throw new Error(message);
277
+ }
278
+
279
+ // src/objects/clearance-redaction.ts
280
+ function redactObjectRow(row, clearance) {
281
+ return redactRow(row, clearance, true);
282
+ }
283
+ function omitHiddenProperties(row, clearance) {
284
+ return redactRow(row, clearance, false);
285
+ }
286
+ function attachRedactions(row, clearance) {
287
+ const hidden = clearance.hiddenProperties(row.objectTypeId);
288
+ if (hidden !== undefined)
289
+ row.redactions = hidden.redactions;
290
+ if (row.links === undefined)
291
+ return;
292
+ for (const value of Object.values(row.links)) {
293
+ if (value === null)
294
+ continue;
295
+ if (Array.isArray(value)) {
296
+ for (const linked of value)
297
+ attachRedactions(linked, clearance);
298
+ } else {
299
+ attachRedactions(value, clearance);
300
+ }
301
+ }
302
+ }
303
+ function redactRow(row, clearance, withRedactions) {
304
+ const hidden = clearance.hiddenProperties(row.objectTypeId);
305
+ const links = row.links;
306
+ if (hidden === undefined && links === undefined)
307
+ return row;
308
+ const redacted = { ...row };
309
+ if (hidden !== undefined) {
310
+ redacted.properties = withoutKeys(row.properties, hidden.ids);
311
+ if (withRedactions)
312
+ redacted.redactions = hidden.redactions;
313
+ }
314
+ if (links !== undefined) {
315
+ redacted.links = Object.fromEntries(Object.entries(links).map(([linkId, value]) => [
316
+ linkId,
317
+ redactLinkValue(value, clearance, withRedactions)
318
+ ]));
319
+ }
320
+ return redacted;
321
+ }
322
+ function redactLinkValue(value, clearance, withRedactions) {
323
+ if (value === null)
324
+ return null;
325
+ if (Array.isArray(value)) {
326
+ return value.map((row) => redactRow(row, clearance, withRedactions));
327
+ }
328
+ return redactRow(value, clearance, withRedactions);
329
+ }
330
+ function redactDomainEvent(event, clearance) {
331
+ if (event.topic !== "objects")
332
+ return event;
333
+ const hidden = clearance.hiddenProperties(event.payload.objectTypeId);
334
+ if (hidden === undefined)
335
+ return event;
336
+ if (event.type === "object.deleted") {
337
+ return {
338
+ ...event,
339
+ payload: {
340
+ ...event.payload,
341
+ propertyChanges: withoutKeys(event.payload.propertyChanges, hidden.ids),
342
+ redactions: hidden.redactions
343
+ }
344
+ };
345
+ }
346
+ return {
347
+ ...event,
348
+ payload: {
349
+ ...event.payload,
350
+ properties: withoutKeys(event.payload.properties, hidden.ids),
351
+ propertyChanges: withoutKeys(event.payload.propertyChanges, hidden.ids),
352
+ redactions: hidden.redactions
353
+ }
354
+ };
355
+ }
356
+ function withoutKeys(record, hidden) {
357
+ const kept = { ...record };
358
+ for (const key of hidden)
359
+ delete kept[key];
360
+ return kept;
361
+ }
362
+
363
+ // src/objects/query/clearance-admission.ts
364
+ function createClearanceQueryAdmission(clearance) {
365
+ const reachedTypes = new WeakMap;
366
+ const state = (objectTypeIds) => {
367
+ const created = Object.freeze({});
368
+ reachedTypes.set(created, Object.freeze([...objectTypeIds]));
369
+ return created;
370
+ };
371
+ const reached = (input) => {
372
+ const objectTypeIds = reachedTypes.get(input);
373
+ if (!objectTypeIds) {
374
+ throw new Error("[Sixb] Clearance query admission received a state it did not create.");
375
+ }
376
+ return objectTypeIds;
377
+ };
378
+ const empty = state([]);
379
+ const admission = {
380
+ empty: () => empty,
381
+ source: (input) => ({
382
+ state: state(input.result.objectTypeIds),
383
+ ...denied(unreadableTypeAmong(clearance, input.result.objectTypeIds))
384
+ }),
385
+ edge: (input) => {
386
+ const sourceTypeIds = input.direction === "outgoing" ? reached(input.state) : [
387
+ ...input.result.objectTypeIds,
388
+ ...input.sourceObjectTypeId ? [input.sourceObjectTypeId] : []
389
+ ];
390
+ const link = sourceTypeIds.map((objectTypeId) => clearance.unreadableLink(objectTypeId, input.linkId)).find((unreadable) => unreadable !== undefined);
391
+ return {
392
+ state: state(input.result.objectTypeIds),
393
+ ...denied(link ?? unreadableTypeAmong(clearance, input.result.objectTypeIds))
394
+ };
395
+ },
396
+ set: (input) => input.op === "subtract" ? input.states[0] ?? empty : state([...new Set(input.states.flatMap(reached))]),
397
+ property: (input) => {
398
+ if (input.use === "project")
399
+ return;
400
+ const objectTypeIds = input.objectTypeId === undefined ? reached(input.state) : [input.objectTypeId];
401
+ for (const objectTypeId of objectTypeIds) {
402
+ const marking = clearance.missingMarking(objectTypeId, input.propertyId);
403
+ if (marking === undefined)
404
+ continue;
405
+ return new AuthorizationError2(`clearance:marking:${marking}`, `[Sixb] Cannot ${PROPERTY_USE_VERBS[input.use]} '${objectTypeId}.${input.propertyId}' at '${input.path}': it requires clearance for marking '${marking}'.`);
406
+ }
407
+ return;
408
+ }
409
+ };
410
+ return Object.freeze(admission);
411
+ }
412
+ function unreadableTypeAmong(clearance, objectTypeIds) {
413
+ for (const objectTypeId of objectTypeIds) {
414
+ const unreadable = clearance.unreadableType(objectTypeId);
415
+ if (unreadable)
416
+ return unreadable;
417
+ }
418
+ return;
419
+ }
420
+ function denied(unreadable) {
421
+ return unreadable ? { denial: unreadableError(unreadable) } : {};
422
+ }
423
+ var PROPERTY_USE_VERBS = {
424
+ filter: "filter by",
425
+ text: "search",
426
+ vector: "run a vector search over",
427
+ sort: "sort by",
428
+ project: "project",
429
+ "expand.orderBy": "order expanded objects by",
430
+ facet: "facet by"
431
+ };
432
+
433
+ // src/objects/query/link-query-clearance.ts
434
+ function assertLinkQueryReadable(input) {
435
+ const { ontology, clearance } = input;
436
+ const { types, links } = clearance.unreadable();
437
+ if (types.size === 0 && links.length === 0)
438
+ return;
439
+ const preflight = preflightObjectQueryLinks({ ...input.request, query: input.query }, { ontology });
440
+ const selected = preflight.validated.result.objectTypeIds;
441
+ const outgoing = preflight.direction !== "incoming";
442
+ const incoming = preflight.direction !== "outgoing";
443
+ const named = (linkId) => preflight.linkId === undefined || preflight.linkId === linkId;
444
+ const targets = (expected, objectTypeId) => (typeof expected === "string" ? [expected] : expected).some((target) => ontology.isValidLinkTarget(target, objectTypeId));
445
+ for (const link of links) {
446
+ if (!named(link.linkId))
447
+ continue;
448
+ if (outgoing && selected.includes(link.objectTypeId) || incoming && selected.some((id) => targets(link.targetObjectTypeId, id))) {
449
+ throw unreadableError(link);
450
+ }
451
+ }
452
+ const sealed = [...types].filter(([id]) => input.viewableByGrants(id));
453
+ if (sealed.length === 0)
454
+ return;
455
+ for (const objectType of ontology.listObjectTypes()) {
456
+ for (const link of objectType.links) {
457
+ if (!named(link.id))
458
+ continue;
459
+ if (outgoing && selected.includes(objectType.id)) {
460
+ const other = sealed.find(([id]) => targets(link.targetObjectTypeId, id));
461
+ if (other)
462
+ throw unreadableError(other[1]);
463
+ }
464
+ const source = types.get(objectType.id);
465
+ if (incoming && source && input.viewableByGrants(objectType.id) && selected.some((id) => targets(link.targetObjectTypeId, id))) {
466
+ throw unreadableError(source);
467
+ }
468
+ }
469
+ }
470
+ }
471
+
472
+ // src/objects/telemetry/workload.ts
473
+ var MAX_DELEGATED_TELEMETRY_HISTORY_SERIES = 100;
474
+ var MAX_DELEGATED_TELEMETRY_HISTORY_POINTS = 1e4;
475
+ var DEFAULT_DELEGATED_TELEMETRY_HISTORY_LIMIT_PER_SERIES = 100;
476
+
477
+ class TelemetryHistoryWorkloadExceededError extends Error {
478
+ metric;
479
+ limit;
480
+ name = "TelemetryHistoryWorkloadExceededError";
481
+ code = "telemetry_history_workload_exceeded";
482
+ constructor(metric, limit) {
483
+ super(`[Sixb] Delegated telemetry history exceeded its ${metric} limit (${limit}).`);
484
+ this.metric = metric;
485
+ this.limit = limit;
486
+ }
487
+ }
488
+ function admitTelemetryHistoryReadWorkload(input, delegated) {
489
+ const seriesCount = input.seriesCount;
490
+ const limitPerSeries = input.limitPerSeries;
491
+ if (!Number.isSafeInteger(seriesCount) || seriesCount < 0) {
492
+ throw new Error("[Sixb] Telemetry history series must have a non-negative safe integer length.");
493
+ }
494
+ if (limitPerSeries !== undefined && (!Number.isSafeInteger(limitPerSeries) || limitPerSeries < 0)) {
495
+ throw new Error("[Sixb] Telemetry history limit must be a non-negative safe integer.");
496
+ }
497
+ if (!delegated) {
498
+ const admission = limitPerSeries === undefined ? {} : { limitPerSeries };
499
+ return Object.freeze(admission);
500
+ }
501
+ if (seriesCount > MAX_DELEGATED_TELEMETRY_HISTORY_SERIES) {
502
+ throw new TelemetryHistoryWorkloadExceededError("series", MAX_DELEGATED_TELEMETRY_HISTORY_SERIES);
503
+ }
504
+ if (seriesCount === 0) {
505
+ return Object.freeze({
506
+ ...limitPerSeries === undefined ? {} : { limitPerSeries },
507
+ maxPointOccurrences: MAX_DELEGATED_TELEMETRY_HISTORY_POINTS
508
+ });
509
+ }
510
+ const maxLimitPerSeries = Math.floor(MAX_DELEGATED_TELEMETRY_HISTORY_POINTS / seriesCount);
511
+ const effectiveLimitPerSeries = limitPerSeries ?? Math.min(DEFAULT_DELEGATED_TELEMETRY_HISTORY_LIMIT_PER_SERIES, maxLimitPerSeries);
512
+ if (effectiveLimitPerSeries > maxLimitPerSeries) {
513
+ throw new TelemetryHistoryWorkloadExceededError("points", MAX_DELEGATED_TELEMETRY_HISTORY_POINTS);
514
+ }
515
+ return Object.freeze({
516
+ limitPerSeries: effectiveLimitPerSeries,
517
+ maxPointOccurrences: MAX_DELEGATED_TELEMETRY_HISTORY_POINTS
518
+ });
519
+ }
520
+
521
+ // src/objects/authorized-ontology-view.ts
522
+ function createAuthorizedOntologyView(input) {
523
+ const allObjectTypes = input.ontology.listObjectTypes();
524
+ const registeredObjectTypeIds = new Set(allObjectTypes.map((objectType) => objectType.id));
525
+ const requestedObjectTypeIds = selectedObjectTypeIds(input.selection, allObjectTypes);
526
+ const visibleObjectTypeIds = new Set([...requestedObjectTypeIds].filter((objectTypeId) => registeredObjectTypeIds.has(objectTypeId)));
527
+ const selectedSchema = input.selection.kind === "selected" ? collectSelectedSchema(input.selection.scope) : undefined;
528
+ const projectedObjectTypes = [];
529
+ for (const objectType of allObjectTypes) {
530
+ if (!visibleObjectTypeIds.has(objectType.id))
531
+ continue;
532
+ const propertyIds = selectedSchema?.propertyIdsByObjectType.get(objectType.id) ?? new Set(objectType.properties.map((property) => property.id));
533
+ const links = selectedSchema ? selectedSchema.linksBySourceType.get(objectType.id) ?? new Map : input.selection.kind === "all" ? allDeclaredLinks(objectType) : allVisibleLinks(input.ontology, objectType, visibleObjectTypeIds);
534
+ projectedObjectTypes.push(projectObjectType({
535
+ objectType,
536
+ propertyIds,
537
+ links,
538
+ visibleObjectTypeIds,
539
+ ontology: input.ontology,
540
+ targetMode: input.selection.kind === "all" ? "original" : input.selection.kind === "types" ? "principal" : "exact",
541
+ exposeContracts: input.selection.kind !== "selected"
542
+ }));
543
+ }
544
+ const objectTypes = projectedObjectTypes;
545
+ const objectTypesById = new Map(objectTypes.map((objectType) => [objectType.id, objectType]));
546
+ const valueTypesById = input.selection.kind === "selected" ? collectVisibleValueTypes(input.ontology.getValueTypesById(), objectTypes) : snapshotAllValueTypes(input.ontology.getValueTypesById());
547
+ const release = (value, budgetValue = value) => {
548
+ input.assertOutputWithinLimit?.(budgetValue);
549
+ return value;
550
+ };
551
+ const cloneObjectType = (objectType) => structuredClone(objectType);
552
+ const cloneValueTypes = () => new Map([...valueTypesById].map(([valueTypeId, valueType]) => [
553
+ valueTypeId,
554
+ structuredClone(valueType)
555
+ ]));
556
+ return Object.freeze({
557
+ listObjectTypes: () => release(objectTypes.map(cloneObjectType)),
558
+ getObjectTypeById: (objectTypeId) => {
559
+ const objectType = objectTypesById.get(objectTypeId);
560
+ return release(objectType ? cloneObjectType(objectType) : null);
561
+ },
562
+ resolveObjectType: (objectTypeId) => {
563
+ const objectType = objectTypesById.get(objectTypeId);
564
+ return objectType ? release(cloneObjectType(objectType)) : unknownObjectType(objectTypeId);
565
+ },
566
+ getValueTypesById: () => {
567
+ const valueTypes = cloneValueTypes();
568
+ return release(valueTypes, [...valueTypes.entries()]);
569
+ },
570
+ getPrimaryPropertyId: (objectTypeId) => {
571
+ const objectType = objectTypesById.get(objectTypeId);
572
+ if (!objectType)
573
+ return unknownObjectType(objectTypeId);
574
+ const primary = objectType.properties.find((property) => property.primary);
575
+ if (!primary) {
576
+ throw new OntologyValidationError2(`[Sixb] Object type '${objectTypeId}' does not expose its primary property in this execution scope.`);
577
+ }
578
+ return release(primary.id);
579
+ },
580
+ listSubTypes: (objectTypeId) => {
581
+ const subTypes = visibleObjectTypeIds.has(objectTypeId) ? input.ontology.listSubTypes(objectTypeId).filter((subTypeId) => visibleObjectTypeIds.has(subTypeId)) : [];
582
+ return release(subTypes);
583
+ },
584
+ isValidLinkTarget: (expected, actual) => {
585
+ if (input.selection.kind === "all") {
586
+ return release(input.ontology.isValidLinkTarget(expected, actual));
587
+ }
588
+ if (!visibleObjectTypeIds.has(actual))
589
+ return release(false);
590
+ const expectedTypes = Array.isArray(expected) ? expected : [expected];
591
+ if (input.selection.kind === "selected") {
592
+ return release(expectedTypes.some((expectedType) => expectedType === "*" || expectedType === actual));
593
+ }
594
+ return release(expectedTypes.some((expectedType) => expectedType === "*" || visibleObjectTypeIds.has(expectedType) && input.ontology.isValidLinkTarget(expectedType, actual)));
595
+ }
596
+ });
597
+ }
598
+ function selectedObjectTypeIds(selection, allObjectTypes) {
599
+ switch (selection.kind) {
600
+ case "all":
601
+ return new Set(allObjectTypes.map((objectType) => objectType.id));
602
+ case "types":
603
+ return new Set(selection.objectTypeIds);
604
+ case "selected":
605
+ return new Set(selection.scope.objects.map((object) => object.objectTypeId));
606
+ }
607
+ }
608
+ function collectSelectedSchema(scope) {
609
+ const propertyIdsByObjectType = new Map;
610
+ for (const object of scope.objects) {
611
+ const properties = propertyIdsByObjectType.get(object.objectTypeId) ?? new Set;
612
+ for (const propertyId of object.propertyIds)
613
+ properties.add(propertyId);
614
+ propertyIdsByObjectType.set(object.objectTypeId, properties);
615
+ }
616
+ const linksBySourceType = new Map;
617
+ for (const step of scope.steps) {
618
+ const links = linksBySourceType.get(step.sourceObjectTypeId) ?? new Map;
619
+ const selected = links.get(step.linkId) ?? {
620
+ targetObjectTypeIds: new Set,
621
+ propertyIds: new Set
622
+ };
623
+ selected.targetObjectTypeIds.add(step.targetObjectTypeId);
624
+ for (const propertyId of step.propertyIds)
625
+ selected.propertyIds.add(propertyId);
626
+ links.set(step.linkId, selected);
627
+ linksBySourceType.set(step.sourceObjectTypeId, links);
628
+ }
629
+ return { propertyIdsByObjectType, linksBySourceType };
630
+ }
631
+ function allDeclaredLinks(objectType) {
632
+ return new Map(objectType.links.map((link) => [
633
+ link.id,
634
+ {
635
+ targetObjectTypeIds: new Set(typeof link.targetObjectTypeId === "string" ? [link.targetObjectTypeId] : link.targetObjectTypeId),
636
+ propertyIds: new Set(link.properties?.map((property) => property.id) ?? [])
637
+ }
638
+ ]));
639
+ }
640
+ function allVisibleLinks(ontology, objectType, visibleObjectTypeIds) {
641
+ const links = new Map;
642
+ for (const link of objectType.links) {
643
+ const targetObjectTypeIds = new Set([...visibleObjectTypeIds].filter((targetObjectTypeId) => ontology.isValidLinkTarget(link.targetObjectTypeId, targetObjectTypeId)));
644
+ if (targetObjectTypeIds.size === 0)
645
+ continue;
646
+ links.set(link.id, {
647
+ targetObjectTypeIds,
648
+ propertyIds: new Set(link.properties?.map((property) => property.id) ?? [])
649
+ });
650
+ }
651
+ return links;
652
+ }
653
+ function projectObjectType(input) {
654
+ const properties = input.objectType.properties.filter((property) => input.propertyIds.has(property.id)).map(snapshotProperty);
655
+ const visiblePropertyIds = new Set(properties.map((property) => property.id));
656
+ const links = input.objectType.links.flatMap((link) => {
657
+ const selected = input.links.get(link.id);
658
+ if (!selected)
659
+ return [];
660
+ if (input.targetMode === "original") {
661
+ return [snapshotLink(link, snapshotLinkTarget(link.targetObjectTypeId), selected.propertyIds)];
662
+ }
663
+ const targetObjectTypeIds = new Set([...selected.targetObjectTypeIds].filter((targetObjectTypeId) => input.visibleObjectTypeIds.has(targetObjectTypeId) && input.ontology.isValidLinkTarget(link.targetObjectTypeId, targetObjectTypeId)));
664
+ if (targetObjectTypeIds.size === 0)
665
+ return [];
666
+ const target = input.targetMode === "principal" ? principalLinkTargets(link, targetObjectTypeIds, input.visibleObjectTypeIds) : exactLinkTargets(targetObjectTypeIds);
667
+ return [snapshotLink(link, target, selected.propertyIds, { omitEmptyProperties: true })];
668
+ });
669
+ const projected = {
670
+ id: input.objectType.id,
671
+ name: input.objectType.name,
672
+ description: input.objectType.description,
673
+ quantityKind: input.objectType.quantityKind,
674
+ seeAlso: input.objectType.seeAlso ? [...input.objectType.seeAlso] : undefined,
675
+ extends: input.objectType.extends && input.visibleObjectTypeIds.has(input.objectType.extends) ? input.objectType.extends : undefined,
676
+ parents: projectOptionalIds(input.objectType.parents, input.visibleObjectTypeIds, input.targetMode === "original"),
677
+ implements: input.exposeContracts && input.objectType.implements ? [...input.objectType.implements] : undefined,
678
+ properties,
679
+ links,
680
+ search: projectSearch(input.objectType.search, visiblePropertyIds, {
681
+ preserveEmpty: input.targetMode !== "exact"
682
+ })
683
+ };
684
+ const withTokens = {
685
+ ...projected,
686
+ p: createPropertyTokenMap2(projected),
687
+ l: createLinkTokenMap2(projected)
688
+ };
689
+ return deepFreeze(withTokens);
690
+ }
691
+ function principalLinkTargets(link, allowedTargetObjectTypeIds, visibleObjectTypeIds) {
692
+ if (link.targetObjectTypeId === "*")
693
+ return exactLinkTargets(allowedTargetObjectTypeIds);
694
+ const declared = Array.isArray(link.targetObjectTypeId) ? link.targetObjectTypeId : [link.targetObjectTypeId];
695
+ if (declared.every((objectTypeId) => visibleObjectTypeIds.has(objectTypeId))) {
696
+ return snapshotLinkTarget(link.targetObjectTypeId);
697
+ }
698
+ return exactLinkTargets(allowedTargetObjectTypeIds);
699
+ }
700
+ function exactLinkTargets(targetObjectTypeIds) {
701
+ const targets = [...targetObjectTypeIds].sort();
702
+ return targets.length === 1 ? targets[0] : targets;
703
+ }
704
+ function projectOptionalIds(ids, visibleObjectTypeIds, preserveOriginal) {
705
+ if (!ids)
706
+ return;
707
+ if (preserveOriginal)
708
+ return [...ids];
709
+ const visible = ids.filter((id) => visibleObjectTypeIds.has(id));
710
+ return visible.length > 0 ? visible : undefined;
711
+ }
712
+ function snapshotLink(link, targetObjectTypeId, propertyIds, options = {}) {
713
+ const properties = link.properties?.filter((property) => propertyIds.has(property.id)).map(snapshotProperty);
714
+ return {
715
+ id: link.id,
716
+ name: link.name,
717
+ description: link.description,
718
+ targetObjectTypeId,
719
+ cardinality: link.cardinality,
720
+ properties: options.omitEmptyProperties && properties?.length === 0 ? undefined : properties
721
+ };
722
+ }
723
+ function snapshotLinkTarget(target) {
724
+ return typeof target === "string" ? target : [...target];
725
+ }
726
+ function snapshotProperty(property) {
727
+ return {
728
+ id: property.id,
729
+ name: property.name,
730
+ schema: snapshotSchema(property.schema),
731
+ description: property.description,
732
+ required: property.required,
733
+ nullable: property.nullable,
734
+ primary: property.primary,
735
+ mode: property.mode,
736
+ semanticType: property.semanticType,
737
+ query: snapshotPropertyQuery(property.query)
738
+ };
739
+ }
740
+ function snapshotPropertyQuery(query) {
741
+ if (!query)
742
+ return;
743
+ return {
744
+ searchable: query.searchable,
745
+ filterable: query.filterable,
746
+ sortable: query.sortable,
747
+ text: query.text,
748
+ exact: query.exact,
749
+ facet: query.facet,
750
+ weight: query.weight
751
+ };
752
+ }
753
+ function projectSearch(search, visiblePropertyIds, options) {
754
+ if (!search)
755
+ return;
756
+ const title = search.title && visiblePropertyIds.has(search.title) ? search.title : undefined;
757
+ const selectedDefaultText = search.defaultText?.filter((propertyId) => visiblePropertyIds.has(propertyId));
758
+ const selectedExact = search.exact?.filter((propertyId) => visiblePropertyIds.has(propertyId));
759
+ const defaultText = options.preserveEmpty || selectedDefaultText?.length ? selectedDefaultText : undefined;
760
+ const exact = options.preserveEmpty || selectedExact?.length ? selectedExact : undefined;
761
+ const vectors = search.vectors === undefined ? undefined : snapshotVectorProfiles(Object.fromEntries(Object.entries(search.vectors).filter(([, profile]) => profile.source.every((id) => visiblePropertyIds.has(id)))));
762
+ const projected = {
763
+ ...vectors === undefined || Object.keys(vectors).length === 0 ? {} : { vectors },
764
+ ...title === undefined ? {} : { title },
765
+ ...defaultText === undefined ? {} : { defaultText },
766
+ ...exact === undefined ? {} : { exact }
767
+ };
768
+ return Object.keys(projected).length > 0 || options.preserveEmpty ? projected : undefined;
769
+ }
770
+ function snapshotAllValueTypes(registered) {
771
+ return new Map([...registered.values()].map((valueType) => {
772
+ const snapshot = snapshotValueType(valueType);
773
+ return [snapshot.id, snapshot];
774
+ }));
775
+ }
776
+ function collectVisibleValueTypes(registered, objectTypes) {
777
+ const referencedIds = new Set;
778
+ const pendingSchemas = [];
779
+ const visitedSchemas = new Set;
780
+ for (const objectType of objectTypes) {
781
+ for (const property of objectType.properties)
782
+ pendingSchemas.push(property.schema);
783
+ for (const link of objectType.links) {
784
+ for (const property of link.properties ?? [])
785
+ pendingSchemas.push(property.schema);
786
+ }
787
+ }
788
+ while (pendingSchemas.length > 0) {
789
+ const schema = pendingSchemas.pop();
790
+ if (typeof schema === "string" || visitedSchemas.has(schema))
791
+ continue;
792
+ visitedSchemas.add(schema);
793
+ if (schema.type === "valueTypeRef") {
794
+ if (!referencedIds.has(schema.valueTypeId)) {
795
+ referencedIds.add(schema.valueTypeId);
796
+ const valueType = registered.get(schema.valueTypeId);
797
+ if (valueType)
798
+ pendingSchemas.push(valueType.schema);
799
+ }
800
+ if (schema._resolved)
801
+ pendingSchemas.push(schema._resolved);
802
+ } else if (schema.type === "object") {
803
+ for (const field of Object.values(schema.properties))
804
+ pendingSchemas.push(field.schema);
805
+ } else if (schema.type === "array") {
806
+ pendingSchemas.push(schema.items);
807
+ } else if (schema.type === "map") {
808
+ pendingSchemas.push(schema.valueSchema);
809
+ }
810
+ }
811
+ return new Map([...referencedIds].map((valueTypeId) => registered.get(valueTypeId)).filter((valueType) => valueType !== undefined).map((valueType) => {
812
+ const snapshot = snapshotValueType(valueType);
813
+ return [snapshot.id, snapshot];
814
+ }));
815
+ }
816
+ function snapshotValueType(valueType) {
817
+ return deepFreeze({
818
+ id: valueType.id,
819
+ name: valueType.name,
820
+ description: valueType.description,
821
+ schema: snapshotSchema(valueType.schema),
822
+ semanticType: valueType.semanticType
823
+ });
824
+ }
825
+ function snapshotSchema(schema) {
826
+ return deepFreeze(structuredClone(schema));
827
+ }
828
+ function deepFreeze(value, seen = new Set) {
829
+ if (typeof value !== "object" || value === null || seen.has(value))
830
+ return value;
831
+ seen.add(value);
832
+ for (const key of Reflect.ownKeys(value)) {
833
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
834
+ if (descriptor && "value" in descriptor)
835
+ deepFreeze(descriptor.value, seen);
836
+ }
837
+ return Object.freeze(value);
838
+ }
839
+ function unknownObjectType(objectTypeId) {
840
+ throw new OntologyNotFoundError2(formatUnknownObjectTypeMessage(objectTypeId));
841
+ }
842
+
843
+ // src/execution/object-reader-ontology.ts
844
+ class ObjectReaderOntology {
845
+ registry;
846
+ #authority;
847
+ #view;
848
+ constructor(registry, authority) {
849
+ this.registry = registry;
850
+ this.#authority = authority;
851
+ Object.freeze(this);
852
+ }
853
+ view() {
854
+ const authority = this.#authority;
855
+ this.#view ??= createAuthorizedOntologyView({
856
+ ontology: this.registry,
857
+ selection: selectionForAuthority(authority, this.registry),
858
+ ...authority.type === "delegated" ? {
859
+ assertOutputWithinLimit: (value) => assertObjectReadOutputWithinLimit2(value, authority.objectRead.limits)
860
+ } : {}
861
+ });
862
+ return this.#view;
863
+ }
864
+ }
865
+ function selectionForAuthority(authority, ontology) {
866
+ switch (authority.type) {
867
+ case "unrestricted":
868
+ return { kind: "all" };
869
+ case "principal":
870
+ return {
871
+ kind: "types",
872
+ objectTypeIds: ontology.listObjectTypes().filter((objectType) => isAllowed2(authority.context, {
873
+ kind: "object.view",
874
+ objectTypeId: objectType.id
875
+ })).map((objectType) => objectType.id)
876
+ };
877
+ case "delegated":
878
+ return { kind: "selected", scope: authority.objectRead.scope };
879
+ }
880
+ }
881
+
882
+ // src/objects/query/selected-read-admission.ts
883
+ var selectedStateBrand = Symbol("sixb.selected-object-query-admission-state");
884
+ function createSelectedObjectQueryAdmission(scope) {
885
+ const selectionByKey = new Map;
886
+ const selectionsByType = new Map;
887
+ const propertiesBySelection = new Map;
888
+ for (const selection of scope.objects) {
889
+ const key = selectionKey(selection.nodeId, selection.objectTypeId);
890
+ selectionByKey.set(key, selection);
891
+ propertiesBySelection.set(key, new Set(selection.propertyIds));
892
+ const byType = selectionsByType.get(selection.objectTypeId) ?? [];
893
+ byType.push(selection);
894
+ selectionsByType.set(selection.objectTypeId, byType);
895
+ }
896
+ const outgoing = indexSteps(scope.steps, "outgoing", selectionByKey);
897
+ const incoming = indexSteps(scope.steps, "incoming", selectionByKey);
898
+ const emptyState = selectedState([]);
899
+ const admission = {
900
+ empty: () => emptyState,
901
+ source: (input) => {
902
+ const selections = input.result.objectTypeIds.flatMap((objectTypeId) => selectionsByType.get(objectTypeId) ?? []);
903
+ const state = selectedState(selections);
904
+ if (input.kind === "refs") {
905
+ const missingType = [...new Set(input.refs?.map((ref) => ref.objectTypeId) ?? [])].sort().find((objectTypeId) => !selectionsByType.has(objectTypeId));
906
+ if (missingType) {
907
+ return denied2(state, new AuthorizationError2(`view:object:${missingType}`, `[Sixb] Delegated query cannot reference object type '${missingType}' at '${input.path}': the selected object scope does not contain that type.`));
908
+ }
909
+ }
910
+ if (state.selections.length > 0)
911
+ return { state };
912
+ const objectTypeId = input.objectTypeId ?? input.result.objectTypeIds[0] ?? "unknown";
913
+ return denied2(state, new AuthorizationError2(`view:object:${objectTypeId}`, `[Sixb] Delegated query cannot start from object type '${objectTypeId}' at '${input.path}': the selected object scope does not contain that type.`));
914
+ },
915
+ property: (input) => propertyDenial(asSelectedState(input.state), input.propertyId, input.objectTypeId, input.use, input.path, propertiesBySelection),
916
+ edge: (input) => {
917
+ const state = asSelectedState(input.state);
918
+ const next = followEdge(state, input.linkId, input.direction, input.sourceObjectTypeId, outgoing, incoming, input.result.objectTypeIds);
919
+ if (next.selections.length > 0 || state.selections.length === 0)
920
+ return { state: next };
921
+ return denied2(next, edgeDenial(state, input.linkId, input.direction, input.sourceObjectTypeId, input.use, input.path));
922
+ },
923
+ set: ({ op, states }) => {
924
+ if (op === "subtract")
925
+ return asSelectedState(states[0] ?? emptyState);
926
+ return selectedState(states.flatMap((state) => asSelectedState(state).selections));
927
+ },
928
+ assertPropertySelected: (input) => {
929
+ const denial = propertyDenial(asSelectedState(input.state), input.propertyId, input.objectTypeId, input.use, input.path, propertiesBySelection);
930
+ if (denial)
931
+ throw denial;
932
+ },
933
+ assertIncidentEdgeSelected: (input) => {
934
+ if (input.linkId === undefined)
935
+ return;
936
+ const state = asSelectedState(input.state);
937
+ const directions = input.direction === "both" ? ["outgoing", "incoming"] : [input.direction];
938
+ const next = selectedState(directions.flatMap((direction) => followEdge(state, input.linkId, direction, undefined, outgoing, incoming).selections));
939
+ if (next.selections.length > 0 || state.selections.length === 0)
940
+ return;
941
+ throw edgeDenial(state, input.linkId, input.direction, undefined, "queryLinks", input.path);
942
+ }
943
+ };
944
+ return Object.freeze(admission);
945
+ }
946
+ function indexSteps(steps, direction, selectionByKey) {
947
+ const index = new Map;
948
+ for (const step of steps) {
949
+ const fromKey = direction === "outgoing" ? selectionKey(step.parentNodeId, step.sourceObjectTypeId) : selectionKey(step.nodeId, step.targetObjectTypeId);
950
+ const toKey = direction === "outgoing" ? selectionKey(step.nodeId, step.targetObjectTypeId) : selectionKey(step.parentNodeId, step.sourceObjectTypeId);
951
+ const target = selectionByKey.get(toKey);
952
+ if (!selectionByKey.has(fromKey) || !target) {
953
+ throw new Error("[Sixb] Compiled selected object scope contains an invalid query path step.");
954
+ }
955
+ const key = edgeKey(direction === "outgoing" ? step.parentNodeId : step.nodeId, direction === "outgoing" ? step.sourceObjectTypeId : step.targetObjectTypeId, step.linkId);
956
+ const targets = index.get(key) ?? [];
957
+ targets.push(target);
958
+ index.set(key, targets);
959
+ }
960
+ return index;
961
+ }
962
+ function followEdge(state, linkId, direction, sourceObjectTypeId, outgoing, incoming, resultObjectTypeIds) {
963
+ const index = direction === "outgoing" ? outgoing : incoming;
964
+ const resultTypes = resultObjectTypeIds ? new Set(resultObjectTypeIds) : undefined;
965
+ const selections = state.selections.flatMap((selection) => {
966
+ const candidates = index.get(edgeKey(selection.nodeId, selection.objectTypeId, linkId)) ?? [];
967
+ return candidates.filter((candidate) => (resultTypes === undefined || resultTypes.has(candidate.objectTypeId)) && (direction === "outgoing" || sourceObjectTypeId === undefined || candidate.objectTypeId === sourceObjectTypeId));
968
+ });
969
+ return selectedState(selections);
970
+ }
971
+ function propertyDenial(state, propertyId, objectTypeId, use, path, propertiesBySelection) {
972
+ const candidates = objectTypeId ? state.selections.filter((selection) => selection.objectTypeId === objectTypeId) : state.selections;
973
+ if (candidates.length === 0)
974
+ return;
975
+ const missing = candidates.find((selection) => !propertiesBySelection.get(selectionKey(selection.nodeId, selection.objectTypeId))?.has(propertyId));
976
+ if (!missing)
977
+ return;
978
+ const objectTypeIds = [...new Set(candidates.map((selection) => selection.objectTypeId))].sort();
979
+ return new AuthorizationError2(`view:object:${objectTypeIds.join(",")}:property:${propertyId}`, `[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)}).`);
980
+ }
981
+ function edgeDenial(state, linkId, direction, sourceObjectTypeId, use, path) {
982
+ const source = sourceObjectTypeId ? `:${sourceObjectTypeId}` : "";
983
+ return new AuthorizationError2(`view:link:${direction}${source}:${linkId}`, `[Sixb] Delegated query cannot use ${direction} link '${linkId}' for ${use} from ${formatState(state)} at '${path}': that exact read-scope path is not selected.`);
984
+ }
985
+ function formatState(state) {
986
+ if (state.selections.length === 0)
987
+ return "an empty read-scope provenance";
988
+ return `read-scope provenance ${state.selections.map(formatSelection).join(", ")}`;
989
+ }
990
+ function formatSelection(selection) {
991
+ return `'${selection.objectTypeId}'@node ${selection.nodeId}`;
992
+ }
993
+ function selectedState(selections) {
994
+ const unique = new Map;
995
+ for (const selection of selections) {
996
+ unique.set(selectionKey(selection.nodeId, selection.objectTypeId), selection);
997
+ }
998
+ return Object.freeze({
999
+ [selectedStateBrand]: true,
1000
+ selections: Object.freeze([...unique.values()].sort((left, right) => left.nodeId - right.nodeId || left.objectTypeId.localeCompare(right.objectTypeId)))
1001
+ });
1002
+ }
1003
+ function asSelectedState(state) {
1004
+ if (state[selectedStateBrand] !== true) {
1005
+ throw new Error("[Sixb] Object query admission state belongs to another semantic admission.");
1006
+ }
1007
+ return state;
1008
+ }
1009
+ function denied2(state, denial) {
1010
+ return { state, denial };
1011
+ }
1012
+ function selectionKey(nodeId, objectTypeId) {
1013
+ return JSON.stringify([nodeId, objectTypeId]);
1014
+ }
1015
+ function edgeKey(nodeId, objectTypeId, linkId) {
1016
+ return JSON.stringify([nodeId, objectTypeId, linkId]);
1017
+ }
1018
+
1019
+ // src/execution/object-reader-clearance.ts
1020
+ class ObjectReaderClearance {
1021
+ #ontology;
1022
+ #static;
1023
+ #clearances;
1024
+ #applied;
1025
+ #lastSnapshot;
1026
+ #lastClearance;
1027
+ constructor(input) {
1028
+ this.#ontology = input.ontology;
1029
+ this.#clearances = input.clearances;
1030
+ this.#static = input.clearances && resolvePropertyClearance(input.ontology, input.clearances);
1031
+ if (input.clearances && input.appliedMarkings?.affects(input.clearances)) {
1032
+ this.#applied = input.appliedMarkings;
1033
+ }
1034
+ Object.freeze(this);
1035
+ }
1036
+ current() {
1037
+ const applied = this.#applied;
1038
+ const clearances = this.#clearances;
1039
+ if (!applied || !clearances)
1040
+ return this.#static;
1041
+ return applied.current().then((snapshot) => {
1042
+ if (snapshot !== this.#lastSnapshot) {
1043
+ this.#lastClearance = resolvePropertyClearance(this.#ontology, clearances, snapshot);
1044
+ this.#lastSnapshot = snapshot;
1045
+ }
1046
+ return this.#lastClearance;
1047
+ });
1048
+ }
1049
+ forEvent(sources) {
1050
+ const applied = this.#applied;
1051
+ const clearances = this.#clearances;
1052
+ if (!applied || !clearances)
1053
+ return this.#static;
1054
+ return applied.current().then((snapshot) => sources.origin ? applied.forEventOrigin(snapshot, sources.origin) : snapshot).then((snapshot) => sources.earlier ? applied.forEarlierValues(snapshot, sources.objectTypeId) : snapshot).then((snapshot) => resolvePropertyClearance(this.#ontology, clearances, snapshot));
1055
+ }
1056
+ }
1057
+
1058
+ // src/execution/object-reader-security.ts
1059
+ class ObjectReaderSecurity {
1060
+ authorization;
1061
+ authority;
1062
+ runtime;
1063
+ delegation;
1064
+ clearance;
1065
+ constructor(input) {
1066
+ const authority = input.authority;
1067
+ this.authorization = input.authorization;
1068
+ this.authority = authority;
1069
+ this.runtime = Object.freeze({
1070
+ projectId: input.projectId,
1071
+ runtimeAuthorization: input.authorization,
1072
+ ...authority.type === "principal" ? { authorization: authority.context } : {}
1073
+ });
1074
+ if (authority.type === "delegated") {
1075
+ const scope = authority.objectRead.scope;
1076
+ this.delegation = Object.freeze({
1077
+ objectTypeIds: new Set(scope.objects.map((object) => object.objectTypeId)),
1078
+ linkDefinitions: new Set(scope.steps.map(delegatedLinkDefinitionKey)),
1079
+ queryAdmission: createSelectedObjectQueryAdmission(scope)
1080
+ });
1081
+ }
1082
+ this.clearance = new ObjectReaderClearance({
1083
+ ontology: input.ontology,
1084
+ clearances: clearancesForAuthority(authority),
1085
+ ...input.appliedMarkings === undefined ? {} : { appliedMarkings: input.appliedMarkings }
1086
+ });
1087
+ Object.freeze(this);
1088
+ }
1089
+ assertObjectTypesViewable(objectTypeIds, clearance) {
1090
+ if (this.delegation) {
1091
+ for (const objectTypeId of new Set(objectTypeIds)) {
1092
+ if (this.delegation.objectTypeIds.has(objectTypeId))
1093
+ continue;
1094
+ throw new AuthorizationError2(`delegated:object.view:${objectTypeId}`, `[Sixb] Delegated authorization does not select object type '${objectTypeId}'.`);
1095
+ }
1096
+ } else {
1097
+ for (const objectTypeId of new Set(objectTypeIds)) {
1098
+ assertAuthorized2(this.runtime, { kind: "object.view", objectTypeId });
1099
+ }
1100
+ }
1101
+ if (!clearance)
1102
+ return;
1103
+ for (const objectTypeId of new Set(objectTypeIds)) {
1104
+ const unreadable = clearance.unreadableType(objectTypeId);
1105
+ if (unreadable)
1106
+ throw unreadableError(unreadable);
1107
+ }
1108
+ }
1109
+ isObjectTypeViewable(objectTypeId, clearance) {
1110
+ if (clearance?.unreadableType(objectTypeId))
1111
+ return false;
1112
+ if (this.delegation)
1113
+ return this.delegation.objectTypeIds.has(objectTypeId);
1114
+ return isAllowed2(this.runtime.authorization, { kind: "object.view", objectTypeId });
1115
+ }
1116
+ isLinkViewable(link, clearance) {
1117
+ if (!this.isObjectTypeViewable(link.sourceTypeId, clearance) || !this.isObjectTypeViewable(link.targetTypeId, clearance) || clearance?.unreadableLink(link.sourceTypeId, link.linkId)) {
1118
+ return false;
1119
+ }
1120
+ return this.delegation?.linkDefinitions.has(delegatedLinkDefinitionKey(link)) ?? true;
1121
+ }
1122
+ }
1123
+ function clearancesForAuthority(authority) {
1124
+ switch (authority.type) {
1125
+ case "unrestricted":
1126
+ return;
1127
+ case "principal":
1128
+ return authority.context.clearances ?? new Set;
1129
+ case "delegated":
1130
+ return new Set;
1131
+ }
1132
+ }
1133
+ function delegatedLinkDefinitionKey(input) {
1134
+ return "sourceObjectTypeId" in input ? JSON.stringify([input.sourceObjectTypeId, input.linkId, input.targetObjectTypeId]) : JSON.stringify([input.sourceTypeId, input.linkId, input.targetTypeId]);
1135
+ }
1136
+
1137
+ // src/execution/authorized-object-reader.ts
1138
+ var readerConstructionKey = Object.freeze({});
1139
+
1140
+ class AuthorizedObjectReaderImpl {
1141
+ #ontology;
1142
+ #security;
1143
+ #models;
1144
+ #storage;
1145
+ constructor(key, input) {
1146
+ if (key !== readerConstructionKey) {
1147
+ throw new Error("[Sixb] AuthorizedObjectReader can only be created by Core.");
1148
+ }
1149
+ this.#ontology = input.ontology;
1150
+ this.#security = input.security;
1151
+ this.#models = input.models;
1152
+ this.#storage = input.storage;
1153
+ }
1154
+ static assertBound(reader, scope) {
1155
+ const capturedScope = captureExecutionScope(scope);
1156
+ resolveExecutionScopeAuthorization(reader.#security.runtime.projectId, capturedScope);
1157
+ if (capturedScope.authorization !== reader.#security.authorization) {
1158
+ throw new Error("[Sixb] AuthorizedObjectReader is not bound to this exact execution authority.");
1159
+ }
1160
+ }
1161
+ static async clearance(reader) {
1162
+ return reader.#security.clearance.current();
1163
+ }
1164
+ static eventClearance(reader, sources) {
1165
+ return reader.#security.clearance.forEvent(sources);
1166
+ }
1167
+ static ontologyView(reader) {
1168
+ return reader.#ontology.view();
1169
+ }
1170
+ get projectId() {
1171
+ return this.#security.runtime.projectId;
1172
+ }
1173
+ async getByPrimaryId(input) {
1174
+ const request = snapshotReadValue({
1175
+ objectTypeId: input.objectTypeId,
1176
+ primaryId: input.primaryId
1177
+ });
1178
+ const clearance = await this.#security.clearance.current();
1179
+ this.#security.assertObjectTypesViewable([request.objectTypeId], clearance);
1180
+ const row = await this.#storage.getByPrimaryId({
1181
+ ...request,
1182
+ projectId: this.#security.runtime.projectId
1183
+ });
1184
+ return this.#detachRows(row && this.#omitHidden(row, clearance), (detached) => [detached], clearance);
1185
+ }
1186
+ async getByPrimaryIdBatch(input) {
1187
+ const request = snapshotReadValue({
1188
+ items: input.items.map((item) => ({
1189
+ objectTypeId: item.objectTypeId,
1190
+ primaryId: item.primaryId
1191
+ }))
1192
+ });
1193
+ const clearance = await this.#security.clearance.current();
1194
+ this.#security.assertObjectTypesViewable(request.items.map((item) => item.objectTypeId), clearance);
1195
+ const rows = await this.#storage.getByPrimaryIdBatch({
1196
+ ...request,
1197
+ projectId: this.#security.runtime.projectId
1198
+ });
1199
+ return this.#detachRows(new Map([...rows].map(([key, row]) => [key, this.#omitHidden(row, clearance)])), (detached) => detached.values(), clearance);
1200
+ }
1201
+ async canReadObjectProperty(input) {
1202
+ const request = snapshotReadValue({
1203
+ objectTypeId: input.objectTypeId,
1204
+ primaryId: input.primaryId,
1205
+ propertyId: input.propertyId
1206
+ });
1207
+ const clearance = await this.#security.clearance.current();
1208
+ this.#security.assertObjectTypesViewable([request.objectTypeId], clearance);
1209
+ if (hidesProperty(request, clearance))
1210
+ return false;
1211
+ if (this.#security.authority.type !== "delegated")
1212
+ return true;
1213
+ const [readable] = await this.#storage.selectsObjectProperties({
1214
+ projectId: this.#security.runtime.projectId,
1215
+ items: [request]
1216
+ });
1217
+ return readable ?? false;
1218
+ }
1219
+ async canReadObjectPropertiesBatch(input) {
1220
+ const request = snapshotReadValue({
1221
+ items: input.items.map((item) => ({
1222
+ objectTypeId: item.objectTypeId,
1223
+ primaryId: item.primaryId,
1224
+ propertyId: item.propertyId
1225
+ }))
1226
+ });
1227
+ const clearance = await this.#security.clearance.current();
1228
+ this.#security.assertObjectTypesViewable(request.items.map((item) => item.objectTypeId), clearance);
1229
+ const selected = this.#security.authority.type === "delegated" ? await this.#storage.selectsObjectProperties({
1230
+ ...request,
1231
+ projectId: this.#security.runtime.projectId
1232
+ }) : request.items.map(() => true);
1233
+ return request.items.map((item, index) => !hidesProperty(item, clearance) && selected[index] === true);
1234
+ }
1235
+ async list(input) {
1236
+ const request = snapshotReadValue({
1237
+ objectTypeId: typeof input.objectTypeId === "string" ? input.objectTypeId : input.objectTypeId === undefined ? undefined : [...input.objectTypeId],
1238
+ primaryIdPrefix: input.primaryIdPrefix,
1239
+ primaryIdSuffix: input.primaryIdSuffix,
1240
+ updatedAfter: input.updatedAfter,
1241
+ updatedBefore: input.updatedBefore,
1242
+ createdAfter: input.createdAfter,
1243
+ createdBefore: input.createdBefore,
1244
+ limit: input.limit,
1245
+ offset: input.offset,
1246
+ orderBy: input.orderBy,
1247
+ order: input.order
1248
+ });
1249
+ const clearance = await this.#security.clearance.current();
1250
+ const objectTypeId = this.#resolveListObjectTypes(request.objectTypeId, clearance);
1251
+ if (Array.isArray(objectTypeId) && objectTypeId.length === 0) {
1252
+ return { objects: [], hasMore: false, total: 0 };
1253
+ }
1254
+ const page = await this.#storage.list({
1255
+ ...request,
1256
+ ...objectTypeId === undefined ? {} : { objectTypeId },
1257
+ projectId: this.#security.runtime.projectId
1258
+ });
1259
+ return this.#detachRows({ ...page, objects: page.objects.map((row) => this.#omitHidden(row, clearance)) }, (detached) => detached.objects, clearance);
1260
+ }
1261
+ async listLinks(input) {
1262
+ const request = snapshotReadValue({
1263
+ objectTypeId: input.objectTypeId,
1264
+ objectId: input.objectId,
1265
+ linkId: input.linkId,
1266
+ direction: input.direction
1267
+ });
1268
+ const clearance = await this.#security.clearance.current();
1269
+ this.#security.assertObjectTypesViewable([request.objectTypeId], clearance);
1270
+ const links = detachReadResult(await this.#storage.listLinks({
1271
+ ...request,
1272
+ projectId: this.#security.runtime.projectId
1273
+ }));
1274
+ return links.filter((link) => this.#security.isLinkViewable(link, clearance));
1275
+ }
1276
+ async listLinksBatch(input) {
1277
+ const request = snapshotReadValue({
1278
+ direction: input.direction,
1279
+ items: input.items.map((item) => ({
1280
+ objectTypeId: item.objectTypeId,
1281
+ objectId: item.objectId,
1282
+ linkId: item.linkId
1283
+ }))
1284
+ });
1285
+ const clearance = await this.#security.clearance.current();
1286
+ this.#security.assertObjectTypesViewable(request.items.map((item) => item.objectTypeId), clearance);
1287
+ const pages = detachReadResult(await this.#storage.listLinksBatch({
1288
+ ...request,
1289
+ projectId: this.#security.runtime.projectId
1290
+ }));
1291
+ const filtered = new Map;
1292
+ for (const [key, links] of pages) {
1293
+ filtered.set(key, links.filter((link) => this.#security.isLinkViewable(link, clearance)));
1294
+ }
1295
+ return filtered;
1296
+ }
1297
+ async executeQuery(input) {
1298
+ const query = snapshotAuthoredQuery(input.query);
1299
+ const includeTotal = snapshotReadValue(input.includeTotal);
1300
+ const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query;
1301
+ const clearance = await this.#security.clearance.current();
1302
+ const result = await executeObjectQuery2({
1303
+ query: executionQuery,
1304
+ ...includeTotal === undefined ? {} : { includeTotal },
1305
+ projectId: this.#security.runtime.projectId,
1306
+ signal: input.signal
1307
+ }, this.#queryExecutorOptions(clearance));
1308
+ return this.#detachRows({ ...result, objects: result.objects.map((row) => this.#omitHidden(row, clearance)) }, (detached) => detached.objects, clearance);
1309
+ }
1310
+ async queryLinks(input) {
1311
+ const query = snapshotAuthoredQuery(input.query);
1312
+ const request = snapshotReadValue({
1313
+ direction: input.direction,
1314
+ linkId: input.linkId,
1315
+ includeObjects: input.includeObjects,
1316
+ pageSize: input.pageSize,
1317
+ pageToken: input.pageToken
1318
+ });
1319
+ let executionQuery = query;
1320
+ const admission = this.#security.delegation?.queryAdmission;
1321
+ if (admission) {
1322
+ const preflight = preflightObjectQueryLinks({ query, ...request, projectId: this.#security.runtime.projectId }, { ontology: this.#ontology.registry });
1323
+ const admitted = validateObjectQueryWithAdmission(preflight.validated.query, { ontology: this.#ontology.registry, normalize: false }, admission);
1324
+ admission.assertIncidentEdgeSelected({
1325
+ state: admitted.admissionState,
1326
+ ...preflight.linkId === undefined ? {} : { linkId: preflight.linkId },
1327
+ direction: preflight.direction,
1328
+ path: "$.linkId"
1329
+ });
1330
+ executionQuery = admitted.query;
1331
+ }
1332
+ const clearance = await this.#security.clearance.current();
1333
+ if (clearance) {
1334
+ assertLinkQueryReadable({
1335
+ ontology: this.#ontology.registry,
1336
+ clearance,
1337
+ query,
1338
+ request: { ...request, projectId: this.#security.runtime.projectId },
1339
+ viewableByGrants: (objectTypeId) => this.#security.isObjectTypeViewable(objectTypeId, undefined)
1340
+ });
1341
+ }
1342
+ const result = detachReadResult(await executeObjectQueryLinks2({ query: executionQuery, ...request, projectId: this.#security.runtime.projectId }, this.#queryExecutorOptions(clearance)));
1343
+ if (result.objects.some((row) => !this.#security.isObjectTypeViewable(row.objectTypeId, clearance)) || result.links.some((link) => !this.#security.isLinkViewable(link, clearance))) {
1344
+ throw new Error("[Sixb] Object storage returned a link page outside its authorized scope.");
1345
+ }
1346
+ return {
1347
+ ...result,
1348
+ objects: result.objects.map((row) => clearance ? redactObjectRow(row, clearance) : row)
1349
+ };
1350
+ }
1351
+ async count(input) {
1352
+ const query = snapshotAuthoredQuery(input.query);
1353
+ const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query;
1354
+ const clearance = await this.#security.clearance.current();
1355
+ return detachReadResult(await countObjects2({ query: executionQuery, projectId: this.#security.runtime.projectId }, this.#queryExecutorOptions(clearance)));
1356
+ }
1357
+ async exists(input) {
1358
+ const query = snapshotAuthoredQuery(input.query);
1359
+ const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query;
1360
+ const clearance = await this.#security.clearance.current();
1361
+ return detachReadResult(await existsObjects2({ query: executionQuery, projectId: this.#security.runtime.projectId }, this.#queryExecutorOptions(clearance)));
1362
+ }
1363
+ async facet(input) {
1364
+ const query = snapshotAuthoredQuery(input.query);
1365
+ const facets = snapshotFacetRequests(input.facets);
1366
+ let executionQuery = query;
1367
+ let executionFacets = facets;
1368
+ const admission = this.#security.delegation?.queryAdmission;
1369
+ if (admission) {
1370
+ const validated = validateObjectQuery2(query, { ontology: this.#ontology.registry });
1371
+ const normalizedFacets = validateObjectFacetRequests(facets, validated.result.objectTypeIds, {
1372
+ ontology: this.#ontology.registry
1373
+ });
1374
+ const admitted = validateObjectQueryWithAdmission(validated.query, { ontology: this.#ontology.registry, normalize: false }, admission);
1375
+ normalizedFacets.forEach((facet, index) => {
1376
+ admission.assertPropertySelected({
1377
+ state: admitted.admissionState,
1378
+ propertyId: facet.propertyId,
1379
+ use: "facet",
1380
+ path: `$.facets[${index}].propertyId`
1381
+ });
1382
+ });
1383
+ executionQuery = admitted.query;
1384
+ executionFacets = normalizedFacets;
1385
+ }
1386
+ const clearance = await this.#security.clearance.current();
1387
+ return detachReadResult(await facetObjects2({
1388
+ query: executionQuery,
1389
+ facets: executionFacets,
1390
+ projectId: this.#security.runtime.projectId
1391
+ }, this.#queryExecutorOptions(clearance)));
1392
+ }
1393
+ async writtenRowRedactor(objectTypeId) {
1394
+ const clearance = await this.#security.clearance.current();
1395
+ assertTargetsReadable(clearance, { objectTypeIds: [objectTypeId] });
1396
+ return (row) => clearance ? redactObjectRow(row, clearance) : row;
1397
+ }
1398
+ async assertReadable(targets) {
1399
+ assertTargetsReadable(await this.#security.clearance.current(), targets);
1400
+ }
1401
+ assertVisibleOutputWithinLimit(value) {
1402
+ if (this.#security.authority.type !== "delegated")
1403
+ return;
1404
+ assertObjectReadOutputWithinLimit2(value, this.#security.authority.objectRead.limits);
1405
+ }
1406
+ admitTelemetryHistoryRead(input) {
1407
+ return admitTelemetryHistoryReadWorkload(input, this.#security.authority.type === "delegated");
1408
+ }
1409
+ #queryExecutorOptions(clearance) {
1410
+ const admission = this.#executorAdmission(clearance);
1411
+ if (this.#security.authority.type === "delegated") {
1412
+ return {
1413
+ ontology: this.#ontology.registry,
1414
+ storage: this.#storage,
1415
+ embeddingModels: this.#models.embedding,
1416
+ rerankingModels: this.#models.reranking,
1417
+ ...admission === undefined ? {} : { admission }
1418
+ };
1419
+ }
1420
+ return {
1421
+ ontology: this.#ontology.registry,
1422
+ embeddingModels: this.#models.embedding,
1423
+ rerankingModels: this.#models.reranking,
1424
+ storage: this.#storage,
1425
+ runtimeAuthorization: this.#security.runtime.runtimeAuthorization,
1426
+ ...this.#security.runtime.authorization === undefined ? {} : { authorization: this.#security.runtime.authorization },
1427
+ ...admission === undefined ? {} : { admission }
1428
+ };
1429
+ }
1430
+ #executorAdmission(clearance) {
1431
+ const admission = clearance && createClearanceQueryAdmission(clearance);
1432
+ const selected = this.#security.delegation?.queryAdmission;
1433
+ if (selected && admission)
1434
+ return composeObjectQueryAdmissions(selected, admission);
1435
+ return selected ?? admission;
1436
+ }
1437
+ #omitHidden(row, clearance) {
1438
+ return clearance ? omitHiddenProperties(row, clearance) : row;
1439
+ }
1440
+ #detachRows(result, rows, clearance) {
1441
+ const detached = detachReadResult(result);
1442
+ if (clearance) {
1443
+ for (const row of rows(detached))
1444
+ if (row)
1445
+ attachRedactions(row, clearance);
1446
+ }
1447
+ return detached;
1448
+ }
1449
+ #admitDelegatedQuery(query) {
1450
+ const admission = this.#security.delegation?.queryAdmission;
1451
+ if (!admission)
1452
+ return;
1453
+ return validateObjectQueryWithAdmission(query, { ontology: this.#ontology.registry }, admission);
1454
+ }
1455
+ #resolveListObjectTypes(requested, clearance) {
1456
+ if (requested !== undefined) {
1457
+ const objectTypeIds = typeof requested === "string" ? [requested] : [...new Set(requested)];
1458
+ for (const objectTypeId of objectTypeIds) {
1459
+ this.#ontology.registry.resolveObjectType(objectTypeId);
1460
+ }
1461
+ this.#security.assertObjectTypesViewable(objectTypeIds, clearance);
1462
+ return typeof requested === "string" ? requested : objectTypeIds;
1463
+ }
1464
+ if (this.#security.authority.type === "unrestricted")
1465
+ return;
1466
+ return this.#ontology.registry.listObjectTypes().map((objectType) => objectType.id).filter((objectTypeId) => this.#security.isObjectTypeViewable(objectTypeId, clearance));
1467
+ }
1468
+ }
1469
+ Object.freeze(AuthorizedObjectReaderImpl.prototype);
1470
+ Object.freeze(AuthorizedObjectReaderImpl);
1471
+ function createAuthorizedObjectReader(input) {
1472
+ const scope = captureExecutionScope(input.scope);
1473
+ const projectId = scope.execution.projectId;
1474
+ const authority = resolveExecutionScopeAuthorization(projectId, scope);
1475
+ const storage = objectStorageForAuthority(authority, input.objectStorage);
1476
+ const reader = new AuthorizedObjectReaderImpl(readerConstructionKey, {
1477
+ ontology: new ObjectReaderOntology(input.ontology, authority),
1478
+ security: new ObjectReaderSecurity({
1479
+ authorization: scope.authorization,
1480
+ authority,
1481
+ projectId,
1482
+ ontology: input.ontology,
1483
+ ...input.appliedMarkings === undefined ? {} : { appliedMarkings: input.appliedMarkings }
1484
+ }),
1485
+ models: Object.freeze({
1486
+ ...input.embeddingModels === undefined ? {} : { embedding: input.embeddingModels },
1487
+ ...input.rerankingModels === undefined ? {} : { reranking: input.rerankingModels }
1488
+ }),
1489
+ storage
1490
+ });
1491
+ Object.freeze(reader);
1492
+ return reader;
1493
+ }
1494
+ function assertAuthorizedObjectReaderBinding(input) {
1495
+ AuthorizedObjectReaderImpl.assertBound(input.reader, input.scope);
1496
+ }
1497
+ function getAuthorizedOntologyView(reader) {
1498
+ return AuthorizedObjectReaderImpl.ontologyView(reader);
1499
+ }
1500
+ function readerClearance(reader) {
1501
+ return AuthorizedObjectReaderImpl.clearance(reader);
1502
+ }
1503
+ function readerEventClearance(reader, sources) {
1504
+ return AuthorizedObjectReaderImpl.eventClearance(reader, sources);
1505
+ }
1506
+ function assertTargetsReadable(clearance, targets) {
1507
+ if (!clearance)
1508
+ return;
1509
+ for (const objectTypeId of targets.objectTypeIds) {
1510
+ const unreadable = clearance.unreadableType(objectTypeId);
1511
+ if (unreadable)
1512
+ throw unreadableError(unreadable);
1513
+ }
1514
+ for (const link of targets.links ?? []) {
1515
+ const unreadable = clearance.unreadableLink(link.objectTypeId, link.linkId);
1516
+ if (unreadable)
1517
+ throw unreadableError(unreadable);
1518
+ }
1519
+ }
1520
+ function hidesProperty(item, clearance) {
1521
+ return clearance?.missingMarking(item.objectTypeId, item.propertyId) !== undefined;
1522
+ }
1523
+ function objectStorageForAuthority(authority, objectStorage) {
1524
+ switch (authority.type) {
1525
+ case "principal":
1526
+ case "unrestricted":
1527
+ return objectStorage;
1528
+ case "delegated":
1529
+ return objectStorage.createSelectedReadScope({
1530
+ projectId: authority.projectId,
1531
+ scope: authority.objectRead.scope,
1532
+ limits: authority.objectRead.limits
1533
+ });
1534
+ default:
1535
+ return assertNever(authority, `[Sixb] Unsupported object reader authority '${String(authority.type)}'.`);
1536
+ }
1537
+ }
1538
+ function detachReadResult(value) {
1539
+ return structuredClone(value);
1540
+ }
1541
+ function snapshotReadValue(value) {
1542
+ return structuredClone(value);
1543
+ }
1544
+ function snapshotFacetRequests(facets) {
1545
+ if (!Array.isArray(facets)) {
1546
+ throw new ObjectQueryValidationError2([
1547
+ {
1548
+ path: "$.facets",
1549
+ code: "invalid_facets",
1550
+ message: "facets must be an array"
1551
+ }
1552
+ ]);
1553
+ }
1554
+ const length = facets.length;
1555
+ if (!Number.isSafeInteger(length) || length > MAX_OBJECT_READ_FACETS2) {
1556
+ throw new ObjectQueryValidationError2([
1557
+ {
1558
+ path: "$.facets",
1559
+ code: "too_many_facets",
1560
+ message: `facets must include at most ${MAX_OBJECT_READ_FACETS2} facet requests`
1561
+ }
1562
+ ]);
1563
+ }
1564
+ const snapshot = [];
1565
+ for (let index = 0;index < length; index += 1) {
1566
+ const facet = facets[index];
1567
+ snapshot.push({ propertyId: facet.propertyId, limit: facet.limit });
1568
+ }
1569
+ return snapshot;
1570
+ }
1571
+ function snapshotAuthoredQuery(query) {
1572
+ try {
1573
+ const snapshot = structuredClone(query);
1574
+ const pending = [snapshot];
1575
+ const seen = new Set;
1576
+ for (const node of pending) {
1577
+ if (seen.has(node))
1578
+ continue;
1579
+ seen.add(node);
1580
+ if (node.kind === "vector" && (typeof node.vector !== "string" || typeof node.profile !== "string" || ("propertyId" in node))) {
1581
+ throw new ObjectQueryValidationError2([
1582
+ {
1583
+ path: "$",
1584
+ code: "invalid_vector_search_input",
1585
+ message: "Vector search requires a named profile and search text"
1586
+ }
1587
+ ]);
1588
+ }
1589
+ if ("input" in node)
1590
+ pending.push(node.input);
1591
+ if (node.kind === "set")
1592
+ pending.push(...node.inputs);
1593
+ }
1594
+ return snapshot;
1595
+ } catch (error) {
1596
+ if (error instanceof ObjectQueryValidationError2)
1597
+ throw error;
1598
+ throw new ObjectQueryValidationError2([
1599
+ {
1600
+ path: "$",
1601
+ code: "query_not_cloneable",
1602
+ message: "Object query must contain only structured-cloneable data"
1603
+ }
1604
+ ]);
1605
+ }
1606
+ }
1607
+
1608
+ // src/actions/run-authorization.ts
1609
+ async function canReadActionRunSubject(objectReader, run) {
1610
+ if (run.subject.kind !== "object")
1611
+ return true;
1612
+ const clearance = await readerClearance(objectReader);
1613
+ return clearance?.unreadableType(run.subject.objectTypeId) === undefined;
1614
+ }
1615
+ async function unreadableActionRunTypes(objectReader) {
1616
+ const clearance = await readerClearance(objectReader);
1617
+ return new Set(clearance?.unreadable().types.keys());
1618
+ }
1619
+ async function canDelegationAccessActionRun(input) {
1620
+ const subject = input.run.subject;
1621
+ if (!input.authority.delegation || subject.kind !== "object" || !input.authority.actionApply.some((target) => target.actionId === input.run.actionId && target.subject.objectTypeId === subject.objectTypeId && target.subject.primaryId === subject.primaryId)) {
1622
+ return false;
1623
+ }
1624
+ return actionRunBelongsToShareGrant({
1625
+ storage: input.storage,
1626
+ projectId: input.projectId,
1627
+ run: input.run,
1628
+ grantId: input.authority.delegation.grantId
1629
+ });
1630
+ }
1631
+ async function actionRunBelongsToShareGrant(input) {
1632
+ const parent = await findPrimitiveParentRequestExecution({
1633
+ executions: input.storage.executions,
1634
+ projectId: input.projectId,
1635
+ executionId: input.run.executionId,
1636
+ primitive: { kind: "action", id: input.run.actionId, runId: input.run.id }
1637
+ });
1638
+ const authorization = parent?.authorizationRef;
1639
+ return authorization?.type === "delegated" && authorization.delegation.kind === "share" && authorization.delegation.grantId === input.grantId;
1640
+ }
1641
+
1642
+ // src/runtime/ai-cost.ts
1643
+ async function resolveExecutionCosts(input) {
1644
+ if (input.executionIds.length === 0)
1645
+ return [];
1646
+ if (!input.storage)
1647
+ return input.executionIds.map(() => {
1648
+ return;
1649
+ });
1650
+ return input.storage.summarizeExecutions({
1651
+ projectId: input.projectId,
1652
+ executionIds: input.executionIds
1653
+ });
1654
+ }
1655
+
1656
+ // src/activity/timeline.ts
1657
+ var ACTIVITY_TIMELINE_LIMIT = 200;
1658
+ var SESSION_GRACE_MS = ACTIVITY_MIN_IDLE_TIMEOUT_MS / 2;
1659
+ async function composeActivityTimeline(runtime, input, now) {
1660
+ const { page, visit } = input;
1661
+ const { storage, projectId } = runtime;
1662
+ const [ledger, connection] = await Promise.all([
1663
+ storage.executions.listBySession({
1664
+ projectId,
1665
+ session: { type: visit.actor.type, id: page.sessionId },
1666
+ ...sessionWindow(visit),
1667
+ limit: ACTIVITY_TIMELINE_LIMIT
1668
+ }),
1669
+ readActivityConnection(runtime, page, input.grant, now)
1670
+ ]);
1671
+ const executions = ledger.executions;
1672
+ const ofKind = (kind) => executions.flatMap((execution) => execution.executor.type === "primitive" && execution.executor.kind === kind ? [execution.id] : []);
1673
+ const agentRunIds = executions.flatMap((execution) => execution.executor.type === "agent" ? [execution.executor.runId] : []);
1674
+ const byId = new Map(executions.map((execution) => [execution.id, execution]));
1675
+ const withAgent = executions.filter((execution) => lineage(execution, byId).some((ancestor) => ancestor.executor.type === "agent"));
1676
+ const [actionRuns, workflowRuns, agentRuns, costs] = await Promise.all([
1677
+ storage.actionRuns?.getByExecutionIds({ projectId, executionIds: ofKind("action") }) ?? [],
1678
+ storage.workflowRuns?.getByExecutionIds({ projectId, executionIds: ofKind("workflow") }) ?? [],
1679
+ storage.agents?.runs.getByIds({ projectId, ids: agentRunIds }) ?? [],
1680
+ resolveExecutionCosts({
1681
+ storage: storage.aiCosts,
1682
+ projectId,
1683
+ executionIds: withAgent.map((execution) => execution.id)
1684
+ })
1685
+ ]);
1686
+ const conversations = new Map(agentRuns.flatMap((run) => run.kind === "conversation" ? [[run.executionId, run]] : []));
1687
+ const subjects = actionRuns.flatMap((run) => run.subject.kind === "object" ? [run.subject] : []);
1688
+ const [threads, readable, unreadableRunTypes] = await Promise.all([
1689
+ storage.agents?.threads.getByIds({
1690
+ projectId,
1691
+ ids: [...conversations.values()].map((run) => run.threadId)
1692
+ }) ?? [],
1693
+ readableObjects(runtime, subjects),
1694
+ subjects.length > 0 ? unreadableActionRunTypes(runtime.objectReader) : new Set
1695
+ ]);
1696
+ const actionRunByExecution = new Map(actionRuns.map((run) => [run.executionId, run]));
1697
+ const workflowRunByExecution = new Map(workflowRuns.map((run) => [run.executionId, run]));
1698
+ const messagesByThread = new Map(threads.map((thread) => [thread.id, thread.messageCount]));
1699
+ const costByAgent = rollUpCosts(byId, conversations, withAgent, costs);
1700
+ const executionEntries = executions.flatMap((execution) => {
1701
+ const at = new Date(execution.createdAt);
1702
+ const executor = execution.executor;
1703
+ const authority = execution.authorizationRef;
1704
+ if (executor.type === "primitive" && authority.type === "trustedPrimitive") {
1705
+ if (executor.kind === "action") {
1706
+ const run = actionRunByExecution.get(execution.id);
1707
+ const subject = run?.subject.kind === "object" ? run.subject : undefined;
1708
+ const object = subject && readable.has(objectBatchKey2(subject.objectTypeId, subject.primaryId)) ? { objectTypeId: subject.objectTypeId, primaryId: subject.primaryId } : undefined;
1709
+ const runVisible = run !== undefined && canViewActionRun2(runtime.authorization, run) && (subject === undefined || !unreadableRunTypes.has(subject.objectTypeId));
1710
+ return [
1711
+ {
1712
+ kind: "action",
1713
+ at,
1714
+ executionId: execution.id,
1715
+ actionId: authority.primitive.id,
1716
+ runId: executor.runId,
1717
+ status: run?.status ?? "incomplete",
1718
+ runVisible,
1719
+ ...object === undefined ? {} : { object }
1720
+ }
1721
+ ];
1722
+ }
1723
+ if (executor.kind === "workflow") {
1724
+ const run = workflowRunByExecution.get(execution.id);
1725
+ return [
1726
+ {
1727
+ kind: "workflow",
1728
+ at,
1729
+ executionId: execution.id,
1730
+ workflowId: authority.primitive.id,
1731
+ runId: executor.runId,
1732
+ status: run?.status ?? "incomplete",
1733
+ runVisible: run !== undefined && canViewWorkflowRun2(runtime.authorization, run)
1734
+ }
1735
+ ];
1736
+ }
1737
+ }
1738
+ const conversation = conversations.get(execution.id);
1739
+ if (conversation) {
1740
+ const cost = costByAgent.get(execution.id);
1741
+ return [
1742
+ {
1743
+ kind: "agent",
1744
+ at,
1745
+ executionId: execution.id,
1746
+ runId: conversation.id,
1747
+ threadId: conversation.threadId,
1748
+ status: conversation.status,
1749
+ messages: messagesByThread.get(conversation.threadId) ?? 0,
1750
+ ...cost === undefined ? {} : { cost }
1751
+ }
1752
+ ];
1753
+ }
1754
+ return [];
1755
+ });
1756
+ const recorded = [
1757
+ ...page.pageViews.map((pageView) => ({
1758
+ kind: "page",
1759
+ at: new Date(pageView.receivedAt),
1760
+ sequence: pageView.sequence,
1761
+ route: pageView.route
1762
+ })),
1763
+ ...page.interactions.map((interaction) => ({
1764
+ kind: "interaction",
1765
+ at: new Date(interaction.receivedAt),
1766
+ sequence: interaction.sequence,
1767
+ name: interaction.name,
1768
+ route: interaction.route
1769
+ }))
1770
+ ].sort((left, right) => left.sequence - right.sequence);
1771
+ const cutoffs = [
1772
+ page.hasMore ? recorded.at(-1)?.at : undefined,
1773
+ ledger.truncated ? executions.filter((execution) => execution.source.type !== "execution").at(-1)?.createdAt : undefined
1774
+ ].flatMap((at) => at === undefined ? [] : [at.getTime()]);
1775
+ const cutoff = cutoffs.length > 0 ? Math.min(...cutoffs) : Number.POSITIVE_INFINITY;
1776
+ const entries = [...recorded, ...executionEntries].filter((entry) => entry.at.getTime() <= cutoff).sort((left, right) => left.at.getTime() - right.at.getTime());
1777
+ return {
1778
+ visit,
1779
+ ...connection === undefined ? {} : { connection },
1780
+ entries,
1781
+ truncated: page.hasMore || ledger.truncated
1782
+ };
1783
+ }
1784
+ function sessionWindow(visit) {
1785
+ const startedAt = visit.startedAt.getTime();
1786
+ return {
1787
+ from: new Date(startedAt - SESSION_GRACE_MS),
1788
+ to: new Date(Math.min(visit.lastSeenAt.getTime() + SESSION_GRACE_MS, startedAt + ACTIVITY_MAX_VISIT_MS2 - SESSION_GRACE_MS))
1789
+ };
1790
+ }
1791
+ function lineage(execution, byId) {
1792
+ const chain = [];
1793
+ let current = execution;
1794
+ while (current) {
1795
+ chain.push(current);
1796
+ current = current.source.type === "execution" ? byId.get(current.source.executionId) : undefined;
1797
+ }
1798
+ return chain;
1799
+ }
1800
+ function rollUpCosts(byId, conversations, withAgent, costs) {
1801
+ const grouped = new Map;
1802
+ withAgent.forEach((execution, index) => {
1803
+ const cost = costs[index];
1804
+ const owner = lineage(execution, byId).find((ancestor) => conversations.has(ancestor.id));
1805
+ if (!cost || !owner) {
1806
+ return;
1807
+ }
1808
+ const summaries = grouped.get(owner.id) ?? [];
1809
+ summaries.push(cost);
1810
+ grouped.set(owner.id, summaries);
1811
+ });
1812
+ return new Map([...grouped].flatMap(([owner, summaries]) => {
1813
+ const total = addCosts(summaries);
1814
+ return total ? [[owner, total]] : [];
1815
+ }));
1816
+ }
1817
+ function addCosts(summaries) {
1818
+ const amounts = new Map;
1819
+ let ratedCallCount = 0;
1820
+ let unpriceableCallCount = 0;
1821
+ let unvaluedCallCount = 0;
1822
+ for (const summary of summaries) {
1823
+ for (const money of summary.amounts) {
1824
+ amounts.set(money.currency, (amounts.get(money.currency) ?? 0n) + BigInt(money.amountNanos));
1825
+ }
1826
+ ratedCallCount += summary.ratedCallCount;
1827
+ unpriceableCallCount += summary.unpriceableCallCount;
1828
+ unvaluedCallCount += summary.unvaluedCallCount;
1829
+ }
1830
+ if (ratedCallCount + unpriceableCallCount + unvaluedCallCount === 0) {
1831
+ return;
1832
+ }
1833
+ return {
1834
+ amounts: [...amounts].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([currency, amount]) => ({ currency, amountNanos: amount.toString() })),
1835
+ ratedCallCount,
1836
+ unpriceableCallCount,
1837
+ unvaluedCallCount
1838
+ };
1839
+ }
1840
+ async function readableObjects(runtime, subjects) {
1841
+ const byType = new Map;
1842
+ for (const subject of subjects) {
1843
+ const items = byType.get(subject.objectTypeId) ?? new Map;
1844
+ items.set(subject.primaryId, subject);
1845
+ byType.set(subject.objectTypeId, items);
1846
+ }
1847
+ const readable = new Set;
1848
+ await Promise.all([...byType.values()].map(async (items) => {
1849
+ try {
1850
+ const rows = await runtime.objectReader.getByPrimaryIdBatch({ items: [...items.values()] });
1851
+ for (const key of rows.keys()) {
1852
+ readable.add(key);
1853
+ }
1854
+ } catch (error) {
1855
+ if (!(error instanceof AuthorizationError2)) {
1856
+ throw error;
1857
+ }
1858
+ }
1859
+ }));
1860
+ return readable;
1861
+ }
1862
+
1863
+ // src/activity/execution.ts
1864
+ var PROFILE_READ_CONCURRENCY = 8;
1865
+ function createActivityRuntime(runtime, service) {
1866
+ const assertObservable = () => assertAuthorized2(runtime, { kind: "activity.observe" });
1867
+ return {
1868
+ async list(query) {
1869
+ assertObservable();
1870
+ const page = await service.list(query);
1871
+ return { ...page, visits: await nameSharedVisits(runtime, page.visits) };
1872
+ },
1873
+ async users(query) {
1874
+ assertObservable();
1875
+ const page = await service.users(query);
1876
+ const users = await mapInChunks(page.users, PROFILE_READ_CONCURRENCY, async (user) => {
1877
+ const profile = await runtime.storage.auth?.users.getById({
1878
+ projectId: runtime.projectId,
1879
+ id: user.userId
1880
+ });
1881
+ return profile?.displayName ? { ...user, displayName: profile.displayName } : user;
1882
+ });
1883
+ return { users, hasMore: page.hasMore };
1884
+ },
1885
+ async summarize(query) {
1886
+ assertObservable();
1887
+ return service.summarize(query);
1888
+ },
1889
+ async calendar(query) {
1890
+ assertObservable();
1891
+ return service.calendar(query);
1892
+ },
1893
+ async timeline(visitId) {
1894
+ assertObservable();
1895
+ const page = await service.readWithSession({ id: visitId, limit: ACTIVITY_TIMELINE_LIMIT });
1896
+ if (!page) {
1897
+ return null;
1898
+ }
1899
+ const shared = await nameSharedVisit(runtime, page.visit);
1900
+ return composeActivityTimeline(runtime, { ...shared, page }, new Date);
1901
+ },
1902
+ async connections(query) {
1903
+ assertObservable();
1904
+ return readActivityConnections(runtime, service, query, new Date);
1905
+ }
1906
+ };
1907
+ }
1908
+ function createActivityCaptureRuntime(runtime, service) {
1909
+ return {
1910
+ captureOptions() {
1911
+ captureSource(runtime);
1912
+ return service.captureOptions;
1913
+ },
1914
+ async capture(events) {
1915
+ return service.capture(captureSource(runtime), events);
1916
+ }
1917
+ };
1918
+ }
1919
+ var activityCaptureKey = Symbol("sixb.activityCapture");
1920
+ function registerActivityCaptureRuntime(owner, capture) {
1921
+ Object.defineProperty(owner, activityCaptureKey, {
1922
+ configurable: false,
1923
+ enumerable: false,
1924
+ value: capture,
1925
+ writable: false
1926
+ });
1927
+ }
1928
+ function getActivityCaptureRuntime2(owner) {
1929
+ const capture = owner[activityCaptureKey];
1930
+ if (!capture) {
1931
+ throw new Error("[Sixb] Activity capture is not registered for this execution.");
1932
+ }
1933
+ return capture;
1934
+ }
1935
+ function captureSource(runtime) {
1936
+ const ref = getAuthorizationRef(runtime.runtimeAuthorization);
1937
+ if (ref.type === "principal" && ref.principal.type === "user" && ref.credential?.type === "session") {
1938
+ return {
1939
+ actor: { type: "user", userId: ref.principal.id },
1940
+ sessionId: ref.credential.id
1941
+ };
1942
+ }
1943
+ if (ref.type === "delegated") {
1944
+ return {
1945
+ actor: { type: "share", grantId: ref.delegation.grantId },
1946
+ sessionId: ref.delegation.sessionId
1947
+ };
1948
+ }
1949
+ throw new AuthorizationError2("activity.capture", "[Sixb] Activity is recorded only for a signed-in user's session or a shared link's session.");
1950
+ }
1951
+ async function mapInChunks(items, size, map) {
1952
+ const results = [];
1953
+ for (let start = 0;start < items.length; start += size) {
1954
+ const chunk = await Promise.all(items.slice(start, start + size).map(map));
1955
+ results.push(...chunk);
1956
+ }
1957
+ return results;
1958
+ }
1959
+
1960
+ // src/models/execution/session.ts
1961
+ class ModelExecutionSession {
1962
+ runtime;
1963
+ execution;
1964
+ binding;
1965
+ recorder;
1966
+ constructor(runtime, execution) {
1967
+ this.runtime = runtime;
1968
+ this.execution = execution;
1969
+ }
1970
+ bind(input) {
1971
+ if (this.binding)
1972
+ throw new Error("[SixbModels] Execution attempt is already bound.");
1973
+ this.binding = { ...input };
1974
+ }
1975
+ signal(signal) {
1976
+ const binding = this.requireBinding();
1977
+ return signal ? AbortSignal.any([binding.signal, signal]) : binding.signal;
1978
+ }
1979
+ async admitEmbeddingCall(admit) {
1980
+ const admission = this.requireBinding().embeddingAdmission;
1981
+ if (admission)
1982
+ await admission(admit);
1983
+ else
1984
+ await admit();
1985
+ }
1986
+ accounting() {
1987
+ const { accounting } = this.requireBinding();
1988
+ this.recorder ??= accounting ? Promise.resolve(accounting) : this.createRecorder();
1989
+ return this.recorder;
1990
+ }
1991
+ requireBinding() {
1992
+ if (!this.binding) {
1993
+ throw new Error("[SixbModels] Model calls require a bound request or worker execution attempt.");
1994
+ }
1995
+ return this.binding;
1996
+ }
1997
+ async createRecorder() {
1998
+ const runtime = this.runtime;
1999
+ const execution = this.execution;
2000
+ const { attempt } = this.requireBinding();
2001
+ const storage = {
2002
+ ...requireAccountingCapabilities(runtime.storage),
2003
+ transaction: runtime.storage.transaction.bind(runtime.storage)
2004
+ };
2005
+ const { requesterGroupIds } = await ensureExecutionRecord2(runtime.storage.executions, executionRecordInputFromRuntime({
2006
+ execution,
2007
+ runtimeAuthorization: runtime.runtimeAuthorization
2008
+ }));
2009
+ return new AiModelCallRecorder2({
2010
+ storage,
2011
+ projectId: runtime.projectId,
2012
+ executionId: execution.id,
2013
+ attempt,
2014
+ requesterGroupIds,
2015
+ limits: createAiModelCallLimitController2({
2016
+ storage,
2017
+ projectId: runtime.projectId,
2018
+ requestedBy: execution.requestedBy,
2019
+ requesterGroupIds
2020
+ }),
2021
+ recoverAiModelCall: (input) => enqueueAiModelCallRecovery2(runtime.queues.agents, input)
2022
+ });
2023
+ }
2024
+ }
2025
+
2026
+ export { redactDomainEvent, createAuthorizedObjectReader, assertAuthorizedObjectReaderBinding, getAuthorizedOntologyView, readerClearance, readerEventClearance, registerOntologyMutationRuntime2, getOntologyMutationRuntime2, shareOntologyMutationRuntime2, createOntologyMutationRuntime2, canReadActionRunSubject, unreadableActionRunTypes, canDelegationAccessActionRun, actionRunBelongsToShareGrant, decodeActivityConnectionsCursor, resolveExecutionCosts, createActivityRuntime, createActivityCaptureRuntime, registerActivityCaptureRuntime, getActivityCaptureRuntime2, ModelExecutionSession };
2027
+
2028
+ //# debugId=84DA6826BB3C05B764756E2164756E21