nolo-cli 0.253.0-alpha.1 → 0.255.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/{_executeModel-VUXEWLLQ.js → _executeModel-XD2EAFVG.js} +44 -43
  2. package/{action-4MADDU52.js → action-C6IQAKN4.js} +5 -5
  3. package/{addContentAction-MT4BECXT.js → addContentAction-53364YDW.js} +8 -8
  4. package/{addDialogAgentAction-ZZTJ5GBD.js → addDialogAgentAction-U5DD5EN5.js} +7 -7
  5. package/{agentDeleteCommand-SU5IKIW3.js → agentDeleteCommand-AI2AAFA4.js} +59 -58
  6. package/{agentEmailCommands-SHLVY627.js → agentEmailCommands-I544I2MU.js} +60 -59
  7. package/{agentListCommands-3NTMYMVI.js → agentListCommands-3NB4FDIJ.js} +26 -25
  8. package/{agentMachineCommands-MYXLAKQF.js → agentMachineCommands-RZEHM6NS.js} +22 -21
  9. package/{agentRecordCommands-EIZTKSWW.js → agentRecordCommands-X2AVD6Y2.js} +59 -58
  10. package/{agentRunCommand-RB3EIT4I.js → agentRunCommand-XU5TL3WO.js} +63 -59
  11. package/{agentRunControl-5ABAIBQT.js → agentRunControl-3TIVJ3SR.js} +3 -2
  12. package/{agentRuntimeLocal-IO3GGTCJ.js → agentRuntimeLocal-3MAEFYSB.js} +18 -17
  13. package/{agentSlice-TQVS23WV.js → agentSlice-ZFY3PT3D.js} +9 -9
  14. package/{appDeleteCommands-ZQ4ZEKTC.js → appDeleteCommands-J5BTYVPC.js} +24 -23
  15. package/{appDeployCommands-4XT7PFW5.js → appDeployCommands-I3JIN7TN.js} +24 -23
  16. package/{appDeployStatusCommands-5RVMRYQW.js → appDeployStatusCommands-BKJVLIOV.js} +24 -23
  17. package/{appGetCommands-VH5W3RFK.js → appGetCommands-67JTU36H.js} +24 -23
  18. package/{appListCommands-TAHZLAL3.js → appListCommands-HF4GFCN4.js} +24 -23
  19. package/{authCommand-HBO5G6RL.js → authCommand-Y3CXNAYM.js} +4 -4
  20. package/{builtinSkillRegistry-66PEOD4Y.js → builtinSkillRegistry-FVEEO4U2.js} +3 -3
  21. package/{chromeOpsCommands-AA555ANS.js → chromeOpsCommands-W5I2AEOV.js} +1 -1
  22. package/{chunk-D3WOFN6N.js → chunk-223KZUJ6.js} +1 -1
  23. package/{chunk-TI2JIXK4.js → chunk-24Z44WHO.js} +27 -27
  24. package/{chunk-FZSGYLFV.js → chunk-2BHHT2TR.js} +4 -4
  25. package/{chunk-IRORRPH2.js → chunk-3W2J3LFB.js} +21 -10
  26. package/{chunk-2RCMFPUZ.js → chunk-46FETNLF.js} +2 -2
  27. package/{chunk-CO6E7YK6.js → chunk-5P3PPQVP.js} +1 -1
  28. package/{chunk-VKAITWPC.js → chunk-6FONTXR7.js} +45 -25
  29. package/{chunk-KWARDHBI.js → chunk-6N4IKMTH.js} +37 -2
  30. package/{chunk-M7GMJBQJ.js → chunk-6VEO7Z3Y.js} +3 -3
  31. package/{chunk-2VYX3ZCR.js → chunk-6VNBJ7GI.js} +5 -5
  32. package/{chunk-GK772DEV.js → chunk-7BIJFGKS.js} +3 -3
  33. package/{chunk-3SEBCWLD.js → chunk-7EUJ65PF.js} +2057 -223
  34. package/{chunk-4GWNEPY6.js → chunk-7PTWFSZZ.js} +1 -1
  35. package/{chunk-CIAV4WK2.js → chunk-7WHCIA5V.js} +2 -2
  36. package/{chunk-O3WZMJAN.js → chunk-AAYDROBM.js} +2 -2
  37. package/{chunk-53UOBNTI.js → chunk-ADYWV732.js} +8 -8
  38. package/{chunk-WLHUANWZ.js → chunk-AIFQKNPP.js} +1 -1
  39. package/{chunk-GFXPPQZN.js → chunk-AKBNCTPY.js} +1 -1
  40. package/{chunk-HEUHCHAR.js → chunk-BD22OFDQ.js} +3 -3
  41. package/{chunk-SID2TFMV.js → chunk-BXGU6274.js} +104 -55
  42. package/{chunk-SCY2O7CU.js → chunk-BZMDWGQQ.js} +2 -2
  43. package/{chunk-UMI4NNZP.js → chunk-CAPHUP3M.js} +2 -2
  44. package/{chunk-JKO32CCL.js → chunk-CBIGMWMI.js} +1 -1
  45. package/{chunk-JP2BH4NC.js → chunk-CEKRIR22.js} +1 -1
  46. package/{chunk-6AJIU6OC.js → chunk-D53SPVAC.js} +3 -3
  47. package/{chunk-HS4JGZQH.js → chunk-DWES4SXY.js} +1 -1
  48. package/{chunk-3272HU62.js → chunk-E47JZP2R.js} +1 -1
  49. package/{chunk-D4CUS6NT.js → chunk-E4HBZDV6.js} +3 -3
  50. package/{chunk-JJABK3QO.js → chunk-EXD7S7QW.js} +58 -7
  51. package/{chunk-YGDYYFRX.js → chunk-GYX6XTAI.js} +3 -5
  52. package/{chunk-CMYZT2XN.js → chunk-H3KLIPAL.js} +5 -5
  53. package/{chunk-CF7U32BX.js → chunk-H6EKTB6X.js} +2 -2
  54. package/{chunk-VYRTLHIT.js → chunk-HDKMVYNJ.js} +1 -1
  55. package/chunk-HEVRQGGH.js +106 -0
  56. package/{chunk-4CL6QIQZ.js → chunk-HPDLPEUG.js} +2 -2
  57. package/{chunk-YQYSQUP3.js → chunk-HZQGCFPJ.js} +10 -10
  58. package/{chunk-7STRX24O.js → chunk-JAAYO52G.js} +8 -7
  59. package/{chunk-QV32GSVO.js → chunk-JPZKKSGT.js} +1 -1
  60. package/{chunk-Z2ZCKNKX.js → chunk-JW6OURKM.js} +261 -228
  61. package/{chunk-4AFKLWZP.js → chunk-K5X4D2TS.js} +156 -1767
  62. package/{chunk-MPOUZIF4.js → chunk-KF7M2UEK.js} +499 -7
  63. package/{chunk-VZCBYCHV.js → chunk-KG27JIG4.js} +2 -2
  64. package/{chunk-PTY2VZM5.js → chunk-KO5GO2BC.js} +6 -8
  65. package/{chunk-4BQ5QKIG.js → chunk-KRDG2XCI.js} +10 -10
  66. package/{chunk-OLS2J3WE.js → chunk-LLUBUHNT.js} +1 -1
  67. package/{chunk-CUQNRU4X.js → chunk-LQ4CQKTS.js} +3 -3
  68. package/{chunk-52M4RYVP.js → chunk-MDHI2LWF.js} +1 -1
  69. package/{chunk-XWR2YD4L.js → chunk-MLK3FEXG.js} +1 -1
  70. package/{chunk-KQBGXCKM.js → chunk-MNFUKRRU.js} +3 -3
  71. package/{chunk-FRC2DNTN.js → chunk-NAW2SN54.js} +1 -1
  72. package/{chunk-UHW6SCVK.js → chunk-NUHQO3RB.js} +1 -1
  73. package/{chunk-CYGFNMCH.js → chunk-OKAXQFON.js} +1 -1
  74. package/{chunk-P4JX7YMQ.js → chunk-ONTHDYFU.js} +22 -2
  75. package/{chunk-PR25J652.js → chunk-PNBQ5JTA.js} +1 -1
  76. package/{chunk-2BJ53346.js → chunk-PVHY7Y6T.js} +6 -6
  77. package/{chunk-K4LLTJUO.js → chunk-Q2MPKE4B.js} +5 -105
  78. package/{chunk-MARF3TN2.js → chunk-Q66O5LN3.js} +4 -4
  79. package/{chunk-TOHMK27J.js → chunk-QEVT4LQ3.js} +68 -54
  80. package/{chunk-OMIXG25B.js → chunk-QGFLVQ6E.js} +1 -1
  81. package/{chunk-25BDZGD7.js → chunk-QJKDHR4Y.js} +2 -2
  82. package/{chunk-ANQ544EU.js → chunk-QNZRR3NT.js} +9 -9
  83. package/{chunk-WMMKHEGQ.js → chunk-R3FZHW4Q.js} +12 -12
  84. package/{chunk-KZAT2M2V.js → chunk-RIWKZT7E.js} +22 -0
  85. package/{chunk-OWXOXKH7.js → chunk-SCAC3NM5.js} +2 -2
  86. package/{chunk-EG3JTV7H.js → chunk-TCAAHWCY.js} +2 -2
  87. package/{chunk-NMGG3NUB.js → chunk-U6QNVOR5.js} +1 -1
  88. package/{chunk-5UYDG6HP.js → chunk-V5NK6KMF.js} +8 -13
  89. package/{chunk-AIHNB5QH.js → chunk-VQR2ACSC.js} +6 -4
  90. package/{chunk-HEQJ5XND.js → chunk-WS36XPJD.js} +2 -2
  91. package/{chunk-MRYKRL2V.js → chunk-WSLL7VV4.js} +2 -2
  92. package/{dialogUsageCommand-3JMINURR.js → chunk-Y2TCTNUD.js} +19 -12
  93. package/{chunk-UHTT23PH.js → chunk-YKCFDOO4.js} +765 -29
  94. package/{chunk-DNY33GGQ.js → chunk-YN23INFZ.js} +1 -1
  95. package/{chunk-5HUO7SEX.js → chunk-YQLAFJRQ.js} +1 -1
  96. package/{chunk-VPSPVLCM.js → chunk-ZMJMHXYX.js} +3 -3
  97. package/{chunk-W4S5FQWQ.js → chunk-ZTHAJU3O.js} +1 -1
  98. package/{cliAgentConfigHelpers-FKBPFPKR.js → cliAgentConfigHelpers-BXHQ3PXP.js} +2 -2
  99. package/{cliLocalAgentRecordReader-2WBUVRVD.js → cliLocalAgentRecordReader-Q6677YID.js} +22 -21
  100. package/{commandRegistry-JDCGWIWD.js → commandRegistry-YCKR4SWB.js} +82 -78
  101. package/{contentThunks-B6BY7GS3.js → contentThunks-R2ZLM2Z3.js} +20 -20
  102. package/{cooldownCommands-PT5L4LNB.js → cooldownCommands-TVZBWUN3.js} +1 -1
  103. package/{createAgentAutomationAction-TQ6IA5SV.js → createAgentAutomationAction-Q665HFZS.js} +20 -20
  104. package/{createDialogAction-QKMGD2TS.js → createDialogAction-VOGA6VXH.js} +21 -21
  105. package/{createPageAction-7EEVGWGG.js → createPageAction-FICG35GF.js} +21 -21
  106. package/{dbSlice-HXFRXGI3.js → dbSlice-RWPSVHBC.js} +7 -7
  107. package/{deleteFile-QDSZVTUJ.js → deleteFile-ECU6FU5C.js} +5 -5
  108. package/{dialogCommands-MEH4CVRL.js → dialogCommands-TCIB4AMT.js} +28 -25
  109. package/{dialogNotifyCommand-JKYVSR6K.js → dialogNotifyCommand-IASQGEMW.js} +3 -3
  110. package/{dialogSlice-6WIME53P.js → dialogSlice-SCZJH2Q3.js} +18 -18
  111. package/dialogTraceCommand-E3BYXL3D.js +961 -0
  112. package/dialogUsageCommand-WJ3U6KZU.js +27 -0
  113. package/{docCreateCommands-MVAYVGQ5.js → docCreateCommands-UHY2QSEL.js} +23 -22
  114. package/{docDeleteCommands-TKXPRA3O.js → docDeleteCommands-JX53B6VB.js} +24 -23
  115. package/{docReadCommands-MR2YKCZP.js → docReadCommands-H5XZBEYD.js} +23 -22
  116. package/{docStore-VEHQHXRM.js → docStore-KTTOVQLL.js} +8 -8
  117. package/{docUpdateCommands-VJ6A6F7F.js → docUpdateCommands-YYYU6CHT.js} +23 -22
  118. package/{handleSendMessageAction-X5LGNJX5.js → handleSendMessageAction-FRGNSG6B.js} +32 -32
  119. package/{hostCredentialCreate-AQYSWUKA.js → hostCredentialCreate-V5EDFPAV.js} +59 -58
  120. package/index.js +7 -7
  121. package/{localRuntimeAdapter-FA4OGZGU.js → localRuntimeAdapter-VMGFXQOJ.js} +58 -57
  122. package/{machineCommands-VKU6MAFA.js → machineCommands-AUPY2QB6.js} +59 -58
  123. package/{machineWsRunDispatch-XQQHHOX4.js → machineWsRunDispatch-KNOARY66.js} +59 -58
  124. package/{mcpLocalAuthorizeCommand-Y3SOZFXT.js → mcpLocalAuthorizeCommand-RBXJDE6J.js} +2 -2
  125. package/{memberThunks-ZXEUM6DH.js → memberThunks-43B7UYC5.js} +9 -9
  126. package/package.json +1 -1
  127. package/{projectArchive-674NJOYI.js → projectArchive-KON534LA.js} +21 -21
  128. package/{read-T5WPCAY7.js → read-KG6INYUT.js} +5 -5
  129. package/{readDocTool-DW4DCRQG.js → readDocTool-N3GA52JR.js} +1 -1
  130. package/{readlineWorkspace-HFPEDOHN.js → readlineWorkspace-MHYNJR5O.js} +599 -840
  131. package/{removeDialogAgentAction-MXJEB77K.js → removeDialogAgentAction-EEVSOQOJ.js} +9 -9
  132. package/{runAgentClientLoop-NU3JNHSH.js → runAgentClientLoop-YRGQCRC4.js} +51 -40
  133. package/{secretCommands-BXAQEOES.js → secretCommands-POD67M6Y.js} +2 -2
  134. package/{setDialogExtraReferencesAction-BILVMHM7.js → setDialogExtraReferencesAction-DNO5POHA.js} +8 -8
  135. package/{setPrimaryDialogAgentAction-CUBBWACR.js → setPrimaryDialogAgentAction-QABBEO4C.js} +9 -9
  136. package/{settingThunks-BRBBAGEK.js → settingThunks-DVKG4X4S.js} +10 -10
  137. package/{skillDiscovery-MDDKPTW3.js → skillDiscovery-5GEGWJ6N.js} +3 -3
  138. package/{spaceCommands-K4HHG7OO.js → spaceCommands-USN52WYJ.js} +22 -21
  139. package/{streamAgentChatTurn-7FDXIRMB.js → streamAgentChatTurn-EQO3ULUB.js} +62 -50
  140. package/{switchDialogAgentAction-SSI2CSNE.js → switchDialogAgentAction-KYWJSGOO.js} +7 -7
  141. package/{tableCommands-C3P2HHKK.js → tableCommands-EFA754RE.js} +2 -2
  142. package/{tools-GC45557U.js → tools-UME4HYSH.js} +36 -35
  143. package/{tuiRestart-7IKI6JZK.js → tuiRestart-VN5F4GYU.js} +4 -3
  144. package/tuiSummaryLlmCaller-HROLGN4F.js +1 -1
  145. package/{updateCommands-BZ4YDHNM.js → updateCommands-L32TVOI7.js} +3 -3
  146. package/{updateDialogTitleAction-OAC5MWMS.js → updateDialogTitleAction-NZIGJL5Q.js} +20 -20
  147. package/{usageCommand-HVCMX7BG.js → usageCommand-WI6SQOPB.js} +1 -1
  148. package/{usageRebuildCommand-VMPIZ2ME.js → usageRebuildCommand-WQRLLZAT.js} +2 -2
  149. package/{windowsSelfUpdate-4BAXX7C3.js → windowsSelfUpdate-AGVLDVQS.js} +2 -2
  150. package/lib-62SWPXNF.js +0 -21042
@@ -6,6 +6,16 @@ import {
6
6
  resolvePureVNextRuntime,
7
7
  touchMemoryItemsInDb
8
8
  } from "./chunk-GAHJLSDO.js";
9
+ import {
10
+ listFavoriteAgentIdsAcrossServers,
11
+ listLocalCachedAgents,
12
+ listRemoteAgents,
13
+ listRemoteAgentsAcrossServers,
14
+ normalizeListedAgent
15
+ } from "./chunk-BD22OFDQ.js";
16
+ import {
17
+ refreshSubscriptionQuotas
18
+ } from "./chunk-P27E22MA.js";
9
19
  import {
10
20
  getReadableCliDb
11
21
  } from "./chunk-ZYPXOQS2.js";
@@ -30,10 +40,10 @@ import {
30
40
  resolveBoundMachineId,
31
41
  resolveFileWriteGateEnabled,
32
42
  resolveRawAgentInput,
33
- resolveServerUrl,
43
+ resolveServerUrl as resolveServerUrl2,
34
44
  validateInstaboxWorkspaceSelection,
35
45
  writeUsage
36
- } from "./chunk-TOHMK27J.js";
46
+ } from "./chunk-QEVT4LQ3.js";
37
47
  import {
38
48
  boxGlyphs,
39
49
  displayWidth,
@@ -43,7 +53,7 @@ import {
43
53
  stripAnsi,
44
54
  tokenizeAnsiLine,
45
55
  visibleWidth
46
- } from "./chunk-QV32GSVO.js";
56
+ } from "./chunk-JPZKKSGT.js";
47
57
  import {
48
58
  clearCredentialAvailability,
49
59
  readEffectiveCredentialEntry
@@ -89,11 +99,14 @@ import {
89
99
  } from "./chunk-BMQ2MJUK.js";
90
100
  import {
91
101
  resolveCliLocalRuntimeKeyCapability
92
- } from "./chunk-4AFKLWZP.js";
102
+ } from "./chunk-K5X4D2TS.js";
103
+ import {
104
+ isCallerAtFreePoolTop
105
+ } from "./chunk-EXD7S7QW.js";
93
106
  import {
94
107
  parseUiCard,
95
108
  uiCardFallback
96
- } from "./chunk-4BQ5QKIG.js";
109
+ } from "./chunk-KRDG2XCI.js";
97
110
  import {
98
111
  isGatewayHttpStatus
99
112
  } from "./chunk-NF64D32W.js";
@@ -104,7 +117,7 @@ import {
104
117
  loadOwnerItemsFromDb,
105
118
  parseUiAskChoiceContent,
106
119
  resolveAgentMemoryPolicy
107
- } from "./chunk-CMYZT2XN.js";
120
+ } from "./chunk-H3KLIPAL.js";
108
121
  import {
109
122
  API_REPORTED_COST_MULTIPLIER,
110
123
  estimateMessagesTokens,
@@ -113,7 +126,7 @@ import {
113
126
  resolveAgentContextWindow,
114
127
  resolveOccupancy,
115
128
  resolveOccupancyWindow
116
- } from "./chunk-TI2JIXK4.js";
129
+ } from "./chunk-24Z44WHO.js";
117
130
  import {
118
131
  getDefaultCliLocalRuntimeDb
119
132
  } from "./chunk-J55F3IEZ.js";
@@ -121,13 +134,18 @@ import {
121
134
  parsePositiveFiniteNumberOrFallback
122
135
  } from "./chunk-Y5GCAMGP.js";
123
136
  import {
137
+ readLiveDbRecordAfterTombstoneMerge
138
+ } from "./chunk-7PTWFSZZ.js";
139
+ import {
140
+ queryUserRecords,
124
141
  readDbRecord,
125
142
  resolveAgentRecordFromHybridStore
126
- } from "./chunk-D4CUS6NT.js";
143
+ } from "./chunk-E4HBZDV6.js";
127
144
  import {
145
+ isPlatformPaidAgentCall,
128
146
  resolveEffectiveReasoningEffortOverride,
129
147
  withReasoningEffortOverride
130
- } from "./chunk-AIHNB5QH.js";
148
+ } from "./chunk-VQR2ACSC.js";
131
149
  import {
132
150
  isTransientFetchError
133
151
  } from "./chunk-DXWGFL2Z.js";
@@ -151,7 +169,7 @@ import {
151
169
  settleRunTerminalAuthoritatively,
152
170
  spawnLocalBackgroundRun,
153
171
  transitionRunToTerminal
154
- } from "./chunk-P4JX7YMQ.js";
172
+ } from "./chunk-ONTHDYFU.js";
155
173
  import {
156
174
  formatAgentListCard,
157
175
  formatFinishedRunCard,
@@ -165,7 +183,7 @@ import {
165
183
  } from "./chunk-S25VJYXV.js";
166
184
  import {
167
185
  buildSkillDiscoveryContextLayer
168
- } from "./chunk-UHW6SCVK.js";
186
+ } from "./chunk-NUHQO3RB.js";
169
187
  import {
170
188
  isCliAuthorityBrokerProtocolError,
171
189
  isCliAuthorityBrokerTimeoutError,
@@ -182,10 +200,10 @@ import {
182
200
  readActionGate,
183
201
  readAgentsMdLayerFromDisk,
184
202
  registerDialogOwner
185
- } from "./chunk-3SEBCWLD.js";
203
+ } from "./chunk-7EUJ65PF.js";
186
204
  import {
187
205
  resolveAgentRuntimeConfigFromRecord
188
- } from "./chunk-XWR2YD4L.js";
206
+ } from "./chunk-MLK3FEXG.js";
189
207
  import {
190
208
  resolveAgentImageInputSupport
191
209
  } from "./chunk-BZLGPM5B.js";
@@ -196,6 +214,7 @@ import {
196
214
  } from "./chunk-56GBUMO5.js";
197
215
  import {
198
216
  classifyFailureSubclass,
217
+ formatQuotaSummary,
199
218
  isCapacitySaturatedRateLimit,
200
219
  isQuotaExhaustedText,
201
220
  resolveAvailabilityAction,
@@ -209,7 +228,7 @@ import {
209
228
  ATTACHMENT_PART_VERSION,
210
229
  describeAttachmentForModel,
211
230
  normalizeAttachmentPart
212
- } from "./chunk-CIAV4WK2.js";
231
+ } from "./chunk-7WHCIA5V.js";
213
232
  import {
214
233
  findCodexOAuthPinnedContextWindow,
215
234
  normalizeUsage,
@@ -227,7 +246,7 @@ import {
227
246
  } from "./chunk-USGHJSGO.js";
228
247
  import {
229
248
  workspaceChildEnv
230
- } from "./chunk-KWARDHBI.js";
249
+ } from "./chunk-6N4IKMTH.js";
231
250
  import {
232
251
  QUOTA_ERROR_PATTERNS,
233
252
  isQuotaExhaustedError
@@ -243,7 +262,7 @@ import {
243
262
  buildMemoryUseGuidanceLayer,
244
263
  partitionScopedBlocks,
245
264
  renderTurnContextBlocksWithScope
246
- } from "./chunk-5HUO7SEX.js";
265
+ } from "./chunk-YQLAFJRQ.js";
247
266
  import {
248
267
  isTombstoneRecord
249
268
  } from "./chunk-BV3FLP2L.js";
@@ -259,16 +278,18 @@ import {
259
278
  import {
260
279
  isBuiltinNoloAgentRef,
261
280
  resolveLocalUserId
262
- } from "./chunk-OMIXG25B.js";
281
+ } from "./chunk-QGFLVQ6E.js";
263
282
  import {
283
+ NOLO_DEFAULT_AGENT_KEY,
264
284
  isLocalCliAgentKey
265
285
  } from "./chunk-BR3GT6MR.js";
266
286
  import {
267
287
  BUILTIN_NOLO_AGENT_KEY,
288
+ BUILTIN_NOLO_AGENT_MODEL,
268
289
  BUILTIN_NOLO_AGENT_NAME,
269
290
  builtinAgentCatalogEntryById,
270
291
  parseBuiltinPlatformAgentId
271
- } from "./chunk-KZAT2M2V.js";
292
+ } from "./chunk-RIWKZT7E.js";
272
293
  import {
273
294
  parsePublicAgentId
274
295
  } from "./chunk-M2EJHDJP.js";
@@ -282,7 +303,10 @@ import {
282
303
  import {
283
304
  RuntimeProtocolMismatchError,
284
305
  RuntimeVersionMismatchError,
306
+ parseUserIdFromAuthToken,
285
307
  resolveAuthToken,
308
+ resolveServerCandidates,
309
+ resolveServerUrl,
286
310
  validateAgentRunProtocol
287
311
  } from "./chunk-BIDSIRTS.js";
288
312
  import {
@@ -299,7 +323,7 @@ import {
299
323
  toolIcon,
300
324
  toolLabel,
301
325
  toolLabelVariants
302
- } from "./chunk-5UYDG6HP.js";
326
+ } from "./chunk-V5NK6KMF.js";
303
327
  import {
304
328
  isAntigravityOAuthAgent
305
329
  } from "./chunk-6SOWMEAY.js";
@@ -12791,6 +12815,667 @@ ${t("agentRunStream.malformedToolCallRejectedNoDialog")}
12791
12815
  };
12792
12816
  }
12793
12817
 
12818
+ // packages/cli/client/callerPoolTop.ts
12819
+ function catalogEntryToPoolCandidate(entry, userId) {
12820
+ return {
12821
+ agentKey: entry.key,
12822
+ model: entry.model,
12823
+ requiresPaidApproval: isPlatformPaidAgentCall({
12824
+ agentConfig: {
12825
+ key: entry.key,
12826
+ // 自有 agent 的私有 key 形如 agent-<userId>-<id>:归属判据认这个形状。
12827
+ privateKey: entry.kind === "private" ? entry.key : void 0,
12828
+ model: entry.model,
12829
+ apiSource: entry.apiSource,
12830
+ cliProvider: entry.cliProvider
12831
+ },
12832
+ callerUserId: userId ?? void 0
12833
+ })
12834
+ };
12835
+ }
12836
+ function resolveCallerPoolTopFromCatalog(args) {
12837
+ const entries = args.entries;
12838
+ const userId = typeof args.userId === "string" ? args.userId.trim() : "";
12839
+ if (!entries || entries.length === 0 || !userId) return void 0;
12840
+ return isCallerAtFreePoolTop(
12841
+ { model: args.model ?? null, agentKey: args.agentKey ?? null },
12842
+ entries.map((entry) => catalogEntryToPoolCandidate(entry, userId))
12843
+ );
12844
+ }
12845
+ function pickCallerPoolIdentityFromAgentConfig(args) {
12846
+ const asPart = (value) => {
12847
+ const text = typeof value === "string" ? value.trim() : "";
12848
+ return text.length > 0 ? text : null;
12849
+ };
12850
+ const config = args.agentConfig ?? null;
12851
+ return {
12852
+ agentKey: asPart(config?.key) ?? asPart(args.agentKey),
12853
+ model: asPart(config?.model) ?? asPart(args.modelOverride)
12854
+ };
12855
+ }
12856
+ var CLI_CALLER_POOL_TOP_LATCH_LIMIT = 64;
12857
+ var cliCallerPoolTopLatch = /* @__PURE__ */ new Map();
12858
+ var asLatchPart = (value) => {
12859
+ const text = typeof value === "string" ? value.trim() : "";
12860
+ return text.length > 0 ? text : "-";
12861
+ };
12862
+ function buildCliCallerPoolTopLatchKey(args) {
12863
+ const dialogId = typeof args.dialogId === "string" ? args.dialogId.trim() : "";
12864
+ if (!dialogId) return null;
12865
+ return [dialogId, asLatchPart(args.agentKey), asLatchPart(args.model)].join("\0");
12866
+ }
12867
+ function resolveLatchedCliCallerIsPoolTop(args) {
12868
+ const latchAgentKey = "latchAgentKey" in args ? args.latchAgentKey : args.agentKey;
12869
+ const latchModel = "latchModel" in args ? args.latchModel : args.model;
12870
+ const latchKey = buildCliCallerPoolTopLatchKey({
12871
+ dialogId: args.dialogId,
12872
+ agentKey: latchAgentKey,
12873
+ model: latchModel
12874
+ });
12875
+ if (!latchKey) return resolveCallerPoolTopFromCatalog(args);
12876
+ if (cliCallerPoolTopLatch.has(latchKey)) return cliCallerPoolTopLatch.get(latchKey);
12877
+ const resolved = resolveCallerPoolTopFromCatalog(args);
12878
+ cliCallerPoolTopLatch.set(latchKey, resolved);
12879
+ while (cliCallerPoolTopLatch.size > CLI_CALLER_POOL_TOP_LATCH_LIMIT) {
12880
+ const oldest = cliCallerPoolTopLatch.keys().next();
12881
+ if (oldest.done) break;
12882
+ cliCallerPoolTopLatch.delete(oldest.value);
12883
+ }
12884
+ return resolved;
12885
+ }
12886
+
12887
+ // packages/ai/agent/utils/sortUtils.ts
12888
+ function sortAgentsFavoriteOwnedPublic(items) {
12889
+ const map = /* @__PURE__ */ new Map();
12890
+ for (const item of items) {
12891
+ const existing = map.get(item.key);
12892
+ if (!existing) {
12893
+ map.set(item.key, { ...item });
12894
+ continue;
12895
+ }
12896
+ map.set(item.key, {
12897
+ ...existing,
12898
+ ...item,
12899
+ key: existing.key,
12900
+ favoritedAt: Math.max(existing.favoritedAt ?? 0, item.favoritedAt ?? 0) || void 0,
12901
+ isOwned: Boolean(existing.isOwned || item.isOwned),
12902
+ isPublic: Boolean(existing.isPublic || item.isPublic),
12903
+ updatedAt: Math.max(existing.updatedAt ?? 0, item.updatedAt ?? 0),
12904
+ order: existing.order ?? item.order
12905
+ });
12906
+ }
12907
+ const arr = Array.from(map.values());
12908
+ arr.sort((a, b) => {
12909
+ const aFav = a.favoritedAt != null && a.favoritedAt > 0;
12910
+ const bFav = b.favoritedAt != null && b.favoritedAt > 0;
12911
+ if (aFav !== bFav) return aFav ? -1 : 1;
12912
+ if (aFav && bFav) {
12913
+ const diff = (b.favoritedAt ?? 0) - (a.favoritedAt ?? 0);
12914
+ if (diff !== 0) return diff;
12915
+ }
12916
+ const aOwned = Boolean(a.isOwned);
12917
+ const bOwned = Boolean(b.isOwned);
12918
+ if (aOwned !== bOwned) return aOwned ? -1 : 1;
12919
+ const aPublic = Boolean(a.isPublic);
12920
+ const bPublic = Boolean(b.isPublic);
12921
+ if (aPublic !== bPublic) return aPublic ? -1 : 1;
12922
+ const tsDiff = (b.updatedAt ?? 0) - (a.updatedAt ?? 0);
12923
+ if (tsDiff !== 0) return tsDiff;
12924
+ const aOrder = a.order ?? Number.POSITIVE_INFINITY;
12925
+ const bOrder = b.order ?? Number.POSITIVE_INFINITY;
12926
+ if (aOrder !== bOrder) return aOrder - bOrder;
12927
+ return a.key.localeCompare(b.key);
12928
+ });
12929
+ return arr;
12930
+ }
12931
+
12932
+ // packages/cli/tui/agentCatalog.ts
12933
+ var DEFAULT_TUI_AGENT_KEY = NOLO_DEFAULT_AGENT_KEY;
12934
+ function formatAgentSourceLabel(entry) {
12935
+ if (entry.kind === "platform" || entry.apiSource === "platform") return t("agentSourcePlatform");
12936
+ if (entry.apiSource === "cli") {
12937
+ return entry.cliProvider ? `${t("agentSourceSubscription")}(${entry.cliProvider})` : t("agentSourceSubscription");
12938
+ }
12939
+ if (entry.apiSource === "custom") return t("agentSourceApi");
12940
+ return t("agentSourcePlatform");
12941
+ }
12942
+ var PLATFORM_AGENTS = [
12943
+ {
12944
+ // 名称与模型都从 builtinAgentCatalog 派生:`/switch` 里的 nolo 项直接显示
12945
+ // 它实际指向的模型(当前 deepseek-flash),换代自动跟随。
12946
+ name: BUILTIN_NOLO_AGENT_NAME,
12947
+ key: DEFAULT_TUI_AGENT_KEY,
12948
+ model: BUILTIN_NOLO_AGENT_MODEL,
12949
+ kind: "platform",
12950
+ description: "one assistant that routes work across your agents and data"
12951
+ }
12952
+ ];
12953
+ function resolveCatalogPlatformAgents(_env = process.env) {
12954
+ return PLATFORM_AGENTS;
12955
+ }
12956
+ function toUpdatedAt(value) {
12957
+ if (value == null) return 0;
12958
+ const parsed = new Date(value).getTime();
12959
+ return Number.isFinite(parsed) ? parsed : 0;
12960
+ }
12961
+ function listedAgentToCatalogEntry(agent) {
12962
+ return {
12963
+ name: agent.name,
12964
+ key: agent.privateKey,
12965
+ model: agent.model,
12966
+ kind: "private",
12967
+ updatedAt: toUpdatedAt(agent.updatedAt),
12968
+ ...agent.apiSource ? { apiSource: agent.apiSource } : {},
12969
+ ...agent.cliProvider ? { cliProvider: agent.cliProvider } : {},
12970
+ ...agent.quota ? { quota: agent.quota } : {}
12971
+ };
12972
+ }
12973
+ function mergeCatalogEntries(currentKey, platformAgents, privateAgents, favoritedAtByKey = {}) {
12974
+ const seen = /* @__PURE__ */ new Set();
12975
+ const merged = [];
12976
+ const push = (entry) => {
12977
+ if (seen.has(entry.key)) return;
12978
+ seen.add(entry.key);
12979
+ const favoritedAt = favoritedAtByKey[entry.key];
12980
+ merged.push(favoritedAt ? { ...entry, favoritedAt } : entry);
12981
+ };
12982
+ const current = [...platformAgents, ...privateAgents].find((entry) => entry.key === currentKey) ?? null;
12983
+ if (current) push(current);
12984
+ for (const entry of platformAgents) {
12985
+ if (entry.key !== currentKey) push(entry);
12986
+ }
12987
+ const sortablePrivate = privateAgents.map((entry) => ({
12988
+ key: entry.key,
12989
+ ...favoritedAtByKey[entry.key] !== void 0 ? { favoritedAt: favoritedAtByKey[entry.key] } : {},
12990
+ isOwned: true,
12991
+ updatedAt: entry.updatedAt ?? 0
12992
+ }));
12993
+ const sortedKeys = sortAgentsFavoriteOwnedPublic(sortablePrivate);
12994
+ const sortedKeyOrder = new Map(sortedKeys.map((item, i) => [item.key, i]));
12995
+ const sortedPrivate = [...privateAgents].sort(
12996
+ (a, b) => (sortedKeyOrder.get(a.key) ?? 0) - (sortedKeyOrder.get(b.key) ?? 0)
12997
+ );
12998
+ for (const entry of sortedPrivate) {
12999
+ if (entry.key !== currentKey) push(entry);
13000
+ }
13001
+ return merged;
13002
+ }
13003
+ function formatUnavailableFavoritesNotice(unavailableFavoriteCount) {
13004
+ if (!Number.isFinite(unavailableFavoriteCount) || unavailableFavoriteCount <= 0) {
13005
+ return null;
13006
+ }
13007
+ return t(
13008
+ "agentCatalogUnavailableFavorites",
13009
+ String(Math.floor(unavailableFavoriteCount))
13010
+ );
13011
+ }
13012
+ var agentCatalogCache = null;
13013
+ var lastRefresh = null;
13014
+ function getAgentCatalogRefreshStatus(args = {}) {
13015
+ const env = args.env ?? process.env;
13016
+ const token = resolveAuthToken([], env);
13017
+ const key = `${token ? parseUserIdFromAuthToken(token) ?? "anon" : "anon"}|${resolveServerUrl(env)}`;
13018
+ return lastRefresh?.cacheKey === key ? lastRefresh.status : null;
13019
+ }
13020
+ var agentCatalogRefreshInFlight = null;
13021
+ var agentCatalogGeneration = 0;
13022
+ var agentCatalogRawLoadInFlight = /* @__PURE__ */ new Map();
13023
+ var AGENT_CATALOG_FRESH_MS = 15e3;
13024
+ var AGENT_CATALOG_MAX_STALE_MS = 5 * 6e4;
13025
+ var AGENT_CATALOG_FOREGROUND_DEADLINE_MS = 2500;
13026
+ var AGENT_CATALOG_BACKGROUND_DEADLINE_MS = 8e3;
13027
+ function resolveCatalogDeadlineMs(kind, env) {
13028
+ const override = Number.parseInt(env.NOLO_TUI_CATALOG_DEADLINE_MS ?? "", 10);
13029
+ if (Number.isFinite(override) && override > 0) return override;
13030
+ return kind === "foreground" ? AGENT_CATALOG_FOREGROUND_DEADLINE_MS : AGENT_CATALOG_BACKGROUND_DEADLINE_MS;
13031
+ }
13032
+ var SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES = 1;
13033
+ var SERVER_COOLDOWN_MS = 5 * 6e4;
13034
+ var serverHealth = /* @__PURE__ */ new Map();
13035
+ var serverHealthNow = () => Date.now();
13036
+ function filterHealthyServers(serverUrls) {
13037
+ const now = serverHealthNow();
13038
+ const healthy = serverUrls.filter((url) => {
13039
+ const state2 = serverHealth.get(url);
13040
+ if (!state2) return true;
13041
+ return !(state2.consecutiveFailures >= SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES && now - state2.trippedAt < SERVER_COOLDOWN_MS);
13042
+ });
13043
+ return healthy.length > 0 ? healthy : serverUrls;
13044
+ }
13045
+ function keepPrimaryServer(serverUrls, primary) {
13046
+ return serverUrls.includes(primary) ? serverUrls : [primary, ...serverUrls];
13047
+ }
13048
+ function recordServerFailures(failures) {
13049
+ const now = serverHealthNow();
13050
+ for (const failure of failures) {
13051
+ const state2 = serverHealth.get(failure.serverUrl) ?? {
13052
+ consecutiveFailures: 0,
13053
+ trippedAt: 0
13054
+ };
13055
+ state2.consecutiveFailures += 1;
13056
+ if (state2.consecutiveFailures >= SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES) {
13057
+ state2.trippedAt = now;
13058
+ }
13059
+ serverHealth.set(failure.serverUrl, state2);
13060
+ }
13061
+ }
13062
+ function recordServerSuccesses(serverUrls) {
13063
+ for (const url of serverUrls) serverHealth.delete(url);
13064
+ }
13065
+ function withFetchDeadline(fetchImpl, deadlineMs) {
13066
+ return async (input, init) => {
13067
+ let timer;
13068
+ const deadline = new Promise((_, reject) => {
13069
+ timer = setTimeout(
13070
+ () => reject(new Error(`catalog fetch deadline exceeded (${deadlineMs}ms)`)),
13071
+ deadlineMs
13072
+ );
13073
+ });
13074
+ const signal = init?.signal;
13075
+ let onAbort;
13076
+ let aborted = null;
13077
+ if (signal) {
13078
+ if (signal.aborted) {
13079
+ throw signal.reason ?? new Error("catalog fetch aborted");
13080
+ }
13081
+ aborted = new Promise((_, reject) => {
13082
+ onAbort = () => reject(signal.reason ?? new Error("catalog fetch aborted"));
13083
+ signal.addEventListener("abort", onAbort, { once: true });
13084
+ });
13085
+ }
13086
+ try {
13087
+ const response = await Promise.race([
13088
+ fetchImpl(input, init),
13089
+ deadline,
13090
+ ...aborted ? [aborted] : []
13091
+ ]);
13092
+ const text = await Promise.race([
13093
+ response.text(),
13094
+ deadline,
13095
+ ...aborted ? [aborted] : []
13096
+ ]);
13097
+ return new Response(text, {
13098
+ status: response.status,
13099
+ statusText: response.statusText,
13100
+ headers: response.headers
13101
+ });
13102
+ } finally {
13103
+ if (timer) clearTimeout(timer);
13104
+ if (signal && onAbort) signal.removeEventListener("abort", onAbort);
13105
+ }
13106
+ };
13107
+ }
13108
+ function readCachedAgentCatalogEntries() {
13109
+ return agentCatalogCache?.entries ?? null;
13110
+ }
13111
+ function hasWarmAgentCatalogCache(args = {}) {
13112
+ const env = args.env ?? process.env;
13113
+ const authToken = resolveAuthToken([], env);
13114
+ const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
13115
+ const cacheKey = `${userId ?? "anon"}|${resolveServerUrl(env)}`;
13116
+ return agentCatalogCache?.cacheKey === cacheKey && Date.now() - agentCatalogCache.at < AGENT_CATALOG_MAX_STALE_MS;
13117
+ }
13118
+ async function loadAgentCatalog(args) {
13119
+ return (await loadAgentCatalogWithNotices(args)).entries;
13120
+ }
13121
+ async function loadAgentCatalogWithNotices(args) {
13122
+ const env = args.env ?? process.env;
13123
+ const authToken = resolveAuthToken([], env);
13124
+ const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
13125
+ const cacheKey = `${userId ?? "anon"}|${resolveServerUrl(env)}`;
13126
+ const cached = agentCatalogCache?.cacheKey === cacheKey ? agentCatalogCache : null;
13127
+ if (cached && !args.fresh && Date.now() - cached.at < AGENT_CATALOG_MAX_STALE_MS) {
13128
+ const refreshStatus = getAgentCatalogRefreshStatus({ env });
13129
+ if (args.revalidateInBackground || Date.now() - cached.at >= AGENT_CATALOG_FRESH_MS) {
13130
+ refreshAgentCatalogInBackground(args, env, cacheKey);
13131
+ }
13132
+ if (args.currentKey && cached.entries.length > 1 && cached.entries[0]?.key !== args.currentKey) {
13133
+ const idx = cached.entries.findIndex((entry) => entry.key === args.currentKey);
13134
+ if (idx > 0) {
13135
+ return {
13136
+ entries: [
13137
+ cached.entries[idx],
13138
+ ...cached.entries.slice(0, idx),
13139
+ ...cached.entries.slice(idx + 1)
13140
+ ],
13141
+ refreshStatus,
13142
+ unavailableFavoriteCount: cached.unavailableFavoriteCount
13143
+ };
13144
+ }
13145
+ }
13146
+ return {
13147
+ entries: cached.entries,
13148
+ refreshStatus,
13149
+ unavailableFavoriteCount: cached.unavailableFavoriteCount
13150
+ };
13151
+ }
13152
+ let rawData;
13153
+ const generation = args.fresh ? ++agentCatalogGeneration : agentCatalogGeneration;
13154
+ const deadlineKind = args.fresh ? "foreground" : args.deadlineKind ?? "foreground";
13155
+ const inFlight2 = agentCatalogRawLoadInFlight.get(deadlineKind);
13156
+ if (inFlight2) {
13157
+ rawData = await inFlight2;
13158
+ } else {
13159
+ const promise = fetchRawCatalogData({ ...args, deadlineKind }, env);
13160
+ agentCatalogRawLoadInFlight.set(deadlineKind, promise);
13161
+ try {
13162
+ rawData = await promise;
13163
+ } finally {
13164
+ if (agentCatalogRawLoadInFlight.get(deadlineKind) === promise) {
13165
+ agentCatalogRawLoadInFlight.delete(deadlineKind);
13166
+ }
13167
+ }
13168
+ }
13169
+ const entries = mergeCatalogEntries(
13170
+ args.currentKey,
13171
+ resolveCatalogPlatformAgents(env),
13172
+ rawData.privateAgents,
13173
+ rawData.favoritedAtByKey
13174
+ );
13175
+ if (generation === agentCatalogGeneration) {
13176
+ lastRefresh = { cacheKey, status: rawData.status };
13177
+ }
13178
+ if (generation === agentCatalogGeneration && rawData.status === "success") {
13179
+ agentCatalogCache = {
13180
+ cacheKey,
13181
+ at: Date.now(),
13182
+ entries,
13183
+ unavailableFavoriteCount: rawData.unavailableFavoriteCount
13184
+ };
13185
+ }
13186
+ void mergeCatalogQuotas(entries, { env, fetchImpl: args.fetchImpl }).catch(() => {
13187
+ });
13188
+ return { entries, unavailableFavoriteCount: rawData.unavailableFavoriteCount, refreshStatus: rawData.status };
13189
+ }
13190
+ async function mergeCatalogQuotas(entries, args) {
13191
+ const fresh = await refreshSubscriptionQuotas({
13192
+ entries: entries.map((entry) => ({
13193
+ key: entry.key,
13194
+ ...entry.quota ? { quota: entry.quota } : {},
13195
+ probeable: entry.kind === "private"
13196
+ })),
13197
+ ...args.env ? { env: args.env } : {},
13198
+ ...args.fetchImpl ? { fetchImpl: args.fetchImpl } : {}
13199
+ });
13200
+ for (const entry of entries) {
13201
+ const quota = fresh[entry.key];
13202
+ if (quota) entry.quota = quota;
13203
+ }
13204
+ }
13205
+ function refreshAgentCatalogInBackground(args, env, cacheKey) {
13206
+ if (agentCatalogRefreshInFlight) return;
13207
+ const generation = agentCatalogGeneration;
13208
+ agentCatalogRefreshInFlight = fetchRawCatalogData(
13209
+ { ...args, deadlineKind: "background" },
13210
+ env
13211
+ ).then(async (rawData) => {
13212
+ if (generation !== agentCatalogGeneration) return;
13213
+ lastRefresh = { cacheKey, status: rawData.status };
13214
+ if (rawData.status !== "success") return;
13215
+ const entries = mergeCatalogEntries(
13216
+ args.currentKey,
13217
+ resolveCatalogPlatformAgents(env),
13218
+ rawData.privateAgents,
13219
+ rawData.favoritedAtByKey
13220
+ );
13221
+ await mergeCatalogQuotas(entries, { env, fetchImpl: args.fetchImpl });
13222
+ if (generation === agentCatalogGeneration) {
13223
+ agentCatalogCache = {
13224
+ cacheKey,
13225
+ at: Date.now(),
13226
+ entries,
13227
+ unavailableFavoriteCount: rawData.unavailableFavoriteCount
13228
+ };
13229
+ }
13230
+ }).catch(() => {
13231
+ if (generation === agentCatalogGeneration) lastRefresh = { cacheKey, status: "failed" };
13232
+ }).finally(() => {
13233
+ agentCatalogRefreshInFlight = null;
13234
+ });
13235
+ }
13236
+ async function prefillCatalogFromLocalDb(_args) {
13237
+ }
13238
+ function prefetchAgentCatalog(args) {
13239
+ void (async () => {
13240
+ await prefillCatalogFromLocalDb({ env: args.env, getDb: args.getDb }).catch(() => {
13241
+ });
13242
+ void loadAgentCatalog({ ...args, currentKey: "", deadlineKind: "background" }).catch(() => {
13243
+ });
13244
+ })();
13245
+ }
13246
+ async function fetchRawCatalogData(args, env) {
13247
+ const deadlineMs = resolveCatalogDeadlineMs(args.deadlineKind ?? "foreground", env);
13248
+ const fetchImpl = withFetchDeadline(args.fetchImpl ?? fetch, deadlineMs);
13249
+ const fallbackFetchImpl = args.fallbackFetchImpl ? withFetchDeadline(args.fallbackFetchImpl, deadlineMs) : void 0;
13250
+ const authToken = resolveAuthToken([], env);
13251
+ const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
13252
+ if (!authToken || !userId) {
13253
+ return { privateAgents: [], favoritedAtByKey: {}, unavailableFavoriteCount: 0, status: "success" };
13254
+ }
13255
+ const serverUrl = resolveServerUrl(env);
13256
+ const allServerUrls = resolveServerCandidates([], env, serverUrl);
13257
+ const serverUrls = (args.deadlineKind ?? "foreground") === "foreground" ? keepPrimaryServer(filterHealthyServers(allServerUrls), serverUrl) : allServerUrls;
13258
+ const fetchStartedAt = performance.now();
13259
+ let listedAgents = [];
13260
+ let catalogAuthoritative = false;
13261
+ let catalogAvailable = false;
13262
+ let favoritesFailed = false;
13263
+ const favoritesPromise = listFavoriteAgentIdsAcrossServers({
13264
+ authToken,
13265
+ fetchImpl,
13266
+ serverUrls,
13267
+ onFailure: () => {
13268
+ favoritesFailed = true;
13269
+ }
13270
+ }).catch(() => {
13271
+ favoritesFailed = true;
13272
+ return {};
13273
+ });
13274
+ try {
13275
+ const remoteResult = await listRemoteAgentsAcrossServers({
13276
+ authToken,
13277
+ fallbackFetchImpl,
13278
+ fetchImpl,
13279
+ serverUrls,
13280
+ userId
13281
+ });
13282
+ listedAgents = remoteResult.agents;
13283
+ catalogAvailable = true;
13284
+ catalogAuthoritative = remoteResult.failures.length === 0 && serverUrls.length === allServerUrls.length;
13285
+ recordServerSuccesses(serverUrls.filter(
13286
+ (url) => !remoteResult.failures.some((f) => f.serverUrl === url)
13287
+ ));
13288
+ recordServerFailures(remoteResult.failures);
13289
+ } catch {
13290
+ try {
13291
+ const localBudgetMs = Math.max(
13292
+ 500,
13293
+ deadlineMs - (performance.now() - fetchStartedAt)
13294
+ );
13295
+ let localTimer;
13296
+ try {
13297
+ listedAgents = await Promise.race([
13298
+ (async () => {
13299
+ const db = args.getDb ? await args.getDb() : await getReadableCliDb({ write: () => {
13300
+ } });
13301
+ return listLocalCachedAgents({ db, userId });
13302
+ })(),
13303
+ new Promise((_, reject) => {
13304
+ localTimer = setTimeout(
13305
+ () => reject(new Error("local catalog deadline exceeded")),
13306
+ localBudgetMs
13307
+ );
13308
+ })
13309
+ ]);
13310
+ catalogAvailable = true;
13311
+ } finally {
13312
+ if (localTimer) clearTimeout(localTimer);
13313
+ }
13314
+ } catch {
13315
+ try {
13316
+ listedAgents = await listRemoteAgents({
13317
+ authToken,
13318
+ fallbackFetchImpl,
13319
+ fetchImpl,
13320
+ serverUrl,
13321
+ userId,
13322
+ queryUserRecords,
13323
+ readDbRecord
13324
+ });
13325
+ catalogAvailable = true;
13326
+ } catch {
13327
+ listedAgents = [];
13328
+ }
13329
+ }
13330
+ }
13331
+ const privateAgents = listedAgents.map(listedAgentToCatalogEntry);
13332
+ const favoritedAtByKey = await favoritesPromise;
13333
+ for (const agent of listedAgents) {
13334
+ const favoritedAt = [agent.privateKey, agent.publicKey, agent.id].map((key) => favoritedAtByKey[key]).find((value) => value !== void 0);
13335
+ if (favoritedAt !== void 0) favoritedAtByKey[agent.privateKey] = favoritedAt;
13336
+ }
13337
+ const existingKeys = /* @__PURE__ */ new Set();
13338
+ for (const agent of listedAgents) {
13339
+ existingKeys.add(agent.privateKey);
13340
+ existingKeys.add(agent.publicKey);
13341
+ existingKeys.add(agent.id);
13342
+ }
13343
+ let unavailableFavoriteCount = 0;
13344
+ let orphanSkipped = false;
13345
+ await Promise.all(
13346
+ Object.keys(favoritedAtByKey).map(async (favKey) => {
13347
+ if (existingKeys.has(favKey)) return;
13348
+ const remainingMs = deadlineMs - (performance.now() - fetchStartedAt);
13349
+ if (remainingMs <= 0) {
13350
+ orphanSkipped = true;
13351
+ return;
13352
+ }
13353
+ try {
13354
+ let orphanTimer;
13355
+ const orphanDeadline = new Promise((_, reject) => {
13356
+ orphanTimer = setTimeout(
13357
+ () => reject(new Error("orphan hydrate deadline")),
13358
+ remainingMs
13359
+ );
13360
+ });
13361
+ try {
13362
+ const favRead = await Promise.race([
13363
+ readLiveDbRecordAfterTombstoneMerge({
13364
+ authToken,
13365
+ dbKey: favKey,
13366
+ fallbackFetchImpl,
13367
+ fetchImpl,
13368
+ serverUrls
13369
+ }),
13370
+ orphanDeadline
13371
+ ]);
13372
+ const record = favRead.record;
13373
+ if (!record || record.type && record.type !== "agent") return;
13374
+ const norm = normalizeListedAgent(record);
13375
+ if (!norm) return;
13376
+ if (existingKeys.has(norm.privateKey) || existingKeys.has(norm.publicKey) || existingKeys.has(norm.id)) {
13377
+ return;
13378
+ }
13379
+ existingKeys.add(norm.privateKey);
13380
+ existingKeys.add(norm.publicKey);
13381
+ existingKeys.add(norm.id);
13382
+ privateAgents.push(listedAgentToCatalogEntry(norm));
13383
+ } finally {
13384
+ if (orphanTimer) clearTimeout(orphanTimer);
13385
+ }
13386
+ } catch {
13387
+ unavailableFavoriteCount += 1;
13388
+ }
13389
+ })
13390
+ );
13391
+ const status = !catalogAvailable && favoritesFailed ? "failed" : catalogAuthoritative && !favoritesFailed && unavailableFavoriteCount === 0 && !orphanSkipped ? "success" : "degraded";
13392
+ return { privateAgents, favoritedAtByKey, unavailableFavoriteCount, status };
13393
+ }
13394
+ function renderAgentCatalogList(entries, currentKey, options) {
13395
+ const lines = ["Agents:"];
13396
+ entries.forEach((entry, index) => {
13397
+ const current = entry.key === currentKey ? " (current)" : "";
13398
+ const favorite = entry.favoritedAt ? " \u2605" : "";
13399
+ const detail = entry.description ? ` \u2014 ${entry.description}` : "";
13400
+ const quota = formatQuotaSummary(entry.quota, Date.now(), { model: entry.model });
13401
+ const trailing = quota ? ` [${quota}]` : detail;
13402
+ lines.push(
13403
+ ` ${String(index + 1).padStart(2)} ${entry.name.padEnd(18)} ${entry.model.padEnd(14)} ${formatAgentSourceLabel(entry)}${favorite}${trailing}${current}`
13404
+ );
13405
+ });
13406
+ lines.push("");
13407
+ const notice = formatUnavailableFavoritesNotice(
13408
+ options?.unavailableFavoriteCount ?? 0
13409
+ );
13410
+ if (notice) lines.push(notice);
13411
+ lines.push("Tip: run /switch in an interactive terminal to pick with \u2191\u2193.");
13412
+ return lines.join("\n");
13413
+ }
13414
+ function resolveEntryApiSource(entry) {
13415
+ if (entry.apiSource) return entry.apiSource;
13416
+ return entry.kind === "platform" ? "platform" : void 0;
13417
+ }
13418
+ function toSwitchTarget(entry) {
13419
+ const apiSource = resolveEntryApiSource(entry);
13420
+ return {
13421
+ name: entry.name,
13422
+ key: entry.key,
13423
+ model: entry.model,
13424
+ ...apiSource ? { apiSource } : {}
13425
+ };
13426
+ }
13427
+ function findAgentCatalogEntry(entries, rawTarget) {
13428
+ const target = rawTarget.trim();
13429
+ if (!target) return null;
13430
+ if (/^\d+$/.test(target)) {
13431
+ const entry = entries[Number(target) - 1];
13432
+ return entry ? toSwitchTarget(entry) : null;
13433
+ }
13434
+ const lower = target.toLowerCase();
13435
+ const byName = entries.find(
13436
+ (entry) => entry.name.toLowerCase() === lower || entry.key.toLowerCase() === lower || entry.key.toLowerCase().endsWith(`-${lower}`)
13437
+ );
13438
+ if (byName) return toSwitchTarget(byName);
13439
+ if (target.startsWith("agent-") || target.startsWith("agent-pub-")) {
13440
+ const builtin = builtinAgentCatalogEntryById(
13441
+ parseBuiltinPlatformAgentId(target) ?? parsePublicAgentId(target)
13442
+ );
13443
+ if (builtin) {
13444
+ return {
13445
+ name: builtin.name,
13446
+ key: target,
13447
+ model: builtin.model,
13448
+ apiSource: builtin.apiSource ?? "platform"
13449
+ };
13450
+ }
13451
+ return { name: target, key: target };
13452
+ }
13453
+ return null;
13454
+ }
13455
+ function lookupCachedAgentName(agentKey) {
13456
+ const trimmed = agentKey.trim();
13457
+ if (!trimmed) return void 0;
13458
+ const platform = PLATFORM_AGENTS.find(
13459
+ (p) => p.key === trimmed || p.key.toLowerCase() === trimmed.toLowerCase()
13460
+ );
13461
+ if (platform?.name) return platform.name;
13462
+ const builtin = builtinAgentCatalogEntryById(
13463
+ parseBuiltinPlatformAgentId(trimmed) ?? parsePublicAgentId(trimmed)
13464
+ );
13465
+ if (builtin?.name) return builtin.name;
13466
+ if (agentCatalogCache?.entries) {
13467
+ const direct = agentCatalogCache.entries.find(
13468
+ (entry) => entry.key === trimmed || entry.key.toLowerCase() === trimmed.toLowerCase()
13469
+ );
13470
+ if (direct?.name) return direct.name;
13471
+ const suffix = agentCatalogCache.entries.find(
13472
+ (entry) => entry.key.toLowerCase().endsWith(`-${trimmed.toLowerCase()}`) || trimmed.toLowerCase().endsWith(`-${entry.key.toLowerCase()}`)
13473
+ );
13474
+ if (suffix?.name) return suffix.name;
13475
+ }
13476
+ return void 0;
13477
+ }
13478
+
12794
13479
  // packages/cli/client/agentRunPlatformTools.ts
12795
13480
  var SERVER_PLATFORM_TOOL_NAMES = /* @__PURE__ */ new Set([
12796
13481
  "addTableRow",
@@ -13087,7 +13772,7 @@ function isBalanceExhaustedError(error) {
13087
13772
 
13088
13773
  // packages/cli/client/agentRun.ts
13089
13774
  async function loadRunLocalAgentTurn() {
13090
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-IO3GGTCJ.js");
13775
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-3MAEFYSB.js");
13091
13776
  return runLocalAgentTurn;
13092
13777
  }
13093
13778
  var stripDebugNoise = (s) => s.replace(/\s*raw="[\s\S]*"/g, "").replace(/\s*raw=\S+/g, "").replace(/\s*headers=\[[^\]]*\]/g, "").replace(/\s*headers=\S+/g, "").trim();
@@ -14444,6 +15129,32 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
14444
15129
  const durableAttachmentParts = ENABLE_REMOTE_ATTACHMENT_PART_WRITES ? localAttachmentParts : [];
14445
15130
  const hasDurableAttachments = durableAttachmentParts.length > 0;
14446
15131
  const runLocalAgentTurn = await loadRunLocalAgentTurn();
15132
+ const poolEntries = readCachedAgentCatalogEntries();
15133
+ const poolAgentConfig = poolEntries && poolEntries.length > 0 && userId ? await (async () => {
15134
+ try {
15135
+ return await adapter.loadAgentConfig(options.agentKey);
15136
+ } catch {
15137
+ return null;
15138
+ }
15139
+ })() : null;
15140
+ const poolIdentity = pickCallerPoolIdentityFromAgentConfig({
15141
+ agentConfig: poolAgentConfig,
15142
+ agentKey: options.agentKey,
15143
+ // --model 覆盖已在 adapter 层应用到 agentConfig,这里只是 config 未加载时的兜底。
15144
+ modelOverride: options.modelOverride?.model ?? null
15145
+ });
15146
+ const callerIsPoolTop = resolveLatchedCliCallerIsPoolTop({
15147
+ dialogId: currentDialogId,
15148
+ entries: poolEntries,
15149
+ agentKey: poolIdentity.agentKey,
15150
+ latchAgentKey: options.agentKey,
15151
+ latchModel: options.modelOverride?.model ?? null,
15152
+ model: poolIdentity.model ?? resolveAgentModelIdentity({
15153
+ agentKey: options.agentKey,
15154
+ agentName: options.agentName
15155
+ }).model ?? null,
15156
+ userId
15157
+ });
14447
15158
  const result = await runLocalAgentTurn({
14448
15159
  adapter,
14449
15160
  agentRef: options.agentKey,
@@ -14501,6 +15212,7 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
14501
15212
  userMessages: messages
14502
15213
  }) } : {},
14503
15214
  runKind: options.env.NOLO_AGENT_RUN_CHILD === "1" ? "subtask" : "interactive",
15215
+ ...callerIsPoolTop === void 0 ? {} : { callerIsPoolTop },
14504
15216
  // 展示能力由宿主声明(TUI=narrow),非交互 CLI/后台留空 → unknown;
14505
15217
  // 排版段只在能力已知时由 localLoop 注入,server 线不读该字段。
14506
15218
  ...options.responseViewport ? { responseViewport: options.responseViewport } : {},
@@ -15070,25 +15782,33 @@ function buildHostEnvironmentLayer(options) {
15070
15782
  var finiteCount = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
15071
15783
  var isUsageObject = (usage) => Boolean(usage) && typeof usage === "object";
15072
15784
  var readInputTokens = (usage) => finiteCount(usage.input_tokens) ?? finiteCount(usage.prompt_tokens) ?? 0;
15785
+ var readOutputTokens = (usage) => finiteCount(usage.output_tokens) ?? finiteCount(usage.completion_tokens);
15073
15786
  var computeCacheHitRatio = (inputTokens, cachedTokens) => {
15074
15787
  if (cachedTokens === null) return null;
15075
15788
  if (!Number.isFinite(inputTokens) || inputTokens <= 0) return 0;
15076
15789
  return Math.round(cachedTokens / inputTokens * 1e4) / 1e4;
15077
15790
  };
15078
- var withRatio = (inputTokens, cachedTokens) => ({
15791
+ var withRatio = (inputTokens, cachedTokens, outputTokens) => ({
15079
15792
  input_tokens: inputTokens,
15080
15793
  cached_tokens: cachedTokens,
15081
- cache_hit_ratio: computeCacheHitRatio(inputTokens, cachedTokens)
15794
+ cache_hit_ratio: computeCacheHitRatio(inputTokens, cachedTokens),
15795
+ ...typeof outputTokens === "number" && Number.isFinite(outputTokens) ? { output_tokens: Math.max(0, Math.floor(outputTokens)) } : {}
15082
15796
  });
15083
15797
  var summarizeCacheUsage = (usage) => {
15084
15798
  if (!isUsageObject(usage)) return void 0;
15085
15799
  if (Object.keys(usage).length === 0) return void 0;
15086
- return withRatio(readInputTokens(usage), readCacheReadInputTokensOrNull(usage));
15800
+ return withRatio(
15801
+ readInputTokens(usage),
15802
+ readCacheReadInputTokensOrNull(usage),
15803
+ readOutputTokens(usage)
15804
+ );
15087
15805
  };
15088
15806
  var summarizeCacheUsageRecords = (records) => {
15089
15807
  if (!records || records.length === 0) return void 0;
15090
15808
  let inputTokens = 0;
15091
15809
  let cachedTokens = 0;
15810
+ let outputTokens = 0;
15811
+ let sawOutput = false;
15092
15812
  let sawUsage = false;
15093
15813
  for (const record of records) {
15094
15814
  const summary = summarizeCacheUsage(record?.usage);
@@ -15096,16 +15816,21 @@ var summarizeCacheUsageRecords = (records) => {
15096
15816
  sawUsage = true;
15097
15817
  inputTokens += summary.input_tokens;
15098
15818
  cachedTokens = cachedTokens === null || summary.cached_tokens === null ? null : cachedTokens + summary.cached_tokens;
15819
+ if (typeof summary.output_tokens === "number") {
15820
+ sawOutput = true;
15821
+ outputTokens += summary.output_tokens;
15822
+ }
15099
15823
  }
15100
15824
  if (!sawUsage) return void 0;
15101
- return withRatio(inputTokens, cachedTokens);
15825
+ return withRatio(inputTokens, cachedTokens, sawOutput ? outputTokens : void 0);
15102
15826
  };
15103
15827
  var mergeCacheUsageSummaries = (left, right) => {
15104
15828
  if (!left) return right;
15105
15829
  if (!right) return left;
15106
15830
  const inputTokens = left.input_tokens + right.input_tokens;
15107
15831
  const cachedTokens = left.cached_tokens === null || right.cached_tokens === null ? null : left.cached_tokens + right.cached_tokens;
15108
- return withRatio(inputTokens, cachedTokens);
15832
+ const outputTokens = typeof left.output_tokens === "number" && typeof right.output_tokens === "number" ? left.output_tokens + right.output_tokens : typeof left.output_tokens === "number" ? left.output_tokens : right.output_tokens;
15833
+ return withRatio(inputTokens, cachedTokens, outputTokens);
15109
15834
  };
15110
15835
 
15111
15836
  // packages/cli/agentRunDoD.ts
@@ -17649,7 +18374,7 @@ async function runAgentRunCommandImpl(args, deps) {
17649
18374
  await readDbRecord({
17650
18375
  dbKey: agentKey,
17651
18376
  authToken: resolveAuthToken(args, env),
17652
- serverUrl: resolveServerUrl(env),
18377
+ serverUrl: resolveServerUrl2(env),
17653
18378
  fetchImpl: fetch
17654
18379
  }).catch(() => null)
17655
18380
  );
@@ -17682,7 +18407,7 @@ async function runAgentRunCommandImpl(args, deps) {
17682
18407
  if (parsed.skillRefs?.length) {
17683
18408
  const skills = [];
17684
18409
  const authToken = resolveAuthToken(args, env);
17685
- const serverUrl = resolveServerUrl(env);
18410
+ const serverUrl = resolveServerUrl2(env);
17686
18411
  for (const ref of parsed.skillRefs) {
17687
18412
  try {
17688
18413
  const resolved = await resolveSkillReference(ref, {
@@ -17818,7 +18543,7 @@ async function runAgentRunCommandImpl(args, deps) {
17818
18543
  if (!deps.memoryRecallDisabled) {
17819
18544
  try {
17820
18545
  memoryPromptBlock = await resolveCliMemory({
17821
- serverUrl: resolveServerUrl(env),
18546
+ serverUrl: resolveServerUrl2(env),
17822
18547
  authToken: resolveAuthToken(args, env),
17823
18548
  agentKey: effectiveAgentKey,
17824
18549
  userInput: effectiveMessage,
@@ -17897,7 +18622,7 @@ async function runAgentRunCommandImpl(args, deps) {
17897
18622
  // 放在 buildRunOptions 这个唯一构造点上,首轮 / quota fallback / 队列 drain
17898
18623
  // 三处 runner(...) 调用自动一致;远端分支走 server 线,不读该字段。
17899
18624
  responseViewport: "unknown",
17900
- serverUrl: resolveServerUrl(env),
18625
+ serverUrl: resolveServerUrl2(env),
17901
18626
  message: formatTurnMessage(turnMessage),
17902
18627
  imageUrls,
17903
18628
  scriptDir: deps.scriptDir,
@@ -18223,6 +18948,17 @@ export {
18223
18948
  preserveContextUsageWithoutReceipt,
18224
18949
  resolveContextUsage,
18225
18950
  renderTokenStatus,
18951
+ DEFAULT_TUI_AGENT_KEY,
18952
+ formatAgentSourceLabel,
18953
+ resolveCatalogPlatformAgents,
18954
+ formatUnavailableFavoritesNotice,
18955
+ hasWarmAgentCatalogCache,
18956
+ loadAgentCatalog,
18957
+ loadAgentCatalogWithNotices,
18958
+ prefetchAgentCatalog,
18959
+ renderAgentCatalogList,
18960
+ findAgentCatalogEntry,
18961
+ lookupCachedAgentName,
18226
18962
  redactSecrets,
18227
18963
  resolveCliColorEnabled,
18228
18964
  dimCliText,