nolo-cli 0.97.0-alpha.2 → 0.97.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 (182) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-G2MRKK2K.js → _executeModel-DYHTQJZC.js} +68 -63
  3. package/{action-YVYQEAAV.js → action-GI44T4DR.js} +10 -10
  4. package/{addContentAction-O7R66HEX.js → addContentAction-B2DRF7P6.js} +9 -9
  5. package/{addDialogAgentAction-74OA7KYP.js → addDialogAgentAction-T3I7IXPK.js} +15 -17
  6. package/{agentDeleteCommand-4427YKQF.js → agentDeleteCommand-LLNNP3AM.js} +47 -43
  7. package/{agentEmailCommands-RNBKKO7Q.js → agentEmailCommands-MQOP76DK.js} +90 -82
  8. package/agentListCommands-J3MWAZWO.js +741 -0
  9. package/{agentMachineCommands-FOFX5S2Q.js → agentMachineCommands-EQIRKAZO.js} +42 -38
  10. package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-EMZCM6VA.js} +1 -1
  11. package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-HF4A42D4.js} +1 -1
  12. package/agentRecordCommands-7MQRBMWZ.js +136 -0
  13. package/{agentRunCommand-2W3Q3A7M.js → agentRunCommand-H6BYSTJ7.js} +90 -80
  14. package/{agentRunControl-WCTKX5VL.js → agentRunControl-2TTTUTSW.js} +2 -2
  15. package/{agentRuntimeLocal-IW3IM5P6.js → agentRuntimeLocal-AY6YNUAL.js} +44 -36
  16. package/{agentSlice-SK47GTN7.js → agentSlice-FOZUXW7X.js} +11 -11
  17. package/{appDeleteCommands-ZXLXNRHF.js → appDeleteCommands-QTTL3QF3.js} +42 -38
  18. package/{appDeployCommands-PWB4YERK.js → appDeployCommands-43LJECGV.js} +42 -38
  19. package/{appDeployStatusCommands-2EZKZP7Y.js → appDeployStatusCommands-L5BKOLYW.js} +42 -38
  20. package/{appGetCommands-JNUKOWHO.js → appGetCommands-HOFZKOPC.js} +42 -38
  21. package/{appListCommands-6X3H67SS.js → appListCommands-I7C3SJCE.js} +42 -38
  22. package/{authCommand-F4EFRRX6.js → authCommand-2YPMMIJN.js} +117 -23
  23. package/{authCommands-RGOGCPP6.js → authCommands-FFDS4FVX.js} +7 -5
  24. package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-CALVIJTX.js} +6 -5
  25. package/{chatQueueReduxAdapter-ZJ555AT2.js → chatQueueReduxAdapter-NMEZRYC2.js} +30 -29
  26. package/{chromeCommands-FZYAU75D.js → chromeCommands-K27J4OVZ.js} +124 -28
  27. package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-IXRLN57H.js} +4 -3
  28. package/{chunk-6OZ36FXI.js → chunk-27ONFIEY.js} +22 -4
  29. package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
  30. package/{chunk-YQTQQX2H.js → chunk-2UV22D2F.js} +1 -1
  31. package/{chunk-7D6Z6AA4.js → chunk-3BFMH6GE.js} +6 -7
  32. package/{chunk-OIVSQH2O.js → chunk-3BXNTXYI.js} +299 -5
  33. package/{chunk-QIAVMDHY.js → chunk-3LX6YE3P.js} +4 -4
  34. package/{chunk-EYAQT56M.js → chunk-4DPP773Q.js} +2 -2
  35. package/chunk-4LCOCOR5.js +50 -0
  36. package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
  37. package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
  38. package/{chunk-E4MARS3Q.js → chunk-5GVBDNTO.js} +1 -1
  39. package/chunk-5J3PYNUP.js +255 -0
  40. package/chunk-5MMAK75Q.js +15 -0
  41. package/{chunk-JPGCXHNM.js → chunk-5OA5HMTL.js} +1 -1
  42. package/{chunk-42V6BK2E.js → chunk-62IL3KQV.js} +4 -34
  43. package/{chunk-6YTOJY35.js → chunk-6D2JFXLY.js} +35 -0
  44. package/{chunk-3BMYXEUW.js → chunk-6O4IK4V2.js} +1 -1
  45. package/{chunk-IIVGDG4I.js → chunk-6PHKBY2Q.js} +10 -4
  46. package/{chunk-ASQYTZTR.js → chunk-6ZWMH6TJ.js} +69 -36
  47. package/{chunk-ABQYVJBJ.js → chunk-7CHC4W22.js} +1 -1
  48. package/{chunk-GQBOR3G6.js → chunk-7KVZ5LDQ.js} +2 -2
  49. package/{chunk-SDTTBMBU.js → chunk-7WCQEMPB.js} +888 -1079
  50. package/{chunk-BLJWCTRL.js → chunk-AOPCEXTB.js} +1 -1
  51. package/{chunk-WGR3J4Q6.js → chunk-APMUYAPK.js} +17 -4
  52. package/{chunk-Q554LLSI.js → chunk-AUDNYVRC.js} +1 -1
  53. package/{chunk-RG6JBBX5.js → chunk-AWF3WO5R.js} +166 -13
  54. package/{chunk-GPCZ7UXG.js → chunk-AZRHIN5B.js} +1 -1
  55. package/chunk-BMQ2MJUK.js +153 -0
  56. package/{chunk-B4ZH7KVO.js → chunk-C3VLSD4K.js} +236 -36
  57. package/{chunk-4EZHSKTB.js → chunk-C53ZG23R.js} +2 -2
  58. package/chunk-CHOZJMJS.js +78 -0
  59. package/{chunk-HJUYAD4A.js → chunk-CPUFH46E.js} +8 -8
  60. package/{chunk-LS2ZANRJ.js → chunk-CTUQJVQM.js} +1 -1
  61. package/{chunk-BP4XNZRM.js → chunk-CU3QB4HW.js} +3 -3
  62. package/{chunk-ACTMNVHM.js → chunk-CYSYR67N.js} +1 -1
  63. package/{chunk-KQ4ONNQD.js → chunk-DAWDCRIG.js} +82 -8
  64. package/{chunk-VLTIYV3X.js → chunk-DCLMZ5TX.js} +4 -4
  65. package/{chunk-UKZDAFYT.js → chunk-DSSTTEKI.js} +6 -10
  66. package/{chunk-L7I247DF.js → chunk-EKS2APRJ.js} +21 -5
  67. package/{chunk-HVURBGF3.js → chunk-ESRMFY7G.js} +2 -2
  68. package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
  69. package/chunk-GMZLP5DV.js +82 -0
  70. package/{chunk-FDTR4QJ6.js → chunk-H6A6X4EK.js} +32 -1
  71. package/{chunk-DVINR3PL.js → chunk-HDLLCBRF.js} +1 -1
  72. package/{chunk-OIMN34NA.js → chunk-HKTIX4ZE.js} +23 -76
  73. package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
  74. package/{chunk-H62HCIUP.js → chunk-HYZIYH2H.js} +11 -10
  75. package/{chunk-3VNWWVKB.js → chunk-I3QNET24.js} +30 -17
  76. package/{chunk-WV42OMV7.js → chunk-IAESIMK7.js} +4 -4
  77. package/chunk-JBOO3DKI.js +7808 -0
  78. package/{chunk-O35EJJVP.js → chunk-JJ7P5CIY.js} +56 -34
  79. package/{chunk-OZPMVBJI.js → chunk-JZ5II5UV.js} +15 -20
  80. package/{chunk-JRQFUXY7.js → chunk-KCDUTE5V.js} +96 -19
  81. package/{chunk-QLNJRTKI.js → chunk-KHVJXNRY.js} +100 -100
  82. package/{chunk-ADTY7BWR.js → chunk-L76GP4ER.js} +24 -5
  83. package/{chunk-7S4YWN7P.js → chunk-MX574M24.js} +1 -1
  84. package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
  85. package/{chunk-53HEEOTT.js → chunk-O26PCYLS.js} +80 -13
  86. package/{chunk-3DII57IT.js → chunk-O2OWEFII.js} +1 -1
  87. package/{chunk-TDRTS7QW.js → chunk-O6JPWEEK.js} +77 -17
  88. package/chunk-OCZKATRC.js +129 -0
  89. package/{chunk-6D6VBVEW.js → chunk-OTEMQQZI.js} +80 -14
  90. package/chunk-P6GMCCAT.js +870 -0
  91. package/{chunk-3SK4LEIH.js → chunk-PLRLUZWS.js} +853 -209
  92. package/{chunk-DHDMC6FO.js → chunk-QKUMVP3O.js} +11 -6
  93. package/{chunk-X4QAVDFE.js → chunk-RMAWULCS.js} +498 -480
  94. package/{chunk-V4MJDUSR.js → chunk-RSEEDUMS.js} +2 -2
  95. package/{chunk-UZGQNTVW.js → chunk-S5XGT6GB.js} +5 -3
  96. package/{chunk-76WEAXJB.js → chunk-SACTCJAC.js} +18 -15
  97. package/{chunk-AFUORTY4.js → chunk-SONWNI3L.js} +21 -21
  98. package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
  99. package/{chunk-2YMRWISD.js → chunk-TU5NE4U3.js} +9 -84
  100. package/chunk-TY3TIUJK.js +89 -0
  101. package/chunk-UEGYKNHO.js +13349 -0
  102. package/chunk-UNYJU5L6.js +780 -0
  103. package/{chunk-J4MOO56S.js → chunk-UQNS32WZ.js} +10 -2
  104. package/chunk-VIWDGTDA.js +8 -0
  105. package/chunk-VJVNU77E.js +83 -0
  106. package/{chunk-EHKBVWKL.js → chunk-VYN7O3OY.js} +1 -1
  107. package/{chunk-NEDZDG3M.js → chunk-WILHZY7K.js} +45 -45
  108. package/{chunk-UKWGR5SS.js → chunk-WIWM4FE3.js} +187 -398
  109. package/{chunk-R7N5TMTV.js → chunk-X7YLNILS.js} +13 -13
  110. package/{chunk-O6OSWFZQ.js → chunk-XUWRURDF.js} +6 -0
  111. package/{chunk-Q67DOFOO.js → chunk-Y3PMXGLH.js} +2 -0
  112. package/{chunk-SNPMM7H3.js → chunk-Y6AZRODX.js} +13 -13
  113. package/{chunk-RSJECD7I.js → chunk-YJKDTJ2X.js} +7 -7
  114. package/{chunk-SH43IESU.js → chunk-YUNJN43V.js} +44 -9
  115. package/{chunk-TOP2VXOR.js → chunk-Z4CSIXYP.js} +2 -2
  116. package/{chunk-2F7RJC6L.js → chunk-ZOVKKMF6.js} +1 -1
  117. package/chunk-ZRAU6T47.js +56 -0
  118. package/{chunk-Z77CRGTW.js → chunk-ZYWQNCBN.js} +1 -1
  119. package/commandRegistry-HUFXCF7Z.js +833 -0
  120. package/{contentThunks-YLWTUILV.js → contentThunks-TD5YOAQM.js} +32 -30
  121. package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
  122. package/{createAgentAutomationAction-HFLPOBWQ.js → createAgentAutomationAction-XUG62ANM.js} +32 -30
  123. package/{createDialogAction-4H52MURR.js → createDialogAction-L3CMZKNL.js} +36 -33
  124. package/{createPageAction-5YDRMJOS.js → createPageAction-WJ3MX6JS.js} +38 -36
  125. package/{chunk-NUVMWYJM.js → cursorProvider-YGGNMVWX.js} +2494 -9892
  126. package/{dbSlice-XVWBAGYN.js → dbSlice-DQ32LYTJ.js} +8 -8
  127. package/{deleteFile-YG6QMJLU.js → deleteFile-NX6QHCWZ.js} +3 -3
  128. package/{dialogCommands-KFK2FF5B.js → dialogCommands-VM3I4HBW.js} +45 -41
  129. package/{dialogSlice-TMSHUGEM.js → dialogSlice-DSHG3YUE.js} +36 -29
  130. package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
  131. package/{docCreateCommands-V777WOZ7.js → docCreateCommands-TYUJPCOP.js} +44 -40
  132. package/{docDeleteCommands-5KHT7Z5Q.js → docDeleteCommands-5XEG2LXO.js} +44 -40
  133. package/{docReadCommands-BLROGWP3.js → docReadCommands-M6RO6QHV.js} +43 -39
  134. package/{docStore-OBC5QOW7.js → docStore-RYOGMPEF.js} +11 -10
  135. package/{docUpdateCommands-QXOZHQ5H.js → docUpdateCommands-DKOFTZRX.js} +44 -40
  136. package/{fetchMessages-EIU7UFFK.js → fetchMessages-67MEFPZR.js} +2 -2
  137. package/{getPricing-LUSEABA6.js → getPricing-NMMFT3YI.js} +3 -3
  138. package/{handleSendMessageAction-4LGNXH6T.js → handleSendMessageAction-XH742B27.js} +91 -83
  139. package/index.js +87 -884
  140. package/{localDialogRead-BTFJ4V2I.js → localDialogRead-EBRS242U.js} +2 -2
  141. package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-5W6IJRAD.js} +6 -6
  142. package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-3LRMNLCM.js} +1 -1
  143. package/{machineCommands-SNLCRHQK.js → machineCommands-EY3SKJCP.js} +85 -77
  144. package/{machineWsRunDispatch-ZGZVDQSO.js → machineWsRunDispatch-OJ77YNRD.js} +82 -74
  145. package/{memberThunks-QGFLFVCI.js → memberThunks-5ZXPR63F.js} +9 -9
  146. package/{models-T3SG6MJ5.js → models-ZPU5EDF4.js} +2 -2
  147. package/oauthTokenStore-ITEB663N.js +23 -0
  148. package/package.json +1 -1
  149. package/pdf-U6KSUEZZ.js +26435 -0
  150. package/processSpawn-SOAV3FEV.js +11 -0
  151. package/profileConfig-ZGOFORWV.js +43 -0
  152. package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-76AVU3HD.js} +7 -7
  153. package/{providerRegistry-757OWH3O.js → providerRegistry-Z62NC45X.js} +11 -7
  154. package/{read-COE3ZYR6.js → read-EPTJRAEF.js} +5 -5
  155. package/{readDocTool-5USN4A6V.js → readDocTool-W4NDXNEX.js} +5 -3
  156. package/{readlineWorkspace-OUL7ZN7D.js → readlineWorkspace-PMTHAVMB.js} +2447 -2022
  157. package/{removeDialogAgentAction-IX3MN2ZO.js → removeDialogAgentAction-BVAWQKXE.js} +17 -19
  158. package/{runAgentClientLoop-GD3APV7V.js → runAgentClientLoop-7WXN6I7L.js} +62 -58
  159. package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-3USD722U.js} +3 -3
  160. package/runtimeModeArgs-2Y7BALTO.js +31 -0
  161. package/{setDialogExtraReferencesAction-X4HCPNZL.js → setDialogExtraReferencesAction-LYY45IAD.js} +12 -11
  162. package/{setPrimaryDialogAgentAction-4GMIQLOD.js → setPrimaryDialogAgentAction-73IL7DLU.js} +18 -20
  163. package/{settingSlice-ZQZVUPKK.js → settingSlice-Q6EKL7EQ.js} +9 -9
  164. package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
  165. package/{spaceCommands-TIDVUPDV.js → spaceCommands-QFP4ZXKG.js} +44 -40
  166. package/{streamAgentChatTurn-M73KWCCU.js → streamAgentChatTurn-B4PXPJJS.js} +184 -91
  167. package/{switchDialogAgentAction-N52LRPA3.js → switchDialogAgentAction-UUXDSQ6X.js} +15 -17
  168. package/{tableCommands-O6NWHFKV.js → tableCommands-G7RV3RU3.js} +4 -4
  169. package/{toolApiClient-QVJ6HDNN.js → toolApiClient-INIQCPGY.js} +3 -3
  170. package/{tools-DXXDQ2CP.js → tools-QFS2L7BU.js} +55 -51
  171. package/{tuiSummaryLlmCaller-VJY3YD2Q.js → tuiSummaryLlmCaller-74NRRLVW.js} +18 -16
  172. package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
  173. package/{updateDialogTitleAction-XI73NQMU.js → updateDialogTitleAction-HTDYCNNZ.js} +81 -43
  174. package/agentListCommands-O4AEMQVV.js +0 -406
  175. package/agentRecordCommands-6QK7AMXQ.js +0 -128
  176. package/chunk-M76ECQRD.js +0 -13658
  177. package/chunk-Q5FJJ6XI.js +0 -103
  178. package/chunk-S7Z2HMCN.js +0 -25
  179. package/chunk-WRFW73PB.js +0 -18881
  180. package/{chunk-VMFTFOWF.js → chunk-3AH7LNUB.js} +7 -7
  181. package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
  182. 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-O6JPWEEK.js";
12
+ import {
13
+ applyCredentialAvailability,
14
+ readCredentialAvailability
15
+ } from "./chunk-62IL3KQV.js";
16
+ import {
17
+ getReadableCliDb
18
+ } from "./chunk-CTUQJVQM.js";
19
+ import {
20
+ buildSpaceLookup,
21
+ getSpaceContentKeys
22
+ } from "./chunk-ID4G2MAR.js";
23
+ import {
24
+ readLiveDbRecordAfterTombstoneMerge
25
+ } from "./chunk-AOPCEXTB.js";
26
+ import {
27
+ queryUserRecords,
28
+ readDbRecord
29
+ } from "./chunk-SACTCJAC.js";
30
+ import "./chunk-ZYWQNCBN.js";
31
+ import "./chunk-SV5IJK6K.js";
32
+ import {
33
+ resolveNoloHome
34
+ } from "./chunk-GLKOYSRU.js";
35
+ import {
36
+ buildAgentDiscoveryResult,
37
+ matchesAgentQuery,
38
+ summarizeCredentialGroups,
39
+ toDiscoverySafeAgentSummary
40
+ } from "./chunk-AWF3WO5R.js";
41
+ import "./chunk-KQHGZWSV.js";
42
+ import "./chunk-DAWDCRIG.js";
43
+ import "./chunk-YYLHWIW6.js";
44
+ import "./chunk-7WCQEMPB.js";
45
+ import "./chunk-P6GMCCAT.js";
46
+ import "./chunk-ZNFJWEN4.js";
47
+ import "./chunk-TU5NE4U3.js";
48
+ import "./chunk-GMZLP5DV.js";
49
+ import "./chunk-CHOZJMJS.js";
50
+ import "./chunk-C53ZG23R.js";
51
+ import "./chunk-5ZUL4CUO.js";
52
+ import "./chunk-CQ3WA2NE.js";
53
+ import "./chunk-2MBTWINN.js";
54
+ import "./chunk-N7J63Q6C.js";
55
+ import "./chunk-EKS2APRJ.js";
56
+ import "./chunk-PUOC4YRO.js";
57
+ import "./chunk-6PHKBY2Q.js";
58
+ import {
59
+ isAgentUnavailableNow
60
+ } from "./chunk-H6A6X4EK.js";
61
+ import "./chunk-S5XGT6GB.js";
62
+ import "./chunk-27ONFIEY.js";
63
+ import "./chunk-WILHZY7K.js";
64
+ import {
65
+ normalizeTimingMs
66
+ } from "./chunk-6ZWMH6TJ.js";
67
+ import "./chunk-5MMAK75Q.js";
68
+ import "./chunk-PSCNXBYA.js";
69
+ import "./chunk-ESRMFY7G.js";
70
+ import "./chunk-BYXBJQAS.js";
71
+ import "./chunk-DWLEOOGR.js";
72
+ import "./chunk-7KVZ5LDQ.js";
73
+ import {
74
+ toErrorMessage
75
+ } from "./chunk-HNMXYYJR.js";
76
+ import "./chunk-3BXNTXYI.js";
77
+ import "./chunk-W7XHHYWM.js";
78
+ import "./chunk-RSEEDUMS.js";
79
+ import "./chunk-UAD2WT54.js";
80
+ import "./chunk-HNGRBWYF.js";
81
+ import "./chunk-HDLLCBRF.js";
82
+ import "./chunk-4VJAC32I.js";
83
+ import "./chunk-XUWRURDF.js";
84
+ import "./chunk-5J3PYNUP.js";
85
+ import {
86
+ parseUserIdFromAuthToken,
87
+ readOption,
88
+ resolveAuthToken,
89
+ resolveServerCandidates,
90
+ resolveServerUrl
91
+ } from "./chunk-A7GB5UGH.js";
92
+ import "./chunk-OLZBQWZU.js";
93
+ import "./chunk-Y6ROFCZO.js";
94
+ import {
95
+ getModelAbility
96
+ } from "./chunk-CYSYR67N.js";
97
+ import "./chunk-Y3PMXGLH.js";
98
+ import "./chunk-KX6YBIHG.js";
99
+ import "./chunk-HYZIYH2H.js";
100
+ import "./chunk-7CHC4W22.js";
101
+ import {
102
+ createKey,
103
+ createTokenKey
104
+ } from "./chunk-3AH7LNUB.js";
105
+ import "./chunk-WWC7I6TA.js";
106
+ import "./chunk-QSJ3HFEF.js";
107
+ import "./chunk-IAESIMK7.js";
108
+ import "./chunk-WIWM4FE3.js";
109
+ import "./chunk-QOKAKDPE.js";
110
+ import "./chunk-SEJ5OS6F.js";
111
+ import "./chunk-OW765XBU.js";
112
+ import "./chunk-GBRG75BQ.js";
113
+ import "./chunk-KUG52IAP.js";
114
+ import "./chunk-BNGW5ASC.js";
115
+ import "./chunk-M2EJHDJP.js";
116
+ import "./chunk-3EUW3WEO.js";
117
+ import "./chunk-U6VC4MU4.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
+ };