@sixb/core 0.1.7 → 0.1.8

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 (612) hide show
  1. package/dist/actions/delegated-admission.d.ts +24 -0
  2. package/dist/actions/delegated-admission.d.ts.map +1 -0
  3. package/dist/actions/descriptor.d.ts +29 -0
  4. package/dist/actions/descriptor.d.ts.map +1 -0
  5. package/dist/actions/execution.d.ts +5 -5
  6. package/dist/actions/execution.d.ts.map +1 -1
  7. package/dist/actions/index.js +36 -30
  8. package/dist/actions/index.js.map +1 -1
  9. package/dist/actions/request.d.ts.map +1 -1
  10. package/dist/actions/run-authorization.d.ts +20 -0
  11. package/dist/actions/run-authorization.d.ts.map +1 -0
  12. package/dist/actions/run-dispatch.d.ts +3 -1
  13. package/dist/actions/run-dispatch.d.ts.map +1 -1
  14. package/dist/actions/worker.js +3 -3
  15. package/dist/actions/worker.js.map +1 -1
  16. package/dist/agents/adapters.d.ts +5 -122
  17. package/dist/agents/adapters.d.ts.map +1 -1
  18. package/dist/agents/authority.d.ts +1 -1
  19. package/dist/agents/authority.d.ts.map +1 -1
  20. package/dist/agents/context-resolution.d.ts.map +1 -1
  21. package/dist/agents/context.js +1 -1
  22. package/dist/agents/errors.d.ts +0 -9
  23. package/dist/agents/errors.d.ts.map +1 -1
  24. package/dist/agents/execution.d.ts.map +1 -1
  25. package/dist/agents/identity.d.ts +3 -0
  26. package/dist/agents/identity.d.ts.map +1 -0
  27. package/dist/agents/index.d.ts +3 -3
  28. package/dist/agents/index.d.ts.map +1 -1
  29. package/dist/agents/index.js +43 -43
  30. package/dist/agents/index.js.map +1 -1
  31. package/dist/agents/message.d.ts +4 -5
  32. package/dist/agents/message.d.ts.map +1 -1
  33. package/dist/agents/model-loop.d.ts +2 -0
  34. package/dist/agents/model-loop.d.ts.map +1 -1
  35. package/dist/agents/request.d.ts.map +1 -1
  36. package/dist/agents/tool-definition.d.ts +0 -1
  37. package/dist/agents/tool-definition.d.ts.map +1 -1
  38. package/dist/agents/validation.d.ts +0 -4
  39. package/dist/agents/validation.d.ts.map +1 -1
  40. package/dist/ai-usage/execution.d.ts.map +1 -1
  41. package/dist/auth/index.js +8 -5
  42. package/dist/auth/index.js.map +1 -1
  43. package/dist/authorization/decision.d.ts +10 -2
  44. package/dist/authorization/decision.d.ts.map +1 -1
  45. package/dist/authorization/grant-kinds.d.ts +2 -1
  46. package/dist/authorization/grant-kinds.d.ts.map +1 -1
  47. package/dist/authorization/index.d.ts +1 -1
  48. package/dist/authorization/index.d.ts.map +1 -1
  49. package/dist/authorization/index.js +7 -4
  50. package/dist/authorization/index.js.map +1 -1
  51. package/dist/bootstrap/discovery.d.ts +7 -1
  52. package/dist/bootstrap/discovery.d.ts.map +1 -1
  53. package/dist/bootstrap/index.js +46 -39
  54. package/dist/bootstrap/index.js.map +1 -1
  55. package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -1
  56. package/dist/chunk-19jp6g9d.js +131 -0
  57. package/dist/chunk-19jp6g9d.js.map +11 -0
  58. package/dist/{chunk-x0qhkqje.js → chunk-2dw777qw.js} +50 -5
  59. package/dist/{chunk-x0qhkqje.js.map → chunk-2dw777qw.js.map} +4 -3
  60. package/dist/chunk-359jm1jw.js +147 -0
  61. package/dist/chunk-359jm1jw.js.map +10 -0
  62. package/dist/{chunk-2b5qtban.js → chunk-3xep5cjx.js} +56 -21
  63. package/dist/chunk-3xep5cjx.js.map +15 -0
  64. package/dist/{chunk-qjycjdj6.js → chunk-3z1qec12.js} +6 -8
  65. package/dist/{chunk-qjycjdj6.js.map → chunk-3z1qec12.js.map} +2 -2
  66. package/dist/{chunk-5jcdmjam.js → chunk-4jjp5k14.js} +1 -1
  67. package/dist/{chunk-n2arzn6e.js → chunk-4qfkag59.js} +44 -221
  68. package/dist/chunk-4qfkag59.js.map +20 -0
  69. package/dist/{chunk-rre42skh.js → chunk-4sm0aznx.js} +515 -80
  70. package/dist/{chunk-rre42skh.js.map → chunk-4sm0aznx.js.map} +11 -7
  71. package/dist/chunk-4yqmp43v.js +159 -0
  72. package/dist/chunk-4yqmp43v.js.map +11 -0
  73. package/dist/{chunk-atmkaf60.js → chunk-5e3pq99w.js} +2 -6
  74. package/dist/{chunk-atmkaf60.js.map → chunk-5e3pq99w.js.map} +3 -3
  75. package/dist/{chunk-agsvg9ar.js → chunk-5ntny1qx.js} +1 -1
  76. package/dist/{chunk-z2sery1b.js → chunk-9nbmsvn5.js} +60 -20
  77. package/dist/chunk-9nbmsvn5.js.map +11 -0
  78. package/dist/{chunk-e4rvtvpw.js → chunk-aa2pen2v.js} +250 -78
  79. package/dist/chunk-aa2pen2v.js.map +34 -0
  80. package/dist/{chunk-64sr682n.js → chunk-ajnan18g.js} +11 -8
  81. package/dist/chunk-ajnan18g.js.map +12 -0
  82. package/dist/{chunk-9aehf39w.js → chunk-f26bck4t.js} +4 -4
  83. package/dist/{chunk-7ds9620f.js → chunk-fvt9rjsa.js} +23 -7
  84. package/dist/chunk-fvt9rjsa.js.map +10 -0
  85. package/dist/{chunk-kt81c11h.js → chunk-gbejpkex.js} +5 -5
  86. package/dist/{chunk-kt81c11h.js.map → chunk-gbejpkex.js.map} +1 -1
  87. package/dist/{chunk-vjjv9mrb.js → chunk-gzasd5b6.js} +5 -5
  88. package/dist/{chunk-vjjv9mrb.js.map → chunk-gzasd5b6.js.map} +3 -3
  89. package/dist/{chunk-d63tybny.js → chunk-h0k55pc7.js} +4 -4
  90. package/dist/{chunk-d63tybny.js.map → chunk-h0k55pc7.js.map} +1 -1
  91. package/dist/chunk-h5vqbfmd.js +1537 -0
  92. package/dist/chunk-h5vqbfmd.js.map +19 -0
  93. package/dist/{chunk-3kv70xwp.js → chunk-j1sbhm7p.js} +18 -2
  94. package/dist/chunk-j1sbhm7p.js.map +10 -0
  95. package/dist/{chunk-hdz94br2.js → chunk-k522z7v6.js} +10 -5
  96. package/dist/chunk-k522z7v6.js.map +10 -0
  97. package/dist/{chunk-wjgm6jjt.js → chunk-mth82m8t.js} +128 -94
  98. package/dist/chunk-mth82m8t.js.map +14 -0
  99. package/dist/{chunk-qv38twt8.js → chunk-mwsxn98e.js} +46 -25
  100. package/dist/{chunk-qv38twt8.js.map → chunk-mwsxn98e.js.map} +6 -6
  101. package/dist/chunk-n4khvw9n.js +111 -0
  102. package/dist/chunk-n4khvw9n.js.map +11 -0
  103. package/dist/{chunk-qjzp9xyb.js → chunk-nn0tekr1.js} +6 -8
  104. package/dist/chunk-nn0tekr1.js.map +12 -0
  105. package/dist/chunk-nx7k8tpr.js +436 -0
  106. package/dist/chunk-nx7k8tpr.js.map +12 -0
  107. package/dist/{chunk-08twe8m6.js → chunk-p1rzczbt.js} +1 -1
  108. package/dist/{chunk-37wk412q.js → chunk-p1x242ad.js} +587 -70
  109. package/dist/chunk-p1x242ad.js.map +25 -0
  110. package/dist/{chunk-tn7xcs2n.js → chunk-pc7ys28c.js} +68 -5
  111. package/dist/chunk-pc7ys28c.js.map +14 -0
  112. package/dist/{chunk-3fqt22c4.js → chunk-q0k9nc5a.js} +280 -88
  113. package/dist/chunk-q0k9nc5a.js.map +14 -0
  114. package/dist/chunk-r8jrnexe.js +403 -0
  115. package/dist/chunk-r8jrnexe.js.map +10 -0
  116. package/dist/{chunk-gbrpsx4m.js → chunk-rafagrwr.js} +30 -2
  117. package/dist/chunk-rafagrwr.js.map +11 -0
  118. package/dist/{chunk-xdpwpkha.js → chunk-rv2hkwwa.js} +1 -1
  119. package/dist/{chunk-6ed5bwnd.js → chunk-sbzzr4kx.js} +1203 -691
  120. package/dist/{chunk-6ed5bwnd.js.map → chunk-sbzzr4kx.js.map} +15 -9
  121. package/dist/{chunk-d2ndstdf.js → chunk-v1xppd0y.js} +13 -11
  122. package/dist/{chunk-d2ndstdf.js.map → chunk-v1xppd0y.js.map} +2 -2
  123. package/dist/chunk-v4en4jc2.js +252 -0
  124. package/dist/chunk-v4en4jc2.js.map +10 -0
  125. package/dist/{chunk-1kamz6j0.js → chunk-w1tvjszy.js} +1 -1
  126. package/dist/{chunk-rp1mvzb4.js → chunk-w9tg6yyb.js} +11 -6
  127. package/dist/{chunk-rp1mvzb4.js.map → chunk-w9tg6yyb.js.map} +3 -3
  128. package/dist/{chunk-4nxeacx7.js → chunk-wdage1eb.js} +1 -1
  129. package/dist/{chunk-ha58tjtt.js → chunk-wtf06et8.js} +9 -5
  130. package/dist/{chunk-ha58tjtt.js.map → chunk-wtf06et8.js.map} +3 -3
  131. package/dist/{chunk-h0knpbz5.js → chunk-xajtptbw.js} +782 -211
  132. package/dist/chunk-xajtptbw.js.map +40 -0
  133. package/dist/{chunk-xc7hq65b.js → chunk-yp8ee62z.js} +49 -2
  134. package/dist/chunk-yp8ee62z.js.map +11 -0
  135. package/dist/chunk-z4ccwbkz.js +139 -0
  136. package/dist/chunk-z4ccwbkz.js.map +10 -0
  137. package/dist/datasets/builders.d.ts +11 -2
  138. package/dist/datasets/builders.d.ts.map +1 -1
  139. package/dist/datasets/changes.d.ts +14 -4
  140. package/dist/datasets/changes.d.ts.map +1 -1
  141. package/dist/datasets/execution.d.ts +15 -1
  142. package/dist/datasets/execution.d.ts.map +1 -1
  143. package/dist/datasets/index.d.ts +1 -0
  144. package/dist/datasets/index.d.ts.map +1 -1
  145. package/dist/datasets/sequence.d.ts +7 -0
  146. package/dist/datasets/sequence.d.ts.map +1 -0
  147. package/dist/datasets/types.d.ts +1 -0
  148. package/dist/datasets/types.d.ts.map +1 -1
  149. package/dist/datasets/validation.d.ts.map +1 -1
  150. package/dist/datasets/write.d.ts +37 -0
  151. package/dist/datasets/write.d.ts.map +1 -0
  152. package/dist/datasets/write.js +17 -0
  153. package/dist/datasets/write.js.map +9 -0
  154. package/dist/events/execution.d.ts.map +1 -1
  155. package/dist/events/types/datasets.d.ts +2 -6
  156. package/dist/events/types/datasets.d.ts.map +1 -1
  157. package/dist/execution/agent.d.ts.map +1 -1
  158. package/dist/execution/agent.js +39 -32
  159. package/dist/execution/agent.js.map +1 -1
  160. package/dist/execution/authorization.d.ts +58 -20
  161. package/dist/execution/authorization.d.ts.map +1 -1
  162. package/dist/execution/authorized-object-reader.d.ts +69 -0
  163. package/dist/execution/authorized-object-reader.d.ts.map +1 -0
  164. package/dist/execution/durable.d.ts.map +1 -1
  165. package/dist/execution/index.d.ts +1 -1
  166. package/dist/execution/index.d.ts.map +1 -1
  167. package/dist/execution/primitive.js +39 -32
  168. package/dist/execution/primitive.js.map +2 -2
  169. package/dist/execution/request.d.ts +11 -0
  170. package/dist/execution/request.d.ts.map +1 -1
  171. package/dist/execution/request.js +76 -40
  172. package/dist/execution/request.js.map +3 -3
  173. package/dist/execution/scopes.d.ts +16 -0
  174. package/dist/execution/scopes.d.ts.map +1 -1
  175. package/dist/execution/types.d.ts +9 -0
  176. package/dist/execution/types.d.ts.map +1 -1
  177. package/dist/http/api-routes.d.ts +2 -0
  178. package/dist/http/api-routes.d.ts.map +1 -1
  179. package/dist/http/index.js +1 -1
  180. package/dist/index.d.ts +8 -5
  181. package/dist/index.d.ts.map +1 -1
  182. package/dist/index.js +92 -78
  183. package/dist/index.js.map +1 -1
  184. package/dist/lake-storage/definition-updates.d.ts.map +1 -1
  185. package/dist/lake-storage/errors.d.ts +5 -1
  186. package/dist/lake-storage/errors.d.ts.map +1 -1
  187. package/dist/lake-storage/in-memory.d.ts +1 -0
  188. package/dist/lake-storage/in-memory.d.ts.map +1 -1
  189. package/dist/lake-storage/index.d.ts +6 -1
  190. package/dist/lake-storage/index.d.ts.map +1 -1
  191. package/dist/lake-storage/index.js +24 -7
  192. package/dist/lake-storage/index.js.map +1 -1
  193. package/dist/lake-storage/merge-validation.d.ts.map +1 -1
  194. package/dist/lake-storage/merge.d.ts +13 -2
  195. package/dist/lake-storage/merge.d.ts.map +1 -1
  196. package/dist/lake-storage/source-ordering.d.ts +19 -0
  197. package/dist/lake-storage/source-ordering.d.ts.map +1 -0
  198. package/dist/lake-storage/sql-transforms.d.ts +2 -1
  199. package/dist/lake-storage/sql-transforms.d.ts.map +1 -1
  200. package/dist/lake-storage/types.d.ts +10 -5
  201. package/dist/lake-storage/types.d.ts.map +1 -1
  202. package/dist/lake-storage/version-inputs.d.ts +4 -0
  203. package/dist/lake-storage/version-inputs.d.ts.map +1 -0
  204. package/dist/materializer/index.js +25 -22
  205. package/dist/materializer/index.js.map +1 -1
  206. package/dist/objects/authorized-ontology-view.d.ts +25 -0
  207. package/dist/objects/authorized-ontology-view.d.ts.map +1 -0
  208. package/dist/objects/execution.d.ts +1 -1
  209. package/dist/objects/execution.d.ts.map +1 -1
  210. package/dist/objects/index.js +29 -26
  211. package/dist/objects/index.js.map +1 -1
  212. package/dist/objects/link/authorization.d.ts +2 -7
  213. package/dist/objects/link/authorization.d.ts.map +1 -1
  214. package/dist/objects/query/executor.d.ts +4 -2
  215. package/dist/objects/query/executor.d.ts.map +1 -1
  216. package/dist/objects/query/index.js +24 -21
  217. package/dist/objects/query/index.js.map +1 -1
  218. package/dist/objects/query/links.d.ts +22 -1
  219. package/dist/objects/query/links.d.ts.map +1 -1
  220. package/dist/objects/query/selected-read-admission.d.ts +27 -0
  221. package/dist/objects/query/selected-read-admission.d.ts.map +1 -0
  222. package/dist/objects/query/validate.d.ts +60 -2
  223. package/dist/objects/query/validate.d.ts.map +1 -1
  224. package/dist/objects/sdk/object-handle.d.ts.map +1 -1
  225. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  226. package/dist/objects/sdk/runtime-query-executor.d.ts +2 -7
  227. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
  228. package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -1
  229. package/dist/objects/service/list-service.d.ts +2 -3
  230. package/dist/objects/service/list-service.d.ts.map +1 -1
  231. package/dist/objects/telemetry/history.d.ts +8 -6
  232. package/dist/objects/telemetry/history.d.ts.map +1 -1
  233. package/dist/objects/telemetry/index.d.ts +2 -2
  234. package/dist/objects/telemetry/index.d.ts.map +1 -1
  235. package/dist/objects/telemetry/workload.d.ts +11 -0
  236. package/dist/objects/telemetry/workload.d.ts.map +1 -0
  237. package/dist/ontology/index.d.ts +2 -1
  238. package/dist/ontology/index.d.ts.map +1 -1
  239. package/dist/ontology/index.js +13 -12
  240. package/dist/ontology/index.js.map +1 -1
  241. package/dist/ontology/inference/index.d.ts +2 -1
  242. package/dist/ontology/inference/index.d.ts.map +1 -1
  243. package/dist/ontology/internal.d.ts +0 -1
  244. package/dist/ontology/internal.d.ts.map +1 -1
  245. package/dist/ontology/internal.js +5 -10
  246. package/dist/ontology/internal.js.map +3 -3
  247. package/dist/ontology/json-schema.d.ts +10 -6
  248. package/dist/ontology/json-schema.d.ts.map +1 -1
  249. package/dist/ontology/link-path-selection.d.ts +35 -0
  250. package/dist/ontology/link-path-selection.d.ts.map +1 -0
  251. package/dist/ontology/refs.d.ts +2 -0
  252. package/dist/ontology/refs.d.ts.map +1 -1
  253. package/dist/ontology/tokens.d.ts +2 -1
  254. package/dist/ontology/tokens.d.ts.map +1 -1
  255. package/dist/pipelines/execution.d.ts.map +1 -1
  256. package/dist/pipelines/index.js +27 -24
  257. package/dist/pipelines/index.js.map +1 -1
  258. package/dist/pipelines/request.d.ts.map +1 -1
  259. package/dist/projections/execution.d.ts.map +1 -1
  260. package/dist/projections/internal.js +25 -22
  261. package/dist/projections/internal.js.map +1 -1
  262. package/dist/projections/run-dispatch.d.ts.map +1 -1
  263. package/dist/rules/execution.d.ts.map +1 -1
  264. package/dist/runtime/create.d.ts +4 -1
  265. package/dist/runtime/create.d.ts.map +1 -1
  266. package/dist/runtime/definitions.d.ts +2 -0
  267. package/dist/runtime/definitions.d.ts.map +1 -1
  268. package/dist/runtime/host.d.ts +2 -0
  269. package/dist/runtime/host.d.ts.map +1 -1
  270. package/dist/runtime/internal.d.ts +1 -0
  271. package/dist/runtime/internal.d.ts.map +1 -1
  272. package/dist/runtime/resolve-definitions.d.ts +2 -0
  273. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  274. package/dist/runtime/sixb.d.ts +4 -0
  275. package/dist/runtime/sixb.d.ts.map +1 -1
  276. package/dist/runtime/types.d.ts +3 -0
  277. package/dist/runtime/types.d.ts.map +1 -1
  278. package/dist/schedules/execution.d.ts +2 -1
  279. package/dist/schedules/execution.d.ts.map +1 -1
  280. package/dist/security/every.d.ts +4 -1
  281. package/dist/security/every.d.ts.map +1 -1
  282. package/dist/security/grants.d.ts +7 -2
  283. package/dist/security/grants.d.ts.map +1 -1
  284. package/dist/security/index.d.ts +1 -1
  285. package/dist/security/index.d.ts.map +1 -1
  286. package/dist/security/registry.d.ts +1 -0
  287. package/dist/security/registry.d.ts.map +1 -1
  288. package/dist/security/types.d.ts +7 -1
  289. package/dist/security/types.d.ts.map +1 -1
  290. package/dist/security/validation.d.ts +2 -0
  291. package/dist/security/validation.d.ts.map +1 -1
  292. package/dist/shares/access-plan.d.ts +22 -0
  293. package/dist/shares/access-plan.d.ts.map +1 -0
  294. package/dist/shares/builders.d.ts +14 -0
  295. package/dist/shares/builders.d.ts.map +1 -0
  296. package/dist/shares/compiler.d.ts +14 -0
  297. package/dist/shares/compiler.d.ts.map +1 -0
  298. package/dist/shares/errors.d.ts +4 -0
  299. package/dist/shares/errors.d.ts.map +1 -0
  300. package/dist/shares/execution.d.ts +57 -0
  301. package/dist/shares/execution.d.ts.map +1 -0
  302. package/dist/shares/index.d.ts +10 -0
  303. package/dist/shares/index.d.ts.map +1 -0
  304. package/dist/shares/internal.d.ts +3 -0
  305. package/dist/shares/internal.d.ts.map +1 -0
  306. package/dist/shares/internal.js +239 -0
  307. package/dist/shares/internal.js.map +10 -0
  308. package/dist/shares/intersection.d.ts +9 -0
  309. package/dist/shares/intersection.d.ts.map +1 -0
  310. package/dist/shares/session-protocol.d.ts +41 -0
  311. package/dist/shares/session-protocol.d.ts.map +1 -0
  312. package/dist/shares/types.d.ts +51 -0
  313. package/dist/shares/types.d.ts.map +1 -0
  314. package/dist/shares/validation.d.ts +11 -0
  315. package/dist/shares/validation.d.ts.map +1 -0
  316. package/dist/storage/action-runs/provider.js +2 -2
  317. package/dist/storage/agents/provider.js +2 -2
  318. package/dist/storage/executions/in-memory.d.ts +3 -0
  319. package/dist/storage/executions/in-memory.d.ts.map +1 -1
  320. package/dist/storage/executions/provider.d.ts +4 -1
  321. package/dist/storage/executions/provider.d.ts.map +1 -1
  322. package/dist/storage/executions/provider.js +23 -3
  323. package/dist/storage/executions/provider.js.map +3 -3
  324. package/dist/storage/executions/run-link.d.ts +7 -0
  325. package/dist/storage/executions/run-link.d.ts.map +1 -1
  326. package/dist/storage/executions/validation.d.ts +6 -0
  327. package/dist/storage/executions/validation.d.ts.map +1 -1
  328. package/dist/storage/in-memory/index.d.ts +8 -0
  329. package/dist/storage/in-memory/index.d.ts.map +1 -1
  330. package/dist/storage/index.d.ts +8 -2
  331. package/dist/storage/index.d.ts.map +1 -1
  332. package/dist/storage/index.js +65 -36
  333. package/dist/storage/index.js.map +1 -1
  334. package/dist/storage/objects/execution-limits.d.ts +25 -0
  335. package/dist/storage/objects/execution-limits.d.ts.map +1 -0
  336. package/dist/storage/objects/guard.d.ts +16 -0
  337. package/dist/storage/objects/guard.d.ts.map +1 -0
  338. package/dist/storage/objects/in-memory/index.d.ts +3 -0
  339. package/dist/storage/objects/in-memory/index.d.ts.map +1 -0
  340. package/dist/storage/objects/in-memory/keys.d.ts +10 -0
  341. package/dist/storage/objects/in-memory/keys.d.ts.map +1 -0
  342. package/dist/storage/objects/in-memory/query.d.ts +31 -0
  343. package/dist/storage/objects/in-memory/query.d.ts.map +1 -0
  344. package/dist/storage/objects/in-memory/read-scope.d.ts +18 -0
  345. package/dist/storage/objects/in-memory/read-scope.d.ts.map +1 -0
  346. package/dist/storage/objects/in-memory/read-source.d.ts +10 -0
  347. package/dist/storage/objects/in-memory/read-source.d.ts.map +1 -0
  348. package/dist/storage/objects/in-memory/selected-reader.d.ts +9 -0
  349. package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -0
  350. package/dist/storage/objects/{in-memory.d.ts → in-memory/storage.d.ts} +13 -10
  351. package/dist/storage/objects/in-memory/storage.d.ts.map +1 -0
  352. package/dist/storage/objects/index.d.ts +4 -1
  353. package/dist/storage/objects/index.d.ts.map +1 -1
  354. package/dist/storage/objects/keys.d.ts +1 -1
  355. package/dist/storage/objects/keys.d.ts.map +1 -1
  356. package/dist/storage/objects/read-scope.d.ts +25 -0
  357. package/dist/storage/objects/read-scope.d.ts.map +1 -0
  358. package/dist/storage/objects/types.d.ts +114 -22
  359. package/dist/storage/objects/types.d.ts.map +1 -1
  360. package/dist/storage/operation-scope.d.ts +3 -0
  361. package/dist/storage/operation-scope.d.ts.map +1 -1
  362. package/dist/storage/operation-scope.js +4 -2
  363. package/dist/storage/operation-scope.js.map +1 -1
  364. package/dist/storage/pipeline-runs/provider.js +2 -2
  365. package/dist/storage/projection-runs/provider.js +2 -2
  366. package/dist/storage/share-grants/errors.d.ts +8 -0
  367. package/dist/storage/share-grants/errors.d.ts.map +1 -0
  368. package/dist/storage/share-grants/in-memory.d.ts +11 -0
  369. package/dist/storage/share-grants/in-memory.d.ts.map +1 -0
  370. package/dist/storage/share-grants/index.d.ts +5 -0
  371. package/dist/storage/share-grants/index.d.ts.map +1 -0
  372. package/dist/storage/share-grants/provider.d.ts +4 -0
  373. package/dist/storage/share-grants/provider.d.ts.map +1 -0
  374. package/dist/storage/share-grants/provider.js +24 -0
  375. package/dist/storage/share-grants/provider.js.map +9 -0
  376. package/dist/storage/share-grants/record.d.ts +11 -0
  377. package/dist/storage/share-grants/record.d.ts.map +1 -0
  378. package/dist/storage/share-grants/types.d.ts +97 -0
  379. package/dist/storage/share-grants/types.d.ts.map +1 -0
  380. package/dist/storage/share-sessions/errors.d.ts +8 -0
  381. package/dist/storage/share-sessions/errors.d.ts.map +1 -0
  382. package/dist/storage/share-sessions/in-memory.d.ts +14 -0
  383. package/dist/storage/share-sessions/in-memory.d.ts.map +1 -0
  384. package/dist/storage/share-sessions/index.d.ts +5 -0
  385. package/dist/storage/share-sessions/index.d.ts.map +1 -0
  386. package/dist/storage/share-sessions/provider.d.ts +3 -0
  387. package/dist/storage/share-sessions/provider.d.ts.map +1 -0
  388. package/dist/storage/share-sessions/provider.js +20 -0
  389. package/dist/storage/share-sessions/provider.js.map +9 -0
  390. package/dist/storage/share-sessions/record.d.ts +8 -0
  391. package/dist/storage/share-sessions/record.d.ts.map +1 -0
  392. package/dist/storage/share-sessions/types.d.ts +50 -0
  393. package/dist/storage/share-sessions/types.d.ts.map +1 -0
  394. package/dist/storage/sync-runs/provider.js +2 -2
  395. package/dist/storage/transaction.d.ts +2 -1
  396. package/dist/storage/transaction.d.ts.map +1 -1
  397. package/dist/storage/types.d.ts +8 -0
  398. package/dist/storage/types.d.ts.map +1 -1
  399. package/dist/storage/webhook-runs/provider.js +2 -2
  400. package/dist/storage/workflow-runs/provider.js +10 -7
  401. package/dist/storage/workflow-runs/provider.js.map +1 -1
  402. package/dist/syncs/execution.d.ts.map +1 -1
  403. package/dist/syncs/index.js +27 -24
  404. package/dist/syncs/index.js.map +1 -1
  405. package/dist/syncs/request.d.ts.map +1 -1
  406. package/dist/testing/dataset-sequence-contract.d.ts +4 -0
  407. package/dist/testing/dataset-sequence-contract.d.ts.map +1 -0
  408. package/dist/testing/effective-storage-contract.d.ts.map +1 -1
  409. package/dist/testing/execution-storage-contract.d.ts +4 -0
  410. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  411. package/dist/testing/index.d.ts +3 -0
  412. package/dist/testing/index.d.ts.map +1 -1
  413. package/dist/testing/index.js +2555 -908
  414. package/dist/testing/index.js.map +11 -7
  415. package/dist/testing/lake-merge-storage-contract.d.ts +1 -0
  416. package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -1
  417. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  418. package/dist/testing/object-read-scope-contract.d.ts +22 -0
  419. package/dist/testing/object-read-scope-contract.d.ts.map +1 -0
  420. package/dist/testing/share-grant-storage-contract.d.ts +10 -0
  421. package/dist/testing/share-grant-storage-contract.d.ts.map +1 -0
  422. package/dist/testing/share-session-storage-contract.d.ts +9 -0
  423. package/dist/testing/share-session-storage-contract.d.ts.map +1 -0
  424. package/dist/webhooks/internal.js +24 -21
  425. package/dist/webhooks/internal.js.map +2 -2
  426. package/dist/workflows/execution.d.ts.map +1 -1
  427. package/dist/workflows/index.js +42 -35
  428. package/dist/workflows/index.js.map +1 -1
  429. package/dist/workflows/request.d.ts.map +1 -1
  430. package/package.json +25 -1
  431. package/src/actions/delegated-admission.ts +72 -0
  432. package/src/actions/descriptor.ts +58 -0
  433. package/src/actions/execution.ts +99 -24
  434. package/src/actions/request.ts +136 -19
  435. package/src/actions/run-authorization.ts +53 -0
  436. package/src/actions/run-dispatch.ts +8 -1
  437. package/src/agents/adapters.ts +30 -420
  438. package/src/agents/authority.ts +3 -4
  439. package/src/agents/context-resolution.ts +1 -4
  440. package/src/agents/errors.ts +0 -10
  441. package/src/agents/execution.ts +13 -5
  442. package/src/agents/identity.ts +4 -0
  443. package/src/agents/index.ts +1 -20
  444. package/src/agents/message.ts +4 -5
  445. package/src/agents/model-loop.ts +54 -6
  446. package/src/agents/request.ts +16 -3
  447. package/src/agents/tool-definition.ts +0 -19
  448. package/src/agents/validation.ts +6 -65
  449. package/src/ai-usage/execution.ts +4 -11
  450. package/src/authorization/decision.ts +29 -14
  451. package/src/authorization/grant-kinds.ts +10 -0
  452. package/src/authorization/index.ts +1 -0
  453. package/src/bootstrap/discovery.ts +3 -0
  454. package/src/bootstrap/ontology-type-manifest.ts +12 -6
  455. package/src/datasets/builders.ts +23 -2
  456. package/src/datasets/changes.ts +16 -4
  457. package/src/datasets/execution.ts +76 -5
  458. package/src/datasets/index.ts +1 -0
  459. package/src/datasets/sequence.ts +77 -0
  460. package/src/datasets/types.ts +1 -0
  461. package/src/datasets/validation.ts +26 -0
  462. package/src/datasets/write.ts +240 -0
  463. package/src/events/execution.ts +57 -7
  464. package/src/events/types/datasets.ts +2 -6
  465. package/src/execution/agent.ts +1 -4
  466. package/src/execution/authorization.ts +470 -90
  467. package/src/execution/authorized-object-reader.ts +695 -0
  468. package/src/execution/durable.ts +10 -2
  469. package/src/execution/index.ts +1 -0
  470. package/src/execution/request.ts +63 -13
  471. package/src/execution/scopes.ts +36 -6
  472. package/src/execution/types.ts +8 -0
  473. package/src/http/api-routes.ts +45 -0
  474. package/src/index.ts +36 -15
  475. package/src/lake-storage/definition-updates.ts +9 -0
  476. package/src/lake-storage/errors.ts +6 -1
  477. package/src/lake-storage/in-memory.ts +53 -17
  478. package/src/lake-storage/index.ts +10 -1
  479. package/src/lake-storage/merge-validation.ts +12 -2
  480. package/src/lake-storage/merge.ts +40 -2
  481. package/src/lake-storage/source-ordering.ts +95 -0
  482. package/src/lake-storage/sql-transforms.ts +2 -1
  483. package/src/lake-storage/types.ts +10 -5
  484. package/src/lake-storage/version-inputs.ts +14 -0
  485. package/src/objects/authorized-ontology-view.ts +512 -0
  486. package/src/objects/execution.ts +98 -143
  487. package/src/objects/link/authorization.ts +3 -2
  488. package/src/objects/query/executor.ts +45 -34
  489. package/src/objects/query/links.ts +84 -25
  490. package/src/objects/query/selected-read-admission.ts +310 -0
  491. package/src/objects/query/validate.ts +353 -36
  492. package/src/objects/sdk/object-handle.ts +2 -8
  493. package/src/objects/sdk/object-set.ts +10 -11
  494. package/src/objects/sdk/runtime-query-executor.ts +8 -28
  495. package/src/objects/sdk/telemetry-channel.ts +11 -7
  496. package/src/objects/service/list-service.ts +15 -29
  497. package/src/objects/telemetry/history.ts +297 -17
  498. package/src/objects/telemetry/index.ts +2 -2
  499. package/src/objects/telemetry/workload.ts +79 -0
  500. package/src/ontology/index.ts +7 -1
  501. package/src/ontology/inference/index.ts +4 -1
  502. package/src/ontology/internal.ts +0 -1
  503. package/src/ontology/json-schema.ts +13 -12
  504. package/src/ontology/link-path-selection.ts +193 -0
  505. package/src/ontology/refs.ts +19 -0
  506. package/src/ontology/tokens.ts +15 -8
  507. package/src/pipelines/execution.ts +30 -7
  508. package/src/pipelines/request.ts +5 -0
  509. package/src/projections/execution.ts +72 -11
  510. package/src/projections/run-dispatch.ts +6 -12
  511. package/src/rules/execution.ts +20 -8
  512. package/src/runtime/create.ts +5 -1
  513. package/src/runtime/definitions.ts +2 -0
  514. package/src/runtime/host.ts +25 -6
  515. package/src/runtime/internal.ts +1 -0
  516. package/src/runtime/resolve-definitions.ts +9 -0
  517. package/src/runtime/sixb.ts +23 -2
  518. package/src/runtime/types.ts +3 -0
  519. package/src/schedules/execution.ts +24 -2
  520. package/src/security/every.ts +4 -0
  521. package/src/security/grants.ts +45 -3
  522. package/src/security/index.ts +1 -0
  523. package/src/security/registry.ts +3 -0
  524. package/src/security/types.ts +8 -0
  525. package/src/security/validation.ts +3 -0
  526. package/src/shares/access-plan.ts +225 -0
  527. package/src/shares/builders.ts +381 -0
  528. package/src/shares/compiler.ts +359 -0
  529. package/src/shares/errors.ts +3 -0
  530. package/src/shares/execution.ts +394 -0
  531. package/src/shares/index.ts +28 -0
  532. package/src/shares/internal.ts +9 -0
  533. package/src/shares/intersection.ts +178 -0
  534. package/src/shares/session-protocol.ts +258 -0
  535. package/src/shares/types.ts +76 -0
  536. package/src/shares/validation.ts +40 -0
  537. package/src/storage/executions/in-memory.ts +9 -1
  538. package/src/storage/executions/provider.ts +30 -1
  539. package/src/storage/executions/run-link.ts +29 -0
  540. package/src/storage/executions/validation.ts +46 -1
  541. package/src/storage/in-memory/index.ts +21 -2
  542. package/src/storage/index.ts +51 -0
  543. package/src/storage/objects/execution-limits.ts +283 -0
  544. package/src/storage/objects/guard.ts +55 -0
  545. package/src/storage/objects/in-memory/index.ts +2 -0
  546. package/src/storage/objects/in-memory/keys.ts +46 -0
  547. package/src/storage/objects/in-memory/query.ts +754 -0
  548. package/src/storage/objects/in-memory/read-scope.ts +211 -0
  549. package/src/storage/objects/in-memory/read-source.ts +10 -0
  550. package/src/storage/objects/in-memory/selected-reader.ts +252 -0
  551. package/src/storage/objects/in-memory/storage.ts +589 -0
  552. package/src/storage/objects/index.ts +21 -0
  553. package/src/storage/objects/keys.ts +1 -1
  554. package/src/storage/objects/read-scope.ts +672 -0
  555. package/src/storage/objects/types.ts +123 -19
  556. package/src/storage/operation-scope.ts +16 -0
  557. package/src/storage/share-grants/errors.ts +14 -0
  558. package/src/storage/share-grants/in-memory.ts +107 -0
  559. package/src/storage/share-grants/index.ts +14 -0
  560. package/src/storage/share-grants/provider.ts +11 -0
  561. package/src/storage/share-grants/record.ts +347 -0
  562. package/src/storage/share-grants/types.ts +112 -0
  563. package/src/storage/share-sessions/errors.ts +14 -0
  564. package/src/storage/share-sessions/in-memory.ts +105 -0
  565. package/src/storage/share-sessions/index.ts +11 -0
  566. package/src/storage/share-sessions/provider.ts +9 -0
  567. package/src/storage/share-sessions/record.ts +176 -0
  568. package/src/storage/share-sessions/types.ts +57 -0
  569. package/src/storage/transaction.ts +14 -2
  570. package/src/storage/types.ts +27 -0
  571. package/src/syncs/execution.ts +25 -5
  572. package/src/syncs/request.ts +5 -0
  573. package/src/testing/dataset-sequence-contract.ts +373 -0
  574. package/src/testing/effective-storage-contract.ts +34 -0
  575. package/src/testing/execution-storage-contract.ts +79 -0
  576. package/src/testing/index.ts +16 -0
  577. package/src/testing/lake-merge-storage-contract.ts +3 -0
  578. package/src/testing/lake-storage-contract.ts +58 -0
  579. package/src/testing/object-read-scope-contract.ts +939 -0
  580. package/src/testing/share-grant-storage-contract.ts +325 -0
  581. package/src/testing/share-session-storage-contract.ts +235 -0
  582. package/src/workflows/execution.ts +53 -14
  583. package/src/workflows/request.ts +5 -0
  584. package/dist/chunk-2b5qtban.js.map +0 -14
  585. package/dist/chunk-37wk412q.js.map +0 -23
  586. package/dist/chunk-3fqt22c4.js.map +0 -14
  587. package/dist/chunk-3kv70xwp.js.map +0 -10
  588. package/dist/chunk-64sr682n.js.map +0 -12
  589. package/dist/chunk-7ds9620f.js.map +0 -10
  590. package/dist/chunk-dqn23610.js +0 -72
  591. package/dist/chunk-dqn23610.js.map +0 -11
  592. package/dist/chunk-e4rvtvpw.js.map +0 -34
  593. package/dist/chunk-gbrpsx4m.js.map +0 -11
  594. package/dist/chunk-h0knpbz5.js.map +0 -38
  595. package/dist/chunk-hdz94br2.js.map +0 -10
  596. package/dist/chunk-n2arzn6e.js.map +0 -20
  597. package/dist/chunk-qjzp9xyb.js.map +0 -12
  598. package/dist/chunk-tn7xcs2n.js.map +0 -13
  599. package/dist/chunk-wjgm6jjt.js.map +0 -13
  600. package/dist/chunk-xc7hq65b.js.map +0 -10
  601. package/dist/chunk-y35ma3mj.js +0 -551
  602. package/dist/chunk-y35ma3mj.js.map +0 -15
  603. package/dist/chunk-z2sery1b.js.map +0 -11
  604. package/dist/storage/objects/in-memory.d.ts.map +0 -1
  605. package/src/storage/objects/in-memory.ts +0 -1241
  606. /package/dist/{chunk-5jcdmjam.js.map → chunk-4jjp5k14.js.map} +0 -0
  607. /package/dist/{chunk-agsvg9ar.js.map → chunk-5ntny1qx.js.map} +0 -0
  608. /package/dist/{chunk-9aehf39w.js.map → chunk-f26bck4t.js.map} +0 -0
  609. /package/dist/{chunk-08twe8m6.js.map → chunk-p1rzczbt.js.map} +0 -0
  610. /package/dist/{chunk-xdpwpkha.js.map → chunk-rv2hkwwa.js.map} +0 -0
  611. /package/dist/{chunk-1kamz6j0.js.map → chunk-w1tvjszy.js.map} +0 -0
  612. /package/dist/{chunk-4nxeacx7.js.map → chunk-wdage1eb.js.map} +0 -0
@@ -3,20 +3,24 @@ import {
3
3
  SyncValidationError,
4
4
  createConnectorRuntime,
5
5
  requestSyncRun
6
- } from "./chunk-ha58tjtt.js";
6
+ } from "./chunk-wtf06et8.js";
7
7
  import {
8
8
  aiLimitSubjectsFromAttribution,
9
9
  aiUsageLimitExceededError,
10
10
  aiUsageLimitUnavailableError,
11
11
  applicableAiLimitPolicyStatuses
12
12
  } from "./chunk-c15dr03f.js";
13
+ import {
14
+ compileShareAccessPlan
15
+ } from "./chunk-v4en4jc2.js";
13
16
  import {
14
17
  PipelineError,
15
18
  requestPipelineRun
16
- } from "./chunk-rp1mvzb4.js";
19
+ } from "./chunk-w9tg6yyb.js";
17
20
  import {
18
21
  appendTelemetry,
19
22
  createObjectSet,
23
+ getLatestTelemetryPoint,
20
24
  getTelemetryHistoryBatch,
21
25
  listObjects,
22
26
  removeLink1 as removeLink,
@@ -24,48 +28,48 @@ import {
24
28
  upsertLinkBatch1 as upsertLinkBatch,
25
29
  upsertObject1 as upsertObject,
26
30
  upsertObjectBatch1 as upsertObjectBatch
27
- } from "./chunk-e4rvtvpw.js";
31
+ } from "./chunk-aa2pen2v.js";
28
32
  import {
29
33
  shareOntologyMutationRuntime
30
34
  } from "./chunk-xhy826cz.js";
31
- import {
32
- countObjects,
33
- executeObjectQuery,
34
- executeObjectQueryLinks,
35
- existsObjects,
36
- facetObjects
37
- } from "./chunk-3fqt22c4.js";
38
35
  import {
39
36
  registerConnectorConnectionsRuntime
40
37
  } from "./chunk-nf4r78r4.js";
41
38
  import {
42
- isActionDefinition,
39
+ writeDataset
40
+ } from "./chunk-359jm1jw.js";
41
+ import {
42
+ getDatasetPrimaryKeyColumns
43
+ } from "./chunk-n4khvw9n.js";
44
+ import {
45
+ assertAuthorizedObjectReaderBinding,
46
+ canDelegationAccessActionRun,
47
+ getAuthorizedOntologyView,
43
48
  requestAction,
44
49
  requestActionAndWait
45
- } from "./chunk-y35ma3mj.js";
50
+ } from "./chunk-h5vqbfmd.js";
46
51
  import {
47
52
  createPrimitiveExecutionRecord,
48
53
  ensureExecutionRecord,
49
54
  executionRecordInputFromRuntime
50
- } from "./chunk-hdz94br2.js";
55
+ } from "./chunk-k522z7v6.js";
51
56
  import {
57
+ ObjectNotFoundError,
52
58
  WORKFLOW_RUN_FAILURE_CODES
53
- } from "./chunk-6ed5bwnd.js";
59
+ } from "./chunk-sbzzr4kx.js";
60
+ import {
61
+ ShareGrantStorageError
62
+ } from "./chunk-nx7k8tpr.js";
54
63
  import {
55
- WorkflowRunError,
56
- agentServiceAccountId
57
- } from "./chunk-qjzp9xyb.js";
64
+ WorkflowRunError
65
+ } from "./chunk-nn0tekr1.js";
58
66
  import {
59
67
  ExecutionStorageError
60
- } from "./chunk-gbrpsx4m.js";
68
+ } from "./chunk-rafagrwr.js";
61
69
  import {
62
70
  AGENT_REASONING_LEVELS,
63
71
  AgentStorageError
64
- } from "./chunk-08twe8m6.js";
65
- import {
66
- isObjectRefSchema,
67
- validateSchemaOrRefValue
68
- } from "./chunk-dqn23610.js";
72
+ } from "./chunk-p1rzczbt.js";
69
73
  import {
70
74
  RuntimeError
71
75
  } from "./chunk-p2vqaxkc.js";
@@ -73,29 +77,36 @@ import {
73
77
  isModelReasoning
74
78
  } from "./chunk-trxxmgnf.js";
75
79
  import {
76
- reportRunFailure
80
+ reportRunFailure,
81
+ shareSixbErrorReporter
77
82
  } from "./chunk-jq43kdvk.js";
78
83
  import {
79
84
  AgentRequestError,
80
85
  normalizeAgentContextEntries
81
- } from "./chunk-atmkaf60.js";
86
+ } from "./chunk-5e3pq99w.js";
82
87
  import {
83
88
  publishAgentRunActivity
84
89
  } from "./chunk-7y0f6rf1.js";
85
90
  import {
86
91
  SYSTEM_PRINCIPAL,
92
+ isActionDefinition,
87
93
  principalsEqual
88
- } from "./chunk-rre42skh.js";
94
+ } from "./chunk-4sm0aznx.js";
89
95
  import {
90
96
  snapshotRequesterGroupIds
91
97
  } from "./chunk-4a849fr1.js";
98
+ import {
99
+ isObjectRefSchema,
100
+ validateSchemaOrRefValue
101
+ } from "./chunk-2dw777qw.js";
92
102
  import {
93
103
  AuthorizationError,
104
+ agentServiceAccountId,
94
105
  assertAuthorized,
95
106
  assertCanManageConnector,
107
+ assertObjectReadOutputWithinLimit,
96
108
  assertPrivileged,
97
109
  assertProviderAccess,
98
- assertRuntimeAuthorizationBound,
99
110
  canViewActionRun,
100
111
  canViewEvent,
101
112
  canViewPipelineRun,
@@ -106,11 +117,13 @@ import {
106
117
  createAgentRuntimeAuthorization,
107
118
  getAuthorizationRef,
108
119
  isAllowed,
109
- resolveExecutionScopeAuthorization
110
- } from "./chunk-37wk412q.js";
120
+ isRuntimeAllowed,
121
+ resolveExecutionScopeAuthorization,
122
+ resolveRuntimeAuthorizationForProject
123
+ } from "./chunk-p1x242ad.js";
111
124
  import {
112
125
  assertObjectTypeRegistered
113
- } from "./chunk-d63tybny.js";
126
+ } from "./chunk-h0k55pc7.js";
114
127
  import {
115
128
  supportsDirectUpload,
116
129
  supportsRangeRead
@@ -122,39 +135,105 @@ import {
122
135
  isPlainRecord
123
136
  } from "./chunk-n6jxh8sw.js";
124
137
 
138
+ // src/actions/descriptor.ts
139
+ function snapshotActionDescriptor(action) {
140
+ const params = Object.fromEntries(Object.entries(action.params).map(([id, config]) => [id, structuredClone(config)]));
141
+ return deepFreeze({
142
+ id: action.id,
143
+ ...action.description === undefined ? {} : { description: action.description },
144
+ binding: action.binding.kind === "global" ? { kind: "global" } : { kind: "object", objectTypeId: action.binding.objectType.id },
145
+ params,
146
+ phases: {
147
+ validate: action.phases.validate.length > 0,
148
+ writeback: action.phases.writeback !== undefined,
149
+ edits: action.phases.edits !== undefined,
150
+ effects: action.phases.effects !== undefined
151
+ }
152
+ });
153
+ }
154
+ function deepFreeze(value, seen = new Set) {
155
+ if (typeof value !== "object" || value === null || seen.has(value))
156
+ return value;
157
+ seen.add(value);
158
+ for (const key of Reflect.ownKeys(value)) {
159
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
160
+ if (descriptor && "value" in descriptor)
161
+ deepFreeze(descriptor.value, seen);
162
+ }
163
+ return Object.freeze(value);
164
+ }
165
+
125
166
  // src/actions/execution.ts
126
167
  function createActionsRuntime(runtime, execution) {
127
- const canList = (action) => isAllowed(runtime.authorization, { kind: "action.apply", actionId: action.id }) && (action.binding.kind === "global" || isAllowed(runtime.authorization, {
128
- kind: "object.view",
129
- objectTypeId: action.binding.objectType.id
130
- }));
168
+ const projectId = runtime.projectId;
169
+ const runtimeAuthorization = runtime.runtimeAuthorization;
170
+ const objectReader = runtime.objectReader;
171
+ assertAuthorizedObjectReaderBinding({
172
+ reader: objectReader,
173
+ scope: { execution, authorization: runtimeAuthorization }
174
+ });
175
+ const authorization = resolveRuntimeAuthorizationForProject({
176
+ projectId,
177
+ runtimeAuthorization
178
+ });
179
+ const canList = (action) => {
180
+ if (authorization.type === "denied")
181
+ return false;
182
+ if (authorization.type === "delegated") {
183
+ const binding = action.binding;
184
+ return binding.kind === "object" && authorization.actionApply.some((target) => target.actionId === action.id && target.subject.objectTypeId === binding.objectType.id) && getAuthorizedOntologyView(objectReader).getObjectTypeById(binding.objectType.id) !== null;
185
+ }
186
+ if (authorization.type === "unrestricted")
187
+ return true;
188
+ return isAllowed(authorization.context, { kind: "action.apply", actionId: action.id }) && (action.binding.kind === "global" || isAllowed(authorization.context, {
189
+ kind: "object.view",
190
+ objectTypeId: action.binding.objectType.id
191
+ }));
192
+ };
193
+ const release = (value) => {
194
+ if (authorization.type === "delegated") {
195
+ assertObjectReadOutputWithinLimit(value, authorization.objectRead.limits);
196
+ }
197
+ return value;
198
+ };
199
+ const describeAll = (actions) => release(actions.filter(canList).map(snapshotActionDescriptor));
131
200
  return {
132
- list: () => runtime.actionRegistry.list().filter(canList),
201
+ list: () => describeAll(runtime.actionRegistry.list()),
133
202
  getById: (actionId) => {
134
203
  const action = runtime.actionRegistry.getById(actionId);
135
- return action && canList(action) ? action : null;
204
+ return release(action && canList(action) ? snapshotActionDescriptor(action) : null);
136
205
  },
137
- listGlobal: () => runtime.actionRegistry.listGlobal().filter(canList),
138
- listForType: (objectType) => runtime.actionRegistry.listForType(objectType).filter(canList),
206
+ listGlobal: () => describeAll(runtime.actionRegistry.listGlobal()),
207
+ listForType: (objectType) => describeAll(runtime.actionRegistry.listForType(objectType).filter((action) => authorization.type !== "delegated" || action.binding.kind === "object" && action.binding.objectType.id === objectType.id)),
139
208
  request: (input) => requestAction(runtime, execution, input),
140
209
  requestAndWait: (input) => requestActionAndWait(runtime, execution, input),
141
210
  runs: {
142
211
  getById: async (runId) => {
212
+ if (authorization.type === "denied" || authorization.type === "delegated" && (!authorization.delegation || authorization.actionApply.length === 0))
213
+ return null;
143
214
  const run = await runtime.storage.actionRuns?.getById({
144
- projectId: runtime.projectId,
215
+ projectId,
145
216
  id: runId
146
217
  }) ?? null;
147
- return run && canViewActionRun(runtime.authorization, run) ? run : null;
218
+ return run && (authorization.type === "unrestricted" || authorization.type === "principal" && canViewActionRun(authorization.context, run) || authorization.type === "delegated" && await canDelegationAccessActionRun({
219
+ storage: runtime.storage,
220
+ projectId,
221
+ authority: authorization,
222
+ run
223
+ })) ? release(run) : null;
148
224
  },
149
225
  list: (input = {}) => {
226
+ if (authorization.type === "denied" || authorization.type === "delegated") {
227
+ return Promise.resolve({ runs: [], hasMore: false, total: 0 });
228
+ }
150
229
  const storage = runtime.storage.actionRuns;
151
230
  if (!storage)
152
231
  return Promise.resolve({ runs: [], hasMore: false, total: 0 });
153
232
  return storage.list({
154
- projectId: runtime.projectId,
155
233
  ...input,
156
- actionIds: runtime.authorization ? [...runtime.authorization.grants["apply:action"]] : undefined,
157
- objectTypeIds: runtime.authorization ? [...runtime.authorization.grants["view:object"]] : undefined
234
+ projectId,
235
+ actionIds: authorization.type === "principal" ? [...authorization.context.grants["apply:action"]] : undefined,
236
+ objectTypeIds: authorization.type === "principal" ? [...authorization.context.grants["view:object"]] : undefined
158
237
  });
159
238
  }
160
239
  }
@@ -230,9 +309,7 @@ async function resolveAgentContextParts(runtime, input) {
230
309
  } catch {
231
310
  invalidContext(`context references an unknown object type '${objectTypeId}'`);
232
311
  }
233
- assertAuthorized(runtime, { kind: "object.view", objectTypeId });
234
- const object = await runtime.storage.objects.getByPrimaryId({
235
- projectId: runtime.projectId,
312
+ const object = await runtime.objectReader.getByPrimaryId({
236
313
  objectTypeId,
237
314
  primaryId
238
315
  });
@@ -362,6 +439,10 @@ function assertNoAgentSelector(input) {
362
439
 
363
440
  // src/agents/request.ts
364
441
  async function requestAgentRun(runtime, execution, models, input) {
442
+ const authority = resolveExecutionScopeAuthorization(runtime.projectId, {
443
+ execution,
444
+ authorization: runtime.runtimeAuthorization
445
+ });
365
446
  assertNoAgentSelector(input);
366
447
  assertAuthorized(runtime, { kind: "agent.run" });
367
448
  assertRequestAuthorityCanRunAgent(runtime);
@@ -369,7 +450,7 @@ async function requestAgentRun(runtime, execution, models, input) {
369
450
  const contextParts = await resolveAgentContextParts(runtime, input.context);
370
451
  const agents = requireAgentStorage(runtime);
371
452
  const projectId = runtime.projectId;
372
- const principal = runtime.authorization?.principal ?? input.principal ?? SYSTEM_PRINCIPAL;
453
+ const principal = authority.type === "principal" ? authority.context.principal : input.principal ?? SYSTEM_PRINCIPAL;
373
454
  const runId = createAgentRunId();
374
455
  const durableExecution = await prepareDurableAgentExecution(runtime, execution, runId);
375
456
  const requesterGroupIds = durableExecution.requestedBy ? await snapshotRequesterGroupIds({
@@ -434,6 +515,10 @@ async function requestAgentRun(runtime, execution, models, input) {
434
515
  };
435
516
  }
436
517
  async function retryAgentRun(runtime, execution, models, failedRun) {
518
+ resolveExecutionScopeAuthorization(runtime.projectId, {
519
+ execution,
520
+ authorization: runtime.runtimeAuthorization
521
+ });
437
522
  assertAuthorized(runtime, { kind: "agent.run" });
438
523
  assertRequestAuthorityCanRunAgent(runtime);
439
524
  if (failedRun.status !== "failed") {
@@ -591,18 +676,23 @@ function requireAgentStorage(runtime) {
591
676
 
592
677
  // src/agents/execution.ts
593
678
  function createAgentRuntime(runtime, execution, models) {
594
- const principal = runtime.authorization?.principal ?? SYSTEM_PRINCIPAL;
595
- const allowed = () => isAllowed(runtime.authorization, { kind: "agent.run" });
679
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
680
+ const principal = authority.type === "principal" ? authority.context.principal : SYSTEM_PRINCIPAL;
681
+ const allowed = () => isRuntimeAllowed(runtime, { kind: "agent.run" });
596
682
  const getVisibleThreadRecord = async (threadId) => {
683
+ if (authority.type === "denied" || authority.type === "delegated")
684
+ return null;
597
685
  const thread = await runtime.storage.agents?.threads.getById({
598
686
  projectId: runtime.projectId,
599
687
  id: threadId
600
688
  }) ?? null;
601
689
  if (!thread || !allowed())
602
690
  return null;
603
- return runtime.authorization && !principalsEqual(principal, thread.ownerPrincipal) ? null : thread;
691
+ return authority.type === "principal" && !principalsEqual(principal, thread.ownerPrincipal) ? null : thread;
604
692
  };
605
693
  const getAgent = () => {
694
+ if (authority.type === "denied" || authority.type === "delegated")
695
+ return null;
606
696
  const model = models?.language.default;
607
697
  if (!model || !allowed())
608
698
  return null;
@@ -612,6 +702,8 @@ function createAgentRuntime(runtime, execution, models) {
612
702
  };
613
703
  };
614
704
  const getVisibleRunRecord = async (runId) => {
705
+ if (authority.type === "denied" || authority.type === "delegated")
706
+ return null;
615
707
  const run = await runtime.storage.agents?.runs.getById({
616
708
  projectId: runtime.projectId,
617
709
  id: runId
@@ -648,13 +740,16 @@ function createAgentRuntime(runtime, execution, models) {
648
740
  getById: getVisibleThreadRecord,
649
741
  list: async (input = {}) => {
650
742
  assertNoAgentSelector(input);
743
+ if (authority.type === "denied" || authority.type === "delegated") {
744
+ return { threads: [], hasMore: false, total: 0 };
745
+ }
651
746
  const storage = runtime.storage.agents;
652
747
  if (!storage || !allowed())
653
748
  return { threads: [], hasMore: false, total: 0 };
654
749
  return storage.threads.list({
655
750
  ...input,
656
751
  projectId: runtime.projectId,
657
- ownerPrincipal: runtime.authorization ? principal : undefined
752
+ ownerPrincipal: authority.type === "principal" ? principal : undefined
658
753
  });
659
754
  }
660
755
  },
@@ -752,8 +847,7 @@ function createAiUsageRuntime(runtime, security) {
752
847
  const assertObservable = () => assertAuthorized(runtime, { kind: "aiUsage.observe" });
753
848
  const assertManageable = () => assertAuthorized(runtime, { kind: "aiUsage.manage" });
754
849
  const assertPolicyReadable = () => {
755
- const resolved = assertRuntimeAuthorizationBound(runtime);
756
- if (resolved.type === "principal" && !isAllowed(resolved.context, { kind: "aiUsage.observe" }) && !isAllowed(resolved.context, { kind: "aiUsage.manage" })) {
850
+ if (!isRuntimeAllowed(runtime, { kind: "aiUsage.observe" }) && !isRuntimeAllowed(runtime, { kind: "aiUsage.manage" })) {
757
851
  assertObservable();
758
852
  }
759
853
  };
@@ -774,10 +868,7 @@ function createAiUsageRuntime(runtime, security) {
774
868
  limitsConfigured: runtime.storage.aiLimits !== undefined,
775
869
  assertObservable,
776
870
  assertManageable,
777
- canManageLimits: () => {
778
- const resolved = assertRuntimeAuthorizationBound(runtime);
779
- return resolved.type !== "principal" || isAllowed(resolved.context, { kind: "aiUsage.manage" });
780
- },
871
+ canManageLimits: () => isRuntimeAllowed(runtime, { kind: "aiUsage.manage" }),
781
872
  queryOverview: (input) => {
782
873
  assertObservable();
783
874
  return requireCosts().queryProjectOverview({ ...input, projectId: runtime.projectId });
@@ -934,21 +1025,88 @@ function commandContext(runtime, execution, connectorId) {
934
1025
  }
935
1026
 
936
1027
  // src/datasets/execution.ts
937
- function createDatasetsRuntime(runtime, source) {
938
- const allowed = (datasetId) => isAllowed(runtime.authorization, { kind: "dataset.view", datasetId });
1028
+ function createDatasetsRuntime(runtime, execution, source, lakeStorage, blobStorage) {
1029
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
1030
+ const allowed = (datasetId) => isRuntimeAllowed(runtime, { kind: "dataset.view", datasetId });
939
1031
  return {
940
- list: () => source.list().filter((dataset) => allowed(dataset.id)),
1032
+ list: () => authority.type === "denied" || authority.type === "delegated" ? [] : source.list().filter((dataset) => allowed(dataset.id)),
941
1033
  getById: (datasetId) => {
1034
+ if (authority.type === "denied" || authority.type === "delegated")
1035
+ return null;
942
1036
  const dataset = source.getById(datasetId);
943
1037
  return dataset && allowed(datasetId) ? dataset : null;
1038
+ },
1039
+ async ingest(dataset, input) {
1040
+ assertPrivileged(runtime, "datasets.ingest");
1041
+ const registered = source.getById(dataset.id);
1042
+ if (!registered)
1043
+ throw new Error(`[Sixb] Dataset '${dataset.id}' is not registered.`);
1044
+ if (getDatasetPrimaryKeyColumns(registered) === null) {
1045
+ throw new Error(`[Sixb] Dataset '${dataset.id}' must define a primaryKey before ingestion.`);
1046
+ }
1047
+ if (typeof lakeStorage.beginMerge !== "function") {
1048
+ throw new Error("[Sixb] Dataset ingestion requires a lake provider with merge support.");
1049
+ }
1050
+ const producer = { kind: "ingest", id: execution.id };
1051
+ const result = await writeDataset({
1052
+ lakeStorage,
1053
+ blobStorage,
1054
+ dataset: registered,
1055
+ mode: "merge",
1056
+ signal: input.signal ?? new AbortController().signal,
1057
+ producer,
1058
+ readValues: async () => async function* () {
1059
+ for await (const value of input.changes)
1060
+ yield { value };
1061
+ }()
1062
+ });
1063
+ if (result.outcome === "created") {
1064
+ await runtime.events.emit({
1065
+ events: [
1066
+ {
1067
+ type: "dataset.version.committed",
1068
+ payload: {
1069
+ datasetId: registered.id,
1070
+ versionId: result.version.versionId,
1071
+ createdAt: result.version.createdAt.toISOString(),
1072
+ producer
1073
+ }
1074
+ }
1075
+ ],
1076
+ correlationId: execution.correlationId
1077
+ }, { source: "SixbDatasets" });
1078
+ }
1079
+ return result;
944
1080
  }
945
1081
  };
946
1082
  }
947
1083
 
948
1084
  // src/events/execution.ts
949
1085
  function createEventsRuntime(runtime) {
1086
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
1087
+ const visibleEvents = (events) => {
1088
+ switch (authority.type) {
1089
+ case "denied":
1090
+ case "delegated":
1091
+ return [];
1092
+ case "principal":
1093
+ return events.filter((event) => canViewEvent(authority.context, event));
1094
+ case "unrestricted":
1095
+ return [...events];
1096
+ }
1097
+ };
950
1098
  return {
951
- canRead: (event) => canViewEvent(runtime.authorization, event),
1099
+ canRead: (event) => {
1100
+ switch (authority.type) {
1101
+ case "denied":
1102
+ case "delegated":
1103
+ return false;
1104
+ case "principal":
1105
+ return canViewEvent(authority.context, event);
1106
+ case "unrestricted":
1107
+ return true;
1108
+ }
1109
+ },
952
1110
  append: (input) => {
953
1111
  assertPrivileged(runtime, "events.append");
954
1112
  return runtime.events.append(input);
@@ -958,15 +1116,42 @@ function createEventsRuntime(runtime) {
958
1116
  return runtime.events.emit(input, options);
959
1117
  },
960
1118
  read: async (input) => {
1119
+ switch (authority.type) {
1120
+ case "denied":
1121
+ case "delegated":
1122
+ return [];
1123
+ case "principal":
1124
+ case "unrestricted":
1125
+ break;
1126
+ }
961
1127
  const events = await runtime.events.read(input);
962
- return events.filter((event) => canViewEvent(runtime.authorization, event));
1128
+ return visibleEvents(events);
963
1129
  },
964
- latestCursor: () => runtime.events.latestCursor(),
965
- subscribe: (input, handler) => runtime.events.subscribe(input, (events) => {
966
- const visible = events.filter((event) => canViewEvent(runtime.authorization, event));
967
- if (visible.length > 0)
968
- handler(visible);
969
- })
1130
+ latestCursor: () => {
1131
+ switch (authority.type) {
1132
+ case "denied":
1133
+ case "delegated":
1134
+ return Promise.resolve(undefined);
1135
+ case "principal":
1136
+ case "unrestricted":
1137
+ return runtime.events.latestCursor();
1138
+ }
1139
+ },
1140
+ subscribe: (input, handler) => {
1141
+ switch (authority.type) {
1142
+ case "denied":
1143
+ case "delegated":
1144
+ return Promise.resolve(() => {});
1145
+ case "principal":
1146
+ case "unrestricted":
1147
+ break;
1148
+ }
1149
+ return runtime.events.subscribe(input, (events) => {
1150
+ const visible = visibleEvents(events);
1151
+ if (visible.length > 0)
1152
+ handler(visible);
1153
+ });
1154
+ }
970
1155
  };
971
1156
  }
972
1157
 
@@ -988,129 +1173,118 @@ function createLogsRuntime(runtime, source) {
988
1173
 
989
1174
  // src/objects/execution.ts
990
1175
  function createObjectsRuntime(runtime, execution) {
1176
+ const runtimeAuthorization = runtime.runtimeAuthorization;
1177
+ const objectReader = runtime.objectReader;
1178
+ assertAuthorizedObjectReaderBinding({
1179
+ reader: objectReader,
1180
+ scope: { execution, authorization: runtimeAuthorization }
1181
+ });
1182
+ const authorization = runtime.authorization;
1183
+ const capturedRuntime = {
1184
+ projectId: runtime.projectId,
1185
+ broker: runtime.broker,
1186
+ ontology: runtime.ontology,
1187
+ actionRegistry: runtime.actionRegistry,
1188
+ events: runtime.events,
1189
+ storage: runtime.storage,
1190
+ queues: runtime.queues,
1191
+ runtimeAuthorization,
1192
+ objectReader,
1193
+ ...authorization === undefined ? {} : { authorization }
1194
+ };
1195
+ shareOntologyMutationRuntime(runtime, capturedRuntime);
1196
+ shareSixbErrorReporter(runtime, capturedRuntime);
1197
+ Object.freeze(capturedRuntime);
1198
+ const ontologyView = () => getAuthorizedOntologyView(objectReader);
991
1199
  const objects = Object.assign((objectType) => {
992
- assertObjectTypeRegistered(runtime.ontology.getObjectTypesById(), objectType);
993
- return createObjectSet({ ...runtime, execution, objectType });
1200
+ assertObjectTypeRegistered(capturedRuntime.ontology.getObjectTypesById(), objectType);
1201
+ return createObjectSet({ ...capturedRuntime, execution, objectType });
994
1202
  }, {
995
- listTypes: () => runtime.ontology.listObjectTypes().filter((objectType) => isAllowed(runtime.authorization, {
996
- kind: "object.view",
997
- objectTypeId: objectType.id
998
- })),
999
- getTypeById: (objectTypeId) => {
1000
- const objectType = runtime.ontology.getObjectTypeById(objectTypeId);
1001
- return objectType && isAllowed(runtime.authorization, { kind: "object.view", objectTypeId }) ? objectType : null;
1002
- },
1003
- resolveType: (objectTypeId) => {
1004
- assertAuthorized(runtime, { kind: "object.view", objectTypeId });
1005
- return runtime.ontology.resolveObjectType(objectTypeId);
1006
- },
1007
- getValueTypesById: () => runtime.ontology.getValueTypesById(),
1008
- listSubTypes: (objectTypeId) => runtime.ontology.listSubTypes(objectTypeId),
1009
- isValidLinkTarget: (expected, actual) => runtime.ontology.isValidLinkTarget(expected, actual),
1010
- executeQuery: (input) => executeObjectQuery({ projectId: runtime.projectId, ...input }, {
1011
- ontology: runtime.ontology,
1012
- storage: runtime.storage.objects,
1013
- runtimeAuthorization: runtime.runtimeAuthorization,
1014
- authorization: runtime.authorization
1015
- }),
1016
- queryLinks: (input) => executeObjectQueryLinks({ projectId: runtime.projectId, ...input }, {
1017
- ontology: runtime.ontology,
1018
- storage: runtime.storage.objects,
1019
- runtimeAuthorization: runtime.runtimeAuthorization,
1020
- authorization: runtime.authorization
1021
- }),
1022
- count: (input) => countObjects({ projectId: runtime.projectId, ...input }, {
1023
- ontology: runtime.ontology,
1024
- storage: runtime.storage.objects,
1025
- runtimeAuthorization: runtime.runtimeAuthorization,
1026
- authorization: runtime.authorization
1027
- }),
1028
- exists: (input) => existsObjects({ projectId: runtime.projectId, ...input }, {
1029
- ontology: runtime.ontology,
1030
- storage: runtime.storage.objects,
1031
- runtimeAuthorization: runtime.runtimeAuthorization,
1032
- authorization: runtime.authorization
1033
- }),
1034
- facet: (input) => facetObjects({ projectId: runtime.projectId, ...input }, {
1035
- ontology: runtime.ontology,
1036
- storage: runtime.storage.objects,
1037
- runtimeAuthorization: runtime.runtimeAuthorization,
1038
- authorization: runtime.authorization
1039
- }),
1203
+ listTypes: () => ontologyView().listObjectTypes(),
1204
+ getTypeById: (objectTypeId) => ontologyView().getObjectTypeById(objectTypeId),
1205
+ resolveType: (objectTypeId) => ontologyView().resolveObjectType(objectTypeId),
1206
+ getValueTypesById: () => ontologyView().getValueTypesById(),
1207
+ listSubTypes: (objectTypeId) => ontologyView().listSubTypes(objectTypeId),
1208
+ isValidLinkTarget: (expected, actual) => ontologyView().isValidLinkTarget(expected, actual),
1209
+ executeQuery: (input) => objectReader.executeQuery(input),
1210
+ queryLinks: (input) => objectReader.queryLinks(input),
1211
+ count: (input) => objectReader.count(input),
1212
+ exists: (input) => objectReader.exists(input),
1213
+ facet: (input) => objectReader.facet(input),
1040
1214
  listLinks: async (input) => {
1041
- assertAuthorized(runtime, { kind: "object.view", objectTypeId: input.objectTypeId });
1042
- const links = await runtime.storage.objects.listLinks({
1043
- projectId: runtime.projectId,
1044
- ...input
1045
- });
1046
- return links.filter((link) => isAllowed(runtime.authorization, {
1047
- kind: "object.view",
1048
- objectTypeId: link.sourceTypeId
1049
- }) && isAllowed(runtime.authorization, {
1050
- kind: "object.view",
1051
- objectTypeId: link.targetTypeId
1052
- }));
1215
+ return objectReader.listLinks(input);
1053
1216
  },
1054
- getTelemetryHistoryBatch: (input) => getTelemetryHistoryBatch({ projectId: runtime.projectId, ...input }, {
1055
- storage: runtime.storage.timeseries,
1056
- runtimeAuthorization: runtime.runtimeAuthorization,
1057
- authorization: runtime.authorization
1058
- }),
1059
- getTelemetryHistory: (input) => {
1060
- assertAuthorized(runtime, { kind: "object.view", objectTypeId: input.objectTypeId });
1061
- return runtime.storage.timeseries.getHistory({
1062
- projectId: runtime.projectId,
1063
- ...input
1064
- });
1217
+ getTelemetryHistoryBatch: (input) => {
1218
+ const timeseries = capturedRuntime.storage.timeseries;
1219
+ return getTelemetryHistoryBatch(input, { storage: timeseries, objectReader });
1065
1220
  },
1066
- getLatestTelemetry: (input) => {
1067
- assertAuthorized(runtime, { kind: "object.view", objectTypeId: input.objectTypeId });
1068
- return runtime.storage.timeseries.getLatest({
1069
- projectId: runtime.projectId,
1070
- ...input
1071
- });
1221
+ getTelemetryHistory: async (input) => {
1222
+ const timeseries = capturedRuntime.storage.timeseries;
1223
+ const objectTypeId = input.objectTypeId;
1224
+ const objectId = input.objectId;
1225
+ const propertyId = input.propertyId;
1226
+ const from = input.from;
1227
+ const to = input.to;
1228
+ const limit = input.limit;
1229
+ const order = input.order;
1230
+ const [result] = await getTelemetryHistoryBatch({
1231
+ series: [{ objectTypeId, objectId, propertyId }],
1232
+ ...from === undefined ? {} : { from },
1233
+ ...to === undefined ? {} : { to },
1234
+ ...limit === undefined ? {} : { limitPerSeries: limit },
1235
+ ...order === undefined ? {} : { order }
1236
+ }, { storage: timeseries, objectReader });
1237
+ return result?.points ?? [];
1072
1238
  },
1073
- list: (params) => listObjects(runtime, params),
1074
- get: async (objectTypeId, primaryId) => {
1075
- assertAuthorized(runtime, { kind: "object.view", objectTypeId });
1076
- return runtime.storage.objects.getByPrimaryId({
1077
- projectId: runtime.projectId,
1078
- objectTypeId,
1079
- primaryId
1080
- });
1239
+ getLatestTelemetry: async (input) => {
1240
+ const timeseries = capturedRuntime.storage.timeseries;
1241
+ const objectTypeId = input.objectTypeId;
1242
+ const objectId = input.objectId;
1243
+ const propertyId = input.propertyId;
1244
+ return getLatestTelemetryPoint({ objectTypeId, objectId, propertyId }, { storage: timeseries, objectReader });
1081
1245
  },
1246
+ list: (params) => listObjects(capturedRuntime, params),
1247
+ get: (objectTypeId, primaryId) => objectReader.getByPrimaryId({ objectTypeId, primaryId }),
1082
1248
  getPrimaryPropertyId: (objectTypeId) => {
1083
- assertAuthorized(runtime, { kind: "object.view", objectTypeId });
1084
- return runtime.ontology.getPrimaryPropertyId(objectTypeId);
1249
+ return ontologyView().getPrimaryPropertyId(objectTypeId);
1085
1250
  },
1086
- upsert: (objectTypeId, properties) => upsertObject(runtime, objectTypeId, properties),
1087
- upsertBatch: (objectTypeId, items) => upsertObjectBatch(runtime, objectTypeId, items),
1088
- upsertLink: (objectTypeId, sourceId, linkId, target) => upsertLink(runtime, objectTypeId, sourceId, linkId, target),
1089
- upsertLinkBatch: (items) => upsertLinkBatch(runtime, items),
1090
- removeLink: (objectTypeId, sourceId, linkId, target) => removeLink(runtime, objectTypeId, sourceId, linkId, target),
1091
- appendTelemetry: (objectTypeId, items) => appendTelemetry(runtime, objectTypeId, items)
1251
+ upsert: (objectTypeId, properties) => upsertObject(capturedRuntime, objectTypeId, properties),
1252
+ upsertBatch: (objectTypeId, items) => upsertObjectBatch(capturedRuntime, objectTypeId, items),
1253
+ upsertLink: (objectTypeId, sourceId, linkId, target) => upsertLink(capturedRuntime, objectTypeId, sourceId, linkId, target),
1254
+ upsertLinkBatch: (items) => upsertLinkBatch(capturedRuntime, items),
1255
+ removeLink: (objectTypeId, sourceId, linkId, target) => removeLink(capturedRuntime, objectTypeId, sourceId, linkId, target),
1256
+ appendTelemetry: (objectTypeId, items) => appendTelemetry(capturedRuntime, objectTypeId, items)
1092
1257
  });
1093
1258
  return objects;
1094
1259
  }
1095
1260
 
1096
1261
  // src/pipelines/execution.ts
1097
1262
  function createPipelinesRuntime(runtime, execution, source) {
1098
- const allowed = (pipelineId) => isAllowed(runtime.authorization, { kind: "pipeline.run", pipelineId });
1263
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
1264
+ const allowed = (pipelineId) => isRuntimeAllowed(runtime, { kind: "pipeline.run", pipelineId });
1099
1265
  const visibleIds = () => source.list().filter((pipeline) => allowed(pipeline.id)).map((pipeline) => pipeline.id);
1266
+ const historyFilterIds = () => authority.type === "unrestricted" ? undefined : authority.type === "principal" ? visibleIds() : [];
1100
1267
  const getRun = async (runId) => {
1268
+ if (authority.type === "denied" || authority.type === "delegated")
1269
+ return null;
1101
1270
  const run = await runtime.storage.pipelineRuns?.getById({
1102
1271
  projectId: runtime.projectId,
1103
1272
  id: runId
1104
1273
  }) ?? null;
1105
- return run && canViewPipelineRun(runtime.authorization, run) ? run : null;
1274
+ if (!run)
1275
+ return null;
1276
+ return authority.type === "unrestricted" || canViewPipelineRun(authority.context, run) ? run : null;
1106
1277
  };
1107
1278
  return {
1108
- list: () => source.list().filter((pipeline) => allowed(pipeline.id)),
1279
+ list: () => authority.type === "denied" || authority.type === "delegated" ? [] : source.list().filter((pipeline) => allowed(pipeline.id)),
1109
1280
  getById: (pipelineId) => {
1281
+ if (authority.type === "denied" || authority.type === "delegated")
1282
+ return null;
1110
1283
  const pipeline = source.getById(pipelineId);
1111
1284
  return pipeline && allowed(pipelineId) ? pipeline : null;
1112
1285
  },
1113
1286
  request: async (input) => {
1287
+ assertAuthorized(runtime, { kind: "pipeline.run", pipelineId: input.pipelineId });
1114
1288
  const pipeline = source.getById(input.pipelineId);
1115
1289
  if (!pipeline)
1116
1290
  throw new PipelineError(`[Sixb] Unknown pipeline '${input.pipelineId}'`);
@@ -1119,16 +1293,22 @@ function createPipelinesRuntime(runtime, execution, source) {
1119
1293
  runs: {
1120
1294
  getById: getRun,
1121
1295
  list: (input = {}) => {
1296
+ if (authority.type === "denied" || authority.type === "delegated") {
1297
+ return Promise.resolve({ runs: [], hasMore: false, total: 0 });
1298
+ }
1122
1299
  const storage = runtime.storage.pipelineRuns;
1123
1300
  if (!storage)
1124
1301
  return Promise.resolve({ runs: [], hasMore: false, total: 0 });
1125
1302
  return storage.list({
1126
- projectId: runtime.projectId,
1127
1303
  ...input,
1128
- pipelineIds: runtime.authorization ? visibleIds() : undefined
1304
+ pipelineIds: historyFilterIds(),
1305
+ projectId: runtime.projectId
1129
1306
  });
1130
1307
  },
1131
1308
  listLatest: (pipelineIds) => {
1309
+ if (authority.type === "denied" || authority.type === "delegated") {
1310
+ return Promise.resolve({ runs: [] });
1311
+ }
1132
1312
  const storage = runtime.storage.pipelineRuns;
1133
1313
  if (!storage || pipelineIds.length === 0)
1134
1314
  return Promise.resolve({ runs: [] });
@@ -1143,9 +1323,9 @@ function createPipelinesRuntime(runtime, execution, source) {
1143
1323
  if (!storage || !await getRun(runId))
1144
1324
  return null;
1145
1325
  return storage.listSteps({
1146
- projectId: runtime.projectId,
1147
1326
  ...input,
1148
- pipelineRunId: runId
1327
+ pipelineRunId: runId,
1328
+ projectId: runtime.projectId
1149
1329
  });
1150
1330
  }
1151
1331
  }
@@ -1154,39 +1334,95 @@ function createPipelinesRuntime(runtime, execution, source) {
1154
1334
 
1155
1335
  // src/projections/execution.ts
1156
1336
  function createProjectionsRuntime(runtime, source) {
1157
- const visible = (projection) => canViewProjection(runtime.authorization, projection);
1337
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
1338
+ const listVisible = (list) => {
1339
+ switch (authority.type) {
1340
+ case "denied":
1341
+ case "delegated":
1342
+ return [];
1343
+ case "principal":
1344
+ return list().filter((projection) => canViewProjection(authority.context, projection));
1345
+ case "unrestricted":
1346
+ return [...list()];
1347
+ }
1348
+ };
1349
+ const visible = (projection) => {
1350
+ switch (authority.type) {
1351
+ case "denied":
1352
+ case "delegated":
1353
+ return false;
1354
+ case "principal":
1355
+ return canViewProjection(authority.context, projection);
1356
+ case "unrestricted":
1357
+ return true;
1358
+ }
1359
+ };
1158
1360
  const visibleIds = (projectionIds) => projectionIds.filter((projectionId) => {
1159
1361
  const projection = source.getById(projectionId);
1160
1362
  return projection !== null && visible(projection);
1161
1363
  });
1162
1364
  return {
1163
- list: () => source.list().filter(visible),
1164
- listObjects: () => source.listObjects().filter(visible),
1165
- listLinks: () => source.listLinks().filter(visible),
1166
- listTelemetry: () => source.listTelemetry().filter(visible),
1365
+ list: () => listVisible(() => source.list()),
1366
+ listObjects: () => listVisible(() => source.listObjects()),
1367
+ listLinks: () => listVisible(() => source.listLinks()),
1368
+ listTelemetry: () => listVisible(() => source.listTelemetry()),
1167
1369
  getById: (projectionId) => {
1370
+ switch (authority.type) {
1371
+ case "denied":
1372
+ case "delegated":
1373
+ return null;
1374
+ case "principal":
1375
+ case "unrestricted":
1376
+ break;
1377
+ }
1168
1378
  const projection = source.getById(projectionId);
1169
1379
  return projection && visible(projection) ? projection : null;
1170
1380
  },
1171
1381
  runs: {
1172
1382
  getById: async (runId) => {
1383
+ switch (authority.type) {
1384
+ case "denied":
1385
+ case "delegated":
1386
+ return null;
1387
+ case "principal":
1388
+ case "unrestricted":
1389
+ break;
1390
+ }
1173
1391
  const run = await runtime.storage.projectionRuns?.getById({
1174
1392
  projectId: runtime.projectId,
1175
1393
  id: runId
1176
1394
  }) ?? null;
1177
- return run && canViewProjectionRun(runtime.authorization, run.target) ? run : null;
1395
+ if (!run)
1396
+ return null;
1397
+ return authority.type === "unrestricted" || canViewProjectionRun(authority.context, run.target) ? run : null;
1178
1398
  },
1179
1399
  list: (input = {}) => {
1400
+ switch (authority.type) {
1401
+ case "denied":
1402
+ case "delegated":
1403
+ return Promise.resolve({ runs: [], hasMore: false, total: 0 });
1404
+ case "principal":
1405
+ case "unrestricted":
1406
+ break;
1407
+ }
1180
1408
  const storage = runtime.storage.projectionRuns;
1181
1409
  if (!storage)
1182
1410
  return Promise.resolve({ runs: [], hasMore: false, total: 0 });
1183
1411
  return storage.list({
1184
- projectId: runtime.projectId,
1185
1412
  ...input,
1186
- objectTypeIds: runtime.authorization ? [...runtime.authorization.grants["view:object"]] : undefined
1413
+ objectTypeIds: authority.type === "principal" ? [...authority.context.grants["view:object"]] : undefined,
1414
+ projectId: runtime.projectId
1187
1415
  });
1188
1416
  },
1189
1417
  listLatest: (projectionIds) => {
1418
+ switch (authority.type) {
1419
+ case "denied":
1420
+ case "delegated":
1421
+ return Promise.resolve({ runs: [] });
1422
+ case "principal":
1423
+ case "unrestricted":
1424
+ break;
1425
+ }
1190
1426
  const storage = runtime.storage.projectionRuns;
1191
1427
  if (!storage || projectionIds.length === 0)
1192
1428
  return Promise.resolve({ runs: [] });
@@ -1199,25 +1435,35 @@ function createProjectionsRuntime(runtime, source) {
1199
1435
 
1200
1436
  // src/rules/execution.ts
1201
1437
  function createRulesRuntime(runtime, source) {
1202
- const visible = (rule) => isAllowed(runtime.authorization, {
1203
- kind: "object.view",
1204
- objectTypeId: rule.subject.objectTypeId
1205
- });
1438
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
1439
+ const visible = (rule) => {
1440
+ if (authority.type === "denied" || authority.type === "delegated")
1441
+ return false;
1442
+ return isRuntimeAllowed(runtime, {
1443
+ kind: "object.view",
1444
+ objectTypeId: rule.subject.objectTypeId
1445
+ });
1446
+ };
1206
1447
  return {
1207
- list: () => source.list().filter(visible),
1448
+ list: () => authority.type === "denied" || authority.type === "delegated" ? [] : source.list().filter(visible),
1208
1449
  getById: (ruleId) => {
1450
+ if (authority.type === "denied" || authority.type === "delegated")
1451
+ return null;
1209
1452
  const rule = source.getById(ruleId);
1210
1453
  return rule && visible(rule) ? rule : null;
1211
1454
  },
1212
1455
  states: {
1213
1456
  list: (input = {}) => {
1457
+ if (authority.type === "denied" || authority.type === "delegated") {
1458
+ return Promise.resolve({ states: [], hasMore: false, total: 0 });
1459
+ }
1214
1460
  const storage = runtime.storage.rules;
1215
1461
  if (!storage)
1216
1462
  return Promise.resolve({ states: [], hasMore: false, total: 0 });
1217
1463
  return storage.listActive({
1218
- projectId: runtime.projectId,
1219
1464
  ...input,
1220
- objectTypeIds: runtime.authorization ? [...runtime.authorization.grants["view:object"]] : undefined
1465
+ objectTypeIds: authority.type === "principal" ? [...authority.context.grants["view:object"]] : undefined,
1466
+ projectId: runtime.projectId
1221
1467
  });
1222
1468
  }
1223
1469
  }
@@ -1225,24 +1471,299 @@ function createRulesRuntime(runtime, source) {
1225
1471
  }
1226
1472
 
1227
1473
  // src/schedules/execution.ts
1228
- function createSchedulesRuntime(schedules) {
1474
+ function createSchedulesRuntime(runtime, schedules) {
1475
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
1229
1476
  return {
1230
- list: () => schedules.list(),
1231
- getById: (scheduleId) => schedules.getById(scheduleId)
1477
+ list: () => {
1478
+ switch (authority.type) {
1479
+ case "denied":
1480
+ case "delegated":
1481
+ return [];
1482
+ case "principal":
1483
+ case "unrestricted":
1484
+ return schedules.list();
1485
+ }
1486
+ },
1487
+ getById: (scheduleId) => {
1488
+ switch (authority.type) {
1489
+ case "denied":
1490
+ case "delegated":
1491
+ return null;
1492
+ case "principal":
1493
+ case "unrestricted":
1494
+ return schedules.getById(scheduleId);
1495
+ }
1496
+ }
1232
1497
  };
1233
1498
  }
1234
1499
 
1500
+ // src/shares/execution.ts
1501
+ import { createHash as createHash2, randomBytes, randomUUID as randomUUID4 } from "crypto";
1502
+ var MAX_CREATE_ATTEMPTS = 5;
1503
+
1504
+ class ShareError extends Error {
1505
+ reason;
1506
+ name = "ShareError";
1507
+ constructor(reason, message, options) {
1508
+ super(message, options);
1509
+ this.reason = reason;
1510
+ }
1511
+ }
1512
+ function createSharesRuntime(runtime, execution, definitions) {
1513
+ const managementPrincipal = () => {
1514
+ const authority = resolveExecutionScopeAuthorization(runtime.projectId, {
1515
+ execution,
1516
+ authorization: runtime.runtimeAuthorization
1517
+ });
1518
+ if (authority.type !== "principal" || authority.context.principal.type === "system") {
1519
+ throw new ShareError("unauthenticated", "[Sixb] Shared access grants require user or service-account authority.");
1520
+ }
1521
+ return {
1522
+ type: authority.context.principal.type,
1523
+ id: authority.context.principal.id
1524
+ };
1525
+ };
1526
+ const canManage = (shareId) => {
1527
+ try {
1528
+ managementPrincipal();
1529
+ return isRuntimeAllowed(runtime, { kind: "share.manage", shareId });
1530
+ } catch {
1531
+ return false;
1532
+ }
1533
+ };
1534
+ const resolveManageableDefinition = (definitionId) => {
1535
+ const id = validDefinitionId(definitionId);
1536
+ managementPrincipal();
1537
+ assertCanManage(runtime, id);
1538
+ return resolveDefinition(definitions, id);
1539
+ };
1540
+ const issueByDefinition = async (definition, input) => {
1541
+ assertInputObject(input, "Shared access issue input");
1542
+ const issuer = managementPrincipal();
1543
+ assertCanManage(runtime, definition.id);
1544
+ const storage = requireShareStorage(runtime);
1545
+ const createdAt = new Date;
1546
+ const expiresAt = validFutureDate(input.expiresAt, createdAt);
1547
+ const target = exactTarget(definition, input.target);
1548
+ const object = await runtime.objectReader.getByPrimaryId({
1549
+ objectTypeId: target.objectTypeId,
1550
+ primaryId: target.primaryId
1551
+ });
1552
+ if (!object) {
1553
+ throw new ObjectNotFoundError(target.objectTypeId, target.primaryId, "Share target not found");
1554
+ }
1555
+ const authoritySnapshot = {
1556
+ version: 1,
1557
+ access: compileShareAccessPlan({
1558
+ share: definition,
1559
+ target,
1560
+ ontology: runtime.ontology,
1561
+ actions: runtime.actionRegistry
1562
+ })
1563
+ };
1564
+ for (let attempt = 0;attempt < MAX_CREATE_ATTEMPTS; attempt += 1) {
1565
+ const secret = randomBytes(32).toString("base64url");
1566
+ try {
1567
+ const grant = await storage.create({
1568
+ id: `shr_${randomUUID4()}`,
1569
+ projectId: runtime.projectId,
1570
+ definitionId: definition.id,
1571
+ target,
1572
+ issuedBy: issuer,
1573
+ authoritySnapshot,
1574
+ tokenHash: sha256(secret),
1575
+ destinationPath: input.destinationPath,
1576
+ createdAt,
1577
+ expiresAt
1578
+ });
1579
+ return { grant: publicGrant(grant), secret };
1580
+ } catch (error) {
1581
+ if (error instanceof ShareGrantStorageError && error.code === "invalid_input") {
1582
+ throw new ShareError("invalid_input", error.message, { cause: error });
1583
+ }
1584
+ if (!(error instanceof ShareGrantStorageError) || error.code !== "duplicate" || attempt === MAX_CREATE_ATTEMPTS - 1) {
1585
+ throw storageFailure("issue", error);
1586
+ }
1587
+ }
1588
+ }
1589
+ throw storageFailure("issue");
1590
+ };
1591
+ const listByDefinition = async (definition, input = {}) => {
1592
+ assertInputObject(input, "Shared access list input");
1593
+ managementPrincipal();
1594
+ assertCanManage(runtime, definition.id);
1595
+ const storage = requireShareStorage(runtime);
1596
+ const target = input.target === undefined ? undefined : exactTarget(definition, input.target);
1597
+ try {
1598
+ const result = await storage.list({
1599
+ projectId: runtime.projectId,
1600
+ definitionId: definition.id,
1601
+ ...target === undefined ? {} : { target },
1602
+ includeRevoked: input.includeRevoked,
1603
+ includeExpired: input.includeExpired,
1604
+ now: new Date,
1605
+ limit: input.limit,
1606
+ offset: input.offset
1607
+ });
1608
+ return { ...result, grants: result.grants.map(publicGrant) };
1609
+ } catch (error) {
1610
+ if (error instanceof ShareGrantStorageError && error.code === "invalid_input") {
1611
+ throw new ShareError("invalid_input", error.message, { cause: error });
1612
+ }
1613
+ throw storageFailure("list", error);
1614
+ }
1615
+ };
1616
+ return {
1617
+ listDefinitions: () => definitions.list().filter((definition) => canManage(definition.id)),
1618
+ getDefinitionById: (definitionId) => {
1619
+ const definition = definitions.getById(definitionId);
1620
+ return definition && canManage(definition.id) ? definition : null;
1621
+ },
1622
+ async issue(definition, input) {
1623
+ return issueByDefinition(resolveManageableDefinition(definitionIdFromReference(definition)), input);
1624
+ },
1625
+ async issueById(input) {
1626
+ assertInputObject(input, "Shared access issue input");
1627
+ return issueByDefinition(resolveManageableDefinition(input.definitionId), input);
1628
+ },
1629
+ async list(definition, input) {
1630
+ return listByDefinition(resolveManageableDefinition(definitionIdFromReference(definition)), input);
1631
+ },
1632
+ async listById(input) {
1633
+ assertInputObject(input, "Shared access list input");
1634
+ const definition = resolveManageableDefinition(input.definitionId);
1635
+ const { primaryId, includeRevoked, includeExpired, limit, offset } = input;
1636
+ return listByDefinition(definition, {
1637
+ ...primaryId === undefined ? {} : {
1638
+ target: {
1639
+ objectTypeId: definition.target.objectTypeId,
1640
+ primaryId
1641
+ }
1642
+ },
1643
+ includeRevoked,
1644
+ includeExpired,
1645
+ limit,
1646
+ offset
1647
+ });
1648
+ },
1649
+ revoke: async (grantId) => {
1650
+ const actor = managementPrincipal();
1651
+ const storage = requireShareStorage(runtime);
1652
+ if (typeof grantId !== "string" || !grantId.trim()) {
1653
+ throw new ShareError("invalid_input", "[Sixb] Shared access grant id must not be empty.");
1654
+ }
1655
+ let current;
1656
+ try {
1657
+ current = await storage.getById({ projectId: runtime.projectId, id: grantId });
1658
+ } catch (error) {
1659
+ throw storageFailure("load for revocation", error);
1660
+ }
1661
+ if (!current)
1662
+ return null;
1663
+ if (!definitions.getById(current.definitionId) || !canManage(current.definitionId)) {
1664
+ return null;
1665
+ }
1666
+ try {
1667
+ const revoked = await storage.revoke({
1668
+ projectId: runtime.projectId,
1669
+ id: grantId,
1670
+ revokedAt: new Date,
1671
+ revokedBy: actor
1672
+ });
1673
+ return revoked ? publicGrant(revoked) : null;
1674
+ } catch (error) {
1675
+ throw storageFailure("revoke", error);
1676
+ }
1677
+ }
1678
+ };
1679
+ }
1680
+ function definitionIdFromReference(value) {
1681
+ return typeof value === "object" && value !== null ? value.id : undefined;
1682
+ }
1683
+ function assertInputObject(value, label) {
1684
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
1685
+ throw new ShareError("invalid_input", `[Sixb] ${label} must be an object.`);
1686
+ }
1687
+ }
1688
+ function resolveDefinition(definitions, definitionId) {
1689
+ const id = validDefinitionId(definitionId);
1690
+ const definition = definitions.getById(id);
1691
+ if (!definition) {
1692
+ throw new ShareError("not_found", `[Sixb] Unknown Share definition '${id}'.`);
1693
+ }
1694
+ return definition;
1695
+ }
1696
+ function validDefinitionId(value) {
1697
+ if (typeof value !== "string" || !value.trim()) {
1698
+ throw new ShareError("invalid_input", "[Sixb] Share definition id must not be empty.");
1699
+ }
1700
+ return value;
1701
+ }
1702
+ function assertCanManage(runtime, shareId) {
1703
+ assertAuthorized(runtime, { kind: "share.manage", shareId });
1704
+ }
1705
+ function requireShareStorage(runtime) {
1706
+ const storage = runtime.storage.shareGrants;
1707
+ if (!storage) {
1708
+ throw new ShareError("storage_unavailable", "[Sixb] Share grant storage is not configured on this runtime.");
1709
+ }
1710
+ return storage;
1711
+ }
1712
+ function exactTarget(definition, value) {
1713
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
1714
+ throw new ShareError("invalid_input", "[Sixb] Share target must be an exact object reference.");
1715
+ }
1716
+ const objectTypeId = value.objectTypeId;
1717
+ const primaryId = value.primaryId;
1718
+ if (typeof objectTypeId !== "string" || typeof primaryId !== "string" || !primaryId.trim()) {
1719
+ throw new ShareError("invalid_input", "[Sixb] Share target must be an exact object reference.");
1720
+ }
1721
+ if (objectTypeId !== definition.target.objectTypeId) {
1722
+ throw new ShareError("invalid_input", `[Sixb] Share '${definition.id}' targets '${definition.target.objectTypeId}', not '${objectTypeId}'.`);
1723
+ }
1724
+ return Object.freeze({ objectTypeId, primaryId });
1725
+ }
1726
+ function validFutureDate(value, now) {
1727
+ if (!(value instanceof Date) || !Number.isFinite(value.getTime()) || value <= now) {
1728
+ throw new ShareError("invalid_input", "[Sixb] Shared access expiry must be a valid future date.");
1729
+ }
1730
+ return new Date(value);
1731
+ }
1732
+ function sha256(value) {
1733
+ return createHash2("sha256").update(value).digest("hex");
1734
+ }
1735
+ function publicGrant(record) {
1736
+ const {
1737
+ projectId: _projectId,
1738
+ authoritySnapshot: _authoritySnapshot,
1739
+ authorityDigest: _authorityDigest,
1740
+ tokenHash: _tokenHash,
1741
+ ...grant
1742
+ } = record;
1743
+ return structuredClone(grant);
1744
+ }
1745
+ function storageFailure(operation, cause) {
1746
+ return new ShareError("storage_failure", `[Sixb] Share grant storage failed to ${operation}.`, {
1747
+ cause
1748
+ });
1749
+ }
1750
+
1235
1751
  // src/syncs/execution.ts
1236
1752
  function createSyncsRuntime(runtime, execution, source) {
1237
- const allowed = (syncId) => isAllowed(runtime.authorization, { kind: "sync.run", syncId });
1753
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
1754
+ const allowed = (syncId) => isRuntimeAllowed(runtime, { kind: "sync.run", syncId });
1238
1755
  const visibleIds = () => source.list().filter((sync) => allowed(sync.id)).map((sync) => sync.id);
1756
+ const historyFilterIds = () => authority.type === "unrestricted" ? undefined : authority.type === "principal" ? visibleIds() : [];
1239
1757
  return {
1240
- list: () => source.list().filter((sync) => allowed(sync.id)),
1758
+ list: () => authority.type === "denied" || authority.type === "delegated" ? [] : source.list().filter((sync) => allowed(sync.id)),
1241
1759
  getById: (syncId) => {
1760
+ if (authority.type === "denied" || authority.type === "delegated")
1761
+ return null;
1242
1762
  const sync = source.getById(syncId);
1243
1763
  return sync && allowed(syncId) ? sync : null;
1244
1764
  },
1245
1765
  request: async (input) => {
1766
+ assertAuthorized(runtime, { kind: "sync.run", syncId: input.syncId });
1246
1767
  const sync = source.getById(input.syncId);
1247
1768
  if (!sync)
1248
1769
  throw new SyncValidationError(`[Sixb] Unknown sync '${input.syncId}'`);
@@ -1250,6 +1771,8 @@ function createSyncsRuntime(runtime, execution, source) {
1250
1771
  },
1251
1772
  runs: {
1252
1773
  getById: async (runId) => {
1774
+ if (authority.type === "denied" || authority.type === "delegated")
1775
+ return null;
1253
1776
  const run = await runtime.storage.syncRuns?.getById({
1254
1777
  projectId: runtime.projectId,
1255
1778
  id: runId
@@ -1257,16 +1780,22 @@ function createSyncsRuntime(runtime, execution, source) {
1257
1780
  return run && allowed(run.syncId) ? run : null;
1258
1781
  },
1259
1782
  list: (input = {}) => {
1783
+ if (authority.type === "denied" || authority.type === "delegated") {
1784
+ return Promise.resolve({ runs: [], hasMore: false, total: 0 });
1785
+ }
1260
1786
  const storage = runtime.storage.syncRuns;
1261
1787
  if (!storage)
1262
1788
  return Promise.resolve({ runs: [], hasMore: false, total: 0 });
1263
1789
  return storage.list({
1264
- projectId: runtime.projectId,
1265
1790
  ...input,
1266
- syncIds: runtime.authorization ? visibleIds() : undefined
1791
+ syncIds: historyFilterIds(),
1792
+ projectId: runtime.projectId
1267
1793
  });
1268
1794
  },
1269
1795
  listLatest: (syncIds) => {
1796
+ if (authority.type === "denied" || authority.type === "delegated") {
1797
+ return Promise.resolve({ runs: [] });
1798
+ }
1270
1799
  const storage = runtime.storage.syncRuns;
1271
1800
  if (!storage || syncIds.length === 0)
1272
1801
  return Promise.resolve({ runs: [] });
@@ -1292,7 +1821,7 @@ class WorkflowValidationError extends Error {
1292
1821
  }
1293
1822
 
1294
1823
  // src/workflows/run-dispatch.ts
1295
- import { randomUUID as randomUUID4 } from "crypto";
1824
+ import { randomUUID as randomUUID5 } from "crypto";
1296
1825
  import { isDeepStrictEqual } from "util";
1297
1826
 
1298
1827
  // src/workflows/validation.ts
@@ -1981,7 +2510,7 @@ async function persistWorkflowRun(input, request) {
1981
2510
  assertExistingWorkflowRun(existing, input.workflow.id, request.snapshot);
1982
2511
  return { run: existing, created: false };
1983
2512
  }
1984
- const execution = await input.createExecution(`exec_${randomUUID4()}`, request.runId);
2513
+ const execution = await input.createExecution(`exec_${randomUUID5()}`, request.runId);
1985
2514
  const queuedAt = new Date;
1986
2515
  try {
1987
2516
  return await input.storage.transaction(async (tx) => {
@@ -2088,7 +2617,7 @@ async function failWorkflowRunPublication(input, run, error) {
2088
2617
  }
2089
2618
  function resolveWorkflowRunId(runId) {
2090
2619
  if (runId === undefined)
2091
- return `run_${randomUUID4()}`;
2620
+ return `run_${randomUUID5()}`;
2092
2621
  if (!runId.trim()) {
2093
2622
  throw new WorkflowValidationError("[Sixb] Workflow run id must not be empty");
2094
2623
  }
@@ -2134,6 +2663,10 @@ function assertNonBlank(value, label) {
2134
2663
 
2135
2664
  // src/workflows/request.ts
2136
2665
  async function requestWorkflowRun(runtime, execution, workflow, options = {}) {
2666
+ resolveExecutionScopeAuthorization(runtime.projectId, {
2667
+ execution,
2668
+ authorization: runtime.runtimeAuthorization
2669
+ });
2137
2670
  assertAuthorized(runtime, { kind: "workflow.run", workflowId: workflow.id });
2138
2671
  const requesterGroupIds = execution.requestedBy ? await snapshotRequesterGroupIds({
2139
2672
  auth: runtime.storage.auth,
@@ -2168,15 +2701,31 @@ async function requestWorkflowRun(runtime, execution, workflow, options = {}) {
2168
2701
 
2169
2702
  // src/workflows/execution.ts
2170
2703
  function createWorkflowsRuntime(runtime, execution, source) {
2171
- const allowed = (workflowId) => isAllowed(runtime.authorization, { kind: "workflow.run", workflowId });
2172
- const canAccessHistory = (workflowId) => allowed(workflowId) && (!runtime.authorization || source.getById(workflowId) !== null);
2704
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
2705
+ const allowed = (workflowId) => isRuntimeAllowed(runtime, { kind: "workflow.run", workflowId });
2706
+ const canAccessHistory = (workflowId) => {
2707
+ switch (authority.type) {
2708
+ case "denied":
2709
+ case "delegated":
2710
+ return false;
2711
+ case "unrestricted":
2712
+ return true;
2713
+ case "principal":
2714
+ return allowed(workflowId) && source.getById(workflowId) !== null;
2715
+ }
2716
+ };
2173
2717
  const visibleIds = () => source.list().filter((workflow) => allowed(workflow.id)).map((workflow) => workflow.id);
2718
+ const historyFilterIds = () => authority.type === "unrestricted" ? undefined : authority.type === "principal" ? visibleIds() : [];
2174
2719
  const getVisibleRunRecord = async (runId) => {
2720
+ if (authority.type === "denied" || authority.type === "delegated")
2721
+ return null;
2175
2722
  const run = await runtime.storage.workflowRuns?.getById({
2176
2723
  projectId: runtime.projectId,
2177
2724
  id: runId
2178
2725
  }) ?? null;
2179
- return run && canViewWorkflowRun(runtime.authorization, run) && canAccessHistory(run.workflowId) ? run : null;
2726
+ if (!run || !canAccessHistory(run.workflowId))
2727
+ return null;
2728
+ return authority.type === "unrestricted" || canViewWorkflowRun(authority.context, run) ? run : null;
2180
2729
  };
2181
2730
  const getRun = async (runId) => {
2182
2731
  const run = await getVisibleRunRecord(runId);
@@ -2187,9 +2736,9 @@ function createWorkflowsRuntime(runtime, execution, source) {
2187
2736
  if (!storage || !await getVisibleRunRecord(runId))
2188
2737
  return null;
2189
2738
  const result = await storage.nodes.list({
2190
- projectId: runtime.projectId,
2191
2739
  ...input,
2192
- workflowRunId: runId
2740
+ workflowRunId: runId,
2741
+ projectId: runtime.projectId
2193
2742
  });
2194
2743
  return {
2195
2744
  ...result,
@@ -2197,13 +2746,16 @@ function createWorkflowsRuntime(runtime, execution, source) {
2197
2746
  };
2198
2747
  };
2199
2748
  return {
2200
- list: () => source.list().filter((workflow) => allowed(workflow.id)),
2749
+ list: () => authority.type === "denied" || authority.type === "delegated" ? [] : source.list().filter((workflow) => allowed(workflow.id)),
2201
2750
  getById: (workflowId) => {
2751
+ if (authority.type === "denied" || authority.type === "delegated")
2752
+ return null;
2202
2753
  const workflow = source.getById(workflowId);
2203
2754
  return workflow && allowed(workflowId) ? workflow : null;
2204
2755
  },
2205
2756
  request: (workflow, options) => requestWorkflowRun(runtime, execution, workflow, options),
2206
2757
  requestById: async (input) => {
2758
+ assertAuthorized(runtime, { kind: "workflow.run", workflowId: input.workflowId });
2207
2759
  const workflow = source.getById(input.workflowId);
2208
2760
  if (!workflow) {
2209
2761
  throw new WorkflowValidationError(`[Sixb] Unknown workflow '${input.workflowId}'`);
@@ -2213,13 +2765,16 @@ function createWorkflowsRuntime(runtime, execution, source) {
2213
2765
  runs: {
2214
2766
  getById: getRun,
2215
2767
  list: async (input = {}) => {
2768
+ if (authority.type === "denied" || authority.type === "delegated") {
2769
+ return { runs: [], hasMore: false, total: 0 };
2770
+ }
2216
2771
  const storage = runtime.storage.workflowRuns;
2217
2772
  if (!storage)
2218
2773
  return { runs: [], hasMore: false, total: 0 };
2219
2774
  const result = await storage.list({
2220
- projectId: runtime.projectId,
2221
2775
  ...input,
2222
- workflowIds: runtime.authorization ? visibleIds() : undefined
2776
+ workflowIds: historyFilterIds(),
2777
+ projectId: runtime.projectId
2223
2778
  });
2224
2779
  return {
2225
2780
  ...result,
@@ -2227,6 +2782,9 @@ function createWorkflowsRuntime(runtime, execution, source) {
2227
2782
  };
2228
2783
  },
2229
2784
  listLatest: async (workflowIds) => {
2785
+ if (authority.type === "denied" || authority.type === "delegated") {
2786
+ return { runs: [] };
2787
+ }
2230
2788
  const storage = runtime.storage.workflowRuns;
2231
2789
  if (!storage || workflowIds.length === 0)
2232
2790
  return { runs: [] };
@@ -2245,20 +2803,27 @@ function createWorkflowsRuntime(runtime, execution, source) {
2245
2803
  },
2246
2804
  interventions: {
2247
2805
  getById: async (interventionId) => {
2806
+ if (authority.type === "denied" || authority.type === "delegated")
2807
+ return null;
2248
2808
  const intervention = await runtime.storage.workflowInterventions?.getById({
2249
2809
  projectId: runtime.projectId,
2250
2810
  id: interventionId
2251
2811
  }) ?? null;
2252
- return intervention && canViewWorkflowIntervention(runtime.authorization, intervention) && canAccessHistory(intervention.workflowId) ? intervention : null;
2812
+ if (!intervention || !canAccessHistory(intervention.workflowId))
2813
+ return null;
2814
+ return authority.type === "unrestricted" || canViewWorkflowIntervention(authority.context, intervention) ? intervention : null;
2253
2815
  },
2254
2816
  list: (input = {}) => {
2817
+ if (authority.type === "denied" || authority.type === "delegated") {
2818
+ return Promise.resolve({ interventions: [], hasMore: false, total: 0 });
2819
+ }
2255
2820
  const storage = runtime.storage.workflowInterventions;
2256
2821
  if (!storage)
2257
2822
  return Promise.resolve({ interventions: [], hasMore: false, total: 0 });
2258
2823
  return storage.list({
2259
- projectId: runtime.projectId,
2260
2824
  ...input,
2261
- workflowIds: runtime.authorization ? visibleIds() : undefined
2825
+ workflowIds: historyFilterIds(),
2826
+ projectId: runtime.projectId
2262
2827
  });
2263
2828
  }
2264
2829
  }
@@ -2337,6 +2902,14 @@ async function attachRequestedBy(runtime, run) {
2337
2902
  // src/runtime/sixb.ts
2338
2903
  var boundSixbInstances = new WeakSet;
2339
2904
  function createBoundSixb(runtime, dependencies, execution) {
2905
+ resolveExecutionScopeAuthorization(runtime.projectId, {
2906
+ execution,
2907
+ authorization: runtime.runtimeAuthorization
2908
+ });
2909
+ assertAuthorizedObjectReaderBinding({
2910
+ reader: runtime.objectReader,
2911
+ scope: { execution, authorization: runtime.runtimeAuthorization }
2912
+ });
2340
2913
  const sixb = {
2341
2914
  execution,
2342
2915
  ...createExecutionFacades(runtime, execution, dependencies)
@@ -2355,7 +2928,7 @@ function createExecutionFacades(runtime, execution, dependencies) {
2355
2928
  return {
2356
2929
  objects: createObjectsRuntime(runtime, execution),
2357
2930
  actions: createActionsRuntime(runtime, execution),
2358
- datasets: createDatasetsRuntime(runtime, dependencies.definitions.datasets),
2931
+ datasets: createDatasetsRuntime(runtime, execution, dependencies.definitions.datasets, dependencies.lakeStorage, dependencies.blobStorage),
2359
2932
  workflows: createWorkflowsRuntime(runtime, execution, dependencies.definitions.workflows),
2360
2933
  syncs: createSyncsRuntime(runtime, execution, dependencies.definitions.syncs),
2361
2934
  pipelines: createPipelinesRuntime(runtime, execution, dependencies.definitions.pipelines),
@@ -2365,7 +2938,8 @@ function createExecutionFacades(runtime, execution, dependencies) {
2365
2938
  aiUsage: createAiUsageRuntime(runtime, dependencies.definitions.security),
2366
2939
  events: createEventsRuntime(runtime),
2367
2940
  logs: createLogsRuntime(runtime, dependencies.logging),
2368
- schedules: createSchedulesRuntime(dependencies.definitions.schedules),
2941
+ schedules: createSchedulesRuntime(runtime, dependencies.definitions.schedules),
2942
+ shares: createSharesRuntime(runtime, execution, dependencies.definitions.shares),
2369
2943
  connector: createConnectorRuntime(runtime, execution, dependencies.connectorService),
2370
2944
  blobs: createBlobsRuntime(runtime, execution, dependencies.blobStorage)
2371
2945
  };
@@ -2430,10 +3004,7 @@ function restoreAgentExecutionScope(input) {
2430
3004
  return Object.freeze({
2431
3005
  execution: context,
2432
3006
  authorization: createAgentRuntimeAuthorization({
2433
- projectId: input.execution.projectId,
2434
- executionId: input.execution.id,
2435
- ...input.actorId === undefined ? {} : { actorId: input.actorId },
2436
- runId: input.runId,
3007
+ execution: context,
2437
3008
  authority: input.authorization.type === "principal" ? {
2438
3009
  type: "principal",
2439
3010
  context: input.authorization.context,
@@ -2481,6 +3052,6 @@ function invalidAgentExecution(executionId, runId) {
2481
3052
  throw new ExecutionStorageError("invalid_input", `[Sixb] Execution '${executionId}' does not authorize Agent run '${runId}'.`);
2482
3053
  }
2483
3054
 
2484
- export { resolveAgentContextParts, agentRunQueueJobId, subagentRunQueueJobId, workflowAgentNodeQueueJobId, dispatchQueuedAgentRuns, dispatchQueuedSubagentRuns, createAgentThreadId, createAgentRunId, createSubagentRunId, createSubagentExecutionId, createAgentMessageId, agentContextCheckpointId, createAgentRunExecutionToken, assertNoAgentDefinitions, WorkflowDefinitionError, WorkflowValidationError, assertNonEmpty, isStepDefinition, isAgentStepDefinition, isInterventionDefinition, isWorkflowDefinition, validateWorkflowDefinition, validateWorkflowsAtStartup, validateWorkflowAgentStepGroupReferences, validateWorkflowInput, validateWorkflowStepInput, validateWorkflowStepOutput, validateWorkflowInterventionInput, validateWorkflowInterventionResponse, validateWorkflowInterventionDefaultResponse, validateWorkflowAgentStepInput, validateWorkflowAgentStepOutput, snapshotWorkflowAgentStepInput, snapshotWorkflowAgentStepOutput, snapshotWorkflowInput, snapshotWorkflowStepInput, snapshotWorkflowStepOutput, snapshotWorkflowInterventionInput, snapshotWorkflowInterventionResponse, snapshotWorkflowInterventionDefaultResponse, snapshotWorkflowActionInput, WorkflowRunDispatcher, requestWorkflowRun, createBoundSixb, isBoundSixb, canInheritAgentRequestAuthorization, createAgentExecutionRecord, createInheritedAgentExecutionRecord, bindDurableAgentExecution, restoreAgentExecutionScope, assertAgentExecutionRecord, requestAgentRun, retryAgentRun };
3055
+ export { resolveAgentContextParts, agentRunQueueJobId, subagentRunQueueJobId, workflowAgentNodeQueueJobId, dispatchQueuedAgentRuns, dispatchQueuedSubagentRuns, createAgentThreadId, createAgentRunId, createSubagentRunId, createSubagentExecutionId, createAgentMessageId, agentContextCheckpointId, createAgentRunExecutionToken, assertNoAgentDefinitions, ShareError, WorkflowDefinitionError, WorkflowValidationError, assertNonEmpty, isStepDefinition, isAgentStepDefinition, isInterventionDefinition, isWorkflowDefinition, validateWorkflowDefinition, validateWorkflowsAtStartup, validateWorkflowAgentStepGroupReferences, validateWorkflowInput, validateWorkflowStepInput, validateWorkflowStepOutput, validateWorkflowInterventionInput, validateWorkflowInterventionResponse, validateWorkflowInterventionDefaultResponse, validateWorkflowAgentStepInput, validateWorkflowAgentStepOutput, snapshotWorkflowAgentStepInput, snapshotWorkflowAgentStepOutput, snapshotWorkflowInput, snapshotWorkflowStepInput, snapshotWorkflowStepOutput, snapshotWorkflowInterventionInput, snapshotWorkflowInterventionResponse, snapshotWorkflowInterventionDefaultResponse, snapshotWorkflowActionInput, WorkflowRunDispatcher, requestWorkflowRun, createBoundSixb, isBoundSixb, canInheritAgentRequestAuthorization, createAgentExecutionRecord, createInheritedAgentExecutionRecord, bindDurableAgentExecution, restoreAgentExecutionScope, assertAgentExecutionRecord, requestAgentRun, retryAgentRun };
2485
3056
 
2486
- //# debugId=00C5E0281CC5D43264756E2164756E21
3057
+ //# debugId=3C841C41C07F660564756E2164756E21