nolo-cli 0.149.0-alpha.1 → 0.151.0-alpha.3

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 (258) hide show
  1. package/{_executeModel-OW3H7ICR.js → _executeModel-T7ANHTUW.js} +134 -91
  2. package/accountResolver-7RYB4D2P.js +300 -0
  3. package/action-SXJD5N5R.js +23 -0
  4. package/{addContentAction-B2DRF7P6.js → addContentAction-ZV774PHH.js} +20 -14
  5. package/{addDialogAgentAction-2P2FLTLD.js → addDialogAgentAction-A6SMKAGH.js} +26 -22
  6. package/{agentDeleteCommand-7IDWF6E3.js → agentDeleteCommand-4L5KCKFY.js} +181 -93
  7. package/{agentEmailCommands-A6XBQZBN.js → agentEmailCommands-2IMMIRO2.js} +132 -112
  8. package/{agentGrantCommands-M3XFO6EN.js → agentGrantCommands-HOJ3JBBQ.js} +3 -3
  9. package/agentListCommands-TWFLUYIZ.js +802 -0
  10. package/{agentMachineCommands-DQPUIMAC.js → agentMachineCommands-KIWXWT6L.js} +58 -62
  11. package/{agentProviderCommands-YK2BIIXZ.js → agentProviderCommands-HL6MBLCL.js} +149 -2
  12. package/{agentPullCommand-HF4A42D4.js → agentPullCommand-FA43RBRU.js} +7 -7
  13. package/agentRecordCommands-727NPCRW.js +154 -0
  14. package/agentRunCommand-JASIG3FZ.js +183 -0
  15. package/{agentRunControl-2SKCR4SB.js → agentRunControl-IFM7IGMG.js} +10 -2
  16. package/{agentRuntimeLocal-AK2QVJHY.js → agentRuntimeLocal-KKSQJMTE.js} +47 -50
  17. package/{agentSlice-O4RUQUMT.js → agentSlice-SLV57QGU.js} +23 -16
  18. package/{appDeleteCommands-N3XEVVYC.js → appDeleteCommands-4PL4KYRN.js} +58 -59
  19. package/{appDeployCommands-AWFIXYVW.js → appDeployCommands-EEEXCEB6.js} +67 -63
  20. package/{appDeployStatusCommands-CZRON2FO.js → appDeployStatusCommands-35ZX7T66.js} +56 -56
  21. package/{appGetCommands-XQIUY4TD.js → appGetCommands-WFCHXJWF.js} +56 -56
  22. package/{appListCommands-NNG4H36Y.js → appListCommands-XY2U6DPF.js} +57 -59
  23. package/{authCommand-UBJ4EWYZ.js → authCommand-QYN47CQD.js} +371 -68
  24. package/{authCommands-H6WKKCRW.js → authCommands-77CHYBGF.js} +12 -9
  25. package/{builtinSkillRegistry-ZMF6YGNO.js → builtinSkillRegistry-TDQ6JB2E.js} +13 -11
  26. package/{chromeCommands-2N6MEWRU.js → chromeCommands-OBBNJCLS.js} +314 -13
  27. package/chromeOpsCommands-3Z34RKSE.js +472 -0
  28. package/{chunk-ALXHV7NK.js → chunk-2GGXHQIW.js} +43 -4
  29. package/{localRuntimeAuthority-5W6IJRAD.js → chunk-2IXDJNZI.js} +154 -75
  30. package/{chunk-IVZJWTDI.js → chunk-36OMEXXR.js} +89 -21
  31. package/{chunk-H6A6X4EK.js → chunk-3MZAGMYY.js} +16 -0
  32. package/chunk-3PVYUPXK.js +40 -0
  33. package/chunk-3SZA4U64.js +1192 -0
  34. package/{chunk-ID7LNBWR.js → chunk-3T4ZG6AC.js} +1920 -644
  35. package/{chunk-GNMAFAIS.js → chunk-44WXLHFI.js} +1 -1
  36. package/{chunk-AGGIDPCZ.js → chunk-4JH2UMJR.js} +6 -0
  37. package/chunk-4LCOCOR5.js +50 -0
  38. package/chunk-4YRTZIVN.js +871 -0
  39. package/{chunk-N7J63Q6C.js → chunk-56GBUMO5.js} +10 -1
  40. package/{chunk-W7XHHYWM.js → chunk-5BHQICF2.js} +5 -1
  41. package/{chunk-XUWRURDF.js → chunk-5EBLANFT.js} +1 -1
  42. package/{chunk-3AH7LNUB.js → chunk-5EMSBTQ6.js} +33 -14
  43. package/{chunk-YRRASA5Q.js → chunk-5MM7NNO6.js} +113 -52
  44. package/chunk-5MMAK75Q.js +15 -0
  45. package/{chunk-TXH4IWJL.js → chunk-626KHJNX.js} +20 -11
  46. package/{chunk-M5PVFLD4.js → chunk-64K7WX26.js} +90 -21
  47. package/{chunk-AKG5W4LG.js → chunk-6CCFTVBP.js} +76 -221
  48. package/chunk-6MJNEXUU.js +614 -0
  49. package/{chunk-62IL3KQV.js → chunk-6MXDOUMH.js} +15 -3
  50. package/{chunk-QOKAKDPE.js → chunk-6Q7UTJKR.js} +6 -94
  51. package/chunk-6QDYSCPW.js +223 -0
  52. package/{chunk-HYZIYH2H.js → chunk-74RAWNQN.js} +56 -63
  53. package/chunk-7DPNBQSV.js +9 -0
  54. package/{chunk-IAESIMK7.js → chunk-A4MW3YZL.js} +10 -14
  55. package/{chunk-OMRJYNCI.js → chunk-AG7MCDLR.js} +26 -31
  56. package/chunk-AGIM7IMJ.js +147 -0
  57. package/{chunk-7CHC4W22.js → chunk-AIZE5TDM.js} +3 -3
  58. package/chunk-AJ3G7X2K.js +7012 -0
  59. package/{chunk-5GVBDNTO.js → chunk-AU7AXHUL.js} +1 -1
  60. package/{chunk-4H22P2JV.js → chunk-AUIJZACN.js} +2073 -1275
  61. package/{chunk-CIF4X6ZM.js → chunk-AWVFQMOV.js} +25 -3
  62. package/{chunk-YAQJJDC2.js → chunk-BJEZC5RA.js} +214 -51
  63. package/{chunk-RYZINGPM.js → chunk-BPMPOFWP.js} +347 -235
  64. package/{chunk-YUNJN43V.js → chunk-BU2YQBV4.js} +215 -28
  65. package/{chunk-XPRWFQQK.js → chunk-CBHGZRCE.js} +38 -12
  66. package/{chunk-Y3PMXGLH.js → chunk-CHCS6XPJ.js} +365 -144
  67. package/chunk-CHOZJMJS.js +78 -0
  68. package/chunk-CYJWI3NH.js +119 -0
  69. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  70. package/{chunk-3SV7RM24.js → chunk-D2QN6CTI.js} +117 -72
  71. package/{chunk-TZZ2WRBL.js → chunk-DFDXM2Y4.js} +20 -16
  72. package/{chunk-5TEEECZM.js → chunk-E2AKSW7L.js} +10 -7
  73. package/{chunk-RSEEDUMS.js → chunk-EDX5XSJM.js} +2 -2
  74. package/{chunk-QDSINZM3.js → chunk-EUGTFFO6.js} +2 -23
  75. package/{chunk-UNYJU5L6.js → chunk-EYLGAEB4.js} +5 -1
  76. package/{chunk-CU3QB4HW.js → chunk-EYWJT7A2.js} +12 -12
  77. package/{chunk-BNGW5ASC.js → chunk-EZVK3N5L.js} +66 -18
  78. package/{chunk-6FGTMQCL.js → chunk-F32Z66T4.js} +6 -10
  79. package/{chunk-ZOVKKMF6.js → chunk-FY4SDK2E.js} +1 -1
  80. package/chunk-G6OOUQWJ.js +417 -0
  81. package/{chunk-PQWU42UQ.js → chunk-GCKHQECX.js} +6 -6
  82. package/chunk-GKXCHNTE.js +15 -0
  83. package/{chunk-P6GMCCAT.js → chunk-GQV5KHJU.js} +78 -12
  84. package/{chunk-B2XUQXQX.js → chunk-HIQ4GF53.js} +191 -68
  85. package/{chunk-GMZLP5DV.js → chunk-HNUWUO75.js} +30 -19
  86. package/{chunk-UASIEDKM.js → chunk-I2XLRXVX.js} +36 -31
  87. package/{chunk-5UTFL4QJ.js → chunk-I2ZMGXXF.js} +10 -5
  88. package/chunk-I42VC5KR.js +15 -0
  89. package/{chunk-3BXNTXYI.js → chunk-I4SN4NUQ.js} +1199 -56
  90. package/chunk-IA7TRNNR.js +11 -0
  91. package/{chunk-WIWM4FE3.js → chunk-IJERIUXS.js} +55 -748
  92. package/{chunk-BIDGLJQ3.js → chunk-IK2TSJQA.js} +45 -8
  93. package/{chunk-CPUFH46E.js → chunk-ILU2NPWY.js} +10 -10
  94. package/{chunk-SLLGJZDT.js → chunk-ISQL4V7C.js} +4 -4
  95. package/chunk-IT3ZZRJE.js +12 -0
  96. package/{chunk-DY7ANLKG.js → chunk-JKMLSTZK.js} +43 -12
  97. package/{chunk-6TPOEJMQ.js → chunk-JZX2XLKC.js} +64 -23
  98. package/{chunk-27ONFIEY.js → chunk-K2AER7RX.js} +19 -12
  99. package/{chunk-O2OWEFII.js → chunk-KFHQQ3NO.js} +1 -1
  100. package/{chunk-QXGPFY6J.js → chunk-LGN377P3.js} +27 -17
  101. package/{chunk-L36OWPP3.js → chunk-LIQJTQRN.js} +118 -139
  102. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  103. package/{chunk-5J3PYNUP.js → chunk-NYYFIKHI.js} +17 -3
  104. package/{chunk-6O4IK4V2.js → chunk-OFFL4DCR.js} +1 -1
  105. package/{chunk-B6SAMB33.js → chunk-OWYYDMGJ.js} +209 -9
  106. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  107. package/{chunk-CTUQJVQM.js → chunk-P5QACQDK.js} +1 -1
  108. package/{chunk-TB3MIBRC.js → chunk-PIDUNDFS.js} +572 -430
  109. package/{chunk-4JMDLJAD.js → chunk-PJNFNEJE.js} +114 -37
  110. package/chunk-PKZKOVA5.js +11507 -0
  111. package/{chunk-Z4CSIXYP.js → chunk-PLSVXHSA.js} +3 -3
  112. package/chunk-PWTNI4N7.js +47 -0
  113. package/chunk-QFEW2ULV.js +42 -0
  114. package/{chunk-RGNEEJ3Y.js → chunk-QLQ573SU.js} +35 -9
  115. package/chunk-QQ56R7KS.js +88 -0
  116. package/chunk-QYPE3TS3.js +43 -0
  117. package/{chunk-HTVYCXBP.js → chunk-RN2GPWN6.js} +354 -120
  118. package/{chunk-ATLTFRYJ.js → chunk-ROCUB2H2.js} +280 -98
  119. package/{chunk-4DPP773Q.js → chunk-RSHPU4PD.js} +59 -11
  120. package/chunk-RVWMAFIT.js +134 -0
  121. package/{chunk-ESHYE7WU.js → chunk-S73EPYNC.js} +10 -7
  122. package/{chunk-UQNS32WZ.js → chunk-SCMHQUMK.js} +1 -1
  123. package/chunk-SW4S4XYB.js +1794 -0
  124. package/{chunk-ZUEK6A6C.js → chunk-TTH4HOJD.js} +1973 -754
  125. package/chunk-TY3TIUJK.js +89 -0
  126. package/{chunk-X2QRZXZH.js → chunk-TYJ5XFEA.js} +4 -4
  127. package/{chunk-ALFH24P3.js → chunk-TYYRSFBG.js} +197 -155
  128. package/{chunk-MST6R3E4.js → chunk-U5GPBQDG.js} +34 -22
  129. package/chunk-U5ICMAFV.js +14110 -0
  130. package/{chunk-7KVZ5LDQ.js → chunk-UBUH2TCC.js} +18 -4
  131. package/chunk-UEILX4EV.js +15 -0
  132. package/chunk-UHTDNB5Y.js +140 -0
  133. package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
  134. package/{chunk-OHOVNO7I.js → chunk-UOKFKFPO.js} +6 -3
  135. package/{chunk-XISEYOGH.js → chunk-USHQX6VT.js} +5 -5
  136. package/chunk-UUPR3TD7.js +53 -0
  137. package/{chunk-3DAVPNFT.js → chunk-V4EE3D54.js} +122 -107
  138. package/{chunk-HDLLCBRF.js → chunk-VEA7H5FG.js} +2 -2
  139. package/chunk-VHGD6FHV.js +116 -0
  140. package/chunk-VIWDGTDA.js +8 -0
  141. package/{chunk-GOH6RW6F.js → chunk-VJXHL6MH.js} +34 -11
  142. package/{chunk-4XEYAFLY.js → chunk-VL5KOY2C.js} +623 -94
  143. package/{chunk-EADNWBAZ.js → chunk-VP3BINY7.js} +13 -0
  144. package/{chunk-DXHL7G2L.js → chunk-VWW6O2TL.js} +274 -93
  145. package/{chunk-EOARMOVD.js → chunk-W4S6OTSC.js} +6 -3
  146. package/chunk-WD4XYDYC.js +567 -0
  147. package/chunk-WJZOQR2J.js +151 -0
  148. package/{chunk-AUDNYVRC.js → chunk-XETG4RIX.js} +5 -5
  149. package/{chunk-MX574M24.js → chunk-XI7DGLUK.js} +4 -4
  150. package/{chunk-3L2WKC3W.js → chunk-XPWGOTBQ.js} +8 -1
  151. package/chunk-XRUSXPCQ.js +514 -0
  152. package/{chunk-I4OPU5TK.js → chunk-XS47QOFV.js} +273 -11
  153. package/{chunk-S5XGT6GB.js → chunk-XZNCX52W.js} +30 -9
  154. package/{chunk-5OA5HMTL.js → chunk-YLMMECCH.js} +1 -1
  155. package/{chunk-CFT5HBGW.js → chunk-YVLQXTUB.js} +448 -12
  156. package/chunk-YVPQATSC.js +709 -0
  157. package/chunk-ZEZC7IIM.js +126 -0
  158. package/{chunk-ALGORS6Y.js → chunk-ZF6526IQ.js} +43 -8
  159. package/chunk-ZIWPQEFU.js +165 -0
  160. package/chunk-ZRAU6T47.js +56 -0
  161. package/{cliExecutor-AWYR3T33.js → cliExecutor-BWBF2MTI.js} +4 -3
  162. package/{clipboardy-BX4NMYHE.js → clipboardy-GCO3GT3I.js} +3 -8
  163. package/{commandRegistry-2KBOXZQC.js → commandRegistry-NBLZEMCW.js} +183 -107
  164. package/contentThunks-6AIWNSGO.js +84 -0
  165. package/{cooldownCommands-ZLEPIB4A.js → cooldownCommands-JFKTYS2D.js} +2 -2
  166. package/{createAgentAutomationAction-5UGTB26P.js → createAgentAutomationAction-4BUS65DZ.js} +53 -44
  167. package/createDialogAction-QAIKSCG4.js +76 -0
  168. package/{createPageAction-CDLDKPRM.js → createPageAction-DXCZ334C.js} +65 -54
  169. package/cursorProvider-YGGNMVWX.js +6123 -0
  170. package/{db-VQSAOWAO.js → db-2QOTXYGH.js} +11 -5
  171. package/{dbSlice-DQ32LYTJ.js → dbSlice-J37OGIXH.js} +19 -13
  172. package/{deleteFile-NX6QHCWZ.js → deleteFile-6JWDDRVP.js} +10 -6
  173. package/dialogCommands-YZLSJB6X.js +113 -0
  174. package/{dialogSlice-N3YB65G5.js → dialogSlice-PVUSMKFW.js} +53 -39
  175. package/{docCreateCommands-ZSLGVBZT.js → docCreateCommands-JB2RRMRJ.js} +54 -57
  176. package/{docDeleteCommands-5N4GVZBG.js → docDeleteCommands-AQENULNM.js} +56 -58
  177. package/{docReadCommands-YJSAA7AV.js → docReadCommands-DYD25YLQ.js} +53 -56
  178. package/{docStore-E3CEOV5Q.js → docStore-CSEBEMKP.js} +25 -16
  179. package/{docUpdateCommands-WEMLSW6W.js → docUpdateCommands-3GVS23QL.js} +54 -57
  180. package/{fetchMessages-67MEFPZR.js → fetchMessages-IIJWQ3HR.js} +5 -4
  181. package/{getPricing-NMMFT3YI.js → getPricing-FKK3F5EJ.js} +11 -9
  182. package/{handleSendMessageAction-DQAD5ERJ.js → handleSendMessageAction-G2TLYGC4.js} +422 -118
  183. package/index.js +11 -7
  184. package/{lib-FRRS27KN.js → lib-4YTWAGY7.js} +581 -248
  185. package/{localDialogRead-EBRS242U.js → localDialogRead-FSOMOPDZ.js} +2 -2
  186. package/localRuntimeAdapter-B4TAYYA7.js +244 -0
  187. package/localRuntimeAuthority-JDAD7CB6.js +16 -0
  188. package/{localRuntimeDb-3LRMNLCM.js → localRuntimeDb-CVC62PM5.js} +1 -1
  189. package/{machineCommands-HAP75VSG.js → machineCommands-6OBFD3XF.js} +503 -161
  190. package/{machineInfo-66ZFUMLE.js → machineInfo-UKPTZO5Y.js} +2 -2
  191. package/machineWsRunDispatch-OO7N3O3Y.js +169 -0
  192. package/{memberThunks-5ZXPR63F.js → memberThunks-66DH6ABQ.js} +25 -18
  193. package/{models-ZPU5EDF4.js → models-LAS4B2B5.js} +2 -2
  194. package/package.json +1 -1
  195. package/{providerPresetApply-DD6NGWW6.js → providerPresetApply-MY66I6NT.js} +10 -10
  196. package/{providerRegistry-XDRLMYGJ.js → providerRegistry-QOE2FT57.js} +13 -9
  197. package/{read-EPTJRAEF.js → read-DC4NUGN6.js} +12 -8
  198. package/{readDocTool-W4NDXNEX.js → readDocTool-NCJ5NT25.js} +1 -1
  199. package/{readlineWorkspace-7BC66QSX.js → readlineWorkspace-UIQN7JUR.js} +5017 -915
  200. package/{removeDialogAgentAction-OSYNZRX7.js → removeDialogAgentAction-E2H3OZU6.js} +29 -28
  201. package/{runAgentClientLoop-6E6UC3CE.js → runAgentClientLoop-GS3SGG37.js} +154 -97
  202. package/{runtimeDoctorCommands-ID23PNNZ.js → runtimeDoctorCommands-GIOGC5SC.js} +17 -17
  203. package/secretCommands-ZXZRLR3R.js +700 -0
  204. package/setDialogExtraReferencesAction-SITRPMYU.js +37 -0
  205. package/{setPrimaryDialogAgentAction-WZ7KI3YA.js → setPrimaryDialogAgentAction-U7N45TGC.js} +30 -29
  206. package/{chunk-SONWNI3L.js → settingThunks-Y7SVJOMZ.js} +223 -928
  207. package/{skillDiscovery-ZBU76COE.js → skillDiscovery-QC35EQY4.js} +2 -2
  208. package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
  209. package/{spaceCommands-UJOVU4XI.js → spaceCommands-ZR5BR3GX.js} +59 -59
  210. package/{streamAgentChatTurn-3UXPYFNX.js → streamAgentChatTurn-4XYC33KE.js} +309 -165
  211. package/{switchDialogAgentAction-GMR7WN3P.js → switchDialogAgentAction-OMGBD3N2.js} +26 -22
  212. package/{tableCommands-G7RV3RU3.js → tableCommands-U3QDY4L6.js} +19 -17
  213. package/{toolApiClient-CVGWM4PN.js → toolApiClient-7WSJJJBV.js} +6 -5
  214. package/tools-P77EE7Q4.js +124 -0
  215. package/tuiSummaryLlmCaller-BM3VSTBU.js +130 -0
  216. package/{updateCommands-4EHDLF5J.js → updateCommands-NQXAGFM7.js} +3 -3
  217. package/{updateDialogTitleAction-UPFV7TDT.js → updateDialogTitleAction-CIANVPZC.js} +102 -57
  218. package/workloadLifecycle-36DXRZKU.js +320 -0
  219. package/action-GI44T4DR.js +0 -31
  220. package/agentListCommands-IW3GQVUP.js +0 -427
  221. package/agentRecordCommands-VCA76W6B.js +0 -134
  222. package/agentRunCommand-YNLDKVR7.js +0 -161
  223. package/browser-image-compression-MFDTD7K6.js +0 -1763
  224. package/chatQueueReduxAdapter-TJRMXMYA.js +0 -186
  225. package/chromeOpsCommands-IXRLN57H.js +0 -289
  226. package/chunk-36KZDDO5.js +0 -2415
  227. package/chunk-ACQD6YI2.js +0 -25363
  228. package/chunk-CQ3WA2NE.js +0 -299
  229. package/chunk-CYSYR67N.js +0 -93
  230. package/chunk-JBTJAPUF.js +0 -35
  231. package/chunk-K2CSUCHJ.js +0 -620
  232. package/chunk-LTRXGFMS.js +0 -83
  233. package/chunk-M76ECQRD.js +0 -13658
  234. package/chunk-MEYIRKDN.js +0 -8967
  235. package/chunk-OCZKATRC.js +0 -129
  236. package/chunk-OTGFTBLI.js +0 -13
  237. package/chunk-PUOC4YRO.js +0 -394
  238. package/chunk-PZZTFEKK.js +0 -34
  239. package/chunk-URMS4XY2.js +0 -10
  240. package/chunk-UV6VISQJ.js +0 -20
  241. package/chunk-VJVNU77E.js +0 -83
  242. package/chunk-XYJSY4KG.js +0 -13807
  243. package/chunk-Y5GCAMGP.js +0 -9
  244. package/chunk-YPREESF4.js +0 -225
  245. package/contentThunks-BDIQRZR6.js +0 -73
  246. package/createDialogAction-B7VGVEVU.js +0 -66
  247. package/dialogCommands-G7YBVAMC.js +0 -102
  248. package/levelLazyShim-GZBKODGI.js +0 -7
  249. package/machineWsRunDispatch-L32G7C4P.js +0 -149
  250. package/serverStoreFactory-YMXDF4NI.js +0 -20
  251. package/setDialogExtraReferencesAction-M32UYNCG.js +0 -30
  252. package/settingSlice-Q6EKL7EQ.js +0 -204
  253. package/syncMapping-N6RGXGBW.js +0 -437
  254. package/tools-MKYDMWA4.js +0 -111
  255. package/tuiSummaryLlmCaller-3YFNHCTW.js +0 -128
  256. package/{chunk-SV5IJK6K.js → chunk-NBTY7YJF.js} +3 -3
  257. package/{chunk-2SYTUTLI.js → chunk-YBNHPX4S.js} +3 -3
  258. package/{offlineMarxistsAgentCommand-HGXZV4XJ.js → offlineMarxistsAgentCommand-2QTHJCHV.js} +4 -4
@@ -0,0 +1,802 @@
1
+ import {
2
+ decorateAgentsWithPublicStatusAcrossServers,
3
+ formatQuotaSummary,
4
+ listFavoriteAgentIdsAcrossServers,
5
+ listLocalCachedAgents,
6
+ listRemoteAgents,
7
+ listRemoteAgentsAcrossServers,
8
+ listRemotePublicAgents,
9
+ normalizeListedAgent,
10
+ parseAgentListArgs
11
+ } from "./chunk-VJXHL6MH.js";
12
+ import {
13
+ refreshSubscriptionQuotas
14
+ } from "./chunk-U4STABYN.js";
15
+ import {
16
+ getReadableCliDb
17
+ } from "./chunk-P5QACQDK.js";
18
+ import {
19
+ applyCredentialAvailability,
20
+ clearCredentialAvailabilityIfMarkedAt,
21
+ readCredentialAvailability,
22
+ readCredentialEntry
23
+ } from "./chunk-6MXDOUMH.js";
24
+ import {
25
+ t
26
+ } from "./chunk-SW4S4XYB.js";
27
+ import {
28
+ buildSpaceLookup,
29
+ getSpaceContentKeys
30
+ } from "./chunk-ID4G2MAR.js";
31
+ import {
32
+ readLiveDbRecordAfterTombstoneMerge
33
+ } from "./chunk-USHQX6VT.js";
34
+ import {
35
+ queryUserRecords,
36
+ readDbRecord
37
+ } from "./chunk-ZF6526IQ.js";
38
+ import "./chunk-UUPR3TD7.js";
39
+ import "./chunk-NBTY7YJF.js";
40
+ import {
41
+ buildAgentDiscoveryResult,
42
+ matchesAgentQuery,
43
+ summarizeCredentialGroups,
44
+ toDiscoverySafeAgentSummary
45
+ } from "./chunk-JKMLSTZK.js";
46
+ import "./chunk-OXME3PEE.js";
47
+ import "./chunk-UKZX3NHN.js";
48
+ import "./chunk-UEILX4EV.js";
49
+ import "./chunk-D2MDMY2M.js";
50
+ import "./chunk-AUIJZACN.js";
51
+ import "./chunk-GQV5KHJU.js";
52
+ import "./chunk-ZNFJWEN4.js";
53
+ import "./chunk-LGN377P3.js";
54
+ import "./chunk-HNUWUO75.js";
55
+ import "./chunk-CHOZJMJS.js";
56
+ import "./chunk-PWTNI4N7.js";
57
+ import "./chunk-UOKFKFPO.js";
58
+ import "./chunk-5ZUL4CUO.js";
59
+ import "./chunk-GCKHQECX.js";
60
+ import "./chunk-G6OOUQWJ.js";
61
+ import "./chunk-56GBUMO5.js";
62
+ import "./chunk-WJZOQR2J.js";
63
+ import "./chunk-WD4XYDYC.js";
64
+ import "./chunk-3SZA4U64.js";
65
+ import "./chunk-QLQ573SU.js";
66
+ import {
67
+ isAgentUnavailableNow,
68
+ resolveCredentialKeyWithFallback,
69
+ shouldClearCooldownFromQuota
70
+ } from "./chunk-3MZAGMYY.js";
71
+ import "./chunk-2MBTWINN.js";
72
+ import "./chunk-6CCFTVBP.js";
73
+ import {
74
+ normalizeTimingMs
75
+ } from "./chunk-BPMPOFWP.js";
76
+ import "./chunk-5MMAK75Q.js";
77
+ import "./chunk-DWLEOOGR.js";
78
+ import "./chunk-LIQJTQRN.js";
79
+ import "./chunk-UHTDNB5Y.js";
80
+ import "./chunk-KX6YBIHG.js";
81
+ import "./chunk-7DPNBQSV.js";
82
+ import "./chunk-5EBLANFT.js";
83
+ import "./chunk-NYYFIKHI.js";
84
+ import "./chunk-EZVK3N5L.js";
85
+ import "./chunk-M2EJHDJP.js";
86
+ import {
87
+ createKey,
88
+ createTokenKey
89
+ } from "./chunk-5EMSBTQ6.js";
90
+ import "./chunk-I42VC5KR.js";
91
+ import "./chunk-U6VC4MU4.js";
92
+ import "./chunk-TYYRSFBG.js";
93
+ import "./chunk-XZNCX52W.js";
94
+ import "./chunk-WWC7I6TA.js";
95
+ import "./chunk-PSCNXBYA.js";
96
+ import "./chunk-K2AER7RX.js";
97
+ import "./chunk-UBUH2TCC.js";
98
+ import "./chunk-I4SN4NUQ.js";
99
+ import "./chunk-5BHQICF2.js";
100
+ import "./chunk-KUG52IAP.js";
101
+ import "./chunk-3EUW3WEO.js";
102
+ import {
103
+ toErrorMessage
104
+ } from "./chunk-HNMXYYJR.js";
105
+ import {
106
+ resolveNoloHome
107
+ } from "./chunk-GLKOYSRU.js";
108
+ import {
109
+ parseUserIdFromAuthToken,
110
+ readOption,
111
+ resolveAuthToken,
112
+ resolveServerCandidates,
113
+ resolveServerUrl
114
+ } from "./chunk-A7GB5UGH.js";
115
+ import "./chunk-OLZBQWZU.js";
116
+ import "./chunk-LCBAMY2M.js";
117
+ import "./chunk-4SN6J65J.js";
118
+ import "./chunk-CF7PE763.js";
119
+ import "./chunk-G3SUCT4W.js";
120
+ import "./chunk-Y6ROFCZO.js";
121
+ import {
122
+ getModelAbility
123
+ } from "./chunk-RVWMAFIT.js";
124
+ import "./chunk-CHCS6XPJ.js";
125
+ import "./chunk-QSJ3HFEF.js";
126
+ import "./chunk-ZWQUWF6W.js";
127
+ import "./chunk-VEA7H5FG.js";
128
+ import "./chunk-4VJAC32I.js";
129
+ import "./chunk-4VNS5WPM.js";
130
+
131
+ // packages/ai/agent/speedSampleCache.ts
132
+ var SPEED_SAMPLE_DISK_CACHE_TTL_MS = 10 * 6e4;
133
+ var SPEED_SAMPLE_SCAN_BUDGET_MS = 8e3;
134
+ var SPEED_SAMPLE_CACHE_VERSION = 1;
135
+ var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
136
+ var sanitizeSample = (value) => {
137
+ if (!value || typeof value !== "object") return null;
138
+ const sample = value;
139
+ const clean = {};
140
+ if (isFiniteNumber(sample.firstOutputMs)) clean.firstOutputMs = sample.firstOutputMs;
141
+ if (isFiniteNumber(sample.callDurationMs)) clean.callDurationMs = sample.callDurationMs;
142
+ if (isFiniteNumber(sample.output_tokens)) clean.output_tokens = sample.output_tokens;
143
+ return clean.firstOutputMs === void 0 && clean.callDurationMs === void 0 ? null : clean;
144
+ };
145
+ async function readSpeedSamplesCache(cachePath, options) {
146
+ const ttlMs = isFiniteNumber(options.ttlMs) ? options.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
147
+ try {
148
+ const fs = await import("node:fs/promises");
149
+ const raw = await fs.readFile(cachePath, "utf8");
150
+ const parsed = JSON.parse(raw);
151
+ if (!parsed || typeof parsed !== "object") return null;
152
+ if (parsed.version !== SPEED_SAMPLE_CACHE_VERSION) return null;
153
+ if (parsed.userId !== options.userId) return null;
154
+ if (!isFiniteNumber(parsed.at)) return null;
155
+ const age = options.now - parsed.at;
156
+ if (age < 0 || age >= ttlMs) return null;
157
+ const samples = /* @__PURE__ */ new Map();
158
+ const source = parsed.samples;
159
+ if (!source || typeof source !== "object") return null;
160
+ for (const [model, list] of Object.entries(source)) {
161
+ if (!model || !Array.isArray(list)) continue;
162
+ const cleaned = [];
163
+ for (const entry of list) {
164
+ const sample = sanitizeSample(entry);
165
+ if (sample) cleaned.push(sample);
166
+ }
167
+ samples.set(model, cleaned);
168
+ }
169
+ return samples;
170
+ } catch {
171
+ return null;
172
+ }
173
+ }
174
+ async function writeSpeedSamplesCache(cachePath, payload) {
175
+ try {
176
+ const fs = await import("node:fs/promises");
177
+ const path2 = await import("node:path");
178
+ await fs.mkdir(path2.dirname(cachePath), { recursive: true });
179
+ await fs.writeFile(cachePath, JSON.stringify(payload), "utf8");
180
+ } catch {
181
+ }
182
+ }
183
+
184
+ // packages/ai/token/observedSpeedResolver.ts
185
+ var DEFAULT_OBSERVED_SPEED_SAMPLE_SIZE = 20;
186
+ var MIN_THROUGHPUT_WINDOW_MS = 200;
187
+ var MAX_PLAUSIBLE_OUTPUT_TPS = 3e3;
188
+ var isFiniteNumber2 = (value) => typeof value === "number" && Number.isFinite(value);
189
+ var medianOf = (values) => {
190
+ if (values.length === 0) return void 0;
191
+ const sorted = [...values].sort((a, b) => a - b);
192
+ const middle = Math.floor(sorted.length / 2);
193
+ return sorted.length % 2 === 1 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
194
+ };
195
+ function resolveObservedSpeed(records, options = {}) {
196
+ const limit = isFiniteNumber2(options.limit) ? Math.max(0, Math.floor(options.limit)) : DEFAULT_OBSERVED_SPEED_SAMPLE_SIZE;
197
+ const sample = Array.isArray(records) ? records.slice(0, limit) : [];
198
+ const firstOutputSamples = [];
199
+ const tpsSamples = [];
200
+ for (const record of sample) {
201
+ if (!record || typeof record !== "object") continue;
202
+ const { firstOutputMs, callDurationMs, output_tokens: outputTokens } = record;
203
+ const firstOutput = normalizeTimingMs(firstOutputMs);
204
+ const callDuration = normalizeTimingMs(callDurationMs);
205
+ if (firstOutput !== void 0) {
206
+ firstOutputSamples.push(firstOutput);
207
+ }
208
+ if (firstOutput !== void 0 && callDuration !== void 0 && callDuration - firstOutput >= MIN_THROUGHPUT_WINDOW_MS && isFiniteNumber2(outputTokens) && outputTokens > 0) {
209
+ const seconds = (callDuration - firstOutput) / 1e3;
210
+ const tokensPerSecond = outputTokens / seconds;
211
+ if (isFiniteNumber2(tokensPerSecond) && tokensPerSecond <= MAX_PLAUSIBLE_OUTPUT_TPS) {
212
+ tpsSamples.push(tokensPerSecond);
213
+ }
214
+ }
215
+ }
216
+ const medianFirstOutputMs = medianOf(firstOutputSamples);
217
+ const medianTps = medianOf(tpsSamples);
218
+ return {
219
+ firstOutputSampleCount: firstOutputSamples.length,
220
+ throughputSampleCount: tpsSamples.length,
221
+ ...medianFirstOutputMs !== void 0 ? { medianFirstOutputMs: Math.round(medianFirstOutputMs) } : {},
222
+ ...medianTps !== void 0 ? { medianOutputTokensPerSecond: Math.round(medianTps * 100) / 100 } : {}
223
+ };
224
+ }
225
+
226
+ // packages/ai/agent/candidateSpeedContext.ts
227
+ var OBSERVED_SPEED_WINDOW = 50;
228
+ var MIN_OBSERVED_FIRST_OUTPUT_SAMPLES = 5;
229
+ var SPEED_SAMPLES_CACHE_TTL_MS = 5 * 6e4;
230
+ var SPEED_SAMPLES_CACHE_MAX_ENTRIES = 500;
231
+ var MAX_PLAUSIBLE_AA_FIRST_ANSWER_S = 60;
232
+ function normalizeSpeedModelName(raw) {
233
+ const name = raw.trim().toLowerCase();
234
+ const slash = name.lastIndexOf("/");
235
+ return slash === -1 ? name : name.slice(slash + 1);
236
+ }
237
+ var isFiniteNumber3 = (value) => typeof value === "number" && Number.isFinite(value);
238
+ var REASONING_EFFORT_SUFFIXES = ["minimal", "low", "medium", "high", "xhigh"];
239
+ var REASONING_EFFORT_SUFFIX_RE = new RegExp(`-(?:${REASONING_EFFORT_SUFFIXES.join("|")})$`);
240
+ function stripReasoningEffortSuffix(model) {
241
+ const base = model.replace(REASONING_EFFORT_SUFFIX_RE, "");
242
+ return base && base !== model ? base : null;
243
+ }
244
+ function resolveOneBare(model, samplesByModel) {
245
+ const observed = resolveObservedSpeed(samplesByModel.get(model) ?? [], {
246
+ limit: OBSERVED_SPEED_WINDOW
247
+ });
248
+ if (observed.firstOutputSampleCount >= MIN_OBSERVED_FIRST_OUTPUT_SAMPLES && observed.medianFirstOutputMs !== void 0) {
249
+ return {
250
+ source: "observed",
251
+ firstOutputMs: observed.medianFirstOutputMs,
252
+ ...observed.medianOutputTokensPerSecond !== void 0 ? { outputTps: observed.medianOutputTokensPerSecond } : {},
253
+ firstOutputSamples: observed.firstOutputSampleCount,
254
+ tpsSamples: observed.throughputSampleCount
255
+ };
256
+ }
257
+ const aa = getModelAbility(model)?.aaSnapshot;
258
+ if (!aa) return null;
259
+ const firstAnswerTokenS = isFiniteNumber3(aa.firstAnswerTokenS) && aa.firstAnswerTokenS <= MAX_PLAUSIBLE_AA_FIRST_ANSWER_S ? aa.firstAnswerTokenS : void 0;
260
+ if (!isFiniteNumber3(aa.outputSpeedTps) && firstAnswerTokenS === void 0) {
261
+ return null;
262
+ }
263
+ return {
264
+ source: "aa",
265
+ ...firstAnswerTokenS !== void 0 ? { firstAnswerTokenS } : {},
266
+ ...isFiniteNumber3(aa.outputSpeedTps) ? { outputTps: aa.outputSpeedTps } : {},
267
+ measuredAt: aa.measuredAt
268
+ };
269
+ }
270
+ function resolveOne(model, samplesByModel) {
271
+ const direct = resolveOneBare(model, samplesByModel);
272
+ if (direct) return { model, ...direct };
273
+ const base = stripReasoningEffortSuffix(model);
274
+ if (!base) return null;
275
+ const stripped = resolveOneBare(base, samplesByModel);
276
+ return stripped ? { model, ...stripped } : null;
277
+ }
278
+ function resolveCandidateSpeedFacts(models, samplesByModel) {
279
+ const unique = [
280
+ ...new Set(
281
+ models.filter((model) => typeof model === "string").map(normalizeSpeedModelName).filter(Boolean)
282
+ )
283
+ ];
284
+ return unique.map((model) => resolveOne(model, samplesByModel)).filter((fact) => fact !== null);
285
+ }
286
+ var formatSeconds = (ms) => `${(ms / 1e3).toFixed(1)}s`;
287
+ var formatTps = (tps) => String(Math.round(tps));
288
+ var SPEED_CONTEXT_HEADER = "speed (observed=\u672C\u7528\u6237\u6700\u8FD1\u8C03\u7528\u4E2D\u4F4D\u6570, firstOutput \u542B\u63A8\u7406\u8F93\u51FA; aa=Artificial Analysis \u5FEB\u7167, firstAnswer \u542B\u601D\u8003\u65F6\u95F4, \u4E24\u6E90\u4E0D\u53EF\u76F4\u63A5\u6BD4\u8F83; tps=n/a \u8868\u793A\u65E0\u53EF\u4FE1\u541E\u5410\u6837\u672C):";
289
+ function formatCandidateSpeedFacts(facts) {
290
+ if (facts.length === 0) return null;
291
+ const lines = facts.map((fact) => {
292
+ if (fact.source === "observed") {
293
+ const tps = fact.outputTps !== void 0 ? formatTps(fact.outputTps) : "n/a";
294
+ return ` ${fact.model}: firstOutput=${formatSeconds(fact.firstOutputMs ?? 0)} tps=${tps} [observed n=${fact.firstOutputSamples ?? 0} tpsN=${fact.tpsSamples ?? 0}]`;
295
+ }
296
+ const parts = [];
297
+ if (fact.firstAnswerTokenS !== void 0) parts.push(`firstAnswer=${fact.firstAnswerTokenS.toFixed(1)}s`);
298
+ parts.push(`tps=${fact.outputTps !== void 0 ? formatTps(fact.outputTps) : "n/a"}`);
299
+ return ` ${fact.model}: ${parts.join(" ")} [aa measuredAt=${fact.measuredAt}]`;
300
+ });
301
+ return `${SPEED_CONTEXT_HEADER}
302
+ ${lines.join("\n")}`;
303
+ }
304
+ function buildCandidateSpeedContext(models, samplesByModel) {
305
+ return formatCandidateSpeedFacts(resolveCandidateSpeedFacts(models, samplesByModel));
306
+ }
307
+ var SPEED_SAMPLE_PAGE_SIZE = 2e3;
308
+ var eventTime = (value) => {
309
+ if (isFiniteNumber3(value.timestamp)) return value.timestamp;
310
+ if (isFiniteNumber3(value.createdAt)) return value.createdAt;
311
+ return 0;
312
+ };
313
+ function collectSample(collected, value) {
314
+ if (typeof value.model !== "string") return;
315
+ if (!isFiniteNumber3(value.firstOutputMs) && !isFiniteNumber3(value.callDurationMs)) return;
316
+ const model = normalizeSpeedModelName(value.model);
317
+ if (!model) return;
318
+ const list = collected.get(model) ?? [];
319
+ list.push({
320
+ t: eventTime(value),
321
+ firstOutputMs: value.firstOutputMs,
322
+ callDurationMs: value.callDurationMs,
323
+ output_tokens: value.output_tokens
324
+ });
325
+ collected.set(model, list);
326
+ }
327
+ function finalizeSamples(collected) {
328
+ const result = /* @__PURE__ */ new Map();
329
+ for (const [model, list] of collected) {
330
+ list.sort((a, b) => b.t - a.t);
331
+ result.set(
332
+ model,
333
+ list.slice(0, OBSERVED_SPEED_WINDOW).map(({ t: _t, ...sample }) => sample)
334
+ );
335
+ }
336
+ return result;
337
+ }
338
+ async function collectRecentSpeedSamples(db, userId, options = {}) {
339
+ const pageSize = isFiniteNumber3(options.pageSize) && options.pageSize > 0 ? Math.floor(options.pageSize) : SPEED_SAMPLE_PAGE_SIZE;
340
+ const budgetMs = isFiniteNumber3(options.budgetMs) ? options.budgetMs : Number.POSITIVE_INFINITY;
341
+ const { start, end } = createTokenKey.rangeOfUser(userId);
342
+ const failedPrefix = createKey("token", userId, "failed-call", "");
343
+ const collected = /* @__PURE__ */ new Map();
344
+ const startedAt = Date.now();
345
+ let lastKey;
346
+ let budgetExhausted = false;
347
+ while (true) {
348
+ if (Date.now() - startedAt >= budgetMs) {
349
+ budgetExhausted = true;
350
+ break;
351
+ }
352
+ const pageOptions = {
353
+ ...lastKey === void 0 ? { gte: start } : { gt: lastKey },
354
+ lte: end,
355
+ limit: pageSize
356
+ };
357
+ let accepted = 0;
358
+ let newestKey = lastKey;
359
+ for await (const [key, raw] of db.iterator(pageOptions)) {
360
+ if (typeof key !== "string") continue;
361
+ if (lastKey !== void 0 && key <= lastKey) continue;
362
+ accepted += 1;
363
+ newestKey = key;
364
+ if (key.startsWith(failedPrefix)) continue;
365
+ if (!raw || typeof raw !== "object") continue;
366
+ collectSample(collected, raw);
367
+ }
368
+ if (accepted === 0 || accepted < pageSize) break;
369
+ lastKey = newestKey;
370
+ }
371
+ return { samples: finalizeSamples(collected), budgetExhausted };
372
+ }
373
+ async function loadRecentSpeedSamples(db, userId, options = {}) {
374
+ const { samples } = await collectRecentSpeedSamples(db, userId, options);
375
+ return samples;
376
+ }
377
+ async function loadSpeedSamplesWithDiskCache(db, userId, now, cache) {
378
+ try {
379
+ const ttlMs = isFiniteNumber3(cache.ttlMs) ? cache.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
380
+ const cached = await readSpeedSamplesCache(cache.cachePath, { userId, now, ttlMs });
381
+ if (cached) return cached;
382
+ const { samples, budgetExhausted } = await collectRecentSpeedSamples(db, userId, {
383
+ pageSize: cache.pageSize,
384
+ budgetMs: isFiniteNumber3(cache.budgetMs) ? cache.budgetMs : SPEED_SAMPLE_SCAN_BUDGET_MS
385
+ });
386
+ if (budgetExhausted) return /* @__PURE__ */ new Map();
387
+ await writeSpeedSamplesCache(cache.cachePath, {
388
+ version: SPEED_SAMPLE_CACHE_VERSION,
389
+ userId,
390
+ at: now,
391
+ samples: Object.fromEntries(samples)
392
+ });
393
+ return samples;
394
+ } catch {
395
+ return /* @__PURE__ */ new Map();
396
+ }
397
+ }
398
+ var samplesCache = /* @__PURE__ */ new Map();
399
+ function writeSamplesCache(userId, now, samples) {
400
+ for (const [key, entry] of samplesCache) {
401
+ if (now - entry.at >= SPEED_SAMPLES_CACHE_TTL_MS) samplesCache.delete(key);
402
+ }
403
+ samplesCache.delete(userId);
404
+ samplesCache.set(userId, { at: now, samples });
405
+ while (samplesCache.size > SPEED_SAMPLES_CACHE_MAX_ENTRIES) {
406
+ const oldest = samplesCache.keys().next().value;
407
+ if (oldest === void 0) break;
408
+ samplesCache.delete(oldest);
409
+ }
410
+ }
411
+ async function loadCachedSpeedSamples(db, userId, now) {
412
+ const hit = samplesCache.get(userId);
413
+ if (hit && now - hit.at < SPEED_SAMPLES_CACHE_TTL_MS) return hit.samples;
414
+ const samples = await loadRecentSpeedSamples(db, userId);
415
+ writeSamplesCache(userId, now, samples);
416
+ return samples;
417
+ }
418
+ async function injectSpeedContextIntoListAgentsResult(result, options = {}) {
419
+ try {
420
+ let parsed;
421
+ try {
422
+ parsed = JSON.parse(result);
423
+ } catch {
424
+ return result;
425
+ }
426
+ if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.agents)) return result;
427
+ const models = parsed.agents.map((agent) => agent?.model).filter((model) => typeof model === "string");
428
+ if (models.length === 0) return result;
429
+ const now = options.now ?? Date.now();
430
+ let samples = /* @__PURE__ */ new Map();
431
+ const userId = typeof options.userId === "string" ? options.userId.trim() : "";
432
+ if (options.db && userId) {
433
+ try {
434
+ samples = options.diskCache ? await loadSpeedSamplesWithDiskCache(options.db, userId, now, options.diskCache) : await loadCachedSpeedSamples(options.db, userId, now);
435
+ } catch {
436
+ samples = /* @__PURE__ */ new Map();
437
+ }
438
+ }
439
+ const speedContext = buildCandidateSpeedContext(models, samples);
440
+ return speedContext ? JSON.stringify({ ...parsed, speedContext }) : result;
441
+ } catch {
442
+ return result;
443
+ }
444
+ }
445
+
446
+ // packages/cli/agentListCommands.ts
447
+ import path from "node:path";
448
+ var discardOutput = { write: () => void 0 };
449
+ function resolveSpeedSamplesCachePath(env, userId) {
450
+ const safeUserId = userId.replace(/[^A-Za-z0-9._-]/g, "_");
451
+ const mergedEnv = { ...process.env, ...env };
452
+ return path.join(resolveNoloHome({ env: mergedEnv }), "cache", `speed-samples-${safeUserId}.json`);
453
+ }
454
+ async function runAgentListCommand(args, deps = {}) {
455
+ const env = deps.env ?? process.env;
456
+ const output = deps.output ?? process.stdout;
457
+ const { wantJson, wantSafe, publicOnly, scope: requestedScope, idsOnly, showUnavailable, verbose, query } = parseAgentListArgs(args);
458
+ if (requestedScope && !["preferred", "public", "all"].includes(requestedScope)) {
459
+ throw new Error(`Invalid scope '${requestedScope}'`);
460
+ }
461
+ if (requestedScope && publicOnly && requestedScope !== "public") {
462
+ throw new Error(`Conflicting arguments: scope='${requestedScope}' conflicts with publicOnly=true.`);
463
+ }
464
+ const scope = requestedScope ?? "preferred";
465
+ const spaceInput = readOption(args, "--space") ?? readOption(args, "--space-id");
466
+ const authToken = resolveAuthToken(args, env);
467
+ if (!authToken) {
468
+ output.write("[nolo] agent list requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
469
+ return 1;
470
+ }
471
+ const userId = parseUserIdFromAuthToken(authToken);
472
+ if (!userId) {
473
+ output.write("[nolo] agent list could not read userId from AUTH_TOKEN.\n");
474
+ return 1;
475
+ }
476
+ const fetchImpl = deps.fetchImpl ?? fetch;
477
+ const fallbackFetchImpl = deps.fallbackFetchImpl;
478
+ const serverUrl = resolveServerUrl(args, env);
479
+ const serverUrls = resolveServerCandidates(args, env, serverUrl);
480
+ try {
481
+ let agents;
482
+ let source;
483
+ let serverFailures = [];
484
+ try {
485
+ const remoteResult = await listRemoteAgentsAcrossServers({
486
+ authToken,
487
+ fallbackFetchImpl,
488
+ fetchImpl,
489
+ serverUrls,
490
+ userId
491
+ });
492
+ agents = remoteResult.agents;
493
+ serverFailures = remoteResult.failures;
494
+ source = "global-cache";
495
+ } catch {
496
+ try {
497
+ const db = deps.db ?? await getReadableCliDb(output);
498
+ agents = await listLocalCachedAgents({ db, userId });
499
+ source = "local-cache";
500
+ } catch {
501
+ agents = await listRemoteAgents({
502
+ authToken,
503
+ fallbackFetchImpl,
504
+ fetchImpl,
505
+ serverUrl,
506
+ userId,
507
+ queryUserRecords,
508
+ readDbRecord
509
+ });
510
+ source = "remote-cache";
511
+ }
512
+ }
513
+ if (scope !== "preferred") {
514
+ const publicAgents = await Promise.all(serverUrls.map((url) => listRemotePublicAgents({
515
+ authToken,
516
+ fetchImpl,
517
+ serverUrl: url,
518
+ limit: 500
519
+ })));
520
+ agents = publicAgents.flat();
521
+ if (scope === "all") {
522
+ const preferred = await listRemoteAgentsAcrossServers({
523
+ authToken,
524
+ fallbackFetchImpl,
525
+ fetchImpl,
526
+ serverUrls,
527
+ userId
528
+ });
529
+ agents = [...preferred.agents, ...agents];
530
+ }
531
+ }
532
+ agents = agents.filter((agent) => agent.privateKey.startsWith("agent-"));
533
+ let resolvedSpaceId = null;
534
+ let spaceContentKeys = null;
535
+ if (spaceInput) {
536
+ const { spaceId, spaceKey } = buildSpaceLookup(spaceInput);
537
+ resolvedSpaceId = spaceId;
538
+ const spaceRead = await readLiveDbRecordAfterTombstoneMerge({
539
+ authToken,
540
+ dbKey: spaceKey,
541
+ fallbackFetchImpl,
542
+ fetchImpl,
543
+ serverUrls
544
+ });
545
+ serverFailures = [...serverFailures, ...spaceRead.failures];
546
+ const spaceRecord = spaceRead.record;
547
+ const currentSpaceContentKeys = getSpaceContentKeys(spaceRecord);
548
+ spaceContentKeys = currentSpaceContentKeys;
549
+ agents = agents.filter(
550
+ (agent) => currentSpaceContentKeys.has(agent.privateKey) || currentSpaceContentKeys.has(agent.publicKey) || currentSpaceContentKeys.has(agent.id)
551
+ );
552
+ }
553
+ if (source === "global-cache") {
554
+ await decorateAgentsWithPublicStatusAcrossServers({
555
+ agents,
556
+ authToken,
557
+ fallbackFetchImpl,
558
+ fetchImpl,
559
+ serverUrls
560
+ });
561
+ }
562
+ if (publicOnly) {
563
+ agents = agents.filter((agent) => agent.publicRecordExists);
564
+ }
565
+ const originalAgentDeadlines = new Map(agents.map((agent) => [agent.privateKey, agent.nextAvailableAt]));
566
+ agents = applyCredentialAvailability(
567
+ agents,
568
+ await readCredentialAvailability(env).catch(() => ({}))
569
+ );
570
+ let unavailableCount = agents.filter((agent) => isAgentUnavailableNow(agent)).length;
571
+ let agentsForOutput = showUnavailable ? agents : agents.filter((agent) => !isAgentUnavailableNow(agent));
572
+ if (query && typeof query === "string" && query.trim()) {
573
+ agentsForOutput = agentsForOutput.filter((agent) => matchesAgentQuery(agent, query));
574
+ }
575
+ const refreshCandidates = !idsOnly ? [.../* @__PURE__ */ new Set([...agentsForOutput, ...agents.filter(
576
+ (agent) => !agentsForOutput.includes(agent) && isAgentUnavailableNow(agent) && agent.credentialConfigured === true && (!query || !String(query).trim() || matchesAgentQuery(agent, query))
577
+ )])] : agentsForOutput;
578
+ if (!idsOnly) {
579
+ const fresh = await refreshSubscriptionQuotas({
580
+ entries: refreshCandidates.map((agent) => ({
581
+ key: agent.privateKey,
582
+ ...agent.quota ? { quota: agent.quota } : {},
583
+ probeable: agent.credentialConfigured === true
584
+ })),
585
+ env,
586
+ cliArgs: args,
587
+ fetchImpl
588
+ });
589
+ const now = Date.now();
590
+ for (const agent of refreshCandidates) {
591
+ const quota = fresh[agent.privateKey];
592
+ if (!quota) continue;
593
+ agent.quota = quota;
594
+ try {
595
+ const key = resolveCredentialKeyWithFallback(agent);
596
+ if (!key) continue;
597
+ const entry = await readCredentialEntry(key, env);
598
+ if (entry && shouldClearCooldownFromQuota(entry, quota, now)) {
599
+ await clearCredentialAvailabilityIfMarkedAt(key, entry.markedAt, env);
600
+ const remainingAvailability = await readCredentialAvailability(env).catch(() => ({}));
601
+ for (const sibling of agents) {
602
+ if (resolveCredentialKeyWithFallback(sibling) !== key) continue;
603
+ const originalDeadline = originalAgentDeadlines.get(sibling.privateKey);
604
+ if (typeof originalDeadline === "number") sibling.nextAvailableAt = originalDeadline;
605
+ else delete sibling.nextAvailableAt;
606
+ Object.assign(sibling, applyCredentialAvailability([sibling], remainingAvailability)[0]);
607
+ }
608
+ }
609
+ } catch {
610
+ }
611
+ }
612
+ unavailableCount = agents.filter((agent) => isAgentUnavailableNow(agent)).length;
613
+ if (!showUnavailable) {
614
+ agentsForOutput = agents.filter((agent) => !isAgentUnavailableNow(agent));
615
+ if (query && typeof query === "string" && query.trim()) {
616
+ agentsForOutput = agentsForOutput.filter((agent) => matchesAgentQuery(agent, query));
617
+ }
618
+ }
619
+ }
620
+ if (idsOnly) {
621
+ output.write(`${agentsForOutput.map((agent) => agent.id).join("\n")}
622
+ `);
623
+ return 0;
624
+ }
625
+ if (wantSafe) {
626
+ const favoritesMap = await listFavoriteAgentIdsAcrossServers({
627
+ authToken,
628
+ fetchImpl,
629
+ serverUrls
630
+ }).catch(() => ({}));
631
+ const existingKeys = /* @__PURE__ */ new Set();
632
+ for (const agent of agents) {
633
+ existingKeys.add(agent.privateKey);
634
+ existingKeys.add(agent.publicKey);
635
+ existingKeys.add(agent.id);
636
+ }
637
+ const extraFavoriteRecords = [];
638
+ const hydratedFavoriteAgents = [];
639
+ for (const favKey of Object.keys(favoritesMap)) {
640
+ if (existingKeys.has(favKey)) continue;
641
+ try {
642
+ const favRead = await readLiveDbRecordAfterTombstoneMerge({
643
+ authToken,
644
+ dbKey: favKey,
645
+ fallbackFetchImpl,
646
+ fetchImpl,
647
+ serverUrls
648
+ });
649
+ const record = favRead.record;
650
+ if (!record || record.type && record.type !== "agent") continue;
651
+ const norm = normalizeListedAgent(record);
652
+ const candidateKeys = [record.dbKey, record.publicKey, record.id].filter((key) => typeof key === "string" && key.length > 0);
653
+ if (spaceContentKeys && !candidateKeys.some((key) => spaceContentKeys?.has(key))) {
654
+ continue;
655
+ }
656
+ if (norm) {
657
+ if (!favKey.startsWith("agent-pub-")) {
658
+ norm.verifiedAgentKey = favKey;
659
+ if (typeof record.userId === "string" && record.userId) {
660
+ norm.ownerId = record.userId;
661
+ }
662
+ }
663
+ agents.push(norm);
664
+ hydratedFavoriteAgents.push(norm);
665
+ existingKeys.add(norm.privateKey);
666
+ existingKeys.add(norm.publicKey);
667
+ existingKeys.add(norm.id);
668
+ } else {
669
+ extraFavoriteRecords.push(record);
670
+ for (const key of candidateKeys) existingKeys.add(key);
671
+ }
672
+ } catch {
673
+ }
674
+ }
675
+ if (source === "global-cache" && hydratedFavoriteAgents.length > 0) {
676
+ await decorateAgentsWithPublicStatusAcrossServers({
677
+ agents: hydratedFavoriteAgents,
678
+ authToken,
679
+ fallbackFetchImpl,
680
+ fetchImpl,
681
+ serverUrls
682
+ });
683
+ }
684
+ const safeRecords = [...agents, ...extraFavoriteRecords].map((record) => toDiscoverySafeAgentSummary(record, { favoritesMap, userId })).filter((agent) => publicOnly ? agent.isPublic === true : true);
685
+ const discovery = buildAgentDiscoveryResult({
686
+ agents: safeRecords,
687
+ scope: "all",
688
+ query,
689
+ showUnavailable,
690
+ verbose
691
+ });
692
+ const listResult = JSON.stringify({
693
+ success: true,
694
+ userId,
695
+ ...resolvedSpaceId ? { spaceId: resolvedSpaceId } : {},
696
+ total: discovery.total,
697
+ unavailableCount: discovery.unavailableCount,
698
+ unavailableAgents: discovery.unavailableAgents,
699
+ credentialGroups: discovery.credentialGroups,
700
+ agents: discovery.agents
701
+ }, null, 2);
702
+ const withSpeedContext = await injectSpeedContextIntoListAgentsResult(listResult, {
703
+ db: deps.db ?? await getReadableCliDb(discardOutput),
704
+ userId,
705
+ diskCache: { cachePath: resolveSpeedSamplesCachePath(env, userId) }
706
+ });
707
+ output.write(withSpeedContext);
708
+ output.write("\n");
709
+ return 0;
710
+ }
711
+ if (wantJson) {
712
+ const credentialGroups = summarizeCredentialGroups(agentsForOutput);
713
+ output.write(JSON.stringify({
714
+ userId,
715
+ ...resolvedSpaceId ? { spaceId: resolvedSpaceId } : {},
716
+ targetServers: serverUrls,
717
+ ...serverFailures.length ? { serverFailures } : {},
718
+ total: agentsForOutput.length,
719
+ publicCount: agentsForOutput.filter((agent) => agent.publicRecordExists).length,
720
+ unavailableCount,
721
+ credentialGroups,
722
+ source,
723
+ agents: agentsForOutput
724
+ }, null, 2));
725
+ output.write("\n");
726
+ return 0;
727
+ }
728
+ output.write(`userId: ${userId}
729
+ `);
730
+ if (resolvedSpaceId) {
731
+ output.write(`spaceId: ${resolvedSpaceId}
732
+ `);
733
+ }
734
+ output.write(`targetServers: ${serverUrls.join(", ")}
735
+ `);
736
+ if (serverFailures.length) {
737
+ output.write(`serverFailures: ${serverFailures.length}
738
+ `);
739
+ }
740
+ output.write(`total agents: ${agentsForOutput.length}
741
+ `);
742
+ output.write(`public agents: ${agentsForOutput.filter((agent) => agent.publicRecordExists).length}
743
+ `);
744
+ if (unavailableCount > 0 && !showUnavailable) {
745
+ output.write(t("agent.unavailableHidden", String(unavailableCount)));
746
+ const unavailableList = agents.filter((agent) => isAgentUnavailableNow(agent));
747
+ for (const unavail of unavailableList) {
748
+ const remainingSec = Math.max(0, Math.ceil(((unavail.nextAvailableAt ?? 0) - Date.now()) / 1e3));
749
+ const quotaSummary = formatQuotaSummary(unavail.quota);
750
+ const quotaText = quotaSummary ? ` (${quotaSummary})` : "";
751
+ output.write(
752
+ t("agent.rateLimitedRecovery", unavail.name, unavail.id, String(remainingSec), quotaText)
753
+ );
754
+ }
755
+ }
756
+ output.write(`source: ${source}
757
+ `);
758
+ if (agentsForOutput.length === 0) {
759
+ output.write("\n(no agents found)\n");
760
+ return 0;
761
+ }
762
+ for (const agent of agentsForOutput) {
763
+ const status = agent.publicRecordExists ? "public" : "private";
764
+ const flagMismatch = agent.isPublicFlag !== agent.publicRecordExists ? ` flag=${agent.isPublicFlag}` : "";
765
+ const credentialLine = agent.credentialConfigured ? `credentialConfigured=true${agent.credentialRef ? ` credentialRef=${agent.credentialRef}` : ""}${agent.apiKeyRef ? ` apiKeyRef=${agent.apiKeyRef}` : ""}` : "credentialConfigured=false";
766
+ const availabilityLine = typeof agent.nextAvailableAt === "number" && agent.nextAvailableAt > Date.now() ? `nextAvailableAt=${new Date(agent.nextAvailableAt).toISOString()}` : "nextAvailableAt=now";
767
+ const quotaSummary = formatQuotaSummary(agent.quota);
768
+ const quotaLine = `quota=${quotaSummary ?? "-"}`;
769
+ output.write(
770
+ [
771
+ `
772
+ [${status}] ${agent.name}`,
773
+ `id=${agent.id}`,
774
+ `type=${agent.type ?? "-"}`,
775
+ `model=${agent.model}`,
776
+ `updatedAt=${agent.updatedAt ?? "-"}`,
777
+ // 不输出 privateKey(dbKey 属敏感标识,与 web 端 listAgentsFunc 降权
778
+ // 对齐;需要完整记录请用 --json)。
779
+ // 私有 agent(publicRecordExists=false)的公开记录不存在,输出 "-" 而非
780
+ // 一个库里不存在的 agent-pub-<id>,避免误导调用方拿它去 readAgent。
781
+ `publicKey=${agent.publicRecordExists ? agent.publicKey : "-"}${flagMismatch}`,
782
+ `tools=${agent.tools.join(", ") || "-"}`,
783
+ credentialLine,
784
+ availabilityLine,
785
+ quotaLine
786
+ ].join("\n")
787
+ );
788
+ output.write("\n");
789
+ }
790
+ return 0;
791
+ } catch (error) {
792
+ output.write(
793
+ `[nolo] agent list failed: ${toErrorMessage(error)}
794
+ `
795
+ );
796
+ return 1;
797
+ }
798
+ }
799
+ export {
800
+ resolveSpeedSamplesCachePath,
801
+ runAgentListCommand
802
+ };