nolo-cli 0.107.0-alpha.4 → 0.107.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 (211) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-UDCSOTD2.js → _executeModel-M573MKVE.js} +78 -70
  3. package/action-GVA5ARSJ.js +20 -0
  4. package/{addContentAction-MB2HHMDZ.js → addContentAction-M2WOWZCL.js} +13 -12
  5. package/{addDialogAgentAction-MCEABSBA.js → addDialogAgentAction-QMAQ5Z6N.js} +19 -20
  6. package/{agentDeleteCommand-OWYHN6D6.js → agentDeleteCommand-ZFHYRHBS.js} +118 -43
  7. package/{agentEmailCommands-AU5I4M4W.js → agentEmailCommands-X6AVPIVQ.js} +100 -90
  8. package/agentListCommands-PAD2CI2I.js +741 -0
  9. package/{agentMachineCommands-YMNME2L6.js → agentMachineCommands-UPH6RJCC.js} +50 -46
  10. package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-CMVTBY5X.js} +97 -2
  11. package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-B4T2DJ5H.js} +1 -1
  12. package/agentRecordCommands-UMACPRAF.js +138 -0
  13. package/agentRunCommand-H6KKHHMU.js +167 -0
  14. package/{agentRunControl-AVJR4JW4.js → agentRunControl-3HWA2LLQ.js} +2 -2
  15. package/{agentRuntimeLocal-KCMC2TBD.js → agentRuntimeLocal-N4YGKL7M.js} +44 -40
  16. package/{agentSlice-R7PR6KYM.js → agentSlice-2LPP43XH.js} +15 -14
  17. package/{appDeleteCommands-JEPA3EWE.js → appDeleteCommands-7DAF33AM.js} +46 -42
  18. package/{appDeployCommands-UTB76XFM.js → appDeployCommands-ZPZSMFGZ.js} +46 -42
  19. package/{appDeployStatusCommands-LGHF2SBD.js → appDeployStatusCommands-FWBDSSS5.js} +46 -42
  20. package/{appGetCommands-PX2BFHOB.js → appGetCommands-SZZOHGEP.js} +46 -42
  21. package/{appListCommands-BSMPTWKC.js → appListCommands-FPMUBDPM.js} +46 -42
  22. package/{authCommand-YW42YZA4.js → authCommand-VL3G26NQ.js} +119 -25
  23. package/{authCommands-RGOGCPP6.js → authCommands-5RTUDYZW.js} +7 -5
  24. package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-ZK4K67Y5.js} +11 -9
  25. package/{chromeCommands-FZYAU75D.js → chromeCommands-AU5ZJXBG.js} +289 -37
  26. package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-ZYTCMNHG.js} +156 -22
  27. package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
  28. package/{chunk-HVURBGF3.js → chunk-2U3NHADM.js} +6 -6
  29. package/{chunk-QTGQ2LTL.js → chunk-3DQY5IFB.js} +6 -10
  30. package/{chunk-XT35TTFG.js → chunk-3IXAHOJS.js} +19 -21
  31. package/{chunk-UVA7OYO3.js → chunk-3W67RV75.js} +29 -9
  32. package/chunk-4LCOCOR5.js +50 -0
  33. package/{chunk-JPGCXHNM.js → chunk-4LKMZ3RR.js} +1 -1
  34. package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
  35. package/{chunk-6D6VBVEW.js → chunk-4W24JM32.js} +80 -14
  36. package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
  37. package/{chunk-E4MARS3Q.js → chunk-5GVBDNTO.js} +1 -1
  38. package/{chunk-C3M4465B.js → chunk-5HYJ3DSZ.js} +404 -659
  39. package/chunk-5MMAK75Q.js +15 -0
  40. package/{chunk-7S4YWN7P.js → chunk-5UUIGN6I.js} +4 -4
  41. package/{chunk-42V6BK2E.js → chunk-62IL3KQV.js} +4 -34
  42. package/{chunk-4MK3I7Y4.js → chunk-6MAW4XOF.js} +5 -5
  43. package/{chunk-3UZPUAES.js → chunk-74PPKIY2.js} +1 -1
  44. package/chunk-76HO2DP6.js +15 -0
  45. package/{chunk-ASIFZ2WY.js → chunk-7BBP7ZX3.js} +66 -54
  46. package/{chunk-VLTIYV3X.js → chunk-7I25CBT5.js} +34 -8
  47. package/{chunk-IBOZNTG2.js → chunk-7X5XZ34C.js} +23 -28
  48. package/chunk-AGIM7IMJ.js +147 -0
  49. package/{chunk-5UTFL4QJ.js → chunk-APO5TOXO.js} +1 -1
  50. package/{chunk-EEGDMATE.js → chunk-AZOVPTL6.js} +91 -81
  51. package/{chunk-6OZ36FXI.js → chunk-BIPGGSJS.js} +22 -4
  52. package/{chunk-EYAQT56M.js → chunk-BNQMNUKZ.js} +9 -6
  53. package/{chunk-62CATUYY.js → chunk-CBUMFIFE.js} +834 -962
  54. package/{chunk-OIVSQH2O.js → chunk-CDEEFJXN.js} +308 -11
  55. package/chunk-CHOZJMJS.js +78 -0
  56. package/{chunk-ETI2NYVF.js → chunk-CIP3AAMT.js} +4 -4
  57. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  58. package/{chunk-W7HLWAQ7.js → chunk-DE45KZNH.js} +118 -90
  59. package/{chunk-Q554LLSI.js → chunk-DMXLXZKL.js} +1 -1
  60. package/{chunk-3VNWWVKB.js → chunk-E3YWHWCR.js} +50 -18
  61. package/{chunk-HKNXJGEC.js → chunk-ECFHBYUW.js} +85 -50
  62. package/{chunk-ACTMNVHM.js → chunk-EHSYSKXV.js} +1 -1
  63. package/{chunk-WV42OMV7.js → chunk-ELUDRSRD.js} +8 -8
  64. package/{chunk-ABQYVJBJ.js → chunk-EV235ILT.js} +5 -5
  65. package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
  66. package/{chunk-BFDFRLLQ.js → chunk-EZ4VZHAG.js} +5 -5
  67. package/{chunk-GO3Z72MT.js → chunk-FHLMQIU7.js} +65 -95
  68. package/{chunk-2F7RJC6L.js → chunk-FOXQ7BAB.js} +1 -1
  69. package/{chunk-SH43IESU.js → chunk-GGC55Q32.js} +199 -29
  70. package/chunk-GMZLP5DV.js +82 -0
  71. package/{chunk-FDTR4QJ6.js → chunk-H6A6X4EK.js} +32 -1
  72. package/{chunk-DVINR3PL.js → chunk-HDLLCBRF.js} +1 -1
  73. package/{chunk-QOKAKDPE.js → chunk-HIM3FCLF.js} +0 -1
  74. package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
  75. package/{chunk-BNGW5ASC.js → chunk-I2RGRVQ7.js} +22 -2
  76. package/{chunk-O6OSWFZQ.js → chunk-IHPDK6UD.js} +6 -0
  77. package/{chunk-QDSINZM3.js → chunk-IXH3HKY2.js} +1 -22
  78. package/{chunk-GQBOR3G6.js → chunk-JBKHQOYK.js} +8 -4
  79. package/{chunk-XD2MJFUG.js → chunk-JEFXP73H.js} +1 -1
  80. package/{chunk-PBA4UJBK.js → chunk-JIXGJTBU.js} +4 -4
  81. package/{chunk-AEOE4Z6Q.js → chunk-K6L5PNXK.js} +39 -15
  82. package/{chunk-Z77CRGTW.js → chunk-KA5O5KQL.js} +1 -1
  83. package/{chunk-GPCZ7UXG.js → chunk-KD6D6BLA.js} +1 -1
  84. package/{chunk-4CR5I7BD.js → chunk-KFWDYYSS.js} +47 -67
  85. package/{chunk-UZGQNTVW.js → chunk-KHKTDMYG.js} +8 -6
  86. package/{chunk-JDPFV2JV.js → chunk-KWUKOQM2.js} +20 -11
  87. package/{chunk-MRIHM22T.js → chunk-LBFL6RZG.js} +58 -9
  88. package/{chunk-LS2ZANRJ.js → chunk-LOCNXNOU.js} +1 -1
  89. package/{chunk-DHDMC6FO.js → chunk-LUBFABMJ.js} +15 -14
  90. package/{chunk-NA35QHCF.js → chunk-LVBFKW65.js} +1 -1
  91. package/chunk-LWLNLZC5.js +265 -0
  92. package/chunk-N4NGJDT6.js +929 -0
  93. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  94. package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
  95. package/chunk-NWENLDMM.js +42 -0
  96. package/chunk-O7SVKKLY.js +875 -0
  97. package/chunk-OCZKATRC.js +129 -0
  98. package/{chunk-6Z7MY3V7.js → chunk-OEJLGVBL.js} +5 -5
  99. package/{chunk-VMFTFOWF.js → chunk-OKGVNZTL.js} +35 -8
  100. package/{chunk-GEPUP7OO.js → chunk-OR2UWD6X.js} +3 -3
  101. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  102. package/{chunk-J4MOO56S.js → chunk-PNXHPLRU.js} +10 -2
  103. package/{chunk-3BMYXEUW.js → chunk-R5AJODNI.js} +1 -1
  104. package/{chunk-P5EVSOPA.js → chunk-R6EBQEQE.js} +22 -29
  105. package/chunk-RQ6CTX2E.js +164 -0
  106. package/{chunk-MS7TSPZR.js → chunk-RU36ZYSG.js} +19 -17
  107. package/{chunk-ALXHV7NK.js → chunk-RWXLPUKI.js} +40 -4
  108. package/{chunk-KQ4ONNQD.js → chunk-RXA3HAVW.js} +190 -8
  109. package/{chunk-IIVGDG4I.js → chunk-SJKULPGX.js} +13 -7
  110. package/{chunk-Q67DOFOO.js → chunk-SZC4REES.js} +212 -105
  111. package/{chunk-JRQFUXY7.js → chunk-TBAXFWOS.js} +99 -22
  112. package/{chunk-PQFHGD77.js → chunk-TBM2RS3U.js} +161 -14
  113. package/{chunk-NOF3HDSN.js → chunk-TFOIJFCM.js} +11 -9
  114. package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
  115. package/chunk-TY3TIUJK.js +89 -0
  116. package/{chunk-I3TQJXQ7.js → chunk-U3C3IA32.js} +9 -2
  117. package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
  118. package/chunk-UM7TA3K4.js +1008 -0
  119. package/{chunk-6YTOJY35.js → chunk-VBG7GWWR.js} +253 -8
  120. package/{chunk-GL3EHUR4.js → chunk-VHGYUYQ3.js} +69 -47
  121. package/chunk-VIWDGTDA.js +8 -0
  122. package/chunk-VJVNU77E.js +83 -0
  123. package/chunk-VM6IE2GN.js +8004 -0
  124. package/{chunk-UKWGR5SS.js → chunk-VY6VFGKR.js} +194 -1144
  125. package/chunk-VZLO4XJD.js +17 -0
  126. package/chunk-W32HPLTL.js +13692 -0
  127. package/{chunk-AHAHBQMU.js → chunk-WDLSZMTA.js} +2 -2
  128. package/{chunk-53HEEOTT.js → chunk-WF5X57VW.js} +83 -16
  129. package/{chunk-VRTTFDBM.js → chunk-WPHY3VPF.js} +35 -22
  130. package/{chunk-3L2WKC3W.js → chunk-XPWGOTBQ.js} +8 -1
  131. package/chunk-YV25TM3R.js +780 -0
  132. package/chunk-ZRAU6T47.js +56 -0
  133. package/{chunk-IBOOZVVD.js → chunk-ZTKZZY2A.js} +851 -279
  134. package/commandRegistry-ASW6IVZ3.js +833 -0
  135. package/{contentThunks-IV2T3EJC.js → contentThunks-4XNVOIR7.js} +39 -36
  136. package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
  137. package/{createAgentAutomationAction-JCOIEYY4.js → createAgentAutomationAction-NHHTCJMC.js} +40 -37
  138. package/createDialogAction-XEBTHDB3.js +70 -0
  139. package/{createPageAction-D2VOOLP3.js → createPageAction-VR3WW2AQ.js} +47 -43
  140. package/{chunk-FG3HKPQP.js → cursorProvider-YGGNMVWX.js} +2751 -10185
  141. package/{dbSlice-A6C6H32X.js → dbSlice-TG4MZ5EB.js} +12 -11
  142. package/{deleteFile-YG6QMJLU.js → deleteFile-KESP65GC.js} +7 -6
  143. package/{dialogCommands-H7FPUYUQ.js → dialogCommands-FJWQG3MX.js} +50 -47
  144. package/{dialogSlice-6JZOOTDS.js → dialogSlice-GVRDGCRG.js} +57 -37
  145. package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
  146. package/{docCreateCommands-WRG2JLGM.js → docCreateCommands-AZSK4NAG.js} +48 -44
  147. package/{docDeleteCommands-SHWJIBJS.js → docDeleteCommands-DDJMSMFZ.js} +49 -45
  148. package/{docReadCommands-WJN3WT6O.js → docReadCommands-5F5Q6EBZ.js} +47 -43
  149. package/{docStore-HUPQ2FSS.js → docStore-SUZUUWDI.js} +17 -13
  150. package/{docUpdateCommands-IE32IL6O.js → docUpdateCommands-XPNPVZOC.js} +48 -44
  151. package/{fetchMessages-EIU7UFFK.js → fetchMessages-3PXAHKCR.js} +5 -5
  152. package/{getPricing-LUSEABA6.js → getPricing-DOBBZLOK.js} +4 -4
  153. package/{handleSendMessageAction-DFPMQ7YM.js → handleSendMessageAction-VC6VTFKS.js} +109 -42
  154. package/index.js +87 -884
  155. package/{lib-FRRS27KN.js → lib-PU2G2MSO.js} +523 -191
  156. package/{localDialogRead-BTFJ4V2I.js → localDialogRead-UYCKO7YZ.js} +2 -2
  157. package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-TU6OBC76.js} +9 -6
  158. package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-VKWVOPPI.js} +1 -1
  159. package/{machineCommands-M2T2I5NF.js → machineCommands-M634V2L3.js} +98 -89
  160. package/machineWsRunDispatch-Z3HUSTFI.js +154 -0
  161. package/{memberThunks-P2ECUJ56.js → memberThunks-5S5D3N4U.js} +20 -18
  162. package/{models-T3SG6MJ5.js → models-PQU25T6Q.js} +2 -2
  163. package/oauthTokenStore-ITEB663N.js +23 -0
  164. package/package.json +1 -1
  165. package/processSpawn-SOAV3FEV.js +11 -0
  166. package/profileConfig-ZGOFORWV.js +43 -0
  167. package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-HAQWVAQX.js} +7 -7
  168. package/{providerRegistry-757OWH3O.js → providerRegistry-5FGWB3X5.js} +11 -7
  169. package/{read-COE3ZYR6.js → read-LSYFLSIM.js} +8 -7
  170. package/{readDocTool-5USN4A6V.js → readDocTool-XWRXV3DR.js} +5 -3
  171. package/{readlineWorkspace-XQRDGWRZ.js → readlineWorkspace-J3YD3DNW.js} +2596 -2032
  172. package/{removeDialogAgentAction-J6X5QMTA.js → removeDialogAgentAction-4TEFC3VL.js} +22 -26
  173. package/{runAgentClientLoop-5ZA62FBA.js → runAgentClientLoop-APSMCLAF.js} +79 -72
  174. package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-PIVSBZRZ.js} +4 -4
  175. package/runtimeModeArgs-2Y7BALTO.js +31 -0
  176. package/{setDialogExtraReferencesAction-WX5VTY6O.js → setDialogExtraReferencesAction-LSEN44OY.js} +16 -14
  177. package/{setPrimaryDialogAgentAction-FN22THHT.js → setPrimaryDialogAgentAction-SR366X5A.js} +23 -27
  178. package/{chunk-GP5LKBUZ.js → settingThunks-CTVPPGIN.js} +226 -940
  179. package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
  180. package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
  181. package/{spaceCommands-5GLCWZPO.js → spaceCommands-3UK63WPE.js} +51 -47
  182. package/{streamAgentChatTurn-6UZJMYRB.js → streamAgentChatTurn-DNY2PSRW.js} +215 -115
  183. package/{switchDialogAgentAction-LVTEV3FR.js → switchDialogAgentAction-M6NAFOOU.js} +19 -20
  184. package/{tableCommands-O6NWHFKV.js → tableCommands-6U4BMLRR.js} +10 -10
  185. package/{toolApiClient-QVJ6HDNN.js → toolApiClient-AD7CXTA4.js} +4 -3
  186. package/tools-X5UWATZK.js +117 -0
  187. package/{tuiSummaryLlmCaller-OHHFTHMG.js → tuiSummaryLlmCaller-DEH7ZEM6.js} +25 -23
  188. package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
  189. package/{updateDialogTitleAction-QTKNIURB.js → updateDialogTitleAction-YSY5BF5A.js} +84 -45
  190. package/action-P4TNFGAD.js +0 -31
  191. package/agentListCommands-B2V4YAC4.js +0 -410
  192. package/agentRecordCommands-G4KK4R7H.js +0 -128
  193. package/agentRunCommand-UTZJA23G.js +0 -156
  194. package/browser-image-compression-MFDTD7K6.js +0 -1763
  195. package/chatQueueReduxAdapter-2P6NFX64.js +0 -186
  196. package/chunk-CQ3WA2NE.js +0 -299
  197. package/chunk-M76ECQRD.js +0 -13658
  198. package/chunk-MEYIRKDN.js +0 -8967
  199. package/chunk-PUOC4YRO.js +0 -394
  200. package/chunk-Q5FJJ6XI.js +0 -103
  201. package/chunk-S7Z2HMCN.js +0 -25
  202. package/chunk-T75QD6AB.js +0 -20923
  203. package/chunk-Y5GCAMGP.js +0 -9
  204. package/chunk-YPREESF4.js +0 -225
  205. package/createDialogAction-NGG7YVNU.js +0 -65
  206. package/machineWsRunDispatch-ISBKOOD7.js +0 -144
  207. package/settingSlice-P4ZW7K5X.js +0 -204
  208. package/syncMapping-N6RGXGBW.js +0 -437
  209. package/tools-KMGFWO43.js +0 -110
  210. package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
  211. package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
@@ -0,0 +1,741 @@
1
+ import {
2
+ decorateAgentsWithPublicStatusAcrossServers,
3
+ formatQuotaSummary,
4
+ listFavoriteAgentIdsAcrossServers,
5
+ listLocalCachedAgents,
6
+ listRemoteAgents,
7
+ listRemoteAgentsAcrossServers,
8
+ listRemotePublicAgents,
9
+ normalizeListedAgent,
10
+ parseAgentListArgs
11
+ } from "./chunk-AZOVPTL6.js";
12
+ import {
13
+ buildSpaceLookup,
14
+ getSpaceContentKeys
15
+ } from "./chunk-ID4G2MAR.js";
16
+ import {
17
+ readLiveDbRecordAfterTombstoneMerge
18
+ } from "./chunk-OR2UWD6X.js";
19
+ import {
20
+ applyCredentialAvailability,
21
+ readCredentialAvailability
22
+ } from "./chunk-62IL3KQV.js";
23
+ import {
24
+ getReadableCliDb
25
+ } from "./chunk-LOCNXNOU.js";
26
+ import {
27
+ queryUserRecords,
28
+ readDbRecord
29
+ } from "./chunk-K6L5PNXK.js";
30
+ import "./chunk-KA5O5KQL.js";
31
+ import "./chunk-SV5IJK6K.js";
32
+ import {
33
+ buildAgentDiscoveryResult,
34
+ matchesAgentQuery,
35
+ summarizeCredentialGroups,
36
+ toDiscoverySafeAgentSummary
37
+ } from "./chunk-TBM2RS3U.js";
38
+ import "./chunk-OXME3PEE.js";
39
+ import {
40
+ resolveNoloHome
41
+ } from "./chunk-GLKOYSRU.js";
42
+ import "./chunk-UKZX3NHN.js";
43
+ import "./chunk-CBUMFIFE.js";
44
+ import "./chunk-N4NGJDT6.js";
45
+ import "./chunk-ZNFJWEN4.js";
46
+ import "./chunk-FHLMQIU7.js";
47
+ import "./chunk-GMZLP5DV.js";
48
+ import "./chunk-CHOZJMJS.js";
49
+ import "./chunk-6MAW4XOF.js";
50
+ import "./chunk-5ZUL4CUO.js";
51
+ import "./chunk-N7J63Q6C.js";
52
+ import "./chunk-LBFL6RZG.js";
53
+ import "./chunk-UM7TA3K4.js";
54
+ import "./chunk-SJKULPGX.js";
55
+ import {
56
+ isAgentUnavailableNow
57
+ } from "./chunk-H6A6X4EK.js";
58
+ import "./chunk-2MBTWINN.js";
59
+ import "./chunk-ECFHBYUW.js";
60
+ import {
61
+ normalizeTimingMs
62
+ } from "./chunk-R6EBQEQE.js";
63
+ import "./chunk-5MMAK75Q.js";
64
+ import "./chunk-BYXBJQAS.js";
65
+ import "./chunk-DWLEOOGR.js";
66
+ import "./chunk-2U3NHADM.js";
67
+ import "./chunk-KX6YBIHG.js";
68
+ import "./chunk-PSCNXBYA.js";
69
+ import "./chunk-WDLSZMTA.js";
70
+ import "./chunk-UAD2WT54.js";
71
+ import "./chunk-WPHY3VPF.js";
72
+ import "./chunk-EV235ILT.js";
73
+ import "./chunk-HNGRBWYF.js";
74
+ import "./chunk-HDLLCBRF.js";
75
+ import "./chunk-4VJAC32I.js";
76
+ import "./chunk-IHPDK6UD.js";
77
+ import "./chunk-LWLNLZC5.js";
78
+ import "./chunk-RXA3HAVW.js";
79
+ import "./chunk-KHKTDMYG.js";
80
+ import "./chunk-BIPGGSJS.js";
81
+ import "./chunk-JBKHQOYK.js";
82
+ import "./chunk-CDEEFJXN.js";
83
+ import "./chunk-W7XHHYWM.js";
84
+ import {
85
+ toErrorMessage
86
+ } from "./chunk-HNMXYYJR.js";
87
+ import {
88
+ parseUserIdFromAuthToken,
89
+ readOption,
90
+ resolveAuthToken,
91
+ resolveServerCandidates,
92
+ resolveServerUrl
93
+ } from "./chunk-A7GB5UGH.js";
94
+ import "./chunk-OLZBQWZU.js";
95
+ import "./chunk-Y6ROFCZO.js";
96
+ import {
97
+ getModelAbility
98
+ } from "./chunk-EHSYSKXV.js";
99
+ import "./chunk-SZC4REES.js";
100
+ import "./chunk-QSJ3HFEF.js";
101
+ import "./chunk-ELUDRSRD.js";
102
+ import "./chunk-O7SVKKLY.js";
103
+ import "./chunk-D2MDMY2M.js";
104
+ import "./chunk-I2RGRVQ7.js";
105
+ import "./chunk-M2EJHDJP.js";
106
+ import "./chunk-KUG52IAP.js";
107
+ import {
108
+ createKey,
109
+ createTokenKey
110
+ } from "./chunk-OKGVNZTL.js";
111
+ import "./chunk-WWC7I6TA.js";
112
+ import "./chunk-VY6VFGKR.js";
113
+ import "./chunk-HIM3FCLF.js";
114
+ import "./chunk-OW765XBU.js";
115
+ import "./chunk-SEJ5OS6F.js";
116
+ import "./chunk-U6VC4MU4.js";
117
+ import "./chunk-3EUW3WEO.js";
118
+ import "./chunk-LCBAMY2M.js";
119
+ import "./chunk-4SN6J65J.js";
120
+ import "./chunk-CF7PE763.js";
121
+ import "./chunk-G3SUCT4W.js";
122
+ import "./chunk-4VNS5WPM.js";
123
+
124
+ // packages/ai/agent/speedSampleCache.ts
125
+ var SPEED_SAMPLE_DISK_CACHE_TTL_MS = 10 * 6e4;
126
+ var SPEED_SAMPLE_SCAN_BUDGET_MS = 8e3;
127
+ var SPEED_SAMPLE_CACHE_VERSION = 1;
128
+ var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
129
+ var sanitizeSample = (value) => {
130
+ if (!value || typeof value !== "object") return null;
131
+ const sample = value;
132
+ const clean = {};
133
+ if (isFiniteNumber(sample.firstOutputMs)) clean.firstOutputMs = sample.firstOutputMs;
134
+ if (isFiniteNumber(sample.callDurationMs)) clean.callDurationMs = sample.callDurationMs;
135
+ if (isFiniteNumber(sample.output_tokens)) clean.output_tokens = sample.output_tokens;
136
+ return clean.firstOutputMs === void 0 && clean.callDurationMs === void 0 ? null : clean;
137
+ };
138
+ async function readSpeedSamplesCache(cachePath, options) {
139
+ const ttlMs = isFiniteNumber(options.ttlMs) ? options.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
140
+ try {
141
+ const fs = await import("node:fs/promises");
142
+ const raw = await fs.readFile(cachePath, "utf8");
143
+ const parsed = JSON.parse(raw);
144
+ if (!parsed || typeof parsed !== "object") return null;
145
+ if (parsed.version !== SPEED_SAMPLE_CACHE_VERSION) return null;
146
+ if (parsed.userId !== options.userId) return null;
147
+ if (!isFiniteNumber(parsed.at)) return null;
148
+ const age = options.now - parsed.at;
149
+ if (age < 0 || age >= ttlMs) return null;
150
+ const samples = /* @__PURE__ */ new Map();
151
+ const source = parsed.samples;
152
+ if (!source || typeof source !== "object") return null;
153
+ for (const [model, list] of Object.entries(source)) {
154
+ if (!model || !Array.isArray(list)) continue;
155
+ const cleaned = [];
156
+ for (const entry of list) {
157
+ const sample = sanitizeSample(entry);
158
+ if (sample) cleaned.push(sample);
159
+ }
160
+ samples.set(model, cleaned);
161
+ }
162
+ return samples;
163
+ } catch {
164
+ return null;
165
+ }
166
+ }
167
+ async function writeSpeedSamplesCache(cachePath, payload) {
168
+ try {
169
+ const fs = await import("node:fs/promises");
170
+ const path2 = await import("node:path");
171
+ await fs.mkdir(path2.dirname(cachePath), { recursive: true });
172
+ await fs.writeFile(cachePath, JSON.stringify(payload), "utf8");
173
+ } catch {
174
+ }
175
+ }
176
+
177
+ // packages/ai/token/observedSpeedResolver.ts
178
+ var DEFAULT_OBSERVED_SPEED_SAMPLE_SIZE = 20;
179
+ var MIN_THROUGHPUT_WINDOW_MS = 200;
180
+ var MAX_PLAUSIBLE_OUTPUT_TPS = 3e3;
181
+ var isFiniteNumber2 = (value) => typeof value === "number" && Number.isFinite(value);
182
+ var medianOf = (values) => {
183
+ if (values.length === 0) return void 0;
184
+ const sorted = [...values].sort((a, b) => a - b);
185
+ const middle = Math.floor(sorted.length / 2);
186
+ return sorted.length % 2 === 1 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
187
+ };
188
+ function resolveObservedSpeed(records, options = {}) {
189
+ const limit = isFiniteNumber2(options.limit) ? Math.max(0, Math.floor(options.limit)) : DEFAULT_OBSERVED_SPEED_SAMPLE_SIZE;
190
+ const sample = Array.isArray(records) ? records.slice(0, limit) : [];
191
+ const firstOutputSamples = [];
192
+ const tpsSamples = [];
193
+ for (const record of sample) {
194
+ if (!record || typeof record !== "object") continue;
195
+ const { firstOutputMs, callDurationMs, output_tokens: outputTokens } = record;
196
+ const firstOutput = normalizeTimingMs(firstOutputMs);
197
+ const callDuration = normalizeTimingMs(callDurationMs);
198
+ if (firstOutput !== void 0) {
199
+ firstOutputSamples.push(firstOutput);
200
+ }
201
+ if (firstOutput !== void 0 && callDuration !== void 0 && callDuration - firstOutput >= MIN_THROUGHPUT_WINDOW_MS && isFiniteNumber2(outputTokens) && outputTokens > 0) {
202
+ const seconds = (callDuration - firstOutput) / 1e3;
203
+ const tokensPerSecond = outputTokens / seconds;
204
+ if (isFiniteNumber2(tokensPerSecond) && tokensPerSecond <= MAX_PLAUSIBLE_OUTPUT_TPS) {
205
+ tpsSamples.push(tokensPerSecond);
206
+ }
207
+ }
208
+ }
209
+ const medianFirstOutputMs = medianOf(firstOutputSamples);
210
+ const medianTps = medianOf(tpsSamples);
211
+ return {
212
+ firstOutputSampleCount: firstOutputSamples.length,
213
+ throughputSampleCount: tpsSamples.length,
214
+ ...medianFirstOutputMs !== void 0 ? { medianFirstOutputMs: Math.round(medianFirstOutputMs) } : {},
215
+ ...medianTps !== void 0 ? { medianOutputTokensPerSecond: Math.round(medianTps * 100) / 100 } : {}
216
+ };
217
+ }
218
+
219
+ // packages/ai/agent/candidateSpeedContext.ts
220
+ var OBSERVED_SPEED_WINDOW = 50;
221
+ var MIN_OBSERVED_FIRST_OUTPUT_SAMPLES = 5;
222
+ var SPEED_SAMPLES_CACHE_TTL_MS = 5 * 6e4;
223
+ var SPEED_SAMPLES_CACHE_MAX_ENTRIES = 500;
224
+ var MAX_PLAUSIBLE_AA_FIRST_ANSWER_S = 60;
225
+ function normalizeSpeedModelName(raw) {
226
+ const name = raw.trim().toLowerCase();
227
+ const slash = name.lastIndexOf("/");
228
+ return slash === -1 ? name : name.slice(slash + 1);
229
+ }
230
+ var isFiniteNumber3 = (value) => typeof value === "number" && Number.isFinite(value);
231
+ var REASONING_EFFORT_SUFFIXES = ["minimal", "low", "medium", "high", "xhigh"];
232
+ var REASONING_EFFORT_SUFFIX_RE = new RegExp(`-(?:${REASONING_EFFORT_SUFFIXES.join("|")})$`);
233
+ function stripReasoningEffortSuffix(model) {
234
+ const base = model.replace(REASONING_EFFORT_SUFFIX_RE, "");
235
+ return base && base !== model ? base : null;
236
+ }
237
+ function resolveOneBare(model, samplesByModel) {
238
+ const observed = resolveObservedSpeed(samplesByModel.get(model) ?? [], {
239
+ limit: OBSERVED_SPEED_WINDOW
240
+ });
241
+ if (observed.firstOutputSampleCount >= MIN_OBSERVED_FIRST_OUTPUT_SAMPLES && observed.medianFirstOutputMs !== void 0) {
242
+ return {
243
+ source: "observed",
244
+ firstOutputMs: observed.medianFirstOutputMs,
245
+ ...observed.medianOutputTokensPerSecond !== void 0 ? { outputTps: observed.medianOutputTokensPerSecond } : {},
246
+ firstOutputSamples: observed.firstOutputSampleCount,
247
+ tpsSamples: observed.throughputSampleCount
248
+ };
249
+ }
250
+ const aa = getModelAbility(model)?.aaSnapshot;
251
+ if (!aa) return null;
252
+ const firstAnswerTokenS = isFiniteNumber3(aa.firstAnswerTokenS) && aa.firstAnswerTokenS <= MAX_PLAUSIBLE_AA_FIRST_ANSWER_S ? aa.firstAnswerTokenS : void 0;
253
+ if (!isFiniteNumber3(aa.outputSpeedTps) && firstAnswerTokenS === void 0) {
254
+ return null;
255
+ }
256
+ return {
257
+ source: "aa",
258
+ ...firstAnswerTokenS !== void 0 ? { firstAnswerTokenS } : {},
259
+ ...isFiniteNumber3(aa.outputSpeedTps) ? { outputTps: aa.outputSpeedTps } : {},
260
+ measuredAt: aa.measuredAt
261
+ };
262
+ }
263
+ function resolveOne(model, samplesByModel) {
264
+ const direct = resolveOneBare(model, samplesByModel);
265
+ if (direct) return { model, ...direct };
266
+ const base = stripReasoningEffortSuffix(model);
267
+ if (!base) return null;
268
+ const stripped = resolveOneBare(base, samplesByModel);
269
+ return stripped ? { model, ...stripped } : null;
270
+ }
271
+ function resolveCandidateSpeedFacts(models, samplesByModel) {
272
+ const unique = [
273
+ ...new Set(
274
+ models.filter((model) => typeof model === "string").map(normalizeSpeedModelName).filter(Boolean)
275
+ )
276
+ ];
277
+ return unique.map((model) => resolveOne(model, samplesByModel)).filter((fact) => fact !== null);
278
+ }
279
+ var formatSeconds = (ms) => `${(ms / 1e3).toFixed(1)}s`;
280
+ var formatTps = (tps) => String(Math.round(tps));
281
+ 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):";
282
+ function formatCandidateSpeedFacts(facts) {
283
+ if (facts.length === 0) return null;
284
+ const lines = facts.map((fact) => {
285
+ if (fact.source === "observed") {
286
+ const tps = fact.outputTps !== void 0 ? formatTps(fact.outputTps) : "n/a";
287
+ return ` ${fact.model}: firstOutput=${formatSeconds(fact.firstOutputMs ?? 0)} tps=${tps} [observed n=${fact.firstOutputSamples ?? 0} tpsN=${fact.tpsSamples ?? 0}]`;
288
+ }
289
+ const parts = [];
290
+ if (fact.firstAnswerTokenS !== void 0) parts.push(`firstAnswer=${fact.firstAnswerTokenS.toFixed(1)}s`);
291
+ parts.push(`tps=${fact.outputTps !== void 0 ? formatTps(fact.outputTps) : "n/a"}`);
292
+ return ` ${fact.model}: ${parts.join(" ")} [aa measuredAt=${fact.measuredAt}]`;
293
+ });
294
+ return `${SPEED_CONTEXT_HEADER}
295
+ ${lines.join("\n")}`;
296
+ }
297
+ function buildCandidateSpeedContext(models, samplesByModel) {
298
+ return formatCandidateSpeedFacts(resolveCandidateSpeedFacts(models, samplesByModel));
299
+ }
300
+ var SPEED_SAMPLE_PAGE_SIZE = 2e3;
301
+ var eventTime = (value) => {
302
+ if (isFiniteNumber3(value.timestamp)) return value.timestamp;
303
+ if (isFiniteNumber3(value.createdAt)) return value.createdAt;
304
+ return 0;
305
+ };
306
+ function collectSample(collected, value) {
307
+ if (typeof value.model !== "string") return;
308
+ if (!isFiniteNumber3(value.firstOutputMs) && !isFiniteNumber3(value.callDurationMs)) return;
309
+ const model = normalizeSpeedModelName(value.model);
310
+ if (!model) return;
311
+ const list = collected.get(model) ?? [];
312
+ list.push({
313
+ t: eventTime(value),
314
+ firstOutputMs: value.firstOutputMs,
315
+ callDurationMs: value.callDurationMs,
316
+ output_tokens: value.output_tokens
317
+ });
318
+ collected.set(model, list);
319
+ }
320
+ function finalizeSamples(collected) {
321
+ const result = /* @__PURE__ */ new Map();
322
+ for (const [model, list] of collected) {
323
+ list.sort((a, b) => b.t - a.t);
324
+ result.set(
325
+ model,
326
+ list.slice(0, OBSERVED_SPEED_WINDOW).map(({ t: _t, ...sample }) => sample)
327
+ );
328
+ }
329
+ return result;
330
+ }
331
+ async function collectRecentSpeedSamples(db, userId, options = {}) {
332
+ const pageSize = isFiniteNumber3(options.pageSize) && options.pageSize > 0 ? Math.floor(options.pageSize) : SPEED_SAMPLE_PAGE_SIZE;
333
+ const budgetMs = isFiniteNumber3(options.budgetMs) ? options.budgetMs : Number.POSITIVE_INFINITY;
334
+ const { start, end } = createTokenKey.rangeOfUser(userId);
335
+ const failedPrefix = createKey("token", userId, "failed-call", "");
336
+ const collected = /* @__PURE__ */ new Map();
337
+ const startedAt = Date.now();
338
+ let lastKey;
339
+ let budgetExhausted = false;
340
+ while (true) {
341
+ if (Date.now() - startedAt >= budgetMs) {
342
+ budgetExhausted = true;
343
+ break;
344
+ }
345
+ const pageOptions = {
346
+ ...lastKey === void 0 ? { gte: start } : { gt: lastKey },
347
+ lte: end,
348
+ limit: pageSize
349
+ };
350
+ let accepted = 0;
351
+ let newestKey = lastKey;
352
+ for await (const [key, raw] of db.iterator(pageOptions)) {
353
+ if (typeof key !== "string") continue;
354
+ if (lastKey !== void 0 && key <= lastKey) continue;
355
+ accepted += 1;
356
+ newestKey = key;
357
+ if (key.startsWith(failedPrefix)) continue;
358
+ if (!raw || typeof raw !== "object") continue;
359
+ collectSample(collected, raw);
360
+ }
361
+ if (accepted === 0 || accepted < pageSize) break;
362
+ lastKey = newestKey;
363
+ }
364
+ return { samples: finalizeSamples(collected), budgetExhausted };
365
+ }
366
+ async function loadRecentSpeedSamples(db, userId, options = {}) {
367
+ const { samples } = await collectRecentSpeedSamples(db, userId, options);
368
+ return samples;
369
+ }
370
+ async function loadSpeedSamplesWithDiskCache(db, userId, now, cache) {
371
+ try {
372
+ const ttlMs = isFiniteNumber3(cache.ttlMs) ? cache.ttlMs : SPEED_SAMPLE_DISK_CACHE_TTL_MS;
373
+ const cached = await readSpeedSamplesCache(cache.cachePath, { userId, now, ttlMs });
374
+ if (cached) return cached;
375
+ const { samples, budgetExhausted } = await collectRecentSpeedSamples(db, userId, {
376
+ pageSize: cache.pageSize,
377
+ budgetMs: isFiniteNumber3(cache.budgetMs) ? cache.budgetMs : SPEED_SAMPLE_SCAN_BUDGET_MS
378
+ });
379
+ if (budgetExhausted) return /* @__PURE__ */ new Map();
380
+ await writeSpeedSamplesCache(cache.cachePath, {
381
+ version: SPEED_SAMPLE_CACHE_VERSION,
382
+ userId,
383
+ at: now,
384
+ samples: Object.fromEntries(samples)
385
+ });
386
+ return samples;
387
+ } catch {
388
+ return /* @__PURE__ */ new Map();
389
+ }
390
+ }
391
+ var samplesCache = /* @__PURE__ */ new Map();
392
+ function writeSamplesCache(userId, now, samples) {
393
+ for (const [key, entry] of samplesCache) {
394
+ if (now - entry.at >= SPEED_SAMPLES_CACHE_TTL_MS) samplesCache.delete(key);
395
+ }
396
+ samplesCache.delete(userId);
397
+ samplesCache.set(userId, { at: now, samples });
398
+ while (samplesCache.size > SPEED_SAMPLES_CACHE_MAX_ENTRIES) {
399
+ const oldest = samplesCache.keys().next().value;
400
+ if (oldest === void 0) break;
401
+ samplesCache.delete(oldest);
402
+ }
403
+ }
404
+ async function loadCachedSpeedSamples(db, userId, now) {
405
+ const hit = samplesCache.get(userId);
406
+ if (hit && now - hit.at < SPEED_SAMPLES_CACHE_TTL_MS) return hit.samples;
407
+ const samples = await loadRecentSpeedSamples(db, userId);
408
+ writeSamplesCache(userId, now, samples);
409
+ return samples;
410
+ }
411
+ async function injectSpeedContextIntoListAgentsResult(result, options = {}) {
412
+ try {
413
+ let parsed;
414
+ try {
415
+ parsed = JSON.parse(result);
416
+ } catch {
417
+ return result;
418
+ }
419
+ if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.agents)) return result;
420
+ const models = parsed.agents.map((agent) => agent?.model).filter((model) => typeof model === "string");
421
+ if (models.length === 0) return result;
422
+ const now = options.now ?? Date.now();
423
+ let samples = /* @__PURE__ */ new Map();
424
+ const userId = typeof options.userId === "string" ? options.userId.trim() : "";
425
+ if (options.db && userId) {
426
+ try {
427
+ samples = options.diskCache ? await loadSpeedSamplesWithDiskCache(options.db, userId, now, options.diskCache) : await loadCachedSpeedSamples(options.db, userId, now);
428
+ } catch {
429
+ samples = /* @__PURE__ */ new Map();
430
+ }
431
+ }
432
+ const speedContext = buildCandidateSpeedContext(models, samples);
433
+ return speedContext ? JSON.stringify({ ...parsed, speedContext }) : result;
434
+ } catch {
435
+ return result;
436
+ }
437
+ }
438
+
439
+ // packages/cli/agentListCommands.ts
440
+ import path from "node:path";
441
+ var discardOutput = { write: () => void 0 };
442
+ function resolveSpeedSamplesCachePath(env, userId) {
443
+ const safeUserId = userId.replace(/[^A-Za-z0-9._-]/g, "_");
444
+ const mergedEnv = { ...process.env, ...env };
445
+ return path.join(resolveNoloHome({ env: mergedEnv }), "cache", `speed-samples-${safeUserId}.json`);
446
+ }
447
+ async function runAgentListCommand(args, deps = {}) {
448
+ const env = deps.env ?? process.env;
449
+ const output = deps.output ?? process.stdout;
450
+ const { wantJson, wantSafe, publicOnly, scope: requestedScope, idsOnly, showUnavailable, verbose, query } = parseAgentListArgs(args);
451
+ if (requestedScope && !["preferred", "public", "all"].includes(requestedScope)) {
452
+ throw new Error(`Invalid scope '${requestedScope}'`);
453
+ }
454
+ if (requestedScope && publicOnly && requestedScope !== "public") {
455
+ throw new Error(`Conflicting arguments: scope='${requestedScope}' conflicts with publicOnly=true.`);
456
+ }
457
+ const scope = requestedScope ?? "preferred";
458
+ const spaceInput = readOption(args, "--space") ?? readOption(args, "--space-id");
459
+ const authToken = resolveAuthToken(args, env);
460
+ if (!authToken) {
461
+ output.write("[nolo] agent list requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
462
+ return 1;
463
+ }
464
+ const userId = parseUserIdFromAuthToken(authToken);
465
+ if (!userId) {
466
+ output.write("[nolo] agent list could not read userId from AUTH_TOKEN.\n");
467
+ return 1;
468
+ }
469
+ const fetchImpl = deps.fetchImpl ?? fetch;
470
+ const fallbackFetchImpl = deps.fallbackFetchImpl;
471
+ const serverUrl = resolveServerUrl(args, env);
472
+ const serverUrls = resolveServerCandidates(args, env, serverUrl);
473
+ try {
474
+ let agents;
475
+ let source;
476
+ let serverFailures = [];
477
+ try {
478
+ const remoteResult = await listRemoteAgentsAcrossServers({
479
+ authToken,
480
+ fallbackFetchImpl,
481
+ fetchImpl,
482
+ serverUrls,
483
+ userId
484
+ });
485
+ agents = remoteResult.agents;
486
+ serverFailures = remoteResult.failures;
487
+ source = "global-cache";
488
+ } catch {
489
+ try {
490
+ const db = deps.db ?? await getReadableCliDb(output);
491
+ agents = await listLocalCachedAgents({ db, userId });
492
+ source = "local-cache";
493
+ } catch {
494
+ agents = await listRemoteAgents({
495
+ authToken,
496
+ fallbackFetchImpl,
497
+ fetchImpl,
498
+ serverUrl,
499
+ userId,
500
+ queryUserRecords,
501
+ readDbRecord
502
+ });
503
+ source = "remote-cache";
504
+ }
505
+ }
506
+ if (scope !== "preferred") {
507
+ const publicAgents = await Promise.all(serverUrls.map((url) => listRemotePublicAgents({
508
+ authToken,
509
+ fetchImpl,
510
+ serverUrl: url,
511
+ limit: 500
512
+ })));
513
+ agents = publicAgents.flat();
514
+ if (scope === "all") {
515
+ const preferred = await listRemoteAgentsAcrossServers({
516
+ authToken,
517
+ fallbackFetchImpl,
518
+ fetchImpl,
519
+ serverUrls,
520
+ userId
521
+ });
522
+ agents = [...preferred.agents, ...agents];
523
+ }
524
+ }
525
+ agents = agents.filter((agent) => agent.privateKey.startsWith("agent-"));
526
+ let resolvedSpaceId = null;
527
+ let spaceContentKeys = null;
528
+ if (spaceInput) {
529
+ const { spaceId, spaceKey } = buildSpaceLookup(spaceInput);
530
+ resolvedSpaceId = spaceId;
531
+ const spaceRead = await readLiveDbRecordAfterTombstoneMerge({
532
+ authToken,
533
+ dbKey: spaceKey,
534
+ fallbackFetchImpl,
535
+ fetchImpl,
536
+ serverUrls
537
+ });
538
+ serverFailures = [...serverFailures, ...spaceRead.failures];
539
+ const spaceRecord = spaceRead.record;
540
+ const currentSpaceContentKeys = getSpaceContentKeys(spaceRecord);
541
+ spaceContentKeys = currentSpaceContentKeys;
542
+ agents = agents.filter(
543
+ (agent) => currentSpaceContentKeys.has(agent.privateKey) || currentSpaceContentKeys.has(agent.publicKey) || currentSpaceContentKeys.has(agent.id)
544
+ );
545
+ }
546
+ if (source === "global-cache") {
547
+ await decorateAgentsWithPublicStatusAcrossServers({
548
+ agents,
549
+ authToken,
550
+ fallbackFetchImpl,
551
+ fetchImpl,
552
+ serverUrls
553
+ });
554
+ }
555
+ if (publicOnly) {
556
+ agents = agents.filter((agent) => agent.publicRecordExists);
557
+ }
558
+ agents = applyCredentialAvailability(
559
+ agents,
560
+ await readCredentialAvailability(env).catch(() => ({}))
561
+ );
562
+ const unavailableCount = agents.filter((agent) => isAgentUnavailableNow(agent)).length;
563
+ let agentsForOutput = showUnavailable ? agents : agents.filter((agent) => !isAgentUnavailableNow(agent));
564
+ if (query && typeof query === "string" && query.trim()) {
565
+ agentsForOutput = agentsForOutput.filter((agent) => matchesAgentQuery(agent, query));
566
+ }
567
+ if (idsOnly) {
568
+ output.write(`${agentsForOutput.map((agent) => agent.id).join("\n")}
569
+ `);
570
+ return 0;
571
+ }
572
+ if (wantSafe) {
573
+ const favoritesMap = await listFavoriteAgentIdsAcrossServers({
574
+ authToken,
575
+ fetchImpl,
576
+ serverUrls
577
+ }).catch(() => ({}));
578
+ const existingKeys = /* @__PURE__ */ new Set();
579
+ for (const agent of agents) {
580
+ existingKeys.add(agent.privateKey);
581
+ existingKeys.add(agent.publicKey);
582
+ existingKeys.add(agent.id);
583
+ }
584
+ const extraFavoriteRecords = [];
585
+ const hydratedFavoriteAgents = [];
586
+ for (const favKey of Object.keys(favoritesMap)) {
587
+ if (existingKeys.has(favKey)) continue;
588
+ try {
589
+ const favRead = await readLiveDbRecordAfterTombstoneMerge({
590
+ authToken,
591
+ dbKey: favKey,
592
+ fallbackFetchImpl,
593
+ fetchImpl,
594
+ serverUrls
595
+ });
596
+ const record = favRead.record;
597
+ if (!record || record.type && record.type !== "agent") continue;
598
+ const norm = normalizeListedAgent(record);
599
+ const candidateKeys = [record.dbKey, record.publicKey, record.id].filter((key) => typeof key === "string" && key.length > 0);
600
+ if (spaceContentKeys && !candidateKeys.some((key) => spaceContentKeys?.has(key))) {
601
+ continue;
602
+ }
603
+ if (norm) {
604
+ if (!favKey.startsWith("agent-pub-")) {
605
+ norm.verifiedAgentKey = favKey;
606
+ if (typeof record.userId === "string" && record.userId) {
607
+ norm.ownerId = record.userId;
608
+ }
609
+ }
610
+ agents.push(norm);
611
+ hydratedFavoriteAgents.push(norm);
612
+ existingKeys.add(norm.privateKey);
613
+ existingKeys.add(norm.publicKey);
614
+ existingKeys.add(norm.id);
615
+ } else {
616
+ extraFavoriteRecords.push(record);
617
+ for (const key of candidateKeys) existingKeys.add(key);
618
+ }
619
+ } catch {
620
+ }
621
+ }
622
+ if (source === "global-cache" && hydratedFavoriteAgents.length > 0) {
623
+ await decorateAgentsWithPublicStatusAcrossServers({
624
+ agents: hydratedFavoriteAgents,
625
+ authToken,
626
+ fallbackFetchImpl,
627
+ fetchImpl,
628
+ serverUrls
629
+ });
630
+ }
631
+ const safeRecords = [...agents, ...extraFavoriteRecords].map((record) => toDiscoverySafeAgentSummary(record, { favoritesMap, userId })).filter((agent) => publicOnly ? agent.isPublic === true : true);
632
+ const discovery = buildAgentDiscoveryResult({
633
+ agents: safeRecords,
634
+ scope: "all",
635
+ query,
636
+ showUnavailable,
637
+ verbose
638
+ });
639
+ const listResult = JSON.stringify({
640
+ success: true,
641
+ userId,
642
+ ...resolvedSpaceId ? { spaceId: resolvedSpaceId } : {},
643
+ total: discovery.total,
644
+ unavailableCount: discovery.unavailableCount,
645
+ unavailableAgents: discovery.unavailableAgents,
646
+ credentialGroups: discovery.credentialGroups,
647
+ agents: discovery.agents
648
+ }, null, 2);
649
+ const withSpeedContext = await injectSpeedContextIntoListAgentsResult(listResult, {
650
+ db: deps.db ?? await getReadableCliDb(discardOutput),
651
+ userId,
652
+ diskCache: { cachePath: resolveSpeedSamplesCachePath(env, userId) }
653
+ });
654
+ output.write(withSpeedContext);
655
+ output.write("\n");
656
+ return 0;
657
+ }
658
+ if (wantJson) {
659
+ const credentialGroups = summarizeCredentialGroups(agentsForOutput);
660
+ output.write(JSON.stringify({
661
+ userId,
662
+ ...resolvedSpaceId ? { spaceId: resolvedSpaceId } : {},
663
+ targetServers: serverUrls,
664
+ ...serverFailures.length ? { serverFailures } : {},
665
+ total: agentsForOutput.length,
666
+ publicCount: agentsForOutput.filter((agent) => agent.publicRecordExists).length,
667
+ unavailableCount,
668
+ credentialGroups,
669
+ source,
670
+ agents: agentsForOutput
671
+ }, null, 2));
672
+ output.write("\n");
673
+ return 0;
674
+ }
675
+ output.write(`userId: ${userId}
676
+ `);
677
+ if (resolvedSpaceId) {
678
+ output.write(`spaceId: ${resolvedSpaceId}
679
+ `);
680
+ }
681
+ output.write(`targetServers: ${serverUrls.join(", ")}
682
+ `);
683
+ if (serverFailures.length) {
684
+ output.write(`serverFailures: ${serverFailures.length}
685
+ `);
686
+ }
687
+ output.write(`total agents: ${agentsForOutput.length}
688
+ `);
689
+ output.write(`public agents: ${agentsForOutput.filter((agent) => agent.publicRecordExists).length}
690
+ `);
691
+ if (unavailableCount > 0 && !showUnavailable) {
692
+ output.write(`\u26D4 ${unavailableCount} agent(s) temporarily unavailable (429) hidden. Use --show-unavailable to list them.
693
+ `);
694
+ }
695
+ output.write(`source: ${source}
696
+ `);
697
+ if (agentsForOutput.length === 0) {
698
+ output.write("\n(no agents found)\n");
699
+ return 0;
700
+ }
701
+ for (const agent of agentsForOutput) {
702
+ const status = agent.publicRecordExists ? "public" : "private";
703
+ const flagMismatch = agent.isPublicFlag !== agent.publicRecordExists ? ` flag=${agent.isPublicFlag}` : "";
704
+ const credentialLine = agent.credentialConfigured ? `credentialConfigured=true${agent.credentialRef ? ` credentialRef=${agent.credentialRef}` : ""}${agent.apiKeyRef ? ` apiKeyRef=${agent.apiKeyRef}` : ""}` : "credentialConfigured=false";
705
+ const availabilityLine = typeof agent.nextAvailableAt === "number" && agent.nextAvailableAt > Date.now() ? `nextAvailableAt=${new Date(agent.nextAvailableAt).toISOString()}` : "nextAvailableAt=now";
706
+ const quotaSummary = formatQuotaSummary(agent.quota);
707
+ const quotaLine = `quota=${quotaSummary ?? "-"}`;
708
+ output.write(
709
+ [
710
+ `
711
+ [${status}] ${agent.name}`,
712
+ `id=${agent.id}`,
713
+ `type=${agent.type ?? "-"}`,
714
+ `model=${agent.model}`,
715
+ `updatedAt=${agent.updatedAt ?? "-"}`,
716
+ // 不输出 privateKey(dbKey 属敏感标识,与 web 端 listAgentsFunc 降权
717
+ // 对齐;需要完整记录请用 --json)。
718
+ // 私有 agent(publicRecordExists=false)的公开记录不存在,输出 "-" 而非
719
+ // 一个库里不存在的 agent-pub-<id>,避免误导调用方拿它去 readAgent。
720
+ `publicKey=${agent.publicRecordExists ? agent.publicKey : "-"}${flagMismatch}`,
721
+ `tools=${agent.tools.join(", ") || "-"}`,
722
+ credentialLine,
723
+ availabilityLine,
724
+ quotaLine
725
+ ].join("\n")
726
+ );
727
+ output.write("\n");
728
+ }
729
+ return 0;
730
+ } catch (error) {
731
+ output.write(
732
+ `[nolo] agent list failed: ${toErrorMessage(error)}
733
+ `
734
+ );
735
+ return 1;
736
+ }
737
+ }
738
+ export {
739
+ resolveSpeedSamplesCachePath,
740
+ runAgentListCommand
741
+ };