@sixb/core 0.1.24 → 0.1.26

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 (448) hide show
  1. package/dist/actions/index.js +35 -35
  2. package/dist/agents/attachment-keys.d.ts +25 -0
  3. package/dist/agents/attachment-keys.d.ts.map +1 -0
  4. package/dist/agents/cancel.d.ts +12 -0
  5. package/dist/agents/cancel.d.ts.map +1 -1
  6. package/dist/agents/children.d.ts.map +1 -1
  7. package/dist/agents/dispatch.d.ts +1 -9
  8. package/dist/agents/dispatch.d.ts.map +1 -1
  9. package/dist/agents/execution.d.ts +5 -0
  10. package/dist/agents/execution.d.ts.map +1 -1
  11. package/dist/agents/index.d.ts +31 -6
  12. package/dist/agents/index.d.ts.map +1 -1
  13. package/dist/agents/index.js +154 -66
  14. package/dist/agents/index.js.map +1 -1
  15. package/dist/agents/model-loop.d.ts +3 -5
  16. package/dist/agents/model-loop.d.ts.map +1 -1
  17. package/dist/agents/model-routing.d.ts +4 -1
  18. package/dist/agents/model-routing.d.ts.map +1 -1
  19. package/dist/agents/request.d.ts +9 -1
  20. package/dist/agents/request.d.ts.map +1 -1
  21. package/dist/agents/run-after-finish.d.ts +11 -0
  22. package/dist/agents/run-after-finish.d.ts.map +1 -0
  23. package/dist/agents/run-artifacts.d.ts +56 -0
  24. package/dist/agents/run-artifacts.d.ts.map +1 -0
  25. package/dist/agents/run-events.d.ts +49 -0
  26. package/dist/agents/run-events.d.ts.map +1 -0
  27. package/dist/agents/run-fence.d.ts +38 -0
  28. package/dist/agents/run-fence.d.ts.map +1 -0
  29. package/dist/agents/run-liveness.d.ts +36 -0
  30. package/dist/agents/run-liveness.d.ts.map +1 -0
  31. package/dist/agents/run-plan.d.ts +110 -0
  32. package/dist/agents/run-plan.d.ts.map +1 -0
  33. package/dist/agents/run-session-children.d.ts +89 -0
  34. package/dist/agents/run-session-children.d.ts.map +1 -0
  35. package/dist/agents/run-session-http.d.ts +37 -0
  36. package/dist/agents/run-session-http.d.ts.map +1 -0
  37. package/dist/agents/run-session-serve.d.ts +24 -0
  38. package/dist/agents/run-session-serve.d.ts.map +1 -0
  39. package/dist/agents/run-session-wire.d.ts +31 -0
  40. package/dist/agents/run-session-wire.d.ts.map +1 -0
  41. package/dist/agents/run-session.d.ts +239 -0
  42. package/dist/agents/run-session.d.ts.map +1 -0
  43. package/dist/agents/run-token.d.ts +40 -0
  44. package/dist/agents/run-token.d.ts.map +1 -0
  45. package/dist/agents/run-tools.d.ts +68 -0
  46. package/dist/agents/run-tools.d.ts.map +1 -0
  47. package/dist/agents/run-turn.d.ts +59 -0
  48. package/dist/agents/run-turn.d.ts.map +1 -0
  49. package/dist/agents/streams/index.js +1 -1
  50. package/dist/agents/streams/internal.d.ts +1 -1
  51. package/dist/agents/streams/internal.d.ts.map +1 -1
  52. package/dist/agents/streams/internal.js +2 -4
  53. package/dist/agents/streams/internal.js.map +1 -1
  54. package/dist/agents/streams/protocol.d.ts +1 -96
  55. package/dist/agents/streams/protocol.d.ts.map +1 -1
  56. package/dist/agents/subagent-runs.d.ts +7 -1
  57. package/dist/agents/subagent-runs.d.ts.map +1 -1
  58. package/dist/agents/tool-files.d.ts +34 -0
  59. package/dist/agents/tool-files.d.ts.map +1 -0
  60. package/dist/agents/workflow-node-session.d.ts +99 -0
  61. package/dist/agents/workflow-node-session.d.ts.map +1 -0
  62. package/dist/artifacts/frames/index.js +6 -3
  63. package/dist/artifacts/frames/index.js.map +3 -3
  64. package/dist/artifacts/frames/probe.d.ts.map +1 -1
  65. package/dist/artifacts/index.js.map +1 -1
  66. package/dist/artifacts/publish/index.d.ts +1 -1
  67. package/dist/artifacts/publish/index.d.ts.map +1 -1
  68. package/dist/artifacts/publish/index.js +19 -19
  69. package/dist/auth/index.js +8 -8
  70. package/dist/authorization/index.js +4 -4
  71. package/dist/bootstrap/index.js +45 -43
  72. package/dist/bootstrap/index.js.map +2 -2
  73. package/dist/{chunk-2fn60nvs.js → chunk-06sg8s4z.js} +2 -2
  74. package/dist/{chunk-2fn60nvs.js.map → chunk-06sg8s4z.js.map} +1 -1
  75. package/dist/chunk-07kkp2e1.js.map +1 -1
  76. package/dist/{chunk-9ntbsnke.js → chunk-0bc3w0zq.js} +7 -7
  77. package/dist/{chunk-9ntbsnke.js.map → chunk-0bc3w0zq.js.map} +2 -2
  78. package/dist/{chunk-d2m879s4.js → chunk-0kk2wt0h.js} +27 -27
  79. package/dist/chunk-0kk2wt0h.js.map +12 -0
  80. package/dist/chunk-16a9dmfy.js.map +1 -1
  81. package/dist/chunk-18sk89cg.js.map +2 -2
  82. package/dist/{chunk-3qms4nax.js → chunk-1vg43g9q.js} +20 -20
  83. package/dist/{chunk-3qms4nax.js.map → chunk-1vg43g9q.js.map} +4 -4
  84. package/dist/{chunk-hqsp2sx4.js → chunk-1xvqgg88.js} +31 -33
  85. package/dist/{chunk-hqsp2sx4.js.map → chunk-1xvqgg88.js.map} +6 -6
  86. package/dist/chunk-2adz0h75.js.map +1 -1
  87. package/dist/{chunk-fm62y49k.js → chunk-2pk5hjj9.js} +5 -3
  88. package/dist/{chunk-fm62y49k.js.map → chunk-2pk5hjj9.js.map} +5 -5
  89. package/dist/{chunk-vrf90dkv.js → chunk-2vjnyz1s.js} +1 -1
  90. package/dist/{chunk-vrf90dkv.js.map → chunk-2vjnyz1s.js.map} +1 -1
  91. package/dist/{chunk-4f3ydv7t.js → chunk-315qye3g.js} +1 -1
  92. package/dist/{chunk-4f3ydv7t.js.map → chunk-315qye3g.js.map} +1 -1
  93. package/dist/{chunk-rap5w0x0.js → chunk-31khg3g0.js} +1 -1
  94. package/dist/{chunk-rap5w0x0.js.map → chunk-31khg3g0.js.map} +1 -1
  95. package/dist/chunk-45ngkxkp.js.map +1 -1
  96. package/dist/chunk-48jezz3j.js.map +1 -1
  97. package/dist/{chunk-vr3j63jq.js → chunk-4jq2bg8t.js} +78 -78
  98. package/dist/{chunk-vr3j63jq.js.map → chunk-4jq2bg8t.js.map} +4 -4
  99. package/dist/chunk-4ymrcdbm.js.map +1 -1
  100. package/dist/chunk-58geavnf.js.map +1 -1
  101. package/dist/{chunk-6y0mkhex.js → chunk-59kf345w.js} +2 -2
  102. package/dist/{chunk-6y0mkhex.js.map → chunk-59kf345w.js.map} +1 -1
  103. package/dist/{chunk-3p93tb91.js → chunk-6qn7nmd3.js} +102 -102
  104. package/dist/{chunk-3p93tb91.js.map → chunk-6qn7nmd3.js.map} +4 -4
  105. package/dist/chunk-73j0v4qv.js +355 -0
  106. package/dist/chunk-73j0v4qv.js.map +13 -0
  107. package/dist/{chunk-2gjj5dx3.js → chunk-78ymxrn0.js} +1 -1
  108. package/dist/{chunk-6bkbyer5.js → chunk-7ex2p3zp.js} +3 -3
  109. package/dist/{chunk-6bkbyer5.js.map → chunk-7ex2p3zp.js.map} +1 -1
  110. package/dist/{chunk-5tfev0fv.js → chunk-7hf6tkgs.js} +167 -167
  111. package/dist/{chunk-5tfev0fv.js.map → chunk-7hf6tkgs.js.map} +4 -4
  112. package/dist/{chunk-8z4726jz.js → chunk-7wn5z7mq.js} +10 -10
  113. package/dist/{chunk-8z4726jz.js.map → chunk-7wn5z7mq.js.map} +2 -2
  114. package/dist/{chunk-6n69k945.js → chunk-8mb7mt8n.js} +2 -2
  115. package/dist/chunk-8ncg20rd.js.map +1 -1
  116. package/dist/{chunk-68wghpdf.js → chunk-8v5a54qz.js} +50 -11
  117. package/dist/{chunk-68wghpdf.js.map → chunk-8v5a54qz.js.map} +3 -3
  118. package/dist/{chunk-gqm0b7vd.js → chunk-8v6xzwgr.js} +92 -76
  119. package/dist/{chunk-gqm0b7vd.js.map → chunk-8v6xzwgr.js.map} +6 -6
  120. package/dist/{chunk-m36fw8ft.js → chunk-8wsjr52f.js} +1 -1
  121. package/dist/{chunk-vd1rk42q.js → chunk-8xnz9vvp.js} +4 -4
  122. package/dist/{chunk-vd1rk42q.js.map → chunk-8xnz9vvp.js.map} +1 -1
  123. package/dist/chunk-9mab3dvg.js.map +1 -1
  124. package/dist/chunk-9tc8dxmn.js.map +1 -1
  125. package/dist/chunk-9x8dybsb.js.map +2 -2
  126. package/dist/chunk-a3faa34j.js.map +1 -1
  127. package/dist/{chunk-62a63pr6.js → chunk-axb4ss9a.js} +7 -7
  128. package/dist/{chunk-62a63pr6.js.map → chunk-axb4ss9a.js.map} +2 -2
  129. package/dist/{chunk-z3ryd53f.js → chunk-b6ghvap7.js} +35 -11
  130. package/dist/{chunk-z3ryd53f.js.map → chunk-b6ghvap7.js.map} +3 -3
  131. package/dist/{chunk-sqfvnvqj.js → chunk-c14ap3s9.js} +2 -2
  132. package/dist/{chunk-sqfvnvqj.js.map → chunk-c14ap3s9.js.map} +1 -1
  133. package/dist/{chunk-661ezhks.js → chunk-cbcgs9f7.js} +87 -8
  134. package/dist/chunk-cbcgs9f7.js.map +11 -0
  135. package/dist/chunk-cwdzcv37.js.map +1 -1
  136. package/dist/{chunk-bab05bhg.js → chunk-dgtd0836.js} +1 -1
  137. package/dist/{chunk-1j6j0rht.js → chunk-e24fvw8g.js} +1 -1
  138. package/dist/{chunk-1j6j0rht.js.map → chunk-e24fvw8g.js.map} +1 -1
  139. package/dist/chunk-e5wf5vz0.js.map +1 -1
  140. package/dist/chunk-eptrvnby.js.map +1 -1
  141. package/dist/chunk-ey1nk510.js.map +1 -1
  142. package/dist/{chunk-j936th07.js → chunk-fakrpfy3.js} +58 -58
  143. package/dist/{chunk-j936th07.js.map → chunk-fakrpfy3.js.map} +5 -5
  144. package/dist/chunk-fb3feg1e.js.map +1 -1
  145. package/dist/chunk-ff5xkv0p.js.map +1 -1
  146. package/dist/chunk-fntqb7qy.js.map +1 -1
  147. package/dist/{chunk-7ny9mjgm.js → chunk-ft3w5ahs.js} +1 -1
  148. package/dist/chunk-g663fahq.js.map +1 -1
  149. package/dist/{chunk-cdk3egjj.js → chunk-h1na2cxc.js} +1 -1
  150. package/dist/{chunk-cdk3egjj.js.map → chunk-h1na2cxc.js.map} +1 -1
  151. package/dist/chunk-hn2r7z41.js.map +1 -1
  152. package/dist/{chunk-24bqx0dx.js → chunk-hn76sanm.js} +1 -1
  153. package/dist/{chunk-24bqx0dx.js.map → chunk-hn76sanm.js.map} +1 -1
  154. package/dist/chunk-jmfet9r4.js.map +1 -1
  155. package/dist/{chunk-bnr4a734.js → chunk-jn3ysaf2.js} +24 -22
  156. package/dist/{chunk-bnr4a734.js.map → chunk-jn3ysaf2.js.map} +5 -5
  157. package/dist/{chunk-4y26vs3v.js → chunk-jspskey0.js} +16 -3
  158. package/dist/chunk-jspskey0.js.map +10 -0
  159. package/dist/{chunk-r6szek0x.js → chunk-jt3r6thp.js} +2 -135
  160. package/dist/chunk-jt3r6thp.js.map +10 -0
  161. package/dist/chunk-kfee1h52.js.map +1 -1
  162. package/dist/{chunk-qx00vjrj.js → chunk-kwfhd1g0.js} +23 -23
  163. package/dist/{chunk-qx00vjrj.js.map → chunk-kwfhd1g0.js.map} +4 -4
  164. package/dist/chunk-m427qgq0.js.map +1 -1
  165. package/dist/chunk-mbsbxarb.js.map +1 -1
  166. package/dist/{chunk-et017krg.js → chunk-mdxmt0n3.js} +8657 -8704
  167. package/dist/{chunk-et017krg.js.map → chunk-mdxmt0n3.js.map} +37 -37
  168. package/dist/chunk-mmagke4x.js.map +1 -1
  169. package/dist/{chunk-2x19q6k6.js → chunk-mqx25wwh.js} +319 -154
  170. package/dist/chunk-mqx25wwh.js.map +18 -0
  171. package/dist/chunk-mzx71snp.js.map +1 -1
  172. package/dist/chunk-n8q5j6y5.js.map +1 -1
  173. package/dist/chunk-npcr0228.js.map +1 -1
  174. package/dist/{chunk-m2nevja0.js → chunk-phm3c7b9.js} +1 -1
  175. package/dist/{chunk-m2nevja0.js.map → chunk-phm3c7b9.js.map} +1 -1
  176. package/dist/chunk-qf954wje.js.map +1 -1
  177. package/dist/{chunk-65pyhyas.js → chunk-qgvbxfqv.js} +6 -8
  178. package/dist/{chunk-65pyhyas.js.map → chunk-qgvbxfqv.js.map} +2 -2
  179. package/dist/{chunk-hk38wahh.js → chunk-qst145py.js} +4 -4
  180. package/dist/{chunk-hk38wahh.js.map → chunk-qst145py.js.map} +1 -1
  181. package/dist/{chunk-c844dkwd.js → chunk-qtzftvxa.js} +4 -5
  182. package/dist/{chunk-c844dkwd.js.map → chunk-qtzftvxa.js.map} +2 -2
  183. package/dist/chunk-ratkv4zc.js +3 -0
  184. package/dist/chunk-ratkv4zc.js.map +9 -0
  185. package/dist/{chunk-nzapm6p0.js → chunk-s3we74h8.js} +1 -2
  186. package/dist/chunk-s3we74h8.js.map +12 -0
  187. package/dist/{chunk-0xmt5p5y.js → chunk-t3brw0wd.js} +1 -2
  188. package/dist/{chunk-0xmt5p5y.js.map → chunk-t3brw0wd.js.map} +2 -2
  189. package/dist/chunk-t5608tkq.js.map +1 -1
  190. package/dist/chunk-tdxfsg1c.js.map +1 -1
  191. package/dist/{chunk-1t6k1avb.js → chunk-tnhqtfea.js} +1 -1
  192. package/dist/chunk-vhbw5sqm.js.map +1 -1
  193. package/dist/{chunk-rp9wwk7b.js → chunk-vx4e4zv4.js} +30 -30
  194. package/dist/{chunk-rp9wwk7b.js.map → chunk-vx4e4zv4.js.map} +4 -4
  195. package/dist/chunk-waqk73p1.js.map +1 -1
  196. package/dist/chunk-x0v3jd47.js.map +1 -1
  197. package/dist/{chunk-yecwnwpq.js → chunk-xm8qgbqm.js} +58 -29
  198. package/dist/{chunk-yecwnwpq.js.map → chunk-xm8qgbqm.js.map} +7 -7
  199. package/dist/{chunk-97wr6p2g.js → chunk-y7j6x4h0.js} +8 -8
  200. package/dist/{chunk-97wr6p2g.js.map → chunk-y7j6x4h0.js.map} +4 -4
  201. package/dist/{chunk-xe0732g0.js → chunk-yavhtnac.js} +12 -8
  202. package/dist/{chunk-xe0732g0.js.map → chunk-yavhtnac.js.map} +4 -4
  203. package/dist/chunk-yd00vzqr.js +3394 -0
  204. package/dist/chunk-yd00vzqr.js.map +37 -0
  205. package/dist/{chunk-n9w3n38q.js → chunk-ye5c8016.js} +54 -8
  206. package/dist/chunk-ye5c8016.js.map +23 -0
  207. package/dist/chunk-yw9pyg66.js.map +1 -1
  208. package/dist/{chunk-nydf3dbe.js → chunk-z9mg7wya.js} +37 -20
  209. package/dist/chunk-z9mg7wya.js.map +13 -0
  210. package/dist/chunk-zbc929zg.js.map +1 -1
  211. package/dist/chunk-zhh1jd89.js +290 -0
  212. package/dist/chunk-zhh1jd89.js.map +10 -0
  213. package/dist/connectors/connections/authorizations.d.ts +2 -2
  214. package/dist/connectors/connections/authorizations.d.ts.map +1 -1
  215. package/dist/connectors/connections/service.d.ts.map +1 -1
  216. package/dist/connectors/connections/tokens.d.ts +2 -2
  217. package/dist/connectors/connections/tokens.d.ts.map +1 -1
  218. package/dist/connectors/connections/validation.d.ts +5 -0
  219. package/dist/connectors/connections/validation.d.ts.map +1 -1
  220. package/dist/connectors/types.d.ts +9 -2
  221. package/dist/connectors/types.d.ts.map +1 -1
  222. package/dist/datasets/write.js +3 -3
  223. package/dist/deploy/internal.js +2 -5
  224. package/dist/deploy/internal.js.map +3 -3
  225. package/dist/deploy/types.d.ts +0 -2
  226. package/dist/deploy/types.d.ts.map +1 -1
  227. package/dist/execution/agent.d.ts +2 -2
  228. package/dist/execution/agent.d.ts.map +1 -1
  229. package/dist/execution/agent.js +38 -38
  230. package/dist/execution/agent.js.map +1 -1
  231. package/dist/execution/primitive.js +35 -35
  232. package/dist/execution/request.js +37 -37
  233. package/dist/execution/request.js.map +2 -2
  234. package/dist/http/api-routes.d.ts +12 -11
  235. package/dist/http/api-routes.d.ts.map +1 -1
  236. package/dist/http/index.js +1 -1
  237. package/dist/index.d.ts +3 -3
  238. package/dist/index.d.ts.map +1 -1
  239. package/dist/index.js +53 -51
  240. package/dist/index.js.map +1 -1
  241. package/dist/lake-storage/index.js +3 -3
  242. package/dist/logging/internal.js +1 -1
  243. package/dist/materializer/index.js +17 -17
  244. package/dist/models/execution/errors.d.ts +5 -0
  245. package/dist/models/execution/errors.d.ts.map +1 -1
  246. package/dist/models/execution/index.d.ts +2 -1
  247. package/dist/models/execution/index.d.ts.map +1 -1
  248. package/dist/models/execution/index.js +55 -50
  249. package/dist/models/execution/index.js.map +1 -1
  250. package/dist/models/execution/model-call-recorder.d.ts +7 -2
  251. package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
  252. package/dist/models/execution.d.ts.map +1 -1
  253. package/dist/models/language-call.d.ts +51 -0
  254. package/dist/models/language-call.d.ts.map +1 -0
  255. package/dist/objects/index.js +35 -35
  256. package/dist/objects/query/index.js +17 -17
  257. package/dist/ontology/docs-markdown.d.ts.map +1 -1
  258. package/dist/ontology/index.d.ts +1 -1
  259. package/dist/ontology/index.d.ts.map +1 -1
  260. package/dist/ontology/index.js +4 -4
  261. package/dist/ontology/internal.js +8 -275
  262. package/dist/ontology/internal.js.map +3 -4
  263. package/dist/ontology/user-ref.d.ts +21 -3
  264. package/dist/ontology/user-ref.d.ts.map +1 -1
  265. package/dist/pipelines/index.js +19 -19
  266. package/dist/projections/builders.d.ts +13 -2
  267. package/dist/projections/builders.d.ts.map +1 -1
  268. package/dist/projections/index.d.ts +1 -1
  269. package/dist/projections/index.d.ts.map +1 -1
  270. package/dist/projections/internal.js +17 -17
  271. package/dist/projections/types.d.ts +7 -0
  272. package/dist/projections/types.d.ts.map +1 -1
  273. package/dist/projections/validation.d.ts +2 -0
  274. package/dist/projections/validation.d.ts.map +1 -1
  275. package/dist/query.js +2 -2
  276. package/dist/queues/in-memory.d.ts +0 -1
  277. package/dist/queues/in-memory.d.ts.map +1 -1
  278. package/dist/queues/index.d.ts +1 -1
  279. package/dist/queues/index.d.ts.map +1 -1
  280. package/dist/queues/index.js +1 -1
  281. package/dist/queues/types.d.ts +0 -8
  282. package/dist/queues/types.d.ts.map +1 -1
  283. package/dist/runtime/internal.js +23 -23
  284. package/dist/runtime/internal.js.map +1 -1
  285. package/dist/sandboxes/configuration.d.ts +4 -6
  286. package/dist/sandboxes/configuration.d.ts.map +1 -1
  287. package/dist/sandboxes/environment.d.ts.map +1 -1
  288. package/dist/sandboxes/exec.d.ts +5 -3
  289. package/dist/sandboxes/exec.d.ts.map +1 -1
  290. package/dist/sandboxes/guest-credentials.d.ts +61 -0
  291. package/dist/sandboxes/guest-credentials.d.ts.map +1 -0
  292. package/dist/sandboxes/index.d.ts +2 -0
  293. package/dist/sandboxes/index.d.ts.map +1 -1
  294. package/dist/sandboxes/index.js +23 -9
  295. package/dist/sandboxes/index.js.map +1 -1
  296. package/dist/sandboxes/sandbox.d.ts +18 -4
  297. package/dist/sandboxes/sandbox.d.ts.map +1 -1
  298. package/dist/security/internal.js +1 -1
  299. package/dist/security/internal.js.map +1 -1
  300. package/dist/shares/internal.js +17 -17
  301. package/dist/shares/internal.js.map +1 -1
  302. package/dist/storage/agents/in-memory.d.ts +3 -1
  303. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  304. package/dist/storage/agents/index.d.ts +1 -1
  305. package/dist/storage/agents/index.d.ts.map +1 -1
  306. package/dist/storage/agents/provider.d.ts +6 -0
  307. package/dist/storage/agents/provider.d.ts.map +1 -1
  308. package/dist/storage/agents/provider.js +8 -2
  309. package/dist/storage/agents/provider.js.map +1 -1
  310. package/dist/storage/agents/types.d.ts +63 -7
  311. package/dist/storage/agents/types.d.ts.map +1 -1
  312. package/dist/storage/ai-cost/provider.js +2 -2
  313. package/dist/storage/connector-connections/provider.js.map +1 -1
  314. package/dist/storage/file-upload-sessions/provider.js +9 -9
  315. package/dist/storage/index.d.ts +1 -1
  316. package/dist/storage/index.d.ts.map +1 -1
  317. package/dist/storage/index.js +15 -15
  318. package/dist/storage/ontology/provider.js +1 -1
  319. package/dist/storage/share-grants/provider.js +3 -3
  320. package/dist/storage/types.d.ts +1 -1
  321. package/dist/storage/types.d.ts.map +1 -1
  322. package/dist/storage/workflow-runs/provider.js +9 -9
  323. package/dist/syncs/index.js +20 -20
  324. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  325. package/dist/testing/index.d.ts +2 -0
  326. package/dist/testing/index.d.ts.map +1 -1
  327. package/dist/testing/index.js +677 -352
  328. package/dist/testing/index.js.map +9 -7
  329. package/dist/testing/queues-contract.d.ts.map +1 -1
  330. package/dist/testing/sandbox-credentials-contract.d.ts +27 -0
  331. package/dist/testing/sandbox-credentials-contract.d.ts.map +1 -0
  332. package/dist/testing/sandboxes-contract.d.ts.map +1 -1
  333. package/dist/testing/users.d.ts +20 -0
  334. package/dist/testing/users.d.ts.map +1 -0
  335. package/dist/users/execution.d.ts +6 -2
  336. package/dist/users/execution.d.ts.map +1 -1
  337. package/dist/users/index.d.ts +1 -1
  338. package/dist/users/index.d.ts.map +1 -1
  339. package/dist/webhooks/internal.js +17 -17
  340. package/dist/webhooks/internal.js.map +1 -1
  341. package/dist/workers/index.js.map +1 -1
  342. package/dist/workflows/index.js +41 -39
  343. package/dist/workflows/index.js.map +1 -1
  344. package/package.json +1 -1
  345. package/src/agents/README.md +136 -0
  346. package/src/agents/attachment-keys.ts +83 -0
  347. package/src/agents/cancel.ts +16 -1
  348. package/src/agents/children.ts +5 -3
  349. package/src/agents/dispatch.ts +6 -58
  350. package/src/agents/execution.ts +18 -0
  351. package/src/agents/index.ts +127 -21
  352. package/src/agents/model-loop.ts +23 -73
  353. package/src/agents/model-routing.ts +7 -2
  354. package/src/agents/request.ts +69 -20
  355. package/src/agents/run-after-finish.ts +133 -0
  356. package/src/agents/run-artifacts.ts +257 -0
  357. package/src/agents/run-events.ts +302 -0
  358. package/src/agents/run-fence.ts +71 -0
  359. package/src/agents/run-liveness.ts +122 -0
  360. package/src/agents/run-plan.ts +316 -0
  361. package/src/agents/run-session-children.ts +303 -0
  362. package/src/agents/run-session-http.ts +397 -0
  363. package/src/agents/run-session-serve.ts +479 -0
  364. package/src/agents/run-session-wire.ts +189 -0
  365. package/src/agents/run-session.ts +802 -0
  366. package/src/agents/run-token.ts +124 -0
  367. package/src/agents/run-tools.ts +180 -0
  368. package/src/agents/run-turn.ts +265 -0
  369. package/src/agents/streams/internal.ts +0 -1
  370. package/src/agents/streams/protocol.ts +0 -292
  371. package/src/agents/subagent-runs.ts +19 -1
  372. package/src/agents/tool-files.ts +225 -0
  373. package/src/agents/workflow-node-session.ts +387 -0
  374. package/src/artifacts/frames/probe.ts +14 -1
  375. package/src/artifacts/publish/index.ts +1 -0
  376. package/src/connectors/connections/authorizations.ts +3 -2
  377. package/src/connectors/connections/service.ts +5 -1
  378. package/src/connectors/connections/tokens.ts +41 -5
  379. package/src/connectors/connections/validation.ts +21 -0
  380. package/src/connectors/types.ts +12 -2
  381. package/src/deploy/types.ts +0 -2
  382. package/src/deploy/validation.ts +1 -4
  383. package/src/execution/agent.ts +2 -2
  384. package/src/execution/authorized-object-reader.ts +28 -1
  385. package/src/http/api-routes.ts +114 -27
  386. package/src/index.ts +3 -1
  387. package/src/models/execution/README.md +15 -1
  388. package/src/models/execution/errors.ts +14 -0
  389. package/src/models/execution/index.ts +2 -1
  390. package/src/models/execution/model-call-recorder.ts +12 -10
  391. package/src/models/execution.ts +9 -11
  392. package/src/models/language-call.ts +247 -0
  393. package/src/ontology/docs-markdown.ts +14 -0
  394. package/src/ontology/index.ts +1 -1
  395. package/src/ontology/user-ref.ts +40 -6
  396. package/src/projections/builders.ts +48 -4
  397. package/src/projections/index.ts +1 -0
  398. package/src/projections/registry.ts +1 -0
  399. package/src/projections/revision.ts +10 -0
  400. package/src/projections/types.ts +8 -0
  401. package/src/projections/validation.ts +52 -6
  402. package/src/queues/in-memory.ts +0 -5
  403. package/src/queues/index.ts +0 -2
  404. package/src/queues/types.ts +0 -13
  405. package/src/runtime/host.ts +1 -1
  406. package/src/sandboxes/README.md +17 -6
  407. package/src/sandboxes/configuration.ts +7 -9
  408. package/src/sandboxes/environment.ts +1 -0
  409. package/src/sandboxes/exec.ts +17 -9
  410. package/src/sandboxes/guest-credentials.ts +262 -0
  411. package/src/sandboxes/index.ts +14 -0
  412. package/src/sandboxes/sandbox.ts +19 -4
  413. package/src/storage/agents/in-memory.ts +53 -0
  414. package/src/storage/agents/index.ts +2 -0
  415. package/src/storage/agents/provider.ts +56 -11
  416. package/src/storage/agents/types.ts +59 -7
  417. package/src/storage/index.ts +2 -0
  418. package/src/storage/types.ts +1 -0
  419. package/src/testing/agent-storage-contract.ts +175 -2
  420. package/src/testing/ai-model-call-groups-contract.ts +0 -1
  421. package/src/testing/index.ts +5 -0
  422. package/src/testing/queues-contract.ts +0 -16
  423. package/src/testing/sandbox-credentials-contract.ts +284 -0
  424. package/src/testing/sandboxes-contract.ts +21 -0
  425. package/src/testing/users.ts +39 -0
  426. package/src/users/execution.ts +33 -7
  427. package/src/users/index.ts +7 -1
  428. package/dist/agents/api-gateway.d.ts +0 -26
  429. package/dist/agents/api-gateway.d.ts.map +0 -1
  430. package/dist/chunk-2x19q6k6.js.map +0 -17
  431. package/dist/chunk-4y26vs3v.js.map +0 -10
  432. package/dist/chunk-661ezhks.js.map +0 -11
  433. package/dist/chunk-d2m879s4.js.map +0 -12
  434. package/dist/chunk-n9w3n38q.js.map +0 -23
  435. package/dist/chunk-nydf3dbe.js.map +0 -13
  436. package/dist/chunk-nzapm6p0.js.map +0 -12
  437. package/dist/chunk-r6szek0x.js.map +0 -10
  438. package/dist/chunk-vabga7fk.js +0 -176
  439. package/dist/chunk-vabga7fk.js.map +0 -12
  440. package/dist/chunk-vpgwq5nf.js +0 -810
  441. package/dist/chunk-vpgwq5nf.js.map +0 -21
  442. package/src/agents/api-gateway.ts +0 -68
  443. /package/dist/{chunk-2gjj5dx3.js.map → chunk-78ymxrn0.js.map} +0 -0
  444. /package/dist/{chunk-6n69k945.js.map → chunk-8mb7mt8n.js.map} +0 -0
  445. /package/dist/{chunk-m36fw8ft.js.map → chunk-8wsjr52f.js.map} +0 -0
  446. /package/dist/{chunk-bab05bhg.js.map → chunk-dgtd0836.js.map} +0 -0
  447. /package/dist/{chunk-7ny9mjgm.js.map → chunk-ft3w5ahs.js.map} +0 -0
  448. /package/dist/{chunk-1t6k1avb.js.map → chunk-tnhqtfea.js.map} +0 -0
@@ -0,0 +1,18 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/models/execution/model-call-admission.ts", "../src/models/execution/errors.ts", "../src/models/language-call.ts", "../src/models/execution/model-call-accounting.ts", "../src/models/execution/model-call-limits.ts", "../src/models/execution/model-call-recorder.ts", "../src/models/execution/usage.ts", "../src/models/execution/model-call-recovery.ts", "../src/models/execution/recovery-queue.ts"],
4
+ "sourcesContent": [
5
+ "import type { AiModelCallReservationIdentity } from \"../../storage\"\nimport type { ModelKind } from \"../definitions\"\nimport type { ModelCostEstimator, ModelMoney } from \"../pricing\"\n\n/** Default output ceiling when a call and its resolved model supply no limit. */\nexport const AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE = 4_096\n\nexport type AiModelCallInputTokenEstimate =\n | {\n readonly status: \"estimated\"\n readonly tokens: number\n readonly method: \"utf8BytesDividedByFour\"\n }\n | {\n readonly status: \"unavailable\"\n readonly reason: \"nonTextInput\" | \"unserializableInput\"\n }\n\n/** Provider-neutral snapshot passed to aggregate-budget admission before a provider request. */\nexport interface AiModelCallAdmissionInput {\n readonly projectId: string\n readonly executionId: string\n readonly attempt: number\n readonly requesterGroupIds: readonly string[]\n readonly callId: string\n readonly providerId: string\n readonly modelId: string\n /** Selects the applicable limit meters; transcription and reranking skip token limits. */\n readonly modelKind?: ModelKind\n readonly costEstimator?: ModelCostEstimator\n /** A non-token estimate, computed by the resolved binding before inference. */\n readonly reservationCost?: ModelMoney\n readonly inputTokens: AiModelCallInputTokenEstimate\n readonly outputTokenAllowance: number\n readonly estimatedTotalTokens?: number\n}\n\nexport interface AiModelCallAdmissionDecision {\n /** Active means accounting must reconcile the reservation for this provider attempt. */\n readonly reservation: \"active\" | \"none\"\n}\n\nexport type BeforeAiModelCall = (\n input: AiModelCallAdmissionInput\n) => AiModelCallAdmissionDecision | Promise<AiModelCallAdmissionDecision>\n\nexport type MarkAiModelCallUnknown = (input: AiModelCallReservationIdentity) => void | Promise<void>\n\n/**\n * Estimate the exact, prepared provider request without requiring a provider-specific tokenizer.\n *\n * The heuristic is intentionally explicit so reservations are reproducible. Non-text inputs are\n * reported as unavailable; an enforced token or cost policy can then fail closed instead of\n * pretending that an image, file, or provider-defined payload has no token cost.\n */\nexport function estimateAiModelCallInputTokens(input: {\n readonly prompt: unknown\n readonly tools: unknown\n readonly responseFormat: unknown\n}): AiModelCallInputTokenEstimate {\n if (containsNonTextInput(input.prompt)) {\n return { status: \"unavailable\", reason: \"nonTextInput\" }\n }\n\n let serialized: string | undefined\n try {\n serialized = JSON.stringify(input)\n } catch {\n return { status: \"unavailable\", reason: \"unserializableInput\" }\n }\n if (serialized === undefined) {\n return { status: \"unavailable\", reason: \"unserializableInput\" }\n }\n\n const bytes = new TextEncoder().encode(serialized).byteLength\n return {\n status: \"estimated\",\n tokens: Math.ceil(bytes / 4),\n method: \"utf8BytesDividedByFour\",\n }\n}\n\nexport function aiModelCallOutputTokenAllowance(maxOutputTokens: number | undefined): number {\n if (maxOutputTokens === undefined) return AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE\n if (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens <= 0) {\n throw new TypeError(\n \"[SixbModels] AI model-call maxOutputTokens must be a positive safe integer.\"\n )\n }\n return maxOutputTokens\n}\n\nexport function estimatedAiModelCallTotalTokens(\n inputTokens: AiModelCallInputTokenEstimate,\n outputTokenAllowance: number\n): number | undefined {\n if (inputTokens.status !== \"estimated\") return undefined\n const total = inputTokens.tokens + outputTokenAllowance\n if (!Number.isSafeInteger(total)) {\n throw new TypeError(\"[SixbModels] AI model-call token estimate exceeds the safe range.\")\n }\n return total\n}\n\nfunction containsNonTextInput(value: unknown, seen = new WeakSet<object>()): boolean {\n if (value === null || typeof value !== \"object\") return false\n if (\n value instanceof URL ||\n value instanceof ArrayBuffer ||\n ArrayBuffer.isView(value) ||\n (typeof Blob !== \"undefined\" && value instanceof Blob)\n ) {\n return true\n }\n if (seen.has(value)) return false\n seen.add(value)\n\n if (!Array.isArray(value)) {\n const type = Reflect.get(value, \"type\")\n if (\n type === \"image\" ||\n type === \"file\" ||\n type === \"reasoning-file\" ||\n type === \"custom\" ||\n type === \"provider-state\"\n ) {\n return true\n }\n }\n\n return Object.values(value).some((entry) => containsNonTextInput(entry, seen))\n}\n",
6
+ "import { isSixbError } from \"../../errors/internal\"\n\n/** A provider call was not recorded synchronously, so its execution must stop. */\nexport class ModelUsageRecordingError extends Error {\n readonly name = \"ModelUsageRecordingError\"\n\n constructor(\n readonly executionId: string,\n readonly callId: string,\n readonly recoveryScheduled: boolean,\n options?: ErrorOptions\n ) {\n super(\n recoveryScheduled\n ? `[SixbModels] AI usage for call '${callId}' in execution '${executionId}' was deferred to durable recovery.`\n : `[SixbModels] Could not preserve AI usage for call '${callId}' in execution '${executionId}'.`,\n options\n )\n }\n}\n\n/**\n * A model call refused or left unrecorded by the run's accounting: its AI limits refused it, or its\n * record could not be written. The run ends with this failure, never one that relabels it.\n */\nexport function isModelCallAccountingFailure(error: unknown): boolean {\n return (\n error instanceof ModelUsageRecordingError ||\n (isSixbError(error) &&\n (error.code === \"ai.usage_limit_exceeded\" || error.code === \"ai.usage_limit_unavailable\"))\n )\n}\n",
7
+ "import { ModelStreamError } from \"./errors\"\nimport type {\n LanguageModelStreamEvent,\n ModelCallEndEvent,\n ModelProviderIds,\n ModelRoute,\n ModelUsage,\n} from \"./events\"\nimport type {\n LanguageModel,\n LanguageModelRequest,\n LanguageModelStream,\n ModelReasoning,\n} from \"./language-model\"\nimport {\n estimateModelCall,\n type ModelCallCost,\n type ModelReportedCost,\n rateModelCall,\n} from \"./pricing\"\n\n/**\n * What a language model call's stream says about the call: who served it, what it used and what\n * the provider charged. Only its `finish` event settles the meters, so a call that ends without one\n * is recorded with its usage unknown.\n */\nexport class LanguageModelCallMeter {\n private usage: ModelUsage = {}\n private responseId: string | undefined\n private providerIds: ModelProviderIds | undefined\n private responseModelId: string | undefined\n private reportedCost: ModelReportedCost | undefined\n private route: ModelRoute | undefined\n private settled = false\n\n /** Whether the stream finished, so its meters are final. */\n get finished(): boolean {\n return this.settled\n }\n\n accept(event: LanguageModelStreamEvent): void {\n if (event.type === \"response-metadata\") {\n this.responseId = event.id ?? this.responseId\n if (event.providerIds) this.providerIds = { ...this.providerIds, ...event.providerIds }\n this.responseModelId = event.modelId ?? this.responseModelId\n } else if (event.type === \"finish\") {\n this.settled = true\n this.usage = event.usage\n this.reportedCost = event.reportedCost\n this.route = event.route\n }\n }\n\n /** The meters as the stream reported them. */\n facts() {\n return {\n usage: this.usage,\n ...(this.responseId === undefined ? {} : { responseId: this.responseId }),\n ...(this.providerIds === undefined ? {} : { providerIds: this.providerIds }),\n ...(this.responseModelId === undefined ? {} : { responseModelId: this.responseModelId }),\n ...(this.reportedCost === undefined ? {} : { reportedCost: this.reportedCost }),\n ...(this.route === undefined ? {} : { route: this.route }),\n }\n }\n\n /**\n * How the call ended, as it is recorded: rated from the provider's charge when it reported one,\n * else estimated from the model's rate card. An unfinished call's usage stays unknown, never free.\n */\n end(call: {\n readonly model: Pick<LanguageModel, \"providerId\" | \"modelId\" | \"costEstimator\">\n readonly callId: string\n readonly requestedReasoning?: ModelReasoning\n }): ModelCallEndEvent {\n const facts = this.facts()\n const estimate: ModelCallCost = this.settled\n ? estimateModelCall(call.model, facts)\n : { status: \"unpriceable\", reason: \"missing-usage\" }\n const cost = facts.reportedCost\n ? rateModelCall({ usage: facts.usage, reported: facts.reportedCost })\n : estimate\n return {\n callId: call.callId,\n modelKind: \"language\",\n providerId: call.model.providerId,\n modelId: call.model.modelId,\n responseId: facts.responseId ?? `${call.callId}:response`,\n providerIds: facts.providerIds,\n responseModelId: facts.responseModelId,\n usage: facts.usage,\n cost,\n ...(facts.reportedCost === undefined ? {} : { estimate }),\n ...(call.requestedReasoning === undefined\n ? {}\n : { requestedReasoning: call.requestedReasoning }),\n ...(facts.route === undefined ? {} : { route: facts.route }),\n }\n }\n}\n\n/**\n * A call whose provider sends nothing for this long fails, its usage recorded unknown. A model\n * thinking at length still streams: providers keep a reasoning stream alive with events.\n */\nexport const MODEL_CALL_IDLE_MS = 10 * 60_000\n\n/**\n * The model, with each call it makes reported once as it ends: when it finishes, before its\n * `finish` event reaches the reader, or however it ends instead, its usage then unknown: failed,\n * silent past {@link MODEL_CALL_IDLE_MS}, or let go by its reader, even before its first event. A\n * call is reported by the model that served it, never by whoever reads its stream.\n */\nexport function reportModelCalls(\n model: LanguageModel,\n onEnd: (event: ModelCallEndEvent) => void | Promise<void>\n): LanguageModel {\n const { providerId, modelId, definition, costEstimator, rateCard } = model\n const { defaultReasoning, maxOutputTokens } = model\n // Read and bound once: a provider's model keeps its state in private fields.\n return {\n providerId,\n modelId,\n definition,\n ...(costEstimator === undefined ? {} : { costEstimator }),\n ...(rateCard === undefined ? {} : { rateCard }),\n ...(defaultReasoning === undefined ? {} : { defaultReasoning }),\n ...(maxOutputTokens === undefined ? {} : { maxOutputTokens }),\n ...(model.validateResponseFormat === undefined\n ? {}\n : { validateResponseFormat: model.validateResponseFormat.bind(model) }),\n stream: async (request) => {\n // Aborted once the provider goes silent, or the reader lets the call go.\n const stop = new AbortController()\n const opening = model.stream({\n ...request,\n signal: AbortSignal.any([request.signal, stop.signal]),\n })\n // A response that never comes is not a call: nothing was accepted, so nothing is reported.\n const opened = await withinIdle(opening, stop, (late) => closeEvents(late.events))\n return { ...opened, events: reportedEvents(model, request, opened, stop, onEnd) }\n },\n }\n}\n\nfunction reportedEvents(\n model: LanguageModel,\n request: LanguageModelRequest,\n stream: LanguageModelStream,\n stop: AbortController,\n onEnd: (event: ModelCallEndEvent) => void | Promise<void>\n): AsyncIterable<LanguageModelStreamEvent> {\n const meter = new LanguageModelCallMeter()\n let reported: Promise<void> | undefined\n // Once accepted, a call is reported exactly once, however it ends.\n const report = () => {\n reported ??= (async () =>\n onEnd(\n meter.end({\n model,\n callId: request.callId,\n ...(request.reasoning === undefined ? {} : { requestedReasoning: request.reasoning }),\n })\n ))()\n return reported\n }\n let source: AsyncIterator<LanguageModelStreamEvent> | undefined\n let done = false\n\n // An iterator of its own, not a generator: a generator's `finally` never runs for a reader that\n // lets go before its first `next()`, so that call would go unreported.\n const events: AsyncIterator<LanguageModelStreamEvent> = {\n async next() {\n if (done) return { done: true, value: undefined }\n source ??= stream.events[Symbol.asyncIterator]()\n let result: IteratorResult<LanguageModelStreamEvent>\n try {\n result = await withinIdle(source.next(), stop)\n } catch (error) {\n done = true\n if (stop.signal.aborted) closeEvents(source)\n await report()\n throw error\n }\n if (result.done) {\n done = true\n await report()\n return result\n }\n meter.accept(result.value)\n if (result.value.type === \"finish\") await report()\n return result\n },\n async return(value) {\n done = true\n if (!reported) stop.abort(new DOMException(\"The reader let the model call go.\", \"AbortError\"))\n if (source) closeEvents(source)\n else closeEvents(stream.events)\n try {\n await report()\n } catch (error) {\n // Thrown to a reader that broke off, but lost on one that threw: say it here too.\n console.error(\n `[SixbModels] Model call '${request.callId}' ended early, and recording it failed.`,\n error\n )\n throw error\n }\n return { done: true, value }\n },\n }\n return { [Symbol.asyncIterator]: () => events }\n}\n\n/** Settle with `pending`, or fail once the provider has been silent for {@link MODEL_CALL_IDLE_MS}. */\nasync function withinIdle<T>(\n pending: Promise<T>,\n stop: AbortController,\n onLate?: (value: T) => void\n): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined\n const silence = new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const error = new ModelStreamError(\n `[SixbModels] The model sent nothing for ${MODEL_CALL_IDLE_MS / 60_000} minutes.`\n )\n // A provider that honors its signal stops; one that does not is left behind.\n stop.abort(error)\n reject(error)\n }, MODEL_CALL_IDLE_MS)\n })\n try {\n return await Promise.race([pending, silence])\n } finally {\n clearTimeout(timer)\n if (stop.signal.aborted) pending.then(onLate, () => {})\n }\n}\n\n/** Close a provider's stream without waiting on it: one that ignores its signal may never settle. */\nfunction closeEvents(\n events: AsyncIterable<LanguageModelStreamEvent> | AsyncIterator<LanguageModelStreamEvent>\n): void {\n const iterator = Symbol.asyncIterator in events ? events[Symbol.asyncIterator]() : events\n void Promise.resolve()\n .then(() => iterator.return?.())\n .catch(() => {})\n}\n",
8
+ "import { createHash } from \"node:crypto\"\nimport { assertJsonObject } from \"../../json\"\nimport type {\n AiBillableMeter,\n AiCostStorage,\n AiLimitStorage,\n AiModelCallCostRecord,\n AiModelCallUsageRecord,\n AiPricingContext,\n AiUsageStorage,\n RecordAiModelCallResult,\n Storage,\n} from \"../../storage\"\nimport {\n aiModelCallCostMatchesUsage,\n normalizeAiModelCallCostRecord,\n} from \"../../storage/ai-cost/provider\"\nimport { normalizeAiModelCallRecord } from \"../../storage/ai-usage/record\"\nimport type { ModelCostEstimate } from \"../pricing\"\nimport type { ModelCallAccountingStorage, RecoverAiModelCallInput } from \"./types\"\n\ninterface RecordAiModelCallAccountingInput extends RecoverAiModelCallInput {\n readonly storage: Pick<ModelCallAccountingStorage, \"transaction\">\n}\n\ninterface AiAccountingCapabilities {\n readonly aiUsage: AiUsageStorage\n readonly aiCosts: AiCostStorage\n readonly aiLimits: AiLimitStorage\n}\n\n/** Atomically append one provider call's usage and the valuation captured by the model runtime. */\nexport async function recordAiModelCallAccounting(\n input: RecordAiModelCallAccountingInput\n): Promise<RecordAiModelCallResult> {\n return input.storage.transaction(async (tx) => {\n const { aiUsage, aiCosts, aiLimits } = requireAccountingCapabilities(tx)\n const usage = await aiUsage.recordModelCall(input.usage)\n // Usage deduplicates provider lifecycle replays by execution/call identity. Always attach the\n // valuation to the canonical row it returns, not the fresh candidate ID from a replay.\n const canonical = normalizeModelCallAccounting({\n ...input,\n usage: usage.record,\n ratedAt: usage.record.recordedAt,\n })\n const record = modelCostRecord(canonical, usage.record.id)\n const estimate =\n canonical.cost.status !== \"reported\" || canonical.estimate === undefined\n ? undefined\n : modelCostRecord({ ...canonical, cost: canonical.estimate }, usage.record.id)\n await aiCosts.recordModelCallCost({\n ...record,\n ...(estimate === undefined\n ? {}\n : {\n estimate:\n estimate.status === \"rated\"\n ? { status: \"rated\", money: estimate.money, components: estimate.components }\n : {\n status: \"unpriceable\",\n reason: estimate.reason,\n ...(estimate.missingMeters === undefined\n ? {}\n : { missingMeters: estimate.missingMeters }),\n },\n }),\n })\n if (usage.created) {\n await aiLimits.recordModelCallActuals({\n projectId: usage.record.projectId,\n usageRecordId: usage.record.id,\n recordedAt: input.ratedAt,\n })\n }\n if (input.reconcileLimitReservation) {\n await aiLimits.reconcileModelCall({\n projectId: usage.record.projectId,\n executionId: usage.record.executionId,\n attempt: usage.record.attempt,\n callId: usage.record.callId,\n usageRecordId: usage.record.id,\n reconciledAt: input.ratedAt,\n })\n }\n return usage\n })\n}\n\n/** Sanitize optional enrichment before either persistence or a JSON-safe recovery handoff. */\nexport function normalizeModelCallAccounting(\n input: RecoverAiModelCallInput\n): RecoverAiModelCallInput {\n const usage = normalizeAiModelCallRecord(input.usage)\n return {\n ...input,\n cost:\n input.cost.status === \"reported\" ? input.cost : validatedEstimate(input.cost, input, usage),\n ...(input.estimate === undefined\n ? {}\n : { estimate: validatedEstimate(input.estimate, input, usage) }),\n }\n}\n\nfunction validatedEstimate(\n cost: ModelCostEstimate,\n input: RecoverAiModelCallInput,\n usage: AiModelCallUsageRecord\n): ModelCostEstimate {\n try {\n assertJsonObject(cost, \"model cost estimate\")\n const record = normalizeAiModelCallCostRecord(modelCostRecord({ ...input, cost }, usage.id))\n if (!aiModelCallCostMatchesUsage(record, usage)) {\n throw new TypeError(\"Estimate quantities do not match recorded usage.\")\n }\n return structuredClone(cost)\n } catch {\n console.warn(\n \"[SixbModels] Invalid model cost estimate; preserving call usage and provider cost.\"\n )\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n}\n\nfunction modelCostRecord(\n input: RecoverAiModelCallInput,\n usageRecordId: string\n): AiModelCallCostRecord {\n const billingIdentity = {\n providerId: input.usage.providerId,\n modelId: input.usage.requestedModelId,\n }\n const pricingContext: AiPricingContext = {\n ...(input.route?.providerId === undefined ? {} : { routedProviderId: input.route.providerId }),\n ...(input.route?.modelId === undefined ? {} : { routedModelId: input.route.modelId }),\n }\n if (input.cost.status === \"reported\" || input.cost.status === \"rated\") {\n return {\n projectId: input.usage.projectId,\n usageRecordId,\n status: \"rated\",\n billingIdentity,\n pricingContext,\n priceSource: costPriceSource(input.usage, input.cost),\n money: input.cost.money,\n components: input.cost.status === \"rated\" ? input.cost.components : [],\n ratedAt: new Date(input.ratedAt),\n }\n }\n\n const reason =\n input.cost.reason === \"missing-rate-card\"\n ? \"missingRateCard\"\n : input.cost.reason === \"missing-usage\"\n ? \"missingUsageMeter\"\n : input.cost.reason === \"unsupported-pricing-dimension\"\n ? \"unsupportedPricingDimension\"\n : \"invalidUsageForFormula\"\n const missingMeters =\n reason === \"missingUsageMeter\" ? normalizeMissingMeters(input.cost.missingMeters) : undefined\n return {\n projectId: input.usage.projectId,\n usageRecordId,\n status: \"unpriceable\",\n billingIdentity,\n pricingContext,\n reason,\n ...(missingMeters === undefined ? {} : { missingMeters }),\n ratedAt: new Date(input.ratedAt),\n }\n}\n\nfunction costPriceSource(\n usage: RecoverAiModelCallInput[\"usage\"],\n cost: Extract<RecoverAiModelCallInput[\"cost\"], { status: \"reported\" | \"rated\" }>\n) {\n if (cost.status === \"reported\") {\n return {\n sourceId: \"provider-reported\",\n sourceEntryId: `${usage.providerId}/${usage.responseId}`,\n sourceVersion: \"response-v1\",\n observedAt: new Date(usage.occurredAt),\n }\n }\n const rates = cost.components.map(({ meter, rateAmountNanosPerMillion }) => ({\n meter,\n rateAmountNanosPerMillion,\n }))\n const version = createHash(\"sha256\").update(JSON.stringify(rates)).digest(\"hex\")\n return {\n sourceId: \"model-rate-card\",\n sourceEntryId: `${usage.providerId}/${usage.requestedModelId}`,\n sourceVersion: `sha256:${version}`,\n observedAt: new Date(usage.occurredAt),\n }\n}\n\nfunction normalizeMissingMeters(\n meters: Extract<RecoverAiModelCallInput[\"cost\"], { status: \"unpriceable\" }>[\"missingMeters\"]\n): readonly AiBillableMeter[] {\n const fallback: readonly AiBillableMeter[] = [\"tokens.input.total\", \"tokens.output.total\"]\n return [...new Set<AiBillableMeter>(meters ?? fallback)]\n}\n\nexport function requireAccountingCapabilities(\n storage: Pick<Storage, \"aiUsage\" | \"aiCosts\" | \"aiLimits\">\n): AiAccountingCapabilities {\n if (!storage.aiUsage || !storage.aiCosts || !storage.aiLimits) {\n throw new Error(\n \"[SixbModels] AI model-call accounting requires storage.aiUsage, storage.aiCosts, and storage.aiLimits.\"\n )\n }\n return { aiUsage: storage.aiUsage, aiCosts: storage.aiCosts, aiLimits: storage.aiLimits }\n}\n",
9
+ "import { isSixbError } from \"../../errors/internal\"\nimport type { AuthorizablePrincipal } from \"../../execution\"\nimport type {\n AiLimitPolicy,\n AiLimitQuantity,\n AiModelCallReservationIdentity,\n ReserveAiModelCallResult,\n} from \"../../storage\"\nimport {\n aiLimitSubjectsFromAttribution,\n aiUsageLimitExceededError,\n aiUsageLimitUnavailableError,\n applicableAiLimitPolicies,\n} from \"../../storage/ai-limits/enforcement\"\nimport { aiLimitMeterApplies } from \"../../storage/ai-limits/provider\"\nimport type {\n AiModelCallAdmissionDecision,\n AiModelCallAdmissionInput,\n BeforeAiModelCall,\n MarkAiModelCallUnknown,\n} from \"./model-call-admission\"\nimport type { ModelCallAccountingStorage } from \"./types\"\n\nexport interface AiModelCallLimitController {\n readonly beforeModelCall: BeforeAiModelCall\n readonly markModelCallUnknown: MarkAiModelCallUnknown\n}\n\n/** Build the reservation lifecycle for model calls from any execution. */\nexport function createAiModelCallLimitController(input: {\n readonly storage: Pick<ModelCallAccountingStorage, \"aiLimits\">\n readonly projectId: string\n readonly requestedBy?: AuthorizablePrincipal\n readonly requesterGroupIds: readonly string[]\n}): AiModelCallLimitController {\n const subjects = aiLimitSubjectsFromAttribution(input.requestedBy, input.requesterGroupIds)\n\n return {\n beforeModelCall: async (admission) => {\n let applicable: readonly AiLimitPolicy[]\n try {\n const policies = await input.storage.aiLimits.listPolicies({\n projectId: input.projectId,\n })\n applicable = applicableAiLimitPolicies(policies, subjects).filter((policy) =>\n aiLimitMeterApplies(policy.limit.meter, admission.modelKind)\n )\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n // This read is the fast no-policy path. A concurrently created policy linearizes after it;\n // every later call will see it, while existing policies always continue to atomic reserve.\n if (applicable.length === 0) return { reservation: \"none\" }\n\n const estimates = reservationEstimates(\n admission,\n applicable.some((policy) => policy.limit.meter === \"cost.catalogEstimated\")\n )\n if (estimates.length === 0) {\n throw aiUsageLimitUnavailableError([\"missingEstimate\"])\n }\n\n let result: ReserveAiModelCallResult\n try {\n result = await input.storage.aiLimits.reserveModelCall({\n ...reservationIdentity(admission),\n subjects,\n estimates,\n ...(admission.modelKind === undefined ? {} : { modelKind: admission.modelKind }),\n })\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n switch (result.status) {\n case \"reserved\":\n return { reservation: \"active\" } satisfies AiModelCallAdmissionDecision\n case \"notRequired\":\n return { reservation: \"none\" } satisfies AiModelCallAdmissionDecision\n case \"denied\":\n throw aiUsageLimitExceededError(result.resetAt)\n case \"unavailable\":\n throw aiUsageLimitUnavailableError(result.reasons)\n case \"terminal\":\n throw aiUsageLimitUnavailableError([\"terminalReservationReplay\"])\n }\n },\n markModelCallUnknown: async (identity) => {\n try {\n await input.storage.aiLimits.markReservationUnknown(identity)\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n },\n }\n}\n\nfunction reservationEstimates(\n input: AiModelCallAdmissionInput,\n needsCost: boolean\n): readonly AiLimitQuantity[] {\n const estimates: AiLimitQuantity[] = []\n if (input.inputTokens.status === \"estimated\" && input.estimatedTotalTokens !== undefined) {\n estimates.push({ meter: \"tokens.total\", amount: input.estimatedTotalTokens })\n }\n\n if (needsCost) {\n try {\n let money = input.reservationCost\n if (money == null && input.inputTokens.status === \"estimated\") {\n money = input.costEstimator?.estimateReservation?.({\n inputTokens: input.inputTokens.tokens,\n outputTokens: input.outputTokenAllowance,\n })\n }\n\n if (money) {\n estimates.push({ meter: \"cost.catalogEstimated\", amount: money })\n }\n } catch {\n // An unavailable price must not prevent a token-only policy from being evaluated.\n return estimates\n }\n }\n\n return estimates\n}\n\nfunction reservationIdentity(input: AiModelCallAdmissionInput): AiModelCallReservationIdentity {\n return {\n projectId: input.projectId,\n executionId: input.executionId,\n attempt: input.attempt,\n callId: input.callId,\n }\n}\n\nfunction limitStorageUnavailable(error: unknown): unknown {\n if (\n isSixbError(error) &&\n (error.code === \"ai.usage_limit_exceeded\" || error.code === \"ai.usage_limit_unavailable\")\n ) {\n return error\n }\n return aiUsageLimitUnavailableError([\"limitStorageUnavailable\"])\n}\n",
10
+ "import { randomUUID } from \"node:crypto\"\nimport type { FileRef } from \"../../blob-storage/types\"\nimport {\n AiUsageStorageError,\n type ReadonlyJsonObject,\n type RecordAiModelCallInput,\n} from \"../../storage\"\nimport type { ModelCallEndEvent, ModelUsage } from \"../events\"\nimport { reportModelCalls } from \"../language-call\"\nimport type { LanguageModel } from \"../language-model\"\nimport { ModelUsageRecordingError } from \"./errors\"\nimport {\n normalizeModelCallAccounting,\n recordAiModelCallAccounting,\n requireAccountingCapabilities,\n} from \"./model-call-accounting\"\nimport {\n type AiModelCallAdmissionInput,\n aiModelCallOutputTokenAllowance,\n estimateAiModelCallInputTokens,\n estimatedAiModelCallTotalTokens,\n} from \"./model-call-admission\"\nimport type { AiModelCallLimitController } from \"./model-call-limits\"\nimport { isPermanentAiUsageRecoveryError } from \"./model-call-recovery\"\nimport type {\n ModelCallAccountingStorage,\n RecoverAiModelCall,\n RecoverAiModelCallInput,\n} from \"./types\"\nimport { aiModelCallUsageFromModel } from \"./usage\"\n\nconst STORAGE_RETRY_DELAYS_MS = [50, 200, 600] as const\n\nexport interface AiModelCallRecorderInput {\n readonly storage: ModelCallAccountingStorage\n readonly projectId: string\n readonly executionId: string\n readonly attempt: number\n readonly requesterGroupIds: readonly string[]\n readonly limits: AiModelCallLimitController\n readonly recoverAiModelCall: RecoverAiModelCall\n}\n\ninterface AiModelCallRecorderInternals {\n readonly generateId?: () => string\n readonly now?: () => Date\n readonly retryDelaysMs?: readonly number[]\n readonly sleep?: (ms: number) => Promise<void>\n readonly recordAccounting?: (input: RecoverAiModelCallInput) => Promise<void>\n}\n\n/** Admit every model call against the execution's limits, and record each before it is over. */\nexport class AiModelCallRecorder {\n private readonly generateId: () => string\n private readonly now: () => Date\n private readonly retryDelaysMs: readonly number[]\n private readonly sleep: (ms: number) => Promise<void>\n private readonly recordAccounting: (input: RecoverAiModelCallInput) => Promise<void>\n private readonly reservations = new Set<string>()\n private admissionError: unknown\n private recordingError: ModelUsageRecordingError | undefined\n\n constructor(\n private readonly input: AiModelCallRecorderInput,\n internals: AiModelCallRecorderInternals = {}\n ) {\n requireAccountingCapabilities(input.storage)\n this.generateId = internals.generateId ?? (() => `ai_usage_${randomUUID()}`)\n this.now = internals.now ?? (() => new Date())\n this.retryDelaysMs = internals.retryDelaysMs ?? STORAGE_RETRY_DELAYS_MS\n this.sleep = internals.sleep ?? sleep\n this.recordAccounting =\n internals.recordAccounting ??\n (async (recovery) => {\n await recordAiModelCallAccounting({ storage: this.input.storage, ...recovery })\n })\n }\n\n /** The execution every call this recorder admits is attributed to. */\n get executionId(): string {\n return this.input.executionId\n }\n\n /** The execution attempt every call this recorder admits is attributed to. */\n get attempt(): number {\n return this.input.attempt\n }\n\n /**\n * Wrap the resolved model so every call it makes is admitted against the execution's limits and\n * records itself: the wrapper reads the stream it hands on, and records the call when it finishes,\n * before its `finish` event reaches the reader, or when it ends otherwise, its usage unknown. Who\n * reads the stream never reports what the call used.\n */\n wrapModel(model: LanguageModel): LanguageModel {\n const recorded = reportModelCalls(model, this.onModelCallEnd)\n // Its settings carried over, which whoever calls the model reads.\n return {\n ...recorded,\n stream: async (request) => {\n this.assertHealthy()\n const inputTokens = estimateAiModelCallInputTokens({\n prompt: request.messages,\n tools: request.tools,\n responseFormat: request.responseFormat,\n })\n const outputTokenAllowance = aiModelCallOutputTokenAllowance(request.maxOutputTokens)\n await this.admitCall({\n callId: request.callId,\n providerId: model.providerId,\n modelId: model.modelId,\n costEstimator: model.costEstimator,\n inputTokens,\n outputTokenAllowance,\n estimatedTotalTokens: estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance),\n })\n try {\n return await recorded.stream(request)\n } catch (error) {\n await this.markCallUnknown(request.callId)\n throw error\n }\n },\n }\n }\n\n /** Admit one provider attempt, independently of its language or embedding protocol. */\n async admitCall(\n call: Omit<\n AiModelCallAdmissionInput,\n \"projectId\" | \"executionId\" | \"attempt\" | \"requesterGroupIds\"\n >\n ): Promise<void> {\n this.assertHealthy()\n try {\n const decision = await this.input.limits.beforeModelCall({\n ...call,\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n requesterGroupIds: this.input.requesterGroupIds,\n })\n if (decision.reservation === \"active\") this.reservations.add(call.callId)\n } catch (error) {\n // Execution boundaries must retain the original coded admission failure.\n this.admissionError = error\n throw error\n }\n }\n\n /** Keep an unresolved reservation when an attempted call's billable outcome is unknown. */\n private async markCallUnknown(callId: string): Promise<void> {\n if (!this.reservations.has(callId)) return\n await this.input.limits.markModelCallUnknown({\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n callId,\n })\n }\n\n readonly onModelCallEnd = async (event: ModelCallEndEvent): Promise<void> => {\n // Calls already in flight still need their own accounting after another call fails.\n // Only admission is gated by the execution's sticky failure.\n try {\n const occurredAt = this.now()\n const record: RecordAiModelCallInput = {\n id: this.generateId(),\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n callId: event.callId,\n requesterGroupIds: this.input.requesterGroupIds,\n providerId: event.providerId,\n ...(event.providerIds === undefined ? {} : { providerIds: event.providerIds }),\n requestedModelId: event.modelId,\n ...(event.modelKind === undefined ? {} : { modelKind: event.modelKind }),\n ...(event.requestedReasoning === undefined\n ? {}\n : { requestedReasoning: event.requestedReasoning }),\n ...(event.responseModelId === undefined ? {} : { responseModelId: event.responseModelId }),\n responseId: event.responseId,\n usage: aiModelCallUsageFromModel(event.usage),\n ...(event.usage.raw === undefined ? {} : { rawUsage: rawUsage(event.usage) }),\n occurredAt,\n }\n const recoveryInput = normalizeModelCallAccounting({\n usage: record,\n cost: event.cost,\n ...(event.estimate === undefined ? {} : { estimate: event.estimate }),\n ...(event.route === undefined ? {} : { route: event.route }),\n ratedAt: new Date(occurredAt),\n ...(this.reservations.has(event.callId) ? { reconcileLimitReservation: true } : {}),\n })\n\n try {\n await retryOperation(\n () => this.recordAccounting(recoveryInput),\n this.retryDelaysMs,\n this.sleep,\n (error) => !isPermanentAiUsageRecoveryError(error)\n )\n } catch (storageError) {\n if (isPermanentAiUsageRecoveryError(storageError)) throw storageError\n\n try {\n await retryOperation(\n () => this.input.recoverAiModelCall(recoveryInput),\n this.retryDelaysMs,\n this.sleep,\n (error) => !isPermanentAiUsageRecoveryError(error)\n )\n } catch (recoveryError) {\n throw new AggregateError(\n [storageError, recoveryError],\n \"Direct AI accounting and durable recovery both failed.\"\n )\n }\n throw new ModelUsageRecordingError(this.input.executionId, event.callId, true, {\n cause: storageError,\n })\n }\n } catch (error) {\n const recordingError =\n error instanceof ModelUsageRecordingError\n ? error\n : new ModelUsageRecordingError(this.input.executionId, event.callId, false, {\n cause: error,\n })\n this.recordingError ??= recordingError\n throw recordingError\n }\n }\n\n /** Record the files a completed call produced; the call's readers download them through it. */\n async recordFiles(callId: string, files: readonly FileRef[]): Promise<void> {\n try {\n await retryOperation(\n () =>\n this.input.storage.aiUsage.recordModelCallFiles({\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n callId,\n files,\n }),\n this.retryDelaysMs,\n this.sleep,\n (error) => !(error instanceof TypeError || error instanceof AiUsageStorageError)\n )\n } catch (error) {\n throw new Error(\n `[SixbModels] Model call '${callId}' completed, but its files could not be recorded.`,\n { cause: error }\n )\n }\n }\n\n assertHealthy(): void {\n if (this.admissionError !== undefined) throw this.admissionError\n if (this.recordingError) throw this.recordingError\n }\n}\n\nfunction rawUsage(usage: ModelUsage): ReadonlyJsonObject {\n return structuredClone(usage.raw ?? {})\n}\n\nasync function retryOperation<TResult>(\n operation: () => Promise<TResult>,\n retryDelaysMs: readonly number[],\n wait: (ms: number) => Promise<void>,\n shouldRetry: (error: unknown) => boolean\n): Promise<TResult> {\n for (let attempt = 0; ; attempt += 1) {\n try {\n return await operation()\n } catch (error) {\n if (!shouldRetry(error)) throw error\n const delay = retryDelaysMs[attempt]\n if (delay === undefined) throw error\n await wait(delay)\n }\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n",
11
+ "import type { AiModelCallUsageInput } from \"../../storage\"\nimport type { ModelUsage } from \"../events\"\n\n/** Map one provider-neutral model call into Sixb's durable accounting vocabulary. */\nexport function aiModelCallUsageFromModel(usage: ModelUsage): AiModelCallUsageInput {\n return {\n ...(usage.audioDurationMs === undefined ? {} : { audioDurationMs: usage.audioDurationMs }),\n ...(usage.inputTokens === undefined ? {} : { inputTokens: usage.inputTokens }),\n ...(usage.outputTokens === undefined ? {} : { outputTokens: usage.outputTokens }),\n ...(usage.uncachedInputTokens === undefined\n ? {}\n : { uncachedInputTokens: usage.uncachedInputTokens }),\n ...(usage.cacheReadInputTokens === undefined\n ? {}\n : { cacheReadInputTokens: usage.cacheReadInputTokens }),\n ...(usage.cacheWriteInputTokens === undefined\n ? {}\n : { cacheWriteInputTokens: usage.cacheWriteInputTokens }),\n ...(usage.textOutputTokens === undefined ? {} : { textOutputTokens: usage.textOutputTokens }),\n ...(usage.reasoningOutputTokens === undefined\n ? {}\n : { reasoningOutputTokens: usage.reasoningOutputTokens }),\n ...(usage.imageOutputTokens === undefined\n ? {}\n : { imageOutputTokens: usage.imageOutputTokens }),\n ...(usage.audioOutputTokens === undefined\n ? {}\n : { audioOutputTokens: usage.audioOutputTokens }),\n ...(usage.outputImages === undefined ? {} : { outputImages: usage.outputImages }),\n ...(usage.inputCharacters === undefined ? {} : { inputCharacters: usage.inputCharacters }),\n }\n}\n",
12
+ "import type { RecordAiModelCallInput, RecordAiModelCallResult } from \"../../storage\"\nimport { AiCostStorageError, AiLimitStorageError, AiUsageStorageError } from \"../../storage\"\nimport { normalizeAiModelCallRecord } from \"../../storage/ai-usage/record\"\nimport { recordAiModelCallAccounting } from \"./model-call-accounting\"\nimport type {\n AiModelCallAccountingPayload,\n AiModelCallRecordPayload,\n AiModelCallRecoveryRecord,\n ModelCallAccountingStorage,\n RecoverAiModelCallInput,\n} from \"./types\"\nimport { aiModelCallUsageFromModel } from \"./usage\"\n\nclass InvalidAiUsageRecoveryJobError extends Error {\n readonly name = \"InvalidAiUsageRecoveryJobError\"\n\n constructor(message: string, options?: ErrorOptions) {\n super(`[SixbModels] ${message}`, options)\n }\n}\n\n/** Encode one failed accounting transaction for a durable, JSON-safe handoff. */\nexport function modelCallRecoveryPayload(input: RecoverAiModelCallInput): {\n readonly record: AiModelCallRecordPayload\n readonly accounting: AiModelCallAccountingPayload\n} {\n normalizeAiModelCallRecord(input.usage)\n return {\n record: toQueuePayload(input.usage),\n accounting: toAccountingPayload(input),\n }\n}\n\n/** Replay one durable handoff through the idempotent atomic accounting boundary. */\nexport async function recordRecoveredAiModelCall(\n storage: Pick<ModelCallAccountingStorage, \"transaction\">,\n job: AiModelCallRecoveryRecord\n): Promise<RecordAiModelCallResult> {\n const usage = fromQueuePayload(job)\n const accounting = accountingFromQueuePayload(job)\n return recordAiModelCallAccounting({ storage, usage, ...accounting })\n}\n\n/** Validation and referential-integrity failures cannot become valid through queue redelivery. */\nexport function isPermanentAiUsageRecoveryError(error: unknown): boolean {\n return (\n error instanceof InvalidAiUsageRecoveryJobError ||\n error instanceof TypeError ||\n (error instanceof AiUsageStorageError &&\n (error.code === \"duplicate_id\" || error.code === \"missing_execution\")) ||\n (error instanceof AiCostStorageError &&\n (error.code === \"missing_usage\" || error.code === \"cost_mismatch\")) ||\n (error instanceof AiLimitStorageError &&\n (error.code === \"missing_execution\" ||\n error.code === \"missing_reservation\" ||\n error.code === \"missing_usage_record\" ||\n error.code === \"usage_mismatch\" ||\n error.code === \"reservation_conflict\" ||\n error.code === \"reconciliation_conflict\" ||\n error.code === \"invalid_reservation_state\"))\n )\n}\n\nfunction toQueuePayload(record: RecordAiModelCallInput): AiModelCallRecordPayload {\n return {\n id: record.id,\n executionId: record.executionId,\n attempt: record.attempt,\n callId: record.callId,\n requesterGroupIds: [...record.requesterGroupIds],\n providerId: record.providerId,\n ...(record.providerIds === undefined\n ? {}\n : { providerIds: structuredClone(record.providerIds) }),\n requestedModelId: record.requestedModelId,\n ...(record.modelKind === undefined ? {} : { modelKind: record.modelKind }),\n ...(record.requestedReasoning === undefined\n ? {}\n : { requestedReasoning: structuredClone(record.requestedReasoning) }),\n ...(record.responseModelId === undefined ? {} : { responseModelId: record.responseModelId }),\n responseId: record.responseId,\n usage: aiModelCallUsageFromModel(record.usage),\n ...(record.rawUsage === undefined ? {} : { rawUsage: structuredClone(record.rawUsage) }),\n occurredAt: record.occurredAt.toISOString(),\n }\n}\n\nfunction toAccountingPayload(input: RecoverAiModelCallInput): AiModelCallAccountingPayload {\n return {\n cost: structuredClone(input.cost),\n ...(input.estimate === undefined ? {} : { estimate: structuredClone(input.estimate) }),\n ...(input.route === undefined ? {} : { route: structuredClone(input.route) }),\n ratedAt: input.ratedAt.toISOString(),\n ...(input.reconcileLimitReservation ? { reconcileLimitReservation: true } : {}),\n }\n}\n\nfunction fromQueuePayload(job: AiModelCallRecoveryRecord): RecordAiModelCallInput {\n const occurredAt = parseDate(job.payload.record.occurredAt, job.id, \"occurredAt\")\n return { ...job.payload.record, projectId: job.projectId, occurredAt }\n}\n\nfunction accountingFromQueuePayload(\n job: AiModelCallRecoveryRecord\n): Omit<RecoverAiModelCallInput, \"usage\"> {\n const accounting = job.payload.accounting\n return {\n cost: structuredClone(accounting.cost),\n ...(accounting.estimate === undefined\n ? {}\n : { estimate: structuredClone(accounting.estimate) }),\n ...(accounting.route === undefined ? {} : { route: structuredClone(accounting.route) }),\n ratedAt: parseDate(accounting.ratedAt, job.id, \"ratedAt\"),\n reconcileLimitReservation: accounting.reconcileLimitReservation === true,\n }\n}\n\nfunction parseDate(value: string, jobId: string, field: string): Date {\n const date = new Date(value)\n if (!Number.isFinite(date.getTime())) {\n throw new InvalidAiUsageRecoveryJobError(\n `AI usage recovery job '${jobId}' has an invalid ${field} timestamp.`\n )\n }\n return date\n}\n",
13
+ "import { createSixbError } from \"../../errors/internal\"\nimport type { AgentQueueJob, Queue } from \"../../queues\"\nimport { modelCallRecoveryPayload } from \"./model-call-recovery\"\nimport type { RecoverAiModelCallInput } from \"./types\"\n\n/** Stable queue identity: a lost enqueue response can safely retry the same accounting handoff. */\nfunction agentAiUsageRecoveryJobId(recordId: string): string {\n return `agt_usage_job_${recordId}`\n}\n\n/** Transport adapter for the agent worker's existing durable recovery lane. */\nexport async function enqueueAiModelCallRecovery(\n queue: Pick<Queue<AgentQueueJob>, \"enqueue\">,\n input: RecoverAiModelCallInput\n): Promise<void> {\n const payload = modelCallRecoveryPayload(input)\n const record = input.usage\n const jobId = agentAiUsageRecoveryJobId(record.id)\n const [job] = await queue.enqueue({\n projectId: record.projectId,\n jobs: [{ id: jobId, type: \"agent.ai-usage.record.requested\", payload }],\n })\n\n if (job?.id !== jobId || job.type !== \"agent.ai-usage.record.requested\") {\n throw createSixbError(\n \"internal.unexpected\",\n `[SixbModels] Agent queue did not confirm AI usage recovery job '${jobId}'.`,\n { details: { jobId } }\n )\n }\n}\n"
14
+ ],
15
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,IAAM,uCAAuC;AAkD7C,SAAS,8BAA8B,CAAC,OAIb;AAAA,EAChC,IAAI,qBAAqB,MAAM,MAAM,GAAG;AAAA,IACtC,OAAO,EAAE,QAAQ,eAAe,QAAQ,eAAe;AAAA,EACzD;AAAA,EAEA,IAAI;AAAA,EACJ,IAAI;AAAA,IACF,aAAa,KAAK,UAAU,KAAK;AAAA,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ACf,MAAM,UAAU,yBAAyB,KAAK;AAAA,EAC9C,MAAM,SAAS,MAAM;AAAA,EACrB,MAAM,QAAQ,0BAA0B,OAAO,EAAE;AAAA,EACjD,OAAO,OAAO,MAAM,MAAM,QAAQ;AAAA,IAChC,WAAW,OAAO;AAAA,IAClB,MAAM,CAAC,EAAE,IAAI,OAAO,MAAM,mCAAmC,QAAQ,CAAC;AAAA,EACxE,CAAC;AAAA,EAED,IAAI,KAAK,OAAO,SAAS,IAAI,SAAS,mCAAmC;AAAA,IACvE,MAAM,iBACJ,uBACA,mEAAmE,WACnE,EAAE,SAAS,EAAE,MAAM,EAAE,CACvB;AAAA,EACF;AAAA;",
16
+ "debugId": "E9009B4AC2DD257B64756E2164756E21",
17
+ "names": []
18
+ }
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "import { compareStrings, type JsonValue } from \"../json\"\nimport type { ExecutionRecord } from \"../storage/executions/types\"\nimport type {\n EventExecutor,\n OntologyMaterializationEvent,\n OntologyMaterializationEventAttribution,\n OntologyMaterializationEventCommit,\n OntologyMaterializationEventDraft,\n} from \"./events\"\nimport type { OntologyMaterializationPropertyChangeMap } from \"./model\"\n\n/** The partition key of an object's events, which the log can be read by. */\nexport function objectPartitionKey(object: {\n readonly objectTypeId: string\n readonly primaryId: string\n}): string {\n return `${object.objectTypeId}:${object.primaryId}`\n}\n\n/** Where an event sits in its commit: its id and its ordinal. */\nexport interface OntologyMaterializationEventSequence {\n readonly id: string\n readonly commitOrdinal: number\n}\n\n/**\n * The event consumers receive, rebuilt from the draft storage keeps, the commit it belongs to and\n * the execution that commit ran under. It is the exact event core would have built in one piece,\n * so storing drafts changes nothing a consumer can observe.\n */\nexport function materializationEvent(\n draft: OntologyMaterializationEventDraft,\n sequence: OntologyMaterializationEventSequence,\n commit: OntologyMaterializationEventCommit,\n attribution: OntologyMaterializationEventAttribution\n): OntologyMaterializationEvent {\n const context = {\n id: sequence.id,\n schemaVersion: 1 as const,\n projectId: commit.projectId,\n occurredAt: commit.committedAt,\n correlationId: attribution.correlationId,\n origin: structuredClone(commit.origin),\n ...(attribution.requestedBy === undefined\n ? {}\n : { requestedBy: { ...attribution.requestedBy } }),\n executor: structuredClone(attribution.executor),\n commitId: commit.id,\n commitOrdinal: sequence.commitOrdinal,\n }\n switch (draft.type) {\n case \"object.created\":\n return {\n ...context,\n type: draft.type,\n topic: \"objects\",\n partitionKey: objectPartitionKey(draft.payload),\n payload: {\n ...draft.payload,\n propertyChanges: createdPropertyChanges(draft.payload.properties),\n },\n }\n case \"object.updated\":\n return {\n ...context,\n type: draft.type,\n topic: \"objects\",\n partitionKey: objectPartitionKey(draft.payload),\n payload: draft.payload,\n }\n case \"object.deleted\":\n return {\n ...context,\n type: draft.type,\n topic: \"objects\",\n partitionKey: objectPartitionKey(draft.payload),\n payload: draft.payload,\n }\n case \"link.created\":\n return {\n ...context,\n type: draft.type,\n topic: \"links\",\n partitionKey: `${draft.payload.sourceTypeId}:${draft.payload.sourceId}:${draft.payload.linkId}`,\n payload: {\n ...draft.payload,\n propertyChanges: createdPropertyChanges(draft.payload.properties ?? {}),\n },\n }\n case \"link.updated\":\n return {\n ...context,\n type: draft.type,\n topic: \"links\",\n partitionKey: `${draft.payload.sourceTypeId}:${draft.payload.sourceId}:${draft.payload.linkId}`,\n payload: draft.payload,\n }\n case \"link.deleted\":\n return {\n ...context,\n type: draft.type,\n topic: \"links\",\n partitionKey: `${draft.payload.sourceTypeId}:${draft.payload.sourceId}:${draft.payload.linkId}`,\n payload: draft.payload,\n }\n case \"telemetry.appended\":\n return {\n ...context,\n type: draft.type,\n topic: \"telemetry\",\n partitionKey: `${draft.payload.objectTypeId}:${draft.payload.objectId}:${draft.payload.propertyId}`,\n payload: draft.payload,\n }\n }\n}\n\n/**\n * What the events of a commit say about who asked for it and what wrote it, read from the\n * execution it ran under. A primitive's id lives in the execution's authority, the only place the\n * durable record keeps it.\n */\nexport function eventAttribution(\n execution: Pick<\n ExecutionRecord,\n \"id\" | \"correlationId\" | \"requestedBy\" | \"executor\" | \"authorizationRef\"\n >\n): OntologyMaterializationEventAttribution {\n const attribution = {\n correlationId: execution.correlationId,\n executor: eventExecutor(execution),\n }\n if (execution.requestedBy === undefined) return attribution\n const { type, id } = execution.requestedBy\n return { ...attribution, requestedBy: { type, id } }\n}\n\nfunction eventExecutor(\n execution: Pick<ExecutionRecord, \"id\" | \"executor\" | \"authorizationRef\">\n): EventExecutor {\n const { executor, authorizationRef } = execution\n switch (executor.type) {\n case \"request\":\n return { type: \"request\", requestId: executor.requestId }\n case \"agent\":\n return { type: \"agent\", runId: executor.runId }\n case \"kernel\":\n return { type: \"kernel\", operation: structuredClone(executor.operation) }\n case \"primitive\":\n if (\n authorizationRef.type !== \"trustedPrimitive\" ||\n authorizationRef.primitive.kind !== executor.kind ||\n authorizationRef.primitive.runId !== executor.runId\n ) {\n throw new Error(\n `[Sixb] Execution '${execution.id}' runs a primitive without that primitive's authority.`\n )\n }\n return {\n type: \"primitive\",\n kind: executor.kind,\n id: authorizationRef.primitive.id,\n runId: executor.runId,\n }\n }\n}\n\n/** A creation changes every property it sets, from nothing to its value, in key order. */\nfunction createdPropertyChanges(\n properties: Readonly<Record<string, JsonValue>>\n): OntologyMaterializationPropertyChangeMap {\n const changes: Record<string, { readonly operation: \"created\"; readonly after: JsonValue }> = {}\n for (const id of Object.keys(properties).sort(compareStrings)) {\n changes[id] = { operation: \"created\", after: properties[id] as JsonValue }\n }\n return changes\n}\n"
6
6
  ],
7
- "mappings": ";;;;;;AAYO,SAAS,kBAAkB,CAAC,QAGxB;AAAA,EACT,OAAO,GAAG,OAAO,gBAAgB,OAAO;AAAA;AAcnC,SAAS,qBAAoB,CAClC,OACA,UACA,QACA,aAC8B;AAAA,EAC9B,MAAM,UAAU;AAAA,IACd,IAAI,SAAS;AAAA,IACb,eAAe;AAAA,IACf,WAAW,OAAO;AAAA,IAClB,YAAY,OAAO;AAAA,IACnB,eAAe,YAAY;AAAA,IAC3B,QAAQ,gB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AAU;AAAA,EAC/B,OAAO,KAAK,aAAa,aAAa,EAAE,MAAM,GAAG,EAAE;AAAA;AAGrD,SAAS,aAAa,CACpB,WACe;AAAA,EACf,QAAQ,UAAU,qBAAqB;AAAA,EACvC,QAAQ,SAAS;AAAA,IACf,KAAK;AAAA,MACH,OAAO,EAAE,MAAM,WAAW,WAAW,SAAS,UAAU;AAAA,IAC1D,KAAK;AAAA,MACH,OAAO,EAAE,MAAM,SAAS,OAAO,SAAS,MAAM;AAAA,IAChD,KAAK;AAAA,MACH,OAAO,EAAE,MAAM,UAAU,WAAW,gBAAgB,SAAS,SAAS,EAAE;AAAA,IAC1E,KAAK;AAAA,MACH,IACE,iBAAiB,SAAS,sBAC1B,iBAAiB,UAAU,SAAS,SAAS,QAC7C,iBAAiB,UAAU,UAAU,SAAS,OAC9C;AAAA,QACA,MAAM,IAAI,MACR,qBAAqB,UAAU,0DACjC;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,MAAM;AAAA,QACN,MAAM,SAAS;AAAA,QACf,IAAI,iBAAiB,UAAU;AAAA,QAC/B,OAAO,SAAS;AAAA,MAClB;AAAA;AAAA;AAKN,SAAS,sBAAsB,CAC7B,YAC0C;AAAA,EAC1C,MAAM,UAAwF,CAAC;AAAA,EAC/F,WAAW,MAAM,OAAO,KAAK,UAAU,EAAE,KAAK,cAAc,GAAG;AAAA,IAC7D,QAAQ,MAAM,EAAE,WAAW,WAAW,OAAO,WAAW,IAAiB;AAAA,EAC3E;AAAA,EACA,OAAO;AAAA;",
8
8
  "debugId": "854E2A27957635C464756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "import { MaterializationConflictError } from \"./errors\"\nimport type { PinnedDatasetVersion } from \"./model\"\n\nexport type PinnedDatasetWatermarkConflict =\n | \"version-metadata-mismatch\"\n | \"older-version\"\n | \"ambiguous-version\"\n\n/**\n * Orders versions of one dataset. A projection rebound to a different dataset starts a new\n * watermark: versions of two datasets have no order, and whether a run may read that dataset is\n * decided by the registered definition, which rejects runs pinned to any other dataset.\n */\nexport function comparePinnedDatasetWatermarks(\n active: PinnedDatasetVersion,\n next: PinnedDatasetVersion\n): PinnedDatasetWatermarkConflict | null {\n if (active.datasetId !== next.datasetId) return null\n if (active.versionId === next.versionId && active.createdAt !== next.createdAt) {\n return \"version-metadata-mismatch\"\n }\n\n const activeAt = Date.parse(active.createdAt)\n const nextAt = Date.parse(next.createdAt)\n if (nextAt < activeAt) return \"older-version\"\n if (nextAt === activeAt && next.versionId !== active.versionId) return \"ambiguous-version\"\n return null\n}\n\nexport function assertPinnedDatasetWatermark(\n active: PinnedDatasetVersion,\n next: PinnedDatasetVersion,\n subject: string\n): void {\n const conflict = comparePinnedDatasetWatermarks(active, next)\n if (!conflict) return\n\n const message = pinnedDatasetWatermarkConflictMessage(conflict, subject)\n throw new MaterializationConflictError(\"projection-fence\", message)\n}\n\nfunction pinnedDatasetWatermarkConflictMessage(\n conflict: PinnedDatasetWatermarkConflict,\n subject: string\n): string {\n switch (conflict) {\n case \"version-metadata-mismatch\":\n return `${subject} reused an immutable dataset version id with different metadata.`\n case \"older-version\":\n return `${subject} dataset version is older than the active watermark.`\n case \"ambiguous-version\":\n return `${subject} dataset watermark is ambiguous.`\n }\n}\n"
6
6
  ],
7
- "mappings": ";;;;;;AAaO,SAAS,+BAA8B,CAC5C,QACA,MACuC;AAAA,EACvC,IAAI,OAAO,cAAc,KAAK;AAAA,IAAW,OAAO;AAAA,EAChD,IAAI,OAAO,cAAc,KAAK,aAAa,OAAO,cAAc,KAAK,WAAW;AAAA,IAC9E,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,KAAK,MAAM,OAAO,SAAS;AAAA,EAC5C,MAAM,SAAS,KAAK,MAAM,KAAK,SAAS;AAAA,EACxC,IAAI,SAAS;AAAA,IAAU,OAAO;AAAA,EAC9B,IAAI,WAAW,YAAY,KAAK,cAAc,OAAO;AAAA,IAAW,OAAO;AAA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AAAA,MACH,OAAO,GAAG;AAAA;AAAA;",
8
8
  "debugId": "29E6A60E8B2B90FF64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -6,7 +6,7 @@
6
6
  "import { normalizeReportedError } from \"./normalize\"\nimport type { SixbErrorContext, SixbErrorHandler } from \"./types\"\n\nconst DEFAULT_FLUSH_TIMEOUT_MS = 5_000\n\nexport interface ErrorReporter {\n report(error: unknown, context: SixbErrorContext): void\n}\n\n/** Failure-isolated, non-blocking adapter around the configured callback. */\nexport class SixbErrorReporter implements ErrorReporter {\n private readonly pending = new Set<Promise<void>>()\n\n constructor(private readonly handler?: SixbErrorHandler) {}\n\n report(error: unknown, context: SixbErrorContext): void {\n const normalizedError = normalizeReportedError(error)\n if (!this.handler) {\n reportToConsole(normalizedError, context)\n return\n }\n\n const invocation = Promise.resolve()\n .then(() => this.handler?.(normalizedError, context))\n .then(() => undefined)\n .catch((handlerError) => {\n try {\n console.error(\"[Sixb] onError handler failed:\", handlerError)\n } catch {\n // Error reporting must never escape back into framework execution.\n }\n })\n\n const tracked = invocation.finally(() => {\n this.pending.delete(tracked)\n })\n this.pending.add(tracked)\n }\n\n async flush(timeoutMs = DEFAULT_FLUSH_TIMEOUT_MS): Promise<void> {\n const deadline = Date.now() + Math.max(0, timeoutMs)\n while (this.pending.size > 0) {\n const remainingMs = deadline - Date.now()\n if (remainingMs <= 0 || !(await settleWithin([...this.pending], remainingMs))) {\n try {\n console.error(\n `[Sixb] Timed out after ${timeoutMs}ms waiting for ${this.pending.size} onError handler(s).`\n )\n } catch {\n // Error reporting must never escape back into framework shutdown.\n }\n return\n }\n }\n }\n}\n\nfunction reportToConsole(error: Error, context: SixbErrorContext): void {\n try {\n console.error(`[Sixb] Unhandled ${context.type}:`, error, context)\n } catch {\n // Error reporting must never escape back into framework execution.\n }\n}\n\nasync function settleWithin(\n promises: readonly Promise<void>[],\n timeoutMs: number\n): Promise<boolean> {\n let timeout: ReturnType<typeof setTimeout> | undefined\n try {\n return await Promise.race([\n Promise.allSettled(promises).then(() => true),\n new Promise<false>((resolve) => {\n timeout = setTimeout(() => resolve(false), timeoutMs)\n }),\n ])\n } finally {\n if (timeout) clearTimeout(timeout)\n }\n}\n",
7
7
  "import { randomUUID } from \"node:crypto\"\nimport { captureSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport type { ActionRunFailure } from \"../storage/action-runs\"\nimport type { VectorIndexingFailureCode } from \"../storage/ontology/vector-indexing\"\nimport type { ErrorReporter } from \"./reporter\"\nimport type { SixbFailedRun } from \"./types\"\n\nfunction resolveOccurredAt(occurredAt?: Date | string): string {\n if (occurredAt instanceof Date) return occurredAt.toISOString()\n return occurredAt ?? new Date().toISOString()\n}\n\nexport type ReportRunFailureInput = SixbFailedRun & {\n readonly projectId: string\n readonly attempt?: number\n}\n\nexport function reportRunFailure(\n reporter: ErrorReporter,\n error: unknown,\n input: ReportRunFailureInput\n): void {\n const occurredAt = input.failure.at\n reporter.report(error, {\n ...input,\n type: \"run.failed\",\n notificationId: `project:${input.projectId}:run:${input.runKind}:${input.run.runId}:failed:${occurredAt}`,\n occurredAt,\n })\n}\n\nexport interface ReportActionPhaseFailureInput {\n readonly projectId: string\n readonly actionId: string\n readonly runId: string\n readonly phase: \"effects\"\n readonly failure: ActionRunFailure<\"effects\">\n}\n\nexport function reportActionPhaseFailure(\n reporter: ErrorReporter,\n error: unknown,\n input: ReportActionPhaseFailureInput\n): void {\n reporter.report(error, {\n type: \"action.phase.failed\",\n notificationId: `project:${input.projectId}:action:${input.actionId}:run:${input.runId}:phase:${input.phase}:failed:${input.failure.at}`,\n projectId: input.projectId,\n occurredAt: input.failure.at,\n actionId: input.actionId,\n runId: input.runId,\n phase: input.phase,\n failure: input.failure,\n })\n}\n\nexport interface ReportEventDeliveryFailureInput {\n readonly projectId: string\n /** Exact durable failure when this delivery was persisted by the ontology outbox. */\n readonly failure?: SixbFailure<\"event.delivery_failed\">\n /** Event types that never reached subscribers. Payloads must not be passed in. */\n readonly eventTypes: readonly string[]\n readonly occurredAt?: Date | string\n /** Delivery attempts so far. Defaults to 1, which is right for a rejected emit. */\n readonly attempts?: number\n /** Envelope ids, when the events were persisted before delivery failed. */\n readonly eventIds?: readonly string[]\n /**\n * Identity of this loss, used only when nothing was persisted. Defaults to a fresh id; pass one to\n * make a report reproducible in a test.\n */\n readonly occurrenceId?: string\n}\n\n/**\n * Report that domain events were lost.\n *\n * Both delivery paths land here: the outbox dispatcher, which has persisted envelope ids and retries,\n * and a rejected `events.emit()`, which has only the types. Reporting must work for both — an earlier\n * version returned early on an empty `eventIds`, which silently dropped exactly the case this exists\n * to surface.\n *\n * Each path keys on the strongest identity it has. The outbox persisted its envelopes, so the ids plus\n * the attempt number name the loss exactly and stay stable if one report is delivered twice. A rejected\n * emit persisted nothing and is always terminal at attempt 1, so the type list alone was its whole\n * correlation — and two schedules losing `schedule.triggered` in the same broker outage are dispatched\n * concurrently, land in the same millisecond, and were therefore one notification. A timestamp does not\n * fix that; an identity does.\n */\nexport function reportEventDeliveryFailure(\n reporter: ErrorReporter,\n error: unknown,\n input: ReportEventDeliveryFailureInput\n): void {\n const occurredAt = input.failure?.at ?? resolveOccurredAt(input.occurredAt)\n const attempts = input.attempts ?? 1\n const eventIds = input.eventIds === undefined ? undefined : [...input.eventIds].sort()\n const eventTypes = [...input.eventTypes]\n const failure =\n input.failure ??\n captureSixbFailure(error, {\n allowedCodes: [\"event.delivery_failed\"],\n defaultCode: \"event.delivery_failed\",\n details: {\n attempts,\n eventTypes,\n ...(eventIds === undefined ? {} : { eventIds }),\n },\n at: new Date(occurredAt),\n })\n const firstEventId = eventIds?.[0]\n const occurrence = firstEventId\n ? `events:${firstEventId}:attempt:${attempts}`\n : `emit:${input.occurrenceId ?? randomUUID()}`\n reporter.report(error, {\n type: \"event.delivery.failed\",\n notificationId: `project:${input.projectId}:event-delivery:${occurrence}`,\n projectId: input.projectId,\n occurredAt,\n failure,\n attempts,\n eventTypes,\n ...(eventIds === undefined ? {} : { eventIds }),\n })\n}\n\nexport interface ReportRuleEvaluationFailureInput {\n readonly projectId: string\n readonly source: \"live\" | \"reconciliation\"\n readonly eventIds?: readonly string[]\n readonly occurredAt?: Date | string\n /** Set when the failure could be attributed to one rule/subject candidate. */\n readonly ruleId?: string\n readonly subject?: { readonly objectTypeId: string; readonly primaryId: string }\n}\n\nexport function reportRuleEvaluationFailure(\n reporter: ErrorReporter,\n error: unknown,\n input: ReportRuleEvaluationFailureInput\n): void {\n const occurredAt = resolveOccurredAt(input.occurredAt)\n const eventIds = [...(input.eventIds ?? [])].sort()\n const failure = captureSixbFailure(error, {\n allowedCodes: [\"internal.unexpected\"],\n defaultCode: \"internal.unexpected\",\n details: {\n source: input.source,\n eventIds,\n ...(input.ruleId === undefined ? {} : { ruleId: input.ruleId }),\n ...(input.subject === undefined ? {} : { subject: input.subject }),\n },\n at: new Date(occurredAt),\n })\n // A candidate-level failure keys on the candidate, so two rules failing over the same batch stay\n // two notifications rather than collapsing into one.\n const occurrence =\n input.ruleId && input.subject\n ? `${input.ruleId}:${input.subject.objectTypeId}:${input.subject.primaryId}`\n : (eventIds[0] ?? \"current-state\")\n reporter.report(error, {\n type: \"rule.evaluation.failed\",\n notificationId: `project:${input.projectId}:rule-evaluation:${input.source}:${occurrence}:failed:${occurredAt}`,\n projectId: input.projectId,\n occurredAt,\n failure,\n source: input.source,\n eventIds,\n ...(input.ruleId === undefined ? {} : { ruleId: input.ruleId }),\n ...(input.subject === undefined ? {} : { subject: input.subject }),\n })\n}\n\nexport interface ReportVectorIndexingFailureInput {\n readonly projectId: string\n readonly indexingId: string\n readonly failure: SixbFailure<VectorIndexingFailureCode>\n readonly objectTypeId: string\n readonly primaryId: string\n readonly profile: string\n}\n\nexport function reportVectorIndexingFailure(\n reporter: ErrorReporter,\n error: unknown,\n input: ReportVectorIndexingFailureInput\n): void {\n reporter.report(error, {\n ...input,\n type: \"vector.indexing.failed\",\n occurredAt: input.failure.at,\n notificationId: `vector-indexing:${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O;AAAA,IACrB,MAAM;AAAA,IACN,gBAAgB,WAAW,MAAM,6BAA6B,MAAM,UAAU,qBAAqB;AAAA,IACnG,WAAW,MAAM;AAAA,IACjB;AAAA,IACA;AAAA,IACA,QAAQ,MAAM;AAAA,IACd;AAAA,OACI,MAAM,WAAW,YAAY,CAAC,IAAI,EAAE,QAAQ,MAAM,OAAO;AAAA,OACzD,MAAM,YAAY,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,QAAQ;AAAA,EAClE,CAAC;AAAA;AAYI,SAAS,4BAA2B,CACzC,UACA,OACA,OACM;AAAA,EACN,SAAS,OAAO,OAAO;AAAA,OAClB;AAAA,IACH,MAAM;AAAA,IACN,YAAY,MAAM,QAAQ;AAAA,IAC1B,gBAAgB,mBAAmB,MAAM,aAAa,MAAM;AAAA,EAC9D,CAAC;AAAA;",
10
10
  "debugId": "7DDB4B995793DF2C64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  isDatasetDefinition2
4
- } from "./chunk-c844dkwd.js";
4
+ } from "./chunk-qtzftvxa.js";
5
5
  import {
6
6
  isScheduleReference2,
7
7
  isScheduleDefinition2
@@ -6,7 +6,7 @@
6
6
  "import type { DatasetDefinition } from \"../datasets\"\nimport type { DatasetWriteMode } from \"../lake-storage\"\nimport { SQL_DIALECT } from \"../lake-storage/sql-transforms\"\nimport type { ScheduleDefinition, ScheduleReference } from \"../schedules\"\nimport { isScheduleDefinition } from \"../schedules\"\nimport { PipelineError } from \"./errors\"\nimport type {\n PipelineBuilder,\n PipelineDefinition,\n PipelineGraph,\n PipelineStepDefinition,\n PipelineStepExecutorBuilder,\n PipelineStepInputBuilder,\n PipelineStepOutputBuilder,\n PipelineStepOutputOptions,\n PipelineStepRunHandler,\n} from \"./types\"\n\nfunction assertNonEmpty(value: string, field: string): void {\n if (!value.trim()) {\n throw new PipelineError(`Pipeline ${field} must not be empty.`)\n }\n}\n\nfunction assertDataset(dataset: DatasetDefinition, field: string): void {\n assertNonEmpty(dataset.id, field)\n}\n\nfunction assertDatasetWriteMode(mode: DatasetWriteMode): void {\n if (mode !== \"snapshot\" && mode !== \"append\") {\n throw new PipelineError(`Pipeline step output mode '${mode}' is not supported.`)\n }\n}\n\nfunction assertInputs(inputs: Readonly<Record<string, DatasetDefinition>>): void {\n const entries = Object.entries(inputs)\n if (entries.length === 0) {\n throw new PipelineError(\"Pipeline step input dataset must contain at least one entry.\")\n }\n\n for (const [name, dataset] of entries) {\n assertNonEmpty(name, \"step input name\")\n assertDataset(dataset, \"step input dataset\")\n }\n}\n\nfunction scheduleReference(schedule: ScheduleDefinition): ScheduleReference {\n if (!isScheduleDefinition(schedule)) {\n throw new PipelineError(\"Pipeline .when(...) only accepts schedules.\")\n }\n return { type: \"schedule\", scheduleId: schedule.id }\n}\n\nfunction createPipelineBuilder<TId extends string>(\n definition: PipelineDefinition<TId>\n): PipelineBuilder<TId> {\n return {\n ...definition,\n when(schedule: ScheduleDefinition): PipelineBuilder<TId> {\n return createPipelineBuilder({\n ...definition,\n triggers: [...definition.triggers, scheduleReference(schedule)],\n })\n },\n // biome-ignore lint/suspicious/noThenProperty: Pipeline composition intentionally uses `.then(step)`.\n then(step: PipelineStepDefinition): PipelineBuilder<TId> {\n const graph: PipelineGraph = {\n kind: \"sequence\",\n nodes: [...definition.graph.nodes, { kind: \"step\", step }],\n }\n\n return createPipelineBuilder({\n ...definition,\n graph,\n })\n },\n }\n}\n\n/**\n * Define one dataset transform step.\n *\n * The returned definition is inert until referenced by a pipeline definition.\n */\nexport function definePipelineStep<TId extends string>(id: TId): PipelineStepInputBuilder<TId> {\n assertNonEmpty(id, \"step id\")\n\n return {\n inputs<TInputs extends Record<string, DatasetDefinition>>(\n inputs: TInputs\n ): PipelineStepOutputBuilder<TId, TInputs> {\n assertInputs(inputs)\n\n return {\n output(\n dataset: DatasetDefinition,\n options: PipelineStepOutputOptions = {}\n ): PipelineStepExecutorBuilder<TId, TInputs> {\n assertDataset(dataset, \"step output dataset\")\n const mode = options.mode ?? \"snapshot\"\n assertDatasetWriteMode(mode)\n\n return {\n run(handler): PipelineStepDefinition<TId, TInputs> {\n return {\n kind: \"pipeline.step\",\n id,\n inputs,\n output: dataset,\n mode,\n executor: {\n kind: \"run\",\n handler: handler as unknown as PipelineStepRunHandler,\n },\n }\n },\n sql(sql): PipelineStepDefinition<TId, TInputs> {\n return {\n kind: \"pipeline.step\",\n id,\n inputs,\n output: dataset,\n mode,\n executor: {\n kind: \"sql\",\n dialect: SQL_DIALECT.duckdb,\n sql,\n },\n }\n },\n }\n },\n }\n },\n }\n}\n\n/**\n * Define a sequential pipeline that composes dataset transform steps.\n *\n * The returned definition is inert and safe to export from `pipelines/` modules.\n */\nexport function definePipeline<TId extends string>(id: TId): PipelineBuilder<TId> {\n assertNonEmpty(id, \"id\")\n\n return createPipelineBuilder({\n kind: \"pipeline\",\n id,\n triggers: [],\n graph: {\n kind: \"sequence\",\n nodes: [],\n },\n })\n}\n",
7
7
  "import type { DatasetDefinition } from \"../datasets\"\nimport { isDatasetDefinition } from \"../datasets\"\nimport type {\n DatasetRow,\n DatasetVersion,\n DatasetWriteMode,\n ReadDatasetRowsInput,\n} from \"../lake-storage\"\nimport {\n isSqlDialect,\n type SqlDialect,\n type SqlTransformBody,\n} from \"../lake-storage/sql-transforms\"\nimport type { Logger } from \"../logging\"\nimport type { ScheduleDefinition, ScheduleReference } from \"../schedules\"\nimport { isScheduleReference } from \"../schedules\"\n\n// ── Step execution ─────────────────────────────────────────\n\nexport type PipelineStepExecutor =\n | {\n readonly kind: \"sql\"\n readonly dialect: SqlDialect\n readonly sql: SqlTransformBody<SqlDialect>\n }\n | {\n readonly kind: \"run\"\n readonly handler: PipelineStepRunHandler\n }\n\nexport interface PipelineStepInput {\n readonly dataset: DatasetDefinition\n readonly version: DatasetVersion\n readRows(input?: Omit<ReadDatasetRowsInput, \"datasetId\" | \"versionId\">): AsyncIterable<DatasetRow>\n}\n\nexport interface PipelineStepOutput {\n writeRows(rows: Iterable<DatasetRow> | AsyncIterable<DatasetRow>): Promise<void>\n}\n\nexport interface PipelineStepRunContext<\n TInputs extends Record<string, DatasetDefinition> = Record<string, DatasetDefinition>,\n> {\n readonly projectId: string\n readonly pipelineId: string\n readonly stepId: string\n readonly runId: string\n readonly signal: AbortSignal\n readonly inputs: { readonly [K in keyof TInputs]: PipelineStepInput }\n readonly output: PipelineStepOutput\n readonly logger: Logger\n}\n\nexport type PipelineStepRunHandler<\n TInputs extends Record<string, DatasetDefinition> = Record<string, DatasetDefinition>,\n> = (ctx: PipelineStepRunContext<TInputs>) => Promise<void> | void\n\n// ── Step definition ────────────────────────────────────────\n\nexport interface PipelineStepDefinition<\n TId extends string = string,\n TInputs extends Record<string, DatasetDefinition> = Record<string, DatasetDefinition>,\n> {\n readonly kind: \"pipeline.step\"\n readonly id: TId\n readonly inputs: Readonly<TInputs>\n readonly output: DatasetDefinition\n readonly mode: DatasetWriteMode\n readonly executor: PipelineStepExecutor\n}\n\n// ── Pipeline definition ────────────────────────────────────\n\nexport interface PipelineStepNode {\n readonly kind: \"step\"\n readonly step: PipelineStepDefinition\n}\n\nexport interface PipelineSequenceGraph {\n readonly kind: \"sequence\"\n readonly nodes: readonly PipelineStepNode[]\n}\n\nexport type PipelineGraph = PipelineSequenceGraph\n\n/**\n * Inert pipeline definition registered with Sixb.\n *\n * V1 executes a single sequential graph. The graph shape leaves room for\n * parallel nodes later without changing step definitions.\n */\nexport interface PipelineDefinition<TId extends string = string> {\n readonly kind: \"pipeline\"\n readonly id: TId\n readonly triggers: readonly ScheduleReference[]\n readonly graph: PipelineGraph\n}\n\n// ── Builder interfaces ─────────────────────────────────────\n\nexport interface PipelineStepInputBuilder<TId extends string = string> {\n inputs<TInputs extends Record<string, DatasetDefinition>>(\n inputs: TInputs\n ): PipelineStepOutputBuilder<TId, TInputs>\n}\n\nexport interface PipelineStepOutputBuilder<\n TId extends string = string,\n TInputs extends Record<string, DatasetDefinition> = Record<string, DatasetDefinition>,\n> {\n output(\n dataset: DatasetDefinition,\n options?: PipelineStepOutputOptions\n ): PipelineStepExecutorBuilder<TId, TInputs>\n}\n\nexport interface PipelineStepExecutorBuilder<\n TId extends string = string,\n TInputs extends Record<string, DatasetDefinition> = Record<string, DatasetDefinition>,\n> {\n run(handler: PipelineStepRunHandler<TInputs>): PipelineStepDefinition<TId, TInputs>\n sql(sql: SqlTransformBody<SqlDialect>): PipelineStepDefinition<TId, TInputs>\n}\n\nexport interface PipelineStepOutputOptions {\n readonly mode?: DatasetWriteMode\n}\n\nexport interface PipelineBuilder<TId extends string = string> extends PipelineDefinition<TId> {\n when(schedule: ScheduleDefinition): PipelineBuilder<TId>\n then(step: PipelineStepDefinition): PipelineBuilder<TId>\n}\n\n// ── Type guards ────────────────────────────────────────────\n\n/** Runtime type guard for values discovered from `pipelines/` modules. */\nexport function isPipelineDefinition(value: unknown): value is PipelineDefinition {\n if (!isRecord(value)) return false\n return (\n value.kind === \"pipeline\" &&\n typeof value.id === \"string\" &&\n Array.isArray(value.triggers) &&\n value.triggers.every(isScheduleReference) &&\n isPipelineGraph(value.graph)\n )\n}\n\nexport function isPipelineStepDefinition(value: unknown): value is PipelineStepDefinition {\n return (\n isRecord(value) &&\n value.kind === \"pipeline.step\" &&\n typeof value.id === \"string\" &&\n isInputsRecord(value.inputs) &&\n isDatasetDefinition(value.output) &&\n isDatasetWriteMode(value.mode) &&\n isPipelineStepExecutor(value.executor)\n )\n}\n\nfunction isPipelineGraph(value: unknown): value is PipelineGraph {\n return (\n isRecord(value) &&\n value.kind === \"sequence\" &&\n Array.isArray(value.nodes) &&\n value.nodes.every(\n (node) => isRecord(node) && node.kind === \"step\" && isPipelineStepDefinition(node.step)\n )\n )\n}\n\nfunction isPipelineStepExecutor(value: unknown): value is PipelineStepExecutor {\n if (!isRecord(value)) return false\n\n switch (value.kind) {\n case \"sql\":\n return isSqlDialect(value.dialect) && typeof value.sql === \"function\"\n case \"run\":\n return typeof value.handler === \"function\"\n default:\n return false\n }\n}\n\nfunction isInputsRecord(value: unknown): value is Readonly<Record<string, DatasetDefinition>> {\n return (\n isRecord(value) &&\n Object.entries(value).every(\n ([key, dataset]) => key.trim().length > 0 && isDatasetDefinition(dataset)\n )\n )\n}\n\nfunction isDatasetWriteMode(value: unknown): value is DatasetWriteMode {\n return value === \"snapshot\" || value === \"append\"\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n"
8
8
  ],
9
- "mappings": ";;;;;;;;;;;;AASO,IAAM,cAAc;AAAA,EACzB,QAAQ;AACV;AAEO,IAAM,eAAe,OAAO,OAAO,WAAW;AAiG9C,SAAS,YAAY,CAAC,OAAqC;AAAA,EAChE,OAAO,OAAO,UAAU,YAAY,aAAa,SAAS,KAAmB;AAAA;;;AC7F/E,SAAS,cAAc,CAAC,OAAe,OAAqB;AAAA,EAC1D,IAAI,CAAC,MAAM,KAAK,GAAG;AAAA,IACjB,MAAM,IAAI,eAAc,YAAY,0BAA0B;AAAA,EAChE;AAAA;AAGF,SAAS,aAAa,CAAC,SAA4B,OAAqB;AAAA,EACtE,eAAe,QAAQ,IAAI,KAAK;AAAA;AAGlC,SAAS,sBAAsB,CAAC,MAA8B;AAAA,EAC5D,IAAI,SAAS,cAAc,SAAS,UAAU;AAAA,IAC5C,MAAM,IAAI,eAAc,8BAA8B,yBAAyB;AAAA,EACjF;AAAA;AAGF,SAAS,YAAY,CAAC,QAA2D;AAAA,EAC/E,MAAM,UAAU,OAAO,QAAQ,MAAM;AAAA,EACrC,IAAI,QAAQ,WAAW,GAAG;AAAA,IACxB,MAAM,IAAI,eAAc,8DAA8D;AAAA,EACxF;AAAA,EAEA,YAAY,MAAM,YAAY,SAAS;AAAA,IACrC,eAAe,MAAM,iBAAiB;AAAA,IACtC,cAAc,SAAS,oBAAoB;AAAA,EAC7C;AAAA;AAGF,SAAS,iBAAiB,CAAC,UAAiD;AAAA,EAC1E,IAAI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UAAU,0BAAyB,KAAK,IAAI,CACxF;AAAA;AAIJ,SAAS,sBAAsB,CAAC,OAA+C;AAAA,EAC7E,IAAI,CAAC,SAAS,KAAK;AAAA,IAAG,OAAO;AAAA,EAE7B,QAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,MACH,OAAO,aAAa,MAAM,OAAO,KAAK,OAAO,MAAM,QAAQ;AAAA,IAC7D,KAAK;AAAA,MACH,OAAO,OAAO,MAAM,YAAY;AAAA,IAClC;AAAA,MACE,OAAO;AAAA;AAAA;AAIb,SAAS,cAAc,CAAC,OAAsE;AAAA,EAC5F,OACE,SAAS,KAAK,KACd,OAAO,QAAQ,KAAK,EAAE,MACpB,EAAE,KAAK,aAAa,IAAI,KAAK,EAAE,SAAS,KAAK,qBAAoB,OAAO,CAC1E;AAAA;AAIJ,SAAS,kBAAkB,CAAC,OAA2C;AAAA,EACrE,OAAO,UAAU,cAAc,UAAU;AAAA;AAG3C,SAAS,QAAQ,CAAC,OAAkD;AAAA,EAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAAA;",
10
10
  "debugId": "483E90D721E5117C64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -5,7 +5,7 @@
5
5
  "/**\n * Base error for webhook-run storage operations.\n */\nexport type WebhookRunErrorCode =\n | \"delivery_conflict\"\n | \"duplicate_run\"\n | \"invalid_execution\"\n | \"invalid_transition\"\n | \"not_found\"\n\nexport class WebhookRunError extends Error {\n readonly name = \"WebhookRunError\"\n\n constructor(\n message: string,\n readonly code?: WebhookRunErrorCode\n ) {\n super(message)\n }\n}\n",
6
6
  "import type { ExecutionStorage } from \"../executions\"\nimport { findPrimitiveRunExecution } from \"../executions/run-link\"\nimport { WebhookRunError } from \"./errors\"\n\n/** Validate the semantic link between a durable Webhook delivery and its immutable execution. */\nexport async function assertWebhookRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly runId: string\n readonly route: string\n}): Promise<void> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: { kind: \"webhook\", id: input.route, runId: input.runId },\n sourceTypes: [\"webhook\"],\n })\n if (\n !execution ||\n execution.source.type !== \"webhook\" ||\n execution.source.deliveryId !== input.runId\n ) {\n throw new WebhookRunError(\n `[Sixb] Execution '${input.executionId}' does not authorize Webhook run '${input.runId}'.`,\n \"invalid_execution\"\n )\n }\n}\n"
7
7
  ],
8
- "mappings": ";;;;;;AAUO,MAAM,yBAAwB,MAAM;AAAA,EAK9B;AAAA,EAJF,OAAO;AAAA,EAEhB,WAAW,CACT,SACS,MACT;AAAA,IACA,MAAM,OAAO;AAAA,IAFJ;AAAA;AAIb;;;ACdA,eAAsB,0BAAyB,CAAC,OAM9B;AAAA,EAChB,MAAM,YAAY,MAAM,0BAA0B;AAAA,IAChD,YAAY,MAAM;AAAA,IAClB,WAAW,MAAM;AAAA,IACjB,aAAa,MAAM;AAAA,IACnB,WAAW,EAAE,MAAM,WAAW,IAAI,MAAM,OAAO,OAAO,MAAM,MAAM;AAAA,IAClE,aAAa,CAAC,SAAS;AAAA,EACzB,CAAC;AAAA,EACD,IACE,CAAC,aACD,UAAU,OAAO,SAAS,aAC1B,UAAU,OAAO,eAAe,MAAM,OACtC;AAAA,IACA,MAAM,IAAI,iBACR,qBAAqB,MAAM,gDAAgD,MAAM,WACjF,mBACF;AAAA,EACF;AAAA;",
8
+ "mappings": ";;;;;;AAUO,MAAM,yBAAwB,MAAM;AAAA,EAK9B;AAAA,EAJF,OAAO;AAAA,EAEhB,WAAW,CACT,SACS,MACT;AAAA,IACA,MAAM,OAAO;AAAA,IAFJ;AAAA;AAIb;;;ACdO,eAAe,0BAAyB,CAAC,OAM9B;AAAA,EAChB,MAAM,YAAY,MAAM,0BAA0B;AAAA,IAChD,YAAY,MAAM;AAAA,IAClB,WAAW,MAAM;AAAA,IACjB,aAAa,MAAM;AAAA,IACnB,WAAW,EAAE,MAAM,WAAW,IAAI,MAAM,OAAO,OAAO,MAAM,MAAM;AAAA,IAClE,aAAa,CAAC,SAAS;AAAA,EACzB,CAAC;AAAA,EACD,IACE,CAAC,aACD,UAAU,OAAO,SAAS,aAC1B,UAAU,OAAO,eAAe,MAAM,OACtC;AAAA,IACA,MAAM,IAAI,iBACR,qBAAqB,MAAM,gDAAgD,MAAM,WACjF,mBACF;AAAA,EACF;AAAA;",
9
9
  "debugId": "7BB4F14E611BDF3F64756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,4 +1,9 @@
1
1
  // @bun
2
+ import {
3
+ isUserRef,
4
+ isCurrentUser,
5
+ currentUserNotStorableMessage
6
+ } from "./chunk-jspskey0.js";
2
7
  import {
3
8
  isFileRef2,
4
9
  isValidFileRef
@@ -6,11 +11,6 @@ import {
6
11
  import {
7
12
  withFailureMessage2
8
13
  } from "./chunk-6eqsgvxk.js";
9
- import {
10
- isUserRef,
11
- isCurrentUser,
12
- currentUserNotStorableMessage
13
- } from "./chunk-4y26vs3v.js";
14
14
  import {
15
15
  OntologyValidationError2
16
16
  } from "./chunk-cqr3acm1.js";
@@ -690,7 +690,6 @@ function validateLinkProperties2(objectType, link, properties, existingPropertie
690
690
  }
691
691
  }
692
692
  }
693
-
694
693
  // src/ontology/query-capabilities.ts
695
694
  function isExactSchema(schema) {
696
695
  if (typeof schema === "string")
@@ -942,7 +941,6 @@ function validateQueryIndexes(typeId, objectType, valueTypes) {
942
941
  throw new OntologyValidationError2(`[Sixb] Query index direction must be asc or desc on '${typeId}'`);
943
942
  }
944
943
  }
945
-
946
944
  // src/ontology/units/quantitative-types.ts
947
945
  var angleUnits = {
948
946
  degreeOfArc: { name: "Degree of Arc", symbol: "\xB0" },
@@ -1556,4 +1554,4 @@ function validateTelemetryUnit2(property, propertyPath, unit, valueTypesById) {
1556
1554
  }
1557
1555
  export { validateSchemaValue2, assertValidFileRefs2, resolveValueTypeRef2, resolveValueTypeSchema2, isRecord2, normalizeObjectProperties2, normalizeSchemaValue2, coerceSchemaValueToTyped2, isPrimitiveSchema, primitiveTraits, UNIQUE_VALUE_KEY_VERSION, uniqueValueKind, uniquePropertiesOf, uniqueValueKey, assertObjectTypeRegistered2, assertPropertyTokenBelongsToObjectType2, assertLinkTokenBelongsToObjectType2, assertKnownProperties2, assertRequiredProperties2, validateObjectProperties2, validatePrimaryProperties2, validatePropertyDefinitions2, validatePropertyValue2, findPrimitiveSchema, assertLinkTargetType2, assertTargetTypeCompatible2, normalizeLinkProperties2, validateLinkProperties2, isExactSchema, isSortableSchema, isTextSchema, isContainsSchema, queryScalarKindForSchema, resolvePropertyQueryCapabilities2, resolveQuerySchema, validateQueryMetadata2, quantitativeTypes2, getUnit2, getUnitsFor2, isValidUnit2, getUnitSymbol2, isQuantitativeTypeId2, isUnitId2, assertTelemetryProperty2, resolveSemanticType2, validateTelemetryUnit2 };
1558
1556
 
1559
- //# debugId=819D50151832A85A64756E2164756E21
1557
+ //# debugId=5A6C162946E6DCB564756E2164756E21