nolo-cli 0.265.0-alpha.1 → 0.266.0-alpha.1

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 (539) hide show
  1. package/{chunk-LXP53WGF.js → chunk-05wkntba.js} +44 -40
  2. package/{chunk-XFYFMTOM.js → chunk-08ts2q1n.js} +9 -11
  3. package/{chromeCommands-MVEEIY4R.js → chunk-0a3m1n6h.js} +182 -238
  4. package/chunk-0gfvc7g8.js +13 -0
  5. package/{chunk-CF7PE763.js → chunk-0h0sncy4.js} +3 -4
  6. package/{chunk-3UH7SS4W.js → chunk-0nsxwrge.js} +232 -241
  7. package/chunk-0ra8cne4.js +11 -0
  8. package/{chunk-MRACVEPZ.js → chunk-0sgwk7am.js} +1 -3
  9. package/{chunk-PEXGRTTQ.js → chunk-0tsfn0dk.js} +44 -45
  10. package/{chunk-WOAZVUSN.js → chunk-0y8cbwzy.js} +26 -30
  11. package/chunk-12gz55kk.js +6 -0
  12. package/{chunk-GLKOYSRU.js → chunk-186gshgw.js} +3 -6
  13. package/chunk-19w4ss38.js +44 -0
  14. package/{chunk-RF576RYE.js → chunk-1cakzp6r.js} +23 -23
  15. package/chunk-1fbfwbzp.js +27 -0
  16. package/{chunk-4IVMDQBA.js → chunk-1fv9k8zt.js} +103 -68
  17. package/{chunk-Q5FJJ6XI.js → chunk-1js4cdzp.js} +11 -19
  18. package/{chunk-YECCIUYU.js → chunk-1nhx0er5.js} +63 -63
  19. package/chunk-1p152b7g.js +12 -0
  20. package/{chunk-LBPW6OCD.js → chunk-1ynbq3yr.js} +322 -353
  21. package/{chunk-6UBGXX2W.js → chunk-1zrg4h5n.js} +3 -4
  22. package/{chunk-Y5GCAMGP.js → chunk-2g6zsfq8.js} +1 -3
  23. package/chunk-2hekb0eh.js +17 -0
  24. package/chunk-2pj6qzq5.js +12 -0
  25. package/chunk-2tvd4jyp.js +226 -0
  26. package/chunk-2ygg7azv.js +846 -0
  27. package/chunk-33405wtv.js +50 -0
  28. package/chunk-34axejtd.js +30 -0
  29. package/{tableCommands-FCPDULSU.js → chunk-3700dvt3.js} +224 -276
  30. package/{pdf-KE3QI2V7.js → chunk-3j08t1nm.js} +12505 -10133
  31. package/chunk-3j9gq18v.js +111 -0
  32. package/{chunk-2QKIWEZS.js → chunk-3qfpcdkm.js} +486 -505
  33. package/{settingThunks-PNC7ZISV.js → chunk-3r2x7h64.js} +189 -272
  34. package/{agentGrantCommands-2VLLXGIU.js → chunk-3tbj5fxt.js} +61 -56
  35. package/chunk-40whhjj5.js +168 -0
  36. package/chunk-4301919y.js +7 -0
  37. package/chunk-43adz39e.js +77 -0
  38. package/{chunk-5ZUL4CUO.js → chunk-49v3zc4g.js} +1 -3
  39. package/chunk-4dd7mxkb.js +72 -0
  40. package/{chunk-BKP325XS.js → chunk-4hapfzpq.js} +66 -62
  41. package/chunk-4mm7dz0m.js +95 -0
  42. package/chunk-4pqxempz.js +440 -0
  43. package/chunk-4x9zf5pv.js +10 -0
  44. package/{chunk-CA7LGAHV.js → chunk-511q8qzv.js} +66 -57
  45. package/{chunk-S52BPZ7A.js → chunk-53v9g0np.js} +49 -64
  46. package/chunk-572mg6q5.js +19 -0
  47. package/{chunk-DXDCL3Z6.js → chunk-57eyhmwr.js} +17173 -16165
  48. package/chunk-5hsr0zjm.js +156 -0
  49. package/chunk-5k883yyd.js +20 -0
  50. package/chunk-5m0wsee4.js +639 -0
  51. package/{memberThunks-IPS3SLOF.js → chunk-5r1sq2gt.js} +299 -373
  52. package/chunk-648rq4np.js +255 -0
  53. package/{chunk-IYRZKHA6.js → chunk-666yjw5c.js} +63 -86
  54. package/{chunk-4O22PGNQ.js → chunk-6cdcbmtp.js} +19 -19
  55. package/chunk-6dbyqcf7.js +59 -0
  56. package/{agentProviderCommands-2W3VXDLV.js → chunk-6e8mgp1x.js} +82 -105
  57. package/chunk-6n0pw7sx.js +44 -0
  58. package/chunk-6q1b7381.js +361 -0
  59. package/chunk-6sj756ry.js +23 -0
  60. package/{chunk-XGYQCBWS.js → chunk-6t7a7zck.js} +14785 -14454
  61. package/chunk-6yarwtxh.js +776 -0
  62. package/chunk-708h542p.js +18 -0
  63. package/chunk-76f076t8.js +266 -0
  64. package/chunk-782rrrwv.js +523 -0
  65. package/{workloadLifecycle-P2SJVV3S.js → chunk-7gk330wp.js} +77 -84
  66. package/{chunk-EZKIRVLJ.js → chunk-7ks60vxy.js} +146 -128
  67. package/{chunk-FI4DPLR7.js → chunk-7mrqbxe8.js} +342 -228
  68. package/chunk-7sztayrd.js +169 -0
  69. package/chunk-7vgt2mxz.js +15 -0
  70. package/{localFirstLog-OIETGK66.js → chunk-7z8y4k6y.js} +0 -2
  71. package/{chunk-KDDXC2IH.js → chunk-82htft2m.js} +49 -11
  72. package/{updateDialogTitleAction-OPAZF5VC.js → chunk-88vrtxxg.js} +65 -137
  73. package/{chunk-LS5KAVFQ.js → chunk-8dtjbp79.js} +293 -229
  74. package/chunk-8fajbkaz.js +50 -0
  75. package/chunk-8m1ebxpw.js +65 -0
  76. package/{accountResolver-JYG5L7YP.js → chunk-8mgfeg0w.js} +37 -30
  77. package/{chunk-LPXBBC32.js → chunk-8myksy35.js} +156 -160
  78. package/{chunk-BMQ2MJUK.js → chunk-8nrj7dc7.js} +75 -66
  79. package/{commandRegistry-XPLM5SWC.js → chunk-8t8x64ec.js} +228 -286
  80. package/chunk-8yj4pq79.js +458 -0
  81. package/{chunk-5MKPNTJP.js → chunk-8z6pepcx.js} +43 -48
  82. package/{chunk-UYQILGDR.js → chunk-90egc9vb.js} +122 -102
  83. package/{chunk-Z6LVL5MC.js → chunk-91q5dc5r.js} +10 -14
  84. package/{chunk-U6VC4MU4.js → chunk-96jtrqk1.js} +2 -4
  85. package/{chunk-H57T64RA.js → chunk-996j61av.js} +28 -31
  86. package/{chunk-Q6FKWH66.js → chunk-9cxgb9jy.js} +137 -243
  87. package/{chunk-2ZBPWX7N.js → chunk-9q1gbmet.js} +62 -104
  88. package/chunk-9qtjh73q.js +344 -0
  89. package/{chunk-SR57FDTX.js → chunk-9raka469.js} +72 -155
  90. package/{chunk-V6K5U4YE.js → chunk-9vh4v046.js} +32 -41
  91. package/{chunk-AGIM7IMJ.js → chunk-9yr1fy7j.js} +14 -49
  92. package/{chunk-FGFJUFPS.js → chunk-a16x0wt6.js} +11 -18
  93. package/chunk-a5b2rvzs.js +131 -0
  94. package/{chunk-7DPNBQSV.js → chunk-a7bz6nc3.js} +3 -4
  95. package/chunk-ac85azv9.js +29 -0
  96. package/{chunk-VXL2FZTP.js → chunk-ahhbkad4.js} +16 -20
  97. package/{chunk-37DGW762.js → chunk-anhksj2j.js} +16 -29
  98. package/{cliAuthorityBrokerServer-27C5YBYP.js → chunk-atvmx76t.js} +180 -186
  99. package/{chunk-E6A5NHDH.js → chunk-av2mzeqz.js} +16 -17
  100. package/chunk-avbwrb0z.js +614 -0
  101. package/chunk-avr6rqe5.js +544 -0
  102. package/{workContextQueryProjection-CACY5VFE.js → chunk-axx60d5a.js} +7 -7
  103. package/{chunk-EWQ3HGNZ.js → chunk-b00vzjkb.js} +30 -23
  104. package/chunk-b0m6ezxr.js +132 -0
  105. package/chunk-bbd5mgdt.js +47 -0
  106. package/chunk-bcecft0r.js +28 -0
  107. package/chunk-beyr4pyp.js +33 -0
  108. package/{chunk-BR3GT6MR.js → chunk-bge0cagn.js} +7 -18
  109. package/{offlineMarxistsAgentCommand-MFURGWHL.js → chunk-bh53zg3t.js} +33 -43
  110. package/chunk-bmx1cw89.js +37 -0
  111. package/chunk-br2195h4.js +22 -0
  112. package/chunk-bsqkwveq.js +56 -0
  113. package/{chunk-DZJWSGCV.js → chunk-c09s2z1m.js} +139 -98
  114. package/chunk-c235kypv.js +24636 -0
  115. package/{chunk-2JMYAH5O.js → chunk-c30j6pyh.js} +213 -256
  116. package/chunk-c3v6r6sq.js +29 -0
  117. package/{chunk-NACE7NWO.js → chunk-c5z7qspt.js} +1177 -1196
  118. package/{chunk-GWB6AGME.js → chunk-c6jvz0mp.js} +34 -50
  119. package/{chunk-PRJ473FK.js → chunk-cd6h9qqs.js} +14 -12
  120. package/chunk-cdt0amyy.js +37 -0
  121. package/{chunk-2AJLG6PY.js → chunk-cfh6tfc3.js} +73 -86
  122. package/{chunk-WIVVNJUS.js → chunk-ch4ck1yz.js} +38 -68
  123. package/chunk-chtvrtp5.js +55 -0
  124. package/{chunk-EYLGAEB4.js → chunk-ckvz7abv.js} +170 -165
  125. package/{chunk-YZMNK53S.js → chunk-csf18m5w.js} +32 -25
  126. package/{chunk-C36L6ZID.js → chunk-cwnvf8dt.js} +2 -10
  127. package/chunk-cy7thb6n.js +19877 -0
  128. package/{dialogPortabilityCommands-YQJNB2KL.js → chunk-d61q9nah.js} +439 -487
  129. package/chunk-d6xdy0gp.js +142 -0
  130. package/{chunk-SCEPD46O.js → chunk-dh69vqbd.js} +6386 -6498
  131. package/{chunk-KJ4J2XQB.js → chunk-dj4ggbc6.js} +17 -19
  132. package/{chunk-LISC7BD4.js → chunk-djrrhbk3.js} +29 -37
  133. package/chunk-drqzzzvr.js +822 -0
  134. package/chunk-e1n7edjk.js +33 -0
  135. package/chunk-e3atr4hk.js +59 -0
  136. package/chunk-e9bn2aav.js +13 -0
  137. package/chunk-ed396rfq.js +87 -0
  138. package/chunk-eha8ggh6.js +10 -0
  139. package/{chunk-B7CTVEUV.js → chunk-ek122zzt.js} +893 -948
  140. package/chunk-epnmvek4.js +22 -0
  141. package/{chunk-S25VJYXV.js → chunk-eqzvk3xm.js} +69 -80
  142. package/chunk-ex34n71b.js +2874 -0
  143. package/{chunk-56OAS5RZ.js → chunk-f3ad6q4h.js} +7 -11
  144. package/{chunk-3PVYUPXK.js → chunk-f8jepva1.js} +6 -7
  145. package/{chunk-GH34JXNV.js → chunk-f9yvy9t9.js} +114 -92
  146. package/chunk-fbdz4f0j.js +90 -0
  147. package/{chunk-J44TXB4J.js → chunk-fcsc2day.js} +216 -164
  148. package/chunk-fevdhnbh.js +19 -0
  149. package/chunk-fkrgqq8w.js +3300 -0
  150. package/{chunk-TSBJVMNW.js → chunk-fs3bvh2p.js} +42 -57
  151. package/chunk-fvwzyhah.js +134 -0
  152. package/chunk-g0mpxdp9.js +101 -0
  153. package/{chunk-JGUHOA42.js → chunk-g35f20d1.js} +450 -414
  154. package/{chunk-3L2WKC3W.js → chunk-g5fhtjqg.js} +13 -16
  155. package/{chunk-APOIIIB4.js → chunk-gcq01td7.js} +270 -227
  156. package/{chunk-ADMRXWXJ.js → chunk-ge97b11r.js} +121 -42
  157. package/chunk-ghjtgbkw.js +180 -0
  158. package/chunk-gkra36c1.js +16 -0
  159. package/chunk-gmz86t60.js +1000 -0
  160. package/{localDialogRead-GWGWSL5K.js → chunk-gszpesze.js} +5 -12
  161. package/chunk-gvsfec9m.js +16536 -0
  162. package/{chunk-QSJ3HFEF.js → chunk-h1hzmqph.js} +1 -3
  163. package/chunk-h30dg154.js +17 -0
  164. package/chunk-h3hkb7cw.js +241 -0
  165. package/chunk-h40py996.js +28 -0
  166. package/{chunk-47T3QP4V.js → chunk-h60gnewh.js} +112 -116
  167. package/{agentPullCommand-XEGOUYQT.js → chunk-hkwsv9xf.js} +33 -45
  168. package/chunk-hnyg0gwj.js +28 -0
  169. package/{chunk-KSV6T4AH.js → chunk-hqqqph5w.js} +12 -4
  170. package/{chunk-YQJEXXDK.js → chunk-hrngs1wy.js} +157 -246
  171. package/{chunk-LRLLWD4P.js → chunk-htf69s94.js} +14 -12
  172. package/chunk-j0yxesh3.js +83 -0
  173. package/{chunk-VF4K2QE6.js → chunk-j22t9g05.js} +3 -6
  174. package/{chunk-3R4AYHJR.js → chunk-j4a8m2zn.js} +5 -34
  175. package/chunk-j9p4jnwg.js +27 -0
  176. package/{chunk-R72QWIFO.js → chunk-jdycmfsm.js} +9 -9
  177. package/chunk-jdyvrne0.js +52 -0
  178. package/{spacePruneCommand-YKIEUIDQ.js → chunk-je0b66qf.js} +44 -62
  179. package/{chunk-HNMXYYJR.js → chunk-jec44fkj.js} +3 -4
  180. package/{chunk-526GLZJE.js → chunk-jf1ex00r.js} +107 -73
  181. package/chunk-jgqdec9b.js +31 -0
  182. package/{chunk-56GBUMO5.js → chunk-jkw9n4h5.js} +16 -25
  183. package/{chunk-BY2CHBIZ.js → chunk-jmnzdwjt.js} +867 -965
  184. package/chunk-jqq57s0a.js +58 -0
  185. package/{chunk-OKUSDVRS.js → chunk-jtkn5aj6.js} +27 -38
  186. package/chunk-jwvzn9r0.js +316 -0
  187. package/chunk-k1re0fc7.js +107 -0
  188. package/chunk-k2ep3rb2.js +103 -0
  189. package/{chunk-JEXVIMYZ.js → chunk-k6ycb24w.js} +5 -8
  190. package/{chunk-RI7SXDJW.js → chunk-kawvydbk.js} +383 -195
  191. package/chunk-kf2ghpzh.js +10 -0
  192. package/{chunk-S6FAHQDH.js → chunk-kgah9e46.js} +28 -59
  193. package/{chunk-6A6CTCMC.js → chunk-kjjepkvc.js} +71 -82
  194. package/chunk-kn4dgg4j.js +4113 -0
  195. package/{chunk-2LFYMWM3.js → chunk-kn5p91n8.js} +43 -53
  196. package/{chunk-MVOZ22RZ.js → chunk-kntqrbwc.js} +8 -12
  197. package/{chunk-I6YIA2TY.js → chunk-kq3vr7mx.js} +25 -20
  198. package/chunk-kz1x1d8n.js +15 -0
  199. package/{mcpLocalAuthorizeCommand-IKOFKY5U.js → chunk-m22e7tt2.js} +53 -71
  200. package/{chunk-ZNFJWEN4.js → chunk-m32rwr4d.js} +11 -8
  201. package/chunk-m39e9m18.js +93 -0
  202. package/{chunk-4D4QD7FT.js → chunk-m5518371.js} +64 -56
  203. package/{chunk-LHTXSC2E.js → chunk-mb5hnfyp.js} +9 -11
  204. package/chunk-mexet11v.js +11 -0
  205. package/chunk-mg2hgfgh.js +185 -0
  206. package/chunk-mmdhm4kx.js +10317 -0
  207. package/chunk-mz002yz8.js +2821 -0
  208. package/chunk-mzadqnyq.js +56 -0
  209. package/{chunk-VIDPVFP3.js → chunk-n3r1ebdm.js} +5 -6
  210. package/chunk-n438qea7.js +33 -0
  211. package/chunk-n5ffnhnb.js +93 -0
  212. package/chunk-nbvd87fy.js +9 -0
  213. package/{chunk-E36V7MPY.js → chunk-ndej7jc9.js} +53 -43
  214. package/{chunk-B767MA64.js → chunk-nen6rwe4.js} +62 -22
  215. package/chunk-nf06tr3v.js +16 -0
  216. package/chunk-ng8z355q.js +16 -0
  217. package/{chunk-4MEKE5D3.js → chunk-nhtxfv8k.js} +78 -63
  218. package/{runAgentClientLoop-ELTV5MSJ.js → chunk-nj62jscj.js} +132 -214
  219. package/{chunk-GBWGPTA7.js → chunk-nkryrkyp.js} +16 -19
  220. package/chunk-nmesxem8.js +197 -0
  221. package/{chunk-YR4J7RFS.js → chunk-nmq0qwbn.js} +117 -164
  222. package/chunk-nph8brvw.js +7 -0
  223. package/chunk-nr8fees9.js +10 -0
  224. package/{chunk-DFI7MVCQ.js → chunk-nvewvf7h.js} +1441 -1427
  225. package/{chunk-G7Y4GXTY.js → chunk-nyamhphs.js} +70 -79
  226. package/chunk-nz1c8tcg.js +111 -0
  227. package/{chunk-GPLUFN2E.js → chunk-nzc5yffh.js} +176 -217
  228. package/{chunk-G3SUCT4W.js → chunk-p1vg4bx8.js} +2 -4
  229. package/chunk-p3k3abe8.js +202 -0
  230. package/chunk-p4zy30q5.js +8 -0
  231. package/{chunk-ZJACPM5O.js → chunk-p6se1rx0.js} +102 -102
  232. package/chunk-p9dpshev.js +6968 -0
  233. package/chunk-pa42wxr0.js +116 -0
  234. package/{chunk-TA5QI4MM.js → chunk-paxthgqp.js} +56 -107
  235. package/{readlineWorkspace-5EASNOQ4.js → chunk-pb35s8d9.js} +5395 -5786
  236. package/{chunk-XT6C2QZW.js → chunk-pbebzbcq.js} +8 -8
  237. package/chunk-pbx7e1mb.js +11 -0
  238. package/chunk-pe5czfn9.js +8 -0
  239. package/chunk-pextk1j4.js +62 -0
  240. package/chunk-pf5rywc6.js +575 -0
  241. package/chunk-pjfhd3fz.js +136 -0
  242. package/chunk-pkhqb0fs.js +243 -0
  243. package/chunk-pm5xb9jh.js +26 -0
  244. package/{chunk-Y3KGWZKF.js → chunk-ppdmmdkx.js} +110 -97
  245. package/chunk-pqp6y2hs.js +9 -0
  246. package/{chunk-QHEN7NZ7.js → chunk-ptz8fm2n.js} +12 -17
  247. package/{chunk-EUHMI5KG.js → chunk-pwqnvbt7.js} +65 -46
  248. package/chunk-pzr31nz7.js +12 -0
  249. package/{chunk-WWC7I6TA.js → chunk-q3cx89sw.js} +2 -4
  250. package/chunk-q5pe7be3.js +78 -0
  251. package/{chunk-ZHWTBHT3.js → chunk-q6zqbxp2.js} +418 -409
  252. package/chunk-q7r0e1p3.js +15 -0
  253. package/chunk-q8t2fecd.js +6 -0
  254. package/{chunk-2QAZCYOM.js → chunk-q94zx4d0.js} +721 -753
  255. package/{runtimeDoctorCommands-52MBG5JN.js → chunk-qarz1az1.js} +65 -85
  256. package/{chunk-4INJGWE3.js → chunk-qdcvr25b.js} +72 -53
  257. package/{streamAgentChatTurn-BL3ESUEN.js → chunk-qxs27wfg.js} +1079 -1475
  258. package/{chunk-GIXWVN2W.js → chunk-r06ycjjr.js} +50 -47
  259. package/{chunk-63W5N6P3.js → chunk-r20jw5hb.js} +57 -38
  260. package/{chunk-I5BYFTYK.js → chunk-r7sfwdka.js} +1201 -1142
  261. package/{chunk-UMADT6B2.js → chunk-r9sp1yyb.js} +6 -8
  262. package/{handleSendMessageAction-VQP5HT5I.js → chunk-rbd2vgb3.js} +627 -757
  263. package/chunk-rc37js46.js +12 -0
  264. package/{chunk-5YI447UL.js → chunk-rmngk6r3.js} +67 -76
  265. package/chunk-rnhbnbrq.js +15 -0
  266. package/{chunk-WRHVVIGI.js → chunk-rsfnmrt5.js} +111 -131
  267. package/{chunk-YFSM2366.js → chunk-rvvn2rhj.js} +28 -22
  268. package/{chunk-4Y6CZ2N4.js → chunk-s0fpz7ht.js} +37 -33
  269. package/{chunk-VI4SWTUO.js → chunk-s1cqzb2r.js} +77 -65
  270. package/{chunk-6QDYSCPW.js → chunk-s8q81tda.js} +73 -65
  271. package/chunk-s9hy639e.js +6 -0
  272. package/{chunk-R5GO3YZP.js → chunk-s9vbwme8.js} +115 -106
  273. package/chunk-sger1m1b.js +20 -0
  274. package/chunk-spe6crvk.js +60 -0
  275. package/chunk-spwsrvh9.js +70 -0
  276. package/chunk-sr05zpk7.js +573 -0
  277. package/{chunk-M2EJHDJP.js → chunk-srncrd3f.js} +1 -12
  278. package/{chunk-QXHFIX7W.js → chunk-sry80bpx.js} +71 -53
  279. package/{chunk-PSCNXBYA.js → chunk-t6q69p83.js} +3 -4
  280. package/{chunk-UAD2WT54.js → chunk-t714r4q0.js} +9 -28
  281. package/chunk-t7vbraqe.js +42 -0
  282. package/{chunk-CVMMWN6P.js → chunk-td7653rr.js} +10 -20
  283. package/{chunk-3BQDF4QB.js → chunk-tmytcetz.js} +17 -21
  284. package/{chunk-AMWMV56B.js → chunk-tta4prwg.js} +16 -15
  285. package/chunk-tvh8azgq.js +4829 -0
  286. package/{chunk-ID4G2MAR.js → chunk-v08kbfm8.js} +10 -11
  287. package/{chunk-IHU2ZFCQ.js → chunk-v1x702q8.js} +801 -852
  288. package/{chunk-KHCLMKZZ.js → chunk-v39fea91.js} +576 -247
  289. package/{chunk-OW765XBU.js → chunk-vejtd8p2.js} +3 -4
  290. package/chunk-vep7zkha.js +368 -0
  291. package/chunk-vfwn1k7n.js +142 -0
  292. package/chunk-vg68vxhx.js +20 -0
  293. package/chunk-vgcqgnsm.js +31 -0
  294. package/{chunk-NF64D32W.js → chunk-vnzyjdea.js} +1 -3
  295. package/{chunk-ZCLSM5AK.js → chunk-vqgtw1px.js} +800 -717
  296. package/chunk-vv1gr5xz.js +76 -0
  297. package/{spaceCommands-Z2CTQD6G.js → chunk-w1qeadpq.js} +176 -242
  298. package/chunk-w468ez1p.js +13 -0
  299. package/chunk-w49s0t79.js +14 -0
  300. package/{mcpLocalManageCommands-KUDZQRM4.js → chunk-w58zhfbn.js} +91 -93
  301. package/chunk-w5b74aq6.js +11 -0
  302. package/chunk-w7y41qyw.js +117 -0
  303. package/chunk-w820gg1w.js +4165 -0
  304. package/{chunk-DBJAJ4UD.js → chunk-wdsmaqmt.js} +399 -453
  305. package/{chunk-3EUW3WEO.js → chunk-wfvvnmmj.js} +1 -3
  306. package/{chunk-QY4NZCDA.js → chunk-wkr04bhk.js} +432 -651
  307. package/{chunk-KUG52IAP.js → chunk-ws402twv.js} +1 -3
  308. package/chunk-wzwh311q.js +164 -0
  309. package/{runtimeModeArgs-X7DL7PUN.js → chunk-x5vtgvwn.js} +6 -5
  310. package/{agentMachineCommands-AXPZRHUY.js → chunk-x8h2csmq.js} +152 -195
  311. package/{chunk-BAZCS5XG.js → chunk-x9zfjnrc.js} +59 -47
  312. package/{chunk-WTIJKWCI.js → chunk-xcarc2rf.js} +50 -56
  313. package/chunk-xf33gz0a.js +8 -0
  314. package/{chunk-PVFYPUIM.js → chunk-y7b3gwx1.js} +78 -71
  315. package/{memoryCommands-SVLAVFCV.js → chunk-y7sphmnh.js} +119 -95
  316. package/{agentListCommands-436FHOIT.js → chunk-ycvaafhc.js} +260 -374
  317. package/chunk-yd7zprb0.js +9 -0
  318. package/chunk-yfz3d27k.js +40 -0
  319. package/{chunk-MKR6KDD3.js → chunk-ykv9g3m4.js} +141 -125
  320. package/chunk-ystjgb9e.js +544 -0
  321. package/chunk-yysxn7ep.js +12 -0
  322. package/{chunk-AL3TYDIF.js → chunk-z17eyawk.js} +18 -16
  323. package/{machineCommands-LHJMILRA.js → chunk-z17q416p.js} +442 -563
  324. package/chunk-z1n98pcf.js +12 -0
  325. package/{dialogTraceCommand-HWXGIGZX.js → chunk-z566jx5r.js} +292 -397
  326. package/chunk-zjxd6942.js +6 -0
  327. package/{versionChangeNotice-RFABJGJE.js → chunk-zk11x9y5.js} +7 -9
  328. package/{chunk-TEFD5E2D.js → chunk-zt73yc33.js} +48 -51
  329. package/chunk-zvs2fra1.js +5 -0
  330. package/{chunk-SVFFKLMR.js → chunk-zwee84rh.js} +117 -141
  331. package/chunk-zxgfqv72.js +8 -0
  332. package/index.js +53 -69
  333. package/package.json +4 -4
  334. package/_executeModel-B3ENLKM4.js +0 -341
  335. package/action-UK3HXGXF.js +0 -30
  336. package/addContentAction-CAKFVBDM.js +0 -38
  337. package/addDialogAgentAction-KLJ2YWWM.js +0 -77
  338. package/agentDeleteCommand-R4LKLXQR.js +0 -523
  339. package/agentEmailCommands-SUEXVAY4.js +0 -742
  340. package/agentRecordCommands-NE4OPX5K.js +0 -211
  341. package/agentRun-NSNLIOM7.js +0 -251
  342. package/agentRunCommand-T6QTKMCJ.js +0 -249
  343. package/agentRunControl-U2MV74WR.js +0 -211
  344. package/agentRuntimeLocal-P4MMGIR6.js +0 -189
  345. package/agentSlice-FZJZONCT.js +0 -52
  346. package/appConfigCommands-W4JQHMOJ.js +0 -417
  347. package/appDeleteCommands-IXR47IAV.js +0 -183
  348. package/appDeployCommands-LB6DHDF4.js +0 -232
  349. package/appDeployStatusCommands-UQ6MJL6D.js +0 -204
  350. package/appGetCommands-M5JCTDDQ.js +0 -185
  351. package/appListCommands-TE3ZHE3I.js +0 -186
  352. package/appMigrateCommands-FOXH6R4B.js +0 -230
  353. package/appSourceCommands-3ACYB6I7.js +0 -279
  354. package/authCommand-I5OBJP5S.js +0 -66
  355. package/authCommands-I6KCGOCN.js +0 -54
  356. package/builtinSkillRegistry-MIXYSZUU.js +0 -35
  357. package/chromeOpsCommands-IZRCYDSW.js +0 -579
  358. package/chunk-24BICQPB.js +0 -25
  359. package/chunk-2E4BYAUE.js +0 -69
  360. package/chunk-2O72G3U2.js +0 -17157
  361. package/chunk-2OROOEOQ.js +0 -229
  362. package/chunk-2R6M34JP.js +0 -27225
  363. package/chunk-2SXN7LAY.js +0 -15
  364. package/chunk-35JIFLIG.js +0 -30
  365. package/chunk-3VXVE2LF.js +0 -12
  366. package/chunk-4DBTBNTX.js +0 -477
  367. package/chunk-4JH2UMJR.js +0 -40
  368. package/chunk-4SN6J65J.js +0 -38
  369. package/chunk-4TDUT2LC.js +0 -441
  370. package/chunk-5MMAK75Q.js +0 -15
  371. package/chunk-6NYQHXMV.js +0 -1737
  372. package/chunk-6R4IY46J.js +0 -14
  373. package/chunk-7K4J76JQ.js +0 -917
  374. package/chunk-7LR2IFUH.js +0 -100
  375. package/chunk-AETZ7AD6.js +0 -274
  376. package/chunk-ATNTHIZI.js +0 -13
  377. package/chunk-BPB3T5EU.js +0 -791
  378. package/chunk-BV3FLP2L.js +0 -133
  379. package/chunk-BVYHE6QD.js +0 -110
  380. package/chunk-BWJLEN6X.js +0 -1388
  381. package/chunk-CHOZJMJS.js +0 -78
  382. package/chunk-CYS6HOJ2.js +0 -1710
  383. package/chunk-D2LTQAGN.js +0 -464
  384. package/chunk-DALXH7BG.js +0 -3392
  385. package/chunk-DKEOYC4L.js +0 -15210
  386. package/chunk-DLXL4NSL.js +0 -1179
  387. package/chunk-DSBRIUX5.js +0 -23
  388. package/chunk-DWLEOOGR.js +0 -8
  389. package/chunk-E2KZNP6C.js +0 -13
  390. package/chunk-E5JV4DCB.js +0 -272
  391. package/chunk-EUGTFFO6.js +0 -42
  392. package/chunk-FBNVJ2TO.js +0 -294
  393. package/chunk-FGXG6OLW.js +0 -34
  394. package/chunk-FRFFUKGH.js +0 -3085
  395. package/chunk-G22P2J7O.js +0 -1775
  396. package/chunk-G5KDYBTG.js +0 -432
  397. package/chunk-GBXRKW26.js +0 -613
  398. package/chunk-HEVRQGGH.js +0 -106
  399. package/chunk-HHXF57CL.js +0 -180
  400. package/chunk-HI5RS2O4.js +0 -2109
  401. package/chunk-HJTI7RZV.js +0 -94
  402. package/chunk-HRWRIPTB.js +0 -531
  403. package/chunk-HYCVEESH.js +0 -2824
  404. package/chunk-I42VC5KR.js +0 -15
  405. package/chunk-IB5AR52X.js +0 -15
  406. package/chunk-IIRJ4P4I.js +0 -24
  407. package/chunk-IT3ZZRJE.js +0 -12
  408. package/chunk-IV6VUVLJ.js +0 -88
  409. package/chunk-J42X32PV.js +0 -472
  410. package/chunk-JDMWYVUF.js +0 -449
  411. package/chunk-JKVOKKMQ.js +0 -53
  412. package/chunk-JRTNUU5Z.js +0 -54
  413. package/chunk-K7HLFORE.js +0 -226
  414. package/chunk-KGBASAB5.js +0 -74
  415. package/chunk-KGKTN2NX.js +0 -25
  416. package/chunk-KX6YBIHG.js +0 -8
  417. package/chunk-KYHNSSL2.js +0 -62
  418. package/chunk-KZO2MTVM.js +0 -140
  419. package/chunk-L2DHCG6C.js +0 -779
  420. package/chunk-LKZPX6YH.js +0 -0
  421. package/chunk-LLP2NDED.js +0 -201
  422. package/chunk-LOFRSJX2.js +0 -47
  423. package/chunk-M75RM77T.js +0 -3970
  424. package/chunk-MDAYRIP7.js +0 -1889
  425. package/chunk-MI6HRMCK.js +0 -25
  426. package/chunk-MTNQNLSE.js +0 -1029
  427. package/chunk-NH4PUEWK.js +0 -762
  428. package/chunk-NHLLXINQ.js +0 -8
  429. package/chunk-NTUNHTJV.js +0 -40
  430. package/chunk-OJKUU3LP.js +0 -67
  431. package/chunk-OQH3TAB7.js +0 -299
  432. package/chunk-P62DHV4F.js +0 -443
  433. package/chunk-PHIERFHT.js +0 -574
  434. package/chunk-PKDFU6MY.js +0 -102
  435. package/chunk-PL5RKESU.js +0 -40
  436. package/chunk-PSJJBBWV.js +0 -42
  437. package/chunk-QKM55LP2.js +0 -739
  438. package/chunk-QQ56R7KS.js +0 -88
  439. package/chunk-QYPE3TS3.js +0 -43
  440. package/chunk-REAE2SZK.js +0 -62
  441. package/chunk-RGQ4UUWZ.js +0 -208
  442. package/chunk-RIRFHJTW.js +0 -353
  443. package/chunk-RYMLMTPZ.js +0 -547
  444. package/chunk-SSGTV4FC.js +0 -303
  445. package/chunk-SVKWZ3EG.js +0 -607
  446. package/chunk-T7KODHYS.js +0 -317
  447. package/chunk-TZXPT53C.js +0 -8
  448. package/chunk-U67V476Y.js +0 -35
  449. package/chunk-UEILX4EV.js +0 -15
  450. package/chunk-VIWDGTDA.js +0 -8
  451. package/chunk-VXUQWCEZ.js +0 -138
  452. package/chunk-W5GKF5ZW.js +0 -32
  453. package/chunk-WDWZPASX.js +0 -29
  454. package/chunk-WX266G2C.js +0 -9594
  455. package/chunk-YCITCYSJ.js +0 -356
  456. package/chunk-Z3KTXWWB.js +0 -76
  457. package/chunk-ZC3CMUKU.js +0 -322
  458. package/chunk-ZV7ZY46L.js +0 -1343
  459. package/cliAgentConfigHelpers-WB2S7PDO.js +0 -47
  460. package/cliAuthorityBrokerClient-3SKOA7OZ.js +0 -23
  461. package/cliAuthorityBrokerProcess-BMBVXPKU.js +0 -24
  462. package/cliAuthorityStoreDriver-6FE3BJNB.js +0 -20
  463. package/cliEnvHelpers-7V5ZWUJA.js +0 -34
  464. package/cliExecutor-N3445G2Z.js +0 -45
  465. package/cliLocalAgentRecordReader-QKKRK53P.js +0 -113
  466. package/cloudAutomationCommands-S52NKCLL.js +0 -310
  467. package/contentThunks-RK6MJWBY.js +0 -100
  468. package/cooldownCommands-ZFDAL4MR.js +0 -79
  469. package/createAgentAutomationAction-KN7XLCU2.js +0 -173
  470. package/createDialogAction-KAG6DBVM.js +0 -87
  471. package/createPageAction-7XNPH76L.js +0 -91
  472. package/cursorProvider-2RACMEMF.js +0 -6123
  473. package/db-LTHLW7QA.js +0 -178
  474. package/dbSlice-WNUHTF4C.js +0 -76
  475. package/deleteDbKey-MUCJP6DK.js +0 -87
  476. package/desktopFolderProjects-4POAMVJN.js +0 -45
  477. package/dialogCommands-4MOLJW4G.js +0 -165
  478. package/dialogMessageRecord-2HJTEXQX.js +0 -7
  479. package/dialogNotifyCommand-YL2GFKLO.js +0 -45
  480. package/dialogSlice-BD6WOOD3.js +0 -200
  481. package/dialogUsageCommand-IO2BQKL2.js +0 -31
  482. package/docCreateCommands-OYLRBK2M.js +0 -255
  483. package/docDeleteCommands-3NF6QPJU.js +0 -226
  484. package/docReadCommands-CBAERJAP.js +0 -184
  485. package/docStore-RK4CD4QN.js +0 -89
  486. package/docUpdateCommands-BAMCGX6F.js +0 -326
  487. package/ebookDownloaderAgentCommand-NOIZ6U7Y.js +0 -675
  488. package/fetchMessages-P7FSCSXV.js +0 -19
  489. package/getPricing-KNXVEIUI.js +0 -40
  490. package/hostCredentialCreate-CPIWBALC.js +0 -402
  491. package/i18n-SAK6DDY4.js +0 -51
  492. package/keys-FXEGMKSG.js +0 -183
  493. package/legacyMigration-TF4SYJCZ.js +0 -19
  494. package/levelAuthorityStore-L5SVDM5O.js +0 -10
  495. package/localAutomationCommands-WPYIYTDP.js +0 -199
  496. package/localAutomationRuntime-M7WWU6WY.js +0 -61
  497. package/localRecall-BDYKXB46.js +0 -17
  498. package/localRuntimeAdapter-SNE2NUDN.js +0 -310
  499. package/localRuntimeAuthority-Q5C2KWGF.js +0 -45
  500. package/localRuntimeDb-MM3DINZM.js +0 -12
  501. package/machineInfo-HNPJHQFU.js +0 -14
  502. package/machineWsRunDispatch-VHEIHXWY.js +0 -228
  503. package/models-TOXYINNM.js +0 -10
  504. package/oauthTokenStore-RUYNYALS.js +0 -24
  505. package/overlay-JA3SPVUS.js +0 -15
  506. package/parityCommands-5OCBPVES.js +0 -613
  507. package/processSpawn-6GEO77KV.js +0 -11
  508. package/profileConfig-KOWK4HOG.js +0 -49
  509. package/projectArchive-HUET56SH.js +0 -132
  510. package/providerPresetApply-YCVSP2WX.js +0 -235
  511. package/providerRegistry-26PAUYH2.js +0 -24
  512. package/read-D4WYJQJQ.js +0 -32
  513. package/readDocTool-3S3OQFOH.js +0 -22
  514. package/rememberExplicit-ZPI6KK5M.js +0 -16
  515. package/remove-AHRMUDMH.js +0 -32
  516. package/removeDialogAgentAction-AALRBFSA.js +0 -81
  517. package/secretCommands-2PSS3QNZ.js +0 -24
  518. package/setDialogExtraReferencesAction-SLHQ3GYL.js +0 -39
  519. package/setPrimaryDialogAgentAction-XKCSGJ7M.js +0 -96
  520. package/skillDiscovery-IUEZZG2B.js +0 -29
  521. package/skillSummaryMarker-62UW7HI7.js +0 -9
  522. package/slateToRenderMarkdown-R3X74MCX.js +0 -7
  523. package/slateUtils-ESQAJ6RN.js +0 -19
  524. package/store-WSAVTR32.js +0 -50
  525. package/switchDialogAgentAction-YJIWQGIR.js +0 -70
  526. package/tombstones-FQQMEDOW.js +0 -32
  527. package/toolApiClient-FVXTIIEN.js +0 -42
  528. package/tools-KB6CJ2KT.js +0 -147
  529. package/tuiRestart-LU2BDLAW.js +0 -50
  530. package/tuiSummaryLlmCaller-Z2ZVBIGN.js +0 -53
  531. package/updateCommands-4QP7WJLA.js +0 -63
  532. package/usageCommand-AZX7D3LB.js +0 -31
  533. package/usageRebuildCommand-XV5QQCHK.js +0 -623
  534. package/userDataMerge-HT2ZVHBJ.js +0 -13
  535. package/windowsSelfUpdate-5OFKSW6Y.js +0 -14
  536. package/workContext-ZAW6VXT7.js +0 -18
  537. package/workContextAccess-VU5I4LKZ.js +0 -11
  538. package/workContextWriteNotice-YCSSMHN4.js +0 -7
  539. /package/{chunk-BYXBJQAS.js → chunk-0bcc25vg.js} +0 -0
@@ -1,108 +1,301 @@
1
1
  import {
2
- normalizeTimingMs
3
- } from "./chunk-H57T64RA.js";
4
- import {
5
- sha256Hex
6
- } from "./chunk-6R4IY46J.js";
2
+ isPlatformManagedProvider,
3
+ PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL,
4
+ resolvePlatformEffectiveModel,
5
+ platformHostedModels
6
+ } from "./chunk-fkrgqq8w.js";
7
7
  import {
8
- isAbortError
9
- } from "./chunk-7DPNBQSV.js";
8
+ openrouterModels,
9
+ cloudflareModels,
10
+ gmiModels,
11
+ zaiModels,
12
+ MODEL_LOOKUP_MAP
13
+ } from "./chunk-kawvydbk.js";
10
14
  import {
11
15
  estimateTokenCount
12
- } from "./chunk-PSCNXBYA.js";
16
+ } from "./chunk-t6q69p83.js";
13
17
  import {
14
- MODEL_LOOKUP_MAP
15
- } from "./chunk-RI7SXDJW.js";
18
+ normalizeTimingMs
19
+ } from "./chunk-996j61av.js";
16
20
  import {
17
- ALL_MODELS
18
- } from "./chunk-DSBRIUX5.js";
21
+ sha256Hex2
22
+ } from "./chunk-kn5p91n8.js";
19
23
  import {
20
- PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL,
21
- isPlatformManagedProvider,
22
- resolvePlatformEffectiveModel
23
- } from "./chunk-G22P2J7O.js";
24
+ isAbortError
25
+ } from "./chunk-a7bz6nc3.js";
24
26
  import {
25
27
  asTrimmedLowercaseString
26
- } from "./chunk-QSJ3HFEF.js";
27
- import {
28
- asTrimmedNonEmptyStringArray
29
- } from "./chunk-I42VC5KR.js";
28
+ } from "./chunk-h1hzmqph.js";
30
29
  import {
31
30
  asOptionalFiniteNumber
32
- } from "./chunk-WWC7I6TA.js";
31
+ } from "./chunk-q3cx89sw.js";
32
+ import {
33
+ asTrimmedNonEmptyStringArray
34
+ } from "./chunk-w5b74aq6.js";
33
35
  import {
34
36
  asOptionalTrimmedString
35
- } from "./chunk-G3SUCT4W.js";
37
+ } from "./chunk-p1vg4bx8.js";
36
38
 
37
- // packages/agent-runtime/serverProxyPolicy.ts
38
- var OAUTH_APIKEY_REFS = /* @__PURE__ */ new Set([
39
- "xai",
40
- "chatgpt",
41
- "cursor"
42
- ]);
43
- function isGoogleFamilyProvider(provider) {
44
- const normalized = asTrimmedLowercaseString(provider);
45
- return normalized === "google" || normalized.startsWith("google-");
46
- }
47
- function isOAuthApiKeyRef(value) {
48
- const ref = asTrimmedLowercaseString(value);
49
- return ref.length > 0 && OAUTH_APIKEY_REFS.has(ref);
39
+ // packages/ai/llm/models.ts
40
+ var withProvider = (provider) => (models) => models.map((model) => ({ ...model, provider }));
41
+ var ALL_MODELS3 = [
42
+ ...withProvider("nolo")(platformHostedModels),
43
+ ...withProvider("openrouter")(openrouterModels),
44
+ ...withProvider("cloudflare")(cloudflareModels),
45
+ ...withProvider("gmi")(gmiModels),
46
+ ...withProvider("zai")(zaiModels)
47
+ ];
48
+
49
+ // packages/ai/llm/getModelContextWindow.ts
50
+ var DEFAULT_CONTEXT_WINDOW = 256000;
51
+ var QWEN_3_6_CONTEXT_WINDOW = 262144;
52
+ var GLM_5_2_CONTEXT_WINDOW = 1e6;
53
+ var GPT_6_1_SOL_CONTEXT_WINDOW = 500000;
54
+ var GPT_6_1_SOL_PATTERN = /(^|\/)gpt-6\.1[- ]sol(?![a-z])/;
55
+ var GPT_6_1_PINNED_PATTERN = /(^|\/)gpt-(?:6\.1[- ](sol|terra)|6\.2[- ](sol|astra))(?![a-z0-9])/;
56
+ var GPT_272K_PINNED_PATTERN = /(^|\/)(gpt-6[- ](astra|luna|sol)|gpt-5\.6[- ](sol|terra|luna))(?![a-z0-9])/;
57
+ var GPT_272K_CONTEXT_WINDOW = 272000;
58
+ function channelPinnedContextWindow(normalizedName) {
59
+ if (GPT_6_1_PINNED_PATTERN.test(normalizedName))
60
+ return GPT_6_1_SOL_CONTEXT_WINDOW;
61
+ if (GPT_272K_PINNED_PATTERN.test(normalizedName))
62
+ return GPT_272K_CONTEXT_WINDOW;
63
+ return;
50
64
  }
51
- function shouldUseServerProxy(agentConfig, requestProvider) {
52
- const effectiveProvider = (requestProvider || agentConfig.provider || "").toLowerCase();
53
- if (isGoogleFamilyProvider(effectiveProvider)) {
54
- return true;
65
+ var ANTIGRAVITY_EFFORT_SUFFIXES = [
66
+ "-tiered",
67
+ "-extra-low",
68
+ "-low",
69
+ "-medium",
70
+ "-high"
71
+ ];
72
+ function stripEffortSuffix(model) {
73
+ for (const suffix of ANTIGRAVITY_EFFORT_SUFFIXES) {
74
+ if (model.endsWith(suffix) && model.length > suffix.length) {
75
+ return model.slice(0, -suffix.length);
76
+ }
55
77
  }
56
- if (isOAuthApiKeyRef(agentConfig.apiKeyRef)) {
57
- return true;
78
+ return model;
79
+ }
80
+ function stripPreviewSuffix(model) {
81
+ const suffix = "-preview";
82
+ if (model.endsWith(suffix) && model.length > suffix.length) {
83
+ return model.slice(0, -suffix.length);
58
84
  }
59
- if (agentConfig.apiSource === "custom" && isRemoteCustomEndpoint(agentConfig.customProviderUrl)) {
60
- return true;
85
+ return model;
86
+ }
87
+ function stripModelTag(model) {
88
+ const colonIndex = model.indexOf(":");
89
+ if (colonIndex > 0) {
90
+ return model.slice(0, colonIndex);
61
91
  }
62
- return !!agentConfig.useServerProxy;
92
+ return model;
63
93
  }
64
- var LOCAL_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "::1", "0.0.0.0"]);
65
- function isRemoteCustomEndpoint(url) {
66
- if (typeof url !== "string") return false;
67
- try {
68
- const host = new URL(url).hostname.toLowerCase().replace(/^\[|\]$/g, "");
69
- return !LOCAL_HOSTS.has(host);
70
- } catch {
71
- return false;
94
+ var fullModelMap = null;
95
+ var getFullModelMap = () => {
96
+ if (!fullModelMap) {
97
+ fullModelMap = new Map;
98
+ for (const [provider, models] of Object.entries(MODEL_LOOKUP_MAP)) {
99
+ for (const model of models) {
100
+ const entry = { ...model, provider };
101
+ fullModelMap.set(model.name, entry);
102
+ if (model.displayName) {
103
+ fullModelMap.set(model.displayName.toLowerCase(), entry);
104
+ }
105
+ }
106
+ }
72
107
  }
108
+ return fullModelMap;
109
+ };
110
+ var legacyModelMap = null;
111
+ var getLegacyModelMap = () => {
112
+ if (!legacyModelMap) {
113
+ legacyModelMap = new Map;
114
+ for (const model of ALL_MODELS3) {
115
+ legacyModelMap.set(model.name, model);
116
+ if (model.displayName) {
117
+ legacyModelMap.set(model.displayName.toLowerCase(), model);
118
+ }
119
+ }
120
+ }
121
+ return legacyModelMap;
122
+ };
123
+ function fuzzyContextWindow(normalizedName) {
124
+ const bareModelName = (normalizedName.includes("/") ? normalizedName.slice(normalizedName.lastIndexOf("/") + 1) : normalizedName).replace(/:.*$/, "");
125
+ if (normalizedName.includes("qwen-long") || normalizedName.includes("qwen3-long"))
126
+ return 10485760;
127
+ if (normalizedName.includes("qwen-coder") || normalizedName.includes("qwen3-coder"))
128
+ return 1048576;
129
+ if (normalizedName.includes("qwen3.8") || normalizedName.includes("qwen3p8"))
130
+ return 1e6;
131
+ if (normalizedName.includes("minimax-m3") || normalizedName.includes("minimax_m3"))
132
+ return 1e6;
133
+ if (bareModelName === "mimo-v2.6-pro" || normalizedName === "mimo v2.6 pro")
134
+ return 1048576;
135
+ if (normalizedName.includes("glm-5.3") || normalizedName.includes("glm5.3"))
136
+ return 1050000;
137
+ if (normalizedName.includes("glm-5.2") || normalizedName.includes("glm5.2"))
138
+ return GLM_5_2_CONTEXT_WINDOW;
139
+ if (normalizedName.includes("deepseek"))
140
+ return 1e6;
141
+ if (GPT_6_1_SOL_PATTERN.test(normalizedName))
142
+ return GPT_6_1_SOL_CONTEXT_WINDOW;
143
+ const channelPinned = channelPinnedContextWindow(normalizedName);
144
+ if (channelPinned !== undefined)
145
+ return channelPinned;
146
+ if (normalizedName.includes("gpt-5") || normalizedName.includes("gpt-4.1"))
147
+ return 1047576;
148
+ if (normalizedName.startsWith("cursor-grok-4.5"))
149
+ return 1e6;
150
+ if (normalizedName.includes("claude-4.6"))
151
+ return 1e6;
152
+ if (normalizedName.includes("gemini-3.1"))
153
+ return 1e6;
154
+ if (normalizedName.includes("gemini"))
155
+ return 1048576;
156
+ if (normalizedName.includes("qwen3.6") || normalizedName.includes("qwen3p6"))
157
+ return QWEN_3_6_CONTEXT_WINDOW;
158
+ if (normalizedName.includes("qwen3.7") || normalizedName.includes("qwen3p7"))
159
+ return 262144;
160
+ if (/minimax[-_ ]m2(?![\d.])/.test(normalizedName))
161
+ return 262144;
162
+ const MISTRAL_LARGE_4 = /mistral[-_ ]large[-_ ]4/;
163
+ const large4 = MISTRAL_LARGE_4.exec(normalizedName);
164
+ if (large4) {
165
+ const rest = normalizedName.slice(large4.index + large4[0].length);
166
+ if (rest === "" || /^[-:_@/\s]/.test(rest))
167
+ return 524288;
168
+ }
169
+ if (normalizedName.includes("mistral-vibe-cli") || normalizedName.includes("mistral-medium-3.5") || normalizedName.includes("mistral-medium-3-5") || normalizedName.includes("mistral-medium-latest") || normalizedName.includes("mistral-medium-2604") || normalizedName.includes("mistral-large-latest") || normalizedName.includes("mistral-large-2512") || normalizedName.includes("mistral-small-latest") || normalizedName.includes("mistral-small-2603") || normalizedName.includes("magistral-medium-latest") || normalizedName.includes("magistral-small-latest") || normalizedName.includes("mistral vibe cli") || normalizedName.includes("mistral medium 3.5") || normalizedName.includes("mistral large (latest)")) {
170
+ return 262144;
171
+ }
172
+ if (bareModelName === "mistral-medium" || bareModelName === "mistral-medium-3")
173
+ return 262144;
174
+ if (normalizedName.includes("mistral-embed") || normalizedName.includes("codestral-embed"))
175
+ return 8192;
176
+ if (normalizedName.includes("mistral-ocr"))
177
+ return 16384;
178
+ if (normalizedName.includes("mistral-moderation"))
179
+ return 131072;
180
+ if (normalizedName.includes("codestral") || normalizedName.includes("mistral-code"))
181
+ return 256000;
182
+ if (normalizedName.includes("claude"))
183
+ return 200000;
184
+ if (normalizedName.includes("llama3.1") || normalizedName.includes("llama-3.1") || normalizedName.includes("llama3.2") || normalizedName.includes("llama-3.2") || normalizedName.includes("llama3.3") || normalizedName.includes("llama-3.3") || normalizedName.includes("qwen2.5") || normalizedName.includes("qwen-2.5") || normalizedName.includes("mistral-nemo") || normalizedName.includes("phi3.5") || normalizedName.includes("phi-3.5") || normalizedName.includes("phi4") || normalizedName.includes("phi-4")) {
185
+ return 131072;
186
+ }
187
+ if (normalizedName.includes("qwen2") || normalizedName.includes("qwen-2") || normalizedName.includes("mistral") || normalizedName.includes("mixtral")) {
188
+ return 32768;
189
+ }
190
+ if (normalizedName.includes("codellama") || normalizedName.includes("starcoder") || normalizedName.includes("phi3") || normalizedName.includes("phi-3")) {
191
+ return 16384;
192
+ }
193
+ if (normalizedName.includes("llama3") || normalizedName.includes("llama-3") || normalizedName.includes("gemma2") || normalizedName.includes("gemma-2") || normalizedName.includes("gemma")) {
194
+ return 8192;
195
+ }
196
+ if (/(^|[^a-z])llama/.test(normalizedName)) {
197
+ return 4096;
198
+ }
199
+ return;
73
200
  }
74
-
75
- // packages/core/chat/messageContentSerialize.ts
76
- var serializeMessageContent = (content, imagePlaceholder = "[\u56FE\u7247]") => {
77
- if (typeof content === "string") {
78
- return content.trim() || null;
201
+ var findCodexOAuthPinnedContextWindow = (modelName, provider) => {
202
+ if (!modelName)
203
+ return;
204
+ if (isPlatformManagedProvider(provider, modelName))
205
+ return;
206
+ return channelPinnedContextWindow(modelName.toLowerCase());
207
+ };
208
+ var findModelContextWindow = (modelName, provider) => findModelContextWindowImpl(modelName, provider, false);
209
+ var findModelContextWindowImpl = (modelName, provider, allowHyphenRetry) => {
210
+ if (!modelName)
211
+ return;
212
+ const onPlatformChannel = isPlatformManagedProvider(provider, modelName);
213
+ const aliasKey = modelName.trim().toLowerCase().replace(/\s+/g, "-");
214
+ const aliasedName = resolvePlatformEffectiveModel(aliasKey);
215
+ const effectiveName = onPlatformChannel && aliasedName && aliasedName !== aliasKey ? aliasedName : modelName;
216
+ const normalizedName = effectiveName.toLowerCase();
217
+ const map = getFullModelMap();
218
+ const rawCandidates = [effectiveName, normalizedName];
219
+ const strippedTag = stripModelTag(modelName);
220
+ if (strippedTag !== modelName) {
221
+ rawCandidates.push(strippedTag, strippedTag.toLowerCase());
79
222
  }
80
- if (Array.isArray(content)) {
81
- const fragments = [];
82
- for (const part of content) {
83
- if (!part || typeof part !== "object") continue;
84
- if (part.type === "text" && typeof part.text === "string") {
85
- const text = part.text.trim();
86
- if (text) fragments.push(text);
87
- } else if (part.type === "image_url") {
88
- fragments.push(imagePlaceholder);
223
+ const candidates = [];
224
+ for (const base of rawCandidates) {
225
+ candidates.push(base);
226
+ const strippedEffort = stripEffortSuffix(base);
227
+ if (strippedEffort !== base) {
228
+ candidates.push(strippedEffort, strippedEffort.toLowerCase());
229
+ }
230
+ const strippedPreview = stripPreviewSuffix(base);
231
+ if (strippedPreview !== base) {
232
+ candidates.push(strippedPreview, strippedPreview.toLowerCase());
233
+ }
234
+ if (strippedEffort !== base) {
235
+ const strippedBoth = stripPreviewSuffix(strippedEffort);
236
+ if (strippedBoth !== strippedEffort) {
237
+ candidates.push(strippedBoth, strippedBoth.toLowerCase());
89
238
  }
90
239
  }
91
- const joined = fragments.join("\n").trim();
92
- return joined || null;
93
240
  }
94
- return null;
241
+ for (const candidate of candidates) {
242
+ const model = map.get(candidate);
243
+ if (model?.contextWindow) {
244
+ if (!onPlatformChannel && (channelPinnedContextWindow(model.name.toLowerCase()) !== undefined || channelPinnedContextWindow(candidate.toLowerCase()) !== undefined)) {
245
+ continue;
246
+ }
247
+ return typeof model.contextWindow === "number" ? model.contextWindow : undefined;
248
+ }
249
+ }
250
+ if (onPlatformChannel) {
251
+ const effective = resolvePlatformEffectiveModel(normalizedName);
252
+ if (effective && effective !== normalizedName) {
253
+ const aliased = map.get(effective);
254
+ if (aliased?.contextWindow) {
255
+ return typeof aliased.contextWindow === "number" ? aliased.contextWindow : undefined;
256
+ }
257
+ }
258
+ }
259
+ if (!onPlatformChannel) {
260
+ for (const candidate of candidates) {
261
+ const pinned = channelPinnedContextWindow(candidate.toLowerCase());
262
+ if (pinned !== undefined)
263
+ return pinned;
264
+ }
265
+ }
266
+ const fuzzy = fuzzyContextWindow(normalizedName);
267
+ if (fuzzy !== undefined)
268
+ return fuzzy;
269
+ if (!allowHyphenRetry) {
270
+ const canonical = normalizeSeparators(modelName);
271
+ if (canonical.toLowerCase() !== normalizedName) {
272
+ return findModelContextWindowImpl(canonical, provider, true);
273
+ }
274
+ }
275
+ return;
276
+ };
277
+ function normalizeSeparators(raw) {
278
+ return raw.replace(/\s+/g, "-").replace(/(?<=[a-z0-9])_(?=[a-z0-9])/g, "-");
279
+ }
280
+ var getModelContextWindow = (modelName, provider) => findModelContextWindow(modelName, provider) ?? DEFAULT_CONTEXT_WINDOW;
281
+ var getModelInfo = (modelName) => {
282
+ if (!modelName)
283
+ return null;
284
+ const map = getLegacyModelMap();
285
+ return map.get(modelName) || map.get(modelName.toLowerCase()) || null;
95
286
  };
96
287
 
97
288
  // packages/ai/token/cacheTokenFields.ts
98
289
  var finiteTokenCount = (value) => {
99
- if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
290
+ if (typeof value !== "number" || !Number.isFinite(value))
291
+ return;
100
292
  return Math.max(0, Math.floor(value));
101
293
  };
102
294
  var readNested = (value, path) => {
103
295
  let cursor = value;
104
296
  for (const key of path) {
105
- if (!cursor || typeof cursor !== "object") return void 0;
297
+ if (!cursor || typeof cursor !== "object")
298
+ return;
106
299
  cursor = cursor[key];
107
300
  }
108
301
  return finiteTokenCount(cursor);
@@ -110,12 +303,14 @@ var readNested = (value, path) => {
110
303
  var firstPositive = (usage, readers) => {
111
304
  for (const read of readers) {
112
305
  const value = read(usage);
113
- if (value !== void 0 && value !== 0) return value;
306
+ if (value !== undefined && value !== 0)
307
+ return value;
114
308
  }
115
309
  return 0;
116
310
  };
117
311
  var topLevel = (field) => (usage) => {
118
- if (!usage || typeof usage !== "object") return void 0;
312
+ if (!usage || typeof usage !== "object")
313
+ return;
119
314
  return finiteTokenCount(usage[field]);
120
315
  };
121
316
  var nested = (path) => (usage) => readNested(usage, path);
@@ -123,9 +318,11 @@ var firstPresentAsNumber = (usage, readers) => {
123
318
  let sawField = false;
124
319
  for (const read of readers) {
125
320
  const value = read(usage);
126
- if (value === void 0) continue;
321
+ if (value === undefined)
322
+ continue;
127
323
  sawField = true;
128
- if (value !== 0) return value;
324
+ if (value !== 0)
325
+ return value;
129
326
  }
130
327
  return sawField ? 0 : null;
131
328
  };
@@ -146,23 +343,28 @@ var readCacheCreationInputTokens = (usage) => firstPositive(usage, CACHE_CREATIO
146
343
 
147
344
  // packages/ai/token/normalizeUsage.ts
148
345
  var normalizeStringArray = (value) => {
149
- if (!Array.isArray(value)) return void 0;
346
+ if (!Array.isArray(value))
347
+ return;
150
348
  const normalized = [...new Set(asTrimmedNonEmptyStringArray(value))];
151
- return normalized.length > 0 ? normalized : void 0;
349
+ return normalized.length > 0 ? normalized : undefined;
152
350
  };
153
351
  var finiteTokenCount2 = (value) => {
154
352
  const finite = asOptionalFiniteNumber(value);
155
- if (finite === void 0) return void 0;
353
+ if (finite === undefined)
354
+ return;
156
355
  return Math.max(0, Math.floor(finite));
157
356
  };
158
357
  var readFiniteNumberField = (usage, field) => {
159
- if (!usage || typeof usage !== "object") return void 0;
160
- if (!(field in usage)) return void 0;
358
+ if (!usage || typeof usage !== "object")
359
+ return;
360
+ if (!(field in usage))
361
+ return;
161
362
  const candidate = usage[field];
162
363
  return asOptionalFiniteNumber(candidate);
163
364
  };
164
365
  var readOptionalOutputTokens = (usage) => {
165
- if (!usage || typeof usage !== "object") return void 0;
366
+ if (!usage || typeof usage !== "object")
367
+ return;
166
368
  const field = "output_tokens" in usage && usage.output_tokens != null ? "output_tokens" : "completion_tokens";
167
369
  return readFiniteNumberField(usage, field);
168
370
  };
@@ -178,18 +380,18 @@ var normalizeUsage = (usage) => {
178
380
  cost: 0
179
381
  };
180
382
  }
181
- const inputTokens = "input_tokens" in usage ? usage.input_tokens ?? 0 : "prompt_tokens" in usage ? usage.prompt_tokens : 0;
182
- const outputTokens = "output_tokens" in usage ? usage.output_tokens ?? 0 : "completion_tokens" in usage ? usage.completion_tokens : 0;
383
+ const inputTokens = "input_tokens" in usage ? usage.input_tokens ?? 0 : ("prompt_tokens" in usage) ? usage.prompt_tokens : 0;
384
+ const outputTokens = "output_tokens" in usage ? usage.output_tokens ?? 0 : ("completion_tokens" in usage) ? usage.completion_tokens : 0;
183
385
  const cacheCreationInputTokens = readCacheCreationInputTokens(usage);
184
386
  const cacheReadInputTokens = readCacheReadInputTokens(usage);
185
387
  let cost = 0;
186
388
  const providedCost = readFiniteNumberField(usage, "cost");
187
- if (providedCost !== void 0) {
389
+ if (providedCost !== undefined) {
188
390
  cost = providedCost;
189
391
  }
190
392
  const xaiTicks = readCostInUsdTicks(usage);
191
- if (xaiTicks !== void 0 && providedCost === void 0) {
192
- cost = xaiTicks / 1e10;
393
+ if (xaiTicks !== undefined && providedCost === undefined) {
394
+ cost = xaiTicks / 10000000000;
193
395
  }
194
396
  const billingProvider = asOptionalTrimmedString(usage.billing_provider);
195
397
  const billingModel = asOptionalTrimmedString(usage.billing_model);
@@ -197,19 +399,11 @@ var normalizeUsage = (usage) => {
197
399
  const billingEstimated = "billing_estimated" in usage && usage.billing_estimated === true;
198
400
  const serverBilled = "server_billed" in usage && usage.server_billed === true;
199
401
  const providerCallId = asOptionalTrimmedString(usage.provider_call_id);
200
- const imageGenerationCount = "image_generation_count" in usage ? asOptionalFiniteNumber(usage.image_generation_count) : void 0;
201
- const providerResponseIds = normalizeStringArray(
202
- usage.provider_response_ids
203
- );
204
- const providerRequestIds = normalizeStringArray(
205
- usage.provider_request_ids
206
- );
207
- const firstOutputMs = normalizeTimingMs(
208
- readFiniteNumberField(usage, "firstOutputMs") ?? readFiniteNumberField(usage, "firstTokenMs")
209
- );
210
- const callDurationMs = normalizeTimingMs(
211
- readFiniteNumberField(usage, "callDurationMs") ?? readFiniteNumberField(usage, "durationMs")
212
- );
402
+ const imageGenerationCount = "image_generation_count" in usage ? asOptionalFiniteNumber(usage.image_generation_count) : undefined;
403
+ const providerResponseIds = normalizeStringArray(usage.provider_response_ids);
404
+ const providerRequestIds = normalizeStringArray(usage.provider_request_ids);
405
+ const firstOutputMs = normalizeTimingMs(readFiniteNumberField(usage, "firstOutputMs") ?? readFiniteNumberField(usage, "firstTokenMs"));
406
+ const callDurationMs = normalizeTimingMs(readFiniteNumberField(usage, "callDurationMs") ?? readFiniteNumberField(usage, "durationMs"));
213
407
  return {
214
408
  input_tokens: inputTokens,
215
409
  output_tokens: outputTokens,
@@ -226,184 +420,109 @@ var normalizeUsage = (usage) => {
226
420
  ...billingEstimated ? { billing_estimated: true } : {},
227
421
  ...serverBilled ? { server_billed: true } : {},
228
422
  ...providerCallId ? { provider_call_id: providerCallId } : {},
229
- ...xaiTicks !== void 0 ? { cost_in_usd_ticks: xaiTicks } : {},
230
- ...firstOutputMs !== void 0 ? { firstOutputMs } : {},
231
- ...callDurationMs !== void 0 ? { callDurationMs } : {}
423
+ ...xaiTicks !== undefined ? { cost_in_usd_ticks: xaiTicks } : {},
424
+ ...firstOutputMs !== undefined ? { firstOutputMs } : {},
425
+ ...callDurationMs !== undefined ? { callDurationMs } : {}
232
426
  };
233
427
  };
234
428
 
235
- // packages/ai/context/summaryContract.ts
236
- var SUMMARY_TOTAL_BUDGET_MS = { automatic: 6e4, manual: 12e4 };
237
- var realClock = {
238
- now: Date.now,
239
- setTimeout: (callback, ms) => setTimeout(callback, ms),
240
- clearTimeout: (handle) => clearTimeout(handle)
241
- };
242
- function createSummaryBudget(options) {
243
- const clock = options.clock ?? realClock;
244
- if (options.deadlineMs !== void 0 && !Number.isFinite(options.deadlineMs)) {
245
- throw new RangeError("Summary deadline must be finite");
246
- }
247
- const deadlineMs = Math.min(clock.now() + SUMMARY_TOTAL_BUDGET_MS[options.mode], options.deadlineMs ?? Infinity);
248
- const controller = new AbortController();
249
- const cancel = () => controller.abort(new DOMException("Summary cancelled", "AbortError"));
250
- const expire = () => controller.abort(new DOMException("Summary deadline exceeded", "TimeoutError"));
251
- const remainingMs = () => Math.max(0, deadlineMs - clock.now());
252
- let disposed = false;
253
- let active = 0;
254
- const check = () => {
255
- if (disposed) cancel();
256
- if (!controller.signal.aborted && remainingMs() === 0) expire();
257
- if (controller.signal.aborted) throw controller.signal.reason;
258
- };
259
- let timer;
260
- const cleanup = () => {
261
- if (timer !== void 0) clock.clearTimeout(timer);
262
- options.signal?.removeEventListener("abort", cancel);
263
- };
264
- controller.signal.addEventListener("abort", cleanup, { once: true });
265
- options.signal?.addEventListener("abort", cancel, { once: true });
266
- if (options.signal?.aborted) cancel();
267
- else if (remainingMs() === 0) expire();
268
- else timer = clock.setTimeout(expire, remainingMs());
269
- const budget = {
270
- deadlineMs,
271
- signal: controller.signal,
272
- remainingMs,
273
- child: (maxMs) => createSummaryBudget({
274
- ...options,
275
- clock,
276
- signal: controller.signal,
277
- deadlineMs: Math.min(deadlineMs, clock.now() + maxMs)
278
- }),
279
- async run(operation) {
280
- check();
281
- active++;
282
- let onAbort;
283
- const stopped = new Promise((_, reject) => {
284
- onAbort = () => reject(controller.signal.reason);
285
- controller.signal.addEventListener("abort", onAbort, { once: true });
286
- });
287
- try {
288
- const value = await Promise.race([Promise.resolve().then(() => {
289
- check();
290
- return operation({ deadlineMs, signal: controller.signal });
291
- }), stopped]);
292
- check();
293
- return value;
294
- } finally {
295
- active--;
296
- if (onAbort) controller.signal.removeEventListener("abort", onAbort);
297
- }
298
- },
299
- dispose() {
300
- disposed = true;
301
- if (active) cancel();
302
- cleanup();
303
- }
304
- };
305
- return budget;
306
- }
307
- function record(value) {
308
- return value !== null && typeof value === "object" ? value : {};
429
+ // packages/agent-runtime/serverProxyPolicy.ts
430
+ var OAUTH_APIKEY_REFS = new Set([
431
+ "xai",
432
+ "chatgpt",
433
+ "cursor"
434
+ ]);
435
+ function isGoogleFamilyProvider(provider) {
436
+ const normalized = asTrimmedLowercaseString(provider);
437
+ return normalized === "google" || normalized.startsWith("google-");
309
438
  }
310
- function identifier(value) {
311
- return typeof value === "string" && value.length <= 128 && /^[a-zA-Z0-9][a-zA-Z0-9._:/-]*$/.test(value) && !/https?:|^bearer|^sk-|^vault-cred|^nolo_cred/i.test(value) ? value : void 0;
439
+ function isOAuthApiKeyRef(value) {
440
+ const ref = asTrimmedLowercaseString(value);
441
+ return ref.length > 0 && OAUTH_APIKEY_REFS.has(ref);
312
442
  }
313
- function classifySummaryError(error, context = {}) {
314
- const top = record(error);
315
- const nested2 = record(top.error);
316
- const rawStatus = top.status ?? top.statusCode ?? nested2.status;
317
- const status = typeof rawStatus === "number" && Number.isInteger(rawStatus) && rawStatus >= 100 && rawStatus <= 599 ? rawStatus : void 0;
318
- const code = identifier(top.code ?? nested2.code);
319
- const errorType = identifier(top.type ?? nested2.type);
320
- const balanceSource = errorType === "insufficient_balance_error" || top.balanceSource === "upstream" ? "upstream" : code === "INSUFFICIENT_BALANCE" ? "platform-user" : void 0;
321
- const category = top.name === "TimeoutError" || code === "ETIMEDOUT" || code === "DEADLINE_EXCEEDED" ? "timeout" : isAbortError(error) ? "cancelled" : status !== void 0 ? "http" : code ? "provider" : "unknown";
322
- return {
323
- category,
324
- message: `Summary ${category} failure`,
325
- ...status === void 0 ? {} : { status },
326
- ...code === void 0 ? {} : { code },
327
- ...errorType === void 0 ? {} : { errorType },
328
- ...balanceSource === void 0 ? {} : { balanceSource },
329
- model: identifier(top.model) ?? identifier(context.model),
330
- provider: identifier(top.provider) ?? identifier(context.provider),
331
- attemptId: identifier(top.attemptId) ?? identifier(context.attemptId),
332
- stage: identifier(top.stage) ?? identifier(context.stage) ?? "attempt",
333
- ...Object.fromEntries(["finishReason", "responseStatus", "incompleteReason"].flatMap((key) => {
334
- const value = identifier(top[key]);
335
- return value === void 0 ? [] : [[key, value]];
336
- })),
337
- ...Object.fromEntries(["maxOutputTokens", "completionTokens", "outputChars"].flatMap((key) => typeof top[key] === "number" && Number.isSafeInteger(top[key]) && top[key] >= 0 ? [[key, top[key]]] : []))
338
- };
443
+ function shouldUseServerProxy(agentConfig, requestProvider) {
444
+ const effectiveProvider = (requestProvider || agentConfig.provider || "").toLowerCase();
445
+ if (isGoogleFamilyProvider(effectiveProvider)) {
446
+ return true;
447
+ }
448
+ if (isOAuthApiKeyRef(agentConfig.apiKeyRef)) {
449
+ return true;
450
+ }
451
+ if (agentConfig.apiSource === "custom" && isRemoteCustomEndpoint(agentConfig.customProviderUrl)) {
452
+ return true;
453
+ }
454
+ return !!agentConfig.useServerProxy;
339
455
  }
340
- function isTruncatedCompletion(completion) {
341
- return completion.truncated === true || completion.finishReason === "length" || completion.finishReason === "max_tokens" || completion.responseStatus === "incomplete" || completion.incompleteReason !== void 0;
456
+ var LOCAL_HOSTS = new Set(["127.0.0.1", "localhost", "::1", "0.0.0.0"]);
457
+ function isRemoteCustomEndpoint(url) {
458
+ if (typeof url !== "string")
459
+ return false;
460
+ try {
461
+ const host = new URL(url).hostname.toLowerCase().replace(/^\[|\]$/g, "");
462
+ return !LOCAL_HOSTS.has(host);
463
+ } catch {
464
+ return false;
465
+ }
342
466
  }
343
- function summaryCompletionTokens(usage) {
344
- const tokens = readOptionalOutputTokens(usage);
345
- return typeof tokens === "number" && Number.isSafeInteger(tokens) && tokens >= 0 ? tokens : void 0;
467
+
468
+ // packages/core/compactWhitespace.ts
469
+ function compactWhitespace(value) {
470
+ return value.replace(/\s+/g, " ").trim();
346
471
  }
347
472
 
348
- // packages/ai/context/summaryRouting.ts
349
- function selectSummaryRoute(input) {
350
- return input.authenticated && input.platformAvailable && !!input.userId && input.userId !== "local" && input.userId !== "guest" && typeof input.credits === "number" && Number.isFinite(input.credits) && input.credits > 0 ? { kind: "platform", model: PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL } : { kind: "current" };
473
+ // packages/core/clipCompactText.ts
474
+ function clipCompactText(value, max, ellipsis = "...") {
475
+ const compact = compactWhitespace(value);
476
+ if (compact.length <= max)
477
+ return compact;
478
+ if (max <= ellipsis.length)
479
+ return compact.slice(0, max);
480
+ return `${compact.slice(0, max - ellipsis.length)}${ellipsis}`;
351
481
  }
352
- async function runSummaryWithContract(args) {
353
- const attempts = [];
354
- const execute = async (route, budget = args.budget) => {
355
- const attempt = args[route];
356
- try {
357
- const completion = await budget.run((context) => attempt.run(context));
358
- if (typeof completion?.text !== "string") {
359
- throw { code: "INVALID_SUMMARY_COMPLETION", stage: "decode" };
482
+
483
+ // packages/core/chat/messageContentSerialize.ts
484
+ var serializeMessageContent = (content, imagePlaceholder = "[图片]") => {
485
+ if (typeof content === "string") {
486
+ return content.trim() || null;
487
+ }
488
+ if (Array.isArray(content)) {
489
+ const fragments = [];
490
+ for (const part of content) {
491
+ if (!part || typeof part !== "object")
492
+ continue;
493
+ if (part.type === "text" && typeof part.text === "string") {
494
+ const text = part.text.trim();
495
+ if (text)
496
+ fragments.push(text);
497
+ } else if (part.type === "image_url") {
498
+ fragments.push(imagePlaceholder);
360
499
  }
361
- const text = completion.text.trim();
362
- const kind = isTruncatedCompletion(completion) ? "truncated" : text ? "success" : "empty";
363
- attempts.push({ route, outcome: kind });
364
- if (kind === "empty") return { kind, route, attempts, completion };
365
- return { kind, text, route, attempts, completion };
366
- } catch (cause) {
367
- const error = classifySummaryError(args.budget.signal.aborted ? args.budget.signal.reason : cause, attempt);
368
- const kind = error.category === "cancelled" ? "cancelled" : "error";
369
- attempts.push({ route, outcome: kind, error });
370
- return { kind, error, route, attempts };
371
- }
372
- };
373
- if (selectSummaryRoute(args.eligibility).kind === "platform") {
374
- const primary = args.budget.child(Math.min(25e3, Math.floor(args.budget.remainingMs() / 2)));
375
- try {
376
- const result = await execute("platform", primary);
377
- if (result.kind === "success" || result.kind === "cancelled" || args.budget.signal.aborted) return result;
378
- } finally {
379
- primary.dispose();
380
500
  }
501
+ const joined = fragments.join(`
502
+ `).trim();
503
+ return joined || null;
381
504
  }
382
- return execute("current");
383
- }
505
+ return null;
506
+ };
384
507
 
385
508
  // packages/ai/context/toolOutputCap.ts
386
509
  var TOOL_OUTPUT_CAP_WINDOW_RATIO = 0.12;
387
- var TOOL_OUTPUT_CAP_MIN_TOKENS = 4e3;
388
- var TOOL_OUTPUT_CAP_MAX_TOKENS = 5e4;
510
+ var TOOL_OUTPUT_CAP_MIN_TOKENS = 4000;
511
+ var TOOL_OUTPUT_CAP_MAX_TOKENS = 50000;
389
512
  var COMPRESSION_TRIGGER_RATIO_MAX = 0.9;
390
513
  var clamp = (v, min, max) => Math.min(max, Math.max(min, v));
391
- var capToolOutputTokens = (contextWindow) => clamp(
392
- Math.floor(contextWindow * TOOL_OUTPUT_CAP_WINDOW_RATIO),
393
- TOOL_OUTPUT_CAP_MIN_TOKENS,
394
- TOOL_OUTPUT_CAP_MAX_TOKENS
395
- );
514
+ var capToolOutputTokens = (contextWindow) => clamp(Math.floor(contextWindow * TOOL_OUTPUT_CAP_WINDOW_RATIO), TOOL_OUTPUT_CAP_MIN_TOKENS, TOOL_OUTPUT_CAP_MAX_TOKENS);
396
515
  var resolveCompressionTriggerRatio = (_contextWindow) => COMPRESSION_TRIGGER_RATIO_MAX;
397
516
  var truncateToolOutputForContext = (text, contextWindow) => {
398
- if (!text) return text;
517
+ if (!text)
518
+ return text;
399
519
  const capTokens = capToolOutputTokens(contextWindow);
400
- if (estimateTokenCount(text) <= capTokens) return text;
520
+ if (estimateTokenCount(text) <= capTokens)
521
+ return text;
401
522
  const build = (keepChars) => {
402
523
  const headChars = Math.floor(keepChars * 0.6);
403
524
  const tailChars = keepChars - headChars;
404
- const omittedTokens = estimateTokenCount(
405
- text.slice(headChars, text.length - tailChars)
406
- );
525
+ const omittedTokens = estimateTokenCount(text.slice(headChars, text.length - tailChars));
407
526
  return text.slice(0, headChars) + `
408
527
  ...[tool output truncated: ~${omittedTokens} tokens omitted]...
409
528
  ` + text.slice(text.length - tailChars);
@@ -412,8 +531,10 @@ var truncateToolOutputForContext = (text, contextWindow) => {
412
531
  let hi = text.length;
413
532
  while (lo < hi) {
414
533
  const mid = Math.ceil((lo + hi) / 2);
415
- if (estimateTokenCount(build(mid)) <= capTokens) lo = mid;
416
- else hi = mid - 1;
534
+ if (estimateTokenCount(build(mid)) <= capTokens)
535
+ lo = mid;
536
+ else
537
+ hi = mid - 1;
417
538
  }
418
539
  return build(lo);
419
540
  };
@@ -423,7 +544,7 @@ var MIN_COMPRESS_COUNT = 5;
423
544
  var INPUT_ITEM_TRIGGER_RATIO = 0.9;
424
545
  var INPUT_ITEM_RETENTION_RATIO = 0.6;
425
546
  var ACTIVE_SUMMARY_TAIL_KEEP_COUNT = 2;
426
- var RECENT_ORIGINAL_TOKEN_BUDGET = 2e4;
547
+ var RECENT_ORIGINAL_TOKEN_BUDGET = 20000;
427
548
  var MIN_TRIGGER_PENDING_COUNT = MIN_COMPRESS_COUNT + ACTIVE_SUMMARY_TAIL_KEEP_COUNT;
428
549
  var getMessageTokenCount = (msg) => {
429
550
  const content = serializeMessageContent(msg.content) || "";
@@ -431,12 +552,11 @@ var getMessageTokenCount = (msg) => {
431
552
  if (Array.isArray(msg.tool_calls)) {
432
553
  for (const call of msg.tool_calls) {
433
554
  const fn = call?.function;
434
- if (fn?.name) tokens += estimateTokenCount(fn.name);
555
+ if (fn?.name)
556
+ tokens += estimateTokenCount(fn.name);
435
557
  const args = fn?.arguments;
436
558
  if (args) {
437
- tokens += estimateTokenCount(
438
- typeof args === "string" ? args : JSON.stringify(args)
439
- );
559
+ tokens += estimateTokenCount(typeof args === "string" ? args : JSON.stringify(args));
440
560
  }
441
561
  }
442
562
  }
@@ -444,16 +564,17 @@ var getMessageTokenCount = (msg) => {
444
564
  };
445
565
  var hasOpenEndedToolCall = (msg) => !!msg && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0;
446
566
  var normalizeContextUsageRatio = (value) => {
447
- if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
567
+ if (typeof value !== "number" || !Number.isFinite(value))
568
+ return;
448
569
  const ratio = value > 1 ? value / 100 : value;
449
- return ratio >= 0 && ratio <= 1 ? ratio : void 0;
570
+ return ratio >= 0 && ratio <= 1 ? ratio : undefined;
450
571
  };
451
572
  var emptyPlan = (startIndex, diagnostics) => ({
452
573
  shouldCompress: false,
453
574
  compressCount: 0,
454
575
  msgsToCompress: [],
455
576
  msgsToKeep: [],
456
- newSummarizedBeforeId: void 0,
577
+ newSummarizedBeforeId: undefined,
457
578
  startIndex,
458
579
  ...diagnostics ? { diagnostics } : {}
459
580
  });
@@ -461,7 +582,8 @@ function findPendingMessages(allMsgs, summarizedBeforeId) {
461
582
  let startIndex = 0;
462
583
  if (summarizedBeforeId) {
463
584
  const found = allMsgs.findIndex((m) => m.id === summarizedBeforeId);
464
- if (found !== -1) startIndex = found + 1;
585
+ if (found !== -1)
586
+ startIndex = found + 1;
465
587
  }
466
588
  return { pendingMsgs: allMsgs.slice(startIndex), startIndex };
467
589
  }
@@ -475,8 +597,8 @@ function shouldTriggerCompaction(args) {
475
597
  realContextUsagePercent
476
598
  } = args;
477
599
  const usageRatio = normalizeContextUsageRatio(realContextUsagePercent);
478
- const triggeredByRealUsage = usageRatio !== void 0 && usageRatio >= triggerRatio;
479
- const triggeredByEstimate = usageRatio === void 0 && totalUsed >= historyBudget;
600
+ const triggeredByRealUsage = usageRatio !== undefined && usageRatio >= triggerRatio;
601
+ const triggeredByEstimate = usageRatio === undefined && totalUsed >= historyBudget;
480
602
  const shouldRunActiveSummary = force && (reason === "manual" || reason === "budget_rescue");
481
603
  const triggeredByColdResume = false;
482
604
  return {
@@ -489,32 +611,27 @@ function shouldTriggerCompaction(args) {
489
611
  function calculateCompressCount(pendingMsgs, rawMessageBudget) {
490
612
  let tokensToKeep = 0;
491
613
  let keepCount = 0;
492
- for (let i = pendingMsgs.length - 1; i >= 0; i--) {
614
+ for (let i = pendingMsgs.length - 1;i >= 0; i--) {
493
615
  const t = getMessageTokenCount(pendingMsgs[i]);
494
- if (tokensToKeep + t > rawMessageBudget) break;
616
+ if (tokensToKeep + t > rawMessageBudget)
617
+ break;
495
618
  tokensToKeep += t;
496
619
  keepCount++;
497
620
  }
498
621
  return pendingMsgs.length - keepCount;
499
622
  }
500
623
  function resolveEffectiveCompactionBudgets(args) {
501
- const effectiveHistoryBudget = Math.max(0, Math.min(
502
- Math.floor(args.contextWindow),
503
- Math.floor(args.historyBudget)
504
- ));
624
+ const effectiveHistoryBudget = Math.max(0, Math.min(Math.floor(args.contextWindow), Math.floor(args.historyBudget)));
505
625
  const newSummaryTokenReserve = args.newSummaryTokenReserve ?? Math.min(8192, Math.max(1, Math.floor(args.contextWindow / 4)));
506
626
  return {
507
627
  effectiveHistoryBudget,
508
- effectiveRawMessageBudget: Math.max(0, Math.min(
509
- RECENT_ORIGINAL_TOKEN_BUDGET,
510
- effectiveHistoryBudget - Math.max(0, newSummaryTokenReserve)
511
- ))
628
+ effectiveRawMessageBudget: Math.max(0, Math.min(RECENT_ORIGINAL_TOKEN_BUDGET, effectiveHistoryBudget - Math.max(0, newSummaryTokenReserve)))
512
629
  };
513
630
  }
514
631
  function guardToolChainBoundary(pendingMsgs, compressCount, preserveByProjection) {
515
632
  let safeLimit = Math.max(0, pendingMsgs.length - 1);
516
633
  if (!preserveByProjection) {
517
- for (let i = pendingMsgs.length - 1; i >= 0; i--) {
634
+ for (let i = pendingMsgs.length - 1;i >= 0; i--) {
518
635
  if (pendingMsgs[i].role === "user") {
519
636
  safeLimit = i;
520
637
  break;
@@ -561,16 +678,16 @@ function planCompression(input) {
561
678
  const pendingTokens = pendingMsgs.reduce((sum, msg) => sum + getMessageTokenCount(msg), 0);
562
679
  let coveredUserTokens = 0;
563
680
  if (preserveLatestUserByProjection && summary && startIndex > 0) {
564
- for (let i = startIndex - 1; i >= 0; i--) {
681
+ for (let i = startIndex - 1;i >= 0; i--) {
565
682
  if (allMsgs[i].role === "user") {
566
683
  coveredUserTokens = getMessageTokenCount(allMsgs[i]);
567
684
  break;
568
685
  }
569
686
  }
570
687
  }
571
- const maxInputItems = typeof input.maxInputItems === "number" && Number.isFinite(input.maxInputItems) && input.maxInputItems > 0 ? input.maxInputItems : void 0;
688
+ const maxInputItems = typeof input.maxInputItems === "number" && Number.isFinite(input.maxInputItems) && input.maxInputItems > 0 ? input.maxInputItems : undefined;
572
689
  const itemCount = pendingMsgs.length + (summary ? 1 : 0) + 1 + (coveredUserTokens > 0 ? 1 : 0);
573
- const triggeredByItemLimit = maxInputItems !== void 0 && itemCount >= maxInputItems * INPUT_ITEM_TRIGGER_RATIO;
690
+ const triggeredByItemLimit = maxInputItems !== undefined && itemCount >= maxInputItems * INPUT_ITEM_TRIGGER_RATIO;
574
691
  const totalUsed = summaryTokens + coveredUserTokens + pendingTokens;
575
692
  const triggerRatio = resolveCompressionTriggerRatio(contextWindow);
576
693
  const historyBudget = Math.floor(contextWindow * triggerRatio);
@@ -590,13 +707,13 @@ function planCompression(input) {
590
707
  });
591
708
  const diagnostics = {
592
709
  pendingMsgCount: pendingMsgs.length,
593
- ...maxInputItems !== void 0 ? { itemCount, maxInputItems, triggeredByItemLimit } : {},
710
+ ...maxInputItems !== undefined ? { itemCount, maxInputItems, triggeredByItemLimit } : {},
594
711
  totalUsed,
595
712
  historyBudget,
596
713
  triggerRatio,
597
714
  realUsageRatio: normalizeContextUsageRatio(realContextUsagePercent),
598
715
  triggeredByRealUsage,
599
- triggeredByEstimate: normalizeContextUsageRatio(realContextUsagePercent) === void 0 && totalUsed >= historyBudget,
716
+ triggeredByEstimate: normalizeContextUsageRatio(realContextUsagePercent) === undefined && totalUsed >= historyBudget,
600
717
  triggeredByColdResume,
601
718
  shouldRunActiveSummary
602
719
  };
@@ -614,128 +731,291 @@ function planCompression(input) {
614
731
  summaryTokens,
615
732
  newSummaryTokenReserve: input.newSummaryTokenReserve
616
733
  });
617
- const minimumPrefixTokens = Math.min(1e3, Math.floor(contextWindow * 0.1));
734
+ const minimumPrefixTokens = Math.min(1000, Math.floor(contextWindow * 0.1));
618
735
  const tailBudget = triggeredByItemLimit ? effectiveRawMessageBudget : Math.min(effectiveRawMessageBudget, Math.max(0, pendingTokens - minimumPrefixTokens));
619
- const itemCompressCount = maxInputItems !== void 0 ? calculateItemCompressCount(pendingMsgs, maxInputItems, preserveLatestUserByProjection) : 0;
736
+ const itemCompressCount = maxInputItems !== undefined ? calculateItemCompressCount(pendingMsgs, maxInputItems, preserveLatestUserByProjection) : 0;
620
737
  const guardedCut = (tokenCompressCount) => {
621
738
  let candidate = Math.max(tokenCompressCount, itemCompressCount);
622
739
  let guarded = guardToolChainBoundary(pendingMsgs, candidate, preserveLatestUserByProjection);
623
740
  while (guarded < itemCompressCount && candidate < pendingMsgs.length - 1) {
624
741
  candidate++;
625
742
  const next = guardToolChainBoundary(pendingMsgs, candidate, preserveLatestUserByProjection);
626
- if (next === guarded && pendingMsgs[next]?.role === "user" && !preserveLatestUserByProjection) break;
743
+ if (next === guarded && pendingMsgs[next]?.role === "user" && !preserveLatestUserByProjection)
744
+ break;
627
745
  guarded = next;
628
746
  }
629
747
  return guarded;
630
748
  };
631
- let compressCount = guardedCut(calculateCompressCount(pendingMsgs, tailBudget));
632
- if (preserveLatestUserByProjection) {
633
- let latestUser = -1;
634
- for (let i = pendingMsgs.length - 1; i >= 0; i--) {
635
- if (pendingMsgs[i].role === "user") {
636
- latestUser = i;
637
- break;
749
+ let compressCount = guardedCut(calculateCompressCount(pendingMsgs, tailBudget));
750
+ if (preserveLatestUserByProjection) {
751
+ let latestUser = -1;
752
+ for (let i = pendingMsgs.length - 1;i >= 0; i--) {
753
+ if (pendingMsgs[i].role === "user") {
754
+ latestUser = i;
755
+ break;
756
+ }
757
+ }
758
+ const preservedTokens = latestUser >= 0 && latestUser < compressCount ? getMessageTokenCount(pendingMsgs[latestUser]) : latestUser < 0 ? coveredUserTokens : 0;
759
+ if (preservedTokens > 0) {
760
+ compressCount = guardedCut(calculateCompressCount(pendingMsgs, Math.max(0, tailBudget - preservedTokens)));
761
+ }
762
+ }
763
+ if (compressCount === 0) {
764
+ return emptyPlan(startIndex, { ...diagnostics, compressCount, emptyReason: "no-safe-prefix" });
765
+ }
766
+ const allowSmallPrefix = reason !== "task_completed" && (shouldRunActiveSummary || triggeredByRealUsage || diagnostics.triggeredByEstimate);
767
+ const compressibleTokens = pendingMsgs.slice(0, compressCount).reduce((sum, msg) => sum + getMessageTokenCount(msg), 0);
768
+ if (compressCount < MIN_COMPRESS_COUNT && !(allowSmallPrefix && compressibleTokens >= 1000)) {
769
+ return emptyPlan(startIndex, {
770
+ ...diagnostics,
771
+ compressCount,
772
+ emptyReason: "below-min-compress-count"
773
+ });
774
+ }
775
+ const msgsToCompress = pendingMsgs.slice(0, compressCount);
776
+ const msgsToKeep = pendingMsgs.slice(compressCount);
777
+ const newSummarizedBeforeId = msgsToCompress[msgsToCompress.length - 1].id;
778
+ return {
779
+ shouldCompress: true,
780
+ compressCount,
781
+ msgsToCompress,
782
+ msgsToKeep,
783
+ newSummarizedBeforeId,
784
+ startIndex,
785
+ diagnostics: {
786
+ ...diagnostics,
787
+ compressCount,
788
+ recentOriginalTokenBudget: tailBudget,
789
+ retainedTailOverBudget: msgsToKeep.reduce((sum, msg) => sum + getMessageTokenCount(msg), 0) > tailBudget
790
+ }
791
+ };
792
+ }
793
+
794
+ // packages/ai/context/summaryContract.ts
795
+ var SUMMARY_TOTAL_BUDGET_MS = { automatic: 60000, manual: 120000 };
796
+ var realClock = {
797
+ now: Date.now,
798
+ setTimeout: (callback, ms) => setTimeout(callback, ms),
799
+ clearTimeout: (handle) => clearTimeout(handle)
800
+ };
801
+ function createSummaryBudget(options) {
802
+ const clock = options.clock ?? realClock;
803
+ if (options.deadlineMs !== undefined && !Number.isFinite(options.deadlineMs)) {
804
+ throw new RangeError("Summary deadline must be finite");
805
+ }
806
+ const deadlineMs = Math.min(clock.now() + SUMMARY_TOTAL_BUDGET_MS[options.mode], options.deadlineMs ?? Infinity);
807
+ const controller = new AbortController;
808
+ const cancel = () => controller.abort(new DOMException("Summary cancelled", "AbortError"));
809
+ const expire = () => controller.abort(new DOMException("Summary deadline exceeded", "TimeoutError"));
810
+ const remainingMs = () => Math.max(0, deadlineMs - clock.now());
811
+ let disposed = false;
812
+ let active = 0;
813
+ const check = () => {
814
+ if (disposed)
815
+ cancel();
816
+ if (!controller.signal.aborted && remainingMs() === 0)
817
+ expire();
818
+ if (controller.signal.aborted)
819
+ throw controller.signal.reason;
820
+ };
821
+ let timer;
822
+ const cleanup = () => {
823
+ if (timer !== undefined)
824
+ clock.clearTimeout(timer);
825
+ options.signal?.removeEventListener("abort", cancel);
826
+ };
827
+ controller.signal.addEventListener("abort", cleanup, { once: true });
828
+ options.signal?.addEventListener("abort", cancel, { once: true });
829
+ if (options.signal?.aborted)
830
+ cancel();
831
+ else if (remainingMs() === 0)
832
+ expire();
833
+ else
834
+ timer = clock.setTimeout(expire, remainingMs());
835
+ const budget = {
836
+ deadlineMs,
837
+ signal: controller.signal,
838
+ remainingMs,
839
+ child: (maxMs) => createSummaryBudget({
840
+ ...options,
841
+ clock,
842
+ signal: controller.signal,
843
+ deadlineMs: Math.min(deadlineMs, clock.now() + maxMs)
844
+ }),
845
+ async run(operation) {
846
+ check();
847
+ active++;
848
+ let onAbort;
849
+ const stopped = new Promise((_, reject) => {
850
+ onAbort = () => reject(controller.signal.reason);
851
+ controller.signal.addEventListener("abort", onAbort, { once: true });
852
+ });
853
+ try {
854
+ const value = await Promise.race([Promise.resolve().then(() => {
855
+ check();
856
+ return operation({ deadlineMs, signal: controller.signal });
857
+ }), stopped]);
858
+ check();
859
+ return value;
860
+ } finally {
861
+ active--;
862
+ if (onAbort)
863
+ controller.signal.removeEventListener("abort", onAbort);
864
+ }
865
+ },
866
+ dispose() {
867
+ disposed = true;
868
+ if (active)
869
+ cancel();
870
+ cleanup();
871
+ }
872
+ };
873
+ return budget;
874
+ }
875
+ function record(value) {
876
+ return value !== null && typeof value === "object" ? value : {};
877
+ }
878
+ function identifier(value) {
879
+ return typeof value === "string" && value.length <= 128 && /^[a-zA-Z0-9][a-zA-Z0-9._:/-]*$/.test(value) && !/https?:|^bearer|^sk-|^vault-cred|^nolo_cred/i.test(value) ? value : undefined;
880
+ }
881
+ function classifySummaryError(error, context = {}) {
882
+ const top = record(error);
883
+ const nested = record(top.error);
884
+ const rawStatus = top.status ?? top.statusCode ?? nested.status;
885
+ const status = typeof rawStatus === "number" && Number.isInteger(rawStatus) && rawStatus >= 100 && rawStatus <= 599 ? rawStatus : undefined;
886
+ const code = identifier(top.code ?? nested.code);
887
+ const errorType = identifier(top.type ?? nested.type);
888
+ const balanceSource = errorType === "insufficient_balance_error" || top.balanceSource === "upstream" ? "upstream" : code === "INSUFFICIENT_BALANCE" ? "platform-user" : undefined;
889
+ const category = top.name === "TimeoutError" || code === "ETIMEDOUT" || code === "DEADLINE_EXCEEDED" ? "timeout" : isAbortError(error) ? "cancelled" : status !== undefined ? "http" : code ? "provider" : "unknown";
890
+ return {
891
+ category,
892
+ message: `Summary ${category} failure`,
893
+ ...status === undefined ? {} : { status },
894
+ ...code === undefined ? {} : { code },
895
+ ...errorType === undefined ? {} : { errorType },
896
+ ...balanceSource === undefined ? {} : { balanceSource },
897
+ model: identifier(top.model) ?? identifier(context.model),
898
+ provider: identifier(top.provider) ?? identifier(context.provider),
899
+ attemptId: identifier(top.attemptId) ?? identifier(context.attemptId),
900
+ stage: identifier(top.stage) ?? identifier(context.stage) ?? "attempt",
901
+ ...Object.fromEntries(["finishReason", "responseStatus", "incompleteReason"].flatMap((key) => {
902
+ const value = identifier(top[key]);
903
+ return value === undefined ? [] : [[key, value]];
904
+ })),
905
+ ...Object.fromEntries(["maxOutputTokens", "completionTokens", "outputChars"].flatMap((key) => typeof top[key] === "number" && Number.isSafeInteger(top[key]) && top[key] >= 0 ? [[key, top[key]]] : []))
906
+ };
907
+ }
908
+ function isTruncatedCompletion(completion) {
909
+ return completion.truncated === true || completion.finishReason === "length" || completion.finishReason === "max_tokens" || completion.responseStatus === "incomplete" || completion.incompleteReason !== undefined;
910
+ }
911
+ function summaryCompletionTokens(usage) {
912
+ const tokens = readOptionalOutputTokens(usage);
913
+ return typeof tokens === "number" && Number.isSafeInteger(tokens) && tokens >= 0 ? tokens : undefined;
914
+ }
915
+ // packages/ai/context/summaryRouting.ts
916
+ function selectSummaryRoute(input) {
917
+ return input.authenticated && input.platformAvailable && !!input.userId && input.userId !== "local" && input.userId !== "guest" && typeof input.credits === "number" && Number.isFinite(input.credits) && input.credits > 0 ? { kind: "platform", model: PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL } : { kind: "current" };
918
+ }
919
+ async function runSummaryWithContract(args) {
920
+ const attempts = [];
921
+ const execute = async (route, budget = args.budget) => {
922
+ const attempt = args[route];
923
+ try {
924
+ const completion = await budget.run((context) => attempt.run(context));
925
+ if (typeof completion?.text !== "string") {
926
+ throw { code: "INVALID_SUMMARY_COMPLETION", stage: "decode" };
638
927
  }
928
+ const text = completion.text.trim();
929
+ const kind = isTruncatedCompletion(completion) ? "truncated" : text ? "success" : "empty";
930
+ attempts.push({ route, outcome: kind });
931
+ if (kind === "empty")
932
+ return { kind, route, attempts, completion };
933
+ return { kind, text, route, attempts, completion };
934
+ } catch (cause) {
935
+ const error = classifySummaryError(args.budget.signal.aborted ? args.budget.signal.reason : cause, attempt);
936
+ const kind = error.category === "cancelled" ? "cancelled" : "error";
937
+ attempts.push({ route, outcome: kind, error });
938
+ return { kind, error, route, attempts };
639
939
  }
640
- const preservedTokens = latestUser >= 0 && latestUser < compressCount ? getMessageTokenCount(pendingMsgs[latestUser]) : latestUser < 0 ? coveredUserTokens : 0;
641
- if (preservedTokens > 0) {
642
- compressCount = guardedCut(
643
- calculateCompressCount(pendingMsgs, Math.max(0, tailBudget - preservedTokens))
644
- );
940
+ };
941
+ if (selectSummaryRoute(args.eligibility).kind === "platform") {
942
+ const primary = args.budget.child(Math.min(25000, Math.floor(args.budget.remainingMs() / 2)));
943
+ try {
944
+ const result = await execute("platform", primary);
945
+ if (result.kind === "success" || result.kind === "cancelled" || args.budget.signal.aborted)
946
+ return result;
947
+ } finally {
948
+ primary.dispose();
645
949
  }
646
950
  }
647
- if (compressCount === 0) {
648
- return emptyPlan(startIndex, { ...diagnostics, compressCount, emptyReason: "no-safe-prefix" });
649
- }
650
- const allowSmallPrefix = reason !== "task_completed" && (shouldRunActiveSummary || triggeredByRealUsage || diagnostics.triggeredByEstimate);
651
- const compressibleTokens = pendingMsgs.slice(0, compressCount).reduce((sum, msg) => sum + getMessageTokenCount(msg), 0);
652
- if (compressCount < MIN_COMPRESS_COUNT && !(allowSmallPrefix && compressibleTokens >= 1e3)) {
653
- return emptyPlan(startIndex, {
654
- ...diagnostics,
655
- compressCount,
656
- emptyReason: "below-min-compress-count"
657
- });
658
- }
659
- const msgsToCompress = pendingMsgs.slice(0, compressCount);
660
- const msgsToKeep = pendingMsgs.slice(compressCount);
661
- const newSummarizedBeforeId = msgsToCompress[msgsToCompress.length - 1].id;
662
- return {
663
- shouldCompress: true,
664
- compressCount,
665
- msgsToCompress,
666
- msgsToKeep,
667
- newSummarizedBeforeId,
668
- startIndex,
669
- diagnostics: {
670
- ...diagnostics,
671
- compressCount,
672
- recentOriginalTokenBudget: tailBudget,
673
- retainedTailOverBudget: msgsToKeep.reduce((sum, msg) => sum + getMessageTokenCount(msg), 0) > tailBudget
674
- }
675
- };
951
+ return execute("current");
676
952
  }
677
953
 
678
954
  // packages/ai/context/compactionShared.ts
679
955
  var COMPACTION_SUMMARY_SCHEMA_VERSION = 2;
680
- var COMPACTION_SUMMARY_SYSTEM_PROMPT = `\u4F60\u662F\u5BF9\u8BDD\u4E0A\u4E0B\u6587\u538B\u7F29\u5668\u3002\u6839\u636E\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\u548C\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF0C\u8F93\u51FA\u53EF\u66FF\u4EE3\u539F\u59CB\u6D88\u606F\u7684\u4E8B\u5B9E\u6027\u8981\u70B9\uFF0C\u4F9B\u540E\u7EED\u5BF9\u8BDD\u76F4\u63A5\u4F7F\u7528\u3002
956
+ var COMPACTION_SUMMARY_SYSTEM_PROMPT = `你是对话上下文压缩器。根据【现有记忆】和【新增对话】,输出可替代原始消息的事实性要点,供后续对话直接使用。
681
957
 
682
- \u4E25\u683C\u53EA\u8F93\u51FA\u4E0B\u9762\u4E09\u90E8\u5206\uFF0C\u6807\u9898\u5FC5\u987B\u5B8C\u5168\u4E00\u81F4\uFF1A
683
- \u5173\u952E\u4E8B\u5B9E\u6863\u6848
958
+ 严格只输出下面三部分,标题必须完全一致:
959
+ 关键事实档案
684
960
  - ...
685
- \u5BF9\u8BDD\u8FDB\u5C55\u4E0E\u5F85\u529E
961
+ 对话进展与待办
686
962
  - ...
687
- \u6587\u4EF6\u64CD\u4F5C\u6E05\u5355
963
+ 文件操作清单
688
964
  - ...
689
965
 
690
- \u8981\u6C42\uFF1A
691
- 1) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u7528\u6237\u4E3B\u8981\u8BED\u8A00\uFF1B\u4E13\u6709\u540D\u8BCD\u3001\u6587\u4EF6\u8DEF\u5F84\u3001\u6807\u8BC6\u7B26\u3001\u547D\u4EE4\u4FDD\u7559\u539F\u6587\uFF0C\u4E0D\u8981\u7FFB\u8BD1\u6216\u8F6C\u8FF0\u3002
692
- 2) \u5173\u952E\u4E8B\u5B9E\u6863\u6848\u7684**\u524D\u4E24\u9879\u56FA\u5B9A\u662F**\uFF1A
693
- - \u300C\u539F\u59CB\u76EE\u6807\u300D\uFF1A\u8FD9\u6BB5\u5BF9\u8BDD**\u6700\u521D**\u7684\u610F\u56FE\u4E0E\u539F\u8BDD\uFF08\u5C3D\u91CF\u4FDD\u7559\u4ED6\u7684\u539F\u8BDD\u4E0E\u7528\u8BCD\uFF0C\u4E0D\u8981\u6539\u5199\u6210\u4EFB\u52A1\u6E05\u5355\uFF09\u3002
694
- "\u6700\u521D"\u6307\u5F00\u5BF9\u8BDD\u90A3\u4E00\u523B\u2014\u2014\u4E0D\u5F97\u7528\u5BF9\u8BDD\u540E\u6765\u7684\u67D0\u53E5\u7528\u6237\u8BDD\uFF08\u5982\u4E34\u7761\u59D4\u6258\u3001\u4E2D\u671F\u8F6C\u8FF0\uFF09\u66FF\u4EE3\u6700\u521D\u76EE\u6807\uFF1B
695
- \u6700\u521D\u539F\u8BDD\u4E0D\u5728\u672C\u6B21\u538B\u7F29\u8303\u56F4\u5185\u65F6\uFF0C\u6309\u300C\u8F93\u5165\u672A\u8986\u76D6\u300D\u5199"\u8F93\u5165\u4E2D\u672A\u89C1"\uFF0C\u518D\u4F9D\u636E\u5BF9\u8BDD\u5185\u6700\u65E9\u53EF\u8003\u7684\u590D\u8FF0\u5E76\u6CE8\u660E\u3002
696
- \u589E\u91CF\u66F4\u65B0\u65F6\u6CBF\u7528\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\u91CC\u5DF2\u6709\u7684\u300C\u539F\u59CB\u76EE\u6807\u300D\uFF0C\u4E0D\u8981\u88AB\u65B0\u589E\u5BF9\u8BDD\u6539\u5199\u2014\u2014\u5B83\u662F\u7A33\u5B9A\u5B57\u6BB5\uFF1B
697
- \u4EC5\u5F53\u65B0\u5BF9\u8BDD\u660E\u786E\u8868\u660E\u539F\u6587\u6709\u4E8B\u5B9E\u6027\u9519\u8BEF\u65F6\u624D\u4FEE\u6B63\uFF0C\u5E76\u5728\u300C\u76EE\u6807\u6F14\u5316\u300D\u91CC\u6CE8\u660E\u3002
698
- - \u300C\u76EE\u6807\u6F14\u5316\u300D\uFF1A\u82E5\u4E2D\u9014\u8F6C\u5411\uFF0C\u5199\u6E05\u8F6C\u5411\u4E86\u4EC0\u4E48\u3001\u56E0\u4E3A\u4EC0\u4E48\uFF1B\u6CA1\u6709\u8F6C\u5411\u5C31\u5199\u300C\u65E0\u8F6C\u5411\u300D\u6216\u7701\u7565\u8FD9\u4E00\u9879\uFF0C\u4E0D\u8981\u786C\u51D1\u3002
699
- \u88AB\u540E\u7EED\u5DE5\u4F5C\u53D6\u4EE3\u7684\u662F"\u65B9\u6848"\uFF0C\u4E0D\u662F"\u7528\u6237\u7684\u521D\u59CB\u610F\u56FE"\u2014\u2014\u521D\u59CB\u610F\u56FE\u4E0D\u5F97\u7701\u7565\u3002
700
- \u5176\u540E\u624D\u662F\uFF1A\u7528\u6237\u504F\u597D\u3001\u7EA6\u675F\u3001\u6280\u672F\u6808\u3001\u786E\u5B9A\u7684\u6587\u4EF6\u8DEF\u5F84\u3001\u6838\u5FC3\u51B3\u7B56\u3001\u672A\u5B8C\u6210\u5F85\u529E\u3002\u4FDD\u7559\u786E\u5207\u503C\uFF08\u7AEF\u53E3\u53F7\u3001\u7248\u672C\u53F7\u3001\u8DEF\u5F84\u3001\u53D8\u91CF\u540D\u3001\u9519\u8BEF\u4FE1\u606F\u539F\u6587\uFF09\uFF0C\u4E0D\u8981\u6982\u62EC\u6210"\u67D0\u4E2A\u7AEF\u53E3"\u6216"\u67D0\u4E2A\u6587\u4EF6"\u6216"\u67D0\u62A5\u9519"\u3002
701
- \u5173\u952E\u4E8B\u5B9E\u6863\u6848\u8FD8\u5FC5\u987B\u5305\u542B\u4EE5\u4E0B\u4E09\u9879\uFF08\u53EF\u63A5\u5728\u56FA\u5B9A\u4E24\u9879\u4E4B\u540E\uFF0C\u7F3A\u4FE1\u606F\u65F6\u5982\u5B9E\u5199\u660E\uFF0C\u4E0D\u5F97\u7701\u7565\uFF09\uFF1A
702
- - \u300C\u5DF2\u8BC1\u4F2A\u7684\u5047\u8BBE\u300D\uFF1A\u88AB\u8BC1\u636E\u5426\u51B3\u6216\u51B3\u5B9A\u4E0D\u91C7\u7528\u7684\u7ED3\u8BBA\u5355\u5217\uFF0C\u6CE8\u660E"\u5DF2\u8BC1\u4F2A/\u4E0D\u91C7\u7528"\u53CA\u4F9D\u636E\uFF0C\u9632\u6B62\u7EED\u4F5C\u628A\u5B83\u5F53\u4E8B\u5B9E\u91CD\u542F\u3002
703
- - \u300C\u5361\u70B9\u4E0E\u9700\u7528\u6237\u51B3\u5B9A\u300D\uFF1A\u963B\u585E\u9879\u5361\u5728\u54EA\u3001\u9700\u8981\u7528\u6237\u63D0\u4F9B\u4EC0\u4E48\uFF08\u6388\u6743 / \u51ED\u636E / \u51B3\u5B9A\uFF09\uFF0C\u5199\u6E05\u695A\uFF0C\u4E0D\u5F97\u542B\u7CCA\u3002
704
- - \u300C\u8F93\u5165\u672A\u8986\u76D6\u300D\uFF1A\u538B\u7F29\u8303\u56F4\u5185\u67E5\u4E0D\u5230\u7684\u5173\u952E\u4FE1\u606F\uFF08\u5982\u521D\u59CB\u539F\u8BDD\u3001\u6307\u5B9A id\uFF09\uFF0C\u5FC5\u987B\u5199"\u8F93\u5165\u4E2D\u672A\u89C1"\uFF0C\u7981\u6B62\u8111\u8865\u3002
705
- 3) \u5BF9\u8BDD\u8FDB\u5C55\u4E0E\u5F85\u529E\u4EE5\u7B2C\u4E00\u4EBA\u79F0\u7EED\u4F5C\u7B14\u8BB0\u7684\u53E3\u543B\u5199\uFF08"\u6211\u505A\u4E86\u2026""\u7528\u6237\u8981\u6C42\u2026""\u4E0B\u4E00\u6B65\u6211\u9700\u8981\u2026"\uFF09\uFF0C\u4E0D\u8981\u5199\u6210\u7B2C\u4E09\u65B9\u89C2\u5BDF\u62A5\u544A\u3002\u5148\u6781\u7B80\u6982\u62EC\u65E7\u4E0A\u4E0B\u6587\uFF0C\u518D\u66F4\u8BE6\u7EC6\u8BB0\u5F55\u6700\u8FD1\u8FDB\u5C55\u3001\u7ED3\u8BBA\u3001\u5206\u6B67\u4E0E\u4E0B\u4E00\u6B65\u3002\u5BF9\u4E8E\u58F0\u79F0\u5DF2\u5B8C\u6210\u4F46\u5C1A\u672A\u9A8C\u8BC1\u7684\u5DE5\u4F5C\uFF08\u5982\u5DE5\u5177\u8C03\u7528\u8FD4\u56DE\u6210\u529F\u4F46\u7ED3\u679C\u672A\u4EBA\u5DE5\u786E\u8BA4\uFF09\uFF0C\u660E\u786E\u6807\u6CE8"\uFF08\u5F85\u9A8C\u8BC1\uFF09"\u2014\u2014\u4E0D\u8981\u9ED8\u8BA4\u4FE1\u4EFB\u5DE5\u5177\u8FD4\u56DE\u503C\u3002
706
- 4) \u6587\u4EF6\u64CD\u4F5C\u6E05\u5355\uFF1A**\u4F18\u5148\u5217\u51FA\u5199\u5165\u3001\u7F16\u8F91\u8FC7\u7684\u6587\u4EF6\u8DEF\u5F84**\uFF1B\u8BFB\u53D6\u7C7B\u53EA\u4FDD\u7559\u5173\u952E\u771F\u503C/\u5165\u53E3\u8DEF\u5F84\uFF0C\u4EE5\u53CA\u540E\u7EED\u7EED\u4F5C\u4ECD\u9700\u5F15\u7528\u7684\u8DEF\u5F84\uFF0C\u96F6\u788E\u3001\u4E00\u6B21\u6027\u7684\u53EA\u8BFB\u63A2\u7D22\u8DEF\u5F84\u4E00\u5F8B\u7701\u7565\uFF08\u5982: - \u5199\u5165: path/to/file\uFF1B\u672A\u6D89\u53CA\u5219\u5199"\u65E0"\uFF09\u3002\u6709\u957F\u5EA6\u7EA6\u675F\u65F6\u5408\u5E76\u65E7\u64CD\u4F5C\uFF0C\u7701\u7565\u65E0\u5173\u8BFB\u53D6\u3002
707
- 5) \u5FFD\u7565\u5BD2\u6684\u3001\u91CD\u590D\u5C1D\u8BD5\u548C\u65E0\u4EF7\u503C\u5E9F\u8BDD\uFF1B**\u5DF2\u653E\u5F03\u7684\u65B9\u6848/\u5C1D\u8BD5**\u53EF\u4EE5\u7701\u7565\uFF0C\u4F46\u7528\u6237\u5F53\u521D\u7684\u610F\u56FE\u4E0E\u7406\u7531\u4E0D\u53EF\u7701\u7565\uFF08\u89C1\u7B2C 2 \u6761\uFF09\u3002
708
- 6) \u4E0D\u8981\u7F16\u9020\u672A\u51FA\u73B0\u7684\u4FE1\u606F\uFF1B\u4E0D\u8981\u5F00\u573A\u767D\u3001\u7ED3\u675F\u8BED\u3001markdown \u4EE3\u7801\u5757\u6216\u989D\u5916\u7AE0\u8282\uFF1B\u4E0D\u8981\u8C03\u7528\u4EFB\u4F55\u5DE5\u5177\u3002`;
966
+ 要求:
967
+ 1) 使用对话主语言;混合语言时优先用户主要语言;专有名词、文件路径、标识符、命令保留原文,不要翻译或转述。
968
+ 2) 关键事实档案的**前两项固定是**:
969
+ - 「原始目标」:这段对话**最初**的意图与原话(尽量保留他的原话与用词,不要改写成任务清单)。
970
+ "最初"指开对话那一刻——不得用对话后来的某句用户话(如临睡委托、中期转述)替代最初目标;
971
+ 最初原话不在本次压缩范围内时,按「输入未覆盖」写"输入中未见",再依据对话内最早可考的复述并注明。
972
+ 增量更新时沿用【现有记忆】里已有的「原始目标」,不要被新增对话改写——它是稳定字段;
973
+ 仅当新对话明确表明原文有事实性错误时才修正,并在「目标演化」里注明。
974
+ - 「目标演化」:若中途转向,写清转向了什么、因为什么;没有转向就写「无转向」或省略这一项,不要硬凑。
975
+ 被后续工作取代的是"方案",不是"用户的初始意图"——初始意图不得省略。
976
+ 其后才是:用户偏好、约束、技术栈、确定的文件路径、核心决策、未完成待办。保留确切值(端口号、版本号、路径、变量名、错误信息原文),不要概括成"某个端口"或"某个文件"或"某报错"。
977
+ 关键事实档案还必须包含以下三项(可接在固定两项之后,缺信息时如实写明,不得省略):
978
+ - 「已证伪的假设」:被证据否决或决定不采用的结论单列,注明"已证伪/不采用"及依据,防止续作把它当事实重启。
979
+ - 「卡点与需用户决定」:阻塞项卡在哪、需要用户提供什么(授权 / 凭据 / 决定),写清楚,不得含糊。
980
+ - 「输入未覆盖」:压缩范围内查不到的关键信息(如初始原话、指定 id),必须写"输入中未见",禁止脑补。
981
+ 3) 对话进展与待办以第一人称续作笔记的口吻写("我做了…""用户要求…""下一步我需要…"),不要写成第三方观察报告。先极简概括旧上下文,再更详细记录最近进展、结论、分歧与下一步。对于声称已完成但尚未验证的工作(如工具调用返回成功但结果未人工确认),明确标注"(待验证)"——不要默认信任工具返回值。
982
+ 4) 文件操作清单:**优先列出写入、编辑过的文件路径**;读取类只保留关键真值/入口路径,以及后续续作仍需引用的路径,零碎、一次性的只读探索路径一律省略(如: - 写入: path/to/file;未涉及则写"无")。有长度约束时合并旧操作,省略无关读取。
983
+ 5) 忽略寒暄、重复尝试和无价值废话;**已放弃的方案/尝试**可以省略,但用户当初的意图与理由不可省略(见第 2 条)。
984
+ 6) 不要编造未出现的信息;不要开场白、结束语、markdown 代码块或额外章节;不要调用任何工具。`;
709
985
  function formatMessageContentFallback(msg) {
710
986
  const content = serializeMessageContent(msg.content);
711
- if (content) return content;
987
+ if (content)
988
+ return content;
712
989
  if (Array.isArray(msg.tool_calls)) {
713
990
  return `[tool_calls:${msg.tool_calls.map((c) => c.function?.name).filter(Boolean).join(",")}]`;
714
991
  }
715
- return "[\u975E\u6587\u672C\u5185\u5BB9]";
992
+ return "[非文本内容]";
716
993
  }
717
994
  function buildCompactionUserContent(args) {
718
995
  const parts = [];
719
- if (args.outputTokenBudget !== void 0) {
996
+ if (args.outputTokenBudget !== undefined) {
720
997
  const budget = args.outputTokenBudget;
721
- if (!Number.isFinite(budget) || budget < 1) throw new RangeError("Invalid summary output budget");
998
+ if (!Number.isFinite(budget) || budget < 1)
999
+ throw new RangeError("Invalid summary output budget");
722
1000
  const limit = Math.floor(budget);
723
- const target = Math.max(1, Math.min(2e3, Math.floor(limit / 2)));
1001
+ const target = Math.max(1, Math.min(2000, Math.floor(limit / 2)));
724
1002
  parts.push(`Summary target: ${target} tokens; hard output limit: ${limit} tokens. Complete 3 sections; merge old progress/files.`);
725
1003
  }
726
- parts.push(`\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\uFF1A
727
- ${args.previousSummary || "(\u65E0)"}`);
728
- if (args.fileOpsText !== void 0) {
729
- parts.push(`\u3010\u6587\u4EF6\u64CD\u4F5C\u6E05\u5355\u3011\uFF1A
730
- ${args.fileOpsText || "\u65E0"}`);
1004
+ parts.push(`【现有记忆】:
1005
+ ${args.previousSummary || "(无)"}`);
1006
+ if (args.fileOpsText !== undefined) {
1007
+ parts.push(`【文件操作清单】:
1008
+ ${args.fileOpsText || "无"}`);
731
1009
  }
732
- parts.push(`\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF1A
1010
+ parts.push(`【新增对话】:
733
1011
  ${args.messagesText}`);
734
- return parts.join("\n\n").trim();
1012
+ return parts.join(`
1013
+
1014
+ `).trim();
735
1015
  }
736
1016
  function extractFileOperationsFromCalls(calls, resolveCanonicalName) {
737
1017
  const result = [];
738
- const seen = /* @__PURE__ */ new Set();
1018
+ const seen = new Set;
739
1019
  const fileOperationByTool = {
740
1020
  readFile: "read",
741
1021
  writeFile: "write",
@@ -743,17 +1023,18 @@ function extractFileOperationsFromCalls(calls, resolveCanonicalName) {
743
1023
  };
744
1024
  for (const call of calls) {
745
1025
  const rawName = call.function?.name || call.name || "";
746
- if (!rawName) continue;
1026
+ if (!rawName)
1027
+ continue;
747
1028
  const canonicalName = resolveCanonicalName(rawName);
748
1029
  const opType = fileOperationByTool[canonicalName];
749
- if (!opType) continue;
1030
+ if (!opType)
1031
+ continue;
750
1032
  let rawArgs = call.function?.arguments;
751
1033
  let parsedArgs = null;
752
1034
  if (typeof rawArgs === "string") {
753
1035
  try {
754
1036
  parsedArgs = JSON.parse(rawArgs);
755
- } catch {
756
- }
1037
+ } catch {}
757
1038
  } else if (typeof rawArgs === "object" && rawArgs !== null) {
758
1039
  parsedArgs = rawArgs;
759
1040
  }
@@ -769,27 +1050,33 @@ function extractFileOperationsFromCalls(calls, resolveCanonicalName) {
769
1050
  return result;
770
1051
  }
771
1052
  function makeBoundedExcerpt(content) {
772
- const evidence = selectEvidenceLines(content.split("\n"));
1053
+ const evidence = selectEvidenceLines(content.split(`
1054
+ `));
773
1055
  return (maxChars) => {
774
- if (content.length <= maxChars) return content;
1056
+ if (content.length <= maxChars)
1057
+ return content;
775
1058
  const marker = `
776
1059
  [... ${content.length} chars projected ...]
777
1060
  `;
778
1061
  const available = maxChars - marker.length;
779
- if (available < 3) return marker.trim();
1062
+ if (available < 3)
1063
+ return marker.trim();
780
1064
  const evidenceCap = Math.floor(available * 0.2);
781
1065
  const selected = [];
782
1066
  let evidenceLength = 0;
783
1067
  for (const line of evidence) {
784
1068
  const cost = line.length + 1;
785
- if (evidenceLength + cost > evidenceCap) continue;
1069
+ if (evidenceLength + cost > evidenceCap)
1070
+ continue;
786
1071
  selected.push(line);
787
1072
  evidenceLength += cost;
788
1073
  }
789
1074
  const remainder = available - evidenceLength;
790
1075
  const headLength = Math.ceil(remainder / 2);
791
1076
  const tailLength = Math.floor(remainder / 2);
792
- return content.slice(0, headLength) + marker + (selected.length ? selected.join("\n") + "\n" : "") + (tailLength ? content.slice(-tailLength) : "");
1077
+ return content.slice(0, headLength) + marker + (selected.length ? selected.join(`
1078
+ `) + `
1079
+ ` : "") + (tailLength ? content.slice(-tailLength) : "");
793
1080
  };
794
1081
  }
795
1082
  var OMITTED_ROLE_ORDER = ["user", "assistant", "tool", "system"];
@@ -800,8 +1087,8 @@ function formatOmittedRun(start, end, counts) {
800
1087
  ...[...counts.keys()].filter((role) => !OMITTED_ROLE_ORDER.includes(role))
801
1088
  ];
802
1089
  const parts = ordered.filter((role) => (counts.get(role) ?? 0) > 0).map((role) => `${role} ${counts.get(role)}`);
803
- const range = start === end ? `\u6D88\u606F ${start + 1}` : `\u6D88\u606F ${start + 1}\u2013${end + 1}`;
804
- return `[... ${range} \u5DF2\u7701\u7565\uFF1A${parts.join("\u3001")} ...]`;
1090
+ const range = start === end ? `消息 ${start + 1}` : `消息 ${start + 1}–${end + 1}`;
1091
+ return `[... ${range} 已省略:${parts.join("、")} ...]`;
805
1092
  }
806
1093
  var SUMMARY_HEAD_SHARE = 0.4;
807
1094
  var DECLARATION_RESERVE = 40;
@@ -809,36 +1096,45 @@ var USER_MESSAGE_MAX_DEMAND = 600;
809
1096
  var SUMMARY_USER_SHARE = 0.2;
810
1097
  var DECLARATION_SPLIT_COST = 20;
811
1098
  function interruptedBatchMarker(declared, returned) {
812
- const scope = "[\u672C\u6BB5\u5386\u53F2\u8303\u56F4\u5185";
813
- return returned === 0 ? `${scope}\uFF0C\u8BE5\u5DE5\u5177\u6279\u6B21\u5728\u540E\u7EED\u7528\u6237\u6D88\u606F\u524D\u6CA1\u6709\u8BB0\u5F55\u5230\u7ED3\u679C\uFF0C\u6309\u4E2D\u65AD\u5904\u7406\uFF1A\u58F0\u660E\u8FC7\u7684\u8C03\u7528\u4E0D\u8BA1\u4E3A\u5DF2\u5B8C\u6210\u3002]` : `${scope}\uFF0C\u8BE5\u5DE5\u5177\u6279\u6B21\u58F0\u660E\u4E86 ${declared} \u4E2A\u8C03\u7528\uFF0C\u53EA\u8BB0\u5F55\u4E86 ${returned} \u4E2A\u7ED3\u679C\uFF1B\u672A\u8BB0\u5F55\u7ED3\u679C\u7684\u8C03\u7528\u6309\u4E2D\u65AD\u5904\u7406\uFF0C\u4E0D\u8BA1\u4E3A\u5DF2\u5B8C\u6210\u3002]`;
1099
+ const scope = "[本段历史范围内";
1100
+ return returned === 0 ? `${scope},该工具批次在后续用户消息前没有记录到结果,按中断处理:声明过的调用不计为已完成。]` : `${scope},该工具批次声明了 ${declared} 个调用,只记录了 ${returned} 个结果;未记录结果的调用按中断处理,不计为已完成。]`;
814
1101
  }
815
1102
  function projectInterruptedHistoricalBatches(source) {
816
- const resultIndices = /* @__PURE__ */ new Map();
1103
+ const resultIndices = new Map;
817
1104
  source.forEach((msg, index) => {
818
- const resultId = msg.role === "tool" ? msg.tool_call_id : void 0;
819
- if (typeof resultId !== "string" || !resultId) return;
1105
+ const resultId = msg.role === "tool" ? msg.tool_call_id : undefined;
1106
+ if (typeof resultId !== "string" || !resultId)
1107
+ return;
820
1108
  const existing = resultIndices.get(resultId);
821
- if (existing) existing.push(index);
822
- else resultIndices.set(resultId, [index]);
1109
+ if (existing)
1110
+ existing.push(index);
1111
+ else
1112
+ resultIndices.set(resultId, [index]);
823
1113
  });
824
1114
  return source.map((msg, index) => {
825
- if (msg.role !== "assistant" || !msg.tool_calls?.length) return msg;
1115
+ if (msg.role !== "assistant" || !msg.tool_calls?.length)
1116
+ return msg;
826
1117
  const declared = msg.tool_calls.map((call) => call?.id);
827
- if (declared.some((id) => typeof id !== "string" || !id) || new Set(declared).size !== declared.length) return msg;
1118
+ if (declared.some((id) => typeof id !== "string" || !id) || new Set(declared).size !== declared.length)
1119
+ return msg;
828
1120
  const declaredIds = declared;
829
1121
  let cursor = index + 1;
830
1122
  const returned = [];
831
1123
  while (cursor < source.length && source[cursor].role === "tool") {
832
1124
  const resultId = source[cursor].tool_call_id;
833
- if (typeof resultId !== "string" || !resultId || !declaredIds.includes(resultId) || returned.includes(resultId)) return msg;
1125
+ if (typeof resultId !== "string" || !resultId || !declaredIds.includes(resultId) || returned.includes(resultId))
1126
+ return msg;
834
1127
  returned.push(resultId);
835
1128
  cursor++;
836
1129
  }
837
- if (source[cursor]?.role !== "user") return msg;
838
- if (returned.length === declaredIds.length) return msg;
1130
+ if (source[cursor]?.role !== "user")
1131
+ return msg;
1132
+ if (returned.length === declaredIds.length)
1133
+ return msg;
839
1134
  const returnedSet = new Set(returned);
840
1135
  const ambiguous = declaredIds.some((id) => !returnedSet.has(id) && (resultIndices.get(id) ?? []).some((at) => at < index + 1 || at > cursor - 1));
841
- if (ambiguous) return msg;
1136
+ if (ambiguous)
1137
+ return msg;
842
1138
  const keptCalls = msg.tool_calls.filter((call) => returnedSet.has(call.id));
843
1139
  const { tool_calls: _declaredCalls, ...rest } = msg;
844
1140
  const text = serializeMessageContent(msg.content);
@@ -855,52 +1151,53 @@ function buildHistoricalCompactionRequest(args) {
855
1151
  const source = args.msgsToCompress;
856
1152
  const projected = projectInterruptedHistoricalBatches(source);
857
1153
  const bounded = buildBoundedCompactionRequest({ ...args, msgsToCompress: projected });
858
- if (bounded.status !== "ready") return bounded;
859
- const sourceIndexById = /* @__PURE__ */ new Map();
1154
+ if (bounded.status !== "ready")
1155
+ return bounded;
1156
+ const sourceIndexById = new Map;
860
1157
  source.forEach((msg, index) => {
861
- if (!sourceIndexById.has(msg.id)) sourceIndexById.set(msg.id, index);
1158
+ if (!sourceIndexById.has(msg.id))
1159
+ sourceIndexById.set(msg.id, index);
862
1160
  });
863
1161
  const coveredMessages = bounded.coveredMessages.map((msg) => {
864
1162
  const index = sourceIndexById.get(msg.id);
865
- if (index === void 0) {
1163
+ if (index === undefined) {
866
1164
  throw new Error(`historical compaction coverage returned an unknown message id: ${msg.id}`);
867
1165
  }
868
1166
  return source[index];
869
1167
  });
870
1168
  const isOrderedPrefix = !bounded.partial && coveredMessages.length === source.length && coveredMessages.every((msg, position) => msg === source[position]);
871
1169
  if (!isOrderedPrefix) {
872
- throw new Error(
873
- `historical compaction coverage is no longer an ordered 1:1 prefix of the source (covered ${coveredMessages.length} of ${source.length}, partial=${bounded.partial})`
874
- );
1170
+ throw new Error(`historical compaction coverage is no longer an ordered 1:1 prefix of the source (covered ${coveredMessages.length} of ${source.length}, partial=${bounded.partial})`);
875
1171
  }
876
1172
  return { ...bounded, coveredMessages };
877
1173
  }
878
1174
  var MAX_SUMMARY_READ_FILE_OPS = 25;
879
1175
  function formatBoundedFileOperations(operations, maxReadOps = MAX_SUMMARY_READ_FILE_OPS) {
880
1176
  if (operations.length === 0) {
881
- return { text: "\u65E0", keptCount: 0, droppedReads: 0 };
1177
+ return { text: "无", keptCount: 0, droppedReads: 0 };
882
1178
  }
883
1179
  const readIndices = [];
884
- for (let i = 0; i < operations.length; i++) {
885
- if (operations[i].type === "read") readIndices.push(i);
1180
+ for (let i = 0;i < operations.length; i++) {
1181
+ if (operations[i].type === "read")
1182
+ readIndices.push(i);
886
1183
  }
887
1184
  const cap = Math.max(0, Math.floor(maxReadOps));
888
- const droppedReadSet = new Set(
889
- readIndices.length > cap ? readIndices.slice(0, readIndices.length - cap) : []
890
- );
891
- const labelsByOperation = { read: "\u8BFB\u53D6", write: "\u5199\u5165", edit: "\u7F16\u8F91" };
1185
+ const droppedReadSet = new Set(readIndices.length > cap ? readIndices.slice(0, readIndices.length - cap) : []);
1186
+ const labelsByOperation = { read: "读取", write: "写入", edit: "编辑" };
892
1187
  const lines = [];
893
- for (let i = 0; i < operations.length; i++) {
894
- if (droppedReadSet.has(i)) continue;
1188
+ for (let i = 0;i < operations.length; i++) {
1189
+ if (droppedReadSet.has(i))
1190
+ continue;
895
1191
  const op = operations[i];
896
1192
  lines.push(`- ${labelsByOperation[op.type]}: ${op.path}`);
897
1193
  }
898
1194
  const droppedReads = droppedReadSet.size;
899
1195
  if (droppedReads > 0) {
900
- lines.push(`- (... \u5176\u4F59 ${droppedReads} \u6761\u53EA\u8BFB\u63A2\u7D22\u8DEF\u5F84\u5DF2\u7701\u7565)`);
1196
+ lines.push(`- (... 其余 ${droppedReads} 条只读探索路径已省略)`);
901
1197
  }
902
1198
  return {
903
- text: lines.join("\n") || "\u65E0",
1199
+ text: lines.join(`
1200
+ `) || "无",
904
1201
  keptCount: operations.length - droppedReads,
905
1202
  droppedReads
906
1203
  };
@@ -923,12 +1220,15 @@ function buildBoundedCompactionRequest(args) {
923
1220
  ...extra
924
1221
  }
925
1222
  });
926
- if (!windowValid) return blocked("invalid-window");
927
- if (!msgs.length) return blocked("empty-input");
1223
+ if (!windowValid)
1224
+ return blocked("invalid-window");
1225
+ if (!msgs.length)
1226
+ return blocked("empty-input");
928
1227
  const systemTokens = estimateTokenCount(COMPACTION_SUMMARY_SYSTEM_PROMPT);
929
- for (let i = 0; i < msgs.length; ) {
1228
+ for (let i = 0;i < msgs.length; ) {
930
1229
  const msg = msgs[i];
931
- if (msg.role === "tool") return blocked("no-safe-group");
1230
+ if (msg.role === "tool")
1231
+ return blocked("no-safe-group");
932
1232
  const calls = msg.role === "assistant" && Array.isArray(msg.tool_calls) ? msg.tool_calls : [];
933
1233
  if (!calls.length) {
934
1234
  i++;
@@ -936,7 +1236,7 @@ function buildBoundedCompactionRequest(args) {
936
1236
  }
937
1237
  const ids = calls.map((call) => call.id);
938
1238
  const hasIds = ids.every((id) => typeof id === "string" && id.length > 0);
939
- if (!hasIds && ids.some((id) => id !== void 0) || hasIds && new Set(ids).size !== ids.length) {
1239
+ if (!hasIds && ids.some((id) => id !== undefined) || hasIds && new Set(ids).size !== ids.length) {
940
1240
  return blocked("no-safe-group");
941
1241
  }
942
1242
  const remaining = new Set(ids);
@@ -944,26 +1244,28 @@ function buildBoundedCompactionRequest(args) {
944
1244
  i++;
945
1245
  while (i < msgs.length && msgs[i].role === "tool") {
946
1246
  const id = msgs[i].tool_call_id;
947
- if (hasIds ? !id || !remaining.delete(id) : id !== void 0) {
1247
+ if (hasIds ? !id || !remaining.delete(id) : id !== undefined) {
948
1248
  return blocked("no-safe-group");
949
1249
  }
950
1250
  count++;
951
1251
  i++;
952
1252
  }
953
- if (count !== calls.length || hasIds && remaining.size) return blocked("no-safe-group");
1253
+ if (count !== calls.length || hasIds && remaining.size)
1254
+ return blocked("no-safe-group");
954
1255
  }
955
1256
  const canonicalize = args.canonicalizeToolName ?? ((name) => name);
956
- const operations = /* @__PURE__ */ new Map();
1257
+ const operations = new Map;
957
1258
  for (const msg of msgs) {
958
- if (!Array.isArray(msg.tool_calls)) continue;
1259
+ if (!Array.isArray(msg.tool_calls))
1260
+ continue;
959
1261
  for (const op of extractFileOperationsFromCalls(msg.tool_calls, canonicalize)) {
960
1262
  operations.set(JSON.stringify([op.type, op.path]), op);
961
1263
  }
962
1264
  }
963
1265
  const boundedFileOps = formatBoundedFileOperations([...operations.values()]);
964
1266
  const fileOpsText = boundedFileOps.text;
965
- const note = "\u4EE5\u4E0B\u662F\u6709\u635F\u6295\u5F71\uFF1A\u90E8\u5206\u6D88\u606F\u88AB\u622A\u53D6\uFF0C\u8FDE\u7EED\u7701\u7565\u7684\u533A\u95F4\u5408\u5E76\u4E3A\u4E00\u884C [...] \u58F0\u660E\uFF1B\u539F\u6587\u4ECD\u5B58\u5386\u53F2\u3002";
966
- const omitted = "[... \u5185\u5BB9\u5DF2\u622A\u53D6 ...]";
1267
+ const note = "以下是有损投影:部分消息被截取,连续省略的区间合并为一行 [...] 声明;原文仍存历史。";
1268
+ const omitted = "[... 内容已截取 ...]";
967
1269
  const contents = msgs.map((msg) => serializeMessageContent(msg.content) || formatMessageContentFallback(msg));
968
1270
  const excerpts = contents.map((content) => makeBoundedExcerpt(content));
969
1271
  const raw = contents.map((content, i) => msgs[i].role === "tool" ? excerpts[i](TOOL_RESULT_TRUNCATE_CHARS) : content);
@@ -1001,7 +1303,8 @@ function buildBoundedCompactionRequest(args) {
1001
1303
  return blocked("no-budget", diagnosticsOf(0, msgs.length));
1002
1304
  }
1003
1305
  const projectContent = (i, allowance) => {
1004
- if (demands[i] <= allowance) return raw[i];
1306
+ if (demands[i] <= allowance)
1307
+ return raw[i];
1005
1308
  let lo = 0;
1006
1309
  let hi = Math.min(contents[i].length, msgs[i].role === "tool" ? TOOL_RESULT_TRUNCATE_CHARS : contents[i].length);
1007
1310
  let best = omitted;
@@ -1017,135 +1320,154 @@ function buildBoundedCompactionRequest(args) {
1017
1320
  }
1018
1321
  return best;
1019
1322
  };
1020
- const selectRegions = (budget2) => {
1323
+ const selectRegions = (budget) => {
1021
1324
  const expanded = msgs.map(() => false);
1022
1325
  const allowances = msgs.map(() => 0);
1023
1326
  let used = 0;
1024
- const declarationReserve = Math.min(DECLARATION_RESERVE, Math.max(4, Math.floor(budget2 / 4)));
1025
- const room = () => budget2 - used - declarationReserve;
1327
+ const declarationReserve = Math.min(DECLARATION_RESERVE, Math.max(4, Math.floor(budget / 4)));
1328
+ const room = () => budget - used - declarationReserve;
1026
1329
  const takeFull = (i) => {
1027
1330
  expanded[i] = true;
1028
1331
  allowances[i] = demands[i];
1029
1332
  used += lineOverheads[i] + demands[i];
1030
1333
  };
1031
1334
  const drop = (i) => {
1032
- if (!expanded[i]) return;
1335
+ if (!expanded[i])
1336
+ return;
1033
1337
  expanded[i] = false;
1034
1338
  used -= lineOverheads[i] + allowances[i];
1035
1339
  allowances[i] = 0;
1036
1340
  };
1037
- const headBudget = Math.floor(budget2 * SUMMARY_HEAD_SHARE);
1341
+ const headBudget = Math.floor(budget * SUMMARY_HEAD_SHARE);
1038
1342
  let headEnd = -1;
1039
1343
  let headUsed = 0;
1040
- for (let i = 0; i < msgs.length; i++) {
1344
+ for (let i = 0;i < msgs.length; i++) {
1041
1345
  const cost = lineOverheads[i] + demands[i];
1042
1346
  const limit = i === 0 ? Math.max(headBudget, room()) : headBudget - headUsed;
1043
- if (cost > limit) break;
1347
+ if (cost > limit)
1348
+ break;
1044
1349
  takeFull(i);
1045
1350
  headUsed += cost;
1046
1351
  headEnd = i;
1047
1352
  }
1048
- const userBudget = Math.floor(budget2 * SUMMARY_USER_SHARE);
1353
+ const userBudget = Math.floor(budget * SUMMARY_USER_SHARE);
1049
1354
  let userSpend = 0;
1050
- for (let i = msgs.length - 1; i > headEnd; i--) {
1051
- if (expanded[i] || msgs[i].role !== "user") continue;
1052
- if (demands[i] > USER_MESSAGE_MAX_DEMAND) continue;
1355
+ for (let i = msgs.length - 1;i > headEnd; i--) {
1356
+ if (expanded[i] || msgs[i].role !== "user")
1357
+ continue;
1358
+ if (demands[i] > USER_MESSAGE_MAX_DEMAND)
1359
+ continue;
1053
1360
  const cost = lineOverheads[i] + demands[i] + DECLARATION_SPLIT_COST;
1054
- if (userSpend + cost > userBudget || cost > room()) continue;
1361
+ if (userSpend + cost > userBudget || cost > room())
1362
+ continue;
1055
1363
  takeFull(i);
1056
1364
  userSpend += cost;
1057
1365
  }
1058
1366
  let tailStart = msgs.length;
1059
- for (let i = msgs.length - 1; i > headEnd; i--) {
1367
+ for (let i = msgs.length - 1;i > headEnd; i--) {
1060
1368
  if (expanded[i]) {
1061
1369
  tailStart = i;
1062
1370
  continue;
1063
1371
  }
1064
- if (lineOverheads[i] + demands[i] > room()) break;
1372
+ if (lineOverheads[i] + demands[i] > room())
1373
+ break;
1065
1374
  takeFull(i);
1066
1375
  tailStart = i;
1067
1376
  }
1068
1377
  const boundaryCap = Math.floor(room() * 0.5);
1069
1378
  const takeBoundary = (i) => {
1070
1379
  const inline = Math.min(room(), boundaryCap) - lineOverheads[i];
1071
- if (inline < MIN_INLINE_CONTENT_TOKENS) return false;
1380
+ if (inline < MIN_INLINE_CONTENT_TOKENS)
1381
+ return false;
1072
1382
  expanded[i] = true;
1073
1383
  allowances[i] = inline;
1074
1384
  used += lineOverheads[i] + inline;
1075
1385
  return true;
1076
1386
  };
1077
- if (tailStart - 1 > headEnd && !expanded[tailStart - 1] && takeBoundary(tailStart - 1)) tailStart--;
1078
- if (headEnd + 1 < tailStart && !expanded[headEnd + 1] && takeBoundary(headEnd + 1)) headEnd++;
1387
+ if (tailStart - 1 > headEnd && !expanded[tailStart - 1] && takeBoundary(tailStart - 1))
1388
+ tailStart--;
1389
+ if (headEnd + 1 < tailStart && !expanded[headEnd + 1] && takeBoundary(headEnd + 1))
1390
+ headEnd++;
1079
1391
  let grew = true;
1080
1392
  while (grew) {
1081
1393
  grew = false;
1082
- for (let i = tailStart - 1; i > headEnd; i--) {
1394
+ for (let i = tailStart - 1;i > headEnd; i--) {
1083
1395
  if (expanded[i]) {
1084
1396
  tailStart = i;
1085
1397
  continue;
1086
1398
  }
1087
- if (lineOverheads[i] + demands[i] > room()) break;
1399
+ if (lineOverheads[i] + demands[i] > room())
1400
+ break;
1088
1401
  takeFull(i);
1089
1402
  tailStart = i;
1090
1403
  grew = true;
1091
1404
  break;
1092
1405
  }
1093
- for (let i = headEnd + 1; i < tailStart; i++) {
1406
+ for (let i = headEnd + 1;i < tailStart; i++) {
1094
1407
  if (expanded[i]) {
1095
1408
  headEnd = i;
1096
1409
  continue;
1097
1410
  }
1098
- if (lineOverheads[i] + demands[i] > room()) break;
1411
+ if (lineOverheads[i] + demands[i] > room())
1412
+ break;
1099
1413
  takeFull(i);
1100
1414
  headEnd = i;
1101
1415
  grew = true;
1102
1416
  break;
1103
1417
  }
1104
1418
  }
1105
- const callOfResult = /* @__PURE__ */ new Map();
1106
- const resultsOfCall = /* @__PURE__ */ new Map();
1107
- for (let i = 0; i < msgs.length; i++) {
1419
+ const callOfResult = new Map;
1420
+ const resultsOfCall = new Map;
1421
+ for (let i = 0;i < msgs.length; i++) {
1108
1422
  const msg = msgs[i];
1109
1423
  const calls = msg.role === "assistant" && Array.isArray(msg.tool_calls) ? msg.tool_calls : [];
1110
- if (!calls.length) continue;
1424
+ if (!calls.length)
1425
+ continue;
1111
1426
  const ids = calls.map((call) => call.id);
1112
1427
  const byId = ids.every((id) => typeof id === "string" && id.length > 0);
1113
1428
  const results = [];
1114
- for (let j = i + 1; j < msgs.length && msgs[j].role === "tool"; j++) {
1429
+ for (let j = i + 1;j < msgs.length && msgs[j].role === "tool"; j++) {
1115
1430
  const id = msgs[j].tool_call_id;
1116
- if (!(byId ? typeof id === "string" && ids.includes(id) : id === void 0)) break;
1431
+ if (!(byId ? typeof id === "string" && ids.includes(id) : id === undefined))
1432
+ break;
1117
1433
  results.push(j);
1118
1434
  callOfResult.set(j, i);
1119
1435
  }
1120
1436
  resultsOfCall.set(i, results);
1121
1437
  }
1122
1438
  for (const [callIndex, results] of resultsOfCall) {
1123
- if (!expanded[callIndex] || !results.length) continue;
1124
- if (results.every((j) => expanded[j])) continue;
1439
+ if (!expanded[callIndex] || !results.length)
1440
+ continue;
1441
+ if (results.every((j) => expanded[j]))
1442
+ continue;
1125
1443
  drop(callIndex);
1126
1444
  }
1127
- for (let i = 0; i < msgs.length; i++) {
1128
- if (!expanded[i] || msgs[i].role !== "tool") continue;
1445
+ for (let i = 0;i < msgs.length; i++) {
1446
+ if (!expanded[i] || msgs[i].role !== "tool")
1447
+ continue;
1129
1448
  const callIndex = callOfResult.get(i);
1130
- if (callIndex === void 0 || !expanded[callIndex]) drop(i);
1449
+ if (callIndex === undefined || !expanded[callIndex])
1450
+ drop(i);
1131
1451
  }
1132
1452
  return { expanded, allowances };
1133
1453
  };
1134
- const render = (budget2) => {
1135
- const { expanded, allowances } = selectRegions(budget2);
1454
+ const render = (budget) => {
1455
+ const { expanded, allowances } = selectRegions(budget);
1136
1456
  const pieces = [];
1137
1457
  let runStart = -1;
1138
- let runCounts = /* @__PURE__ */ new Map();
1458
+ let runCounts = new Map;
1139
1459
  const flushRun = (end) => {
1140
- if (runStart < 0) return;
1460
+ if (runStart < 0)
1461
+ return;
1141
1462
  pieces.push(formatOmittedRun(runStart, end, runCounts));
1142
1463
  runStart = -1;
1143
- runCounts = /* @__PURE__ */ new Map();
1464
+ runCounts = new Map;
1144
1465
  };
1145
1466
  let expandedCount = 0;
1146
- for (let i = 0; i < msgs.length; i++) {
1467
+ for (let i = 0;i < msgs.length; i++) {
1147
1468
  if (!expanded[i]) {
1148
- if (runStart < 0) runStart = i;
1469
+ if (runStart < 0)
1470
+ runStart = i;
1149
1471
  runCounts.set(msgs[i].role, (runCounts.get(msgs[i].role) ?? 0) + 1);
1150
1472
  continue;
1151
1473
  }
@@ -1155,7 +1477,8 @@ function buildBoundedCompactionRequest(args) {
1155
1477
  }
1156
1478
  flushRun(msgs.length - 1);
1157
1479
  const promptContent = promptFor(`${note}
1158
- ${pieces.join("\n")}`);
1480
+ ${pieces.join(`
1481
+ `)}`);
1159
1482
  return {
1160
1483
  promptContent,
1161
1484
  inputTokens: systemTokens + estimateTokenCount(promptContent),
@@ -1165,7 +1488,7 @@ ${pieces.join("\n")}`);
1165
1488
  };
1166
1489
  let budget = availableTokens;
1167
1490
  let last = render(budget);
1168
- for (let attempt = 0; attempt < 12 && last.inputTokens > cap; attempt++) {
1491
+ for (let attempt = 0;attempt < 12 && last.inputTokens > cap; attempt++) {
1169
1492
  const overflow = last.inputTokens - cap;
1170
1493
  budget = Math.max(0, Math.floor(budget - Math.max(overflow, Math.ceil(budget * 0.15))));
1171
1494
  last = render(budget);
@@ -1186,33 +1509,29 @@ ${pieces.join("\n")}`);
1186
1509
  omittedMessages: last.omittedCount
1187
1510
  };
1188
1511
  }
1189
- var TOOL_RESULT_TRUNCATE_CHARS = 4e3;
1190
- var SUMMARY_INPUT_MAX_TOKENS = 3e4;
1512
+ var TOOL_RESULT_TRUNCATE_CHARS = 4000;
1513
+ var SUMMARY_INPUT_MAX_TOKENS = 30000;
1191
1514
  function computeSummaryInputTokenCap(contextWindow) {
1192
1515
  const halfWindow = typeof contextWindow === "number" && Number.isFinite(contextWindow) && contextWindow > 0 ? Math.floor(contextWindow * 0.5) : SUMMARY_INPUT_MAX_TOKENS;
1193
1516
  return Math.max(1, Math.min(SUMMARY_INPUT_MAX_TOKENS, halfWindow));
1194
1517
  }
1195
1518
  var EVIDENCE_LINE_PATTERNS = [
1196
- // commit sha:必须带 git 语境(commit/sha/HEAD/merge/push 输出 a..b)且含字母+数字
1197
1519
  /\b(?:commit|sha|HEAD|merge|revert|cherry-pick)\b[^\n]{0,24}\b(?=[0-9a-f]*[a-f])(?=[0-9a-f]*\d)[0-9a-f]{7,40}\b/i,
1198
1520
  /\b(?=[0-9a-f]*[a-f])(?=[0-9a-f]*\d)[0-9a-f]{7,40}\.\.(?=[0-9a-f]*[a-f])[0-9a-f]{7,40}\b/,
1199
- // 测试结论:带计数的 pass/fail,或 bun/jest 风格的 (pass)/(fail) 行首
1200
1521
  /\b\d+\s+(?:pass|passed|fail|failed|tests?)\b/i,
1201
1522
  /^\s*\((?:pass|fail)\)/i,
1202
1523
  /^\s*(?:FAIL|PASS|ERROR)\b[:\s]/,
1203
- // 退出码 / HTTP 状态:必须带键名
1204
1524
  /\bexit(?:\s*code|Code|_code)?\s*[=:]\s*\d+/i,
1205
1525
  /\bHTTP\/[\d.]+\s+[1-5]\d{2}\b/,
1206
1526
  /\b(?:status|statusCode|http_code|code)\s*[=:]\s*[1-5]\d{2}\b/i,
1207
- // 错误:行首的 XxxError:/Exception:,或 error: 前缀;超时带 timeout 关键结构
1208
1527
  /^\s*(?:Uncaught\s+)?[A-Z]\w*(?:Error|Exception)\b\s*:/,
1209
1528
  /^\s*(?:error|fatal|panic)\s*:/i,
1210
1529
  /\bTimeout\s+\d+\s*ms\s+exceeded\b/i,
1211
- // 堆栈帧
1212
1530
  /^\s*at\s+\S+.*:\d+(?::\d+)?\)?\s*$/
1213
1531
  ];
1214
1532
  function isEvidenceLine(line) {
1215
- if (!line) return false;
1533
+ if (!line)
1534
+ return false;
1216
1535
  return EVIDENCE_LINE_PATTERNS.some((re) => re.test(line));
1217
1536
  }
1218
1537
  function selectEvidenceLines(lines) {
@@ -1246,12 +1565,12 @@ function buildCompactionMetrics(args) {
1246
1565
  residentReductionTokens: previousSummaryTokens + compressedTokens - newSummaryTokens,
1247
1566
  ...summaryInput ? {
1248
1567
  summaryInputTokens: summaryInput.inputTokens,
1249
- ...summaryInput.capTokens !== void 0 ? { summaryInputCapTokens: summaryInput.capTokens } : {},
1250
- ...summaryInput.expandedMessages !== void 0 ? { summaryExpandedMessages: summaryInput.expandedMessages } : {},
1251
- ...summaryInput.omittedMessages !== void 0 ? { summaryOmittedMessages: summaryInput.omittedMessages } : {}
1568
+ ...summaryInput.capTokens !== undefined ? { summaryInputCapTokens: summaryInput.capTokens } : {},
1569
+ ...summaryInput.expandedMessages !== undefined ? { summaryExpandedMessages: summaryInput.expandedMessages } : {},
1570
+ ...summaryInput.omittedMessages !== undefined ? { summaryOmittedMessages: summaryInput.omittedMessages } : {}
1252
1571
  } : {},
1253
- ...args.planCounts?.pendingMessageCount !== void 0 ? { pendingMessageCount: args.planCounts.pendingMessageCount } : {},
1254
- ...args.planCounts?.plannedCompressCount !== void 0 ? { plannedCompressCount: args.planCounts.plannedCompressCount } : {}
1572
+ ...args.planCounts?.pendingMessageCount !== undefined ? { pendingMessageCount: args.planCounts.pendingMessageCount } : {},
1573
+ ...args.planCounts?.plannedCompressCount !== undefined ? { plannedCompressCount: args.planCounts.plannedCompressCount } : {}
1255
1574
  };
1256
1575
  }
1257
1576
  function buildCompactionMetricsFromPlan(args) {
@@ -1275,23 +1594,25 @@ function formatCompactionMetricsLog(metrics) {
1275
1594
  const llmInfo = metrics.summaryUsage ? `, summary_llm_in=${metrics.summaryUsage.input_tokens ?? "?"} out=${metrics.summaryUsage.output_tokens ?? "?"}` : "";
1276
1595
  const netInfo = `, net=${metrics.residentReductionTokens}`;
1277
1596
  const omittedTotal = (metrics.summaryExpandedMessages ?? 0) + (metrics.summaryOmittedMessages ?? 0);
1278
- const capSuffix = metrics.summaryInputCapTokens !== void 0 ? `/${metrics.summaryInputCapTokens}` : "";
1279
- const omittedSuffix = metrics.summaryOmittedMessages !== void 0 ? ` omitted=${metrics.summaryOmittedMessages}/${omittedTotal}` : "";
1280
- const projectionInfo = metrics.summaryInputTokens !== void 0 ? `, summary_in=${metrics.summaryInputTokens}${capSuffix}${omittedSuffix}` : "";
1281
- const planInfo = metrics.pendingMessageCount !== void 0 ? `, pending=${metrics.pendingMessageCount}${metrics.plannedCompressCount !== void 0 ? ` fold=${metrics.plannedCompressCount}/${metrics.pendingMessageCount}` : ""}` : "";
1597
+ const capSuffix = metrics.summaryInputCapTokens !== undefined ? `/${metrics.summaryInputCapTokens}` : "";
1598
+ const omittedSuffix = metrics.summaryOmittedMessages !== undefined ? ` omitted=${metrics.summaryOmittedMessages}/${omittedTotal}` : "";
1599
+ const projectionInfo = metrics.summaryInputTokens !== undefined ? `, summary_in=${metrics.summaryInputTokens}${capSuffix}${omittedSuffix}` : "";
1600
+ const planInfo = metrics.pendingMessageCount !== undefined ? `, pending=${metrics.pendingMessageCount}${metrics.plannedCompressCount !== undefined ? ` fold=${metrics.plannedCompressCount}/${metrics.pendingMessageCount}` : ""}` : "";
1282
1601
  return `[Compaction] reason=${metrics.reason} compressed=${metrics.compressedCount}->${metrics.retainedCount} msgs, tokens=${totalBefore}->${totalAfter} (ratio=${ratio})${llmInfo}${netInfo}${projectionInfo}${planInfo}`;
1283
1602
  }
1284
1603
  function computeSummarySourceMetadata(messagesWithIds, summarizedBeforeId) {
1285
- if (!summarizedBeforeId) return void 0;
1604
+ if (!summarizedBeforeId)
1605
+ return;
1286
1606
  const found = messagesWithIds.findIndex((m) => m.id === summarizedBeforeId);
1287
- if (found === -1) return void 0;
1607
+ if (found === -1)
1608
+ return;
1288
1609
  const slice = messagesWithIds.slice(0, found + 1).map((m, index) => ({
1289
1610
  id: `local-${index}`,
1290
1611
  role: m.role,
1291
1612
  content: m.content ?? "",
1292
1613
  ...Array.isArray(m.tool_calls) ? { tool_calls: m.tool_calls } : {}
1293
1614
  }));
1294
- const sourceHash = sha256Hex(JSON.stringify(slice));
1615
+ const sourceHash = sha256Hex2(JSON.stringify(slice));
1295
1616
  return {
1296
1617
  sourceHash,
1297
1618
  sourceCount: found + 1,
@@ -1299,242 +1620,4 @@ function computeSummarySourceMetadata(messagesWithIds, summarizedBeforeId) {
1299
1620
  };
1300
1621
  }
1301
1622
 
1302
- // packages/ai/llm/getModelContextWindow.ts
1303
- var DEFAULT_CONTEXT_WINDOW = 256e3;
1304
- var QWEN_3_6_CONTEXT_WINDOW = 262144;
1305
- var GLM_5_2_CONTEXT_WINDOW = 1e6;
1306
- var GPT_6_1_SOL_CONTEXT_WINDOW = 5e5;
1307
- var GPT_6_1_SOL_PATTERN = /(^|\/)gpt-6\.1[- ]sol(?![a-z])/;
1308
- var GPT_6_1_PINNED_PATTERN = /(^|\/)gpt-(?:6\.1[- ](sol|terra)|6\.2[- ](sol|astra))(?![a-z0-9])/;
1309
- var GPT_272K_PINNED_PATTERN = /(^|\/)(gpt-6[- ](astra|luna|sol)|gpt-5\.6[- ](sol|terra|luna))(?![a-z0-9])/;
1310
- var GPT_272K_CONTEXT_WINDOW = 272e3;
1311
- function channelPinnedContextWindow(normalizedName) {
1312
- if (GPT_6_1_PINNED_PATTERN.test(normalizedName)) return GPT_6_1_SOL_CONTEXT_WINDOW;
1313
- if (GPT_272K_PINNED_PATTERN.test(normalizedName)) return GPT_272K_CONTEXT_WINDOW;
1314
- return void 0;
1315
- }
1316
- var ANTIGRAVITY_EFFORT_SUFFIXES = [
1317
- "-tiered",
1318
- "-extra-low",
1319
- "-low",
1320
- "-medium",
1321
- "-high"
1322
- ];
1323
- function stripEffortSuffix(model) {
1324
- for (const suffix of ANTIGRAVITY_EFFORT_SUFFIXES) {
1325
- if (model.endsWith(suffix) && model.length > suffix.length) {
1326
- return model.slice(0, -suffix.length);
1327
- }
1328
- }
1329
- return model;
1330
- }
1331
- function stripPreviewSuffix(model) {
1332
- const suffix = "-preview";
1333
- if (model.endsWith(suffix) && model.length > suffix.length) {
1334
- return model.slice(0, -suffix.length);
1335
- }
1336
- return model;
1337
- }
1338
- function stripModelTag(model) {
1339
- const colonIndex = model.indexOf(":");
1340
- if (colonIndex > 0) {
1341
- return model.slice(0, colonIndex);
1342
- }
1343
- return model;
1344
- }
1345
- var fullModelMap = null;
1346
- var getFullModelMap = () => {
1347
- if (!fullModelMap) {
1348
- fullModelMap = /* @__PURE__ */ new Map();
1349
- for (const [provider, models] of Object.entries(MODEL_LOOKUP_MAP)) {
1350
- for (const model of models) {
1351
- const entry = { ...model, provider };
1352
- fullModelMap.set(model.name, entry);
1353
- if (model.displayName) {
1354
- fullModelMap.set(model.displayName.toLowerCase(), entry);
1355
- }
1356
- }
1357
- }
1358
- }
1359
- return fullModelMap;
1360
- };
1361
- var legacyModelMap = null;
1362
- var getLegacyModelMap = () => {
1363
- if (!legacyModelMap) {
1364
- legacyModelMap = /* @__PURE__ */ new Map();
1365
- for (const model of ALL_MODELS) {
1366
- legacyModelMap.set(model.name, model);
1367
- if (model.displayName) {
1368
- legacyModelMap.set(model.displayName.toLowerCase(), model);
1369
- }
1370
- }
1371
- }
1372
- return legacyModelMap;
1373
- };
1374
- function fuzzyContextWindow(normalizedName) {
1375
- const bareModelName = (normalizedName.includes("/") ? normalizedName.slice(normalizedName.lastIndexOf("/") + 1) : normalizedName).replace(/:.*$/, "");
1376
- if (normalizedName.includes("qwen-long") || normalizedName.includes("qwen3-long")) return 10485760;
1377
- if (normalizedName.includes("qwen-coder") || normalizedName.includes("qwen3-coder")) return 1048576;
1378
- if (normalizedName.includes("qwen3.8") || normalizedName.includes("qwen3p8")) return 1e6;
1379
- if (normalizedName.includes("minimax-m3") || normalizedName.includes("minimax_m3")) return 1e6;
1380
- if (bareModelName === "mimo-v2.6-pro" || normalizedName === "mimo v2.6 pro") return 1048576;
1381
- if (normalizedName.includes("glm-5.3") || normalizedName.includes("glm5.3")) return 105e4;
1382
- if (normalizedName.includes("glm-5.2") || normalizedName.includes("glm5.2")) return GLM_5_2_CONTEXT_WINDOW;
1383
- if (normalizedName.includes("deepseek")) return 1e6;
1384
- if (GPT_6_1_SOL_PATTERN.test(normalizedName)) return GPT_6_1_SOL_CONTEXT_WINDOW;
1385
- const channelPinned = channelPinnedContextWindow(normalizedName);
1386
- if (channelPinned !== void 0) return channelPinned;
1387
- if (normalizedName.includes("gpt-5") || normalizedName.includes("gpt-4.1")) return 1047576;
1388
- if (normalizedName.startsWith("cursor-grok-4.5")) return 1e6;
1389
- if (normalizedName.includes("claude-4.6")) return 1e6;
1390
- if (normalizedName.includes("gemini-3.1")) return 1e6;
1391
- if (normalizedName.includes("gemini")) return 1048576;
1392
- if (normalizedName.includes("qwen3.6") || normalizedName.includes("qwen3p6")) return QWEN_3_6_CONTEXT_WINDOW;
1393
- if (normalizedName.includes("qwen3.7") || normalizedName.includes("qwen3p7")) return 262144;
1394
- if (/minimax[-_ ]m2(?![\d.])/.test(normalizedName)) return 262144;
1395
- const MISTRAL_LARGE_4 = /mistral[-_ ]large[-_ ]4/;
1396
- const large4 = MISTRAL_LARGE_4.exec(normalizedName);
1397
- if (large4) {
1398
- const rest = normalizedName.slice(large4.index + large4[0].length);
1399
- if (rest === "" || /^[-:_@/\s]/.test(rest)) return 524288;
1400
- }
1401
- if (normalizedName.includes("mistral-vibe-cli") || normalizedName.includes("mistral-medium-3.5") || normalizedName.includes("mistral-medium-3-5") || normalizedName.includes("mistral-medium-latest") || normalizedName.includes("mistral-medium-2604") || normalizedName.includes("mistral-large-latest") || normalizedName.includes("mistral-large-2512") || normalizedName.includes("mistral-small-latest") || normalizedName.includes("mistral-small-2603") || normalizedName.includes("magistral-medium-latest") || normalizedName.includes("magistral-small-latest") || // 展示名(TUI 传 displayName 的路径;Mistral 不在 MODEL_LOOKUP_MAP,无法走精确表):
1402
- normalizedName.includes("mistral vibe cli") || normalizedName.includes("mistral medium 3.5") || normalizedName.includes("mistral large (latest)")) {
1403
- return 262144;
1404
- }
1405
- if (bareModelName === "mistral-medium" || bareModelName === "mistral-medium-3") return 262144;
1406
- if (normalizedName.includes("mistral-embed") || normalizedName.includes("codestral-embed")) return 8192;
1407
- if (normalizedName.includes("mistral-ocr")) return 16384;
1408
- if (normalizedName.includes("mistral-moderation")) return 131072;
1409
- if (normalizedName.includes("codestral") || normalizedName.includes("mistral-code")) return 256e3;
1410
- if (normalizedName.includes("claude")) return 2e5;
1411
- if (normalizedName.includes("llama3.1") || normalizedName.includes("llama-3.1") || normalizedName.includes("llama3.2") || normalizedName.includes("llama-3.2") || normalizedName.includes("llama3.3") || normalizedName.includes("llama-3.3") || normalizedName.includes("qwen2.5") || normalizedName.includes("qwen-2.5") || normalizedName.includes("mistral-nemo") || normalizedName.includes("phi3.5") || normalizedName.includes("phi-3.5") || normalizedName.includes("phi4") || normalizedName.includes("phi-4")) {
1412
- return 131072;
1413
- }
1414
- if (normalizedName.includes("qwen2") || normalizedName.includes("qwen-2") || normalizedName.includes("mistral") || normalizedName.includes("mixtral")) {
1415
- return 32768;
1416
- }
1417
- if (normalizedName.includes("codellama") || normalizedName.includes("starcoder") || normalizedName.includes("phi3") || normalizedName.includes("phi-3")) {
1418
- return 16384;
1419
- }
1420
- if (normalizedName.includes("llama3") || normalizedName.includes("llama-3") || normalizedName.includes("gemma2") || normalizedName.includes("gemma-2") || normalizedName.includes("gemma")) {
1421
- return 8192;
1422
- }
1423
- if (/(^|[^a-z])llama/.test(normalizedName)) {
1424
- return 4096;
1425
- }
1426
- return void 0;
1427
- }
1428
- var findCodexOAuthPinnedContextWindow = (modelName, provider) => {
1429
- if (!modelName) return void 0;
1430
- if (isPlatformManagedProvider(provider, modelName)) return void 0;
1431
- return channelPinnedContextWindow(modelName.toLowerCase());
1432
- };
1433
- var findModelContextWindow = (modelName, provider) => findModelContextWindowImpl(modelName, provider, false);
1434
- var findModelContextWindowImpl = (modelName, provider, allowHyphenRetry) => {
1435
- if (!modelName) return void 0;
1436
- const onPlatformChannel = isPlatformManagedProvider(provider, modelName);
1437
- const aliasKey = modelName.trim().toLowerCase().replace(/\s+/g, "-");
1438
- const aliasedName = resolvePlatformEffectiveModel(aliasKey);
1439
- const effectiveName = onPlatformChannel && aliasedName && aliasedName !== aliasKey ? aliasedName : modelName;
1440
- const normalizedName = effectiveName.toLowerCase();
1441
- const map = getFullModelMap();
1442
- const rawCandidates = [effectiveName, normalizedName];
1443
- const strippedTag = stripModelTag(modelName);
1444
- if (strippedTag !== modelName) {
1445
- rawCandidates.push(strippedTag, strippedTag.toLowerCase());
1446
- }
1447
- const candidates = [];
1448
- for (const base of rawCandidates) {
1449
- candidates.push(base);
1450
- const strippedEffort = stripEffortSuffix(base);
1451
- if (strippedEffort !== base) {
1452
- candidates.push(strippedEffort, strippedEffort.toLowerCase());
1453
- }
1454
- const strippedPreview = stripPreviewSuffix(base);
1455
- if (strippedPreview !== base) {
1456
- candidates.push(strippedPreview, strippedPreview.toLowerCase());
1457
- }
1458
- if (strippedEffort !== base) {
1459
- const strippedBoth = stripPreviewSuffix(strippedEffort);
1460
- if (strippedBoth !== strippedEffort) {
1461
- candidates.push(strippedBoth, strippedBoth.toLowerCase());
1462
- }
1463
- }
1464
- }
1465
- for (const candidate of candidates) {
1466
- const model = map.get(candidate);
1467
- if (model?.contextWindow) {
1468
- if (!onPlatformChannel && (channelPinnedContextWindow(model.name.toLowerCase()) !== void 0 || channelPinnedContextWindow(candidate.toLowerCase()) !== void 0)) {
1469
- continue;
1470
- }
1471
- return typeof model.contextWindow === "number" ? model.contextWindow : void 0;
1472
- }
1473
- }
1474
- if (onPlatformChannel) {
1475
- const effective = resolvePlatformEffectiveModel(normalizedName);
1476
- if (effective && effective !== normalizedName) {
1477
- const aliased = map.get(effective);
1478
- if (aliased?.contextWindow) {
1479
- return typeof aliased.contextWindow === "number" ? aliased.contextWindow : void 0;
1480
- }
1481
- }
1482
- }
1483
- if (!onPlatformChannel) {
1484
- for (const candidate of candidates) {
1485
- const pinned = channelPinnedContextWindow(candidate.toLowerCase());
1486
- if (pinned !== void 0) return pinned;
1487
- }
1488
- }
1489
- const fuzzy = fuzzyContextWindow(normalizedName);
1490
- if (fuzzy !== void 0) return fuzzy;
1491
- if (!allowHyphenRetry) {
1492
- const canonical = normalizeSeparators(modelName);
1493
- if (canonical.toLowerCase() !== normalizedName) {
1494
- return findModelContextWindowImpl(canonical, provider, true);
1495
- }
1496
- }
1497
- return void 0;
1498
- };
1499
- function normalizeSeparators(raw) {
1500
- return raw.replace(/\s+/g, "-").replace(/(?<=[a-z0-9])_(?=[a-z0-9])/g, "-");
1501
- }
1502
- var getModelContextWindow = (modelName, provider) => findModelContextWindow(modelName, provider) ?? DEFAULT_CONTEXT_WINDOW;
1503
- var getModelInfo = (modelName) => {
1504
- if (!modelName) return null;
1505
- const map = getLegacyModelMap();
1506
- return map.get(modelName) || map.get(modelName.toLowerCase()) || null;
1507
- };
1508
-
1509
- export {
1510
- DEFAULT_CONTEXT_WINDOW,
1511
- findCodexOAuthPinnedContextWindow,
1512
- findModelContextWindow,
1513
- getModelContextWindow,
1514
- getModelInfo,
1515
- readCacheReadInputTokens,
1516
- readCacheReadInputTokensOrNull,
1517
- readCacheCreationInputTokens,
1518
- normalizeUsage,
1519
- isOAuthApiKeyRef,
1520
- shouldUseServerProxy,
1521
- serializeMessageContent,
1522
- resolveCompressionTriggerRatio,
1523
- truncateToolOutputForContext,
1524
- getMessageTokenCount,
1525
- resolveEffectiveCompactionBudgets,
1526
- planCompression,
1527
- createSummaryBudget,
1528
- classifySummaryError,
1529
- isTruncatedCompletion,
1530
- summaryCompletionTokens,
1531
- selectSummaryRoute,
1532
- runSummaryWithContract,
1533
- COMPACTION_SUMMARY_SCHEMA_VERSION,
1534
- COMPACTION_SUMMARY_SYSTEM_PROMPT,
1535
- extractFileOperationsFromCalls,
1536
- buildHistoricalCompactionRequest,
1537
- buildCompactionMetricsFromPlan,
1538
- formatCompactionMetricsLog,
1539
- computeSummarySourceMetadata
1540
- };
1623
+ export { ALL_MODELS3, DEFAULT_CONTEXT_WINDOW, findCodexOAuthPinnedContextWindow, findModelContextWindow, getModelContextWindow, getModelInfo, readCacheReadInputTokens, readCacheReadInputTokensOrNull, readCacheCreationInputTokens, normalizeUsage, isOAuthApiKeyRef, shouldUseServerProxy, compactWhitespace, clipCompactText, serializeMessageContent, resolveCompressionTriggerRatio, truncateToolOutputForContext, getMessageTokenCount, resolveEffectiveCompactionBudgets, planCompression, createSummaryBudget, classifySummaryError, isTruncatedCompletion, summaryCompletionTokens, selectSummaryRoute, runSummaryWithContract, COMPACTION_SUMMARY_SCHEMA_VERSION, COMPACTION_SUMMARY_SYSTEM_PROMPT, extractFileOperationsFromCalls, buildHistoricalCompactionRequest, buildCompactionMetricsFromPlan, formatCompactionMetricsLog, computeSummarySourceMetadata };