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.
Files changed (538) hide show
  1. package/{chunk-LXP53WGF.js → chunk-05wkntba.js} +44 -40
  2. package/{chunk-XFYFMTOM.js → chunk-08ts2q1n.js} +9 -11
  3. package/{chromeCommands-MVEEIY4R.js → chunk-0a3m1n6h.js} +182 -238
  4. package/chunk-0gfvc7g8.js +13 -0
  5. package/{chunk-CF7PE763.js → chunk-0h0sncy4.js} +3 -4
  6. package/{chunk-3UH7SS4W.js → chunk-0nsxwrge.js} +232 -241
  7. package/chunk-0ra8cne4.js +11 -0
  8. package/{chunk-MRACVEPZ.js → chunk-0sgwk7am.js} +1 -3
  9. package/{chunk-PEXGRTTQ.js → chunk-0tsfn0dk.js} +44 -45
  10. package/{chunk-WOAZVUSN.js → chunk-0y8cbwzy.js} +26 -30
  11. package/chunk-12gz55kk.js +6 -0
  12. package/{chunk-GLKOYSRU.js → chunk-186gshgw.js} +3 -6
  13. package/chunk-19w4ss38.js +44 -0
  14. package/{chunk-RF576RYE.js → chunk-1cakzp6r.js} +23 -23
  15. package/chunk-1fbfwbzp.js +27 -0
  16. package/{chunk-4IVMDQBA.js → chunk-1fv9k8zt.js} +103 -68
  17. package/{chunk-Q5FJJ6XI.js → chunk-1js4cdzp.js} +11 -19
  18. package/{chunk-YECCIUYU.js → chunk-1nhx0er5.js} +63 -63
  19. package/chunk-1p152b7g.js +12 -0
  20. package/{chunk-HXEO5DNV.js → chunk-1ynbq3yr.js} +322 -353
  21. package/{chunk-6UBGXX2W.js → chunk-1zrg4h5n.js} +3 -4
  22. package/{chunk-Y5GCAMGP.js → chunk-2g6zsfq8.js} +1 -3
  23. package/chunk-2hekb0eh.js +17 -0
  24. package/chunk-2pj6qzq5.js +12 -0
  25. package/chunk-2tvd4jyp.js +226 -0
  26. package/chunk-2ygg7azv.js +846 -0
  27. package/chunk-33405wtv.js +50 -0
  28. package/chunk-34axejtd.js +30 -0
  29. package/{tableCommands-FCPDULSU.js → chunk-3700dvt3.js} +224 -276
  30. package/{pdf-KE3QI2V7.js → chunk-3j08t1nm.js} +12505 -10133
  31. package/chunk-3j9gq18v.js +111 -0
  32. package/{chunk-LYPJYBE5.js → chunk-3qfpcdkm.js} +486 -505
  33. package/{settingThunks-PNC7ZISV.js → chunk-3r2x7h64.js} +189 -272
  34. package/{agentGrantCommands-2VLLXGIU.js → chunk-3tbj5fxt.js} +61 -56
  35. package/chunk-40whhjj5.js +168 -0
  36. package/chunk-4301919y.js +7 -0
  37. package/chunk-43adz39e.js +77 -0
  38. package/{chunk-5ZUL4CUO.js → chunk-49v3zc4g.js} +1 -3
  39. package/chunk-4dd7mxkb.js +72 -0
  40. package/{chunk-BKP325XS.js → chunk-4hapfzpq.js} +66 -62
  41. package/chunk-4mm7dz0m.js +95 -0
  42. package/chunk-4pqxempz.js +440 -0
  43. package/chunk-4x9zf5pv.js +10 -0
  44. package/{chunk-CA7LGAHV.js → chunk-511q8qzv.js} +66 -57
  45. package/{chunk-U7OULUMF.js → chunk-53v9g0np.js} +49 -64
  46. package/chunk-572mg6q5.js +19 -0
  47. package/{chunk-QAW6BEWQ.js → chunk-57eyhmwr.js} +17173 -16165
  48. package/chunk-5hsr0zjm.js +156 -0
  49. package/chunk-5k883yyd.js +20 -0
  50. package/chunk-5m0wsee4.js +639 -0
  51. package/{memberThunks-NEZRAW5K.js → chunk-5r1sq2gt.js} +299 -373
  52. package/chunk-648rq4np.js +255 -0
  53. package/{chunk-IYRZKHA6.js → chunk-666yjw5c.js} +63 -86
  54. package/{chunk-4O22PGNQ.js → chunk-6cdcbmtp.js} +19 -19
  55. package/chunk-6dbyqcf7.js +59 -0
  56. package/{agentProviderCommands-2W3VXDLV.js → chunk-6e8mgp1x.js} +82 -105
  57. package/chunk-6n0pw7sx.js +44 -0
  58. package/chunk-6q1b7381.js +361 -0
  59. package/chunk-6sj756ry.js +23 -0
  60. package/{chunk-4UNN45DS.js → chunk-6t7a7zck.js} +14785 -14454
  61. package/chunk-6yarwtxh.js +776 -0
  62. package/chunk-708h542p.js +18 -0
  63. package/chunk-76f076t8.js +266 -0
  64. package/chunk-782rrrwv.js +523 -0
  65. package/{workloadLifecycle-P2SJVV3S.js → chunk-7gk330wp.js} +77 -84
  66. package/{chunk-EZKIRVLJ.js → chunk-7ks60vxy.js} +146 -128
  67. package/{chunk-FI4DPLR7.js → chunk-7mrqbxe8.js} +342 -228
  68. package/chunk-7sztayrd.js +169 -0
  69. package/chunk-7vgt2mxz.js +15 -0
  70. package/{localFirstLog-OIETGK66.js → chunk-7z8y4k6y.js} +0 -2
  71. package/{chunk-KDDXC2IH.js → chunk-82htft2m.js} +49 -11
  72. package/{updateDialogTitleAction-XOSLNRT3.js → chunk-88vrtxxg.js} +65 -137
  73. package/{chunk-LS5KAVFQ.js → chunk-8dtjbp79.js} +293 -229
  74. package/chunk-8fajbkaz.js +50 -0
  75. package/chunk-8m1ebxpw.js +65 -0
  76. package/{accountResolver-JYG5L7YP.js → chunk-8mgfeg0w.js} +37 -30
  77. package/{chunk-LPXBBC32.js → chunk-8myksy35.js} +156 -160
  78. package/{chunk-BMQ2MJUK.js → chunk-8nrj7dc7.js} +75 -66
  79. package/{commandRegistry-ENNFT77C.js → chunk-8t8x64ec.js} +228 -286
  80. package/chunk-8yj4pq79.js +458 -0
  81. package/{chunk-5MKPNTJP.js → chunk-8z6pepcx.js} +43 -48
  82. package/{chunk-UYQILGDR.js → chunk-90egc9vb.js} +122 -102
  83. package/{chunk-EODBQPRM.js → chunk-91q5dc5r.js} +10 -14
  84. package/{chunk-U6VC4MU4.js → chunk-96jtrqk1.js} +2 -4
  85. package/{chunk-H57T64RA.js → chunk-996j61av.js} +28 -31
  86. package/{chunk-Q6FKWH66.js → chunk-9cxgb9jy.js} +137 -243
  87. package/{chunk-2ZBPWX7N.js → chunk-9q1gbmet.js} +62 -104
  88. package/chunk-9qtjh73q.js +344 -0
  89. package/{chunk-SR57FDTX.js → chunk-9raka469.js} +72 -155
  90. package/{chunk-V6K5U4YE.js → chunk-9vh4v046.js} +32 -41
  91. package/{chunk-AGIM7IMJ.js → chunk-9yr1fy7j.js} +14 -49
  92. package/{chunk-FGFJUFPS.js → chunk-a16x0wt6.js} +11 -18
  93. package/chunk-a5b2rvzs.js +131 -0
  94. package/{chunk-7DPNBQSV.js → chunk-a7bz6nc3.js} +3 -4
  95. package/chunk-ac85azv9.js +29 -0
  96. package/{chunk-VXL2FZTP.js → chunk-ahhbkad4.js} +16 -20
  97. package/{chunk-37DGW762.js → chunk-anhksj2j.js} +16 -29
  98. package/{cliAuthorityBrokerServer-27C5YBYP.js → chunk-atvmx76t.js} +180 -186
  99. package/{chunk-E6A5NHDH.js → chunk-av2mzeqz.js} +16 -17
  100. package/chunk-avbwrb0z.js +614 -0
  101. package/chunk-avr6rqe5.js +544 -0
  102. package/{workContextQueryProjection-CACY5VFE.js → chunk-axx60d5a.js} +7 -7
  103. package/{chunk-EWQ3HGNZ.js → chunk-b00vzjkb.js} +30 -23
  104. package/chunk-b0m6ezxr.js +132 -0
  105. package/chunk-bbd5mgdt.js +47 -0
  106. package/chunk-bcecft0r.js +28 -0
  107. package/chunk-beyr4pyp.js +33 -0
  108. package/{chunk-BR3GT6MR.js → chunk-bge0cagn.js} +7 -18
  109. package/{offlineMarxistsAgentCommand-MFURGWHL.js → chunk-bh53zg3t.js} +33 -43
  110. package/chunk-bmx1cw89.js +37 -0
  111. package/chunk-br2195h4.js +22 -0
  112. package/chunk-bsqkwveq.js +56 -0
  113. package/{chunk-QAU6KM2U.js → chunk-c09s2z1m.js} +139 -98
  114. package/chunk-c235kypv.js +24636 -0
  115. package/{chunk-2JMYAH5O.js → chunk-c30j6pyh.js} +213 -256
  116. package/chunk-c3v6r6sq.js +29 -0
  117. package/{chunk-PDSXYHNI.js → chunk-c5z7qspt.js} +1177 -1196
  118. package/{chunk-GWB6AGME.js → chunk-c6jvz0mp.js} +34 -50
  119. package/{chunk-PRJ473FK.js → chunk-cd6h9qqs.js} +14 -12
  120. package/chunk-cdt0amyy.js +37 -0
  121. package/{chunk-2AJLG6PY.js → chunk-cfh6tfc3.js} +73 -86
  122. package/{chunk-WIVVNJUS.js → chunk-ch4ck1yz.js} +38 -68
  123. package/chunk-chtvrtp5.js +55 -0
  124. package/{chunk-EYLGAEB4.js → chunk-ckvz7abv.js} +170 -165
  125. package/{chunk-YZMNK53S.js → chunk-csf18m5w.js} +32 -25
  126. package/{chunk-C36L6ZID.js → chunk-cwnvf8dt.js} +2 -10
  127. package/chunk-cy7thb6n.js +19877 -0
  128. package/{dialogPortabilityCommands-YQJNB2KL.js → chunk-d61q9nah.js} +439 -487
  129. package/chunk-d6xdy0gp.js +142 -0
  130. package/{chunk-EBH4RFJ6.js → chunk-dh69vqbd.js} +6390 -6496
  131. package/{chunk-KJ4J2XQB.js → chunk-dj4ggbc6.js} +17 -19
  132. package/{chunk-LISC7BD4.js → chunk-djrrhbk3.js} +29 -37
  133. package/chunk-drqzzzvr.js +822 -0
  134. package/chunk-e1n7edjk.js +33 -0
  135. package/chunk-e3atr4hk.js +59 -0
  136. package/chunk-e9bn2aav.js +13 -0
  137. package/chunk-ed396rfq.js +87 -0
  138. package/chunk-eha8ggh6.js +10 -0
  139. package/{chunk-MALPQFGT.js → chunk-ek122zzt.js} +893 -948
  140. package/chunk-epnmvek4.js +22 -0
  141. package/{chunk-S25VJYXV.js → chunk-eqzvk3xm.js} +69 -80
  142. package/chunk-ex34n71b.js +2874 -0
  143. package/{chunk-56OAS5RZ.js → chunk-f3ad6q4h.js} +7 -11
  144. package/{chunk-3PVYUPXK.js → chunk-f8jepva1.js} +6 -7
  145. package/{chunk-GH34JXNV.js → chunk-f9yvy9t9.js} +114 -92
  146. package/chunk-fbdz4f0j.js +90 -0
  147. package/{chunk-J44TXB4J.js → chunk-fcsc2day.js} +216 -164
  148. package/chunk-fevdhnbh.js +19 -0
  149. package/chunk-fkrgqq8w.js +3300 -0
  150. package/{chunk-TSBJVMNW.js → chunk-fs3bvh2p.js} +42 -57
  151. package/chunk-fvwzyhah.js +134 -0
  152. package/chunk-g0mpxdp9.js +101 -0
  153. package/{chunk-LTQ6ECCF.js → chunk-g35f20d1.js} +450 -414
  154. package/{chunk-3L2WKC3W.js → chunk-g5fhtjqg.js} +13 -16
  155. package/{chunk-DBEOW57U.js → chunk-gcq01td7.js} +270 -227
  156. package/{chunk-ADMRXWXJ.js → chunk-ge97b11r.js} +121 -42
  157. package/chunk-ghjtgbkw.js +180 -0
  158. package/chunk-gkra36c1.js +16 -0
  159. package/chunk-gmz86t60.js +1000 -0
  160. package/{localDialogRead-GWGWSL5K.js → chunk-gszpesze.js} +5 -12
  161. package/chunk-gvsfec9m.js +16536 -0
  162. package/{chunk-QSJ3HFEF.js → chunk-h1hzmqph.js} +1 -3
  163. package/chunk-h30dg154.js +17 -0
  164. package/chunk-h3hkb7cw.js +241 -0
  165. package/chunk-h40py996.js +28 -0
  166. package/{chunk-47T3QP4V.js → chunk-h60gnewh.js} +112 -116
  167. package/{agentPullCommand-XEGOUYQT.js → chunk-hkwsv9xf.js} +33 -45
  168. package/chunk-hnyg0gwj.js +28 -0
  169. package/{chunk-KSV6T4AH.js → chunk-hqqqph5w.js} +12 -4
  170. package/{chunk-YQJEXXDK.js → chunk-hrngs1wy.js} +157 -246
  171. package/{chunk-LRLLWD4P.js → chunk-htf69s94.js} +14 -12
  172. package/chunk-j0yxesh3.js +83 -0
  173. package/{chunk-VF4K2QE6.js → chunk-j22t9g05.js} +3 -6
  174. package/{chunk-3R4AYHJR.js → chunk-j4a8m2zn.js} +5 -34
  175. package/chunk-j9p4jnwg.js +27 -0
  176. package/{chunk-R72QWIFO.js → chunk-jdycmfsm.js} +9 -9
  177. package/chunk-jdyvrne0.js +52 -0
  178. package/{spacePruneCommand-YKIEUIDQ.js → chunk-je0b66qf.js} +44 -62
  179. package/{chunk-HNMXYYJR.js → chunk-jec44fkj.js} +3 -4
  180. package/{chunk-526GLZJE.js → chunk-jf1ex00r.js} +107 -73
  181. package/chunk-jgqdec9b.js +31 -0
  182. package/{chunk-56GBUMO5.js → chunk-jkw9n4h5.js} +16 -25
  183. package/{chunk-7422ZLGL.js → chunk-jmnzdwjt.js} +867 -965
  184. package/chunk-jqq57s0a.js +58 -0
  185. package/{chunk-OKUSDVRS.js → chunk-jtkn5aj6.js} +27 -38
  186. package/chunk-jwvzn9r0.js +316 -0
  187. package/chunk-k1re0fc7.js +107 -0
  188. package/chunk-k2ep3rb2.js +103 -0
  189. package/{chunk-JEXVIMYZ.js → chunk-k6ycb24w.js} +5 -8
  190. package/{chunk-RI7SXDJW.js → chunk-kawvydbk.js} +383 -195
  191. package/chunk-kf2ghpzh.js +10 -0
  192. package/{chunk-S6FAHQDH.js → chunk-kgah9e46.js} +28 -59
  193. package/{chunk-T3MWVUBE.js → chunk-kjjepkvc.js} +71 -82
  194. package/chunk-kn4dgg4j.js +4113 -0
  195. package/{chunk-2LFYMWM3.js → chunk-kn5p91n8.js} +43 -53
  196. package/{chunk-MVOZ22RZ.js → chunk-kntqrbwc.js} +8 -12
  197. package/{chunk-I6YIA2TY.js → chunk-kq3vr7mx.js} +25 -20
  198. package/chunk-kz1x1d8n.js +15 -0
  199. package/{mcpLocalAuthorizeCommand-IKOFKY5U.js → chunk-m22e7tt2.js} +53 -71
  200. package/{chunk-ZNFJWEN4.js → chunk-m32rwr4d.js} +11 -8
  201. package/chunk-m39e9m18.js +93 -0
  202. package/{chunk-4D4QD7FT.js → chunk-m5518371.js} +64 -56
  203. package/{chunk-LHTXSC2E.js → chunk-mb5hnfyp.js} +9 -11
  204. package/chunk-mexet11v.js +11 -0
  205. package/chunk-mg2hgfgh.js +185 -0
  206. package/chunk-mmdhm4kx.js +10317 -0
  207. package/chunk-mz002yz8.js +2821 -0
  208. package/chunk-mzadqnyq.js +56 -0
  209. package/{chunk-VIDPVFP3.js → chunk-n3r1ebdm.js} +5 -6
  210. package/chunk-n438qea7.js +33 -0
  211. package/chunk-n5ffnhnb.js +93 -0
  212. package/chunk-nbvd87fy.js +9 -0
  213. package/{chunk-E36V7MPY.js → chunk-ndej7jc9.js} +53 -43
  214. package/{chunk-B767MA64.js → chunk-nen6rwe4.js} +62 -22
  215. package/chunk-nf06tr3v.js +16 -0
  216. package/chunk-ng8z355q.js +16 -0
  217. package/{chunk-4MEKE5D3.js → chunk-nhtxfv8k.js} +78 -63
  218. package/{runAgentClientLoop-2SFASHDS.js → chunk-nj62jscj.js} +132 -214
  219. package/{chunk-GBWGPTA7.js → chunk-nkryrkyp.js} +16 -19
  220. package/chunk-nmesxem8.js +197 -0
  221. package/{chunk-YR4J7RFS.js → chunk-nmq0qwbn.js} +117 -164
  222. package/chunk-nph8brvw.js +7 -0
  223. package/chunk-nr8fees9.js +10 -0
  224. package/{chunk-DFI7MVCQ.js → chunk-nvewvf7h.js} +1441 -1427
  225. package/{chunk-G7Y4GXTY.js → chunk-nyamhphs.js} +70 -79
  226. package/chunk-nz1c8tcg.js +111 -0
  227. package/{chunk-GPLUFN2E.js → chunk-nzc5yffh.js} +176 -217
  228. package/{chunk-G3SUCT4W.js → chunk-p1vg4bx8.js} +2 -4
  229. package/chunk-p3k3abe8.js +202 -0
  230. package/chunk-p4zy30q5.js +8 -0
  231. package/{chunk-ZJACPM5O.js → chunk-p6se1rx0.js} +102 -102
  232. package/chunk-p9dpshev.js +6968 -0
  233. package/chunk-pa42wxr0.js +116 -0
  234. package/{chunk-TA5QI4MM.js → chunk-paxthgqp.js} +56 -107
  235. package/{readlineWorkspace-ZH5FGDMI.js → chunk-pb35s8d9.js} +5395 -5786
  236. package/{chunk-XT6C2QZW.js → chunk-pbebzbcq.js} +8 -8
  237. package/chunk-pbx7e1mb.js +11 -0
  238. package/chunk-pe5czfn9.js +8 -0
  239. package/chunk-pextk1j4.js +62 -0
  240. package/chunk-pf5rywc6.js +575 -0
  241. package/chunk-pjfhd3fz.js +136 -0
  242. package/{chunk-ZCMAKAZM.js → chunk-pkhqb0fs.js} +118 -59
  243. package/chunk-pm5xb9jh.js +26 -0
  244. package/{chunk-Y3KGWZKF.js → chunk-ppdmmdkx.js} +110 -97
  245. package/chunk-pqp6y2hs.js +9 -0
  246. package/{chunk-QHEN7NZ7.js → chunk-ptz8fm2n.js} +12 -17
  247. package/{chunk-EUHMI5KG.js → chunk-pwqnvbt7.js} +65 -46
  248. package/chunk-pzr31nz7.js +12 -0
  249. package/{chunk-WWC7I6TA.js → chunk-q3cx89sw.js} +2 -4
  250. package/chunk-q5pe7be3.js +78 -0
  251. package/{chunk-ZHWTBHT3.js → chunk-q6zqbxp2.js} +418 -409
  252. package/chunk-q7r0e1p3.js +15 -0
  253. package/chunk-q8t2fecd.js +6 -0
  254. package/{chunk-2QAZCYOM.js → chunk-q94zx4d0.js} +721 -753
  255. package/{runtimeDoctorCommands-52MBG5JN.js → chunk-qarz1az1.js} +65 -85
  256. package/{chunk-4INJGWE3.js → chunk-qdcvr25b.js} +72 -53
  257. package/{streamAgentChatTurn-KOUWITHH.js → chunk-qxs27wfg.js} +1079 -1475
  258. package/{chunk-GIXWVN2W.js → chunk-r06ycjjr.js} +50 -47
  259. package/{chunk-63W5N6P3.js → chunk-r20jw5hb.js} +57 -38
  260. package/{chunk-I5BYFTYK.js → chunk-r7sfwdka.js} +1201 -1142
  261. package/{chunk-UMADT6B2.js → chunk-r9sp1yyb.js} +6 -8
  262. package/{handleSendMessageAction-FHGUFT2X.js → chunk-rbd2vgb3.js} +627 -757
  263. package/chunk-rc37js46.js +12 -0
  264. package/{chunk-5YI447UL.js → chunk-rmngk6r3.js} +67 -76
  265. package/chunk-rnhbnbrq.js +15 -0
  266. package/{chunk-WRHVVIGI.js → chunk-rsfnmrt5.js} +111 -131
  267. package/{chunk-YFSM2366.js → chunk-rvvn2rhj.js} +28 -22
  268. package/{chunk-4Y6CZ2N4.js → chunk-s0fpz7ht.js} +37 -33
  269. package/{chunk-VI4SWTUO.js → chunk-s1cqzb2r.js} +77 -65
  270. package/{chunk-6QDYSCPW.js → chunk-s8q81tda.js} +73 -65
  271. package/chunk-s9hy639e.js +6 -0
  272. package/{chunk-R5GO3YZP.js → chunk-s9vbwme8.js} +115 -106
  273. package/chunk-sger1m1b.js +20 -0
  274. package/chunk-spe6crvk.js +60 -0
  275. package/chunk-spwsrvh9.js +70 -0
  276. package/chunk-sr05zpk7.js +573 -0
  277. package/{chunk-M2EJHDJP.js → chunk-srncrd3f.js} +1 -12
  278. package/{chunk-QXHFIX7W.js → chunk-sry80bpx.js} +71 -53
  279. package/{chunk-PSCNXBYA.js → chunk-t6q69p83.js} +3 -4
  280. package/{chunk-UAD2WT54.js → chunk-t714r4q0.js} +9 -28
  281. package/chunk-t7vbraqe.js +42 -0
  282. package/{chunk-CVMMWN6P.js → chunk-td7653rr.js} +10 -20
  283. package/{chunk-3BQDF4QB.js → chunk-tmytcetz.js} +17 -21
  284. package/{chunk-AMWMV56B.js → chunk-tta4prwg.js} +16 -15
  285. package/chunk-tvh8azgq.js +4829 -0
  286. package/{chunk-ID4G2MAR.js → chunk-v08kbfm8.js} +10 -11
  287. package/{chunk-OKPOQGQJ.js → chunk-v1x702q8.js} +801 -852
  288. package/{chunk-KHCLMKZZ.js → chunk-v39fea91.js} +576 -247
  289. package/{chunk-OW765XBU.js → chunk-vejtd8p2.js} +3 -4
  290. package/chunk-vep7zkha.js +368 -0
  291. package/chunk-vfwn1k7n.js +142 -0
  292. package/chunk-vg68vxhx.js +20 -0
  293. package/chunk-vgcqgnsm.js +31 -0
  294. package/{chunk-NF64D32W.js → chunk-vnzyjdea.js} +1 -3
  295. package/{chunk-ZCLSM5AK.js → chunk-vqgtw1px.js} +800 -717
  296. package/chunk-vv1gr5xz.js +76 -0
  297. package/{spaceCommands-Z2CTQD6G.js → chunk-w1qeadpq.js} +176 -242
  298. package/chunk-w468ez1p.js +13 -0
  299. package/chunk-w49s0t79.js +14 -0
  300. package/{mcpLocalManageCommands-KUDZQRM4.js → chunk-w58zhfbn.js} +91 -93
  301. package/chunk-w5b74aq6.js +11 -0
  302. package/chunk-w7y41qyw.js +117 -0
  303. package/chunk-w820gg1w.js +4165 -0
  304. package/{chunk-DBJAJ4UD.js → chunk-wdsmaqmt.js} +399 -453
  305. package/{chunk-3EUW3WEO.js → chunk-wfvvnmmj.js} +1 -3
  306. package/{chunk-QY4NZCDA.js → chunk-wkr04bhk.js} +432 -651
  307. package/{chunk-KUG52IAP.js → chunk-ws402twv.js} +1 -3
  308. package/chunk-wzwh311q.js +164 -0
  309. package/{runtimeModeArgs-X7DL7PUN.js → chunk-x5vtgvwn.js} +6 -5
  310. package/{agentMachineCommands-COJD2KPZ.js → chunk-x8h2csmq.js} +152 -195
  311. package/{chunk-BAZCS5XG.js → chunk-x9zfjnrc.js} +59 -47
  312. package/{chunk-WTIJKWCI.js → chunk-xcarc2rf.js} +50 -56
  313. package/chunk-xf33gz0a.js +8 -0
  314. package/{chunk-PVFYPUIM.js → chunk-y7b3gwx1.js} +78 -71
  315. package/{memoryCommands-SVLAVFCV.js → chunk-y7sphmnh.js} +119 -95
  316. package/{agentListCommands-436FHOIT.js → chunk-ycvaafhc.js} +260 -374
  317. package/chunk-yd7zprb0.js +9 -0
  318. package/chunk-yfz3d27k.js +40 -0
  319. package/{chunk-MKR6KDD3.js → chunk-ykv9g3m4.js} +141 -125
  320. package/chunk-ystjgb9e.js +544 -0
  321. package/chunk-yysxn7ep.js +12 -0
  322. package/{chunk-AL3TYDIF.js → chunk-z17eyawk.js} +18 -16
  323. package/{machineCommands-RVB5OG2X.js → chunk-z17q416p.js} +442 -563
  324. package/chunk-z1n98pcf.js +12 -0
  325. package/{dialogTraceCommand-HWXGIGZX.js → chunk-z566jx5r.js} +292 -397
  326. package/chunk-zjxd6942.js +6 -0
  327. package/{versionChangeNotice-RFABJGJE.js → chunk-zk11x9y5.js} +7 -9
  328. package/{chunk-TEFD5E2D.js → chunk-zt73yc33.js} +48 -51
  329. package/chunk-zvs2fra1.js +5 -0
  330. package/{chunk-SVFFKLMR.js → chunk-zwee84rh.js} +117 -141
  331. package/chunk-zxgfqv72.js +8 -0
  332. package/index.js +53 -69
  333. package/package.json +4 -4
  334. package/_executeModel-YQNZNR2Y.js +0 -341
  335. package/action-UK3HXGXF.js +0 -30
  336. package/addContentAction-CAKFVBDM.js +0 -38
  337. package/addDialogAgentAction-KLJ2YWWM.js +0 -77
  338. package/agentDeleteCommand-S5FVPYKT.js +0 -523
  339. package/agentEmailCommands-ZEFMGVKM.js +0 -742
  340. package/agentRecordCommands-JZ35AC5A.js +0 -211
  341. package/agentRun-UIO43TUG.js +0 -251
  342. package/agentRunCommand-ATLKKD6O.js +0 -249
  343. package/agentRunControl-U2MV74WR.js +0 -211
  344. package/agentRuntimeLocal-P4MMGIR6.js +0 -189
  345. package/agentSlice-HHNKNNYM.js +0 -52
  346. package/appConfigCommands-W4JQHMOJ.js +0 -417
  347. package/appDeleteCommands-IXR47IAV.js +0 -183
  348. package/appDeployCommands-LB6DHDF4.js +0 -232
  349. package/appDeployStatusCommands-UQ6MJL6D.js +0 -204
  350. package/appGetCommands-M5JCTDDQ.js +0 -185
  351. package/appListCommands-TE3ZHE3I.js +0 -186
  352. package/appMigrateCommands-FOXH6R4B.js +0 -230
  353. package/appSourceCommands-3ACYB6I7.js +0 -279
  354. package/authCommand-I5OBJP5S.js +0 -66
  355. package/authCommands-I6KCGOCN.js +0 -54
  356. package/builtinSkillRegistry-MIXYSZUU.js +0 -35
  357. package/chromeOpsCommands-IZRCYDSW.js +0 -579
  358. package/chunk-24BICQPB.js +0 -25
  359. package/chunk-2E4BYAUE.js +0 -69
  360. package/chunk-2O72G3U2.js +0 -17157
  361. package/chunk-2OROOEOQ.js +0 -229
  362. package/chunk-2R6M34JP.js +0 -27225
  363. package/chunk-2SXN7LAY.js +0 -15
  364. package/chunk-35JIFLIG.js +0 -30
  365. package/chunk-3VXVE2LF.js +0 -12
  366. package/chunk-4DBTBNTX.js +0 -477
  367. package/chunk-4JH2UMJR.js +0 -40
  368. package/chunk-4RUQ2PFX.js +0 -432
  369. package/chunk-4SN6J65J.js +0 -38
  370. package/chunk-5MMAK75Q.js +0 -15
  371. package/chunk-6NYQHXMV.js +0 -1737
  372. package/chunk-6R4IY46J.js +0 -14
  373. package/chunk-7E6YXSFZ.js +0 -441
  374. package/chunk-7K4J76JQ.js +0 -917
  375. package/chunk-7LR2IFUH.js +0 -100
  376. package/chunk-AETZ7AD6.js +0 -274
  377. package/chunk-ATNTHIZI.js +0 -13
  378. package/chunk-BPB3T5EU.js +0 -791
  379. package/chunk-BV3FLP2L.js +0 -133
  380. package/chunk-BVYHE6QD.js +0 -110
  381. package/chunk-BWJLEN6X.js +0 -1388
  382. package/chunk-CHOZJMJS.js +0 -78
  383. package/chunk-D2LTQAGN.js +0 -464
  384. package/chunk-DALXH7BG.js +0 -3392
  385. package/chunk-DBCWXGOC.js +0 -15210
  386. package/chunk-DLXL4NSL.js +0 -1179
  387. package/chunk-DSBRIUX5.js +0 -23
  388. package/chunk-DWLEOOGR.js +0 -8
  389. package/chunk-E2KZNP6C.js +0 -13
  390. package/chunk-E5JV4DCB.js +0 -272
  391. package/chunk-EUGTFFO6.js +0 -42
  392. package/chunk-FBNVJ2TO.js +0 -294
  393. package/chunk-FGXG6OLW.js +0 -34
  394. package/chunk-G22P2J7O.js +0 -1775
  395. package/chunk-HEVRQGGH.js +0 -106
  396. package/chunk-HHXF57CL.js +0 -180
  397. package/chunk-HI5RS2O4.js +0 -2109
  398. package/chunk-HJTI7RZV.js +0 -94
  399. package/chunk-HRWRIPTB.js +0 -531
  400. package/chunk-HYCVEESH.js +0 -2824
  401. package/chunk-I42VC5KR.js +0 -15
  402. package/chunk-IB5AR52X.js +0 -15
  403. package/chunk-IIRJ4P4I.js +0 -24
  404. package/chunk-IT3ZZRJE.js +0 -12
  405. package/chunk-IV6VUVLJ.js +0 -88
  406. package/chunk-J42X32PV.js +0 -472
  407. package/chunk-JDMWYVUF.js +0 -449
  408. package/chunk-JKVOKKMQ.js +0 -53
  409. package/chunk-JRTNUU5Z.js +0 -54
  410. package/chunk-K7HLFORE.js +0 -226
  411. package/chunk-KGBASAB5.js +0 -74
  412. package/chunk-KGKTN2NX.js +0 -25
  413. package/chunk-KX6YBIHG.js +0 -8
  414. package/chunk-KYHNSSL2.js +0 -62
  415. package/chunk-KZO2MTVM.js +0 -140
  416. package/chunk-LKZPX6YH.js +0 -0
  417. package/chunk-LLP2NDED.js +0 -201
  418. package/chunk-LOFRSJX2.js +0 -47
  419. package/chunk-M75RM77T.js +0 -3970
  420. package/chunk-MDAYRIP7.js +0 -1889
  421. package/chunk-MI6HRMCK.js +0 -25
  422. package/chunk-MTNQNLSE.js +0 -1029
  423. package/chunk-NH4PUEWK.js +0 -762
  424. package/chunk-NHLLXINQ.js +0 -8
  425. package/chunk-NTUNHTJV.js +0 -40
  426. package/chunk-OJKUU3LP.js +0 -67
  427. package/chunk-OQH3TAB7.js +0 -299
  428. package/chunk-P62DHV4F.js +0 -443
  429. package/chunk-PHIERFHT.js +0 -574
  430. package/chunk-PKDFU6MY.js +0 -102
  431. package/chunk-PL5RKESU.js +0 -40
  432. package/chunk-PSJJBBWV.js +0 -42
  433. package/chunk-QKM55LP2.js +0 -739
  434. package/chunk-QQ56R7KS.js +0 -88
  435. package/chunk-QYPE3TS3.js +0 -43
  436. package/chunk-REAE2SZK.js +0 -62
  437. package/chunk-RGQ4UUWZ.js +0 -208
  438. package/chunk-RIRFHJTW.js +0 -353
  439. package/chunk-RYMLMTPZ.js +0 -547
  440. package/chunk-SSGTV4FC.js +0 -303
  441. package/chunk-SVKWZ3EG.js +0 -607
  442. package/chunk-T7KODHYS.js +0 -317
  443. package/chunk-TGVVE5BA.js +0 -3085
  444. package/chunk-TKLBBR7P.js +0 -779
  445. package/chunk-TZXPT53C.js +0 -8
  446. package/chunk-U67V476Y.js +0 -35
  447. package/chunk-UEILX4EV.js +0 -15
  448. package/chunk-VIWDGTDA.js +0 -8
  449. package/chunk-VXUQWCEZ.js +0 -138
  450. package/chunk-W5GKF5ZW.js +0 -32
  451. package/chunk-WDWZPASX.js +0 -29
  452. package/chunk-WX266G2C.js +0 -9594
  453. package/chunk-YCITCYSJ.js +0 -356
  454. package/chunk-Z3KTXWWB.js +0 -76
  455. package/chunk-ZC3CMUKU.js +0 -322
  456. package/chunk-ZSZBHRLP.js +0 -1710
  457. package/chunk-ZV7ZY46L.js +0 -1343
  458. package/cliAgentConfigHelpers-WB2S7PDO.js +0 -47
  459. package/cliAuthorityBrokerClient-3SKOA7OZ.js +0 -23
  460. package/cliAuthorityBrokerProcess-BMBVXPKU.js +0 -24
  461. package/cliAuthorityStoreDriver-6FE3BJNB.js +0 -20
  462. package/cliEnvHelpers-7V5ZWUJA.js +0 -34
  463. package/cliExecutor-N3445G2Z.js +0 -45
  464. package/cliLocalAgentRecordReader-QKKRK53P.js +0 -113
  465. package/cloudAutomationCommands-S52NKCLL.js +0 -310
  466. package/contentThunks-ERA42OXW.js +0 -100
  467. package/cooldownCommands-ZFDAL4MR.js +0 -79
  468. package/createAgentAutomationAction-DMD2VDPI.js +0 -173
  469. package/createDialogAction-3SPOJQAK.js +0 -87
  470. package/createPageAction-AVXUMZVT.js +0 -91
  471. package/cursorProvider-2RACMEMF.js +0 -6123
  472. package/db-LTHLW7QA.js +0 -178
  473. package/dbSlice-WNUHTF4C.js +0 -76
  474. package/deleteDbKey-KV6MYBAI.js +0 -87
  475. package/desktopFolderProjects-4POAMVJN.js +0 -45
  476. package/dialogCommands-4MOLJW4G.js +0 -165
  477. package/dialogMessageRecord-2HJTEXQX.js +0 -7
  478. package/dialogNotifyCommand-YL2GFKLO.js +0 -45
  479. package/dialogSlice-Q7H2YVNO.js +0 -200
  480. package/dialogUsageCommand-IO2BQKL2.js +0 -31
  481. package/docCreateCommands-OYLRBK2M.js +0 -255
  482. package/docDeleteCommands-3NF6QPJU.js +0 -226
  483. package/docReadCommands-CBAERJAP.js +0 -184
  484. package/docStore-GWPFDV6Y.js +0 -89
  485. package/docUpdateCommands-BAMCGX6F.js +0 -326
  486. package/ebookDownloaderAgentCommand-NOIZ6U7Y.js +0 -675
  487. package/fetchMessages-P7FSCSXV.js +0 -19
  488. package/getPricing-KNXVEIUI.js +0 -40
  489. package/hostCredentialCreate-2VEYBXJV.js +0 -402
  490. package/i18n-SAK6DDY4.js +0 -51
  491. package/keys-FXEGMKSG.js +0 -183
  492. package/legacyMigration-TF4SYJCZ.js +0 -19
  493. package/levelAuthorityStore-L5SVDM5O.js +0 -10
  494. package/localAutomationCommands-XSK7SM7I.js +0 -199
  495. package/localAutomationRuntime-5WBO7HGQ.js +0 -61
  496. package/localRecall-BDYKXB46.js +0 -17
  497. package/localRuntimeAdapter-Y6H6XRIH.js +0 -310
  498. package/localRuntimeAuthority-Q5C2KWGF.js +0 -45
  499. package/localRuntimeDb-MM3DINZM.js +0 -12
  500. package/machineInfo-HNPJHQFU.js +0 -14
  501. package/machineWsRunDispatch-Y5SJGCEE.js +0 -228
  502. package/models-TOXYINNM.js +0 -10
  503. package/oauthTokenStore-RUYNYALS.js +0 -24
  504. package/overlay-JA3SPVUS.js +0 -15
  505. package/parityCommands-5OCBPVES.js +0 -613
  506. package/processSpawn-6GEO77KV.js +0 -11
  507. package/profileConfig-KOWK4HOG.js +0 -49
  508. package/projectArchive-WE3VVPZ2.js +0 -132
  509. package/providerPresetApply-YCVSP2WX.js +0 -235
  510. package/providerRegistry-26PAUYH2.js +0 -24
  511. package/read-D4WYJQJQ.js +0 -32
  512. package/readDocTool-3S3OQFOH.js +0 -22
  513. package/rememberExplicit-ZPI6KK5M.js +0 -16
  514. package/remove-AHRMUDMH.js +0 -32
  515. package/removeDialogAgentAction-AALRBFSA.js +0 -81
  516. package/secretCommands-2PSS3QNZ.js +0 -24
  517. package/setDialogExtraReferencesAction-SLHQ3GYL.js +0 -39
  518. package/setPrimaryDialogAgentAction-XKCSGJ7M.js +0 -96
  519. package/skillDiscovery-IUEZZG2B.js +0 -29
  520. package/skillSummaryMarker-62UW7HI7.js +0 -9
  521. package/slateToRenderMarkdown-R3X74MCX.js +0 -7
  522. package/slateUtils-ESQAJ6RN.js +0 -19
  523. package/store-WSAVTR32.js +0 -50
  524. package/switchDialogAgentAction-YJIWQGIR.js +0 -70
  525. package/tombstones-FQQMEDOW.js +0 -32
  526. package/toolApiClient-FVXTIIEN.js +0 -42
  527. package/tools-WN4AVSNS.js +0 -147
  528. package/tuiRestart-LU2BDLAW.js +0 -50
  529. package/tuiSummaryLlmCaller-Z2ZVBIGN.js +0 -53
  530. package/updateCommands-4QP7WJLA.js +0 -63
  531. package/usageCommand-AZX7D3LB.js +0 -31
  532. package/usageRebuildCommand-XV5QQCHK.js +0 -623
  533. package/userDataMerge-HT2ZVHBJ.js +0 -13
  534. package/windowsSelfUpdate-5OFKSW6Y.js +0 -14
  535. package/workContext-ZAW6VXT7.js +0 -18
  536. package/workContextAccess-VU5I4LKZ.js +0 -11
  537. package/workContextWriteNotice-YCSSMHN4.js +0 -7
  538. /package/{chunk-BYXBJQAS.js → chunk-0bcc25vg.js} +0 -0
package/chunk-BWJLEN6X.js DELETED
@@ -1,1388 +0,0 @@
1
- import {
2
- resolveObservedSpeed
3
- } from "./chunk-AMWMV56B.js";
4
- import {
5
- fnv1a32Hex
6
- } from "./chunk-UEILX4EV.js";
7
- import {
8
- compareAgentSelection,
9
- isEmptyListAgentsFragmentRequest
10
- } from "./chunk-ZV7ZY46L.js";
11
- import {
12
- resolveAgentAvailability
13
- } from "./chunk-LS5KAVFQ.js";
14
- import {
15
- LIST_AGENTS_PAGE_BUDGET,
16
- sanitizeToolOutputText,
17
- scrubSecrets
18
- } from "./chunk-D2LTQAGN.js";
19
- import {
20
- isOAuthApiKeyRef
21
- } from "./chunk-ZCLSM5AK.js";
22
- import {
23
- resolveModelTier
24
- } from "./chunk-HEVRQGGH.js";
25
- import {
26
- isOwnedAgentKey,
27
- ownedAgentKey,
28
- publicAgentKey
29
- } from "./chunk-M2EJHDJP.js";
30
- import {
31
- resolveModelReasoningCapability
32
- } from "./chunk-RI7SXDJW.js";
33
- import {
34
- REASONING_EFFORT_OPTIONS
35
- } from "./chunk-7LR2IFUH.js";
36
- import {
37
- isSubscriptionEndpoint,
38
- isSubscriptionOAuthCredential
39
- } from "./chunk-SR57FDTX.js";
40
- import {
41
- asTrimmedLowercaseString
42
- } from "./chunk-QSJ3HFEF.js";
43
- import {
44
- createKey,
45
- createTokenKey
46
- } from "./chunk-DLXL4NSL.js";
47
-
48
- // packages/core/gptProTier.ts
49
- var GPT_PRO_REQUIRED_RECHARGE_AMOUNT = 199;
50
- var SUPPORTED_TIER_PROVIDERS = /* @__PURE__ */ new Set([
51
- "nolo",
52
- "openai",
53
- "deepinfra"
54
- ]);
55
- var CLAUDE_PREMIUM_RE = /^(?:anthropic\/)?claude-(opus|fable)(?:-\d+(?:[.-]\d+)*(?:-[a-z0-9]+)*)?$/i;
56
- var GPT_PRO_RE = /^(?:openai\/)?gpt-[a-z0-9.-]+-pro(?:-[a-z0-9]+(?:[.-][a-z0-9]+)*)?$/i;
57
- var GPT_SOL_RE = /^(?:openai\/)?gpt-\d+(?:\.\d+)*-sol(?:-[a-z0-9]+(?:[.-][a-z0-9]+)*)?$/i;
58
- var GPT_ASTRA_RE = /^(?:openai\/)?gpt-\d+(?:\.\d+)*-astra(?:-[a-z0-9]+(?:[.-][a-z0-9]+)*)?$/i;
59
- var KIMI_K3_MODELS = /* @__PURE__ */ new Set([
60
- "kimi-k3",
61
- "moonshotai/kimi-k3",
62
- // 2026-11-18:K3 由 K3.1 Pro 接替(目录换成 kimi-k3.1-pro),旗舰档门槛保持一致 —
63
- // 不因换代把 199 档位约束漏掉。
64
- "kimi-k3.1-pro",
65
- "moonshotai/kimi-k3.1-pro",
66
- // 旧 K2.6 经 PLATFORM_MODEL_ALIASES 执行同一 K3.1 Pro 上游与计费:档位判定按
67
- // 请求 id 直查,不带这一条就会出现「换个旧 id 绕过 premium 门槛」。
68
- "kimi-k2.6",
69
- "moonshotai/kimi-k2.6"
70
- ]);
71
- function classifyPremiumModel(model) {
72
- const normalizedModel = asTrimmedLowercaseString(model);
73
- if (!normalizedModel) return void 0;
74
- const claudeMatch = CLAUDE_PREMIUM_RE.exec(normalizedModel);
75
- if (claudeMatch) {
76
- return claudeMatch[1].toLowerCase() === "opus" ? "claude-opus" : "claude-fable";
77
- }
78
- if (GPT_PRO_RE.test(normalizedModel)) {
79
- return "gpt-pro";
80
- }
81
- if (GPT_SOL_RE.test(normalizedModel)) {
82
- return "gpt-sol";
83
- }
84
- if (GPT_ASTRA_RE.test(normalizedModel)) {
85
- return "gpt-astra";
86
- }
87
- if (KIMI_K3_MODELS.has(normalizedModel)) {
88
- return "kimi-k3";
89
- }
90
- return void 0;
91
- }
92
- function isGptProModel(provider, model) {
93
- const normalizedProvider = asTrimmedLowercaseString(provider);
94
- if (!SUPPORTED_TIER_PROVIDERS.has(normalizedProvider)) {
95
- return false;
96
- }
97
- return classifyPremiumModel(model) !== void 0;
98
- }
99
- var GPT_PRO_BLOCKED_MESSAGE = `GPT Pro / Kimi K3.1 Pro \u7B49\u9AD8\u7EA7\u6A21\u578B\u9700\u8981\u5148\u5F00\u901A ${GPT_PRO_REQUIRED_RECHARGE_AMOUNT} \u79EF\u5206\u6863\u4F4D\u3002`;
100
- function shouldBlockForGptPro(input) {
101
- if (input?.premium !== true || input?.platformPaid !== true) {
102
- return { blocked: false };
103
- }
104
- if (asTrimmedLowercaseString(input.gptProStatus) === "active") {
105
- return { blocked: false };
106
- }
107
- return { blocked: true, message: GPT_PRO_BLOCKED_MESSAGE };
108
- }
109
-
110
- // packages/ai/agent/agentBilling.ts
111
- function resolveBillingSource(candidate) {
112
- if (candidate?.local === true || candidate?.isLocal === true || candidate?.cliProvider === "local" || candidate?.apiSource === "local" || candidate?.provider === "local" || candidate?.billingSource === "local") return "local";
113
- if (candidate?.isOwned !== true) {
114
- const ownerUserId = typeof candidate?.userId === "string" && candidate.userId.trim() ? candidate.userId.trim() : typeof candidate?.ownerId === "string" && candidate.ownerId.trim() ? candidate.ownerId.trim() : "";
115
- if (ownerUserId && (candidate?.isOAuth === true || isOAuthApiKeyRef(candidate?.apiKeyRef))) {
116
- return "owner_subscription";
117
- }
118
- return "platform_credits";
119
- }
120
- if (candidate?.isOAuth === true || candidate?.billingSource === "user_subscription" || candidate?.apiSource === "oauth" || isOAuthApiKeyRef(candidate?.apiKeyRef)) return "user_subscription";
121
- if (candidate?.apiSource === "custom" || candidate?.billingSource === "user_api") {
122
- if (isSubscriptionEndpoint(candidate?.customProviderUrl) || isSubscriptionOAuthCredential(candidate?.apiKeyRef)) {
123
- return "user_subscription";
124
- }
125
- return "user_api";
126
- }
127
- return "platform_credits";
128
- }
129
-
130
- // packages/ai/economics/economicsPolicy.ts
131
- var DEEPSEEK_PRICING_DOC = "https://api-docs.deepseek.com/quick_start/pricing";
132
- var BIGMODEL_CODING_PLAN_USAGE_NOTES = "https://docs.bigmodel.cn/cn/coding-plan/usage-notes";
133
- var WEEKDAYS_MON_FRI = [1, 2, 3, 4, 5];
134
- var DEEPSEEK_API_POLICY = {
135
- id: "deepseek_api",
136
- version: "2026-09-weekday-utc-peak-2x",
137
- windows: [
138
- { timezone: "UTC", weekdays: WEEKDAYS_MON_FRI, startMinute: 60, endMinute: 240 },
139
- { timezone: "UTC", weekdays: WEEKDAYS_MON_FRI, startMinute: 360, endMinute: 600 }
140
- ],
141
- effectiveFrom: Date.UTC(2026, 7, 16, 16, 0, 0),
142
- peakPriceMultiplier: 2,
143
- offPeakPriceMultiplier: 1,
144
- sourceUrl: DEEPSEEK_PRICING_DOC
145
- };
146
- var BIGMODEL_GLM_CODING_PLAN_POLICY = {
147
- id: "bigmodel_glm_coding_plan",
148
- version: "2026-09-coding-plan-sh-peak-14-18",
149
- windows: [
150
- { timezone: "Asia/Shanghai", weekdays: WEEKDAYS_MON_FRI, startMinute: 840, endMinute: 1080 }
151
- ],
152
- peakQuotaMultiplier: 1,
153
- offPeakQuotaMultiplier: 0.5,
154
- sourceUrl: BIGMODEL_CODING_PLAN_USAGE_NOTES
155
- };
156
- var ECONOMICS_POLICIES = [
157
- DEEPSEEK_API_POLICY,
158
- BIGMODEL_GLM_CODING_PLAN_POLICY
159
- ];
160
- function resolveEconomicsSourceId(input) {
161
- const provider = typeof input?.provider === "string" ? input.provider.trim().toLowerCase() : "";
162
- if (input?.apiSource?.trim().toLowerCase() === "platform") return null;
163
- const rawUrl = typeof input?.customProviderUrl === "string" ? input.customProviderUrl.trim() : "";
164
- let hostname = "";
165
- let pathname = "";
166
- if (rawUrl) {
167
- try {
168
- const parsed = new URL(rawUrl);
169
- hostname = parsed.hostname.toLowerCase();
170
- pathname = parsed.pathname;
171
- } catch {
172
- return null;
173
- }
174
- }
175
- if (provider === "deepseek") {
176
- if (rawUrl && hostname !== "api.deepseek.com") return null;
177
- return rawUrl ? "deepseek_api" : null;
178
- }
179
- if (provider === "bigmodel") {
180
- if (hostname === "open.bigmodel.cn" && pathname.startsWith("/api/coding/")) {
181
- return "bigmodel_glm_coding_plan";
182
- }
183
- return null;
184
- }
185
- return null;
186
- }
187
-
188
- // packages/ai/economics/economicsSnapshot.ts
189
- var wallClockFormatterCache = /* @__PURE__ */ new Map();
190
- function getWallClockFormatter(timezone) {
191
- let formatter = wallClockFormatterCache.get(timezone);
192
- if (!formatter) {
193
- formatter = new Intl.DateTimeFormat("en-US", {
194
- timeZone: timezone,
195
- hourCycle: "h23",
196
- year: "numeric",
197
- month: "2-digit",
198
- day: "2-digit",
199
- hour: "2-digit",
200
- minute: "2-digit",
201
- second: "2-digit"
202
- });
203
- wallClockFormatterCache.set(timezone, formatter);
204
- }
205
- return formatter;
206
- }
207
- function getZonedWallClock(timezone, at) {
208
- const parts = getWallClockFormatter(timezone).formatToParts(new Date(at));
209
- const values = {};
210
- for (const part of parts) {
211
- if (part.type !== "literal") values[part.type] = Number(part.value);
212
- }
213
- const year = values.year;
214
- const month = values.month;
215
- const day = values.day;
216
- const hour = values.hour;
217
- const minute = values.minute;
218
- const second = values.second;
219
- const weekday = new Date(Date.UTC(year, month - 1, day)).getUTCDay();
220
- return { year, month, day, hour, minute, second, weekday, minutesOfDay: hour * 60 + minute };
221
- }
222
- function getTimeZoneOffsetMs(timezone, at) {
223
- const atSecond = Math.floor(at / 1e3) * 1e3;
224
- const clock = getZonedWallClock(timezone, atSecond);
225
- return Date.UTC(clock.year, clock.month - 1, clock.day, clock.hour, clock.minute, clock.second) - atSecond;
226
- }
227
- function zonedWallClockToEpochMs(timezone, year, month, day, minutesOfDay) {
228
- const guess = Date.UTC(year, month - 1, day, Math.floor(minutesOfDay / 60), minutesOfDay % 60);
229
- let instant = guess - getTimeZoneOffsetMs(timezone, guess);
230
- instant = guess - getTimeZoneOffsetMs(timezone, instant);
231
- return instant;
232
- }
233
- function resolveEconomicsPeriod(policy, at) {
234
- for (const window of policy.windows) {
235
- const clock = getZonedWallClock(window.timezone, at);
236
- if (!window.weekdays.includes(clock.weekday)) continue;
237
- if (clock.minutesOfDay >= window.startMinute && clock.minutesOfDay < window.endMinute) {
238
- return "peak";
239
- }
240
- }
241
- return "off_peak";
242
- }
243
- function findNextEconomicsBoundary(policy, at) {
244
- let best;
245
- for (const window of policy.windows) {
246
- const anchor = getZonedWallClock(window.timezone, at);
247
- for (let dayOffset = 0; dayOffset <= 7; dayOffset++) {
248
- const dayUtc = new Date(Date.UTC(anchor.year, anchor.month - 1, anchor.day + dayOffset));
249
- const weekday = dayUtc.getUTCDay();
250
- if (!window.weekdays.includes(weekday)) continue;
251
- const year = dayUtc.getUTCFullYear();
252
- const month = dayUtc.getUTCMonth() + 1;
253
- const day = dayUtc.getUTCDate();
254
- for (const edge of [window.startMinute, window.endMinute]) {
255
- const instant = zonedWallClockToEpochMs(window.timezone, year, month, day, edge);
256
- if (instant > at && (best === void 0 || instant < best)) best = instant;
257
- }
258
- }
259
- }
260
- return best;
261
- }
262
- function selectEconomicsPolicyVersion(policies, sourceId, at) {
263
- const applicable = policies.filter(
264
- (policy) => policy.id === sourceId && (policy.effectiveFrom === void 0 || policy.effectiveFrom <= at) && (policy.effectiveUntil === void 0 || at < policy.effectiveUntil)
265
- );
266
- if (applicable.length === 0) return null;
267
- return applicable.reduce(
268
- (latest, candidate) => (candidate.effectiveFrom ?? -Infinity) >= (latest.effectiveFrom ?? -Infinity) ? candidate : latest
269
- );
270
- }
271
- function findNextPolicyBoundary(policy, at, policies) {
272
- const boundaries = [
273
- policy.effectiveUntil,
274
- ...policies.filter((candidate) => candidate.id === policy.id).map((candidate) => candidate.effectiveFrom).filter((value) => value !== void 0 && value > at)
275
- ].filter((value) => value !== void 0 && value > at);
276
- return boundaries.length > 0 ? Math.min(...boundaries) : void 0;
277
- }
278
- function resolveEconomicsSnapshot(input, at, policies = ECONOMICS_POLICIES) {
279
- const sourceId = resolveEconomicsSourceId(input);
280
- if (!sourceId) return null;
281
- const policy = selectEconomicsPolicyVersion(policies, sourceId, at);
282
- if (!policy) return null;
283
- const period = resolveEconomicsPeriod(policy, at);
284
- const priceMultiplier = period === "peak" ? policy.peakPriceMultiplier : policy.offPeakPriceMultiplier;
285
- const quotaMultiplier = period === "peak" ? policy.peakQuotaMultiplier : policy.offPeakQuotaMultiplier;
286
- const windowBoundary = findNextEconomicsBoundary(policy, at);
287
- const policyBoundary = findNextPolicyBoundary(policy, at, policies);
288
- const changesAt = [windowBoundary, policyBoundary].filter((value) => value !== void 0).sort((a, b) => a - b)[0];
289
- return {
290
- source: sourceId,
291
- policyVersion: policy.version,
292
- period,
293
- ...priceMultiplier !== void 0 ? { priceMultiplier } : {},
294
- ...quotaMultiplier !== void 0 ? { quotaMultiplier } : {},
295
- ...changesAt !== void 0 ? { changesAt } : {}
296
- };
297
- }
298
-
299
- // packages/ai/agent/safeAgentSummary.ts
300
- function deriveCredentialGroup(ref) {
301
- if (!ref || typeof ref !== "string") return void 0;
302
- const trimmed = ref.trim();
303
- if (!trimmed) return void 0;
304
- if (isOAuthApiKeyRef(trimmed)) {
305
- return {
306
- credentialGroup: trimmed.toLowerCase(),
307
- credentialKind: "oauth"
308
- };
309
- }
310
- const hash = fnv1a32Hex(trimmed);
311
- return {
312
- credentialGroup: `cred-${hash}`,
313
- credentialKind: "api-key"
314
- };
315
- }
316
- function deriveCustomProviderCredentialGroup(userId, customProviderUrl) {
317
- if (typeof customProviderUrl !== "string" || !customProviderUrl.trim()) {
318
- return void 0;
319
- }
320
- const basis = `${userId ?? ""}|${customProviderUrl.trim().toLowerCase()}`;
321
- return {
322
- credentialGroup: `custom-${fnv1a32Hex(basis)}`,
323
- credentialKind: "api-key"
324
- };
325
- }
326
- function summarizeCredentialGroups(agents, now = Date.now()) {
327
- const groups = /* @__PURE__ */ new Map();
328
- for (const agent of agents) {
329
- if (!agent.credentialGroup || !agent.credentialKind) continue;
330
- if (agent.isOwned === false) continue;
331
- const existing = groups.get(agent.credentialGroup);
332
- const at = typeof agent.nextAvailableAt === "number" && agent.nextAvailableAt > now ? agent.nextAvailableAt : void 0;
333
- if (!existing) {
334
- groups.set(agent.credentialGroup, {
335
- credentialGroup: agent.credentialGroup,
336
- credentialKind: agent.credentialKind,
337
- agentCount: 1,
338
- ...at !== void 0 ? { availableAt: at } : {}
339
- });
340
- } else {
341
- existing.agentCount += 1;
342
- if (at !== void 0) {
343
- existing.availableAt = Math.max(existing.availableAt ?? 0, at);
344
- }
345
- }
346
- }
347
- return Array.from(groups.values()).sort(
348
- (a, b) => a.credentialGroup.localeCompare(b.credentialGroup)
349
- );
350
- }
351
- function parseTimestamp(val) {
352
- if (typeof val === "number" && Number.isFinite(val)) return val;
353
- if (typeof val === "string") return Date.parse(val) || 0;
354
- return 0;
355
- }
356
- function safeTimestamp(val) {
357
- if (typeof val === "number" && Number.isFinite(val)) return val;
358
- if (typeof val === "string") return val;
359
- return null;
360
- }
361
- function parseAgentRecordId(privateKey, explicitId) {
362
- if (explicitId && typeof explicitId === "string" && explicitId.trim()) {
363
- return explicitId.trim();
364
- }
365
- if (privateKey && typeof privateKey === "string") {
366
- const match = privateKey.match(/^agent-[^-]+-(.+)$/i);
367
- if (match?.[1]) return match[1];
368
- }
369
- return null;
370
- }
371
- function resolveFavoriteStatus(record, options) {
372
- if (options?.isFavorite !== void 0) {
373
- return {
374
- isFavorite: !!options.isFavorite,
375
- favoritedAt: safeTimestamp(options.favoritedAt)
376
- };
377
- }
378
- if (record?.isFavorite === true) {
379
- return {
380
- isFavorite: true,
381
- favoritedAt: safeTimestamp(record?.favoritedAt)
382
- };
383
- }
384
- const favoritesMap = options?.favoritesMap;
385
- if (!favoritesMap) {
386
- return { isFavorite: false, favoritedAt: null };
387
- }
388
- const candidateKeys = [];
389
- if (typeof record?.dbKey === "string" && record.dbKey) candidateKeys.push(record.dbKey);
390
- if (typeof record?.privateKey === "string" && record.privateKey) candidateKeys.push(record.privateKey);
391
- if (typeof record?.publicKey === "string" && record.publicKey) candidateKeys.push(record.publicKey);
392
- if (typeof record?.verifiedAgentKey === "string" && record.verifiedAgentKey) {
393
- candidateKeys.push(record.verifiedAgentKey);
394
- }
395
- if (typeof record?.id === "string" && record.id) {
396
- candidateKeys.push(record.id);
397
- candidateKeys.push(publicAgentKey(record.id));
398
- if (options?.userId) {
399
- candidateKeys.push(ownedAgentKey(options.userId, record.id));
400
- }
401
- }
402
- let matched = false;
403
- let highestFavAt = null;
404
- let highestFavTime = -1;
405
- for (const key of candidateKeys) {
406
- const val = favoritesMap instanceof Map ? favoritesMap.get(key) : favoritesMap[key];
407
- if (val !== void 0 && val !== false && val !== null) {
408
- const favAt = val === true ? 1 : safeTimestamp(val);
409
- if (favAt === null) continue;
410
- matched = true;
411
- const time = parseTimestamp(favAt);
412
- if (time > highestFavTime) {
413
- highestFavTime = time;
414
- highestFavAt = favAt;
415
- }
416
- }
417
- }
418
- if (matched) {
419
- return {
420
- isFavorite: true,
421
- favoritedAt: highestFavAt ?? 1
422
- };
423
- }
424
- return { isFavorite: false, favoritedAt: null };
425
- }
426
- function isOwnedAgentRecord(record, userId) {
427
- if (!userId) return false;
428
- if (typeof record?.userId === "string" && record.userId === userId || typeof record?.ownerId === "string" && record.ownerId === userId) {
429
- return true;
430
- }
431
- return [record?.dbKey, record?.privateKey].some(
432
- (key) => isOwnedAgentKey(key, userId)
433
- );
434
- }
435
- function subscriptionQuotaChannel(source) {
436
- if (typeof source !== "string") return void 0;
437
- const id = source.toLowerCase();
438
- if (id.includes("fetchavailablemodels:pool:")) return "antigravity";
439
- const probe = id.match(/(?:^|[^a-z0-9-])(antigravity|codex|anthropic|claude|cursor|devin|xai)-oauth(?=$|[^a-z0-9-])/)?.[1];
440
- if (probe === "codex") return "chatgpt";
441
- if (probe === "anthropic") return "claude";
442
- return probe;
443
- }
444
- function toSafeAgentSummary(record, options) {
445
- const rawId = parseAgentRecordId(
446
- typeof record?.privateKey === "string" ? record.privateKey : record?.dbKey,
447
- typeof record?.id === "string" ? record.id : void 0
448
- );
449
- const id = rawId ?? (typeof record?.id === "string" ? record.id : null);
450
- const publicRecordDenied = record?.publicRecordExists === false || options?.publicRecordExists === false;
451
- const publicRecordConfirmed = record?.publicRecordExists === true || options?.publicRecordExists === true;
452
- let publicKey;
453
- if (typeof record?.publicKey === "string" && record.publicKey && !publicRecordDenied) {
454
- publicKey = record.publicKey;
455
- } else if (publicRecordConfirmed && id) {
456
- publicKey = publicAgentKey(id);
457
- }
458
- const name = typeof record?.name === "string" && record.name ? record.name : "(unnamed)";
459
- const handle = typeof record?.handle === "string" && record.handle ? record.handle : null;
460
- const introduction = typeof record?.introduction === "string" && record.introduction ? record.introduction : typeof record?.description === "string" && record.description ? record.description : null;
461
- const roleText = typeof record?.introduction === "string" ? record.introduction.trim().replace(/\s+/g, " ") : "";
462
- const roleChars = Array.from(roleText);
463
- const roleHint = roleChars.length > 60 ? `${roleChars.slice(0, 59).join("")}\u2026` : roleText;
464
- const model = typeof record?.model === "string" && record.model ? record.model : null;
465
- const provider = typeof record?.provider === "string" && record.provider ? record.provider : typeof record?.apiSource === "string" && record.apiSource ? record.apiSource : null;
466
- const apiSource = typeof record?.apiSource === "string" && record.apiSource ? record.apiSource : null;
467
- const cliProvider = typeof record?.cliProvider === "string" && record.cliProvider ? record.cliProvider : null;
468
- const tools = Array.isArray(record?.tools) ? record.tools.filter((t) => typeof t === "string") : [];
469
- const inputPrice = typeof record?.inputPrice === "number" && Number.isFinite(record.inputPrice) ? record.inputPrice : null;
470
- const outputPrice = typeof record?.outputPrice === "number" && Number.isFinite(record.outputPrice) ? record.outputPrice : null;
471
- const favStatus = resolveFavoriteStatus(record, options);
472
- const isPublic = record?.isPublic === true || record?.isPublicFlag === true || record?.publicRecordExists === true;
473
- const updatedAt = safeTimestamp(record?.updatedAt ?? record?.createdAt ?? record?.created);
474
- const nextAvailableAt = typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? record.nextAvailableAt : void 0;
475
- const currentUserId = options?.userId;
476
- const ownedKey = currentUserId ? [record?.dbKey, record?.privateKey].find(
477
- (key) => isOwnedAgentKey(key, currentUserId)
478
- ) : void 0;
479
- const isOwned = isOwnedAgentRecord(record, currentUserId);
480
- const isOAuth = isOAuthApiKeyRef(record?.apiKeyRef);
481
- const billingSource = resolveBillingSource({
482
- ...record,
483
- isOAuth,
484
- isOwned,
485
- apiSource,
486
- cliProvider,
487
- provider,
488
- isPublic
489
- });
490
- const economics = resolveEconomicsSnapshot(
491
- {
492
- provider,
493
- apiSource,
494
- customProviderUrl: typeof record?.customProviderUrl === "string" ? record.customProviderUrl : null
495
- },
496
- options?.now ?? Date.now()
497
- );
498
- const verifiedSharedKey = typeof record?.verifiedAgentKey === "string" && record.verifiedAgentKey ? record.verifiedAgentKey : void 0;
499
- let agentKey;
500
- if (currentUserId) {
501
- if (isOwned) {
502
- agentKey = ownedKey ?? (id ? ownedAgentKey(currentUserId, id) : void 0);
503
- } else if (publicKey) {
504
- agentKey = publicKey;
505
- } else {
506
- agentKey = verifiedSharedKey;
507
- }
508
- }
509
- const rawCredRef = (typeof record?.apiKeyRef === "string" && record.apiKeyRef ? record.apiKeyRef : void 0) ?? (typeof record?.credentialRef === "string" && record.credentialRef ? record.credentialRef : void 0);
510
- const credInfo = deriveCredentialGroup(record?.credentialGroup ?? rawCredRef);
511
- const credentialGroup = record?.credentialGroup ?? credInfo?.credentialGroup;
512
- const credentialKind = record?.credentialKind ?? credInfo?.credentialKind;
513
- const rawQuota = record?.quota;
514
- const snapshot = rawQuota && Array.isArray(rawQuota.windows) && Number.isFinite(rawQuota.observedAt) ? rawQuota : void 0;
515
- const ref = typeof rawCredRef === "string" ? rawCredRef.trim().toLowerCase() : void 0;
516
- const group = typeof credentialGroup === "string" ? credentialGroup.trim().toLowerCase() : void 0;
517
- const oauthChannel = isOAuthApiKeyRef(ref) ? ref : isOAuthApiKeyRef(group) ? group : void 0;
518
- const providerId = provider?.trim().toLowerCase();
519
- const channel = oauthChannel ?? (providerId === "google-antigravity" ? "antigravity" : providerId);
520
- const platformChannel = apiSource === "platform" || providerId === "nolo" && !oauthChannel && apiSource !== "custom";
521
- const windows = snapshot?.windows.filter((window) => {
522
- const origin = subscriptionQuotaChannel(window?.source);
523
- return !origin || !platformChannel && (!channel || origin === channel);
524
- });
525
- const foreignOnly = Boolean(snapshot?.windows.length && windows?.length === 0);
526
- const quota = snapshot && windows && !foreignOnly ? { ...snapshot, windows } : void 0;
527
- const observedAt = record?.quotaExhaustion?.observedAt;
528
- const quotaExhaustion = !foreignOnly && typeof observedAt === "number" && Number.isFinite(observedAt) ? { observedAt } : void 0;
529
- const availability = resolveAgentAvailability(
530
- { nextAvailableAt, quota, quotaExhaustion, model },
531
- options?.now ?? Date.now()
532
- );
533
- return {
534
- id,
535
- ...agentKey !== void 0 ? { agentKey } : {},
536
- ...publicKey !== void 0 ? { publicKey } : {},
537
- name,
538
- handle,
539
- introduction,
540
- ...roleHint ? { roleHint } : {},
541
- model,
542
- modelTier: resolveModelTier(model),
543
- provider,
544
- apiSource,
545
- cliProvider,
546
- billingSource,
547
- tools,
548
- inputPrice,
549
- outputPrice,
550
- isFavorite: favStatus.isFavorite,
551
- favoritedAt: favStatus.favoritedAt,
552
- isPublic,
553
- // 复用 platformPaidCall.ts 的唯一判据(该文件头明确它是「谁出钱」的真源):
554
- // 自己写 billingSource === "platform_credits" 会与 199 门槛口径分叉——
555
- // 例如 apiSource==="cli" 的本地 CLI Agent 在 resolveBillingSource 里会落到
556
- // platform_credits,但 isPlatformPaidAgentCall 显式短路为「非平台垫付」。
557
- requiresPaidApproval: isPlatformPaidAgentCall({
558
- agentConfig: record ?? void 0,
559
- callerUserId: currentUserId ?? void 0
560
- }),
561
- ...economics ? { economics } : {},
562
- isOwned,
563
- isOAuth,
564
- ...nextAvailableAt !== void 0 ? { nextAvailableAt } : {},
565
- availabilityStatus: availability.status,
566
- availabilityReason: availability.reason,
567
- ...quota !== void 0 ? { quota } : {},
568
- ...quotaExhaustion ? { quotaExhaustion } : {},
569
- ...credentialGroup !== void 0 ? { credentialGroup } : {},
570
- ...credentialKind !== void 0 ? { credentialKind } : {},
571
- // 「未知 ≠ 独立」:无 credentialGroup 时显式 credentialed:false,调用方
572
- // 不得把缺失解读成独立凭证(并发扇出守卫依赖这个区分)。
573
- credentialed: credentialGroup !== void 0,
574
- updatedAt
575
- };
576
- }
577
- function sortSafeAgentSummaries(agents) {
578
- return [...agents].sort(compareAgentSelection);
579
- }
580
- var AGENT_SUMMARY_FIELDS = [
581
- // —— 派发决策必需(短字段,必须排最前)——
582
- // agentKey 是唯一不可推导、必须逐字复制的字段;截断时它首先被保住。
583
- "agentKey",
584
- "name",
585
- "model",
586
- "modelTier",
587
- "billingSource",
588
- // 扣费授权判据:listAgents 默认走 compact 投影,缺了它模型在默认派发
589
- // 流程里读不到「派它之前要先问用户」(2026-11-15 事故成因)。
590
- "requiresPaidApproval",
591
- "availabilityStatus",
592
- "credentialGroup",
593
- "isFavorite",
594
- "isOAuth",
595
- "isOwned",
596
- "isPublic",
597
- // —— 次要身份/来源字段(仍很短)——
598
- "provider",
599
- "apiSource",
600
- "credentialKind",
601
- "credentialed",
602
- // 仅限流中的 agent 才会带(可用 agent 上不存在)。额度/冷却只作参考信息,
603
- // 不参与派发门控:这类 agent 同样在 agents 主列表里(带标注),不做过滤,
604
- // 所以这两个字段只在确实限流时才占字节。
605
- "nextAvailableAt",
606
- "availabilityReason",
607
- // —— 体积大的说明性字段(排在每条记录最后,截断时先牺牲它们)——
608
- // Phase 2A economics 快照(period/multipliers/changesAt 等小对象)。
609
- // 只对 DeepSeek API / BigModel GLM Coding Plan 存在;不含完整 policy/windows。
610
- "economics"
611
- ];
612
- var AGENT_SUMMARY_TRAILING_FIELDS = [
613
- "tools",
614
- // 额度快照(windows 数组,体积最大):只有上游真上报过窗口的 agent 才带。
615
- "quota"
616
- ];
617
- var COMPACT_AGENT_SUMMARY_FIELDS = [
618
- ...AGENT_SUMMARY_FIELDS,
619
- "roleHint",
620
- ...AGENT_SUMMARY_TRAILING_FIELDS
621
- ];
622
- function omitNullishAgentSummaryFields(summary) {
623
- const result = {};
624
- for (const [key, value] of Object.entries(summary)) {
625
- if (value !== null && value !== void 0) {
626
- result[key] = value;
627
- }
628
- }
629
- return result;
630
- }
631
- function finiteOptionalNumber(value) {
632
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
633
- }
634
- function compactQuotaForSummary(quota) {
635
- if (!quota || !Array.isArray(quota.windows)) return void 0;
636
- const observedAt = finiteOptionalNumber(quota.observedAt);
637
- if (observedAt === void 0) return void 0;
638
- const windows = [];
639
- for (const window of quota.windows) {
640
- if (!window || typeof window.scope !== "string" || !window.scope) continue;
641
- const utilization = finiteOptionalNumber(window.utilization);
642
- const remaining = finiteOptionalNumber(window.remaining);
643
- const limit = finiteOptionalNumber(window.limit);
644
- const resetAt = finiteOptionalNumber(window.resetAt);
645
- const unit = typeof window.unit === "string" && window.unit ? window.unit : void 0;
646
- windows.push({
647
- scope: window.scope,
648
- ...utilization !== void 0 ? { utilization } : {},
649
- ...remaining !== void 0 ? { remaining } : {},
650
- ...limit !== void 0 ? { limit } : {},
651
- ...unit !== void 0 ? { unit } : {},
652
- ...resetAt !== void 0 ? { resetAt } : {}
653
- });
654
- }
655
- const rawPlan = quota.plan;
656
- const planName = rawPlan && typeof rawPlan.name === "string" && rawPlan.name ? rawPlan.name : void 0;
657
- const monthlyCreditsUsd = finiteOptionalNumber(rawPlan?.monthlyCreditsUsd);
658
- const plan = planName ? { name: planName, ...monthlyCreditsUsd !== void 0 ? { monthlyCreditsUsd } : {} } : void 0;
659
- return {
660
- observedAt,
661
- windows,
662
- ...plan ? { plan } : {}
663
- };
664
- }
665
- function promoteSharedCredentialGroupQuota(agents, groups) {
666
- if (!agents.length || !groups.length) return { agents, groups };
667
- const groupByName = new Map(groups.map((group) => [group.credentialGroup, group]));
668
- const restored = agents.map((agent) => {
669
- const ref = agent.quotaRef;
670
- if (typeof ref !== "string") return agent;
671
- const fromGroup = groupByName.get(ref)?.quota;
672
- const rest = { ...agent };
673
- delete rest.quotaRef;
674
- if (fromGroup) rest.quota = fromGroup;
675
- return rest;
676
- });
677
- const bareGroups = groups.map(({ quota: _dropped, ...rest }) => rest);
678
- const slimQuota = restored.map((agent) => compactQuotaForSummary(agent.quota));
679
- const byGroup = /* @__PURE__ */ new Map();
680
- slimQuota.forEach((quota, index) => {
681
- const agent = restored[index];
682
- const groupKey = agent.credentialGroup;
683
- if (!quota || quota.windows.length === 0) return;
684
- if (agent.isOwned !== true) return;
685
- if (typeof groupKey !== "string" || !groupKey) return;
686
- if (!groupByName.has(groupKey)) return;
687
- const clusters = byGroup.get(groupKey) ?? /* @__PURE__ */ new Map();
688
- const signature = JSON.stringify([
689
- quota.windows,
690
- quota.plan ?? null,
691
- quota.observedAt ?? null
692
- ]);
693
- const indices = clusters.get(signature) ?? [];
694
- indices.push(index);
695
- clusters.set(signature, indices);
696
- byGroup.set(groupKey, clusters);
697
- });
698
- const promoted = /* @__PURE__ */ new Map();
699
- const refFor = /* @__PURE__ */ new Map();
700
- for (const [groupKey, clusters] of byGroup) {
701
- let best;
702
- for (const indices of clusters.values()) {
703
- if (indices.length < 2) continue;
704
- if (!best || indices.length > best.length) best = indices;
705
- }
706
- if (!best) continue;
707
- const observedAt = slimQuota[best[0]].observedAt;
708
- const { plan } = slimQuota[best[0]];
709
- promoted.set(groupKey, {
710
- observedAt,
711
- windows: slimQuota[best[0]].windows,
712
- ...plan ? { plan } : {}
713
- });
714
- for (const index of best) refFor.set(index, groupKey);
715
- }
716
- const nextAgents = restored.map((agent, index) => {
717
- const ref = refFor.get(index);
718
- if (!ref) return agent;
719
- const rest = { ...agent };
720
- delete rest.quota;
721
- rest.quotaRef = ref;
722
- return rest;
723
- });
724
- const nextGroups = bareGroups.map((group) => {
725
- const quota = promoted.get(group.credentialGroup);
726
- return quota ? { ...group, quota } : group;
727
- });
728
- return { agents: nextAgents, groups: nextGroups };
729
- }
730
- function toCompactAgentSummary(summary) {
731
- const compact = {};
732
- for (const field of COMPACT_AGENT_SUMMARY_FIELDS) {
733
- const value = summary[field];
734
- if (value !== null && value !== void 0) {
735
- compact[field] = value;
736
- }
737
- }
738
- return compact;
739
- }
740
- var ULTRA_COMPACT_AGENT_SUMMARY_FIELDS = [
741
- ...AGENT_SUMMARY_FIELDS,
742
- ...AGENT_SUMMARY_TRAILING_FIELDS
743
- ];
744
- function toUltraCompactAgentSummary(summary) {
745
- const compact = {};
746
- for (const field of ULTRA_COMPACT_AGENT_SUMMARY_FIELDS) {
747
- const value = summary[field];
748
- if (value !== null && value !== void 0) {
749
- compact[field] = value;
750
- }
751
- }
752
- if (compact.quota !== void 0) {
753
- const quota = compactQuotaForSummary(compact.quota);
754
- if (quota) {
755
- compact.quota = quota;
756
- } else {
757
- delete compact.quota;
758
- }
759
- }
760
- return compact;
761
- }
762
-
763
- // packages/ai/agent/platformPaidCall.ts
764
- var asTrimmed = (value) => typeof value === "string" ? value.trim() : "";
765
- var hasOAuthCredentialShape = (agentConfig) => isOAuthApiKeyRef(agentConfig?.apiKeyRef);
766
- function isPlatformPaidAgentCall(probe) {
767
- const agentConfig = probe?.agentConfig ?? {};
768
- const authKind = asTrimmed(probe?.authKind);
769
- if (authKind) return authKind === "platform-key";
770
- if (asTrimmed(agentConfig.apiSource) === "cli") return false;
771
- return resolveBillingSource({
772
- local: agentConfig.local,
773
- isLocal: agentConfig.isLocal,
774
- cliProvider: agentConfig.cliProvider,
775
- apiSource: agentConfig.apiSource,
776
- provider: agentConfig.provider,
777
- billingSource: agentConfig.billingSource,
778
- // 形态证明而非记录自声明(见文件头):自声明 isOAuth 不足以证明 OAuth 通道归属。
779
- isOAuth: hasOAuthCredentialShape(agentConfig),
780
- apiKeyRef: agentConfig.apiKeyRef,
781
- customProviderUrl: agentConfig.customProviderUrl,
782
- isOwned: isOwnedAgentRecord(
783
- agentConfig,
784
- asTrimmed(probe?.callerUserId) || void 0
785
- ),
786
- userId: agentConfig.userId,
787
- ownerId: agentConfig.ownerId
788
- }) === "platform_credits";
789
- }
790
-
791
- // packages/ai/agent/speedSampleCache.ts
792
- var SPEED_SAMPLE_DISK_CACHE_TTL_MS = 10 * 6e4;
793
- var SPEED_SAMPLE_SCAN_BUDGET_MS = 2500;
794
- var SPEED_SAMPLE_CACHE_VERSION = 4;
795
- var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
796
- var sanitizeSample = (value) => {
797
- if (!value || typeof value !== "object") return null;
798
- const sample = value;
799
- const clean = {};
800
- if (isFiniteNumber(sample.firstOutputMs)) clean.firstOutputMs = sample.firstOutputMs;
801
- if (isFiniteNumber(sample.callDurationMs)) clean.callDurationMs = sample.callDurationMs;
802
- if (isFiniteNumber(sample.output_tokens)) clean.output_tokens = sample.output_tokens;
803
- if (isFiniteNumber(sample.t)) clean.t = sample.t;
804
- return clean.firstOutputMs === void 0 && clean.callDurationMs === void 0 ? null : clean;
805
- };
806
- var SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS = 7 * 24 * 60 * 6e4;
807
- async function parseCacheFile(cachePath, userId) {
808
- try {
809
- const fs = await import("node:fs/promises");
810
- const raw = await fs.readFile(cachePath, "utf8");
811
- const parsed = JSON.parse(raw);
812
- if (!parsed || typeof parsed !== "object") return null;
813
- const version = parsed.version;
814
- if (version !== SPEED_SAMPLE_CACHE_VERSION) {
815
- return null;
816
- }
817
- if (parsed.userId !== userId) return null;
818
- if (!isFiniteNumber(parsed.at)) return null;
819
- const source = parsed.samples;
820
- if (!source || typeof source !== "object") return null;
821
- const samples = /* @__PURE__ */ new Map();
822
- for (const [model, list] of Object.entries(source)) {
823
- if (!model || !Array.isArray(list)) continue;
824
- const cleaned = [];
825
- for (const entry of list) {
826
- const sample = sanitizeSample(entry);
827
- if (sample) cleaned.push(sample);
828
- }
829
- samples.set(model, cleaned);
830
- }
831
- const complete = parsed.complete === true;
832
- const cursor = typeof parsed.cursor === "string" && parsed.cursor.length > 0 ? parsed.cursor : void 0;
833
- return { samples, at: parsed.at, complete, cursor: complete ? void 0 : cursor };
834
- } catch {
835
- return null;
836
- }
837
- }
838
- async function readSpeedSamplesSnapshot(cachePath, options) {
839
- const maxAgeMs = isFiniteNumber(options.maxAgeMs) ? options.maxAgeMs : SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS;
840
- const parsed = await parseCacheFile(cachePath, options.userId);
841
- if (!parsed || !parsed.complete) return null;
842
- const age = options.now - parsed.at;
843
- if (age < 0 || age >= maxAgeMs) return null;
844
- return { samples: parsed.samples, ageMs: age };
845
- }
846
- async function readSpeedSamplesProgress(cachePath, userId) {
847
- const parsed = await parseCacheFile(cachePath, userId);
848
- if (!parsed) return null;
849
- return {
850
- samples: parsed.samples,
851
- at: parsed.at,
852
- complete: parsed.complete,
853
- ...parsed.cursor === void 0 ? {} : { cursor: parsed.cursor }
854
- };
855
- }
856
- function resolveSpeedSamplesProgressPath(cachePath) {
857
- return `${cachePath}.progress`;
858
- }
859
- async function writeSpeedSamplesCache(cachePath, payload) {
860
- try {
861
- const fs = await import("node:fs/promises");
862
- const path = await import("node:path");
863
- await fs.mkdir(path.dirname(cachePath), { recursive: true });
864
- const tmpPath = `${cachePath}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
865
- await fs.writeFile(tmpPath, JSON.stringify(payload), "utf8");
866
- await fs.rename(tmpPath, cachePath);
867
- } catch {
868
- }
869
- }
870
-
871
- // packages/ai/agent/candidateSpeedContext.ts
872
- var OBSERVED_SPEED_WINDOW = 50;
873
- var MIN_OBSERVED_FIRST_OUTPUT_SAMPLES = 5;
874
- var SPEED_SAMPLES_CACHE_TTL_MS = 5 * 6e4;
875
- var SPEED_SAMPLES_CACHE_MAX_ENTRIES = 500;
876
- function normalizeSpeedModelName(raw) {
877
- const name = raw.trim().toLowerCase();
878
- const slash = name.lastIndexOf("/");
879
- return slash === -1 ? name : name.slice(slash + 1);
880
- }
881
- var isFiniteNumber2 = (value) => typeof value === "number" && Number.isFinite(value);
882
- var REASONING_EFFORT_SUFFIXES = ["minimal", "low", "medium", "high", "xhigh"];
883
- var REASONING_EFFORT_SUFFIX_RE = new RegExp(`-(?:${REASONING_EFFORT_SUFFIXES.join("|")})$`);
884
- function stripReasoningEffortSuffix(model) {
885
- const base = model.replace(REASONING_EFFORT_SUFFIX_RE, "");
886
- return base && base !== model ? base : null;
887
- }
888
- function resolveOneBare(model, samplesByModel) {
889
- const observed = resolveObservedSpeed(samplesByModel.get(model) ?? [], {
890
- limit: OBSERVED_SPEED_WINDOW
891
- });
892
- if (observed.firstOutputSampleCount >= MIN_OBSERVED_FIRST_OUTPUT_SAMPLES && observed.medianFirstOutputMs !== void 0) {
893
- return {
894
- source: "observed",
895
- firstOutputMs: observed.medianFirstOutputMs,
896
- ...observed.medianOutputTokensPerSecond !== void 0 ? { outputTps: observed.medianOutputTokensPerSecond } : {},
897
- firstOutputSamples: observed.firstOutputSampleCount,
898
- tpsSamples: observed.throughputSampleCount
899
- };
900
- }
901
- return null;
902
- }
903
- function resolveOne(model, samplesByModel) {
904
- const direct = resolveOneBare(model, samplesByModel);
905
- if (direct) return { model, ...direct };
906
- const base = stripReasoningEffortSuffix(model);
907
- if (!base) return null;
908
- const stripped = resolveOneBare(base, samplesByModel);
909
- return stripped ? { model, ...stripped } : null;
910
- }
911
- function resolveCandidateSpeedFacts(models, samplesByModel) {
912
- const unique = [
913
- ...new Set(
914
- models.filter((model) => typeof model === "string").map(normalizeSpeedModelName).filter(Boolean)
915
- )
916
- ];
917
- return unique.map((model) => resolveOne(model, samplesByModel)).filter((fact) => fact !== null);
918
- }
919
- var formatSeconds = (ms) => `${(ms / 1e3).toFixed(1)}s`;
920
- var formatTps = (tps) => String(Math.round(tps));
921
- var SPEED_CONTEXT_HEADER = "speed (observed=\u672C\u7528\u6237\u5B9E\u6D4B\u8C03\u7528\u4E2D\u4F4D\u6570, firstOutput \u542B\u63A8\u7406\u8F93\u51FA; tps=generation\uFF08\u4E0D\u542B\u7AEF\u5230\u7AEF\u53E3\u5F84\uFF09, tps=n/a \u8868\u793A\u65E0\u53EF\u4FE1\u541E\u5410\u6837\u672C\u3002\u672A\u5217\u51FA\u7684 model \u8868\u793A\u6CA1\u6709\u5B9E\u6D4B\u6837\u672C\uFF0C\u4E0D\u4EE3\u8868\u6162):";
922
- function formatSnapshotAge(ageMs) {
923
- const minutes = Math.floor(ageMs / 6e4);
924
- if (minutes < 1) return "<1min";
925
- if (minutes < 60) return `${minutes}min`;
926
- const hours = Math.floor(minutes / 60);
927
- if (hours < 24) return `${hours}h`;
928
- return `${Math.floor(hours / 24)}d`;
929
- }
930
- function formatCandidateSpeedFacts(facts, options = {}) {
931
- if (facts.length === 0) return null;
932
- const lines = facts.map((fact) => {
933
- const tps = fact.outputTps !== void 0 ? formatTps(fact.outputTps) : "n/a";
934
- return ` ${fact.model}: firstOutput=${formatSeconds(fact.firstOutputMs ?? 0)} tps=${tps} [observed n=${fact.firstOutputSamples ?? 0} tpsN=${fact.tpsSamples ?? 0}]`;
935
- });
936
- const age = options.snapshotAgeMs;
937
- const note = typeof age === "number" && age > 0 ? ` (snapshot=${formatSnapshotAge(age)}\u524D\u91C7\u96C6\u7684\u5B8C\u6574\u7A97\u53E3, \u975E\u672C\u6B21\u5B9E\u65F6\u626B\u63CF)` : "";
938
- return `${SPEED_CONTEXT_HEADER}${note}
939
- ${lines.join("\n")}`;
940
- }
941
- function buildCandidateSpeedContext(models, samplesByModel, options = {}) {
942
- return formatCandidateSpeedFacts(resolveCandidateSpeedFacts(models, samplesByModel), options);
943
- }
944
- var SPEED_SAMPLE_PAGE_SIZE = 2e3;
945
- var DISPATCH_ENTRY_PATH = "agent-run";
946
- var eventTime = (value) => {
947
- if (isFiniteNumber2(value.timestamp)) return value.timestamp;
948
- if (isFiniteNumber2(value.createdAt)) return value.createdAt;
949
- return 0;
950
- };
951
- function collectSample(collected, value) {
952
- if (typeof value.model !== "string") return;
953
- if (!isFiniteNumber2(value.firstOutputMs) && !isFiniteNumber2(value.callDurationMs)) return;
954
- const model = normalizeSpeedModelName(value.model);
955
- if (!model) return;
956
- const list = collected.get(model) ?? [];
957
- list.push({
958
- t: eventTime(value),
959
- firstOutputMs: value.firstOutputMs,
960
- callDurationMs: value.callDurationMs,
961
- output_tokens: value.output_tokens
962
- });
963
- collected.set(model, list);
964
- }
965
- function finalizeSamples(collected, keepTime = false) {
966
- const result = /* @__PURE__ */ new Map();
967
- for (const [model, list] of collected) {
968
- list.sort((a, b) => b.t - a.t);
969
- const window = list.slice(0, OBSERVED_SPEED_WINDOW);
970
- result.set(
971
- model,
972
- keepTime ? window : window.map(({ t: _t, ...sample }) => sample)
973
- );
974
- }
975
- return result;
976
- }
977
- async function collectRecentSpeedSamples(db, userId, options = {}) {
978
- const pageSize = isFiniteNumber2(options.pageSize) && options.pageSize > 0 ? Math.floor(options.pageSize) : SPEED_SAMPLE_PAGE_SIZE;
979
- const budgetMs = isFiniteNumber2(options.budgetMs) ? options.budgetMs : Number.POSITIVE_INFINITY;
980
- const { start, end } = createTokenKey.rangeOfUser(userId);
981
- const failedPrefix = createKey("token", userId, "failed-call", "");
982
- const dispatchRunCache = /* @__PURE__ */ new Map();
983
- const isDispatchSampleRecord = async (record, resolver, cache) => {
984
- if (record.entry_path !== DISPATCH_ENTRY_PATH && record.entry_path !== "cli-local") return false;
985
- const runId = typeof record.dialogId === "string" ? record.dialogId.trim() : "";
986
- if (!runId) return false;
987
- const cacheKey = `${record.entry_path}:${runId}`;
988
- const cached = cache.get(cacheKey);
989
- if (cached !== void 0) return cached;
990
- let dispatch = false;
991
- if (resolver) {
992
- try {
993
- dispatch = await resolver(runId, record.entry_path) === true;
994
- } catch {
995
- dispatch = false;
996
- }
997
- }
998
- cache.set(cacheKey, dispatch);
999
- return dispatch;
1000
- };
1001
- const collected = /* @__PURE__ */ new Map();
1002
- const startedAt = Date.now();
1003
- let lastKey = options.startAfter;
1004
- let budgetExhausted = false;
1005
- let scanned = 0;
1006
- while (true) {
1007
- if (Date.now() - startedAt >= budgetMs) {
1008
- budgetExhausted = true;
1009
- break;
1010
- }
1011
- const pageOptions = {
1012
- ...lastKey === void 0 ? { gte: start } : { gt: lastKey },
1013
- lte: end,
1014
- limit: pageSize
1015
- };
1016
- let accepted = 0;
1017
- let newestKey = lastKey;
1018
- for await (const [key, raw] of db.iterator(pageOptions)) {
1019
- if (typeof key !== "string") continue;
1020
- if (lastKey !== void 0 && key <= lastKey) continue;
1021
- accepted += 1;
1022
- scanned += 1;
1023
- newestKey = key;
1024
- if (key.startsWith(failedPrefix)) continue;
1025
- if (!raw || typeof raw !== "object") continue;
1026
- const record = raw;
1027
- const resolver = options.isDispatchRun ?? db.isDispatchRun;
1028
- if (!await isDispatchSampleRecord(
1029
- record,
1030
- resolver ? (runId, entryPath) => resolver.call(db, runId, entryPath) : void 0,
1031
- dispatchRunCache
1032
- ))
1033
- continue;
1034
- collectSample(collected, record);
1035
- }
1036
- if (accepted === 0 || accepted < pageSize) break;
1037
- lastKey = newestKey;
1038
- }
1039
- return {
1040
- samples: finalizeSamples(collected, options.keepTime === true),
1041
- budgetExhausted,
1042
- scanned,
1043
- ...budgetExhausted && lastKey !== void 0 ? { nextCursor: lastKey } : {}
1044
- };
1045
- }
1046
- function mergeNewestSamples(into, from) {
1047
- for (const [model, list] of from) {
1048
- const merged = [...into.get(model) ?? [], ...list];
1049
- merged.sort(
1050
- (a, b) => (b.t ?? 0) - (a.t ?? 0)
1051
- );
1052
- into.set(model, merged.slice(0, OBSERVED_SPEED_WINDOW));
1053
- }
1054
- }
1055
- async function loadSpeedSamplesWithDiskCache(db, userId, now, cache) {
1056
- try {
1057
- const ttlMs = isFiniteNumber2(cache.ttlMs) ? cache.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
1058
- const snapshot = await readSpeedSamplesSnapshot(cache.cachePath, { userId, now });
1059
- if (snapshot && snapshot.ageMs < ttlMs) return { samples: snapshot.samples };
1060
- const progressPath = resolveSpeedSamplesProgressPath(cache.cachePath);
1061
- const progress = await readSpeedSamplesProgress(progressPath, userId);
1062
- const resumable = progress && !progress.complete && progress.cursor ? progress : void 0;
1063
- const collected = new Map(resumable?.samples ?? []);
1064
- let step;
1065
- try {
1066
- step = await collectRecentSpeedSamples(db, userId, {
1067
- pageSize: cache.pageSize,
1068
- budgetMs: isFiniteNumber2(cache.budgetMs) ? cache.budgetMs : SPEED_SAMPLE_SCAN_BUDGET_MS,
1069
- keepTime: true,
1070
- ...resumable?.cursor ? { startAfter: resumable.cursor } : {}
1071
- });
1072
- } catch {
1073
- return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
1074
- }
1075
- if (!resumable && step.scanned === 0 && !step.budgetExhausted) {
1076
- return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
1077
- }
1078
- mergeNewestSamples(collected, step.samples);
1079
- if (!step.budgetExhausted) {
1080
- await writeSpeedSamplesCache(cache.cachePath, {
1081
- version: SPEED_SAMPLE_CACHE_VERSION,
1082
- userId,
1083
- at: now,
1084
- complete: true,
1085
- samples: Object.fromEntries(collected)
1086
- });
1087
- await writeSpeedSamplesCache(progressPath, {
1088
- version: SPEED_SAMPLE_CACHE_VERSION,
1089
- userId,
1090
- at: now,
1091
- complete: true,
1092
- samples: {}
1093
- });
1094
- return { samples: collected };
1095
- }
1096
- await writeSpeedSamplesCache(progressPath, {
1097
- version: SPEED_SAMPLE_CACHE_VERSION,
1098
- userId,
1099
- // Progress keeps the cycle's collection start so a later stale label stays honest.
1100
- at: resumable?.at ?? now,
1101
- complete: false,
1102
- samples: Object.fromEntries(collected),
1103
- ...step.nextCursor ? { cursor: step.nextCursor } : {}
1104
- });
1105
- return snapshot ? { samples: snapshot.samples, snapshotAgeMs: snapshot.ageMs } : { samples: /* @__PURE__ */ new Map() };
1106
- } catch {
1107
- return { samples: /* @__PURE__ */ new Map() };
1108
- }
1109
- }
1110
- var samplesCache = /* @__PURE__ */ new Map();
1111
- function writeSamplesCache(userId, now, samples) {
1112
- for (const [key, entry] of samplesCache) {
1113
- if (now - entry.at >= SPEED_SAMPLES_CACHE_TTL_MS) samplesCache.delete(key);
1114
- }
1115
- samplesCache.delete(userId);
1116
- samplesCache.set(userId, { at: now, samples });
1117
- while (samplesCache.size > SPEED_SAMPLES_CACHE_MAX_ENTRIES) {
1118
- const oldest = samplesCache.keys().next().value;
1119
- if (oldest === void 0) break;
1120
- samplesCache.delete(oldest);
1121
- }
1122
- }
1123
- var SPEED_SAMPLE_REFRESH_BUDGET_MS = 6e4;
1124
- var snapshotRefreshes = /* @__PURE__ */ new Map();
1125
- function startSpeedSnapshotRefresh(db, userId, now = Date.now()) {
1126
- const inFlight = snapshotRefreshes.get(userId);
1127
- if (inFlight) return inFlight;
1128
- const job = (async () => {
1129
- try {
1130
- const { samples, budgetExhausted } = await collectRecentSpeedSamples(db, userId, {
1131
- budgetMs: SPEED_SAMPLE_REFRESH_BUDGET_MS
1132
- });
1133
- if (!budgetExhausted) writeSamplesCache(userId, now, samples);
1134
- } catch {
1135
- }
1136
- })().finally(() => {
1137
- snapshotRefreshes.delete(userId);
1138
- });
1139
- snapshotRefreshes.set(userId, job);
1140
- return job;
1141
- }
1142
- async function loadCachedSpeedSamples(db, userId, now) {
1143
- const hit = samplesCache.get(userId);
1144
- if (hit) {
1145
- const age = now - hit.at;
1146
- if (age >= 0 && age < SPEED_SAMPLE_STALE_SNAPSHOT_MAX_MS) {
1147
- if (age >= SPEED_SAMPLES_CACHE_TTL_MS) void startSpeedSnapshotRefresh(db, userId);
1148
- return age >= SPEED_SAMPLES_CACHE_TTL_MS ? { samples: hit.samples, snapshotAgeMs: age } : { samples: hit.samples };
1149
- }
1150
- }
1151
- void startSpeedSnapshotRefresh(db, userId);
1152
- return { samples: /* @__PURE__ */ new Map() };
1153
- }
1154
- async function injectSpeedContextIntoListAgentsResult(result, options = {}) {
1155
- try {
1156
- let parsed;
1157
- try {
1158
- parsed = JSON.parse(result);
1159
- } catch {
1160
- return result;
1161
- }
1162
- if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.agents)) return result;
1163
- const models = parsed.agents.map((agent) => agent?.model).filter((model) => typeof model === "string");
1164
- if (models.length === 0 && !options.compactPage) return result;
1165
- const now = options.now ?? Date.now();
1166
- let samples = /* @__PURE__ */ new Map();
1167
- let snapshotAgeMs;
1168
- const userId = typeof options.userId === "string" ? options.userId.trim() : "";
1169
- if (options.db && userId) {
1170
- try {
1171
- const loaded = options.diskCache ? await loadSpeedSamplesWithDiskCache(options.db, userId, now, options.diskCache) : await loadCachedSpeedSamples(options.db, userId, now);
1172
- samples = loaded.samples;
1173
- snapshotAgeMs = loaded.snapshotAgeMs;
1174
- } catch {
1175
- samples = /* @__PURE__ */ new Map();
1176
- }
1177
- }
1178
- if (options.compactPage) {
1179
- return await serializeCompactAgentPage(parsed, samples, snapshotAgeMs, options);
1180
- }
1181
- const speedContext = buildCandidateSpeedContext(models, samples, { snapshotAgeMs });
1182
- return speedContext ? JSON.stringify({ ...parsed, speedContext }) : result;
1183
- } catch {
1184
- return options.compactPage ? JSON.stringify({ success: false, error: "LIST_AGENTS_PAGE_SERIALIZATION_FAILED" }) : result;
1185
- }
1186
- }
1187
- async function serializeCompactAgentPage(parsed, samples, snapshotAgeMs, options) {
1188
- const maxChars = LIST_AGENTS_PAGE_BUDGET;
1189
- const maxBytes = LIST_AGENTS_PAGE_BUDGET;
1190
- const fits = (page) => page.length <= maxChars && new TextEncoder().encode(page).length <= maxBytes;
1191
- const offset = typeof parsed.offset === "number" ? parsed.offset : 0;
1192
- const candidates = parsed.agents;
1193
- const availableCount = typeof parsed.availableCount === "number" ? parsed.availableCount : parsed.total;
1194
- const groups = Array.isArray(parsed.credentialGroups) ? parsed.credentialGroups : [];
1195
- if (!isEmptyListAgentsFragmentRequest(options)) {
1196
- const fragmentOffset = Number(options.fragmentOffset);
1197
- const agentKey2 = candidates[0]?.agentKey;
1198
- if (typeof options.fragmentOffset !== "number" && (typeof options.fragmentOffset !== "string" || !/^\d+$/.test(options.fragmentOffset)) || !Number.isSafeInteger(fragmentOffset) || fragmentOffset < 0 || typeof agentKey2 !== "string" || agentKey2 !== options.fragmentAgentKey) {
1199
- return JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_INVALID", offset });
1200
- }
1201
- const agent = candidates[0];
1202
- const speedContext = buildCandidateSpeedContext(typeof agent.model === "string" ? [agent.model] : [], samples, { snapshotAgeMs });
1203
- const singleScoped = promoteSharedCredentialGroupQuota(
1204
- [agent],
1205
- groups.filter((group) => group.credentialGroup === agent.credentialGroup)
1206
- );
1207
- const payload = { agent: singleScoped.agents[0], credentialGroups: singleScoped.groups };
1208
- let keyCollision = false;
1209
- const cleanText = (value) => scrubSecrets(sanitizeToolOutputText(value)).cleaned;
1210
- const sanitize = (value) => {
1211
- if (typeof value === "string") return cleanText(value);
1212
- if (Array.isArray(value)) return value.map(sanitize);
1213
- if (value && typeof value === "object") {
1214
- const entries = [];
1215
- const keys = /* @__PURE__ */ new Set();
1216
- for (const [key, item] of Object.entries(value)) {
1217
- const cleanedKey = cleanText(key);
1218
- if (keys.has(cleanedKey)) keyCollision = true;
1219
- keys.add(cleanedKey);
1220
- entries.push([cleanedKey, sanitize(item)]);
1221
- }
1222
- return Object.fromEntries(entries);
1223
- }
1224
- return value;
1225
- };
1226
- const safePayload = sanitize(payload);
1227
- if (keyCollision) return JSON.stringify({ success: false, error: "LIST_AGENTS_SANITIZED_KEY_COLLISION", offset });
1228
- const serialized = JSON.stringify(safePayload);
1229
- const bytes = new TextEncoder().encode(serialized);
1230
- const hash = await globalThis.crypto.subtle.digest("SHA-256", bytes);
1231
- const digest = Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join("");
1232
- if (fragmentOffset > 0 && !options.fragmentDigest || options.fragmentDigest && options.fragmentDigest !== digest) {
1233
- return JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_CHANGED", offset });
1234
- }
1235
- if (fragmentOffset >= serialized.length) return JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_INVALID", offset });
1236
- if (fragmentOffset > 0 && /[\uDC00-\uDFFF]/.test(serialized[fragmentOffset]) && /[\uD800-\uDBFF]/.test(serialized[fragmentOffset - 1])) return JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_INVALID", offset });
1237
- let end = Math.min(serialized.length, fragmentOffset + 3e3);
1238
- if (end < serialized.length && /[\uD800-\uDBFF]/.test(serialized[end - 1]) && /[\uDC00-\uDFFF]/.test(serialized[end])) end--;
1239
- const fragment = serialized.slice(fragmentOffset, end);
1240
- const result = JSON.stringify({ success: true, agentKey: agentKey2, offset, digest, fragment, fragmentOffset, nextFragmentOffset: end, hasMoreFragments: end < serialized.length, nextOffset: offset + 1, ...options.targetedRecheck ? { poolComplete: false } : {}, ...speedContext ? { speedContext: cleanText(speedContext) } : {} });
1241
- return fits(result) ? result : JSON.stringify({ success: false, error: "LIST_AGENTS_FRAGMENT_METADATA_TOO_LARGE", offset });
1242
- }
1243
- const makePage = (count) => {
1244
- const scoped = candidates.slice(0, count);
1245
- const groupKeys = new Set(scoped.map((agent) => agent.credentialGroup).filter(Boolean));
1246
- const promoted = promoteSharedCredentialGroupQuota(
1247
- scoped,
1248
- groups.filter((group) => groupKeys.has(group.credentialGroup))
1249
- );
1250
- const agents = promoted.agents;
1251
- const speedContext = buildCandidateSpeedContext(agents.map((agent) => agent.model).filter((model) => typeof model === "string"), samples, { snapshotAgeMs });
1252
- const nextOffset = offset + count;
1253
- const hasMore = nextOffset < availableCount;
1254
- return JSON.stringify({
1255
- ...parsed,
1256
- offset,
1257
- agents,
1258
- credentialGroups: promoted.groups,
1259
- hasMore,
1260
- ...hasMore ? { nextOffset } : {},
1261
- ...speedContext ? { speedContext } : {}
1262
- });
1263
- };
1264
- if (!candidates.length) {
1265
- const empty = makePage(0);
1266
- if (fits(empty)) return empty;
1267
- } else {
1268
- let best;
1269
- for (let count = 1; count <= candidates.length; count++) {
1270
- const page = makePage(count);
1271
- if (!fits(page)) break;
1272
- best = page;
1273
- }
1274
- if (best) return best;
1275
- }
1276
- const agentKey = typeof candidates[0]?.agentKey === "string" ? candidates[0].agentKey : void 0;
1277
- const error = {
1278
- success: false,
1279
- error: candidates.length ? "LIST_AGENTS_CANDIDATE_TOO_LARGE" : "LIST_AGENTS_PAGE_METADATA_TOO_LARGE",
1280
- offset,
1281
- ...agentKey ? { agentKey, recovery: {
1282
- tool: "listAgents",
1283
- arguments: { compact: true, offset, fragmentOffset: 0, fragmentAgentKey: agentKey },
1284
- note: "Repeat with the same filters and returned digest and nextFragmentOffset; concatenate fragments and parse JSON before continuing at nextOffset."
1285
- } } : {},
1286
- ...candidates.length ? { nextOffset: offset + 1, truncated: parsed.truncated === true, poolComplete: parsed.planningRecommendation?.poolComplete === true, hasMore: offset + 1 < availableCount } : {}
1287
- };
1288
- const encoded = JSON.stringify(error);
1289
- return fits(encoded) ? encoded : JSON.stringify({ success: false, error: "LIST_AGENTS_RECOVERY_ID_TOO_LARGE", offset });
1290
- }
1291
-
1292
- // packages/ai/agent/defaultReasoningEffort.ts
1293
- var defaults = {
1294
- "gpt-6.2-sol": "medium",
1295
- "gpt-6.2-astra": "high",
1296
- "gpt-6.1-sol": "medium",
1297
- "gpt-6.1-terra": "medium",
1298
- "gpt-6-luna": "medium",
1299
- "gpt-6-astra": "high",
1300
- "claude-opus-5-5": "medium",
1301
- "claude-sonnet-5-5": "high",
1302
- "deepseek-flash": "high",
1303
- "deepseek-v4-flash": "high",
1304
- "deepseek-v4.1-flash": "high"
1305
- };
1306
- var deepseekChannels = /* @__PURE__ */ new Set(["opendesign", "ollama-cloud", "lithosai"]);
1307
- var providers = /* @__PURE__ */ new Set(["nolo", "openai", "openrouter", "anthropic", "deepseek", "commandcode", "opencode-go", "stepfun"]);
1308
- function resolveDefaultReasoningEffort(input) {
1309
- const provider = (input.provider ?? "").toLowerCase();
1310
- const model = (input.model ?? "").toLowerCase().split("/").pop() ?? "";
1311
- const isDeepseekFlash = ["deepseek-flash", "deepseek-v4-flash", "deepseek-v4.1-flash"].includes(model);
1312
- const effort = providers.has(provider) || deepseekChannels.has(provider) && isDeepseekFlash ? defaults[model] : void 0;
1313
- if (!effort) return input.fallback;
1314
- if (provider === "nolo" && model.startsWith("claude-") && input.model?.startsWith("anthropic/")) return effort;
1315
- if (provider === "anthropic" && model.startsWith("claude-")) return effort;
1316
- return resolveModelReasoningCapability(provider, input.model).efforts.includes(effort) ? effort : input.fallback;
1317
- }
1318
- function confirmedReasoningEfforts(provider, model) {
1319
- const capability = resolveModelReasoningCapability(provider, model);
1320
- if (capability.source === "provider-fallback") return void 0;
1321
- if (capability.efforts.length === 0) return void 0;
1322
- return capability.efforts;
1323
- }
1324
- var DISPATCH_EFFORT_PREFERENCES = {
1325
- easy: ["low", "minimal", "medium"],
1326
- normal: ["medium", "low", "high"],
1327
- complex: ["high", "medium"],
1328
- extreme: ["xhigh", "max", "high"]
1329
- };
1330
- var DISPATCH_DIFFICULTIES = /* @__PURE__ */ new Set(["easy", "normal", "complex", "extreme"]);
1331
- function normalizeDifficulty(difficulty) {
1332
- const normalized = (difficulty ?? "").trim().toLowerCase();
1333
- return DISPATCH_DIFFICULTIES.has(normalized) ? normalized : "normal";
1334
- }
1335
- function asValidAgentEffort(raw) {
1336
- const normalized = (raw ?? "").trim().toLowerCase();
1337
- return REASONING_EFFORT_OPTIONS.includes(normalized) ? normalized : void 0;
1338
- }
1339
- function hasReasoningEffortSuffix(model) {
1340
- const normalized = (model ?? "").trim().toLowerCase().split("/").pop() ?? "";
1341
- return REASONING_EFFORT_SUFFIXES.some((suffix) => normalized.endsWith(`-${suffix}`));
1342
- }
1343
- function resolveDispatchReasoningEffort(input) {
1344
- if (asValidAgentEffort(input.agentReasoningEffort)) return void 0;
1345
- if (hasReasoningEffortSuffix(input.model)) return void 0;
1346
- if (!(input.provider ?? "").trim() || !(input.model ?? "").trim()) return void 0;
1347
- const efforts = confirmedReasoningEfforts(input.provider, input.model);
1348
- if (!efforts) return void 0;
1349
- const preferences = DISPATCH_EFFORT_PREFERENCES[normalizeDifficulty(input.difficulty)];
1350
- return preferences.find((effort) => efforts.includes(effort));
1351
- }
1352
- function resolveEffectiveReasoningEffortOverride(input) {
1353
- const override = asValidAgentEffort(input.override);
1354
- if (!override) return void 0;
1355
- if (asValidAgentEffort(input.recordReasoningEffort)) return void 0;
1356
- if (hasReasoningEffortSuffix(input.model)) return void 0;
1357
- if (!(input.provider ?? "").trim() || !(input.model ?? "").trim()) return void 0;
1358
- const efforts = confirmedReasoningEfforts(input.provider, input.model);
1359
- return efforts?.includes(override) ? override : void 0;
1360
- }
1361
- function withReasoningEffortOverride(config, effort) {
1362
- if (!effort) return config;
1363
- return {
1364
- ...config,
1365
- reasoning_effort: effort,
1366
- ...config.rawRecord ? { rawRecord: { ...config.rawRecord, reasoning_effort: effort } } : {}
1367
- };
1368
- }
1369
-
1370
- export {
1371
- isGptProModel,
1372
- shouldBlockForGptPro,
1373
- isPlatformPaidAgentCall,
1374
- deriveCredentialGroup,
1375
- deriveCustomProviderCredentialGroup,
1376
- summarizeCredentialGroups,
1377
- toSafeAgentSummary,
1378
- sortSafeAgentSummaries,
1379
- omitNullishAgentSummaryFields,
1380
- promoteSharedCredentialGroupQuota,
1381
- toCompactAgentSummary,
1382
- toUltraCompactAgentSummary,
1383
- injectSpeedContextIntoListAgentsResult,
1384
- resolveDefaultReasoningEffort,
1385
- resolveDispatchReasoningEffort,
1386
- resolveEffectiveReasoningEffortOverride,
1387
- withReasoningEffortOverride
1388
- };