@sixb/core 0.1.5 → 0.1.7

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 (564) hide show
  1. package/dist/actions/index.js +37 -33
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/types/definitions.d.ts +8 -2
  4. package/dist/actions/types/definitions.d.ts.map +1 -1
  5. package/dist/actions/worker.js +3 -3
  6. package/dist/agents/adapters.d.ts +33 -76
  7. package/dist/agents/adapters.d.ts.map +1 -1
  8. package/dist/agents/authority.d.ts +22 -6
  9. package/dist/agents/authority.d.ts.map +1 -1
  10. package/dist/agents/builders.d.ts +3 -11
  11. package/dist/agents/builders.d.ts.map +1 -1
  12. package/dist/agents/context.js +2 -2
  13. package/dist/agents/dispatch.d.ts +9 -1
  14. package/dist/agents/dispatch.d.ts.map +1 -1
  15. package/dist/agents/errors.d.ts +2 -2
  16. package/dist/agents/errors.d.ts.map +1 -1
  17. package/dist/agents/execution.d.ts +9 -10
  18. package/dist/agents/execution.d.ts.map +1 -1
  19. package/dist/agents/ids.d.ts +4 -0
  20. package/dist/agents/ids.d.ts.map +1 -1
  21. package/dist/agents/index.d.ts +13 -9
  22. package/dist/agents/index.d.ts.map +1 -1
  23. package/dist/agents/index.js +80 -68
  24. package/dist/agents/index.js.map +1 -1
  25. package/dist/agents/message.d.ts +17 -10
  26. package/dist/agents/message.d.ts.map +1 -1
  27. package/dist/agents/model-loop.d.ts +56 -0
  28. package/dist/agents/model-loop.d.ts.map +1 -0
  29. package/dist/agents/reference.d.ts +4 -0
  30. package/dist/agents/reference.d.ts.map +1 -0
  31. package/dist/agents/request.d.ts +10 -8
  32. package/dist/agents/request.d.ts.map +1 -1
  33. package/dist/agents/retired-config.d.ts +4 -0
  34. package/dist/agents/retired-config.d.ts.map +1 -0
  35. package/dist/agents/streams.d.ts +13 -8
  36. package/dist/agents/streams.d.ts.map +1 -1
  37. package/dist/agents/streams.js +7 -5
  38. package/dist/agents/streams.js.map +1 -1
  39. package/dist/agents/tool-catalog.d.ts +9 -0
  40. package/dist/agents/tool-catalog.d.ts.map +1 -0
  41. package/dist/agents/tool-definition.d.ts +1 -0
  42. package/dist/agents/tool-definition.d.ts.map +1 -1
  43. package/dist/agents/types.d.ts +31 -68
  44. package/dist/agents/types.d.ts.map +1 -1
  45. package/dist/agents/validation.d.ts +4 -10
  46. package/dist/agents/validation.d.ts.map +1 -1
  47. package/dist/ai-usage/execution.d.ts +53 -0
  48. package/dist/ai-usage/execution.d.ts.map +1 -0
  49. package/dist/ai-usage/index.d.ts +3 -0
  50. package/dist/ai-usage/index.d.ts.map +1 -0
  51. package/dist/auth/index.d.ts +1 -1
  52. package/dist/auth/index.d.ts.map +1 -1
  53. package/dist/auth/index.js +7 -7
  54. package/dist/auth/runtime.d.ts.map +1 -1
  55. package/dist/auth/strategy.d.ts +1 -1
  56. package/dist/auth/strategy.d.ts.map +1 -1
  57. package/dist/auth/types.d.ts +13 -0
  58. package/dist/auth/types.d.ts.map +1 -1
  59. package/dist/authorization/decision.d.ts +5 -2
  60. package/dist/authorization/decision.d.ts.map +1 -1
  61. package/dist/authorization/grant-kinds.d.ts +24 -8
  62. package/dist/authorization/grant-kinds.d.ts.map +1 -1
  63. package/dist/authorization/index.d.ts +1 -1
  64. package/dist/authorization/index.d.ts.map +1 -1
  65. package/dist/authorization/index.js +8 -6
  66. package/dist/authorization/index.js.map +1 -1
  67. package/dist/authorization/resolve.d.ts +3 -3
  68. package/dist/authorization/resolve.d.ts.map +1 -1
  69. package/dist/authorization/types.d.ts +7 -5
  70. package/dist/authorization/types.d.ts.map +1 -1
  71. package/dist/blob-storage/browser.js +2 -2
  72. package/dist/blob-storage/index.js +3 -3
  73. package/dist/bootstrap/discovery.d.ts +1 -7
  74. package/dist/bootstrap/discovery.d.ts.map +1 -1
  75. package/dist/bootstrap/index.js +52 -48
  76. package/dist/bootstrap/index.js.map +1 -1
  77. package/dist/broker/index.js +2 -2
  78. package/dist/{chunk-zqysyfjt.js → chunk-08m3b6w8.js} +1 -1
  79. package/dist/{chunk-xdf9yswn.js → chunk-08twe8m6.js} +93 -8
  80. package/dist/chunk-08twe8m6.js.map +12 -0
  81. package/dist/{chunk-xkthy56g.js → chunk-1kamz6j0.js} +1 -1
  82. package/dist/{chunk-h6h91mfy.js → chunk-2b5qtban.js} +12 -12
  83. package/dist/{chunk-h6h91mfy.js.map → chunk-2b5qtban.js.map} +3 -3
  84. package/dist/{chunk-0172wgm9.js → chunk-2xns679x.js} +10 -2
  85. package/dist/{chunk-0172wgm9.js.map → chunk-2xns679x.js.map} +3 -3
  86. package/dist/{chunk-f83ka50g.js → chunk-37wk412q.js} +86 -28
  87. package/dist/{chunk-f83ka50g.js.map → chunk-37wk412q.js.map} +8 -8
  88. package/dist/{chunk-6d5xdj1q.js → chunk-3fqt22c4.js} +4 -4
  89. package/dist/{chunk-t9xghkva.js → chunk-3kv70xwp.js} +3 -2
  90. package/dist/{chunk-t9xghkva.js.map → chunk-3kv70xwp.js.map} +3 -3
  91. package/dist/{chunk-z3zp0bj1.js → chunk-407j3msh.js} +1 -1
  92. package/dist/{chunk-rhrbz7d4.js → chunk-4a849fr1.js} +1 -1
  93. package/dist/{chunk-62c7t4jc.js → chunk-4nxeacx7.js} +1 -1
  94. package/dist/{chunk-cy0n5dms.js → chunk-5jcdmjam.js} +1 -1
  95. package/dist/{chunk-819wnjz8.js → chunk-64sr682n.js} +7 -7
  96. package/dist/{chunk-v0egge8b.js → chunk-6ed5bwnd.js} +666 -81
  97. package/dist/chunk-6ed5bwnd.js.map +57 -0
  98. package/dist/{chunk-x2yw73hy.js → chunk-7ds9620f.js} +1 -1
  99. package/dist/{chunk-dm72y8wt.js → chunk-7y0f6rf1.js} +29 -16
  100. package/dist/chunk-7y0f6rf1.js.map +10 -0
  101. package/dist/{chunk-72q2y8hn.js → chunk-8tsf6dmc.js} +2 -2
  102. package/dist/{chunk-72q2y8hn.js.map → chunk-8tsf6dmc.js.map} +3 -3
  103. package/dist/{chunk-tbv03sx2.js → chunk-9aehf39w.js} +7 -7
  104. package/dist/{chunk-ezake7g1.js → chunk-agsvg9ar.js} +1 -1
  105. package/dist/{chunk-rdeagz6b.js → chunk-atmkaf60.js} +1 -1
  106. package/dist/{chunk-rdeagz6b.js.map → chunk-atmkaf60.js.map} +2 -2
  107. package/dist/chunk-c15dr03f.js +43 -0
  108. package/dist/chunk-c15dr03f.js.map +10 -0
  109. package/dist/{chunk-78c6xvyr.js → chunk-d2ndstdf.js} +8 -6
  110. package/dist/{chunk-78c6xvyr.js.map → chunk-d2ndstdf.js.map} +2 -2
  111. package/dist/{chunk-rnshztfq.js → chunk-d63tybny.js} +2 -2
  112. package/dist/{chunk-t0jjkep3.js → chunk-d8qkxt2v.js} +4 -2
  113. package/dist/chunk-d8qkxt2v.js.map +10 -0
  114. package/dist/{chunk-vybf6pkp.js → chunk-dbc80ad7.js} +1 -1
  115. package/dist/{chunk-4gz41why.js → chunk-dqn23610.js} +1 -1
  116. package/dist/{chunk-z3ga9q5m.js → chunk-e4rvtvpw.js} +13 -11
  117. package/dist/{chunk-z3ga9q5m.js.map → chunk-e4rvtvpw.js.map} +2 -2
  118. package/dist/{chunk-h9kxd41f.js → chunk-gbrpsx4m.js} +19 -6
  119. package/dist/chunk-gbrpsx4m.js.map +11 -0
  120. package/dist/{chunk-84h6qhmp.js → chunk-h0knpbz5.js} +468 -1236
  121. package/dist/chunk-h0knpbz5.js.map +38 -0
  122. package/dist/{chunk-zp2v2rv6.js → chunk-ha58tjtt.js} +6 -6
  123. package/dist/{chunk-f6erf2vv.js → chunk-hdz94br2.js} +2 -2
  124. package/dist/chunk-jecn6t54.js +307 -0
  125. package/dist/chunk-jecn6t54.js.map +12 -0
  126. package/dist/{chunk-dsrkgtnh.js → chunk-jq43kdvk.js} +1 -1
  127. package/dist/{chunk-wtmzkcht.js → chunk-k34z5rvh.js} +1 -1
  128. package/dist/{chunk-htq0qh7z.js → chunk-ka3a2ft3.js} +2 -2
  129. package/dist/{chunk-4h947jd8.js → chunk-kt81c11h.js} +2 -2
  130. package/dist/chunk-n2arzn6e.js +1745 -0
  131. package/dist/chunk-n2arzn6e.js.map +20 -0
  132. package/dist/{chunk-f2rt4vkh.js → chunk-n2w475r0.js} +3 -3
  133. package/dist/{chunk-t8t39h7v.js → chunk-n6jxh8sw.js} +10 -2
  134. package/dist/chunk-n6jxh8sw.js.map +10 -0
  135. package/dist/{chunk-drjqm1aa.js → chunk-p03r0h5s.js} +310 -28
  136. package/dist/chunk-p03r0h5s.js.map +16 -0
  137. package/dist/chunk-p2vqaxkc.js +528 -0
  138. package/dist/chunk-p2vqaxkc.js.map +15 -0
  139. package/dist/{chunk-gadsm794.js → chunk-qjycjdj6.js} +84 -11
  140. package/dist/chunk-qjycjdj6.js.map +12 -0
  141. package/dist/chunk-qjzp9xyb.js +286 -0
  142. package/dist/chunk-qjzp9xyb.js.map +12 -0
  143. package/dist/{chunk-am6eczah.js → chunk-qv38twt8.js} +50 -69
  144. package/dist/{chunk-am6eczah.js.map → chunk-qv38twt8.js.map} +8 -8
  145. package/dist/{chunk-bhxaq2nn.js → chunk-qw9gvjv5.js} +1 -1
  146. package/dist/{chunk-r0rry8dn.js → chunk-rp1mvzb4.js} +6 -6
  147. package/dist/{chunk-tkdscva6.js → chunk-rre42skh.js} +187 -18
  148. package/dist/chunk-rre42skh.js.map +39 -0
  149. package/dist/{chunk-ghteq96b.js → chunk-s5y30bc9.js} +2 -2
  150. package/dist/{chunk-a31h57d5.js → chunk-tn7xcs2n.js} +2 -2
  151. package/dist/{chunk-6gjqgd3d.js → chunk-tpnd31c1.js} +2 -1
  152. package/dist/chunk-tpnd31c1.js.map +11 -0
  153. package/dist/chunk-trxxmgnf.js +68 -0
  154. package/dist/chunk-trxxmgnf.js.map +11 -0
  155. package/dist/{chunk-ea73pzk7.js → chunk-vjjv9mrb.js} +2 -2
  156. package/dist/{chunk-8b55ygje.js → chunk-w3e09qqk.js} +1 -1
  157. package/dist/{chunk-ckxfnx7f.js → chunk-wjgm6jjt.js} +2 -2
  158. package/dist/{chunk-3j7573mj.js → chunk-x0qhkqje.js} +2 -2
  159. package/dist/{chunk-dysw7nsm.js → chunk-xdpwpkha.js} +2 -2
  160. package/dist/{chunk-1q02e95s.js → chunk-y35ma3mj.js} +11 -16
  161. package/dist/{chunk-1q02e95s.js.map → chunk-y35ma3mj.js.map} +3 -4
  162. package/dist/{chunk-qewtks41.js → chunk-z2sery1b.js} +64 -1
  163. package/dist/{chunk-qewtks41.js.map → chunk-z2sery1b.js.map} +3 -3
  164. package/dist/error-reporting/internal.js +4 -4
  165. package/dist/error-reporting/types.d.ts +7 -2
  166. package/dist/error-reporting/types.d.ts.map +1 -1
  167. package/dist/errors/catalog.d.ts +8 -0
  168. package/dist/errors/catalog.d.ts.map +1 -1
  169. package/dist/errors/internal.js +2 -2
  170. package/dist/events/index.js +4 -4
  171. package/dist/execution/agent.d.ts +18 -9
  172. package/dist/execution/agent.d.ts.map +1 -1
  173. package/dist/execution/agent.js +52 -43
  174. package/dist/execution/agent.js.map +1 -1
  175. package/dist/execution/authorization.d.ts +14 -4
  176. package/dist/execution/authorization.d.ts.map +1 -1
  177. package/dist/execution/primitive.js +45 -43
  178. package/dist/execution/primitive.js.map +2 -2
  179. package/dist/execution/request.d.ts +3 -1
  180. package/dist/execution/request.d.ts.map +1 -1
  181. package/dist/execution/request.js +46 -44
  182. package/dist/execution/request.js.map +3 -3
  183. package/dist/execution/types.d.ts +1 -1
  184. package/dist/execution/types.d.ts.map +1 -1
  185. package/dist/http/api-routes.d.ts.map +1 -1
  186. package/dist/http/index.js +1 -1
  187. package/dist/index.d.ts +9 -6
  188. package/dist/index.d.ts.map +1 -1
  189. package/dist/index.js +82 -77
  190. package/dist/index.js.map +1 -1
  191. package/dist/json.d.ts +2 -0
  192. package/dist/json.d.ts.map +1 -1
  193. package/dist/lake-storage/index.js +5 -5
  194. package/dist/logging/index.js +3 -3
  195. package/dist/logging/types.js +2 -2
  196. package/dist/materialization/index.js +2 -2
  197. package/dist/materializer/index.js +33 -29
  198. package/dist/materializer/index.js.map +1 -1
  199. package/dist/models/catalog.d.ts +40 -0
  200. package/dist/models/catalog.d.ts.map +1 -0
  201. package/dist/models/definitions.d.ts +25 -0
  202. package/dist/models/definitions.d.ts.map +1 -0
  203. package/dist/models/errors.d.ts +52 -0
  204. package/dist/models/errors.d.ts.map +1 -0
  205. package/dist/models/events.d.ts +192 -0
  206. package/dist/models/events.d.ts.map +1 -0
  207. package/dist/models/index.d.ts +17 -39
  208. package/dist/models/index.d.ts.map +1 -1
  209. package/dist/models/index.js +50 -0
  210. package/dist/models/index.js.map +9 -0
  211. package/dist/models/language-model.d.ts +90 -0
  212. package/dist/models/language-model.d.ts.map +1 -0
  213. package/dist/models/messages.d.ts +74 -0
  214. package/dist/models/messages.d.ts.map +1 -0
  215. package/dist/models/pricing.d.ts +69 -0
  216. package/dist/models/pricing.d.ts.map +1 -0
  217. package/dist/models/rate-card.d.ts +24 -0
  218. package/dist/models/rate-card.d.ts.map +1 -0
  219. package/dist/models/tools.d.ts +24 -0
  220. package/dist/models/tools.d.ts.map +1 -0
  221. package/dist/objects/index.js +38 -34
  222. package/dist/objects/index.js.map +1 -1
  223. package/dist/objects/query/index.js +32 -28
  224. package/dist/objects/query/index.js.map +1 -1
  225. package/dist/ontology/index.js +5 -5
  226. package/dist/ontology/internal.js +4 -4
  227. package/dist/pipelines/index.js +37 -35
  228. package/dist/pipelines/index.js.map +1 -1
  229. package/dist/projections/internal.js +35 -31
  230. package/dist/projections/internal.js.map +1 -1
  231. package/dist/queues/in-memory.d.ts +3 -2
  232. package/dist/queues/in-memory.d.ts.map +1 -1
  233. package/dist/queues/index.d.ts +3 -1
  234. package/dist/queues/index.d.ts.map +1 -1
  235. package/dist/queues/index.js +1 -1
  236. package/dist/queues/types.d.ts +15 -3
  237. package/dist/queues/types.d.ts.map +1 -1
  238. package/dist/runtime/create.d.ts +4 -4
  239. package/dist/runtime/create.d.ts.map +1 -1
  240. package/dist/runtime/definitions.d.ts +2 -2
  241. package/dist/runtime/definitions.d.ts.map +1 -1
  242. package/dist/runtime/host.d.ts +3 -2
  243. package/dist/runtime/host.d.ts.map +1 -1
  244. package/dist/runtime/resolve-definitions.d.ts +2 -2
  245. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  246. package/dist/runtime/sixb.d.ts +4 -2
  247. package/dist/runtime/sixb.d.ts.map +1 -1
  248. package/dist/security/every.d.ts +1 -4
  249. package/dist/security/every.d.ts.map +1 -1
  250. package/dist/security/grants.d.ts +6 -5
  251. package/dist/security/grants.d.ts.map +1 -1
  252. package/dist/security/index.d.ts +1 -1
  253. package/dist/security/index.d.ts.map +1 -1
  254. package/dist/security/registry.d.ts +1 -1
  255. package/dist/security/registry.d.ts.map +1 -1
  256. package/dist/security/types.d.ts +13 -5
  257. package/dist/security/types.d.ts.map +1 -1
  258. package/dist/security/validation.d.ts +4 -2
  259. package/dist/security/validation.d.ts.map +1 -1
  260. package/dist/storage/action-runs/failure.js +3 -3
  261. package/dist/storage/action-runs/provider.js +2 -2
  262. package/dist/storage/agents/errors.d.ts +1 -1
  263. package/dist/storage/agents/errors.d.ts.map +1 -1
  264. package/dist/storage/agents/in-memory.d.ts +3 -2
  265. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  266. package/dist/storage/agents/index.d.ts +1 -1
  267. package/dist/storage/agents/index.d.ts.map +1 -1
  268. package/dist/storage/agents/provider.d.ts +11 -4
  269. package/dist/storage/agents/provider.d.ts.map +1 -1
  270. package/dist/storage/agents/provider.js +18 -15
  271. package/dist/storage/agents/provider.js.map +1 -1
  272. package/dist/storage/agents/types.d.ts +65 -17
  273. package/dist/storage/agents/types.d.ts.map +1 -1
  274. package/dist/storage/ai-cost/analytics.d.ts +2 -1
  275. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  276. package/dist/storage/ai-cost/codec.d.ts +3 -2
  277. package/dist/storage/ai-cost/codec.d.ts.map +1 -1
  278. package/dist/storage/ai-cost/groups.d.ts +51 -0
  279. package/dist/storage/ai-cost/groups.d.ts.map +1 -0
  280. package/dist/storage/ai-cost/in-memory.d.ts +11 -1
  281. package/dist/storage/ai-cost/in-memory.d.ts.map +1 -1
  282. package/dist/storage/ai-cost/index.d.ts +1 -1
  283. package/dist/storage/ai-cost/index.d.ts.map +1 -1
  284. package/dist/storage/ai-cost/provider.d.ts +2 -0
  285. package/dist/storage/ai-cost/provider.d.ts.map +1 -1
  286. package/dist/storage/ai-cost/provider.js +29 -13
  287. package/dist/storage/ai-cost/provider.js.map +3 -3
  288. package/dist/storage/ai-cost/types.d.ts +64 -15
  289. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  290. package/dist/storage/ai-cost/validation.d.ts +2 -1
  291. package/dist/storage/ai-cost/validation.d.ts.map +1 -1
  292. package/dist/storage/ai-limits/enforcement.d.ts +14 -0
  293. package/dist/storage/ai-limits/enforcement.d.ts.map +1 -0
  294. package/dist/storage/ai-limits/enforcement.js +21 -0
  295. package/dist/storage/ai-limits/enforcement.js.map +9 -0
  296. package/dist/storage/ai-limits/errors.d.ts +8 -0
  297. package/dist/storage/ai-limits/errors.d.ts.map +1 -0
  298. package/dist/storage/ai-limits/in-memory.d.ts +78 -0
  299. package/dist/storage/ai-limits/in-memory.d.ts.map +1 -0
  300. package/dist/storage/ai-limits/index.d.ts +7 -0
  301. package/dist/storage/ai-limits/index.d.ts.map +1 -0
  302. package/dist/storage/ai-limits/period.d.ts +4 -0
  303. package/dist/storage/ai-limits/period.d.ts.map +1 -0
  304. package/dist/storage/ai-limits/provider.d.ts +85 -0
  305. package/dist/storage/ai-limits/provider.d.ts.map +1 -0
  306. package/dist/storage/ai-limits/provider.js +62 -0
  307. package/dist/storage/ai-limits/provider.js.map +9 -0
  308. package/dist/storage/ai-limits/types.d.ts +175 -0
  309. package/dist/storage/ai-limits/types.d.ts.map +1 -0
  310. package/dist/storage/ai-usage/in-memory.d.ts +4 -0
  311. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  312. package/dist/storage/ai-usage/record.d.ts.map +1 -1
  313. package/dist/storage/ai-usage/types.d.ts +6 -2
  314. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  315. package/dist/storage/auth/errors.d.ts +1 -1
  316. package/dist/storage/auth/errors.d.ts.map +1 -1
  317. package/dist/storage/auth/in-memory/auth-storage.d.ts +4 -1
  318. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  319. package/dist/storage/auth/in-memory/device-authorizations.d.ts +29 -0
  320. package/dist/storage/auth/in-memory/device-authorizations.d.ts.map +1 -0
  321. package/dist/storage/auth/in-memory/shared.d.ts +3 -1
  322. package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
  323. package/dist/storage/auth/index.d.ts +2 -1
  324. package/dist/storage/auth/index.d.ts.map +1 -1
  325. package/dist/storage/auth/types.d.ts +66 -0
  326. package/dist/storage/auth/types.d.ts.map +1 -1
  327. package/dist/storage/connector-connections/provider.js +2 -2
  328. package/dist/storage/executions/provider.js +1 -1
  329. package/dist/storage/executions/run-link.d.ts +7 -2
  330. package/dist/storage/executions/run-link.d.ts.map +1 -1
  331. package/dist/storage/executions/validation.d.ts.map +1 -1
  332. package/dist/storage/in-memory/index.d.ts +4 -0
  333. package/dist/storage/in-memory/index.d.ts.map +1 -1
  334. package/dist/storage/index.d.ts +8 -5
  335. package/dist/storage/index.d.ts.map +1 -1
  336. package/dist/storage/index.js +51 -38
  337. package/dist/storage/index.js.map +1 -1
  338. package/dist/storage/ontology/in-memory/materializations.d.ts +4 -3
  339. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  340. package/dist/storage/ontology/index.d.ts +1 -1
  341. package/dist/storage/ontology/index.d.ts.map +1 -1
  342. package/dist/storage/ontology/materializations.d.ts +7 -3
  343. package/dist/storage/ontology/materializations.d.ts.map +1 -1
  344. package/dist/storage/ontology/provider.d.ts +2 -2
  345. package/dist/storage/ontology/provider.d.ts.map +1 -1
  346. package/dist/storage/ontology/provider.js +3 -3
  347. package/dist/storage/pipeline-runs/provider.js +2 -2
  348. package/dist/storage/projection-runs/provider.js +4 -4
  349. package/dist/storage/sync-runs/provider.js +2 -2
  350. package/dist/storage/types.d.ts +5 -1
  351. package/dist/storage/types.d.ts.map +1 -1
  352. package/dist/storage/webhook-runs/provider.js +2 -2
  353. package/dist/storage/workflow-runs/provider.d.ts +1 -1
  354. package/dist/storage/workflow-runs/provider.js +10 -11
  355. package/dist/storage/workflow-runs/provider.js.map +1 -1
  356. package/dist/storage/workflow-runs/types.d.ts +5 -4
  357. package/dist/storage/workflow-runs/types.d.ts.map +1 -1
  358. package/dist/syncs/index.js +37 -35
  359. package/dist/syncs/index.js.map +1 -1
  360. package/dist/testing/agent-execution.d.ts +3 -1
  361. package/dist/testing/agent-execution.d.ts.map +1 -1
  362. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  363. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  364. package/dist/testing/ai-limit-storage-contract.d.ts +18 -0
  365. package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -0
  366. package/dist/testing/ai-model-call-groups-contract.d.ts +6 -0
  367. package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -0
  368. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  369. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  370. package/dist/testing/index.d.ts +2 -0
  371. package/dist/testing/index.d.ts.map +1 -1
  372. package/dist/testing/index.js +3758 -1945
  373. package/dist/testing/index.js.map +15 -13
  374. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  375. package/dist/testing/queues-contract.d.ts.map +1 -1
  376. package/dist/webhooks/internal.js +32 -28
  377. package/dist/webhooks/internal.js.map +2 -2
  378. package/dist/workers/index.js +2 -2
  379. package/dist/workflows/agent-step-identity.d.ts +3 -0
  380. package/dist/workflows/agent-step-identity.d.ts.map +1 -0
  381. package/dist/workflows/builders.d.ts +2 -3
  382. package/dist/workflows/builders.d.ts.map +1 -1
  383. package/dist/workflows/execution.d.ts +1 -1
  384. package/dist/workflows/execution.d.ts.map +1 -1
  385. package/dist/workflows/failure.d.ts +1 -1
  386. package/dist/workflows/failure.d.ts.map +1 -1
  387. package/dist/workflows/index.d.ts +3 -2
  388. package/dist/workflows/index.d.ts.map +1 -1
  389. package/dist/workflows/index.js +53 -45
  390. package/dist/workflows/index.js.map +1 -1
  391. package/dist/workflows/types.d.ts +26 -11
  392. package/dist/workflows/types.d.ts.map +1 -1
  393. package/dist/workflows/validation.d.ts +7 -1
  394. package/dist/workflows/validation.d.ts.map +1 -1
  395. package/package.json +19 -4
  396. package/src/actions/types/definitions.ts +24 -2
  397. package/src/agents/adapters.ts +109 -115
  398. package/src/agents/authority.ts +214 -32
  399. package/src/agents/builders.ts +3 -50
  400. package/src/agents/context-compaction.ts +4 -0
  401. package/src/agents/dispatch.ts +59 -2
  402. package/src/agents/errors.ts +5 -2
  403. package/src/agents/execution.ts +53 -52
  404. package/src/agents/ids.ts +16 -1
  405. package/src/agents/index.ts +23 -11
  406. package/src/agents/message.ts +18 -9
  407. package/src/agents/model-loop.ts +1023 -0
  408. package/src/agents/reference.ts +7 -0
  409. package/src/agents/request.ts +141 -74
  410. package/src/agents/retired-config.ts +20 -0
  411. package/src/agents/streams.ts +45 -19
  412. package/src/agents/tool-catalog.ts +21 -0
  413. package/src/agents/tool-definition.ts +23 -0
  414. package/src/agents/types.ts +39 -81
  415. package/src/agents/validation.ts +34 -180
  416. package/src/ai-usage/execution.ts +196 -0
  417. package/src/ai-usage/index.ts +15 -0
  418. package/src/auth/index.ts +1 -0
  419. package/src/auth/runtime.ts +8 -0
  420. package/src/auth/strategy.ts +1 -0
  421. package/src/auth/types.ts +14 -0
  422. package/src/authorization/decision.ts +27 -10
  423. package/src/authorization/grant-kinds.ts +62 -15
  424. package/src/authorization/index.ts +1 -0
  425. package/src/authorization/resolve.ts +12 -5
  426. package/src/authorization/types.ts +7 -5
  427. package/src/bootstrap/discovery.ts +0 -3
  428. package/src/error-reporting/types.ts +4 -2
  429. package/src/errors/catalog.ts +8 -0
  430. package/src/execution/agent.ts +129 -22
  431. package/src/execution/authorization.ts +48 -18
  432. package/src/execution/request.ts +4 -1
  433. package/src/execution/types.ts +1 -1
  434. package/src/http/api-routes.ts +63 -0
  435. package/src/index.ts +36 -7
  436. package/src/json.ts +9 -0
  437. package/src/models/catalog.ts +137 -0
  438. package/src/models/definitions.ts +202 -0
  439. package/src/models/errors.ts +83 -0
  440. package/src/models/events.ts +198 -0
  441. package/src/models/index.ts +89 -71
  442. package/src/models/language-model.ts +143 -0
  443. package/src/models/messages.ts +78 -0
  444. package/src/models/pricing.ts +390 -0
  445. package/src/models/rate-card.ts +101 -0
  446. package/src/models/tools.ts +29 -0
  447. package/src/queues/in-memory.ts +5 -0
  448. package/src/queues/index.ts +11 -0
  449. package/src/queues/types.ts +20 -3
  450. package/src/runtime/create.ts +7 -5
  451. package/src/runtime/definitions.ts +2 -2
  452. package/src/runtime/host.ts +3 -2
  453. package/src/runtime/resolve-definitions.ts +13 -36
  454. package/src/runtime/sixb.ts +6 -8
  455. package/src/security/every.ts +0 -4
  456. package/src/security/grants.ts +55 -11
  457. package/src/security/index.ts +2 -0
  458. package/src/security/registry.ts +6 -5
  459. package/src/security/types.ts +15 -4
  460. package/src/security/validation.ts +30 -9
  461. package/src/storage/agents/errors.ts +1 -0
  462. package/src/storage/agents/in-memory.ts +121 -11
  463. package/src/storage/agents/index.ts +7 -0
  464. package/src/storage/agents/provider.ts +150 -6
  465. package/src/storage/agents/types.ts +73 -16
  466. package/src/storage/ai-cost/analytics.ts +63 -6
  467. package/src/storage/ai-cost/codec.ts +37 -12
  468. package/src/storage/ai-cost/groups.ts +248 -0
  469. package/src/storage/ai-cost/in-memory.ts +42 -0
  470. package/src/storage/ai-cost/index.ts +6 -0
  471. package/src/storage/ai-cost/provider.ts +7 -0
  472. package/src/storage/ai-cost/types.ts +76 -14
  473. package/src/storage/ai-cost/validation.ts +147 -17
  474. package/src/storage/ai-limits/enforcement.ts +68 -0
  475. package/src/storage/ai-limits/errors.ts +23 -0
  476. package/src/storage/ai-limits/in-memory.ts +671 -0
  477. package/src/storage/ai-limits/index.ts +31 -0
  478. package/src/storage/ai-limits/period.ts +11 -0
  479. package/src/storage/ai-limits/provider.ts +430 -0
  480. package/src/storage/ai-limits/types.ts +195 -0
  481. package/src/storage/ai-usage/in-memory.ts +13 -0
  482. package/src/storage/ai-usage/record.ts +17 -0
  483. package/src/storage/ai-usage/types.ts +6 -2
  484. package/src/storage/auth/errors.ts +6 -0
  485. package/src/storage/auth/in-memory/auth-storage.ts +69 -0
  486. package/src/storage/auth/in-memory/device-authorizations.ts +145 -0
  487. package/src/storage/auth/in-memory/shared.ts +7 -0
  488. package/src/storage/auth/index.ts +7 -0
  489. package/src/storage/auth/types.ts +73 -0
  490. package/src/storage/executions/run-link.ts +16 -6
  491. package/src/storage/executions/validation.ts +36 -6
  492. package/src/storage/in-memory/index.ts +48 -4
  493. package/src/storage/index.ts +52 -1
  494. package/src/storage/ontology/in-memory/materializations.ts +34 -22
  495. package/src/storage/ontology/index.ts +1 -0
  496. package/src/storage/ontology/materializations.ts +8 -3
  497. package/src/storage/ontology/provider.ts +2 -2
  498. package/src/storage/types.ts +37 -0
  499. package/src/storage/workflow-runs/in-memory.ts +3 -3
  500. package/src/storage/workflow-runs/provider.ts +2 -2
  501. package/src/storage/workflow-runs/types.ts +6 -3
  502. package/src/testing/agent-execution.ts +40 -28
  503. package/src/testing/agent-storage-contract.ts +249 -28
  504. package/src/testing/ai-cost-storage-contract.ts +96 -8
  505. package/src/testing/ai-limit-storage-contract.ts +1134 -0
  506. package/src/testing/ai-model-call-groups-contract.ts +353 -0
  507. package/src/testing/ai-usage-storage-contract.ts +31 -0
  508. package/src/testing/auth-storage-contract.ts +85 -0
  509. package/src/testing/execution-storage-contract.ts +2 -2
  510. package/src/testing/index.ts +10 -0
  511. package/src/testing/materializer-storage-contract.ts +170 -2
  512. package/src/testing/queues-contract.ts +36 -1
  513. package/src/workflows/agent-step-identity.ts +4 -0
  514. package/src/workflows/builders.ts +95 -9
  515. package/src/workflows/execution.ts +2 -2
  516. package/src/workflows/failure.ts +2 -2
  517. package/src/workflows/index.ts +3 -0
  518. package/src/workflows/types.ts +23 -11
  519. package/src/workflows/validation.ts +100 -7
  520. package/dist/chunk-6gjqgd3d.js.map +0 -11
  521. package/dist/chunk-84h6qhmp.js.map +0 -46
  522. package/dist/chunk-a09jx26t.js +0 -55
  523. package/dist/chunk-a09jx26t.js.map +0 -11
  524. package/dist/chunk-dm72y8wt.js.map +0 -10
  525. package/dist/chunk-drjqm1aa.js.map +0 -15
  526. package/dist/chunk-gadsm794.js.map +0 -11
  527. package/dist/chunk-h9kxd41f.js.map +0 -11
  528. package/dist/chunk-nzw7sm3b.js +0 -137
  529. package/dist/chunk-nzw7sm3b.js.map +0 -10
  530. package/dist/chunk-t0jjkep3.js.map +0 -10
  531. package/dist/chunk-t8t39h7v.js.map +0 -10
  532. package/dist/chunk-tkdscva6.js.map +0 -37
  533. package/dist/chunk-v0egge8b.js.map +0 -56
  534. package/dist/chunk-xdf9yswn.js.map +0 -11
  535. /package/dist/{chunk-zqysyfjt.js.map → chunk-08m3b6w8.js.map} +0 -0
  536. /package/dist/{chunk-xkthy56g.js.map → chunk-1kamz6j0.js.map} +0 -0
  537. /package/dist/{chunk-6d5xdj1q.js.map → chunk-3fqt22c4.js.map} +0 -0
  538. /package/dist/{chunk-z3zp0bj1.js.map → chunk-407j3msh.js.map} +0 -0
  539. /package/dist/{chunk-rhrbz7d4.js.map → chunk-4a849fr1.js.map} +0 -0
  540. /package/dist/{chunk-62c7t4jc.js.map → chunk-4nxeacx7.js.map} +0 -0
  541. /package/dist/{chunk-cy0n5dms.js.map → chunk-5jcdmjam.js.map} +0 -0
  542. /package/dist/{chunk-819wnjz8.js.map → chunk-64sr682n.js.map} +0 -0
  543. /package/dist/{chunk-x2yw73hy.js.map → chunk-7ds9620f.js.map} +0 -0
  544. /package/dist/{chunk-tbv03sx2.js.map → chunk-9aehf39w.js.map} +0 -0
  545. /package/dist/{chunk-ezake7g1.js.map → chunk-agsvg9ar.js.map} +0 -0
  546. /package/dist/{chunk-rnshztfq.js.map → chunk-d63tybny.js.map} +0 -0
  547. /package/dist/{chunk-vybf6pkp.js.map → chunk-dbc80ad7.js.map} +0 -0
  548. /package/dist/{chunk-4gz41why.js.map → chunk-dqn23610.js.map} +0 -0
  549. /package/dist/{chunk-zp2v2rv6.js.map → chunk-ha58tjtt.js.map} +0 -0
  550. /package/dist/{chunk-f6erf2vv.js.map → chunk-hdz94br2.js.map} +0 -0
  551. /package/dist/{chunk-dsrkgtnh.js.map → chunk-jq43kdvk.js.map} +0 -0
  552. /package/dist/{chunk-wtmzkcht.js.map → chunk-k34z5rvh.js.map} +0 -0
  553. /package/dist/{chunk-htq0qh7z.js.map → chunk-ka3a2ft3.js.map} +0 -0
  554. /package/dist/{chunk-4h947jd8.js.map → chunk-kt81c11h.js.map} +0 -0
  555. /package/dist/{chunk-f2rt4vkh.js.map → chunk-n2w475r0.js.map} +0 -0
  556. /package/dist/{chunk-bhxaq2nn.js.map → chunk-qw9gvjv5.js.map} +0 -0
  557. /package/dist/{chunk-r0rry8dn.js.map → chunk-rp1mvzb4.js.map} +0 -0
  558. /package/dist/{chunk-ghteq96b.js.map → chunk-s5y30bc9.js.map} +0 -0
  559. /package/dist/{chunk-a31h57d5.js.map → chunk-tn7xcs2n.js.map} +0 -0
  560. /package/dist/{chunk-ea73pzk7.js.map → chunk-vjjv9mrb.js.map} +0 -0
  561. /package/dist/{chunk-8b55ygje.js.map → chunk-w3e09qqk.js.map} +0 -0
  562. /package/dist/{chunk-ckxfnx7f.js.map → chunk-wjgm6jjt.js.map} +0 -0
  563. /package/dist/{chunk-3j7573mj.js.map → chunk-x0qhkqje.js.map} +0 -0
  564. /package/dist/{chunk-dysw7nsm.js.map → chunk-xdpwpkha.js.map} +0 -0
@@ -1,4 +1,27 @@
1
1
  // @bun
2
+ import {
3
+ SyncRunError,
4
+ assertSyncRunExecution
5
+ } from "./chunk-4nxeacx7.js";
6
+ import {
7
+ WebhookRunError,
8
+ assertWebhookRunExecution
9
+ } from "./chunk-agsvg9ar.js";
10
+ import {
11
+ WorkflowRunError,
12
+ assertWorkflowAgentNodeRunExecution,
13
+ assertWorkflowRunExecution
14
+ } from "./chunk-qjzp9xyb.js";
15
+ import {
16
+ CONNECTOR_CONNECTION_RUN_FAILURE_CODES,
17
+ ConnectorConnectionStorageError
18
+ } from "./chunk-5gd7tpv6.js";
19
+ import {
20
+ ExecutionStorageError,
21
+ cloneExecutionRecord,
22
+ normalizeExecutionRecord,
23
+ validateExecutionRecordReferences
24
+ } from "./chunk-gbrpsx4m.js";
2
25
  import {
3
26
  ProviderMaterializationTransactionLifecycle,
4
27
  appendScopeSnapshot,
@@ -27,7 +50,7 @@ import {
27
50
  startScopeAccumulator,
28
51
  uniqueSorted,
29
52
  workUniquenessKey
30
- } from "./chunk-72q2y8hn.js";
53
+ } from "./chunk-8tsf6dmc.js";
31
54
  import {
32
55
  createAgentOperationScope,
33
56
  createAuthOperationScope,
@@ -39,7 +62,7 @@ import {
39
62
  import {
40
63
  PipelineRunError,
41
64
  assertPipelineRunExecution
42
- } from "./chunk-cy0n5dms.js";
65
+ } from "./chunk-5jcdmjam.js";
43
66
  import {
44
67
  ProjectionRunError,
45
68
  advanceProjectionTelemetry,
@@ -66,27 +89,14 @@ import {
66
89
  publicProjectionRunRecord,
67
90
  requireTelemetryProjectionRun,
68
91
  staleProjectionRunExecution
69
- } from "./chunk-dysw7nsm.js";
70
- import {
71
- SyncRunError,
72
- assertSyncRunExecution
73
- } from "./chunk-62c7t4jc.js";
74
- import {
75
- WebhookRunError,
76
- assertWebhookRunExecution
77
- } from "./chunk-ezake7g1.js";
78
- import {
79
- WorkflowRunError,
80
- assertWorkflowAgentNodeRunExecution,
81
- assertWorkflowRunExecution
82
- } from "./chunk-a09jx26t.js";
92
+ } from "./chunk-xdpwpkha.js";
83
93
  import {
84
94
  parseActionRunFailure
85
- } from "./chunk-htq0qh7z.js";
95
+ } from "./chunk-ka3a2ft3.js";
86
96
  import {
87
97
  ActionRunError,
88
98
  assertActionRunExecution
89
- } from "./chunk-xkthy56g.js";
99
+ } from "./chunk-1kamz6j0.js";
90
100
  import {
91
101
  AgentStorageError,
92
102
  agentContextCheckpointMatchesCreateInput,
@@ -94,25 +104,45 @@ import {
94
104
  assertAgentContextCheckpointAuthority,
95
105
  assertAgentContextCheckpointReplayState,
96
106
  assertAgentRunExecution,
97
- assertCreateAgentContextCheckpointInput
98
- } from "./chunk-xdf9yswn.js";
107
+ assertConversationAgentRunSpec,
108
+ assertCreateAgentContextCheckpointInput,
109
+ assertCreateSubagentRunInput,
110
+ assertSubagentRunResult,
111
+ subagentRunMatchesCreateInput
112
+ } from "./chunk-08twe8m6.js";
99
113
  import {
100
114
  InMemoryAiUsageStorage,
101
115
  aiModelCallCostMatchesUsage,
102
116
  buildAiAccountingOverview,
103
117
  buildAiModelCallAccountingList,
118
+ buildAiModelCallGroups,
104
119
  normalizeAiModelCallCostRecord
105
- } from "./chunk-drjqm1aa.js";
106
- import {
107
- CONNECTOR_CONNECTION_RUN_FAILURE_CODES,
108
- ConnectorConnectionStorageError
109
- } from "./chunk-5gd7tpv6.js";
120
+ } from "./chunk-p03r0h5s.js";
110
121
  import {
111
- ExecutionStorageError,
112
- cloneExecutionRecord,
113
- normalizeExecutionRecord,
114
- validateExecutionRecordReferences
115
- } from "./chunk-h9kxd41f.js";
122
+ AiLimitOperationLock,
123
+ AiLimitStorageError,
124
+ aiLimitAccountingEntryAppliesToSubject,
125
+ aiLimitAmountKey,
126
+ aiLimitCalendarMonth,
127
+ aiLimitPolicyDimensionKey,
128
+ aiLimitQuantityFromAmount,
129
+ aiLimitReservationBuckets,
130
+ aiLimitReservationRequestKey,
131
+ aiLimitReservationRequestMatches,
132
+ aiLimitSubjectKey,
133
+ aiLimitSubjectsFromAccountingEntry,
134
+ aiModelCallReservationKey,
135
+ assertAiLimitAccountingMatchesReservation,
136
+ assertNonBlank,
137
+ cloneAiLimitPolicy,
138
+ cloneValidDate,
139
+ normalizeAiLimitAmount,
140
+ normalizeAiModelCallReservationIdentity,
141
+ normalizeCreateAiLimitPolicy,
142
+ normalizeReserveAiModelCall,
143
+ normalizeUpdateAiLimitPolicy,
144
+ resolveAiLimitActual
145
+ } from "./chunk-jecn6t54.js";
116
146
  import {
117
147
  assertPinnedDatasetWatermark
118
148
  } from "./chunk-9dzba0f2.js";
@@ -126,22 +156,22 @@ import {
126
156
  projectionEntityKey,
127
157
  telemetryPointKey,
128
158
  telemetryPointSortKey
129
- } from "./chunk-vybf6pkp.js";
159
+ } from "./chunk-dbc80ad7.js";
130
160
  import {
131
161
  MaterializationConflictError,
132
162
  MaterializationValidationError
133
163
  } from "./chunk-ry24jbr1.js";
134
164
  import {
135
165
  AGENT_RUN_FAILURE_CODES
136
- } from "./chunk-t0jjkep3.js";
166
+ } from "./chunk-d8qkxt2v.js";
137
167
  import {
138
168
  InMemoryAuthStorage,
139
169
  paginate,
140
170
  principalsEqual
141
- } from "./chunk-tkdscva6.js";
171
+ } from "./chunk-rre42skh.js";
142
172
  import {
143
173
  normalizeRequesterGroupIds
144
- } from "./chunk-rhrbz7d4.js";
174
+ } from "./chunk-4a849fr1.js";
145
175
  import {
146
176
  compareDecimalValues
147
177
  } from "./chunk-04b07a9q.js";
@@ -149,11 +179,11 @@ import {
149
179
  createSixbError,
150
180
  parseSixbFailure,
151
181
  toSixbFailure
152
- } from "./chunk-0172wgm9.js";
182
+ } from "./chunk-2xns679x.js";
153
183
  import {
154
184
  cloneJsonValue,
155
185
  stableJsonStringify
156
- } from "./chunk-t8t39h7v.js";
186
+ } from "./chunk-n6jxh8sw.js";
157
187
  // src/storage/action-runs/idempotency.ts
158
188
  function actionSubjectsEqual(left, right) {
159
189
  if (left.kind !== right.kind)
@@ -191,7 +221,7 @@ var runDirectly = async (run) => run();
191
221
  function actionRunKey(projectId, id) {
192
222
  return JSON.stringify([projectId, id]);
193
223
  }
194
- function assertNonBlank(value, fieldName) {
224
+ function assertNonBlank2(value, fieldName) {
195
225
  if (typeof value !== "string" || value.trim().length === 0) {
196
226
  throw new ActionRunError(`[Sixb] Action materialization ${fieldName} must be nonblank.`);
197
227
  }
@@ -451,9 +481,9 @@ class InMemoryActionRunStorage {
451
481
  });
452
482
  }
453
483
  requireMaterializationRun(input) {
454
- assertNonBlank(input.projectId, "projectId");
455
- assertNonBlank(input.runId, "runId");
456
- assertNonBlank(input.actionId, "actionId");
484
+ assertNonBlank2(input.projectId, "projectId");
485
+ assertNonBlank2(input.runId, "runId");
486
+ assertNonBlank2(input.actionId, "actionId");
457
487
  const existing = this.rows.get(actionRunKey(input.projectId, input.runId));
458
488
  if (!existing) {
459
489
  throw new ActionRunError(`[Sixb] Action run '${input.runId}' not found for project '${input.projectId}'.`);
@@ -468,7 +498,7 @@ class InMemoryActionRunStorage {
468
498
  }
469
499
  }
470
500
  // src/agents/message.ts
471
- var AGENT_MESSAGE_CONTENT_VERSION = 1;
501
+ var AGENT_MESSAGE_CONTENT_VERSION = 2;
472
502
 
473
503
  // src/storage/agents/in-memory.ts
474
504
  function normalizeFailure(failure) {
@@ -511,7 +541,6 @@ class InMemoryAgentThreadStore {
511
541
  const record = {
512
542
  id: input.id,
513
543
  projectId: input.projectId,
514
- agentId: input.agentId,
515
544
  ownerPrincipal: clone(input.ownerPrincipal),
516
545
  ...input.title === undefined ? {} : { title: input.title },
517
546
  status: input.status ?? "active",
@@ -530,8 +559,7 @@ class InMemoryAgentThreadStore {
530
559
  async list(input) {
531
560
  const order = input.order ?? "desc";
532
561
  const statuses = input.statuses ? new Set(input.statuses) : null;
533
- const agentIds = input.agentIds ? new Set(input.agentIds) : null;
534
- const filtered = [...this.state.threads.values()].filter((thread) => thread.projectId === input.projectId).filter((thread) => input.agentId ? thread.agentId === input.agentId : true).filter((thread) => agentIds ? agentIds.has(thread.agentId) : true).filter((thread) => statuses ? statuses.has(thread.status) : true).filter((thread) => input.ownerPrincipal ? principalsEqual(thread.ownerPrincipal, input.ownerPrincipal) : true).sort((a, b) => compareByDate(a.lastMessageAt ?? a.createdAt, b.lastMessageAt ?? b.createdAt, a.id, b.id, order));
562
+ const filtered = [...this.state.threads.values()].filter((thread) => thread.projectId === input.projectId).filter((thread) => statuses ? statuses.has(thread.status) : true).filter((thread) => input.ownerPrincipal ? principalsEqual(thread.ownerPrincipal, input.ownerPrincipal) : true).sort((a, b) => compareByDate(a.lastMessageAt ?? a.createdAt, b.lastMessageAt ?? b.createdAt, a.id, b.id, order));
535
563
  const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
536
564
  return { threads: page.map(clone), hasMore, total };
537
565
  }
@@ -545,12 +573,12 @@ class InMemoryAgentRunStore {
545
573
  this.executions = executions;
546
574
  }
547
575
  async create(input) {
576
+ assertConversationAgentRunSpec(input.spec);
548
577
  await assertAgentRunExecution({
549
578
  executions: this.executions,
550
579
  projectId: input.projectId,
551
580
  executionId: input.executionId,
552
- runId: input.id,
553
- agentId: input.agentId
581
+ runId: input.id
554
582
  });
555
583
  const threadKey = key(input.projectId, input.threadId);
556
584
  const thread = this.state.threads.get(threadKey);
@@ -569,12 +597,13 @@ class InMemoryAgentRunStore {
569
597
  }
570
598
  const createdAt = new Date(input.createdAt ?? new Date);
571
599
  const run = {
600
+ kind: "conversation",
572
601
  id: input.id,
573
602
  projectId: input.projectId,
574
603
  executionId: input.executionId,
575
604
  threadId: input.threadId,
576
- agentId: input.agentId,
577
605
  triggerMessageId: input.triggerMessageId,
606
+ spec: clone(input.spec),
578
607
  requesterGroupIds: normalizeRequesterGroupIds(input.requesterGroupIds),
579
608
  status: "queued",
580
609
  attempt: 0,
@@ -589,6 +618,57 @@ class InMemoryAgentRunStore {
589
618
  this.state.threads.set(threadKey, clone(updatedThread));
590
619
  return clone(run);
591
620
  }
621
+ async createSubagent(input) {
622
+ assertCreateSubagentRunInput(input);
623
+ const execution = await assertAgentRunExecution({
624
+ executions: this.executions,
625
+ projectId: input.projectId,
626
+ executionId: input.executionId,
627
+ runId: input.id
628
+ });
629
+ const runKey = key(input.projectId, input.id);
630
+ const existing = this.state.runs.get(runKey);
631
+ if (existing) {
632
+ if (subagentRunMatchesCreateInput(existing, input))
633
+ return clone(existing);
634
+ throw new AgentStorageError("duplicate_id", `[Sixb] Subagent run '${input.id}' already exists with different immutable inputs.`);
635
+ }
636
+ const parent = this.state.runs.get(key(input.projectId, input.parentRunId));
637
+ if (!parent || parent.kind !== "conversation") {
638
+ throw new AgentStorageError("run_not_found", `[Sixb] Parent Agent run '${input.parentRunId}' was not found.`);
639
+ }
640
+ if (parent.status !== "running") {
641
+ throw new AgentStorageError("invalid_state", `[Sixb] Parent Agent run '${parent.id}' is not running (status '${parent.status}').`);
642
+ }
643
+ if (execution.source.type !== "execution" || execution.source.executionId !== parent.executionId) {
644
+ throw new AgentStorageError("invalid_input", `[Sixb] Subagent execution '${execution.id}' is not a child of parent execution '${parent.executionId}'.`);
645
+ }
646
+ if (parent.execution?.token !== input.parentExecutionToken) {
647
+ throw new AgentStorageError("execution_lost", `[Sixb] Parent Agent run '${parent.id}' is no longer owned by this execution.`);
648
+ }
649
+ const activeChildren = [...this.state.runs.values()].filter((run2) => run2.kind === "subagent" && run2.projectId === input.projectId && run2.parentRunId === parent.id && (run2.status === "queued" || run2.status === "running")).length;
650
+ if (activeChildren >= input.maxActiveChildren) {
651
+ throw new AgentStorageError("active_child_limit", `[Sixb] Agent run '${parent.id}' already has ${activeChildren} active subagents.`);
652
+ }
653
+ if ([...this.state.runs.values()].some((run2) => run2.projectId === input.projectId && run2.executionId === input.executionId)) {
654
+ throw new AgentStorageError("duplicate_id", `[Sixb] Execution '${input.executionId}' already belongs to another Agent run.`);
655
+ }
656
+ const run = {
657
+ kind: "subagent",
658
+ id: input.id,
659
+ projectId: input.projectId,
660
+ executionId: input.executionId,
661
+ parentRunId: input.parentRunId,
662
+ spawnKey: input.spawnKey,
663
+ spec: clone(input.spec),
664
+ requesterGroupIds: clone(parent.requesterGroupIds),
665
+ status: "queued",
666
+ attempt: 0,
667
+ createdAt: new Date(input.createdAt ?? new Date)
668
+ };
669
+ this.state.runs.set(runKey, clone(run));
670
+ return clone(run);
671
+ }
592
672
  async start(input) {
593
673
  const run = this.requireStatus(input.projectId, input.id, "queued");
594
674
  const startedAt = new Date(input.startedAt ?? new Date);
@@ -646,6 +726,12 @@ class InMemoryAgentRunStore {
646
726
  if (!run.execution || run.execution.token !== input.executionToken) {
647
727
  throw new AgentStorageError("execution_lost", `[Sixb] Execution token is no longer current on agent run '${input.id}'.`);
648
728
  }
729
+ if (input.status === "succeeded" && run.kind === "subagent") {
730
+ assertSubagentRunResult(input.result, run.id);
731
+ }
732
+ if (input.status === "succeeded" && run.kind === "conversation" && input.result !== undefined) {
733
+ throw new AgentStorageError("invalid_input", `[Sixb] Conversational Agent run '${run.id}' cannot persist a subagent result.`);
734
+ }
649
735
  const completedAt = new Date(input.completedAt ?? new Date);
650
736
  const next = {
651
737
  ...run,
@@ -653,6 +739,7 @@ class InMemoryAgentRunStore {
653
739
  ...input.modelId === undefined ? {} : { modelId: input.modelId },
654
740
  ...input.finishReason === undefined ? {} : { finishReason: input.finishReason },
655
741
  ...input.diagnostics === undefined ? {} : { diagnostics: clone(input.diagnostics) },
742
+ ...input.status === "succeeded" && input.result !== undefined ? { result: clone(input.result) } : {},
656
743
  ...input.status === "succeeded" || input.error === undefined ? {} : { error: normalizeFailure(input.error) },
657
744
  execution: undefined,
658
745
  completedAt
@@ -671,7 +758,8 @@ class InMemoryAgentRunStore {
671
758
  async list(input) {
672
759
  const order = input.order ?? "desc";
673
760
  const statuses = input.statuses ? new Set(input.statuses) : null;
674
- const filtered = [...this.state.runs.values()].filter((run) => run.projectId === input.projectId).filter((run) => input.threadId ? run.threadId === input.threadId : true).filter((run) => input.agentId ? run.agentId === input.agentId : true).filter((run) => statuses ? statuses.has(run.status) : true).filter((run) => input.startedAfter ? (run.startedAt ?? run.createdAt) >= input.startedAfter : true).filter((run) => input.startedBefore ? (run.startedAt ?? run.createdAt) <= input.startedBefore : true).sort((a, b) => compareByDate(a.startedAt ?? a.createdAt, b.startedAt ?? b.createdAt, a.id, b.id, order));
761
+ const kinds = input.kinds ? new Set(input.kinds) : null;
762
+ const filtered = [...this.state.runs.values()].filter((run) => run.projectId === input.projectId).filter((run) => kinds ? kinds.has(run.kind) : true).filter((run) => input.threadId ? run.kind === "conversation" && run.threadId === input.threadId : true).filter((run) => input.parentRunId ? run.kind === "subagent" && run.parentRunId === input.parentRunId : true).filter((run) => statuses ? statuses.has(run.status) : true).filter((run) => input.startedAfter ? (run.startedAt ?? run.createdAt) >= input.startedAfter : true).filter((run) => input.startedBefore ? (run.startedAt ?? run.createdAt) <= input.startedBefore : true).sort((a, b) => compareByDate(a.startedAt ?? a.createdAt, b.startedAt ?? b.createdAt, a.id, b.id, order));
675
763
  const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
676
764
  return { runs: page.map(clone), hasMore, total };
677
765
  }
@@ -689,6 +777,8 @@ class InMemoryAgentRunStore {
689
777
  return run;
690
778
  }
691
779
  releaseThread(run, completedAt) {
780
+ if (run.kind !== "conversation")
781
+ return;
692
782
  const threadKey = key(run.projectId, run.threadId);
693
783
  const thread = this.state.threads.get(threadKey);
694
784
  if (thread && thread.activeRunId === run.id) {
@@ -926,9 +1016,9 @@ class InMemoryAiCostStorage {
926
1016
  this.recordsByUsage.set(key2, structuredClone(record));
927
1017
  }
928
1018
  async summarizeExecutions(input) {
929
- assertNonBlank2(input.projectId, "cost summary projectId");
1019
+ assertNonBlank3(input.projectId, "cost summary projectId");
930
1020
  for (const id of input.executionIds)
931
- assertNonBlank2(id, "cost summary executionId");
1021
+ assertNonBlank3(id, "cost summary executionId");
932
1022
  const requested = new Set(input.executionIds);
933
1023
  const usageByExecution = new Map(input.executionIds.map((id) => [id, []]));
934
1024
  for (const usage of this.usage.snapshot().records.values()) {
@@ -947,9 +1037,32 @@ class InMemoryAiCostStorage {
947
1037
  snapshot() {
948
1038
  return structuredClone({ recordsByUsage: this.recordsByUsage });
949
1039
  }
1040
+ async listModelCallGroups(input) {
1041
+ const items = await this.accountingItems();
1042
+ const roots = new Map;
1043
+ return buildAiModelCallGroups(input, await Promise.all(items.map(async (item) => {
1044
+ const key2 = usageRecordKey(item.usage.projectId, item.usage.executionId);
1045
+ let root = roots.get(key2);
1046
+ if (!root) {
1047
+ root = this.attribution?.resolveGroup?.({
1048
+ projectId: item.usage.projectId,
1049
+ executionId: item.usage.executionId
1050
+ }) ?? Promise.resolve({
1051
+ executionId: item.usage.executionId,
1052
+ attribution: item.attribution
1053
+ });
1054
+ roots.set(key2, root);
1055
+ }
1056
+ return { ...item, root: await root };
1057
+ })));
1058
+ }
950
1059
  restore(snapshot) {
951
1060
  replaceMap(this.recordsByUsage, snapshot.recordsByUsage);
952
1061
  }
1062
+ getRecord(projectId, usageRecordId) {
1063
+ const record = this.recordsByUsage.get(usageRecordKey(projectId, usageRecordId));
1064
+ return record ? structuredClone(record) : null;
1065
+ }
953
1066
  usageRecord(projectId, id) {
954
1067
  return [...this.usage.snapshot().records.values()].find((record) => record.projectId === projectId && record.id === id);
955
1068
  }
@@ -1000,7 +1113,7 @@ function addMoney(amounts, money) {
1000
1113
  function usageRecordKey(projectId, id) {
1001
1114
  return JSON.stringify([projectId, id]);
1002
1115
  }
1003
- function assertNonBlank2(value, field) {
1116
+ function assertNonBlank3(value, field) {
1004
1117
  if (typeof value !== "string" || value.trim().length === 0) {
1005
1118
  throw new TypeError(`[Sixb] AI ${field} must be nonblank.`);
1006
1119
  }
@@ -1010,6 +1123,429 @@ function replaceMap(target, source) {
1010
1123
  for (const [key2, value] of structuredClone(source))
1011
1124
  target.set(key2, value);
1012
1125
  }
1126
+ // src/storage/ai-limits/in-memory.ts
1127
+ class InMemoryAiLimitStorage {
1128
+ options;
1129
+ policies = new Map;
1130
+ policyIdsByDimension = new Map;
1131
+ periodStates = new Map;
1132
+ reservations = new Map;
1133
+ operations = new AiLimitOperationLock;
1134
+ constructor(options = {}) {
1135
+ this.options = options;
1136
+ }
1137
+ settleOperations() {
1138
+ return this.operations.settle();
1139
+ }
1140
+ async createPolicy(input) {
1141
+ return this.operations.run(async () => {
1142
+ const policy = normalizeCreateAiLimitPolicy(input);
1143
+ const key2 = policyKey(policy.projectId, policy.id);
1144
+ const dimensionKey = aiLimitPolicyDimensionKey(policy);
1145
+ if (this.policies.has(key2) || this.policyIdsByDimension.has(dimensionKey)) {
1146
+ throw new AiLimitStorageError("duplicate_policy", `[Sixb] An AI limit policy already exists for '${aiLimitSubjectKey(policy.subject)}' and '${aiLimitAmountKey(normalizeAiLimitAmount(policy.limit))}'.`);
1147
+ }
1148
+ this.policies.set(key2, structuredClone(policy));
1149
+ this.policyIdsByDimension.set(dimensionKey, key2);
1150
+ return cloneAiLimitPolicy(policy);
1151
+ });
1152
+ }
1153
+ async updatePolicy(input) {
1154
+ return this.operations.run(async () => {
1155
+ const update = normalizeUpdateAiLimitPolicy(input);
1156
+ const key2 = policyKey(update.projectId, update.id);
1157
+ const existing = this.policies.get(key2);
1158
+ if (!existing)
1159
+ throw missingPolicy(update.projectId, update.id);
1160
+ if (update.limit !== undefined) {
1161
+ const previous = normalizeAiLimitAmount(existing.limit);
1162
+ const next = normalizeAiLimitAmount(update.limit);
1163
+ if (aiLimitAmountKey(previous) !== aiLimitAmountKey(next)) {
1164
+ throw new TypeError("[Sixb] AI limit policy meter and cost currency are immutable.");
1165
+ }
1166
+ }
1167
+ const policy = {
1168
+ ...existing,
1169
+ ...update.limit === undefined ? {} : { limit: update.limit },
1170
+ ...update.enabled === undefined ? {} : { enabled: update.enabled },
1171
+ updatedAt: update.updatedAt
1172
+ };
1173
+ this.policies.set(key2, structuredClone(policy));
1174
+ return cloneAiLimitPolicy(policy);
1175
+ });
1176
+ }
1177
+ async deletePolicy(input) {
1178
+ return this.operations.run(async () => {
1179
+ validatePolicyIdentity(input);
1180
+ const key2 = policyKey(input.projectId, input.id);
1181
+ const existing = this.policies.get(key2);
1182
+ if (!existing)
1183
+ return false;
1184
+ this.policies.delete(key2);
1185
+ this.policyIdsByDimension.delete(aiLimitPolicyDimensionKey(existing));
1186
+ return true;
1187
+ });
1188
+ }
1189
+ async getPolicy(input) {
1190
+ validatePolicyIdentity(input);
1191
+ const policy = this.policies.get(policyKey(input.projectId, input.id));
1192
+ return policy ? cloneAiLimitPolicy(policy) : null;
1193
+ }
1194
+ async listPolicies(input) {
1195
+ assertNonBlank(input.projectId, "projectId");
1196
+ return [...this.policies.values()].filter((policy) => policy.projectId === input.projectId && (input.includeDisabled || policy.enabled)).sort((left, right) => left.id.localeCompare(right.id)).map(cloneAiLimitPolicy);
1197
+ }
1198
+ async listPolicyStatuses(input) {
1199
+ return this.operations.run(async () => {
1200
+ assertNonBlank(input.projectId, "projectId");
1201
+ const period = aiLimitCalendarMonth(input.at ?? new Date);
1202
+ const existingGroups = input.existingGroupIds === undefined ? undefined : new Set(input.existingGroupIds);
1203
+ const policies = await this.listPolicies({
1204
+ projectId: input.projectId,
1205
+ includeDisabled: input.includeDisabled
1206
+ });
1207
+ return Promise.all(policies.map((policy) => this.policyStatus(policy, period, existingGroups)));
1208
+ });
1209
+ }
1210
+ async reserveModelCall(input) {
1211
+ return this.operations.run(async () => {
1212
+ const request = normalizeReserveAiModelCall(input);
1213
+ const reservationKey = aiModelCallReservationKey(request.identity);
1214
+ const existing = this.reservations.get(reservationKey);
1215
+ if (existing) {
1216
+ if (!aiLimitReservationRequestMatches(existing, request)) {
1217
+ throw new AiLimitStorageError("reservation_conflict", `[Sixb] AI model-call reservation '${input.callId}' was replayed with different subjects, estimates, or period.`);
1218
+ }
1219
+ if (existing.state !== "active") {
1220
+ return { status: "terminal", reservation: structuredClone(existing), created: false };
1221
+ }
1222
+ return { status: "reserved", reservation: structuredClone(existing), created: false };
1223
+ }
1224
+ await this.assertExecutionExists(request.identity.projectId, request.identity.executionId);
1225
+ const enabledPolicies = [...this.policies.values()].filter((policy) => policy.projectId === request.identity.projectId && policy.enabled);
1226
+ const subjectKeys = new Set(request.subjects.map(aiLimitSubjectKey));
1227
+ const estimates = new Map(request.estimates.map((quantity) => {
1228
+ const amount = normalizeAiLimitAmount(quantity);
1229
+ return [aiLimitAmountKey(amount), amount];
1230
+ }));
1231
+ const exhaustedPolicies = [];
1232
+ const unavailablePolicies = [];
1233
+ const unavailableReasons = new Set;
1234
+ for (const policy of enabledPolicies) {
1235
+ if (!subjectKeys.has(aiLimitSubjectKey(policy.subject)))
1236
+ continue;
1237
+ const limit = normalizeAiLimitAmount(policy.limit);
1238
+ const estimate = estimates.get(aiLimitAmountKey(limit));
1239
+ const status = await this.policyStatus(policy, request.period);
1240
+ if (!estimate || status.accountingStatus === "unavailable") {
1241
+ unavailablePolicies.push(status);
1242
+ if (!estimate)
1243
+ unavailableReasons.add("missingEstimate");
1244
+ if (status.accountingStatus === "unavailable") {
1245
+ unavailableReasons.add("incompleteAccounting");
1246
+ }
1247
+ continue;
1248
+ }
1249
+ const actual = normalizeAiLimitAmount(status.consumption.actual).amount;
1250
+ const reserved = normalizeAiLimitAmount(status.consumption.reserved).amount;
1251
+ const unknown = normalizeAiLimitAmount(status.consumption.unknown).amount;
1252
+ if (actual + reserved + unknown + estimate.amount > limit.amount) {
1253
+ exhaustedPolicies.push(status);
1254
+ }
1255
+ }
1256
+ if (unavailablePolicies.length > 0) {
1257
+ unavailablePolicies.sort((left, right) => left.policy.id.localeCompare(right.policy.id));
1258
+ return {
1259
+ status: "unavailable",
1260
+ unavailablePolicies,
1261
+ reasons: [...unavailableReasons].sort()
1262
+ };
1263
+ }
1264
+ if (exhaustedPolicies.length > 0) {
1265
+ exhaustedPolicies.sort((left, right) => left.policy.id.localeCompare(right.policy.id));
1266
+ return {
1267
+ status: "denied",
1268
+ exhaustedPolicies,
1269
+ resetAt: new Date(Math.min(...exhaustedPolicies.map((status) => status.period.resetAt.getTime())))
1270
+ };
1271
+ }
1272
+ const buckets = aiLimitReservationBuckets(enabledPolicies, request.subjects, request.estimates);
1273
+ if (buckets.length === 0)
1274
+ return { status: "notRequired" };
1275
+ for (const bucket of buckets) {
1276
+ const amount = normalizeAiLimitAmount(bucket.estimate);
1277
+ const state = this.requirePeriodState(request.identity.projectId, bucket.subject, amount, request.period);
1278
+ state.reserved += amount.amount;
1279
+ state.updatedAt = new Date(request.reservedAt);
1280
+ }
1281
+ const reservation = {
1282
+ ...request.identity,
1283
+ buckets,
1284
+ requestKey: aiLimitReservationRequestKey(request),
1285
+ period: request.period,
1286
+ state: "active",
1287
+ reservedAt: request.reservedAt,
1288
+ updatedAt: new Date(request.reservedAt)
1289
+ };
1290
+ this.reservations.set(reservationKey, structuredClone(reservation));
1291
+ return { status: "reserved", reservation: structuredClone(reservation), created: true };
1292
+ });
1293
+ }
1294
+ async recordModelCallActuals(input) {
1295
+ return this.operations.run(async () => {
1296
+ assertNonBlank(input.projectId, "projectId");
1297
+ assertNonBlank(input.usageRecordId, "usageRecordId");
1298
+ const recordedAt = cloneValidDate(input.recordedAt ?? new Date, "recordedAt");
1299
+ const entry = await this.requireAccountingEntry(input.projectId, input.usageRecordId);
1300
+ const period = aiLimitCalendarMonth(entry.occurredAt);
1301
+ const subjectKeys = new Set(aiLimitSubjectsFromAccountingEntry(entry).map(aiLimitSubjectKey));
1302
+ for (const state of this.periodStates.values()) {
1303
+ if (state.projectId !== input.projectId || state.period.start.getTime() !== period.start.getTime() || !subjectKeys.has(aiLimitSubjectKey(state.subject))) {
1304
+ continue;
1305
+ }
1306
+ const actual = resolveAiLimitActual([entry], state);
1307
+ state.actual += actual.amount;
1308
+ if (actual.accountingStatus === "unavailable")
1309
+ state.accountingStatus = "unavailable";
1310
+ state.updatedAt = new Date(recordedAt);
1311
+ }
1312
+ });
1313
+ }
1314
+ async reconcileModelCall(input) {
1315
+ return this.operations.run(async () => {
1316
+ const identity = normalizeAiModelCallReservationIdentity(input);
1317
+ assertNonBlank(input.usageRecordId, "usageRecordId");
1318
+ const reconciledAt = cloneValidDate(input.reconciledAt ?? new Date, "reconciledAt");
1319
+ const key2 = aiModelCallReservationKey(identity);
1320
+ const reservation = this.reservations.get(key2);
1321
+ if (!reservation)
1322
+ throw missingReservation(identity);
1323
+ if (reservation.state === "reconciled") {
1324
+ if (reservation.usageRecordId === input.usageRecordId) {
1325
+ return structuredClone(reservation);
1326
+ }
1327
+ throw new AiLimitStorageError("reconciliation_conflict", `[Sixb] AI model-call reservation '${identity.callId}' was reconciled with a different usage record.`);
1328
+ }
1329
+ const accounting = await this.requireAccountingEntry(identity.projectId, input.usageRecordId);
1330
+ assertAiLimitAccountingMatchesReservation(reservation, accounting);
1331
+ this.reconcileEstimateCounters(reservation, accounting, reconciledAt);
1332
+ const reconciled = {
1333
+ ...reservation,
1334
+ state: "reconciled",
1335
+ usageRecordId: input.usageRecordId,
1336
+ updatedAt: reconciledAt
1337
+ };
1338
+ this.reservations.set(key2, structuredClone(reconciled));
1339
+ return structuredClone(reconciled);
1340
+ });
1341
+ }
1342
+ async markReservationUnknown(input) {
1343
+ return this.operations.run(async () => {
1344
+ const identity = normalizeAiModelCallReservationIdentity(input);
1345
+ const markedAt = cloneValidDate(input.markedAt ?? new Date, "markedAt");
1346
+ const key2 = aiModelCallReservationKey(identity);
1347
+ const reservation = this.reservations.get(key2);
1348
+ if (!reservation)
1349
+ throw missingReservation(identity);
1350
+ if (reservation.state === "unknown")
1351
+ return structuredClone(reservation);
1352
+ if (reservation.state !== "active")
1353
+ throw invalidState(reservation, "mark unknown");
1354
+ this.moveEstimateCounter(reservation, "reserved", -1n, markedAt);
1355
+ this.moveEstimateCounter(reservation, "unknown", 1n, markedAt);
1356
+ const unknown = {
1357
+ ...reservation,
1358
+ state: "unknown",
1359
+ updatedAt: markedAt
1360
+ };
1361
+ this.reservations.set(key2, structuredClone(unknown));
1362
+ return structuredClone(unknown);
1363
+ });
1364
+ }
1365
+ snapshot() {
1366
+ return structuredClone({
1367
+ policies: this.policies,
1368
+ policyIdsByDimension: this.policyIdsByDimension,
1369
+ periodStates: this.periodStates,
1370
+ reservations: this.reservations
1371
+ });
1372
+ }
1373
+ restore(snapshot) {
1374
+ replaceMap2(this.policies, snapshot.policies);
1375
+ replaceMap2(this.policyIdsByDimension, snapshot.policyIdsByDimension);
1376
+ replaceMap2(this.periodStates, snapshot.periodStates);
1377
+ replaceMap2(this.reservations, snapshot.reservations);
1378
+ }
1379
+ async policyStatus(policy, period, existingGroups) {
1380
+ const limit = normalizeAiLimitAmount(policy.limit);
1381
+ const state = await this.ensurePeriodState(policy, period);
1382
+ const reserved = state.reserved;
1383
+ const unknown = state.unknown;
1384
+ const consumed = state.actual + reserved + unknown;
1385
+ const remaining = limit.amount > consumed ? limit.amount - consumed : 0n;
1386
+ const quantity = (amount) => aiLimitQuantityFromAmount({ ...limit, amount });
1387
+ return {
1388
+ policy: cloneAiLimitPolicy(policy),
1389
+ period: structuredClone(period),
1390
+ consumption: {
1391
+ actual: quantity(state.actual),
1392
+ reserved: quantity(reserved),
1393
+ unknown: quantity(unknown),
1394
+ remaining: quantity(remaining)
1395
+ },
1396
+ accountingStatus: state.accountingStatus,
1397
+ exhausted: consumed >= limit.amount,
1398
+ orphaned: policy.subject.type === "group" && existingGroups !== undefined && !existingGroups.has(policy.subject.id)
1399
+ };
1400
+ }
1401
+ async ensurePeriodState(policy, period) {
1402
+ const amount = normalizeAiLimitAmount(policy.limit);
1403
+ const key2 = periodStateKey(policy.projectId, policy.subject, amount, period);
1404
+ const existing = this.periodStates.get(key2);
1405
+ if (existing?.accountingStatus === "complete")
1406
+ return existing;
1407
+ const actual = await this.resolvePolicyActual(policy, period, amount);
1408
+ if (existing) {
1409
+ existing.actual = actual.amount;
1410
+ existing.accountingStatus = actual.accountingStatus;
1411
+ existing.updatedAt = new Date;
1412
+ return existing;
1413
+ }
1414
+ const state = {
1415
+ projectId: policy.projectId,
1416
+ subject: structuredClone(policy.subject),
1417
+ meter: amount.meter,
1418
+ currency: amount.currency,
1419
+ period: structuredClone(period),
1420
+ actual: actual.amount,
1421
+ reserved: 0n,
1422
+ unknown: 0n,
1423
+ accountingStatus: actual.accountingStatus,
1424
+ updatedAt: new Date
1425
+ };
1426
+ this.periodStates.set(key2, state);
1427
+ return state;
1428
+ }
1429
+ moveEstimateCounter(reservation, counter, direction, updatedAt) {
1430
+ for (const bucket of reservation.buckets) {
1431
+ const amount = normalizeAiLimitAmount(bucket.estimate);
1432
+ const state = this.requirePeriodState(reservation.projectId, bucket.subject, amount, reservation.period);
1433
+ state[counter] += direction * amount.amount;
1434
+ if (state[counter] < 0n) {
1435
+ throw new Error(`[Sixb] In-memory AI limit ${counter} counter became negative.`);
1436
+ }
1437
+ state.updatedAt = new Date(updatedAt);
1438
+ }
1439
+ }
1440
+ reconcileEstimateCounters(reservation, entry, updatedAt) {
1441
+ for (const bucket of reservation.buckets) {
1442
+ const amount = normalizeAiLimitAmount(bucket.estimate);
1443
+ const state = this.requirePeriodState(reservation.projectId, bucket.subject, amount, reservation.period);
1444
+ const counter = reservation.state === "active" ? "reserved" : "unknown";
1445
+ const actual = resolveAiLimitActual([entry], amount);
1446
+ if (actual.accountingStatus === "complete") {
1447
+ state[counter] -= amount.amount;
1448
+ } else if (reservation.state === "active") {
1449
+ state.reserved -= amount.amount;
1450
+ state.unknown += amount.amount;
1451
+ }
1452
+ if (state.reserved < 0n || state.unknown < 0n) {
1453
+ throw new Error("[Sixb] In-memory AI limit reservation counter became negative.");
1454
+ }
1455
+ state.updatedAt = new Date(updatedAt);
1456
+ }
1457
+ }
1458
+ requirePeriodState(projectId, subject, amount, period) {
1459
+ const state = this.periodStates.get(periodStateKey(projectId, subject, amount, period));
1460
+ if (!state)
1461
+ throw new Error("[Sixb] In-memory AI limit period state is inconsistent.");
1462
+ return state;
1463
+ }
1464
+ async assertExecutionExists(projectId, executionId) {
1465
+ if (this.options.resolveExecution) {
1466
+ if (await this.options.resolveExecution({ projectId, executionId }))
1467
+ return;
1468
+ throw new AiLimitStorageError("missing_execution", `[Sixb] AI limit execution '${executionId}' does not exist in project '${projectId}'.`);
1469
+ }
1470
+ if (this.options.executionExists && await this.options.executionExists({ projectId, executionId })) {
1471
+ return;
1472
+ }
1473
+ throw new AiLimitStorageError("missing_execution", `[Sixb] AI limit execution '${executionId}' does not exist in project '${projectId}'.`);
1474
+ }
1475
+ async resolvePolicyActual(policy, period, dimension) {
1476
+ if (!this.options.listUsageRecords || (policy.subject.type === "user" || policy.subject.type === "serviceAccount") && !this.options.resolveExecution) {
1477
+ return { amount: 0n, accountingStatus: "unavailable" };
1478
+ }
1479
+ const records = await this.options.listUsageRecords({ projectId: policy.projectId });
1480
+ const entries = await Promise.all(records.filter((record) => record.occurredAt.getTime() >= period.start.getTime() && record.occurredAt.getTime() < period.end.getTime()).map((record) => this.accountingEntry(record)));
1481
+ return resolveAiLimitActual(entries.filter((entry) => aiLimitAccountingEntryAppliesToSubject(entry, policy.subject)), dimension);
1482
+ }
1483
+ async requireAccountingEntry(projectId, usageRecordId) {
1484
+ if (!this.options.resolveUsageRecord) {
1485
+ throw new AiLimitStorageError("unavailable_actuals", "[Sixb] In-memory AI limit storage has no immutable accounting source.");
1486
+ }
1487
+ const record = await this.options.resolveUsageRecord({ projectId, usageRecordId });
1488
+ if (!record) {
1489
+ throw new AiLimitStorageError("missing_usage_record", `[Sixb] AI usage record '${usageRecordId}' does not exist in project '${projectId}'.`);
1490
+ }
1491
+ return this.accountingEntry(record);
1492
+ }
1493
+ async accountingEntry(record) {
1494
+ const [execution, cost] = await Promise.all([
1495
+ this.options.resolveExecution?.({
1496
+ projectId: record.projectId,
1497
+ executionId: record.executionId
1498
+ }),
1499
+ this.options.resolveCostRecord?.({
1500
+ projectId: record.projectId,
1501
+ usageRecordId: record.id
1502
+ })
1503
+ ]);
1504
+ const requester = execution?.requestedBy;
1505
+ return {
1506
+ projectId: record.projectId,
1507
+ usageRecordId: record.id,
1508
+ executionId: record.executionId,
1509
+ attempt: record.attempt,
1510
+ callId: record.callId,
1511
+ occurredAt: new Date(record.occurredAt),
1512
+ ...record.usage.totalTokens === undefined ? {} : { totalTokens: record.usage.totalTokens },
1513
+ requesterGroupIds: [...record.requesterGroupIds],
1514
+ ...requester?.type === "user" || requester?.type === "serviceAccount" ? { requester: { type: requester.type, id: requester.id } } : {},
1515
+ ...cost?.status === "rated" ? { valuation: { status: "rated", money: structuredClone(cost.money) } } : cost ? { valuation: { status: "unavailable" } } : {}
1516
+ };
1517
+ }
1518
+ }
1519
+ function policyKey(projectId, id) {
1520
+ return JSON.stringify([projectId, id]);
1521
+ }
1522
+ function periodStateKey(projectId, subject, amount, period) {
1523
+ return JSON.stringify([
1524
+ projectId,
1525
+ aiLimitSubjectKey(subject),
1526
+ amount.meter,
1527
+ amount.currency,
1528
+ period.start.toISOString()
1529
+ ]);
1530
+ }
1531
+ function validatePolicyIdentity(input) {
1532
+ assertNonBlank(input.projectId, "projectId");
1533
+ assertNonBlank(input.id, "policy id");
1534
+ }
1535
+ function missingPolicy(projectId, id) {
1536
+ return new AiLimitStorageError("missing_policy", `[Sixb] AI limit policy '${id}' does not exist in project '${projectId}'.`);
1537
+ }
1538
+ function missingReservation(identity) {
1539
+ return new AiLimitStorageError("missing_reservation", `[Sixb] AI model-call reservation '${identity.callId}' does not exist for execution '${identity.executionId}' attempt ${identity.attempt}.`);
1540
+ }
1541
+ function invalidState(reservation, operation) {
1542
+ return new AiLimitStorageError("invalid_reservation_state", `[Sixb] Cannot ${operation} AI model-call reservation '${reservation.callId}' in state '${reservation.state}'.`);
1543
+ }
1544
+ function replaceMap2(target, source) {
1545
+ target.clear();
1546
+ for (const [key2, value] of structuredClone(source))
1547
+ target.set(key2, value);
1548
+ }
1013
1549
  // src/storage/connector-connections/in-memory.ts
1014
1550
  import { timingSafeEqual } from "crypto";
1015
1551
  function connectionRunBase(record, updatedAt) {
@@ -1699,10 +2235,10 @@ class InMemoryConnectorConnectionStorage {
1699
2235
  };
1700
2236
  }
1701
2237
  restore(snapshot) {
1702
- replaceMap2(this.attempts, snapshot.attempts);
1703
- replaceMap2(this.connectionRuns, snapshot.connectionRuns);
1704
- replaceMap2(this.authorizations, snapshot.authorizations);
1705
- replaceMap2(this.connections, snapshot.connections);
2238
+ replaceMap3(this.attempts, snapshot.attempts);
2239
+ replaceMap3(this.connectionRuns, snapshot.connectionRuns);
2240
+ replaceMap3(this.authorizations, snapshot.authorizations);
2241
+ replaceMap3(this.connections, snapshot.connections);
1706
2242
  }
1707
2243
  now() {
1708
2244
  return new Date(this.options.now?.() ?? new Date);
@@ -1803,7 +2339,7 @@ function safeEqual(left, right) {
1803
2339
  function invalidRun() {
1804
2340
  return new ConnectorConnectionStorageError("run_invalid", "[Sixb] Connector connection run is invalid, expired, or already used.");
1805
2341
  }
1806
- function replaceMap2(target, source) {
2342
+ function replaceMap3(target, source) {
1807
2343
  target.clear();
1808
2344
  for (const [key2, value] of structuredClone(source))
1809
2345
  target.set(key2, value);
@@ -3798,11 +4334,11 @@ class InMemoryOntologyMaterializationStorage {
3798
4334
  await this.assertObject(expected, input.commit.projectId);
3799
4335
  for (const expected of input.expected.links)
3800
4336
  await this.assertLink(expected, input.commit.projectId);
3801
- const expectedScopeStates = new Map;
4337
+ const expectedScopeRevisions = new Map;
3802
4338
  for (const expected of input.expected.linkScopes) {
3803
4339
  const key2 = linkScopeSortKey(expected.source, expected.linkId);
3804
- const current = expectedScopeStates.get(key2) ?? this.computeLinkScopeState(input.commit.projectId, expected.source, expected.linkId);
3805
- expectedScopeStates.set(key2, current);
4340
+ const current = expectedScopeRevisions.get(key2) ?? this.computeEffectiveLinkScope(input.commit.projectId, expected.source, expected.linkId);
4341
+ expectedScopeRevisions.set(key2, current);
3806
4342
  if (current.fingerprint !== expected.fingerprint) {
3807
4343
  throw new MaterializationConflictError("effective-state", `Expected link scope changed for ${expected.source.objectTypeId}:${expected.source.primaryId}.${expected.linkId}.`);
3808
4344
  }
@@ -3831,7 +4367,7 @@ class InMemoryOntologyMaterializationStorage {
3831
4367
  },
3832
4368
  workSealed: false,
3833
4369
  incidentLinksByObject: null,
3834
- linkScopeStates: expectedScopeStates,
4370
+ linkSlotStates: new Map,
3835
4371
  objectExistence: new Map,
3836
4372
  replacement: null
3837
4373
  };
@@ -3857,7 +4393,7 @@ class InMemoryOntologyMaterializationStorage {
3857
4393
  session.appliedPlanItems.length = 0;
3858
4394
  session.outboxEnvelopes.clear();
3859
4395
  session.incidentLinksByObject = null;
3860
- session.linkScopeStates = null;
4396
+ session.linkSlotStates = null;
3861
4397
  session.objectExistence.clear();
3862
4398
  session.replacement = null;
3863
4399
  this.liveSessions.delete(session);
@@ -3904,7 +4440,7 @@ class InMemoryOntologyMaterializationStorage {
3904
4440
  }
3905
4441
  for (const scope of uniqueBy(request.linkScopes, (value) => linkScopeSortKey(value.source, value.linkId))) {
3906
4442
  this.requireSession(input.session);
3907
- const value = this.linkScopeState(session, scope.source, scope.linkId);
4443
+ const value = this.linkSlotState(session, scope.source, scope.linkId);
3908
4444
  yield { objects: [], links: [], linkScopes: [value], points: [] };
3909
4445
  }
3910
4446
  const requestedPoints = uniqueSorted(request.points, (point) => telemetryPointKey(point.series, point.at), (point) => telemetryPointSortKey(point.series, point.at));
@@ -4449,17 +4985,25 @@ class InMemoryOntologyMaterializationStorage {
4449
4985
  effective: row ? linkSnapshot(row) : null
4450
4986
  };
4451
4987
  }
4452
- linkScopeState(session, source, linkId) {
4453
- session.linkScopeStates ??= new Map;
4988
+ linkSlotState(session, source, linkId) {
4989
+ session.linkSlotStates ??= new Map;
4454
4990
  const key2 = linkScopeSortKey(source, linkId);
4455
- const existing = session.linkScopeStates.get(key2);
4991
+ const existing = session.linkSlotStates.get(key2);
4456
4992
  if (existing)
4457
4993
  return structuredClone(existing);
4458
- const computed = this.computeLinkScopeState(session.header.commit.projectId, source, linkId);
4459
- session.linkScopeStates.set(key2, computed);
4994
+ const computed = this.computeLinkSlotState(session.header.commit.projectId, source, linkId);
4995
+ session.linkSlotStates.set(key2, computed);
4460
4996
  return structuredClone(computed);
4461
4997
  }
4462
- computeLinkScopeState(projectId, source, linkId) {
4998
+ computeLinkSlotState(projectId, source, linkId) {
4999
+ const value = this.computeEffectiveLinkScope(projectId, source, linkId);
5000
+ return {
5001
+ ...value,
5002
+ sourceAssertion: this.findActiveLinkScopeSource(projectId, source, linkId),
5003
+ override: structuredClone(publicLinkSlotOverride(this.state.linkSlotOverrides.get(projectEntityKey(projectId, linkScopeKey(source, linkId)))))
5004
+ };
5005
+ }
5006
+ computeEffectiveLinkScope(projectId, source, linkId) {
4463
5007
  const rows = [];
4464
5008
  getInMemoryObjectMaterializerAdapter(this.objects).visitExactScopeLinks(projectId, source.objectTypeId, source.primaryId, linkId, (row) => rows.push(row));
4465
5009
  rows.sort((left, right) => linkRefSortKey(linkRef(left)).localeCompare(linkRefSortKey(linkRef(right))));
@@ -4474,8 +5018,6 @@ class InMemoryOntologyMaterializationStorage {
4474
5018
  const effective = rows.length === 1 ? linkSnapshot(rows[0]) : null;
4475
5019
  return {
4476
5020
  ...finishScopeAccumulator(accumulator),
4477
- sourceAssertion: this.findActiveLinkScopeSource(projectId, source, linkId),
4478
- override: structuredClone(publicLinkSlotOverride(this.state.linkSlotOverrides.get(projectEntityKey(projectId, linkScopeKey(source, linkId))))),
4479
5021
  effective
4480
5022
  };
4481
5023
  }
@@ -6255,7 +6797,9 @@ function compareRequestedAt(left, right, order) {
6255
6797
  var WORKFLOW_RUN_FAILURE_CODES = [
6256
6798
  "internal.unexpected",
6257
6799
  "runtime.cancelled",
6258
- "workflow.node_failed"
6800
+ "workflow.node_failed",
6801
+ "ai.usage_limit_exceeded",
6802
+ "ai.usage_limit_unavailable"
6259
6803
  ];
6260
6804
 
6261
6805
  // src/storage/workflow-runs/in-memory.ts
@@ -6664,7 +7208,7 @@ class InMemoryWorkflowAgentNodeRunStorage {
6664
7208
  projectId: input.projectId,
6665
7209
  executionId: input.executionId,
6666
7210
  nodeRunId: input.nodeRunId,
6667
- agentId: input.agentId,
7211
+ actorId: input.actorId,
6668
7212
  workflowExecutionId: workflowRun.executionId
6669
7213
  });
6670
7214
  if (node.status !== "running") {
@@ -6681,7 +7225,7 @@ class InMemoryWorkflowAgentNodeRunStorage {
6681
7225
  projectId: input.projectId,
6682
7226
  nodeRunId: input.nodeRunId,
6683
7227
  executionId: input.executionId,
6684
- agentId: input.agentId,
7228
+ actorId: input.actorId,
6685
7229
  status: "queued",
6686
7230
  prompt: input.prompt,
6687
7231
  attempt: 0,
@@ -6750,7 +7294,7 @@ class InMemoryWorkflowAgentNodeRunStorage {
6750
7294
  async list(input) {
6751
7295
  const statuses = input.statuses ? new Set(input.statuses) : null;
6752
7296
  const order = input.order ?? "desc";
6753
- const filtered = [...this.runs.values()].filter((run) => run.projectId === input.projectId).filter((run) => input.agentId ? run.agentId === input.agentId : true).filter((run) => statuses ? statuses.has(run.status) : true).sort((a, b) => order === "asc" ? a.createdAt.getTime() - b.createdAt.getTime() : b.createdAt.getTime() - a.createdAt.getTime());
7297
+ const filtered = [...this.runs.values()].filter((run) => run.projectId === input.projectId).filter((run) => input.actorId ? run.actorId === input.actorId : true).filter((run) => statuses ? statuses.has(run.status) : true).sort((a, b) => order === "asc" ? a.createdAt.getTime() - b.createdAt.getTime() : b.createdAt.getTime() - a.createdAt.getTime());
6754
7298
  const { page, total, hasMore } = paginate(filtered, input);
6755
7299
  return { runs: page.map(cloneRecord), total, hasMore };
6756
7300
  }
@@ -6801,7 +7345,31 @@ class InMemoryStorage {
6801
7345
  agentStorage = new InMemoryAgentStorage(this.executionStorage);
6802
7346
  aiUsageStorage = new InMemoryAiUsageStorage(this.executionStorage);
6803
7347
  aiCostStorage = new InMemoryAiCostStorage(this.aiUsageStorage, {
6804
- resolve: (input) => this.resolveAiAccountingAttribution(input)
7348
+ resolve: (input) => this.resolveAiAccountingAttribution(input),
7349
+ resolveGroup: async (input) => {
7350
+ const attribution = await this.resolveAiAccountingAttribution(input);
7351
+ if (attribution?.kind !== "subagent")
7352
+ return { executionId: input.executionId, attribution };
7353
+ const parent = await this.agentStorage.runs.getById({
7354
+ projectId: input.projectId,
7355
+ id: attribution.parentRunId
7356
+ });
7357
+ if (!parent)
7358
+ throw new Error("[Sixb] Subagent accounting parent is missing.");
7359
+ return {
7360
+ executionId: parent.executionId,
7361
+ attribution: await this.resolveAiAccountingAttribution({
7362
+ ...input,
7363
+ executionId: parent.executionId
7364
+ })
7365
+ };
7366
+ }
7367
+ });
7368
+ aiLimitStorage = new InMemoryAiLimitStorage({
7369
+ resolveExecution: ({ projectId, executionId }) => this.executionStorage.getById({ projectId, id: executionId }),
7370
+ resolveUsageRecord: ({ projectId, usageRecordId }) => this.aiUsageStorage.getRecord(projectId, usageRecordId),
7371
+ resolveCostRecord: ({ projectId, usageRecordId }) => this.aiCostStorage.getRecord(projectId, usageRecordId),
7372
+ listUsageRecords: ({ projectId }) => this.aiUsageStorage.listRecords(projectId)
6805
7373
  });
6806
7374
  actionRunStorage = new InMemoryActionRunStorage(this.executionStorage);
6807
7375
  syncRunStorage = new InMemorySyncRunStorage(this.executionStorage);
@@ -6820,6 +7388,7 @@ class InMemoryStorage {
6820
7388
  agents;
6821
7389
  aiUsage;
6822
7390
  aiCosts;
7391
+ aiLimits;
6823
7392
  actionRuns;
6824
7393
  syncRuns;
6825
7394
  pipelineRuns;
@@ -6840,6 +7409,7 @@ class InMemoryStorage {
6840
7409
  this.agents = createAgentOperationScope(this.agentStorage, scope);
6841
7410
  this.aiUsage = createOperationScopedFacade(this.aiUsageStorage, scope);
6842
7411
  this.aiCosts = createOperationScopedFacade(this.aiCostStorage, scope);
7412
+ this.aiLimits = createOperationScopedFacade(this.aiLimitStorage, scope);
6843
7413
  this.actionRuns = createOperationScopedFacade(this.actionRunStorage, scope);
6844
7414
  this.syncRuns = createOperationScopedFacade(this.syncRunStorage, scope);
6845
7415
  this.pipelineRuns = createOperationScopedFacade(this.pipelineRunStorage, scope);
@@ -6872,14 +7442,20 @@ class InMemoryStorage {
6872
7442
  projectId: input.projectId,
6873
7443
  id: execution.executor.runId
6874
7444
  });
6875
- if (directRun) {
7445
+ if (directRun?.kind === "conversation") {
6876
7446
  return {
6877
7447
  kind: "agent",
6878
- agentId: directRun.agentId,
6879
7448
  agentRunId: directRun.id,
6880
7449
  threadId: directRun.threadId
6881
7450
  };
6882
7451
  }
7452
+ if (directRun?.kind === "subagent") {
7453
+ return {
7454
+ kind: "subagent",
7455
+ subagentRunId: directRun.id,
7456
+ parentRunId: directRun.parentRunId
7457
+ };
7458
+ }
6883
7459
  const agentRun = await this.workflowRunStorage.agentNodes.getByNodeRunId({
6884
7460
  projectId: input.projectId,
6885
7461
  nodeRunId: execution.executor.runId
@@ -6894,7 +7470,7 @@ class InMemoryStorage {
6894
7470
  return;
6895
7471
  return {
6896
7472
  kind: "workflowAgent",
6897
- agentId: agentRun.agentId,
7473
+ agentStepId: node.nodeId,
6898
7474
  nodeRunId: agentRun.nodeRunId,
6899
7475
  workflowId: node.workflowId,
6900
7476
  workflowRunId: node.workflowRunId
@@ -6923,7 +7499,13 @@ class InMemoryStorage {
6923
7499
  this.activeTransactionTokens.add(transactionToken);
6924
7500
  this.materializationLifecycles.set(transactionToken, materializationLifecycle);
6925
7501
  try {
6926
- const result = await this.transactionScope.run(transactionToken, async () => run(tx));
7502
+ const result = await this.transactionScope.run(transactionToken, async () => {
7503
+ try {
7504
+ return await run(tx);
7505
+ } finally {
7506
+ await this.aiLimitStorage.settleOperations();
7507
+ }
7508
+ });
6927
7509
  materializationLifecycle.assertCommittable();
6928
7510
  return result;
6929
7511
  } catch (error) {
@@ -6981,6 +7563,7 @@ class InMemoryStorage {
6981
7563
  agents: this.agentStorage,
6982
7564
  aiUsage: this.aiUsageStorage,
6983
7565
  aiCosts: this.aiCostStorage,
7566
+ aiLimits: this.aiLimitStorage,
6984
7567
  actionRuns: this.actionRunStorage,
6985
7568
  syncRuns: this.syncRunStorage,
6986
7569
  pipelineRuns: this.pipelineRunStorage,
@@ -7009,6 +7592,7 @@ class InMemoryStorage {
7009
7592
  agents: this.agentStorage.snapshot(),
7010
7593
  aiUsage: this.aiUsageStorage.snapshot(),
7011
7594
  aiCosts: this.aiCostStorage.snapshot(),
7595
+ aiLimits: this.aiLimitStorage.snapshot(),
7012
7596
  actionRuns: this.actionRunStorage.snapshot(),
7013
7597
  syncRuns: this.syncRunStorage.snapshot(),
7014
7598
  pipelineRuns: this.pipelineRunStorage.snapshot(),
@@ -7030,6 +7614,7 @@ class InMemoryStorage {
7030
7614
  this.agentStorage.restore(snapshot.agents);
7031
7615
  this.aiUsageStorage.restore(snapshot.aiUsage);
7032
7616
  this.aiCostStorage.restore(snapshot.aiCosts);
7617
+ this.aiLimitStorage.restore(snapshot.aiLimits);
7033
7618
  this.actionRunStorage.restore(snapshot.actionRuns);
7034
7619
  this.syncRunStorage.restore(snapshot.syncRuns);
7035
7620
  this.pipelineRunStorage.restore(snapshot.pipelineRuns);
@@ -7251,6 +7836,6 @@ function assertAppliedPrefix(migrations, rows) {
7251
7836
  }
7252
7837
  return [...rows].sort((a, b) => a.version - b.version);
7253
7838
  }
7254
- export { actionSubjectsEqual, actionRunParamsEqual, actionRunPhaseRecordsEqual, finishActionRunPhase, canRequeueActionRunAfterEnqueueFailure, isTerminalActionRun, InMemoryActionRunStorage, AGENT_MESSAGE_CONTENT_VERSION, InMemoryAgentStorage, AiCostStorageError, InMemoryAiCostStorage, InMemoryConnectorConnectionStorage, ObjectNotFoundError, ObjectStorageError, StorageTransactionError, isStorageSerializationFailure, FileUploadSessionError, DEFAULT_FILE_UPLOAD_SESSION_TTL_MS, DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS, createUploadExpiresAt, createFileUploadId, InMemoryFileUploadSessions, compareQueryScalarValues, queryScalarValuesEqual, objectBatchKey, linkBatchKey, objectLinkCursor, canRequeuePipelineRunAfterEnqueueFailure, PIPELINE_RUN_FAILURE_CODES, InMemoryPipelineRunStorage, InMemoryProjectionRunStorage, InMemoryRulesStorage, canRequeueSyncRunAfterEnqueueFailure, SYNC_RUN_FAILURE_CODES, InMemorySyncRunStorage, createTransactionStorageProxy, assertTransactionActive, throwNestedStorageTransaction, WEBHOOK_RUN_FAILURE_CODES, canRetryWebhookRun, InMemoryWebhookRunStorage, WorkflowInterventionError, InMemoryWorkflowInterventionStorage, WORKFLOW_RUN_FAILURE_CODES, InMemoryWorkflowRunStorage, InMemoryWorkflowNodeRunStorage, InMemoryWorkflowAgentNodeRunStorage, InMemoryStorage, isMigrationCapableStorage, migrateStorage, checkStorageSchema, step, defineMigrations, runMigrationSet, describeMigrationHistory };
7839
+ export { actionSubjectsEqual, actionRunParamsEqual, actionRunPhaseRecordsEqual, finishActionRunPhase, canRequeueActionRunAfterEnqueueFailure, isTerminalActionRun, InMemoryActionRunStorage, AGENT_MESSAGE_CONTENT_VERSION, InMemoryAgentStorage, AiCostStorageError, InMemoryAiCostStorage, InMemoryAiLimitStorage, InMemoryConnectorConnectionStorage, ObjectNotFoundError, ObjectStorageError, StorageTransactionError, isStorageSerializationFailure, FileUploadSessionError, DEFAULT_FILE_UPLOAD_SESSION_TTL_MS, DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS, createUploadExpiresAt, createFileUploadId, InMemoryFileUploadSessions, compareQueryScalarValues, queryScalarValuesEqual, objectBatchKey, linkBatchKey, objectLinkCursor, canRequeuePipelineRunAfterEnqueueFailure, PIPELINE_RUN_FAILURE_CODES, InMemoryPipelineRunStorage, InMemoryProjectionRunStorage, InMemoryRulesStorage, canRequeueSyncRunAfterEnqueueFailure, SYNC_RUN_FAILURE_CODES, InMemorySyncRunStorage, createTransactionStorageProxy, assertTransactionActive, throwNestedStorageTransaction, WEBHOOK_RUN_FAILURE_CODES, canRetryWebhookRun, InMemoryWebhookRunStorage, WorkflowInterventionError, InMemoryWorkflowInterventionStorage, WORKFLOW_RUN_FAILURE_CODES, InMemoryWorkflowRunStorage, InMemoryWorkflowNodeRunStorage, InMemoryWorkflowAgentNodeRunStorage, InMemoryStorage, isMigrationCapableStorage, migrateStorage, checkStorageSchema, step, defineMigrations, runMigrationSet, describeMigrationHistory };
7255
7840
 
7256
- //# debugId=AD092B967C71B31564756E2164756E21
7841
+ //# debugId=472382EF0F10AB3864756E2164756E21