nolo-cli 0.254.0-alpha.1 → 0.256.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.
- package/{_executeModel-OMDET3E2.js → _executeModel-E2LL7FPO.js} +44 -43
- package/{action-4MADDU52.js → action-C6IQAKN4.js} +5 -5
- package/{addContentAction-MT4BECXT.js → addContentAction-53364YDW.js} +8 -8
- package/{addDialogAgentAction-ZZTJ5GBD.js → addDialogAgentAction-U5DD5EN5.js} +7 -7
- package/{agentDeleteCommand-5WXEECFH.js → agentDeleteCommand-ORNRRKJO.js} +59 -58
- package/{agentEmailCommands-3QWBB2JL.js → agentEmailCommands-2ALVFOD5.js} +60 -59
- package/{agentListCommands-WTEF5RKJ.js → agentListCommands-6I4NQPR4.js} +26 -25
- package/{agentMachineCommands-DP44GKA6.js → agentMachineCommands-PNHTIJ6A.js} +22 -21
- package/{agentRecordCommands-4I7P34GJ.js → agentRecordCommands-BEZPBYBM.js} +59 -58
- package/{agentRunCommand-VAKWFXJV.js → agentRunCommand-2T72V5KY.js} +63 -59
- package/{agentRunControl-5ABAIBQT.js → agentRunControl-3TIVJ3SR.js} +3 -2
- package/{agentRuntimeLocal-IO3GGTCJ.js → agentRuntimeLocal-3MAEFYSB.js} +18 -17
- package/{agentSlice-5ZSVWJHV.js → agentSlice-KOQXUPKT.js} +9 -9
- package/{appDeleteCommands-ZQ4ZEKTC.js → appDeleteCommands-IIOP3CZU.js} +24 -23
- package/{appDeployCommands-4XT7PFW5.js → appDeployCommands-S5ZNB7MA.js} +24 -23
- package/{appDeployStatusCommands-5RVMRYQW.js → appDeployStatusCommands-MQIGLK3T.js} +24 -23
- package/{appGetCommands-VH5W3RFK.js → appGetCommands-XFX4E3KR.js} +24 -23
- package/{appListCommands-TAHZLAL3.js → appListCommands-QR7LT4AK.js} +24 -23
- package/{authCommand-HBO5G6RL.js → authCommand-HKSXJT3J.js} +4 -4
- package/{builtinSkillRegistry-66PEOD4Y.js → builtinSkillRegistry-FVEEO4U2.js} +3 -3
- package/{chromeOpsCommands-AA555ANS.js → chromeOpsCommands-4UIKH26F.js} +1 -1
- package/{chunk-D3WOFN6N.js → chunk-223KZUJ6.js} +1 -1
- package/{chunk-4Z7Q4QZF.js → chunk-2RZBFJEG.js} +1014 -43
- package/{chunk-AX63ZU2W.js → chunk-3GGVFHWI.js} +4 -4
- package/{chunk-2RCMFPUZ.js → chunk-46FETNLF.js} +2 -2
- package/{chunk-CO6E7YK6.js → chunk-5P3PPQVP.js} +1 -1
- package/{chunk-KWARDHBI.js → chunk-6N4IKMTH.js} +37 -2
- package/{chunk-M7GMJBQJ.js → chunk-6VEO7Z3Y.js} +3 -3
- package/{chunk-2VYX3ZCR.js → chunk-6VNBJ7GI.js} +5 -5
- package/{chunk-MICGEDCN.js → chunk-7B55IVLF.js} +107 -27
- package/{chunk-GK772DEV.js → chunk-7BIJFGKS.js} +3 -3
- package/{chunk-3SEBCWLD.js → chunk-7EUJ65PF.js} +2057 -223
- package/{chunk-25BDZGD7.js → chunk-7JMBQ7YU.js} +2 -2
- package/{chunk-4GWNEPY6.js → chunk-7PTWFSZZ.js} +1 -1
- package/{chunk-CIAV4WK2.js → chunk-7WHCIA5V.js} +2 -2
- package/{chunk-KR4W72OK.js → chunk-ADUCBH4M.js} +45 -25
- package/{chunk-53UOBNTI.js → chunk-ADYWV732.js} +8 -8
- package/{chunk-WLHUANWZ.js → chunk-AIFQKNPP.js} +1 -1
- package/{chunk-GFXPPQZN.js → chunk-AKBNCTPY.js} +1 -1
- package/{chunk-3272HU62.js → chunk-APQBEIOQ.js} +1 -1
- package/{chunk-MW3XUUYS.js → chunk-APXC3SQO.js} +6 -6
- package/{chunk-52M4RYVP.js → chunk-BB76X6O4.js} +1 -1
- package/{chunk-HEUHCHAR.js → chunk-BD22OFDQ.js} +3 -3
- package/{chunk-ZAKWT4XQ.js → chunk-BD5YJJLJ.js} +3 -3
- package/{chunk-SID2TFMV.js → chunk-BXGU6274.js} +104 -55
- package/{chunk-SCY2O7CU.js → chunk-BZMDWGQQ.js} +2 -2
- package/{chunk-QV32GSVO.js → chunk-C63KMRJE.js} +1 -1
- package/{chunk-JKO32CCL.js → chunk-CBIGMWMI.js} +1 -1
- package/{chunk-JP2BH4NC.js → chunk-CEKRIR22.js} +1 -1
- package/{chunk-MR72IIX5.js → chunk-CVDJUPBN.js} +4 -4
- package/{chunk-6AJIU6OC.js → chunk-DCTQJDDQ.js} +3 -3
- package/{chunk-HS4JGZQH.js → chunk-DWES4SXY.js} +1 -1
- package/{chunk-D4CUS6NT.js → chunk-E4HBZDV6.js} +3 -3
- package/{chunk-2G3XMM3O.js → chunk-EXD7S7QW.js} +41 -5
- package/{chunk-YGDYYFRX.js → chunk-GYX6XTAI.js} +3 -5
- package/{chunk-VYRTLHIT.js → chunk-HDKMVYNJ.js} +1 -1
- package/chunk-HEVRQGGH.js +106 -0
- package/{chunk-4CL6QIQZ.js → chunk-HPDLPEUG.js} +2 -2
- package/{chunk-7STRX24O.js → chunk-IZHENZQ5.js} +8 -7
- package/{chunk-IGK4OXAO.js → chunk-JAGD4PSH.js} +499 -7
- package/{chunk-MCQXBKC6.js → chunk-JGVWHUYK.js} +2 -2
- package/{chunk-5UYDG6HP.js → chunk-JOJH3KWV.js} +26 -15
- package/{chunk-Z2ZCKNKX.js → chunk-JW6OURKM.js} +261 -228
- package/{chunk-VZCBYCHV.js → chunk-KG27JIG4.js} +2 -2
- package/{chunk-PTY2VZM5.js → chunk-KO5GO2BC.js} +6 -8
- package/{chunk-TA2JQUWA.js → chunk-KO5PFS74.js} +156 -1767
- package/{chunk-YW5L3XOO.js → chunk-LJ6WIQZO.js} +10 -10
- package/{chunk-OLS2J3WE.js → chunk-LLUBUHNT.js} +1 -1
- package/{chunk-IDCGMZLC.js → chunk-MD7O2NN2.js} +9 -9
- package/{chunk-XWR2YD4L.js → chunk-MLK3FEXG.js} +1 -1
- package/{chunk-KQBGXCKM.js → chunk-MNFUKRRU.js} +3 -3
- package/{chunk-YYHWEVBI.js → chunk-MUDMYJCM.js} +2 -2
- package/{chunk-NEDBPW44.js → chunk-NRUYSNSZ.js} +2 -2
- package/{chunk-UHW6SCVK.js → chunk-NUHQO3RB.js} +1 -1
- package/{chunk-CYGFNMCH.js → chunk-OKAXQFON.js} +1 -1
- package/{chunk-P4JX7YMQ.js → chunk-ONTHDYFU.js} +22 -2
- package/{chunk-PR25J652.js → chunk-PNBQ5JTA.js} +1 -1
- package/{chunk-K4LLTJUO.js → chunk-Q2MPKE4B.js} +5 -105
- package/{chunk-OMIXG25B.js → chunk-QGFLVQ6E.js} +1 -1
- package/{chunk-WMMKHEGQ.js → chunk-R3FZHW4Q.js} +12 -12
- package/{chunk-KZAT2M2V.js → chunk-RIWKZT7E.js} +22 -0
- package/{chunk-FRC2DNTN.js → chunk-RQKTCHQM.js} +1 -1
- package/{chunk-OWXOXKH7.js → chunk-SCAC3NM5.js} +2 -2
- package/{chunk-NXNHG3QT.js → chunk-SIHOY5YI.js} +21 -10
- package/{chunk-HKPIFK7F.js → chunk-TF427WGH.js} +5 -5
- package/{chunk-NMGG3NUB.js → chunk-U6QNVOR5.js} +1 -1
- package/{chunk-6WI4PFPP.js → chunk-V6S5OZSP.js} +68 -54
- package/{chunk-AIHNB5QH.js → chunk-VQR2ACSC.js} +6 -4
- package/{chunk-GJKEOBCV.js → chunk-WFEWP352.js} +10 -10
- package/{chunk-HEQJ5XND.js → chunk-WS36XPJD.js} +2 -2
- package/{chunk-MRYKRL2V.js → chunk-WSLL7VV4.js} +2 -2
- package/{dialogUsageCommand-3JMINURR.js → chunk-Y2TCTNUD.js} +19 -12
- package/{chunk-DNY33GGQ.js → chunk-YN23INFZ.js} +1 -1
- package/{chunk-5HUO7SEX.js → chunk-YQLAFJRQ.js} +1 -1
- package/{chunk-EG3JTV7H.js → chunk-Z3JZ2R5F.js} +2 -2
- package/{chunk-VPSPVLCM.js → chunk-ZMJMHXYX.js} +3 -3
- package/{chunk-W4S5FQWQ.js → chunk-ZTHAJU3O.js} +1 -1
- package/{cliAgentConfigHelpers-FKBPFPKR.js → cliAgentConfigHelpers-BXHQ3PXP.js} +2 -2
- package/{cliLocalAgentRecordReader-2WBUVRVD.js → cliLocalAgentRecordReader-Q6677YID.js} +22 -21
- package/{commandRegistry-DONNI3FW.js → commandRegistry-RNYUOKUE.js} +82 -78
- package/{contentThunks-THSXC6WQ.js → contentThunks-ZDBDDZP3.js} +20 -20
- package/{cooldownCommands-PT5L4LNB.js → cooldownCommands-Y4ZQQ35D.js} +1 -1
- package/{createAgentAutomationAction-WNQOJ4DG.js → createAgentAutomationAction-HEZ3G5L4.js} +20 -20
- package/{createDialogAction-YORDQFFC.js → createDialogAction-DK62W5VA.js} +21 -21
- package/{createPageAction-2S7V5OCW.js → createPageAction-W6NXHVKO.js} +21 -21
- package/{dbSlice-HXFRXGI3.js → dbSlice-RWPSVHBC.js} +7 -7
- package/{deleteFile-QDSZVTUJ.js → deleteFile-ECU6FU5C.js} +5 -5
- package/{dialogCommands-MEH4CVRL.js → dialogCommands-Z24IDINY.js} +28 -25
- package/{dialogNotifyCommand-JKYVSR6K.js → dialogNotifyCommand-IASQGEMW.js} +3 -3
- package/{dialogSlice-JOICDGQU.js → dialogSlice-62GISS77.js} +18 -18
- package/dialogTraceCommand-FDINAIZ6.js +961 -0
- package/dialogUsageCommand-WJ3U6KZU.js +27 -0
- package/{docCreateCommands-MVAYVGQ5.js → docCreateCommands-SXA4TMGJ.js} +23 -22
- package/{docDeleteCommands-TKXPRA3O.js → docDeleteCommands-ELXSZK3F.js} +24 -23
- package/{docReadCommands-MR2YKCZP.js → docReadCommands-DFLAQPI4.js} +23 -22
- package/{docStore-NKVLWCXX.js → docStore-UWF2PMCB.js} +8 -8
- package/{docUpdateCommands-VJ6A6F7F.js → docUpdateCommands-KB6M5HUH.js} +23 -22
- package/{handleSendMessageAction-SNNYOQ4P.js → handleSendMessageAction-ZV6OQPQG.js} +32 -32
- package/{hostCredentialCreate-SDQUFL23.js → hostCredentialCreate-3IA5IJFG.js} +59 -58
- package/index.js +7 -7
- package/{localRuntimeAdapter-JHYH5ZIR.js → localRuntimeAdapter-SSG5ORLZ.js} +58 -57
- package/{machineCommands-BXSBRM7L.js → machineCommands-ECFQMLHA.js} +59 -58
- package/{machineWsRunDispatch-KEXSHGSD.js → machineWsRunDispatch-7PROH7E7.js} +59 -58
- package/{mcpLocalAuthorizeCommand-Y3SOZFXT.js → mcpLocalAuthorizeCommand-RBXJDE6J.js} +2 -2
- package/{memberThunks-ZXEUM6DH.js → memberThunks-43B7UYC5.js} +9 -9
- package/package.json +1 -1
- package/{projectArchive-FDYE7VNC.js → projectArchive-JN43WW4E.js} +21 -21
- package/{read-T5WPCAY7.js → read-KG6INYUT.js} +5 -5
- package/{readDocTool-DW4DCRQG.js → readDocTool-N3GA52JR.js} +1 -1
- package/{readlineWorkspace-ME2C64XI.js → readlineWorkspace-D6EUSB2Q.js} +684 -874
- package/{removeDialogAgentAction-MXJEB77K.js → removeDialogAgentAction-EEVSOQOJ.js} +9 -9
- package/{runAgentClientLoop-UAGXVYW5.js → runAgentClientLoop-FEZTSUSJ.js} +51 -40
- package/{secretCommands-BXAQEOES.js → secretCommands-53NZFD4T.js} +2 -2
- package/{setDialogExtraReferencesAction-BILVMHM7.js → setDialogExtraReferencesAction-DNO5POHA.js} +8 -8
- package/{setPrimaryDialogAgentAction-CUBBWACR.js → setPrimaryDialogAgentAction-QABBEO4C.js} +9 -9
- package/{settingThunks-BRBBAGEK.js → settingThunks-DVKG4X4S.js} +10 -10
- package/{skillDiscovery-MDDKPTW3.js → skillDiscovery-5GEGWJ6N.js} +3 -3
- package/{spaceCommands-K4HHG7OO.js → spaceCommands-4ACQQNZL.js} +70 -25
- package/{streamAgentChatTurn-RZUB6JTH.js → streamAgentChatTurn-I425SVYJ.js} +62 -50
- package/{switchDialogAgentAction-SSI2CSNE.js → switchDialogAgentAction-KYWJSGOO.js} +7 -7
- package/{tableCommands-C3P2HHKK.js → tableCommands-EFA754RE.js} +2 -2
- package/{tools-23F5EEVM.js → tools-WBPFTSMK.js} +36 -35
- package/{tuiRestart-7IKI6JZK.js → tuiRestart-VN5F4GYU.js} +4 -3
- package/tuiSummaryLlmCaller-HROLGN4F.js +1 -1
- package/{updateCommands-BZ4YDHNM.js → updateCommands-VQEBBIGO.js} +3 -3
- package/{updateDialogTitleAction-TJWT4LXL.js → updateDialogTitleAction-VB5DTVXV.js} +20 -20
- package/{usageCommand-HVCMX7BG.js → usageCommand-WI6SQOPB.js} +1 -1
- package/{usageRebuildCommand-VMPIZ2ME.js → usageRebuildCommand-WQRLLZAT.js} +2 -2
- package/{windowsSelfUpdate-4BAXX7C3.js → windowsSelfUpdate-ZEZKGX4M.js} +2 -2
- 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-
|
|
46
|
+
} from "./chunk-V6S5OZSP.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-
|
|
56
|
+
} from "./chunk-C63KMRJE.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-
|
|
102
|
+
} from "./chunk-KO5PFS74.js";
|
|
103
|
+
import {
|
|
104
|
+
isCallerAtFreePoolTop
|
|
105
|
+
} from "./chunk-EXD7S7QW.js";
|
|
93
106
|
import {
|
|
94
107
|
parseUiCard,
|
|
95
108
|
uiCardFallback
|
|
96
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-WFEWP352.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-
|
|
120
|
+
} from "./chunk-TF427WGH.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-
|
|
129
|
+
} from "./chunk-7B55IVLF.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-
|
|
143
|
+
} from "./chunk-E4HBZDV6.js";
|
|
127
144
|
import {
|
|
145
|
+
isPlatformPaidAgentCall,
|
|
128
146
|
resolveEffectiveReasoningEffortOverride,
|
|
129
147
|
withReasoningEffortOverride
|
|
130
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
203
|
+
} from "./chunk-7EUJ65PF.js";
|
|
186
204
|
import {
|
|
187
205
|
resolveAgentRuntimeConfigFromRecord
|
|
188
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
326
|
+
} from "./chunk-JOJH3KWV.js";
|
|
303
327
|
import {
|
|
304
328
|
isAntigravityOAuthAgent
|
|
305
329
|
} from "./chunk-6SOWMEAY.js";
|
|
@@ -8905,6 +8929,7 @@ function polishBreathInsertsBlankBetween(cur, next) {
|
|
|
8905
8929
|
if (isPolishIntroLine(cur) && isPolishListLikeLine(next)) return false;
|
|
8906
8930
|
if (isPolishHeadingLine(cur) || isPolishHeadingLine(next)) return false;
|
|
8907
8931
|
if (isCodeFenceLine(cur) !== isCodeFenceLine(next)) return true;
|
|
8932
|
+
if (plainToolLine(cur).startsWith("\u25B8 ") && plainToolLine(next).startsWith(" \u2026")) return false;
|
|
8908
8933
|
const toolBoundary = toolRowBoundary(cur, next);
|
|
8909
8934
|
if (toolBoundary !== null) return toolBoundary;
|
|
8910
8935
|
return isPolishListLikeLine(cur) !== isPolishListLikeLine(next);
|
|
@@ -9608,6 +9633,7 @@ function parseGit(rest) {
|
|
|
9608
9633
|
const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
|
|
9609
9634
|
if (!tokens2) return null;
|
|
9610
9635
|
let i = 0, context;
|
|
9636
|
+
if (tokens2.length === 1 && tokens2[0] === "--version") return { action: "\u67E5\u7248\u672C", readOnly: true };
|
|
9611
9637
|
while (tokens2[i]?.startsWith("-")) {
|
|
9612
9638
|
const option = tokens2[i++];
|
|
9613
9639
|
if (["-C", "-c", "--git-dir", "--work-tree"].includes(option)) {
|
|
@@ -9641,20 +9667,35 @@ function parseGit(rest) {
|
|
|
9641
9667
|
return null;
|
|
9642
9668
|
}
|
|
9643
9669
|
if (sub === "branch") {
|
|
9644
|
-
let mode = "create", end = false;
|
|
9670
|
+
let mode = "create", end = false, explicitList = false, listFilter = false;
|
|
9645
9671
|
const operands = [];
|
|
9646
|
-
|
|
9672
|
+
const BRANCH_FILTER_FLAGS = ["--merged", "--no-merged", "--contains", "--no-contains", "--points-at"];
|
|
9673
|
+
for (let j = 0; j < args.length; j++) {
|
|
9674
|
+
const token = args[j];
|
|
9647
9675
|
if (!end && token === "--") {
|
|
9648
9676
|
end = true;
|
|
9649
9677
|
continue;
|
|
9650
9678
|
}
|
|
9651
9679
|
if (!end && token.startsWith("-")) {
|
|
9652
9680
|
if (["-d", "-D", "--delete"].includes(token) && mode === "create") mode = "delete";
|
|
9653
|
-
else if (
|
|
9681
|
+
else if (token === "--list" && mode === "create") {
|
|
9682
|
+
mode = "list";
|
|
9683
|
+
explicitList = true;
|
|
9684
|
+
} else if (["-a", "--all", "-r", "--remotes", "-v", "-vv", "--verbose", "--show-current"].includes(token) && mode === "create") mode = "list";
|
|
9685
|
+
else if (mode === "create" && (BRANCH_FILTER_FLAGS.includes(token) || BRANCH_FILTER_FLAGS.some((f) => token.startsWith(`${f}=`)))) {
|
|
9686
|
+
mode = "list";
|
|
9687
|
+
listFilter = true;
|
|
9688
|
+
if (BRANCH_FILTER_FLAGS.includes(token)) {
|
|
9689
|
+
const value = args[j + 1];
|
|
9690
|
+
if (!value || value.startsWith("-")) return null;
|
|
9691
|
+
j++;
|
|
9692
|
+
}
|
|
9693
|
+
} else if (mode === "list" && ["-i", "--ignore-case", "-v", "-vv", "--verbose", "--no-color", "--color", "--column", "--no-column"].includes(token)) continue;
|
|
9654
9694
|
else return null;
|
|
9655
9695
|
} else operands.push(token);
|
|
9656
9696
|
}
|
|
9657
9697
|
if (mode === "delete" && operands.length === 1) return result("\u5220\u9664\u5206\u652F", operands[0], false);
|
|
9698
|
+
if (mode === "list" && operands.length && !explicitList && !listFilter) return null;
|
|
9658
9699
|
if (mode === "list" || !args.length) return result("\u5217\u51FA\u5206\u652F", void 0, true);
|
|
9659
9700
|
if (mode === "create" && operands.length >= 1 && operands.length <= 2) return result("\u521B\u5EFA\u5206\u652F", operands[0], false);
|
|
9660
9701
|
return null;
|
|
@@ -9669,7 +9710,7 @@ function parseGit(rest) {
|
|
|
9669
9710
|
break;
|
|
9670
9711
|
}
|
|
9671
9712
|
if (tok.startsWith("-")) {
|
|
9672
|
-
if (["-m", "-F", "-b", "-B", "-n", "--max-count", "--format", "--pretty", "--since", "--until", "--author", "-U"].includes(tok)) j++;
|
|
9713
|
+
if (["-m", "-F", "-b", "-B", "-n", "--max-count", "--format", "--pretty", "--since", "--until", "--author", "-U", "-L", "-S", "-G"].includes(tok)) j++;
|
|
9673
9714
|
continue;
|
|
9674
9715
|
}
|
|
9675
9716
|
out.push(tok);
|
|
@@ -9687,6 +9728,60 @@ function parseGit(rest) {
|
|
|
9687
9728
|
return result("\u67E5\u5171\u540C\u7956\u5148", void 0, true);
|
|
9688
9729
|
case "rev-parse":
|
|
9689
9730
|
return result("\u67E5\u4ED3\u5E93\u4FE1\u606F", void 0, true);
|
|
9731
|
+
// 以下子命令在 git 里没有写/执行形态(例外一律单独把关),可安全折进探索树。
|
|
9732
|
+
case "version":
|
|
9733
|
+
return result("\u67E5\u7248\u672C", void 0, true);
|
|
9734
|
+
case "ls-files":
|
|
9735
|
+
return result("\u5217\u8DDF\u8E2A\u6587\u4EF6", void 0, true);
|
|
9736
|
+
case "ls-tree": {
|
|
9737
|
+
const target = nonFlagArgs(args).find(isSafeGitTarget);
|
|
9738
|
+
return result("\u770B\u6811", target ? clipShortText(target, 20) : void 0, true);
|
|
9739
|
+
}
|
|
9740
|
+
case "cat-file": {
|
|
9741
|
+
const target = nonFlagArgs(args).find(isSafeGitTarget);
|
|
9742
|
+
return result("\u770B\u5BF9\u8C61", target ? clipShortText(target, 20) : void 0, true);
|
|
9743
|
+
}
|
|
9744
|
+
case "show-ref":
|
|
9745
|
+
case "for-each-ref":
|
|
9746
|
+
return result("\u67E5\u5F15\u7528", void 0, true);
|
|
9747
|
+
case "grep": {
|
|
9748
|
+
if (args.some(
|
|
9749
|
+
(t2) => t2.startsWith("-") && !t2.startsWith("--") && t2.slice(1).includes("O") || t2 === "--open-files-in-pager" || t2.startsWith("--open-files-in-pager=")
|
|
9750
|
+
)) return null;
|
|
9751
|
+
return result("\u641C\u4EE3\u7801", extractSafeSearchTarget(args.join(" ")), true);
|
|
9752
|
+
}
|
|
9753
|
+
case "blame": {
|
|
9754
|
+
const files = nonFlagArgs(args).filter(isSafeGitTarget);
|
|
9755
|
+
const file = files[files.length - 1];
|
|
9756
|
+
return result("\u67E5\u884C\u4F5C\u8005", file ? baseName(file) ?? clipShortText(file, 20) : void 0, true);
|
|
9757
|
+
}
|
|
9758
|
+
case "describe":
|
|
9759
|
+
return result("\u67E5\u7248\u672C\u63CF\u8FF0", void 0, true);
|
|
9760
|
+
case "count-objects":
|
|
9761
|
+
return result("\u7EDF\u8BA1\u5BF9\u8C61", void 0, true);
|
|
9762
|
+
case "shortlog":
|
|
9763
|
+
return result("\u6C47\u603B\u63D0\u4EA4", void 0, true);
|
|
9764
|
+
case "check-ignore": {
|
|
9765
|
+
const file = nonFlagArgs(args).find(isSafeGitTarget);
|
|
9766
|
+
return result("\u67E5\u5FFD\u7565\u89C4\u5219", file ? baseName(file) : void 0, true);
|
|
9767
|
+
}
|
|
9768
|
+
case "reflog": {
|
|
9769
|
+
const op = nonFlagArgs(args)[0];
|
|
9770
|
+
if (op === "expire" || op === "delete" || op === "drop") return null;
|
|
9771
|
+
return result("\u67E5\u5F15\u7528\u65E5\u5FD7", void 0, true);
|
|
9772
|
+
}
|
|
9773
|
+
case "remote": {
|
|
9774
|
+
if (nonFlagArgs(args).length) return null;
|
|
9775
|
+
if (args.some((t2) => !["-v", "--verbose"].includes(t2))) return null;
|
|
9776
|
+
return result("\u67E5\u8FDC\u7AEF", void 0, true);
|
|
9777
|
+
}
|
|
9778
|
+
case "config": {
|
|
9779
|
+
const isReadForm = args.some((t2) => ["--get", "--get-all", "--get-regexp", "--list", "-l", "--show-origin"].includes(t2) || /^--(?:get|get-all|get-regexp|list|show-origin)(?:=|$)/.test(t2));
|
|
9780
|
+
if (!isReadForm) return null;
|
|
9781
|
+
if (args.some((t2) => ["--unset", "--unset-all", "--add", "--replace-all", "--rename-section", "--remove-section", "-e", "--edit"].includes(t2) || /^--(?:unset|unset-all|add|replace-all|rename-section|remove-section|edit)(?:=|$)/.test(t2))) return null;
|
|
9782
|
+
const key = nonFlagArgs(args)[0];
|
|
9783
|
+
return result("\u67E5\u914D\u7F6E", key && isSafeGitTarget(key) ? clipShortText(key, 24) : void 0, true);
|
|
9784
|
+
}
|
|
9690
9785
|
case "show": {
|
|
9691
9786
|
const target = nonFlagArgs(args)[0];
|
|
9692
9787
|
return result("\u770B\u63D0\u4EA4", isSafeGitTarget(target) ? clipShortText(target, 20) : void 0, true);
|
|
@@ -9750,6 +9845,23 @@ function baseName(path2) {
|
|
|
9750
9845
|
const base = parts.pop();
|
|
9751
9846
|
return base || void 0;
|
|
9752
9847
|
}
|
|
9848
|
+
function lastFileOperand(tokens2, valueFlags) {
|
|
9849
|
+
let file;
|
|
9850
|
+
for (let i = 0; i < tokens2.length; i++) {
|
|
9851
|
+
const tok = tokens2[i];
|
|
9852
|
+
if (tok === "--") {
|
|
9853
|
+
const rest = tokens2.slice(i + 1);
|
|
9854
|
+
if (rest.length) file = rest[rest.length - 1];
|
|
9855
|
+
break;
|
|
9856
|
+
}
|
|
9857
|
+
if (tok.startsWith("-")) {
|
|
9858
|
+
if (!tok.includes("=") && valueFlags.has(tok)) i++;
|
|
9859
|
+
continue;
|
|
9860
|
+
}
|
|
9861
|
+
file = tok;
|
|
9862
|
+
}
|
|
9863
|
+
return file;
|
|
9864
|
+
}
|
|
9753
9865
|
function splitSegments(command) {
|
|
9754
9866
|
const segments = [];
|
|
9755
9867
|
let current = "";
|
|
@@ -10264,11 +10376,79 @@ function classifySegment(segment) {
|
|
|
10264
10376
|
}
|
|
10265
10377
|
case "ps":
|
|
10266
10378
|
return { verb: "\u67E5\u8FDB\u7A0B", readOnly: true };
|
|
10267
|
-
case "sha256sum":
|
|
10379
|
+
case "sha256sum":
|
|
10380
|
+
case "sha1sum":
|
|
10381
|
+
case "md5sum":
|
|
10382
|
+
case "sha512sum":
|
|
10383
|
+
case "b2sum":
|
|
10384
|
+
case "cksum": {
|
|
10268
10385
|
const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
|
|
10269
10386
|
const file = tokens2?.find((t2) => !t2.startsWith("-"));
|
|
10270
10387
|
return { verb: "\u7B97\u6821\u9A8C\u548C", target: file ? baseName(file) : void 0, readOnly: true };
|
|
10271
10388
|
}
|
|
10389
|
+
case "du": {
|
|
10390
|
+
const tokens2 = shellWords(stripTrailingPipe(rest));
|
|
10391
|
+
if (!tokens2) return null;
|
|
10392
|
+
const path2 = lastFileOperand(tokens2, /* @__PURE__ */ new Set(["-d", "--max-depth", "-B", "--block-size", "--files0-from", "--exclude", "-t", "--threshold", "--time-style"]));
|
|
10393
|
+
return { verb: "\u67E5\u78C1\u76D8\u5360\u7528", target: path2 ? baseName(path2) : void 0, readOnly: true };
|
|
10394
|
+
}
|
|
10395
|
+
case "df":
|
|
10396
|
+
return { verb: "\u67E5\u78C1\u76D8\u7A7A\u95F4", readOnly: true };
|
|
10397
|
+
case "free":
|
|
10398
|
+
return { verb: "\u67E5\u5185\u5B58", readOnly: true };
|
|
10399
|
+
case "nproc":
|
|
10400
|
+
return { verb: "\u67E5 CPU \u6570", readOnly: true };
|
|
10401
|
+
case "uptime":
|
|
10402
|
+
return { verb: "\u67E5\u8D1F\u8F7D", readOnly: true };
|
|
10403
|
+
case "id": {
|
|
10404
|
+
const tokens2 = shellWords(stripTrailingPipe(rest));
|
|
10405
|
+
if (!tokens2) return null;
|
|
10406
|
+
const user = tokens2.find((t2) => !t2.startsWith("-"));
|
|
10407
|
+
return { verb: "\u67E5\u8EAB\u4EFD", target: user ? clipShortText(user, 24) : void 0, readOnly: true };
|
|
10408
|
+
}
|
|
10409
|
+
case "hostname": {
|
|
10410
|
+
const tokens2 = shellWords(stripTrailingPipe(rest));
|
|
10411
|
+
if (!tokens2) return null;
|
|
10412
|
+
if (tokens2.some((t2) => ["-F", "--file", "-b", "--boot"].includes(t2))) return null;
|
|
10413
|
+
if (tokens2.some((t2) => !t2.startsWith("-"))) return null;
|
|
10414
|
+
return { verb: "\u67E5\u4E3B\u673A\u540D", readOnly: true };
|
|
10415
|
+
}
|
|
10416
|
+
case "date": {
|
|
10417
|
+
const tokens2 = shellWords(stripTrailingPipe(rest));
|
|
10418
|
+
if (!tokens2) return null;
|
|
10419
|
+
if (tokens2.some((t2) => ["-s", "--set", "-f", "--file"].includes(t2) || t2.startsWith("--set="))) return null;
|
|
10420
|
+
const valueFlags = /* @__PURE__ */ new Set(["-d", "--date", "-r", "--reference"]);
|
|
10421
|
+
const positionals = [];
|
|
10422
|
+
for (let i = 0; i < tokens2.length; i++) {
|
|
10423
|
+
const tok = tokens2[i];
|
|
10424
|
+
if (tok.startsWith("-")) {
|
|
10425
|
+
if (!tok.includes("=") && valueFlags.has(tok)) i++;
|
|
10426
|
+
continue;
|
|
10427
|
+
}
|
|
10428
|
+
positionals.push(tok);
|
|
10429
|
+
}
|
|
10430
|
+
if (positionals.some((t2) => !t2.startsWith("+"))) return null;
|
|
10431
|
+
return { verb: "\u67E5\u65F6\u95F4", readOnly: true };
|
|
10432
|
+
}
|
|
10433
|
+
case "basename": {
|
|
10434
|
+
const tokens2 = shellWords(stripTrailingPipe(rest));
|
|
10435
|
+
if (!tokens2) return null;
|
|
10436
|
+
const path2 = tokens2.find((t2) => !t2.startsWith("-"));
|
|
10437
|
+
return { verb: "\u53D6\u6587\u4EF6\u540D", target: path2 ? baseName(path2) : void 0, readOnly: true };
|
|
10438
|
+
}
|
|
10439
|
+
case "dirname": {
|
|
10440
|
+
const tokens2 = shellWords(stripTrailingPipe(rest));
|
|
10441
|
+
if (!tokens2) return null;
|
|
10442
|
+
const path2 = tokens2.find((t2) => !t2.startsWith("-"));
|
|
10443
|
+
return { verb: "\u53D6\u6240\u5728\u76EE\u5F55", target: path2 ? clipShortText(path2, 24) : void 0, readOnly: true };
|
|
10444
|
+
}
|
|
10445
|
+
case "diff":
|
|
10446
|
+
case "cmp": {
|
|
10447
|
+
const tokens2 = shellWords(stripTrailingPipe(rest));
|
|
10448
|
+
if (!tokens2) return null;
|
|
10449
|
+
const file = lastFileOperand(tokens2, /* @__PURE__ */ new Set(["-x", "--exclude", "-I", "--ignore-matching-lines", "-U", "--unified", "-C", "--context", "--label", "-L", "--to-file", "--from-file", "-S", "--starting-file", "--horizon-lines", "--tabsize", "-t"]));
|
|
10450
|
+
return { verb: "\u5BF9\u6BD4\u6587\u4EF6", target: file ? baseName(file) : void 0, readOnly: true };
|
|
10451
|
+
}
|
|
10272
10452
|
case "dnf":
|
|
10273
10453
|
case "yum": {
|
|
10274
10454
|
const sub = rest.split(/\s+/)[0] ?? "";
|
|
@@ -10309,7 +10489,7 @@ function classifySegment(segment) {
|
|
|
10309
10489
|
case "awk":
|
|
10310
10490
|
return { verb: "\u5904\u7406\u6587\u672C", readOnly: true };
|
|
10311
10491
|
case "find": {
|
|
10312
|
-
if (/(?:^|\s)(?:-delete|-exec|-execdir|-ok|-okdir)(?:\s|$)/.test(rest)) return null;
|
|
10492
|
+
if (/(?:^|\s)(?:-delete|-exec|-execdir|-ok|-okdir|-fprint|-fprint0|-fprintf|-fls)(?:\s|$)/.test(rest)) return null;
|
|
10313
10493
|
return { verb: "\u67E5\u627E\u6587\u4EF6", readOnly: true };
|
|
10314
10494
|
}
|
|
10315
10495
|
case "curl":
|
|
@@ -10321,6 +10501,7 @@ function classifySegment(segment) {
|
|
|
10321
10501
|
case "yarn": {
|
|
10322
10502
|
const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]) ?? rest.split(/\s+/).filter(Boolean);
|
|
10323
10503
|
const sub = tokens2[0] ?? "";
|
|
10504
|
+
if (tokens2.length === 1 && ["-v", "-V", "--version"].includes(sub)) return { verb: "\u67E5\u7248\u672C", readOnly: true };
|
|
10324
10505
|
if (sub === "test") {
|
|
10325
10506
|
const target = tokens2.slice(1).find((t2) => !t2.startsWith("-"));
|
|
10326
10507
|
return { verb: "\u8DD1\u6D4B\u8BD5", target: target ? baseName(target) : void 0, readOnly: false };
|
|
@@ -10346,6 +10527,7 @@ function classifySegment(segment) {
|
|
|
10346
10527
|
case "python":
|
|
10347
10528
|
case "python3": {
|
|
10348
10529
|
const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]) ?? [];
|
|
10530
|
+
if (tokens2.length === 1 && ["-V", "-v", "--version"].includes(tokens2[0])) return { verb: "\u67E5\u7248\u672C", readOnly: true };
|
|
10349
10531
|
if (tokens2.includes("--inline-heredoc") || /(?:^|\s)-[A-Za-z]*c(?:\s|$)/.test(rest)) {
|
|
10350
10532
|
return { verb: "\u6267\u884C\u5185\u8054\u811A\u672C (Python)", readOnly: false };
|
|
10351
10533
|
}
|
|
@@ -10354,6 +10536,8 @@ function classifySegment(segment) {
|
|
|
10354
10536
|
}
|
|
10355
10537
|
case "node": {
|
|
10356
10538
|
if (/(?:^|\s)-[A-Za-z]*e(?:\s|$)/.test(rest)) return null;
|
|
10539
|
+
const nodeTokens = shellWords(stripTrailingPipe(rest));
|
|
10540
|
+
if (nodeTokens?.length === 1 && ["-v", "-V", "--version"].includes(nodeTokens[0])) return { verb: "\u67E5\u7248\u672C", readOnly: true };
|
|
10357
10541
|
const script = rest.split(/\s+/).find((t2) => t2 && !t2.startsWith("-"));
|
|
10358
10542
|
return { verb: "\u6267\u884C\u811A\u672C", target: baseName(script ?? ""), readOnly: false };
|
|
10359
10543
|
}
|
|
@@ -10512,6 +10696,8 @@ var PIPELINE_FILTER_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
10512
10696
|
"nl",
|
|
10513
10697
|
"column",
|
|
10514
10698
|
"grep",
|
|
10699
|
+
"egrep",
|
|
10700
|
+
"fgrep",
|
|
10515
10701
|
"rg",
|
|
10516
10702
|
"ag",
|
|
10517
10703
|
"ack",
|
|
@@ -10520,7 +10706,28 @@ var PIPELINE_FILTER_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
10520
10706
|
"more",
|
|
10521
10707
|
"bat",
|
|
10522
10708
|
"awk",
|
|
10523
|
-
"sed"
|
|
10709
|
+
"sed",
|
|
10710
|
+
// 纯 stdout 文本/校验和工具:只读 stdin/文件,没有输出文件参数
|
|
10711
|
+
// (写文件的 tee/xargs/split/xxd 之类**不在此列**)。
|
|
10712
|
+
"diff",
|
|
10713
|
+
"cmp",
|
|
10714
|
+
"comm",
|
|
10715
|
+
"paste",
|
|
10716
|
+
"join",
|
|
10717
|
+
"fold",
|
|
10718
|
+
"expand",
|
|
10719
|
+
"unexpand",
|
|
10720
|
+
"tac",
|
|
10721
|
+
"rev",
|
|
10722
|
+
"strings",
|
|
10723
|
+
"od",
|
|
10724
|
+
"base64",
|
|
10725
|
+
"md5sum",
|
|
10726
|
+
"sha1sum",
|
|
10727
|
+
"sha256sum",
|
|
10728
|
+
"sha512sum",
|
|
10729
|
+
"b2sum",
|
|
10730
|
+
"cksum"
|
|
10524
10731
|
]);
|
|
10525
10732
|
function hasNonFilterPipeline(command) {
|
|
10526
10733
|
let quote = null;
|
|
@@ -11727,7 +11934,7 @@ function normalToolGistRaw(event) {
|
|
|
11727
11934
|
if (query2 || path3) return formatSearchItemQuery(query2, path3);
|
|
11728
11935
|
}
|
|
11729
11936
|
if (isRunToolName(toolName)) {
|
|
11730
|
-
const command2 = typeof metadata.command === "string" ? metadata.command : "";
|
|
11937
|
+
const command2 = typeof metadata.command === "string" ? metadata.command : typeof metadata.cmd === "string" ? metadata.cmd : "";
|
|
11731
11938
|
if (command2) {
|
|
11732
11939
|
const gist = summarizeShellCommand(command2);
|
|
11733
11940
|
if (gist) return truncateByDisplayWidth(redactSecrets(gist.summary), normalRunGistMaxWidth());
|
|
@@ -11751,8 +11958,8 @@ function normalToolGistRaw(event) {
|
|
|
11751
11958
|
function normalToolGist(event) {
|
|
11752
11959
|
return withholdIfSecretLike(normalToolGistRaw(event));
|
|
11753
11960
|
}
|
|
11754
|
-
function formatNormalToolDuration(elapsedMs) {
|
|
11755
|
-
if (typeof elapsedMs !== "number" || !Number.isFinite(elapsedMs) || elapsedMs
|
|
11961
|
+
function formatNormalToolDuration(elapsedMs, includeThreshold = false) {
|
|
11962
|
+
if (typeof elapsedMs !== "number" || !Number.isFinite(elapsedMs) || elapsedMs < 500 || elapsedMs === 500 && !includeThreshold) return "";
|
|
11756
11963
|
if (elapsedMs < 1e3) return `${Math.round(elapsedMs)}ms`;
|
|
11757
11964
|
return `${(elapsedMs / 1e3).toFixed(1)}s`;
|
|
11758
11965
|
}
|
|
@@ -11915,8 +12122,9 @@ var TUI_TREE_TOOLS = {
|
|
|
11915
12122
|
Search: ["exa_search", "globFiles", "searchFiles", "codeSearch"],
|
|
11916
12123
|
Fetch: ["fetchWebpage"]
|
|
11917
12124
|
};
|
|
12125
|
+
var RUN_WINDOW_SIZE = 3;
|
|
11918
12126
|
function toolDetails(event, line) {
|
|
11919
|
-
const command = event.metadata?.command;
|
|
12127
|
+
const command = event.metadata?.command ?? event.metadata?.cmd;
|
|
11920
12128
|
return isRunToolName(event.toolName) && typeof command === "string" ? `${toolRowDetailLine(line)}${safeApprovalMultilineText(command)}
|
|
11921
12129
|
` : toolRowDetailLine(line);
|
|
11922
12130
|
}
|
|
@@ -11937,6 +12145,43 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
|
|
|
11937
12145
|
let scope = 0;
|
|
11938
12146
|
let lastFamilyId;
|
|
11939
12147
|
let tree = null;
|
|
12148
|
+
let runGroup;
|
|
12149
|
+
const formatRunGroup = (event, line) => {
|
|
12150
|
+
const group = runGroup ??= { count: 0, elapsedMs: 0, recent: [], rows: [] };
|
|
12151
|
+
const elapsed = event.elapsedMs;
|
|
12152
|
+
group.count++;
|
|
12153
|
+
if (typeof elapsed === "number" && Number.isFinite(elapsed) && elapsed > 0) group.elapsedMs += elapsed;
|
|
12154
|
+
const gist = safeAskText(normalToolGist(event)) || toolLabel(event.toolName);
|
|
12155
|
+
group.recent.push({ gist, duration: formatNormalToolDuration(elapsed) });
|
|
12156
|
+
if (group.recent.length > RUN_WINDOW_SIZE) group.recent.shift();
|
|
12157
|
+
const payload = { kind: "Run", summary: "", fallback: line, details: toolDetails(event, line) };
|
|
12158
|
+
if (group.count <= RUN_WINDOW_SIZE) {
|
|
12159
|
+
group.rows.push(line.replace(/\n$/, ""));
|
|
12160
|
+
payload.appendOnly = true;
|
|
12161
|
+
} else {
|
|
12162
|
+
const budget = Math.max(1, resolveHistoryLayoutGeometry(process.stdout.columns).contentWidth - displayWidth("\u25C8 "));
|
|
12163
|
+
const fit = (text) => themeText(truncateByDisplayWidth(text, budget), "muted", colorEnabled);
|
|
12164
|
+
const total = formatNormalToolDuration(group.elapsedMs, true);
|
|
12165
|
+
const timing = total ? t("runGroupTiming", total) : "";
|
|
12166
|
+
const count = String(group.count);
|
|
12167
|
+
const prefix = `\u25B8 ${toolIcon("execShell")} \xB7 `;
|
|
12168
|
+
payload.previousLines = group.rows;
|
|
12169
|
+
payload.lines = [
|
|
12170
|
+
fit(prefix + t("runGroupHeader", count, timing)),
|
|
12171
|
+
fit(` \u2026 ${t("runGroupCollapsed", String(group.count - RUN_WINDOW_SIZE))}`),
|
|
12172
|
+
...group.recent.map(({ gist: gist2, duration }) => {
|
|
12173
|
+
const leafPrefix = " \u2713 ";
|
|
12174
|
+
const leafTail = duration ? ` \xB7 ${duration}` : "";
|
|
12175
|
+
const gistBudget = Math.max(0, budget - displayWidth(leafPrefix + leafTail));
|
|
12176
|
+
return fit(`${leafPrefix}${truncateByDisplayWidth(gist2, gistBudget)}${leafTail}`);
|
|
12177
|
+
})
|
|
12178
|
+
];
|
|
12179
|
+
payload.finalizedSummary = fit(prefix + t("runGroupFinal", count, timing));
|
|
12180
|
+
group.rows = payload.lines;
|
|
12181
|
+
}
|
|
12182
|
+
return `${TUI_TREE_MARKER}${JSON.stringify(payload)}${TUI_TREE_END}
|
|
12183
|
+
`;
|
|
12184
|
+
};
|
|
11940
12185
|
const treeKind = (name) => Object.keys(TUI_TREE_TOOLS).find((kind) => TUI_TREE_TOOLS[kind].includes(name)) ?? null;
|
|
11941
12186
|
const treeLine = (kind, counts, items, fallback, details) => {
|
|
11942
12187
|
const activeKinds = Object.keys(counts).filter((k) => counts[k] > 0);
|
|
@@ -11980,16 +12225,21 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
|
|
|
11980
12225
|
`;
|
|
11981
12226
|
};
|
|
11982
12227
|
const formatTreeEvent = (event, call) => {
|
|
11983
|
-
if (event.type === "tool-error")
|
|
12228
|
+
if (event.type === "tool-error") {
|
|
12229
|
+
tree = null;
|
|
12230
|
+
runGroup = void 0;
|
|
12231
|
+
}
|
|
11984
12232
|
if (!opts.tuiTrees || event.type !== "tool-result") return null;
|
|
11985
12233
|
if (isFailedToolResult(event) || event.metadata?.failed || event.metadata?.timedOut || readActionGate(event.metadata?.actionGate) || event.metadata?.permissionRequest) {
|
|
11986
12234
|
tree = null;
|
|
12235
|
+
runGroup = void 0;
|
|
11987
12236
|
return null;
|
|
11988
12237
|
}
|
|
11989
12238
|
const name = event.toolName || call?.toolName || "tool";
|
|
11990
12239
|
const kind = treeKind(name);
|
|
11991
12240
|
if (!kind) {
|
|
11992
12241
|
tree = null;
|
|
12242
|
+
runGroup = void 0;
|
|
11993
12243
|
return null;
|
|
11994
12244
|
}
|
|
11995
12245
|
const activity = projectToolActivity({
|
|
@@ -12009,8 +12259,14 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
|
|
|
12009
12259
|
const isReadOnlyExploration = kind === "Read" || kind === "Search" || kind === "Fetch" || kind === "Run" && activity.readOnly === true;
|
|
12010
12260
|
if (!isReadOnlyExploration) {
|
|
12011
12261
|
tree = null;
|
|
12012
|
-
|
|
12262
|
+
if (event.metadata?.actionGate) {
|
|
12263
|
+
runGroup = void 0;
|
|
12264
|
+
return null;
|
|
12265
|
+
}
|
|
12266
|
+
const runEvent = name === event.toolName ? event : { ...event, toolName: name };
|
|
12267
|
+
return formatRunGroup(runEvent, formatNormalToolLine(runEvent, call, colorEnabled, opts));
|
|
12013
12268
|
}
|
|
12269
|
+
runGroup = void 0;
|
|
12014
12270
|
let item = "";
|
|
12015
12271
|
const m = event.metadata ?? {};
|
|
12016
12272
|
if (kind === "Run") {
|
|
@@ -12042,6 +12298,7 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
|
|
|
12042
12298
|
};
|
|
12043
12299
|
const format = (event) => {
|
|
12044
12300
|
if (event.type === "tool-call") {
|
|
12301
|
+
if (!isRunToolName(event.toolName)) runGroup = void 0;
|
|
12045
12302
|
pending.set(event.toolCallId, {
|
|
12046
12303
|
toolName: event.toolName,
|
|
12047
12304
|
argumentsPreview: event.argumentsPreview
|
|
@@ -12066,10 +12323,12 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
|
|
|
12066
12323
|
};
|
|
12067
12324
|
format.reset = () => {
|
|
12068
12325
|
tree = null;
|
|
12326
|
+
runGroup = void 0;
|
|
12069
12327
|
lastFamilyId = void 0;
|
|
12070
12328
|
scope++;
|
|
12071
12329
|
};
|
|
12072
12330
|
format.consume = (event) => {
|
|
12331
|
+
runGroup = void 0;
|
|
12073
12332
|
if (event.type === "tool-call") {
|
|
12074
12333
|
pending.set(event.toolCallId, {
|
|
12075
12334
|
toolName: event.toolName,
|
|
@@ -12396,7 +12655,7 @@ function createCliTurnOutput(params) {
|
|
|
12396
12655
|
};
|
|
12397
12656
|
const writeVisibleAssistantChunk = (chunk) => {
|
|
12398
12657
|
if (!chunk) return;
|
|
12399
|
-
if (!assistantLabelManaged) formatToolEvent.reset?.();
|
|
12658
|
+
if (!assistantLabelManaged || tuiNarrationPromoted) formatToolEvent.reset?.();
|
|
12400
12659
|
const parsed = processThinkChunk(chunk, thinkState);
|
|
12401
12660
|
thinkState = parsed.state;
|
|
12402
12661
|
if (!parsed.content && !parsed.reasoning) return;
|
|
@@ -12791,6 +13050,667 @@ ${t("agentRunStream.malformedToolCallRejectedNoDialog")}
|
|
|
12791
13050
|
};
|
|
12792
13051
|
}
|
|
12793
13052
|
|
|
13053
|
+
// packages/cli/client/callerPoolTop.ts
|
|
13054
|
+
function catalogEntryToPoolCandidate(entry, userId) {
|
|
13055
|
+
return {
|
|
13056
|
+
agentKey: entry.key,
|
|
13057
|
+
model: entry.model,
|
|
13058
|
+
requiresPaidApproval: isPlatformPaidAgentCall({
|
|
13059
|
+
agentConfig: {
|
|
13060
|
+
key: entry.key,
|
|
13061
|
+
// 自有 agent 的私有 key 形如 agent-<userId>-<id>:归属判据认这个形状。
|
|
13062
|
+
privateKey: entry.kind === "private" ? entry.key : void 0,
|
|
13063
|
+
model: entry.model,
|
|
13064
|
+
apiSource: entry.apiSource,
|
|
13065
|
+
cliProvider: entry.cliProvider
|
|
13066
|
+
},
|
|
13067
|
+
callerUserId: userId ?? void 0
|
|
13068
|
+
})
|
|
13069
|
+
};
|
|
13070
|
+
}
|
|
13071
|
+
function resolveCallerPoolTopFromCatalog(args) {
|
|
13072
|
+
const entries = args.entries;
|
|
13073
|
+
const userId = typeof args.userId === "string" ? args.userId.trim() : "";
|
|
13074
|
+
if (!entries || entries.length === 0 || !userId) return void 0;
|
|
13075
|
+
return isCallerAtFreePoolTop(
|
|
13076
|
+
{ model: args.model ?? null, agentKey: args.agentKey ?? null },
|
|
13077
|
+
entries.map((entry) => catalogEntryToPoolCandidate(entry, userId))
|
|
13078
|
+
);
|
|
13079
|
+
}
|
|
13080
|
+
function pickCallerPoolIdentityFromAgentConfig(args) {
|
|
13081
|
+
const asPart = (value) => {
|
|
13082
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
13083
|
+
return text.length > 0 ? text : null;
|
|
13084
|
+
};
|
|
13085
|
+
const config = args.agentConfig ?? null;
|
|
13086
|
+
return {
|
|
13087
|
+
agentKey: asPart(config?.key) ?? asPart(args.agentKey),
|
|
13088
|
+
model: asPart(config?.model) ?? asPart(args.modelOverride)
|
|
13089
|
+
};
|
|
13090
|
+
}
|
|
13091
|
+
var CLI_CALLER_POOL_TOP_LATCH_LIMIT = 64;
|
|
13092
|
+
var cliCallerPoolTopLatch = /* @__PURE__ */ new Map();
|
|
13093
|
+
var asLatchPart = (value) => {
|
|
13094
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
13095
|
+
return text.length > 0 ? text : "-";
|
|
13096
|
+
};
|
|
13097
|
+
function buildCliCallerPoolTopLatchKey(args) {
|
|
13098
|
+
const dialogId = typeof args.dialogId === "string" ? args.dialogId.trim() : "";
|
|
13099
|
+
if (!dialogId) return null;
|
|
13100
|
+
return [dialogId, asLatchPart(args.agentKey), asLatchPart(args.model)].join("\0");
|
|
13101
|
+
}
|
|
13102
|
+
function resolveLatchedCliCallerIsPoolTop(args) {
|
|
13103
|
+
const latchAgentKey = "latchAgentKey" in args ? args.latchAgentKey : args.agentKey;
|
|
13104
|
+
const latchModel = "latchModel" in args ? args.latchModel : args.model;
|
|
13105
|
+
const latchKey = buildCliCallerPoolTopLatchKey({
|
|
13106
|
+
dialogId: args.dialogId,
|
|
13107
|
+
agentKey: latchAgentKey,
|
|
13108
|
+
model: latchModel
|
|
13109
|
+
});
|
|
13110
|
+
if (!latchKey) return resolveCallerPoolTopFromCatalog(args);
|
|
13111
|
+
if (cliCallerPoolTopLatch.has(latchKey)) return cliCallerPoolTopLatch.get(latchKey);
|
|
13112
|
+
const resolved = resolveCallerPoolTopFromCatalog(args);
|
|
13113
|
+
cliCallerPoolTopLatch.set(latchKey, resolved);
|
|
13114
|
+
while (cliCallerPoolTopLatch.size > CLI_CALLER_POOL_TOP_LATCH_LIMIT) {
|
|
13115
|
+
const oldest = cliCallerPoolTopLatch.keys().next();
|
|
13116
|
+
if (oldest.done) break;
|
|
13117
|
+
cliCallerPoolTopLatch.delete(oldest.value);
|
|
13118
|
+
}
|
|
13119
|
+
return resolved;
|
|
13120
|
+
}
|
|
13121
|
+
|
|
13122
|
+
// packages/ai/agent/utils/sortUtils.ts
|
|
13123
|
+
function sortAgentsFavoriteOwnedPublic(items) {
|
|
13124
|
+
const map = /* @__PURE__ */ new Map();
|
|
13125
|
+
for (const item of items) {
|
|
13126
|
+
const existing = map.get(item.key);
|
|
13127
|
+
if (!existing) {
|
|
13128
|
+
map.set(item.key, { ...item });
|
|
13129
|
+
continue;
|
|
13130
|
+
}
|
|
13131
|
+
map.set(item.key, {
|
|
13132
|
+
...existing,
|
|
13133
|
+
...item,
|
|
13134
|
+
key: existing.key,
|
|
13135
|
+
favoritedAt: Math.max(existing.favoritedAt ?? 0, item.favoritedAt ?? 0) || void 0,
|
|
13136
|
+
isOwned: Boolean(existing.isOwned || item.isOwned),
|
|
13137
|
+
isPublic: Boolean(existing.isPublic || item.isPublic),
|
|
13138
|
+
updatedAt: Math.max(existing.updatedAt ?? 0, item.updatedAt ?? 0),
|
|
13139
|
+
order: existing.order ?? item.order
|
|
13140
|
+
});
|
|
13141
|
+
}
|
|
13142
|
+
const arr = Array.from(map.values());
|
|
13143
|
+
arr.sort((a, b) => {
|
|
13144
|
+
const aFav = a.favoritedAt != null && a.favoritedAt > 0;
|
|
13145
|
+
const bFav = b.favoritedAt != null && b.favoritedAt > 0;
|
|
13146
|
+
if (aFav !== bFav) return aFav ? -1 : 1;
|
|
13147
|
+
if (aFav && bFav) {
|
|
13148
|
+
const diff = (b.favoritedAt ?? 0) - (a.favoritedAt ?? 0);
|
|
13149
|
+
if (diff !== 0) return diff;
|
|
13150
|
+
}
|
|
13151
|
+
const aOwned = Boolean(a.isOwned);
|
|
13152
|
+
const bOwned = Boolean(b.isOwned);
|
|
13153
|
+
if (aOwned !== bOwned) return aOwned ? -1 : 1;
|
|
13154
|
+
const aPublic = Boolean(a.isPublic);
|
|
13155
|
+
const bPublic = Boolean(b.isPublic);
|
|
13156
|
+
if (aPublic !== bPublic) return aPublic ? -1 : 1;
|
|
13157
|
+
const tsDiff = (b.updatedAt ?? 0) - (a.updatedAt ?? 0);
|
|
13158
|
+
if (tsDiff !== 0) return tsDiff;
|
|
13159
|
+
const aOrder = a.order ?? Number.POSITIVE_INFINITY;
|
|
13160
|
+
const bOrder = b.order ?? Number.POSITIVE_INFINITY;
|
|
13161
|
+
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
13162
|
+
return a.key.localeCompare(b.key);
|
|
13163
|
+
});
|
|
13164
|
+
return arr;
|
|
13165
|
+
}
|
|
13166
|
+
|
|
13167
|
+
// packages/cli/tui/agentCatalog.ts
|
|
13168
|
+
var DEFAULT_TUI_AGENT_KEY = NOLO_DEFAULT_AGENT_KEY;
|
|
13169
|
+
function formatAgentSourceLabel(entry) {
|
|
13170
|
+
if (entry.kind === "platform" || entry.apiSource === "platform") return t("agentSourcePlatform");
|
|
13171
|
+
if (entry.apiSource === "cli") {
|
|
13172
|
+
return entry.cliProvider ? `${t("agentSourceSubscription")}(${entry.cliProvider})` : t("agentSourceSubscription");
|
|
13173
|
+
}
|
|
13174
|
+
if (entry.apiSource === "custom") return t("agentSourceApi");
|
|
13175
|
+
return t("agentSourcePlatform");
|
|
13176
|
+
}
|
|
13177
|
+
var PLATFORM_AGENTS = [
|
|
13178
|
+
{
|
|
13179
|
+
// 名称与模型都从 builtinAgentCatalog 派生:`/switch` 里的 nolo 项直接显示
|
|
13180
|
+
// 它实际指向的模型(当前 deepseek-flash),换代自动跟随。
|
|
13181
|
+
name: BUILTIN_NOLO_AGENT_NAME,
|
|
13182
|
+
key: DEFAULT_TUI_AGENT_KEY,
|
|
13183
|
+
model: BUILTIN_NOLO_AGENT_MODEL,
|
|
13184
|
+
kind: "platform",
|
|
13185
|
+
description: "one assistant that routes work across your agents and data"
|
|
13186
|
+
}
|
|
13187
|
+
];
|
|
13188
|
+
function resolveCatalogPlatformAgents(_env = process.env) {
|
|
13189
|
+
return PLATFORM_AGENTS;
|
|
13190
|
+
}
|
|
13191
|
+
function toUpdatedAt(value) {
|
|
13192
|
+
if (value == null) return 0;
|
|
13193
|
+
const parsed = new Date(value).getTime();
|
|
13194
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
13195
|
+
}
|
|
13196
|
+
function listedAgentToCatalogEntry(agent) {
|
|
13197
|
+
return {
|
|
13198
|
+
name: agent.name,
|
|
13199
|
+
key: agent.privateKey,
|
|
13200
|
+
model: agent.model,
|
|
13201
|
+
kind: "private",
|
|
13202
|
+
updatedAt: toUpdatedAt(agent.updatedAt),
|
|
13203
|
+
...agent.apiSource ? { apiSource: agent.apiSource } : {},
|
|
13204
|
+
...agent.cliProvider ? { cliProvider: agent.cliProvider } : {},
|
|
13205
|
+
...agent.quota ? { quota: agent.quota } : {}
|
|
13206
|
+
};
|
|
13207
|
+
}
|
|
13208
|
+
function mergeCatalogEntries(currentKey, platformAgents, privateAgents, favoritedAtByKey = {}) {
|
|
13209
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13210
|
+
const merged = [];
|
|
13211
|
+
const push = (entry) => {
|
|
13212
|
+
if (seen.has(entry.key)) return;
|
|
13213
|
+
seen.add(entry.key);
|
|
13214
|
+
const favoritedAt = favoritedAtByKey[entry.key];
|
|
13215
|
+
merged.push(favoritedAt ? { ...entry, favoritedAt } : entry);
|
|
13216
|
+
};
|
|
13217
|
+
const current = [...platformAgents, ...privateAgents].find((entry) => entry.key === currentKey) ?? null;
|
|
13218
|
+
if (current) push(current);
|
|
13219
|
+
for (const entry of platformAgents) {
|
|
13220
|
+
if (entry.key !== currentKey) push(entry);
|
|
13221
|
+
}
|
|
13222
|
+
const sortablePrivate = privateAgents.map((entry) => ({
|
|
13223
|
+
key: entry.key,
|
|
13224
|
+
...favoritedAtByKey[entry.key] !== void 0 ? { favoritedAt: favoritedAtByKey[entry.key] } : {},
|
|
13225
|
+
isOwned: true,
|
|
13226
|
+
updatedAt: entry.updatedAt ?? 0
|
|
13227
|
+
}));
|
|
13228
|
+
const sortedKeys = sortAgentsFavoriteOwnedPublic(sortablePrivate);
|
|
13229
|
+
const sortedKeyOrder = new Map(sortedKeys.map((item, i) => [item.key, i]));
|
|
13230
|
+
const sortedPrivate = [...privateAgents].sort(
|
|
13231
|
+
(a, b) => (sortedKeyOrder.get(a.key) ?? 0) - (sortedKeyOrder.get(b.key) ?? 0)
|
|
13232
|
+
);
|
|
13233
|
+
for (const entry of sortedPrivate) {
|
|
13234
|
+
if (entry.key !== currentKey) push(entry);
|
|
13235
|
+
}
|
|
13236
|
+
return merged;
|
|
13237
|
+
}
|
|
13238
|
+
function formatUnavailableFavoritesNotice(unavailableFavoriteCount) {
|
|
13239
|
+
if (!Number.isFinite(unavailableFavoriteCount) || unavailableFavoriteCount <= 0) {
|
|
13240
|
+
return null;
|
|
13241
|
+
}
|
|
13242
|
+
return t(
|
|
13243
|
+
"agentCatalogUnavailableFavorites",
|
|
13244
|
+
String(Math.floor(unavailableFavoriteCount))
|
|
13245
|
+
);
|
|
13246
|
+
}
|
|
13247
|
+
var agentCatalogCache = null;
|
|
13248
|
+
var lastRefresh = null;
|
|
13249
|
+
function getAgentCatalogRefreshStatus(args = {}) {
|
|
13250
|
+
const env = args.env ?? process.env;
|
|
13251
|
+
const token = resolveAuthToken([], env);
|
|
13252
|
+
const key = `${token ? parseUserIdFromAuthToken(token) ?? "anon" : "anon"}|${resolveServerUrl(env)}`;
|
|
13253
|
+
return lastRefresh?.cacheKey === key ? lastRefresh.status : null;
|
|
13254
|
+
}
|
|
13255
|
+
var agentCatalogRefreshInFlight = null;
|
|
13256
|
+
var agentCatalogGeneration = 0;
|
|
13257
|
+
var agentCatalogRawLoadInFlight = /* @__PURE__ */ new Map();
|
|
13258
|
+
var AGENT_CATALOG_FRESH_MS = 15e3;
|
|
13259
|
+
var AGENT_CATALOG_MAX_STALE_MS = 5 * 6e4;
|
|
13260
|
+
var AGENT_CATALOG_FOREGROUND_DEADLINE_MS = 2500;
|
|
13261
|
+
var AGENT_CATALOG_BACKGROUND_DEADLINE_MS = 8e3;
|
|
13262
|
+
function resolveCatalogDeadlineMs(kind, env) {
|
|
13263
|
+
const override = Number.parseInt(env.NOLO_TUI_CATALOG_DEADLINE_MS ?? "", 10);
|
|
13264
|
+
if (Number.isFinite(override) && override > 0) return override;
|
|
13265
|
+
return kind === "foreground" ? AGENT_CATALOG_FOREGROUND_DEADLINE_MS : AGENT_CATALOG_BACKGROUND_DEADLINE_MS;
|
|
13266
|
+
}
|
|
13267
|
+
var SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES = 1;
|
|
13268
|
+
var SERVER_COOLDOWN_MS = 5 * 6e4;
|
|
13269
|
+
var serverHealth = /* @__PURE__ */ new Map();
|
|
13270
|
+
var serverHealthNow = () => Date.now();
|
|
13271
|
+
function filterHealthyServers(serverUrls) {
|
|
13272
|
+
const now = serverHealthNow();
|
|
13273
|
+
const healthy = serverUrls.filter((url) => {
|
|
13274
|
+
const state2 = serverHealth.get(url);
|
|
13275
|
+
if (!state2) return true;
|
|
13276
|
+
return !(state2.consecutiveFailures >= SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES && now - state2.trippedAt < SERVER_COOLDOWN_MS);
|
|
13277
|
+
});
|
|
13278
|
+
return healthy.length > 0 ? healthy : serverUrls;
|
|
13279
|
+
}
|
|
13280
|
+
function keepPrimaryServer(serverUrls, primary) {
|
|
13281
|
+
return serverUrls.includes(primary) ? serverUrls : [primary, ...serverUrls];
|
|
13282
|
+
}
|
|
13283
|
+
function recordServerFailures(failures) {
|
|
13284
|
+
const now = serverHealthNow();
|
|
13285
|
+
for (const failure of failures) {
|
|
13286
|
+
const state2 = serverHealth.get(failure.serverUrl) ?? {
|
|
13287
|
+
consecutiveFailures: 0,
|
|
13288
|
+
trippedAt: 0
|
|
13289
|
+
};
|
|
13290
|
+
state2.consecutiveFailures += 1;
|
|
13291
|
+
if (state2.consecutiveFailures >= SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES) {
|
|
13292
|
+
state2.trippedAt = now;
|
|
13293
|
+
}
|
|
13294
|
+
serverHealth.set(failure.serverUrl, state2);
|
|
13295
|
+
}
|
|
13296
|
+
}
|
|
13297
|
+
function recordServerSuccesses(serverUrls) {
|
|
13298
|
+
for (const url of serverUrls) serverHealth.delete(url);
|
|
13299
|
+
}
|
|
13300
|
+
function withFetchDeadline(fetchImpl, deadlineMs) {
|
|
13301
|
+
return async (input, init) => {
|
|
13302
|
+
let timer;
|
|
13303
|
+
const deadline = new Promise((_, reject) => {
|
|
13304
|
+
timer = setTimeout(
|
|
13305
|
+
() => reject(new Error(`catalog fetch deadline exceeded (${deadlineMs}ms)`)),
|
|
13306
|
+
deadlineMs
|
|
13307
|
+
);
|
|
13308
|
+
});
|
|
13309
|
+
const signal = init?.signal;
|
|
13310
|
+
let onAbort;
|
|
13311
|
+
let aborted = null;
|
|
13312
|
+
if (signal) {
|
|
13313
|
+
if (signal.aborted) {
|
|
13314
|
+
throw signal.reason ?? new Error("catalog fetch aborted");
|
|
13315
|
+
}
|
|
13316
|
+
aborted = new Promise((_, reject) => {
|
|
13317
|
+
onAbort = () => reject(signal.reason ?? new Error("catalog fetch aborted"));
|
|
13318
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
13319
|
+
});
|
|
13320
|
+
}
|
|
13321
|
+
try {
|
|
13322
|
+
const response = await Promise.race([
|
|
13323
|
+
fetchImpl(input, init),
|
|
13324
|
+
deadline,
|
|
13325
|
+
...aborted ? [aborted] : []
|
|
13326
|
+
]);
|
|
13327
|
+
const text = await Promise.race([
|
|
13328
|
+
response.text(),
|
|
13329
|
+
deadline,
|
|
13330
|
+
...aborted ? [aborted] : []
|
|
13331
|
+
]);
|
|
13332
|
+
return new Response(text, {
|
|
13333
|
+
status: response.status,
|
|
13334
|
+
statusText: response.statusText,
|
|
13335
|
+
headers: response.headers
|
|
13336
|
+
});
|
|
13337
|
+
} finally {
|
|
13338
|
+
if (timer) clearTimeout(timer);
|
|
13339
|
+
if (signal && onAbort) signal.removeEventListener("abort", onAbort);
|
|
13340
|
+
}
|
|
13341
|
+
};
|
|
13342
|
+
}
|
|
13343
|
+
function readCachedAgentCatalogEntries() {
|
|
13344
|
+
return agentCatalogCache?.entries ?? null;
|
|
13345
|
+
}
|
|
13346
|
+
function hasWarmAgentCatalogCache(args = {}) {
|
|
13347
|
+
const env = args.env ?? process.env;
|
|
13348
|
+
const authToken = resolveAuthToken([], env);
|
|
13349
|
+
const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
|
|
13350
|
+
const cacheKey = `${userId ?? "anon"}|${resolveServerUrl(env)}`;
|
|
13351
|
+
return agentCatalogCache?.cacheKey === cacheKey && Date.now() - agentCatalogCache.at < AGENT_CATALOG_MAX_STALE_MS;
|
|
13352
|
+
}
|
|
13353
|
+
async function loadAgentCatalog(args) {
|
|
13354
|
+
return (await loadAgentCatalogWithNotices(args)).entries;
|
|
13355
|
+
}
|
|
13356
|
+
async function loadAgentCatalogWithNotices(args) {
|
|
13357
|
+
const env = args.env ?? process.env;
|
|
13358
|
+
const authToken = resolveAuthToken([], env);
|
|
13359
|
+
const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
|
|
13360
|
+
const cacheKey = `${userId ?? "anon"}|${resolveServerUrl(env)}`;
|
|
13361
|
+
const cached = agentCatalogCache?.cacheKey === cacheKey ? agentCatalogCache : null;
|
|
13362
|
+
if (cached && !args.fresh && Date.now() - cached.at < AGENT_CATALOG_MAX_STALE_MS) {
|
|
13363
|
+
const refreshStatus = getAgentCatalogRefreshStatus({ env });
|
|
13364
|
+
if (args.revalidateInBackground || Date.now() - cached.at >= AGENT_CATALOG_FRESH_MS) {
|
|
13365
|
+
refreshAgentCatalogInBackground(args, env, cacheKey);
|
|
13366
|
+
}
|
|
13367
|
+
if (args.currentKey && cached.entries.length > 1 && cached.entries[0]?.key !== args.currentKey) {
|
|
13368
|
+
const idx = cached.entries.findIndex((entry) => entry.key === args.currentKey);
|
|
13369
|
+
if (idx > 0) {
|
|
13370
|
+
return {
|
|
13371
|
+
entries: [
|
|
13372
|
+
cached.entries[idx],
|
|
13373
|
+
...cached.entries.slice(0, idx),
|
|
13374
|
+
...cached.entries.slice(idx + 1)
|
|
13375
|
+
],
|
|
13376
|
+
refreshStatus,
|
|
13377
|
+
unavailableFavoriteCount: cached.unavailableFavoriteCount
|
|
13378
|
+
};
|
|
13379
|
+
}
|
|
13380
|
+
}
|
|
13381
|
+
return {
|
|
13382
|
+
entries: cached.entries,
|
|
13383
|
+
refreshStatus,
|
|
13384
|
+
unavailableFavoriteCount: cached.unavailableFavoriteCount
|
|
13385
|
+
};
|
|
13386
|
+
}
|
|
13387
|
+
let rawData;
|
|
13388
|
+
const generation = args.fresh ? ++agentCatalogGeneration : agentCatalogGeneration;
|
|
13389
|
+
const deadlineKind = args.fresh ? "foreground" : args.deadlineKind ?? "foreground";
|
|
13390
|
+
const inFlight2 = agentCatalogRawLoadInFlight.get(deadlineKind);
|
|
13391
|
+
if (inFlight2) {
|
|
13392
|
+
rawData = await inFlight2;
|
|
13393
|
+
} else {
|
|
13394
|
+
const promise = fetchRawCatalogData({ ...args, deadlineKind }, env);
|
|
13395
|
+
agentCatalogRawLoadInFlight.set(deadlineKind, promise);
|
|
13396
|
+
try {
|
|
13397
|
+
rawData = await promise;
|
|
13398
|
+
} finally {
|
|
13399
|
+
if (agentCatalogRawLoadInFlight.get(deadlineKind) === promise) {
|
|
13400
|
+
agentCatalogRawLoadInFlight.delete(deadlineKind);
|
|
13401
|
+
}
|
|
13402
|
+
}
|
|
13403
|
+
}
|
|
13404
|
+
const entries = mergeCatalogEntries(
|
|
13405
|
+
args.currentKey,
|
|
13406
|
+
resolveCatalogPlatformAgents(env),
|
|
13407
|
+
rawData.privateAgents,
|
|
13408
|
+
rawData.favoritedAtByKey
|
|
13409
|
+
);
|
|
13410
|
+
if (generation === agentCatalogGeneration) {
|
|
13411
|
+
lastRefresh = { cacheKey, status: rawData.status };
|
|
13412
|
+
}
|
|
13413
|
+
if (generation === agentCatalogGeneration && rawData.status === "success") {
|
|
13414
|
+
agentCatalogCache = {
|
|
13415
|
+
cacheKey,
|
|
13416
|
+
at: Date.now(),
|
|
13417
|
+
entries,
|
|
13418
|
+
unavailableFavoriteCount: rawData.unavailableFavoriteCount
|
|
13419
|
+
};
|
|
13420
|
+
}
|
|
13421
|
+
void mergeCatalogQuotas(entries, { env, fetchImpl: args.fetchImpl }).catch(() => {
|
|
13422
|
+
});
|
|
13423
|
+
return { entries, unavailableFavoriteCount: rawData.unavailableFavoriteCount, refreshStatus: rawData.status };
|
|
13424
|
+
}
|
|
13425
|
+
async function mergeCatalogQuotas(entries, args) {
|
|
13426
|
+
const fresh = await refreshSubscriptionQuotas({
|
|
13427
|
+
entries: entries.map((entry) => ({
|
|
13428
|
+
key: entry.key,
|
|
13429
|
+
...entry.quota ? { quota: entry.quota } : {},
|
|
13430
|
+
probeable: entry.kind === "private"
|
|
13431
|
+
})),
|
|
13432
|
+
...args.env ? { env: args.env } : {},
|
|
13433
|
+
...args.fetchImpl ? { fetchImpl: args.fetchImpl } : {}
|
|
13434
|
+
});
|
|
13435
|
+
for (const entry of entries) {
|
|
13436
|
+
const quota = fresh[entry.key];
|
|
13437
|
+
if (quota) entry.quota = quota;
|
|
13438
|
+
}
|
|
13439
|
+
}
|
|
13440
|
+
function refreshAgentCatalogInBackground(args, env, cacheKey) {
|
|
13441
|
+
if (agentCatalogRefreshInFlight) return;
|
|
13442
|
+
const generation = agentCatalogGeneration;
|
|
13443
|
+
agentCatalogRefreshInFlight = fetchRawCatalogData(
|
|
13444
|
+
{ ...args, deadlineKind: "background" },
|
|
13445
|
+
env
|
|
13446
|
+
).then(async (rawData) => {
|
|
13447
|
+
if (generation !== agentCatalogGeneration) return;
|
|
13448
|
+
lastRefresh = { cacheKey, status: rawData.status };
|
|
13449
|
+
if (rawData.status !== "success") return;
|
|
13450
|
+
const entries = mergeCatalogEntries(
|
|
13451
|
+
args.currentKey,
|
|
13452
|
+
resolveCatalogPlatformAgents(env),
|
|
13453
|
+
rawData.privateAgents,
|
|
13454
|
+
rawData.favoritedAtByKey
|
|
13455
|
+
);
|
|
13456
|
+
await mergeCatalogQuotas(entries, { env, fetchImpl: args.fetchImpl });
|
|
13457
|
+
if (generation === agentCatalogGeneration) {
|
|
13458
|
+
agentCatalogCache = {
|
|
13459
|
+
cacheKey,
|
|
13460
|
+
at: Date.now(),
|
|
13461
|
+
entries,
|
|
13462
|
+
unavailableFavoriteCount: rawData.unavailableFavoriteCount
|
|
13463
|
+
};
|
|
13464
|
+
}
|
|
13465
|
+
}).catch(() => {
|
|
13466
|
+
if (generation === agentCatalogGeneration) lastRefresh = { cacheKey, status: "failed" };
|
|
13467
|
+
}).finally(() => {
|
|
13468
|
+
agentCatalogRefreshInFlight = null;
|
|
13469
|
+
});
|
|
13470
|
+
}
|
|
13471
|
+
async function prefillCatalogFromLocalDb(_args) {
|
|
13472
|
+
}
|
|
13473
|
+
function prefetchAgentCatalog(args) {
|
|
13474
|
+
void (async () => {
|
|
13475
|
+
await prefillCatalogFromLocalDb({ env: args.env, getDb: args.getDb }).catch(() => {
|
|
13476
|
+
});
|
|
13477
|
+
void loadAgentCatalog({ ...args, currentKey: "", deadlineKind: "background" }).catch(() => {
|
|
13478
|
+
});
|
|
13479
|
+
})();
|
|
13480
|
+
}
|
|
13481
|
+
async function fetchRawCatalogData(args, env) {
|
|
13482
|
+
const deadlineMs = resolveCatalogDeadlineMs(args.deadlineKind ?? "foreground", env);
|
|
13483
|
+
const fetchImpl = withFetchDeadline(args.fetchImpl ?? fetch, deadlineMs);
|
|
13484
|
+
const fallbackFetchImpl = args.fallbackFetchImpl ? withFetchDeadline(args.fallbackFetchImpl, deadlineMs) : void 0;
|
|
13485
|
+
const authToken = resolveAuthToken([], env);
|
|
13486
|
+
const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
|
|
13487
|
+
if (!authToken || !userId) {
|
|
13488
|
+
return { privateAgents: [], favoritedAtByKey: {}, unavailableFavoriteCount: 0, status: "success" };
|
|
13489
|
+
}
|
|
13490
|
+
const serverUrl = resolveServerUrl(env);
|
|
13491
|
+
const allServerUrls = resolveServerCandidates([], env, serverUrl);
|
|
13492
|
+
const serverUrls = (args.deadlineKind ?? "foreground") === "foreground" ? keepPrimaryServer(filterHealthyServers(allServerUrls), serverUrl) : allServerUrls;
|
|
13493
|
+
const fetchStartedAt = performance.now();
|
|
13494
|
+
let listedAgents = [];
|
|
13495
|
+
let catalogAuthoritative = false;
|
|
13496
|
+
let catalogAvailable = false;
|
|
13497
|
+
let favoritesFailed = false;
|
|
13498
|
+
const favoritesPromise = listFavoriteAgentIdsAcrossServers({
|
|
13499
|
+
authToken,
|
|
13500
|
+
fetchImpl,
|
|
13501
|
+
serverUrls,
|
|
13502
|
+
onFailure: () => {
|
|
13503
|
+
favoritesFailed = true;
|
|
13504
|
+
}
|
|
13505
|
+
}).catch(() => {
|
|
13506
|
+
favoritesFailed = true;
|
|
13507
|
+
return {};
|
|
13508
|
+
});
|
|
13509
|
+
try {
|
|
13510
|
+
const remoteResult = await listRemoteAgentsAcrossServers({
|
|
13511
|
+
authToken,
|
|
13512
|
+
fallbackFetchImpl,
|
|
13513
|
+
fetchImpl,
|
|
13514
|
+
serverUrls,
|
|
13515
|
+
userId
|
|
13516
|
+
});
|
|
13517
|
+
listedAgents = remoteResult.agents;
|
|
13518
|
+
catalogAvailable = true;
|
|
13519
|
+
catalogAuthoritative = remoteResult.failures.length === 0 && serverUrls.length === allServerUrls.length;
|
|
13520
|
+
recordServerSuccesses(serverUrls.filter(
|
|
13521
|
+
(url) => !remoteResult.failures.some((f) => f.serverUrl === url)
|
|
13522
|
+
));
|
|
13523
|
+
recordServerFailures(remoteResult.failures);
|
|
13524
|
+
} catch {
|
|
13525
|
+
try {
|
|
13526
|
+
const localBudgetMs = Math.max(
|
|
13527
|
+
500,
|
|
13528
|
+
deadlineMs - (performance.now() - fetchStartedAt)
|
|
13529
|
+
);
|
|
13530
|
+
let localTimer;
|
|
13531
|
+
try {
|
|
13532
|
+
listedAgents = await Promise.race([
|
|
13533
|
+
(async () => {
|
|
13534
|
+
const db = args.getDb ? await args.getDb() : await getReadableCliDb({ write: () => {
|
|
13535
|
+
} });
|
|
13536
|
+
return listLocalCachedAgents({ db, userId });
|
|
13537
|
+
})(),
|
|
13538
|
+
new Promise((_, reject) => {
|
|
13539
|
+
localTimer = setTimeout(
|
|
13540
|
+
() => reject(new Error("local catalog deadline exceeded")),
|
|
13541
|
+
localBudgetMs
|
|
13542
|
+
);
|
|
13543
|
+
})
|
|
13544
|
+
]);
|
|
13545
|
+
catalogAvailable = true;
|
|
13546
|
+
} finally {
|
|
13547
|
+
if (localTimer) clearTimeout(localTimer);
|
|
13548
|
+
}
|
|
13549
|
+
} catch {
|
|
13550
|
+
try {
|
|
13551
|
+
listedAgents = await listRemoteAgents({
|
|
13552
|
+
authToken,
|
|
13553
|
+
fallbackFetchImpl,
|
|
13554
|
+
fetchImpl,
|
|
13555
|
+
serverUrl,
|
|
13556
|
+
userId,
|
|
13557
|
+
queryUserRecords,
|
|
13558
|
+
readDbRecord
|
|
13559
|
+
});
|
|
13560
|
+
catalogAvailable = true;
|
|
13561
|
+
} catch {
|
|
13562
|
+
listedAgents = [];
|
|
13563
|
+
}
|
|
13564
|
+
}
|
|
13565
|
+
}
|
|
13566
|
+
const privateAgents = listedAgents.map(listedAgentToCatalogEntry);
|
|
13567
|
+
const favoritedAtByKey = await favoritesPromise;
|
|
13568
|
+
for (const agent of listedAgents) {
|
|
13569
|
+
const favoritedAt = [agent.privateKey, agent.publicKey, agent.id].map((key) => favoritedAtByKey[key]).find((value) => value !== void 0);
|
|
13570
|
+
if (favoritedAt !== void 0) favoritedAtByKey[agent.privateKey] = favoritedAt;
|
|
13571
|
+
}
|
|
13572
|
+
const existingKeys = /* @__PURE__ */ new Set();
|
|
13573
|
+
for (const agent of listedAgents) {
|
|
13574
|
+
existingKeys.add(agent.privateKey);
|
|
13575
|
+
existingKeys.add(agent.publicKey);
|
|
13576
|
+
existingKeys.add(agent.id);
|
|
13577
|
+
}
|
|
13578
|
+
let unavailableFavoriteCount = 0;
|
|
13579
|
+
let orphanSkipped = false;
|
|
13580
|
+
await Promise.all(
|
|
13581
|
+
Object.keys(favoritedAtByKey).map(async (favKey) => {
|
|
13582
|
+
if (existingKeys.has(favKey)) return;
|
|
13583
|
+
const remainingMs = deadlineMs - (performance.now() - fetchStartedAt);
|
|
13584
|
+
if (remainingMs <= 0) {
|
|
13585
|
+
orphanSkipped = true;
|
|
13586
|
+
return;
|
|
13587
|
+
}
|
|
13588
|
+
try {
|
|
13589
|
+
let orphanTimer;
|
|
13590
|
+
const orphanDeadline = new Promise((_, reject) => {
|
|
13591
|
+
orphanTimer = setTimeout(
|
|
13592
|
+
() => reject(new Error("orphan hydrate deadline")),
|
|
13593
|
+
remainingMs
|
|
13594
|
+
);
|
|
13595
|
+
});
|
|
13596
|
+
try {
|
|
13597
|
+
const favRead = await Promise.race([
|
|
13598
|
+
readLiveDbRecordAfterTombstoneMerge({
|
|
13599
|
+
authToken,
|
|
13600
|
+
dbKey: favKey,
|
|
13601
|
+
fallbackFetchImpl,
|
|
13602
|
+
fetchImpl,
|
|
13603
|
+
serverUrls
|
|
13604
|
+
}),
|
|
13605
|
+
orphanDeadline
|
|
13606
|
+
]);
|
|
13607
|
+
const record = favRead.record;
|
|
13608
|
+
if (!record || record.type && record.type !== "agent") return;
|
|
13609
|
+
const norm = normalizeListedAgent(record);
|
|
13610
|
+
if (!norm) return;
|
|
13611
|
+
if (existingKeys.has(norm.privateKey) || existingKeys.has(norm.publicKey) || existingKeys.has(norm.id)) {
|
|
13612
|
+
return;
|
|
13613
|
+
}
|
|
13614
|
+
existingKeys.add(norm.privateKey);
|
|
13615
|
+
existingKeys.add(norm.publicKey);
|
|
13616
|
+
existingKeys.add(norm.id);
|
|
13617
|
+
privateAgents.push(listedAgentToCatalogEntry(norm));
|
|
13618
|
+
} finally {
|
|
13619
|
+
if (orphanTimer) clearTimeout(orphanTimer);
|
|
13620
|
+
}
|
|
13621
|
+
} catch {
|
|
13622
|
+
unavailableFavoriteCount += 1;
|
|
13623
|
+
}
|
|
13624
|
+
})
|
|
13625
|
+
);
|
|
13626
|
+
const status = !catalogAvailable && favoritesFailed ? "failed" : catalogAuthoritative && !favoritesFailed && unavailableFavoriteCount === 0 && !orphanSkipped ? "success" : "degraded";
|
|
13627
|
+
return { privateAgents, favoritedAtByKey, unavailableFavoriteCount, status };
|
|
13628
|
+
}
|
|
13629
|
+
function renderAgentCatalogList(entries, currentKey, options) {
|
|
13630
|
+
const lines = ["Agents:"];
|
|
13631
|
+
entries.forEach((entry, index) => {
|
|
13632
|
+
const current = entry.key === currentKey ? " (current)" : "";
|
|
13633
|
+
const favorite = entry.favoritedAt ? " \u2605" : "";
|
|
13634
|
+
const detail = entry.description ? ` \u2014 ${entry.description}` : "";
|
|
13635
|
+
const quota = formatQuotaSummary(entry.quota, Date.now(), { model: entry.model });
|
|
13636
|
+
const trailing = quota ? ` [${quota}]` : detail;
|
|
13637
|
+
lines.push(
|
|
13638
|
+
` ${String(index + 1).padStart(2)} ${entry.name.padEnd(18)} ${entry.model.padEnd(14)} ${formatAgentSourceLabel(entry)}${favorite}${trailing}${current}`
|
|
13639
|
+
);
|
|
13640
|
+
});
|
|
13641
|
+
lines.push("");
|
|
13642
|
+
const notice = formatUnavailableFavoritesNotice(
|
|
13643
|
+
options?.unavailableFavoriteCount ?? 0
|
|
13644
|
+
);
|
|
13645
|
+
if (notice) lines.push(notice);
|
|
13646
|
+
lines.push("Tip: run /switch in an interactive terminal to pick with \u2191\u2193.");
|
|
13647
|
+
return lines.join("\n");
|
|
13648
|
+
}
|
|
13649
|
+
function resolveEntryApiSource(entry) {
|
|
13650
|
+
if (entry.apiSource) return entry.apiSource;
|
|
13651
|
+
return entry.kind === "platform" ? "platform" : void 0;
|
|
13652
|
+
}
|
|
13653
|
+
function toSwitchTarget(entry) {
|
|
13654
|
+
const apiSource = resolveEntryApiSource(entry);
|
|
13655
|
+
return {
|
|
13656
|
+
name: entry.name,
|
|
13657
|
+
key: entry.key,
|
|
13658
|
+
model: entry.model,
|
|
13659
|
+
...apiSource ? { apiSource } : {}
|
|
13660
|
+
};
|
|
13661
|
+
}
|
|
13662
|
+
function findAgentCatalogEntry(entries, rawTarget) {
|
|
13663
|
+
const target = rawTarget.trim();
|
|
13664
|
+
if (!target) return null;
|
|
13665
|
+
if (/^\d+$/.test(target)) {
|
|
13666
|
+
const entry = entries[Number(target) - 1];
|
|
13667
|
+
return entry ? toSwitchTarget(entry) : null;
|
|
13668
|
+
}
|
|
13669
|
+
const lower = target.toLowerCase();
|
|
13670
|
+
const byName = entries.find(
|
|
13671
|
+
(entry) => entry.name.toLowerCase() === lower || entry.key.toLowerCase() === lower || entry.key.toLowerCase().endsWith(`-${lower}`)
|
|
13672
|
+
);
|
|
13673
|
+
if (byName) return toSwitchTarget(byName);
|
|
13674
|
+
if (target.startsWith("agent-") || target.startsWith("agent-pub-")) {
|
|
13675
|
+
const builtin = builtinAgentCatalogEntryById(
|
|
13676
|
+
parseBuiltinPlatformAgentId(target) ?? parsePublicAgentId(target)
|
|
13677
|
+
);
|
|
13678
|
+
if (builtin) {
|
|
13679
|
+
return {
|
|
13680
|
+
name: builtin.name,
|
|
13681
|
+
key: target,
|
|
13682
|
+
model: builtin.model,
|
|
13683
|
+
apiSource: builtin.apiSource ?? "platform"
|
|
13684
|
+
};
|
|
13685
|
+
}
|
|
13686
|
+
return { name: target, key: target };
|
|
13687
|
+
}
|
|
13688
|
+
return null;
|
|
13689
|
+
}
|
|
13690
|
+
function lookupCachedAgentName(agentKey) {
|
|
13691
|
+
const trimmed = agentKey.trim();
|
|
13692
|
+
if (!trimmed) return void 0;
|
|
13693
|
+
const platform = PLATFORM_AGENTS.find(
|
|
13694
|
+
(p) => p.key === trimmed || p.key.toLowerCase() === trimmed.toLowerCase()
|
|
13695
|
+
);
|
|
13696
|
+
if (platform?.name) return platform.name;
|
|
13697
|
+
const builtin = builtinAgentCatalogEntryById(
|
|
13698
|
+
parseBuiltinPlatformAgentId(trimmed) ?? parsePublicAgentId(trimmed)
|
|
13699
|
+
);
|
|
13700
|
+
if (builtin?.name) return builtin.name;
|
|
13701
|
+
if (agentCatalogCache?.entries) {
|
|
13702
|
+
const direct = agentCatalogCache.entries.find(
|
|
13703
|
+
(entry) => entry.key === trimmed || entry.key.toLowerCase() === trimmed.toLowerCase()
|
|
13704
|
+
);
|
|
13705
|
+
if (direct?.name) return direct.name;
|
|
13706
|
+
const suffix = agentCatalogCache.entries.find(
|
|
13707
|
+
(entry) => entry.key.toLowerCase().endsWith(`-${trimmed.toLowerCase()}`) || trimmed.toLowerCase().endsWith(`-${entry.key.toLowerCase()}`)
|
|
13708
|
+
);
|
|
13709
|
+
if (suffix?.name) return suffix.name;
|
|
13710
|
+
}
|
|
13711
|
+
return void 0;
|
|
13712
|
+
}
|
|
13713
|
+
|
|
12794
13714
|
// packages/cli/client/agentRunPlatformTools.ts
|
|
12795
13715
|
var SERVER_PLATFORM_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
12796
13716
|
"addTableRow",
|
|
@@ -13087,7 +14007,7 @@ function isBalanceExhaustedError(error) {
|
|
|
13087
14007
|
|
|
13088
14008
|
// packages/cli/client/agentRun.ts
|
|
13089
14009
|
async function loadRunLocalAgentTurn() {
|
|
13090
|
-
const { runLocalAgentTurn } = await import("./agentRuntimeLocal-
|
|
14010
|
+
const { runLocalAgentTurn } = await import("./agentRuntimeLocal-3MAEFYSB.js");
|
|
13091
14011
|
return runLocalAgentTurn;
|
|
13092
14012
|
}
|
|
13093
14013
|
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 +15364,32 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
|
|
|
14444
15364
|
const durableAttachmentParts = ENABLE_REMOTE_ATTACHMENT_PART_WRITES ? localAttachmentParts : [];
|
|
14445
15365
|
const hasDurableAttachments = durableAttachmentParts.length > 0;
|
|
14446
15366
|
const runLocalAgentTurn = await loadRunLocalAgentTurn();
|
|
15367
|
+
const poolEntries = readCachedAgentCatalogEntries();
|
|
15368
|
+
const poolAgentConfig = poolEntries && poolEntries.length > 0 && userId ? await (async () => {
|
|
15369
|
+
try {
|
|
15370
|
+
return await adapter.loadAgentConfig(options.agentKey);
|
|
15371
|
+
} catch {
|
|
15372
|
+
return null;
|
|
15373
|
+
}
|
|
15374
|
+
})() : null;
|
|
15375
|
+
const poolIdentity = pickCallerPoolIdentityFromAgentConfig({
|
|
15376
|
+
agentConfig: poolAgentConfig,
|
|
15377
|
+
agentKey: options.agentKey,
|
|
15378
|
+
// --model 覆盖已在 adapter 层应用到 agentConfig,这里只是 config 未加载时的兜底。
|
|
15379
|
+
modelOverride: options.modelOverride?.model ?? null
|
|
15380
|
+
});
|
|
15381
|
+
const callerIsPoolTop = resolveLatchedCliCallerIsPoolTop({
|
|
15382
|
+
dialogId: currentDialogId,
|
|
15383
|
+
entries: poolEntries,
|
|
15384
|
+
agentKey: poolIdentity.agentKey,
|
|
15385
|
+
latchAgentKey: options.agentKey,
|
|
15386
|
+
latchModel: options.modelOverride?.model ?? null,
|
|
15387
|
+
model: poolIdentity.model ?? resolveAgentModelIdentity({
|
|
15388
|
+
agentKey: options.agentKey,
|
|
15389
|
+
agentName: options.agentName
|
|
15390
|
+
}).model ?? null,
|
|
15391
|
+
userId
|
|
15392
|
+
});
|
|
14447
15393
|
const result = await runLocalAgentTurn({
|
|
14448
15394
|
adapter,
|
|
14449
15395
|
agentRef: options.agentKey,
|
|
@@ -14501,6 +15447,7 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
|
|
|
14501
15447
|
userMessages: messages
|
|
14502
15448
|
}) } : {},
|
|
14503
15449
|
runKind: options.env.NOLO_AGENT_RUN_CHILD === "1" ? "subtask" : "interactive",
|
|
15450
|
+
...callerIsPoolTop === void 0 ? {} : { callerIsPoolTop },
|
|
14504
15451
|
// 展示能力由宿主声明(TUI=narrow),非交互 CLI/后台留空 → unknown;
|
|
14505
15452
|
// 排版段只在能力已知时由 localLoop 注入,server 线不读该字段。
|
|
14506
15453
|
...options.responseViewport ? { responseViewport: options.responseViewport } : {},
|
|
@@ -15070,25 +16017,33 @@ function buildHostEnvironmentLayer(options) {
|
|
|
15070
16017
|
var finiteCount = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
|
|
15071
16018
|
var isUsageObject = (usage) => Boolean(usage) && typeof usage === "object";
|
|
15072
16019
|
var readInputTokens = (usage) => finiteCount(usage.input_tokens) ?? finiteCount(usage.prompt_tokens) ?? 0;
|
|
16020
|
+
var readOutputTokens = (usage) => finiteCount(usage.output_tokens) ?? finiteCount(usage.completion_tokens);
|
|
15073
16021
|
var computeCacheHitRatio = (inputTokens, cachedTokens) => {
|
|
15074
16022
|
if (cachedTokens === null) return null;
|
|
15075
16023
|
if (!Number.isFinite(inputTokens) || inputTokens <= 0) return 0;
|
|
15076
16024
|
return Math.round(cachedTokens / inputTokens * 1e4) / 1e4;
|
|
15077
16025
|
};
|
|
15078
|
-
var withRatio = (inputTokens, cachedTokens) => ({
|
|
16026
|
+
var withRatio = (inputTokens, cachedTokens, outputTokens) => ({
|
|
15079
16027
|
input_tokens: inputTokens,
|
|
15080
16028
|
cached_tokens: cachedTokens,
|
|
15081
|
-
cache_hit_ratio: computeCacheHitRatio(inputTokens, cachedTokens)
|
|
16029
|
+
cache_hit_ratio: computeCacheHitRatio(inputTokens, cachedTokens),
|
|
16030
|
+
...typeof outputTokens === "number" && Number.isFinite(outputTokens) ? { output_tokens: Math.max(0, Math.floor(outputTokens)) } : {}
|
|
15082
16031
|
});
|
|
15083
16032
|
var summarizeCacheUsage = (usage) => {
|
|
15084
16033
|
if (!isUsageObject(usage)) return void 0;
|
|
15085
16034
|
if (Object.keys(usage).length === 0) return void 0;
|
|
15086
|
-
return withRatio(
|
|
16035
|
+
return withRatio(
|
|
16036
|
+
readInputTokens(usage),
|
|
16037
|
+
readCacheReadInputTokensOrNull(usage),
|
|
16038
|
+
readOutputTokens(usage)
|
|
16039
|
+
);
|
|
15087
16040
|
};
|
|
15088
16041
|
var summarizeCacheUsageRecords = (records) => {
|
|
15089
16042
|
if (!records || records.length === 0) return void 0;
|
|
15090
16043
|
let inputTokens = 0;
|
|
15091
16044
|
let cachedTokens = 0;
|
|
16045
|
+
let outputTokens = 0;
|
|
16046
|
+
let sawOutput = false;
|
|
15092
16047
|
let sawUsage = false;
|
|
15093
16048
|
for (const record of records) {
|
|
15094
16049
|
const summary = summarizeCacheUsage(record?.usage);
|
|
@@ -15096,16 +16051,21 @@ var summarizeCacheUsageRecords = (records) => {
|
|
|
15096
16051
|
sawUsage = true;
|
|
15097
16052
|
inputTokens += summary.input_tokens;
|
|
15098
16053
|
cachedTokens = cachedTokens === null || summary.cached_tokens === null ? null : cachedTokens + summary.cached_tokens;
|
|
16054
|
+
if (typeof summary.output_tokens === "number") {
|
|
16055
|
+
sawOutput = true;
|
|
16056
|
+
outputTokens += summary.output_tokens;
|
|
16057
|
+
}
|
|
15099
16058
|
}
|
|
15100
16059
|
if (!sawUsage) return void 0;
|
|
15101
|
-
return withRatio(inputTokens, cachedTokens);
|
|
16060
|
+
return withRatio(inputTokens, cachedTokens, sawOutput ? outputTokens : void 0);
|
|
15102
16061
|
};
|
|
15103
16062
|
var mergeCacheUsageSummaries = (left, right) => {
|
|
15104
16063
|
if (!left) return right;
|
|
15105
16064
|
if (!right) return left;
|
|
15106
16065
|
const inputTokens = left.input_tokens + right.input_tokens;
|
|
15107
16066
|
const cachedTokens = left.cached_tokens === null || right.cached_tokens === null ? null : left.cached_tokens + right.cached_tokens;
|
|
15108
|
-
|
|
16067
|
+
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;
|
|
16068
|
+
return withRatio(inputTokens, cachedTokens, outputTokens);
|
|
15109
16069
|
};
|
|
15110
16070
|
|
|
15111
16071
|
// packages/cli/agentRunDoD.ts
|
|
@@ -17649,7 +18609,7 @@ async function runAgentRunCommandImpl(args, deps) {
|
|
|
17649
18609
|
await readDbRecord({
|
|
17650
18610
|
dbKey: agentKey,
|
|
17651
18611
|
authToken: resolveAuthToken(args, env),
|
|
17652
|
-
serverUrl:
|
|
18612
|
+
serverUrl: resolveServerUrl2(env),
|
|
17653
18613
|
fetchImpl: fetch
|
|
17654
18614
|
}).catch(() => null)
|
|
17655
18615
|
);
|
|
@@ -17682,7 +18642,7 @@ async function runAgentRunCommandImpl(args, deps) {
|
|
|
17682
18642
|
if (parsed.skillRefs?.length) {
|
|
17683
18643
|
const skills = [];
|
|
17684
18644
|
const authToken = resolveAuthToken(args, env);
|
|
17685
|
-
const serverUrl =
|
|
18645
|
+
const serverUrl = resolveServerUrl2(env);
|
|
17686
18646
|
for (const ref of parsed.skillRefs) {
|
|
17687
18647
|
try {
|
|
17688
18648
|
const resolved = await resolveSkillReference(ref, {
|
|
@@ -17818,7 +18778,7 @@ async function runAgentRunCommandImpl(args, deps) {
|
|
|
17818
18778
|
if (!deps.memoryRecallDisabled) {
|
|
17819
18779
|
try {
|
|
17820
18780
|
memoryPromptBlock = await resolveCliMemory({
|
|
17821
|
-
serverUrl:
|
|
18781
|
+
serverUrl: resolveServerUrl2(env),
|
|
17822
18782
|
authToken: resolveAuthToken(args, env),
|
|
17823
18783
|
agentKey: effectiveAgentKey,
|
|
17824
18784
|
userInput: effectiveMessage,
|
|
@@ -17897,7 +18857,7 @@ async function runAgentRunCommandImpl(args, deps) {
|
|
|
17897
18857
|
// 放在 buildRunOptions 这个唯一构造点上,首轮 / quota fallback / 队列 drain
|
|
17898
18858
|
// 三处 runner(...) 调用自动一致;远端分支走 server 线,不读该字段。
|
|
17899
18859
|
responseViewport: "unknown",
|
|
17900
|
-
serverUrl:
|
|
18860
|
+
serverUrl: resolveServerUrl2(env),
|
|
17901
18861
|
message: formatTurnMessage(turnMessage),
|
|
17902
18862
|
imageUrls,
|
|
17903
18863
|
scriptDir: deps.scriptDir,
|
|
@@ -18223,6 +19183,17 @@ export {
|
|
|
18223
19183
|
preserveContextUsageWithoutReceipt,
|
|
18224
19184
|
resolveContextUsage,
|
|
18225
19185
|
renderTokenStatus,
|
|
19186
|
+
DEFAULT_TUI_AGENT_KEY,
|
|
19187
|
+
formatAgentSourceLabel,
|
|
19188
|
+
resolveCatalogPlatformAgents,
|
|
19189
|
+
formatUnavailableFavoritesNotice,
|
|
19190
|
+
hasWarmAgentCatalogCache,
|
|
19191
|
+
loadAgentCatalog,
|
|
19192
|
+
loadAgentCatalogWithNotices,
|
|
19193
|
+
prefetchAgentCatalog,
|
|
19194
|
+
renderAgentCatalogList,
|
|
19195
|
+
findAgentCatalogEntry,
|
|
19196
|
+
lookupCachedAgentName,
|
|
18226
19197
|
redactSecrets,
|
|
18227
19198
|
resolveCliColorEnabled,
|
|
18228
19199
|
dimCliText,
|