@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
@@ -5,7 +5,7 @@
5
5
  "/**\n * Base error for pipeline-run storage operations.\n */\nexport class PipelineRunError extends Error {\n readonly name = \"PipelineRunError\"\n}\n",
6
6
  "import type { ExecutionStorage } from \"../executions\"\nimport { findPrimitiveRunExecution } from \"../executions/run-link\"\nimport { PipelineRunError } from \"./errors\"\n\n/** Validate the semantic link between a durable Pipeline run and its immutable execution. */\nexport async function assertPipelineRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly runId: string\n readonly pipelineId: string\n}): Promise<void> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: { kind: \"pipeline\", id: input.pipelineId, runId: input.runId },\n sourceTypes: [\"execution\", \"schedule\", \"event\"],\n })\n if (!execution) {\n throw new PipelineRunError(\n `[Sixb] Execution '${input.executionId}' does not authorize Pipeline run '${input.runId}'.`\n )\n }\n}\n"
7
7
  ],
8
- "mappings": ";;;;;;AAGO,MAAM,0BAAyB,MAAM;AAAA,EACjC,OAAO;AAClB;;;ACAA,eAAsB,2BAA0B,CAAC,OAM/B;AAAA,EAChB,MAAM,YAAY,MAAM,0BAA0B;AAAA,IAChD,YAAY,MAAM;AAAA,IAClB,WAAW,MAAM;AAAA,IACjB,aAAa,MAAM;AAAA,IACnB,WAAW,EAAE,MAAM,YAAY,IAAI,MAAM,YAAY,OAAO,MAAM,MAAM;AAAA,IACxE,aAAa,CAAC,aAAa,YAAY,OAAO;AAAA,EAChD,CAAC;AAAA,EACD,IAAI,CAAC,WAAW;AAAA,IACd,MAAM,IAAI,kBACR,qBAAqB,MAAM,iDAAiD,MAAM,SACpF;AAAA,EACF;AAAA;",
8
+ "mappings": ";;;;;;AAGO,MAAM,0BAAyB,MAAM;AAAA,EACjC,OAAO;AAClB;;;ACAO,eAAe,2BAA0B,CAAC,OAM/B;AAAA,EAChB,MAAM,YAAY,MAAM,0BAA0B;AAAA,IAChD,YAAY,MAAM;AAAA,IAClB,WAAW,MAAM;AAAA,IACjB,aAAa,MAAM;AAAA,IACnB,WAAW,EAAE,MAAM,YAAY,IAAI,MAAM,YAAY,OAAO,MAAM,MAAM;AAAA,IACxE,aAAa,CAAC,aAAa,YAAY,OAAO;AAAA,EAChD,CAAC;AAAA,EACD,IAAI,CAAC,WAAW;AAAA,IACd,MAAM,IAAI,kBACR,qBAAqB,MAAM,iDAAiD,MAAM,SACpF;AAAA,EACF;AAAA;",
9
9
  "debugId": "541A905468003F0364756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -3,6 +3,10 @@ import {
3
3
  createSixbError2,
4
4
  isSixbError2
5
5
  } from "./chunk-zbc929zg.js";
6
+ import {
7
+ normalizeAiModelCallCostRecord2,
8
+ aiModelCallCostMatchesUsage2
9
+ } from "./chunk-t3brw0wd.js";
6
10
  import {
7
11
  AiLimitStorageError2,
8
12
  aiLimitMeterApplies2
@@ -14,109 +18,78 @@ import {
14
18
  aiUsageLimitUnavailableError2
15
19
  } from "./chunk-dp0cdtj2.js";
16
20
  import {
17
- normalizeAiModelCallCostRecord2,
18
- aiModelCallCostMatchesUsage2
19
- } from "./chunk-0xmt5p5y.js";
21
+ estimateModelCall,
22
+ rateModelCall2
23
+ } from "./chunk-tdxfsg1c.js";
20
24
  import {
21
25
  AiCostStorageError2
22
- } from "./chunk-68wghpdf.js";
26
+ } from "./chunk-8v5a54qz.js";
23
27
  import {
24
28
  AiUsageStorageError2,
25
29
  normalizeAiModelCallRecord2
26
30
  } from "./chunk-pgrf64hp.js";
31
+ import {
32
+ ModelStreamError2
33
+ } from "./chunk-kyjcwqz6.js";
27
34
  import {
28
35
  assertJsonObject2
29
36
  } from "./chunk-wy0qdqfm.js";
30
37
 
31
- // src/models/execution/model-call-limits.ts
32
- function createAiModelCallLimitController2(input) {
33
- const subjects = aiLimitSubjectsFromAttribution2(input.requestedBy, input.requesterGroupIds);
38
+ // src/models/execution/model-call-admission.ts
39
+ var AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE = 4096;
40
+ function estimateAiModelCallInputTokens(input) {
41
+ if (containsNonTextInput(input.prompt)) {
42
+ return { status: "unavailable", reason: "nonTextInput" };
43
+ }
44
+ let serialized;
45
+ try {
46
+ serialized = JSON.stringify(input);
47
+ } catch {
48
+ return { status: "unavailable", reason: "unserializableInput" };
49
+ }
50
+ if (serialized === undefined) {
51
+ return { status: "unavailable", reason: "unserializableInput" };
52
+ }
53
+ const bytes = new TextEncoder().encode(serialized).byteLength;
34
54
  return {
35
- beforeModelCall: async (admission) => {
36
- let applicable;
37
- try {
38
- const policies = await input.storage.aiLimits.listPolicies({
39
- projectId: input.projectId
40
- });
41
- applicable = applicableAiLimitPolicies2(policies, subjects).filter((policy) => aiLimitMeterApplies2(policy.limit.meter, admission.modelKind));
42
- } catch (error) {
43
- throw limitStorageUnavailable(error);
44
- }
45
- if (applicable.length === 0)
46
- return { reservation: "none" };
47
- const estimates = reservationEstimates(admission, applicable.some((policy) => policy.limit.meter === "cost.catalogEstimated"));
48
- if (estimates.length === 0) {
49
- throw aiUsageLimitUnavailableError2(["missingEstimate"]);
50
- }
51
- let result;
52
- try {
53
- result = await input.storage.aiLimits.reserveModelCall({
54
- ...reservationIdentity(admission),
55
- subjects,
56
- estimates,
57
- ...admission.modelKind === undefined ? {} : { modelKind: admission.modelKind }
58
- });
59
- } catch (error) {
60
- throw limitStorageUnavailable(error);
61
- }
62
- switch (result.status) {
63
- case "reserved":
64
- return { reservation: "active" };
65
- case "notRequired":
66
- return { reservation: "none" };
67
- case "denied":
68
- throw aiUsageLimitExceededError2(result.resetAt);
69
- case "unavailable":
70
- throw aiUsageLimitUnavailableError2(result.reasons);
71
- case "terminal":
72
- throw aiUsageLimitUnavailableError2(["terminalReservationReplay"]);
73
- }
74
- },
75
- markModelCallUnknown: async (identity) => {
76
- try {
77
- await input.storage.aiLimits.markReservationUnknown(identity);
78
- } catch (error) {
79
- throw limitStorageUnavailable(error);
80
- }
81
- }
55
+ status: "estimated",
56
+ tokens: Math.ceil(bytes / 4),
57
+ method: "utf8BytesDividedByFour"
82
58
  };
83
59
  }
84
- function reservationEstimates(input, needsCost) {
85
- const estimates = [];
86
- if (input.inputTokens.status === "estimated" && input.estimatedTotalTokens !== undefined) {
87
- estimates.push({ meter: "tokens.total", amount: input.estimatedTotalTokens });
88
- }
89
- if (needsCost) {
90
- try {
91
- let money = input.reservationCost;
92
- if (money == null && input.inputTokens.status === "estimated") {
93
- money = input.costEstimator?.estimateReservation?.({
94
- inputTokens: input.inputTokens.tokens,
95
- outputTokens: input.outputTokenAllowance
96
- });
97
- }
98
- if (money) {
99
- estimates.push({ meter: "cost.catalogEstimated", amount: money });
100
- }
101
- } catch {
102
- return estimates;
103
- }
60
+ function aiModelCallOutputTokenAllowance(maxOutputTokens) {
61
+ if (maxOutputTokens === undefined)
62
+ return AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE;
63
+ if (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens <= 0) {
64
+ throw new TypeError("[SixbModels] AI model-call maxOutputTokens must be a positive safe integer.");
104
65
  }
105
- return estimates;
66
+ return maxOutputTokens;
106
67
  }
107
- function reservationIdentity(input) {
108
- return {
109
- projectId: input.projectId,
110
- executionId: input.executionId,
111
- attempt: input.attempt,
112
- callId: input.callId
113
- };
68
+ function estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance) {
69
+ if (inputTokens.status !== "estimated")
70
+ return;
71
+ const total = inputTokens.tokens + outputTokenAllowance;
72
+ if (!Number.isSafeInteger(total)) {
73
+ throw new TypeError("[SixbModels] AI model-call token estimate exceeds the safe range.");
74
+ }
75
+ return total;
114
76
  }
115
- function limitStorageUnavailable(error) {
116
- if (isSixbError2(error) && (error.code === "ai.usage_limit_exceeded" || error.code === "ai.usage_limit_unavailable")) {
117
- return error;
77
+ function containsNonTextInput(value, seen = new WeakSet) {
78
+ if (value === null || typeof value !== "object")
79
+ return false;
80
+ if (value instanceof URL || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || typeof Blob !== "undefined" && value instanceof Blob) {
81
+ return true;
118
82
  }
119
- return aiUsageLimitUnavailableError2(["limitStorageUnavailable"]);
83
+ if (seen.has(value))
84
+ return false;
85
+ seen.add(value);
86
+ if (!Array.isArray(value)) {
87
+ const type = Reflect.get(value, "type");
88
+ if (type === "image" || type === "file" || type === "reasoning-file" || type === "custom" || type === "provider-state") {
89
+ return true;
90
+ }
91
+ }
92
+ return Object.values(value).some((entry) => containsNonTextInput(entry, seen));
120
93
  }
121
94
 
122
95
  // src/models/execution/errors.ts
@@ -132,6 +105,167 @@ class ModelUsageRecordingError2 extends Error {
132
105
  this.recoveryScheduled = recoveryScheduled;
133
106
  }
134
107
  }
108
+ function isModelCallAccountingFailure2(error) {
109
+ return error instanceof ModelUsageRecordingError2 || isSixbError2(error) && (error.code === "ai.usage_limit_exceeded" || error.code === "ai.usage_limit_unavailable");
110
+ }
111
+
112
+ // src/models/language-call.ts
113
+ class LanguageModelCallMeter {
114
+ usage = {};
115
+ responseId;
116
+ providerIds;
117
+ responseModelId;
118
+ reportedCost;
119
+ route;
120
+ settled = false;
121
+ get finished() {
122
+ return this.settled;
123
+ }
124
+ accept(event) {
125
+ if (event.type === "response-metadata") {
126
+ this.responseId = event.id ?? this.responseId;
127
+ if (event.providerIds)
128
+ this.providerIds = { ...this.providerIds, ...event.providerIds };
129
+ this.responseModelId = event.modelId ?? this.responseModelId;
130
+ } else if (event.type === "finish") {
131
+ this.settled = true;
132
+ this.usage = event.usage;
133
+ this.reportedCost = event.reportedCost;
134
+ this.route = event.route;
135
+ }
136
+ }
137
+ facts() {
138
+ return {
139
+ usage: this.usage,
140
+ ...this.responseId === undefined ? {} : { responseId: this.responseId },
141
+ ...this.providerIds === undefined ? {} : { providerIds: this.providerIds },
142
+ ...this.responseModelId === undefined ? {} : { responseModelId: this.responseModelId },
143
+ ...this.reportedCost === undefined ? {} : { reportedCost: this.reportedCost },
144
+ ...this.route === undefined ? {} : { route: this.route }
145
+ };
146
+ }
147
+ end(call) {
148
+ const facts = this.facts();
149
+ const estimate = this.settled ? estimateModelCall(call.model, facts) : { status: "unpriceable", reason: "missing-usage" };
150
+ const cost = facts.reportedCost ? rateModelCall2({ usage: facts.usage, reported: facts.reportedCost }) : estimate;
151
+ return {
152
+ callId: call.callId,
153
+ modelKind: "language",
154
+ providerId: call.model.providerId,
155
+ modelId: call.model.modelId,
156
+ responseId: facts.responseId ?? `${call.callId}:response`,
157
+ providerIds: facts.providerIds,
158
+ responseModelId: facts.responseModelId,
159
+ usage: facts.usage,
160
+ cost,
161
+ ...facts.reportedCost === undefined ? {} : { estimate },
162
+ ...call.requestedReasoning === undefined ? {} : { requestedReasoning: call.requestedReasoning },
163
+ ...facts.route === undefined ? {} : { route: facts.route }
164
+ };
165
+ }
166
+ }
167
+ var MODEL_CALL_IDLE_MS = 10 * 60000;
168
+ function reportModelCalls2(model, onEnd) {
169
+ const { providerId, modelId, definition, costEstimator, rateCard } = model;
170
+ const { defaultReasoning, maxOutputTokens } = model;
171
+ return {
172
+ providerId,
173
+ modelId,
174
+ definition,
175
+ ...costEstimator === undefined ? {} : { costEstimator },
176
+ ...rateCard === undefined ? {} : { rateCard },
177
+ ...defaultReasoning === undefined ? {} : { defaultReasoning },
178
+ ...maxOutputTokens === undefined ? {} : { maxOutputTokens },
179
+ ...model.validateResponseFormat === undefined ? {} : { validateResponseFormat: model.validateResponseFormat.bind(model) },
180
+ stream: async (request) => {
181
+ const stop = new AbortController;
182
+ const opening = model.stream({
183
+ ...request,
184
+ signal: AbortSignal.any([request.signal, stop.signal])
185
+ });
186
+ const opened = await withinIdle(opening, stop, (late) => closeEvents(late.events));
187
+ return { ...opened, events: reportedEvents(model, request, opened, stop, onEnd) };
188
+ }
189
+ };
190
+ }
191
+ function reportedEvents(model, request, stream, stop, onEnd) {
192
+ const meter = new LanguageModelCallMeter;
193
+ let reported;
194
+ const report = () => {
195
+ reported ??= (async () => onEnd(meter.end({
196
+ model,
197
+ callId: request.callId,
198
+ ...request.reasoning === undefined ? {} : { requestedReasoning: request.reasoning }
199
+ })))();
200
+ return reported;
201
+ };
202
+ let source;
203
+ let done = false;
204
+ const events = {
205
+ async next() {
206
+ if (done)
207
+ return { done: true, value: undefined };
208
+ source ??= stream.events[Symbol.asyncIterator]();
209
+ let result;
210
+ try {
211
+ result = await withinIdle(source.next(), stop);
212
+ } catch (error) {
213
+ done = true;
214
+ if (stop.signal.aborted)
215
+ closeEvents(source);
216
+ await report();
217
+ throw error;
218
+ }
219
+ if (result.done) {
220
+ done = true;
221
+ await report();
222
+ return result;
223
+ }
224
+ meter.accept(result.value);
225
+ if (result.value.type === "finish")
226
+ await report();
227
+ return result;
228
+ },
229
+ async return(value) {
230
+ done = true;
231
+ if (!reported)
232
+ stop.abort(new DOMException("The reader let the model call go.", "AbortError"));
233
+ if (source)
234
+ closeEvents(source);
235
+ else
236
+ closeEvents(stream.events);
237
+ try {
238
+ await report();
239
+ } catch (error) {
240
+ console.error(`[SixbModels] Model call '${request.callId}' ended early, and recording it failed.`, error);
241
+ throw error;
242
+ }
243
+ return { done: true, value };
244
+ }
245
+ };
246
+ return { [Symbol.asyncIterator]: () => events };
247
+ }
248
+ async function withinIdle(pending, stop, onLate) {
249
+ let timer;
250
+ const silence = new Promise((_, reject) => {
251
+ timer = setTimeout(() => {
252
+ const error = new ModelStreamError2(`[SixbModels] The model sent nothing for ${MODEL_CALL_IDLE_MS / 60000} minutes.`);
253
+ stop.abort(error);
254
+ reject(error);
255
+ }, MODEL_CALL_IDLE_MS);
256
+ });
257
+ try {
258
+ return await Promise.race([pending, silence]);
259
+ } finally {
260
+ clearTimeout(timer);
261
+ if (stop.signal.aborted)
262
+ pending.then(onLate, () => {});
263
+ }
264
+ }
265
+ function closeEvents(events) {
266
+ const iterator = Symbol.asyncIterator in events ? events[Symbol.asyncIterator]() : events;
267
+ Promise.resolve().then(() => iterator.return?.()).catch(() => {});
268
+ }
135
269
 
136
270
  // src/models/execution/model-call-accounting.ts
137
271
  import { createHash } from "crypto";
@@ -264,6 +398,100 @@ function requireAccountingCapabilities(storage) {
264
398
  return { aiUsage: storage.aiUsage, aiCosts: storage.aiCosts, aiLimits: storage.aiLimits };
265
399
  }
266
400
 
401
+ // src/models/execution/model-call-limits.ts
402
+ function createAiModelCallLimitController2(input) {
403
+ const subjects = aiLimitSubjectsFromAttribution2(input.requestedBy, input.requesterGroupIds);
404
+ return {
405
+ beforeModelCall: async (admission) => {
406
+ let applicable;
407
+ try {
408
+ const policies = await input.storage.aiLimits.listPolicies({
409
+ projectId: input.projectId
410
+ });
411
+ applicable = applicableAiLimitPolicies2(policies, subjects).filter((policy) => aiLimitMeterApplies2(policy.limit.meter, admission.modelKind));
412
+ } catch (error) {
413
+ throw limitStorageUnavailable(error);
414
+ }
415
+ if (applicable.length === 0)
416
+ return { reservation: "none" };
417
+ const estimates = reservationEstimates(admission, applicable.some((policy) => policy.limit.meter === "cost.catalogEstimated"));
418
+ if (estimates.length === 0) {
419
+ throw aiUsageLimitUnavailableError2(["missingEstimate"]);
420
+ }
421
+ let result;
422
+ try {
423
+ result = await input.storage.aiLimits.reserveModelCall({
424
+ ...reservationIdentity(admission),
425
+ subjects,
426
+ estimates,
427
+ ...admission.modelKind === undefined ? {} : { modelKind: admission.modelKind }
428
+ });
429
+ } catch (error) {
430
+ throw limitStorageUnavailable(error);
431
+ }
432
+ switch (result.status) {
433
+ case "reserved":
434
+ return { reservation: "active" };
435
+ case "notRequired":
436
+ return { reservation: "none" };
437
+ case "denied":
438
+ throw aiUsageLimitExceededError2(result.resetAt);
439
+ case "unavailable":
440
+ throw aiUsageLimitUnavailableError2(result.reasons);
441
+ case "terminal":
442
+ throw aiUsageLimitUnavailableError2(["terminalReservationReplay"]);
443
+ }
444
+ },
445
+ markModelCallUnknown: async (identity) => {
446
+ try {
447
+ await input.storage.aiLimits.markReservationUnknown(identity);
448
+ } catch (error) {
449
+ throw limitStorageUnavailable(error);
450
+ }
451
+ }
452
+ };
453
+ }
454
+ function reservationEstimates(input, needsCost) {
455
+ const estimates = [];
456
+ if (input.inputTokens.status === "estimated" && input.estimatedTotalTokens !== undefined) {
457
+ estimates.push({ meter: "tokens.total", amount: input.estimatedTotalTokens });
458
+ }
459
+ if (needsCost) {
460
+ try {
461
+ let money = input.reservationCost;
462
+ if (money == null && input.inputTokens.status === "estimated") {
463
+ money = input.costEstimator?.estimateReservation?.({
464
+ inputTokens: input.inputTokens.tokens,
465
+ outputTokens: input.outputTokenAllowance
466
+ });
467
+ }
468
+ if (money) {
469
+ estimates.push({ meter: "cost.catalogEstimated", amount: money });
470
+ }
471
+ } catch {
472
+ return estimates;
473
+ }
474
+ }
475
+ return estimates;
476
+ }
477
+ function reservationIdentity(input) {
478
+ return {
479
+ projectId: input.projectId,
480
+ executionId: input.executionId,
481
+ attempt: input.attempt,
482
+ callId: input.callId
483
+ };
484
+ }
485
+ function limitStorageUnavailable(error) {
486
+ if (isSixbError2(error) && (error.code === "ai.usage_limit_exceeded" || error.code === "ai.usage_limit_unavailable")) {
487
+ return error;
488
+ }
489
+ return aiUsageLimitUnavailableError2(["limitStorageUnavailable"]);
490
+ }
491
+
492
+ // src/models/execution/model-call-recorder.ts
493
+ import { randomUUID } from "crypto";
494
+
267
495
  // src/models/execution/usage.ts
268
496
  function aiModelCallUsageFromModel(usage) {
269
497
  return {
@@ -354,66 +582,6 @@ function parseDate(value, jobId, field) {
354
582
  return date;
355
583
  }
356
584
 
357
- // src/models/execution/model-call-recorder.ts
358
- import { randomUUID } from "crypto";
359
-
360
- // src/models/execution/model-call-admission.ts
361
- var AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE = 4096;
362
- function estimateAiModelCallInputTokens(input) {
363
- if (containsNonTextInput(input.prompt)) {
364
- return { status: "unavailable", reason: "nonTextInput" };
365
- }
366
- let serialized;
367
- try {
368
- serialized = JSON.stringify(input);
369
- } catch {
370
- return { status: "unavailable", reason: "unserializableInput" };
371
- }
372
- if (serialized === undefined) {
373
- return { status: "unavailable", reason: "unserializableInput" };
374
- }
375
- const bytes = new TextEncoder().encode(serialized).byteLength;
376
- return {
377
- status: "estimated",
378
- tokens: Math.ceil(bytes / 4),
379
- method: "utf8BytesDividedByFour"
380
- };
381
- }
382
- function aiModelCallOutputTokenAllowance(maxOutputTokens) {
383
- if (maxOutputTokens === undefined)
384
- return AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE;
385
- if (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens <= 0) {
386
- throw new TypeError("[SixbModels] AI model-call maxOutputTokens must be a positive safe integer.");
387
- }
388
- return maxOutputTokens;
389
- }
390
- function estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance) {
391
- if (inputTokens.status !== "estimated")
392
- return;
393
- const total = inputTokens.tokens + outputTokenAllowance;
394
- if (!Number.isSafeInteger(total)) {
395
- throw new TypeError("[SixbModels] AI model-call token estimate exceeds the safe range.");
396
- }
397
- return total;
398
- }
399
- function containsNonTextInput(value, seen = new WeakSet) {
400
- if (value === null || typeof value !== "object")
401
- return false;
402
- if (value instanceof URL || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || typeof Blob !== "undefined" && value instanceof Blob) {
403
- return true;
404
- }
405
- if (seen.has(value))
406
- return false;
407
- seen.add(value);
408
- if (!Array.isArray(value)) {
409
- const type = Reflect.get(value, "type");
410
- if (type === "image" || type === "file" || type === "reasoning-file" || type === "custom" || type === "provider-state") {
411
- return true;
412
- }
413
- }
414
- return Object.values(value).some((entry) => containsNonTextInput(entry, seen));
415
- }
416
-
417
585
  // src/models/execution/model-call-recorder.ts
418
586
  var STORAGE_RETRY_DELAYS_MS = [50, 200, 600];
419
587
 
@@ -445,12 +613,9 @@ class AiModelCallRecorder2 {
445
613
  return this.input.attempt;
446
614
  }
447
615
  wrapModel(model) {
616
+ const recorded = reportModelCalls2(model, this.onModelCallEnd);
448
617
  return {
449
- providerId: model.providerId,
450
- modelId: model.modelId,
451
- definition: model.definition,
452
- costEstimator: model.costEstimator,
453
- ...model.validateResponseFormat === undefined ? {} : { validateResponseFormat: model.validateResponseFormat.bind(model) },
618
+ ...recorded,
454
619
  stream: async (request) => {
455
620
  this.assertHealthy();
456
621
  const inputTokens = estimateAiModelCallInputTokens({
@@ -469,7 +634,7 @@ class AiModelCallRecorder2 {
469
634
  estimatedTotalTokens: estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance)
470
635
  });
471
636
  try {
472
- return await model.stream(request);
637
+ return await recorded.stream(request);
473
638
  } catch (error) {
474
639
  await this.markCallUnknown(request.callId);
475
640
  throw error;
@@ -612,6 +777,6 @@ async function enqueueAiModelCallRecovery2(queue, input) {
612
777
  }
613
778
  }
614
779
 
615
- export { AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE, aiModelCallOutputTokenAllowance, requireAccountingCapabilities, createAiModelCallLimitController2, ModelUsageRecordingError2, recordRecoveredAiModelCall2, isPermanentAiUsageRecoveryError2, AiModelCallRecorder2, enqueueAiModelCallRecovery2 };
780
+ export { AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE, aiModelCallOutputTokenAllowance, ModelUsageRecordingError2, isModelCallAccountingFailure2, LanguageModelCallMeter, reportModelCalls2, requireAccountingCapabilities, createAiModelCallLimitController2, recordRecoveredAiModelCall2, isPermanentAiUsageRecoveryError2, AiModelCallRecorder2, enqueueAiModelCallRecovery2 };
616
781
 
617
- //# debugId=8311E82DEB61C61564756E2164756E21
782
+ //# debugId=E9009B4AC2DD257B64756E2164756E21