@sixb/core 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (691) hide show
  1. package/dist/actions/index.js +53 -50
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/request.d.ts.map +1 -1
  4. package/dist/actions/run/context.d.ts.map +1 -1
  5. package/dist/actions/run/execute.d.ts +3 -0
  6. package/dist/actions/run/execute.d.ts.map +1 -1
  7. package/dist/actions/run/executor.d.ts +3 -0
  8. package/dist/actions/run/executor.d.ts.map +1 -1
  9. package/dist/actions/run/normalize.d.ts.map +1 -1
  10. package/dist/actions/run/types.d.ts +6 -0
  11. package/dist/actions/run/types.d.ts.map +1 -1
  12. package/dist/actions/types/context.d.ts +7 -0
  13. package/dist/actions/types/context.d.ts.map +1 -1
  14. package/dist/agents/context/entries.d.ts +17 -0
  15. package/dist/agents/context/entries.d.ts.map +1 -1
  16. package/dist/agents/context/index.js +3 -2
  17. package/dist/agents/context/index.js.map +1 -1
  18. package/dist/agents/context-model.d.ts.map +1 -1
  19. package/dist/agents/context-resolution.d.ts.map +1 -1
  20. package/dist/agents/execution.d.ts +7 -0
  21. package/dist/agents/execution.d.ts.map +1 -1
  22. package/dist/agents/index.d.ts +1 -1
  23. package/dist/agents/index.d.ts.map +1 -1
  24. package/dist/agents/index.js +62 -57
  25. package/dist/agents/index.js.map +1 -1
  26. package/dist/agents/model-call-retry.d.ts +28 -0
  27. package/dist/agents/model-call-retry.d.ts.map +1 -0
  28. package/dist/agents/model-loop.d.ts +4 -2
  29. package/dist/agents/model-loop.d.ts.map +1 -1
  30. package/dist/agents/model-routing.d.ts +15 -4
  31. package/dist/agents/model-routing.d.ts.map +1 -1
  32. package/dist/agents/request.d.ts.map +1 -1
  33. package/dist/agents/run-artifacts.d.ts +2 -0
  34. package/dist/agents/run-artifacts.d.ts.map +1 -1
  35. package/dist/agents/run-plan.d.ts +1 -1
  36. package/dist/agents/run-plan.d.ts.map +1 -1
  37. package/dist/agents/run-session-http.d.ts.map +1 -1
  38. package/dist/agents/run-session-serve.d.ts.map +1 -1
  39. package/dist/agents/run-session-wire.d.ts +6 -0
  40. package/dist/agents/run-session-wire.d.ts.map +1 -1
  41. package/dist/agents/run-token.d.ts +6 -0
  42. package/dist/agents/run-token.d.ts.map +1 -1
  43. package/dist/agents/streams/index.js +1 -1
  44. package/dist/agents/streams/internal.js +2 -2
  45. package/dist/agents/thread-access.d.ts +13 -0
  46. package/dist/agents/thread-access.d.ts.map +1 -1
  47. package/dist/agents/tool-files.d.ts.map +1 -1
  48. package/dist/artifacts/caller.d.ts +10 -0
  49. package/dist/artifacts/caller.d.ts.map +1 -0
  50. package/dist/artifacts/comment-place.d.ts +26 -0
  51. package/dist/artifacts/comment-place.d.ts.map +1 -0
  52. package/dist/artifacts/comment-text.d.ts +12 -4
  53. package/dist/artifacts/comment-text.d.ts.map +1 -1
  54. package/dist/artifacts/comments.d.ts +8 -2
  55. package/dist/artifacts/comments.d.ts.map +1 -1
  56. package/dist/artifacts/errors.d.ts +1 -1
  57. package/dist/artifacts/errors.d.ts.map +1 -1
  58. package/dist/artifacts/execution.d.ts +73 -5
  59. package/dist/artifacts/execution.d.ts.map +1 -1
  60. package/dist/artifacts/frames/assets.d.ts +27 -7
  61. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  62. package/dist/artifacts/frames/entries.d.ts +5 -4
  63. package/dist/artifacts/frames/entries.d.ts.map +1 -1
  64. package/dist/artifacts/frames/hyperframes.d.ts +12 -0
  65. package/dist/artifacts/frames/hyperframes.d.ts.map +1 -0
  66. package/dist/artifacts/frames/index.d.ts +3 -1
  67. package/dist/artifacts/frames/index.d.ts.map +1 -1
  68. package/dist/artifacts/frames/index.js +20 -6
  69. package/dist/artifacts/frames/index.js.map +3 -3
  70. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  71. package/dist/artifacts/frames/protocol.d.ts +33 -0
  72. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  73. package/dist/artifacts/frames/video-runtime.d.ts +21 -0
  74. package/dist/artifacts/frames/video-runtime.d.ts.map +1 -0
  75. package/dist/artifacts/html.d.ts +23 -0
  76. package/dist/artifacts/html.d.ts.map +1 -1
  77. package/dist/artifacts/index.d.ts +5 -3
  78. package/dist/artifacts/index.d.ts.map +1 -1
  79. package/dist/artifacts/index.js +71 -10
  80. package/dist/artifacts/index.js.map +4 -4
  81. package/dist/artifacts/kinds.d.ts +1 -1
  82. package/dist/artifacts/kinds.d.ts.map +1 -1
  83. package/dist/artifacts/limits.d.ts +37 -0
  84. package/dist/artifacts/limits.d.ts.map +1 -1
  85. package/dist/artifacts/live/document.d.ts.map +1 -1
  86. package/dist/artifacts/live/index.d.ts +6 -2
  87. package/dist/artifacts/live/index.d.ts.map +1 -1
  88. package/dist/artifacts/live/index.js +3432 -13
  89. package/dist/artifacts/live/index.js.map +6 -3
  90. package/dist/artifacts/live/presence.d.ts +7 -5
  91. package/dist/artifacts/live/presence.d.ts.map +1 -1
  92. package/dist/artifacts/live/protocol.d.ts +4 -2
  93. package/dist/artifacts/live/protocol.d.ts.map +1 -1
  94. package/dist/artifacts/live/server.d.ts +1 -1
  95. package/dist/artifacts/live/server.d.ts.map +1 -1
  96. package/dist/artifacts/live/server.js +36 -31
  97. package/dist/artifacts/live/server.js.map +1 -1
  98. package/dist/artifacts/live/state.d.ts +2 -2
  99. package/dist/artifacts/media/media.d.ts +96 -0
  100. package/dist/artifacts/media/media.d.ts.map +1 -0
  101. package/dist/artifacts/media/transcriber.d.ts +29 -0
  102. package/dist/artifacts/media/transcriber.d.ts.map +1 -0
  103. package/dist/artifacts/outline.d.ts +26 -1
  104. package/dist/artifacts/outline.d.ts.map +1 -1
  105. package/dist/artifacts/publish/files.d.ts +5 -2
  106. package/dist/artifacts/publish/files.d.ts.map +1 -1
  107. package/dist/artifacts/publish/index.d.ts +11 -2
  108. package/dist/artifacts/publish/index.d.ts.map +1 -1
  109. package/dist/artifacts/publish/index.js +110 -33
  110. package/dist/artifacts/publish/index.js.map +1 -1
  111. package/dist/artifacts/publish/pdf.d.ts.map +1 -1
  112. package/dist/artifacts/publish/previews.d.ts +7 -2
  113. package/dist/artifacts/publish/previews.d.ts.map +1 -1
  114. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  115. package/dist/artifacts/publish/validate/html.d.ts +5 -4
  116. package/dist/artifacts/publish/validate/html.d.ts.map +1 -1
  117. package/dist/artifacts/publish/validate/video.d.ts +36 -0
  118. package/dist/artifacts/publish/validate/video.d.ts.map +1 -0
  119. package/dist/artifacts/publish/video.d.ts +79 -0
  120. package/dist/artifacts/publish/video.d.ts.map +1 -0
  121. package/dist/artifacts/resolve.d.ts +9 -0
  122. package/dist/artifacts/resolve.d.ts.map +1 -1
  123. package/dist/artifacts/video/composition.d.ts +183 -0
  124. package/dist/artifacts/video/composition.d.ts.map +1 -0
  125. package/dist/artifacts/video/edit.d.ts +298 -0
  126. package/dist/artifacts/video/edit.d.ts.map +1 -0
  127. package/dist/artifacts/video/export.d.ts +142 -0
  128. package/dist/artifacts/video/export.d.ts.map +1 -0
  129. package/dist/artifacts/video/looks.d.ts +133 -0
  130. package/dist/artifacts/video/looks.d.ts.map +1 -0
  131. package/dist/artifacts/video/project.d.ts +74 -0
  132. package/dist/artifacts/video/project.d.ts.map +1 -0
  133. package/dist/artifacts/video/stills.d.ts +65 -0
  134. package/dist/artifacts/video/stills.d.ts.map +1 -0
  135. package/dist/artifacts/video/timeline.d.ts +153 -0
  136. package/dist/artifacts/video/timeline.d.ts.map +1 -0
  137. package/dist/auth/index.js +9 -8
  138. package/dist/auth/index.js.map +1 -1
  139. package/dist/authorization/index.js +5 -4
  140. package/dist/authorization/index.js.map +1 -1
  141. package/dist/blob-storage/browser.d.ts +1 -1
  142. package/dist/blob-storage/browser.d.ts.map +1 -1
  143. package/dist/blob-storage/browser.js +8 -4
  144. package/dist/blob-storage/browser.js.map +1 -1
  145. package/dist/blob-storage/constants.d.ts +8 -3
  146. package/dist/blob-storage/constants.d.ts.map +1 -1
  147. package/dist/blob-storage/download-urls.d.ts +2 -2
  148. package/dist/blob-storage/download-urls.d.ts.map +1 -1
  149. package/dist/blob-storage/index.d.ts +1 -1
  150. package/dist/blob-storage/index.d.ts.map +1 -1
  151. package/dist/blob-storage/index.js +9 -5
  152. package/dist/blob-storage/index.js.map +1 -1
  153. package/dist/blob-storage/internal.d.ts +2 -2
  154. package/dist/blob-storage/internal.d.ts.map +1 -1
  155. package/dist/blob-storage/internal.js +10 -4
  156. package/dist/blob-storage/internal.js.map +1 -1
  157. package/dist/blob-storage/media-type.d.ts +12 -3
  158. package/dist/blob-storage/media-type.d.ts.map +1 -1
  159. package/dist/bootstrap/discovery.d.ts +6 -0
  160. package/dist/bootstrap/discovery.d.ts.map +1 -1
  161. package/dist/bootstrap/index.js +63 -60
  162. package/dist/bootstrap/index.js.map +2 -2
  163. package/dist/{chunk-az95tsh3.js → chunk-0fjryajn.js} +3 -2
  164. package/dist/chunk-0fjryajn.js.map +11 -0
  165. package/dist/{chunk-9tpmfh3n.js → chunk-0mk8qqp9.js} +3 -3
  166. package/dist/{chunk-9tpmfh3n.js.map → chunk-0mk8qqp9.js.map} +3 -3
  167. package/dist/{chunk-88xeh6zx.js → chunk-1g4me5f2.js} +182 -7
  168. package/dist/{chunk-88xeh6zx.js.map → chunk-1g4me5f2.js.map} +3 -3
  169. package/dist/{chunk-7mhbs9yy.js → chunk-1z8ccj53.js} +1 -1
  170. package/dist/{chunk-wkv3h3q7.js → chunk-2138b0ng.js} +115 -8
  171. package/dist/chunk-2138b0ng.js.map +12 -0
  172. package/dist/chunk-23eaayw4.js +3757 -0
  173. package/dist/chunk-23eaayw4.js.map +22 -0
  174. package/dist/{chunk-s8xxef60.js → chunk-2mxq1yd9.js} +48 -41
  175. package/dist/{chunk-s8xxef60.js.map → chunk-2mxq1yd9.js.map} +6 -6
  176. package/dist/{chunk-dmnd9ea6.js → chunk-30a0ftnm.js} +2 -2
  177. package/dist/{chunk-nxysqbt0.js → chunk-389ybvw9.js} +6 -2
  178. package/dist/chunk-389ybvw9.js.map +10 -0
  179. package/dist/{chunk-qbd282aa.js → chunk-39q9ybav.js} +2 -2
  180. package/dist/{chunk-9c9yknwt.js → chunk-3d9w8t4n.js} +111 -23
  181. package/dist/{chunk-9c9yknwt.js.map → chunk-3d9w8t4n.js.map} +5 -5
  182. package/dist/chunk-3dvcdn9w.js +8 -0
  183. package/dist/chunk-3dvcdn9w.js.map +10 -0
  184. package/dist/{chunk-bcz9dxtf.js → chunk-3x902cja.js} +3 -3
  185. package/dist/{chunk-c4nrycdy.js → chunk-4q4a5a96.js} +1 -1
  186. package/dist/{chunk-7r9mqpva.js → chunk-4tdm3fsj.js} +100 -36
  187. package/dist/{chunk-7r9mqpva.js.map → chunk-4tdm3fsj.js.map} +10 -10
  188. package/dist/{chunk-ykchk644.js → chunk-4w8qzy9w.js} +6 -6
  189. package/dist/{chunk-c29729me.js → chunk-4z9xtxke.js} +8 -7
  190. package/dist/chunk-4z9xtxke.js.map +12 -0
  191. package/dist/chunk-5278qwax.js +270 -0
  192. package/dist/chunk-5278qwax.js.map +11 -0
  193. package/dist/{chunk-kft7mp7z.js → chunk-5xkqasvn.js} +1 -1
  194. package/dist/{chunk-k1g14kk3.js → chunk-6a4hp405.js} +4 -5
  195. package/dist/{chunk-k1g14kk3.js.map → chunk-6a4hp405.js.map} +3 -3
  196. package/dist/{chunk-xavet0qs.js → chunk-6whr25gw.js} +2 -2
  197. package/dist/{chunk-mbwsgjn7.js → chunk-7zygtcqq.js} +14 -2
  198. package/dist/chunk-7zygtcqq.js.map +11 -0
  199. package/dist/chunk-88s9z5pf.js +3 -0
  200. package/dist/{chunk-de5sfbc3.js.map → chunk-88s9z5pf.js.map} +1 -1
  201. package/dist/{chunk-ygvay56w.js → chunk-896te58g.js} +2 -2
  202. package/dist/{chunk-pqj8vff9.js → chunk-8eqqqc1h.js} +3 -3
  203. package/dist/{chunk-425ydk65.js → chunk-8tefbhdx.js} +14 -14
  204. package/dist/{chunk-425ydk65.js.map → chunk-8tefbhdx.js.map} +1 -1
  205. package/dist/{chunk-jka26v8c.js → chunk-8x1bsp68.js} +1 -1
  206. package/dist/{chunk-wzcjhv54.js → chunk-93e4w7te.js} +113 -1
  207. package/dist/chunk-93e4w7te.js.map +11 -0
  208. package/dist/{chunk-ym1bqd98.js → chunk-990a5bkc.js} +424 -76
  209. package/dist/chunk-990a5bkc.js.map +21 -0
  210. package/dist/{chunk-fmgf9h5e.js → chunk-9az7kjv4.js} +6 -6
  211. package/dist/{chunk-eg6xqef7.js → chunk-9e5t53z0.js} +3 -3
  212. package/dist/{chunk-eg6xqef7.js.map → chunk-9e5t53z0.js.map} +3 -3
  213. package/dist/{chunk-bs1sd0e0.js → chunk-9p7kyeqz.js} +4 -4
  214. package/dist/chunk-a68zz4r0.js +537 -0
  215. package/dist/chunk-a68zz4r0.js.map +11 -0
  216. package/dist/{chunk-d7vyc7k6.js → chunk-a700gjc8.js} +10 -2
  217. package/dist/chunk-a700gjc8.js.map +10 -0
  218. package/dist/{chunk-gfdh9kqa.js → chunk-a9qzjaz2.js} +2 -5
  219. package/dist/chunk-a9qzjaz2.js.map +10 -0
  220. package/dist/{chunk-ats8y3d9.js → chunk-as94vcty.js} +688 -504
  221. package/dist/{chunk-ats8y3d9.js.map → chunk-as94vcty.js.map} +21 -21
  222. package/dist/{chunk-brybqw5k.js → chunk-bkxm2dzx.js} +1 -1
  223. package/dist/{chunk-ppxf7gw2.js → chunk-d7t9jnym.js} +3 -3
  224. package/dist/{chunk-tapdssb5.js → chunk-e3b1r4d2.js} +8 -7
  225. package/dist/{chunk-tapdssb5.js.map → chunk-e3b1r4d2.js.map} +4 -4
  226. package/dist/{chunk-cg7cygfj.js → chunk-fdmvaz7x.js} +1 -1
  227. package/dist/{chunk-191jz8a6.js → chunk-ff0qdk7z.js} +1 -1
  228. package/dist/{chunk-9vsc919v.js → chunk-fgxvrxx4.js} +22 -2
  229. package/dist/chunk-fgxvrxx4.js.map +10 -0
  230. package/dist/{chunk-wx7smkn2.js → chunk-fq8drkp0.js} +1 -1
  231. package/dist/{chunk-60662fyv.js → chunk-fqms1a8c.js} +132 -4
  232. package/dist/{chunk-60662fyv.js.map → chunk-fqms1a8c.js.map} +8 -6
  233. package/dist/{chunk-v8a1qjzp.js → chunk-hpswfrjj.js} +1 -1
  234. package/dist/{chunk-qttqe1ah.js → chunk-jbg905hn.js} +80 -13
  235. package/dist/chunk-jbg905hn.js.map +25 -0
  236. package/dist/{chunk-bz5bnjjt.js → chunk-jjte0h4p.js} +1 -1
  237. package/dist/{chunk-jt012fxq.js → chunk-jwjwvzj1.js} +797 -51
  238. package/dist/chunk-jwjwvzj1.js.map +38 -0
  239. package/dist/{chunk-f05994as.js → chunk-k3vd2vyz.js} +6 -2
  240. package/dist/chunk-k3vd2vyz.js.map +10 -0
  241. package/dist/chunk-kcqpk9w1.js.map +2 -2
  242. package/dist/chunk-mvz89age.js.map +2 -2
  243. package/dist/{chunk-xrmbhap8.js → chunk-mwg0nwkb.js} +1 -1
  244. package/dist/{chunk-a3faa34j.js → chunk-nfjt8k8j.js} +1 -1
  245. package/dist/{chunk-394zjzjs.js → chunk-nhgqz3g3.js} +3 -3
  246. package/dist/{chunk-bqr703h4.js → chunk-p0c5kkhn.js} +23 -6
  247. package/dist/{chunk-bqr703h4.js.map → chunk-p0c5kkhn.js.map} +3 -3
  248. package/dist/{chunk-92wrka15.js → chunk-q150fnj9.js} +1 -1
  249. package/dist/{chunk-w3t94hm6.js → chunk-qk3zq25v.js} +1 -1
  250. package/dist/{chunk-6hfbz4d0.js → chunk-r588h4ev.js} +1 -1
  251. package/dist/chunk-rtkqczbr.js.map +2 -2
  252. package/dist/{chunk-3qtk0070.js → chunk-ssqbrts1.js} +86 -9
  253. package/dist/chunk-ssqbrts1.js.map +14 -0
  254. package/dist/{chunk-5qqmndhm.js → chunk-szzhrn3e.js} +1 -1
  255. package/dist/{chunk-n1hbwc6y.js → chunk-t6pfch4e.js} +1 -1
  256. package/dist/{chunk-xtztwpkh.js → chunk-v6h4tc2v.js} +86 -5
  257. package/dist/chunk-v6h4tc2v.js.map +12 -0
  258. package/dist/{chunk-brhp9d97.js → chunk-vmqjndb3.js} +2 -2
  259. package/dist/chunk-vtjzwymr.js.map +2 -2
  260. package/dist/{chunk-t19wjmnc.js → chunk-wpba6hhd.js} +54 -20
  261. package/dist/{chunk-t19wjmnc.js.map → chunk-wpba6hhd.js.map} +3 -3
  262. package/dist/{chunk-htdzx40w.js → chunk-wrb1x1ss.js} +12 -4
  263. package/dist/{chunk-htdzx40w.js.map → chunk-wrb1x1ss.js.map} +3 -3
  264. package/dist/{chunk-5sswe5ej.js → chunk-wsv23wvr.js} +2 -2
  265. package/dist/{chunk-90nqenq8.js → chunk-x0hqc54n.js} +4 -4
  266. package/dist/{chunk-sgx82nnt.js → chunk-xg31er4p.js} +43 -4
  267. package/dist/chunk-xg31er4p.js.map +10 -0
  268. package/dist/{chunk-3neam1y5.js → chunk-y3qb965a.js} +2 -2
  269. package/dist/{chunk-gaj8djsw.js → chunk-y57eawng.js} +10 -5
  270. package/dist/{chunk-gaj8djsw.js.map → chunk-y57eawng.js.map} +3 -3
  271. package/dist/{chunk-8ncg20rd.js → chunk-yah25st6.js} +5 -5
  272. package/dist/chunk-yah25st6.js.map +10 -0
  273. package/dist/{chunk-grt2j5vp.js → chunk-ywvxcmqj.js} +106 -13
  274. package/dist/{chunk-grt2j5vp.js.map → chunk-ywvxcmqj.js.map} +8 -7
  275. package/dist/{chunk-xf76csps.js → chunk-zmq9xc9s.js} +70 -31
  276. package/dist/{chunk-xf76csps.js.map → chunk-zmq9xc9s.js.map} +4 -3
  277. package/dist/datasets/write.js +8 -7
  278. package/dist/datasets/write.js.map +1 -1
  279. package/dist/deploy/index.d.ts +1 -1
  280. package/dist/deploy/index.d.ts.map +1 -1
  281. package/dist/deploy/internal.js +2 -2
  282. package/dist/deploy/internal.js.map +2 -2
  283. package/dist/deploy/types.d.ts +8 -58
  284. package/dist/deploy/types.d.ts.map +1 -1
  285. package/dist/env/index.d.ts +10 -3
  286. package/dist/env/index.d.ts.map +1 -1
  287. package/dist/env/index.js.map +2 -2
  288. package/dist/errors/catalog.d.ts.map +1 -1
  289. package/dist/execution/agent.js +53 -50
  290. package/dist/execution/agent.js.map +1 -1
  291. package/dist/execution/kernel-operation.d.ts +1 -0
  292. package/dist/execution/kernel-operation.d.ts.map +1 -1
  293. package/dist/execution/primitive.js +53 -50
  294. package/dist/execution/primitive.js.map +1 -1
  295. package/dist/execution/request.js +54 -51
  296. package/dist/execution/request.js.map +2 -2
  297. package/dist/execution/types.d.ts +5 -0
  298. package/dist/execution/types.d.ts.map +1 -1
  299. package/dist/http/api-routes.d.ts.map +1 -1
  300. package/dist/http/index.js +1 -1
  301. package/dist/index.d.ts +7 -5
  302. package/dist/index.d.ts.map +1 -1
  303. package/dist/index.js +73 -67
  304. package/dist/index.js.map +1 -1
  305. package/dist/lake-storage/index.js +9 -8
  306. package/dist/lake-storage/index.js.map +1 -1
  307. package/dist/maintenance/index.js +9 -8
  308. package/dist/maintenance/index.js.map +2 -2
  309. package/dist/materializer/index.js +26 -24
  310. package/dist/materializer/index.js.map +1 -1
  311. package/dist/models/audio/runtime.d.ts +3 -1
  312. package/dist/models/audio/runtime.d.ts.map +1 -1
  313. package/dist/models/audio/speech.d.ts +2 -2
  314. package/dist/models/audio/speech.d.ts.map +1 -1
  315. package/dist/models/audio/types.d.ts +23 -3
  316. package/dist/models/audio/types.d.ts.map +1 -1
  317. package/dist/models/calls.d.ts +7 -0
  318. package/dist/models/calls.d.ts.map +1 -1
  319. package/dist/models/catalog.d.ts +5 -0
  320. package/dist/models/catalog.d.ts.map +1 -1
  321. package/dist/models/definitions.d.ts +3 -2
  322. package/dist/models/definitions.d.ts.map +1 -1
  323. package/dist/models/errors.d.ts +5 -3
  324. package/dist/models/errors.d.ts.map +1 -1
  325. package/dist/models/events.d.ts +2 -0
  326. package/dist/models/events.d.ts.map +1 -1
  327. package/dist/models/execution/index.d.ts +1 -0
  328. package/dist/models/execution/index.d.ts.map +1 -1
  329. package/dist/models/execution/index.js +33 -28
  330. package/dist/models/execution/index.js.map +1 -1
  331. package/dist/models/execution/model-call-limits.d.ts.map +1 -1
  332. package/dist/models/execution/model-call-recorder.d.ts +8 -0
  333. package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
  334. package/dist/models/execution/session.d.ts +12 -0
  335. package/dist/models/execution/session.d.ts.map +1 -1
  336. package/dist/models/execution/usage.d.ts.map +1 -1
  337. package/dist/models/execution.d.ts +1 -1
  338. package/dist/models/execution.d.ts.map +1 -1
  339. package/dist/models/generation-types.d.ts +2 -0
  340. package/dist/models/generation-types.d.ts.map +1 -1
  341. package/dist/models/index.d.ts +4 -2
  342. package/dist/models/index.d.ts.map +1 -1
  343. package/dist/models/index.js +2 -2
  344. package/dist/models/input-file.d.ts.map +1 -1
  345. package/dist/models/pricing.d.ts +2 -1
  346. package/dist/models/pricing.d.ts.map +1 -1
  347. package/dist/models/rate-card.d.ts +6 -0
  348. package/dist/models/rate-card.d.ts.map +1 -1
  349. package/dist/models/tools.d.ts +5 -0
  350. package/dist/models/tools.d.ts.map +1 -1
  351. package/dist/models/video/catalog.d.ts +13 -0
  352. package/dist/models/video/catalog.d.ts.map +1 -0
  353. package/dist/models/video/check.d.ts +76 -0
  354. package/dist/models/video/check.d.ts.map +1 -0
  355. package/dist/models/video/runtime.d.ts +21 -0
  356. package/dist/models/video/runtime.d.ts.map +1 -0
  357. package/dist/models/video/types.d.ts +188 -0
  358. package/dist/models/video/types.d.ts.map +1 -0
  359. package/dist/objects/execution.d.ts.map +1 -1
  360. package/dist/objects/index.js +53 -50
  361. package/dist/objects/index.js.map +1 -1
  362. package/dist/objects/query/index.js +25 -23
  363. package/dist/objects/query/index.js.map +1 -1
  364. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  365. package/dist/ontology/index.js +4 -4
  366. package/dist/ontology/internal.js +4 -4
  367. package/dist/pipelines/index.js +28 -26
  368. package/dist/pipelines/index.js.map +1 -1
  369. package/dist/projections/internal.js +26 -24
  370. package/dist/projections/internal.js.map +1 -1
  371. package/dist/queues/index.d.ts +1 -1
  372. package/dist/queues/index.d.ts.map +1 -1
  373. package/dist/queues/types.d.ts +103 -6
  374. package/dist/queues/types.d.ts.map +1 -1
  375. package/dist/runtime/create.d.ts.map +1 -1
  376. package/dist/runtime/definitions.d.ts +14 -0
  377. package/dist/runtime/definitions.d.ts.map +1 -1
  378. package/dist/runtime/host.d.ts +3 -1
  379. package/dist/runtime/host.d.ts.map +1 -1
  380. package/dist/runtime/index.d.ts +1 -1
  381. package/dist/runtime/index.d.ts.map +1 -1
  382. package/dist/runtime/internal.d.ts +3 -1
  383. package/dist/runtime/internal.d.ts.map +1 -1
  384. package/dist/runtime/internal.js +49 -43
  385. package/dist/runtime/internal.js.map +2 -2
  386. package/dist/runtime/resolve-definitions.d.ts +2 -1
  387. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  388. package/dist/runtime/sixb.d.ts.map +1 -1
  389. package/dist/sandboxes/errors.d.ts +19 -0
  390. package/dist/sandboxes/errors.d.ts.map +1 -1
  391. package/dist/sandboxes/exec.d.ts +2 -0
  392. package/dist/sandboxes/exec.d.ts.map +1 -1
  393. package/dist/sandboxes/index.d.ts +1 -1
  394. package/dist/sandboxes/index.d.ts.map +1 -1
  395. package/dist/sandboxes/index.js +14 -8
  396. package/dist/sandboxes/index.js.map +1 -1
  397. package/dist/sandboxes/sandbox.d.ts +15 -1
  398. package/dist/sandboxes/sandbox.d.ts.map +1 -1
  399. package/dist/security/public.d.ts +6 -4
  400. package/dist/security/public.d.ts.map +1 -1
  401. package/dist/security/public.js +5 -3
  402. package/dist/security/public.js.map +1 -1
  403. package/dist/shares/internal.js +25 -23
  404. package/dist/shares/internal.js.map +2 -2
  405. package/dist/storage/agents/in-memory.d.ts +2 -1
  406. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  407. package/dist/storage/agents/index.d.ts +1 -1
  408. package/dist/storage/agents/index.d.ts.map +1 -1
  409. package/dist/storage/agents/provider.d.ts.map +1 -1
  410. package/dist/storage/agents/provider.js +5 -5
  411. package/dist/storage/agents/types.d.ts +27 -1
  412. package/dist/storage/agents/types.d.ts.map +1 -1
  413. package/dist/storage/ai-cost/analytics.d.ts +1 -0
  414. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  415. package/dist/storage/ai-cost/groups.d.ts +2 -0
  416. package/dist/storage/ai-cost/groups.d.ts.map +1 -1
  417. package/dist/storage/ai-cost/provider.js +5 -5
  418. package/dist/storage/ai-cost/types.d.ts +2 -1
  419. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  420. package/dist/storage/ai-cost/validation.d.ts.map +1 -1
  421. package/dist/storage/ai-limits/enforcement.js +3 -3
  422. package/dist/storage/ai-limits/provider.js +2 -2
  423. package/dist/storage/ai-usage/in-memory.d.ts +8 -1
  424. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  425. package/dist/storage/ai-usage/index.d.ts +2 -2
  426. package/dist/storage/ai-usage/index.d.ts.map +1 -1
  427. package/dist/storage/ai-usage/record.d.ts +11 -1
  428. package/dist/storage/ai-usage/record.d.ts.map +1 -1
  429. package/dist/storage/ai-usage/types.d.ts +80 -1
  430. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  431. package/dist/storage/ai-usage/usage.d.ts +1 -1
  432. package/dist/storage/ai-usage/usage.d.ts.map +1 -1
  433. package/dist/storage/artifacts/in-memory.d.ts +25 -2
  434. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  435. package/dist/storage/artifacts/index.d.ts +1 -1
  436. package/dist/storage/artifacts/index.d.ts.map +1 -1
  437. package/dist/storage/artifacts/record.d.ts +12 -1
  438. package/dist/storage/artifacts/record.d.ts.map +1 -1
  439. package/dist/storage/artifacts/types.d.ts +198 -6
  440. package/dist/storage/artifacts/types.d.ts.map +1 -1
  441. package/dist/storage/executions/provider.js +3 -2
  442. package/dist/storage/executions/provider.js.map +1 -1
  443. package/dist/storage/file-upload-sessions/provider.js +10 -9
  444. package/dist/storage/file-upload-sessions/provider.js.map +1 -1
  445. package/dist/storage/in-memory/index.d.ts.map +1 -1
  446. package/dist/storage/index.d.ts +4 -4
  447. package/dist/storage/index.d.ts.map +1 -1
  448. package/dist/storage/index.js +25 -23
  449. package/dist/storage/index.js.map +1 -1
  450. package/dist/storage/internal.d.ts +2 -2
  451. package/dist/storage/internal.d.ts.map +1 -1
  452. package/dist/storage/internal.js +34 -14
  453. package/dist/storage/internal.js.map +2 -2
  454. package/dist/storage/workflow-runs/provider.js +10 -9
  455. package/dist/storage/workflow-runs/provider.js.map +1 -1
  456. package/dist/syncs/index.js +29 -27
  457. package/dist/syncs/index.js.map +1 -1
  458. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  459. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  460. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  461. package/dist/testing/artifact-storage-contract.d.ts +3 -0
  462. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  463. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  464. package/dist/testing/index.js +686 -75
  465. package/dist/testing/index.js.map +10 -10
  466. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  467. package/dist/testing/queues-contract.d.ts.map +1 -1
  468. package/dist/testing/sandboxes-contract.d.ts.map +1 -1
  469. package/dist/webhooks/internal.js +26 -24
  470. package/dist/webhooks/internal.js.map +2 -2
  471. package/dist/workers/index.js +5 -5
  472. package/dist/workers/index.js.map +1 -1
  473. package/dist/workflows/index.js +60 -57
  474. package/dist/workflows/index.js.map +1 -1
  475. package/package.json +3 -1
  476. package/src/actions/request.ts +2 -0
  477. package/src/actions/run/context.ts +1 -0
  478. package/src/actions/run/execute.ts +5 -1
  479. package/src/actions/run/executor.ts +4 -0
  480. package/src/actions/run/normalize.ts +4 -0
  481. package/src/actions/run/types.ts +6 -0
  482. package/src/actions/types/context.ts +7 -0
  483. package/src/agents/README.md +3 -1
  484. package/src/agents/context/entries.ts +63 -9
  485. package/src/agents/context-model.ts +9 -0
  486. package/src/agents/context-resolution.ts +7 -0
  487. package/src/agents/execution.ts +39 -0
  488. package/src/agents/index.ts +1 -0
  489. package/src/agents/model-call-retry.ts +69 -0
  490. package/src/agents/model-loop.ts +86 -12
  491. package/src/agents/model-routing.ts +104 -38
  492. package/src/agents/request.ts +27 -1
  493. package/src/agents/run-artifacts.ts +10 -5
  494. package/src/agents/run-plan.ts +2 -1
  495. package/src/agents/run-session-http.ts +1 -0
  496. package/src/agents/run-session-serve.ts +23 -2
  497. package/src/agents/run-session-wire.ts +45 -0
  498. package/src/agents/run-token.ts +7 -0
  499. package/src/agents/thread-access.ts +34 -1
  500. package/src/agents/tool-files.ts +23 -7
  501. package/src/artifacts/caller.ts +42 -0
  502. package/src/artifacts/comment-place.ts +51 -0
  503. package/src/artifacts/comment-text.ts +50 -7
  504. package/src/artifacts/comments.ts +132 -34
  505. package/src/artifacts/errors.ts +1 -0
  506. package/src/artifacts/execution.ts +249 -5
  507. package/src/artifacts/frames/assets.ts +93 -15
  508. package/src/artifacts/frames/entries.ts +7 -4
  509. package/src/artifacts/frames/generated/hyperframes-notices.txt +290 -0
  510. package/src/artifacts/frames/generated/hyperframes.txt +1145 -0
  511. package/src/artifacts/frames/generated.d.ts +5 -0
  512. package/src/artifacts/frames/hyperframes.ts +14 -0
  513. package/src/artifacts/frames/index.ts +5 -0
  514. package/src/artifacts/frames/kit.ts +7 -3
  515. package/src/artifacts/frames/protocol.ts +56 -0
  516. package/src/artifacts/frames/video-runtime.ts +165 -0
  517. package/src/artifacts/html.ts +13 -0
  518. package/src/artifacts/index.ts +7 -0
  519. package/src/artifacts/kinds.ts +9 -1
  520. package/src/artifacts/limits.ts +43 -0
  521. package/src/artifacts/live/document.ts +27 -3
  522. package/src/artifacts/live/index.ts +58 -2
  523. package/src/artifacts/live/presence.ts +17 -5
  524. package/src/artifacts/live/protocol.ts +4 -2
  525. package/src/artifacts/live/server.ts +1 -1
  526. package/src/artifacts/live/state.ts +3 -3
  527. package/src/artifacts/media/README.md +75 -0
  528. package/src/artifacts/media/media.ts +316 -0
  529. package/src/artifacts/media/transcriber.ts +84 -0
  530. package/src/artifacts/outline.ts +28 -0
  531. package/src/artifacts/publish/files.ts +19 -6
  532. package/src/artifacts/publish/index.ts +49 -2
  533. package/src/artifacts/publish/pdf.ts +3 -1
  534. package/src/artifacts/publish/previews.ts +22 -8
  535. package/src/artifacts/publish/publish.ts +4 -1
  536. package/src/artifacts/publish/validate/html.ts +23 -18
  537. package/src/artifacts/publish/validate/video.ts +309 -0
  538. package/src/artifacts/publish/video.ts +235 -0
  539. package/src/artifacts/resolve.ts +45 -0
  540. package/src/artifacts/video/README.md +402 -0
  541. package/src/artifacts/video/composition.ts +898 -0
  542. package/src/artifacts/video/edit.ts +3967 -0
  543. package/src/artifacts/video/export.ts +352 -0
  544. package/src/artifacts/video/looks.ts +694 -0
  545. package/src/artifacts/video/project.ts +198 -0
  546. package/src/artifacts/video/stills.ts +168 -0
  547. package/src/artifacts/video/timeline.ts +658 -0
  548. package/src/blob-storage/browser.ts +1 -1
  549. package/src/blob-storage/constants.ts +9 -3
  550. package/src/blob-storage/download-urls.ts +5 -3
  551. package/src/blob-storage/index.ts +1 -0
  552. package/src/blob-storage/internal.ts +13 -2
  553. package/src/blob-storage/media-type.ts +149 -8
  554. package/src/bootstrap/discovery.ts +61 -11
  555. package/src/deploy/index.ts +0 -5
  556. package/src/deploy/types.ts +8 -63
  557. package/src/deploy/validation.ts +1 -1
  558. package/src/env/index.ts +10 -4
  559. package/src/errors/catalog.ts +2 -1
  560. package/src/execution/authorization.ts +2 -2
  561. package/src/execution/kernel-operation.ts +14 -0
  562. package/src/execution/types.ts +2 -0
  563. package/src/http/api-routes.ts +117 -0
  564. package/src/index.ts +21 -1
  565. package/src/lake-storage/definition-updates.ts +3 -9
  566. package/src/models/audio/runtime.ts +48 -3
  567. package/src/models/audio/speech.ts +2 -2
  568. package/src/models/audio/types.ts +24 -3
  569. package/src/models/calls.ts +35 -18
  570. package/src/models/catalog.ts +9 -2
  571. package/src/models/definitions.ts +4 -2
  572. package/src/models/errors.ts +5 -3
  573. package/src/models/events.ts +2 -0
  574. package/src/models/execution/README.md +68 -2
  575. package/src/models/execution/index.ts +1 -0
  576. package/src/models/execution/model-call-limits.ts +11 -5
  577. package/src/models/execution/model-call-recorder.ts +14 -0
  578. package/src/models/execution/session.ts +52 -23
  579. package/src/models/execution/usage.ts +1 -0
  580. package/src/models/execution.ts +13 -2
  581. package/src/models/generation-types.ts +2 -0
  582. package/src/models/index.ts +20 -1
  583. package/src/models/input-file.ts +7 -2
  584. package/src/models/pricing.ts +19 -1
  585. package/src/models/rate-card.ts +15 -3
  586. package/src/models/tools.ts +5 -0
  587. package/src/models/video/catalog.ts +101 -0
  588. package/src/models/video/check.ts +441 -0
  589. package/src/models/video/runtime.ts +550 -0
  590. package/src/models/video/types.ts +194 -0
  591. package/src/objects/execution.ts +2 -0
  592. package/src/objects/sdk/object-set.ts +2 -0
  593. package/src/queues/index.ts +5 -0
  594. package/src/queues/types.ts +126 -5
  595. package/src/runtime/create.ts +1 -0
  596. package/src/runtime/definitions.ts +25 -0
  597. package/src/runtime/host.ts +6 -1
  598. package/src/runtime/index.ts +6 -1
  599. package/src/runtime/internal.ts +3 -1
  600. package/src/runtime/resolve-definitions.ts +7 -1
  601. package/src/runtime/sixb.ts +12 -4
  602. package/src/sandboxes/README.md +12 -2
  603. package/src/sandboxes/errors.ts +27 -0
  604. package/src/sandboxes/exec.ts +3 -1
  605. package/src/sandboxes/index.ts +3 -0
  606. package/src/sandboxes/sandbox.ts +15 -1
  607. package/src/security/public.ts +6 -4
  608. package/src/storage/agents/in-memory.ts +39 -0
  609. package/src/storage/agents/index.ts +1 -0
  610. package/src/storage/agents/provider.ts +8 -0
  611. package/src/storage/agents/types.ts +32 -1
  612. package/src/storage/ai-cost/analytics.ts +2 -0
  613. package/src/storage/ai-cost/codec.ts +1 -0
  614. package/src/storage/ai-cost/groups.ts +7 -0
  615. package/src/storage/ai-cost/types.ts +2 -0
  616. package/src/storage/ai-cost/validation.ts +2 -0
  617. package/src/storage/ai-usage/in-memory.ts +93 -0
  618. package/src/storage/ai-usage/index.ts +10 -0
  619. package/src/storage/ai-usage/record.ts +106 -0
  620. package/src/storage/ai-usage/types.ts +102 -1
  621. package/src/storage/ai-usage/usage.ts +2 -0
  622. package/src/storage/artifacts/in-memory.ts +108 -11
  623. package/src/storage/artifacts/index.ts +14 -0
  624. package/src/storage/artifacts/record.ts +203 -1
  625. package/src/storage/artifacts/types.ts +199 -6
  626. package/src/storage/executions/validation.ts +2 -2
  627. package/src/storage/in-memory/index.ts +1 -1
  628. package/src/storage/index.ts +22 -1
  629. package/src/storage/internal.ts +9 -0
  630. package/src/testing/agent-storage-contract.ts +135 -0
  631. package/src/testing/ai-cost-storage-contract.ts +1 -0
  632. package/src/testing/ai-usage-storage-contract.ts +145 -1
  633. package/src/testing/artifact-storage-contract.ts +330 -0
  634. package/src/testing/execution-storage-contract.ts +10 -2
  635. package/src/testing/lake-storage-contract.ts +27 -0
  636. package/src/testing/queues-contract.ts +71 -0
  637. package/src/testing/sandboxes-contract.ts +50 -0
  638. package/dist/chunk-3723kgba.js +0 -29
  639. package/dist/chunk-3723kgba.js.map +0 -10
  640. package/dist/chunk-3qtk0070.js.map +0 -14
  641. package/dist/chunk-8ncg20rd.js.map +0 -10
  642. package/dist/chunk-9vsc919v.js.map +0 -10
  643. package/dist/chunk-az95tsh3.js.map +0 -11
  644. package/dist/chunk-c29729me.js.map +0 -12
  645. package/dist/chunk-d7vyc7k6.js.map +0 -10
  646. package/dist/chunk-de5sfbc3.js +0 -3
  647. package/dist/chunk-f05994as.js.map +0 -10
  648. package/dist/chunk-gfdh9kqa.js.map +0 -11
  649. package/dist/chunk-jt012fxq.js.map +0 -34
  650. package/dist/chunk-mbwsgjn7.js.map +0 -11
  651. package/dist/chunk-nxysqbt0.js.map +0 -10
  652. package/dist/chunk-qttqe1ah.js.map +0 -24
  653. package/dist/chunk-sgx82nnt.js.map +0 -10
  654. package/dist/chunk-vs2s3p8n.js +0 -2274
  655. package/dist/chunk-vs2s3p8n.js.map +0 -20
  656. package/dist/chunk-wkv3h3q7.js.map +0 -12
  657. package/dist/chunk-wzcjhv54.js.map +0 -11
  658. package/dist/chunk-xtztwpkh.js.map +0 -12
  659. package/dist/chunk-ym1bqd98.js.map +0 -19
  660. /package/dist/{chunk-7mhbs9yy.js.map → chunk-1z8ccj53.js.map} +0 -0
  661. /package/dist/{chunk-dmnd9ea6.js.map → chunk-30a0ftnm.js.map} +0 -0
  662. /package/dist/{chunk-qbd282aa.js.map → chunk-39q9ybav.js.map} +0 -0
  663. /package/dist/{chunk-bcz9dxtf.js.map → chunk-3x902cja.js.map} +0 -0
  664. /package/dist/{chunk-c4nrycdy.js.map → chunk-4q4a5a96.js.map} +0 -0
  665. /package/dist/{chunk-ykchk644.js.map → chunk-4w8qzy9w.js.map} +0 -0
  666. /package/dist/{chunk-kft7mp7z.js.map → chunk-5xkqasvn.js.map} +0 -0
  667. /package/dist/{chunk-xavet0qs.js.map → chunk-6whr25gw.js.map} +0 -0
  668. /package/dist/{chunk-ygvay56w.js.map → chunk-896te58g.js.map} +0 -0
  669. /package/dist/{chunk-pqj8vff9.js.map → chunk-8eqqqc1h.js.map} +0 -0
  670. /package/dist/{chunk-jka26v8c.js.map → chunk-8x1bsp68.js.map} +0 -0
  671. /package/dist/{chunk-fmgf9h5e.js.map → chunk-9az7kjv4.js.map} +0 -0
  672. /package/dist/{chunk-bs1sd0e0.js.map → chunk-9p7kyeqz.js.map} +0 -0
  673. /package/dist/{chunk-brybqw5k.js.map → chunk-bkxm2dzx.js.map} +0 -0
  674. /package/dist/{chunk-ppxf7gw2.js.map → chunk-d7t9jnym.js.map} +0 -0
  675. /package/dist/{chunk-cg7cygfj.js.map → chunk-fdmvaz7x.js.map} +0 -0
  676. /package/dist/{chunk-191jz8a6.js.map → chunk-ff0qdk7z.js.map} +0 -0
  677. /package/dist/{chunk-wx7smkn2.js.map → chunk-fq8drkp0.js.map} +0 -0
  678. /package/dist/{chunk-v8a1qjzp.js.map → chunk-hpswfrjj.js.map} +0 -0
  679. /package/dist/{chunk-bz5bnjjt.js.map → chunk-jjte0h4p.js.map} +0 -0
  680. /package/dist/{chunk-xrmbhap8.js.map → chunk-mwg0nwkb.js.map} +0 -0
  681. /package/dist/{chunk-a3faa34j.js.map → chunk-nfjt8k8j.js.map} +0 -0
  682. /package/dist/{chunk-394zjzjs.js.map → chunk-nhgqz3g3.js.map} +0 -0
  683. /package/dist/{chunk-92wrka15.js.map → chunk-q150fnj9.js.map} +0 -0
  684. /package/dist/{chunk-w3t94hm6.js.map → chunk-qk3zq25v.js.map} +0 -0
  685. /package/dist/{chunk-6hfbz4d0.js.map → chunk-r588h4ev.js.map} +0 -0
  686. /package/dist/{chunk-5qqmndhm.js.map → chunk-szzhrn3e.js.map} +0 -0
  687. /package/dist/{chunk-n1hbwc6y.js.map → chunk-t6pfch4e.js.map} +0 -0
  688. /package/dist/{chunk-brhp9d97.js.map → chunk-vmqjndb3.js.map} +0 -0
  689. /package/dist/{chunk-5sswe5ej.js.map → chunk-wsv23wvr.js.map} +0 -0
  690. /package/dist/{chunk-90nqenq8.js.map → chunk-x0hqc54n.js.map} +0 -0
  691. /package/dist/{chunk-3neam1y5.js.map → chunk-y3qb965a.js.map} +0 -0
@@ -1,11 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/execution/kernel-operation.ts", "../src/execution/script.ts"],
4
- "sourcesContent": [
5
- "import type { KernelOperation } from \"./types\"\n\nexport function kernelOperationId(operation: KernelOperation): string {\n switch (operation.type) {\n case \"ontology.recover\":\n return operation.recoveryId\n case \"ontology.indexVectors\":\n return operation.indexingId\n default:\n return unknownOperation(operation)\n }\n}\n\nexport function kernelOperationFromId(type: KernelOperation[\"type\"], id: string): KernelOperation {\n switch (type) {\n case \"ontology.recover\":\n return { type, recoveryId: id }\n case \"ontology.indexVectors\":\n return { type, indexingId: id }\n default:\n return unknownOperation(type)\n }\n}\n\nfunction unknownOperation(_operation: never): never {\n throw new Error(\"[Sixb] Unknown kernel operation.\")\n}\n",
6
- "/** The longest script path an execution records, so a stored source stays a short label. */\nconst MAX_SCRIPT_PATH_LENGTH = 1_024\n\n/**\n * A script execution names its file by a path relative to the project, with forward slashes: what\n * a reader of the record can find in the repository.\n */\nexport function isScriptPath(path: unknown): path is string {\n return (\n typeof path === \"string\" &&\n path !== \"\" &&\n path.trim() === path &&\n path.length <= MAX_SCRIPT_PATH_LENGTH &&\n !path.startsWith(\"/\") &&\n !path.includes(\"\\\\\") &&\n !path.includes(\"\\0\") &&\n path.split(\"/\").every((segment) => segment !== \"\" && segment !== \".\" && segment !== \"..\")\n )\n}\n\nexport function assertScriptPath(path: unknown): asserts path is string {\n if (!isScriptPath(path)) {\n throw new Error(\n `[Sixb] Script path '${String(path)}' must be relative to the project, such as 'scripts/fix.ts'.`\n )\n }\n}\n"
7
- ],
8
- "mappings": ";;AAEO,SAAS,iBAAiB,CAAC,WAAoC;AAAA,EACpE,QAAQ,UAAU;AAAA,IAChB,KAAK;AAAA,MACH,OAAO,UAAU;AAAA,IACnB,KAAK;AAAA,MACH,OAAO,UAAU;AAAA,IACnB;AAAA,MACE,OAAO,iBAAiB,SAAS;AAAA;AAAA;AAIhC,SAAS,qBAAqB,CAAC,MAA+B,IAA6B;AAAA,EAChG,QAAQ;AAAA,IACN,KAAK;AAAA,MACH,OAAO,EAAE,MAAM,YAAY,GAAG;AAAA,IAChC,KAAK;AAAA,MACH,OAAO,EAAE,MAAM,YAAY,GAAG;AAAA,IAChC;AAAA,MACE,OAAO,iBAAiB,IAAI;AAAA;AAAA;AAIlC,SAAS,gBAAgB,CAAC,YAA0B;AAAA,EAClD,MAAM,IAAI,MAAM,kCAAkC;AAAA;;;ACxBpD,IAAM,yBAAyB;AAMxB,SAAS,YAAY,CAAC,MAA+B;AAAA,EAC1D,OACE,OAAO,SAAS,YAChB,SAAS,MACT,KAAK,KAAK,MAAM,QAChB,KAAK,UAAU,0BACf,CAAC,KAAK,WAAW,GAAG,KACpB,CAAC,KAAK,SAAS,IAAI,KACnB,CAAC,KAAK,SAAS,MAAI,KACnB,KAAK,MAAM,GAAG,EAAE,MAAM,CAAC,YAAY,YAAY,MAAM,YAAY,OAAO,YAAY,IAAI;AAAA;AAIrF,SAAS,gBAAgB,CAAC,MAAuC;AAAA,EACtE,IAAI,CAAC,aAAa,IAAI,GAAG;AAAA,IACvB,MAAM,IAAI,MACR,uBAAuB,OAAO,IAAI,+DACpC;AAAA,EACF;AAAA;",
9
- "debugId": "0A3FF84B965DFB0B64756E2164756E21",
10
- "names": []
11
- }
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/storage/agents/types.ts"],
4
- "sourcesContent": [
5
- "import type { ActionSubject } from \"../../actions/types\"\nimport type { AgentMessage, AgentMessagePart, AgentMessageRole } from \"../../agents/message\"\nimport type { AgentReasoning } from \"../../agents/types\"\nimport type { Principal, UserPrincipal } from \"../../auth\"\nimport type { FileRef } from \"../../blob-storage/types\"\nimport type { SixbErrorCode, SixbFailure } from \"../../errors/types\"\nimport type { JsonObject, JsonValue } from \"../../json\"\nimport type {\n LanguageModelRef,\n LanguageModelTier,\n LanguageModelTierProbabilities,\n} from \"../../models\"\nimport type { ActionRunFailure, ActionRunParams } from \"../action-runs/types\"\n\n// ── agent_threads — one conversation with an agent ──────────────────────────────────────────────\n\nexport type AgentThreadStatus = \"active\" | \"archived\"\n\n/** Immutable, non-secret application input. Never store resolved env or credentials here. */\nexport type AgentThreadSandboxParams = Readonly<Record<string, JsonValue>>\n\n/** Worker-owned state, independent from the immutable application binding. */\nexport interface AgentThreadSandboxState {\n /** Exact name passed to the provider. Replacements always receive a fresh name. */\n readonly name: string\n readonly status: \"new\" | \"busy\" | \"ready\" | \"blocked\" | \"unavailable\"\n readonly sourceFingerprint?: string\n readonly initialized: boolean\n /** Durable context boundary: local files from before this reset are no longer available. */\n readonly resetAt?: string\n /** Never expires automatically: a delayed provider operation must not reach a successor. */\n readonly owner?: { readonly runId: string; readonly executionToken: string }\n}\n\nexport type TransitionAgentThreadSandboxInput = {\n readonly projectId: string\n readonly id: string\n} & (\n | {\n readonly action: \"acquire\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly sourceFingerprint: string\n }\n | {\n readonly action: \"replace\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly nextName: string\n }\n | {\n readonly action: \"settle\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly status: \"ready\" | \"blocked\" | \"unavailable\"\n readonly initialized: boolean\n }\n | {\n readonly action: \"recreate\"\n readonly expectedSandboxName: string\n readonly name: string\n }\n | {\n /** Go on in the sandbox a failed save left, as its owner chose: the one named `name`. */\n readonly action: \"restore\"\n readonly name: string\n }\n)\n\n/**\n * A conversation, or the thread a sub-agent works in. A sub-agent's thread is never listed, and\n * whoever reads its conversation reads it.\n */\nexport type AgentThreadKind = \"conversation\" | \"subagent\"\n\n/** Where a sub-agent's thread comes from: its conversation, the turn that spawned it, and its key. */\nexport interface AgentThreadParent {\n readonly threadId: string\n /** The turn that spawned it. Its later runs work under the turns that go on with it. */\n readonly spawnedBy: string\n readonly key: string\n}\n\n/** The computer a thread runs on, and the folder there its turns work in. */\nexport interface AgentThreadComputer {\n /** The CLI's id for the computer: a thread's turns are claimed by that computer alone. */\n readonly id: string\n /** What its owner calls the computer, such as \"Anthony's MacBook Pro\". */\n readonly name: string\n /** The absolute path its turns work in, on that computer. */\n readonly folder: string\n}\n\n/** Where a thread runs: which of its owner's computers, and the folder there. */\nexport type AgentThreadPlace = Pick<AgentThreadComputer, \"id\" | \"folder\">\n\nexport interface AgentThreadRecord {\n readonly id: string\n readonly projectId: string\n readonly kind: AgentThreadKind\n /** Set exactly on a sub-agent's thread. */\n readonly parent?: AgentThreadParent\n /** Who owns/opened the thread. Reuses the canonical auth principal (gains `agent` later for free). */\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n readonly sandboxState?: AgentThreadSandboxState\n /**\n * Where its turns run: on its owner's computer, which claims them, or, when absent, in the cloud.\n * A computer's thread takes turns from its owner alone.\n */\n readonly runsOn?: \"computer\"\n /**\n * Where on its owner's computers a computer's thread runs: set when it is created, and when its\n * owner moves it. Only that computer, open in that folder, claims its turns. A computer's thread\n * created before folders were kept has none until its owner moves it.\n */\n readonly computer?: AgentThreadComputer\n /**\n * When its turns last moved to where they run now, from a computer to the cloud or between\n * folders: the files earlier turns worked on are not here.\n */\n readonly movedAt?: Date\n readonly status: AgentThreadStatus\n /** Single-flight anchor: the id of the one run currently allowed to write, or `null` when idle. */\n readonly activeRunId: string | null\n readonly lastMessageAt?: Date\n readonly messageCount: number\n readonly createdAt: Date\n readonly updatedAt: Date\n}\n\nexport interface CreateAgentThreadInput {\n readonly id: string\n readonly projectId: string\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n readonly runsOn?: \"computer\"\n /** Where a computer's thread runs: required with `runsOn: \"computer\"`, refused without it. */\n readonly computer?: AgentThreadComputer\n readonly status?: AgentThreadStatus\n readonly createdAt?: Date\n readonly updatedAt?: Date\n}\n\n/**\n * A new thread holding a copy of another thread's finished messages. A turn still running is left\n * behind: what came from its trigger message on is not copied. Copies keep their `seq`, content,\n * author and `runId`, and get new ids. Runs are not copied, so the fork's runs, usage and cost are\n * its own; copied answers still show their run's diagnostics.\n *\n * Only the latest checkpoint the copy can use comes along, so the markers of earlier compactions\n * are not in the fork. The fork has no `lastMessageAt` until its first new message, so it sorts\n * by its creation.\n */\nexport interface ForkAgentThreadInput {\n readonly projectId: string\n /** The thread whose history is copied. */\n readonly sourceThreadId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n /** Provider name of the fork's new sandbox; given exactly when `sandboxParams` is. */\n readonly sandboxName?: string\n /**\n * The source's shared artifacts, each id mapped to its copy's: the copied messages and summary\n * name the copies instead.\n */\n readonly artifactCopies?: Readonly<Record<string, string>>\n readonly createdAt?: Date\n}\n\n/** A conversation's sub-agent threads, oldest first. */\nexport interface ListAgentThreadChildrenInput {\n readonly projectId: string\n /** The conversation. */\n readonly parentThreadId: string\n /** Only those this turn spawned. */\n readonly parentRunId?: string\n /** At most this many, 100 by default. */\n readonly limit?: number\n readonly offset?: number\n}\n\n/** Conversations only: a sub-agent's thread is read through its conversation. */\nexport interface ListAgentThreadsInput {\n readonly projectId: string\n readonly statuses?: readonly AgentThreadStatus[]\n readonly ownerPrincipal?: Principal\n /** Only the threads this user takes part in. */\n readonly participantPrincipal?: UserPrincipal\n /** Only the threads that run on this computer, in this folder, with a turn active. */\n readonly activeOnComputer?: AgentThreadPlace\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentThreadsResult {\n readonly threads: readonly AgentThreadRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_thread_participants — the users a thread's owner added to it ─────────────────────────\n\nexport interface AgentThreadParticipantRecord {\n readonly projectId: string\n readonly threadId: string\n readonly principal: UserPrincipal\n readonly addedAt: Date\n readonly addedBy: Principal\n}\n\nexport interface AddAgentThreadParticipantsInput {\n readonly projectId: string\n readonly threadId: string\n /**\n * Distinct users, checked by the caller. Someone already taking part keeps when and by whom they\n * were first added.\n */\n readonly principals: readonly UserPrincipal[]\n readonly addedBy: Principal\n /** Refused with `participant_limit`, adding no one, when the thread would hold more. */\n readonly maxParticipants: number\n readonly addedAt?: Date\n}\n\nexport interface AssignAgentThreadComputerInput {\n readonly projectId: string\n readonly id: string\n /** Where the thread's turns run from now on. */\n readonly computer: AgentThreadComputer\n /** Its `movedAt` when this changes the computer or folder of a thread that had one. */\n readonly movedAt?: Date\n}\n\nexport interface MoveAgentThreadToCloudInput {\n readonly projectId: string\n readonly id: string\n readonly movedAt?: Date\n}\n\n/** A computer's thread, now in the cloud, and its queued turn, now the cloud's to run. */\nexport interface MoveAgentThreadToCloudResult {\n readonly thread: AgentThreadRecord\n readonly queued?: ConversationAgentRunRecord\n}\n\n/**\n * An open `sixb` on its owner's computer: while it is live, the threads that run on that computer\n * in its folder are reachable there. It ends when `sixb` closes, or lapses when it stops renewing.\n */\nexport interface AgentComputerSessionRecord {\n readonly projectId: string\n /** Chosen by the computer, once per open `sixb`; unique among its owner's sessions. */\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly computer: AgentThreadComputer\n readonly expiresAt: Date\n /** Its threads' background commands, as its latest renewal reported them. */\n readonly backgroundCommands?: readonly AgentComputerBackgroundCommand[]\n /** The commands someone asked to stop: each renewal hands back those still running. */\n readonly stopRequests?: readonly AgentBackgroundCommandRef[]\n}\n\n/** How many background commands a computer session reports, and keeps stop requests for. */\nexport const AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX = 64\n\n/**\n * A background command an open `sixb` runs for one of its threads, which outlives the turn that\n * started it: the web shows how it stands between turns.\n */\nexport interface AgentComputerBackgroundCommand {\n readonly threadId: string\n /** `bg_<hex>`, as the agent's tools name it. */\n readonly id: string\n readonly command: string\n readonly status: \"running\" | \"exited\" | \"stopped\"\n readonly exitCode?: number\n /** ISO timestamps. */\n readonly startedAt: string\n readonly endedAt?: string\n}\n\n/** A background command by its start: its id comes again once `sixb` restarts. */\nexport interface AgentBackgroundCommandRef {\n readonly threadId: string\n readonly id: string\n readonly startedAt: string\n}\n\nexport interface RemoveAgentThreadParticipantInput {\n readonly projectId: string\n readonly threadId: string\n readonly principal: UserPrincipal\n}\n\nexport interface ListAgentThreadParticipantsInput {\n readonly projectId: string\n readonly threadIds: readonly string[]\n}\n\n// ── agent_thread_reads — how far each person has read a conversation ──────────────────────────\n\n/**\n * How far one person's reading of a conversation has reached, as the `seq` of its last message.\n *\n * A watermark, not a flag: nothing writes here when a message arrives, so new ones sit past it\n * until the reader moves it. A mark never moves it backwards, so two devices converge on the later\n * position and a stale one cannot rewind the other. Only a deletion does: when a retry or an edit\n * takes the newest messages away, every place past what remains comes back to it, because the next\n * messages take those numbers again.\n */\nexport interface AgentThreadReadRecord {\n readonly projectId: string\n readonly threadId: string\n readonly principal: UserPrincipal\n /** The highest message `seq` this person's reading has reached. 0 when none has. */\n readonly throughSeq: number\n /** When this person last looked: every mark sets it, even one that leaves `throughSeq` alone. */\n readonly readAt: Date\n}\n\n/**\n * One person's place in a conversation, and what arrived past it.\n *\n * `unread` counts the messages past `throughSeq` that are new to them: every Agent answer and\n * every other person's message. What they wrote is not, nor a message that only reports how\n * approved calls ended (`countsAsThreadMessage`).\n */\nexport interface AgentThreadReadState {\n readonly threadId: string\n /** Where their reading reached, never past `headSeq`. 0 when they have no row. */\n readonly throughSeq: number\n /** The `seq` of the thread's newest message, 0 when it has none. */\n readonly headSeq: number\n /** Messages past `throughSeq` that someone else wrote. */\n readonly unread: number\n /** When they last looked; absent until they have a row. */\n readonly readAt?: Date\n}\n\nexport interface MarkAgentThreadReadInput {\n readonly projectId: string\n readonly threadId: string\n readonly principal: UserPrincipal\n /**\n * The last message they read, or the thread's newest when absent. A message the thread no longer\n * holds marks nothing: a retry or an edit took it away, and its number may already name another.\n */\n readonly throughMessageId?: string\n readonly readAt?: Date\n}\n\nexport interface ListAgentThreadReadsInput {\n readonly projectId: string\n readonly threadIds: readonly string[]\n readonly principal: UserPrincipal\n}\n\nexport interface AgentThreadReadStore {\n /**\n * Record that this person's reading reached a message, never moving it back, and that they\n * looked now. A participant has a row from the moment they join, and the migration gave one to\n * everyone in the threads that existed before; an owner without one reads as 0 until their\n * first mark. Answers their place afterwards.\n */\n mark(input: MarkAgentThreadReadInput): Promise<AgentThreadReadState>\n /** One person's place in each of these threads; a thread that does not exist is absent. */\n list(input: ListAgentThreadReadsInput): Promise<readonly AgentThreadReadState[]>\n}\n\n// ── agent_runs — one loop execution (the worker job; attribution + fencing) ───────────────────\n\n/** Lifecycle shared by every durable agent execution, conversational or workflow-owned. */\nexport type AgentExecutionStatus = \"queued\" | \"running\" | \"succeeded\" | \"failed\" | \"cancelled\"\n\nexport type AgentRunStatus = AgentExecutionStatus\nexport type AgentRunKind = \"conversation\" | \"subagent\"\n\n/** Error codes an agent execution can persist and expose through its public contract. */\nexport const AGENT_RUN_FAILURE_CODES = [\n \"internal.unexpected\",\n \"runtime.cancelled\",\n \"agent.context_limit_exceeded\",\n \"agent.execution_failed\",\n \"agent.step_limit_reached\",\n \"ai.usage_limit_exceeded\",\n \"ai.usage_limit_unavailable\",\n] as const satisfies readonly [SixbErrorCode, ...SixbErrorCode[]]\n\nexport type AgentRunFailureCode = (typeof AGENT_RUN_FAILURE_CODES)[number]\n\n/**\n * Why a run ended — Sixb's provider-independent vocabulary. It includes model-loop reasons plus\n * platform-level endings such as `timeout`, `interrupted` for a turn whose worker died before\n * finishing it, `awaiting_approval` for a succeeded turn that paused on calls waiting for its\n * requester, or `awaiting_answer` for a succeeded sub-agent that paused on a question its parent\n * answers in a later turn, so reads remain typed and exhaustive. `other` and `unknown` preserve terminal state\n * when a provider adds a new reason.\n */\nexport const AGENT_RUN_FINISH_REASONS = [\n \"stop\",\n \"length\",\n \"content-filter\",\n \"tool-calls\",\n \"timeout\",\n \"interrupted\",\n \"awaiting_approval\",\n \"awaiting_answer\",\n \"error\",\n \"other\",\n \"unknown\",\n] as const\n\nexport type AgentRunFinishReason = (typeof AGENT_RUN_FINISH_REASONS)[number]\n\n/**\n * Coerce an external finish-reason string — a DB column or an SDK value — to {@link\n * AgentRunFinishReason}. An unrecognised value becomes `\"unknown\"` rather than being dropped.\n */\nexport function coerceAgentRunFinishReason(\n value: string | null | undefined\n): AgentRunFinishReason | undefined {\n if (value === null || value === undefined) {\n return undefined\n }\n return (AGENT_RUN_FINISH_REASONS as readonly string[]).includes(value)\n ? (value as AgentRunFinishReason)\n : \"unknown\"\n}\n\n/** Stable, user-facing diagnostics emitted by the platform while executing a run. */\nexport const AGENT_RUN_DIAGNOSTIC_CODES = [\"step_limit_reached\", \"output_limit_reached\"] as const\n\n/**\n * Closed on purpose, and the wire is closed with it.\n *\n * Sixb writes these codes and the generated client is what reads them, so an open union would only\n * be honest if the HTTP schema were open too — and that costs the OpenAPI enum, the client's\n * autocompletion, and the app's exhaustive `switch`. Sixb owns both ends, so a new code is a minor\n * version bump: cheap here, and a broken `switch` is better than a 500 from `z.enum`.\n */\nexport type AgentRunDiagnosticCode = (typeof AGENT_RUN_DIAGNOSTIC_CODES)[number]\nexport type AgentRunDiagnosticSeverity = \"warning\" | \"error\"\n\nexport interface AgentRunDiagnostic {\n readonly code: AgentRunDiagnosticCode\n readonly severity: AgentRunDiagnosticSeverity\n /** What the diagnostic is about: the turn as a whole. */\n readonly scope: \"run\"\n /** Sanitized, stable copy suitable for display to an end user. */\n readonly message: string\n}\n\n/**\n * Authorization state for the current queue delivery.\n *\n * `queueLeaseExpiresAt` is a persisted projection of `ClaimedQueueJob.leaseExpiresAt`, not an\n * independently managed run lease. It may only be extended from a successful queue lease renewal.\n */\nexport interface AgentRunExecution {\n readonly token: string\n readonly queueLeaseExpiresAt: Date\n}\n\ninterface AgentRunRecordBase {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly status: AgentRunStatus\n readonly modelId?: string\n /** Why the run ended (our own SDK-independent enum). */\n readonly finishReason?: AgentRunFinishReason\n /** Platform diagnostics are transcript annotations, never agent-authored message content. */\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n /** Portable failure snapshot when the run did not succeed. */\n readonly error?: SixbFailure<AgentRunFailureCode>\n /** Execution attempts: `0` while queued, `1` on first start, incremented on redelivery. */\n readonly attempt: number\n readonly execution?: AgentRunExecution\n /**\n * When someone asked a running run to stop. Its run token stops working at once, and its runner\n * learns of it at its next lease renewal if the broker's cancel never reached it.\n */\n readonly cancelRequestedAt?: Date\n readonly createdAt: Date\n readonly startedAt?: Date\n readonly completedAt?: Date\n}\n\nexport interface ConversationAgentRunRecord extends AgentRunRecordBase {\n readonly kind: \"conversation\"\n readonly threadId: string\n readonly triggerMessageId: string\n /** Immutable model selection captured at admission. Absent only on runs predating this field. */\n readonly spec?: ConversationAgentRunSpec\n}\n\n/** Immutable, serialisable model selection and requester settings for one conversational turn. */\nexport interface ConversationAgentRunSpec {\n readonly model: LanguageModelRef\n /** With tiers, the tier of the model the turn runs on. */\n readonly tier?: LanguageModelTier\n /**\n * How likely the decision model judged each tier, when Sixb picked the turn's model. Kept to\n * calibrate the thresholds the tier is picked from (`heavy` from 0.4, `light` from 0.8).\n */\n readonly tierProbabilities?: LanguageModelTierProbabilities\n readonly reasoning?: AgentReasoning\n /** Canonical IANA time zone of the requester. Absent uses the project time zone. */\n readonly timeZone?: string\n /** Canonical BCP 47 language of the requester. Absent uses the project locale. */\n readonly locale?: string\n /** What the turn may change without asking its requester. Absent on older runs: `auto`. */\n readonly approvalMode?: AgentApprovalMode\n /** Its thread's `runsOn` when it was asked for: a computer's turn never reaches the agent queue. */\n readonly runsOn?: \"computer\"\n /**\n * Which computer and folder the turn ran in: captured with `runsOn: \"computer\"` and updated if a\n * queued turn moves to another folder before starting.\n */\n readonly computer?: AgentThreadPlace\n}\n\n/** Immutable, serialisable child configuration captured before dispatch. */\nexport interface SubagentRunSpec {\n readonly model: LanguageModelRef\n /** With tiers, the tier of the model the child runs on. Absent on children admitted before it. */\n readonly tier?: LanguageModelTier\n readonly reasoning?: AgentReasoning\n /** Focused task supplied by the parent Agent. */\n readonly task: string\n /** At most this many steps per run, as its parent asked: the project's limit still applies. */\n readonly maxSteps?: number\n /** Project tools available when the child was admitted. Runtime tools are injected separately. */\n readonly toolNames: readonly string[]\n /** The parent turn's mode, copied when the child was admitted. Absent: `auto`. */\n readonly approvalMode?: AgentApprovalMode\n /** The parent turn's requester settings. Absent uses the project's. */\n readonly timeZone?: string\n readonly locale?: string\n /** Files the parent handed over, copied into the child's sandbox at these paths. */\n readonly files?: readonly SubagentRunFile[]\n}\n\n/** A file a parent and its child hand each other, stored once and copied into a sandbox. */\nexport interface SubagentRunFile {\n /** Relative, `/`-separated, without `.` or `..` segments. */\n readonly path: string\n readonly fileRef: FileRef\n}\n\n/** Durable child output returned to its parent by `wait`. */\nexport interface SubagentRunResult {\n /** Empty only for a child that paused on its held calls before it answered. */\n readonly text: string\n /** What the child wrote under `out/`, by path relative to it. */\n readonly files?: readonly SubagentRunFile[]\n /** Why none of what it wrote under `out/` came back, and what to do about it. */\n readonly filesError?: string\n /**\n * What its parent sent a paused child that it had not read: the run that continues it reads it\n * first.\n */\n readonly unread?: readonly { readonly id: string; readonly text: string }[]\n}\n\nexport interface SubagentRunRecord extends AgentRunRecordBase {\n readonly kind: \"subagent\"\n /** The child's own thread, which holds its task and its work. */\n readonly threadId: string\n /** The message of its thread that started the run. */\n readonly triggerMessageId: string\n /** The conversation turn the child runs under: its mode and cancellation. */\n readonly parentRunId: string\n /** Stable parent-selected key that makes repeated tool execution idempotent. */\n readonly spawnKey: string\n readonly spec: SubagentRunSpec\n readonly result?: SubagentRunResult\n}\n\nexport type AgentRunRecord = ConversationAgentRunRecord | SubagentRunRecord\n\nexport interface CreateAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly threadId: string\n readonly triggerMessageId: string\n readonly spec: ConversationAgentRunSpec\n readonly createdAt?: Date\n}\n\nexport interface CreateSubagentRunInput {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly parentRunId: string\n /** Current parent delivery token. New children are admitted only while that delivery owns it. */\n readonly parentExecutionToken: string\n readonly spawnKey: string\n readonly spec: SubagentRunSpec\n /**\n * The child's thread. Its first run creates it, owned by the conversation's owner; a later run\n * goes into it, and is refused while another run of the thread is active.\n */\n readonly thread: { readonly id: string; readonly create: boolean }\n /** The user message that starts the run, appended to the child's thread with the run's id. */\n readonly trigger: Pick<AppendAgentMessageInput, \"id\" | \"parts\" | \"metadata\">\n /** Internal safety bound enforced atomically across worker processes. */\n readonly maxActiveChildren: number\n readonly createdAt?: Date\n}\n\nexport interface StartAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly modelId?: string\n readonly execution: AgentRunExecution\n readonly startedAt?: Date\n /**\n * Start it only as a computer's turn, there and in that folder: one whose thread moved meanwhile\n * is refused with `invalid_state`, so it never starts where its thread no longer runs.\n */\n readonly onComputer?: AgentThreadPlace\n}\n\nexport interface FinishQueuedAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly status: \"failed\" | \"cancelled\"\n readonly error?: SixbFailure<AgentRunFailureCode>\n readonly completedAt?: Date\n}\n\nexport interface ReclaimAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly execution: AgentRunExecution\n /**\n * Take the run over only if the lease last recorded on it ran out by then, checked in the same\n * write: a renewal that lands first keeps it its runner's. Otherwise `invalid_state`.\n */\n readonly ifLapsedBy?: Date\n}\n\nexport interface ConfirmAgentRunExecutionOwnershipInput {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n /** Exact expiration returned by the queue claim or its latest successful renewal. */\n readonly queueLeaseExpiresAt: Date\n}\n\nexport interface RequestAgentRunCancelInput {\n readonly id: string\n readonly projectId: string\n readonly at?: Date\n}\n\nexport type FinishAgentRunInput =\n | {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n readonly status: \"succeeded\"\n readonly modelId?: string\n readonly finishReason?: AgentRunFinishReason\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n readonly result?: SubagentRunResult\n readonly completedAt?: Date\n }\n | {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n readonly status: \"failed\" | \"cancelled\"\n readonly modelId?: string\n /** Only a succeeded run pauses. */\n readonly finishReason?: Exclude<AgentRunFinishReason, \"awaiting_approval\" | \"awaiting_answer\">\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n readonly error?: SixbFailure<AgentRunFailureCode>\n readonly completedAt?: Date\n }\n\nexport interface ListAgentRunsInput {\n readonly projectId: string\n readonly kinds?: readonly AgentRunKind[]\n readonly threadId?: string\n readonly parentRunId?: string\n readonly statuses?: readonly AgentRunStatus[]\n /** Effective start time; runs that never started use `createdAt`. */\n readonly startedAfter?: Date\n /** Effective start time; runs that never started use `createdAt`. */\n readonly startedBefore?: Date\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n /** Leave out the turns that wait for a computer: only a worker's to run. */\n readonly excludeComputerTurns?: boolean\n}\n\nexport interface ListThreadSubagentsInput {\n readonly projectId: string\n /** The conversation whose turns spawned them. */\n readonly threadId: string\n readonly spawnKey?: string\n readonly finishReason?: AgentRunFinishReason\n /** Only children spawned by turns whose trigger message is still in the thread. */\n readonly retainedTurnsOnly?: boolean\n /** At most this many, 100 by default. */\n readonly limit?: number\n}\n\nexport interface ListAgentRunsResult {\n readonly runs: readonly AgentRunRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\nexport interface ListLatestAgentRunsInput {\n readonly projectId: string\n readonly threadIds: readonly string[]\n}\n\n// ── agent_messages — one message (assistant messages inserted only once finalized) ─────────────\n\nexport type { AgentMessageRole }\n\nexport interface AgentMessageRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /**\n * The run that produced this message; `null` for user-authored messages. In a sub-agent's thread\n * every message has one, its trigger too, so a run's messages are deleted whole. A message copied\n * by a fork keeps the run that produced it, which belongs to the thread it was copied from.\n */\n readonly runId: string | null\n readonly role: AgentMessageRole\n /** Principal that authored this persisted message: caller for user messages, agent identity later for assistant messages. */\n readonly authorPrincipal?: Principal\n /** Monotonic per thread, assigned by the store. */\n readonly seq: number\n /** Structured message content — text / reasoning / step boundaries / tool calls. */\n readonly parts: readonly AgentMessagePart[]\n /** Message-level metadata (mirrors `UIMessage.metadata`). */\n readonly metadata?: JsonValue\n /** Versions the `parts` shape so it can be migrated; stamped from `AGENT_MESSAGE_CONTENT_VERSION`. */\n readonly contentVersion: number\n readonly createdAt: Date\n readonly completedAt?: Date\n}\n\n/** Append a message: a {@link AgentMessage} (role + parts + metadata) plus its storage identity. */\nexport interface AppendAgentMessageInput extends AgentMessage {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly runId: string | null\n readonly authorPrincipal?: Principal\n readonly createdAt?: Date\n readonly completedAt?: Date\n}\n\nexport interface DeleteAgentMessagesFromSeqInput {\n readonly projectId: string\n readonly threadId: string\n /** Delete every message whose per-thread sequence is greater than or equal to this boundary. */\n readonly fromSeq: number\n}\n\nexport interface DeleteAgentMessagesByRunInput {\n readonly projectId: string\n readonly threadId: string\n readonly runId: string\n /**\n * The run that deletes them, when one does: refused with `execution_lost` unless it still runs\n * under this token, checked in the same transaction as the delete.\n */\n readonly fence?: { readonly runId: string; readonly executionToken: string }\n}\n\nexport interface ListAgentMessagesInput {\n readonly projectId: string\n readonly threadId: string\n /** Return only messages whose per-thread sequence is greater than this retained boundary. */\n readonly afterSeq?: number\n readonly roles?: readonly AgentMessageRole[]\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentMessagesResult {\n readonly messages: readonly AgentMessageRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_context_checkpoints — append-only model-context boundaries ──────────────────────────\n\nexport type AgentContextCheckpointReason = \"threshold\" | \"overflow\"\n\n/**\n * A durable summary boundary used only when projecting a thread into model context.\n *\n * Checkpoints never replace or mutate transcript messages. Normal thread reads remain authoritative\n * and complete; the worker reads the latest checkpoint and only the retained message tail.\n */\nexport interface AgentContextCheckpointRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /** A fork's copy keeps the run that wrote the summary, in the thread it was copied from. */\n readonly createdByRunId: string\n readonly previousCheckpointId?: string\n readonly reason: AgentContextCheckpointReason\n readonly summary: string\n readonly summaryFormatVersion: 1\n readonly summarizedThroughSeq: number\n readonly observedHeadSeq: number\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n readonly summaryModelId: string\n readonly createdAt: Date\n}\n\nexport interface CreateAgentContextCheckpointInput {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly createdByRunId: string\n /** Compare-and-swap anchor. `null` means the thread must not have a prior checkpoint. */\n readonly expectedPreviousCheckpointId: string | null\n /** Compare-and-swap anchor for the complete transcript observed by the summarizer. */\n readonly expectedHeadSeq: number\n /** Current delivery token for `createdByRunId`; stale redeliveries must not write. */\n readonly executionToken: string\n readonly reason: AgentContextCheckpointReason\n readonly summary: string\n readonly summaryFormatVersion: 1\n readonly summarizedThroughSeq: number\n readonly observedHeadSeq: number\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n readonly summaryModelId: string\n readonly createdAt?: Date\n}\n\n// ── Store ───────────────────────────────────────────────────────────────────────────────────────\n\nexport interface AgentThreadStore {\n /** Atomic run-fenced transition, or explicit idle-thread recreation. */\n transitionSandbox(input: TransitionAgentThreadSandboxInput): Promise<AgentThreadSandboxState>\n create(input: CreateAgentThreadInput): Promise<AgentThreadRecord>\n /**\n * Create a thread holding a copy of another's finished history, in one transaction. The source's\n * sub-agent threads are not copied, and a sub-agent's thread is refused.\n */\n fork(input: ForkAgentThreadInput): Promise<AgentThreadRecord>\n getById(params: { projectId: string; id: string }): Promise<AgentThreadRecord | null>\n /** The threads found, in first-occurrence input order; a missing one is omitted. */\n getByIds(params: {\n readonly projectId: string\n readonly ids: readonly string[]\n }): Promise<readonly AgentThreadRecord[]>\n list(input: ListAgentThreadsInput): Promise<ListAgentThreadsResult>\n /** The sub-agents' threads of a conversation, by creation and id, all of them or one turn's. */\n listChildren(input: ListAgentThreadChildrenInput): Promise<readonly AgentThreadRecord[]>\n /**\n * Add users atomically and return every participant of the thread afterwards. A sub-agent's\n * thread has none: its readers are its conversation's.\n */\n addParticipants(\n input: AddAgentThreadParticipantsInput\n ): Promise<readonly AgentThreadParticipantRecord[]>\n /** Whether the user took part until now. */\n removeParticipant(input: RemoveAgentThreadParticipantInput): Promise<boolean>\n /**\n * Move a conversation thread to a computer and folder, from the cloud or from another computer or\n * folder, and return the thread after. Refused while a turn holds a cloud thread or runs on its\n * computer.\n */\n assignComputer(input: AssignAgentThreadComputerInput): Promise<AgentThreadRecord>\n /**\n * Move a computer's thread to the cloud, in one transaction with its queued turn, which the cloud\n * runs instead. Refused with `active_run_exists` while a turn runs on the computer, and\n * `invalid_input` for a thread already in the cloud.\n */\n moveToCloud(input: MoveAgentThreadToCloudInput): Promise<MoveAgentThreadToCloudResult>\n /** The participants of these threads, oldest first, then by user id and thread id. */\n listParticipants(\n input: ListAgentThreadParticipantsInput\n ): Promise<readonly AgentThreadParticipantRecord[]>\n}\n\nexport interface AgentRunStore {\n /**\n * Persist a queued turn and atomically claim the thread's single-flight slot. A sub-agent's\n * thread takes only child runs.\n */\n create(input: CreateAgentRunInput): Promise<ConversationAgentRunRecord>\n /**\n * Persist or replay one idempotent child run while atomically enforcing parent fan-out. In one\n * transaction it creates the child's thread or takes it (single-flight, as a conversation), then\n * appends the trigger and the run.\n */\n createSubagent(input: CreateSubagentRunInput): Promise<SubagentRunRecord>\n /** Transition a queued run to running and install the first delivery's execution token. */\n start(input: StartAgentRunInput): Promise<AgentRunRecord>\n /** Finish a queued run before execution and release the thread's single-flight slot. */\n finishQueued(input: FinishQueuedAgentRunInput): Promise<AgentRunRecord>\n /** Rotate the execution token for a redelivered running job (`attempt++`). */\n reclaim(input: ReclaimAgentRunInput): Promise<AgentRunRecord>\n /**\n * Project the queue's latest confirmed ownership expiration onto the current execution.\n * Implementations must fence by token and must never move the expiration backwards.\n */\n confirmExecutionOwnership(input: ConfirmAgentRunExecutionOwnershipInput): Promise<AgentRunRecord>\n /**\n * Record that a running run was asked to stop, keeping the first time it was. A run in any other\n * state is returned as it is: a queued one is cancelled with `finishQueued`.\n */\n requestCancel(input: RequestAgentRunCancelInput): Promise<AgentRunRecord>\n /**\n * Finalize a run and release the thread's `activeRunId`. `finishReason: \"awaiting_approval\"`\n * needs a call the run holds (see `approvals.holdsRun`). A turn that ends any other way cancels\n * its pending approvals and stops resuming on the rest; a child that fails or is cancelled\n * cancels its own pending ones.\n */\n finish(input: FinishAgentRunInput): Promise<AgentRunRecord>\n getById(params: { projectId: string; id: string }): Promise<AgentRunRecord | null>\n getByIds(params: {\n projectId: string\n ids: readonly string[]\n }): Promise<readonly AgentRunRecord[]>\n /**\n * The children of a conversation's turns, the latest turn's first, by its effective start, and\n * within a turn the latest admitted first. Read by key (one per turn) or by finish reason.\n */\n listThreadSubagents(input: ListThreadSubagentsInput): Promise<readonly SubagentRunRecord[]>\n /** The newest run of each thread, by creation and id; a thread without one is absent. */\n latestByThread(input: ListLatestAgentRunsInput): Promise<readonly AgentRunRecord[]>\n list(input: ListAgentRunsInput): Promise<ListAgentRunsResult>\n}\n\nexport interface AgentMessageStore {\n /** Insert a message (its `parts` are the canonical content) and bump thread stats. */\n append(input: AppendAgentMessageInput): Promise<AgentMessageRecord>\n /**\n * Delete every message produced by one run and repair the thread's message stats. A reader's\n * place past the newest message left comes back to it: the next message reuses those numbers.\n */\n deleteByRunId(input: DeleteAgentMessagesByRunInput): Promise<number>\n /**\n * Delete every message at or after `fromSeq` and repair the thread's message stats. A reader's\n * place past the newest message left comes back to it: the edit that follows reuses the numbers.\n */\n deleteFromSeq(input: DeleteAgentMessagesFromSeqInput): Promise<number>\n getById(params: { projectId: string; id: string }): Promise<AgentMessageRecord | null>\n list(input: ListAgentMessagesInput): Promise<ListAgentMessagesResult>\n}\n\nexport interface DeleteAgentContextCheckpointsAfterSeqInput {\n readonly projectId: string\n readonly threadId: string\n /** Delete checkpoints whose observed head exceeds this retained sequence boundary. */\n readonly afterSeq: number\n}\n\nexport interface AgentContextCheckpointStore {\n /**\n * Append one checkpoint after atomically validating run ownership and both transcript anchors.\n * Repeating the same payload for the same creating run is idempotent.\n */\n create(input: CreateAgentContextCheckpointInput): Promise<AgentContextCheckpointRecord>\n /** The thread's checkpoints created by the requested runs, in first-occurrence input order. */\n getByRunIds(input: {\n readonly projectId: string\n readonly threadId: string\n readonly runIds: readonly string[]\n }): Promise<readonly AgentContextCheckpointRecord[]>\n getLatest(input: {\n readonly projectId: string\n readonly threadId: string\n }): Promise<AgentContextCheckpointRecord | null>\n /** Delete checkpoints that observed messages past `afterSeq`, newest first. */\n deleteAfterSeq(input: DeleteAgentContextCheckpointsAfterSeqInput): Promise<number>\n}\n\n// ── agent_approvals — calls of the Agent that wait for whoever asked ───────────────────────────\n\n/**\n * What the Agent may change without asking its requester: `manual` asks for every action and\n * workflow, `accept-edits` runs the actions that only change Sixb, `auto` runs everything.\n */\nexport const AGENT_APPROVAL_MODES = [\"manual\", \"accept-edits\", \"auto\"] as const\n\nexport type AgentApprovalMode = (typeof AGENT_APPROVAL_MODES)[number]\n\n/** The modes that hold some calls: the one that held a call is recorded on its approval. */\nexport const AGENT_HOLDING_APPROVAL_MODES = [\n \"manual\",\n \"accept-edits\",\n] as const satisfies readonly AgentApprovalMode[]\n\nexport type AgentHoldingApprovalMode = (typeof AGENT_HOLDING_APPROVAL_MODES)[number]\n\nexport const AGENT_APPROVAL_STATUSES = [\n \"pending\",\n \"approved\",\n \"denied\",\n \"cancelled\",\n \"superseded\",\n \"expired\",\n] as const\n\nexport type AgentApprovalStatus = (typeof AGENT_APPROVAL_STATUSES)[number]\n\n/** The statuses a pending approval is settled to without a decision. */\nexport type AgentApprovalSettledStatus = Extract<\n AgentApprovalStatus,\n \"cancelled\" | \"superseded\" | \"expired\"\n>\n\n/**\n * The held call, as it runs once approved. An action's params are normalized: what the user\n * approves is exactly what runs. Its run id is the one the Agent named, so a repeated request finds\n * the same approval and the same run.\n */\nexport type AgentApprovalCall =\n | {\n readonly kind: \"action\"\n readonly actionId: string\n readonly subject: ActionSubject\n readonly params: ActionRunParams\n readonly actionRunId: string\n /** `external` when the action has a writeback or effects: it reaches beyond Sixb. */\n readonly effect: \"ontology\" | \"external\"\n }\n | {\n readonly kind: \"workflow\"\n readonly workflowId: string\n readonly input: JsonObject\n readonly workflowRunId: string\n }\n\n/** What running an approved call gave. */\nexport type AgentApprovalOutcome =\n | {\n readonly kind: \"action-run\"\n readonly runId: string\n readonly status: \"succeeded\" | \"failed\"\n readonly error?: ActionRunFailure\n }\n | { readonly kind: \"workflow-run\"; readonly runId: string; readonly queuedAt: string }\n /** The call was refused when it ran, for example because its requester lost a grant. */\n | { readonly kind: \"error\"; readonly error: SixbFailure }\n\nexport interface AgentApprovalRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /** The conversation turn the call belongs to. */\n readonly runId: string\n /** The run that made the call: the turn itself, or one of its children. */\n readonly callerRunId: string\n /** Who asked for the turn: the only one who decides, as the call runs with their rights. */\n readonly requestedBy: Principal\n /** The mode that held the call. */\n readonly mode: AgentHoldingApprovalMode\n /** The call's run id, unique among a thread's pending, approved and denied approvals. */\n readonly callKey: string\n readonly call: AgentApprovalCall\n readonly status: AgentApprovalStatus\n readonly createdAt: Date\n readonly expiresAt: Date\n readonly decidedAt?: Date\n readonly decidedBy?: Principal\n /** Set once an approved call ran. */\n readonly outcome?: AgentApprovalOutcome\n /** The user message that told the model how the approval ended. */\n readonly reportedInMessageId?: string\n /** \"Always allow\": the mode its requester raised the turn's calls to when deciding this one. */\n readonly raisedMode?: AgentApprovalMode\n /**\n * The turn will not resume for it: stopped, its requester left, or another of its calls was set\n * aside. The thread's next message still reports it.\n */\n readonly turnStoppedAt?: Date\n /** When a process last took the approved call to run it; a stale claim can be taken again. */\n readonly executionClaimedAt?: Date\n}\n\nexport interface RequestAgentApprovalInput {\n readonly id: string\n readonly projectId: string\n readonly runId: string\n readonly callerRunId: string\n /** The caller run's current delivery token: a stale delivery holds nothing. */\n readonly executionToken: string\n readonly requestedBy: Principal\n readonly mode: AgentHoldingApprovalMode\n readonly call: AgentApprovalCall\n readonly createdAt?: Date\n readonly expiresAt: Date\n}\n\nexport interface RequestAgentApprovalResult {\n readonly approval: AgentApprovalRecord\n /** `false` when a pending, approved or denied approval of the thread had the same call key. */\n readonly created: boolean\n}\n\nexport interface DecideAgentApprovalInput {\n readonly projectId: string\n readonly id: string\n readonly decision: \"approved\" | \"denied\"\n readonly decidedBy: Principal\n readonly decidedAt?: Date\n /** With `approved`: \"Always allow\" raised the turn's mode to this one. */\n readonly raisedMode?: AgentApprovalMode\n}\n\nexport interface DecideAgentApprovalResult {\n /** The approval afterwards: `expired` when its time ran out before this decision. */\n readonly approval: AgentApprovalRecord\n /** Whether this call moved it out of `pending` with the decision. */\n readonly decided: boolean\n}\n\nexport interface SettleAgentApprovalsInput {\n readonly projectId: string\n readonly threadId: string\n readonly status: AgentApprovalSettledStatus\n}\n\n/** Stop a thread's turn, or a requester's turns there, from resuming on their calls. */\nexport interface StopAgentApprovalsInput {\n readonly projectId: string\n readonly threadId: string\n /** Only the calls of this conversation turn. */\n readonly runId?: string\n /** Only the calls this principal asked for. */\n readonly requestedBy?: Principal\n readonly stoppedAt?: Date\n}\n\nexport interface StopAgentApprovalsResult {\n /** The pending approvals it cancelled. */\n readonly cancelled: readonly AgentApprovalRecord[]\n /** How many unreported approvals it stopped, the cancelled ones included. */\n readonly stopped: number\n}\n\nexport interface RewindAgentApprovalsInput {\n readonly projectId: string\n readonly threadId: string\n /** Conversation runs removed from the thread: their approvals leave with them. */\n readonly runIds: readonly string[]\n /**\n * Message ids removed by the rewind: an earlier turn's approval reported in one becomes\n * unreported again so the replacement message carries its outcome.\n */\n readonly clearedMessageIds?: readonly string[]\n readonly cancelledAt?: Date\n}\n\nexport interface RewindAgentApprovalsResult {\n /** Pending approvals of the rewound runs, as `cancelled` records to announce. */\n readonly cancelled: readonly AgentApprovalRecord[]\n /** Total approvals deleted for the rewound runs. */\n readonly deleted: number\n}\n\n/** Where a keyset listing resumes: after this approval, in the order approvals are listed. */\nexport interface AgentApprovalCursor {\n readonly createdAt: Date\n readonly id: string\n}\n\nexport interface MarkAgentApprovalsReportedInput {\n readonly projectId: string\n readonly threadId: string\n readonly ids: readonly string[]\n readonly messageId: string\n /** A resume: an approval whose turn was stopped is not marked. */\n readonly resuming?: boolean\n}\n\nexport interface ListAgentApprovalsInput {\n readonly projectId: string\n readonly threadId?: string\n readonly runId?: string\n readonly requestedBy?: Principal\n readonly statuses?: readonly AgentApprovalStatus[]\n /** `false`: only the approvals no message reported yet. */\n readonly reported?: boolean\n readonly limit?: number\n readonly offset?: number\n}\n\nexport interface ListAgentApprovalsResult {\n /** Oldest first. */\n readonly approvals: readonly AgentApprovalRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n/**\n * Held calls and their decisions. `runs.finish` settles a run's approvals in its own transaction:\n * a turn that pauses keeps them for their decision, any other ending cancels its pending ones.\n */\nexport interface AgentApprovalStore {\n /**\n * Fenced like a checkpoint: the caller run is running with `executionToken`, and is the\n * conversation turn `runId` or one of its children. Returns the thread's pending, approved or\n * denied approval with the same call key when there is one, and creates one otherwise.\n */\n request(input: RequestAgentApprovalInput): Promise<RequestAgentApprovalResult>\n /** Compare-and-swap from `pending`; `null` when no such approval exists. */\n decide(input: DecideAgentApprovalInput): Promise<DecideAgentApprovalResult | null>\n /** Record what an approved call gave, once: an approval with an outcome is returned unchanged. */\n recordOutcome(input: {\n readonly projectId: string\n readonly id: string\n readonly outcome: AgentApprovalOutcome\n }): Promise<AgentApprovalRecord>\n /** Settle the thread's pending approvals, and return the ones it settled. */\n settle(input: SettleAgentApprovalsInput): Promise<readonly AgentApprovalRecord[]>\n /** Expire the project's pending approvals whose time ran out by `now`, and return them. */\n expireDue(input: {\n readonly projectId: string\n readonly now: Date\n readonly limit?: number\n }): Promise<readonly AgentApprovalRecord[]>\n /**\n * Cancel the matching pending approvals and mark every matching one no message reported yet as\n * stopped: their turn never resumes on them.\n */\n stop(input: StopAgentApprovalsInput): Promise<StopAgentApprovalsResult>\n /**\n * Remove approvals belonging to rewound turns and unmark earlier turns' approvals whose\n * reporting message was removed.\n */\n rewind(input: RewindAgentApprovalsInput): Promise<RewindAgentApprovalsResult>\n /** Mark the ones no message reported yet, and return their ids. */\n markReported(input: MarkAgentApprovalsReportedInput): Promise<readonly string[]>\n /**\n * Whether the run holds a call: one of its approvals, or one it made for its turn, pending, or\n * decided and not reported yet. `runs.finish` checks the same before `awaiting_approval`.\n */\n holdsRun(input: { readonly projectId: string; readonly runId: string }): Promise<boolean>\n /**\n * Take an approved call without an outcome to run it, unless another process took it after\n * `staleBefore`; its decision is its first claim. `null` when it is not there to take.\n */\n claimExecution(input: {\n readonly projectId: string\n readonly id: string\n readonly claimedAt: Date\n readonly staleBefore: Date\n }): Promise<AgentApprovalRecord | null>\n /**\n * What a repair pass works on, oldest first: approved calls without an outcome whose claim is\n * older than `claimableBefore`, and decided calls no message reported whose turn is not stopped.\n */\n listRepairable(input: {\n readonly projectId: string\n readonly claimableBefore: Date\n readonly after?: AgentApprovalCursor\n readonly limit: number\n }): Promise<readonly AgentApprovalRecord[]>\n getById(params: {\n readonly projectId: string\n readonly id: string\n }): Promise<AgentApprovalRecord | null>\n list(input: ListAgentApprovalsInput): Promise<ListAgentApprovalsResult>\n}\n\n/** Each user's approval mode: a default, and their own choice in each thread. */\nexport interface AgentApprovalModeStore {\n getDefault(input: {\n readonly projectId: string\n readonly principal: Principal\n }): Promise<AgentApprovalMode | null>\n setDefault(input: {\n readonly projectId: string\n readonly principal: Principal\n readonly mode: AgentApprovalMode\n readonly updatedAt?: Date\n }): Promise<void>\n getForThread(input: {\n readonly projectId: string\n readonly threadId: string\n readonly principal: Principal\n }): Promise<AgentApprovalMode | null>\n /**\n * `null` clears the choice: the user's turns in the thread follow their default again. Throws\n * `thread_not_found` when the thread does not exist.\n */\n setForThread(input: {\n readonly projectId: string\n readonly threadId: string\n readonly principal: Principal\n readonly mode: AgentApprovalMode | null\n readonly updatedAt?: Date\n }): Promise<void>\n}\n\n// ── Memory ──────────────────────────────────────────────────────────────────────────────────────\n\n/** One file of a memory repo, at its path from the repo root. */\nexport interface AgentMemoryFile {\n readonly path: string\n readonly contents: string\n}\n\n/** A memory repo as of its latest revision. */\nexport interface AgentMemoryRepoRecord {\n /** 0 before the first save. */\n readonly revision: number\n /** Ordered by path. */\n readonly files: readonly AgentMemoryFile[]\n}\n\n/** One change of a save: the file's new contents, or `null` to delete it. */\nexport interface AgentMemoryChange {\n readonly path: string\n readonly contents: string | null\n}\n\nexport interface SaveAgentMemoryInput {\n readonly projectId: string\n /** `user:<userId>` or `project`. */\n readonly repoId: string\n /** The revision the caller loaded. */\n readonly baseRevision: number\n readonly message: string\n readonly author: Principal\n /** The conversation the save came from, `/agents/<threadId>`. */\n readonly source?: string\n readonly changes: readonly AgentMemoryChange[]\n readonly createdAt?: Date\n}\n\nexport type SaveAgentMemoryResult =\n | { readonly saved: true; readonly revision: number }\n | {\n readonly saved: false\n /** The repo's latest revision. */\n readonly revision: number\n /** Files in `changes` that another save changed after `baseRevision`, as they are now. */\n readonly conflicts: readonly AgentMemoryChange[]\n }\n\n/** One save: who made it, why, and which paths it wrote. A revision never changes. */\nexport interface AgentMemoryRevisionRecord {\n readonly revision: number\n readonly message: string\n readonly author: Principal\n readonly source?: string\n /** Ordered by path. */\n readonly changes: readonly { readonly path: string; readonly deleted: boolean }[]\n readonly createdAt: Date\n}\n\nexport interface ListAgentMemoryRevisionsInput {\n readonly projectId: string\n readonly repoId: string\n readonly limit?: number\n readonly offset?: number\n}\n\nexport interface ListAgentMemoryRevisionsResult {\n /** Newest first. */\n readonly revisions: readonly AgentMemoryRevisionRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n/**\n * Memory repos as append-only revisions: a save inserts one revision and the files it wrote, and\n * never updates a row. Paths, sizes and who may save are decided in Core before a call reaches\n * storage.\n */\nexport interface AgentMemoryStore {\n /**\n * The repo at its latest revision, or with `asOf` at the latest revision saved by then, and with\n * `revision` at the latest up to that one: revision 0 and no files when none was. File versions\n * pruned from the history are missing from it.\n */\n get(input: {\n readonly projectId: string\n readonly repoId: string\n readonly asOf?: Date\n readonly revision?: number\n }): Promise<AgentMemoryRepoRecord>\n /**\n * In one transaction: reports a conflict when a path in `changes` was written after\n * `baseRevision`, or when the repo is behind `baseRevision` because it was deleted; otherwise\n * stores the next revision. The same transaction removes file versions older than\n * {@link AGENT_MEMORY_HISTORY_DAYS} days that are not their path's latest.\n */\n save(input: SaveAgentMemoryInput): Promise<SaveAgentMemoryResult>\n listRevisions(input: ListAgentMemoryRevisionsInput): Promise<ListAgentMemoryRevisionsResult>\n /** Deletes the repo with its history. */\n delete(input: { readonly projectId: string; readonly repoId: string }): Promise<void>\n}\n\n/** How long a file version that is not its path's latest stays in a repo's history. */\nexport const AGENT_MEMORY_HISTORY_DAYS = 90\n\n/** Each open `sixb` on its owner's computers, as a lease it renews. */\nexport interface AgentComputerSessionStore {\n /**\n * Open the session, or renew it until `expiresAt`; its computer, folder and background commands\n * are kept as given, and its stop requests as they are.\n */\n hold(input: Omit<AgentComputerSessionRecord, \"stopRequests\">): Promise<void>\n /**\n * Record that someone asked to stop one of its commands, once, keeping the newest\n * {@link AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX}. Null when the owner holds no such session.\n */\n requestStop(input: {\n readonly projectId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly command: AgentBackgroundCommandRef\n }): Promise<AgentComputerSessionRecord | null>\n /** End the owner's session; null when it is not open. */\n release(input: {\n readonly projectId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n }): Promise<AgentComputerSessionRecord | null>\n /** The owner's sessions live at `now`. */\n listLive(input: {\n readonly projectId: string\n readonly ownerPrincipal: Principal\n readonly now: Date\n }): Promise<readonly AgentComputerSessionRecord[]>\n /** Remove every session that lapsed before `now`, and return them. */\n removeLapsed(input: {\n readonly projectId: string\n readonly now: Date\n }): Promise<readonly AgentComputerSessionRecord[]>\n}\n\n// ── agent_token_rates — what each model's tokenizer measured on the project's agent runs ──────\n\n/** How many measurements a project keeps per model: its newest. */\nexport const AGENT_TOKEN_RATE_SAMPLES = 20\n\n/**\n * The band of bytes per token a measurement may show. Every tokenizer measured on agent turns\n * reads 2.1 to 4.7; a value outside is a broken measurement, and a single one would set its\n * model's rate for the whole project.\n */\nexport const AGENT_TOKEN_RATE_MIN_BYTES_PER_TOKEN = 1\nexport const AGENT_TOKEN_RATE_MAX_BYTES_PER_TOKEN = 8\n\n/**\n * One run's measurement of its model's tokenizer: the UTF-8 bytes of a request's text, as the\n * Agent's context estimator weighs them, against the text tokens the provider counted for it.\n */\nexport interface AgentTokenRateRecord {\n readonly projectId: string\n readonly providerId: string\n readonly modelId: string\n /** The agent run or workflow step that measured it: one measurement each. */\n readonly runId: string\n readonly bytes: number\n readonly tokens: number\n readonly measuredAt: Date\n}\n\n/**\n * The newest measurements of each model's bytes per token, per project. Agent runs start their\n * context estimate from them; losing them only makes the next estimates more conservative.\n */\nexport interface AgentTokenRateStore {\n /**\n * Keep a run's measurement, in place of one it recorded before, and drop the model's\n * measurements past its newest {@link AGENT_TOKEN_RATE_SAMPLES}.\n */\n record(input: AgentTokenRateRecord): Promise<void>\n /** The model's measurements, newest first: at most {@link AGENT_TOKEN_RATE_SAMPLES}. */\n listLatest(input: {\n readonly projectId: string\n readonly providerId: string\n readonly modelId: string\n }): Promise<readonly AgentTokenRateRecord[]>\n}\n\n// -- agent_thread_inbox: mid-run steers and queued follow-up messages -------------------------\n\nexport const AGENT_INBOX_MODES = [\"steer\", \"queue\"] as const\nexport type AgentInboxMode = (typeof AGENT_INBOX_MODES)[number]\n\n/** Maximum pending items one conversation thread holds in its inbox at once. */\nexport const AGENT_THREAD_INBOX_MAX_ITEMS = 50\n\n/** Optional per-turn overrides carried by a queued or immediate inbox item. */\nexport interface AgentInboxSpec {\n readonly model?: LanguageModelRef\n readonly reasoning?: AgentReasoning\n readonly approvalMode?: AgentApprovalMode\n}\n\n/** Claim recorded when a running conversation turn drains a `steer` item at a step boundary. */\nexport interface AgentInboxClaim {\n readonly runId: string\n readonly executionToken: string\n readonly stepIndex: number\n readonly afterAnswer?: boolean\n}\n\nexport interface AgentInboxItemRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /** Stable id reserved for `agent_messages` once this item is delivered. */\n readonly messageId: string\n readonly seq: number\n readonly authorPrincipal: Principal\n readonly mode: AgentInboxMode\n readonly parts: readonly AgentMessagePart[]\n readonly spec?: AgentInboxSpec\n readonly timeZone?: string\n readonly locale?: string\n /** Marked by Send now so `afterAgentRunFinished` dispatches it across a user cancel. */\n readonly immediate?: boolean\n /**\n * An edit waiting for the turn it stopped to end: the earlier message it replaces. When it\n * starts, the thread first rewinds to that message. Always sent now, as a queued message.\n */\n readonly replacesMessageId?: string\n /**\n * The execution of the request that sent it. A turn that starts it without a request of its\n * sender's runs as a child of this one, with the sender's grants as they are then.\n */\n readonly executionId?: string\n readonly claimedBy?: AgentInboxClaim\n readonly createdAt: Date\n readonly updatedAt: Date\n}\n\nexport interface EnqueueAgentInboxItemInput {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly messageId: string\n readonly authorPrincipal: Principal\n readonly mode: AgentInboxMode\n readonly parts: readonly AgentMessagePart[]\n readonly spec?: AgentInboxSpec\n readonly timeZone?: string\n readonly locale?: string\n readonly immediate?: boolean\n /**\n * An edit waiting for the turn it stopped to end: the earlier message it replaces. When it\n * starts, the thread first rewinds to that message. Always sent now, as a queued message.\n */\n readonly replacesMessageId?: string\n readonly executionId?: string\n readonly createdAt?: Date\n}\n\nexport interface EnqueueAgentInboxItemResult {\n readonly item: AgentInboxItemRecord\n readonly created: boolean\n}\n\nexport interface ListAgentInboxItemsInput {\n readonly projectId: string\n readonly threadId: string\n /** Whether items already claimed by a running step are included; defaults to `true`. */\n readonly includeClaimed?: boolean\n}\n\nexport interface UpdateAgentInboxItemInput {\n readonly projectId: string\n readonly threadId: string\n readonly id: string\n readonly mode?: AgentInboxMode\n readonly parts?: readonly AgentMessagePart[]\n readonly spec?: AgentInboxSpec | null\n readonly immediate?: boolean\n readonly updatedAt?: Date\n}\n\nexport interface RemoveAgentInboxItemInput {\n readonly projectId: string\n readonly threadId: string\n readonly id: string\n}\n\nexport interface TakeAgentInboxSteersInput {\n readonly projectId: string\n readonly threadId: string\n readonly runId: string\n readonly executionToken: string\n readonly stepIndex: number\n readonly afterAnswer?: boolean\n /**\n * The run's requester: a turn runs as them, so it reads only the steers they sent. Another\n * participant's steer waits for a turn of theirs.\n */\n readonly authorPrincipal: Principal\n}\n\nexport interface ConsumeClaimedAgentInboxInput {\n readonly projectId: string\n readonly threadId: string\n readonly runId: string\n readonly executionToken: string\n /** Message ids persisted into `agent_messages`; other claims of this run are released. */\n readonly messageIds: readonly string[]\n}\n\nexport interface TakeNextQueuedAgentInboxInput {\n readonly projectId: string\n readonly threadId: string\n /** When `true`, only an item marked `immediate` is popped (used after a user cancel). */\n readonly onlyImmediate?: boolean\n /**\n * Only an item this person sent: a turn runs as its requester, so it starts the messages they\n * sent, and another participant's waits for a turn of theirs.\n */\n readonly authorPrincipal?: Principal\n}\n\nexport interface ListWaitingAgentInboxThreadsInput {\n readonly projectId: string\n /** Only threads holding an item created before this: newer ones a turn's end is still starting. */\n readonly createdBefore: Date\n /** Page after this thread id, in id order. */\n readonly afterThreadId?: string\n readonly limit: number\n}\n\nexport interface AgentInboxStore {\n enqueue(input: EnqueueAgentInboxItemInput): Promise<EnqueueAgentInboxItemResult>\n getById(params: { projectId: string; id: string }): Promise<AgentInboxItemRecord | null>\n list(input: ListAgentInboxItemsInput): Promise<readonly AgentInboxItemRecord[]>\n /** Update an unclaimed inbox item; throws `invalid_state` when already claimed. */\n update(input: UpdateAgentInboxItemInput): Promise<AgentInboxItemRecord | null>\n /** Remove an unclaimed inbox item; throws `invalid_state` when already claimed. */\n remove(input: RemoveAgentInboxItemInput): Promise<AgentInboxItemRecord | null>\n /**\n * Fenced by `(runId, executionToken)`: claim the non-immediate steers `authorPrincipal` sent, in\n * FIFO order. The thread's running turn holds it, so a claim any other execution left behind (one\n * this run replaced, or a turn whose release failed) was never written, and is taken over.\n */\n takeSteers(input: TakeAgentInboxSteersInput): Promise<readonly AgentInboxItemRecord[]>\n /** Consume persisted claims of `(runId, executionToken)` and release any unwritten ones. */\n consumeClaimed(input: ConsumeClaimedAgentInboxInput): Promise<readonly AgentInboxItemRecord[]>\n /** Release remaining claims held by `runId` after an interrupted, failed, or cancelled turn. */\n releaseClaimed(input: { projectId: string; runId: string }): Promise<number>\n /** Pop the next unclaimed item when `thread.activeRunId` is null; null when busy or empty. */\n takeNextQueued(input: TakeNextQueuedAgentInboxInput): Promise<AgentInboxItemRecord | null>\n /** Ids of threads no turn holds whose inbox still holds an item, for the repair pass. */\n listWaitingThreads(input: ListWaitingAgentInboxThreadsInput): Promise<readonly string[]>\n}\n\nexport interface AgentStorage {\n readonly threads: AgentThreadStore\n readonly reads: AgentThreadReadStore\n readonly runs: AgentRunStore\n readonly messages: AgentMessageStore\n readonly checkpoints: AgentContextCheckpointStore\n readonly memory: AgentMemoryStore\n readonly approvals: AgentApprovalStore\n readonly approvalModes: AgentApprovalModeStore\n readonly computers: AgentComputerSessionStore\n readonly tokenRates: AgentTokenRateStore\n readonly inbox: AgentInboxStore\n}\n"
6
- ],
7
- "mappings": ";;AAgRO,IAAM,0CAAyC;AAmH/C,IAAM,2BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAYO,IAAM,4BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,SAAS,2BAA0B,CACxC,OACkC;AAAA,EAClC,IAAI,UAAU,QAAQ,UAAU,WAAW;AAAA,IACzC;AAAA,EACF;AAAA,EACA,OAAQ,0BAA+C,SAAS,KAAK,IAChE,QACD;AAAA;AAIC,IAAM,8BAA6B,CAAC,sBAAsB,sBAAsB;AAqjBhF,IAAM,wBAAuB,CAAC,UAAU,gBAAgB,MAAM;AAK9D,IAAM,gCAA+B;AAAA,EAC1C;AAAA,EACA;AACF;AAIO,IAAM,2BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA4YO,IAAM,4BAA4B;AAyClC,IAAM,4BAA2B;AAOjC,IAAM,wCAAuC;AAC7C,IAAM,uCAAuC;AAqC7C,IAAM,qBAAoB,CAAC,SAAS,OAAO;AAI3C,IAAM,gCAA+B;",
8
- "debugId": "CC2BA11790A9557964756E2164756E21",
9
- "names": []
10
- }
@@ -1,24 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/models/audio/errors.ts", "../src/models/catalog-index.ts", "../src/models/audio/catalog.ts", "../src/models/decision/validation.ts", "../src/models/decision/catalog.ts", "../src/models/image/catalog.ts", "../src/models/reranking-model.ts", "../src/models/web-search-model.ts", "../src/models/catalog.ts", "../src/models/decision/errors.ts", "../src/models/decision/output.ts", "../src/models/decision/questions.ts", "../src/models/image/errors.ts", "../src/models/rate-card.ts", "../src/models/pricing.ts"],
4
- "sourcesContent": [
5
- "import { ModelProviderError } from \"../errors\"\nimport type { SpeechModelResponseMetadata, TranscriptionModelResponseMetadata } from \"./types\"\n\n/** Retains billing metadata even when the provider returns an invalid transcript. */\nexport class TranscriptionModelResponseError extends ModelProviderError {\n constructor(\n message: string,\n providerId: string,\n modelId: string,\n readonly metadata: TranscriptionModelResponseMetadata,\n options?: ErrorOptions\n ) {\n super(message, providerId, modelId, {\n ...options,\n code: \"invalid_transcription_response\",\n retryable: false,\n })\n }\n}\n\n/** Retains billing metadata even when the provider returns invalid audio. */\nexport class SpeechModelResponseError extends ModelProviderError {\n constructor(\n message: string,\n providerId: string,\n modelId: string,\n readonly metadata: SpeechModelResponseMetadata,\n options?: ErrorOptions\n ) {\n super(message, providerId, modelId, {\n ...options,\n code: \"invalid_speech_response\",\n retryable: false,\n })\n }\n}\n",
6
- "import { RuntimeError } from \"../runtime/errors\"\nimport type { ModelRef } from \"./catalog\"\n\ninterface ModelBinding {\n readonly providerId: string\n readonly modelId: string\n}\n\ninterface ModelEntry<TModel> extends ModelRef {\n readonly model: TModel\n}\n\ninterface ModelIndex<TEntry> {\n list(): readonly TEntry[]\n getByRef(ref: ModelRef): TEntry | null\n}\n\n/** Private index shared by model families; default selection belongs to each family. */\nexport function indexModelBindings<TModel extends ModelBinding>(\n models: readonly TModel[],\n kind: string,\n validate: (model: TModel, index: number) => void\n): ModelIndex<ModelEntry<TModel>>\n/** A family that adds its own fields to each entry, such as a language model's tier. */\nexport function indexModelBindings<TModel extends ModelBinding, TFields extends object>(\n models: readonly TModel[],\n kind: string,\n validate: (model: TModel, index: number) => void,\n fields: (index: number) => TFields\n): ModelIndex<ModelEntry<TModel> & TFields>\nexport function indexModelBindings<TModel extends ModelBinding>(\n models: readonly TModel[],\n kind: string,\n validate: (model: TModel, index: number) => void,\n fields?: (index: number) => object\n): ModelIndex<ModelEntry<TModel>> {\n const byRef = new Map<string, ModelEntry<TModel>>()\n\n for (const [index, model] of models.entries()) {\n validate(model, index)\n const key = JSON.stringify([model.providerId, model.modelId])\n if (byRef.has(key)) {\n throw new RuntimeError(\n `[Sixb] Duplicate ${kind} model '${model.providerId}/${model.modelId}' in 'models.${kind}'. Each provider and model id pair may be configured once.`\n )\n }\n\n const entry = { provider: model.providerId, modelId: model.modelId, model }\n byRef.set(key, Object.freeze(fields ? { ...entry, ...fields(index) } : entry))\n }\n\n const entries = Object.freeze([...byRef.values()])\n return Object.freeze({\n list: () => entries,\n getByRef: (ref: ModelRef) => byRef.get(JSON.stringify([ref.provider, ref.modelId])) ?? null,\n })\n}\n",
7
- "import type { ModelRef } from \"../catalog\"\nimport { indexModelBindings } from \"../catalog-index\"\nimport type { SpeechModel, TranscriptionModel } from \"./types\"\n\nexport interface TranscriptionModelEntry extends ModelRef {\n readonly model: TranscriptionModel\n}\n\nexport interface TranscriptionModelCatalog {\n readonly default: TranscriptionModelEntry\n list(): readonly TranscriptionModelEntry[]\n getByRef(ref: ModelRef): TranscriptionModelEntry | null\n}\n\nexport interface SpeechModelEntry extends ModelRef {\n readonly model: SpeechModel\n}\n\nexport interface SpeechModelCatalog {\n readonly default: SpeechModelEntry\n list(): readonly SpeechModelEntry[]\n getByRef(ref: ModelRef): SpeechModelEntry | null\n}\n\nexport interface AudioModelCatalog {\n readonly transcription?: TranscriptionModelCatalog\n readonly speech?: SpeechModelCatalog\n}\n\nexport interface AudioModelCatalogInput {\n /** Ordered; the first entry is the default transcriber. */\n readonly transcription?: readonly TranscriptionModel[]\n /** Ordered; the first entry is the default speech model. */\n readonly speech?: readonly SpeechModel[]\n}\n\nexport function createAudioCatalog(\n input: AudioModelCatalogInput | undefined\n): AudioModelCatalog | undefined {\n if (input === undefined) return undefined\n if (\n !input ||\n typeof input !== \"object\" ||\n Array.isArray(input) ||\n (input.transcription === undefined && input.speech === undefined)\n ) {\n throw new TypeError(\"[Sixb] models.audio must configure transcription or speech models.\")\n }\n\n const transcription = familyCatalog(\n input.transcription,\n \"transcription\",\n assertTranscriptionModel\n )\n const speech = familyCatalog(input.speech, \"speech\", assertSpeechModel)\n return Object.freeze({\n ...(transcription === undefined ? {} : { transcription }),\n ...(speech === undefined ? {} : { speech }),\n })\n}\n\nfunction familyCatalog<TModel extends { readonly providerId: string; readonly modelId: string }>(\n models: readonly TModel[] | undefined,\n family: \"transcription\" | \"speech\",\n validate: (model: TModel) => void\n) {\n if (models === undefined) return undefined\n if (!Array.isArray(models)) {\n throw new TypeError(\n `[Sixb] models.audio.${family} must be a nonempty array of ${family} models.`\n )\n }\n\n const index = indexModelBindings(models, `audio.${family}`, validate)\n const [defaultEntry] = index.list()\n if (!defaultEntry) {\n throw new TypeError(`[Sixb] models.audio.${family} must contain at least one model.`)\n }\n return Object.freeze({ ...index, default: defaultEntry })\n}\n\nexport function assertTranscriptionModel(model: unknown): asserts model is TranscriptionModel {\n const candidate = model as Partial<TranscriptionModel> | null\n const definition = candidate?.definition\n if (\n !candidate ||\n !isValidId(candidate.providerId) ||\n !isValidId(candidate.modelId) ||\n typeof candidate.transcribe !== \"function\" ||\n definition?.kind !== \"transcription\" ||\n definition.providerId !== candidate.providerId ||\n definition.modelId !== candidate.modelId\n ) {\n throw invalidModel()\n }\n\n if (!Number.isSafeInteger(definition.maxInputBytes) || definition.maxInputBytes <= 0) {\n throw invalidModel()\n }\n\n const mediaTypes = definition.mediaTypes\n if (\n mediaTypes !== undefined &&\n (!Array.isArray(mediaTypes) ||\n mediaTypes.length === 0 ||\n !mediaTypes.every((type) => typeof type === \"string\" && /^audio\\/[a-z0-9.+-]+$/.test(type)))\n ) {\n throw invalidModel()\n }\n}\n\nfunction isValidId(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0 && value.trim() === value\n}\n\nfunction invalidModel(): TypeError {\n return new TypeError(\n \"[SixbModels] Invalid transcription model identity, definition or input limits.\"\n )\n}\n\nexport function assertSpeechModel(model: unknown): asserts model is SpeechModel {\n const candidate = model as Partial<SpeechModel> | null\n const definition = candidate?.definition\n if (\n !candidate ||\n !isValidId(candidate.providerId) ||\n !isValidId(candidate.modelId) ||\n typeof candidate.speak !== \"function\" ||\n definition?.kind !== \"speech\" ||\n definition.providerId !== candidate.providerId ||\n definition.modelId !== candidate.modelId\n ) {\n throw invalidSpeechModel(\"identity\")\n }\n\n const limit = definition.maxInputCharacters\n if (limit !== undefined && (!Number.isSafeInteger(limit) || limit <= 0)) {\n throw invalidSpeechModel(\"maxInputCharacters\")\n }\n if (!isOptionalList(definition.voices)) throw invalidSpeechModel(\"voices\")\n if (\n !isOptionalList(definition.outputMediaTypes) ||\n definition.outputMediaTypes?.some((type) => !/^audio\\/[a-z0-9.+-]+$/.test(type))\n ) {\n throw invalidSpeechModel(\"outputMediaTypes\")\n }\n if (definition.instructions !== undefined && typeof definition.instructions !== \"boolean\") {\n throw invalidSpeechModel(\"instructions\")\n }\n if (\n candidate.defaultVoice !== undefined &&\n (!isValidId(candidate.defaultVoice) ||\n (definition.voices !== undefined && !definition.voices.includes(candidate.defaultVoice)))\n ) {\n throw invalidSpeechModel(\"defaultVoice\")\n }\n}\n\nfunction isOptionalList(value: unknown): boolean {\n return (\n value === undefined ||\n (Array.isArray(value) && value.length > 0 && value.every((entry) => isValidId(entry)))\n )\n}\n\nfunction invalidSpeechModel(field: string): TypeError {\n return new TypeError(`[SixbModels] Invalid speech model ${field}.`)\n}\n",
8
- "import { assertJsonValue, cloneJsonValue } from \"../../json\"\nimport { UnsupportedModelFeatureError } from \"../errors\"\nimport type {\n ChoiceQuestion,\n DecisionAnswers,\n DecisionContent,\n DecisionModel,\n DecisionModelDefinition,\n DecisionQuestion,\n DecisionQuestions,\n ScoreQuestion,\n} from \"./types\"\n\ntype DecisionCapabilities = DecisionModelDefinition[\"capabilities\"]\n\n// Allow serialization rounding without normalizing provider answers.\nconst DISTRIBUTION_TOLERANCE = 1e-4\nconst CHOICE_TOLERANCE = 1e-6\n\nexport function assertDecisionContent(\n value: unknown,\n path: string\n): asserts value is DecisionContent {\n assertJsonValue(value, path)\n if (value === null || (typeof value !== \"string\" && typeof value !== \"object\")) {\n throw new TypeError(`[SixbModels] ${path} must be text, a JSON object or an array.`)\n }\n}\n\nexport function assertDecisionQuestions(value: unknown): asserts value is DecisionQuestions {\n assertJsonValue(value, \"questions\")\n const questions = readRecord(value, \"questions\")\n if (!Object.keys(questions).length) {\n fail(\"questions must not be empty\")\n }\n\n for (const [key, question] of Object.entries(questions)) {\n if (!key.trim()) {\n fail(\"question names must not be empty\")\n }\n assertQuestion(question, `questions.${key}`)\n }\n}\n\nfunction assertQuestion(value: unknown, path: string): void {\n const question = readRecord(value, path)\n assertDecisionContent(question.instructions, `${path}.instructions`)\n if (typeof question.instructions === \"string\" && !question.instructions.trim()) {\n fail(`${path}.instructions must not be empty`)\n }\n\n switch (question.type) {\n case \"choice\":\n assertOnlyKeys(question, [\"type\", \"instructions\", \"options\"], path)\n assertChoiceOptions(question.options, `${path}.options`)\n break\n case \"score\":\n assertOnlyKeys(question, [\"type\", \"instructions\", \"levels\"], path)\n assertScoreLevels(question.levels, `${path}.levels`)\n break\n case \"probability\":\n assertOnlyKeys(question, [\"type\", \"instructions\"], path)\n break\n default:\n fail(`${path}.type is not a supported decision primitive`)\n }\n}\n\nfunction assertChoiceOptions(value: unknown, path: string): void {\n const options = readRecord(value, path)\n if (!Object.keys(options).length) {\n fail(`${path} must not be empty`)\n }\n\n for (const [option, description] of Object.entries(options)) {\n if (!option.trim()) {\n fail(`${path} contains an empty label`)\n }\n if (description !== null) {\n assertDecisionContent(description, `${path}.${option}`)\n }\n }\n}\n\nfunction assertScoreLevels(value: unknown, path: string): void {\n if (!Array.isArray(value) || value.length < 2) {\n fail(`${path} needs at least two levels`)\n }\n\n for (const level of value) {\n assertDecisionContent(level, path)\n }\n}\n\nexport function assertDecisionModel(model: DecisionModel): void {\n const definition = model?.definition\n if (\n !model ||\n typeof model.evaluate !== \"function\" ||\n !isValidId(model.providerId) ||\n !isValidId(model.modelId) ||\n definition?.kind !== \"decision\" ||\n definition.providerId !== model.providerId ||\n definition.modelId !== model.modelId\n ) {\n fail(\"Expected a DecisionModel with matching provider/model identity\")\n }\n\n const capabilities = definition.capabilities\n if (\n !capabilities ||\n !Array.isArray(capabilities.questions) ||\n !capabilities.questions.length ||\n capabilities.questions.some((kind) => ![\"choice\", \"score\", \"probability\"].includes(kind)) ||\n new Set(capabilities.questions).size !== capabilities.questions.length\n ) {\n fail(\"Decision model capabilities must list distinct supported question types\")\n }\n\n assertCapabilityLimit(capabilities.maxChoices, \"maxChoices\", 1)\n assertCapabilityLimit(capabilities.maxScoreLevels, \"maxScoreLevels\", 2)\n const decimals = capabilities.answerDecimalPlaces\n if (\n decimals !== undefined &&\n (!Number.isSafeInteger(decimals) || decimals < 1 || decimals > 15)\n ) {\n fail(\"Invalid decision answerDecimalPlaces (expected 1–15)\")\n }\n}\n\nfunction assertCapabilityLimit(value: number | undefined, name: string, minimum: number): void {\n if (value !== undefined && (!Number.isSafeInteger(value) || value < minimum)) {\n fail(`Invalid decision capability '${name}'`)\n }\n}\n\nexport function assertDecisionSupport(model: DecisionModel, questions: DecisionQuestions): void {\n for (const [key, question] of Object.entries(questions)) {\n if (!supportsQuestion(model.definition.capabilities, question)) {\n throw new UnsupportedModelFeatureError(\n `[SixbModels] Model '${model.providerId}/${model.modelId}' does not support questions.${key}.`\n )\n }\n }\n}\n\nexport function supportsQuestion(\n capabilities: DecisionCapabilities,\n question: DecisionQuestion\n): boolean {\n if (!capabilities.questions.includes(question.type)) return false\n\n switch (question.type) {\n case \"choice\":\n return Object.keys(question.options).length <= (capabilities.maxChoices ?? Infinity)\n case \"score\":\n return question.levels.length <= (capabilities.maxScoreLevels ?? Infinity)\n case \"probability\":\n return true\n }\n}\n\nexport function validateDecisionAnswers<const Q extends DecisionQuestions>(\n questions: Q,\n value: unknown,\n answerDecimalPlaces?: number\n): DecisionAnswers<Q> {\n assertJsonValue(value, \"decision output\")\n const answers = readRecord(value, \"decision output\")\n assertExactKeys(answers, Object.keys(questions), \"decision output\")\n\n const roundingError = answerDecimalPlaces === undefined ? 0 : 0.5 * 10 ** -answerDecimalPlaces\n for (const [key, question] of Object.entries(questions)) {\n assertAnswer(question, answers[key], `output.${key}`, roundingError)\n }\n\n // Validation establishes the mapped type; callers receive an independent JSON snapshot.\n return cloneJsonValue(value) as DecisionAnswers<Q>\n}\n\nfunction assertAnswer(\n question: DecisionQuestion,\n value: unknown,\n path: string,\n roundingError: number\n): void {\n const answer = readRecord(value, path)\n if (question.type === \"probability\") {\n assertExactKeys(answer, [\"probability\"], path)\n readProbability(answer.probability, path)\n return\n }\n\n assertOnlyKeys(answer, [question.type, \"probabilities\", \"confidence\"], path)\n if (answer.confidence !== undefined) {\n readProbability(answer.confidence, `${path}.confidence`)\n }\n\n const distribution =\n question.type === \"choice\"\n ? validateChoiceAnswer(question, answer, path)\n : validateScoreAnswer(question, answer, path, roundingError)\n\n const total = distribution.reduce((sum, probability) => sum + probability, 0)\n const tolerance = Math.max(DISTRIBUTION_TOLERANCE, distribution.length * roundingError)\n if (Math.abs(total - 1) > tolerance + Number.EPSILON * distribution.length) {\n fail(`${path}.probabilities must sum to one`)\n }\n}\n\nfunction validateChoiceAnswer(\n question: ChoiceQuestion,\n answer: Record<string, unknown>,\n path: string\n): number[] {\n const probabilities = readRecord(answer.probabilities, `${path}.probabilities`)\n assertExactKeys(probabilities, Object.keys(question.options), `${path}.probabilities`)\n const distribution = Object.values(probabilities).map((value) => readProbability(value, path))\n\n if (typeof answer.choice !== \"string\" || !Object.hasOwn(question.options, answer.choice)) {\n fail(`${path}.choice is not a declared option`)\n }\n\n const winner = readProbability(probabilities[answer.choice], path)\n if (winner + CHOICE_TOLERANCE < Math.max(...distribution)) {\n fail(`${path}.choice is not a highest-probability option`)\n }\n\n return distribution\n}\n\nfunction validateScoreAnswer(\n question: ScoreQuestion,\n answer: Record<string, unknown>,\n path: string,\n roundingError: number\n): number[] {\n if (\n !Array.isArray(answer.probabilities) ||\n answer.probabilities.length !== question.levels.length\n ) {\n fail(`${path}.probabilities must match the score levels`)\n }\n\n const distribution = answer.probabilities.map((value) => readProbability(value, path))\n const expected = distribution.reduce((sum, probability, index) => sum + probability * index, 0)\n const levels = question.levels.length\n const [minimum, maximum] = roundingError\n ? roundedScoreBounds(distribution, roundingError, path)\n : [expected, expected]\n const tolerance = roundingError || DISTRIBUTION_TOLERANCE * levels\n if (\n typeof answer.score !== \"number\" ||\n !Number.isFinite(answer.score) ||\n answer.score < 0 ||\n answer.score > question.levels.length - 1 ||\n answer.score < minimum - tolerance - Number.EPSILON * levels ** 2 ||\n answer.score > maximum + tolerance + Number.EPSILON * levels ** 2\n ) {\n fail(`${path}.score is inconsistent with its distribution`)\n }\n\n return distribution\n}\n\n/** Find possible means without changing the returned probabilities. */\nfunction roundedScoreBounds(\n distribution: readonly number[],\n roundingError: number,\n path: string\n): readonly [number, number] {\n const lower = distribution.map((value) => Math.max(0, value - roundingError))\n const upper = distribution.map((value) => Math.min(1, value + roundingError))\n const remaining = 1 - lower.reduce((sum, value) => sum + value, 0)\n const epsilon = Number.EPSILON * distribution.length\n if (remaining < -epsilon || upper.reduce((sum, value) => sum + value, 0) < 1 - epsilon) {\n fail(`${path}.probabilities must sum to one`)\n }\n\n const base = lower.reduce((sum, value, index) => sum + value * index, 0)\n function extreme(highestFirst: boolean): number {\n let mass = Math.max(0, remaining)\n let mean = base\n // Start at each probability's lower bound, then allocate exactly the remaining mass.\n // Filling lower levels first minimizes the mean; filling higher levels maximizes it.\n for (let offset = 0; offset < distribution.length && mass > 0; offset++) {\n const index = highestFirst ? distribution.length - 1 - offset : offset\n const added = Math.min(mass, upper[index]! - lower[index]!)\n mean += added * index\n mass -= added\n }\n return mean\n }\n return [extreme(false), extreme(true)]\n}\n\nfunction readProbability(value: unknown, path: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0 || value > 1) {\n fail(`${path} must contain probabilities between zero and one`)\n }\n return value\n}\n\nfunction readRecord(value: unknown, path: string): Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n fail(`${path} must be an object`)\n }\n return value as Record<string, unknown>\n}\n\nfunction assertOnlyKeys(\n value: Record<string, unknown>,\n keys: readonly string[],\n path: string\n): void {\n if (Object.keys(value).some((key) => !keys.includes(key))) {\n fail(`${path} contains an unknown field`)\n }\n}\n\nfunction assertExactKeys(\n value: Record<string, unknown>,\n keys: readonly string[],\n path: string\n): void {\n assertOnlyKeys(value, keys, path)\n if (keys.some((key) => !Object.hasOwn(value, key))) {\n fail(`${path} is missing an expected field`)\n }\n}\n\nfunction isValidId(value: unknown): value is string {\n return typeof value === \"string\" && !!value.trim() && value.trim() === value\n}\n\nfunction fail(detail: string): never {\n throw new TypeError(`[SixbModels] ${detail}.`)\n}\n",
9
- "import { RuntimeError } from \"../../runtime/errors\"\nimport type { ModelRef } from \"../catalog\"\nimport { indexModelBindings } from \"../catalog-index\"\nimport type { DecisionModel } from \"./types\"\nimport { assertDecisionModel } from \"./validation\"\n\nexport interface DecisionModelEntry extends ModelRef {\n readonly model: DecisionModel\n}\n\nexport interface DecisionModelCatalog {\n readonly default: DecisionModelEntry\n list(): readonly DecisionModelEntry[]\n getByRef(ref: ModelRef): DecisionModelEntry | null\n}\n\nexport function createDecisionCatalog(\n models: readonly DecisionModel[] | undefined\n): DecisionModelCatalog | undefined {\n if (models === undefined) return undefined\n if (!Array.isArray(models)) {\n throw new RuntimeError(\"[Sixb] models.decision must be a nonempty array of decision models.\")\n }\n\n const index = indexModelBindings(models, \"decision\", assertDecisionModel)\n const [defaultEntry] = index.list()\n if (!defaultEntry) {\n throw new RuntimeError(\"[Sixb] models.decision must be a nonempty array of decision models.\")\n }\n\n return Object.freeze({ ...index, default: defaultEntry })\n}\n",
10
- "import type { ModelRef } from \"../catalog\"\nimport { indexModelBindings } from \"../catalog-index\"\nimport type { ImageModel } from \"./types\"\n\nexport interface ImageModelEntry extends ModelRef {\n readonly model: ImageModel\n}\n\nexport interface ImageModelCatalog {\n readonly default: ImageModelEntry\n list(): readonly ImageModelEntry[]\n getByRef(ref: ModelRef): ImageModelEntry | null\n}\n\nexport function createImageCatalog(\n models: readonly ImageModel[] | undefined\n): ImageModelCatalog | undefined {\n if (models === undefined) return undefined\n if (!Array.isArray(models)) {\n throw new TypeError(\"[Sixb] models.image must be a nonempty array of image models.\")\n }\n\n const index = indexModelBindings(models, \"image\", assertImageModel)\n const [defaultEntry] = index.list()\n if (!defaultEntry) {\n throw new TypeError(\"[Sixb] models.image must contain at least one model.\")\n }\n\n return Object.freeze({ ...index, default: defaultEntry })\n}\n\nexport function assertImageModel(model: unknown): asserts model is ImageModel {\n const candidate = model as Partial<ImageModel> | null\n const definition = candidate?.definition\n if (\n !candidate ||\n !isValidId(candidate.providerId) ||\n !isValidId(candidate.modelId) ||\n typeof candidate.generate !== \"function\" ||\n definition?.kind !== \"image\" ||\n definition.providerId !== candidate.providerId ||\n definition.modelId !== candidate.modelId\n ) {\n throw invalidModel(\"identity\")\n }\n\n if (\n definition.maxImagesPerCall !== undefined &&\n !isPositiveInteger(definition.maxImagesPerCall)\n ) {\n throw invalidModel(\"maxImagesPerCall\")\n }\n for (const field of [\"sizes\", \"aspectRatios\", \"qualities\", \"styles\"] as const) {\n if (!isOptionalList(definition[field])) throw invalidModel(field)\n }\n\n const inputImages = definition.inputImages\n if (\n inputImages !== undefined &&\n (!inputImages ||\n !isPositiveInteger(inputImages.maxCount) ||\n !isPositiveInteger(inputImages.maxBytes) ||\n !isOptionalList(inputImages.mediaTypes) ||\n inputImages.mediaTypes?.some((type) => !/^image\\/[a-z0-9.+-]+$/.test(type)))\n ) {\n throw invalidModel(\"inputImages\")\n }\n}\n\nfunction isOptionalList(value: unknown): boolean {\n return (\n value === undefined ||\n (Array.isArray(value) &&\n value.length > 0 &&\n value.every((entry) => typeof entry === \"string\" && entry.trim() === entry && entry))\n )\n}\n\nfunction isPositiveInteger(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value > 0\n}\n\nfunction isValidId(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0 && value.trim() === value\n}\n\nfunction invalidModel(field: string): TypeError {\n return new TypeError(`[SixbModels] Invalid image model ${field}.`)\n}\n",
11
- "import type { ModelDefinition } from \"./definitions\"\nimport { ModelProviderError } from \"./errors\"\nimport type { ModelProviderIds, ModelRoute, ModelUsage } from \"./events\"\nimport type { ModelCostEstimator, ModelReportedCost } from \"./pricing\"\n\nexport interface RerankingModelDefinition extends ModelDefinition {\n readonly kind: \"reranking\"\n}\n\n/** Serializable identity; the server resolves its own registered binding. */\nexport interface RerankingModelRef {\n readonly providerId: string\n readonly modelId: string\n readonly definition: RerankingModelDefinition\n}\n\nexport interface RerankingModelRequest {\n readonly query: string\n readonly documents: readonly string[]\n readonly signal?: AbortSignal\n}\n\nexport interface RerankingModelResponseMetadata {\n readonly usage?: ModelUsage\n readonly providerIds?: ModelProviderIds\n readonly responseModelId?: string\n readonly reportedCost?: ModelReportedCost\n readonly route?: ModelRoute\n}\n\nexport interface RerankingResult {\n /** Position in the original documents array. */\n readonly index: number\n /** Provider relevance score, not a calibrated probability. */\n readonly score: number\n}\n\nexport interface RerankingModelResult extends RerankingModelResponseMetadata {\n /** One result per input document; Sixb validates completeness and orders by score. */\n readonly results: readonly RerankingResult[]\n}\n\nexport interface RerankingModel extends RerankingModelRef {\n readonly costEstimator?: ModelCostEstimator\n resolve?(): Promise<RerankingModel>\n rerank(request: RerankingModelRequest): Promise<RerankingModelResult>\n}\n\nexport function assertRerankingModel(model: RerankingModel): void {\n if (\n !model ||\n typeof model !== \"object\" ||\n typeof model.rerank !== \"function\" ||\n !validIdentifier(model.providerId) ||\n !validIdentifier(model.modelId) ||\n model.definition?.kind !== \"reranking\" ||\n model.definition.providerId !== model.providerId ||\n model.definition.modelId !== model.modelId\n ) {\n throw new TypeError(\"[Sixb] Expected a RerankingModel with a valid identity and rerank method.\")\n }\n}\n\nexport function validateRerankingResults(\n results: unknown,\n documentCount: number\n): RerankingResult[] {\n if (!Array.isArray(results) || results.length !== documentCount) {\n throw new TypeError(\"[SixbModels] Reranking must return one result per document.\")\n }\n const seen = new Set<number>()\n const validated = results.map((result: unknown) => {\n if (!result || typeof result !== \"object\") {\n throw new TypeError(\"[SixbModels] Invalid reranking result.\")\n }\n const index: unknown = Reflect.get(result, \"index\")\n const score: unknown = Reflect.get(result, \"score\")\n if (\n typeof index !== \"number\" ||\n !Number.isSafeInteger(index) ||\n index < 0 ||\n index >= documentCount ||\n seen.has(index) ||\n typeof score !== \"number\" ||\n !Number.isFinite(score)\n ) {\n throw new TypeError(\"[SixbModels] Reranking requires unique valid indices and finite scores.\")\n }\n seen.add(index)\n return { index, score }\n })\n // Stable ties preserve candidate rank, independent of the provider's response ordering.\n return validated.sort((left, right) => right.score - left.score || left.index - right.index)\n}\n\nfunction validIdentifier(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0 && value.trim() === value\n}\n\nexport class RerankingModelResponseError extends ModelProviderError {\n constructor(\n message: string,\n providerId: string,\n modelId: string,\n readonly metadata: RerankingModelResponseMetadata,\n options?: { cause?: unknown }\n ) {\n super(message, providerId, modelId, {\n code: \"invalid_reranking_response\",\n retryable: false,\n cause: options?.cause,\n })\n }\n}\n",
12
- "import type { ModelDefinition } from \"./definitions\"\nimport { ModelProviderError } from \"./errors\"\nimport type { ModelProviderIds, ModelRoute, ModelUsage } from \"./events\"\nimport type { ModelCostEstimator, ModelMoney, ModelReportedCost } from \"./pricing\"\n\nexport interface WebSearchModelDefinition extends ModelDefinition {\n readonly kind: \"web-search\"\n}\n\nexport interface WebSearchModelRequest {\n readonly query: string\n /** How many results to return; Sixb clamps it to 1–10. */\n readonly maxResults: number\n /** A hint for the provider; Sixb filters the results again. */\n readonly allowedDomains?: readonly string[]\n readonly blockedDomains?: readonly string[]\n readonly signal?: AbortSignal\n}\n\n/** One search result. Sixb cuts the snippet to 300 characters. */\nexport interface WebSearchHit {\n readonly url: string\n readonly title: string\n readonly snippet: string\n /** ISO 8601, when the provider knows when the page was published. */\n readonly publishedAt?: string\n}\n\nexport interface WebSearchModelResponseMetadata {\n readonly usage?: ModelUsage\n readonly providerIds?: ModelProviderIds\n readonly responseModelId?: string\n readonly reportedCost?: ModelReportedCost\n readonly route?: ModelRoute\n}\n\nexport interface WebSearchModelResult extends WebSearchModelResponseMetadata {\n readonly results: readonly WebSearchHit[]\n}\n\nexport interface WebSearchCostEstimator extends Pick<ModelCostEstimator, \"estimate\"> {\n /** Return undefined if the search cannot be priced safely before it runs. */\n estimateReservation?(input: { readonly maxResults: number }): ModelMoney | undefined\n}\n\n/** Provider binding. Resolving it may fetch metadata, but must never run a search. */\nexport interface WebSearchModel {\n readonly providerId: string\n readonly modelId: string\n readonly definition: WebSearchModelDefinition\n readonly costEstimator?: WebSearchCostEstimator\n resolve?(): Promise<WebSearchModel>\n search(request: WebSearchModelRequest): Promise<WebSearchModelResult>\n}\n\n/** A billable reply Sixb could not read; its metadata is still recorded. */\nexport class WebSearchModelResponseError extends ModelProviderError {\n constructor(\n message: string,\n providerId: string,\n modelId: string,\n readonly metadata: WebSearchModelResponseMetadata,\n options?: { cause?: unknown }\n ) {\n super(message, providerId, modelId, {\n code: \"invalid_web_search_response\",\n retryable: false,\n cause: options?.cause,\n })\n }\n}\n\n/** The most results one search returns. */\nexport const MAX_WEB_SEARCH_RESULTS = 10\n\nconst SNIPPET_CHARACTERS = 300\n\nexport function assertWebSearchModel(model: WebSearchModel): void {\n if (\n !model ||\n typeof model !== \"object\" ||\n typeof model.search !== \"function\" ||\n !validIdentifier(model.providerId) ||\n !validIdentifier(model.modelId) ||\n model.definition?.kind !== \"web-search\" ||\n model.definition.providerId !== model.providerId ||\n model.definition.modelId !== model.modelId\n ) {\n throw new TypeError(\"[Sixb] Expected a WebSearchModel with a valid identity and search method.\")\n }\n}\n\n/**\n * Check a provider's hits and keep at most `maxResults`: string titles and snippets, snippets cut\n * to 300 characters. A hit without an http(s) URL is dropped, and so is a date that does not parse;\n * the other hits are kept.\n */\nexport function validateWebSearchHits(results: unknown, maxResults: number): WebSearchHit[] {\n if (!Array.isArray(results)) {\n throw new TypeError(\"[SixbModels] Web search must return a list of results.\")\n }\n\n const hits: WebSearchHit[] = []\n for (const result of results as unknown[]) {\n if (!result || typeof result !== \"object\") {\n throw new TypeError(\"[SixbModels] Invalid web search result.\")\n }\n\n const url: unknown = Reflect.get(result, \"url\")\n const title: unknown = Reflect.get(result, \"title\")\n const snippet: unknown = Reflect.get(result, \"snippet\")\n const publishedAt: unknown = Reflect.get(result, \"publishedAt\")\n if (\n typeof title !== \"string\" ||\n typeof snippet !== \"string\" ||\n (publishedAt !== undefined && typeof publishedAt !== \"string\")\n ) {\n throw new TypeError(\"[SixbModels] Web search results need a title and a snippet.\")\n }\n\n // One odd hit should not cost the caller the others.\n if (!isWebUrl(url)) continue\n\n const text = snippet.trim()\n const published = publishedAt === undefined ? Number.NaN : Date.parse(publishedAt)\n\n hits.push({\n url,\n title: title.trim(),\n snippet: text.length > SNIPPET_CHARACTERS ? `${text.slice(0, SNIPPET_CHARACTERS)}…` : text,\n ...(Number.isNaN(published) ? {} : { publishedAt: new Date(published).toISOString() }),\n })\n if (hits.length === maxResults) break\n }\n\n return hits\n}\n\nfunction isWebUrl(value: unknown): value is string {\n if (typeof value !== \"string\") return false\n\n try {\n const { protocol } = new URL(value)\n return protocol === \"http:\" || protocol === \"https:\"\n } catch {\n return false\n }\n}\n\nfunction validIdentifier(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0 && value.trim() === value\n}\n",
13
- "import { RuntimeError } from \"../runtime/errors\"\nimport {\n type AudioModelCatalog,\n type AudioModelCatalogInput,\n createAudioCatalog,\n} from \"./audio/catalog\"\nimport { indexModelBindings } from \"./catalog-index\"\nimport { createDecisionCatalog, type DecisionModelCatalog } from \"./decision/catalog\"\nimport type { DecisionModel } from \"./decision/types\"\nimport {\n defineLanguageModel,\n type LanguageModelDefinition,\n type ModelDefinition,\n} from \"./definitions\"\nimport { assertEmbeddingModel, type EmbeddingModel } from \"./embedding-model\"\nimport { createImageCatalog, type ImageModelCatalog } from \"./image/catalog\"\nimport type { ImageModel } from \"./image/types\"\nimport {\n type LanguageModel,\n MODEL_REASONING_LEVELS,\n modelReasoningSupportIssue,\n} from \"./language-model\"\nimport { assertRerankingModel, type RerankingModel } from \"./reranking-model\"\nimport { assertWebSearchModel, type WebSearchModel } from \"./web-search-model\"\n\n/** Stable identity of a configured provider binding. */\nexport interface ModelRef {\n readonly provider: string\n readonly modelId: string\n}\n\nexport type LanguageModelRef = ModelRef\n\nexport interface EmbeddingModelEntry extends ModelRef {\n readonly model: EmbeddingModel\n}\n\nexport interface EmbeddingModelCatalog {\n list(): readonly EmbeddingModelEntry[]\n getByRef(ref: ModelRef): EmbeddingModelEntry | null\n}\n\nexport interface RerankingModelEntry extends ModelRef {\n readonly model: RerankingModel\n}\n\nexport interface RerankingModelCatalog {\n list(): readonly RerankingModelEntry[]\n getByRef(ref: ModelRef): RerankingModelEntry | null\n}\n\nexport interface WebSearchModelEntry extends ModelRef {\n readonly model: WebSearchModel\n}\n\nexport interface WebSearchModelCatalog {\n /** The one Sixb searches with. */\n readonly default: WebSearchModelEntry\n list(): readonly WebSearchModelEntry[]\n getByRef(ref: ModelRef): WebSearchModelEntry | null\n}\n\n/** The cost and strength classes a project can configure language models in. */\nexport const LANGUAGE_MODEL_TIERS = [\"light\", \"standard\", \"heavy\"] as const\n\nexport type LanguageModelTier = (typeof LANGUAGE_MODEL_TIERS)[number]\n\n/** How likely a decision model judged each tier, each from 0 to 1. */\nexport type LanguageModelTierProbabilities = Readonly<Record<LanguageModelTier, number>>\n\nexport function isLanguageModelTier(value: unknown): value is LanguageModelTier {\n return (LANGUAGE_MODEL_TIERS as readonly unknown[]).includes(value)\n}\n\n/** The tiers as errors list them: \"light, standard or heavy\". */\nexport function formatLanguageModelTiers(): string {\n const last = LANGUAGE_MODEL_TIERS.at(-1)\n return `${LANGUAGE_MODEL_TIERS.slice(0, -1).join(\", \")} or ${last}`\n}\n\n/** Language models by tier; each takes a model or an ordered list, whose first is the tier's. */\nexport interface LanguageModelTiers {\n readonly light?: LanguageModel | readonly LanguageModel[]\n /** Its first model is the project default, and stands in for a tier left out. */\n readonly standard: LanguageModel | readonly LanguageModel[]\n readonly heavy?: LanguageModel | readonly LanguageModel[]\n}\n\n/** The configured language models, with the project default. */\nexport interface LanguageModelCatalog {\n readonly default: LanguageModelEntry\n /** The tiers the project configures, in tier order; empty when `models.language` is a list. */\n readonly tiers: readonly LanguageModelTier[]\n /** Configured order; with tiers, light, standard then heavy, each tier in its own order. */\n list(): readonly LanguageModelEntry[]\n getByRef(ref: LanguageModelRef): LanguageModelEntry | null\n /** The tier's first model; a tier left out, or any tier of a list, gives the default. */\n getByTier(tier: LanguageModelTier): LanguageModelEntry\n}\n\n/**\n * One configured language model.\n *\n * The identity describes the configured binding, not only a vendor model. For example,\n * A gateway binding and a direct provider binding for the same vendor model are distinct because their\n * `provider` values differ.\n */\nexport interface LanguageModelEntry extends LanguageModelRef {\n readonly model: LanguageModel\n /** The tier the model is configured in; absent when `models.language` is a list. */\n readonly tier?: LanguageModelTier\n}\n\n/** Models a project allows Sixb to use, organized by technical model kind. */\nexport interface ModelCatalog {\n readonly audio?: AudioModelCatalog\n readonly language?: LanguageModelCatalog\n readonly decision?: DecisionModelCatalog\n readonly embedding: EmbeddingModelCatalog\n readonly image?: ImageModelCatalog\n readonly reranking?: RerankingModelCatalog\n readonly webSearch?: WebSearchModelCatalog\n}\n\nexport interface ModelCatalogInput {\n readonly audio?: AudioModelCatalogInput\n /**\n * Ordered, the first entry being the project default; or tiers, whose first `standard` model is\n * the default.\n */\n readonly language?: readonly LanguageModel[] | LanguageModelTiers\n /** Ordered; the first entry is the project default decision model. */\n readonly decision?: readonly DecisionModel[]\n readonly embedding?: readonly EmbeddingModel[]\n /** Ordered; the first entry is the default image model. */\n readonly image?: readonly ImageModel[]\n /** Available rerankers; no default model and no automatic activation. */\n readonly reranking?: readonly RerankingModel[]\n /**\n * Ordered; the first is the one Sixb searches with. Omitted, Sixb searches with the default\n * language model's own web search, else the first language model that offers one.\n */\n readonly webSearch?: readonly WebSearchModel[]\n}\n\n// Only statically required inputs make their corresponding catalogs required.\ntype ConfiguredModelKinds<TInput> = {\n [Kind in keyof ModelCatalog]-?: [TInput] extends [\n Record<Kind, readonly unknown[] | LanguageModelTiers>,\n ]\n ? Kind\n : never\n}[keyof ModelCatalog]\n\nexport type ModelCatalogFor<TInput extends ModelCatalogInput> = ModelCatalog &\n Required<Pick<ModelCatalog, ConfiguredModelKinds<TInput>>> &\n ([TInput] extends [{ readonly audio: { readonly transcription: readonly unknown[] } }]\n ? {\n readonly audio: AudioModelCatalog & {\n readonly transcription: NonNullable<AudioModelCatalog[\"transcription\"]>\n }\n }\n : unknown) &\n ([TInput] extends [{ readonly audio: { readonly speech: readonly unknown[] } }]\n ? {\n readonly audio: AudioModelCatalog & {\n readonly speech: NonNullable<AudioModelCatalog[\"speech\"]>\n }\n }\n : unknown)\n\n/** Build an immutable catalog while preserving each family's default and empty-list rules. */\nexport function createModelCatalog<TInput extends ModelCatalogInput>(\n input: TInput\n): ModelCatalogFor<TInput>\nexport function createModelCatalog(input: ModelCatalogInput): ModelCatalog {\n if (!input || typeof input !== \"object\" || Array.isArray(input)) {\n throw new RuntimeError(\"[Sixb] 'models' must be a model catalog configuration.\")\n }\n\n const language = createLanguageCatalog(input.language)\n const embedding = createEmbeddingCatalog(input.embedding)\n const decision = createDecisionCatalog(input.decision)\n const audio = createAudioCatalog(input.audio)\n const image = createImageCatalog(input.image)\n const reranking = createRerankingCatalog(input.reranking)\n const webSearch = createWebSearchCatalog(input.webSearch, language)\n\n if (\n !language &&\n !decision &&\n !audio &&\n !image &&\n embedding.list().length === 0 &&\n !reranking?.list().length &&\n !webSearch\n ) {\n throw new RuntimeError(\n \"[Sixb] Configure at least one language, embedding, decision, audio, image, reranking or web search model.\"\n )\n }\n\n return Object.freeze({ language, embedding, decision, audio, image, reranking, webSearch })\n}\n\nfunction createRerankingCatalog(\n models: readonly RerankingModel[] | undefined\n): RerankingModelCatalog | undefined {\n if (models === undefined) return undefined\n if (!Array.isArray(models)) {\n throw new RuntimeError(\"[Sixb] models.reranking must be an array of reranking models.\")\n }\n return indexModelBindings(models, \"reranking\", assertRerankingModel)\n}\n\n/**\n * The project's own list, else the search its default language model offers, else the first\n * language model's that offers one. Discovered, the catalog holds that one search alone.\n */\nfunction createWebSearchCatalog(\n models: readonly WebSearchModel[] | undefined,\n language: LanguageModelCatalog | undefined\n): WebSearchModelCatalog | undefined {\n if (models !== undefined && !Array.isArray(models)) {\n throw new RuntimeError(\"[Sixb] models.webSearch must be an array of web search models.\")\n }\n if (models?.length === 0) {\n throw new RuntimeError(\n \"[Sixb] models.webSearch must contain at least one model. Omit it to search with your language models' own web search.\"\n )\n }\n\n const discovered =\n language?.default.model.webSearch ??\n language?.list().find((entry) => entry.model.webSearch)?.model.webSearch\n const configured = models ?? (discovered ? [discovered] : [])\n\n const index = indexModelBindings(configured, \"webSearch\", assertWebSearchModel)\n const [defaultEntry] = index.list()\n if (!defaultEntry) return undefined\n\n return Object.freeze({ ...index, default: defaultEntry })\n}\n\nfunction createLanguageCatalog(\n input: ModelCatalogInput[\"language\"]\n): LanguageModelCatalog | undefined {\n if (input === undefined) return undefined\n\n const configured = configuredLanguageModels(input)\n const index = indexModelBindings(\n configured.map(({ model }) => model),\n \"language\",\n (model, position) => {\n const { path } = configured[position]\n assertValidLanguageModel(model, (detail) => invalidLanguageModel(path, detail))\n },\n (position): Pick<LanguageModelEntry, \"tier\"> => {\n const { tier } = configured[position]\n return tier === undefined ? {} : { tier }\n }\n )\n const entries = index.list()\n\n const defaultEntry = entries.find((entry) => entry.tier === \"standard\") ?? entries[0]\n if (!defaultEntry) {\n throw new RuntimeError(\n \"[Sixb] 'models.language' needs at least one model. Configure one or omit 'models.language'.\"\n )\n }\n\n const tiers = LANGUAGE_MODEL_TIERS.filter((tier) => entries.some((entry) => entry.tier === tier))\n\n return Object.freeze({\n ...index,\n default: defaultEntry,\n tiers: Object.freeze(tiers),\n getByTier: (tier: LanguageModelTier) =>\n entries.find((entry) => entry.tier === tier) ?? defaultEntry,\n })\n}\n\n/**\n * The model code runs: its own as given, a tier's model from the catalog, or the default. A string\n * that is not a tier throws, since a caller's types may not have checked it.\n */\nexport function selectLanguageModel(\n catalog: LanguageModelCatalog | undefined,\n model: LanguageModel | LanguageModelTier | undefined\n): LanguageModel | undefined {\n if (model === undefined) return catalog?.default.model\n if (typeof model !== \"string\") return model\n\n if (!isLanguageModelTier(model)) {\n throw new TypeError(\n `[Sixb] Unknown model tier '${model}'. Use ${formatLanguageModelTiers()}, or pass a model.`\n )\n }\n\n return catalog?.getByTier(model).model\n}\n\ninterface ConfiguredLanguageModel {\n readonly model: LanguageModel\n readonly tier?: LanguageModelTier\n /** Where the model was configured, for its errors. */\n readonly path: string\n}\n\n/** Flatten a list, or tiers in tier order, without validating the models themselves. */\nfunction configuredLanguageModels(\n input: readonly LanguageModel[] | LanguageModelTiers\n): readonly ConfiguredLanguageModel[] {\n if (Array.isArray(input)) {\n return input.map((model, index) => ({ model, path: `models.language[${index}]` }))\n }\n if (typeof input !== \"object\" || input === null) {\n throw new RuntimeError(\n \"[Sixb] 'models.language' must be an array of Sixb language models, or tiers: { light, standard, heavy }.\"\n )\n }\n\n const unknown = Object.keys(input).find((key) => !isLanguageModelTier(key))\n if (unknown !== undefined) {\n throw new RuntimeError(\n `[Sixb] Unknown model tier '${unknown}' in 'models.language'. Use ${formatLanguageModelTiers()}, or pass an array of models.`\n )\n }\n // Array.isArray does not narrow a readonly array out of the union.\n const tiers = input as LanguageModelTiers\n if (tiers.standard === undefined) {\n throw new RuntimeError(\n \"[Sixb] 'models.language' tiers need 'standard': its first model is the project default.\"\n )\n }\n\n return LANGUAGE_MODEL_TIERS.flatMap((tier) => {\n const models = tiers[tier]\n if (models === undefined) return []\n if (!Array.isArray(models)) {\n return [{ model: models, tier, path: `models.language.${tier}` }]\n }\n if (models.length === 0) {\n throw new RuntimeError(`[Sixb] 'models.language.${tier}' needs at least one model.`)\n }\n return models.map((model, index) => ({\n model,\n tier,\n path: `models.language.${tier}[${index}]`,\n }))\n })\n}\n\nfunction createEmbeddingCatalog(\n models: readonly EmbeddingModel[] | undefined\n): EmbeddingModelCatalog {\n if (models !== undefined && !Array.isArray(models)) {\n throw new RuntimeError(\"[Sixb] models.embedding must be an array of embedding models.\")\n }\n\n return indexModelBindings(models ?? [], \"embedding\", assertEmbeddingModel)\n}\n\n/** Builds the error for an invalid language model, naming where it was configured. */\ntype InvalidLanguageModel = (detail: string) => Error\n\n/**\n * Check a language model the project configures, in the catalog or on an agent step: its shape\n * and identity, its default reasoning and its output limit.\n */\nexport function assertValidLanguageModel(\n model: unknown,\n fail: InvalidLanguageModel\n): asserts model is LanguageModel {\n assertLanguageModel(model, fail)\n assertDefaultReasoning(model, fail)\n assertMaxOutputTokens(model, fail)\n}\n\n// Capabilities known without catalog I/O. Unknown support is accepted: providers fall back to their\n// default when a resolved model turns out not to support the level.\nfunction assertDefaultReasoning(model: LanguageModel, fail: InvalidLanguageModel): void {\n const reasoning: unknown = model.defaultReasoning\n if (reasoning === undefined) return\n if (!(MODEL_REASONING_LEVELS as readonly unknown[]).includes(reasoning)) {\n throw fail(`expected 'defaultReasoning' to be one of: ${MODEL_REASONING_LEVELS.join(\", \")}`)\n }\n const issue = modelReasoningSupportIssue(model.definition.capabilities.reasoning, reasoning)\n if (issue !== undefined) {\n throw fail(`default reasoning '${reasoning}' cannot be used: ${issue}`)\n }\n}\n\n// Providers validate their own options; this holds the same rule for providers written elsewhere.\nfunction assertMaxOutputTokens(model: LanguageModel, fail: InvalidLanguageModel): void {\n const maxOutputTokens: unknown = model.maxOutputTokens\n if (maxOutputTokens === undefined) return\n if (\n typeof maxOutputTokens !== \"number\" ||\n !Number.isSafeInteger(maxOutputTokens) ||\n maxOutputTokens <= 0\n ) {\n throw fail(\"expected 'maxOutputTokens' to be a positive safe integer\")\n }\n const modelMaximum = model.definition.maxOutputTokens\n if (modelMaximum !== undefined && maxOutputTokens > modelMaximum) {\n throw fail(`'maxOutputTokens' (${maxOutputTokens}) exceeds the model maximum (${modelMaximum})`)\n }\n}\n\nfunction assertLanguageModel(\n model: unknown,\n fail: InvalidLanguageModel\n): asserts model is LanguageModel {\n if ((typeof model !== \"object\" && typeof model !== \"function\") || model === null) {\n throw fail(\"expected a Sixb LanguageModel instance\")\n }\n\n const candidate = model as Record<string, unknown>\n assertModelIdentifier(candidate.providerId, \"provider\", fail)\n assertModelIdentifier(candidate.modelId, \"modelId\", fail)\n if (typeof candidate.stream !== \"function\") {\n throw fail(\"expected 'stream' to be a function\")\n }\n try {\n const definition = defineLanguageModel(candidate.definition as LanguageModelDefinition)\n if (\n definition.providerId !== candidate.providerId ||\n definition.modelId !== candidate.modelId\n ) {\n throw new Error(\"definition identity does not match the binding\")\n }\n } catch (error) {\n throw fail(error instanceof Error ? error.message : \"invalid definition\")\n }\n}\n\nfunction assertModelIdentifier(\n value: unknown,\n field: \"provider\" | \"modelId\",\n fail: InvalidLanguageModel\n): void {\n if (typeof value !== \"string\" || value.length === 0) {\n throw fail(`expected '${field}' to be a non-empty string`)\n }\n if (value.trim() !== value) {\n throw fail(`expected '${field}' not to have surrounding whitespace`)\n }\n}\n\nfunction invalidLanguageModel(path: string, detail: string): RuntimeError {\n return new RuntimeError(`[Sixb] Invalid language model at '${path}': ${detail}.`)\n}\n\n/** Provider-owned metadata lookup, independent from the project's configured bindings. */\nexport interface ModelDefinitionCatalog<TDefinition extends ModelDefinition = ModelDefinition> {\n get(modelId: string): Promise<TDefinition | undefined>\n list(): Promise<readonly TDefinition[]>\n}\n\nexport type LanguageModelDefinitionCatalog = ModelDefinitionCatalog<LanguageModelDefinition>\n",
14
- "import { ModelProviderError } from \"../errors\"\nimport type { DecisionModelResponseMetadata } from \"./types\"\n\nexport class DecisionModelResponseError extends ModelProviderError {\n constructor(\n message: string,\n providerId: string,\n modelId: string,\n readonly metadata: DecisionModelResponseMetadata,\n options?: ErrorOptions\n ) {\n super(message, providerId, modelId, {\n ...options,\n code: \"invalid_decision_response\",\n retryable: false,\n })\n }\n}\n",
15
- "import type { SchemaOrRef } from \"../../ontology/refs\"\nimport type {\n ChoiceQuestion,\n DecisionContent,\n DecisionQuestion,\n DecisionQuestions,\n ScoreQuestion,\n} from \"./types\"\nimport { assertDecisionQuestions } from \"./validation\"\n\ntype RequiredField<S extends SchemaOrRef> = { required: true; schema: S }\ntype ChoiceAnswerSchema<C extends Readonly<Record<string, DecisionContent | null>>> = {\n type: \"object\"\n properties: {\n choice: RequiredField<{\n type: \"enum\"\n valueType: \"string\"\n values: `${Extract<keyof C, string | number>}`[]\n }>\n probabilities: RequiredField<{\n type: \"object\"\n properties: { [K in keyof C]: RequiredField<\"double\"> }\n }>\n confidence: { schema: \"double\" }\n }\n}\nexport type DecisionAnswerSchema<Q extends DecisionQuestion> =\n Q extends ChoiceQuestion<infer C>\n ? ChoiceAnswerSchema<C>\n : Q extends ScoreQuestion\n ? {\n type: \"object\"\n properties: {\n score: RequiredField<\"double\">\n probabilities: RequiredField<{ type: \"array\"; items: \"double\" }>\n confidence: { schema: \"double\" }\n }\n }\n : { type: \"object\"; properties: { probability: RequiredField<\"double\"> } }\nexport type DecisionOutputShape<Q extends DecisionQuestions> = {\n -readonly [K in keyof Q]: DecisionAnswerSchema<Q[K]>\n}\n\n/** Ordinary Sixb output schemas for actions/workflow steps; evaluate() validates distributions. */\nexport function decisionOutput<const Q extends DecisionQuestions>(\n questions: Q\n): DecisionOutputShape<Q> {\n assertDecisionQuestions(questions)\n const result: Record<string, SchemaOrRef> = Object.fromEntries(\n Object.entries(questions).map(([key, q]) => {\n if (q.type === \"probability\")\n return [\n key,\n {\n type: \"object\",\n properties: { probability: { required: true, schema: \"double\" } },\n },\n ]\n const confidence = { schema: \"double\" as const }\n if (q.type === \"score\")\n return [\n key,\n {\n type: \"object\",\n properties: {\n score: { required: true, schema: \"double\" },\n probabilities: { required: true, schema: { type: \"array\", items: \"double\" } },\n confidence,\n },\n },\n ]\n return [\n key,\n {\n type: \"object\",\n properties: {\n choice: {\n required: true,\n schema: { type: \"enum\", valueType: \"string\", values: Object.keys(q.options) },\n },\n probabilities: {\n required: true,\n schema: {\n type: \"object\",\n properties: Object.fromEntries(\n Object.keys(q.options).map((option) => [\n option,\n { required: true, schema: \"double\" },\n ])\n ),\n },\n },\n confidence,\n },\n },\n ]\n })\n )\n // Each branch builds the corresponding schema while retaining literal option keys in the type.\n return result as DecisionOutputShape<Q>\n}\n",
16
- "import type { ChoiceQuestion, DecisionContent, ProbabilityQuestion, ScoreQuestion } from \"./types\"\nimport { assertDecisionQuestions } from \"./validation\"\n\n/** Plain serializable descriptors; no registration or inference takes place here. */\nexport const question = {\n choice<const TOptions extends Readonly<Record<string, DecisionContent | null>>>(input: {\n readonly instructions: DecisionContent\n readonly options: TOptions\n }): ChoiceQuestion<TOptions> {\n const result = { ...input, type: \"choice\" as const }\n assertDecisionQuestions({ question: result })\n return result\n },\n score<\n const TLevels extends readonly [DecisionContent, DecisionContent, ...DecisionContent[]],\n >(input: {\n readonly instructions: DecisionContent\n readonly levels: TLevels\n }): ScoreQuestion<TLevels> {\n const result = { ...input, type: \"score\" as const }\n assertDecisionQuestions({ question: result })\n return result\n },\n probability(instructions: DecisionContent): ProbabilityQuestion {\n const result = { type: \"probability\" as const, instructions }\n assertDecisionQuestions({ question: result })\n return result\n },\n}\n",
17
- "import { ModelProviderError } from \"../errors\"\nimport type { ImageModelResponseMetadata } from \"./types\"\n\n/** Retains billing metadata even when the provider returns invalid images. */\nexport class ImageModelResponseError extends ModelProviderError {\n constructor(\n message: string,\n providerId: string,\n modelId: string,\n readonly metadata: ImageModelResponseMetadata,\n options?: ErrorOptions\n ) {\n super(message, providerId, modelId, {\n ...options,\n code: \"invalid_image_response\",\n retryable: false,\n })\n }\n}\n",
18
- "/** Decimal USD. Strings keep provider prices exact. */\nexport type ModelUnitPrice = string\n\nexport interface ModelPricingTier {\n readonly minTokens: number\n readonly maxTokens?: number\n readonly price: ModelUnitPrice\n}\n\nexport type ModelTokenPrice =\n | ModelUnitPrice\n | { readonly default: ModelUnitPrice; readonly tiers: readonly ModelPricingTier[] }\n\n/** Request facts a price can depend on, such as an image's size or a voice's tier. */\nexport interface ModelPricingDimensions {\n readonly size?: string\n readonly quality?: string\n readonly style?: string\n readonly voiceTier?: string\n}\n\nexport interface ModelPriceVariant extends ModelPricingDimensions {\n readonly price: ModelUnitPrice\n}\n\n/**\n * One price, or prices that vary with the request. Every variant names the same dimensions; a\n * request no variant matches is billed at `default`, and is unpriceable without one.\n */\nexport type ModelVariantPrice =\n | ModelUnitPrice\n | { readonly default?: ModelUnitPrice; readonly variants: readonly ModelPriceVariant[] }\n\n/**\n * What one provider bills for one model. A card lists only the meters its provider charges:\n * token prices come as an input and output pair, per million tokens.\n */\nexport interface ModelRateCard {\n readonly currency: \"USD\"\n readonly input?: ModelTokenPrice\n readonly output?: ModelTokenPrice\n readonly cacheReadInput?: ModelTokenPrice\n readonly cacheWriteInput?: ModelTokenPrice\n readonly cacheWriteInput5m?: ModelTokenPrice\n readonly cacheWriteInput1h?: ModelTokenPrice\n /** Output tokens that encode images, when billed apart from other output. */\n readonly imageOutput?: ModelTokenPrice\n /** Output tokens that encode audio, when billed apart from other output. */\n readonly audioOutput?: ModelTokenPrice\n /** Per generated image. Image output tokens are then not billed as tokens. */\n readonly images?: ModelVariantPrice\n /** Per million input characters. */\n readonly characters?: ModelVariantPrice\n /** Per second of input audio, as transcription bills. */\n readonly audioInputSeconds?: ModelVariantPrice\n}\n\nconst PRICING_DIMENSIONS = [\"size\", \"quality\", \"style\", \"voiceTier\"] as const\n\nconst TOKEN_DETAIL_FIELDS = [\n \"cacheReadInput\",\n \"cacheWriteInput\",\n \"cacheWriteInput5m\",\n \"cacheWriteInput1h\",\n \"imageOutput\",\n \"audioOutput\",\n] as const\n\n/** Validate and snapshot provider-owned pricing independently of operational metadata. */\nexport function defineModelRateCard(rateCard: ModelRateCard): ModelRateCard {\n assertRecord(rateCard, \"rate card\")\n if (rateCard.currency !== \"USD\") {\n throw new TypeError(\"[Sixb] Model rate cards must use USD.\")\n }\n\n const tokens = rateCard.input !== undefined || rateCard.output !== undefined\n if (tokens && (rateCard.input === undefined || rateCard.output === undefined)) {\n throw new TypeError(\"[Sixb] Model rate cards must price input and output tokens together.\")\n }\n if (!tokens && TOKEN_DETAIL_FIELDS.some((field) => rateCard[field] !== undefined)) {\n throw new TypeError(\"[Sixb] Model rate card token details require input and output prices.\")\n }\n if (\n !tokens &&\n rateCard.images === undefined &&\n rateCard.characters === undefined &&\n rateCard.audioInputSeconds === undefined\n ) {\n throw new TypeError(\"[Sixb] Model rate cards must price tokens, images, characters or audio.\")\n }\n if (rateCard.images !== undefined && rateCard.imageOutput !== undefined) {\n throw new TypeError(\n \"[Sixb] Model rate cards bill image output per image or per token, not both.\"\n )\n }\n\n return Object.freeze({\n currency: \"USD\",\n ...(tokens ? { input: tokenPrice(rateCard.input), output: tokenPrice(rateCard.output) } : {}),\n ...(rateCard.cacheReadInput === undefined\n ? {}\n : { cacheReadInput: tokenPrice(rateCard.cacheReadInput) }),\n ...(rateCard.cacheWriteInput === undefined\n ? {}\n : { cacheWriteInput: tokenPrice(rateCard.cacheWriteInput) }),\n ...(rateCard.cacheWriteInput5m === undefined\n ? {}\n : { cacheWriteInput5m: tokenPrice(rateCard.cacheWriteInput5m) }),\n ...(rateCard.cacheWriteInput1h === undefined\n ? {}\n : { cacheWriteInput1h: tokenPrice(rateCard.cacheWriteInput1h) }),\n ...(rateCard.imageOutput === undefined\n ? {}\n : { imageOutput: tokenPrice(rateCard.imageOutput) }),\n ...(rateCard.audioOutput === undefined\n ? {}\n : { audioOutput: tokenPrice(rateCard.audioOutput) }),\n ...(rateCard.images === undefined ? {} : { images: variantPrice(rateCard.images, \"images\") }),\n ...(rateCard.characters === undefined\n ? {}\n : { characters: variantPrice(rateCard.characters, \"characters\") }),\n ...(rateCard.audioInputSeconds === undefined\n ? {}\n : { audioInputSeconds: variantPrice(rateCard.audioInputSeconds, \"audioInputSeconds\") }),\n })\n}\n\n/** @internal The price for a request, and the variant that set it. */\nexport function resolveModelVariantPrice(\n price: ModelVariantPrice,\n dimensions: ModelPricingDimensions | undefined\n): { readonly price: ModelUnitPrice; readonly variant?: string } | undefined {\n if (typeof price === \"string\") return { price }\n const variant = price.variants.find((candidate) =>\n PRICING_DIMENSIONS.every(\n (dimension) =>\n candidate[dimension] === undefined || candidate[dimension] === dimensions?.[dimension]\n )\n )\n if (variant) {\n const label = PRICING_DIMENSIONS.flatMap((dimension) => variant[dimension] ?? []).join(\" · \")\n return { price: variant.price, variant: label }\n }\n return price.default === undefined ? undefined : { price: price.default }\n}\n\n/** @internal Every price a request could be billed at, for conservative reservations. */\nexport function modelVariantPrices(price: ModelVariantPrice): readonly ModelUnitPrice[] {\n if (typeof price === \"string\") return [price]\n return [\n ...(price.default === undefined ? [] : [price.default]),\n ...price.variants.map((variant) => variant.price),\n ]\n}\n\nfunction variantPrice(value: ModelVariantPrice, field: string): ModelVariantPrice {\n if (typeof value === \"string\") return price(value)\n assertRecord(value, `${field} price`)\n if (!Array.isArray(value.variants) || value.variants.length === 0) {\n throw new TypeError(`[Sixb] Model ${field} price variants must be a nonempty array.`)\n }\n\n let shape: string | undefined\n const seen = new Set<string>()\n const variants = value.variants.map((variant): ModelPriceVariant => {\n assertRecord(variant, `${field} price variant`)\n const dimensions: { -readonly [K in keyof ModelPricingDimensions]: string } = {}\n for (const dimension of PRICING_DIMENSIONS) {\n const named = variant[dimension]\n if (named === undefined) continue\n if (typeof named !== \"string\" || !named.trim()) {\n throw new TypeError(`[Sixb] Model ${field} price variant ${dimension} must be nonblank.`)\n }\n dimensions[dimension] = named\n }\n\n // One shared set of dimensions means a request matches at most one variant.\n const key = Object.keys(dimensions).join(\",\")\n if (!key || (shape !== undefined && key !== shape)) {\n throw new TypeError(\n `[Sixb] Model ${field} price variants must all name the same pricing dimensions.`\n )\n }\n shape = key\n const identity = JSON.stringify(Object.values(dimensions))\n if (seen.has(identity)) {\n throw new TypeError(`[Sixb] Model ${field} price variants must be distinct.`)\n }\n seen.add(identity)\n\n return Object.freeze({ ...dimensions, price: price(variant.price) })\n })\n\n return Object.freeze({\n ...(value.default === undefined ? {} : { default: price(value.default) }),\n variants: Object.freeze(variants),\n })\n}\n\nfunction tokenPrice(value: ModelTokenPrice | undefined): ModelTokenPrice {\n if (typeof value === \"string\") return price(value)\n assertRecord(value, \"token price\")\n if (!Array.isArray(value.tiers)) throw new TypeError(\"[Sixb] Model price tiers must be an array.\")\n let previousMax = 0\n return Object.freeze({\n default: price(value.default),\n tiers: Object.freeze(\n value.tiers.map((tier, index) => {\n assertRecord(tier, \"price tier\")\n if (\n typeof tier.minTokens !== \"number\" ||\n !Number.isSafeInteger(tier.minTokens) ||\n tier.minTokens < 0\n ) {\n throw new TypeError(\"[Sixb] Model price tier has an invalid minimum.\")\n }\n if (index > 0 && tier.minTokens < previousMax) {\n throw new TypeError(\"[Sixb] Model price tiers must be ordered and nonoverlapping.\")\n }\n if (\n tier.maxTokens !== undefined &&\n (typeof tier.maxTokens !== \"number\" ||\n !Number.isSafeInteger(tier.maxTokens) ||\n tier.maxTokens <= tier.minTokens)\n ) {\n throw new TypeError(\"[Sixb] Model price tier has an invalid maximum.\")\n }\n previousMax = tier.maxTokens ?? Number.POSITIVE_INFINITY\n return Object.freeze({\n minTokens: tier.minTokens,\n ...(tier.maxTokens === undefined ? {} : { maxTokens: tier.maxTokens }),\n price: price(tier.price),\n })\n })\n ),\n })\n}\n\nfunction price(value: unknown): string {\n if (typeof value !== \"string\" || !/^(?:0|[1-9]\\d*)(?:\\.\\d+)?$/.test(value)) {\n throw new TypeError(\"[Sixb] Model price must be a nonnegative decimal string.\")\n }\n return value\n}\n\nfunction assertRecord(value: unknown, field: string): asserts value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(`[Sixb] Model ${field} must be an object.`)\n }\n}\n",
19
- "import type { ModelRoute, ModelUsage } from \"./events\"\nimport {\n type ModelPricingDimensions,\n type ModelRateCard,\n type ModelTokenPrice,\n type ModelVariantPrice,\n modelVariantPrices,\n resolveModelVariantPrice,\n} from \"./rate-card\"\n\n/** Optional local financial enrichment cannot discard a completed, billable call. */\nexport function estimateModelCall(\n model: { readonly costEstimator?: Pick<ModelCostEstimator, \"estimate\"> },\n input: Parameters<ModelCostEstimator[\"estimate\"]>[0]\n): ModelCostEstimate {\n try {\n return model.costEstimator?.estimate(input) ?? rateModelCall({ usage: input.usage })\n } catch {\n console.warn(\n \"[Sixb] Model cost estimation failed; preserving usage and available provider cost.\"\n )\n return { status: \"unpriceable\", reason: \"missing-rate-card\" }\n }\n}\n\nexport interface ModelMoney {\n readonly currency: \"USD\"\n /** Billionths of one currency unit, serialized as an integer string. */\n readonly amountNanos: string\n}\n\nexport interface ModelReportedCost {\n readonly money: ModelMoney\n readonly providerId?: string\n}\n\n/** A local estimate is never a provider-reported charge. No financial API is required to run. */\nexport type ModelCostEstimate = Exclude<ModelCallCost, { status: \"reported\" }>\n\nexport interface ModelCostEstimator {\n /** Conservative token-cost reservation, including cache writes and pricing tiers.\n * Return undefined when routing or non-token charges prevent a safe local estimate. */\n estimateReservation?(input: {\n readonly inputTokens: number\n readonly outputTokens: number\n }): ModelMoney | undefined\n\n estimate(input: {\n readonly usage: ModelUsage\n readonly route?: ModelRoute\n readonly responseModelId?: string\n /** The request's size, quality, style or voice tier, for prices that vary with them. */\n readonly dimensions?: ModelPricingDimensions\n }): ModelCostEstimate\n}\n\nexport type ModelCostMeter =\n | \"audio.input.milliseconds\"\n | \"characters.input\"\n | \"images.output\"\n | \"tokens.input.total\"\n | \"tokens.input.uncached\"\n | \"tokens.input.cacheRead\"\n | \"tokens.input.cacheWrite\"\n | \"tokens.input.cacheWrite5m\"\n | \"tokens.input.cacheWrite1h\"\n | \"tokens.output.total\"\n | \"tokens.output.text\"\n | \"tokens.output.reasoning\"\n | \"tokens.output.image\"\n | \"tokens.output.audio\"\n\nexport interface ModelCostComponent {\n readonly meter: ModelCostMeter\n readonly quantity: string\n readonly rateAmountNanosPerMillion: string\n readonly chargeAmountNanos: string\n /** The price variant that applied, such as `1024x1024 · high`. Display only. */\n readonly variant?: string\n}\n\nexport type ModelCallCost =\n | { readonly status: \"reported\"; readonly money: ModelMoney; readonly providerId?: string }\n | {\n readonly status: \"rated\"\n readonly money: ModelMoney\n readonly components: readonly ModelCostComponent[]\n }\n | {\n readonly status: \"unpriceable\"\n readonly reason:\n | \"missing-rate-card\"\n | \"missing-usage\"\n | \"inconsistent-usage\"\n | \"unsupported-pricing-dimension\"\n readonly missingMeters?: readonly ModelCostMeter[]\n }\n\ntype Unpriceable = Extract<ModelCallCost, { status: \"unpriceable\" }>\n\ntype TokenRateCard = ModelRateCard & {\n readonly input: ModelTokenPrice\n readonly output: ModelTokenPrice\n}\n\nfunction pricesTokens(card: ModelRateCard): card is TokenRateCard {\n return card.input !== undefined && card.output !== undefined\n}\n\n/**\n * Reserve at the highest rates the request could be billed at, before cache usage, the final tier\n * and the produced media are known. Undefined when a meter the card bills has no bound.\n */\nexport function estimateModelReservation(input: {\n readonly inputTokens?: number\n readonly outputTokens?: number\n readonly outputImages?: number\n readonly inputCharacters?: number\n readonly dimensions?: ModelPricingDimensions\n readonly rateCard?: ModelRateCard\n}): ModelMoney | undefined {\n if (!input.rateCard) return undefined\n const counts = [input.inputTokens, input.outputTokens, input.outputImages, input.inputCharacters]\n if (!counts.every((n) => n === undefined || (Number.isSafeInteger(n) && n >= 0))) {\n throw new TypeError(\"[Sixb] Model reservation estimates must be nonnegative safe integers.\")\n }\n const maxRate = (prices: readonly (ModelTokenPrice | undefined)[]) => {\n const rates = prices.flatMap((price) =>\n price === undefined\n ? []\n : typeof price === \"string\"\n ? [price]\n : [price.default, ...price.tiers.map((tier) => tier.price)]\n )\n return highestRate(rates)\n }\n const card = input.rateCard\n const charge = (quantity: number, rate: bigint) =>\n (BigInt(quantity) * rate + 999_999n) / 1_000_000n\n\n let total = 0n\n if (pricesTokens(card)) {\n if (input.inputTokens === undefined || input.outputTokens === undefined) return undefined\n const inputRate = maxRate([\n card.input,\n card.cacheReadInput,\n card.cacheWriteInput,\n card.cacheWriteInput5m,\n card.cacheWriteInput1h,\n ])\n const outputRate = maxRate([card.output, card.imageOutput, card.audioOutput])\n total += charge(input.inputTokens, inputRate) + charge(input.outputTokens, outputRate)\n }\n if (card.images !== undefined) {\n if (input.outputImages === undefined) return undefined\n total += BigInt(input.outputImages) * reservationPrice(card.images, input.dimensions)\n }\n // Nothing measures an audio file's duration before it is sent.\n if (card.audioInputSeconds !== undefined) return undefined\n if (card.characters !== undefined) {\n if (input.inputCharacters === undefined) return undefined\n total += charge(input.inputCharacters, reservationPrice(card.characters, input.dimensions))\n }\n return { currency: \"USD\", amountNanos: total.toString() }\n}\n\nfunction reservationPrice(\n price: ModelVariantPrice,\n dimensions: ModelPricingDimensions | undefined\n): bigint {\n const resolved = resolveModelVariantPrice(price, dimensions)\n // The default applies to unknown dimensions; reserving it could fall short of a variant.\n return resolved?.variant !== undefined || typeof price === \"string\"\n ? decimalDollarsToNanos(resolved!.price)\n : highestRate(modelVariantPrices(price))\n}\n\nfunction highestRate(prices: readonly string[]): bigint {\n return prices.reduce((max, price) => {\n const rate = decimalDollarsToNanos(price)\n return rate > max ? rate : max\n }, 0n)\n}\n\n/**\n * Prefer the provider's bill over rate-card estimates, then rate the call locally. A call is\n * billed by tokens, by units (images, characters) or both; every quantity must be covered by one.\n */\nexport function rateModelCall(input: {\n readonly usage: ModelUsage\n readonly rateCard?: ModelRateCard\n readonly dimensions?: ModelPricingDimensions\n readonly reported?: undefined\n}): ModelCostEstimate\nexport function rateModelCall(input: {\n readonly usage: ModelUsage\n readonly rateCard?: ModelRateCard\n readonly dimensions?: ModelPricingDimensions\n readonly reported?: ModelReportedCost\n}): ModelCallCost\nexport function rateModelCall(input: {\n readonly usage: ModelUsage\n readonly rateCard?: ModelRateCard\n readonly dimensions?: ModelPricingDimensions\n readonly reported?: ModelReportedCost\n}): ModelCallCost {\n if (input.reported) {\n assertAmountNanos(input.reported.money.amountNanos)\n return {\n status: \"reported\",\n money: input.reported.money,\n ...(input.reported.providerId === undefined ? {} : { providerId: input.reported.providerId }),\n }\n }\n if (!input.rateCard) return { status: \"unpriceable\", reason: \"missing-rate-card\" }\n const { usage, rateCard } = input\n if (!validUsageCounters(usage)) {\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n\n const units = rateUnits(usage, rateCard, input.dimensions)\n if (!Array.isArray(units)) return units\n const tokens = pricesTokens(rateCard) ? rateTokens(usage, rateCard) : []\n if (!Array.isArray(tokens)) return tokens\n\n const components = [...tokens, ...units]\n const total = components.reduce((sum, entry) => sum + BigInt(entry.chargeAmountNanos), 0n)\n return {\n status: \"rated\",\n money: { currency: rateCard.currency, amountNanos: total.toString() },\n components,\n }\n}\n\nfunction rateUnits(\n usage: ModelUsage,\n rateCard: ModelRateCard,\n dimensions: ModelPricingDimensions | undefined\n): ModelCostComponent[] | Unpriceable {\n // Without token prices, a count the card doesn't price is a charge nothing covers.\n if (!pricesTokens(rateCard)) {\n const unpriced: ModelCostMeter[] = [\n ...((usage.outputImages ?? 0) > 0 && rateCard.images === undefined\n ? ([\"images.output\"] as const)\n : []),\n ...((usage.inputCharacters ?? 0) > 0 && rateCard.characters === undefined\n ? ([\"characters.input\"] as const)\n : []),\n ]\n if (unpriced.length > 0) {\n return { status: \"unpriceable\", reason: \"missing-rate-card\", missingMeters: unpriced }\n }\n }\n\n // Each card price, its meter, and the power of ten from its unit to nanos per million units.\n // Audio duration is charged only where a card prices it: speech reports the duration of\n // the audio it made, which nothing bills.\n const components: ModelCostComponent[] = []\n const missing: ModelCostMeter[] = []\n for (const [meter, quantity, price, exponent] of [\n [\"images.output\", usage.outputImages, rateCard.images, 15],\n [\"characters.input\", usage.inputCharacters, rateCard.characters, 9],\n [\"audio.input.milliseconds\", usage.audioDurationMs, rateCard.audioInputSeconds, 12],\n ] as const) {\n if (price === undefined) continue\n if (quantity === undefined) {\n missing.push(meter)\n continue\n }\n // A priced call that produced nothing keeps its zero-quantity component.\n if (quantity === 0 && pricesTokens(rateCard)) continue\n const resolved = resolveModelVariantPrice(price, dimensions) ?? (quantity === 0 ? zero : null)\n if (!resolved) return { status: \"unpriceable\", reason: \"unsupported-pricing-dimension\" }\n components.push(\n componentAtRate(meter, quantity, scaledDecimal(resolved.price, exponent), resolved.variant)\n )\n }\n if (missing.length > 0) {\n return { status: \"unpriceable\", reason: \"missing-usage\", missingMeters: missing }\n }\n return components\n}\n\nconst zero: { readonly price: string; readonly variant?: string } = { price: \"0\" }\n\nfunction rateTokens(\n usage: ModelUsage,\n rateCard: TokenRateCard\n): ModelCostComponent[] | Unpriceable {\n if (usage.inputTokens === undefined || usage.outputTokens === undefined) {\n return {\n status: \"unpriceable\",\n reason: \"missing-usage\",\n missingMeters: [\n ...(usage.inputTokens === undefined ? ([\"tokens.input.total\"] as const) : []),\n ...(usage.outputTokens === undefined ? ([\"tokens.output.total\"] as const) : []),\n ],\n }\n }\n\n const partitioned = partitionInputUsage(usage, rateCard)\n if (partitioned.status !== \"rated\") return partitioned\n\n const components: ModelCostComponent[] = []\n if (!partitioned.partitioned) {\n components.push(\n component(\"tokens.input.total\", usage.inputTokens, rateCard.input, usage.inputTokens)\n )\n } else {\n components.push(\n component(\"tokens.input.uncached\", partitioned.uncached, rateCard.input, usage.inputTokens)\n )\n if (partitioned.cacheRead !== undefined) {\n components.push(\n component(\n \"tokens.input.cacheRead\",\n partitioned.cacheRead,\n rateCard.cacheReadInput!,\n usage.inputTokens\n )\n )\n }\n if (partitioned.cacheWrite !== undefined) {\n components.push(\n component(\n \"tokens.input.cacheWrite\",\n partitioned.cacheWrite,\n rateCard.cacheWriteInput!,\n usage.inputTokens\n )\n )\n }\n if (partitioned.cacheWrite5m !== undefined) {\n components.push(\n component(\n \"tokens.input.cacheWrite5m\",\n partitioned.cacheWrite5m,\n rateCard.cacheWriteInput5m ?? rateCard.cacheWriteInput!,\n usage.inputTokens\n )\n )\n }\n if (partitioned.cacheWrite1h !== undefined) {\n components.push(\n component(\n \"tokens.input.cacheWrite1h\",\n partitioned.cacheWrite1h,\n rateCard.cacheWriteInput1h ?? rateCard.cacheWriteInput!,\n usage.inputTokens\n )\n )\n }\n }\n\n const output = rateOutputTokens(usage, usage.outputTokens, usage.inputTokens, rateCard)\n if (!Array.isArray(output)) return output\n return [...components, ...output]\n}\n\n/**\n * Output tokens split by what bills them: per-image prices cover image tokens, media token prices\n * bill their own share, and the rest is text and reasoning. Splitting requires those counts.\n */\nfunction rateOutputTokens(\n usage: ModelUsage,\n outputTokens: number,\n tierTokens: number,\n rateCard: TokenRateCard\n): ModelCostComponent[] | Unpriceable {\n const imagesCoverTokens = rateCard.images !== undefined && (usage.outputImages ?? 0) > 0\n const missing: ModelCostMeter[] = []\n if (\n (imagesCoverTokens || rateCard.imageOutput !== undefined) &&\n usage.imageOutputTokens === undefined\n ) {\n missing.push(\"tokens.output.image\")\n }\n if (rateCard.audioOutput !== undefined && usage.audioOutputTokens === undefined) {\n missing.push(\"tokens.output.audio\")\n }\n if (missing.length > 0) {\n return { status: \"unpriceable\", reason: \"missing-usage\", missingMeters: missing }\n }\n\n const covered = imagesCoverTokens ? usage.imageOutputTokens! : 0\n const media: ModelCostComponent[] = []\n if (!imagesCoverTokens && rateCard.imageOutput !== undefined && usage.imageOutputTokens! > 0) {\n media.push(\n component(\"tokens.output.image\", usage.imageOutputTokens!, rateCard.imageOutput, tierTokens)\n )\n }\n if (rateCard.audioOutput !== undefined && usage.audioOutputTokens! > 0) {\n media.push(\n component(\"tokens.output.audio\", usage.audioOutputTokens!, rateCard.audioOutput, tierTokens)\n )\n }\n if (covered === 0 && media.length === 0) {\n return [component(\"tokens.output.total\", outputTokens, rateCard.output, tierTokens)]\n }\n\n const remainder =\n outputTokens - covered - media.reduce((sum, entry) => sum + Number(entry.quantity), 0)\n if (remainder < 0) return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n const text = usage.textOutputTokens\n const reasoning = usage.reasoningOutputTokens\n if (remainder > 0 && text === undefined) {\n return { status: \"unpriceable\", reason: \"missing-usage\", missingMeters: [\"tokens.output.text\"] }\n }\n if (remainder > 0 && text! + (reasoning ?? 0) !== remainder) {\n return reasoning === undefined\n ? {\n status: \"unpriceable\",\n reason: \"missing-usage\",\n missingMeters: [\"tokens.output.reasoning\"],\n }\n : { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n return [\n ...(remainder > 0 && text! > 0\n ? [component(\"tokens.output.text\", text!, rateCard.output, tierTokens)]\n : []),\n ...(remainder > 0 && (reasoning ?? 0) > 0\n ? [component(\"tokens.output.reasoning\", reasoning!, rateCard.output, tierTokens)]\n : []),\n ...media,\n ]\n}\n\ntype PartitionResult =\n | { readonly status: \"rated\"; readonly partitioned: false }\n | {\n readonly status: \"rated\"\n readonly partitioned: true\n readonly uncached: number\n readonly cacheRead?: number\n readonly cacheWrite?: number\n readonly cacheWrite5m?: number\n readonly cacheWrite1h?: number\n }\n | Extract<ModelCallCost, { status: \"unpriceable\" }>\n\nfunction partitionInputUsage(usage: ModelUsage, rateCard: ModelRateCard): PartitionResult {\n const hasSpecificWrites =\n usage.cacheWrite5mInputTokens !== undefined || usage.cacheWrite1hInputTokens !== undefined\n const cacheWriteSpecific =\n (usage.cacheWrite5mInputTokens ?? 0) + (usage.cacheWrite1hInputTokens ?? 0)\n if (\n hasSpecificWrites &&\n usage.cacheWriteInputTokens !== undefined &&\n usage.cacheWriteInputTokens !== cacheWriteSpecific\n ) {\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n\n const partitioned =\n usage.uncachedInputTokens !== undefined ||\n usage.cacheReadInputTokens !== undefined ||\n usage.cacheWriteInputTokens !== undefined ||\n hasSpecificWrites ||\n rateCard.cacheReadInput !== undefined ||\n rateCard.cacheWriteInput !== undefined ||\n rateCard.cacheWriteInput5m !== undefined ||\n rateCard.cacheWriteInput1h !== undefined\n if (!partitioned) return { status: \"rated\", partitioned: false }\n\n const cacheRead = usage.cacheReadInputTokens ?? 0\n const totalWrite = usage.cacheWriteInputTokens ?? cacheWriteSpecific\n if (usage.inputTokens !== undefined && cacheRead + totalWrite > usage.inputTokens) {\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n\n const missing: ModelCostMeter[] = []\n if (usage.uncachedInputTokens === undefined) missing.push(\"tokens.input.uncached\")\n if (rateCard.cacheReadInput !== undefined && usage.cacheReadInputTokens === undefined) {\n missing.push(\"tokens.input.cacheRead\")\n }\n if (\n rateCard.cacheWriteInput !== undefined &&\n rateCard.cacheWriteInput5m === undefined &&\n rateCard.cacheWriteInput1h === undefined &&\n usage.cacheWriteInputTokens === undefined\n ) {\n missing.push(\"tokens.input.cacheWrite\")\n }\n if (rateCard.cacheWriteInput5m !== undefined && usage.cacheWrite5mInputTokens === undefined) {\n missing.push(\"tokens.input.cacheWrite5m\")\n }\n if (rateCard.cacheWriteInput1h !== undefined && usage.cacheWrite1hInputTokens === undefined) {\n missing.push(\"tokens.input.cacheWrite1h\")\n }\n if (missing.length > 0) {\n return { status: \"unpriceable\", reason: \"missing-usage\", missingMeters: missing }\n }\n if (cacheRead > 0 && rateCard.cacheReadInput === undefined) {\n return {\n status: \"unpriceable\",\n reason: \"missing-rate-card\",\n missingMeters: [\"tokens.input.cacheRead\"],\n }\n }\n if (!hasSpecificWrites && totalWrite > 0 && rateCard.cacheWriteInput === undefined) {\n return {\n status: \"unpriceable\",\n reason: \"missing-rate-card\",\n missingMeters: [\"tokens.input.cacheWrite\"],\n }\n }\n if (\n (usage.cacheWrite5mInputTokens ?? 0) > 0 &&\n rateCard.cacheWriteInput5m === undefined &&\n rateCard.cacheWriteInput === undefined\n ) {\n return {\n status: \"unpriceable\",\n reason: \"missing-rate-card\",\n missingMeters: [\"tokens.input.cacheWrite5m\"],\n }\n }\n if (\n (usage.cacheWrite1hInputTokens ?? 0) > 0 &&\n rateCard.cacheWriteInput1h === undefined &&\n rateCard.cacheWriteInput === undefined\n ) {\n return {\n status: \"unpriceable\",\n reason: \"missing-rate-card\",\n missingMeters: [\"tokens.input.cacheWrite1h\"],\n }\n }\n\n const uncached = usage.uncachedInputTokens!\n if (uncached + cacheRead + totalWrite !== usage.inputTokens) {\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n return {\n status: \"rated\",\n partitioned: true,\n uncached,\n ...(rateCard.cacheReadInput === undefined ? {} : { cacheRead }),\n ...(hasSpecificWrites\n ? {\n ...(rateCard.cacheWriteInput5m !== undefined || rateCard.cacheWriteInput !== undefined\n ? { cacheWrite5m: usage.cacheWrite5mInputTokens ?? 0 }\n : {}),\n ...(rateCard.cacheWriteInput1h !== undefined || rateCard.cacheWriteInput !== undefined\n ? { cacheWrite1h: usage.cacheWrite1hInputTokens ?? 0 }\n : {}),\n }\n : rateCard.cacheWriteInput === undefined\n ? {}\n : { cacheWrite: totalWrite }),\n }\n}\n\nfunction validUsageCounters(usage: ModelUsage): boolean {\n return Object.entries(usage)\n .filter(([key]) => key !== \"raw\")\n .every(([, value]) => value === undefined || (Number.isSafeInteger(value) && value >= 0))\n}\n\nfunction component(\n meter: ModelCostMeter,\n quantity: number,\n price: ModelTokenPrice,\n tierTokens: number\n): ModelCostComponent {\n return componentAtRate(meter, quantity, decimalDollarsToNanos(resolvePrice(price, tierTokens)))\n}\n\nfunction componentAtRate(\n meter: ModelCostMeter,\n quantity: number,\n rate: bigint,\n variant?: string\n): ModelCostComponent {\n const charge = (BigInt(quantity) * rate + 500_000n) / 1_000_000n\n return {\n meter,\n quantity: quantity.toString(),\n rateAmountNanosPerMillion: rate.toString(),\n chargeAmountNanos: charge.toString(),\n ...(variant ? { variant } : {}),\n }\n}\n\nfunction resolvePrice(price: ModelTokenPrice, tokens: number): string {\n if (typeof price === \"string\") return price\n return (\n price.tiers.find(\n (tier) =>\n tokens >= tier.minTokens && (tier.maxTokens === undefined || tokens < tier.maxTokens)\n )?.price ?? price.default\n )\n}\n\n/** A decimal price times 10^exponent, rounded half up at the first dropped digit. */\nfunction scaledDecimal(value: string, exponent: number): bigint {\n const [whole = \"0\", fraction = \"\"] = value.split(\".\")\n const kept = fraction.slice(0, exponent).padEnd(exponent, \"0\")\n const roundUp = Number(fraction[exponent] ?? \"0\") >= 5\n return BigInt(whole) * 10n ** BigInt(exponent) + BigInt(kept) + (roundUp ? 1n : 0n)\n}\n\nfunction decimalDollarsToNanos(value: string): bigint {\n const [whole = \"0\", fraction = \"\"] = value.split(\".\")\n const nanos = fraction.slice(0, 9).padEnd(9, \"0\")\n const roundUp = Number(fraction[9] ?? \"0\") >= 5\n return BigInt(whole) * 1_000_000_000n + BigInt(nanos) + (roundUp ? 1n : 0n)\n}\n\nfunction assertAmountNanos(value: string): void {\n if (!/^(?:0|[1-9]\\d*)$/.test(value)) {\n throw new TypeError(\"[Sixb] Provider-reported model cost must use nonnegative amountNanos.\")\n }\n}\n"
20
- ],
21
- "mappings": ";;;;;;;;;;;;;;;;;;;AAIO,MAAM,yCAAwC,oBAAmB;AAAA,EAK3D;AAAA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Ac,aAAa,SAAS,KAAK,UAC/E,GAAG,SAAS,MAAM;AAAA;AAKtB,SAAS,aAAa,CAAC,OAAe,UAA0B;AAAA,EAC9D,OAAO,QAAQ,KAAK,WAAW,MAAM,MAAM,MAAM,GAAG;AAAA,EACpD,MAAM,OAAO,SAAS,MAAM,GAAG,QAAQ,EAAE,OAAO,UAAU,GAAG;AAAA,EAC7D,MAAM,UAAU,OAAO,SAAS,aAAa,GAAG,KAAK;AAAA,EACrD,OAAO,OAAO,KAAK,IAAI,OAAO,OAAO,QAAQ,IAAI,OAAO,IAAI,KAAK,UAAU,KAAK;AAAA;AAGlF,SAAS,qBAAqB,CAAC,OAAuB;AAAA,EACpD,OAAO,QAAQ,KAAK,WAAW,MAAM,MAAM,MAAM,GAAG;AAAA,EACpD,MAAM,QAAQ,SAAS,MAAM,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG;AAAA,EAChD,MAAM,UAAU,OAAO,SAAS,MAAM,GAAG,KAAK;AAAA,EAC9C,OAAO,OAAO,KAAK,IAAI,cAAiB,OAAO,KAAK,KAAK,UAAU,KAAK;AAAA;AAG1E,SAAS,iBAAiB,CAAC,OAAqB;AAAA,EAC9C,IAAI,CAAC,mBAAmB,KAAK,KAAK,GAAG;AAAA,IACnC,MAAM,IAAI,UAAU,uEAAuE;AAAA,EAC7F;AAAA;",
22
- "debugId": "530B9B10FEC6AA3964756E2164756E21",
23
- "names": []
24
- }
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/agents/context/entries.ts"],
4
- "sourcesContent": [
5
- "import type { JsonValue } from \"../../json\"\nimport { cloneJsonValue, getInvalidJsonValueReason, stableJsonStringify } from \"../../json\"\nimport type { ObjectRef } from \"../../ontology/refs\"\nimport { AgentRequestError } from \"../errors\"\n\nexport type AgentContextInput =\n | {\n readonly kind: \"object\"\n readonly ref: ObjectRef\n /**\n * What the chat shows for this object instead of its title. Display only: it is not part of\n * the context's identity and is never sent to the model.\n */\n readonly label?: string\n }\n | {\n readonly kind: \"app-state\"\n readonly id: string\n readonly label: string\n readonly description: string\n readonly value: JsonValue\n }\n\nexport type AgentContextOrigin = \"ambient\" | \"explicit\"\n\nexport interface AgentContextEntryInput {\n readonly context: AgentContextInput\n readonly origin: AgentContextOrigin\n}\n\n/** Durable user-message part. Origin is display provenance, never an authorization grant. */\nexport interface AgentContextPart extends AgentContextEntryInput {\n readonly type: \"context\"\n}\n\nexport const MAX_AGENT_CONTEXT_ENTRIES = 12\nexport const MAX_AGENT_APP_STATE_ENTRY_BYTES = 16 * 1024\nexport const MAX_AGENT_APP_STATE_TOTAL_BYTES = 64 * 1024\nexport const MAX_AGENT_CONTEXT_LABEL_LENGTH = 200\n\n/** Typed constructors for context values shared by custom apps and agent clients. */\nexport const agentContext = {\n object<const TObjectTypeId extends string>(\n objectType: { readonly id: TObjectTypeId },\n primaryId: string,\n options: { readonly label?: string } = {}\n ) {\n const label =\n options.label === undefined\n ? undefined\n : objectContextLabel(options.label, \"agentContext.object() label\", (message) => {\n throw new TypeError(`[Sixb] ${message}.`)\n })\n return {\n kind: \"object\" as const,\n ref: { objectTypeId: objectType.id, primaryId },\n ...(label === undefined ? {} : { label }),\n }\n },\n\n appState<const TValue extends JsonValue>(\n id: string,\n input: {\n readonly label: string\n readonly description: string\n readonly value: TValue\n }\n ) {\n return { kind: \"app-state\" as const, id, ...input }\n },\n}\n\n/** Stable identity shared by core deduplication and context-aware clients. */\nexport function agentContextIdentity(context: AgentContextInput): string {\n return context.kind === \"object\"\n ? `object:${encodeURIComponent(context.ref.objectTypeId)}:${encodeURIComponent(context.ref.primaryId)}`\n : `app-state:${encodeURIComponent(context.id)}`\n}\n\n/** Stable semantic key for client-side comparisons. */\nexport function agentContextFingerprint(context: AgentContextInput): string {\n return stableJsonStringify(context)\n}\n\n/**\n * Validate transport-independent context rules and clone mutable app state before it can become\n * durable. Object existence and visibility are resolved separately because they require a runtime.\n */\nexport function normalizeAgentContextEntries(\n input: readonly AgentContextEntryInput[] | undefined\n): readonly AgentContextEntryInput[] {\n if (input === undefined) return []\n if (!Array.isArray(input)) invalidContext(\"context must be an array\")\n if (input.length > MAX_AGENT_CONTEXT_ENTRIES) {\n invalidContext(`context cannot contain more than ${MAX_AGENT_CONTEXT_ENTRIES} entries`)\n }\n\n const entries: AgentContextEntryInput[] = []\n const byIdentity = new Map<string, string>()\n let totalAppStateBytes = 0\n\n for (const [index, rawEntry] of input.entries()) {\n const entry = normalizeEntry(rawEntry, index)\n const identity = agentContextIdentity(entry.context)\n // A label is display only, so two entries that differ only by label are the same entry; the\n // first one's label is kept.\n const serialized = stableJsonStringify(\n entry.context.kind === \"object\"\n ? { ...entry, context: { kind: \"object\", ref: entry.context.ref } }\n : entry\n )\n const existing = byIdentity.get(identity)\n\n if (existing !== undefined) {\n if (existing === serialized) continue\n invalidContext(`context contains conflicting entries for '${identity}'`)\n }\n\n if (entry.context.kind === \"app-state\") {\n const bytes = utf8ByteLength(serialized)\n if (bytes > MAX_AGENT_APP_STATE_ENTRY_BYTES) {\n invalidContext(\n `context entry '${identity}' exceeds the ${MAX_AGENT_APP_STATE_ENTRY_BYTES}-byte limit`\n )\n }\n totalAppStateBytes += bytes\n if (totalAppStateBytes > MAX_AGENT_APP_STATE_TOTAL_BYTES) {\n invalidContext(\n `app-state context exceeds the ${MAX_AGENT_APP_STATE_TOTAL_BYTES}-byte message limit`\n )\n }\n }\n\n byIdentity.set(identity, serialized)\n entries.push(entry)\n }\n\n return entries\n}\n\nfunction normalizeEntry(rawEntry: unknown, index: number): AgentContextEntryInput {\n if (!isRecord(rawEntry)) invalidContext(`context[${index}] must be an object`)\n if (rawEntry.origin !== \"ambient\" && rawEntry.origin !== \"explicit\") {\n invalidContext(`context[${index}].origin must be 'ambient' or 'explicit'`)\n }\n if (!isRecord(rawEntry.context)) invalidContext(`context[${index}].context must be an object`)\n\n const context = rawEntry.context\n if (context.kind === \"object\") {\n if (!isRecord(context.ref)) invalidContext(`context[${index}].context.ref must be an object`)\n const objectTypeId = requireNonEmptyString(\n context.ref.objectTypeId,\n `context[${index}].context.ref.objectTypeId`\n )\n const primaryId = requireNonEmptyString(\n context.ref.primaryId,\n `context[${index}].context.ref.primaryId`\n )\n const label =\n context.label === undefined\n ? undefined\n : objectContextLabel(context.label, `context[${index}].context.label`, invalidContext)\n return {\n context: {\n kind: \"object\",\n ref: { objectTypeId, primaryId },\n ...(label === undefined ? {} : { label }),\n },\n origin: rawEntry.origin,\n }\n }\n\n if (context.kind === \"app-state\") {\n const id = requireNonEmptyString(context.id, `context[${index}].context.id`)\n const label = requireNonEmptyString(context.label, `context[${index}].context.label`)\n const description = requireNonEmptyString(\n context.description,\n `context[${index}].context.description`\n )\n const reason = getInvalidJsonValueReason(context.value, `context[${index}].context.value`)\n if (reason) {\n invalidContext(`context[${index}].context.value must be a JSON value; ${reason}`)\n }\n return {\n context: {\n kind: \"app-state\",\n id,\n label,\n description,\n value: cloneJsonValue(context.value as JsonValue),\n },\n origin: rawEntry.origin,\n }\n }\n\n invalidContext(`context[${index}].context.kind must be 'object' or 'app-state'`)\n}\n\nfunction objectContextLabel(\n value: unknown,\n label: string,\n fail: (message: string) => never\n): string {\n const trimmed = typeof value === \"string\" ? value.trim() : \"\"\n if (!trimmed) fail(`${label} must be a non-empty string`)\n if (trimmed.length > MAX_AGENT_CONTEXT_LABEL_LENGTH) {\n fail(`${label} must be at most ${MAX_AGENT_CONTEXT_LABEL_LENGTH} characters`)\n }\n return trimmed\n}\n\nfunction requireNonEmptyString(value: unknown, label: string): string {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n invalidContext(`${label} must be a non-empty string`)\n }\n return value\n}\n\nfunction utf8ByteLength(value: string): number {\n return new TextEncoder().encode(value).byteLength\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction invalidContext(message: string): never {\n throw new AgentRequestError(\"invalid_context\", `[Sixb] Invalid agent context: ${message}.`)\n}\n"
6
- ],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