gemi 0.204.2 → 0.205.0

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 (248) hide show
  1. package/dist/ai/AgentProvider.d.ts +80 -3
  2. package/dist/ai/AgentProvider.d.ts.map +1 -1
  3. package/dist/ai/client/index.js +12 -10
  4. package/dist/ai/client/index.js.map +1 -1
  5. package/dist/ai/index.d.ts +2 -2
  6. package/dist/ai/index.d.ts.map +1 -1
  7. package/dist/ai/index.js +4 -4
  8. package/dist/ai/index.js.map +3 -3
  9. package/dist/ai/providers/anthropicRequest.d.ts +142 -0
  10. package/dist/ai/providers/anthropicRequest.d.ts.map +1 -0
  11. package/dist/ai/providers/anthropicStream.d.ts +54 -0
  12. package/dist/ai/providers/anthropicStream.d.ts.map +1 -0
  13. package/dist/ai/providers/call.d.ts +14 -3
  14. package/dist/ai/providers/call.d.ts.map +1 -1
  15. package/dist/ai/providers/capabilities.d.ts +31 -0
  16. package/dist/ai/providers/capabilities.d.ts.map +1 -1
  17. package/dist/ai/providers/endpoints.d.ts +40 -0
  18. package/dist/ai/providers/endpoints.d.ts.map +1 -1
  19. package/dist/ai/providers/http.d.ts.map +1 -1
  20. package/dist/ai/providers/request.d.ts +43 -1
  21. package/dist/ai/providers/request.d.ts.map +1 -1
  22. package/dist/ai/runtime.d.ts +5 -1
  23. package/dist/ai/runtime.d.ts.map +1 -1
  24. package/dist/ai/testing/RecordingProvider.d.ts +5 -2
  25. package/dist/ai/testing/RecordingProvider.d.ts.map +1 -1
  26. package/dist/ai/testing/index.js +3 -3
  27. package/dist/ai/testing/index.js.map +3 -3
  28. package/dist/ai/types.d.ts +34 -0
  29. package/dist/ai/types.d.ts.map +1 -1
  30. package/dist/ai/usageMeter.d.ts +4 -1
  31. package/dist/ai/usageMeter.d.ts.map +1 -1
  32. package/dist/app/index.js +2 -2
  33. package/dist/app/index.js.map +1 -1
  34. package/dist/bun/plugin.js +2 -2
  35. package/dist/bun/plugin.js.map +1 -1
  36. package/dist/bun/preload.js +2 -2
  37. package/dist/bun/preload.js.map +1 -1
  38. package/dist/{chunk-2t1eyzvq.js → chunk-06w8hhnk.js} +2 -2
  39. package/dist/{chunk-2t1eyzvq.js.map → chunk-06w8hhnk.js.map} +1 -1
  40. package/dist/{chunk-0t1d9s34.js → chunk-09hzyf9g.js} +3 -3
  41. package/dist/{chunk-0t1d9s34.js.map → chunk-09hzyf9g.js.map} +1 -1
  42. package/dist/{chunk-bq4pgzcd.js → chunk-0cckwd91.js} +2 -2
  43. package/dist/{chunk-bq4pgzcd.js.map → chunk-0cckwd91.js.map} +1 -1
  44. package/dist/{chunk-9hqnecjt.js → chunk-0eq7am78.js} +2 -2
  45. package/dist/{chunk-9hqnecjt.js.map → chunk-0eq7am78.js.map} +1 -1
  46. package/dist/{chunk-jma5d7zd.js → chunk-1em8t2x1.js} +3 -3
  47. package/dist/{chunk-jma5d7zd.js.map → chunk-1em8t2x1.js.map} +1 -1
  48. package/dist/{chunk-ek0dvbck.js → chunk-1tc6j8bn.js} +3 -3
  49. package/dist/{chunk-ek0dvbck.js.map → chunk-1tc6j8bn.js.map} +1 -1
  50. package/dist/{chunk-dk1xxtgk.js → chunk-24tj4dzx.js} +2 -2
  51. package/dist/{chunk-dk1xxtgk.js.map → chunk-24tj4dzx.js.map} +1 -1
  52. package/dist/{chunk-cg009t41.js → chunk-2qcmcbsk.js} +2 -2
  53. package/dist/{chunk-cg009t41.js.map → chunk-2qcmcbsk.js.map} +1 -1
  54. package/dist/{chunk-s5hdrpam.js → chunk-34vvev4a.js} +3 -3
  55. package/dist/{chunk-s5hdrpam.js.map → chunk-34vvev4a.js.map} +1 -1
  56. package/dist/{chunk-f52maa9b.js → chunk-3830ee5d.js} +2 -2
  57. package/dist/{chunk-f52maa9b.js.map → chunk-3830ee5d.js.map} +1 -1
  58. package/dist/{chunk-yykrvrpt.js → chunk-39dz1abf.js} +1 -1
  59. package/dist/{chunk-vsd5h2d9.js → chunk-3z8d8v8q.js} +3 -3
  60. package/dist/{chunk-vsd5h2d9.js.map → chunk-3z8d8v8q.js.map} +1 -1
  61. package/dist/{chunk-f9c8bnzx.js → chunk-460c8k50.js} +3 -3
  62. package/dist/{chunk-f9c8bnzx.js.map → chunk-460c8k50.js.map} +1 -1
  63. package/dist/{chunk-wxyxnbh6.js → chunk-4ksnhx8x.js} +4 -4
  64. package/dist/{chunk-wxyxnbh6.js.map → chunk-4ksnhx8x.js.map} +1 -1
  65. package/dist/chunk-4q59y78y.js +5 -0
  66. package/dist/{chunk-cf7xc02m.js.map → chunk-4q59y78y.js.map} +1 -1
  67. package/dist/{chunk-4m8t67px.js → chunk-65btke6p.js} +2 -2
  68. package/dist/{chunk-4m8t67px.js.map → chunk-65btke6p.js.map} +1 -1
  69. package/dist/{chunk-efnerp0c.js → chunk-6cx6kh04.js} +2 -2
  70. package/dist/{chunk-efnerp0c.js.map → chunk-6cx6kh04.js.map} +1 -1
  71. package/dist/{chunk-jmsfkzav.js → chunk-6ge27ygx.js} +2 -2
  72. package/dist/{chunk-jmsfkzav.js.map → chunk-6ge27ygx.js.map} +1 -1
  73. package/dist/{chunk-x26jb60f.js → chunk-6x2zbh1q.js} +2 -2
  74. package/dist/{chunk-x26jb60f.js.map → chunk-6x2zbh1q.js.map} +1 -1
  75. package/dist/{chunk-0hfzzb3k.js → chunk-6zpf257t.js} +3 -3
  76. package/dist/{chunk-0hfzzb3k.js.map → chunk-6zpf257t.js.map} +1 -1
  77. package/dist/{chunk-cq7hk8v9.js → chunk-72e857nw.js} +2 -2
  78. package/dist/{chunk-cq7hk8v9.js.map → chunk-72e857nw.js.map} +1 -1
  79. package/dist/{chunk-4v5c4mes.js → chunk-77dt2tap.js} +2 -2
  80. package/dist/{chunk-4v5c4mes.js.map → chunk-77dt2tap.js.map} +1 -1
  81. package/dist/{chunk-ptpzh61m.js → chunk-78g1cngk.js} +2 -2
  82. package/dist/{chunk-ptpzh61m.js.map → chunk-78g1cngk.js.map} +1 -1
  83. package/dist/{chunk-d7kknkmq.js → chunk-7wzhdq1x.js} +3 -3
  84. package/dist/{chunk-d7kknkmq.js.map → chunk-7wzhdq1x.js.map} +1 -1
  85. package/dist/{chunk-6g1xac70.js → chunk-8ar7180x.js} +2 -2
  86. package/dist/{chunk-6g1xac70.js.map → chunk-8ar7180x.js.map} +1 -1
  87. package/dist/{chunk-d3k38gk1.js → chunk-8d2g78vc.js} +2 -2
  88. package/dist/{chunk-d3k38gk1.js.map → chunk-8d2g78vc.js.map} +1 -1
  89. package/dist/{chunk-yrbvfda9.js → chunk-8ncqxja2.js} +1 -1
  90. package/dist/{chunk-6w6q9mxe.js → chunk-8q5kxzxn.js} +3 -3
  91. package/dist/{chunk-6w6q9mxe.js.map → chunk-8q5kxzxn.js.map} +1 -1
  92. package/dist/{chunk-y45whafz.js → chunk-9m6mkaqb.js} +2 -2
  93. package/dist/{chunk-y45whafz.js.map → chunk-9m6mkaqb.js.map} +1 -1
  94. package/dist/{chunk-zk1vwwv6.js → chunk-9qyet3nb.js} +2 -2
  95. package/dist/{chunk-zk1vwwv6.js.map → chunk-9qyet3nb.js.map} +1 -1
  96. package/dist/{chunk-p2nqksdq.js → chunk-a7rgrcs0.js} +3 -3
  97. package/dist/{chunk-p2nqksdq.js.map → chunk-a7rgrcs0.js.map} +1 -1
  98. package/dist/{chunk-x244kqcc.js → chunk-a7zqp5m7.js} +2 -2
  99. package/dist/{chunk-x244kqcc.js.map → chunk-a7zqp5m7.js.map} +1 -1
  100. package/dist/{chunk-y5kfqq4f.js → chunk-aed0vv5g.js} +2 -2
  101. package/dist/{chunk-y5kfqq4f.js.map → chunk-aed0vv5g.js.map} +1 -1
  102. package/dist/chunk-at49en07.js +11 -0
  103. package/dist/chunk-at49en07.js.map +21 -0
  104. package/dist/{chunk-kgjcszx0.js → chunk-b1fcttsr.js} +2 -2
  105. package/dist/{chunk-kgjcszx0.js.map → chunk-b1fcttsr.js.map} +1 -1
  106. package/dist/{chunk-9m7c4mws.js → chunk-ba1h9pm6.js} +2 -2
  107. package/dist/{chunk-9m7c4mws.js.map → chunk-ba1h9pm6.js.map} +1 -1
  108. package/dist/{chunk-7gxmf9rg.js → chunk-bpqkzpkt.js} +2 -2
  109. package/dist/{chunk-7gxmf9rg.js.map → chunk-bpqkzpkt.js.map} +1 -1
  110. package/dist/{chunk-qcrj4t72.js → chunk-bxznwntw.js} +2 -2
  111. package/dist/{chunk-qcrj4t72.js.map → chunk-bxznwntw.js.map} +1 -1
  112. package/dist/{chunk-4c0rb2ng.js → chunk-c8bvpkr2.js} +2 -2
  113. package/dist/{chunk-4c0rb2ng.js.map → chunk-c8bvpkr2.js.map} +1 -1
  114. package/dist/{chunk-jeq8wvj6.js → chunk-cffx7wqp.js} +2 -2
  115. package/dist/{chunk-jeq8wvj6.js.map → chunk-cffx7wqp.js.map} +1 -1
  116. package/dist/{chunk-8jfnn7v6.js → chunk-djnn8vvp.js} +2 -2
  117. package/dist/{chunk-8jfnn7v6.js.map → chunk-djnn8vvp.js.map} +1 -1
  118. package/dist/{chunk-s6bq91cm.js → chunk-dwya9z8p.js} +2 -2
  119. package/dist/{chunk-s6bq91cm.js.map → chunk-dwya9z8p.js.map} +1 -1
  120. package/dist/chunk-e0scxs81.js +5 -0
  121. package/dist/{chunk-xwqdh388.js.map → chunk-e0scxs81.js.map} +4 -4
  122. package/dist/{chunk-0shq2d31.js → chunk-eeq9ty68.js} +2 -2
  123. package/dist/{chunk-0shq2d31.js.map → chunk-eeq9ty68.js.map} +1 -1
  124. package/dist/{chunk-77x9vxht.js → chunk-emt36pxm.js} +2 -2
  125. package/dist/{chunk-77x9vxht.js.map → chunk-emt36pxm.js.map} +1 -1
  126. package/dist/{chunk-k62338g2.js → chunk-etcds9w3.js} +2 -2
  127. package/dist/{chunk-k62338g2.js.map → chunk-etcds9w3.js.map} +1 -1
  128. package/dist/{chunk-yjvqq4hj.js → chunk-ff63e1wx.js} +2 -2
  129. package/dist/{chunk-yjvqq4hj.js.map → chunk-ff63e1wx.js.map} +1 -1
  130. package/dist/{chunk-d5d3a8bm.js → chunk-fhn92are.js} +2 -2
  131. package/dist/{chunk-d5d3a8bm.js.map → chunk-fhn92are.js.map} +1 -1
  132. package/dist/{chunk-crqbzfd5.js → chunk-g6tqje74.js} +2 -2
  133. package/dist/{chunk-crqbzfd5.js.map → chunk-g6tqje74.js.map} +1 -1
  134. package/dist/{chunk-p9pwskv6.js → chunk-hke4hzfm.js} +2 -2
  135. package/dist/{chunk-p9pwskv6.js.map → chunk-hke4hzfm.js.map} +1 -1
  136. package/dist/{chunk-3gkxnfef.js → chunk-hqg4dfca.js} +2 -2
  137. package/dist/{chunk-3gkxnfef.js.map → chunk-hqg4dfca.js.map} +1 -1
  138. package/dist/{chunk-39hed4yr.js → chunk-hthyn5pj.js} +3 -3
  139. package/dist/{chunk-39hed4yr.js.map → chunk-hthyn5pj.js.map} +1 -1
  140. package/dist/{chunk-w3mc696j.js → chunk-jn1h76sa.js} +2 -2
  141. package/dist/{chunk-w3mc696j.js.map → chunk-jn1h76sa.js.map} +1 -1
  142. package/dist/{chunk-ezvtkbp9.js → chunk-jy26hy7z.js} +2 -2
  143. package/dist/{chunk-ezvtkbp9.js.map → chunk-jy26hy7z.js.map} +1 -1
  144. package/dist/{chunk-5km0np8s.js → chunk-jy61580r.js} +2 -2
  145. package/dist/{chunk-5km0np8s.js.map → chunk-jy61580r.js.map} +1 -1
  146. package/dist/{chunk-phvvxv1a.js → chunk-k8peybx0.js} +3 -3
  147. package/dist/{chunk-phvvxv1a.js.map → chunk-k8peybx0.js.map} +1 -1
  148. package/dist/{chunk-3xzhbkya.js → chunk-m3v661b3.js} +3 -3
  149. package/dist/{chunk-3xzhbkya.js.map → chunk-m3v661b3.js.map} +1 -1
  150. package/dist/{chunk-js9rm7g0.js → chunk-ndcqbwsj.js} +2 -2
  151. package/dist/{chunk-js9rm7g0.js.map → chunk-ndcqbwsj.js.map} +1 -1
  152. package/dist/{chunk-cdgnwzwf.js → chunk-ne51fxg2.js} +2 -2
  153. package/dist/{chunk-cdgnwzwf.js.map → chunk-ne51fxg2.js.map} +1 -1
  154. package/dist/{chunk-b1mdan5a.js → chunk-nfher0gz.js} +2 -2
  155. package/dist/{chunk-b1mdan5a.js.map → chunk-nfher0gz.js.map} +1 -1
  156. package/dist/{chunk-e5mqjren.js → chunk-njnng5ew.js} +4 -4
  157. package/dist/{chunk-e5mqjren.js.map → chunk-njnng5ew.js.map} +1 -1
  158. package/dist/{chunk-e3ehv27z.js → chunk-p9c5rc1z.js} +3 -3
  159. package/dist/{chunk-e3ehv27z.js.map → chunk-p9c5rc1z.js.map} +1 -1
  160. package/dist/{chunk-rr8bzm6k.js → chunk-q1t9gvm1.js} +2 -2
  161. package/dist/{chunk-rr8bzm6k.js.map → chunk-q1t9gvm1.js.map} +1 -1
  162. package/dist/{chunk-xvk6aqd7.js → chunk-q751b0jx.js} +3 -3
  163. package/dist/{chunk-xvk6aqd7.js.map → chunk-q751b0jx.js.map} +1 -1
  164. package/dist/{chunk-1kehwa3s.js → chunk-qc0e278w.js} +1 -1
  165. package/dist/{chunk-re9ac4tc.js → chunk-rbkvkv2m.js} +4 -4
  166. package/dist/{chunk-re9ac4tc.js.map → chunk-rbkvkv2m.js.map} +1 -1
  167. package/dist/{chunk-k1gt7fgy.js → chunk-rjtge67x.js} +3 -3
  168. package/dist/{chunk-k1gt7fgy.js.map → chunk-rjtge67x.js.map} +1 -1
  169. package/dist/{chunk-ybcdxrqx.js → chunk-s1fa5f8b.js} +2 -2
  170. package/dist/{chunk-ybcdxrqx.js.map → chunk-s1fa5f8b.js.map} +1 -1
  171. package/dist/{chunk-8pw4zjnx.js → chunk-scw0vknj.js} +1 -1
  172. package/dist/{chunk-gc9g7c4p.js → chunk-sjve1yvv.js} +3 -3
  173. package/dist/{chunk-gc9g7c4p.js.map → chunk-sjve1yvv.js.map} +1 -1
  174. package/dist/{chunk-wn4j741t.js → chunk-te4vz0rw.js} +2 -2
  175. package/dist/{chunk-wn4j741t.js.map → chunk-te4vz0rw.js.map} +1 -1
  176. package/dist/{chunk-2ngdhbz7.js → chunk-tx5zrdmb.js} +2 -2
  177. package/dist/{chunk-2ngdhbz7.js.map → chunk-tx5zrdmb.js.map} +1 -1
  178. package/dist/{chunk-pq15dt8j.js → chunk-v1d7xya8.js} +15 -15
  179. package/dist/{chunk-pq15dt8j.js.map → chunk-v1d7xya8.js.map} +5 -5
  180. package/dist/{chunk-fq5b1k4n.js → chunk-v2fd69at.js} +2 -2
  181. package/dist/{chunk-fq5b1k4n.js.map → chunk-v2fd69at.js.map} +1 -1
  182. package/dist/{chunk-n5k42dh7.js → chunk-vebstesm.js} +3 -3
  183. package/dist/{chunk-n5k42dh7.js.map → chunk-vebstesm.js.map} +1 -1
  184. package/dist/{chunk-n3kg99yw.js → chunk-vyaedzr8.js} +3 -3
  185. package/dist/{chunk-n3kg99yw.js.map → chunk-vyaedzr8.js.map} +1 -1
  186. package/dist/{chunk-9bjggtdt.js → chunk-wdrmzjtq.js} +2 -2
  187. package/dist/{chunk-9bjggtdt.js.map → chunk-wdrmzjtq.js.map} +1 -1
  188. package/dist/{chunk-5gvc03cv.js → chunk-wfees83q.js} +3 -3
  189. package/dist/{chunk-5gvc03cv.js.map → chunk-wfees83q.js.map} +1 -1
  190. package/dist/{chunk-n26atakz.js → chunk-wpfempaj.js} +3 -3
  191. package/dist/{chunk-n26atakz.js.map → chunk-wpfempaj.js.map} +1 -1
  192. package/dist/{chunk-0pgk811s.js → chunk-wrfz0jsw.js} +2 -2
  193. package/dist/{chunk-0pgk811s.js.map → chunk-wrfz0jsw.js.map} +1 -1
  194. package/dist/{chunk-c7nbzryd.js → chunk-xgc5tj8k.js} +3 -3
  195. package/dist/{chunk-c7nbzryd.js.map → chunk-xgc5tj8k.js.map} +1 -1
  196. package/dist/{chunk-1e82gfk9.js → chunk-yj1h4rzn.js} +3 -3
  197. package/dist/{chunk-1e82gfk9.js.map → chunk-yj1h4rzn.js.map} +1 -1
  198. package/dist/{chunk-k9882kqg.js → chunk-zf1eqgzt.js} +2 -2
  199. package/dist/{chunk-k9882kqg.js.map → chunk-zf1eqgzt.js.map} +1 -1
  200. package/dist/{chunk-4ex4s616.js → chunk-znw55n6g.js} +2 -2
  201. package/dist/{chunk-4ex4s616.js.map → chunk-znw55n6g.js.map} +1 -1
  202. package/dist/{chunk-6bfj0mbp.js → chunk-zvk6dydb.js} +3 -3
  203. package/dist/{chunk-6bfj0mbp.js.map → chunk-zvk6dydb.js.map} +1 -1
  204. package/dist/config/index.js +1 -1
  205. package/dist/console/run.js +2 -2
  206. package/dist/console/run.js.map +1 -1
  207. package/dist/container/index.js +2 -2
  208. package/dist/container/index.js.map +1 -1
  209. package/dist/database/index.js +2 -2
  210. package/dist/database/index.js.map +1 -1
  211. package/dist/email/index.js +2 -2
  212. package/dist/email/index.js.map +1 -1
  213. package/dist/facades/index.js +2 -2
  214. package/dist/facades/index.js.map +1 -1
  215. package/dist/foundation/index.js +2 -2
  216. package/dist/foundation/index.js.map +1 -1
  217. package/dist/http/index.js +2 -2
  218. package/dist/http/index.js.map +1 -1
  219. package/dist/i18n/dictionaryRuntime.js +2 -2
  220. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  221. package/dist/i18n/index.js +2 -2
  222. package/dist/i18n/index.js.map +1 -1
  223. package/dist/kernel/index.js +2 -2
  224. package/dist/kernel/index.js.map +1 -1
  225. package/dist/orm/index.js +2 -2
  226. package/dist/orm/index.js.map +1 -1
  227. package/dist/probe/index.js +2 -2
  228. package/dist/probe/index.js.map +1 -1
  229. package/dist/server/index.js +2 -2
  230. package/dist/server/index.js.map +1 -1
  231. package/dist/services/index.js +2 -2
  232. package/dist/services/index.js.map +1 -1
  233. package/dist/services/queue/work.js +2 -2
  234. package/dist/services/queue/work.js.map +1 -1
  235. package/dist/stats/route-table.js +1 -1
  236. package/dist/support/index.js +2 -2
  237. package/dist/support/index.js.map +1 -1
  238. package/dist/vitest/index.js +2 -2
  239. package/dist/vitest/index.js.map +1 -1
  240. package/package.json +1 -1
  241. package/dist/chunk-1x60thpm.js +0 -8
  242. package/dist/chunk-1x60thpm.js.map +0 -19
  243. package/dist/chunk-cf7xc02m.js +0 -5
  244. package/dist/chunk-xwqdh388.js +0 -5
  245. /package/dist/{chunk-yykrvrpt.js.map → chunk-39dz1abf.js.map} +0 -0
  246. /package/dist/{chunk-yrbvfda9.js.map → chunk-8ncqxja2.js.map} +0 -0
  247. /package/dist/{chunk-1kehwa3s.js.map → chunk-qc0e278w.js.map} +0 -0
  248. /package/dist/{chunk-8pw4zjnx.js.map → chunk-scw0vknj.js.map} +0 -0
@@ -0,0 +1,142 @@
1
+ import type { ProviderCapabilities, ProviderStreamParams, ProviderToolNamespace, ProviderToolSpec } from "../AgentProvider";
2
+ import type { JSONSchema } from "../Schema";
3
+ import type { AgentMessage } from "../types";
4
+ /**
5
+ * `ProviderStreamParams` to a Messages API body (`POST /v1/messages`), as a
6
+ * pure function, for the reason `request.ts` gives: everything that can be
7
+ * wrong here is wrong without a socket.
8
+ *
9
+ * The shapes follow Anthropic's API reference. What differs from the
10
+ * Responses builder, and why:
11
+ *
12
+ * - Roles alternate and a tool result is a `user` block. gemi keeps a step's
13
+ * calls and their results on one assistant message; here the calls stay in
14
+ * the assistant turn and the results open the user turn right after it.
15
+ * - `max_tokens` is required, so a call without `maxOutputTokens` sends
16
+ * `DEFAULT_MAX_TOKENS`.
17
+ * - `temperature` is never sent. On API version `2026-10-21` (see
18
+ * `ANTHROPIC_VERSION`) it is a 400 on every model, whatever its value.
19
+ * - `promptCacheKey` has no Anthropic counterpart: the cache keys on the
20
+ * prefix itself, so it is not sent. Caching is asked for with `cache_control`
21
+ * breakpoints instead; see `withCacheBreakpoints`.
22
+ */
23
+ export type MessagesBlock = Record<string, unknown>;
24
+ export type MessagesMessage = {
25
+ role: "user" | "assistant";
26
+ content: MessagesBlock[];
27
+ };
28
+ export type MessagesTool = Record<string, unknown>;
29
+ export type MessagesRequest = {
30
+ model: string;
31
+ max_tokens: number;
32
+ messages: MessagesMessage[];
33
+ stream: true;
34
+ system?: MessagesBlock[];
35
+ tools?: MessagesTool[];
36
+ tool_choice?: {
37
+ type: "auto" | "any" | "none" | "tool";
38
+ name?: string;
39
+ disable_parallel_tool_use?: boolean;
40
+ };
41
+ thinking?: {
42
+ type: "adaptive";
43
+ display?: "summarized";
44
+ block_binding?: {
45
+ prefix_mismatch_behavior: "drop_block";
46
+ };
47
+ } | {
48
+ type: "between_tools";
49
+ };
50
+ output_config?: {
51
+ effort?: string;
52
+ format?: {
53
+ type: "json_schema";
54
+ schema: JSONSchema;
55
+ };
56
+ };
57
+ };
58
+ /**
59
+ * Sent when the agent sets no `maxOutputTokens`. Every current Claude model
60
+ * takes 64K or more (128K on the 4.6-and-later families, 64K on Haiku 4.5), and
61
+ * the request is streamed, so a high cap costs nothing until it is used; a low
62
+ * one cuts an answer off mid-thought.
63
+ */
64
+ export declare const DEFAULT_MAX_TOKENS = 64000;
65
+ export declare function buildMessagesRequest(params: ProviderStreamParams, ctx: {
66
+ /** What the request names: the model id, or a Foundry deployment. */
67
+ model: string;
68
+ /** The model id, which the per-model rules below read. */
69
+ modelId: string;
70
+ capabilities: ProviderCapabilities;
71
+ forcedToolChoice: boolean;
72
+ /** Whether `thinking.block_binding` can be sent (it needs a beta header
73
+ * that Anthropic's API takes and Foundry is not known to). */
74
+ blockBinding: boolean;
75
+ }): MessagesRequest;
76
+ /** The beta header `thinking.block_binding` needs. */
77
+ export declare const THINKING_BINDING_BETA = "thinking-binding-controls-2026-08-01";
78
+ /**
79
+ * The request edits that answer a 400 once, with what to change.
80
+ *
81
+ * - `thinking`: a thinking block was bound to a different conversation (see
82
+ * PRESERVED THINKING above) and the binding was not sent. The blocks are
83
+ * stripped and the request asked again, which keeps the text and tool calls
84
+ * and loses only the reasoning, as `drop_block` would.
85
+ * - `schema`: `Schema is too complex for compilation.` The answer is asked for
86
+ * in the system prompt instead, as for a loose schema.
87
+ */
88
+ export declare function recoverableRequestError(message: string): "thinking" | "schema" | undefined;
89
+ /** The request without any thinking block, for the `thinking` retry. */
90
+ export declare function withoutThinkingBlocks(body: MessagesRequest): MessagesRequest;
91
+ /**
92
+ * The agent's schema as structured outputs takes it, transformed the way
93
+ * Anthropic's SDKs transform one: a constraint the API refuses (the keywords
94
+ * above, a `minItems` over 1, a string `format` outside the supported list, a
95
+ * `pattern` with backreferences, lookaround or `\b`) is removed and written
96
+ * into the node's `description` instead (`{minimum: 100}`), so the model still
97
+ * reads it; and every object gets `additionalProperties: false`, which the API
98
+ * requires. Nothing is lost: `Agent` validates the answer against the agent's
99
+ * own schema, constraints included.
100
+ */
101
+ export declare function toClaudeSchema(schema: JSONSchema): JSONSchema;
102
+ /**
103
+ * `AgentMessage[]` to alternating `user` / `assistant` messages.
104
+ *
105
+ * Parts are laid out in order, each with the role it has on this API: the
106
+ * assistant's text and tool calls are `assistant`, a tool result is `user`, and
107
+ * the user's own words and files are `user`. Consecutive blocks of one role
108
+ * are one message, which is what the API wants and what a step that called
109
+ * three tools needs: three `tool_use` blocks in one turn, three `tool_result`
110
+ * blocks in the next.
111
+ *
112
+ * Tool results are not placed where they sit in gemi's message but right after
113
+ * the turn that made their calls, first in the user turn, in call order: the
114
+ * API requires every `tool_use` to be answered in the very next message, with
115
+ * the results before anything else in it. A step's calls are answered where
116
+ * the step is known to be over: at the next message, or, when gemi kept the
117
+ * next step on the same message, at the first block after a tool result. The
118
+ * pairing rules are those of
119
+ * `reconcileToolPairs` in `request.ts`, and for the same reasons: a repeated
120
+ * call or result is dropped, a result for a call this history does not hold is
121
+ * dropped, and a call left without a result gets one saying so.
122
+ */
123
+ export declare function toMessages(messages: AgentMessage[], capabilities: ProviderCapabilities): MessagesMessage[];
124
+ /**
125
+ * Tools onto the `tools` array, flat: this provider reports no tool search
126
+ * (`capabilitiesForClaude`), so a namespace is flattened and a deferred tool
127
+ * is sent whole, exactly as `toResponsesTools` does for a model without it.
128
+ *
129
+ * `strict` is not sent. Anthropic's strict tool use allows at most 20 strict
130
+ * tools and 24 optional parameters across them per request, and refuses
131
+ * numeric and length constraints, so passing gemi's flag through would turn an
132
+ * agent with many tools into a 400. `Agent` validates every call's arguments
133
+ * against the tool's schema either way.
134
+ *
135
+ * `eager_input_streaming` is on for every tool: the request is always
136
+ * streamed, and without it the API buffers each argument until it is whole, so
137
+ * a tool that writes a file sends nothing for as long as the model writes it.
138
+ * It also gives up the API's own validation of the arguments, which `Agent`
139
+ * does anyway.
140
+ */
141
+ export declare function toMessagesTools(tools: (ProviderToolSpec | ProviderToolNamespace)[] | undefined): MessagesTool[];
142
+ //# sourceMappingURL=anthropicRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropicRequest.d.ts","sourceRoot":"","sources":["../../../ai/providers/anthropicRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,UAAU,CAAC;AAUtE;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpD,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAAC,OAAO,EAAE,aAAa,EAAE,CAAA;CAAE,CAAC;AACvF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,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AM,EAAE,UAAU,GAAG,UAAU,CA8B7D;AAkED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,YAAY,EAAE,EACxB,YAAY,EAAE,oBAAoB,GACjC,eAAe,EAAE,CAsHnB;AAmED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,CAAC,gBAAgB,GAAG,qBAAqB,CAAC,EAAE,GAAG,SAAS,GAC9D,YAAY,EAAE,CAahB"}
@@ -0,0 +1,54 @@
1
+ import type { ProviderEvent } from "../AgentProvider";
2
+ import type { AgentError, Usage } from "../types";
3
+ /**
4
+ * The Messages API SSE stream to `ProviderEvent`, a pure function over chunks
5
+ * like `parseResponsesStream`, driven in the tests by the hand-written
6
+ * fixtures in `__fixtures__/anthropic-*.sse`.
7
+ *
8
+ * The event flow, from Anthropic's streaming reference: `message_start` (the
9
+ * model and the input usage), then per content block `content_block_start`,
10
+ * its `content_block_delta`s and `content_block_stop`, then `message_delta`
11
+ * (the stop reason, and usage that is CUMULATIVE, not an increment) and
12
+ * `message_stop`. `ping` frames come at any time, an `error` frame can replace
13
+ * the rest, and unknown event types are to be ignored.
14
+ *
15
+ * Thinking is `reasoning-delta`s with no id. A `thinking` block's text streams
16
+ * as it comes, and at its stop one more, empty delta carries the signature as
17
+ * `providerMetadata.anthropic`, which closes the part. A `redacted_thinking`
18
+ * block is one empty delta carrying its `data`. `anthropicRequest.ts` turns
19
+ * those parts back into the blocks, unchanged, as the API requires.
20
+ */
21
+ type ParseOptions = {
22
+ /** The agent asked for an `output` schema, so text is the answer's JSON. */
23
+ structuredOutput?: boolean;
24
+ };
25
+ export declare function parseMessagesStream(chunks: AsyncIterable<string> | Iterable<string>, options?: ParseOptions): AsyncGenerator<ProviderEvent>;
26
+ /**
27
+ * An `error` frame, which arrives on a 200: the request was accepted and the
28
+ * failure came later, so it is retryable unless its type says the request
29
+ * itself is wrong. `overloaded_error` is the one seen most, the 529 of a
30
+ * streamed call.
31
+ */
32
+ export declare function anthropicStreamError(raw: any): AgentError;
33
+ type RawUsage = {
34
+ input_tokens?: number;
35
+ output_tokens?: number;
36
+ cache_creation_input_tokens?: number;
37
+ cache_read_input_tokens?: number;
38
+ /** From `output_tokens_details.thinking_tokens`, part of `output_tokens`. */
39
+ thinking_tokens?: number;
40
+ };
41
+ /**
42
+ * Anthropic usage onto `Usage`.
43
+ *
44
+ * Anthropic reports input in three disjoint parts: `input_tokens` (after the
45
+ * last cache breakpoint), `cache_read_input_tokens` and
46
+ * `cache_creation_input_tokens`. gemi's `inputTokens` is the whole prompt, as
47
+ * OpenAI reports it, so it is their sum, and the two cache parts are its
48
+ * breakdown (`cachedInputTokens`, `cacheWriteInputTokens`). Thinking tokens are part
49
+ * of `output_tokens` and are its `reasoningTokens` breakdown. A field the
50
+ * response did not carry stays absent rather than zero.
51
+ */
52
+ export declare function toAnthropicUsage(raw: RawUsage | undefined): Usage;
53
+ export {};
54
+ //# sourceMappingURL=anthropicStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropicStream.d.ts","sourceRoot":"","sources":["../../../ai/providers/anthropicStream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAgB,KAAK,EAAE,MAAM,UAAU,CAAC;AAGhE;;;;;;;;;;;;;;;;;GAiBG;AAEH,KAAK,YAAY,GAAG;IAClB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAIF,wBAAuB,mBAAmB,CACxC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,EAChD,OAAO,GAAE,YAAiB,GACzB,cAAc,CAAC,aAAa,CAAC,CAyK/B;AAyCD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAqBzD;AAED,KAAK,QAAQ,GAAG;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAmBF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,GAAG,KAAK,CAWjE"}
@@ -89,12 +89,21 @@ export declare function responsesEndpoint(target: ProviderTarget): ResponsesEndp
89
89
  * break counts, not only the limits above. Once retries are spent, the partial
90
90
  * calls stay and the call ends with the error, as before.
91
91
  */
92
- export declare function streamResponses(endpoint: ResponsesEndpoint, body: ResponsesRequest, params: {
92
+ export declare function streamResponses<Body extends object = ResponsesRequest>(endpoint: ResponsesEndpoint, body: Body, params: {
93
93
  signal?: AbortSignal;
94
94
  structuredOutput: boolean;
95
95
  /** The file ids `body` sends, with their names — for the note that
96
- * replaces a file the provider refuses. See `providers/fileRejection.ts`. */
96
+ * replaces a file the provider refuses. See `providers/fileRejection.ts`.
97
+ * Responses bodies only: without it a refused file fails the call. */
97
98
  files?: Map<string, SentFile>;
99
+ /**
100
+ * The SSE parser. Defaults to the Responses one; the Anthropic provider
101
+ * passes `parseMessagesStream`, and everything else here (retries, the
102
+ * stream limits, holding back until the first content event) is shared.
103
+ */
104
+ parse?: (chunks: AsyncIterable<string>, options: {
105
+ structuredOutput: boolean;
106
+ }) => AsyncIterable<ProviderEvent>;
98
107
  }): AsyncGenerator<ProviderEvent>;
99
108
  /**
100
109
  * What a file is uploaded *for*, which decides where its id is accepted.
@@ -121,5 +130,7 @@ export type UploadPurpose = "user_data" | "assistants";
121
130
  * The purpose is the caller's because it is a property of the provider, not of
122
131
  * the file — see `UploadPurpose`.
123
132
  */
124
- export declare function uploadFile(endpoint: ResponsesEndpoint, file: File, purpose?: UploadPurpose): Promise<string>;
133
+ export declare function uploadFile(endpoint: ResponsesEndpoint, file: File,
134
+ /** `null` for Anthropic's Files API, which takes no purpose. */
135
+ purpose?: UploadPurpose | null): Promise<string>;
125
136
  //# sourceMappingURL=call.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../../ai/providers/call.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASlD,OAAO,EAIL,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGlD;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB;2DACuD;IACvD,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;wDACoD;IACpD,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC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;AACV,gEAAgE;AAChE,OAAO,GAAE,aAAa,GAAG,IAAkB,GAC1C,OAAO,CAAC,MAAM,CAAC,CAyBjB"}
@@ -47,6 +47,37 @@ import type { ProviderCapabilities } from "../AgentProvider";
47
47
  * alone.
48
48
  */
49
49
  export declare function capabilitiesForModel(model: string): ProviderCapabilities;
50
+ /**
51
+ * What a Claude model can do, read off its id, with the same bias as
52
+ * `capabilitiesForModel`: an id this does not know gets every capability that
53
+ * is safe to guess.
54
+ *
55
+ * - `reasoning`: adaptive thinking (`thinking: {type: "adaptive"}` with
56
+ * `output_config.effort`), which the 4.6 models and everything after take.
57
+ * The 4.5 generation and older only take a token budget and answer adaptive
58
+ * thinking with a 400, so `reasoning` is dropped for them.
59
+ * - `fileInput`: images (JPEG, PNG, GIF, WebP), PDFs and plain text, uploaded
60
+ * through the Files API. Other types are not shown; see `fileBlocks`.
61
+ * - `toolSearch`: false for now. Anthropic has a tool search tool, but
62
+ * replaying its results in a history is not built yet, so deferred tools and
63
+ * namespaces are sent flat and whole, which runs the agent the same.
64
+ *
65
+ * Forced tool choice is not a capability an agent can branch on; it decides
66
+ * how the request is built. See `supportsForcedToolChoice`.
67
+ */
68
+ export declare function capabilitiesForClaude(model: string): ProviderCapabilities;
69
+ /**
70
+ * Whether a Claude model takes `tool_choice` `any` and `tool`.
71
+ *
72
+ * Claude Opus 5.5, Claude Sonnet 5.5, Claude Fable 5.1 (and the Mythos and
73
+ * 5.2 releases beside them) answer both with a 400, and every release since
74
+ * Claude Opus 5 that did not keep them has dropped them. So this is a list of
75
+ * the families known to take them, not of those known to refuse, and an id it
76
+ * does not know is sent `auto`: a step that should have called a tool and
77
+ * wrote text instead is a worse step, while a 400 is a failed one on every
78
+ * forced step.
79
+ */
80
+ export declare function supportsForcedToolChoice(model: string): boolean;
50
81
  export type Family = {
51
82
  kind: "gpt" | "o";
52
83
  major: number;
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../ai/providers/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAgDxE;AA4CD,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAcrD"}
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../ai/providers/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAgDxE;AAkCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAazE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQ/D;AAYD,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAcrD"}
@@ -219,6 +219,46 @@ export declare function openAITarget(config: ProviderConfig, defaults?: TargetDe
219
219
  */
220
220
  export declare function azureResourceBase(config: AzureConfig): string;
221
221
  export declare function azureTarget(config: AzureConfig, defaults?: TargetDefaults): ProviderTarget;
222
+ /**
223
+ * The Messages API version sent as `anthropic-version`. `2026-10-21` is the
224
+ * version the current SDKs send: on it `temperature`, `top_p` and `top_k` are a
225
+ * 400 on every model, which is why `buildMessagesRequest` never sends them.
226
+ */
227
+ export declare const ANTHROPIC_VERSION = "2026-10-21";
228
+ /**
229
+ * Anthropic's API, `https://api.anthropic.com` unless `baseURL` (or
230
+ * `ANTHROPIC_BASE_URL`) names a gateway in front of it. The base is the host,
231
+ * as the SDKs take it; a trailing `/v1` is accepted too and not doubled.
232
+ *
233
+ * Authenticates with `x-api-key` (`apiKey`, else `ANTHROPIC_API_KEY`), or
234
+ * with `ANTHROPIC_AUTH_TOKEN` as a bearer when there is no key (the SDKs'
235
+ * order), read per request like the others.
236
+ */
237
+ export declare function anthropicTarget(config: ProviderConfig, defaults?: TargetDefaults): ProviderTarget;
238
+ /** `AzureAnthropicProvider`'s config: the Azure OpenAI fields that apply. */
239
+ export type FoundryConfig = ProviderConfig & {
240
+ /**
241
+ * The resource's Anthropic base, `https://<resource>.services.ai.azure.com/anthropic`
242
+ * (the deployment's Target URI without `/v1/messages`). `baseURL` works too.
243
+ */
244
+ endpoint?: string;
245
+ /** Just the resource name; expanded to the base above. */
246
+ resourceName?: string;
247
+ /** The deployment to call, when it is not named after the model. */
248
+ deployment?: string;
249
+ /** For Entra ID instead of a key, called per request (tokens expire). */
250
+ getToken?: () => Promise<string>;
251
+ };
252
+ /**
253
+ * Claude on Azure AI Foundry: the same Messages API under the resource's
254
+ * `/anthropic` path. The settings and their environment variables are the
255
+ * ones Anthropic's Foundry SDK clients read: `endpoint`/`baseURL` or
256
+ * `ANTHROPIC_FOUNDRY_BASE_URL`, else `resourceName` or
257
+ * `ANTHROPIC_FOUNDRY_RESOURCE`; the key in `api-key` (`apiKey`, else
258
+ * `ANTHROPIC_FOUNDRY_API_KEY`), or an Entra token from `getToken` as a bearer
259
+ * (scope `https://ai.azure.com/.default`).
260
+ */
261
+ export declare function foundryTarget(config: FoundryConfig, defaults?: TargetDefaults): ProviderTarget;
222
262
  /**
223
263
  * Azure's realtime surface, which is the GA `/openai/v1` one regardless of the
224
264
  * configured api-version.
@@ -1 +1 @@
1
- {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../../ai/providers/endpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG;IACzC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,OAAO,EAAE,MAAM,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MAAM,CAG5E;AA6CD;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,KAAK,GAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAgB,GACxE,OAAO,CAAC,IAAI,CAAC,CAef;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,QAAQ,CAAC,CAyGnB;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,EACvC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACzC,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,KAAK,CAAA;CAAE,GAC1C,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAyCnC"}
@@ -1,5 +1,5 @@
1
1
  import type { ProviderCapabilities, ProviderStreamParams, ProviderToolNamespace, ProviderToolSpec } from "../AgentProvider";
2
- import type { AgentMessage, ToolResultPart } from "../types";
2
+ import type { AgentMessage, FilePart, ToolResultPart } from "../types";
3
3
  /**
4
4
  * Building the request body is a pure function, on purpose.
5
5
  *
@@ -47,6 +47,48 @@ export declare function buildResponsesRequest(params: ProviderStreamParams, ctx:
47
47
  * and all the calls after.
48
48
  */
49
49
  export declare function toResponsesInput(messages: AgentMessage[], capabilities: ProviderCapabilities, tools?: (ProviderToolSpec | ProviderToolNamespace)[]): ResponsesInputItem[];
50
+ /**
51
+ * `FilePart.attachmentId`, if it is one.
52
+ *
53
+ * In stateless mode the history arrives from the browser and only the turn
54
+ * itself is checked at the door (`toClientTurn`), so a part posted back as
55
+ * history can hold anything here. A value that is not a gemi id is treated as
56
+ * absent rather than refused: it names nothing a tool could resolve, and
57
+ * refusing it would fail every later turn of a conversation over a field the
58
+ * model could not have used.
59
+ */
60
+ export declare function attachmentIdOf(part: FilePart): string | undefined;
61
+ /**
62
+ * The line that tells the model an attachment's id, sent just before the file
63
+ * block it labels (or alone, when there is no file block to send).
64
+ *
65
+ * WHY A LINE AT ALL. A model that has seen a user's image has no id to put in
66
+ * a tool's arguments unless it is told one. Whatever it writes there instead
67
+ * is answered by `ctx.attachments.file()` with `AttachmentNotFoundError` —
68
+ * correctly, for an id that was never obtainable. For a storage-only upload
69
+ * this line is all the model gets: without it, it does not know a file exists.
70
+ *
71
+ * WHY THIS FORMAT. `[attachment id="…" name="…" mimeType="…"]`, each value
72
+ * JSON-quoted. The filename is the user's and can hold spaces, quotes, `]` or
73
+ * a newline; JSON quoting means none of them can end a field, end the bracket,
74
+ * or start a second line that reads as another attachment, so the id a model
75
+ * copies out is exactly the id. The unquoted form (`[attachment gemi_att_… my
76
+ * photo.png image/png]`) looks tidier and is ambiguous as soon as a name has a
77
+ * space. A key with no value is left out rather than written as `name=""`.
78
+ *
79
+ * WHY IT SAYS WHEN THE FILE IS NOT SHOWN. A storage-only upload, or any file
80
+ * sent to a model without `fileInput`, has no block beside the line. Left
81
+ * unsaid, a line that names `photo.png` invites the model to describe a
82
+ * picture it never saw.
83
+ */
84
+ export declare function attachmentLine(part: FilePart, shown: boolean): string;
85
+ /** Whether a file part goes to the image block. See `fileContent`. */
86
+ export declare function isImageFile(part: FilePart): boolean;
87
+ /**
88
+ * The two file parts no request can carry: a gemi attachment id in `fileId`,
89
+ * and a part with neither id. See the `file` case in `toResponsesInput`.
90
+ */
91
+ export declare function assertFilePart(part: FilePart, attachmentId: string | undefined): void;
50
92
  /**
51
93
  * Every tool call gets an output, including the ones that never ran.
52
94
  *
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","s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7D;AAuFD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,CAAC,gBAAgB,GAAG,qBAAqB,CAAC,EAAE,GAAG,SAAS,EAC/D,YAAY,EAAE,oBAAoB,GACjC,aAAa,EAAE,CA2CjB"}
@@ -119,6 +119,10 @@ export declare function appendText(message: AgentMessage, type: "text" | "reason
119
119
  * UI renders, and a provider that reports no item id (Azure does not always)
120
120
  * should still show its thinking. It just cannot be echoed back, which is the
121
121
  * bargain `reasoningItem` already documents.
122
+ *
123
+ * `providerMetadata` (#477) arrives on a part's last delta and closes it: a
124
+ * part that has it is not joined again, so two thinking blocks with no id
125
+ * (Anthropic's have none) stay two parts, each with its own signature.
122
126
  */
123
- export declare function appendReasoning(message: AgentMessage, id: string | undefined, delta: string): void;
127
+ export declare function appendReasoning(message: AgentMessage, id: string | undefined, delta: string, providerMetadata?: Record<string, unknown>): void;
124
128
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../ai/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;;GAUG;AAIH,qBAAa,UAAW,SAAQ,KAAK;;CAKpC;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CASjF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAY5D;AAID,wBAAgB,UAAU,IAAI,KAAK,CAElC;AAED,wBAAgB,QAAQ,CAAC,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,EACtB,KAAK,EAAE,MAAM,EACb,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAc3C"}
@@ -136,8 +136,10 @@ export declare class RecordingMismatchError extends Error {
136
136
  * the two differ.
137
137
  *
138
138
  * UPLOADS are answered `upload_<n>`, by order, so a file need not be the same
139
- * bytes on another machine for its call to replay. Recording, the file goes to
140
- * the live provider, and the calls show the model the provider's id.
139
+ * bytes on another machine for its call to replay. A sub-run counts its own,
140
+ * `upload_<key>_<n>`, so the ids stay the same however sub-runs interleave.
141
+ * Recording, the file goes to the live provider, and the calls show the model
142
+ * the provider's id.
141
143
  *
142
144
  * TIME. `recordedAt` is when the recording started. `pinClock(recordedAt)`
143
145
  * runs a replay at that time, so dates relative to today come out as recorded.
@@ -158,6 +160,7 @@ export declare class RecordingProvider extends AgentProvider {
158
160
  private sent;
159
161
  /** Recording: the live provider's file id of each upload, by the id answered here. */
160
162
  private readonly uploads;
163
+ /** Uploads answered so far, counted per run and per sub-run. */
161
164
  private uploadCount;
162
165
  /** Recording: the position the next call's prompt was pinned to. */
163
166
  private read?;
@@ -1 +1 @@
1
- {"version":3,"file":"RecordingProvider.d.ts","sourceRoot":"","sources":["../../../ai/testing/RecordingProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAE1B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,kBAAkB,EAAE,YAAY,EAAE,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEnG;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,eAAe,CAAC;IACzB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,2FAA2F;IAC3F,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,KAAK,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AC,aAAa,CAAC;YAW3D,UAAU;YA2DV,UAAU;IAkCzB,OAAO,CAAC,KAAK;IAIb,yEAAyE;IACzE,OAAO,CAAC,SAAS,CAAK;IAEtB;;;OAGG;IACH,OAAO,CAAC,SAAS;IAiDjB;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAiBf;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAwIhB,wFAAwF;YAC1E,IAAI;IAuBlB,kEAAkE;YACpD,KAAK;CAiBpB"}
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{la as g}from"../../chunk-1x60thpm.js";import"../../chunk-xwqdh388.js";import{Sj as v,Tj as m}from"../../chunk-6g1xac70.js";import"../../chunk-k9882kqg.js";import{createHash as s}from"crypto";import{createHash as S}from"crypto";import{existsSync as h,readdirSync as l,readFileSync as c,statSync as d}from"fs";import{join as q,relative as p,sep as i}from"path";var P="\u241F",F=6,n=/\{\{>\s*([^}\s]+)\s*\}\}/g,b=(D)=>D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function R(D){let $=D.filter((B)=>B.length>=F),z=D.filter((B)=>B.length<F);return(B)=>{let C=B;for(let G of $)if(C.includes(G))C=C.split(G).join(P);for(let G of z)C=C.replace(new RegExp(`${b(G)}\\s*${P}`,"g"),P).replace(new RegExp(`${P}\\s*${b(G)}`,"g"),P);return C.replace(new RegExp(`\\s*${P}[\\s${P}]*`,"g"),P)}}function y(D,$=[]){for(let z of l(D)){if(z==="node_modules")continue;let B=q(D,z);if(d(B).isDirectory())y(B,$);else if(z.endsWith(".md"))$.push(B)}return $}class L{data;root;options;constructor(D,$={}){this.data=D;this.options=$,this.root=$.root??process.cwd()}static blob(D){return S("sha1").update(`blob ${Buffer.byteLength(D)}\x00`).update(D).digest("hex")}static pieces(D){return D.split(/\{\{[^}]*\}\}/).map(($)=>$.trim()).filter(($)=>$.length>0)}static tool(D){return S("sha256").update(JSON.stringify({description:D.description,parameters:D.parameters})).digest("hex")}static prompts(D={}){let $=D.root??process.cwd(),z=new Map;for(let B of D.dirs??["app/agents"]){if(!h(q($,B)))continue;for(let C of y(q($,B)).sort())z.set(p($,C).split(i).join("/"),c(C,"utf8"))}return z}static of(D,$,z={}){let B=[...D].join(`
2
+ import{la as g}from"../../chunk-at49en07.js";import"../../chunk-e0scxs81.js";import{Uj as v,Vj as m}from"../../chunk-8ar7180x.js";import"../../chunk-zf1eqgzt.js";import{createHash as s}from"crypto";import{createHash as S}from"crypto";import{existsSync as h,readdirSync as l,readFileSync as c,statSync as d}from"fs";import{join as q,relative as p,sep as i}from"path";var P="\u241F",F=6,n=/\{\{>\s*([^}\s]+)\s*\}\}/g,b=(D)=>D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function R(D){let $=D.filter((B)=>B.length>=F),z=D.filter((B)=>B.length<F);return(B)=>{let C=B;for(let G of $)if(C.includes(G))C=C.split(G).join(P);for(let G of z)C=C.replace(new RegExp(`${b(G)}\\s*${P}`,"g"),P).replace(new RegExp(`${P}\\s*${b(G)}`,"g"),P);return C.replace(new RegExp(`\\s*${P}[\\s${P}]*`,"g"),P)}}function y(D,$=[]){for(let z of l(D)){if(z==="node_modules")continue;let B=q(D,z);if(d(B).isDirectory())y(B,$);else if(z.endsWith(".md"))$.push(B)}return $}class L{data;root;options;constructor(D,$={}){this.data=D;this.options=$,this.root=$.root??process.cwd()}static blob(D){return S("sha1").update(`blob ${Buffer.byteLength(D)}\x00`).update(D).digest("hex")}static pieces(D){return D.split(/\{\{[^}]*\}\}/).map(($)=>$.trim()).filter(($)=>$.length>0)}static tool(D){return S("sha256").update(JSON.stringify({description:D.description,parameters:D.parameters})).digest("hex")}static prompts(D={}){let $=D.root??process.cwd(),z=new Map;for(let B of D.dirs??["app/agents"]){if(!h(q($,B)))continue;for(let C of y(q($,B)).sort())z.set(p($,C).split(i).join("/"),c(C,"utf8"))}return z}static of(D,$,z={}){let B=[...D].join(`
3
3
  \x00
4
- `),C={};for(let[Y,Q]of L.prompts(z))if(L.pieces(Q).filter((Z)=>Z.length>=12).sort((Z,K)=>K.length-Z.length).slice(0,3).some((Z)=>B.includes(Z)))C[Y]=L.blob(Q);let G=[...$.keys()].sort(),X=z.inputs?.(new Set(G));return new L({prompts:C,tools:Object.fromEntries(G.map((Y)=>[Y,[...$.get(Y)].sort()])),...X&&Object.keys(X).length>0?{inputs:a(X)}:{}},z)}same(D){let $=D instanceof L?D.data:D;return JSON.stringify(this.data)===JSON.stringify($)}changed(){let D=this.options.inputs?.(new Set(Object.keys(this.data.tools)))??{};return[...this.changedPrompts().map(([$])=>$),...Object.entries(this.data.inputs??{}).filter(([$,z])=>D[$]!==z).map(([$])=>`input ${$}`)]}cutters(){let D=L.prompts(this.options),$=this.changedPrompts(),z=new Map,B=new Map;for(let[C,G]of $){let X=this.readBlob(G);if(X===void 0)throw Error(`${C} changed since the recording, and the version it was recorded with (${G}) can't be read back from git`);if(z.set(C,X),D.has(C))B.set(C,D.get(C))}return{changed:$.map(([C])=>C),recorded:R(this.piecesWithPartials(z,(C)=>{let G=this.data.prompts[C];return G&&this.readBlob(G)||D.get(C)})),sent:R(this.piecesWithPartials(B,(C)=>D.get(C)))}}changedPrompts(){let D=L.prompts(this.options);return Object.entries(this.data.prompts).filter(([$,z])=>{let B=D.get($);return B===void 0||L.blob(B)!==z})}readBlob(D){if(this.options.readBlob)return this.options.readBlob(D);let $=Bun.spawnSync(["git","cat-file","blob",D],{cwd:this.root});return $.exitCode===0?$.stdout.toString():void 0}piecesWithPartials(D,$){let z=this.options.dirs??["app/agents"],B=this.options.shared??"prompts",C=[...D];while(C.length>0){let[G,X]=C.pop(),Y=z.find((Q)=>G.startsWith(`${Q}/`));if(Y===void 0)continue;for(let[,Q]of X.matchAll(n)){let V=`${Y}/${Q.includes("/")?Q:`${B}/${Q}`}.md`,Z=D.has(V)?void 0:$(V);if(Z===void 0)continue;D.set(V,Z),C.push([V,Z])}}return[...D.values()].flatMap((G)=>L.pieces(G)).sort((G,X)=>X.length-G.length)}}function a(D){return Object.fromEntries(Object.entries(D).sort(([$],[z])=>$.localeCompare(z)))}class N extends Error{constructor(D){super(`${D} Record again.`);this.name="RecordingMismatchError"}}var o=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g;function T(D,$){if(typeof D==="string")return $(D);if(Array.isArray(D))return D.map((z)=>T(z,$));if(D&&typeof D==="object")return Object.fromEntries(Object.entries(D).map(([z,B])=>[z,T(B,$)]));return D}function f(D){return JSON.parse(JSON.stringify(D,function($,z){if($==="nested")return;if($==="output"&&this.type==="tool-result"&&"modelOutput"in this)return;return z}))}function u(){let D;return{promise:new Promise((z)=>D=z),resolve:D}}var r=(D)=>s("sha256").update(D).digest("hex"),E=(D)=>D.flatMap(($)=>("tools"in $)?$.tools:[$]);function x(D){return D.map(({role:$,content:z})=>({role:$,parts:(Array.isArray(z)?z:[]).flatMap((B)=>{if(B?.type==="tool-call")return[{call:B.name,input:B.input??B.args}];if(B?.type==="tool-result")return[{result:B.name,status:B.status}];if(B?.type==="file")return[{file:!0}];return[]})}))}class M extends g{live;model;capabilities;recordedAt;calls;recordedNested;children=new Map;parent;key;sent=[];uploads;uploadCount=0;read;shared;options;texts=new Set;toolHashes=new Map;toolLists=new Set;recorded;cuts;constructor(D,$,z,B){super();this.live=D;if(this.options={...z,match:z.match??"wording",ids:new RegExp(z.ids??o,"g"),waitMs:z.waitMs??60000},B){let{parent:C}=B;this.parent=C,this.key=B.key,this.model=C.model,this.capabilities=C.capabilities,this.recordedAt=C.recordedAt,this.calls=B.calls,this.recordedNested={},this.uploads=C.uploads,this.shared=C.shared;return}if(this.shared={ids:new Map,stale:new Set,staleCalls:0,started:0,moved:u()},this.uploads=new Map,D){this.model=D.model,this.capabilities=D.capabilities,this.recordedAt=new Date,this.calls=[],this.recordedNested={};return}if(!$||$.version!==1||!Array.isArray($.calls))throw Error("RecordingProvider.replay needs a recording made by RecordingProvider.");if(this.model=$.model,this.capabilities=$.capabilities,this.recordedAt=new Date($.recordedAt),this.calls=structuredClone($.calls),this.recordedNested=structuredClone($.nested??{}),$.fingerprints)this.recorded=new L($.fingerprints,z.fingerprints)}static record(D,$={}){return new M(D,void 0,$)}static replay(D,$={}){return new M(void 0,D,$)}get isRecording(){return this.live!==void 0}get stale(){return this.shared.stale}get staleCalls(){return this.shared.staleCalls}nested(D){if(this.parent)return this.parent.nested(D);let $=this.children.get(D);if(!$){let z=this.recordedNested[D];if(!this.live&&!z)throw new N(`The recording has no sub-run "${D}".`);$=new M(this.live,void 0,this.options,{parent:this,key:D,calls:z??[]}),this.children.set(D,$)}return $}recording(){if(this.parent)return this.parent.recording();if(!this.live)throw Error("Only a recording provider (`record`) has a recording to save.");return{version:1,model:this.model,capabilities:this.capabilities,recordedAt:this.recordedAt.toISOString(),calls:structuredClone(this.calls),...this.options.fingerprints?{fingerprints:this.fingerprints().data}:{},...this.children.size>0?{nested:Object.fromEntries([...this.children].map(([D,$])=>[D,structuredClone($.calls)]))}:{}}}fingerprints(){let D=this.parent??this;return L.of(D.texts,D.toolHashes,this.options.fingerprints)}static changedSince(D,$={}){return D.fingerprints?new L(D.fingerprints,$).changed():[]}replayedInFull(){let D=this.parent??this;return D.calls.length===0&&Object.entries(D.recordedNested).every(([$,z])=>(D.children.get($)?.calls??z).length===0)}async pin(D){if(this.live)return this.read=D,D;let $=this.calls[0]?.read;if($===void 0)return D;return await(this.parent??this).reach($,this.where()),$}async upload(D){let $=this.parent??this,z=`upload_${++$.uploadCount}`;if(this.live)this.uploads.set(z,await this.live.upload(D));return z}normalizeError(D){return this.live?this.live.normalizeError(D):super.normalizeError(D)}async*stream(D){let $=this.requestOf(D);if(this.live){yield*this.recordCall(D,$);return}yield*this.replayCall(D,$)}async*recordCall(D,$){let z=this.parent??this,B=z.shared.started++,C=this.read;this.read=void 0;let G=[],X=D.messages.map((Q)=>({...Q,content:Q.content.map((V)=>V.type==="file"&&V.fileId&&this.uploads.has(V.fileId)?{...V,fileId:this.uploads.get(V.fileId)}:V)}));for await(let Q of this.live.stream({...D,messages:X})){let V=G.at(-1);if(Q.type==="tool-call-discard"){let Z=new Set(Q.toolCallIds),K=G.filter((H)=>H.type!=="tool-call-delta"||!Z.has(H.toolCallId));G.splice(0,G.length,...K)}else if(Q.type==="retry");else if(V&&(Q.type==="text-delta"||Q.type==="output-delta")&&V.type===Q.type)V.delta+=Q.delta;else if(V?.type==="tool-call-delta"&&Q.type==="tool-call-delta"&&V.toolCallId===Q.toolCallId)V.argsDelta+=Q.argsDelta;else G.push({...Q});yield Q}let Y=this.options.position?await this.options.position():void 0;this.calls.push({request:$,events:G,at:B,...C!==void 0?{read:C}:{},...Y!==void 0?{ended:Y}:{}})}async*replayCall(D,$){let z=this.parent??this,B=this.where(),C=this.calls[0];if(this.options.ordered&&C?.at!==void 0)await z.turn(C.at,B);let G=this.calls.shift();if(!G)throw new N(`${B}: call ${this.sentCalls} was not recorded (the recording has no more calls).`);let{promptCacheKey:X,...Y}=G.request;if(!z.matches(JSON.stringify(Y),$))z.tolerate(B,{...G,request:Y},$,D.tools??[]);if(G.ended!==void 0)await z.reach(G.ended,B);let Q=z.shared.ids;for(let V of G.events)yield JSON.parse(JSON.stringify(V).replace(this.options.ids,(Z)=>Q.get(Z)??Z))}where(){return this.key===void 0?"the recording":`sub-run "${this.key}"`}sentCalls=0;requestOf(D){this.sentCalls++;let{signal:$,promptCacheKey:z,messages:B,tools:C,...G}=D,X=B.map(({role:K,content:H})=>({role:K,content:f(H)})),Y=this.sent.length>0&&this.sent.length<=X.length&&JSON.stringify(X.slice(0,this.sent.length))===JSON.stringify(this.sent)?this.sent.length:0;this.sent=X;let Q=C&&C.length>0?JSON.stringify(C):void 0,V=this.parent??this,Z=(K)=>{return V.texts.add(K),K};if(T([G,X.slice(Y)],Z),Q&&!V.toolLists.has(Q)){V.toolLists.add(Q);for(let K of E(C)){T(K,Z);let H=V.toolHashes.get(K.name)??new Set;H.add(L.tool(K)),V.toolHashes.set(K.name,H)}}return{...f(G),...Q?{tools:`sha256:${r(Q)}`,toolNames:E(C).map((K)=>K.name).sort()}:{},...Y>0?{after:Y}:{},messages:X.slice(Y)}}matches(D,$){let z=this.options.ids,B=JSON.stringify($),C=D.match(z)??[],G=B.match(z)??[];if(C.length!==G.length)return!1;let X=new Map(this.shared.ids);for(let[Y,Q]of C.entries()){let V=X.get(Q)??G[Y];if(V!==G[Y])return!1;X.set(Q,V)}if(D.replace(z,(Y)=>X.get(Y))!==B)return!1;for(let[Y,Q]of X)this.shared.ids.set(Y,Q);return!0}tolerate(D,$,z,B){let C=this.options.ids,G=this.options.match,X=$.request,Y=(j,J,I)=>{let A=JSON.stringify(j).replace(C,"<id>"),W=JSON.stringify(J).replace(C,"<id>"),_=0;while(_<A.length&&A[_]===W[_])_++;throw new N(`${D}: the request differs from the recorded one${I}. Recorded: \u2026${A.slice(Math.max(0,_-80),_+120)}\u2026 Sent: \u2026${W.slice(Math.max(0,_-80),_+120)}\u2026`)};if(G==="exact")Y(X,z,"");let{tools:Q,toolNames:V,...Z}=X,{tools:K,toolNames:H,...k}=z,w=[];if(!this.matches(JSON.stringify(Z),k))if(G==="wording"){if(!this.recorded)Y(Z,k,", and the recording has no fingerprints to tell a reworded prompt by");try{this.cuts??=this.recorded.cutters()}catch(I){throw new N(`${D}: ${I.message}.`)}let j=T(Z,this.cuts.recorded),J=T(k,this.cuts.sent);if(this.cuts.changed.length===0||!this.matches(JSON.stringify(j),J))Y(j,J,this.cuts.changed.length>0?", beyond the wording of the prompts changed since":"");w.push(...this.cuts.changed.map((I)=>`${I} changed`))}else{if(!((X.after??0)===(z.after??0)&&this.matches(JSON.stringify(x(X.messages)),x(z.messages))))Y(Z,k," in the conversation itself");let{messages:J,...I}=Z,{messages:A,...W}=k;if(!this.matches(JSON.stringify(J),A))w.push("message text changed");let _=new Set([...Object.keys(I),...Object.keys(W)]);for(let U of[..._].sort()){let O=JSON.stringify(I[U]??null);if(!this.matches(O,W[U]??null))w.push(`${U} changed`)}}if(Q!==K){let j=E(B);for(let J of $.events){if(J.type!=="tool-call")continue;let I=j.find((O)=>O.name===J.name);if(!I)throw new N(`${D}: the recorded answer calls ${J.name}, which is not offered any more.`);let A=Object.fromEntries([...JSON.stringify(I.parameters).matchAll(/"format":"([^"]+)"/g)].map(([,O])=>[O,!0])),W;try{W=JSON.parse(J.args||"{}")}catch{W=void 0}let _;try{_=m.fromJSONSchema(I.parameters,{unknownKeys:"error",formats:A})}catch(O){if(!(O instanceof v))throw O}let U=_?.safeParse(W);if(U&&U.ok===!1)throw new N(`${D}: the recorded call of ${J.name} does not fit its schema any more (${U.errors.join("; ")}).`)}if(this.recorded){let J=j.filter((I)=>!this.recorded.data.tools[I.name]?.includes(L.tool(I))).map((I)=>I.name).sort();w.push(J.length>0?`tools changed: ${J.join(", ")}`:"the tools offered changed")}else{let J=new Set(V??[]),I=new Set(H??[]),A=[...I].filter((_)=>!J.has(_)),W=[...J].filter((_)=>!I.has(_));w.push(A.length>0||W.length>0?`tools offered changed (${[...A.map((_)=>`+${_}`),...W.map((_)=>`-${_}`)].join(", ")})`:"the tools offered changed")}}this.shared.staleCalls++;for(let j of w)this.shared.stale.add(j)}async turn(D,$){let z=this.shared;z.pending??=[...this.calls,...Object.values(this.recordedNested).flat()].map((B)=>B.at).filter((B)=>B!==void 0).sort((B,C)=>B-C);while(z.pending[0]!==void 0&&z.pending[0]<D){let B=z.moved.promise;if(!await Promise.race([B.then(()=>!0),new Promise((G)=>setTimeout(()=>G(!1),this.options.waitMs))]))throw new N(`${$}: call ${D} waits for call ${z.pending[0]}, which the replay does not make.`)}z.pending=z.pending.filter((B)=>B!==D),z.moved.resolve(),z.moved=u()}async reach(D,$){let z=this.options.position;if(!z)return;let B=await z(),C=0;while(B<D){await new Promise((X)=>setTimeout(X,25));let G=await z();if(C=G===B?C+25:0,B=G,C>=this.options.waitMs)throw new N(`${$}: a call waits for the app to reach ${D}; it stays at ${B}.`)}}}function t(D){let $=globalThis.Date,z=new $(D).getTime()-$.now();if(!Number.isFinite(z))throw Error(`pinClock: ${String(D)} is not a date.`);class B extends ${constructor(...C){if(C.length===0)super($.now()+z);else super(...C)}static now(){return $.now()+z}}return globalThis.Date=B,()=>{if(globalThis.Date===B)globalThis.Date=$}}export{t as pinClock,M as RecordingProvider,N as RecordingMismatchError,L as Fingerprints};
4
+ `),C={};for(let[Y,Q]of L.prompts(z))if(L.pieces(Q).filter((Z)=>Z.length>=12).sort((Z,K)=>K.length-Z.length).slice(0,3).some((Z)=>B.includes(Z)))C[Y]=L.blob(Q);let G=[...$.keys()].sort(),X=z.inputs?.(new Set(G));return new L({prompts:C,tools:Object.fromEntries(G.map((Y)=>[Y,[...$.get(Y)].sort()])),...X&&Object.keys(X).length>0?{inputs:a(X)}:{}},z)}same(D){let $=D instanceof L?D.data:D;return JSON.stringify(this.data)===JSON.stringify($)}changed(){let D=this.options.inputs?.(new Set(Object.keys(this.data.tools)))??{};return[...this.changedPrompts().map(([$])=>$),...Object.entries(this.data.inputs??{}).filter(([$,z])=>D[$]!==z).map(([$])=>`input ${$}`)]}cutters(){let D=L.prompts(this.options),$=this.changedPrompts(),z=new Map,B=new Map;for(let[C,G]of $){let X=this.readBlob(G);if(X===void 0)throw Error(`${C} changed since the recording, and the version it was recorded with (${G}) can't be read back from git`);if(z.set(C,X),D.has(C))B.set(C,D.get(C))}return{changed:$.map(([C])=>C),recorded:R(this.piecesWithPartials(z,(C)=>{let G=this.data.prompts[C];return G&&this.readBlob(G)||D.get(C)})),sent:R(this.piecesWithPartials(B,(C)=>D.get(C)))}}changedPrompts(){let D=L.prompts(this.options);return Object.entries(this.data.prompts).filter(([$,z])=>{let B=D.get($);return B===void 0||L.blob(B)!==z})}readBlob(D){if(this.options.readBlob)return this.options.readBlob(D);let $=Bun.spawnSync(["git","cat-file","blob",D],{cwd:this.root});return $.exitCode===0?$.stdout.toString():void 0}piecesWithPartials(D,$){let z=this.options.dirs??["app/agents"],B=this.options.shared??"prompts",C=[...D];while(C.length>0){let[G,X]=C.pop(),Y=z.find((Q)=>G.startsWith(`${Q}/`));if(Y===void 0)continue;for(let[,Q]of X.matchAll(n)){let V=`${Y}/${Q.includes("/")?Q:`${B}/${Q}`}.md`,Z=D.has(V)?void 0:$(V);if(Z===void 0)continue;D.set(V,Z),C.push([V,Z])}}return[...D.values()].flatMap((G)=>L.pieces(G)).sort((G,X)=>X.length-G.length)}}function a(D){return Object.fromEntries(Object.entries(D).sort(([$],[z])=>$.localeCompare(z)))}class N extends Error{constructor(D){super(`${D} Record again.`);this.name="RecordingMismatchError"}}var o=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g;function T(D,$){if(typeof D==="string")return $(D);if(Array.isArray(D))return D.map((z)=>T(z,$));if(D&&typeof D==="object")return Object.fromEntries(Object.entries(D).map(([z,B])=>[z,T(B,$)]));return D}function f(D){return JSON.parse(JSON.stringify(D,function($,z){if($==="nested")return;if($==="output"&&this.type==="tool-result"&&"modelOutput"in this)return;return z}))}function u(){let D;return{promise:new Promise((z)=>D=z),resolve:D}}var r=(D)=>s("sha256").update(D).digest("hex"),E=(D)=>D.flatMap(($)=>("tools"in $)?$.tools:[$]);function x(D){return D.map(({role:$,content:z})=>({role:$,parts:(Array.isArray(z)?z:[]).flatMap((B)=>{if(B?.type==="tool-call")return[{call:B.name,input:B.input??B.args}];if(B?.type==="tool-result")return[{result:B.name,status:B.status}];if(B?.type==="file")return[{file:!0}];return[]})}))}class M extends g{live;model;capabilities;recordedAt;calls;recordedNested;children=new Map;parent;key;sent=[];uploads;uploadCount=0;read;shared;options;texts=new Set;toolHashes=new Map;toolLists=new Set;recorded;cuts;constructor(D,$,z,B){super();this.live=D;if(this.options={...z,match:z.match??"wording",ids:new RegExp(z.ids??o,"g"),waitMs:z.waitMs??60000},B){let{parent:C}=B;this.parent=C,this.key=B.key,this.model=C.model,this.capabilities=C.capabilities,this.recordedAt=C.recordedAt,this.calls=B.calls,this.recordedNested={},this.uploads=C.uploads,this.shared=C.shared;return}if(this.shared={ids:new Map,stale:new Set,staleCalls:0,started:0,moved:u()},this.uploads=new Map,D){this.model=D.model,this.capabilities=D.capabilities,this.recordedAt=new Date,this.calls=[],this.recordedNested={};return}if(!$||$.version!==1||!Array.isArray($.calls))throw Error("RecordingProvider.replay needs a recording made by RecordingProvider.");if(this.model=$.model,this.capabilities=$.capabilities,this.recordedAt=new Date($.recordedAt),this.calls=structuredClone($.calls),this.recordedNested=structuredClone($.nested??{}),$.fingerprints)this.recorded=new L($.fingerprints,z.fingerprints)}static record(D,$={}){return new M(D,void 0,$)}static replay(D,$={}){return new M(void 0,D,$)}get isRecording(){return this.live!==void 0}get stale(){return this.shared.stale}get staleCalls(){return this.shared.staleCalls}nested(D){if(this.parent)return this.parent.nested(D);let $=this.children.get(D);if(!$){let z=this.recordedNested[D];if(!this.live&&!z)throw new N(`The recording has no sub-run "${D}".`);$=new M(this.live,void 0,this.options,{parent:this,key:D,calls:z??[]}),this.children.set(D,$)}return $}recording(){if(this.parent)return this.parent.recording();if(!this.live)throw Error("Only a recording provider (`record`) has a recording to save.");return{version:1,model:this.model,capabilities:this.capabilities,recordedAt:this.recordedAt.toISOString(),calls:structuredClone(this.calls),...this.options.fingerprints?{fingerprints:this.fingerprints().data}:{},...this.children.size>0?{nested:Object.fromEntries([...this.children].map(([D,$])=>[D,structuredClone($.calls)]))}:{}}}fingerprints(){let D=this.parent??this;return L.of(D.texts,D.toolHashes,this.options.fingerprints)}static changedSince(D,$={}){return D.fingerprints?new L(D.fingerprints,$).changed():[]}replayedInFull(){let D=this.parent??this;return D.calls.length===0&&Object.entries(D.recordedNested).every(([$,z])=>(D.children.get($)?.calls??z).length===0)}async pin(D){if(this.live)return this.read=D,D;let $=this.calls[0]?.read;if($===void 0)return D;return await(this.parent??this).reach($,this.where()),$}async upload(D){let $=++this.uploadCount,z=this.key===void 0?`upload_${$}`:`upload_${this.key}_${$}`;if(this.live)this.uploads.set(z,await this.live.upload(D));return z}normalizeError(D){return this.live?this.live.normalizeError(D):super.normalizeError(D)}async*stream(D){let $=this.requestOf(D);if(this.live){yield*this.recordCall(D,$);return}yield*this.replayCall(D,$)}async*recordCall(D,$){let z=this.parent??this,B=z.shared.started++,C=this.read;this.read=void 0;let G=[],X=D.messages.map((Q)=>({...Q,content:Q.content.map((V)=>V.type==="file"&&V.fileId&&this.uploads.has(V.fileId)?{...V,fileId:this.uploads.get(V.fileId)}:V)}));for await(let Q of this.live.stream({...D,messages:X})){let V=G.at(-1);if(Q.type==="tool-call-discard"){let Z=new Set(Q.toolCallIds),K=G.filter((H)=>H.type!=="tool-call-delta"||!Z.has(H.toolCallId));G.splice(0,G.length,...K)}else if(Q.type==="retry");else if(V&&(Q.type==="text-delta"||Q.type==="output-delta")&&V.type===Q.type)V.delta+=Q.delta;else if(V?.type==="tool-call-delta"&&Q.type==="tool-call-delta"&&V.toolCallId===Q.toolCallId)V.argsDelta+=Q.argsDelta;else G.push({...Q});yield Q}let Y=this.options.position?await this.options.position():void 0;this.calls.push({request:$,events:G,at:B,...C!==void 0?{read:C}:{},...Y!==void 0?{ended:Y}:{}})}async*replayCall(D,$){let z=this.parent??this,B=this.where(),C=this.calls[0];if(this.options.ordered&&C?.at!==void 0)await z.turn(C.at,B);let G=this.calls.shift();if(!G)throw new N(`${B}: call ${this.sentCalls} was not recorded (the recording has no more calls).`);let{promptCacheKey:X,...Y}=G.request;if(!z.matches(JSON.stringify(Y),$))z.tolerate(B,{...G,request:Y},$,D.tools??[]);if(G.ended!==void 0)await z.reach(G.ended,B);let Q=z.shared.ids;for(let V of G.events)yield JSON.parse(JSON.stringify(V).replace(this.options.ids,(Z)=>Q.get(Z)??Z))}where(){return this.key===void 0?"the recording":`sub-run "${this.key}"`}sentCalls=0;requestOf(D){this.sentCalls++;let{signal:$,promptCacheKey:z,messages:B,tools:C,...G}=D,X=B.map(({role:K,content:H})=>({role:K,content:f(H)})),Y=this.sent.length>0&&this.sent.length<=X.length&&JSON.stringify(X.slice(0,this.sent.length))===JSON.stringify(this.sent)?this.sent.length:0;this.sent=X;let Q=C&&C.length>0?JSON.stringify(C):void 0,V=this.parent??this,Z=(K)=>{return V.texts.add(K),K};if(T([G,X.slice(Y)],Z),Q&&!V.toolLists.has(Q)){V.toolLists.add(Q);for(let K of E(C)){T(K,Z);let H=V.toolHashes.get(K.name)??new Set;H.add(L.tool(K)),V.toolHashes.set(K.name,H)}}return{...f(G),...Q?{tools:`sha256:${r(Q)}`,toolNames:E(C).map((K)=>K.name).sort()}:{},...Y>0?{after:Y}:{},messages:X.slice(Y)}}matches(D,$){let z=this.options.ids,B=JSON.stringify($),C=D.match(z)??[],G=B.match(z)??[];if(C.length!==G.length)return!1;let X=new Map(this.shared.ids);for(let[Y,Q]of C.entries()){let V=X.get(Q)??G[Y];if(V!==G[Y])return!1;X.set(Q,V)}if(D.replace(z,(Y)=>X.get(Y))!==B)return!1;for(let[Y,Q]of X)this.shared.ids.set(Y,Q);return!0}tolerate(D,$,z,B){let C=this.options.ids,G=this.options.match,X=$.request,Y=(j,J,I)=>{let A=JSON.stringify(j).replace(C,"<id>"),W=JSON.stringify(J).replace(C,"<id>"),_=0;while(_<A.length&&A[_]===W[_])_++;throw new N(`${D}: the request differs from the recorded one${I}. Recorded: \u2026${A.slice(Math.max(0,_-80),_+120)}\u2026 Sent: \u2026${W.slice(Math.max(0,_-80),_+120)}\u2026`)};if(G==="exact")Y(X,z,"");let{tools:Q,toolNames:V,...Z}=X,{tools:K,toolNames:H,...k}=z,w=[];if(!this.matches(JSON.stringify(Z),k))if(G==="wording"){if(!this.recorded)Y(Z,k,", and the recording has no fingerprints to tell a reworded prompt by");try{this.cuts??=this.recorded.cutters()}catch(I){throw new N(`${D}: ${I.message}.`)}let j=T(Z,this.cuts.recorded),J=T(k,this.cuts.sent);if(this.cuts.changed.length===0||!this.matches(JSON.stringify(j),J))Y(j,J,this.cuts.changed.length>0?", beyond the wording of the prompts changed since":"");w.push(...this.cuts.changed.map((I)=>`${I} changed`))}else{if(!((X.after??0)===(z.after??0)&&this.matches(JSON.stringify(x(X.messages)),x(z.messages))))Y(Z,k," in the conversation itself");let{messages:J,...I}=Z,{messages:A,...W}=k;if(!this.matches(JSON.stringify(J),A))w.push("message text changed");let _=new Set([...Object.keys(I),...Object.keys(W)]);for(let U of[..._].sort()){let O=JSON.stringify(I[U]??null);if(!this.matches(O,W[U]??null))w.push(`${U} changed`)}}if(Q!==K){let j=E(B);for(let J of $.events){if(J.type!=="tool-call")continue;let I=j.find((O)=>O.name===J.name);if(!I)throw new N(`${D}: the recorded answer calls ${J.name}, which is not offered any more.`);let A=Object.fromEntries([...JSON.stringify(I.parameters).matchAll(/"format":"([^"]+)"/g)].map(([,O])=>[O,!0])),W;try{W=JSON.parse(J.args||"{}")}catch{W=void 0}let _;try{_=m.fromJSONSchema(I.parameters,{unknownKeys:"error",formats:A})}catch(O){if(!(O instanceof v))throw O}let U=_?.safeParse(W);if(U&&U.ok===!1)throw new N(`${D}: the recorded call of ${J.name} does not fit its schema any more (${U.errors.join("; ")}).`)}if(this.recorded){let J=j.filter((I)=>!this.recorded.data.tools[I.name]?.includes(L.tool(I))).map((I)=>I.name).sort();w.push(J.length>0?`tools changed: ${J.join(", ")}`:"the tools offered changed")}else{let J=new Set(V??[]),I=new Set(H??[]),A=[...I].filter((_)=>!J.has(_)),W=[...J].filter((_)=>!I.has(_));w.push(A.length>0||W.length>0?`tools offered changed (${[...A.map((_)=>`+${_}`),...W.map((_)=>`-${_}`)].join(", ")})`:"the tools offered changed")}}this.shared.staleCalls++;for(let j of w)this.shared.stale.add(j)}async turn(D,$){let z=this.shared;z.pending??=[...this.calls,...Object.values(this.recordedNested).flat()].map((B)=>B.at).filter((B)=>B!==void 0).sort((B,C)=>B-C);while(z.pending[0]!==void 0&&z.pending[0]<D){let B=z.moved.promise;if(!await Promise.race([B.then(()=>!0),new Promise((G)=>setTimeout(()=>G(!1),this.options.waitMs))]))throw new N(`${$}: call ${D} waits for call ${z.pending[0]}, which the replay does not make.`)}z.pending=z.pending.filter((B)=>B!==D),z.moved.resolve(),z.moved=u()}async reach(D,$){let z=this.options.position;if(!z)return;let B=await z(),C=0;while(B<D){await new Promise((X)=>setTimeout(X,25));let G=await z();if(C=G===B?C+25:0,B=G,C>=this.options.waitMs)throw new N(`${$}: a call waits for the app to reach ${D}; it stays at ${B}.`)}}}function t(D){let $=globalThis.Date,z=new $(D).getTime()-$.now();if(!Number.isFinite(z))throw Error(`pinClock: ${String(D)} is not a date.`);class B extends ${constructor(...C){if(C.length===0)super($.now()+z);else super(...C)}static now(){return $.now()+z}}return globalThis.Date=B,()=>{if(globalThis.Date===B)globalThis.Date=$}}export{t as pinClock,M as RecordingProvider,N as RecordingMismatchError,L as Fingerprints};
5
5
 
6
- //# debugId=6EE7E64E84FD59CE64756E2164756E21
6
+ //# debugId=AFE64E590F6A1B0B64756E2164756E21