nolo-cli 0.264.0-alpha.2 → 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.
- package/{chunk-LXP53WGF.js → chunk-05wkntba.js} +44 -40
- package/{chunk-XFYFMTOM.js → chunk-08ts2q1n.js} +9 -11
- package/{chromeCommands-MVEEIY4R.js → chunk-0a3m1n6h.js} +182 -238
- package/chunk-0gfvc7g8.js +13 -0
- package/{chunk-CF7PE763.js → chunk-0h0sncy4.js} +3 -4
- package/{chunk-3UH7SS4W.js → chunk-0nsxwrge.js} +232 -241
- package/chunk-0ra8cne4.js +11 -0
- package/{chunk-MRACVEPZ.js → chunk-0sgwk7am.js} +1 -3
- package/{chunk-PEXGRTTQ.js → chunk-0tsfn0dk.js} +44 -45
- package/{chunk-WOAZVUSN.js → chunk-0y8cbwzy.js} +26 -30
- package/chunk-12gz55kk.js +6 -0
- package/{chunk-GLKOYSRU.js → chunk-186gshgw.js} +3 -6
- package/chunk-19w4ss38.js +44 -0
- package/{chunk-RF576RYE.js → chunk-1cakzp6r.js} +23 -23
- package/chunk-1fbfwbzp.js +27 -0
- package/{chunk-4IVMDQBA.js → chunk-1fv9k8zt.js} +103 -68
- package/{chunk-Q5FJJ6XI.js → chunk-1js4cdzp.js} +11 -19
- package/{chunk-YECCIUYU.js → chunk-1nhx0er5.js} +63 -63
- package/chunk-1p152b7g.js +12 -0
- package/{chunk-HXEO5DNV.js → chunk-1ynbq3yr.js} +322 -353
- package/{chunk-6UBGXX2W.js → chunk-1zrg4h5n.js} +3 -4
- package/{chunk-Y5GCAMGP.js → chunk-2g6zsfq8.js} +1 -3
- package/chunk-2hekb0eh.js +17 -0
- package/chunk-2pj6qzq5.js +12 -0
- package/chunk-2tvd4jyp.js +226 -0
- package/chunk-2ygg7azv.js +846 -0
- package/chunk-33405wtv.js +50 -0
- package/chunk-34axejtd.js +30 -0
- package/{tableCommands-FCPDULSU.js → chunk-3700dvt3.js} +224 -276
- package/{pdf-KE3QI2V7.js → chunk-3j08t1nm.js} +12505 -10133
- package/chunk-3j9gq18v.js +111 -0
- package/{chunk-LYPJYBE5.js → chunk-3qfpcdkm.js} +486 -505
- package/{settingThunks-PNC7ZISV.js → chunk-3r2x7h64.js} +189 -272
- package/{agentGrantCommands-2VLLXGIU.js → chunk-3tbj5fxt.js} +61 -56
- package/chunk-40whhjj5.js +168 -0
- package/chunk-4301919y.js +7 -0
- package/chunk-43adz39e.js +77 -0
- package/{chunk-5ZUL4CUO.js → chunk-49v3zc4g.js} +1 -3
- package/chunk-4dd7mxkb.js +72 -0
- package/{chunk-BKP325XS.js → chunk-4hapfzpq.js} +66 -62
- package/chunk-4mm7dz0m.js +95 -0
- package/chunk-4pqxempz.js +440 -0
- package/chunk-4x9zf5pv.js +10 -0
- package/{chunk-CA7LGAHV.js → chunk-511q8qzv.js} +66 -57
- package/{chunk-U7OULUMF.js → chunk-53v9g0np.js} +49 -64
- package/chunk-572mg6q5.js +19 -0
- package/{chunk-QAW6BEWQ.js → chunk-57eyhmwr.js} +17173 -16165
- package/chunk-5hsr0zjm.js +156 -0
- package/chunk-5k883yyd.js +20 -0
- package/chunk-5m0wsee4.js +639 -0
- package/{memberThunks-NEZRAW5K.js → chunk-5r1sq2gt.js} +299 -373
- package/chunk-648rq4np.js +255 -0
- package/{chunk-IYRZKHA6.js → chunk-666yjw5c.js} +63 -86
- package/{chunk-4O22PGNQ.js → chunk-6cdcbmtp.js} +19 -19
- package/chunk-6dbyqcf7.js +59 -0
- package/{agentProviderCommands-2W3VXDLV.js → chunk-6e8mgp1x.js} +82 -105
- package/chunk-6n0pw7sx.js +44 -0
- package/chunk-6q1b7381.js +361 -0
- package/chunk-6sj756ry.js +23 -0
- package/{chunk-4UNN45DS.js → chunk-6t7a7zck.js} +14785 -14454
- package/chunk-6yarwtxh.js +776 -0
- package/chunk-708h542p.js +18 -0
- package/chunk-76f076t8.js +266 -0
- package/chunk-782rrrwv.js +523 -0
- package/{workloadLifecycle-P2SJVV3S.js → chunk-7gk330wp.js} +77 -84
- package/{chunk-EZKIRVLJ.js → chunk-7ks60vxy.js} +146 -128
- package/{chunk-FI4DPLR7.js → chunk-7mrqbxe8.js} +342 -228
- package/chunk-7sztayrd.js +169 -0
- package/chunk-7vgt2mxz.js +15 -0
- package/{localFirstLog-OIETGK66.js → chunk-7z8y4k6y.js} +0 -2
- package/{chunk-KDDXC2IH.js → chunk-82htft2m.js} +49 -11
- package/{updateDialogTitleAction-XOSLNRT3.js → chunk-88vrtxxg.js} +65 -137
- package/{chunk-LS5KAVFQ.js → chunk-8dtjbp79.js} +293 -229
- package/chunk-8fajbkaz.js +50 -0
- package/chunk-8m1ebxpw.js +65 -0
- package/{accountResolver-JYG5L7YP.js → chunk-8mgfeg0w.js} +37 -30
- package/{chunk-LPXBBC32.js → chunk-8myksy35.js} +156 -160
- package/{chunk-BMQ2MJUK.js → chunk-8nrj7dc7.js} +75 -66
- package/{commandRegistry-ENNFT77C.js → chunk-8t8x64ec.js} +228 -286
- package/chunk-8yj4pq79.js +458 -0
- package/{chunk-5MKPNTJP.js → chunk-8z6pepcx.js} +43 -48
- package/{chunk-UYQILGDR.js → chunk-90egc9vb.js} +122 -102
- package/{chunk-EODBQPRM.js → chunk-91q5dc5r.js} +10 -14
- package/{chunk-U6VC4MU4.js → chunk-96jtrqk1.js} +2 -4
- package/{chunk-H57T64RA.js → chunk-996j61av.js} +28 -31
- package/{chunk-Q6FKWH66.js → chunk-9cxgb9jy.js} +137 -243
- package/{chunk-2ZBPWX7N.js → chunk-9q1gbmet.js} +62 -104
- package/chunk-9qtjh73q.js +344 -0
- package/{chunk-SR57FDTX.js → chunk-9raka469.js} +72 -155
- package/{chunk-V6K5U4YE.js → chunk-9vh4v046.js} +32 -41
- package/{chunk-AGIM7IMJ.js → chunk-9yr1fy7j.js} +14 -49
- package/{chunk-FGFJUFPS.js → chunk-a16x0wt6.js} +11 -18
- package/chunk-a5b2rvzs.js +131 -0
- package/{chunk-7DPNBQSV.js → chunk-a7bz6nc3.js} +3 -4
- package/chunk-ac85azv9.js +29 -0
- package/{chunk-VXL2FZTP.js → chunk-ahhbkad4.js} +16 -20
- package/{chunk-37DGW762.js → chunk-anhksj2j.js} +16 -29
- package/{cliAuthorityBrokerServer-27C5YBYP.js → chunk-atvmx76t.js} +180 -186
- package/{chunk-E6A5NHDH.js → chunk-av2mzeqz.js} +16 -17
- package/chunk-avbwrb0z.js +614 -0
- package/chunk-avr6rqe5.js +544 -0
- package/{workContextQueryProjection-CACY5VFE.js → chunk-axx60d5a.js} +7 -7
- package/{chunk-EWQ3HGNZ.js → chunk-b00vzjkb.js} +30 -23
- package/chunk-b0m6ezxr.js +132 -0
- package/chunk-bbd5mgdt.js +47 -0
- package/chunk-bcecft0r.js +28 -0
- package/chunk-beyr4pyp.js +33 -0
- package/{chunk-BR3GT6MR.js → chunk-bge0cagn.js} +7 -18
- package/{offlineMarxistsAgentCommand-MFURGWHL.js → chunk-bh53zg3t.js} +33 -43
- package/chunk-bmx1cw89.js +37 -0
- package/chunk-br2195h4.js +22 -0
- package/chunk-bsqkwveq.js +56 -0
- package/{chunk-QAU6KM2U.js → chunk-c09s2z1m.js} +139 -98
- package/chunk-c235kypv.js +24636 -0
- package/{chunk-2JMYAH5O.js → chunk-c30j6pyh.js} +213 -256
- package/chunk-c3v6r6sq.js +29 -0
- package/{chunk-PDSXYHNI.js → chunk-c5z7qspt.js} +1177 -1196
- package/{chunk-GWB6AGME.js → chunk-c6jvz0mp.js} +34 -50
- package/{chunk-PRJ473FK.js → chunk-cd6h9qqs.js} +14 -12
- package/chunk-cdt0amyy.js +37 -0
- package/{chunk-2AJLG6PY.js → chunk-cfh6tfc3.js} +73 -86
- package/{chunk-WIVVNJUS.js → chunk-ch4ck1yz.js} +38 -68
- package/chunk-chtvrtp5.js +55 -0
- package/{chunk-EYLGAEB4.js → chunk-ckvz7abv.js} +170 -165
- package/{chunk-YZMNK53S.js → chunk-csf18m5w.js} +32 -25
- package/{chunk-C36L6ZID.js → chunk-cwnvf8dt.js} +2 -10
- package/chunk-cy7thb6n.js +19877 -0
- package/{dialogPortabilityCommands-YQJNB2KL.js → chunk-d61q9nah.js} +439 -487
- package/chunk-d6xdy0gp.js +142 -0
- package/{chunk-EBH4RFJ6.js → chunk-dh69vqbd.js} +6390 -6496
- package/{chunk-KJ4J2XQB.js → chunk-dj4ggbc6.js} +17 -19
- package/{chunk-LISC7BD4.js → chunk-djrrhbk3.js} +29 -37
- package/chunk-drqzzzvr.js +822 -0
- package/chunk-e1n7edjk.js +33 -0
- package/chunk-e3atr4hk.js +59 -0
- package/chunk-e9bn2aav.js +13 -0
- package/chunk-ed396rfq.js +87 -0
- package/chunk-eha8ggh6.js +10 -0
- package/{chunk-MALPQFGT.js → chunk-ek122zzt.js} +893 -948
- package/chunk-epnmvek4.js +22 -0
- package/{chunk-S25VJYXV.js → chunk-eqzvk3xm.js} +69 -80
- package/chunk-ex34n71b.js +2874 -0
- package/{chunk-56OAS5RZ.js → chunk-f3ad6q4h.js} +7 -11
- package/{chunk-3PVYUPXK.js → chunk-f8jepva1.js} +6 -7
- package/{chunk-GH34JXNV.js → chunk-f9yvy9t9.js} +114 -92
- package/chunk-fbdz4f0j.js +90 -0
- package/{chunk-J44TXB4J.js → chunk-fcsc2day.js} +216 -164
- package/chunk-fevdhnbh.js +19 -0
- package/chunk-fkrgqq8w.js +3300 -0
- package/{chunk-TSBJVMNW.js → chunk-fs3bvh2p.js} +42 -57
- package/chunk-fvwzyhah.js +134 -0
- package/chunk-g0mpxdp9.js +101 -0
- package/{chunk-LTQ6ECCF.js → chunk-g35f20d1.js} +450 -414
- package/{chunk-3L2WKC3W.js → chunk-g5fhtjqg.js} +13 -16
- package/{chunk-DBEOW57U.js → chunk-gcq01td7.js} +270 -227
- package/{chunk-ADMRXWXJ.js → chunk-ge97b11r.js} +121 -42
- package/chunk-ghjtgbkw.js +180 -0
- package/chunk-gkra36c1.js +16 -0
- package/chunk-gmz86t60.js +1000 -0
- package/{localDialogRead-GWGWSL5K.js → chunk-gszpesze.js} +5 -12
- package/chunk-gvsfec9m.js +16536 -0
- package/{chunk-QSJ3HFEF.js → chunk-h1hzmqph.js} +1 -3
- package/chunk-h30dg154.js +17 -0
- package/chunk-h3hkb7cw.js +241 -0
- package/chunk-h40py996.js +28 -0
- package/{chunk-47T3QP4V.js → chunk-h60gnewh.js} +112 -116
- package/{agentPullCommand-XEGOUYQT.js → chunk-hkwsv9xf.js} +33 -45
- package/chunk-hnyg0gwj.js +28 -0
- package/{chunk-KSV6T4AH.js → chunk-hqqqph5w.js} +12 -4
- package/{chunk-YQJEXXDK.js → chunk-hrngs1wy.js} +157 -246
- package/{chunk-LRLLWD4P.js → chunk-htf69s94.js} +14 -12
- package/chunk-j0yxesh3.js +83 -0
- package/{chunk-VF4K2QE6.js → chunk-j22t9g05.js} +3 -6
- package/{chunk-3R4AYHJR.js → chunk-j4a8m2zn.js} +5 -34
- package/chunk-j9p4jnwg.js +27 -0
- package/{chunk-R72QWIFO.js → chunk-jdycmfsm.js} +9 -9
- package/chunk-jdyvrne0.js +52 -0
- package/{spacePruneCommand-YKIEUIDQ.js → chunk-je0b66qf.js} +44 -62
- package/{chunk-HNMXYYJR.js → chunk-jec44fkj.js} +3 -4
- package/{chunk-526GLZJE.js → chunk-jf1ex00r.js} +107 -73
- package/chunk-jgqdec9b.js +31 -0
- package/{chunk-56GBUMO5.js → chunk-jkw9n4h5.js} +16 -25
- package/{chunk-7422ZLGL.js → chunk-jmnzdwjt.js} +867 -965
- package/chunk-jqq57s0a.js +58 -0
- package/{chunk-OKUSDVRS.js → chunk-jtkn5aj6.js} +27 -38
- package/chunk-jwvzn9r0.js +316 -0
- package/chunk-k1re0fc7.js +107 -0
- package/chunk-k2ep3rb2.js +103 -0
- package/{chunk-JEXVIMYZ.js → chunk-k6ycb24w.js} +5 -8
- package/{chunk-RI7SXDJW.js → chunk-kawvydbk.js} +383 -195
- package/chunk-kf2ghpzh.js +10 -0
- package/{chunk-S6FAHQDH.js → chunk-kgah9e46.js} +28 -59
- package/{chunk-T3MWVUBE.js → chunk-kjjepkvc.js} +71 -82
- package/chunk-kn4dgg4j.js +4113 -0
- package/{chunk-2LFYMWM3.js → chunk-kn5p91n8.js} +43 -53
- package/{chunk-MVOZ22RZ.js → chunk-kntqrbwc.js} +8 -12
- package/{chunk-I6YIA2TY.js → chunk-kq3vr7mx.js} +25 -20
- package/chunk-kz1x1d8n.js +15 -0
- package/{mcpLocalAuthorizeCommand-IKOFKY5U.js → chunk-m22e7tt2.js} +53 -71
- package/{chunk-ZNFJWEN4.js → chunk-m32rwr4d.js} +11 -8
- package/chunk-m39e9m18.js +93 -0
- package/{chunk-4D4QD7FT.js → chunk-m5518371.js} +64 -56
- package/{chunk-LHTXSC2E.js → chunk-mb5hnfyp.js} +9 -11
- package/chunk-mexet11v.js +11 -0
- package/chunk-mg2hgfgh.js +185 -0
- package/chunk-mmdhm4kx.js +10317 -0
- package/chunk-mz002yz8.js +2821 -0
- package/chunk-mzadqnyq.js +56 -0
- package/{chunk-VIDPVFP3.js → chunk-n3r1ebdm.js} +5 -6
- package/chunk-n438qea7.js +33 -0
- package/chunk-n5ffnhnb.js +93 -0
- package/chunk-nbvd87fy.js +9 -0
- package/{chunk-E36V7MPY.js → chunk-ndej7jc9.js} +53 -43
- package/{chunk-B767MA64.js → chunk-nen6rwe4.js} +62 -22
- package/chunk-nf06tr3v.js +16 -0
- package/chunk-ng8z355q.js +16 -0
- package/{chunk-4MEKE5D3.js → chunk-nhtxfv8k.js} +78 -63
- package/{runAgentClientLoop-2SFASHDS.js → chunk-nj62jscj.js} +132 -214
- package/{chunk-GBWGPTA7.js → chunk-nkryrkyp.js} +16 -19
- package/chunk-nmesxem8.js +197 -0
- package/{chunk-YR4J7RFS.js → chunk-nmq0qwbn.js} +117 -164
- package/chunk-nph8brvw.js +7 -0
- package/chunk-nr8fees9.js +10 -0
- package/{chunk-DFI7MVCQ.js → chunk-nvewvf7h.js} +1441 -1427
- package/{chunk-G7Y4GXTY.js → chunk-nyamhphs.js} +70 -79
- package/chunk-nz1c8tcg.js +111 -0
- package/{chunk-GPLUFN2E.js → chunk-nzc5yffh.js} +176 -217
- package/{chunk-G3SUCT4W.js → chunk-p1vg4bx8.js} +2 -4
- package/chunk-p3k3abe8.js +202 -0
- package/chunk-p4zy30q5.js +8 -0
- package/{chunk-ZJACPM5O.js → chunk-p6se1rx0.js} +102 -102
- package/chunk-p9dpshev.js +6968 -0
- package/chunk-pa42wxr0.js +116 -0
- package/{chunk-TA5QI4MM.js → chunk-paxthgqp.js} +56 -107
- package/{readlineWorkspace-ZH5FGDMI.js → chunk-pb35s8d9.js} +5395 -5786
- package/{chunk-XT6C2QZW.js → chunk-pbebzbcq.js} +8 -8
- package/chunk-pbx7e1mb.js +11 -0
- package/chunk-pe5czfn9.js +8 -0
- package/chunk-pextk1j4.js +62 -0
- package/chunk-pf5rywc6.js +575 -0
- package/chunk-pjfhd3fz.js +136 -0
- package/{chunk-ZCMAKAZM.js → chunk-pkhqb0fs.js} +118 -59
- package/chunk-pm5xb9jh.js +26 -0
- package/{chunk-Y3KGWZKF.js → chunk-ppdmmdkx.js} +110 -97
- package/chunk-pqp6y2hs.js +9 -0
- package/{chunk-QHEN7NZ7.js → chunk-ptz8fm2n.js} +12 -17
- package/{chunk-EUHMI5KG.js → chunk-pwqnvbt7.js} +65 -46
- package/chunk-pzr31nz7.js +12 -0
- package/{chunk-WWC7I6TA.js → chunk-q3cx89sw.js} +2 -4
- package/chunk-q5pe7be3.js +78 -0
- package/{chunk-ZHWTBHT3.js → chunk-q6zqbxp2.js} +418 -409
- package/chunk-q7r0e1p3.js +15 -0
- package/chunk-q8t2fecd.js +6 -0
- package/{chunk-2QAZCYOM.js → chunk-q94zx4d0.js} +721 -753
- package/{runtimeDoctorCommands-52MBG5JN.js → chunk-qarz1az1.js} +65 -85
- package/{chunk-4INJGWE3.js → chunk-qdcvr25b.js} +72 -53
- package/{streamAgentChatTurn-KOUWITHH.js → chunk-qxs27wfg.js} +1079 -1475
- package/{chunk-GIXWVN2W.js → chunk-r06ycjjr.js} +50 -47
- package/{chunk-63W5N6P3.js → chunk-r20jw5hb.js} +57 -38
- package/{chunk-I5BYFTYK.js → chunk-r7sfwdka.js} +1201 -1142
- package/{chunk-UMADT6B2.js → chunk-r9sp1yyb.js} +6 -8
- package/{handleSendMessageAction-FHGUFT2X.js → chunk-rbd2vgb3.js} +627 -757
- package/chunk-rc37js46.js +12 -0
- package/{chunk-5YI447UL.js → chunk-rmngk6r3.js} +67 -76
- package/chunk-rnhbnbrq.js +15 -0
- package/{chunk-WRHVVIGI.js → chunk-rsfnmrt5.js} +111 -131
- package/{chunk-YFSM2366.js → chunk-rvvn2rhj.js} +28 -22
- package/{chunk-4Y6CZ2N4.js → chunk-s0fpz7ht.js} +37 -33
- package/{chunk-VI4SWTUO.js → chunk-s1cqzb2r.js} +77 -65
- package/{chunk-6QDYSCPW.js → chunk-s8q81tda.js} +73 -65
- package/chunk-s9hy639e.js +6 -0
- package/{chunk-R5GO3YZP.js → chunk-s9vbwme8.js} +115 -106
- package/chunk-sger1m1b.js +20 -0
- package/chunk-spe6crvk.js +60 -0
- package/chunk-spwsrvh9.js +70 -0
- package/chunk-sr05zpk7.js +573 -0
- package/{chunk-M2EJHDJP.js → chunk-srncrd3f.js} +1 -12
- package/{chunk-QXHFIX7W.js → chunk-sry80bpx.js} +71 -53
- package/{chunk-PSCNXBYA.js → chunk-t6q69p83.js} +3 -4
- package/{chunk-UAD2WT54.js → chunk-t714r4q0.js} +9 -28
- package/chunk-t7vbraqe.js +42 -0
- package/{chunk-CVMMWN6P.js → chunk-td7653rr.js} +10 -20
- package/{chunk-3BQDF4QB.js → chunk-tmytcetz.js} +17 -21
- package/{chunk-AMWMV56B.js → chunk-tta4prwg.js} +16 -15
- package/chunk-tvh8azgq.js +4829 -0
- package/{chunk-ID4G2MAR.js → chunk-v08kbfm8.js} +10 -11
- package/{chunk-OKPOQGQJ.js → chunk-v1x702q8.js} +801 -852
- package/{chunk-KHCLMKZZ.js → chunk-v39fea91.js} +576 -247
- package/{chunk-OW765XBU.js → chunk-vejtd8p2.js} +3 -4
- package/chunk-vep7zkha.js +368 -0
- package/chunk-vfwn1k7n.js +142 -0
- package/chunk-vg68vxhx.js +20 -0
- package/chunk-vgcqgnsm.js +31 -0
- package/{chunk-NF64D32W.js → chunk-vnzyjdea.js} +1 -3
- package/{chunk-ZCLSM5AK.js → chunk-vqgtw1px.js} +800 -717
- package/chunk-vv1gr5xz.js +76 -0
- package/{spaceCommands-Z2CTQD6G.js → chunk-w1qeadpq.js} +176 -242
- package/chunk-w468ez1p.js +13 -0
- package/chunk-w49s0t79.js +14 -0
- package/{mcpLocalManageCommands-KUDZQRM4.js → chunk-w58zhfbn.js} +91 -93
- package/chunk-w5b74aq6.js +11 -0
- package/chunk-w7y41qyw.js +117 -0
- package/chunk-w820gg1w.js +4165 -0
- package/{chunk-DBJAJ4UD.js → chunk-wdsmaqmt.js} +399 -453
- package/{chunk-3EUW3WEO.js → chunk-wfvvnmmj.js} +1 -3
- package/{chunk-QY4NZCDA.js → chunk-wkr04bhk.js} +432 -651
- package/{chunk-KUG52IAP.js → chunk-ws402twv.js} +1 -3
- package/chunk-wzwh311q.js +164 -0
- package/{runtimeModeArgs-X7DL7PUN.js → chunk-x5vtgvwn.js} +6 -5
- package/{agentMachineCommands-COJD2KPZ.js → chunk-x8h2csmq.js} +152 -195
- package/{chunk-BAZCS5XG.js → chunk-x9zfjnrc.js} +59 -47
- package/{chunk-WTIJKWCI.js → chunk-xcarc2rf.js} +50 -56
- package/chunk-xf33gz0a.js +8 -0
- package/{chunk-PVFYPUIM.js → chunk-y7b3gwx1.js} +78 -71
- package/{memoryCommands-SVLAVFCV.js → chunk-y7sphmnh.js} +119 -95
- package/{agentListCommands-436FHOIT.js → chunk-ycvaafhc.js} +260 -374
- package/chunk-yd7zprb0.js +9 -0
- package/chunk-yfz3d27k.js +40 -0
- package/{chunk-MKR6KDD3.js → chunk-ykv9g3m4.js} +141 -125
- package/chunk-ystjgb9e.js +544 -0
- package/chunk-yysxn7ep.js +12 -0
- package/{chunk-AL3TYDIF.js → chunk-z17eyawk.js} +18 -16
- package/{machineCommands-RVB5OG2X.js → chunk-z17q416p.js} +442 -563
- package/chunk-z1n98pcf.js +12 -0
- package/{dialogTraceCommand-HWXGIGZX.js → chunk-z566jx5r.js} +292 -397
- package/chunk-zjxd6942.js +6 -0
- package/{versionChangeNotice-RFABJGJE.js → chunk-zk11x9y5.js} +7 -9
- package/{chunk-TEFD5E2D.js → chunk-zt73yc33.js} +48 -51
- package/chunk-zvs2fra1.js +5 -0
- package/{chunk-SVFFKLMR.js → chunk-zwee84rh.js} +117 -141
- package/chunk-zxgfqv72.js +8 -0
- package/index.js +53 -69
- package/package.json +4 -4
- package/_executeModel-YQNZNR2Y.js +0 -341
- package/action-UK3HXGXF.js +0 -30
- package/addContentAction-CAKFVBDM.js +0 -38
- package/addDialogAgentAction-KLJ2YWWM.js +0 -77
- package/agentDeleteCommand-S5FVPYKT.js +0 -523
- package/agentEmailCommands-ZEFMGVKM.js +0 -742
- package/agentRecordCommands-JZ35AC5A.js +0 -211
- package/agentRun-UIO43TUG.js +0 -251
- package/agentRunCommand-ATLKKD6O.js +0 -249
- package/agentRunControl-U2MV74WR.js +0 -211
- package/agentRuntimeLocal-P4MMGIR6.js +0 -189
- package/agentSlice-HHNKNNYM.js +0 -52
- package/appConfigCommands-W4JQHMOJ.js +0 -417
- package/appDeleteCommands-IXR47IAV.js +0 -183
- package/appDeployCommands-LB6DHDF4.js +0 -232
- package/appDeployStatusCommands-UQ6MJL6D.js +0 -204
- package/appGetCommands-M5JCTDDQ.js +0 -185
- package/appListCommands-TE3ZHE3I.js +0 -186
- package/appMigrateCommands-FOXH6R4B.js +0 -230
- package/appSourceCommands-3ACYB6I7.js +0 -279
- package/authCommand-I5OBJP5S.js +0 -66
- package/authCommands-I6KCGOCN.js +0 -54
- package/builtinSkillRegistry-MIXYSZUU.js +0 -35
- package/chromeOpsCommands-IZRCYDSW.js +0 -579
- package/chunk-24BICQPB.js +0 -25
- package/chunk-2E4BYAUE.js +0 -69
- package/chunk-2O72G3U2.js +0 -17157
- package/chunk-2OROOEOQ.js +0 -229
- package/chunk-2R6M34JP.js +0 -27225
- package/chunk-2SXN7LAY.js +0 -15
- package/chunk-35JIFLIG.js +0 -30
- package/chunk-3VXVE2LF.js +0 -12
- package/chunk-4DBTBNTX.js +0 -477
- package/chunk-4JH2UMJR.js +0 -40
- package/chunk-4RUQ2PFX.js +0 -432
- package/chunk-4SN6J65J.js +0 -38
- package/chunk-5MMAK75Q.js +0 -15
- package/chunk-6NYQHXMV.js +0 -1737
- package/chunk-6R4IY46J.js +0 -14
- package/chunk-7E6YXSFZ.js +0 -441
- package/chunk-7K4J76JQ.js +0 -917
- package/chunk-7LR2IFUH.js +0 -100
- package/chunk-AETZ7AD6.js +0 -274
- package/chunk-ATNTHIZI.js +0 -13
- package/chunk-BPB3T5EU.js +0 -791
- package/chunk-BV3FLP2L.js +0 -133
- package/chunk-BVYHE6QD.js +0 -110
- package/chunk-BWJLEN6X.js +0 -1388
- package/chunk-CHOZJMJS.js +0 -78
- package/chunk-D2LTQAGN.js +0 -464
- package/chunk-DALXH7BG.js +0 -3392
- package/chunk-DBCWXGOC.js +0 -15210
- package/chunk-DLXL4NSL.js +0 -1179
- package/chunk-DSBRIUX5.js +0 -23
- package/chunk-DWLEOOGR.js +0 -8
- package/chunk-E2KZNP6C.js +0 -13
- package/chunk-E5JV4DCB.js +0 -272
- package/chunk-EUGTFFO6.js +0 -42
- package/chunk-FBNVJ2TO.js +0 -294
- package/chunk-FGXG6OLW.js +0 -34
- package/chunk-G22P2J7O.js +0 -1775
- package/chunk-HEVRQGGH.js +0 -106
- package/chunk-HHXF57CL.js +0 -180
- package/chunk-HI5RS2O4.js +0 -2109
- package/chunk-HJTI7RZV.js +0 -94
- package/chunk-HRWRIPTB.js +0 -531
- package/chunk-HYCVEESH.js +0 -2824
- package/chunk-I42VC5KR.js +0 -15
- package/chunk-IB5AR52X.js +0 -15
- package/chunk-IIRJ4P4I.js +0 -24
- package/chunk-IT3ZZRJE.js +0 -12
- package/chunk-IV6VUVLJ.js +0 -88
- package/chunk-J42X32PV.js +0 -472
- package/chunk-JDMWYVUF.js +0 -449
- package/chunk-JKVOKKMQ.js +0 -53
- package/chunk-JRTNUU5Z.js +0 -54
- package/chunk-K7HLFORE.js +0 -226
- package/chunk-KGBASAB5.js +0 -74
- package/chunk-KGKTN2NX.js +0 -25
- package/chunk-KX6YBIHG.js +0 -8
- package/chunk-KYHNSSL2.js +0 -62
- package/chunk-KZO2MTVM.js +0 -140
- package/chunk-LKZPX6YH.js +0 -0
- package/chunk-LLP2NDED.js +0 -201
- package/chunk-LOFRSJX2.js +0 -47
- package/chunk-M75RM77T.js +0 -3970
- package/chunk-MDAYRIP7.js +0 -1889
- package/chunk-MI6HRMCK.js +0 -25
- package/chunk-MTNQNLSE.js +0 -1029
- package/chunk-NH4PUEWK.js +0 -762
- package/chunk-NHLLXINQ.js +0 -8
- package/chunk-NTUNHTJV.js +0 -40
- package/chunk-OJKUU3LP.js +0 -67
- package/chunk-OQH3TAB7.js +0 -299
- package/chunk-P62DHV4F.js +0 -443
- package/chunk-PHIERFHT.js +0 -574
- package/chunk-PKDFU6MY.js +0 -102
- package/chunk-PL5RKESU.js +0 -40
- package/chunk-PSJJBBWV.js +0 -42
- package/chunk-QKM55LP2.js +0 -739
- package/chunk-QQ56R7KS.js +0 -88
- package/chunk-QYPE3TS3.js +0 -43
- package/chunk-REAE2SZK.js +0 -62
- package/chunk-RGQ4UUWZ.js +0 -208
- package/chunk-RIRFHJTW.js +0 -353
- package/chunk-RYMLMTPZ.js +0 -547
- package/chunk-SSGTV4FC.js +0 -303
- package/chunk-SVKWZ3EG.js +0 -607
- package/chunk-T7KODHYS.js +0 -317
- package/chunk-TGVVE5BA.js +0 -3085
- package/chunk-TKLBBR7P.js +0 -779
- package/chunk-TZXPT53C.js +0 -8
- package/chunk-U67V476Y.js +0 -35
- package/chunk-UEILX4EV.js +0 -15
- package/chunk-VIWDGTDA.js +0 -8
- package/chunk-VXUQWCEZ.js +0 -138
- package/chunk-W5GKF5ZW.js +0 -32
- package/chunk-WDWZPASX.js +0 -29
- package/chunk-WX266G2C.js +0 -9594
- package/chunk-YCITCYSJ.js +0 -356
- package/chunk-Z3KTXWWB.js +0 -76
- package/chunk-ZC3CMUKU.js +0 -322
- package/chunk-ZSZBHRLP.js +0 -1710
- package/chunk-ZV7ZY46L.js +0 -1343
- package/cliAgentConfigHelpers-WB2S7PDO.js +0 -47
- package/cliAuthorityBrokerClient-3SKOA7OZ.js +0 -23
- package/cliAuthorityBrokerProcess-BMBVXPKU.js +0 -24
- package/cliAuthorityStoreDriver-6FE3BJNB.js +0 -20
- package/cliEnvHelpers-7V5ZWUJA.js +0 -34
- package/cliExecutor-N3445G2Z.js +0 -45
- package/cliLocalAgentRecordReader-QKKRK53P.js +0 -113
- package/cloudAutomationCommands-S52NKCLL.js +0 -310
- package/contentThunks-ERA42OXW.js +0 -100
- package/cooldownCommands-ZFDAL4MR.js +0 -79
- package/createAgentAutomationAction-DMD2VDPI.js +0 -173
- package/createDialogAction-3SPOJQAK.js +0 -87
- package/createPageAction-AVXUMZVT.js +0 -91
- package/cursorProvider-2RACMEMF.js +0 -6123
- package/db-LTHLW7QA.js +0 -178
- package/dbSlice-WNUHTF4C.js +0 -76
- package/deleteDbKey-KV6MYBAI.js +0 -87
- package/desktopFolderProjects-4POAMVJN.js +0 -45
- package/dialogCommands-4MOLJW4G.js +0 -165
- package/dialogMessageRecord-2HJTEXQX.js +0 -7
- package/dialogNotifyCommand-YL2GFKLO.js +0 -45
- package/dialogSlice-Q7H2YVNO.js +0 -200
- package/dialogUsageCommand-IO2BQKL2.js +0 -31
- package/docCreateCommands-OYLRBK2M.js +0 -255
- package/docDeleteCommands-3NF6QPJU.js +0 -226
- package/docReadCommands-CBAERJAP.js +0 -184
- package/docStore-GWPFDV6Y.js +0 -89
- package/docUpdateCommands-BAMCGX6F.js +0 -326
- package/ebookDownloaderAgentCommand-NOIZ6U7Y.js +0 -675
- package/fetchMessages-P7FSCSXV.js +0 -19
- package/getPricing-KNXVEIUI.js +0 -40
- package/hostCredentialCreate-2VEYBXJV.js +0 -402
- package/i18n-SAK6DDY4.js +0 -51
- package/keys-FXEGMKSG.js +0 -183
- package/legacyMigration-TF4SYJCZ.js +0 -19
- package/levelAuthorityStore-L5SVDM5O.js +0 -10
- package/localAutomationCommands-XSK7SM7I.js +0 -199
- package/localAutomationRuntime-5WBO7HGQ.js +0 -61
- package/localRecall-BDYKXB46.js +0 -17
- package/localRuntimeAdapter-Y6H6XRIH.js +0 -310
- package/localRuntimeAuthority-Q5C2KWGF.js +0 -45
- package/localRuntimeDb-MM3DINZM.js +0 -12
- package/machineInfo-HNPJHQFU.js +0 -14
- package/machineWsRunDispatch-Y5SJGCEE.js +0 -228
- package/models-TOXYINNM.js +0 -10
- package/oauthTokenStore-RUYNYALS.js +0 -24
- package/overlay-JA3SPVUS.js +0 -15
- package/parityCommands-5OCBPVES.js +0 -613
- package/processSpawn-6GEO77KV.js +0 -11
- package/profileConfig-KOWK4HOG.js +0 -49
- package/projectArchive-WE3VVPZ2.js +0 -132
- package/providerPresetApply-YCVSP2WX.js +0 -235
- package/providerRegistry-26PAUYH2.js +0 -24
- package/read-D4WYJQJQ.js +0 -32
- package/readDocTool-3S3OQFOH.js +0 -22
- package/rememberExplicit-ZPI6KK5M.js +0 -16
- package/remove-AHRMUDMH.js +0 -32
- package/removeDialogAgentAction-AALRBFSA.js +0 -81
- package/secretCommands-2PSS3QNZ.js +0 -24
- package/setDialogExtraReferencesAction-SLHQ3GYL.js +0 -39
- package/setPrimaryDialogAgentAction-XKCSGJ7M.js +0 -96
- package/skillDiscovery-IUEZZG2B.js +0 -29
- package/skillSummaryMarker-62UW7HI7.js +0 -9
- package/slateToRenderMarkdown-R3X74MCX.js +0 -7
- package/slateUtils-ESQAJ6RN.js +0 -19
- package/store-WSAVTR32.js +0 -50
- package/switchDialogAgentAction-YJIWQGIR.js +0 -70
- package/tombstones-FQQMEDOW.js +0 -32
- package/toolApiClient-FVXTIIEN.js +0 -42
- package/tools-WN4AVSNS.js +0 -147
- package/tuiRestart-LU2BDLAW.js +0 -50
- package/tuiSummaryLlmCaller-Z2ZVBIGN.js +0 -53
- package/updateCommands-4QP7WJLA.js +0 -63
- package/usageCommand-AZX7D3LB.js +0 -31
- package/usageRebuildCommand-XV5QQCHK.js +0 -623
- package/userDataMerge-HT2ZVHBJ.js +0 -13
- package/windowsSelfUpdate-5OFKSW6Y.js +0 -14
- package/workContext-ZAW6VXT7.js +0 -18
- package/workContextAccess-VU5I4LKZ.js +0 -11
- package/workContextWriteNotice-YCSSMHN4.js +0 -7
- /package/{chunk-BYXBJQAS.js → chunk-0bcc25vg.js} +0 -0
|
@@ -1,108 +1,301 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
2
|
+
isPlatformManagedProvider,
|
|
3
|
+
PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL,
|
|
4
|
+
resolvePlatformEffectiveModel,
|
|
5
|
+
platformHostedModels
|
|
6
|
+
} from "./chunk-fkrgqq8w.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
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-
|
|
16
|
+
} from "./chunk-t6q69p83.js";
|
|
13
17
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
normalizeTimingMs
|
|
19
|
+
} from "./chunk-996j61av.js";
|
|
16
20
|
import {
|
|
17
|
-
|
|
18
|
-
} from "./chunk-
|
|
21
|
+
sha256Hex2
|
|
22
|
+
} from "./chunk-kn5p91n8.js";
|
|
19
23
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
resolvePlatformEffectiveModel
|
|
23
|
-
} from "./chunk-G22P2J7O.js";
|
|
24
|
+
isAbortError
|
|
25
|
+
} from "./chunk-a7bz6nc3.js";
|
|
24
26
|
import {
|
|
25
27
|
asTrimmedLowercaseString
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import {
|
|
28
|
-
asTrimmedNonEmptyStringArray
|
|
29
|
-
} from "./chunk-I42VC5KR.js";
|
|
28
|
+
} from "./chunk-h1hzmqph.js";
|
|
30
29
|
import {
|
|
31
30
|
asOptionalFiniteNumber
|
|
32
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-q3cx89sw.js";
|
|
32
|
+
import {
|
|
33
|
+
asTrimmedNonEmptyStringArray
|
|
34
|
+
} from "./chunk-w5b74aq6.js";
|
|
33
35
|
import {
|
|
34
36
|
asOptionalTrimmedString
|
|
35
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-p1vg4bx8.js";
|
|
36
38
|
|
|
37
|
-
// packages/
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
|
92
|
+
return model;
|
|
63
93
|
}
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
return
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
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))
|
|
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")
|
|
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 !==
|
|
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")
|
|
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 ===
|
|
321
|
+
if (value === undefined)
|
|
322
|
+
continue;
|
|
127
323
|
sawField = true;
|
|
128
|
-
if (value !== 0)
|
|
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))
|
|
346
|
+
if (!Array.isArray(value))
|
|
347
|
+
return;
|
|
150
348
|
const normalized = [...new Set(asTrimmedNonEmptyStringArray(value))];
|
|
151
|
-
return normalized.length > 0 ? normalized :
|
|
349
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
152
350
|
};
|
|
153
351
|
var finiteTokenCount2 = (value) => {
|
|
154
352
|
const finite = asOptionalFiniteNumber(value);
|
|
155
|
-
if (finite ===
|
|
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")
|
|
160
|
-
|
|
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")
|
|
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 !==
|
|
389
|
+
if (providedCost !== undefined) {
|
|
188
390
|
cost = providedCost;
|
|
189
391
|
}
|
|
190
392
|
const xaiTicks = readCostInUsdTicks(usage);
|
|
191
|
-
if (xaiTicks !==
|
|
192
|
-
cost = xaiTicks /
|
|
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) :
|
|
201
|
-
const providerResponseIds = normalizeStringArray(
|
|
202
|
-
|
|
203
|
-
);
|
|
204
|
-
const
|
|
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 !==
|
|
230
|
-
...firstOutputMs !==
|
|
231
|
-
...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/
|
|
236
|
-
var
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
311
|
-
|
|
439
|
+
function isOAuthApiKeyRef(value) {
|
|
440
|
+
const ref = asTrimmedLowercaseString(value);
|
|
441
|
+
return ref.length > 0 && OAUTH_APIKEY_REFS.has(ref);
|
|
312
442
|
}
|
|
313
|
-
function
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
-
|
|
341
|
-
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
467
|
+
|
|
468
|
+
// packages/core/compactWhitespace.ts
|
|
469
|
+
function compactWhitespace(value) {
|
|
470
|
+
return value.replace(/\s+/g, " ").trim();
|
|
346
471
|
}
|
|
347
472
|
|
|
348
|
-
// packages/
|
|
349
|
-
function
|
|
350
|
-
|
|
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
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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
|
|
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 =
|
|
388
|
-
var TOOL_OUTPUT_CAP_MAX_TOKENS =
|
|
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)
|
|
517
|
+
if (!text)
|
|
518
|
+
return text;
|
|
399
519
|
const capTokens = capToolOutputTokens(contextWindow);
|
|
400
|
-
if (estimateTokenCount(text) <= capTokens)
|
|
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)
|
|
416
|
-
|
|
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 =
|
|
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)
|
|
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))
|
|
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 :
|
|
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:
|
|
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)
|
|
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 !==
|
|
479
|
-
const triggeredByEstimate = usageRatio ===
|
|
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;
|
|
614
|
+
for (let i = pendingMsgs.length - 1;i >= 0; i--) {
|
|
493
615
|
const t = getMessageTokenCount(pendingMsgs[i]);
|
|
494
|
-
if (tokensToKeep + t > rawMessageBudget)
|
|
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;
|
|
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;
|
|
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 :
|
|
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 !==
|
|
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 !==
|
|
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) ===
|
|
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(
|
|
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 !==
|
|
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)
|
|
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;
|
|
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
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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
|
-
|
|
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 =
|
|
956
|
+
var COMPACTION_SUMMARY_SYSTEM_PROMPT = `你是对话上下文压缩器。根据【现有记忆】和【新增对话】,输出可替代原始消息的事实性要点,供后续对话直接使用。
|
|
681
957
|
|
|
682
|
-
|
|
683
|
-
|
|
958
|
+
严格只输出下面三部分,标题必须完全一致:
|
|
959
|
+
关键事实档案
|
|
684
960
|
- ...
|
|
685
|
-
|
|
961
|
+
对话进展与待办
|
|
686
962
|
- ...
|
|
687
|
-
|
|
963
|
+
文件操作清单
|
|
688
964
|
- ...
|
|
689
965
|
|
|
690
|
-
|
|
691
|
-
1)
|
|
692
|
-
2)
|
|
693
|
-
-
|
|
694
|
-
"
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
-
|
|
703
|
-
-
|
|
704
|
-
-
|
|
705
|
-
3)
|
|
706
|
-
4)
|
|
707
|
-
5)
|
|
708
|
-
6)
|
|
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)
|
|
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 "[
|
|
992
|
+
return "[非文本内容]";
|
|
716
993
|
}
|
|
717
994
|
function buildCompactionUserContent(args) {
|
|
718
995
|
const parts = [];
|
|
719
|
-
if (args.outputTokenBudget !==
|
|
996
|
+
if (args.outputTokenBudget !== undefined) {
|
|
720
997
|
const budget = args.outputTokenBudget;
|
|
721
|
-
if (!Number.isFinite(budget) || budget < 1)
|
|
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(
|
|
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(
|
|
727
|
-
${args.previousSummary || "(
|
|
728
|
-
if (args.fileOpsText !==
|
|
729
|
-
parts.push(
|
|
730
|
-
${args.fileOpsText || "
|
|
1004
|
+
parts.push(`【现有记忆】:
|
|
1005
|
+
${args.previousSummary || "(无)"}`);
|
|
1006
|
+
if (args.fileOpsText !== undefined) {
|
|
1007
|
+
parts.push(`【文件操作清单】:
|
|
1008
|
+
${args.fileOpsText || "无"}`);
|
|
731
1009
|
}
|
|
732
|
-
parts.push(
|
|
1010
|
+
parts.push(`【新增对话】:
|
|
733
1011
|
${args.messagesText}`);
|
|
734
|
-
return parts.join(
|
|
1012
|
+
return parts.join(`
|
|
1013
|
+
|
|
1014
|
+
`).trim();
|
|
735
1015
|
}
|
|
736
1016
|
function extractFileOperationsFromCalls(calls, resolveCanonicalName) {
|
|
737
1017
|
const result = [];
|
|
738
|
-
const seen =
|
|
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)
|
|
1026
|
+
if (!rawName)
|
|
1027
|
+
continue;
|
|
747
1028
|
const canonicalName = resolveCanonicalName(rawName);
|
|
748
1029
|
const opType = fileOperationByTool[canonicalName];
|
|
749
|
-
if (!opType)
|
|
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(
|
|
1053
|
+
const evidence = selectEvidenceLines(content.split(`
|
|
1054
|
+
`));
|
|
773
1055
|
return (maxChars) => {
|
|
774
|
-
if (content.length <= maxChars)
|
|
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)
|
|
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)
|
|
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(
|
|
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 ?
|
|
804
|
-
return `[... ${range}
|
|
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 = "[
|
|
813
|
-
return returned === 0 ? `${scope}
|
|
1099
|
+
const scope = "[本段历史范围内";
|
|
1100
|
+
return returned === 0 ? `${scope},该工具批次在后续用户消息前没有记录到结果,按中断处理:声明过的调用不计为已完成。]` : `${scope},该工具批次声明了 ${declared} 个调用,只记录了 ${returned} 个结果;未记录结果的调用按中断处理,不计为已完成。]`;
|
|
814
1101
|
}
|
|
815
1102
|
function projectInterruptedHistoricalBatches(source) {
|
|
816
|
-
const resultIndices =
|
|
1103
|
+
const resultIndices = new Map;
|
|
817
1104
|
source.forEach((msg, index) => {
|
|
818
|
-
const resultId = msg.role === "tool" ? msg.tool_call_id :
|
|
819
|
-
if (typeof resultId !== "string" || !resultId)
|
|
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)
|
|
822
|
-
|
|
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)
|
|
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)
|
|
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))
|
|
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")
|
|
838
|
-
|
|
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)
|
|
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")
|
|
859
|
-
|
|
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))
|
|
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 ===
|
|
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: "
|
|
1177
|
+
return { text: "无", keptCount: 0, droppedReads: 0 };
|
|
882
1178
|
}
|
|
883
1179
|
const readIndices = [];
|
|
884
|
-
for (let i = 0;
|
|
885
|
-
if (operations[i].type === "read")
|
|
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
|
-
|
|
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;
|
|
894
|
-
if (droppedReadSet.has(i))
|
|
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(`- (...
|
|
1196
|
+
lines.push(`- (... 其余 ${droppedReads} 条只读探索路径已省略)`);
|
|
901
1197
|
}
|
|
902
1198
|
return {
|
|
903
|
-
text: lines.join(
|
|
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)
|
|
927
|
-
|
|
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;
|
|
1228
|
+
for (let i = 0;i < msgs.length; ) {
|
|
930
1229
|
const msg = msgs[i];
|
|
931
|
-
if (msg.role === "tool")
|
|
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 !==
|
|
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 !==
|
|
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)
|
|
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 =
|
|
1257
|
+
const operations = new Map;
|
|
957
1258
|
for (const msg of msgs) {
|
|
958
|
-
if (!Array.isArray(msg.tool_calls))
|
|
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 = "
|
|
966
|
-
const omitted = "[...
|
|
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)
|
|
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 = (
|
|
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(
|
|
1025
|
-
const room = () =>
|
|
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])
|
|
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(
|
|
1341
|
+
const headBudget = Math.floor(budget * SUMMARY_HEAD_SHARE);
|
|
1038
1342
|
let headEnd = -1;
|
|
1039
1343
|
let headUsed = 0;
|
|
1040
|
-
for (let i = 0;
|
|
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)
|
|
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(
|
|
1353
|
+
const userBudget = Math.floor(budget * SUMMARY_USER_SHARE);
|
|
1049
1354
|
let userSpend = 0;
|
|
1050
|
-
for (let i = msgs.length - 1;
|
|
1051
|
-
if (expanded[i] || msgs[i].role !== "user")
|
|
1052
|
-
|
|
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())
|
|
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;
|
|
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())
|
|
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)
|
|
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))
|
|
1078
|
-
|
|
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;
|
|
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())
|
|
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;
|
|
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())
|
|
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 =
|
|
1106
|
-
const resultsOfCall =
|
|
1107
|
-
for (let i = 0;
|
|
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)
|
|
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;
|
|
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 ===
|
|
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)
|
|
1124
|
-
|
|
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;
|
|
1128
|
-
if (!expanded[i] || msgs[i].role !== "tool")
|
|
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 ===
|
|
1449
|
+
if (callIndex === undefined || !expanded[callIndex])
|
|
1450
|
+
drop(i);
|
|
1131
1451
|
}
|
|
1132
1452
|
return { expanded, allowances };
|
|
1133
1453
|
};
|
|
1134
|
-
const render = (
|
|
1135
|
-
const { expanded, allowances } = selectRegions(
|
|
1454
|
+
const render = (budget) => {
|
|
1455
|
+
const { expanded, allowances } = selectRegions(budget);
|
|
1136
1456
|
const pieces = [];
|
|
1137
1457
|
let runStart = -1;
|
|
1138
|
-
let runCounts =
|
|
1458
|
+
let runCounts = new Map;
|
|
1139
1459
|
const flushRun = (end) => {
|
|
1140
|
-
if (runStart < 0)
|
|
1460
|
+
if (runStart < 0)
|
|
1461
|
+
return;
|
|
1141
1462
|
pieces.push(formatOmittedRun(runStart, end, runCounts));
|
|
1142
1463
|
runStart = -1;
|
|
1143
|
-
runCounts =
|
|
1464
|
+
runCounts = new Map;
|
|
1144
1465
|
};
|
|
1145
1466
|
let expandedCount = 0;
|
|
1146
|
-
for (let i = 0;
|
|
1467
|
+
for (let i = 0;i < msgs.length; i++) {
|
|
1147
1468
|
if (!expanded[i]) {
|
|
1148
|
-
if (runStart < 0)
|
|
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(
|
|
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;
|
|
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 =
|
|
1190
|
-
var SUMMARY_INPUT_MAX_TOKENS =
|
|
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)
|
|
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 !==
|
|
1250
|
-
...summaryInput.expandedMessages !==
|
|
1251
|
-
...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 !==
|
|
1254
|
-
...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 !==
|
|
1279
|
-
const omittedSuffix = metrics.summaryOmittedMessages !==
|
|
1280
|
-
const projectionInfo = metrics.summaryInputTokens !==
|
|
1281
|
-
const planInfo = 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)
|
|
1604
|
+
if (!summarizedBeforeId)
|
|
1605
|
+
return;
|
|
1286
1606
|
const found = messagesWithIds.findIndex((m) => m.id === summarizedBeforeId);
|
|
1287
|
-
if (found === -1)
|
|
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 =
|
|
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
|
-
|
|
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 };
|