@sixb/core 0.1.6 → 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 (909) 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 +50 -40
  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 +5 -5
  15. package/dist/actions/worker.js.map +1 -1
  16. package/dist/agents/adapters.d.ts +6 -166
  17. package/dist/agents/adapters.d.ts.map +1 -1
  18. package/dist/agents/authority.d.ts +22 -6
  19. package/dist/agents/authority.d.ts.map +1 -1
  20. package/dist/agents/builders.d.ts +3 -11
  21. package/dist/agents/builders.d.ts.map +1 -1
  22. package/dist/agents/context-resolution.d.ts.map +1 -1
  23. package/dist/agents/context.js +2 -2
  24. package/dist/agents/dispatch.d.ts +9 -1
  25. package/dist/agents/dispatch.d.ts.map +1 -1
  26. package/dist/agents/errors.d.ts +1 -10
  27. package/dist/agents/errors.d.ts.map +1 -1
  28. package/dist/agents/execution.d.ts +9 -10
  29. package/dist/agents/execution.d.ts.map +1 -1
  30. package/dist/agents/identity.d.ts +3 -0
  31. package/dist/agents/identity.d.ts.map +1 -0
  32. package/dist/agents/ids.d.ts +4 -0
  33. package/dist/agents/ids.d.ts.map +1 -1
  34. package/dist/agents/index.d.ts +15 -11
  35. package/dist/agents/index.d.ts.map +1 -1
  36. package/dist/agents/index.js +90 -78
  37. package/dist/agents/index.js.map +1 -1
  38. package/dist/agents/message.d.ts +19 -13
  39. package/dist/agents/message.d.ts.map +1 -1
  40. package/dist/agents/model-loop.d.ts +58 -0
  41. package/dist/agents/model-loop.d.ts.map +1 -0
  42. package/dist/agents/reference.d.ts +4 -0
  43. package/dist/agents/reference.d.ts.map +1 -0
  44. package/dist/agents/request.d.ts +10 -8
  45. package/dist/agents/request.d.ts.map +1 -1
  46. package/dist/agents/retired-config.d.ts +4 -0
  47. package/dist/agents/retired-config.d.ts.map +1 -0
  48. package/dist/agents/streams.d.ts +13 -8
  49. package/dist/agents/streams.d.ts.map +1 -1
  50. package/dist/agents/streams.js +7 -5
  51. package/dist/agents/streams.js.map +1 -1
  52. package/dist/agents/tool-catalog.d.ts +9 -0
  53. package/dist/agents/tool-catalog.d.ts.map +1 -0
  54. package/dist/agents/tool-definition.d.ts +1 -1
  55. package/dist/agents/tool-definition.d.ts.map +1 -1
  56. package/dist/agents/types.d.ts +31 -68
  57. package/dist/agents/types.d.ts.map +1 -1
  58. package/dist/agents/validation.d.ts +3 -13
  59. package/dist/agents/validation.d.ts.map +1 -1
  60. package/dist/ai-usage/execution.d.ts +53 -0
  61. package/dist/ai-usage/execution.d.ts.map +1 -0
  62. package/dist/ai-usage/index.d.ts +3 -0
  63. package/dist/ai-usage/index.d.ts.map +1 -0
  64. package/dist/auth/index.js +12 -9
  65. package/dist/auth/index.js.map +1 -1
  66. package/dist/authorization/decision.d.ts +14 -3
  67. package/dist/authorization/decision.d.ts.map +1 -1
  68. package/dist/authorization/grant-kinds.d.ts +25 -8
  69. package/dist/authorization/grant-kinds.d.ts.map +1 -1
  70. package/dist/authorization/index.d.ts +1 -1
  71. package/dist/authorization/index.d.ts.map +1 -1
  72. package/dist/authorization/index.js +12 -7
  73. package/dist/authorization/index.js.map +1 -1
  74. package/dist/authorization/resolve.d.ts +3 -3
  75. package/dist/authorization/resolve.d.ts.map +1 -1
  76. package/dist/authorization/types.d.ts +7 -5
  77. package/dist/authorization/types.d.ts.map +1 -1
  78. package/dist/blob-storage/browser.js +2 -2
  79. package/dist/blob-storage/index.js +3 -3
  80. package/dist/bootstrap/discovery.d.ts +6 -6
  81. package/dist/bootstrap/discovery.d.ts.map +1 -1
  82. package/dist/bootstrap/index.js +62 -51
  83. package/dist/bootstrap/index.js.map +1 -1
  84. package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -1
  85. package/dist/broker/index.js +2 -2
  86. package/dist/{chunk-zqysyfjt.js → chunk-08m3b6w8.js} +1 -1
  87. package/dist/chunk-19jp6g9d.js +131 -0
  88. package/dist/chunk-19jp6g9d.js.map +11 -0
  89. package/dist/{chunk-3j7573mj.js → chunk-2dw777qw.js} +50 -5
  90. package/dist/{chunk-3j7573mj.js.map → chunk-2dw777qw.js.map} +4 -3
  91. package/dist/{chunk-0172wgm9.js → chunk-2xns679x.js} +10 -2
  92. package/dist/{chunk-0172wgm9.js.map → chunk-2xns679x.js.map} +3 -3
  93. package/dist/chunk-359jm1jw.js +147 -0
  94. package/dist/chunk-359jm1jw.js.map +10 -0
  95. package/dist/{chunk-dy311asx.js → chunk-3xep5cjx.js} +58 -23
  96. package/dist/chunk-3xep5cjx.js.map +15 -0
  97. package/dist/{chunk-n4spznws.js → chunk-3z1qec12.js} +83 -12
  98. package/dist/chunk-3z1qec12.js.map +12 -0
  99. package/dist/{chunk-z3zp0bj1.js → chunk-407j3msh.js} +1 -1
  100. package/dist/{chunk-rhrbz7d4.js → chunk-4a849fr1.js} +1 -1
  101. package/dist/{chunk-cy0n5dms.js → chunk-4jjp5k14.js} +1 -1
  102. package/dist/chunk-4qfkag59.js +1568 -0
  103. package/dist/chunk-4qfkag59.js.map +20 -0
  104. package/dist/{chunk-1e8m6yn3.js → chunk-4sm0aznx.js} +685 -86
  105. package/dist/chunk-4sm0aznx.js.map +43 -0
  106. package/dist/chunk-4yqmp43v.js +159 -0
  107. package/dist/chunk-4yqmp43v.js.map +11 -0
  108. package/dist/{chunk-rdeagz6b.js → chunk-5e3pq99w.js} +3 -7
  109. package/dist/{chunk-rdeagz6b.js.map → chunk-5e3pq99w.js.map} +3 -3
  110. package/dist/{chunk-ezake7g1.js → chunk-5ntny1qx.js} +1 -1
  111. package/dist/{chunk-dm72y8wt.js → chunk-7y0f6rf1.js} +29 -16
  112. package/dist/chunk-7y0f6rf1.js.map +10 -0
  113. package/dist/{chunk-72q2y8hn.js → chunk-8tsf6dmc.js} +2 -2
  114. package/dist/{chunk-qewtks41.js → chunk-9nbmsvn5.js} +123 -20
  115. package/dist/chunk-9nbmsvn5.js.map +11 -0
  116. package/dist/{chunk-5sxb1168.js → chunk-aa2pen2v.js} +256 -82
  117. package/dist/chunk-aa2pen2v.js.map +34 -0
  118. package/dist/{chunk-819wnjz8.js → chunk-ajnan18g.js} +13 -10
  119. package/dist/chunk-ajnan18g.js.map +12 -0
  120. package/dist/chunk-c15dr03f.js +43 -0
  121. package/dist/chunk-c15dr03f.js.map +10 -0
  122. package/dist/{chunk-t0jjkep3.js → chunk-d8qkxt2v.js} +4 -2
  123. package/dist/chunk-d8qkxt2v.js.map +10 -0
  124. package/dist/{chunk-vybf6pkp.js → chunk-dbc80ad7.js} +1 -1
  125. package/dist/{chunk-nkbfrt0c.js → chunk-f26bck4t.js} +7 -7
  126. package/dist/{chunk-x2yw73hy.js → chunk-fvt9rjsa.js} +23 -7
  127. package/dist/chunk-fvt9rjsa.js.map +10 -0
  128. package/dist/{chunk-znagycq7.js → chunk-gbejpkex.js} +5 -5
  129. package/dist/{chunk-znagycq7.js.map → chunk-gbejpkex.js.map} +1 -1
  130. package/dist/{chunk-e42bc6m3.js → chunk-gzasd5b6.js} +5 -5
  131. package/dist/{chunk-e42bc6m3.js.map → chunk-gzasd5b6.js.map} +3 -3
  132. package/dist/{chunk-rnshztfq.js → chunk-h0k55pc7.js} +6 -6
  133. package/dist/{chunk-rnshztfq.js.map → chunk-h0k55pc7.js.map} +1 -1
  134. package/dist/chunk-h5vqbfmd.js +1537 -0
  135. package/dist/chunk-h5vqbfmd.js.map +19 -0
  136. package/dist/chunk-j1sbhm7p.js +45 -0
  137. package/dist/chunk-j1sbhm7p.js.map +10 -0
  138. package/dist/chunk-jecn6t54.js +307 -0
  139. package/dist/chunk-jecn6t54.js.map +12 -0
  140. package/dist/{chunk-dsrkgtnh.js → chunk-jq43kdvk.js} +1 -1
  141. package/dist/{chunk-wtmzkcht.js → chunk-k34z5rvh.js} +1 -1
  142. package/dist/{chunk-f6erf2vv.js → chunk-k522z7v6.js} +10 -5
  143. package/dist/chunk-k522z7v6.js.map +10 -0
  144. package/dist/{chunk-htq0qh7z.js → chunk-ka3a2ft3.js} +2 -2
  145. package/dist/{chunk-ckxfnx7f.js → chunk-mth82m8t.js} +129 -95
  146. package/dist/chunk-mth82m8t.js.map +14 -0
  147. package/dist/{chunk-5gynx4xn.js → chunk-mwsxn98e.js} +79 -77
  148. package/dist/{chunk-5gynx4xn.js.map → chunk-mwsxn98e.js.map} +8 -8
  149. package/dist/{chunk-f2rt4vkh.js → chunk-n2w475r0.js} +3 -3
  150. package/dist/chunk-n4khvw9n.js +111 -0
  151. package/dist/chunk-n4khvw9n.js.map +11 -0
  152. package/dist/{chunk-t8t39h7v.js → chunk-n6jxh8sw.js} +10 -2
  153. package/dist/chunk-n6jxh8sw.js.map +10 -0
  154. package/dist/chunk-nn0tekr1.js +284 -0
  155. package/dist/chunk-nn0tekr1.js.map +12 -0
  156. package/dist/chunk-nx7k8tpr.js +436 -0
  157. package/dist/chunk-nx7k8tpr.js.map +12 -0
  158. package/dist/{chunk-drjqm1aa.js → chunk-p03r0h5s.js} +310 -28
  159. package/dist/chunk-p03r0h5s.js.map +16 -0
  160. package/dist/{chunk-1g8negke.js → chunk-p1rzczbt.js} +93 -8
  161. package/dist/chunk-p1rzczbt.js.map +12 -0
  162. package/dist/{chunk-f83ka50g.js → chunk-p1x242ad.js} +652 -77
  163. package/dist/chunk-p1x242ad.js.map +25 -0
  164. package/dist/chunk-p2vqaxkc.js +528 -0
  165. package/dist/chunk-p2vqaxkc.js.map +15 -0
  166. package/dist/{chunk-a31h57d5.js → chunk-pc7ys28c.js} +70 -7
  167. package/dist/chunk-pc7ys28c.js.map +14 -0
  168. package/dist/{chunk-md8k0r54.js → chunk-q0k9nc5a.js} +281 -89
  169. package/dist/chunk-q0k9nc5a.js.map +14 -0
  170. package/dist/{chunk-bhxaq2nn.js → chunk-qw9gvjv5.js} +1 -1
  171. package/dist/chunk-r8jrnexe.js +403 -0
  172. package/dist/chunk-r8jrnexe.js.map +10 -0
  173. package/dist/{chunk-h9kxd41f.js → chunk-rafagrwr.js} +48 -7
  174. package/dist/chunk-rafagrwr.js.map +11 -0
  175. package/dist/{chunk-dysw7nsm.js → chunk-rv2hkwwa.js} +2 -2
  176. package/dist/{chunk-ghteq96b.js → chunk-s5y30bc9.js} +2 -2
  177. package/dist/{chunk-t624af60.js → chunk-sbzzr4kx.js} +1848 -757
  178. package/dist/chunk-sbzzr4kx.js.map +63 -0
  179. package/dist/{chunk-6gjqgd3d.js → chunk-tpnd31c1.js} +2 -1
  180. package/dist/chunk-tpnd31c1.js.map +11 -0
  181. package/dist/chunk-trxxmgnf.js +68 -0
  182. package/dist/chunk-trxxmgnf.js.map +11 -0
  183. package/dist/{chunk-0hc5j867.js → chunk-v1xppd0y.js} +17 -13
  184. package/dist/{chunk-0hc5j867.js.map → chunk-v1xppd0y.js.map} +2 -2
  185. package/dist/chunk-v4en4jc2.js +252 -0
  186. package/dist/chunk-v4en4jc2.js.map +10 -0
  187. package/dist/{chunk-xkthy56g.js → chunk-w1tvjszy.js} +1 -1
  188. package/dist/{chunk-8b55ygje.js → chunk-w3e09qqk.js} +1 -1
  189. package/dist/{chunk-8gv5z0zm.js → chunk-w9tg6yyb.js} +13 -8
  190. package/dist/{chunk-8gv5z0zm.js.map → chunk-w9tg6yyb.js.map} +3 -3
  191. package/dist/{chunk-62c7t4jc.js → chunk-wdage1eb.js} +1 -1
  192. package/dist/{chunk-tg5mee00.js → chunk-wtf06et8.js} +11 -7
  193. package/dist/{chunk-tg5mee00.js.map → chunk-wtf06et8.js.map} +3 -3
  194. package/dist/{chunk-nva1xkjz.js → chunk-xajtptbw.js} +1237 -1434
  195. package/dist/chunk-xajtptbw.js.map +40 -0
  196. package/dist/{chunk-xc7hq65b.js → chunk-yp8ee62z.js} +49 -2
  197. package/dist/chunk-yp8ee62z.js.map +11 -0
  198. package/dist/chunk-z4ccwbkz.js +139 -0
  199. package/dist/chunk-z4ccwbkz.js.map +10 -0
  200. package/dist/datasets/builders.d.ts +11 -2
  201. package/dist/datasets/builders.d.ts.map +1 -1
  202. package/dist/datasets/changes.d.ts +14 -4
  203. package/dist/datasets/changes.d.ts.map +1 -1
  204. package/dist/datasets/execution.d.ts +15 -1
  205. package/dist/datasets/execution.d.ts.map +1 -1
  206. package/dist/datasets/index.d.ts +1 -0
  207. package/dist/datasets/index.d.ts.map +1 -1
  208. package/dist/datasets/sequence.d.ts +7 -0
  209. package/dist/datasets/sequence.d.ts.map +1 -0
  210. package/dist/datasets/types.d.ts +1 -0
  211. package/dist/datasets/types.d.ts.map +1 -1
  212. package/dist/datasets/validation.d.ts.map +1 -1
  213. package/dist/datasets/write.d.ts +37 -0
  214. package/dist/datasets/write.d.ts.map +1 -0
  215. package/dist/datasets/write.js +17 -0
  216. package/dist/datasets/write.js.map +9 -0
  217. package/dist/error-reporting/internal.js +4 -4
  218. package/dist/error-reporting/types.d.ts +7 -2
  219. package/dist/error-reporting/types.d.ts.map +1 -1
  220. package/dist/errors/catalog.d.ts +8 -0
  221. package/dist/errors/catalog.d.ts.map +1 -1
  222. package/dist/errors/internal.js +2 -2
  223. package/dist/events/execution.d.ts.map +1 -1
  224. package/dist/events/index.js +4 -4
  225. package/dist/events/types/datasets.d.ts +2 -6
  226. package/dist/events/types/datasets.d.ts.map +1 -1
  227. package/dist/execution/agent.d.ts +18 -9
  228. package/dist/execution/agent.d.ts.map +1 -1
  229. package/dist/execution/agent.js +62 -46
  230. package/dist/execution/agent.js.map +1 -1
  231. package/dist/execution/authorization.d.ts +68 -20
  232. package/dist/execution/authorization.d.ts.map +1 -1
  233. package/dist/execution/authorized-object-reader.d.ts +69 -0
  234. package/dist/execution/authorized-object-reader.d.ts.map +1 -0
  235. package/dist/execution/durable.d.ts.map +1 -1
  236. package/dist/execution/index.d.ts +1 -1
  237. package/dist/execution/index.d.ts.map +1 -1
  238. package/dist/execution/primitive.js +55 -46
  239. package/dist/execution/primitive.js.map +2 -2
  240. package/dist/execution/request.d.ts +14 -1
  241. package/dist/execution/request.d.ts.map +1 -1
  242. package/dist/execution/request.js +92 -54
  243. package/dist/execution/request.js.map +3 -3
  244. package/dist/execution/scopes.d.ts +16 -0
  245. package/dist/execution/scopes.d.ts.map +1 -1
  246. package/dist/execution/types.d.ts +10 -1
  247. package/dist/execution/types.d.ts.map +1 -1
  248. package/dist/http/api-routes.d.ts +2 -0
  249. package/dist/http/api-routes.d.ts.map +1 -1
  250. package/dist/http/index.js +1 -1
  251. package/dist/index.d.ts +15 -9
  252. package/dist/index.d.ts.map +1 -1
  253. package/dist/index.js +128 -109
  254. package/dist/index.js.map +1 -1
  255. package/dist/json.d.ts +2 -0
  256. package/dist/json.d.ts.map +1 -1
  257. package/dist/lake-storage/definition-updates.d.ts.map +1 -1
  258. package/dist/lake-storage/errors.d.ts +5 -1
  259. package/dist/lake-storage/errors.d.ts.map +1 -1
  260. package/dist/lake-storage/in-memory.d.ts +1 -0
  261. package/dist/lake-storage/in-memory.d.ts.map +1 -1
  262. package/dist/lake-storage/index.d.ts +6 -1
  263. package/dist/lake-storage/index.d.ts.map +1 -1
  264. package/dist/lake-storage/index.js +27 -10
  265. package/dist/lake-storage/index.js.map +1 -1
  266. package/dist/lake-storage/merge-validation.d.ts.map +1 -1
  267. package/dist/lake-storage/merge.d.ts +13 -2
  268. package/dist/lake-storage/merge.d.ts.map +1 -1
  269. package/dist/lake-storage/source-ordering.d.ts +19 -0
  270. package/dist/lake-storage/source-ordering.d.ts.map +1 -0
  271. package/dist/lake-storage/sql-transforms.d.ts +2 -1
  272. package/dist/lake-storage/sql-transforms.d.ts.map +1 -1
  273. package/dist/lake-storage/types.d.ts +10 -5
  274. package/dist/lake-storage/types.d.ts.map +1 -1
  275. package/dist/lake-storage/version-inputs.d.ts +4 -0
  276. package/dist/lake-storage/version-inputs.d.ts.map +1 -0
  277. package/dist/logging/index.js +3 -3
  278. package/dist/logging/types.js +2 -2
  279. package/dist/materialization/index.js +2 -2
  280. package/dist/materializer/index.js +38 -31
  281. package/dist/materializer/index.js.map +1 -1
  282. package/dist/models/catalog.d.ts +40 -0
  283. package/dist/models/catalog.d.ts.map +1 -0
  284. package/dist/models/definitions.d.ts +25 -0
  285. package/dist/models/definitions.d.ts.map +1 -0
  286. package/dist/models/errors.d.ts +52 -0
  287. package/dist/models/errors.d.ts.map +1 -0
  288. package/dist/models/events.d.ts +192 -0
  289. package/dist/models/events.d.ts.map +1 -0
  290. package/dist/models/index.d.ts +17 -39
  291. package/dist/models/index.d.ts.map +1 -1
  292. package/dist/models/index.js +50 -0
  293. package/dist/models/index.js.map +9 -0
  294. package/dist/models/language-model.d.ts +90 -0
  295. package/dist/models/language-model.d.ts.map +1 -0
  296. package/dist/models/messages.d.ts +74 -0
  297. package/dist/models/messages.d.ts.map +1 -0
  298. package/dist/models/pricing.d.ts +69 -0
  299. package/dist/models/pricing.d.ts.map +1 -0
  300. package/dist/models/rate-card.d.ts +24 -0
  301. package/dist/models/rate-card.d.ts.map +1 -0
  302. package/dist/models/tools.d.ts +24 -0
  303. package/dist/models/tools.d.ts.map +1 -0
  304. package/dist/objects/authorized-ontology-view.d.ts +25 -0
  305. package/dist/objects/authorized-ontology-view.d.ts.map +1 -0
  306. package/dist/objects/execution.d.ts +1 -1
  307. package/dist/objects/execution.d.ts.map +1 -1
  308. package/dist/objects/index.js +43 -36
  309. package/dist/objects/index.js.map +1 -1
  310. package/dist/objects/link/authorization.d.ts +2 -7
  311. package/dist/objects/link/authorization.d.ts.map +1 -1
  312. package/dist/objects/query/executor.d.ts +4 -2
  313. package/dist/objects/query/executor.d.ts.map +1 -1
  314. package/dist/objects/query/index.js +36 -29
  315. package/dist/objects/query/index.js.map +1 -1
  316. package/dist/objects/query/links.d.ts +22 -1
  317. package/dist/objects/query/links.d.ts.map +1 -1
  318. package/dist/objects/query/selected-read-admission.d.ts +27 -0
  319. package/dist/objects/query/selected-read-admission.d.ts.map +1 -0
  320. package/dist/objects/query/validate.d.ts +60 -2
  321. package/dist/objects/query/validate.d.ts.map +1 -1
  322. package/dist/objects/sdk/object-handle.d.ts.map +1 -1
  323. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  324. package/dist/objects/sdk/runtime-query-executor.d.ts +2 -7
  325. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
  326. package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -1
  327. package/dist/objects/service/list-service.d.ts +2 -3
  328. package/dist/objects/service/list-service.d.ts.map +1 -1
  329. package/dist/objects/telemetry/history.d.ts +8 -6
  330. package/dist/objects/telemetry/history.d.ts.map +1 -1
  331. package/dist/objects/telemetry/index.d.ts +2 -2
  332. package/dist/objects/telemetry/index.d.ts.map +1 -1
  333. package/dist/objects/telemetry/workload.d.ts +11 -0
  334. package/dist/objects/telemetry/workload.d.ts.map +1 -0
  335. package/dist/ontology/index.d.ts +2 -1
  336. package/dist/ontology/index.d.ts.map +1 -1
  337. package/dist/ontology/index.js +15 -14
  338. package/dist/ontology/index.js.map +1 -1
  339. package/dist/ontology/inference/index.d.ts +2 -1
  340. package/dist/ontology/inference/index.d.ts.map +1 -1
  341. package/dist/ontology/internal.d.ts +0 -1
  342. package/dist/ontology/internal.d.ts.map +1 -1
  343. package/dist/ontology/internal.js +5 -10
  344. package/dist/ontology/internal.js.map +3 -3
  345. package/dist/ontology/json-schema.d.ts +10 -6
  346. package/dist/ontology/json-schema.d.ts.map +1 -1
  347. package/dist/ontology/link-path-selection.d.ts +35 -0
  348. package/dist/ontology/link-path-selection.d.ts.map +1 -0
  349. package/dist/ontology/refs.d.ts +2 -0
  350. package/dist/ontology/refs.d.ts.map +1 -1
  351. package/dist/ontology/tokens.d.ts +2 -1
  352. package/dist/ontology/tokens.d.ts.map +1 -1
  353. package/dist/pipelines/execution.d.ts.map +1 -1
  354. package/dist/pipelines/index.js +41 -36
  355. package/dist/pipelines/index.js.map +1 -1
  356. package/dist/pipelines/request.d.ts.map +1 -1
  357. package/dist/projections/execution.d.ts.map +1 -1
  358. package/dist/projections/internal.js +39 -32
  359. package/dist/projections/internal.js.map +1 -1
  360. package/dist/projections/run-dispatch.d.ts.map +1 -1
  361. package/dist/queues/in-memory.d.ts +3 -2
  362. package/dist/queues/in-memory.d.ts.map +1 -1
  363. package/dist/queues/index.d.ts +3 -1
  364. package/dist/queues/index.d.ts.map +1 -1
  365. package/dist/queues/index.js +1 -1
  366. package/dist/queues/types.d.ts +15 -3
  367. package/dist/queues/types.d.ts.map +1 -1
  368. package/dist/rules/execution.d.ts.map +1 -1
  369. package/dist/runtime/create.d.ts +7 -4
  370. package/dist/runtime/create.d.ts.map +1 -1
  371. package/dist/runtime/definitions.d.ts +4 -2
  372. package/dist/runtime/definitions.d.ts.map +1 -1
  373. package/dist/runtime/host.d.ts +5 -2
  374. package/dist/runtime/host.d.ts.map +1 -1
  375. package/dist/runtime/internal.d.ts +1 -0
  376. package/dist/runtime/internal.d.ts.map +1 -1
  377. package/dist/runtime/resolve-definitions.d.ts +4 -2
  378. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  379. package/dist/runtime/sixb.d.ts +8 -2
  380. package/dist/runtime/sixb.d.ts.map +1 -1
  381. package/dist/runtime/types.d.ts +3 -0
  382. package/dist/runtime/types.d.ts.map +1 -1
  383. package/dist/schedules/execution.d.ts +2 -1
  384. package/dist/schedules/execution.d.ts.map +1 -1
  385. package/dist/security/every.d.ts +4 -4
  386. package/dist/security/every.d.ts.map +1 -1
  387. package/dist/security/grants.d.ts +12 -6
  388. package/dist/security/grants.d.ts.map +1 -1
  389. package/dist/security/index.d.ts +1 -1
  390. package/dist/security/index.d.ts.map +1 -1
  391. package/dist/security/registry.d.ts +2 -1
  392. package/dist/security/registry.d.ts.map +1 -1
  393. package/dist/security/types.d.ts +19 -5
  394. package/dist/security/types.d.ts.map +1 -1
  395. package/dist/security/validation.d.ts +6 -2
  396. package/dist/security/validation.d.ts.map +1 -1
  397. package/dist/shares/access-plan.d.ts +22 -0
  398. package/dist/shares/access-plan.d.ts.map +1 -0
  399. package/dist/shares/builders.d.ts +14 -0
  400. package/dist/shares/builders.d.ts.map +1 -0
  401. package/dist/shares/compiler.d.ts +14 -0
  402. package/dist/shares/compiler.d.ts.map +1 -0
  403. package/dist/shares/errors.d.ts +4 -0
  404. package/dist/shares/errors.d.ts.map +1 -0
  405. package/dist/shares/execution.d.ts +57 -0
  406. package/dist/shares/execution.d.ts.map +1 -0
  407. package/dist/shares/index.d.ts +10 -0
  408. package/dist/shares/index.d.ts.map +1 -0
  409. package/dist/shares/internal.d.ts +3 -0
  410. package/dist/shares/internal.d.ts.map +1 -0
  411. package/dist/shares/internal.js +239 -0
  412. package/dist/shares/internal.js.map +10 -0
  413. package/dist/shares/intersection.d.ts +9 -0
  414. package/dist/shares/intersection.d.ts.map +1 -0
  415. package/dist/shares/session-protocol.d.ts +41 -0
  416. package/dist/shares/session-protocol.d.ts.map +1 -0
  417. package/dist/shares/types.d.ts +51 -0
  418. package/dist/shares/types.d.ts.map +1 -0
  419. package/dist/shares/validation.d.ts +11 -0
  420. package/dist/shares/validation.d.ts.map +1 -0
  421. package/dist/storage/action-runs/failure.js +3 -3
  422. package/dist/storage/action-runs/provider.js +2 -2
  423. package/dist/storage/agents/errors.d.ts +1 -1
  424. package/dist/storage/agents/errors.d.ts.map +1 -1
  425. package/dist/storage/agents/in-memory.d.ts +3 -2
  426. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  427. package/dist/storage/agents/index.d.ts +1 -1
  428. package/dist/storage/agents/index.d.ts.map +1 -1
  429. package/dist/storage/agents/provider.d.ts +11 -4
  430. package/dist/storage/agents/provider.d.ts.map +1 -1
  431. package/dist/storage/agents/provider.js +18 -15
  432. package/dist/storage/agents/provider.js.map +1 -1
  433. package/dist/storage/agents/types.d.ts +65 -17
  434. package/dist/storage/agents/types.d.ts.map +1 -1
  435. package/dist/storage/ai-cost/analytics.d.ts +2 -1
  436. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  437. package/dist/storage/ai-cost/codec.d.ts +3 -2
  438. package/dist/storage/ai-cost/codec.d.ts.map +1 -1
  439. package/dist/storage/ai-cost/groups.d.ts +51 -0
  440. package/dist/storage/ai-cost/groups.d.ts.map +1 -0
  441. package/dist/storage/ai-cost/in-memory.d.ts +11 -1
  442. package/dist/storage/ai-cost/in-memory.d.ts.map +1 -1
  443. package/dist/storage/ai-cost/index.d.ts +1 -1
  444. package/dist/storage/ai-cost/index.d.ts.map +1 -1
  445. package/dist/storage/ai-cost/provider.d.ts +2 -0
  446. package/dist/storage/ai-cost/provider.d.ts.map +1 -1
  447. package/dist/storage/ai-cost/provider.js +29 -13
  448. package/dist/storage/ai-cost/provider.js.map +3 -3
  449. package/dist/storage/ai-cost/types.d.ts +64 -15
  450. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  451. package/dist/storage/ai-cost/validation.d.ts +2 -1
  452. package/dist/storage/ai-cost/validation.d.ts.map +1 -1
  453. package/dist/storage/ai-limits/enforcement.d.ts +14 -0
  454. package/dist/storage/ai-limits/enforcement.d.ts.map +1 -0
  455. package/dist/storage/ai-limits/enforcement.js +21 -0
  456. package/dist/storage/ai-limits/enforcement.js.map +9 -0
  457. package/dist/storage/ai-limits/errors.d.ts +8 -0
  458. package/dist/storage/ai-limits/errors.d.ts.map +1 -0
  459. package/dist/storage/ai-limits/in-memory.d.ts +78 -0
  460. package/dist/storage/ai-limits/in-memory.d.ts.map +1 -0
  461. package/dist/storage/ai-limits/index.d.ts +7 -0
  462. package/dist/storage/ai-limits/index.d.ts.map +1 -0
  463. package/dist/storage/ai-limits/period.d.ts +4 -0
  464. package/dist/storage/ai-limits/period.d.ts.map +1 -0
  465. package/dist/storage/ai-limits/provider.d.ts +85 -0
  466. package/dist/storage/ai-limits/provider.d.ts.map +1 -0
  467. package/dist/storage/ai-limits/provider.js +62 -0
  468. package/dist/storage/ai-limits/provider.js.map +9 -0
  469. package/dist/storage/ai-limits/types.d.ts +175 -0
  470. package/dist/storage/ai-limits/types.d.ts.map +1 -0
  471. package/dist/storage/ai-usage/in-memory.d.ts +4 -0
  472. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  473. package/dist/storage/ai-usage/record.d.ts.map +1 -1
  474. package/dist/storage/ai-usage/types.d.ts +6 -2
  475. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  476. package/dist/storage/auth/errors.d.ts +1 -1
  477. package/dist/storage/auth/errors.d.ts.map +1 -1
  478. package/dist/storage/auth/in-memory/auth-storage.d.ts +4 -1
  479. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  480. package/dist/storage/auth/in-memory/device-authorizations.d.ts +29 -0
  481. package/dist/storage/auth/in-memory/device-authorizations.d.ts.map +1 -0
  482. package/dist/storage/auth/in-memory/shared.d.ts +3 -1
  483. package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
  484. package/dist/storage/auth/index.d.ts +2 -1
  485. package/dist/storage/auth/index.d.ts.map +1 -1
  486. package/dist/storage/auth/types.d.ts +66 -0
  487. package/dist/storage/auth/types.d.ts.map +1 -1
  488. package/dist/storage/connector-connections/provider.js +2 -2
  489. package/dist/storage/executions/in-memory.d.ts +3 -0
  490. package/dist/storage/executions/in-memory.d.ts.map +1 -1
  491. package/dist/storage/executions/provider.d.ts +4 -1
  492. package/dist/storage/executions/provider.d.ts.map +1 -1
  493. package/dist/storage/executions/provider.js +23 -3
  494. package/dist/storage/executions/provider.js.map +3 -3
  495. package/dist/storage/executions/run-link.d.ts +14 -2
  496. package/dist/storage/executions/run-link.d.ts.map +1 -1
  497. package/dist/storage/executions/validation.d.ts +6 -0
  498. package/dist/storage/executions/validation.d.ts.map +1 -1
  499. package/dist/storage/in-memory/index.d.ts +12 -0
  500. package/dist/storage/in-memory/index.d.ts.map +1 -1
  501. package/dist/storage/index.d.ts +15 -6
  502. package/dist/storage/index.d.ts.map +1 -1
  503. package/dist/storage/index.js +78 -36
  504. package/dist/storage/index.js.map +1 -1
  505. package/dist/storage/objects/execution-limits.d.ts +25 -0
  506. package/dist/storage/objects/execution-limits.d.ts.map +1 -0
  507. package/dist/storage/objects/guard.d.ts +16 -0
  508. package/dist/storage/objects/guard.d.ts.map +1 -0
  509. package/dist/storage/objects/in-memory/index.d.ts +3 -0
  510. package/dist/storage/objects/in-memory/index.d.ts.map +1 -0
  511. package/dist/storage/objects/in-memory/keys.d.ts +10 -0
  512. package/dist/storage/objects/in-memory/keys.d.ts.map +1 -0
  513. package/dist/storage/objects/in-memory/query.d.ts +31 -0
  514. package/dist/storage/objects/in-memory/query.d.ts.map +1 -0
  515. package/dist/storage/objects/in-memory/read-scope.d.ts +18 -0
  516. package/dist/storage/objects/in-memory/read-scope.d.ts.map +1 -0
  517. package/dist/storage/objects/in-memory/read-source.d.ts +10 -0
  518. package/dist/storage/objects/in-memory/read-source.d.ts.map +1 -0
  519. package/dist/storage/objects/in-memory/selected-reader.d.ts +9 -0
  520. package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -0
  521. package/dist/storage/objects/{in-memory.d.ts → in-memory/storage.d.ts} +13 -10
  522. package/dist/storage/objects/in-memory/storage.d.ts.map +1 -0
  523. package/dist/storage/objects/index.d.ts +4 -1
  524. package/dist/storage/objects/index.d.ts.map +1 -1
  525. package/dist/storage/objects/keys.d.ts +1 -1
  526. package/dist/storage/objects/keys.d.ts.map +1 -1
  527. package/dist/storage/objects/read-scope.d.ts +25 -0
  528. package/dist/storage/objects/read-scope.d.ts.map +1 -0
  529. package/dist/storage/objects/types.d.ts +114 -22
  530. package/dist/storage/objects/types.d.ts.map +1 -1
  531. package/dist/storage/ontology/provider.js +3 -3
  532. package/dist/storage/operation-scope.d.ts +3 -0
  533. package/dist/storage/operation-scope.d.ts.map +1 -1
  534. package/dist/storage/operation-scope.js +4 -2
  535. package/dist/storage/operation-scope.js.map +1 -1
  536. package/dist/storage/pipeline-runs/provider.js +2 -2
  537. package/dist/storage/projection-runs/provider.js +4 -4
  538. package/dist/storage/share-grants/errors.d.ts +8 -0
  539. package/dist/storage/share-grants/errors.d.ts.map +1 -0
  540. package/dist/storage/share-grants/in-memory.d.ts +11 -0
  541. package/dist/storage/share-grants/in-memory.d.ts.map +1 -0
  542. package/dist/storage/share-grants/index.d.ts +5 -0
  543. package/dist/storage/share-grants/index.d.ts.map +1 -0
  544. package/dist/storage/share-grants/provider.d.ts +4 -0
  545. package/dist/storage/share-grants/provider.d.ts.map +1 -0
  546. package/dist/storage/share-grants/provider.js +24 -0
  547. package/dist/storage/share-grants/provider.js.map +9 -0
  548. package/dist/storage/share-grants/record.d.ts +11 -0
  549. package/dist/storage/share-grants/record.d.ts.map +1 -0
  550. package/dist/storage/share-grants/types.d.ts +97 -0
  551. package/dist/storage/share-grants/types.d.ts.map +1 -0
  552. package/dist/storage/share-sessions/errors.d.ts +8 -0
  553. package/dist/storage/share-sessions/errors.d.ts.map +1 -0
  554. package/dist/storage/share-sessions/in-memory.d.ts +14 -0
  555. package/dist/storage/share-sessions/in-memory.d.ts.map +1 -0
  556. package/dist/storage/share-sessions/index.d.ts +5 -0
  557. package/dist/storage/share-sessions/index.d.ts.map +1 -0
  558. package/dist/storage/share-sessions/provider.d.ts +3 -0
  559. package/dist/storage/share-sessions/provider.d.ts.map +1 -0
  560. package/dist/storage/share-sessions/provider.js +20 -0
  561. package/dist/storage/share-sessions/provider.js.map +9 -0
  562. package/dist/storage/share-sessions/record.d.ts +8 -0
  563. package/dist/storage/share-sessions/record.d.ts.map +1 -0
  564. package/dist/storage/share-sessions/types.d.ts +50 -0
  565. package/dist/storage/share-sessions/types.d.ts.map +1 -0
  566. package/dist/storage/sync-runs/provider.js +2 -2
  567. package/dist/storage/transaction.d.ts +2 -1
  568. package/dist/storage/transaction.d.ts.map +1 -1
  569. package/dist/storage/types.d.ts +13 -1
  570. package/dist/storage/types.d.ts.map +1 -1
  571. package/dist/storage/webhook-runs/provider.js +2 -2
  572. package/dist/storage/workflow-runs/provider.d.ts +1 -1
  573. package/dist/storage/workflow-runs/provider.js +14 -12
  574. package/dist/storage/workflow-runs/provider.js.map +1 -1
  575. package/dist/storage/workflow-runs/types.d.ts +5 -4
  576. package/dist/storage/workflow-runs/types.d.ts.map +1 -1
  577. package/dist/syncs/execution.d.ts.map +1 -1
  578. package/dist/syncs/index.js +41 -36
  579. package/dist/syncs/index.js.map +1 -1
  580. package/dist/syncs/request.d.ts.map +1 -1
  581. package/dist/testing/agent-execution.d.ts +3 -1
  582. package/dist/testing/agent-execution.d.ts.map +1 -1
  583. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  584. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  585. package/dist/testing/ai-limit-storage-contract.d.ts +18 -0
  586. package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -0
  587. package/dist/testing/ai-model-call-groups-contract.d.ts +6 -0
  588. package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -0
  589. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  590. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  591. package/dist/testing/dataset-sequence-contract.d.ts +4 -0
  592. package/dist/testing/dataset-sequence-contract.d.ts.map +1 -0
  593. package/dist/testing/effective-storage-contract.d.ts.map +1 -1
  594. package/dist/testing/execution-storage-contract.d.ts +4 -0
  595. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  596. package/dist/testing/index.d.ts +5 -0
  597. package/dist/testing/index.d.ts.map +1 -1
  598. package/dist/testing/index.js +5392 -2070
  599. package/dist/testing/index.js.map +21 -15
  600. package/dist/testing/lake-merge-storage-contract.d.ts +1 -0
  601. package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -1
  602. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  603. package/dist/testing/object-read-scope-contract.d.ts +22 -0
  604. package/dist/testing/object-read-scope-contract.d.ts.map +1 -0
  605. package/dist/testing/queues-contract.d.ts.map +1 -1
  606. package/dist/testing/share-grant-storage-contract.d.ts +10 -0
  607. package/dist/testing/share-grant-storage-contract.d.ts.map +1 -0
  608. package/dist/testing/share-session-storage-contract.d.ts +9 -0
  609. package/dist/testing/share-session-storage-contract.d.ts.map +1 -0
  610. package/dist/webhooks/internal.js +36 -29
  611. package/dist/webhooks/internal.js.map +2 -2
  612. package/dist/workers/index.js +2 -2
  613. package/dist/workflows/agent-step-identity.d.ts +3 -0
  614. package/dist/workflows/agent-step-identity.d.ts.map +1 -0
  615. package/dist/workflows/builders.d.ts +2 -3
  616. package/dist/workflows/builders.d.ts.map +1 -1
  617. package/dist/workflows/execution.d.ts +1 -1
  618. package/dist/workflows/execution.d.ts.map +1 -1
  619. package/dist/workflows/failure.d.ts +1 -1
  620. package/dist/workflows/failure.d.ts.map +1 -1
  621. package/dist/workflows/index.d.ts +3 -2
  622. package/dist/workflows/index.d.ts.map +1 -1
  623. package/dist/workflows/index.js +63 -48
  624. package/dist/workflows/index.js.map +1 -1
  625. package/dist/workflows/request.d.ts.map +1 -1
  626. package/dist/workflows/types.d.ts +26 -11
  627. package/dist/workflows/types.d.ts.map +1 -1
  628. package/dist/workflows/validation.d.ts +7 -1
  629. package/dist/workflows/validation.d.ts.map +1 -1
  630. package/package.json +43 -4
  631. package/src/actions/delegated-admission.ts +72 -0
  632. package/src/actions/descriptor.ts +58 -0
  633. package/src/actions/execution.ts +99 -24
  634. package/src/actions/request.ts +136 -19
  635. package/src/actions/run-authorization.ts +53 -0
  636. package/src/actions/run-dispatch.ts +8 -1
  637. package/src/agents/adapters.ts +60 -456
  638. package/src/agents/authority.ts +215 -34
  639. package/src/agents/builders.ts +3 -50
  640. package/src/agents/context-compaction.ts +4 -0
  641. package/src/agents/context-resolution.ts +1 -4
  642. package/src/agents/dispatch.ts +59 -2
  643. package/src/agents/errors.ts +4 -11
  644. package/src/agents/execution.ts +65 -56
  645. package/src/agents/identity.ts +4 -0
  646. package/src/agents/ids.ts +16 -1
  647. package/src/agents/index.ts +23 -30
  648. package/src/agents/message.ts +20 -12
  649. package/src/agents/model-loop.ts +1071 -0
  650. package/src/agents/reference.ts +7 -0
  651. package/src/agents/request.ts +157 -77
  652. package/src/agents/retired-config.ts +20 -0
  653. package/src/agents/streams.ts +45 -19
  654. package/src/agents/tool-catalog.ts +21 -0
  655. package/src/agents/tool-definition.ts +9 -5
  656. package/src/agents/types.ts +39 -81
  657. package/src/agents/validation.ts +11 -216
  658. package/src/ai-usage/execution.ts +189 -0
  659. package/src/ai-usage/index.ts +15 -0
  660. package/src/authorization/decision.ts +54 -22
  661. package/src/authorization/grant-kinds.ts +72 -15
  662. package/src/authorization/index.ts +2 -0
  663. package/src/authorization/resolve.ts +12 -5
  664. package/src/authorization/types.ts +7 -5
  665. package/src/bootstrap/discovery.ts +3 -3
  666. package/src/bootstrap/ontology-type-manifest.ts +12 -6
  667. package/src/datasets/builders.ts +23 -2
  668. package/src/datasets/changes.ts +16 -4
  669. package/src/datasets/execution.ts +76 -5
  670. package/src/datasets/index.ts +1 -0
  671. package/src/datasets/sequence.ts +77 -0
  672. package/src/datasets/types.ts +1 -0
  673. package/src/datasets/validation.ts +26 -0
  674. package/src/datasets/write.ts +240 -0
  675. package/src/error-reporting/types.ts +4 -2
  676. package/src/errors/catalog.ts +8 -0
  677. package/src/events/execution.ts +57 -7
  678. package/src/events/types/datasets.ts +2 -6
  679. package/src/execution/agent.ts +129 -25
  680. package/src/execution/authorization.ts +493 -83
  681. package/src/execution/authorized-object-reader.ts +695 -0
  682. package/src/execution/durable.ts +10 -2
  683. package/src/execution/index.ts +1 -0
  684. package/src/execution/request.ts +67 -14
  685. package/src/execution/scopes.ts +36 -6
  686. package/src/execution/types.ts +9 -1
  687. package/src/http/api-routes.ts +108 -0
  688. package/src/index.ts +72 -22
  689. package/src/json.ts +9 -0
  690. package/src/lake-storage/definition-updates.ts +9 -0
  691. package/src/lake-storage/errors.ts +6 -1
  692. package/src/lake-storage/in-memory.ts +53 -17
  693. package/src/lake-storage/index.ts +10 -1
  694. package/src/lake-storage/merge-validation.ts +12 -2
  695. package/src/lake-storage/merge.ts +40 -2
  696. package/src/lake-storage/source-ordering.ts +95 -0
  697. package/src/lake-storage/sql-transforms.ts +2 -1
  698. package/src/lake-storage/types.ts +10 -5
  699. package/src/lake-storage/version-inputs.ts +14 -0
  700. package/src/models/catalog.ts +137 -0
  701. package/src/models/definitions.ts +202 -0
  702. package/src/models/errors.ts +83 -0
  703. package/src/models/events.ts +198 -0
  704. package/src/models/index.ts +89 -71
  705. package/src/models/language-model.ts +143 -0
  706. package/src/models/messages.ts +78 -0
  707. package/src/models/pricing.ts +390 -0
  708. package/src/models/rate-card.ts +101 -0
  709. package/src/models/tools.ts +29 -0
  710. package/src/objects/authorized-ontology-view.ts +512 -0
  711. package/src/objects/execution.ts +98 -143
  712. package/src/objects/link/authorization.ts +3 -2
  713. package/src/objects/query/executor.ts +45 -34
  714. package/src/objects/query/links.ts +84 -25
  715. package/src/objects/query/selected-read-admission.ts +310 -0
  716. package/src/objects/query/validate.ts +353 -36
  717. package/src/objects/sdk/object-handle.ts +2 -8
  718. package/src/objects/sdk/object-set.ts +10 -11
  719. package/src/objects/sdk/runtime-query-executor.ts +8 -28
  720. package/src/objects/sdk/telemetry-channel.ts +11 -7
  721. package/src/objects/service/list-service.ts +15 -29
  722. package/src/objects/telemetry/history.ts +297 -17
  723. package/src/objects/telemetry/index.ts +2 -2
  724. package/src/objects/telemetry/workload.ts +79 -0
  725. package/src/ontology/index.ts +7 -1
  726. package/src/ontology/inference/index.ts +4 -1
  727. package/src/ontology/internal.ts +0 -1
  728. package/src/ontology/json-schema.ts +13 -12
  729. package/src/ontology/link-path-selection.ts +193 -0
  730. package/src/ontology/refs.ts +19 -0
  731. package/src/ontology/tokens.ts +15 -8
  732. package/src/pipelines/execution.ts +30 -7
  733. package/src/pipelines/request.ts +5 -0
  734. package/src/projections/execution.ts +72 -11
  735. package/src/projections/run-dispatch.ts +6 -12
  736. package/src/queues/in-memory.ts +5 -0
  737. package/src/queues/index.ts +11 -0
  738. package/src/queues/types.ts +20 -3
  739. package/src/rules/execution.ts +20 -8
  740. package/src/runtime/create.ts +11 -5
  741. package/src/runtime/definitions.ts +4 -2
  742. package/src/runtime/host.ts +28 -8
  743. package/src/runtime/internal.ts +1 -0
  744. package/src/runtime/resolve-definitions.ts +22 -36
  745. package/src/runtime/sixb.ts +29 -10
  746. package/src/runtime/types.ts +3 -0
  747. package/src/schedules/execution.ts +24 -2
  748. package/src/security/every.ts +4 -4
  749. package/src/security/grants.ts +100 -14
  750. package/src/security/index.ts +3 -0
  751. package/src/security/registry.ts +9 -5
  752. package/src/security/types.ts +23 -4
  753. package/src/security/validation.ts +33 -9
  754. package/src/shares/access-plan.ts +225 -0
  755. package/src/shares/builders.ts +381 -0
  756. package/src/shares/compiler.ts +359 -0
  757. package/src/shares/errors.ts +3 -0
  758. package/src/shares/execution.ts +394 -0
  759. package/src/shares/index.ts +28 -0
  760. package/src/shares/internal.ts +9 -0
  761. package/src/shares/intersection.ts +178 -0
  762. package/src/shares/session-protocol.ts +258 -0
  763. package/src/shares/types.ts +76 -0
  764. package/src/shares/validation.ts +40 -0
  765. package/src/storage/agents/errors.ts +1 -0
  766. package/src/storage/agents/in-memory.ts +121 -11
  767. package/src/storage/agents/index.ts +7 -0
  768. package/src/storage/agents/provider.ts +150 -6
  769. package/src/storage/agents/types.ts +73 -16
  770. package/src/storage/ai-cost/analytics.ts +63 -6
  771. package/src/storage/ai-cost/codec.ts +37 -12
  772. package/src/storage/ai-cost/groups.ts +248 -0
  773. package/src/storage/ai-cost/in-memory.ts +42 -0
  774. package/src/storage/ai-cost/index.ts +6 -0
  775. package/src/storage/ai-cost/provider.ts +7 -0
  776. package/src/storage/ai-cost/types.ts +76 -14
  777. package/src/storage/ai-cost/validation.ts +147 -17
  778. package/src/storage/ai-limits/enforcement.ts +68 -0
  779. package/src/storage/ai-limits/errors.ts +23 -0
  780. package/src/storage/ai-limits/in-memory.ts +671 -0
  781. package/src/storage/ai-limits/index.ts +31 -0
  782. package/src/storage/ai-limits/period.ts +11 -0
  783. package/src/storage/ai-limits/provider.ts +430 -0
  784. package/src/storage/ai-limits/types.ts +195 -0
  785. package/src/storage/ai-usage/in-memory.ts +13 -0
  786. package/src/storage/ai-usage/record.ts +17 -0
  787. package/src/storage/ai-usage/types.ts +6 -2
  788. package/src/storage/auth/errors.ts +6 -0
  789. package/src/storage/auth/in-memory/auth-storage.ts +69 -0
  790. package/src/storage/auth/in-memory/device-authorizations.ts +145 -0
  791. package/src/storage/auth/in-memory/shared.ts +7 -0
  792. package/src/storage/auth/index.ts +7 -0
  793. package/src/storage/auth/types.ts +73 -0
  794. package/src/storage/executions/in-memory.ts +9 -1
  795. package/src/storage/executions/provider.ts +30 -1
  796. package/src/storage/executions/run-link.ts +45 -6
  797. package/src/storage/executions/validation.ts +82 -7
  798. package/src/storage/in-memory/index.ts +69 -6
  799. package/src/storage/index.ts +102 -1
  800. package/src/storage/objects/execution-limits.ts +283 -0
  801. package/src/storage/objects/guard.ts +55 -0
  802. package/src/storage/objects/in-memory/index.ts +2 -0
  803. package/src/storage/objects/in-memory/keys.ts +46 -0
  804. package/src/storage/objects/in-memory/query.ts +754 -0
  805. package/src/storage/objects/in-memory/read-scope.ts +211 -0
  806. package/src/storage/objects/in-memory/read-source.ts +10 -0
  807. package/src/storage/objects/in-memory/selected-reader.ts +252 -0
  808. package/src/storage/objects/in-memory/storage.ts +589 -0
  809. package/src/storage/objects/index.ts +21 -0
  810. package/src/storage/objects/keys.ts +1 -1
  811. package/src/storage/objects/read-scope.ts +672 -0
  812. package/src/storage/objects/types.ts +123 -19
  813. package/src/storage/operation-scope.ts +16 -0
  814. package/src/storage/share-grants/errors.ts +14 -0
  815. package/src/storage/share-grants/in-memory.ts +107 -0
  816. package/src/storage/share-grants/index.ts +14 -0
  817. package/src/storage/share-grants/provider.ts +11 -0
  818. package/src/storage/share-grants/record.ts +347 -0
  819. package/src/storage/share-grants/types.ts +112 -0
  820. package/src/storage/share-sessions/errors.ts +14 -0
  821. package/src/storage/share-sessions/in-memory.ts +105 -0
  822. package/src/storage/share-sessions/index.ts +11 -0
  823. package/src/storage/share-sessions/provider.ts +9 -0
  824. package/src/storage/share-sessions/record.ts +176 -0
  825. package/src/storage/share-sessions/types.ts +57 -0
  826. package/src/storage/transaction.ts +14 -2
  827. package/src/storage/types.ts +64 -0
  828. package/src/storage/workflow-runs/in-memory.ts +3 -3
  829. package/src/storage/workflow-runs/provider.ts +2 -2
  830. package/src/storage/workflow-runs/types.ts +6 -3
  831. package/src/syncs/execution.ts +25 -5
  832. package/src/syncs/request.ts +5 -0
  833. package/src/testing/agent-execution.ts +40 -28
  834. package/src/testing/agent-storage-contract.ts +249 -28
  835. package/src/testing/ai-cost-storage-contract.ts +96 -8
  836. package/src/testing/ai-limit-storage-contract.ts +1134 -0
  837. package/src/testing/ai-model-call-groups-contract.ts +353 -0
  838. package/src/testing/ai-usage-storage-contract.ts +31 -0
  839. package/src/testing/auth-storage-contract.ts +85 -0
  840. package/src/testing/dataset-sequence-contract.ts +373 -0
  841. package/src/testing/effective-storage-contract.ts +34 -0
  842. package/src/testing/execution-storage-contract.ts +81 -2
  843. package/src/testing/index.ts +26 -0
  844. package/src/testing/lake-merge-storage-contract.ts +3 -0
  845. package/src/testing/lake-storage-contract.ts +58 -0
  846. package/src/testing/object-read-scope-contract.ts +939 -0
  847. package/src/testing/queues-contract.ts +36 -1
  848. package/src/testing/share-grant-storage-contract.ts +325 -0
  849. package/src/testing/share-session-storage-contract.ts +235 -0
  850. package/src/workflows/agent-step-identity.ts +4 -0
  851. package/src/workflows/builders.ts +95 -9
  852. package/src/workflows/execution.ts +55 -16
  853. package/src/workflows/failure.ts +2 -2
  854. package/src/workflows/index.ts +3 -0
  855. package/src/workflows/request.ts +5 -0
  856. package/src/workflows/types.ts +23 -11
  857. package/src/workflows/validation.ts +100 -7
  858. package/dist/chunk-1e8m6yn3.js.map +0 -37
  859. package/dist/chunk-1g8negke.js.map +0 -11
  860. package/dist/chunk-4gz41why.js +0 -72
  861. package/dist/chunk-4gz41why.js.map +0 -11
  862. package/dist/chunk-5sxb1168.js.map +0 -34
  863. package/dist/chunk-6gjqgd3d.js.map +0 -11
  864. package/dist/chunk-819wnjz8.js.map +0 -12
  865. package/dist/chunk-a31h57d5.js.map +0 -13
  866. package/dist/chunk-a44d5zgd.js +0 -556
  867. package/dist/chunk-a44d5zgd.js.map +0 -16
  868. package/dist/chunk-ckxfnx7f.js.map +0 -13
  869. package/dist/chunk-dm72y8wt.js.map +0 -10
  870. package/dist/chunk-drjqm1aa.js.map +0 -15
  871. package/dist/chunk-dy311asx.js.map +0 -14
  872. package/dist/chunk-f6erf2vv.js.map +0 -10
  873. package/dist/chunk-f83ka50g.js.map +0 -23
  874. package/dist/chunk-fe5ev6mr.js +0 -55
  875. package/dist/chunk-fe5ev6mr.js.map +0 -11
  876. package/dist/chunk-h9kxd41f.js.map +0 -11
  877. package/dist/chunk-hceck7dq.js +0 -137
  878. package/dist/chunk-hceck7dq.js.map +0 -10
  879. package/dist/chunk-md8k0r54.js.map +0 -14
  880. package/dist/chunk-n4spznws.js.map +0 -11
  881. package/dist/chunk-nva1xkjz.js.map +0 -46
  882. package/dist/chunk-qewtks41.js.map +0 -11
  883. package/dist/chunk-t0jjkep3.js.map +0 -10
  884. package/dist/chunk-t624af60.js.map +0 -56
  885. package/dist/chunk-t8t39h7v.js.map +0 -10
  886. package/dist/chunk-t9xghkva.js +0 -28
  887. package/dist/chunk-t9xghkva.js.map +0 -10
  888. package/dist/chunk-x2yw73hy.js.map +0 -10
  889. package/dist/chunk-xc7hq65b.js.map +0 -10
  890. package/dist/storage/objects/in-memory.d.ts.map +0 -1
  891. package/src/storage/objects/in-memory.ts +0 -1241
  892. /package/dist/{chunk-zqysyfjt.js.map → chunk-08m3b6w8.js.map} +0 -0
  893. /package/dist/{chunk-z3zp0bj1.js.map → chunk-407j3msh.js.map} +0 -0
  894. /package/dist/{chunk-rhrbz7d4.js.map → chunk-4a849fr1.js.map} +0 -0
  895. /package/dist/{chunk-cy0n5dms.js.map → chunk-4jjp5k14.js.map} +0 -0
  896. /package/dist/{chunk-ezake7g1.js.map → chunk-5ntny1qx.js.map} +0 -0
  897. /package/dist/{chunk-72q2y8hn.js.map → chunk-8tsf6dmc.js.map} +0 -0
  898. /package/dist/{chunk-vybf6pkp.js.map → chunk-dbc80ad7.js.map} +0 -0
  899. /package/dist/{chunk-nkbfrt0c.js.map → chunk-f26bck4t.js.map} +0 -0
  900. /package/dist/{chunk-dsrkgtnh.js.map → chunk-jq43kdvk.js.map} +0 -0
  901. /package/dist/{chunk-wtmzkcht.js.map → chunk-k34z5rvh.js.map} +0 -0
  902. /package/dist/{chunk-htq0qh7z.js.map → chunk-ka3a2ft3.js.map} +0 -0
  903. /package/dist/{chunk-f2rt4vkh.js.map → chunk-n2w475r0.js.map} +0 -0
  904. /package/dist/{chunk-bhxaq2nn.js.map → chunk-qw9gvjv5.js.map} +0 -0
  905. /package/dist/{chunk-dysw7nsm.js.map → chunk-rv2hkwwa.js.map} +0 -0
  906. /package/dist/{chunk-ghteq96b.js.map → chunk-s5y30bc9.js.map} +0 -0
  907. /package/dist/{chunk-xkthy56g.js.map → chunk-w1tvjszy.js.map} +0 -0
  908. /package/dist/{chunk-8b55ygje.js.map → chunk-w3e09qqk.js.map} +0 -0
  909. /package/dist/{chunk-62c7t4jc.js.map → chunk-wdage1eb.js.map} +0 -0
@@ -1,13 +1,24 @@
1
1
  // @bun
2
+ import {
3
+ compileSelectedObjectReadScope
4
+ } from "./chunk-r8jrnexe.js";
2
5
  import {
3
6
  resolveSemanticType
4
- } from "./chunk-rnshztfq.js";
7
+ } from "./chunk-h0k55pc7.js";
5
8
  import {
6
9
  createSixbError
7
- } from "./chunk-0172wgm9.js";
10
+ } from "./chunk-2xns679x.js";
8
11
  import {
9
12
  compareStrings
10
- } from "./chunk-t8t39h7v.js";
13
+ } from "./chunk-n6jxh8sw.js";
14
+
15
+ // src/execution/authorization.ts
16
+ import { isDeepStrictEqual } from "util";
17
+
18
+ // src/agents/identity.ts
19
+ function agentServiceAccountId(actorId) {
20
+ return `svc_agent_${actorId}`;
21
+ }
11
22
 
12
23
  // src/authorization/grant-kinds.ts
13
24
  var GRANT_KINDS = {
@@ -42,6 +53,11 @@ var GRANT_KINDS = {
42
53
  subject: "action",
43
54
  fix: "Add it to 'actions/' or pass it to createSixb({ actions })."
44
55
  },
56
+ "share:share": {
57
+ universeKey: "shareIds",
58
+ subject: "share",
59
+ fix: "Add it to 'shares/' or pass it to createSixb({ shares })."
60
+ },
45
61
  "run:workflow": {
46
62
  universeKey: "workflowIds",
47
63
  subject: "workflow",
@@ -58,22 +74,33 @@ var GRANT_KINDS = {
58
74
  fix: "Add it to 'pipelines/' or pass it to createSixb({ pipelines })."
59
75
  },
60
76
  "run:agent": {
61
- universeKey: "agentIds",
77
+ singleton: true,
62
78
  subject: "agent",
63
- fix: "Add it to 'agents/' or pass it to createSixb({ agents })."
79
+ fix: "Configure models.language and use the exported agent reference in can.run(agent)."
64
80
  },
65
81
  "observe:logs": {
66
82
  universeKey: "observableIds",
67
83
  subject: "observability surface",
68
84
  fix: 'Use can.observe("logs").'
69
85
  },
86
+ "observe:aiUsage": {
87
+ universeKey: "observableIds",
88
+ subject: "observability surface",
89
+ fix: "Use can.observe(agent.usage)."
90
+ },
70
91
  "manage:connector": {
71
92
  universeKey: "connectorIds",
72
93
  subject: "connector",
73
94
  fix: "Add it to 'connectors/' or pass it to createSixb({ connectors })."
95
+ },
96
+ "manage:aiUsage": {
97
+ universeKey: "manageableIds",
98
+ subject: "management surface",
99
+ fix: "Use can.manage(agent.usage)."
74
100
  }
75
101
  };
76
102
  var GRANT_KIND_KEYS = Object.keys(GRANT_KINDS);
103
+ var TARGETED_GRANT_KIND_KEYS = GRANT_KIND_KEYS.filter((kind) => kind !== "run:agent");
77
104
  function grantKindOf(grant) {
78
105
  switch (grant.capability) {
79
106
  case "access":
@@ -86,20 +113,273 @@ function grantKindOf(grant) {
86
113
  return "append:telemetry";
87
114
  case "apply":
88
115
  return "apply:action";
116
+ case "share":
117
+ return "share:share";
89
118
  case "run":
90
119
  return `run:${grant.target}`;
91
120
  case "observe":
92
- return "observe:logs";
121
+ return `observe:${grant.target}`;
93
122
  case "manage":
94
- return "manage:connector";
123
+ return `manage:${grant.target}`;
95
124
  }
96
125
  }
97
126
  function emptyGrantSets() {
98
- const sets = {};
99
- for (const kind of GRANT_KIND_KEYS) {
100
- sets[kind] = new Set;
127
+ return {
128
+ "access:application": new Set,
129
+ "view:object": new Set,
130
+ "view:dataset": new Set,
131
+ "edit:object": new Set,
132
+ "append:telemetry": new Set,
133
+ "apply:action": new Set,
134
+ "share:share": new Set,
135
+ "run:workflow": new Set,
136
+ "run:sync": new Set,
137
+ "run:pipeline": new Set,
138
+ "run:agent": false,
139
+ "observe:logs": new Set,
140
+ "observe:aiUsage": new Set,
141
+ "manage:connector": new Set,
142
+ "manage:aiUsage": new Set
143
+ };
144
+ }
145
+
146
+ // src/storage/objects/execution-limits.ts
147
+ var MAX_OBJECT_READ_FACETS = 16;
148
+ var MAX_OUTPUT_JSON_DEPTH = 64;
149
+
150
+ class ObjectReadLimitExceededError extends Error {
151
+ metric;
152
+ limit;
153
+ name = "ObjectReadLimitExceededError";
154
+ code = "object_read_limit_exceeded";
155
+ constructor(metric, limit) {
156
+ super(`[Sixb] Object read exceeded its ${metric} limit (${limit}).`);
157
+ this.metric = metric;
158
+ this.limit = limit;
101
159
  }
102
- return sets;
160
+ }
161
+ function snapshotObjectReadExecutionLimits(limits) {
162
+ if (typeof limits !== "object" || limits === null) {
163
+ throw new Error("[Sixb] Object read execution limits must be provided.");
164
+ }
165
+ return Object.freeze({
166
+ maxTraversalFacts: positiveSafeInteger(limits.maxTraversalFacts, "maxTraversalFacts"),
167
+ maxOutputJsonBytes: positiveSafeInteger(limits.maxOutputJsonBytes, "maxOutputJsonBytes")
168
+ });
169
+ }
170
+ function assertObjectReadFacetCount(count) {
171
+ if (!Number.isSafeInteger(count) || count < 0 || count > MAX_OBJECT_READ_FACETS) {
172
+ throw new Error(`[Sixb] An object read supports between 0 and ${MAX_OBJECT_READ_FACETS} facets.`);
173
+ }
174
+ }
175
+ function assertObjectReadOutputWithinLimit(value, limits) {
176
+ const fail = () => {
177
+ throw new ObjectReadLimitExceededError("outputJsonBytes", limits.maxOutputJsonBytes);
178
+ };
179
+ const stack = [];
180
+ let bytes = 0;
181
+ const addBytes = (count) => {
182
+ bytes += count;
183
+ if (bytes > limits.maxOutputJsonBytes)
184
+ fail();
185
+ };
186
+ const addPrimitiveBytes = (primitive) => {
187
+ switch (typeof primitive) {
188
+ case "string":
189
+ addBytes(jsonStringUtf8Length(primitive));
190
+ break;
191
+ case "number":
192
+ addBytes(Number.isFinite(primitive) ? Object.is(primitive, -0) ? 1 : String(primitive).length : 4);
193
+ break;
194
+ case "boolean":
195
+ addBytes(primitive ? 4 : 5);
196
+ break;
197
+ }
198
+ };
199
+ try {
200
+ JSON.stringify(value, function(key, current) {
201
+ const parent = isObject(this) ? this : undefined;
202
+ let parentFrameIndex = -1;
203
+ if (parent) {
204
+ for (let index = stack.length - 1;index >= 0; index -= 1) {
205
+ if (stack[index]?.value === parent) {
206
+ parentFrameIndex = index;
207
+ break;
208
+ }
209
+ }
210
+ }
211
+ const isRoot = parentFrameIndex === -1;
212
+ if (isRoot) {
213
+ stack.length = 0;
214
+ } else {
215
+ stack.length = parentFrameIndex + 1;
216
+ }
217
+ const parentFrame = isRoot ? undefined : stack[parentFrameIndex];
218
+ const parentIsArray = Array.isArray(parent);
219
+ const unsupported = current === undefined || typeof current === "function" || typeof current === "symbol";
220
+ if (!isRoot) {
221
+ if (!parentIsArray && unsupported)
222
+ return current;
223
+ if (!parentFrame)
224
+ return fail();
225
+ if (parentFrame.serializedChildren > 0)
226
+ addBytes(1);
227
+ parentFrame.serializedChildren += 1;
228
+ if (!parentIsArray)
229
+ addBytes(jsonStringUtf8Length(key) + 1);
230
+ } else if (unsupported) {
231
+ return current;
232
+ }
233
+ if (parentIsArray && unsupported) {
234
+ addBytes(4);
235
+ return current;
236
+ }
237
+ if (isObject(current)) {
238
+ const special = inspectJsonSpecialObject(current);
239
+ switch (special.kind) {
240
+ case "primitive":
241
+ addPrimitiveBytes(special.value);
242
+ return special.value;
243
+ case "bigint":
244
+ throw new TypeError("BigInt is not JSON serializable");
245
+ case "raw":
246
+ addBytes(rawJsonUtf8Length(special.value));
247
+ return current;
248
+ case "ordinary":
249
+ break;
250
+ }
251
+ }
252
+ switch (typeof current) {
253
+ case "string":
254
+ addPrimitiveBytes(current);
255
+ break;
256
+ case "number":
257
+ addPrimitiveBytes(current);
258
+ break;
259
+ case "boolean":
260
+ addPrimitiveBytes(current);
261
+ break;
262
+ case "bigint":
263
+ throw new TypeError("BigInt is not JSON serializable");
264
+ case "object":
265
+ if (current === null) {
266
+ addBytes(4);
267
+ break;
268
+ }
269
+ if (stack.some((frame) => frame.value === current)) {
270
+ throw new TypeError("Cyclic object value");
271
+ }
272
+ if (stack.length + 1 > MAX_OUTPUT_JSON_DEPTH)
273
+ fail();
274
+ addBytes(2);
275
+ stack.push({ value: current, serializedChildren: 0 });
276
+ break;
277
+ }
278
+ return current;
279
+ });
280
+ } catch (error) {
281
+ if (error instanceof ObjectReadLimitExceededError)
282
+ throw error;
283
+ if (error instanceof RangeError || error instanceof TypeError)
284
+ fail();
285
+ throw error;
286
+ }
287
+ }
288
+ var jsonWithRawJson = JSON;
289
+ var isRawJson = jsonWithRawJson.isRawJSON?.bind(jsonWithRawJson);
290
+ var booleanValueOf = bindValueOf(Boolean.prototype.valueOf);
291
+ var numberValueOf = bindValueOf(Number.prototype.valueOf);
292
+ var stringValueOf = bindValueOf(String.prototype.valueOf);
293
+ var bigintValueOf = bindValueOf(BigInt.prototype.valueOf);
294
+ var toStringValue = String;
295
+ function inspectJsonSpecialObject(value) {
296
+ if (isRawJson?.(value)) {
297
+ const raw = value.rawJSON;
298
+ if (typeof raw !== "string")
299
+ return { kind: "ordinary" };
300
+ return { kind: "raw", value: raw };
301
+ }
302
+ const boolean = unbox(value, booleanValueOf);
303
+ if (boolean.matched)
304
+ return { kind: "primitive", value: boolean.value };
305
+ const number = unbox(value, numberValueOf);
306
+ if (number.matched)
307
+ return { kind: "primitive", value: +value };
308
+ const string = unbox(value, stringValueOf);
309
+ if (string.matched)
310
+ return { kind: "primitive", value: toStringValue(value) };
311
+ if (unbox(value, bigintValueOf).matched)
312
+ return { kind: "bigint" };
313
+ return { kind: "ordinary" };
314
+ }
315
+ function bindValueOf(unboxer) {
316
+ return Function.prototype.call.bind(unboxer);
317
+ }
318
+ function unbox(value, unboxer) {
319
+ try {
320
+ return { matched: true, value: unboxer(value) };
321
+ } catch {
322
+ return { matched: false };
323
+ }
324
+ }
325
+ function rawJsonUtf8Length(value) {
326
+ let bytes = 0;
327
+ for (let index = 0;index < value.length; index += 1) {
328
+ const code = value.charCodeAt(index);
329
+ if (code <= 127) {
330
+ bytes += 1;
331
+ } else if (code <= 2047) {
332
+ bytes += 2;
333
+ } else if (code >= 55296 && code <= 56319) {
334
+ const next = value.charCodeAt(index + 1);
335
+ if (next >= 56320 && next <= 57343) {
336
+ bytes += 4;
337
+ index += 1;
338
+ } else {
339
+ bytes += 3;
340
+ }
341
+ } else {
342
+ bytes += 3;
343
+ }
344
+ }
345
+ return bytes;
346
+ }
347
+ function jsonStringUtf8Length(value) {
348
+ let bytes = 2;
349
+ for (let index = 0;index < value.length; index += 1) {
350
+ const code = value.charCodeAt(index);
351
+ if (code === 34 || code === 92) {
352
+ bytes += 2;
353
+ } else if (code <= 31) {
354
+ bytes += code === 8 || code === 9 || code === 10 || code === 12 || code === 13 ? 2 : 6;
355
+ } else if (code <= 127) {
356
+ bytes += 1;
357
+ } else if (code <= 2047) {
358
+ bytes += 2;
359
+ } else if (code >= 55296 && code <= 56319) {
360
+ const next = value.charCodeAt(index + 1);
361
+ if (next >= 56320 && next <= 57343) {
362
+ bytes += 4;
363
+ index += 1;
364
+ } else {
365
+ bytes += 6;
366
+ }
367
+ } else if (code >= 56320 && code <= 57343) {
368
+ bytes += 6;
369
+ } else {
370
+ bytes += 3;
371
+ }
372
+ }
373
+ return bytes;
374
+ }
375
+ function isObject(value) {
376
+ return typeof value === "object" && value !== null;
377
+ }
378
+ function positiveSafeInteger(value, name) {
379
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
380
+ throw new Error(`[Sixb] ${name} must be a positive safe integer.`);
381
+ }
382
+ return value;
103
383
  }
104
384
 
105
385
  // src/execution/types.ts
@@ -124,24 +404,32 @@ function isRuntimeAuthorizationCapability(value) {
124
404
 
125
405
  // src/execution/authorization.ts
126
406
  var registeredAuthorizations = new WeakMap;
407
+ var MAX_DELEGATED_ACTION_APPLY_TARGETS = 4096;
408
+ var MAX_DELEGATED_ACTION_IDENTIFIER_CHARACTERS = 1e6;
127
409
  function createPrincipalRuntimeAuthorization(input) {
410
+ if (input.execution.executor.type !== "request") {
411
+ throw new Error("[Sixb] Principal runtime authorization requires a request execution.");
412
+ }
128
413
  return createRegisteredPrincipalAuthorization(input);
129
414
  }
130
415
  function createAgentRuntimeAuthorization(input) {
131
- if (input.context.principal.type !== "serviceAccount") {
132
- throw new Error("[Sixb] Agent execution authority must belong to a service account.");
133
- }
134
- assertNonEmpty(input.executionId, "Execution id");
135
- assertNonEmpty(input.agentId, "Agent id");
136
- assertNonEmpty(input.runId, "Agent run id");
137
- return createRegisteredPrincipalAuthorization(input, {
138
- type: "agent",
139
- executionId: input.executionId,
140
- agentId: input.agentId,
141
- runId: input.runId
416
+ if (input.execution.executor.type !== "agent") {
417
+ throw new Error("[Sixb] Agent runtime authorization requires an Agent execution.");
418
+ }
419
+ if (input.authority.type === "principal") {
420
+ return createRegisteredPrincipalAuthorization({
421
+ execution: input.execution,
422
+ context: input.authority.context,
423
+ ...input.authority.credential === undefined ? {} : { credential: input.authority.credential }
424
+ });
425
+ }
426
+ return register(input.execution, {
427
+ type: "unrestricted",
428
+ projectId: input.execution.projectId,
429
+ ref: Object.freeze({ type: "disabled" })
142
430
  });
143
431
  }
144
- function createRegisteredPrincipalAuthorization(input, executionBinding) {
432
+ function createRegisteredPrincipalAuthorization(input) {
145
433
  const context = snapshotAuthorizationContext(input.context);
146
434
  const credential = input.credential ? snapshotCredential(input.credential) : undefined;
147
435
  assertCredentialMatchesContext(context, credential);
@@ -150,22 +438,46 @@ function createRegisteredPrincipalAuthorization(input, executionBinding) {
150
438
  principal: context.principal,
151
439
  ...credential === undefined ? {} : { credential }
152
440
  });
153
- return register({
441
+ return register(input.execution, {
154
442
  type: "principal",
155
- projectId: input.projectId,
443
+ projectId: input.execution.projectId,
156
444
  context,
157
- ref,
158
- ...executionBinding === undefined ? {} : { executionBinding: Object.freeze({ ...executionBinding }) }
445
+ ref
446
+ });
447
+ }
448
+ function createDisabledRuntimeAuthorization(execution) {
449
+ return register(execution, {
450
+ type: "unrestricted",
451
+ projectId: execution.projectId,
452
+ ref: Object.freeze({ type: "disabled" })
159
453
  });
160
454
  }
161
- function createDisabledRuntimeAuthorization(projectId) {
162
- return register({ type: "unrestricted", projectId, ref: Object.freeze({ type: "disabled" }) });
455
+ function createDelegatedRuntimeAuthorization(input) {
456
+ const execution = input.execution;
457
+ const objectReadInput = input.objectRead;
458
+ const actionApplyInput = input.actionApply;
459
+ const delegationInput = input.delegation;
460
+ const delegation = delegationInput === undefined ? undefined : snapshotSharedDelegation(delegationInput);
461
+ if (execution.executor.type !== "request" || execution.requestedBy !== undefined) {
462
+ throw new Error("[Sixb] Delegated runtime authorization requires a request execution without a principal.");
463
+ }
464
+ const objectRead = Object.freeze({
465
+ scope: compileSelectedObjectReadScope(objectReadInput.selection),
466
+ limits: snapshotObjectReadExecutionLimits(objectReadInput.limits)
467
+ });
468
+ return register(execution, {
469
+ type: "delegated",
470
+ projectId: execution.projectId,
471
+ objectRead,
472
+ actionApply: snapshotDelegatedActionApply(actionApplyInput ?? []),
473
+ ...delegation === undefined ? {} : { delegation }
474
+ });
163
475
  }
164
476
  function createTrustedPrimitiveRuntimeAuthorization(input) {
165
477
  const primitive = snapshotTrustedPrimitive(input.primitive);
166
- return register({
478
+ return register(input.execution, {
167
479
  type: "unrestricted",
168
- projectId: input.projectId,
480
+ projectId: input.execution.projectId,
169
481
  ref: Object.freeze({ type: "trustedPrimitive", primitive })
170
482
  });
171
483
  }
@@ -173,15 +485,38 @@ function resolveRuntimeAuthorization(authorization) {
173
485
  if (!isRuntimeAuthorizationCapability(authorization)) {
174
486
  return { type: "denied" };
175
487
  }
176
- return registeredAuthorizations.get(authorization) ?? { type: "denied" };
488
+ return registeredAuthorizations.get(authorization)?.resolved ?? { type: "denied" };
489
+ }
490
+ function resolveRuntimeAuthorizationForProject(input) {
491
+ const resolved = resolveRuntimeAuthorization(input.runtimeAuthorization);
492
+ if (resolved.type === "denied" || typeof input.projectId !== "string" || resolved.projectId !== input.projectId) {
493
+ return { type: "denied" };
494
+ }
495
+ return resolved;
177
496
  }
178
497
  function getAuthorizationRef(authorization) {
179
498
  const resolved = resolveRuntimeAuthorization(authorization);
180
499
  if (resolved.type === "denied") {
181
500
  throw new Error("[Sixb] Runtime authorization is not a registered Core capability.");
182
501
  }
502
+ if (resolved.type === "delegated") {
503
+ if (resolved.delegation) {
504
+ return { type: "delegated", delegation: { ...resolved.delegation } };
505
+ }
506
+ throw new Error("[Sixb] Delegated runtime authorization cannot cross a durable execution boundary.");
507
+ }
183
508
  return cloneAuthorizationRef(resolved.ref);
184
509
  }
510
+ function snapshotSharedDelegation(input) {
511
+ const kind = input.kind;
512
+ const grantId = input.grantId;
513
+ const sessionId = input.sessionId;
514
+ if (kind !== "share")
515
+ throw new Error("[Sixb] Unknown delegated authority provenance.");
516
+ assertNonEmpty(grantId, "Share grant id");
517
+ assertNonEmpty(sessionId, "Share session id");
518
+ return Object.freeze({ kind, grantId, sessionId });
519
+ }
185
520
  function assertExecutionScopeProject(projectId, scope) {
186
521
  assertNonEmpty(projectId, "Project id");
187
522
  if (scope.execution.projectId !== projectId) {
@@ -207,42 +542,71 @@ function assertExecutionScopeProject(projectId, scope) {
207
542
  });
208
543
  }
209
544
  }
545
+ function captureExecutionScope(scope) {
546
+ const execution = scope.execution;
547
+ const authorization = scope.authorization;
548
+ return Object.freeze({ execution, authorization });
549
+ }
210
550
  function resolveExecutionScopeAuthorization(projectId, scope) {
211
- assertExecutionScopeProject(projectId, scope);
212
- const resolved = resolveRuntimeAuthorization(scope.authorization);
551
+ const capturedScope = captureExecutionScope(scope);
552
+ assertExecutionScopeProject(projectId, capturedScope);
553
+ const resolved = resolveRuntimeAuthorization(capturedScope.authorization);
213
554
  if (resolved.type === "denied") {
214
- throw createSixbError("internal.unexpected", "[Sixb] Execution scope carries unregistered runtime authorization.", { details: { executionId: scope.execution.id, projectId } });
555
+ throw createSixbError("internal.unexpected", "[Sixb] Execution scope carries unregistered runtime authorization.", { details: { executionId: capturedScope.execution.id, projectId } });
215
556
  }
216
- const { execution } = scope;
557
+ const registration = registeredAuthorizations.get(capturedScope.authorization);
558
+ if (!registration || !executionMatchesBinding(registration.execution, capturedScope.execution)) {
559
+ throw invalidExecutionAuthority(capturedScope.execution.id, "authority is bound to different execution provenance");
560
+ }
561
+ assertResolvedAuthorizationMatchesExecution(resolved, capturedScope.execution);
562
+ return resolved;
563
+ }
564
+ function assertResolvedAuthorizationMatchesExecution(resolved, execution) {
217
565
  switch (execution.executor.type) {
218
566
  case "request":
219
567
  if (execution.source.type !== "http" || execution.source.requestId !== execution.executor.requestId) {
220
568
  throw invalidExecutionAuthority(execution.id, "request source does not match its executor");
221
569
  }
222
- if (resolved.ref.type === "principal") {
223
- if (resolved.type !== "principal" || resolved.executionBinding !== undefined || !principalsEqual(execution.requestedBy, resolved.ref.principal)) {
570
+ if (resolved.type === "principal") {
571
+ if (!principalsEqual(execution.requestedBy, resolved.ref.principal)) {
224
572
  throw invalidExecutionAuthority(execution.id, "request authority does not match its requested-by principal");
225
573
  }
226
- return resolved;
574
+ return;
575
+ }
576
+ if (resolved.type === "unrestricted" && resolved.ref.type === "disabled" && execution.requestedBy === undefined) {
577
+ return;
227
578
  }
228
- if (resolved.ref.type === "disabled" && execution.requestedBy === undefined)
229
- return resolved;
230
- throw invalidExecutionAuthority(execution.id, "request execution requires principal or explicitly disabled authority");
579
+ if (resolved.type === "delegated" && execution.requestedBy === undefined)
580
+ return;
581
+ throw invalidExecutionAuthority(execution.id, "request execution requires principal, delegated, or explicitly disabled authority");
231
582
  case "primitive":
232
- if (resolved.ref.type !== "trustedPrimitive" || resolved.ref.primitive.kind !== execution.executor.kind || resolved.ref.primitive.id !== execution.executor.id || resolved.ref.primitive.runId !== execution.executor.runId) {
583
+ if (resolved.type !== "unrestricted" || resolved.ref.type !== "trustedPrimitive" || resolved.ref.primitive.kind !== execution.executor.kind || resolved.ref.primitive.id !== execution.executor.id || resolved.ref.primitive.runId !== execution.executor.runId) {
233
584
  throw invalidExecutionAuthority(execution.id, "trusted primitive authority does not match its executor");
234
585
  }
235
- return resolved;
586
+ return;
236
587
  case "agent":
237
- if (resolved.type !== "principal" || resolved.ref.type !== "principal" || resolved.ref.principal.type !== "serviceAccount" || resolved.ref.credential !== undefined || resolved.executionBinding?.type !== "agent" || resolved.executionBinding.executionId !== execution.id || resolved.executionBinding.agentId !== execution.executor.agentId || resolved.executionBinding.runId !== execution.executor.runId) {
238
- throw invalidExecutionAuthority(execution.id, "agent authority does not match its execution binding");
588
+ if (execution.source.type !== "execution") {
589
+ throw invalidExecutionAuthority(execution.id, "agent execution requires an execution source");
590
+ }
591
+ if (resolved.type === "principal" && resolved.ref.type === "principal") {
592
+ if (resolved.ref.principal.type === "serviceAccount") {
593
+ const actorId = execution.executor.actorId;
594
+ if (actorId === undefined || resolved.ref.principal.id !== agentServiceAccountId(actorId) || resolved.ref.credential !== undefined) {
595
+ throw invalidExecutionAuthority(execution.id, "agent authority must reference its managed service account");
596
+ }
597
+ } else if (resolved.ref.credential === undefined) {
598
+ throw invalidExecutionAuthority(execution.id, "inherited user agent authority requires a credential");
599
+ }
600
+ return;
239
601
  }
240
- return resolved;
602
+ if (resolved.type === "unrestricted" && resolved.ref.type === "disabled")
603
+ return;
604
+ throw invalidExecutionAuthority(execution.id, "agent authority must be principal or explicitly disabled");
241
605
  case "kernel":
242
- if (resolved.ref.type !== "kernel" || execution.requestedBy !== undefined || resolved.ref.operation.type !== execution.executor.operation.type || resolved.ref.operation.recoveryId !== execution.executor.operation.recoveryId) {
606
+ if (resolved.type !== "unrestricted" || resolved.ref.type !== "kernel" || execution.requestedBy !== undefined || resolved.ref.operation.type !== execution.executor.operation.type || resolved.ref.operation.recoveryId !== execution.executor.operation.recoveryId) {
243
607
  throw invalidExecutionAuthority(execution.id, "kernel authority does not match its executor");
244
608
  }
245
- return resolved;
609
+ return;
246
610
  }
247
611
  }
248
612
  function principalsEqual(left, right) {
@@ -251,19 +615,99 @@ function principalsEqual(left, right) {
251
615
  function invalidExecutionAuthority(executionId, reason) {
252
616
  return createSixbError("internal.unexpected", `[Sixb] Execution '${executionId}' is incompatible with its authority: ${reason}.`, { details: { executionId, reason } });
253
617
  }
254
- function register(input) {
618
+ function register(execution, input) {
255
619
  assertNonEmpty(input.projectId, "Authorization project id");
620
+ const executionBinding = snapshotExecutionContext(execution);
621
+ if (input.projectId !== executionBinding.projectId) {
622
+ throw new Error(`[Sixb] Runtime authorization belongs to project '${input.projectId}', not execution project '${executionBinding.projectId}'.`);
623
+ }
624
+ assertResolvedAuthorizationMatchesExecution(input, executionBinding);
256
625
  const authorization = createRuntimeAuthorizationCapability();
257
- registeredAuthorizations.set(authorization, Object.freeze(input));
626
+ registeredAuthorizations.set(authorization, Object.freeze({ resolved: Object.freeze(input), execution: executionBinding }));
258
627
  return authorization;
259
628
  }
629
+ function executionMatchesBinding(binding, execution) {
630
+ try {
631
+ return isDeepStrictEqual(binding, snapshotExecutionContext(execution));
632
+ } catch {
633
+ return false;
634
+ }
635
+ }
636
+ function snapshotExecutionContext(execution) {
637
+ assertNonEmpty(execution.id, "Execution id");
638
+ assertNonEmpty(execution.projectId, "Execution project id");
639
+ assertNonEmpty(execution.correlationId, "Execution correlation id");
640
+ return Object.freeze({
641
+ id: execution.id,
642
+ projectId: execution.projectId,
643
+ ...execution.requestedBy === undefined ? {} : { requestedBy: snapshotAuthorizablePrincipal(execution.requestedBy) },
644
+ executor: snapshotExecutionExecutor(execution.executor),
645
+ source: snapshotExecutionSource(execution.source),
646
+ correlationId: execution.correlationId
647
+ });
648
+ }
649
+ function snapshotExecutionExecutor(executor) {
650
+ switch (executor.type) {
651
+ case "request":
652
+ assertNonEmpty(executor.requestId, "Execution request id");
653
+ return Object.freeze({ type: "request", requestId: executor.requestId });
654
+ case "primitive": {
655
+ const primitive = snapshotTrustedPrimitive(executor);
656
+ return Object.freeze({ type: "primitive", ...primitive });
657
+ }
658
+ case "agent":
659
+ if (executor.actorId !== undefined)
660
+ assertNonEmpty(executor.actorId, "Execution Agent actor id");
661
+ assertNonEmpty(executor.runId, "Execution Agent run id");
662
+ return Object.freeze({
663
+ type: "agent",
664
+ ...executor.actorId === undefined ? {} : { actorId: executor.actorId },
665
+ runId: executor.runId
666
+ });
667
+ case "kernel":
668
+ return Object.freeze({
669
+ type: "kernel",
670
+ operation: snapshotKernelOperation(executor.operation)
671
+ });
672
+ }
673
+ throw new Error(`[Sixb] Unknown execution executor type '${String(executor.type)}'.`);
674
+ }
675
+ function snapshotExecutionSource(source) {
676
+ switch (source.type) {
677
+ case "http":
678
+ assertNonEmpty(source.requestId, "Execution source request id");
679
+ return Object.freeze({ type: "http", requestId: source.requestId });
680
+ case "webhook":
681
+ assertNonEmpty(source.deliveryId, "Execution source delivery id");
682
+ return Object.freeze({ type: "webhook", deliveryId: source.deliveryId });
683
+ case "schedule":
684
+ case "event":
685
+ assertNonEmpty(source.eventId, "Execution source event id");
686
+ return Object.freeze({ type: source.type, eventId: source.eventId });
687
+ case "datasetVersion":
688
+ assertNonEmpty(source.datasetId, "Execution source dataset id");
689
+ assertNonEmpty(source.versionId, "Execution source dataset version id");
690
+ return Object.freeze({
691
+ type: "datasetVersion",
692
+ datasetId: source.datasetId,
693
+ versionId: source.versionId
694
+ });
695
+ case "execution":
696
+ assertNonEmpty(source.executionId, "Execution source execution id");
697
+ return Object.freeze({ type: "execution", executionId: source.executionId });
698
+ }
699
+ throw new Error(`[Sixb] Unknown execution source type '${String(source.type)}'.`);
700
+ }
260
701
  function snapshotAuthorizationContext(context) {
261
702
  const principal = snapshotAuthorizablePrincipal(context.principal);
262
- const grants = emptyGrantSets();
263
- for (const kind of GRANT_KIND_KEYS) {
264
- grants[kind] = new Set(context.grants[kind]);
703
+ const grants = {};
704
+ for (const kind of TARGETED_GRANT_KIND_KEYS) {
705
+ grants[kind] = new ImmutableGrantSet(context.grants[kind]);
265
706
  }
266
- const frozenGrants = Object.freeze(grants);
707
+ const frozenGrants = Object.freeze({
708
+ ...grants,
709
+ "run:agent": context.grants["run:agent"]
710
+ });
267
711
  return Object.freeze({
268
712
  principal,
269
713
  ...context.sessionId === undefined ? {} : { sessionId: context.sessionId },
@@ -272,6 +716,51 @@ function snapshotAuthorizationContext(context) {
272
716
  grants: frozenGrants
273
717
  });
274
718
  }
719
+
720
+ class ImmutableGrantSet {
721
+ #values;
722
+ [Symbol.toStringTag] = "Set";
723
+ constructor(values) {
724
+ this.#values = new Set(values);
725
+ Object.freeze(this);
726
+ }
727
+ get size() {
728
+ return this.#values.size;
729
+ }
730
+ has(value) {
731
+ return this.#values.has(value);
732
+ }
733
+ entries() {
734
+ return this.#values.entries();
735
+ }
736
+ keys() {
737
+ return this.#values.keys();
738
+ }
739
+ values() {
740
+ return this.#values.values();
741
+ }
742
+ [Symbol.iterator]() {
743
+ return this.#values[Symbol.iterator]();
744
+ }
745
+ forEach(callback, thisArg) {
746
+ for (const value of this.#values) {
747
+ callback.call(thisArg, value, value, this);
748
+ }
749
+ }
750
+ add(_value) {
751
+ throw immutableGrantSetMutation();
752
+ }
753
+ delete(_value) {
754
+ throw immutableGrantSetMutation();
755
+ }
756
+ clear() {
757
+ throw immutableGrantSetMutation();
758
+ }
759
+ }
760
+ Object.freeze(ImmutableGrantSet.prototype);
761
+ function immutableGrantSetMutation() {
762
+ return new Error("[Sixb] Runtime authorization grants are immutable.");
763
+ }
275
764
  function snapshotAuthorizablePrincipal(principal) {
276
765
  if (principal.type !== "user" && principal.type !== "serviceAccount") {
277
766
  throw new Error(`[Sixb] Principal type '${principal.type}' cannot hold runtime authorization.`);
@@ -306,6 +795,56 @@ function snapshotTrustedPrimitive(primitive) {
306
795
  assertNonEmpty(primitive.runId, "Trusted primitive run id");
307
796
  return Object.freeze({ kind: primitive.kind, id: primitive.id, runId: primitive.runId });
308
797
  }
798
+ function snapshotKernelOperation(operation) {
799
+ if (operation.type !== "ontology.recover") {
800
+ throw new Error(`[Sixb] Unknown kernel operation '${operation.type}'.`);
801
+ }
802
+ assertNonEmpty(operation.recoveryId, "Kernel recovery id");
803
+ return Object.freeze({ type: operation.type, recoveryId: operation.recoveryId });
804
+ }
805
+ function snapshotDelegatedActionApply(input) {
806
+ if (!Array.isArray(input)) {
807
+ throw new Error("[Sixb] Delegated Action targets must be an array.");
808
+ }
809
+ const targetCount = input.length;
810
+ if (targetCount > MAX_DELEGATED_ACTION_APPLY_TARGETS) {
811
+ throw new Error(`[Sixb] Delegated authority exceeds the maximum of ${MAX_DELEGATED_ACTION_APPLY_TARGETS} Action targets.`);
812
+ }
813
+ let identifierCharacters = 0;
814
+ const targets = [];
815
+ for (let index = 0;index < targetCount; index += 1) {
816
+ const authoredTarget = input[index];
817
+ if (!isRecord(authoredTarget)) {
818
+ throw new Error(`[Sixb] Delegated Action target ${index} must be an object.`);
819
+ }
820
+ const authoredActionId = authoredTarget.actionId;
821
+ const authoredSubject = authoredTarget.subject;
822
+ if (!isRecord(authoredSubject)) {
823
+ throw new Error(`[Sixb] Delegated Action target ${index} subject must be an ObjectRef.`);
824
+ }
825
+ const actionId = delegatedActionIdentifier(authoredActionId, `Delegated Action target ${index} action id`);
826
+ const objectTypeId = delegatedActionIdentifier(authoredSubject.objectTypeId, `Delegated Action target ${index} subject object type id`);
827
+ const primaryId = delegatedActionIdentifier(authoredSubject.primaryId, `Delegated Action target ${index} subject primary id`);
828
+ identifierCharacters += actionId.length + objectTypeId.length + primaryId.length;
829
+ if (identifierCharacters > MAX_DELEGATED_ACTION_IDENTIFIER_CHARACTERS) {
830
+ throw new Error(`[Sixb] Delegated authority exceeds the maximum of ${MAX_DELEGATED_ACTION_IDENTIFIER_CHARACTERS} Action identifier characters.`);
831
+ }
832
+ targets.push(Object.freeze({
833
+ actionId,
834
+ subject: Object.freeze({ objectTypeId, primaryId })
835
+ }));
836
+ }
837
+ return Object.freeze(targets);
838
+ }
839
+ function delegatedActionIdentifier(value, label) {
840
+ if (typeof value !== "string" || !value.trim()) {
841
+ throw new Error(`[Sixb] ${label} must not be empty.`);
842
+ }
843
+ return value;
844
+ }
845
+ function isRecord(value) {
846
+ return typeof value === "object" && value !== null && !Array.isArray(value);
847
+ }
309
848
  function cloneAuthorizationRef(ref) {
310
849
  switch (ref.type) {
311
850
  case "principal":
@@ -316,6 +855,8 @@ function cloneAuthorizationRef(ref) {
316
855
  };
317
856
  case "trustedPrimitive":
318
857
  return { type: "trustedPrimitive", primitive: { ...ref.primitive } };
858
+ case "delegated":
859
+ return { type: "delegated", delegation: { ...ref.delegation } };
319
860
  case "kernel":
320
861
  return { type: "kernel", operation: { ...ref.operation } };
321
862
  case "disabled":
@@ -356,6 +897,8 @@ function atomsFor(request) {
356
897
  return [{ kind: "append:telemetry", id: request.objectTypeId }];
357
898
  case "action.apply":
358
899
  return [{ kind: "apply:action", id: request.actionId }];
900
+ case "share.manage":
901
+ return [{ kind: "share:share", id: request.shareId }];
359
902
  case "workflow.run":
360
903
  return [{ kind: "run:workflow", id: request.workflowId }];
361
904
  case "sync.run":
@@ -363,9 +906,13 @@ function atomsFor(request) {
363
906
  case "pipeline.run":
364
907
  return [{ kind: "run:pipeline", id: request.pipelineId }];
365
908
  case "agent.run":
366
- return [{ kind: "run:agent", id: request.agentId }];
909
+ return [{ kind: "run:agent" }];
367
910
  case "logs.observe":
368
911
  return [{ kind: "observe:logs", id: "logs" }];
912
+ case "aiUsage.observe":
913
+ return [{ kind: "observe:aiUsage", id: "aiUsage" }];
914
+ case "aiUsage.manage":
915
+ return [{ kind: "manage:aiUsage", id: "aiUsage" }];
369
916
  case "connector.manage":
370
917
  return [{ kind: "manage:connector", id: request.connectorId }];
371
918
  case "object.query":
@@ -373,11 +920,16 @@ function atomsFor(request) {
373
920
  }
374
921
  }
375
922
  function atomKey(atom) {
376
- if (atom.kind === "observe:logs")
923
+ if (atom.kind === "run:agent")
924
+ return atom.kind;
925
+ if (atom.kind === "observe:logs" || atom.kind === "observe:aiUsage" || atom.kind === "manage:aiUsage") {
377
926
  return atom.kind;
927
+ }
378
928
  return `${atom.kind}:${atom.id}`;
379
929
  }
380
930
  function holds(grants, atom) {
931
+ if (atom.kind === "run:agent")
932
+ return grants[atom.kind];
381
933
  return grants[atom.kind].has(atom.id);
382
934
  }
383
935
  function evaluate(authorization, request) {
@@ -391,6 +943,9 @@ function isAllowed(authorization, request) {
391
943
  }
392
944
  function assertAuthorized(runtime, request) {
393
945
  const resolved = assertRuntimeAuthorizationBound(runtime);
946
+ if (resolved.type === "delegated") {
947
+ throw new AuthorizationError(`delegated:${request.kind}`, `[Sixb] Operation '${request.kind}' is not covered by delegated authorization.`);
948
+ }
394
949
  const authorization = resolved.type === "principal" ? resolved.context : undefined;
395
950
  const decision = evaluate(authorization, request);
396
951
  if (decision.allowed) {
@@ -398,8 +953,14 @@ function assertAuthorized(runtime, request) {
398
953
  }
399
954
  throw new AuthorizationError(decision.missing[0] ?? request.kind, deniedMessage(authorization, request));
400
955
  }
956
+ function isRuntimeAllowed(runtime, request) {
957
+ const authority = resolveRuntimeAuthorizationForProject(runtime);
958
+ if (authority.type === "denied" || authority.type === "delegated")
959
+ return false;
960
+ return authority.type === "unrestricted" || isAllowed(authority.context, request);
961
+ }
401
962
  function assertRuntimeAuthorizationBound(runtime) {
402
- const resolved = resolveRuntimeAuthorization(runtime.runtimeAuthorization);
963
+ const resolved = resolveRuntimeAuthorizationForProject(runtime);
403
964
  if (resolved.type === "denied") {
404
965
  throw new AuthorizationError("runtime:unbound", "[Sixb] Protected operations require a registered execution scope.");
405
966
  }
@@ -423,13 +984,14 @@ function assertPrivileged(runtime, operation) {
423
984
  throw new AuthorizationError(`privileged:${operation}`, `[Sixb] Operation '${operation}' is not covered by scoped authorization grants.`);
424
985
  }
425
986
  function assertProviderAccess(runtime, execution, operation) {
426
- const resolved = assertRuntimeAuthorizationBound(runtime);
987
+ const resolved = resolveExecutionScopeAuthorization(runtime.projectId, {
988
+ execution,
989
+ authorization: runtime.runtimeAuthorization
990
+ });
427
991
  if (resolved.type === "unrestricted") {
428
992
  return;
429
993
  }
430
- const binding = resolved.executionBinding;
431
- const executor = execution.executor;
432
- if (binding?.type === "agent" && executor.type === "agent" && binding.executionId === execution.id && binding.agentId === executor.agentId && binding.runId === executor.runId) {
994
+ if (execution.executor.type === "agent") {
433
995
  return;
434
996
  }
435
997
  throw new AuthorizationError(`privileged:${operation}`, `[Sixb] Operation '${operation}' is not covered by scoped authorization grants.`);
@@ -449,6 +1011,8 @@ function deniedMessage(authorization, request) {
449
1011
  return `[Sixb] Principal '${principalId}' is not allowed to append telemetry for object type '${request.objectTypeId}'.`;
450
1012
  case "action.apply":
451
1013
  return `[Sixb] Principal '${principalId}' is not allowed to apply action '${request.actionId}'.`;
1014
+ case "share.manage":
1015
+ return `[Sixb] Principal '${principalId}' is not allowed to manage Share '${request.shareId}'.`;
452
1016
  case "workflow.run":
453
1017
  return `[Sixb] Principal '${principalId}' is not allowed to run workflow '${request.workflowId}'.`;
454
1018
  case "sync.run":
@@ -456,9 +1020,13 @@ function deniedMessage(authorization, request) {
456
1020
  case "pipeline.run":
457
1021
  return `[Sixb] Principal '${principalId}' is not allowed to run pipeline '${request.pipelineId}'.`;
458
1022
  case "agent.run":
459
- return `[Sixb] Principal '${principalId}' is not allowed to run agent '${request.agentId}'.`;
1023
+ return `[Sixb] Principal '${principalId}' is not allowed to run the project Agent.`;
460
1024
  case "logs.observe":
461
1025
  return `[Sixb] Principal '${principalId}' is not allowed to observe project logs.`;
1026
+ case "aiUsage.observe":
1027
+ return `[Sixb] Principal '${principalId}' is not allowed to observe project AI usage.`;
1028
+ case "aiUsage.manage":
1029
+ return `[Sixb] Principal '${principalId}' is not allowed to manage project AI usage limits.`;
462
1030
  case "connector.manage":
463
1031
  return `[Sixb] Principal '${principalId}' is not allowed to manage connector '${request.connectorId}'.`;
464
1032
  case "object.query": {
@@ -534,6 +1102,10 @@ function canViewEvent(authorization, event) {
534
1102
  function resolveRoleGrants(role, universe) {
535
1103
  const grants = emptyGrantSets();
536
1104
  for (const grant of role.grants) {
1105
+ if (grant.capability === "run" && grant.target === "agent") {
1106
+ grants["run:agent"] = true;
1107
+ continue;
1108
+ }
537
1109
  const kind = grantKindOf(grant);
538
1110
  const spec = GRANT_KINDS[kind];
539
1111
  expandSelection(grant.selection, universe[spec.universeKey], grants[kind], spec.expandsSubtypes ? universe.getSubTypes : undefined);
@@ -568,7 +1140,10 @@ function resolveAuthorizationContext(input) {
568
1140
  continue;
569
1141
  }
570
1142
  roleIds.push(role.id);
571
- for (const kind of GRANT_KIND_KEYS) {
1143
+ if (role.grants["run:agent"]) {
1144
+ grants["run:agent"] = true;
1145
+ }
1146
+ for (const kind of TARGETED_GRANT_KIND_KEYS) {
572
1147
  for (const id of role.grants[kind]) {
573
1148
  grants[kind].add(id);
574
1149
  }
@@ -968,7 +1543,7 @@ function assertProjectionDataset(dataset) {
968
1543
  }
969
1544
  assertNonEmpty2(dataset.id, "dataset id");
970
1545
  }
971
- function isRecord(value) {
1546
+ function isRecord2(value) {
972
1547
  return typeof value === "object" && value !== null && !Array.isArray(value);
973
1548
  }
974
1549
  function lowerForeignKeyMapping(mapping) {
@@ -981,7 +1556,7 @@ function lowerForeignKeyMapping(mapping) {
981
1556
  return lowered;
982
1557
  }
983
1558
  function isForeignKeyDescriptor(value) {
984
- return isRecord(value) && typeof value.linkId === "string";
1559
+ return isRecord2(value) && typeof value.linkId === "string";
985
1560
  }
986
1561
  function defineProjection(id, target) {
987
1562
  if ("link" in target)
@@ -1134,7 +1709,7 @@ function lowerTelemetryPropertiesPointMapping(objectType, mapping) {
1134
1709
  if (mapping.properties === undefined) {
1135
1710
  throw new ProjectionValidationError("Telemetry projection point mapping requires properties.");
1136
1711
  }
1137
- if (!isRecord(mapping.properties)) {
1712
+ if (!isRecord2(mapping.properties)) {
1138
1713
  throw new ProjectionValidationError("Telemetry projection point mapping properties must be an object.");
1139
1714
  }
1140
1715
  assertNonEmpty2(mapping.objectId, "objectId field");
@@ -1162,7 +1737,7 @@ function lowerTelemetryPropertyMapping(propertyId, input) {
1162
1737
  assertNonEmpty2(input, `property '${propertyId}' value field`);
1163
1738
  return { valueField: input };
1164
1739
  }
1165
- if (!isRecord(input)) {
1740
+ if (!isRecord2(input)) {
1166
1741
  throw new ProjectionValidationError(`Telemetry projection property '${propertyId}' must map a value column or value/unit columns.`);
1167
1742
  }
1168
1743
  const allowedKeys = new Set(["value", "unit"]);
@@ -1231,33 +1806,33 @@ function buildLinkProjection(id, linkToken) {
1231
1806
  };
1232
1807
  }
1233
1808
  function isObjectProjectionDefinition(value) {
1234
- if (!isRecord(value))
1809
+ if (!isRecord2(value))
1235
1810
  return false;
1236
- return value._tag === "ObjectProjectionDefinition" && typeof value.id === "string" && typeof value.objectTypeId === "string" && typeof value.datasetId === "string" && isRecord(value.properties) && isRecord(value.links) && isSourceEditConflictResolution(value.conflictResolution);
1811
+ return value._tag === "ObjectProjectionDefinition" && typeof value.id === "string" && typeof value.objectTypeId === "string" && typeof value.datasetId === "string" && isRecord2(value.properties) && isRecord2(value.links) && isSourceEditConflictResolution(value.conflictResolution);
1237
1812
  }
1238
1813
  function isSourceEditConflictResolution(value) {
1239
1814
  if (value === undefined)
1240
1815
  return true;
1241
- if (!isRecord(value) || typeof value.strategy !== "string")
1816
+ if (!isRecord2(value) || typeof value.strategy !== "string")
1242
1817
  return false;
1243
1818
  if (value.strategy === "editsWin")
1244
1819
  return value.sourceTimestamp === undefined;
1245
1820
  return value.strategy === "mostRecent" && typeof value.sourceTimestamp === "string";
1246
1821
  }
1247
1822
  function isLinkProjectionDefinition(value) {
1248
- if (!isRecord(value))
1823
+ if (!isRecord2(value))
1249
1824
  return false;
1250
1825
  return value._tag === "LinkProjectionDefinition" && typeof value.id === "string" && typeof value.linkId === "string" && typeof value.sourceObjectTypeId === "string" && typeof value.targetObjectTypeId === "string" && typeof value.datasetId === "string" && typeof value.sourceField === "string" && typeof value.targetField === "string";
1251
1826
  }
1252
1827
  function isTelemetryProjectionDefinition(value) {
1253
- if (!isRecord(value))
1828
+ if (!isRecord2(value))
1254
1829
  return false;
1255
1830
  return value._tag === "TelemetryProjectionDefinition" && typeof value.id === "string" && typeof value.objectTypeId === "string" && typeof value.datasetId === "string" && typeof value.objectIdField === "string" && typeof value.atField === "string" && isTelemetryProjectionProperties(value.properties);
1256
1831
  }
1257
1832
  function isTelemetryProjectionProperties(value) {
1258
- if (!isRecord(value) || Object.keys(value).length === 0)
1833
+ if (!isRecord2(value) || Object.keys(value).length === 0)
1259
1834
  return false;
1260
- return Object.values(value).every((mapping) => isRecord(mapping) && typeof mapping.valueField === "string" && (mapping.unitField === undefined || typeof mapping.unitField === "string"));
1835
+ return Object.values(value).every((mapping) => isRecord2(mapping) && typeof mapping.valueField === "string" && (mapping.unitField === undefined || typeof mapping.unitField === "string"));
1261
1836
  }
1262
1837
  function isProjectionDefinition(value) {
1263
1838
  return isObjectProjectionDefinition(value) || isLinkProjectionDefinition(value) || isTelemetryProjectionDefinition(value);
@@ -1307,6 +1882,6 @@ function canViewProjection(authorization, projection) {
1307
1882
  function emptyGrantIndex() {
1308
1883
  return emptyGrantSets();
1309
1884
  }
1310
- export { ProjectionValidationError, computeProjectionOwnership, validateProjectionOwnership, validateTelemetryProjectionFieldMapping, validateProjectionsAtStartup, defineProjection, fromForeignKey, isObjectProjectionDefinition, isLinkProjectionDefinition, isTelemetryProjectionDefinition, isProjectionDefinition, projectionTargetOf, GRANT_KINDS, grantKindOf, createPrincipalRuntimeAuthorization, createAgentRuntimeAuthorization, createDisabledRuntimeAuthorization, createTrustedPrimitiveRuntimeAuthorization, getAuthorizationRef, resolveExecutionScopeAuthorization, AuthorizationError, evaluate, isAllowed, assertAuthorized, assertCanEdit, assertCanAppendTelemetry, assertCanManageConnector, assertPrivileged, assertProviderAccess, isApplicationAccessControlled, canAccessApplication, canViewEvent, resolveRoleGrants, resolveAuthorizationContext, canViewActionRun, canViewWorkflowRun, canViewWorkflowIntervention, canViewPipelineRun, canViewProjectionRun, canViewProjection, emptyGrantIndex };
1885
+ export { ProjectionValidationError, computeProjectionOwnership, validateProjectionOwnership, validateTelemetryProjectionFieldMapping, validateProjectionsAtStartup, defineProjection, fromForeignKey, isObjectProjectionDefinition, isLinkProjectionDefinition, isTelemetryProjectionDefinition, isProjectionDefinition, projectionTargetOf, agentServiceAccountId, GRANT_KINDS, grantKindOf, MAX_OBJECT_READ_FACETS, ObjectReadLimitExceededError, snapshotObjectReadExecutionLimits, assertObjectReadFacetCount, assertObjectReadOutputWithinLimit, createPrincipalRuntimeAuthorization, createAgentRuntimeAuthorization, createDisabledRuntimeAuthorization, createDelegatedRuntimeAuthorization, createTrustedPrimitiveRuntimeAuthorization, resolveRuntimeAuthorizationForProject, getAuthorizationRef, captureExecutionScope, resolveExecutionScopeAuthorization, AuthorizationError, evaluate, isAllowed, assertAuthorized, isRuntimeAllowed, assertRuntimeAuthorizationBound, assertCanEdit, assertCanAppendTelemetry, assertCanManageConnector, assertPrivileged, assertProviderAccess, isApplicationAccessControlled, canAccessApplication, canViewEvent, resolveRoleGrants, resolveAuthorizationContext, canViewActionRun, canViewWorkflowRun, canViewWorkflowIntervention, canViewPipelineRun, canViewProjectionRun, canViewProjection, emptyGrantIndex };
1311
1886
 
1312
- //# debugId=48D20BF42F9CD3F464756E2164756E21
1887
+ //# debugId=57388FDEBF4490DF64756E2164756E21