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,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseResetsInMs
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-b00vzjkb.js";
|
|
4
4
|
|
|
5
5
|
// packages/ai/agent/quotaSnapshot.ts
|
|
6
6
|
function normalizeHeaders(headers) {
|
|
7
7
|
const out = {};
|
|
8
|
-
if (!headers)
|
|
8
|
+
if (!headers)
|
|
9
|
+
return out;
|
|
9
10
|
if (typeof headers.get === "function") {
|
|
10
11
|
headers.forEach((value, key) => {
|
|
11
12
|
out[key.toLowerCase()] = value;
|
|
@@ -13,48 +14,59 @@ function normalizeHeaders(headers) {
|
|
|
13
14
|
return out;
|
|
14
15
|
}
|
|
15
16
|
for (const [key, value] of Object.entries(headers)) {
|
|
16
|
-
if (typeof value === "string")
|
|
17
|
+
if (typeof value === "string")
|
|
18
|
+
out[key.toLowerCase()] = value;
|
|
17
19
|
}
|
|
18
20
|
return out;
|
|
19
21
|
}
|
|
20
22
|
function readNumber(raw) {
|
|
21
|
-
if (typeof raw === "number" && Number.isFinite(raw))
|
|
23
|
+
if (typeof raw === "number" && Number.isFinite(raw))
|
|
24
|
+
return raw >= 0 ? raw : undefined;
|
|
22
25
|
if (typeof raw === "string") {
|
|
23
26
|
const n = Number(raw.trim());
|
|
24
|
-
if (Number.isFinite(n) && n >= 0)
|
|
27
|
+
if (Number.isFinite(n) && n >= 0)
|
|
28
|
+
return n;
|
|
25
29
|
}
|
|
26
|
-
return
|
|
30
|
+
return;
|
|
27
31
|
}
|
|
28
32
|
function readResetAt(raw, now) {
|
|
29
33
|
if (typeof raw === "number" && Number.isFinite(raw)) {
|
|
30
|
-
if (raw >=
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
if (raw >= 1000000000000)
|
|
35
|
+
return raw;
|
|
36
|
+
if (raw >= 1e9)
|
|
37
|
+
return raw * 1000;
|
|
38
|
+
return raw > 0 ? now + raw * 1000 : now;
|
|
33
39
|
}
|
|
34
|
-
if (typeof raw !== "string")
|
|
40
|
+
if (typeof raw !== "string")
|
|
41
|
+
return;
|
|
35
42
|
const text = raw.trim();
|
|
36
|
-
if (!text)
|
|
43
|
+
if (!text)
|
|
44
|
+
return;
|
|
37
45
|
const msMatch = /^(\d+(?:\.\d+)?)ms$/i.exec(text);
|
|
38
46
|
let dur;
|
|
39
47
|
if (msMatch) {
|
|
40
|
-
dur = Number(msMatch[1]) /
|
|
48
|
+
dur = Number(msMatch[1]) / 1000;
|
|
41
49
|
} else {
|
|
42
50
|
const m = /^(?:(\d+(?:\.\d+)?)h)?(?:(\d+(?:\.\d+)?)m)?(?:(\d+(?:\.\d+)?)s)?$/i.exec(text);
|
|
43
51
|
dur = m && (m[1] || m[2] || m[3]) ? Number(m[1] ?? 0) * 3600 + Number(m[2] ?? 0) * 60 + Number(m[3] ?? 0) : NaN;
|
|
44
52
|
}
|
|
45
|
-
if (Number.isFinite(dur))
|
|
53
|
+
if (Number.isFinite(dur))
|
|
54
|
+
return now + dur * 1000;
|
|
46
55
|
const n = Number(text);
|
|
47
56
|
if (Number.isFinite(n)) {
|
|
48
|
-
if (n >=
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
if (n >= 1000000000000)
|
|
58
|
+
return n;
|
|
59
|
+
if (n >= 1e9)
|
|
60
|
+
return n * 1000;
|
|
61
|
+
return n > 0 ? now + n * 1000 : now;
|
|
51
62
|
}
|
|
52
63
|
const parsed = Date.parse(text);
|
|
53
|
-
return Number.isFinite(parsed) ? parsed :
|
|
64
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
54
65
|
}
|
|
55
66
|
function readUtilization(raw) {
|
|
56
67
|
const n = readNumber(raw);
|
|
57
|
-
if (n ===
|
|
68
|
+
if (n === undefined)
|
|
69
|
+
return;
|
|
58
70
|
return n > 1 ? n / 100 : n;
|
|
59
71
|
}
|
|
60
72
|
function mergeWindow(into, win) {
|
|
@@ -63,43 +75,55 @@ function mergeWindow(into, win) {
|
|
|
63
75
|
into.set(win.scope, { ...win });
|
|
64
76
|
return;
|
|
65
77
|
}
|
|
66
|
-
if (win.resetAt !==
|
|
67
|
-
existing.resetAt = existing.resetAt ===
|
|
78
|
+
if (win.resetAt !== undefined) {
|
|
79
|
+
existing.resetAt = existing.resetAt === undefined ? win.resetAt : Math.max(existing.resetAt, win.resetAt);
|
|
68
80
|
}
|
|
69
|
-
if (win.remaining !==
|
|
70
|
-
existing.remaining = existing.remaining ===
|
|
81
|
+
if (win.remaining !== undefined) {
|
|
82
|
+
existing.remaining = existing.remaining === undefined ? win.remaining : Math.min(existing.remaining, win.remaining);
|
|
71
83
|
}
|
|
72
|
-
if (win.limit !==
|
|
73
|
-
existing.limit = existing.limit ===
|
|
84
|
+
if (win.limit !== undefined) {
|
|
85
|
+
existing.limit = existing.limit === undefined ? win.limit : Math.min(existing.limit, win.limit);
|
|
74
86
|
}
|
|
75
|
-
if (win.utilization !==
|
|
76
|
-
existing.utilization = existing.utilization ===
|
|
87
|
+
if (win.utilization !== undefined) {
|
|
88
|
+
existing.utilization = existing.utilization === undefined ? win.utilization : Math.max(existing.utilization, win.utilization);
|
|
77
89
|
}
|
|
78
|
-
if (win.unit !==
|
|
90
|
+
if (win.unit !== undefined && existing.unit === undefined)
|
|
91
|
+
existing.unit = win.unit;
|
|
79
92
|
existing.source = win.source;
|
|
80
93
|
}
|
|
94
|
+
var SUBSCRIPTION_PERIOD_SCOPES = new Set([
|
|
95
|
+
"daily",
|
|
96
|
+
"weekly",
|
|
97
|
+
"monthly",
|
|
98
|
+
"credits",
|
|
99
|
+
"extra-usage"
|
|
100
|
+
]);
|
|
81
101
|
function parseQuotaWindowScope(scope) {
|
|
82
102
|
const matched = /^(gemini|3p|hydrogen|argon)-(.+)$/.exec(scope);
|
|
83
103
|
return matched ? { family: matched[1], period: matched[2] } : { period: scope };
|
|
84
104
|
}
|
|
85
105
|
function resolveQuotaWindowFamily(model) {
|
|
86
|
-
if (typeof model !== "string" || !model.trim())
|
|
87
|
-
|
|
88
|
-
if (/(?:^|[/-])gemini-[^/]*
|
|
106
|
+
if (typeof model !== "string" || !model.trim())
|
|
107
|
+
return;
|
|
108
|
+
if (/(?:^|[/-])gemini-[^/]*hydrogen(?:-|$)/i.test(model))
|
|
109
|
+
return "hydrogen";
|
|
110
|
+
if (/(?:^|[/-])gemini-[^/]*argon(?:-|$)/i.test(model))
|
|
111
|
+
return "argon";
|
|
89
112
|
return /gemini/i.test(model) ? "gemini" : "3p";
|
|
90
113
|
}
|
|
91
114
|
function isQuotaWindowRelevantToFamily(scope, family, source) {
|
|
92
|
-
if (scope === "gemini-5h" && source?.endsWith(":fetchAvailableModels"))
|
|
93
|
-
|
|
115
|
+
if (scope === "gemini-5h" && source?.endsWith(":fetchAvailableModels"))
|
|
116
|
+
return false;
|
|
117
|
+
if (typeof scope !== "string")
|
|
118
|
+
return true;
|
|
94
119
|
const scopeFamily = parseQuotaWindowScope(scope).family;
|
|
95
|
-
return scopeFamily ===
|
|
120
|
+
return scopeFamily === undefined || family === undefined || scopeFamily === family;
|
|
96
121
|
}
|
|
97
122
|
function selectQuotaWindowsForModel(quota, now, model) {
|
|
98
|
-
if (!quota || !Array.isArray(quota.windows))
|
|
123
|
+
if (!quota || !Array.isArray(quota.windows))
|
|
124
|
+
return [];
|
|
99
125
|
const family = resolveQuotaWindowFamily(model);
|
|
100
|
-
return quota.windows.filter(
|
|
101
|
-
(window) => !isQuotaWindowExpired(window, now) && isQuotaWindowRelevantToFamily(window?.scope, family, window?.source)
|
|
102
|
-
);
|
|
126
|
+
return quota.windows.filter((window) => !isQuotaWindowExpired(window, now) && isQuotaWindowRelevantToFamily(window?.scope, family, window?.source));
|
|
103
127
|
}
|
|
104
128
|
function isQuotaWindowExpired(window, now) {
|
|
105
129
|
const resetAt = window?.resetAt;
|
|
@@ -110,12 +134,13 @@ function scanOpenAiRateLimitHeaders(headers, now, out) {
|
|
|
110
134
|
const remaining = readNumber(headers[`x-ratelimit-remaining-${kind}`]);
|
|
111
135
|
const limit = readNumber(headers[`x-ratelimit-limit-${kind}`]);
|
|
112
136
|
const resetAt = readResetAt(headers[`x-ratelimit-reset-${kind}`], now);
|
|
113
|
-
if (remaining ===
|
|
137
|
+
if (remaining === undefined && limit === undefined && resetAt === undefined)
|
|
138
|
+
continue;
|
|
114
139
|
mergeWindow(out, {
|
|
115
140
|
scope: kind,
|
|
116
|
-
...remaining !==
|
|
117
|
-
...limit !==
|
|
118
|
-
...resetAt !==
|
|
141
|
+
...remaining !== undefined ? { remaining } : {},
|
|
142
|
+
...limit !== undefined ? { limit } : {},
|
|
143
|
+
...resetAt !== undefined ? { resetAt } : {},
|
|
119
144
|
unit: kind,
|
|
120
145
|
source: `x-ratelimit-*-${kind}`
|
|
121
146
|
});
|
|
@@ -123,12 +148,12 @@ function scanOpenAiRateLimitHeaders(headers, now, out) {
|
|
|
123
148
|
const genericRemaining = readNumber(headers["x-ratelimit-remaining"]);
|
|
124
149
|
const genericLimit = readNumber(headers["x-ratelimit-limit"]);
|
|
125
150
|
const genericReset = readResetAt(headers["x-ratelimit-reset"], now);
|
|
126
|
-
if (genericRemaining !==
|
|
151
|
+
if (genericRemaining !== undefined || genericLimit !== undefined || genericReset !== undefined) {
|
|
127
152
|
mergeWindow(out, {
|
|
128
153
|
scope: "requests",
|
|
129
|
-
...genericRemaining !==
|
|
130
|
-
...genericLimit !==
|
|
131
|
-
...genericReset !==
|
|
154
|
+
...genericRemaining !== undefined ? { remaining: genericRemaining } : {},
|
|
155
|
+
...genericLimit !== undefined ? { limit: genericLimit } : {},
|
|
156
|
+
...genericReset !== undefined ? { resetAt: genericReset } : {},
|
|
132
157
|
unit: "requests",
|
|
133
158
|
source: "x-ratelimit"
|
|
134
159
|
});
|
|
@@ -136,18 +161,14 @@ function scanOpenAiRateLimitHeaders(headers, now, out) {
|
|
|
136
161
|
}
|
|
137
162
|
function scanAnthropicUnifiedHeaders(headers, now, out) {
|
|
138
163
|
for (const scope of ["5h", "7d"]) {
|
|
139
|
-
const utilization = readUtilization(
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
headers[`anthropic-ratelimit-unified-${scope}-reset`],
|
|
144
|
-
now
|
|
145
|
-
);
|
|
146
|
-
if (utilization === void 0 && resetAt === void 0) continue;
|
|
164
|
+
const utilization = readUtilization(headers[`anthropic-ratelimit-unified-${scope}-utilization`]);
|
|
165
|
+
const resetAt = readResetAt(headers[`anthropic-ratelimit-unified-${scope}-reset`], now);
|
|
166
|
+
if (utilization === undefined && resetAt === undefined)
|
|
167
|
+
continue;
|
|
147
168
|
mergeWindow(out, {
|
|
148
169
|
scope,
|
|
149
|
-
...utilization !==
|
|
150
|
-
...resetAt !==
|
|
170
|
+
...utilization !== undefined ? { utilization } : {},
|
|
171
|
+
...resetAt !== undefined ? { resetAt } : {},
|
|
151
172
|
source: `anthropic-ratelimit-unified-${scope}`
|
|
152
173
|
});
|
|
153
174
|
}
|
|
@@ -162,103 +183,112 @@ function scanGoogleQuotaHeaders(headers, now, out) {
|
|
|
162
183
|
const remaining = readNumber(headers[`${prefix}remaining`]);
|
|
163
184
|
const limit = readNumber(headers[`${prefix}limit`]);
|
|
164
185
|
const resetAt = readResetAt(headers[`${prefix}reset`], now) ?? genericReset;
|
|
165
|
-
if (remaining ===
|
|
186
|
+
if (remaining === undefined && limit === undefined && resetAt === undefined)
|
|
187
|
+
continue;
|
|
166
188
|
mergeWindow(out, {
|
|
167
189
|
scope,
|
|
168
|
-
...remaining !==
|
|
169
|
-
...limit !==
|
|
170
|
-
...resetAt !==
|
|
190
|
+
...remaining !== undefined ? { remaining } : {},
|
|
191
|
+
...limit !== undefined ? { limit } : {},
|
|
192
|
+
...resetAt !== undefined ? { resetAt } : {},
|
|
171
193
|
source: `${prefix}*`
|
|
172
194
|
});
|
|
173
195
|
}
|
|
174
196
|
}
|
|
175
197
|
function scanSub2ApiHeaders(headers, now, out) {
|
|
176
198
|
const FIELD_RE = /^x-sub2api-quota(?:-([a-z0-9][a-z0-9._:-]*))?-(remaining|limit|reset)$/;
|
|
177
|
-
const groups =
|
|
199
|
+
const groups = new Map;
|
|
178
200
|
for (const [name, value] of Object.entries(headers)) {
|
|
179
201
|
const m = FIELD_RE.exec(name);
|
|
180
|
-
if (!m)
|
|
202
|
+
if (!m)
|
|
203
|
+
continue;
|
|
181
204
|
const scope = m[1] ?? "sub2api";
|
|
182
205
|
const group = groups.get(scope) ?? {};
|
|
183
206
|
if (m[2] === "reset") {
|
|
184
207
|
const at = readResetAt(value, now);
|
|
185
|
-
if (at !==
|
|
208
|
+
if (at !== undefined)
|
|
209
|
+
group.resetAt = at;
|
|
186
210
|
} else if (m[2] === "remaining") {
|
|
187
211
|
const n = readNumber(value);
|
|
188
|
-
if (n !==
|
|
212
|
+
if (n !== undefined)
|
|
213
|
+
group.remaining = n;
|
|
189
214
|
} else if (m[2] === "limit") {
|
|
190
215
|
const n = readNumber(value);
|
|
191
|
-
if (n !==
|
|
216
|
+
if (n !== undefined)
|
|
217
|
+
group.limit = n;
|
|
192
218
|
}
|
|
193
219
|
groups.set(scope, group);
|
|
194
220
|
}
|
|
195
221
|
for (const [scope, g] of groups) {
|
|
196
222
|
mergeWindow(out, {
|
|
197
223
|
scope,
|
|
198
|
-
...g.remaining !==
|
|
199
|
-
...g.limit !==
|
|
200
|
-
...g.resetAt !==
|
|
224
|
+
...g.remaining !== undefined ? { remaining: g.remaining } : {},
|
|
225
|
+
...g.limit !== undefined ? { limit: g.limit } : {},
|
|
226
|
+
...g.resetAt !== undefined ? { resetAt: g.resetAt } : {},
|
|
201
227
|
source: "x-sub2api-quota"
|
|
202
228
|
});
|
|
203
229
|
}
|
|
204
230
|
}
|
|
205
231
|
function scanBody(body, now, out) {
|
|
206
|
-
if (!body || typeof body !== "object")
|
|
232
|
+
if (!body || typeof body !== "object")
|
|
233
|
+
return;
|
|
207
234
|
const root = body;
|
|
208
|
-
const error = root.error && typeof root.error === "object" ? root.error :
|
|
235
|
+
const error = root.error && typeof root.error === "object" ? root.error : undefined;
|
|
209
236
|
for (const holder of [root, error]) {
|
|
210
237
|
const quota = holder?.quota;
|
|
211
|
-
if (!quota || typeof quota !== "object")
|
|
238
|
+
if (!quota || typeof quota !== "object")
|
|
239
|
+
continue;
|
|
212
240
|
const q = quota;
|
|
213
241
|
const remaining = readNumber(q.remaining ?? q.remaining_amount);
|
|
214
242
|
const limit = readNumber(q.limit ?? q.total ?? q.quota);
|
|
215
|
-
const resetAt = readResetAt(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const unit = typeof q.unit === "string" && q.unit ? q.unit : void 0;
|
|
220
|
-
if (remaining === void 0 && limit === void 0 && resetAt === void 0) continue;
|
|
243
|
+
const resetAt = readResetAt(q.reset_at ?? q.resets_at ?? q.resetAt ?? q.resetTime ?? q.reset_time, now);
|
|
244
|
+
const unit = typeof q.unit === "string" && q.unit ? q.unit : undefined;
|
|
245
|
+
if (remaining === undefined && limit === undefined && resetAt === undefined)
|
|
246
|
+
continue;
|
|
221
247
|
const scope = typeof q.scope === "string" && q.scope ? q.scope : "daily";
|
|
222
248
|
mergeWindow(out, {
|
|
223
249
|
scope,
|
|
224
|
-
...remaining !==
|
|
225
|
-
...limit !==
|
|
226
|
-
...resetAt !==
|
|
250
|
+
...remaining !== undefined ? { remaining } : {},
|
|
251
|
+
...limit !== undefined ? { limit } : {},
|
|
252
|
+
...resetAt !== undefined ? { resetAt } : {},
|
|
227
253
|
...unit ? { unit } : {},
|
|
228
254
|
source: "body.quota"
|
|
229
255
|
});
|
|
230
256
|
}
|
|
231
257
|
const details = error?.details ?? root.details;
|
|
232
|
-
if (!Array.isArray(details))
|
|
258
|
+
if (!Array.isArray(details))
|
|
259
|
+
return;
|
|
233
260
|
let retryResetAt;
|
|
234
|
-
const quotaScopes =
|
|
261
|
+
const quotaScopes = new Set;
|
|
235
262
|
for (const item of details) {
|
|
236
|
-
if (!item || typeof item !== "object")
|
|
263
|
+
if (!item || typeof item !== "object")
|
|
264
|
+
continue;
|
|
237
265
|
const record = item;
|
|
238
266
|
const type = typeof record["@type"] === "string" ? record["@type"] : "";
|
|
239
267
|
if (type.includes("RetryInfo")) {
|
|
240
268
|
const at = readResetAt(record.retryDelay ?? record.retry_delay, now);
|
|
241
|
-
if (at !==
|
|
269
|
+
if (at !== undefined)
|
|
270
|
+
retryResetAt = retryResetAt === undefined ? at : Math.max(retryResetAt, at);
|
|
242
271
|
}
|
|
243
272
|
if (type.includes("QuotaFailure") && Array.isArray(record.violations)) {
|
|
244
273
|
for (const v of record.violations) {
|
|
245
|
-
const metric = v && typeof v === "object" && typeof v.quotaMetric === "string" ? v.quotaMetric :
|
|
246
|
-
if (metric)
|
|
274
|
+
const metric = v && typeof v === "object" && typeof v.quotaMetric === "string" ? v.quotaMetric : undefined;
|
|
275
|
+
if (metric)
|
|
276
|
+
quotaScopes.add(`model:${metric}`);
|
|
247
277
|
}
|
|
248
278
|
}
|
|
249
279
|
}
|
|
250
|
-
if (retryResetAt !==
|
|
280
|
+
if (retryResetAt !== undefined || quotaScopes.size > 0) {
|
|
251
281
|
if (quotaScopes.size === 0) {
|
|
252
282
|
mergeWindow(out, {
|
|
253
283
|
scope: "user",
|
|
254
|
-
...retryResetAt !==
|
|
284
|
+
...retryResetAt !== undefined ? { resetAt: retryResetAt } : {},
|
|
255
285
|
source: "body.details.RetryInfo"
|
|
256
286
|
});
|
|
257
287
|
}
|
|
258
288
|
for (const scope of quotaScopes) {
|
|
259
289
|
mergeWindow(out, {
|
|
260
290
|
scope,
|
|
261
|
-
...retryResetAt !==
|
|
291
|
+
...retryResetAt !== undefined ? { resetAt: retryResetAt } : {},
|
|
262
292
|
source: "body.details.QuotaFailure"
|
|
263
293
|
});
|
|
264
294
|
}
|
|
@@ -266,23 +296,26 @@ function scanBody(body, now, out) {
|
|
|
266
296
|
}
|
|
267
297
|
function extractQuotaSnapshot(provider, status, headers, body, now) {
|
|
268
298
|
try {
|
|
269
|
-
if (!Number.isFinite(now))
|
|
299
|
+
if (!Number.isFinite(now))
|
|
300
|
+
return;
|
|
270
301
|
const bag = normalizeHeaders(headers);
|
|
271
|
-
const windows =
|
|
302
|
+
const windows = new Map;
|
|
272
303
|
scanOpenAiRateLimitHeaders(bag, now, windows);
|
|
273
304
|
scanAnthropicUnifiedHeaders(bag, now, windows);
|
|
274
305
|
scanGoogleQuotaHeaders(bag, now, windows);
|
|
275
306
|
scanSub2ApiHeaders(bag, now, windows);
|
|
276
307
|
scanBody(body, now, windows);
|
|
277
|
-
if (windows.size === 0)
|
|
308
|
+
if (windows.size === 0)
|
|
309
|
+
return;
|
|
278
310
|
return { windows: [...windows.values()], observedAt: now };
|
|
279
311
|
} catch {
|
|
280
|
-
return
|
|
312
|
+
return;
|
|
281
313
|
}
|
|
282
314
|
}
|
|
283
315
|
function findTightestQuotaWindow(quota, now = Date.now(), options) {
|
|
284
316
|
const windows = selectQuotaWindowsForModel(quota, now, options?.model);
|
|
285
|
-
if (windows.length === 0)
|
|
317
|
+
if (windows.length === 0)
|
|
318
|
+
return;
|
|
286
319
|
let best;
|
|
287
320
|
let bestScore = -Infinity;
|
|
288
321
|
for (const w of windows) {
|
|
@@ -309,60 +342,63 @@ function formatQuotaSummary(quota, now = Date.now(), options) {
|
|
|
309
342
|
const planText = formatPlanLabel(quota?.plan);
|
|
310
343
|
const planName = typeof quota?.plan?.name === "string" ? quota.plan.name.trim() : "";
|
|
311
344
|
const tightest = findTightestQuotaWindow(quota, now, { model: options?.model });
|
|
312
|
-
if (!tightest)
|
|
345
|
+
if (!tightest)
|
|
346
|
+
return compact ? planName || undefined : planText;
|
|
313
347
|
const parts = [];
|
|
314
348
|
if (typeof tightest.utilization === "number") {
|
|
315
349
|
const pct = Math.round(tightest.utilization * 100);
|
|
316
|
-
parts.push(`${pct}
|
|
350
|
+
parts.push(`${pct}%已用`);
|
|
317
351
|
} else if (typeof tightest.remaining === "number") {
|
|
318
352
|
if (typeof tightest.limit === "number") {
|
|
319
353
|
parts.push(`${tightest.remaining}/${tightest.limit}${tightest.unit ? ` ${tightest.unit}` : ""}`);
|
|
320
354
|
} else {
|
|
321
|
-
parts.push(
|
|
355
|
+
parts.push(`余${tightest.remaining}${tightest.unit ? ` ${tightest.unit}` : ""}`);
|
|
322
356
|
}
|
|
323
357
|
}
|
|
324
358
|
if (compact) {
|
|
325
|
-
const head = parts.length > 0 ? parts[0] :
|
|
326
|
-
return [planName ||
|
|
359
|
+
const head = parts.length > 0 ? parts[0] : undefined;
|
|
360
|
+
return [planName || undefined, head].filter(Boolean).join(" · ") || undefined;
|
|
327
361
|
}
|
|
328
362
|
if (tightest.scope && tightest.scope !== "user" && tightest.scope !== "project" && tightest.scope !== tightest.unit) {
|
|
329
363
|
parts.push(tightest.scope);
|
|
330
364
|
}
|
|
331
365
|
if (typeof tightest.resetAt === "number" && tightest.resetAt > now) {
|
|
332
|
-
const diffSec = Math.round((tightest.resetAt - now) /
|
|
366
|
+
const diffSec = Math.round((tightest.resetAt - now) / 1000);
|
|
333
367
|
if (diffSec < 60) {
|
|
334
|
-
parts.push(`${diffSec}s
|
|
368
|
+
parts.push(`${diffSec}s后重置`);
|
|
335
369
|
} else if (diffSec < 3600) {
|
|
336
|
-
parts.push(`${Math.round(diffSec / 60)}m
|
|
370
|
+
parts.push(`${Math.round(diffSec / 60)}m后重置`);
|
|
337
371
|
} else if (diffSec < 86400) {
|
|
338
372
|
const hours = (diffSec / 3600).toFixed(1).replace(/\.0$/, "");
|
|
339
|
-
parts.push(`${hours}h
|
|
373
|
+
parts.push(`${hours}h后重置`);
|
|
340
374
|
} else {
|
|
341
375
|
const days = (diffSec / 86400).toFixed(1).replace(/\.0$/, "");
|
|
342
|
-
parts.push(`${days}d
|
|
376
|
+
parts.push(`${days}d后重置`);
|
|
343
377
|
}
|
|
344
378
|
}
|
|
345
379
|
const onlyScope = parts.length === 0 || parts.length === 1 && parts[0] === tightest.scope;
|
|
346
|
-
if (onlyScope)
|
|
347
|
-
|
|
380
|
+
if (onlyScope)
|
|
381
|
+
return planText;
|
|
382
|
+
return [planText, ...parts].filter(Boolean).join(" · ");
|
|
348
383
|
}
|
|
349
384
|
function formatPlanLabel(plan) {
|
|
350
385
|
const name = typeof plan?.name === "string" ? plan.name.trim() : "";
|
|
351
|
-
if (!name)
|
|
352
|
-
|
|
353
|
-
|
|
386
|
+
if (!name)
|
|
387
|
+
return;
|
|
388
|
+
const credits = typeof plan?.monthlyCreditsUsd === "number" && Number.isFinite(plan.monthlyCreditsUsd) && plan.monthlyCreditsUsd > 0 ? `月度额度 $${plan.monthlyCreditsUsd}` : undefined;
|
|
389
|
+
return [`${name} 套餐`, credits].filter(Boolean).join(" · ");
|
|
354
390
|
}
|
|
355
391
|
|
|
356
392
|
// packages/ai/agent/agentAvailabilityShared.ts
|
|
357
|
-
var DEFAULT_PROVIDER_RETRY_MS = 5 * 60 *
|
|
358
|
-
var THIN_RATE_LIMIT_COOLDOWN_MS = 60 *
|
|
359
|
-
var MAX_COOLDOWN_MS = 24 * 60 * 60 *
|
|
393
|
+
var DEFAULT_PROVIDER_RETRY_MS = 5 * 60 * 1000;
|
|
394
|
+
var THIN_RATE_LIMIT_COOLDOWN_MS = 60 * 1000;
|
|
395
|
+
var MAX_COOLDOWN_MS = 24 * 60 * 60 * 1000;
|
|
360
396
|
function clampCooldownDeadline(at, now) {
|
|
361
397
|
const min = now;
|
|
362
398
|
const max = now + MAX_COOLDOWN_MS;
|
|
363
399
|
return Math.min(Math.max(at, min), max);
|
|
364
400
|
}
|
|
365
|
-
var SUBSCRIPTION_PERIODS =
|
|
401
|
+
var SUBSCRIPTION_PERIODS = new Set(["5h", "7d", "daily", "weekly", "monthly"]);
|
|
366
402
|
function isSubscriptionPeriodWindow(window) {
|
|
367
403
|
const { period } = parseQuotaWindowScope(window.scope);
|
|
368
404
|
return SUBSCRIPTION_PERIODS.has(period.trim().toLowerCase());
|
|
@@ -371,21 +407,26 @@ function isExhaustedWindow(window) {
|
|
|
371
407
|
return window.remaining === 0 || typeof window.utilization === "number" && window.utilization >= 0.95;
|
|
372
408
|
}
|
|
373
409
|
function shouldClearCooldownFromQuota(entry, quota, now, options) {
|
|
374
|
-
if (!(typeof entry.nextAvailableAt === "number" && entry.nextAvailableAt > now))
|
|
375
|
-
|
|
376
|
-
if (
|
|
410
|
+
if (!(typeof entry.nextAvailableAt === "number" && entry.nextAvailableAt > now))
|
|
411
|
+
return false;
|
|
412
|
+
if (typeof entry.markedAt !== "number" || !Number.isFinite(entry.markedAt))
|
|
413
|
+
return false;
|
|
414
|
+
if (!quota || !(quota.observedAt > entry.markedAt))
|
|
415
|
+
return false;
|
|
377
416
|
const family = resolveQuotaWindowFamily(options?.model);
|
|
378
|
-
const relevantWindows = quota.windows.filter(
|
|
379
|
-
(window) => isQuotaWindowRelevantToFamily(window.scope, family, window.source)
|
|
380
|
-
);
|
|
417
|
+
const relevantWindows = quota.windows.filter((window) => isQuotaWindowRelevantToFamily(window.scope, family, window.source));
|
|
381
418
|
const subscriptionWindows = relevantWindows.filter(isSubscriptionPeriodWindow);
|
|
382
|
-
if (subscriptionWindows.length === 0)
|
|
383
|
-
|
|
384
|
-
if (
|
|
419
|
+
if (subscriptionWindows.length === 0)
|
|
420
|
+
return false;
|
|
421
|
+
if (relevantWindows.some(isExhaustedWindow))
|
|
422
|
+
return false;
|
|
423
|
+
if (subscriptionWindows.some((window) => isQuotaWindowExpired(window, now)))
|
|
424
|
+
return false;
|
|
385
425
|
return subscriptionWindows.every((window) => {
|
|
386
426
|
const hasUtilization = typeof window.utilization === "number";
|
|
387
427
|
const hasRemaining = typeof window.remaining === "number";
|
|
388
|
-
if (!hasUtilization && !hasRemaining)
|
|
428
|
+
if (!hasUtilization && !hasRemaining)
|
|
429
|
+
return false;
|
|
389
430
|
return (!hasUtilization || window.utilization < 0.95) && (!hasRemaining || window.remaining > 0);
|
|
390
431
|
});
|
|
391
432
|
}
|
|
@@ -393,9 +434,10 @@ function isAgentUnavailableNow(agent, now = Date.now()) {
|
|
|
393
434
|
const at = agent?.nextAvailableAt;
|
|
394
435
|
return typeof at === "number" && Number.isFinite(at) && at > now;
|
|
395
436
|
}
|
|
396
|
-
var QUOTA_SNAPSHOT_STALE_MS = 2 * 60 * 60 *
|
|
437
|
+
var QUOTA_SNAPSHOT_STALE_MS = 2 * 60 * 60 * 1000;
|
|
397
438
|
function isAdmissibleQuotaSnapshot(quota, now = Date.now()) {
|
|
398
|
-
if (!quota || typeof quota !== "object")
|
|
439
|
+
if (!quota || typeof quota !== "object")
|
|
440
|
+
return false;
|
|
399
441
|
const observedAt = quota.observedAt;
|
|
400
442
|
if (typeof observedAt !== "number" || !Number.isFinite(observedAt)) {
|
|
401
443
|
return false;
|
|
@@ -411,9 +453,7 @@ function resolveAgentAvailability(agent, now = Date.now()) {
|
|
|
411
453
|
const isAdmissible = isAdmissibleQuotaSnapshot(quota, now);
|
|
412
454
|
const hasObservedAt = Boolean(quota) && typeof quota?.observedAt === "number" && Number.isFinite(quota.observedAt);
|
|
413
455
|
const family = resolveQuotaWindowFamily(agent?.model);
|
|
414
|
-
const relevantWindows = (quota?.windows ?? []).filter(
|
|
415
|
-
(window) => isQuotaWindowRelevantToFamily(window?.scope, family, window?.source)
|
|
416
|
-
);
|
|
456
|
+
const relevantWindows = (quota?.windows ?? []).filter((window) => isQuotaWindowRelevantToFamily(window?.scope, family, window?.source));
|
|
417
457
|
const hasWindows = relevantWindows.length > 0;
|
|
418
458
|
const hasValidQuota = isAdmissible && hasWindows;
|
|
419
459
|
if (hasValidQuota) {
|
|
@@ -423,11 +463,14 @@ function resolveAgentAvailability(agent, now = Date.now()) {
|
|
|
423
463
|
let maxResetAt;
|
|
424
464
|
for (const w of relevantWindows) {
|
|
425
465
|
const inspected = inspectQuotaWindowExhaustion(w, now);
|
|
426
|
-
if (!inspected)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
if (inspected.
|
|
430
|
-
|
|
466
|
+
if (!inspected)
|
|
467
|
+
continue;
|
|
468
|
+
if (inspected.resetAt !== undefined && inspected.resetAt > now) {
|
|
469
|
+
if (inspected.remainingZero)
|
|
470
|
+
hasActiveRemainingZero = true;
|
|
471
|
+
if (inspected.utilizationHigh)
|
|
472
|
+
hasActiveUtilizationHigh = true;
|
|
473
|
+
maxResetAt = maxResetAt !== undefined ? Math.max(maxResetAt, inspected.resetAt) : inspected.resetAt;
|
|
431
474
|
} else {
|
|
432
475
|
hasWindowResetPending = true;
|
|
433
476
|
}
|
|
@@ -436,7 +479,7 @@ function resolveAgentAvailability(agent, now = Date.now()) {
|
|
|
436
479
|
return {
|
|
437
480
|
status: "quota_exhausted",
|
|
438
481
|
reason: hasActiveRemainingZero ? "quota_remaining_zero" : "quota_utilization_high",
|
|
439
|
-
...maxResetAt !==
|
|
482
|
+
...maxResetAt !== undefined ? { resetAt: maxResetAt } : {}
|
|
440
483
|
};
|
|
441
484
|
}
|
|
442
485
|
if (hasWindowResetPending) {
|
|
@@ -477,52 +520,58 @@ function resolveAgentAvailability(agent, now = Date.now()) {
|
|
|
477
520
|
};
|
|
478
521
|
}
|
|
479
522
|
function readRetryAfterTimestamp(body, now) {
|
|
480
|
-
if (!body || typeof body !== "object")
|
|
523
|
+
if (!body || typeof body !== "object")
|
|
524
|
+
return;
|
|
481
525
|
const root = body;
|
|
482
526
|
const raw = root.retryAfter ?? root.retry_after ?? root["Retry-After"];
|
|
483
527
|
if (typeof raw === "number" && Number.isFinite(raw)) {
|
|
484
|
-
return raw >
|
|
528
|
+
return raw > 1000000000000 ? raw : now + Math.max(0, raw) * 1000;
|
|
485
529
|
}
|
|
486
530
|
if (typeof raw === "string") {
|
|
487
531
|
const seconds = Number(raw.trim());
|
|
488
|
-
if (Number.isFinite(seconds))
|
|
532
|
+
if (Number.isFinite(seconds))
|
|
533
|
+
return now + Math.max(0, seconds) * 1000;
|
|
489
534
|
const date = Date.parse(raw);
|
|
490
|
-
if (Number.isFinite(date))
|
|
535
|
+
if (Number.isFinite(date))
|
|
536
|
+
return date;
|
|
491
537
|
}
|
|
492
|
-
return
|
|
538
|
+
return;
|
|
493
539
|
}
|
|
494
540
|
function readResetTimestamp(body, now) {
|
|
495
|
-
if (!body || typeof body !== "object")
|
|
541
|
+
if (!body || typeof body !== "object")
|
|
542
|
+
return;
|
|
496
543
|
const root = body;
|
|
497
544
|
const error = root.error && typeof root.error === "object" ? root.error : root;
|
|
498
545
|
if (Array.isArray(error.details)) {
|
|
499
546
|
for (const item of error.details) {
|
|
500
|
-
if (!item || typeof item !== "object")
|
|
547
|
+
if (!item || typeof item !== "object")
|
|
548
|
+
continue;
|
|
501
549
|
const retryDelay = item.retryDelay;
|
|
502
550
|
if (typeof retryDelay === "string") {
|
|
503
551
|
const ms = parseResetsInMs(retryDelay);
|
|
504
|
-
if (typeof ms === "number" && Number.isFinite(ms))
|
|
552
|
+
if (typeof ms === "number" && Number.isFinite(ms))
|
|
553
|
+
return now + ms;
|
|
505
554
|
}
|
|
506
555
|
}
|
|
507
556
|
}
|
|
508
|
-
const details = !Array.isArray(error.details) && error.details && typeof error.details === "object" ? error.details :
|
|
557
|
+
const details = !Array.isArray(error.details) && error.details && typeof error.details === "object" ? error.details : undefined;
|
|
509
558
|
const raw = error.resets_at ?? error.resetsAt ?? error.reset_at ?? error.resetAt ?? details?.resets_at ?? details?.resetsAt ?? details?.reset_at ?? details?.resetAt;
|
|
510
559
|
if (typeof raw === "number" && Number.isFinite(raw)) {
|
|
511
|
-
return raw >
|
|
560
|
+
return raw > 1000000000000 ? raw : raw * 1000;
|
|
512
561
|
}
|
|
513
562
|
if (typeof raw === "string") {
|
|
514
563
|
const parsed = Date.parse(raw);
|
|
515
|
-
if (Number.isFinite(parsed))
|
|
564
|
+
if (Number.isFinite(parsed))
|
|
565
|
+
return parsed;
|
|
516
566
|
}
|
|
517
|
-
return
|
|
567
|
+
return;
|
|
518
568
|
}
|
|
519
569
|
function parseResetAtText(value, now) {
|
|
520
|
-
const m = value.match(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
if (!m?.[1]) return void 0;
|
|
570
|
+
const m = value.match(/resets?\s+at\s+(\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)?)/i);
|
|
571
|
+
if (!m?.[1])
|
|
572
|
+
return;
|
|
524
573
|
const parsed = Date.parse(m[1]);
|
|
525
|
-
return Number.isFinite(parsed) && parsed > now ? parsed :
|
|
574
|
+
return Number.isFinite(parsed) && parsed > now ? parsed : undefined;
|
|
526
575
|
}
|
|
527
576
|
function matchesPeriodicUsageLimitText(text) {
|
|
528
577
|
return /(?:weekly|monthly)\s*(?:\([^)]*\)\s*)?usage\s+limit/i.test(text);
|
|
@@ -534,26 +583,26 @@ function isQuotaLimited403Body(body) {
|
|
|
534
583
|
function parseExplicitAvailableAt(body, now, headers) {
|
|
535
584
|
const headerRetryAfter = headers && typeof headers.get === "function" ? headers.get("retry-after") : headers?.["retry-after"] ?? headers?.["Retry-After"];
|
|
536
585
|
const retryAfter = headerRetryAfter ? readRetryAfterTimestamp({ retryAfter: headerRetryAfter }, now) : readRetryAfterTimestamp(body, now);
|
|
537
|
-
if (retryAfter !==
|
|
586
|
+
if (retryAfter !== undefined && retryAfter > now) {
|
|
538
587
|
return clampCooldownDeadline(retryAfter, now);
|
|
539
588
|
}
|
|
540
589
|
const absolute = readResetTimestamp(body, now);
|
|
541
|
-
if (absolute !==
|
|
590
|
+
if (absolute !== undefined && absolute > now) {
|
|
542
591
|
return clampCooldownDeadline(absolute, now);
|
|
543
592
|
}
|
|
544
593
|
const text = typeof body === "string" ? body : JSON.stringify(body ?? "");
|
|
545
594
|
const absoluteFromText = parseResetAtText(text, now);
|
|
546
|
-
if (absoluteFromText !==
|
|
595
|
+
if (absoluteFromText !== undefined) {
|
|
547
596
|
return clampCooldownDeadline(absoluteFromText, now);
|
|
548
597
|
}
|
|
549
598
|
if (matchesPeriodicUsageLimitText(text)) {
|
|
550
599
|
return clampCooldownDeadline(now + MAX_COOLDOWN_MS, now);
|
|
551
600
|
}
|
|
552
601
|
const relativeMs = parseResetsInMs(text);
|
|
553
|
-
if (relativeMs !==
|
|
602
|
+
if (relativeMs !== undefined) {
|
|
554
603
|
return clampCooldownDeadline(now + relativeMs, now);
|
|
555
604
|
}
|
|
556
|
-
return
|
|
605
|
+
return;
|
|
557
606
|
}
|
|
558
607
|
var QUOTA_EXHAUSTED_TEXT_RE = /insufficient[_ ]?quota|quota\s*(?:(?:is|has|been|was|now|fully|completely|already|entirely)\s+)*(?:limit\s+)?(?:exhausted|depleted|used\s*up|reached|exceeded)|usage\s*limit\s*(?:reached|exceeded|exhausted)|(?:\b(?:weekly|monthly|5-?hour|5h|7-?day|7d)\s*(?:\([^)]*\)\s*)?limit\s*(?:reached|exceeded|exhausted|depleted)\b)|(?:reached|exceeded)\s+your\s+.*?(?:usage\s+)?limit|exceeded\s*your\s*(?:current\s*)?quota|insufficient[_\s-]?(?:balance|credits?)|balance\s*(?:is\s*)?(?:insufficient|too\s*low)|(?:额度|配额|用量)(?:已|已经|也)?(?:用尽|耗尽|用完|超限|不足)|(?:已达到|已达|超出|超过)[^。;,\n]{0,40}(?:用量上限|配额上限|额度上限)|余额(?:不足|不够|已用尽|已耗尽)/i;
|
|
559
608
|
var NEGATED_QUOTA_TEXT_RE = /\b(?:not|no\s+longer|never|haven't|hasn't|isn't|aren't)\s+(?:(?:currently|really|actually|yet)\s+)?(?:quota\s+exhausted|limit\s+exhausted|exhausted|depleted|used\s*up|reached|exceeded|out\s+of\s+quota)\b/i;
|
|
@@ -561,17 +610,24 @@ var CAPACITY_SATURATED_TEXT_RE = /\b(?:is\s+at\s+capacity|at\s+capacity|capacity
|
|
|
561
610
|
var NEGATED_CAPACITY_TEXT_RE = /\b(?:not|no\s+longer|never)\s+(?:(?:currently|really|actually|yet)\s+)?(?:at\s+capacity|capacity\s*(?:is\s*)?(?:saturated|exceeded|unavailable)|overloaded|over\s*capacity)\b/i;
|
|
562
611
|
function isQuotaExhaustedText(body) {
|
|
563
612
|
const text = typeof body === "string" ? body : JSON.stringify(body ?? "");
|
|
564
|
-
if (!text)
|
|
565
|
-
|
|
566
|
-
if (
|
|
613
|
+
if (!text)
|
|
614
|
+
return false;
|
|
615
|
+
if (/"(?:code|status_code)"\s*:\s*"?2056"?(?=\s*[,}])/.test(text))
|
|
616
|
+
return true;
|
|
617
|
+
if (NEGATED_QUOTA_TEXT_RE.test(text))
|
|
618
|
+
return false;
|
|
567
619
|
return QUOTA_EXHAUSTED_TEXT_RE.test(text) || isQuotaLimited403Body(text);
|
|
568
620
|
}
|
|
569
621
|
function isCapacitySaturatedRateLimit(body, now, headers) {
|
|
570
|
-
if (parseExplicitAvailableAt(body, now, headers) !==
|
|
622
|
+
if (parseExplicitAvailableAt(body, now, headers) !== undefined)
|
|
623
|
+
return false;
|
|
571
624
|
const text = typeof body === "string" ? body : JSON.stringify(body ?? "");
|
|
572
|
-
if (!text)
|
|
573
|
-
|
|
574
|
-
if (
|
|
625
|
+
if (!text)
|
|
626
|
+
return false;
|
|
627
|
+
if (isQuotaExhaustedText(text))
|
|
628
|
+
return false;
|
|
629
|
+
if (NEGATED_CAPACITY_TEXT_RE.test(text))
|
|
630
|
+
return false;
|
|
575
631
|
return CAPACITY_SATURATED_TEXT_RE.test(text);
|
|
576
632
|
}
|
|
577
633
|
function resolveNextAvailableAt(body, now, headers) {
|
|
@@ -607,7 +663,8 @@ function mergeAvailabilityDeadline(currentDeadline, nextAvailableAt) {
|
|
|
607
663
|
return typeof currentDeadline === "number" && Number.isFinite(currentDeadline) ? Math.max(currentDeadline, nextAvailableAt) : nextAvailableAt;
|
|
608
664
|
}
|
|
609
665
|
function isPublicOrSystemAgentRecord(agent) {
|
|
610
|
-
if (!agent || typeof agent !== "object")
|
|
666
|
+
if (!agent || typeof agent !== "object")
|
|
667
|
+
return false;
|
|
611
668
|
for (const keyField of ["agentKey", "key", "id", "dbKey", "privateKey"]) {
|
|
612
669
|
const rawKey = agent[keyField];
|
|
613
670
|
if (typeof rawKey === "string") {
|
|
@@ -620,16 +677,19 @@ function isPublicOrSystemAgentRecord(agent) {
|
|
|
620
677
|
return false;
|
|
621
678
|
}
|
|
622
679
|
function resolveAgentOwnerUserId(agent) {
|
|
623
|
-
if (!agent || typeof agent !== "object")
|
|
680
|
+
if (!agent || typeof agent !== "object")
|
|
681
|
+
return;
|
|
624
682
|
if (isPublicOrSystemAgentRecord(agent)) {
|
|
625
|
-
return
|
|
683
|
+
return;
|
|
626
684
|
}
|
|
627
685
|
for (const field of ["ownerUserId", "userId", "ownerId"]) {
|
|
628
686
|
const value = agent[field];
|
|
629
687
|
if (typeof value === "string") {
|
|
630
688
|
const trimmed = value.trim();
|
|
631
|
-
if (trimmed === "system" || trimmed === "pub")
|
|
632
|
-
|
|
689
|
+
if (trimmed === "system" || trimmed === "pub")
|
|
690
|
+
continue;
|
|
691
|
+
if (trimmed)
|
|
692
|
+
return trimmed;
|
|
633
693
|
}
|
|
634
694
|
}
|
|
635
695
|
for (const keyField of ["agentKey", "key", "id", "dbKey", "privateKey"]) {
|
|
@@ -644,24 +704,30 @@ function resolveAgentOwnerUserId(agent) {
|
|
|
644
704
|
}
|
|
645
705
|
}
|
|
646
706
|
}
|
|
647
|
-
return
|
|
707
|
+
return;
|
|
648
708
|
}
|
|
649
709
|
function resolveCredentialCandidateKeys(key) {
|
|
650
|
-
if (!key)
|
|
710
|
+
if (!key)
|
|
711
|
+
return [];
|
|
651
712
|
const trimmed = key.trim();
|
|
652
|
-
if (!trimmed)
|
|
653
|
-
|
|
713
|
+
if (!trimmed)
|
|
714
|
+
return [];
|
|
715
|
+
if (/\|quota:(?:gemini|3p|hydrogen|argon)$/.test(trimmed))
|
|
716
|
+
return [trimmed];
|
|
654
717
|
const candidates = [trimmed];
|
|
655
718
|
const atIndex = trimmed.lastIndexOf("@");
|
|
656
719
|
if (atIndex > 0) {
|
|
657
720
|
const legacyKey = trimmed.slice(0, atIndex).trim();
|
|
658
|
-
if (legacyKey && legacyKey !== trimmed)
|
|
721
|
+
if (legacyKey && legacyKey !== trimmed)
|
|
722
|
+
candidates.push(legacyKey);
|
|
659
723
|
}
|
|
660
724
|
return candidates;
|
|
661
725
|
}
|
|
662
726
|
function resolveCredentialKey(agent) {
|
|
663
|
-
if (!agent || typeof agent !== "object")
|
|
664
|
-
|
|
727
|
+
if (!agent || typeof agent !== "object")
|
|
728
|
+
return;
|
|
729
|
+
if (isPublicOrSystemAgentRecord(agent))
|
|
730
|
+
return;
|
|
665
731
|
let rawRef;
|
|
666
732
|
for (const field of ["apiKeyRef", "credentialRef"]) {
|
|
667
733
|
const value = agent[field];
|
|
@@ -673,13 +739,16 @@ function resolveCredentialKey(agent) {
|
|
|
673
739
|
}
|
|
674
740
|
}
|
|
675
741
|
}
|
|
676
|
-
if (!rawRef)
|
|
677
|
-
|
|
742
|
+
if (!rawRef)
|
|
743
|
+
return;
|
|
744
|
+
if (rawRef.includes("@"))
|
|
745
|
+
return rawRef;
|
|
678
746
|
const owner = resolveAgentOwnerUserId(agent);
|
|
679
747
|
return owner ? `${rawRef}@${owner}` : rawRef;
|
|
680
748
|
}
|
|
681
749
|
function resolveCredentialKeyWithFallback(agent) {
|
|
682
|
-
if (isPublicOrSystemAgentRecord(agent))
|
|
750
|
+
if (isPublicOrSystemAgentRecord(agent))
|
|
751
|
+
return;
|
|
683
752
|
const byRef = resolveCredentialKey(agent);
|
|
684
753
|
if (byRef) {
|
|
685
754
|
const ref = byRef.split("@")[0]?.trim().toLowerCase();
|
|
@@ -688,60 +757,64 @@ function resolveCredentialKeyWithFallback(agent) {
|
|
|
688
757
|
try {
|
|
689
758
|
const host = new URL(String(agent?.customProviderUrl ?? "")).hostname;
|
|
690
759
|
cloudCode = /^(?:daily-|daily-sandbox-)?cloudcode-pa\.googleapis\.com$/.test(host);
|
|
691
|
-
} catch {
|
|
692
|
-
}
|
|
760
|
+
} catch {}
|
|
693
761
|
if (ref === "antigravity" || ref === "gemini" || provider === "google-antigravity" || cloudCode) {
|
|
694
|
-
const family = resolveQuotaWindowFamily(typeof agent?.model === "string" ? agent.model :
|
|
695
|
-
if (family)
|
|
762
|
+
const family = resolveQuotaWindowFamily(typeof agent?.model === "string" ? agent.model : undefined);
|
|
763
|
+
if (family)
|
|
764
|
+
return `${byRef}|quota:${family}`;
|
|
696
765
|
}
|
|
697
766
|
return byRef;
|
|
698
767
|
}
|
|
699
|
-
if (!agent || typeof agent !== "object")
|
|
768
|
+
if (!agent || typeof agent !== "object")
|
|
769
|
+
return;
|
|
700
770
|
const endpoint = agent.customProviderUrl;
|
|
701
771
|
if (typeof endpoint === "string") {
|
|
702
772
|
const trimmed = endpoint.trim();
|
|
703
773
|
if (trimmed) {
|
|
704
774
|
try {
|
|
705
775
|
const origin = new URL(trimmed).origin;
|
|
706
|
-
if (origin && origin !== "null")
|
|
707
|
-
|
|
708
|
-
}
|
|
776
|
+
if (origin && origin !== "null")
|
|
777
|
+
return `custom-endpoint:${origin}`;
|
|
778
|
+
} catch {}
|
|
709
779
|
}
|
|
710
780
|
}
|
|
711
781
|
const key = agent.key;
|
|
712
|
-
if (typeof key === "string" && key.trim())
|
|
713
|
-
|
|
782
|
+
if (typeof key === "string" && key.trim())
|
|
783
|
+
return `custom-agent:${key.trim()}`;
|
|
784
|
+
return;
|
|
714
785
|
}
|
|
715
786
|
var AUTH_ERROR_TEXT_RE = /\b(?:unauthorized|unauthenticated|authentication_error|invalid_api_key|invalid_token|bad_api_key|access_denied)\b/i;
|
|
716
787
|
var BALANCE_ERROR_TEXT_RE = /\b(?:insufficient_balance|wallet balance|coding_plan_exhausted|payment_required|arrears)\b|余额不足|额度已用尽且钱包|充值/i;
|
|
717
788
|
var TEXT_5H_WINDOW_RE = /\b(?:5h|5-hour|5\s*hours?|5\s*hrs?)\b/i;
|
|
718
789
|
var TEXT_WEEKLY_WINDOW_RE = /\b(?:weekly|monthly|7d|7-day|7\s*days?|30-day|month(?:ly)?|week(?:ly)?)\b/i;
|
|
719
790
|
function inspectQuotaWindowExhaustion(window, now) {
|
|
720
|
-
if (!window || typeof window !== "object")
|
|
791
|
+
if (!window || typeof window !== "object")
|
|
792
|
+
return;
|
|
721
793
|
const w = window;
|
|
722
794
|
const scope = typeof w.scope === "string" ? w.scope.toLowerCase() : "";
|
|
723
|
-
const windowSeconds = typeof w.limit_window_seconds === "number" ? w.limit_window_seconds : typeof w.window_seconds === "number" ? w.window_seconds :
|
|
724
|
-
const usedPercent = typeof w.used_percent === "number" ? w.used_percent : typeof w.utilization === "number" ? w.utilization * 100 :
|
|
725
|
-
const remaining = typeof w.remaining === "number" ? w.remaining :
|
|
795
|
+
const windowSeconds = typeof w.limit_window_seconds === "number" ? w.limit_window_seconds : typeof w.window_seconds === "number" ? w.window_seconds : undefined;
|
|
796
|
+
const usedPercent = typeof w.used_percent === "number" ? w.used_percent : typeof w.utilization === "number" ? w.utilization * 100 : undefined;
|
|
797
|
+
const remaining = typeof w.remaining === "number" ? w.remaining : undefined;
|
|
726
798
|
const isZero = remaining === 0;
|
|
727
799
|
const isHigh = typeof usedPercent === "number" && Number.isFinite(usedPercent) && usedPercent >= 95;
|
|
728
|
-
if (!isZero && !isHigh)
|
|
800
|
+
if (!isZero && !isHigh)
|
|
801
|
+
return;
|
|
729
802
|
let scopeType = "limit";
|
|
730
|
-
if (scope === "5h" || scope.includes("5h") || scope.includes("5-hour") || windowSeconds ===
|
|
803
|
+
if (scope === "5h" || scope.includes("5h") || scope.includes("5-hour") || windowSeconds === 18000) {
|
|
731
804
|
scopeType = "5h";
|
|
732
|
-
} else if (scope === "7d" || scope === "weekly" || scope === "monthly" || scope.includes("7d") || scope.includes("week") || scope.includes("month") || windowSeconds === 604800 || windowSeconds ===
|
|
805
|
+
} else if (scope === "7d" || scope === "weekly" || scope === "monthly" || scope.includes("7d") || scope.includes("week") || scope.includes("month") || windowSeconds === 604800 || windowSeconds === 2592000) {
|
|
733
806
|
scopeType = "weekly";
|
|
734
807
|
}
|
|
735
808
|
let resetAt;
|
|
736
809
|
if (typeof w.resetAt === "number" && Number.isFinite(w.resetAt)) {
|
|
737
810
|
resetAt = w.resetAt;
|
|
738
811
|
} else if (typeof w.reset_at === "number" && Number.isFinite(w.reset_at)) {
|
|
739
|
-
resetAt = w.reset_at >=
|
|
812
|
+
resetAt = w.reset_at >= 1000000000000 ? w.reset_at : w.reset_at * 1000;
|
|
740
813
|
} else if (typeof w.resets_at === "number" && Number.isFinite(w.resets_at)) {
|
|
741
|
-
resetAt = w.resets_at >=
|
|
814
|
+
resetAt = w.resets_at >= 1000000000000 ? w.resets_at : w.resets_at * 1000;
|
|
742
815
|
}
|
|
743
816
|
const resetAtIsFinite = typeof resetAt === "number" && Number.isFinite(resetAt);
|
|
744
|
-
if (resetAtIsFinite && resetAt !==
|
|
817
|
+
if (resetAtIsFinite && resetAt !== undefined && resetAt <= now) {
|
|
745
818
|
return {
|
|
746
819
|
isExhausted: true,
|
|
747
820
|
isActive: false,
|
|
@@ -752,7 +825,7 @@ function inspectQuotaWindowExhaustion(window, now) {
|
|
|
752
825
|
utilizationHigh: isHigh
|
|
753
826
|
};
|
|
754
827
|
}
|
|
755
|
-
if (resetAtIsFinite && resetAt !==
|
|
828
|
+
if (resetAtIsFinite && resetAt !== undefined && resetAt > now) {
|
|
756
829
|
return {
|
|
757
830
|
isExhausted: true,
|
|
758
831
|
isActive: true,
|
|
@@ -773,23 +846,28 @@ function inspectQuotaWindowExhaustion(window, now) {
|
|
|
773
846
|
};
|
|
774
847
|
}
|
|
775
848
|
function resolveWindowFromQuotaSnapshot(quota, now = Date.now()) {
|
|
776
|
-
if (!isAdmissibleQuotaSnapshot(quota, now))
|
|
849
|
+
if (!isAdmissibleQuotaSnapshot(quota, now))
|
|
850
|
+
return;
|
|
777
851
|
const q = quota;
|
|
778
852
|
const rateLimitRoot = q.rate_limit && typeof q.rate_limit === "object" ? q.rate_limit : q;
|
|
779
853
|
for (const winKey of ["primary_window", "secondary_window"]) {
|
|
780
854
|
const inspected = inspectQuotaWindowExhaustion(rateLimitRoot[winKey], now);
|
|
781
|
-
if (inspected?.isActive && inspected.scopeType !== "limit")
|
|
855
|
+
if (inspected?.isActive && inspected.scopeType !== "limit")
|
|
856
|
+
return inspected.scopeType;
|
|
782
857
|
}
|
|
783
858
|
if (Array.isArray(q.windows)) {
|
|
784
859
|
let hasLimit = false;
|
|
785
860
|
for (const win of q.windows) {
|
|
786
861
|
const inspected = inspectQuotaWindowExhaustion(win, now);
|
|
787
862
|
if (inspected?.isActive) {
|
|
788
|
-
if (inspected.scopeType === "5h" || inspected.scopeType === "weekly")
|
|
789
|
-
|
|
863
|
+
if (inspected.scopeType === "5h" || inspected.scopeType === "weekly")
|
|
864
|
+
return inspected.scopeType;
|
|
865
|
+
if (inspected.scopeType === "limit")
|
|
866
|
+
hasLimit = true;
|
|
790
867
|
}
|
|
791
868
|
}
|
|
792
|
-
if (hasLimit)
|
|
869
|
+
if (hasLimit)
|
|
870
|
+
return "limit";
|
|
793
871
|
}
|
|
794
872
|
for (const winKey of ["primary_window", "secondary_window"]) {
|
|
795
873
|
const inspected = inspectQuotaWindowExhaustion(rateLimitRoot[winKey], now);
|
|
@@ -797,7 +875,7 @@ function resolveWindowFromQuotaSnapshot(quota, now = Date.now()) {
|
|
|
797
875
|
return "limit";
|
|
798
876
|
}
|
|
799
877
|
}
|
|
800
|
-
return
|
|
878
|
+
return;
|
|
801
879
|
}
|
|
802
880
|
function classifyFailureSubclass(input, now = Date.now()) {
|
|
803
881
|
let status;
|
|
@@ -809,17 +887,20 @@ function classifyFailureSubclass(input, now = Date.now()) {
|
|
|
809
887
|
rawMessage = input;
|
|
810
888
|
} else if (input && typeof input === "object") {
|
|
811
889
|
const rec = input;
|
|
812
|
-
status = typeof rec.status === "number" ? rec.status : typeof rec.statusCode === "number" ? rec.statusCode :
|
|
890
|
+
status = typeof rec.status === "number" ? rec.status : typeof rec.statusCode === "number" ? rec.statusCode : undefined;
|
|
813
891
|
rawMessage = typeof rec.message === "string" ? rec.message : "";
|
|
814
|
-
body = rec.body ?? ("status" in rec || "message" in rec ?
|
|
892
|
+
body = rec.body ?? ("status" in rec || "message" in rec ? undefined : input);
|
|
815
893
|
headers = rec.headers;
|
|
816
894
|
quota = rec.quota;
|
|
817
895
|
}
|
|
818
896
|
const bodyText = typeof body === "string" ? body : JSON.stringify(body ?? "");
|
|
819
897
|
const fullText = `${rawMessage} ${bodyText}`.trim();
|
|
820
|
-
if (status === 401)
|
|
821
|
-
|
|
822
|
-
if (status ===
|
|
898
|
+
if (status === 401)
|
|
899
|
+
return "auth";
|
|
900
|
+
if (status === 402)
|
|
901
|
+
return "balance";
|
|
902
|
+
if (status === 403 && !isQuotaLimited403Body(fullText))
|
|
903
|
+
return "auth";
|
|
823
904
|
if (AUTH_ERROR_TEXT_RE.test(fullText) && !isQuotaExhaustedText(fullText) && !BALANCE_ERROR_TEXT_RE.test(fullText)) {
|
|
824
905
|
return "auth";
|
|
825
906
|
}
|
|
@@ -831,7 +912,7 @@ function classifyFailureSubclass(input, now = Date.now()) {
|
|
|
831
912
|
return "capacity";
|
|
832
913
|
}
|
|
833
914
|
const quotaWindowFromSnapshot = resolveWindowFromQuotaSnapshot(quota, now) ?? resolveWindowFromQuotaSnapshot(body, now);
|
|
834
|
-
const hasConfirmedQuotaExhaustion = quotaWindowFromSnapshot !==
|
|
915
|
+
const hasConfirmedQuotaExhaustion = quotaWindowFromSnapshot !== undefined || status === 403 && isQuotaLimited403Body(fullText) && !NEGATED_QUOTA_TEXT_RE.test(fullText) || isQuotaExhaustedText(fullText);
|
|
835
916
|
if (hasConfirmedQuotaExhaustion) {
|
|
836
917
|
if (quotaWindowFromSnapshot === "5h" || !NEGATED_QUOTA_TEXT_RE.test(fullText) && TEXT_5H_WINDOW_RE.test(fullText)) {
|
|
837
918
|
return "quota_5h";
|
|
@@ -841,28 +922,11 @@ function classifyFailureSubclass(input, now = Date.now()) {
|
|
|
841
922
|
}
|
|
842
923
|
return "quota_limit";
|
|
843
924
|
}
|
|
844
|
-
const isRateLimitLike = status === 429 || /\b(?:rate.?limit|too many requests|throttl(?:ed|ing)|resource_exhausted)\b/i.test(
|
|
845
|
-
fullText
|
|
846
|
-
);
|
|
925
|
+
const isRateLimitLike = status === 429 || /\b(?:rate.?limit|too many requests|throttl(?:ed|ing)|resource_exhausted)\b/i.test(fullText);
|
|
847
926
|
if (isRateLimitLike) {
|
|
848
927
|
return "rate_limit";
|
|
849
928
|
}
|
|
850
929
|
return "unknown";
|
|
851
930
|
}
|
|
852
931
|
|
|
853
|
-
export {
|
|
854
|
-
extractQuotaSnapshot,
|
|
855
|
-
formatQuotaSummary,
|
|
856
|
-
DEFAULT_PROVIDER_RETRY_MS,
|
|
857
|
-
isSubscriptionPeriodWindow,
|
|
858
|
-
shouldClearCooldownFromQuota,
|
|
859
|
-
isAgentUnavailableNow,
|
|
860
|
-
resolveAgentAvailability,
|
|
861
|
-
isQuotaExhaustedText,
|
|
862
|
-
isCapacitySaturatedRateLimit,
|
|
863
|
-
resolveAvailabilityAction,
|
|
864
|
-
mergeAvailabilityDeadline,
|
|
865
|
-
resolveCredentialCandidateKeys,
|
|
866
|
-
resolveCredentialKeyWithFallback,
|
|
867
|
-
classifyFailureSubclass
|
|
868
|
-
};
|
|
932
|
+
export { extractQuotaSnapshot, formatQuotaSummary, DEFAULT_PROVIDER_RETRY_MS, isSubscriptionPeriodWindow, shouldClearCooldownFromQuota, isAgentUnavailableNow, resolveAgentAvailability, isQuotaExhaustedText, isCapacitySaturatedRateLimit, resolveAvailabilityAction, mergeAvailabilityDeadline, resolveCredentialCandidateKeys, resolveCredentialKeyWithFallback, classifyFailureSubclass };
|