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
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveAuthGuidanceState
|
|
3
3
|
} from "./chunk-4YPH5KRA.js";
|
|
4
|
-
import {
|
|
5
|
-
getRestartBlocker,
|
|
6
|
-
hasRestartBlockingRuns
|
|
7
|
-
} from "./chunk-HS4JGZQH.js";
|
|
8
4
|
import {
|
|
9
5
|
runAnthropicOAuthLogin,
|
|
10
6
|
runCursorOAuthLogin,
|
|
@@ -12,7 +8,7 @@ import {
|
|
|
12
8
|
runXaiOAuthDeviceCode,
|
|
13
9
|
runXaiOAuthLogin,
|
|
14
10
|
syncCredentialToServer
|
|
15
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DCTQJDDQ.js";
|
|
16
12
|
import {
|
|
17
13
|
createAccountSessionCore,
|
|
18
14
|
createDeviceAuthorizationProtocol,
|
|
@@ -21,18 +17,12 @@ import {
|
|
|
21
17
|
parseUserToken,
|
|
22
18
|
saveTokenLogin
|
|
23
19
|
} from "./chunk-HQUGB2HM.js";
|
|
24
|
-
import {
|
|
25
|
-
listFavoriteAgentIdsAcrossServers,
|
|
26
|
-
listLocalCachedAgents,
|
|
27
|
-
listRemoteAgents,
|
|
28
|
-
listRemoteAgentsAcrossServers,
|
|
29
|
-
normalizeListedAgent
|
|
30
|
-
} from "./chunk-HEUHCHAR.js";
|
|
31
20
|
import {
|
|
32
21
|
runCloudflareOAuthLogin
|
|
33
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-APQBEIOQ.js";
|
|
34
23
|
import {
|
|
35
24
|
COLLAPSED_PASTE_PLACEHOLDER_RE,
|
|
25
|
+
DEFAULT_TUI_AGENT_KEY,
|
|
36
26
|
MAX_URL_LENGTH,
|
|
37
27
|
OWNER_OAUTH_UNAVAILABLE_HINT,
|
|
38
28
|
THEME_PALETTES,
|
|
@@ -53,28 +43,37 @@ import {
|
|
|
53
43
|
emitTerminalProgramStatus,
|
|
54
44
|
expandCollapsedPastes,
|
|
55
45
|
expandRangeToCollapsedPasteChips,
|
|
46
|
+
findAgentCatalogEntry,
|
|
56
47
|
findCollapsedPasteSpanAt,
|
|
48
|
+
formatAgentSourceLabel,
|
|
57
49
|
formatAssistantDisplay,
|
|
58
50
|
formatCreditsChip,
|
|
59
51
|
formatTokenCount,
|
|
52
|
+
formatUnavailableFavoritesNotice,
|
|
60
53
|
getActiveThemeMode,
|
|
61
54
|
getActiveThemeName,
|
|
62
55
|
getTopReservedRows,
|
|
56
|
+
hasWarmAgentCatalogCache,
|
|
63
57
|
isAuthFailureError,
|
|
64
58
|
isBalanceExhaustedError,
|
|
65
59
|
isInvalidGrantError,
|
|
66
60
|
isLocalContextCoverageFailure,
|
|
67
61
|
isOwnerOAuthUnavailableError,
|
|
68
62
|
isRunResultStalledOrTruncated,
|
|
63
|
+
loadAgentCatalog,
|
|
64
|
+
loadAgentCatalogWithNotices,
|
|
65
|
+
lookupCachedAgentName,
|
|
69
66
|
normalizeHttpUrl,
|
|
70
67
|
openExternalUrl,
|
|
71
68
|
platformCreditsFromUsage,
|
|
72
69
|
polishBreathInsertsBlankBetween,
|
|
73
70
|
preferredTopTaskEntries,
|
|
71
|
+
prefetchAgentCatalog,
|
|
74
72
|
preserveContextUsageWithoutReceipt,
|
|
75
73
|
redactSecrets,
|
|
76
74
|
releaseCollapsedPaste,
|
|
77
75
|
releaseCollapsedPasteReferences,
|
|
76
|
+
renderAgentCatalogList,
|
|
78
77
|
renderSurfaceLine,
|
|
79
78
|
renderTokenStatus,
|
|
80
79
|
replaceCollapsedPastesWithReferences,
|
|
@@ -82,6 +81,7 @@ import {
|
|
|
82
81
|
resolveAgentContextWindow,
|
|
83
82
|
resolveAgentModelIdentity,
|
|
84
83
|
resolveAuthorityTurnCount,
|
|
84
|
+
resolveCatalogPlatformAgents,
|
|
85
85
|
resolveCliColorEnabled,
|
|
86
86
|
resolveCliHyperlinkEnabled,
|
|
87
87
|
resolveCliMemory,
|
|
@@ -110,18 +110,17 @@ import {
|
|
|
110
110
|
toolRowDetailLine,
|
|
111
111
|
tuiRenderThemeFingerprint,
|
|
112
112
|
userBubbleSurfaceBackgroundSequence
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-2RZBFJEG.js";
|
|
114
114
|
import "./chunk-6QDYSCPW.js";
|
|
115
115
|
import "./chunk-GAHJLSDO.js";
|
|
116
|
+
import "./chunk-BD22OFDQ.js";
|
|
117
|
+
import "./chunk-P27E22MA.js";
|
|
118
|
+
import "./chunk-ZYPXOQS2.js";
|
|
116
119
|
import {
|
|
117
|
-
|
|
118
|
-
} from "./chunk-P27E22MA.js";
|
|
119
|
-
import {
|
|
120
|
-
getReadableCliDb
|
|
121
|
-
} from "./chunk-ZYPXOQS2.js";
|
|
122
|
-
import {
|
|
120
|
+
MCP_EXPOSURE_ENV,
|
|
123
121
|
buildCliNoticeText,
|
|
124
122
|
buildNoticeTasksFromRuns,
|
|
123
|
+
buildOpenAiTools,
|
|
125
124
|
clearCliLocalRuntimePreparedAgentCache,
|
|
126
125
|
createCliHybridRecordStore,
|
|
127
126
|
createCliLocalRuntimeAdapter,
|
|
@@ -132,9 +131,10 @@ import {
|
|
|
132
131
|
readTimestamp,
|
|
133
132
|
renderCliNotice,
|
|
134
133
|
renderNoticeElements,
|
|
134
|
+
resolveCliRequestedToolNames,
|
|
135
135
|
resolveNoticeTitle,
|
|
136
136
|
setTurnNoticeMeta
|
|
137
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-V6S5OZSP.js";
|
|
138
138
|
import {
|
|
139
139
|
createHostApprovalCardQueue,
|
|
140
140
|
formatApprovalRemaining,
|
|
@@ -166,24 +166,15 @@ import {
|
|
|
166
166
|
wrapTextToLines,
|
|
167
167
|
wrapTranscriptLine,
|
|
168
168
|
wrapTranscriptLineWithLayout
|
|
169
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-C63KMRJE.js";
|
|
170
170
|
import "./chunk-GIXWVN2W.js";
|
|
171
|
-
import {
|
|
172
|
-
DIALOG_NOTIFY_SOURCE,
|
|
173
|
-
ensureDialogNotifyDir,
|
|
174
|
-
isLeaseLive,
|
|
175
|
-
listNotificationEntries,
|
|
176
|
-
readAck,
|
|
177
|
-
readLease,
|
|
178
|
-
resolveDialogNotifyDirs,
|
|
179
|
-
resolveDialogNotifyRoot,
|
|
180
|
-
writeAck,
|
|
181
|
-
writeLease
|
|
182
|
-
} from "./chunk-CYGFNMCH.js";
|
|
183
171
|
import "./chunk-PENRYZ4D.js";
|
|
184
172
|
import "./chunk-U6RD332P.js";
|
|
185
173
|
import "./chunk-WOAZVUSN.js";
|
|
186
|
-
import
|
|
174
|
+
import {
|
|
175
|
+
getRestartBlocker,
|
|
176
|
+
hasRestartBlockingRuns
|
|
177
|
+
} from "./chunk-DWES4SXY.js";
|
|
187
178
|
import "./chunk-4D4QD7FT.js";
|
|
188
179
|
import "./chunk-PVFYPUIM.js";
|
|
189
180
|
import "./chunk-53W5BXLN.js";
|
|
@@ -192,10 +183,22 @@ import "./chunk-IIRJ4P4I.js";
|
|
|
192
183
|
import "./chunk-C5A54QS7.js";
|
|
193
184
|
import "./chunk-6RSNVJGO.js";
|
|
194
185
|
import "./chunk-324FWHUA.js";
|
|
186
|
+
import {
|
|
187
|
+
DIALOG_NOTIFY_SOURCE,
|
|
188
|
+
ensureDialogNotifyDir,
|
|
189
|
+
isLeaseLive,
|
|
190
|
+
listNotificationEntries,
|
|
191
|
+
readAck,
|
|
192
|
+
readLease,
|
|
193
|
+
resolveDialogNotifyDirs,
|
|
194
|
+
resolveDialogNotifyRoot,
|
|
195
|
+
writeAck,
|
|
196
|
+
writeLease
|
|
197
|
+
} from "./chunk-OKAXQFON.js";
|
|
195
198
|
import {
|
|
196
199
|
defaultPromptReader,
|
|
197
200
|
setSecret
|
|
198
|
-
} from "./chunk-
|
|
201
|
+
} from "./chunk-BB76X6O4.js";
|
|
199
202
|
import {
|
|
200
203
|
createTuiSummaryLlmCaller
|
|
201
204
|
} from "./chunk-OB4FBZXJ.js";
|
|
@@ -203,6 +206,7 @@ import "./chunk-OYUMJMC5.js";
|
|
|
203
206
|
import "./chunk-R7XWZDOH.js";
|
|
204
207
|
import "./chunk-S73EPYNC.js";
|
|
205
208
|
import "./chunk-ZEZC7IIM.js";
|
|
209
|
+
import "./chunk-VIWDGTDA.js";
|
|
206
210
|
import {
|
|
207
211
|
formatSkillSlashReference,
|
|
208
212
|
parseSkillSlashReference,
|
|
@@ -210,28 +214,26 @@ import {
|
|
|
210
214
|
} from "./chunk-PRJ473FK.js";
|
|
211
215
|
import "./chunk-BMQ2MJUK.js";
|
|
212
216
|
import "./chunk-ATNTHIZI.js";
|
|
213
|
-
import "./chunk-
|
|
217
|
+
import "./chunk-ZMJMHXYX.js";
|
|
214
218
|
import "./chunk-JEXVIMYZ.js";
|
|
215
|
-
import
|
|
216
|
-
prepareTools
|
|
217
|
-
} from "./chunk-MCQXBKC6.js";
|
|
219
|
+
import "./chunk-JGVWHUYK.js";
|
|
218
220
|
import "./chunk-KZ4A7EIV.js";
|
|
219
|
-
import "./chunk-
|
|
220
|
-
import "./chunk-
|
|
221
|
+
import "./chunk-KO5PFS74.js";
|
|
222
|
+
import "./chunk-EXD7S7QW.js";
|
|
221
223
|
import "./chunk-MVOZ22RZ.js";
|
|
222
|
-
import "./chunk-
|
|
223
|
-
import "./chunk-
|
|
224
|
+
import "./chunk-KG27JIG4.js";
|
|
225
|
+
import "./chunk-WFEWP352.js";
|
|
224
226
|
import "./chunk-NF64D32W.js";
|
|
225
|
-
import "./chunk-
|
|
227
|
+
import "./chunk-R3FZHW4Q.js";
|
|
226
228
|
import "./chunk-WDWZPASX.js";
|
|
227
|
-
import "./chunk-
|
|
228
|
-
import "./chunk-
|
|
229
|
+
import "./chunk-BD5YJJLJ.js";
|
|
230
|
+
import "./chunk-WSLL7VV4.js";
|
|
229
231
|
import "./chunk-VF4K2QE6.js";
|
|
230
|
-
import "./chunk-
|
|
231
|
-
import "./chunk-
|
|
232
|
-
import "./chunk-
|
|
233
|
-
import "./chunk-
|
|
234
|
-
import "./chunk-
|
|
232
|
+
import "./chunk-LLUBUHNT.js";
|
|
233
|
+
import "./chunk-U6QNVOR5.js";
|
|
234
|
+
import "./chunk-MNFUKRRU.js";
|
|
235
|
+
import "./chunk-TF427WGH.js";
|
|
236
|
+
import "./chunk-LJ6WIQZO.js";
|
|
235
237
|
import {
|
|
236
238
|
createChatQueueRuntime,
|
|
237
239
|
createTurnRequest,
|
|
@@ -239,28 +241,28 @@ import {
|
|
|
239
241
|
historyTokensBeforeLatestAssistant,
|
|
240
242
|
initialChatQueueState,
|
|
241
243
|
normalizeRunCompletionShape
|
|
242
|
-
} from "./chunk-
|
|
243
|
-
import "./chunk-TZXPT53C.js";
|
|
244
|
+
} from "./chunk-7B55IVLF.js";
|
|
244
245
|
import "./chunk-BUDVRYES.js";
|
|
246
|
+
import "./chunk-TZXPT53C.js";
|
|
245
247
|
import {
|
|
246
248
|
BUILTIN_DIALOG_LLM_FALLBACK_MODEL,
|
|
247
249
|
BUILTIN_SUMMARY_LLM_CONFIG
|
|
248
250
|
} from "./chunk-523DITKR.js";
|
|
249
|
-
import "./chunk-
|
|
250
|
-
import "./chunk-
|
|
251
|
+
import "./chunk-MD7O2NN2.js";
|
|
252
|
+
import "./chunk-YN23INFZ.js";
|
|
251
253
|
import "./chunk-BYXBJQAS.js";
|
|
252
|
-
import "./chunk-
|
|
254
|
+
import "./chunk-6VEO7Z3Y.js";
|
|
253
255
|
import {
|
|
254
256
|
getActiveDialogAgentId
|
|
255
257
|
} from "./chunk-5RGU3J7P.js";
|
|
256
258
|
import "./chunk-UVLYNWIE.js";
|
|
257
259
|
import "./chunk-YNIYE47Z.js";
|
|
258
|
-
import "./chunk-
|
|
259
|
-
import "./chunk-
|
|
260
|
+
import "./chunk-BZMDWGQQ.js";
|
|
261
|
+
import "./chunk-46FETNLF.js";
|
|
260
262
|
import "./chunk-UAD2WT54.js";
|
|
261
|
-
import "./chunk-
|
|
263
|
+
import "./chunk-ADYWV732.js";
|
|
262
264
|
import "./chunk-3PVYUPXK.js";
|
|
263
|
-
import "./chunk-
|
|
265
|
+
import "./chunk-WS36XPJD.js";
|
|
264
266
|
import {
|
|
265
267
|
getDefaultCliLocalRuntimeDb
|
|
266
268
|
} from "./chunk-J55F3IEZ.js";
|
|
@@ -270,23 +272,21 @@ import {
|
|
|
270
272
|
normalizeDialogRecord,
|
|
271
273
|
readDialogSnapshot,
|
|
272
274
|
sortDialogs
|
|
273
|
-
} from "./chunk-
|
|
275
|
+
} from "./chunk-IZHENZQ5.js";
|
|
274
276
|
import "./chunk-ID4G2MAR.js";
|
|
275
|
-
import {
|
|
276
|
-
listUserRecordsFromServers,
|
|
277
|
-
readLiveDbRecordAfterTombstoneMerge
|
|
278
|
-
} from "./chunk-4GWNEPY6.js";
|
|
279
277
|
import "./chunk-Y5GCAMGP.js";
|
|
278
|
+
import {
|
|
279
|
+
listUserRecordsFromServers
|
|
280
|
+
} from "./chunk-7PTWFSZZ.js";
|
|
280
281
|
import {
|
|
281
282
|
loadLocalRunChildDialogIds
|
|
282
|
-
} from "./chunk-
|
|
283
|
+
} from "./chunk-AKBNCTPY.js";
|
|
283
284
|
import "./chunk-LKZPX6YH.js";
|
|
284
285
|
import {
|
|
285
286
|
deleteDbRecord,
|
|
286
|
-
queryUserRecords,
|
|
287
287
|
readDbRecord
|
|
288
|
-
} from "./chunk-
|
|
289
|
-
import "./chunk-
|
|
288
|
+
} from "./chunk-E4HBZDV6.js";
|
|
289
|
+
import "./chunk-VQR2ACSC.js";
|
|
290
290
|
import "./chunk-AMWMV56B.js";
|
|
291
291
|
import "./chunk-DXWGFL2Z.js";
|
|
292
292
|
import "./chunk-3L2WKC3W.js";
|
|
@@ -299,8 +299,9 @@ import {
|
|
|
299
299
|
listRunRecords,
|
|
300
300
|
listRunRecordsAsync,
|
|
301
301
|
readRunRecord,
|
|
302
|
+
resolveRunsDir,
|
|
302
303
|
runAgentStopCommand
|
|
303
|
-
} from "./chunk-
|
|
304
|
+
} from "./chunk-ONTHDYFU.js";
|
|
304
305
|
import {
|
|
305
306
|
clipText,
|
|
306
307
|
formatDuration,
|
|
@@ -316,10 +317,10 @@ import "./chunk-KQHEGELM.js";
|
|
|
316
317
|
import "./chunk-QYPE3TS3.js";
|
|
317
318
|
import "./chunk-U35UUM5K.js";
|
|
318
319
|
import "./chunk-RD3QLZQV.js";
|
|
319
|
-
import "./chunk-
|
|
320
|
-
import "./chunk-
|
|
321
|
-
import "./chunk-
|
|
322
|
-
import "./chunk-
|
|
320
|
+
import "./chunk-7BIJFGKS.js";
|
|
321
|
+
import "./chunk-HPDLPEUG.js";
|
|
322
|
+
import "./chunk-ZTHAJU3O.js";
|
|
323
|
+
import "./chunk-HDKMVYNJ.js";
|
|
323
324
|
import {
|
|
324
325
|
isExternalSessionKind
|
|
325
326
|
} from "./chunk-YJPK35HB.js";
|
|
@@ -330,7 +331,7 @@ import {
|
|
|
330
331
|
buildSkillDiscoveryContextBlock,
|
|
331
332
|
buildSkillDiscoveryContextLayer,
|
|
332
333
|
discoverSkills
|
|
333
|
-
} from "./chunk-
|
|
334
|
+
} from "./chunk-NUHQO3RB.js";
|
|
334
335
|
import "./chunk-GBWGPTA7.js";
|
|
335
336
|
import "./chunk-OQFOE4SJ.js";
|
|
336
337
|
import "./chunk-TRRXYFTR.js";
|
|
@@ -342,15 +343,13 @@ import "./chunk-CVMMWN6P.js";
|
|
|
342
343
|
import "./chunk-GLKOYSRU.js";
|
|
343
344
|
import {
|
|
344
345
|
readDialogMessageRecords
|
|
345
|
-
} from "./chunk-
|
|
346
|
-
import "./chunk-
|
|
347
|
-
import "./chunk-
|
|
348
|
-
import "./chunk-
|
|
346
|
+
} from "./chunk-6VNBJ7GI.js";
|
|
347
|
+
import "./chunk-223KZUJ6.js";
|
|
348
|
+
import "./chunk-CEKRIR22.js";
|
|
349
|
+
import "./chunk-CBIGMWMI.js";
|
|
349
350
|
import {
|
|
350
351
|
RUN_WAKE_CHANNEL_ENV,
|
|
351
352
|
buildLoadSkillExecutor,
|
|
352
|
-
buildLocalWorkspaceOpenAiTools,
|
|
353
|
-
buildLocalWorkspaceToolset,
|
|
354
353
|
findSummaryAnchorIndex,
|
|
355
354
|
markCliUserBatchPhase,
|
|
356
355
|
orderDialogHistory,
|
|
@@ -363,20 +362,20 @@ import {
|
|
|
363
362
|
runTaskStop,
|
|
364
363
|
saveCliPendingUserMessages,
|
|
365
364
|
validateStoredSummary
|
|
366
|
-
} from "./chunk-
|
|
365
|
+
} from "./chunk-7EUJ65PF.js";
|
|
367
366
|
import "./chunk-ZNFJWEN4.js";
|
|
368
367
|
import "./chunk-LHCGKAFO.js";
|
|
369
368
|
import "./chunk-OOV5JN25.js";
|
|
370
369
|
import "./chunk-2E4BYAUE.js";
|
|
371
370
|
import "./chunk-AL3TYDIF.js";
|
|
372
|
-
import "./chunk-CHOZJMJS.js";
|
|
373
371
|
import "./chunk-PIVTQRX6.js";
|
|
374
372
|
import "./chunk-HNUWUO75.js";
|
|
373
|
+
import "./chunk-CHOZJMJS.js";
|
|
375
374
|
import "./chunk-DMPZMYH4.js";
|
|
376
|
-
import "./chunk-
|
|
375
|
+
import "./chunk-MLK3FEXG.js";
|
|
377
376
|
import "./chunk-BYXBJQAS.js";
|
|
378
377
|
import "./chunk-BZLGPM5B.js";
|
|
379
|
-
import "./chunk-
|
|
378
|
+
import "./chunk-AIFQKNPP.js";
|
|
380
379
|
import "./chunk-56GBUMO5.js";
|
|
381
380
|
import {
|
|
382
381
|
TOOL_GUIDED_SECTION_ORDER,
|
|
@@ -385,8 +384,8 @@ import {
|
|
|
385
384
|
buildRuntimeGuidanceBlocks,
|
|
386
385
|
resolveResponseGuidelines,
|
|
387
386
|
resolveToolGuidedSections
|
|
388
|
-
} from "./chunk-
|
|
389
|
-
import "./chunk-
|
|
387
|
+
} from "./chunk-BXGU6274.js";
|
|
388
|
+
import "./chunk-Q2MPKE4B.js";
|
|
390
389
|
import {
|
|
391
390
|
classifyFailureSubclass,
|
|
392
391
|
formatQuotaSummary
|
|
@@ -395,14 +394,15 @@ import "./chunk-FXEPZKNJ.js";
|
|
|
395
394
|
import "./chunk-X4O7FJF5.js";
|
|
396
395
|
import "./chunk-TLE77UJ5.js";
|
|
397
396
|
import {
|
|
397
|
+
sanitizeToolOutputText,
|
|
398
398
|
scrubSecrets
|
|
399
|
-
} from "./chunk-
|
|
399
|
+
} from "./chunk-KO5GO2BC.js";
|
|
400
400
|
import "./chunk-KXOPLLFP.js";
|
|
401
401
|
import "./chunk-DNNPARJK.js";
|
|
402
402
|
import "./chunk-2MBTWINN.js";
|
|
403
403
|
import {
|
|
404
404
|
extractReferenceKeysFromMessage
|
|
405
|
-
} from "./chunk-
|
|
405
|
+
} from "./chunk-7WHCIA5V.js";
|
|
406
406
|
import "./chunk-5ZUL4CUO.js";
|
|
407
407
|
import {
|
|
408
408
|
COMPACTION_SUMMARY_SYSTEM_PROMPT,
|
|
@@ -422,17 +422,18 @@ import {
|
|
|
422
422
|
} from "./chunk-2FZVXOFX.js";
|
|
423
423
|
import "./chunk-H57T64RA.js";
|
|
424
424
|
import "./chunk-UKZX3NHN.js";
|
|
425
|
+
import "./chunk-SR4FE5VD.js";
|
|
425
426
|
import {
|
|
426
427
|
clipCompactText
|
|
427
428
|
} from "./chunk-5MMAK75Q.js";
|
|
428
|
-
import "./chunk-SR4FE5VD.js";
|
|
429
429
|
import "./chunk-USGHJSGO.js";
|
|
430
|
-
import "./chunk-KX6YBIHG.js";
|
|
431
430
|
import "./chunk-E6A5NHDH.js";
|
|
431
|
+
import "./chunk-KX6YBIHG.js";
|
|
432
432
|
import {
|
|
433
433
|
formatToolOverflowMarker,
|
|
434
434
|
getProcessRegistry
|
|
435
|
-
} from "./chunk-
|
|
435
|
+
} from "./chunk-6N4IKMTH.js";
|
|
436
|
+
import "./chunk-HEVRQGGH.js";
|
|
436
437
|
import {
|
|
437
438
|
isQuotaExhaustedError
|
|
438
439
|
} from "./chunk-EWQ3HGNZ.js";
|
|
@@ -452,10 +453,10 @@ import {
|
|
|
452
453
|
buildMemoryUseGuidanceLayer,
|
|
453
454
|
partitionScopedBlocks,
|
|
454
455
|
renderTurnContextBlocksWithScope
|
|
455
|
-
} from "./chunk-
|
|
456
|
+
} from "./chunk-YQLAFJRQ.js";
|
|
456
457
|
import {
|
|
457
458
|
buildUserResponseLanguageContext
|
|
458
|
-
} from "./chunk-
|
|
459
|
+
} from "./chunk-GYX6XTAI.js";
|
|
459
460
|
import "./chunk-2SXN7LAY.js";
|
|
460
461
|
import {
|
|
461
462
|
createOAuthTokenStore,
|
|
@@ -467,24 +468,22 @@ import {
|
|
|
467
468
|
dialogMessageRecordToAgentRuntimeMessage
|
|
468
469
|
} from "./chunk-4ZCTKB27.js";
|
|
469
470
|
import {
|
|
470
|
-
expandEnabledPacks,
|
|
471
471
|
listBuiltinSkills
|
|
472
|
-
} from "./chunk-
|
|
472
|
+
} from "./chunk-JW6OURKM.js";
|
|
473
473
|
import "./chunk-EUGTFFO6.js";
|
|
474
474
|
import {
|
|
475
475
|
parseExternalSkillMarkdown
|
|
476
476
|
} from "./chunk-AETZ7AD6.js";
|
|
477
|
-
import "./chunk-
|
|
477
|
+
import "./chunk-5P3PPQVP.js";
|
|
478
478
|
import "./chunk-KHCLMKZZ.js";
|
|
479
479
|
import "./chunk-SYTHYBMI.js";
|
|
480
480
|
import "./chunk-OJKUU3LP.js";
|
|
481
481
|
import "./chunk-YZMNK53S.js";
|
|
482
482
|
import {
|
|
483
483
|
resolveLocalUserId
|
|
484
|
-
} from "./chunk-
|
|
484
|
+
} from "./chunk-QGFLVQ6E.js";
|
|
485
485
|
import {
|
|
486
486
|
CURRENT_OPERATOR_USER_ID,
|
|
487
|
-
NOLO_DEFAULT_AGENT_KEY,
|
|
488
487
|
resolveCliAgentKeyInput
|
|
489
488
|
} from "./chunk-BR3GT6MR.js";
|
|
490
489
|
import "./chunk-JCQ3WCQ3.js";
|
|
@@ -495,13 +494,10 @@ import {
|
|
|
495
494
|
import {
|
|
496
495
|
BUILTIN_NOLO_AGENT_KEY,
|
|
497
496
|
BUILTIN_NOLO_AGENT_MODEL,
|
|
498
|
-
BUILTIN_NOLO_AGENT_NAME
|
|
499
|
-
|
|
500
|
-
parseBuiltinPlatformAgentId
|
|
501
|
-
} from "./chunk-KZAT2M2V.js";
|
|
497
|
+
BUILTIN_NOLO_AGENT_NAME
|
|
498
|
+
} from "./chunk-RIWKZT7E.js";
|
|
502
499
|
import {
|
|
503
|
-
extractCustomId
|
|
504
|
-
parsePublicAgentId
|
|
500
|
+
extractCustomId
|
|
505
501
|
} from "./chunk-M2EJHDJP.js";
|
|
506
502
|
import "./chunk-I42VC5KR.js";
|
|
507
503
|
import "./chunk-P4R5KXU7.js";
|
|
@@ -519,7 +515,7 @@ import {
|
|
|
519
515
|
getCliInstallChannel,
|
|
520
516
|
probeCliUpdate,
|
|
521
517
|
runSelfUpdateDetailed
|
|
522
|
-
} from "./chunk-
|
|
518
|
+
} from "./chunk-Z3JZ2R5F.js";
|
|
523
519
|
import {
|
|
524
520
|
parseUserIdFromAuthToken,
|
|
525
521
|
resolveAuthToken,
|
|
@@ -548,7 +544,7 @@ import {
|
|
|
548
544
|
resolveDefaultSpawn,
|
|
549
545
|
spawnProcess
|
|
550
546
|
} from "./chunk-4O22PGNQ.js";
|
|
551
|
-
import "./chunk-
|
|
547
|
+
import "./chunk-RQKTCHQM.js";
|
|
552
548
|
import {
|
|
553
549
|
dailyWelcomeTip,
|
|
554
550
|
getCliLocale,
|
|
@@ -558,7 +554,7 @@ import {
|
|
|
558
554
|
t,
|
|
559
555
|
toolFamilyOf,
|
|
560
556
|
toolLabelVariants
|
|
561
|
-
} from "./chunk-
|
|
557
|
+
} from "./chunk-JOJH3KWV.js";
|
|
562
558
|
import "./chunk-EJQE5HB7.js";
|
|
563
559
|
import "./chunk-6SOWMEAY.js";
|
|
564
560
|
import {
|
|
@@ -590,595 +586,6 @@ import {
|
|
|
590
586
|
} from "./chunk-QSJ3HFEF.js";
|
|
591
587
|
import "./chunk-U67V476Y.js";
|
|
592
588
|
|
|
593
|
-
// packages/ai/agent/utils/sortUtils.ts
|
|
594
|
-
function sortAgentsFavoriteOwnedPublic(items) {
|
|
595
|
-
const map = /* @__PURE__ */ new Map();
|
|
596
|
-
for (const item of items) {
|
|
597
|
-
const existing = map.get(item.key);
|
|
598
|
-
if (!existing) {
|
|
599
|
-
map.set(item.key, { ...item });
|
|
600
|
-
continue;
|
|
601
|
-
}
|
|
602
|
-
map.set(item.key, {
|
|
603
|
-
...existing,
|
|
604
|
-
...item,
|
|
605
|
-
key: existing.key,
|
|
606
|
-
favoritedAt: Math.max(existing.favoritedAt ?? 0, item.favoritedAt ?? 0) || void 0,
|
|
607
|
-
isOwned: Boolean(existing.isOwned || item.isOwned),
|
|
608
|
-
isPublic: Boolean(existing.isPublic || item.isPublic),
|
|
609
|
-
updatedAt: Math.max(existing.updatedAt ?? 0, item.updatedAt ?? 0),
|
|
610
|
-
order: existing.order ?? item.order
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
const arr = Array.from(map.values());
|
|
614
|
-
arr.sort((a, b) => {
|
|
615
|
-
const aFav = a.favoritedAt != null && a.favoritedAt > 0;
|
|
616
|
-
const bFav = b.favoritedAt != null && b.favoritedAt > 0;
|
|
617
|
-
if (aFav !== bFav) return aFav ? -1 : 1;
|
|
618
|
-
if (aFav && bFav) {
|
|
619
|
-
const diff = (b.favoritedAt ?? 0) - (a.favoritedAt ?? 0);
|
|
620
|
-
if (diff !== 0) return diff;
|
|
621
|
-
}
|
|
622
|
-
const aOwned = Boolean(a.isOwned);
|
|
623
|
-
const bOwned = Boolean(b.isOwned);
|
|
624
|
-
if (aOwned !== bOwned) return aOwned ? -1 : 1;
|
|
625
|
-
const aPublic = Boolean(a.isPublic);
|
|
626
|
-
const bPublic = Boolean(b.isPublic);
|
|
627
|
-
if (aPublic !== bPublic) return aPublic ? -1 : 1;
|
|
628
|
-
const tsDiff = (b.updatedAt ?? 0) - (a.updatedAt ?? 0);
|
|
629
|
-
if (tsDiff !== 0) return tsDiff;
|
|
630
|
-
const aOrder = a.order ?? Number.POSITIVE_INFINITY;
|
|
631
|
-
const bOrder = b.order ?? Number.POSITIVE_INFINITY;
|
|
632
|
-
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
633
|
-
return a.key.localeCompare(b.key);
|
|
634
|
-
});
|
|
635
|
-
return arr;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
// packages/cli/tui/agentCatalog.ts
|
|
639
|
-
var DEFAULT_TUI_AGENT_KEY = NOLO_DEFAULT_AGENT_KEY;
|
|
640
|
-
function formatAgentSourceLabel(entry) {
|
|
641
|
-
if (entry.kind === "platform" || entry.apiSource === "platform") return t("agentSourcePlatform");
|
|
642
|
-
if (entry.apiSource === "cli") {
|
|
643
|
-
return entry.cliProvider ? `${t("agentSourceSubscription")}(${entry.cliProvider})` : t("agentSourceSubscription");
|
|
644
|
-
}
|
|
645
|
-
if (entry.apiSource === "custom") return t("agentSourceApi");
|
|
646
|
-
return t("agentSourcePlatform");
|
|
647
|
-
}
|
|
648
|
-
var PLATFORM_AGENTS = [
|
|
649
|
-
{
|
|
650
|
-
// 名称与模型都从 builtinAgentCatalog 派生:`/switch` 里的 nolo 项直接显示
|
|
651
|
-
// 它实际指向的模型(当前 deepseek-flash),换代自动跟随。
|
|
652
|
-
name: BUILTIN_NOLO_AGENT_NAME,
|
|
653
|
-
key: DEFAULT_TUI_AGENT_KEY,
|
|
654
|
-
model: BUILTIN_NOLO_AGENT_MODEL,
|
|
655
|
-
kind: "platform",
|
|
656
|
-
description: "one assistant that routes work across your agents and data"
|
|
657
|
-
}
|
|
658
|
-
];
|
|
659
|
-
function resolveCatalogPlatformAgents(_env = process.env) {
|
|
660
|
-
return PLATFORM_AGENTS;
|
|
661
|
-
}
|
|
662
|
-
function toUpdatedAt(value) {
|
|
663
|
-
if (value == null) return 0;
|
|
664
|
-
const parsed = new Date(value).getTime();
|
|
665
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
666
|
-
}
|
|
667
|
-
function listedAgentToCatalogEntry(agent) {
|
|
668
|
-
return {
|
|
669
|
-
name: agent.name,
|
|
670
|
-
key: agent.privateKey,
|
|
671
|
-
model: agent.model,
|
|
672
|
-
kind: "private",
|
|
673
|
-
updatedAt: toUpdatedAt(agent.updatedAt),
|
|
674
|
-
...agent.apiSource ? { apiSource: agent.apiSource } : {},
|
|
675
|
-
...agent.cliProvider ? { cliProvider: agent.cliProvider } : {},
|
|
676
|
-
...agent.quota ? { quota: agent.quota } : {}
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
function mergeCatalogEntries(currentKey, platformAgents, privateAgents, favoritedAtByKey = {}) {
|
|
680
|
-
const seen = /* @__PURE__ */ new Set();
|
|
681
|
-
const merged = [];
|
|
682
|
-
const push = (entry) => {
|
|
683
|
-
if (seen.has(entry.key)) return;
|
|
684
|
-
seen.add(entry.key);
|
|
685
|
-
const favoritedAt = favoritedAtByKey[entry.key];
|
|
686
|
-
merged.push(favoritedAt ? { ...entry, favoritedAt } : entry);
|
|
687
|
-
};
|
|
688
|
-
const current = [...platformAgents, ...privateAgents].find((entry) => entry.key === currentKey) ?? null;
|
|
689
|
-
if (current) push(current);
|
|
690
|
-
for (const entry of platformAgents) {
|
|
691
|
-
if (entry.key !== currentKey) push(entry);
|
|
692
|
-
}
|
|
693
|
-
const sortablePrivate = privateAgents.map((entry) => ({
|
|
694
|
-
key: entry.key,
|
|
695
|
-
...favoritedAtByKey[entry.key] !== void 0 ? { favoritedAt: favoritedAtByKey[entry.key] } : {},
|
|
696
|
-
isOwned: true,
|
|
697
|
-
updatedAt: entry.updatedAt ?? 0
|
|
698
|
-
}));
|
|
699
|
-
const sortedKeys = sortAgentsFavoriteOwnedPublic(sortablePrivate);
|
|
700
|
-
const sortedKeyOrder = new Map(sortedKeys.map((item, i) => [item.key, i]));
|
|
701
|
-
const sortedPrivate = [...privateAgents].sort(
|
|
702
|
-
(a, b) => (sortedKeyOrder.get(a.key) ?? 0) - (sortedKeyOrder.get(b.key) ?? 0)
|
|
703
|
-
);
|
|
704
|
-
for (const entry of sortedPrivate) {
|
|
705
|
-
if (entry.key !== currentKey) push(entry);
|
|
706
|
-
}
|
|
707
|
-
return merged;
|
|
708
|
-
}
|
|
709
|
-
function formatUnavailableFavoritesNotice(unavailableFavoriteCount) {
|
|
710
|
-
if (!Number.isFinite(unavailableFavoriteCount) || unavailableFavoriteCount <= 0) {
|
|
711
|
-
return null;
|
|
712
|
-
}
|
|
713
|
-
return t(
|
|
714
|
-
"agentCatalogUnavailableFavorites",
|
|
715
|
-
String(Math.floor(unavailableFavoriteCount))
|
|
716
|
-
);
|
|
717
|
-
}
|
|
718
|
-
var agentCatalogCache = null;
|
|
719
|
-
var lastRefresh = null;
|
|
720
|
-
function getAgentCatalogRefreshStatus(args = {}) {
|
|
721
|
-
const env = args.env ?? process.env;
|
|
722
|
-
const token = resolveAuthToken([], env);
|
|
723
|
-
const key = `${token ? parseUserIdFromAuthToken(token) ?? "anon" : "anon"}|${resolveServerUrl(env)}`;
|
|
724
|
-
return lastRefresh?.cacheKey === key ? lastRefresh.status : null;
|
|
725
|
-
}
|
|
726
|
-
var agentCatalogRefreshInFlight = null;
|
|
727
|
-
var agentCatalogGeneration = 0;
|
|
728
|
-
var agentCatalogRawLoadInFlight = /* @__PURE__ */ new Map();
|
|
729
|
-
var AGENT_CATALOG_FRESH_MS = 15e3;
|
|
730
|
-
var AGENT_CATALOG_MAX_STALE_MS = 5 * 6e4;
|
|
731
|
-
var AGENT_CATALOG_FOREGROUND_DEADLINE_MS = 2500;
|
|
732
|
-
var AGENT_CATALOG_BACKGROUND_DEADLINE_MS = 8e3;
|
|
733
|
-
function resolveCatalogDeadlineMs(kind, env) {
|
|
734
|
-
const override = Number.parseInt(env.NOLO_TUI_CATALOG_DEADLINE_MS ?? "", 10);
|
|
735
|
-
if (Number.isFinite(override) && override > 0) return override;
|
|
736
|
-
return kind === "foreground" ? AGENT_CATALOG_FOREGROUND_DEADLINE_MS : AGENT_CATALOG_BACKGROUND_DEADLINE_MS;
|
|
737
|
-
}
|
|
738
|
-
var SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES = 1;
|
|
739
|
-
var SERVER_COOLDOWN_MS = 5 * 6e4;
|
|
740
|
-
var serverHealth = /* @__PURE__ */ new Map();
|
|
741
|
-
var serverHealthNow = () => Date.now();
|
|
742
|
-
function filterHealthyServers(serverUrls) {
|
|
743
|
-
const now = serverHealthNow();
|
|
744
|
-
const healthy = serverUrls.filter((url) => {
|
|
745
|
-
const state = serverHealth.get(url);
|
|
746
|
-
if (!state) return true;
|
|
747
|
-
return !(state.consecutiveFailures >= SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES && now - state.trippedAt < SERVER_COOLDOWN_MS);
|
|
748
|
-
});
|
|
749
|
-
return healthy.length > 0 ? healthy : serverUrls;
|
|
750
|
-
}
|
|
751
|
-
function keepPrimaryServer(serverUrls, primary) {
|
|
752
|
-
return serverUrls.includes(primary) ? serverUrls : [primary, ...serverUrls];
|
|
753
|
-
}
|
|
754
|
-
function recordServerFailures(failures) {
|
|
755
|
-
const now = serverHealthNow();
|
|
756
|
-
for (const failure of failures) {
|
|
757
|
-
const state = serverHealth.get(failure.serverUrl) ?? {
|
|
758
|
-
consecutiveFailures: 0,
|
|
759
|
-
trippedAt: 0
|
|
760
|
-
};
|
|
761
|
-
state.consecutiveFailures += 1;
|
|
762
|
-
if (state.consecutiveFailures >= SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES) {
|
|
763
|
-
state.trippedAt = now;
|
|
764
|
-
}
|
|
765
|
-
serverHealth.set(failure.serverUrl, state);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
function recordServerSuccesses(serverUrls) {
|
|
769
|
-
for (const url of serverUrls) serverHealth.delete(url);
|
|
770
|
-
}
|
|
771
|
-
function withFetchDeadline(fetchImpl, deadlineMs) {
|
|
772
|
-
return async (input, init) => {
|
|
773
|
-
let timer;
|
|
774
|
-
const deadline = new Promise((_, reject) => {
|
|
775
|
-
timer = setTimeout(
|
|
776
|
-
() => reject(new Error(`catalog fetch deadline exceeded (${deadlineMs}ms)`)),
|
|
777
|
-
deadlineMs
|
|
778
|
-
);
|
|
779
|
-
});
|
|
780
|
-
const signal = init?.signal;
|
|
781
|
-
let onAbort;
|
|
782
|
-
let aborted = null;
|
|
783
|
-
if (signal) {
|
|
784
|
-
if (signal.aborted) {
|
|
785
|
-
throw signal.reason ?? new Error("catalog fetch aborted");
|
|
786
|
-
}
|
|
787
|
-
aborted = new Promise((_, reject) => {
|
|
788
|
-
onAbort = () => reject(signal.reason ?? new Error("catalog fetch aborted"));
|
|
789
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
try {
|
|
793
|
-
const response = await Promise.race([
|
|
794
|
-
fetchImpl(input, init),
|
|
795
|
-
deadline,
|
|
796
|
-
...aborted ? [aborted] : []
|
|
797
|
-
]);
|
|
798
|
-
const text = await Promise.race([
|
|
799
|
-
response.text(),
|
|
800
|
-
deadline,
|
|
801
|
-
...aborted ? [aborted] : []
|
|
802
|
-
]);
|
|
803
|
-
return new Response(text, {
|
|
804
|
-
status: response.status,
|
|
805
|
-
statusText: response.statusText,
|
|
806
|
-
headers: response.headers
|
|
807
|
-
});
|
|
808
|
-
} finally {
|
|
809
|
-
if (timer) clearTimeout(timer);
|
|
810
|
-
if (signal && onAbort) signal.removeEventListener("abort", onAbort);
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
function hasWarmAgentCatalogCache(args = {}) {
|
|
815
|
-
const env = args.env ?? process.env;
|
|
816
|
-
const authToken = resolveAuthToken([], env);
|
|
817
|
-
const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
|
|
818
|
-
const cacheKey = `${userId ?? "anon"}|${resolveServerUrl(env)}`;
|
|
819
|
-
return agentCatalogCache?.cacheKey === cacheKey && Date.now() - agentCatalogCache.at < AGENT_CATALOG_MAX_STALE_MS;
|
|
820
|
-
}
|
|
821
|
-
async function loadAgentCatalog(args) {
|
|
822
|
-
return (await loadAgentCatalogWithNotices(args)).entries;
|
|
823
|
-
}
|
|
824
|
-
async function loadAgentCatalogWithNotices(args) {
|
|
825
|
-
const env = args.env ?? process.env;
|
|
826
|
-
const authToken = resolveAuthToken([], env);
|
|
827
|
-
const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
|
|
828
|
-
const cacheKey = `${userId ?? "anon"}|${resolveServerUrl(env)}`;
|
|
829
|
-
const cached = agentCatalogCache?.cacheKey === cacheKey ? agentCatalogCache : null;
|
|
830
|
-
if (cached && !args.fresh && Date.now() - cached.at < AGENT_CATALOG_MAX_STALE_MS) {
|
|
831
|
-
const refreshStatus = getAgentCatalogRefreshStatus({ env });
|
|
832
|
-
if (args.revalidateInBackground || Date.now() - cached.at >= AGENT_CATALOG_FRESH_MS) {
|
|
833
|
-
refreshAgentCatalogInBackground(args, env, cacheKey);
|
|
834
|
-
}
|
|
835
|
-
if (args.currentKey && cached.entries.length > 1 && cached.entries[0]?.key !== args.currentKey) {
|
|
836
|
-
const idx = cached.entries.findIndex((entry) => entry.key === args.currentKey);
|
|
837
|
-
if (idx > 0) {
|
|
838
|
-
return {
|
|
839
|
-
entries: [
|
|
840
|
-
cached.entries[idx],
|
|
841
|
-
...cached.entries.slice(0, idx),
|
|
842
|
-
...cached.entries.slice(idx + 1)
|
|
843
|
-
],
|
|
844
|
-
refreshStatus,
|
|
845
|
-
unavailableFavoriteCount: cached.unavailableFavoriteCount
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
return {
|
|
850
|
-
entries: cached.entries,
|
|
851
|
-
refreshStatus,
|
|
852
|
-
unavailableFavoriteCount: cached.unavailableFavoriteCount
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
let rawData;
|
|
856
|
-
const generation = args.fresh ? ++agentCatalogGeneration : agentCatalogGeneration;
|
|
857
|
-
const deadlineKind = args.fresh ? "foreground" : args.deadlineKind ?? "foreground";
|
|
858
|
-
const inFlight = agentCatalogRawLoadInFlight.get(deadlineKind);
|
|
859
|
-
if (inFlight) {
|
|
860
|
-
rawData = await inFlight;
|
|
861
|
-
} else {
|
|
862
|
-
const promise = fetchRawCatalogData({ ...args, deadlineKind }, env);
|
|
863
|
-
agentCatalogRawLoadInFlight.set(deadlineKind, promise);
|
|
864
|
-
try {
|
|
865
|
-
rawData = await promise;
|
|
866
|
-
} finally {
|
|
867
|
-
if (agentCatalogRawLoadInFlight.get(deadlineKind) === promise) {
|
|
868
|
-
agentCatalogRawLoadInFlight.delete(deadlineKind);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
const entries = mergeCatalogEntries(
|
|
873
|
-
args.currentKey,
|
|
874
|
-
resolveCatalogPlatformAgents(env),
|
|
875
|
-
rawData.privateAgents,
|
|
876
|
-
rawData.favoritedAtByKey
|
|
877
|
-
);
|
|
878
|
-
if (generation === agentCatalogGeneration) {
|
|
879
|
-
lastRefresh = { cacheKey, status: rawData.status };
|
|
880
|
-
}
|
|
881
|
-
if (generation === agentCatalogGeneration && rawData.status === "success") {
|
|
882
|
-
agentCatalogCache = {
|
|
883
|
-
cacheKey,
|
|
884
|
-
at: Date.now(),
|
|
885
|
-
entries,
|
|
886
|
-
unavailableFavoriteCount: rawData.unavailableFavoriteCount
|
|
887
|
-
};
|
|
888
|
-
}
|
|
889
|
-
void mergeCatalogQuotas(entries, { env, fetchImpl: args.fetchImpl }).catch(() => {
|
|
890
|
-
});
|
|
891
|
-
return { entries, unavailableFavoriteCount: rawData.unavailableFavoriteCount, refreshStatus: rawData.status };
|
|
892
|
-
}
|
|
893
|
-
async function mergeCatalogQuotas(entries, args) {
|
|
894
|
-
const fresh = await refreshSubscriptionQuotas({
|
|
895
|
-
entries: entries.map((entry) => ({
|
|
896
|
-
key: entry.key,
|
|
897
|
-
...entry.quota ? { quota: entry.quota } : {},
|
|
898
|
-
probeable: entry.kind === "private"
|
|
899
|
-
})),
|
|
900
|
-
...args.env ? { env: args.env } : {},
|
|
901
|
-
...args.fetchImpl ? { fetchImpl: args.fetchImpl } : {}
|
|
902
|
-
});
|
|
903
|
-
for (const entry of entries) {
|
|
904
|
-
const quota = fresh[entry.key];
|
|
905
|
-
if (quota) entry.quota = quota;
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
function refreshAgentCatalogInBackground(args, env, cacheKey) {
|
|
909
|
-
if (agentCatalogRefreshInFlight) return;
|
|
910
|
-
const generation = agentCatalogGeneration;
|
|
911
|
-
agentCatalogRefreshInFlight = fetchRawCatalogData(
|
|
912
|
-
{ ...args, deadlineKind: "background" },
|
|
913
|
-
env
|
|
914
|
-
).then(async (rawData) => {
|
|
915
|
-
if (generation !== agentCatalogGeneration) return;
|
|
916
|
-
lastRefresh = { cacheKey, status: rawData.status };
|
|
917
|
-
if (rawData.status !== "success") return;
|
|
918
|
-
const entries = mergeCatalogEntries(
|
|
919
|
-
args.currentKey,
|
|
920
|
-
resolveCatalogPlatformAgents(env),
|
|
921
|
-
rawData.privateAgents,
|
|
922
|
-
rawData.favoritedAtByKey
|
|
923
|
-
);
|
|
924
|
-
await mergeCatalogQuotas(entries, { env, fetchImpl: args.fetchImpl });
|
|
925
|
-
if (generation === agentCatalogGeneration) {
|
|
926
|
-
agentCatalogCache = {
|
|
927
|
-
cacheKey,
|
|
928
|
-
at: Date.now(),
|
|
929
|
-
entries,
|
|
930
|
-
unavailableFavoriteCount: rawData.unavailableFavoriteCount
|
|
931
|
-
};
|
|
932
|
-
}
|
|
933
|
-
}).catch(() => {
|
|
934
|
-
if (generation === agentCatalogGeneration) lastRefresh = { cacheKey, status: "failed" };
|
|
935
|
-
}).finally(() => {
|
|
936
|
-
agentCatalogRefreshInFlight = null;
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
async function prefillCatalogFromLocalDb(_args) {
|
|
940
|
-
}
|
|
941
|
-
function prefetchAgentCatalog(args) {
|
|
942
|
-
void (async () => {
|
|
943
|
-
await prefillCatalogFromLocalDb({ env: args.env, getDb: args.getDb }).catch(() => {
|
|
944
|
-
});
|
|
945
|
-
void loadAgentCatalog({ ...args, currentKey: "", deadlineKind: "background" }).catch(() => {
|
|
946
|
-
});
|
|
947
|
-
})();
|
|
948
|
-
}
|
|
949
|
-
async function fetchRawCatalogData(args, env) {
|
|
950
|
-
const deadlineMs = resolveCatalogDeadlineMs(args.deadlineKind ?? "foreground", env);
|
|
951
|
-
const fetchImpl = withFetchDeadline(args.fetchImpl ?? fetch, deadlineMs);
|
|
952
|
-
const fallbackFetchImpl = args.fallbackFetchImpl ? withFetchDeadline(args.fallbackFetchImpl, deadlineMs) : void 0;
|
|
953
|
-
const authToken = resolveAuthToken([], env);
|
|
954
|
-
const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
|
|
955
|
-
if (!authToken || !userId) {
|
|
956
|
-
return { privateAgents: [], favoritedAtByKey: {}, unavailableFavoriteCount: 0, status: "success" };
|
|
957
|
-
}
|
|
958
|
-
const serverUrl = resolveServerUrl(env);
|
|
959
|
-
const allServerUrls = resolveServerCandidates([], env, serverUrl);
|
|
960
|
-
const serverUrls = (args.deadlineKind ?? "foreground") === "foreground" ? keepPrimaryServer(filterHealthyServers(allServerUrls), serverUrl) : allServerUrls;
|
|
961
|
-
const fetchStartedAt = performance.now();
|
|
962
|
-
let listedAgents = [];
|
|
963
|
-
let catalogAuthoritative = false;
|
|
964
|
-
let catalogAvailable = false;
|
|
965
|
-
let favoritesFailed = false;
|
|
966
|
-
const favoritesPromise = listFavoriteAgentIdsAcrossServers({
|
|
967
|
-
authToken,
|
|
968
|
-
fetchImpl,
|
|
969
|
-
serverUrls,
|
|
970
|
-
onFailure: () => {
|
|
971
|
-
favoritesFailed = true;
|
|
972
|
-
}
|
|
973
|
-
}).catch(() => {
|
|
974
|
-
favoritesFailed = true;
|
|
975
|
-
return {};
|
|
976
|
-
});
|
|
977
|
-
try {
|
|
978
|
-
const remoteResult = await listRemoteAgentsAcrossServers({
|
|
979
|
-
authToken,
|
|
980
|
-
fallbackFetchImpl,
|
|
981
|
-
fetchImpl,
|
|
982
|
-
serverUrls,
|
|
983
|
-
userId
|
|
984
|
-
});
|
|
985
|
-
listedAgents = remoteResult.agents;
|
|
986
|
-
catalogAvailable = true;
|
|
987
|
-
catalogAuthoritative = remoteResult.failures.length === 0 && serverUrls.length === allServerUrls.length;
|
|
988
|
-
recordServerSuccesses(serverUrls.filter(
|
|
989
|
-
(url) => !remoteResult.failures.some((f) => f.serverUrl === url)
|
|
990
|
-
));
|
|
991
|
-
recordServerFailures(remoteResult.failures);
|
|
992
|
-
} catch {
|
|
993
|
-
try {
|
|
994
|
-
const localBudgetMs = Math.max(
|
|
995
|
-
500,
|
|
996
|
-
deadlineMs - (performance.now() - fetchStartedAt)
|
|
997
|
-
);
|
|
998
|
-
let localTimer;
|
|
999
|
-
try {
|
|
1000
|
-
listedAgents = await Promise.race([
|
|
1001
|
-
(async () => {
|
|
1002
|
-
const db = args.getDb ? await args.getDb() : await getReadableCliDb({ write: () => {
|
|
1003
|
-
} });
|
|
1004
|
-
return listLocalCachedAgents({ db, userId });
|
|
1005
|
-
})(),
|
|
1006
|
-
new Promise((_, reject) => {
|
|
1007
|
-
localTimer = setTimeout(
|
|
1008
|
-
() => reject(new Error("local catalog deadline exceeded")),
|
|
1009
|
-
localBudgetMs
|
|
1010
|
-
);
|
|
1011
|
-
})
|
|
1012
|
-
]);
|
|
1013
|
-
catalogAvailable = true;
|
|
1014
|
-
} finally {
|
|
1015
|
-
if (localTimer) clearTimeout(localTimer);
|
|
1016
|
-
}
|
|
1017
|
-
} catch {
|
|
1018
|
-
try {
|
|
1019
|
-
listedAgents = await listRemoteAgents({
|
|
1020
|
-
authToken,
|
|
1021
|
-
fallbackFetchImpl,
|
|
1022
|
-
fetchImpl,
|
|
1023
|
-
serverUrl,
|
|
1024
|
-
userId,
|
|
1025
|
-
queryUserRecords,
|
|
1026
|
-
readDbRecord
|
|
1027
|
-
});
|
|
1028
|
-
catalogAvailable = true;
|
|
1029
|
-
} catch {
|
|
1030
|
-
listedAgents = [];
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
const privateAgents = listedAgents.map(listedAgentToCatalogEntry);
|
|
1035
|
-
const favoritedAtByKey = await favoritesPromise;
|
|
1036
|
-
for (const agent of listedAgents) {
|
|
1037
|
-
const favoritedAt = [agent.privateKey, agent.publicKey, agent.id].map((key) => favoritedAtByKey[key]).find((value) => value !== void 0);
|
|
1038
|
-
if (favoritedAt !== void 0) favoritedAtByKey[agent.privateKey] = favoritedAt;
|
|
1039
|
-
}
|
|
1040
|
-
const existingKeys = /* @__PURE__ */ new Set();
|
|
1041
|
-
for (const agent of listedAgents) {
|
|
1042
|
-
existingKeys.add(agent.privateKey);
|
|
1043
|
-
existingKeys.add(agent.publicKey);
|
|
1044
|
-
existingKeys.add(agent.id);
|
|
1045
|
-
}
|
|
1046
|
-
let unavailableFavoriteCount = 0;
|
|
1047
|
-
let orphanSkipped = false;
|
|
1048
|
-
await Promise.all(
|
|
1049
|
-
Object.keys(favoritedAtByKey).map(async (favKey) => {
|
|
1050
|
-
if (existingKeys.has(favKey)) return;
|
|
1051
|
-
const remainingMs = deadlineMs - (performance.now() - fetchStartedAt);
|
|
1052
|
-
if (remainingMs <= 0) {
|
|
1053
|
-
orphanSkipped = true;
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1056
|
-
try {
|
|
1057
|
-
let orphanTimer;
|
|
1058
|
-
const orphanDeadline = new Promise((_, reject) => {
|
|
1059
|
-
orphanTimer = setTimeout(
|
|
1060
|
-
() => reject(new Error("orphan hydrate deadline")),
|
|
1061
|
-
remainingMs
|
|
1062
|
-
);
|
|
1063
|
-
});
|
|
1064
|
-
try {
|
|
1065
|
-
const favRead = await Promise.race([
|
|
1066
|
-
readLiveDbRecordAfterTombstoneMerge({
|
|
1067
|
-
authToken,
|
|
1068
|
-
dbKey: favKey,
|
|
1069
|
-
fallbackFetchImpl,
|
|
1070
|
-
fetchImpl,
|
|
1071
|
-
serverUrls
|
|
1072
|
-
}),
|
|
1073
|
-
orphanDeadline
|
|
1074
|
-
]);
|
|
1075
|
-
const record = favRead.record;
|
|
1076
|
-
if (!record || record.type && record.type !== "agent") return;
|
|
1077
|
-
const norm = normalizeListedAgent(record);
|
|
1078
|
-
if (!norm) return;
|
|
1079
|
-
if (existingKeys.has(norm.privateKey) || existingKeys.has(norm.publicKey) || existingKeys.has(norm.id)) {
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
|
-
existingKeys.add(norm.privateKey);
|
|
1083
|
-
existingKeys.add(norm.publicKey);
|
|
1084
|
-
existingKeys.add(norm.id);
|
|
1085
|
-
privateAgents.push(listedAgentToCatalogEntry(norm));
|
|
1086
|
-
} finally {
|
|
1087
|
-
if (orphanTimer) clearTimeout(orphanTimer);
|
|
1088
|
-
}
|
|
1089
|
-
} catch {
|
|
1090
|
-
unavailableFavoriteCount += 1;
|
|
1091
|
-
}
|
|
1092
|
-
})
|
|
1093
|
-
);
|
|
1094
|
-
const status = !catalogAvailable && favoritesFailed ? "failed" : catalogAuthoritative && !favoritesFailed && unavailableFavoriteCount === 0 && !orphanSkipped ? "success" : "degraded";
|
|
1095
|
-
return { privateAgents, favoritedAtByKey, unavailableFavoriteCount, status };
|
|
1096
|
-
}
|
|
1097
|
-
function renderAgentCatalogList(entries, currentKey, options) {
|
|
1098
|
-
const lines = ["Agents:"];
|
|
1099
|
-
entries.forEach((entry, index) => {
|
|
1100
|
-
const current = entry.key === currentKey ? " (current)" : "";
|
|
1101
|
-
const favorite = entry.favoritedAt ? " \u2605" : "";
|
|
1102
|
-
const detail = entry.description ? ` \u2014 ${entry.description}` : "";
|
|
1103
|
-
const quota = formatQuotaSummary(entry.quota, Date.now(), { model: entry.model });
|
|
1104
|
-
const trailing = quota ? ` [${quota}]` : detail;
|
|
1105
|
-
lines.push(
|
|
1106
|
-
` ${String(index + 1).padStart(2)} ${entry.name.padEnd(18)} ${entry.model.padEnd(14)} ${formatAgentSourceLabel(entry)}${favorite}${trailing}${current}`
|
|
1107
|
-
);
|
|
1108
|
-
});
|
|
1109
|
-
lines.push("");
|
|
1110
|
-
const notice = formatUnavailableFavoritesNotice(
|
|
1111
|
-
options?.unavailableFavoriteCount ?? 0
|
|
1112
|
-
);
|
|
1113
|
-
if (notice) lines.push(notice);
|
|
1114
|
-
lines.push("Tip: run /switch in an interactive terminal to pick with \u2191\u2193.");
|
|
1115
|
-
return lines.join("\n");
|
|
1116
|
-
}
|
|
1117
|
-
function resolveEntryApiSource(entry) {
|
|
1118
|
-
if (entry.apiSource) return entry.apiSource;
|
|
1119
|
-
return entry.kind === "platform" ? "platform" : void 0;
|
|
1120
|
-
}
|
|
1121
|
-
function toSwitchTarget(entry) {
|
|
1122
|
-
const apiSource = resolveEntryApiSource(entry);
|
|
1123
|
-
return {
|
|
1124
|
-
name: entry.name,
|
|
1125
|
-
key: entry.key,
|
|
1126
|
-
model: entry.model,
|
|
1127
|
-
...apiSource ? { apiSource } : {}
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
function findAgentCatalogEntry(entries, rawTarget) {
|
|
1131
|
-
const target = rawTarget.trim();
|
|
1132
|
-
if (!target) return null;
|
|
1133
|
-
if (/^\d+$/.test(target)) {
|
|
1134
|
-
const entry = entries[Number(target) - 1];
|
|
1135
|
-
return entry ? toSwitchTarget(entry) : null;
|
|
1136
|
-
}
|
|
1137
|
-
const lower = target.toLowerCase();
|
|
1138
|
-
const byName = entries.find(
|
|
1139
|
-
(entry) => entry.name.toLowerCase() === lower || entry.key.toLowerCase() === lower || entry.key.toLowerCase().endsWith(`-${lower}`)
|
|
1140
|
-
);
|
|
1141
|
-
if (byName) return toSwitchTarget(byName);
|
|
1142
|
-
if (target.startsWith("agent-") || target.startsWith("agent-pub-")) {
|
|
1143
|
-
const builtin = builtinAgentCatalogEntryById(
|
|
1144
|
-
parseBuiltinPlatformAgentId(target) ?? parsePublicAgentId(target)
|
|
1145
|
-
);
|
|
1146
|
-
if (builtin) {
|
|
1147
|
-
return {
|
|
1148
|
-
name: builtin.name,
|
|
1149
|
-
key: target,
|
|
1150
|
-
model: builtin.model,
|
|
1151
|
-
apiSource: builtin.apiSource ?? "platform"
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
return { name: target, key: target };
|
|
1155
|
-
}
|
|
1156
|
-
return null;
|
|
1157
|
-
}
|
|
1158
|
-
function lookupCachedAgentName(agentKey) {
|
|
1159
|
-
const trimmed = agentKey.trim();
|
|
1160
|
-
if (!trimmed) return void 0;
|
|
1161
|
-
const platform = PLATFORM_AGENTS.find(
|
|
1162
|
-
(p) => p.key === trimmed || p.key.toLowerCase() === trimmed.toLowerCase()
|
|
1163
|
-
);
|
|
1164
|
-
if (platform?.name) return platform.name;
|
|
1165
|
-
const builtin = builtinAgentCatalogEntryById(
|
|
1166
|
-
parseBuiltinPlatformAgentId(trimmed) ?? parsePublicAgentId(trimmed)
|
|
1167
|
-
);
|
|
1168
|
-
if (builtin?.name) return builtin.name;
|
|
1169
|
-
if (agentCatalogCache?.entries) {
|
|
1170
|
-
const direct = agentCatalogCache.entries.find(
|
|
1171
|
-
(entry) => entry.key === trimmed || entry.key.toLowerCase() === trimmed.toLowerCase()
|
|
1172
|
-
);
|
|
1173
|
-
if (direct?.name) return direct.name;
|
|
1174
|
-
const suffix = agentCatalogCache.entries.find(
|
|
1175
|
-
(entry) => entry.key.toLowerCase().endsWith(`-${trimmed.toLowerCase()}`) || trimmed.toLowerCase().endsWith(`-${entry.key.toLowerCase()}`)
|
|
1176
|
-
);
|
|
1177
|
-
if (suffix?.name) return suffix.name;
|
|
1178
|
-
}
|
|
1179
|
-
return void 0;
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
589
|
// packages/cli/tui/runSnapshotDisplay.ts
|
|
1183
590
|
function runStatusTone(status) {
|
|
1184
591
|
if (!isAgentRunTerminalStatus(status)) return "warning";
|
|
@@ -2569,10 +1976,16 @@ function createTurnHistory() {
|
|
|
2569
1976
|
followBottom: true
|
|
2570
1977
|
};
|
|
2571
1978
|
}
|
|
2572
|
-
function
|
|
1979
|
+
function formatToolDetails(history, last) {
|
|
1980
|
+
return (last ? history.toolDetails?.slice(history.lastTurnToolDetailStart ?? 0) : history.toolDetails)?.join("") ?? "";
|
|
1981
|
+
}
|
|
1982
|
+
function startTurn(history, role, options) {
|
|
2573
1983
|
if (history.currentRole !== null && history.currentContent) {
|
|
2574
1984
|
finalizeCurrentTurn(history);
|
|
2575
1985
|
}
|
|
1986
|
+
if (role === "assistant" && !options?.continueAssistantTurn) {
|
|
1987
|
+
history.lastTurnToolDetailStart = history.toolDetails?.length ?? 0;
|
|
1988
|
+
}
|
|
2576
1989
|
history.currentRole = role;
|
|
2577
1990
|
history.currentContent = "";
|
|
2578
1991
|
history.currentBlocks = [];
|
|
@@ -2585,7 +1998,7 @@ function appendToCurrentTurn(history, chunk) {
|
|
|
2585
1998
|
function appendCurrentBlock(history, kind, chunk) {
|
|
2586
1999
|
if (!chunk) return;
|
|
2587
2000
|
const last = history.currentBlocks.at(-1);
|
|
2588
|
-
if (last?.kind === kind) {
|
|
2001
|
+
if (last?.kind === kind && !last.runWindow) {
|
|
2589
2002
|
last.content = applyTerminalOutputToText(last.content, chunk);
|
|
2590
2003
|
} else {
|
|
2591
2004
|
history.currentBlocks.push({
|
|
@@ -2596,11 +2009,27 @@ function appendCurrentBlock(history, kind, chunk) {
|
|
|
2596
2009
|
}
|
|
2597
2010
|
function finalizeCurrentTurn(history) {
|
|
2598
2011
|
if (history.currentRole !== null) {
|
|
2012
|
+
let content = history.currentContent;
|
|
2013
|
+
const blocks = [];
|
|
2014
|
+
for (let index = history.currentBlocks.length - 1; index >= 0; index--) {
|
|
2015
|
+
const block = history.currentBlocks[index];
|
|
2016
|
+
const window = block.runWindow;
|
|
2017
|
+
const end = window ? window.start + block.content.length : 0;
|
|
2018
|
+
if (window && content.slice(window.start, end) === block.content) {
|
|
2019
|
+
const summary = `${window.finalizedSummary}
|
|
2020
|
+
`;
|
|
2021
|
+
content = content.slice(0, window.start) + summary + content.slice(end);
|
|
2022
|
+
blocks.push({ kind: block.kind, content: summary });
|
|
2023
|
+
} else {
|
|
2024
|
+
blocks.push({ kind: block.kind, content: block.content });
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
blocks.reverse();
|
|
2599
2028
|
history.turns.push({
|
|
2600
2029
|
role: history.currentRole,
|
|
2601
|
-
content: compactTurnContent(
|
|
2030
|
+
content: compactTurnContent(content),
|
|
2602
2031
|
...history.currentRole === "assistant" && history.currentBlocks.length > 0 ? {
|
|
2603
|
-
blocks:
|
|
2032
|
+
blocks: blocks.map((block) => ({
|
|
2604
2033
|
...block,
|
|
2605
2034
|
content: compactTurnContent(block.content)
|
|
2606
2035
|
})).filter((block) => block.content.length > 0)
|
|
@@ -2626,9 +2055,18 @@ function appendLocalTurn(history, command, output) {
|
|
|
2626
2055
|
function readTreePayload(chunk) {
|
|
2627
2056
|
return JSON.parse(chunk.slice(TUI_TREE_MARKER.length).replace(/\u0002\n?$/, ""));
|
|
2628
2057
|
}
|
|
2629
|
-
function applyTreeRewrite(text,
|
|
2630
|
-
if (
|
|
2631
|
-
|
|
2058
|
+
function applyTreeRewrite(text, payload) {
|
|
2059
|
+
if (payload.previousLines && payload.lines) {
|
|
2060
|
+
let end = text.length - Number(text.endsWith("\n"));
|
|
2061
|
+
for (let i = payload.previousLines.length - 1; i >= 0; i--) {
|
|
2062
|
+
if (end < 0) return null;
|
|
2063
|
+
const start = end === 0 ? 0 : text.lastIndexOf("\n", end - 1) + 1;
|
|
2064
|
+
if (stripAnsi(text.slice(start, end)) !== stripAnsi(payload.previousLines[i])) return null;
|
|
2065
|
+
end = start - 1;
|
|
2066
|
+
}
|
|
2067
|
+
return `${text.slice(0, end + 1)}${payload.lines.join("\n")}
|
|
2068
|
+
`;
|
|
2069
|
+
}
|
|
2632
2070
|
const tree = `\u25B8 ${payload.summary}`;
|
|
2633
2071
|
const hadTrailingNewline = text.endsWith("\n");
|
|
2634
2072
|
const body = hadTrailingNewline ? text.slice(0, -1) : text;
|
|
@@ -2651,36 +2089,52 @@ function applyTreeRewrite(text, chunk) {
|
|
|
2651
2089
|
}
|
|
2652
2090
|
function applyOutputChunkToCurrentTurn(history, chunk, kind = "assistant") {
|
|
2653
2091
|
if (kind === "tool") {
|
|
2092
|
+
const payload = chunk.startsWith(TUI_TREE_MARKER) ? readTreePayload(chunk) : null;
|
|
2654
2093
|
const details = history.toolDetails ??= [];
|
|
2655
|
-
details.push(
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
)
|
|
2661
|
-
|
|
2662
|
-
if (chunk.startsWith(TUI_TREE_MARKER)) {
|
|
2663
|
-
const payload = readTreePayload(chunk);
|
|
2664
|
-
if (payload.appendOnly) {
|
|
2094
|
+
details.push(payload ? payload.details ?? payload.fallback : toolRowDetailLine(chunk));
|
|
2095
|
+
while (details.length > MAX_TUI_HISTORY_TURNS * 10) {
|
|
2096
|
+
details.shift();
|
|
2097
|
+
history.lastTurnToolDetailStart = Math.max(0, (history.lastTurnToolDetailStart ?? 0) - 1);
|
|
2098
|
+
}
|
|
2099
|
+
if (payload) {
|
|
2100
|
+
const appendFallback = () => {
|
|
2665
2101
|
history.currentContent = applyTerminalOutputToText(history.currentContent, payload.fallback);
|
|
2666
2102
|
appendCurrentBlock(history, kind, payload.fallback);
|
|
2103
|
+
};
|
|
2104
|
+
if (payload.appendOnly) {
|
|
2105
|
+
appendFallback();
|
|
2667
2106
|
return true;
|
|
2668
2107
|
}
|
|
2669
|
-
const rewrittenTree = applyTreeRewrite(history.currentContent, chunk);
|
|
2670
|
-
if (rewrittenTree === null) {
|
|
2671
|
-
const safe = readTreePayload(chunk).fallback;
|
|
2672
|
-
history.currentContent = applyTerminalOutputToText(history.currentContent, safe);
|
|
2673
|
-
appendCurrentBlock(history, kind, safe);
|
|
2674
|
-
return false;
|
|
2675
|
-
}
|
|
2676
|
-
const treeContent = rewrittenTree;
|
|
2677
|
-
history.currentContent = treeContent;
|
|
2678
2108
|
const lastBlock = history.currentBlocks.at(-1);
|
|
2679
|
-
const
|
|
2109
|
+
const rewrittenTree = applyTreeRewrite(history.currentContent, payload);
|
|
2110
|
+
if (payload.previousLines && payload.lines) {
|
|
2111
|
+
const rewrittenBlock = lastBlock?.kind === "tool" ? applyTreeRewrite(lastBlock.content, payload) : null;
|
|
2112
|
+
if (rewrittenTree !== null && rewrittenBlock !== null && lastBlock) {
|
|
2113
|
+
const window = `${payload.lines.join("\n")}
|
|
2680
2114
|
`;
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2115
|
+
const prefix = rewrittenBlock.slice(0, -window.length);
|
|
2116
|
+
history.currentBlocks.pop();
|
|
2117
|
+
if (prefix) history.currentBlocks.push({ kind: "tool", content: prefix });
|
|
2118
|
+
history.currentBlocks.push({
|
|
2119
|
+
kind: "tool",
|
|
2120
|
+
content: window,
|
|
2121
|
+
...payload.finalizedSummary !== void 0 && {
|
|
2122
|
+
runWindow: { start: rewrittenTree.length - window.length, finalizedSummary: payload.finalizedSummary }
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2125
|
+
history.currentContent = rewrittenTree;
|
|
2126
|
+
return true;
|
|
2127
|
+
}
|
|
2128
|
+
} else if (rewrittenTree !== null) {
|
|
2129
|
+
history.currentContent = rewrittenTree;
|
|
2130
|
+
const treeBlock = `\u25B8 ${payload.summary}
|
|
2131
|
+
`;
|
|
2132
|
+
if (lastBlock?.kind === "tool") lastBlock.content = applyTreeRewrite(lastBlock.content, payload) ?? `${lastBlock.content}${treeBlock}`;
|
|
2133
|
+
else history.currentBlocks.push({ kind: "tool", content: treeBlock });
|
|
2134
|
+
return true;
|
|
2135
|
+
}
|
|
2136
|
+
appendFallback();
|
|
2137
|
+
return false;
|
|
2684
2138
|
}
|
|
2685
2139
|
}
|
|
2686
2140
|
const next = applyTerminalOutputToText(history.currentContent, chunk);
|
|
@@ -3219,12 +2673,12 @@ function getAllTurnEntries(history, contentWidth) {
|
|
|
3219
2673
|
colorEnabled,
|
|
3220
2674
|
themeFingerprint
|
|
3221
2675
|
);
|
|
3222
|
-
const
|
|
3223
|
-
const startRow = finalizedLines +
|
|
2676
|
+
const sep2 = currentTurnSeparator(history);
|
|
2677
|
+
const startRow = finalizedLines + sep2;
|
|
3224
2678
|
entries.push({
|
|
3225
2679
|
startRow,
|
|
3226
2680
|
lineCount: streamingLines.length,
|
|
3227
|
-
separatorAbove:
|
|
2681
|
+
separatorAbove: sep2
|
|
3228
2682
|
});
|
|
3229
2683
|
turns.push({
|
|
3230
2684
|
role: history.currentRole,
|
|
@@ -3376,8 +2830,8 @@ function renderHistory(output, history, inputLines, selection, reservedRows = 0,
|
|
|
3376
2830
|
themeFingerprint
|
|
3377
2831
|
);
|
|
3378
2832
|
currentLines = currentLayoutRows.map((r) => r.rendered);
|
|
3379
|
-
const
|
|
3380
|
-
currentStart = finalizedLines +
|
|
2833
|
+
const sep2 = currentTurnSeparator(history);
|
|
2834
|
+
currentStart = finalizedLines + sep2;
|
|
3381
2835
|
}
|
|
3382
2836
|
const totalLines = currentStart >= 0 ? currentStart + currentLines.length : finalizedLines;
|
|
3383
2837
|
if (history.followBottom) {
|
|
@@ -3712,13 +3166,13 @@ function createDialogHost(args) {
|
|
|
3712
3166
|
};
|
|
3713
3167
|
let operationRunning = false;
|
|
3714
3168
|
const operations = [];
|
|
3715
|
-
const exclusive = (body, cancellation) => new Promise((
|
|
3169
|
+
const exclusive = (body, cancellation) => new Promise((resolve5, reject) => {
|
|
3716
3170
|
const abortQueued = () => {
|
|
3717
3171
|
const index = operations.indexOf(start);
|
|
3718
3172
|
if (index < 0) return;
|
|
3719
3173
|
operations.splice(index, 1);
|
|
3720
3174
|
cancellation?.signal.removeEventListener("abort", abortQueued);
|
|
3721
|
-
|
|
3175
|
+
resolve5(cancellation.cancelled());
|
|
3722
3176
|
};
|
|
3723
3177
|
const start = () => {
|
|
3724
3178
|
cancellation?.signal.removeEventListener("abort", abortQueued);
|
|
@@ -3739,7 +3193,7 @@ function createDialogHost(args) {
|
|
|
3739
3193
|
void Promise.resolve(result).then(
|
|
3740
3194
|
(value) => {
|
|
3741
3195
|
release();
|
|
3742
|
-
|
|
3196
|
+
resolve5(value);
|
|
3743
3197
|
},
|
|
3744
3198
|
(error) => {
|
|
3745
3199
|
release();
|
|
@@ -3748,7 +3202,7 @@ function createDialogHost(args) {
|
|
|
3748
3202
|
);
|
|
3749
3203
|
};
|
|
3750
3204
|
if (cancellation?.signal.aborted) {
|
|
3751
|
-
|
|
3205
|
+
resolve5(cancellation.cancelled());
|
|
3752
3206
|
return;
|
|
3753
3207
|
}
|
|
3754
3208
|
if (operationRunning) {
|
|
@@ -4125,9 +3579,9 @@ function createRawKeyReader(input, options) {
|
|
|
4125
3579
|
};
|
|
4126
3580
|
const resolveWaiter = (value) => {
|
|
4127
3581
|
if (!waiter) return;
|
|
4128
|
-
const
|
|
3582
|
+
const resolve5 = waiter;
|
|
4129
3583
|
waiter = null;
|
|
4130
|
-
|
|
3584
|
+
resolve5(value);
|
|
4131
3585
|
};
|
|
4132
3586
|
const tryDeliver = () => {
|
|
4133
3587
|
if (!waiter) return;
|
|
@@ -4186,12 +3640,12 @@ function createRawKeyReader(input, options) {
|
|
|
4186
3640
|
input.on("close", onClose);
|
|
4187
3641
|
input.on("end", onClose);
|
|
4188
3642
|
input.resume?.();
|
|
4189
|
-
const reader = () => new Promise((
|
|
3643
|
+
const reader = () => new Promise((resolve5) => {
|
|
4190
3644
|
if (closed) {
|
|
4191
|
-
|
|
3645
|
+
resolve5(drainClosed());
|
|
4192
3646
|
return;
|
|
4193
3647
|
}
|
|
4194
|
-
waiter =
|
|
3648
|
+
waiter = resolve5;
|
|
4195
3649
|
tryDeliver();
|
|
4196
3650
|
});
|
|
4197
3651
|
reader.dispose = () => {
|
|
@@ -4226,8 +3680,8 @@ async function runSelectDialog(args) {
|
|
|
4226
3680
|
const input = args.input ?? process.stdin;
|
|
4227
3681
|
const readKey = args.readKey ?? createRawKeyReader(input, hotkeys ? { preserveBracketedPaste: true } : void 0);
|
|
4228
3682
|
let cancelRead;
|
|
4229
|
-
const cancelled = new Promise((
|
|
4230
|
-
cancelRead = () =>
|
|
3683
|
+
const cancelled = new Promise((resolve5) => {
|
|
3684
|
+
cancelRead = () => resolve5(STREAM_CLOSED);
|
|
4231
3685
|
});
|
|
4232
3686
|
args.signal?.addEventListener("abort", cancelRead, { once: true });
|
|
4233
3687
|
if (args.signal?.aborted) cancelRead();
|
|
@@ -4662,7 +4116,7 @@ function createShellApprovalSession(confirm, isAutoConfirm = () => false) {
|
|
|
4662
4116
|
|
|
4663
4117
|
// packages/cli/tui/readlineWorkspace.ts
|
|
4664
4118
|
import { createInterface } from "node:readline";
|
|
4665
|
-
import { basename } from "node:path";
|
|
4119
|
+
import { basename as basename2 } from "node:path";
|
|
4666
4120
|
import { PassThrough } from "node:stream";
|
|
4667
4121
|
import { stdin as defaultInput, stdout as defaultOutput } from "node:process";
|
|
4668
4122
|
|
|
@@ -6136,11 +5590,11 @@ function createSecretInputCoordinator() {
|
|
|
6136
5590
|
};
|
|
6137
5591
|
return {
|
|
6138
5592
|
enqueue(start, options) {
|
|
6139
|
-
return new Promise((
|
|
6140
|
-
const entry = { start, settle:
|
|
5593
|
+
return new Promise((resolve5) => {
|
|
5594
|
+
const entry = { start, settle: resolve5, cancelled: options.cancelled, controller: new AbortController(), detach: () => options.signal?.removeEventListener("abort", abort) };
|
|
6141
5595
|
const abort = () => cancel(entry);
|
|
6142
5596
|
if (closed || options.signal?.aborted) {
|
|
6143
|
-
|
|
5597
|
+
resolve5(options.cancelled());
|
|
6144
5598
|
return;
|
|
6145
5599
|
}
|
|
6146
5600
|
queue.push(entry);
|
|
@@ -6152,9 +5606,9 @@ function createSecretInputCoordinator() {
|
|
|
6152
5606
|
if (active) {
|
|
6153
5607
|
if (!active.controller.signal.aborted) {
|
|
6154
5608
|
if (waiter) {
|
|
6155
|
-
const
|
|
5609
|
+
const resolve5 = waiter;
|
|
6156
5610
|
waiter = null;
|
|
6157
|
-
|
|
5611
|
+
resolve5(token);
|
|
6158
5612
|
} else inbox.push(token);
|
|
6159
5613
|
}
|
|
6160
5614
|
return true;
|
|
@@ -6163,10 +5617,10 @@ function createSecretInputCoordinator() {
|
|
|
6163
5617
|
const entry = queue[0];
|
|
6164
5618
|
active = entry;
|
|
6165
5619
|
inbox = [];
|
|
6166
|
-
const readKey = () => new Promise((
|
|
6167
|
-
if (entry.controller.signal.aborted)
|
|
6168
|
-
else if (inbox.length)
|
|
6169
|
-
else waiter =
|
|
5620
|
+
const readKey = () => new Promise((resolve5) => {
|
|
5621
|
+
if (entry.controller.signal.aborted) resolve5(STREAM_CLOSED);
|
|
5622
|
+
else if (inbox.length) resolve5(inbox.shift());
|
|
5623
|
+
else waiter = resolve5;
|
|
6170
5624
|
});
|
|
6171
5625
|
readKey.dispose = closeInbox;
|
|
6172
5626
|
let operation;
|
|
@@ -6243,8 +5697,8 @@ async function runSecretInputDialog(args) {
|
|
|
6243
5697
|
wakeAbort?.();
|
|
6244
5698
|
readKey?.dispose?.();
|
|
6245
5699
|
};
|
|
6246
|
-
const aborted = new Promise((
|
|
6247
|
-
wakeAbort = () =>
|
|
5700
|
+
const aborted = new Promise((resolve5) => {
|
|
5701
|
+
wakeAbort = () => resolve5(STREAM_CLOSED);
|
|
6248
5702
|
});
|
|
6249
5703
|
try {
|
|
6250
5704
|
readKey = args.readKey ?? createRawKeyReader(input, { preserveBracketedPaste: true });
|
|
@@ -6544,14 +5998,14 @@ function createInlineHostApprovalPrompt(args) {
|
|
|
6544
5998
|
} catch {
|
|
6545
5999
|
}
|
|
6546
6000
|
};
|
|
6547
|
-
const presentOne = (card, context, anchor) => new Promise((
|
|
6001
|
+
const presentOne = (card, context, anchor) => new Promise((resolve5) => {
|
|
6548
6002
|
if (disposed || context.signal?.aborted) {
|
|
6549
|
-
|
|
6003
|
+
resolve5(disposed ? "deny" : "cancelled");
|
|
6550
6004
|
return;
|
|
6551
6005
|
}
|
|
6552
6006
|
const expiresAt = Math.min(card.expiresAt, context.expiresAt ?? Infinity);
|
|
6553
6007
|
if (expiresAt <= now()) {
|
|
6554
|
-
|
|
6008
|
+
resolve5("expired");
|
|
6555
6009
|
return;
|
|
6556
6010
|
}
|
|
6557
6011
|
const abort = () => settle(context.signal?.reason === "expired" ? "expired" : "cancelled", "\u2716 approval ended \u2014 the action was not run");
|
|
@@ -6609,7 +6063,7 @@ function createInlineHostApprovalPrompt(args) {
|
|
|
6609
6063
|
painter?.clear();
|
|
6610
6064
|
} catch {
|
|
6611
6065
|
} finally {
|
|
6612
|
-
|
|
6066
|
+
resolve5(result);
|
|
6613
6067
|
}
|
|
6614
6068
|
}
|
|
6615
6069
|
};
|
|
@@ -7833,7 +7287,19 @@ function createRunRegistryPoller(deps) {
|
|
|
7833
7287
|
}
|
|
7834
7288
|
|
|
7835
7289
|
// packages/cli/tui/runCompletionWatcher.ts
|
|
7290
|
+
import {
|
|
7291
|
+
closeSync,
|
|
7292
|
+
constants as fsConstants,
|
|
7293
|
+
fstatSync,
|
|
7294
|
+
lstatSync,
|
|
7295
|
+
openSync,
|
|
7296
|
+
readSync,
|
|
7297
|
+
realpathSync
|
|
7298
|
+
} from "node:fs";
|
|
7299
|
+
import { basename, dirname, resolve as resolve2, sep } from "node:path";
|
|
7836
7300
|
var WAKE_NOTE_MAX_CHARS = 300;
|
|
7301
|
+
var WAKE_TITLE_MAX_CHARS = 120;
|
|
7302
|
+
var WAKE_AGENT_MAX_CHARS = 80;
|
|
7837
7303
|
function runDuration(record, nowMs = Date.now()) {
|
|
7838
7304
|
return formatRunAge(
|
|
7839
7305
|
{
|
|
@@ -7847,6 +7313,7 @@ function isFailureStatus(status) {
|
|
|
7847
7313
|
return typeof status === "string" && status !== "done";
|
|
7848
7314
|
}
|
|
7849
7315
|
var WAKE_ERROR_PAYLOAD_TOKEN_BUDGET = 500;
|
|
7316
|
+
var WAKE_ERROR_MIN_PAYLOAD_TOKEN_BUDGET = 120;
|
|
7850
7317
|
var WAKE_TOTAL_TOKEN_BUDGET = 2e3;
|
|
7851
7318
|
var escapeXmlAttribute = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
7852
7319
|
function clipTextToTokenBudget(text, budgetTokens) {
|
|
@@ -7870,23 +7337,270 @@ function failureErrorPayload(record, budgetTokens) {
|
|
|
7870
7337
|
const raw = typeof record.note === "string" && record.note.trim() ? record.note : typeof recordError === "string" && recordError.trim() ? recordError : "";
|
|
7871
7338
|
return clipTextToTokenBudget(clipText(raw, 2e3), budgetTokens);
|
|
7872
7339
|
}
|
|
7873
|
-
|
|
7340
|
+
var RESULT_HEAD_MAX_BYTES = 16 * 1024;
|
|
7341
|
+
var WAKE_SUMMARY_MAX_LINES = 25;
|
|
7342
|
+
var WAKE_SUMMARY_MAX_CHARS = 1e3;
|
|
7343
|
+
var WAKE_TOTAL_SUMMARY_CHAR_BUDGET = 2400;
|
|
7344
|
+
var RESULT_FILE_SUFFIX = ".result.md";
|
|
7345
|
+
function isSafeRunId(runId) {
|
|
7346
|
+
if (!runId) return false;
|
|
7347
|
+
if (runId.includes("/") || runId.includes("\\") || runId.includes("\0")) return false;
|
|
7348
|
+
if (runId === "." || runId === ".." || runId.includes("..")) return false;
|
|
7349
|
+
return true;
|
|
7350
|
+
}
|
|
7351
|
+
function canonicalDir(dir) {
|
|
7352
|
+
try {
|
|
7353
|
+
return realpathSync(dir);
|
|
7354
|
+
} catch {
|
|
7355
|
+
return resolve2(dir);
|
|
7356
|
+
}
|
|
7357
|
+
}
|
|
7358
|
+
function isUnderTrustedDir(path3, dir) {
|
|
7359
|
+
const parent = canonicalDir(dirname(path3));
|
|
7360
|
+
const root = canonicalDir(dir);
|
|
7361
|
+
return parent === root || parent.startsWith(root.endsWith(sep) ? root : `${root}${sep}`);
|
|
7362
|
+
}
|
|
7363
|
+
function resolveTrustedResultDirs(explicit) {
|
|
7364
|
+
if (Array.isArray(explicit) && explicit.length > 0) return explicit;
|
|
7365
|
+
return [resolveRunsDir(process.env)];
|
|
7366
|
+
}
|
|
7367
|
+
function resolveTrustedResultPath(resultFile, options = {}) {
|
|
7368
|
+
const raw = typeof resultFile === "string" ? resultFile.trim() : "";
|
|
7369
|
+
if (!raw) return null;
|
|
7370
|
+
if (options.runId !== void 0) {
|
|
7371
|
+
if (!isSafeRunId(options.runId)) return null;
|
|
7372
|
+
if (basename(raw) !== `${options.runId}${RESULT_FILE_SUFFIX}`) return null;
|
|
7373
|
+
}
|
|
7374
|
+
const dirs = resolveTrustedResultDirs(options.trustedResultDirs);
|
|
7375
|
+
const trusted = dirs.some(
|
|
7376
|
+
(dir) => typeof dir === "string" && dir.length > 0 && isUnderTrustedDir(raw, dir)
|
|
7377
|
+
);
|
|
7378
|
+
if (!trusted) return null;
|
|
7379
|
+
return raw;
|
|
7380
|
+
}
|
|
7381
|
+
function trimIncompleteUtf8Tail(buf) {
|
|
7382
|
+
if (buf.length === 0) return buf;
|
|
7383
|
+
let start = buf.length - 1;
|
|
7384
|
+
while (start >= 0 && (buf[start] & 192) === 128) start -= 1;
|
|
7385
|
+
if (start < 0) return buf;
|
|
7386
|
+
const lead = buf[start];
|
|
7387
|
+
let need = 1;
|
|
7388
|
+
if (lead < 128) need = 1;
|
|
7389
|
+
else if ((lead & 224) === 192) need = 2;
|
|
7390
|
+
else if ((lead & 240) === 224) need = 3;
|
|
7391
|
+
else if ((lead & 248) === 240) need = 4;
|
|
7392
|
+
const have = buf.length - start;
|
|
7393
|
+
if (have >= need) return buf;
|
|
7394
|
+
return buf.subarray(0, start);
|
|
7395
|
+
}
|
|
7396
|
+
function readResultFileHead(path3, maxBytes = RESULT_HEAD_MAX_BYTES) {
|
|
7397
|
+
let fd = null;
|
|
7398
|
+
try {
|
|
7399
|
+
const flags = fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0) | (fsConstants.O_NONBLOCK ?? 0);
|
|
7400
|
+
if (!fsConstants.O_NOFOLLOW) {
|
|
7401
|
+
let lst;
|
|
7402
|
+
try {
|
|
7403
|
+
lst = lstatSync(path3);
|
|
7404
|
+
} catch {
|
|
7405
|
+
return null;
|
|
7406
|
+
}
|
|
7407
|
+
if (!lst.isFile()) return null;
|
|
7408
|
+
}
|
|
7409
|
+
fd = openSync(path3, flags);
|
|
7410
|
+
const stat3 = fstatSync(fd);
|
|
7411
|
+
if (!stat3.isFile()) return null;
|
|
7412
|
+
const want = Math.min(stat3.size, maxBytes);
|
|
7413
|
+
if (want <= 0) return null;
|
|
7414
|
+
const buf = Buffer.alloc(want);
|
|
7415
|
+
let read = 0;
|
|
7416
|
+
while (read < want) {
|
|
7417
|
+
const n = readSync(fd, buf, read, want - read, read);
|
|
7418
|
+
if (n <= 0) break;
|
|
7419
|
+
read += n;
|
|
7420
|
+
}
|
|
7421
|
+
if (read <= 0) return null;
|
|
7422
|
+
const sliced = buf.subarray(0, read);
|
|
7423
|
+
const safe = stat3.size > read ? trimIncompleteUtf8Tail(sliced) : sliced;
|
|
7424
|
+
return {
|
|
7425
|
+
head: safe.toString("utf8"),
|
|
7426
|
+
bytesRead: safe.length,
|
|
7427
|
+
bytesTotal: stat3.size
|
|
7428
|
+
};
|
|
7429
|
+
} catch {
|
|
7430
|
+
return null;
|
|
7431
|
+
} finally {
|
|
7432
|
+
if (fd !== null) {
|
|
7433
|
+
try {
|
|
7434
|
+
closeSync(fd);
|
|
7435
|
+
} catch {
|
|
7436
|
+
}
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
}
|
|
7440
|
+
function stripLeadingFrontMatter(text) {
|
|
7441
|
+
const open = /^---\r?\n/.exec(text);
|
|
7442
|
+
if (!open) return text;
|
|
7443
|
+
const rest = text.slice(open[0].length);
|
|
7444
|
+
const immediate = /^---\r?\n/.exec(rest);
|
|
7445
|
+
if (immediate) return rest.slice(immediate[0].length);
|
|
7446
|
+
const close = /\r?\n---\r?\n/.exec(rest);
|
|
7447
|
+
if (!close) return text;
|
|
7448
|
+
return rest.slice(close.index + close[0].length);
|
|
7449
|
+
}
|
|
7450
|
+
function hasUnclosedFrontMatter(text) {
|
|
7451
|
+
const open = /^---\r?\n/.exec(text);
|
|
7452
|
+
if (!open) return false;
|
|
7453
|
+
const rest = text.slice(open[0].length);
|
|
7454
|
+
if (/^---\r?\n/.test(rest)) return false;
|
|
7455
|
+
return !/\r?\n---\r?(\n|$)/.test(rest);
|
|
7456
|
+
}
|
|
7457
|
+
function escapeXmlText(text) {
|
|
7458
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
7459
|
+
}
|
|
7460
|
+
var PEM_PRIVATE_KEY_MARKER = /-----(BEGIN|END) (?:[A-Z0-9 ]+)?PRIVATE KEY-----/g;
|
|
7461
|
+
function hasUnpairedPrivateKeyMarker(text) {
|
|
7462
|
+
if (typeof text !== "string" || !text.includes("PRIVATE KEY")) return false;
|
|
7463
|
+
let open = 0;
|
|
7464
|
+
for (const marker of text.matchAll(PEM_PRIVATE_KEY_MARKER)) {
|
|
7465
|
+
if (marker[1] === "BEGIN") open += 1;
|
|
7466
|
+
else if (open === 0) return true;
|
|
7467
|
+
else open -= 1;
|
|
7468
|
+
}
|
|
7469
|
+
return open > 0;
|
|
7470
|
+
}
|
|
7471
|
+
function trimTrailingNewline(text) {
|
|
7472
|
+
return text.replace(/(?:\r?\n)$/, "");
|
|
7473
|
+
}
|
|
7474
|
+
function normalizeNewlines(text) {
|
|
7475
|
+
return text.includes("\r") ? text.replace(/\r\n/g, "\n") : text;
|
|
7476
|
+
}
|
|
7477
|
+
function newlineCount(text) {
|
|
7478
|
+
let count = 0;
|
|
7479
|
+
for (let i = text.indexOf("\n"); i !== -1; i = text.indexOf("\n", i + 1)) count += 1;
|
|
7480
|
+
return count;
|
|
7481
|
+
}
|
|
7482
|
+
function scrubWakeBody(body) {
|
|
7483
|
+
const sanitized = trimTrailingNewline(sanitizeToolOutputText(body));
|
|
7484
|
+
if (hasUnpairedPrivateKeyMarker(sanitized)) return null;
|
|
7485
|
+
const scrubbed = scrubSecrets(sanitized).cleaned;
|
|
7486
|
+
return {
|
|
7487
|
+
lines: scrubbed.split("\n"),
|
|
7488
|
+
// 99.9% 的报告换行数不变 → 物理行 1:1,行号可信;折叠/跨行控制串被删就没法保证。
|
|
7489
|
+
lineAligned: newlineCount(normalizeNewlines(trimTrailingNewline(body))) === newlineCount(scrubbed)
|
|
7490
|
+
};
|
|
7491
|
+
}
|
|
7492
|
+
function escapedCharCost(ch) {
|
|
7493
|
+
if (ch === "&") return "&".length;
|
|
7494
|
+
if (ch === "<" || ch === ">") return "<".length;
|
|
7495
|
+
return ch.length;
|
|
7496
|
+
}
|
|
7497
|
+
function cutToEscapedBudget(text, budget) {
|
|
7498
|
+
if (budget <= 0) return { text: "", truncated: text.length > 0 };
|
|
7499
|
+
let used = 0;
|
|
7500
|
+
let i = 0;
|
|
7501
|
+
while (i < text.length) {
|
|
7502
|
+
const cp = text.codePointAt(i);
|
|
7503
|
+
const ch = String.fromCodePoint(cp);
|
|
7504
|
+
const cost = escapedCharCost(ch);
|
|
7505
|
+
if (used + cost > budget) return { text: text.slice(0, i), truncated: true };
|
|
7506
|
+
used += cost;
|
|
7507
|
+
i += ch.length;
|
|
7508
|
+
}
|
|
7509
|
+
return { text, truncated: false };
|
|
7510
|
+
}
|
|
7511
|
+
function extractWakeSummary(resultFile, maxChars = WAKE_SUMMARY_MAX_CHARS, options = {}) {
|
|
7512
|
+
if (typeof resultFile !== "string" || !resultFile.trim() || maxChars <= 0) {
|
|
7513
|
+
return null;
|
|
7514
|
+
}
|
|
7515
|
+
const trustedPath = resolveTrustedResultPath(resultFile, options);
|
|
7516
|
+
if (!trustedPath) return null;
|
|
7517
|
+
const read = readResultFileHead(trustedPath);
|
|
7518
|
+
if (!read) return null;
|
|
7519
|
+
if (hasUnclosedFrontMatter(read.head)) return null;
|
|
7520
|
+
if (hasUnpairedPrivateKeyMarker(read.head)) return null;
|
|
7521
|
+
const body = stripLeadingFrontMatter(read.head);
|
|
7522
|
+
const frontMatterChars = read.head.length - body.length;
|
|
7523
|
+
const frontMatterLines = frontMatterChars > 0 ? read.head.slice(0, frontMatterChars).split("\n").length - 1 : 0;
|
|
7524
|
+
const sourceLines = scrubWakeBody(body);
|
|
7525
|
+
if (!sourceLines) return null;
|
|
7526
|
+
const lines = sourceLines.lines;
|
|
7527
|
+
let start = 0;
|
|
7528
|
+
while (start < lines.length && lines[start].trim() === "") start++;
|
|
7529
|
+
if (start >= lines.length) return null;
|
|
7530
|
+
const lineLimited = lines.length - start > WAKE_SUMMARY_MAX_LINES;
|
|
7531
|
+
const picked = lines.slice(start, start + WAKE_SUMMARY_MAX_LINES);
|
|
7532
|
+
while (picked.length > 1 && picked[picked.length - 1].trim() === "") picked.pop();
|
|
7533
|
+
const joined = picked.join("\n").replace(/\s+$/, "");
|
|
7534
|
+
if (!joined.trim()) return null;
|
|
7535
|
+
const cut = cutToEscapedBudget(joined, maxChars);
|
|
7536
|
+
const finalText = cut.text.replace(/\s+$/, "");
|
|
7537
|
+
if (!finalText.trim()) return null;
|
|
7538
|
+
const retainedLines = Math.min(finalText.split("\n").length, picked.length);
|
|
7539
|
+
const firstSourceLine = frontMatterLines + 1 + start;
|
|
7540
|
+
return {
|
|
7541
|
+
text: escapeXmlText(finalText),
|
|
7542
|
+
...sourceLines.lineAligned ? { startLine: firstSourceLine, endLine: firstSourceLine + retainedLines - 1 } : {},
|
|
7543
|
+
truncated: lineLimited || cut.truncated || read.bytesTotal > read.bytesRead
|
|
7544
|
+
};
|
|
7545
|
+
}
|
|
7546
|
+
function renderSummaryBlock(summary) {
|
|
7547
|
+
const linesAttr = typeof summary.startLine === "number" && typeof summary.endLine === "number" ? ` lines="${summary.startLine}-${summary.endLine}"` : "";
|
|
7548
|
+
return [
|
|
7549
|
+
`<summary${linesAttr} truncated="${summary.truncated ? "true" : "false"}">`,
|
|
7550
|
+
summary.text,
|
|
7551
|
+
`</summary>`
|
|
7552
|
+
].join("\n");
|
|
7553
|
+
}
|
|
7554
|
+
var WAKE_SUMMARY_MIN_CHARS = 24;
|
|
7555
|
+
function planWakeSummaries(runs, readSummary = extractWakeSummary, options = {}) {
|
|
7556
|
+
const out = /* @__PURE__ */ new Map();
|
|
7557
|
+
const eligible = runs.filter(
|
|
7558
|
+
(r) => !isFailureStatus(r.status) && typeof r.resultFile === "string" && r.resultFile.trim()
|
|
7559
|
+
);
|
|
7560
|
+
if (!eligible.length) return out;
|
|
7561
|
+
const totalBudget = Math.max(
|
|
7562
|
+
0,
|
|
7563
|
+
options.totalCharBudget ?? WAKE_TOTAL_SUMMARY_CHAR_BUDGET
|
|
7564
|
+
);
|
|
7565
|
+
const perRunChars = Math.min(
|
|
7566
|
+
WAKE_SUMMARY_MAX_CHARS,
|
|
7567
|
+
Math.floor(totalBudget / eligible.length)
|
|
7568
|
+
);
|
|
7569
|
+
if (perRunChars < WAKE_SUMMARY_MIN_CHARS) return out;
|
|
7570
|
+
for (const r of eligible) {
|
|
7571
|
+
try {
|
|
7572
|
+
const summary = readSummary(r.resultFile.trim(), perRunChars, {
|
|
7573
|
+
runId: r.runId,
|
|
7574
|
+
trustedResultDirs: options.trustedResultDirs
|
|
7575
|
+
});
|
|
7576
|
+
if (summary && summary.text.trim()) out.set(r.runId, summary);
|
|
7577
|
+
} catch {
|
|
7578
|
+
}
|
|
7579
|
+
}
|
|
7580
|
+
return out;
|
|
7581
|
+
}
|
|
7582
|
+
function buildRunElement(record, nowMs, errorBudgetTokens, summary) {
|
|
7874
7583
|
const attrs = [
|
|
7875
7584
|
`runId="${escapeXmlAttribute(String(record.runId))}"`,
|
|
7876
7585
|
// Same rule as describeRun: this attribute is parsed by the model, so the
|
|
7877
7586
|
// label keeps the agentKey correlation — title never substitutes for it.
|
|
7878
7587
|
`agent="${escapeXmlAttribute(
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7588
|
+
clipText(
|
|
7589
|
+
resolveRunLabel({
|
|
7590
|
+
agentName: record.agentName,
|
|
7591
|
+
agentKey: record.agentKey,
|
|
7592
|
+
runId: record.runId
|
|
7593
|
+
}),
|
|
7594
|
+
WAKE_AGENT_MAX_CHARS
|
|
7595
|
+
)
|
|
7884
7596
|
)}"`,
|
|
7885
7597
|
`status="${escapeXmlAttribute(String(record.status))}"`
|
|
7886
7598
|
];
|
|
7887
7599
|
const rawTitle = record.title;
|
|
7888
7600
|
if (typeof rawTitle === "string" && rawTitle.trim()) {
|
|
7889
|
-
attrs.push(
|
|
7601
|
+
attrs.push(
|
|
7602
|
+
`title="${escapeXmlAttribute(clipText(rawTitle.trim(), WAKE_TITLE_MAX_CHARS))}"`
|
|
7603
|
+
);
|
|
7890
7604
|
}
|
|
7891
7605
|
if (record.continuedFrom) attrs.push(`continuedFrom="${escapeXmlAttribute(record.continuedFrom)}"`);
|
|
7892
7606
|
const verbose = isFailureStatus(record.status);
|
|
@@ -7910,51 +7624,133 @@ function buildRunElement(record, nowMs, errorBudgetTokens) {
|
|
|
7910
7624
|
if (!verbose) {
|
|
7911
7625
|
const note = typeof record.note === "string" && record.note.trim() ? clipText(record.note, WAKE_NOTE_MAX_CHARS) : "";
|
|
7912
7626
|
if (note) attrs.push(`note="${escapeXmlAttribute(note)}"`);
|
|
7913
|
-
return `<run ${attrs.join(" ")} />`;
|
|
7914
7627
|
}
|
|
7915
7628
|
const body = [];
|
|
7916
|
-
|
|
7917
|
-
if (
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7629
|
+
if (summary) body.push(renderSummaryBlock(summary));
|
|
7630
|
+
if (verbose) {
|
|
7631
|
+
const errorText = failureErrorPayload(record, errorBudgetTokens);
|
|
7632
|
+
if (errorText) body.push(`error: ${errorText}`);
|
|
7633
|
+
const counters = record.activity?.counters;
|
|
7634
|
+
if (counters && typeof counters.toolCalls === "number" && typeof counters.llmCalls === "number" && typeof counters.fileEdits === "number") {
|
|
7635
|
+
body.push(
|
|
7636
|
+
`activity: ${counters.toolCalls} tool calls \xB7 ${counters.llmCalls} llm calls \xB7 ${counters.fileEdits} edits`
|
|
7637
|
+
);
|
|
7638
|
+
}
|
|
7923
7639
|
}
|
|
7924
7640
|
if (body.length === 0) return `<run ${attrs.join(" ")} />`;
|
|
7925
7641
|
return `<run ${attrs.join(" ")}>
|
|
7926
7642
|
${body.join("\n")}
|
|
7927
7643
|
</run>`;
|
|
7928
7644
|
}
|
|
7929
|
-
function renderWakeMessage(elements, count) {
|
|
7645
|
+
function renderWakeMessage(elements, count, omittedCount = 0) {
|
|
7646
|
+
const omittedLine = omittedCount > 0 ? `\u2026 \u53CA\u53E6\u5916 ${omittedCount} \u6761\u5DF2\u5B8C\u6210 run\uFF0C\u7528 controlAgentRun(list) \u67E5\u770B` : null;
|
|
7930
7647
|
return [
|
|
7931
7648
|
`<background_run_completion count="${count}">`,
|
|
7932
7649
|
...elements,
|
|
7933
|
-
|
|
7650
|
+
...omittedLine ? [omittedLine] : [],
|
|
7651
|
+
`\u6709 resultFile \u4E14\u672A\u5185\u8054\u5B8C\u6574\u6458\u8981\uFF08\u65E0\u6458\u8981\u80F6\u56CA\u6216 truncated="true"\uFF09\u3001\u6709\u5F02\u5E38/\u7F3A\u53E3\u3001\u6D89\u9AD8\u98CE\u9669\u51B3\u7B56\u6216\u9700 review verdict \u5168\u91CF\u6838\u9A8C\u65F6\uFF0C\u6709 resultFile \u65F6\u7528 readFile \u5148\u8BFB\u5934\u90E8\u7ED3\u8BBA\uFF08\u5982 lines:"1-60"\uFF09\uFF0C\u518D\u6309\u533A\u95F4\u7EED\u8BFB\uFF1B\u5DF2\u5185\u8054\u5B8C\u6574\u6458\u8981\uFF08truncated="false"\uFF09\u7684\u5E38\u89C4\u975E\u5BA1\u67E5\u7ED3\u679C\u53EF\u76F4\u63A5\u6D88\u8D39\uFF0C\u65E0\u9700\u518D\u8C03 readFile\u3002\u672C\u5730\u7F3A\u5931\u5373\u65E0\u7ED3\u8BBA\uFF0C\u4E0D\u8BFB\u65E5\u5FD7\u3002\u7EC8\u6001\u53EA\u8868\u793A run \u7ED3\u675F\uFF0C\u4E0D\u8BC1\u660E\u4EA4\u4ED8\u3001\u6D4B\u8BD5\u3001\u5BA1\u67E5\u3001\u7528\u6237\u9A8C\u6536\u6216\u5408\u5165\u53D1\u5E03\u3002\u6B63\u6587\u662F\u6267\u884C\u8005\u62A5\u544A\uFF1Bruntime acceptance \u4EC5\u4E3A\u8FD0\u884C\u65F6\u89C2\u6D4B\uFF0Cunknown \u4FDD\u6301\u672A\u77E5\u3002continuedFrom \u4EC5\u4E3A\u7EED\u8DD1\u5173\u8054\uFF0C\u4E0D\u7EE7\u627F\u65E7\u7248\u672C APPROVE\uFF1B\u7ED3\u5408\u5F53\u524D\u5B8C\u6574\u7ED3\u679C\u6838\u5BF9\u8303\u56F4\u3001\u963B\u788D\u4E0E\u8BC1\u636E\u3002`,
|
|
7934
7652
|
`</background_run_completion>`
|
|
7935
7653
|
].join("\n");
|
|
7936
7654
|
}
|
|
7937
|
-
function
|
|
7938
|
-
const
|
|
7939
|
-
const
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
)
|
|
7956
|
-
|
|
7957
|
-
|
|
7655
|
+
function allocateErrorBudgets(failures, availableTokens, needTokens) {
|
|
7656
|
+
const out = /* @__PURE__ */ new Map();
|
|
7657
|
+
const needs = failures.map((r) => ({ runId: r.runId, need: Math.max(0, needTokens(r)) })).sort((a, b) => a.need - b.need);
|
|
7658
|
+
let pool = Math.max(0, availableTokens);
|
|
7659
|
+
for (let i = 0; i < needs.length; i++) {
|
|
7660
|
+
const share = Math.floor(pool / (needs.length - i));
|
|
7661
|
+
const granted = Math.min(needs[i].need, share);
|
|
7662
|
+
out.set(needs[i].runId, granted);
|
|
7663
|
+
pool -= granted;
|
|
7664
|
+
}
|
|
7665
|
+
return out;
|
|
7666
|
+
}
|
|
7667
|
+
function buildWakeMessage(finished, nowMs = Date.now(), options = {}) {
|
|
7668
|
+
const ordered = [
|
|
7669
|
+
...finished.filter((r) => isFailureStatus(r.status)),
|
|
7670
|
+
...finished.filter((r) => !isFailureStatus(r.status))
|
|
7671
|
+
];
|
|
7672
|
+
const attempt = (subset, omittedCount) => {
|
|
7673
|
+
const errorNeed = (r) => Math.min(
|
|
7674
|
+
WAKE_ERROR_PAYLOAD_TOKEN_BUDGET,
|
|
7675
|
+
estimateTokenCount(failureErrorPayload(r, WAKE_ERROR_PAYLOAD_TOKEN_BUDGET)) + 1
|
|
7676
|
+
);
|
|
7677
|
+
const render = (errorBudgets2, summaries) => renderWakeMessage(
|
|
7678
|
+
subset.map(
|
|
7679
|
+
(r) => buildRunElement(
|
|
7680
|
+
r,
|
|
7681
|
+
nowMs,
|
|
7682
|
+
isFailureStatus(r.status) ? errorBudgets2.get(r.runId) ?? 0 : 0,
|
|
7683
|
+
summaries.get(r.runId) ?? null
|
|
7684
|
+
)
|
|
7685
|
+
),
|
|
7686
|
+
finished.length,
|
|
7687
|
+
omittedCount
|
|
7688
|
+
);
|
|
7689
|
+
const bareTokens = estimateTokenCount(render(/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()));
|
|
7690
|
+
if (bareTokens > WAKE_TOTAL_TOKEN_BUDGET) return null;
|
|
7691
|
+
const failures = subset.filter((r) => isFailureStatus(r.status));
|
|
7692
|
+
const errorBudgets = allocateErrorBudgets(
|
|
7693
|
+
failures,
|
|
7694
|
+
WAKE_TOTAL_TOKEN_BUDGET - bareTokens,
|
|
7695
|
+
errorNeed
|
|
7696
|
+
);
|
|
7697
|
+
const includedSuccessCount = subset.length - failures.length;
|
|
7698
|
+
for (const r of failures) {
|
|
7699
|
+
const granted = errorBudgets.get(r.runId) ?? 0;
|
|
7700
|
+
if (includedSuccessCount > 0) {
|
|
7701
|
+
const floor = Math.min(errorNeed(r), WAKE_ERROR_MIN_PAYLOAD_TOKEN_BUDGET);
|
|
7702
|
+
if (granted < floor) return null;
|
|
7703
|
+
} else if (granted <= 0) {
|
|
7704
|
+
return null;
|
|
7705
|
+
}
|
|
7706
|
+
}
|
|
7707
|
+
let withErrors = render(errorBudgets, /* @__PURE__ */ new Map());
|
|
7708
|
+
let withErrorsTokens = estimateTokenCount(withErrors);
|
|
7709
|
+
if (includedSuccessCount === 0) {
|
|
7710
|
+
for (let round = 0; round < 6 && withErrorsTokens > WAKE_TOTAL_TOKEN_BUDGET; round++) {
|
|
7711
|
+
const excess = withErrorsTokens - WAKE_TOTAL_TOKEN_BUDGET;
|
|
7712
|
+
let victim = null;
|
|
7713
|
+
for (const r of failures) {
|
|
7714
|
+
if (!victim || (errorBudgets.get(r.runId) ?? 0) > (errorBudgets.get(victim.runId) ?? 0)) {
|
|
7715
|
+
victim = r;
|
|
7716
|
+
}
|
|
7717
|
+
}
|
|
7718
|
+
const current = victim ? errorBudgets.get(victim.runId) ?? 0 : 0;
|
|
7719
|
+
if (!victim || current <= 0) break;
|
|
7720
|
+
errorBudgets.set(victim.runId, Math.max(0, current - Math.max(1, excess + 2)));
|
|
7721
|
+
withErrors = render(errorBudgets, /* @__PURE__ */ new Map());
|
|
7722
|
+
withErrorsTokens = estimateTokenCount(withErrors);
|
|
7723
|
+
}
|
|
7724
|
+
}
|
|
7725
|
+
if (withErrorsTokens > WAKE_TOTAL_TOKEN_BUDGET) return null;
|
|
7726
|
+
let summaryCharBudget = Math.min(
|
|
7727
|
+
WAKE_TOTAL_SUMMARY_CHAR_BUDGET,
|
|
7728
|
+
// 最坏情况 1.5 token/字符(中文),据此把剩余 token 折成摘要字符预算。
|
|
7729
|
+
Math.floor(Math.max(0, WAKE_TOTAL_TOKEN_BUDGET - withErrorsTokens) / 1.5)
|
|
7730
|
+
);
|
|
7731
|
+
let message = withErrors;
|
|
7732
|
+
for (let round = 0; round < 8; round++) {
|
|
7733
|
+
const summaries = summaryCharBudget >= WAKE_SUMMARY_MIN_CHARS ? planWakeSummaries(subset, extractWakeSummary, {
|
|
7734
|
+
totalCharBudget: summaryCharBudget,
|
|
7735
|
+
trustedResultDirs: options.trustedResultDirs
|
|
7736
|
+
}) : /* @__PURE__ */ new Map();
|
|
7737
|
+
message = render(errorBudgets, summaries);
|
|
7738
|
+
if (summaries.size === 0) break;
|
|
7739
|
+
if (estimateTokenCount(message) <= WAKE_TOTAL_TOKEN_BUDGET) break;
|
|
7740
|
+
summaryCharBudget = Math.floor(summaryCharBudget / 2);
|
|
7741
|
+
if (summaryCharBudget < WAKE_SUMMARY_MIN_CHARS) {
|
|
7742
|
+
summaryCharBudget = 0;
|
|
7743
|
+
}
|
|
7744
|
+
}
|
|
7745
|
+
return estimateTokenCount(message) <= WAKE_TOTAL_TOKEN_BUDGET ? message : null;
|
|
7746
|
+
};
|
|
7747
|
+
const direct = attempt(finished, 0);
|
|
7748
|
+
if (direct) return direct;
|
|
7749
|
+
for (let keep = ordered.length - 1; keep >= 0; keep--) {
|
|
7750
|
+
const trimmed = attempt(ordered.slice(0, keep), ordered.length - keep);
|
|
7751
|
+
if (trimmed) return trimmed;
|
|
7752
|
+
}
|
|
7753
|
+
return renderWakeMessage([], finished.length, ordered.length);
|
|
7958
7754
|
}
|
|
7959
7755
|
function buildWakeDisplayText(finished, nowMs = Date.now()) {
|
|
7960
7756
|
const tasks = finished.map((record) => ({
|
|
@@ -8087,7 +7883,9 @@ function createRunCompletionWatcher(deps) {
|
|
|
8087
7883
|
}
|
|
8088
7884
|
if (finished.length === 0 || now() < retryAt) return;
|
|
8089
7885
|
const shapes = finished.map((r) => normalizeRunCompletionShape(r));
|
|
8090
|
-
const summaryText = buildWakeMessage(finished, now()
|
|
7886
|
+
const summaryText = buildWakeMessage(finished, now(), {
|
|
7887
|
+
trustedResultDirs: [resolveRunsDir(deps.env)]
|
|
7888
|
+
});
|
|
8091
7889
|
const event = {
|
|
8092
7890
|
kind: "child-run-completed",
|
|
8093
7891
|
runs: shapes,
|
|
@@ -8170,7 +7968,7 @@ function createRunCompletionWatcher(deps) {
|
|
|
8170
7968
|
import { readFileSync, statSync as statSync2 } from "node:fs";
|
|
8171
7969
|
import { readFile, stat } from "node:fs/promises";
|
|
8172
7970
|
import { homedir as homedir2 } from "node:os";
|
|
8173
|
-
import { isAbsolute, resolve as
|
|
7971
|
+
import { isAbsolute, resolve as resolve3 } from "node:path";
|
|
8174
7972
|
|
|
8175
7973
|
// packages/cli/tui/compressImage.ts
|
|
8176
7974
|
var MAX_IMAGE_DIMENSION = 1568;
|
|
@@ -8460,7 +8258,7 @@ function resolveImageSource(rawPath, cwd) {
|
|
|
8460
8258
|
return homedir2() + candidate.slice(1);
|
|
8461
8259
|
}
|
|
8462
8260
|
if (isAbsolute(candidate)) return candidate;
|
|
8463
|
-
return
|
|
8261
|
+
return resolve3(cwd, candidate);
|
|
8464
8262
|
}
|
|
8465
8263
|
function isImagePath(path3) {
|
|
8466
8264
|
return IMAGE_EXTENSION_SET.has(extnameOf(path3));
|
|
@@ -8793,12 +8591,12 @@ function mergeAttachedImages(existing, incoming) {
|
|
|
8793
8591
|
return out;
|
|
8794
8592
|
}
|
|
8795
8593
|
async function readImagePaths(paths, options = {}) {
|
|
8796
|
-
const
|
|
8594
|
+
const resolve5 = options.resolve ?? ((p) => p);
|
|
8797
8595
|
const reportedFailures = /* @__PURE__ */ new Set();
|
|
8798
8596
|
const images = [];
|
|
8799
8597
|
const failures = [];
|
|
8800
8598
|
for (const raw of paths) {
|
|
8801
|
-
const absolute =
|
|
8599
|
+
const absolute = resolve5(raw);
|
|
8802
8600
|
try {
|
|
8803
8601
|
const img = await readImageAsDataUrl(absolute, {
|
|
8804
8602
|
...options.maxBytes !== void 0 ? { maxBytes: options.maxBytes } : {}
|
|
@@ -8904,7 +8702,7 @@ async function probeMedia(filePath, opts = {}) {
|
|
|
8904
8702
|
const runner = opts.execFileImpl ?? execFile;
|
|
8905
8703
|
const ffmpegPath = opts.ffmpegPath ?? DEFAULT_FFMPEG_PATH;
|
|
8906
8704
|
const ffprobePath = ffmpegPath.replace(/ffmpeg$/, "ffprobe");
|
|
8907
|
-
return new Promise((
|
|
8705
|
+
return new Promise((resolve5, reject) => {
|
|
8908
8706
|
runner(
|
|
8909
8707
|
ffprobePath,
|
|
8910
8708
|
[
|
|
@@ -8935,7 +8733,7 @@ async function probeMedia(filePath, opts = {}) {
|
|
|
8935
8733
|
const hasAudio = /^codec_type=audio$/m.test(text);
|
|
8936
8734
|
const rateMatch = text.match(/sample_rate=(\d+)/);
|
|
8937
8735
|
const sampleRate = rateMatch ? parseInt(rateMatch[1], 10) : null;
|
|
8938
|
-
|
|
8736
|
+
resolve5({ durationSec, hasAudio, sampleRate });
|
|
8939
8737
|
}
|
|
8940
8738
|
);
|
|
8941
8739
|
});
|
|
@@ -9022,7 +8820,7 @@ async function preprocessMedia(inputPath, opts = {}) {
|
|
|
9022
8820
|
args.push("-af", filter);
|
|
9023
8821
|
}
|
|
9024
8822
|
args.push("-c:a", "libopus", "-b:a", OPUS_BITRATE, outPath);
|
|
9025
|
-
await new Promise((
|
|
8823
|
+
await new Promise((resolve5, reject) => {
|
|
9026
8824
|
runner(ffmpegPath, args, { encoding: "utf8", maxBuffer: 8 * 1024 * 1024 }, (error, _stdout, stderr) => {
|
|
9027
8825
|
if (error) {
|
|
9028
8826
|
reject(
|
|
@@ -9032,7 +8830,7 @@ async function preprocessMedia(inputPath, opts = {}) {
|
|
|
9032
8830
|
);
|
|
9033
8831
|
return;
|
|
9034
8832
|
}
|
|
9035
|
-
|
|
8833
|
+
resolve5();
|
|
9036
8834
|
});
|
|
9037
8835
|
}).catch((err) => {
|
|
9038
8836
|
if (ownOutDir) {
|
|
@@ -9730,7 +9528,7 @@ function parseStatusOutput(branch, status) {
|
|
|
9730
9528
|
return { branch, modified, untracked };
|
|
9731
9529
|
}
|
|
9732
9530
|
function execFileUtf8(file, args, cwd) {
|
|
9733
|
-
return new Promise((
|
|
9531
|
+
return new Promise((resolve5, reject) => {
|
|
9734
9532
|
execFile3(
|
|
9735
9533
|
file,
|
|
9736
9534
|
args,
|
|
@@ -9740,7 +9538,7 @@ function execFileUtf8(file, args, cwd) {
|
|
|
9740
9538
|
reject(err);
|
|
9741
9539
|
return;
|
|
9742
9540
|
}
|
|
9743
|
-
|
|
9541
|
+
resolve5(typeof stdout === "string" ? stdout : String(stdout ?? ""));
|
|
9744
9542
|
}
|
|
9745
9543
|
);
|
|
9746
9544
|
});
|
|
@@ -9824,7 +9622,7 @@ function renderConversationLinks(extracted, t3, target = "pipe") {
|
|
|
9824
9622
|
// packages/cli/tui/sessionDispatch.ts
|
|
9825
9623
|
import { statSync as statSync5 } from "node:fs";
|
|
9826
9624
|
import { homedir as homedir4 } from "node:os";
|
|
9827
|
-
import { resolve as
|
|
9625
|
+
import { resolve as resolve4 } from "node:path";
|
|
9828
9626
|
|
|
9829
9627
|
// packages/cli/tui/agentPicker.ts
|
|
9830
9628
|
function toAgentPickerItems(entries) {
|
|
@@ -9951,29 +9749,35 @@ function renderRecentDiagnostics(env, events = getProcessRingBuffer()?.drain() ?
|
|
|
9951
9749
|
}
|
|
9952
9750
|
|
|
9953
9751
|
// packages/cli/client/estimateCliContext.ts
|
|
9954
|
-
var
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
"
|
|
9958
|
-
|
|
9752
|
+
var CLI_ESTIMATE_ENV = { [RUN_WAKE_CHANNEL_ENV]: "1" };
|
|
9753
|
+
function resolveEstimateEnv(env) {
|
|
9754
|
+
const source = env ?? process.env;
|
|
9755
|
+
const exposeMcp = String(source[MCP_EXPOSURE_ENV] ?? "").trim();
|
|
9756
|
+
return {
|
|
9757
|
+
...CLI_ESTIMATE_ENV,
|
|
9758
|
+
...exposeMcp ? { [MCP_EXPOSURE_ENV]: exposeMcp } : {}
|
|
9759
|
+
};
|
|
9760
|
+
}
|
|
9761
|
+
function resolveDefaultCliToolNames(env) {
|
|
9762
|
+
return canonicalizeToolNames(
|
|
9763
|
+
resolveCliRequestedToolNames(
|
|
9764
|
+
{ key: BUILTIN_NOLO_AGENT_KEY },
|
|
9765
|
+
env,
|
|
9766
|
+
null
|
|
9767
|
+
)
|
|
9768
|
+
);
|
|
9769
|
+
}
|
|
9959
9770
|
var DEFAULT_PROMPT_ESTIMATE_BASELINE = "\u4F60\u662F\u5171\u4EAB\u7A7A\u95F4\u91CC\u7684\u9AD8\u6027\u4EF7\u6BD4\u901A\u7528 AI \u52A9\u624B\u3002\u4F18\u5148\u5FEB\u901F\u3001\u76F4\u63A5\u3001\u7A33\u5B9A\u5730\u5B8C\u6210\u4EFB\u52A1\uFF1B\u9700\u8981\u63A8\u7406\u65F6\u4FDD\u6301\u6B65\u9AA4\u6E05\u6670\u3002";
|
|
9960
9771
|
function readAgentsMd(cwd) {
|
|
9961
9772
|
return readAgentsMdLayerFromDisk(cwd)?.content ?? "";
|
|
9962
9773
|
}
|
|
9963
|
-
function estimateToolSchemas(toolNames) {
|
|
9964
|
-
const
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
const workspaceTools = buildLocalWorkspaceOpenAiTools({
|
|
9969
|
-
toolNames: toolset.toolNames,
|
|
9970
|
-
exposeShellTools: true
|
|
9774
|
+
function estimateToolSchemas(toolNames, env) {
|
|
9775
|
+
const tools = buildOpenAiTools({
|
|
9776
|
+
agentKey: BUILTIN_NOLO_AGENT_KEY,
|
|
9777
|
+
toolNames,
|
|
9778
|
+
env
|
|
9971
9779
|
});
|
|
9972
|
-
|
|
9973
|
-
(name) => toolNames.includes(name)
|
|
9974
|
-
);
|
|
9975
|
-
const platformTools = platformNames.length > 0 ? prepareTools([...platformNames]) : [];
|
|
9976
|
-
return estimateTokenCount(JSON.stringify([...workspaceTools, ...platformTools]));
|
|
9780
|
+
return estimateTokenCount(JSON.stringify(tools));
|
|
9977
9781
|
}
|
|
9978
9782
|
function buildCliEstimateSystemText(opts = {}) {
|
|
9979
9783
|
const cwd = opts.cwd?.trim() || process.cwd();
|
|
@@ -9981,16 +9785,11 @@ function buildCliEstimateSystemText(opts = {}) {
|
|
|
9981
9785
|
const agentName = opts.agentName?.trim() || BUILTIN_NOLO_AGENT_NAME;
|
|
9982
9786
|
const agentKey = opts.agentKey?.trim() || BUILTIN_NOLO_AGENT_KEY;
|
|
9983
9787
|
const prompt = opts.agentPrompt?.trim() || DEFAULT_PROMPT_ESTIMATE_BASELINE;
|
|
9984
|
-
const
|
|
9985
|
-
expandEnabledPacks([...DEFAULT_CLI_PACKS], [])
|
|
9986
|
-
);
|
|
9987
|
-
const toolNames = canonicalizeToolNames([
|
|
9988
|
-
...packTools,
|
|
9989
|
-
...DEFAULT_CLI_PLATFORM_TOOLS
|
|
9990
|
-
]);
|
|
9788
|
+
const toolNames = resolveDefaultCliToolNames(resolveEstimateEnv(opts.env));
|
|
9991
9789
|
const guidance = buildRuntimeGuidanceBlocks(toolNames);
|
|
9992
9790
|
const toolSections = resolveToolGuidedSections(toolNames, {
|
|
9993
|
-
callerModel: opts.model?.trim() || void 0
|
|
9791
|
+
callerModel: opts.model?.trim() || void 0,
|
|
9792
|
+
callerIsPoolTop: opts.callerIsPoolTop
|
|
9994
9793
|
});
|
|
9995
9794
|
const responseGuidelines = resolveResponseGuidelines(
|
|
9996
9795
|
opts.responseViewport ?? "unknown"
|
|
@@ -10020,12 +9819,10 @@ function buildCliEstimateSystemText(opts = {}) {
|
|
|
10020
9819
|
return systemParts.filter((part) => part?.trim()).join("\n\n");
|
|
10021
9820
|
}
|
|
10022
9821
|
function estimateDefaultCliContextTokens(opts = {}) {
|
|
10023
|
-
const
|
|
10024
|
-
|
|
10025
|
-
...DEFAULT_CLI_PLATFORM_TOOLS
|
|
10026
|
-
]);
|
|
9822
|
+
const env = resolveEstimateEnv(opts.env);
|
|
9823
|
+
const toolNames = resolveDefaultCliToolNames(env);
|
|
10027
9824
|
const systemTokens = estimateTokenCount(buildCliEstimateSystemText(opts));
|
|
10028
|
-
const toolTokens = estimateToolSchemas(toolNames);
|
|
9825
|
+
const toolTokens = estimateToolSchemas(toolNames, env);
|
|
10029
9826
|
const historyTokens = opts.messages && opts.messages.length > 0 ? estimateMessagesTokens(opts.messages) : opts.historyText ? estimateTokenCount(opts.historyText) : 0;
|
|
10030
9827
|
return Math.max(0, systemTokens + toolTokens + historyTokens);
|
|
10031
9828
|
}
|
|
@@ -10109,7 +9906,7 @@ function renderPermissionGrantChip(state) {
|
|
|
10109
9906
|
}
|
|
10110
9907
|
function renderStatusLine(state, maxWidth) {
|
|
10111
9908
|
const colorEnabled = resolveCliColorEnabled();
|
|
10112
|
-
const
|
|
9909
|
+
const sep2 = themeText(" \xB7 ", "chrome", colorEnabled);
|
|
10113
9910
|
const agentDisplayName = state.agentName;
|
|
10114
9911
|
const modeSuffix = state.modeLabel && state.modeLabel !== "auto" ? ` \xB7 ${state.modeLabel}` : "";
|
|
10115
9912
|
const agentLabel = `\u2726 ${agentDisplayName}${modeSuffix}`;
|
|
@@ -10266,7 +10063,7 @@ function renderStatusLine(state, maxWidth) {
|
|
|
10266
10063
|
visibleParts = fitted ? [fitted.join(" ")] : [overflowMark];
|
|
10267
10064
|
}
|
|
10268
10065
|
}
|
|
10269
|
-
let body = visibleParts.filter(Boolean).join(
|
|
10066
|
+
let body = visibleParts.filter(Boolean).join(sep2);
|
|
10270
10067
|
if (maxWidth && maxWidth > 0) {
|
|
10271
10068
|
const budget = Math.max(0, maxWidth - padWidth);
|
|
10272
10069
|
if (displayWidth(stripAnsi(body)) > budget) {
|
|
@@ -10578,6 +10375,9 @@ function createInitialTuiState(env = process.env) {
|
|
|
10578
10375
|
agentKey,
|
|
10579
10376
|
userLanguage: asOptionalTrimmedString(env.NOLO_LANG),
|
|
10580
10377
|
responseViewport: TUI_RESPONSE_VIEWPORT,
|
|
10378
|
+
// 估算必须看运行时那同一份 env:`NOLO_EXPOSE_MCP_TOOLS=1` 会让 local 装配
|
|
10379
|
+
// 多出 3 个 MCP 工具 schema,估算器若只看写死的 wake 开关就会低报。
|
|
10380
|
+
env,
|
|
10581
10381
|
...resolveAgentModelIdentity({ agentKey, agentName })
|
|
10582
10382
|
})
|
|
10583
10383
|
};
|
|
@@ -10812,8 +10612,8 @@ ${t("cdUsage")}`
|
|
|
10812
10612
|
};
|
|
10813
10613
|
}
|
|
10814
10614
|
const unquoted = argText.startsWith('"') && argText.endsWith('"') && argText.length >= 2 || argText.startsWith("'") && argText.endsWith("'") && argText.length >= 2 ? argText.slice(1, -1) : argText;
|
|
10815
|
-
const expanded = unquoted === "~" ? homedir4() : unquoted.startsWith("~/") || unquoted.startsWith("~\\") ?
|
|
10816
|
-
const target =
|
|
10615
|
+
const expanded = unquoted === "~" ? homedir4() : unquoted.startsWith("~/") || unquoted.startsWith("~\\") ? resolve4(homedir4(), unquoted.slice(2)) : unquoted;
|
|
10616
|
+
const target = resolve4(state.cwd, expanded);
|
|
10817
10617
|
try {
|
|
10818
10618
|
if (!statSync5(target).isDirectory()) {
|
|
10819
10619
|
return { nextState: state, output: t("cdNotDir", target) };
|
|
@@ -11584,7 +11384,7 @@ async function probeTerminalBackground(args = {}) {
|
|
|
11584
11384
|
if (typeof stdin.setRawMode !== "function") return null;
|
|
11585
11385
|
if (!isTerminal(stdin)) return null;
|
|
11586
11386
|
const wasRaw = Boolean(stdin.isRaw);
|
|
11587
|
-
return await new Promise((
|
|
11387
|
+
return await new Promise((resolve5) => {
|
|
11588
11388
|
let buffer = "";
|
|
11589
11389
|
let settled = false;
|
|
11590
11390
|
let timer;
|
|
@@ -11602,7 +11402,7 @@ async function probeTerminalBackground(args = {}) {
|
|
|
11602
11402
|
if (!wasRaw) stdin.setRawMode?.(false);
|
|
11603
11403
|
} catch {
|
|
11604
11404
|
}
|
|
11605
|
-
|
|
11405
|
+
resolve5(result);
|
|
11606
11406
|
};
|
|
11607
11407
|
const onData = (chunk) => {
|
|
11608
11408
|
buffer += chunk.toString("latin1");
|
|
@@ -11682,7 +11482,7 @@ function appendStreamSafeNotice(history, text, deps) {
|
|
|
11682
11482
|
history.currentBlocks = [];
|
|
11683
11483
|
}
|
|
11684
11484
|
deps.appendLocalTurn(history, "", text);
|
|
11685
|
-
if (wasStreamingAssistant) deps.startTurn(history, "assistant");
|
|
11485
|
+
if (wasStreamingAssistant) deps.startTurn(history, "assistant", { continueAssistantTurn: true });
|
|
11686
11486
|
}
|
|
11687
11487
|
function createTurnInjectionInbox() {
|
|
11688
11488
|
let pending = [];
|
|
@@ -11809,13 +11609,13 @@ function startCiDeployEventStream(args) {
|
|
|
11809
11609
|
let controller = null;
|
|
11810
11610
|
const timers = /* @__PURE__ */ new Set();
|
|
11811
11611
|
const sleepWaiters = /* @__PURE__ */ new Set();
|
|
11812
|
-
const sleepWithRegisteredTimer = (ms) => new Promise((
|
|
11612
|
+
const sleepWithRegisteredTimer = (ms) => new Promise((resolve5) => {
|
|
11813
11613
|
let settled = false;
|
|
11814
11614
|
const wake = () => {
|
|
11815
11615
|
if (settled) return;
|
|
11816
11616
|
settled = true;
|
|
11817
11617
|
sleepWaiters.delete(wake);
|
|
11818
|
-
|
|
11618
|
+
resolve5();
|
|
11819
11619
|
};
|
|
11820
11620
|
const timer = setTimeout(() => {
|
|
11821
11621
|
timers.delete(timer);
|
|
@@ -12133,7 +11933,10 @@ function prepareChildRunConsumption(event, host) {
|
|
|
12133
11933
|
return {
|
|
12134
11934
|
...event,
|
|
12135
11935
|
runs: remainingRuns,
|
|
12136
|
-
text: buildWakeMessage(remainingRuns, now
|
|
11936
|
+
text: buildWakeMessage(remainingRuns, now, {
|
|
11937
|
+
// 与 run 注册表同一个有效 runs 目录(自定义 NOLO_HOME 也要内联)。
|
|
11938
|
+
trustedResultDirs: [resolveRunsDir(host.env)]
|
|
11939
|
+
}),
|
|
12137
11940
|
displayText: buildWakeDisplayText(remainingRuns, now)
|
|
12138
11941
|
};
|
|
12139
11942
|
}
|
|
@@ -12857,11 +12660,11 @@ async function runAskChoiceDialog(args) {
|
|
|
12857
12660
|
}
|
|
12858
12661
|
paint();
|
|
12859
12662
|
while (state.phase === "active") {
|
|
12860
|
-
const sequence = await new Promise((
|
|
12861
|
-
const abort = () =>
|
|
12663
|
+
const sequence = await new Promise((resolve5, reject) => {
|
|
12664
|
+
const abort = () => resolve5(STREAM_CLOSED);
|
|
12862
12665
|
if (request.signal?.aborted) return abort();
|
|
12863
12666
|
request.signal?.addEventListener("abort", abort, { once: true });
|
|
12864
|
-
Promise.resolve(readKey()).then(
|
|
12667
|
+
Promise.resolve(readKey()).then(resolve5, reject).finally(() => request.signal?.removeEventListener("abort", abort));
|
|
12865
12668
|
});
|
|
12866
12669
|
if (sequence === STREAM_CLOSED) {
|
|
12867
12670
|
state = askChoiceReducer(state, { type: "CANCEL" });
|
|
@@ -13785,12 +13588,12 @@ async function detectTrailingSilenceSuggestion(filePath, durationSec, opts = {})
|
|
|
13785
13588
|
"-"
|
|
13786
13589
|
];
|
|
13787
13590
|
try {
|
|
13788
|
-
const stderr = await new Promise((
|
|
13591
|
+
const stderr = await new Promise((resolve5, reject) => {
|
|
13789
13592
|
runner(
|
|
13790
13593
|
opts.ffmpegPath ?? resolveFfmpegPath(),
|
|
13791
13594
|
args,
|
|
13792
13595
|
{ encoding: "utf8", maxBuffer: 16 * 1024 * 1024 },
|
|
13793
|
-
(error, _stdout, stderrText) => error ? reject(error) :
|
|
13596
|
+
(error, _stdout, stderrText) => error ? reject(error) : resolve5(String(stderrText ?? ""))
|
|
13794
13597
|
);
|
|
13795
13598
|
});
|
|
13796
13599
|
return buildTrailingSilenceSuggestion(
|
|
@@ -14960,7 +14763,10 @@ async function runAgentChat(scriptDir, state, message, env, output, agentRunner
|
|
|
14960
14763
|
(r) => !!r.parentDialogId && r.parentDialogId === state.dialogId
|
|
14961
14764
|
);
|
|
14962
14765
|
const childRunNoticeBlocks = injectedChildRunNoticeItems.length > 0 ? [{
|
|
14963
|
-
content: buildWakeMessage(injectedChildRunNoticeItems, Date.now()
|
|
14766
|
+
content: buildWakeMessage(injectedChildRunNoticeItems, Date.now(), {
|
|
14767
|
+
// WAKE-003-CONFIG:与 run 注册表同一有效 runs 目录(尊重自定义 NOLO_HOME)。
|
|
14768
|
+
trustedResultDirs: [resolveRunsDir(env)]
|
|
14769
|
+
}),
|
|
14964
14770
|
cacheScope: "turn"
|
|
14965
14771
|
}] : [];
|
|
14966
14772
|
const contextBlockScopes = partitionScopedBlocks([
|
|
@@ -15161,14 +14967,14 @@ function waitForActionGate(rl, input, output, gate, spawnRunner) {
|
|
|
15161
14967
|
const meta = deriveGateMeta(gate);
|
|
15162
14968
|
const { commandPayload, isConfirmation, displayCommand } = meta;
|
|
15163
14969
|
writeGatePrompt(output, meta);
|
|
15164
|
-
return new Promise((
|
|
14970
|
+
return new Promise((resolve5) => {
|
|
15165
14971
|
let settled = false;
|
|
15166
14972
|
const finish = (result) => {
|
|
15167
14973
|
if (settled) return;
|
|
15168
14974
|
settled = true;
|
|
15169
14975
|
rl.off("close", onClose);
|
|
15170
14976
|
rl.off("SIGINT", onSigint);
|
|
15171
|
-
|
|
14977
|
+
resolve5(result);
|
|
15172
14978
|
};
|
|
15173
14979
|
const cancelResult = (reason) => buildGateCancelledResult(gate, reason);
|
|
15174
14980
|
const failResult = (message) => buildGateFailedResult(gate, message);
|
|
@@ -15232,7 +15038,7 @@ function waitForRawActionGate(input, output, gate, spawnRunner, hooks) {
|
|
|
15232
15038
|
const meta = deriveGateMeta(gate);
|
|
15233
15039
|
const { commandPayload, isConfirmation, displayCommand } = meta;
|
|
15234
15040
|
writeGatePrompt(output, meta);
|
|
15235
|
-
return new Promise((
|
|
15041
|
+
return new Promise((resolve5) => {
|
|
15236
15042
|
const rawInput = input;
|
|
15237
15043
|
let settled = false;
|
|
15238
15044
|
let commandRunning = false;
|
|
@@ -15244,7 +15050,7 @@ function waitForRawActionGate(input, output, gate, spawnRunner, hooks) {
|
|
|
15244
15050
|
input.off("data", onData);
|
|
15245
15051
|
input.off?.("end", onEnd);
|
|
15246
15052
|
input.off?.("close", onEnd);
|
|
15247
|
-
|
|
15053
|
+
resolve5(result);
|
|
15248
15054
|
};
|
|
15249
15055
|
const cancel = (reason) => finish(buildGateCancelledResult(gate, reason));
|
|
15250
15056
|
const fail = (message) => finish(buildGateFailedResult(gate, message));
|
|
@@ -15475,14 +15281,14 @@ function buildWakeRetryContinuationMessage(event) {
|
|
|
15475
15281
|
}
|
|
15476
15282
|
function waitForWakeRetryBackoff(delayMs, signal) {
|
|
15477
15283
|
if (delayMs <= 0 || signal?.aborted) return Promise.resolve();
|
|
15478
|
-
return new Promise((
|
|
15284
|
+
return new Promise((resolve5) => {
|
|
15479
15285
|
const onAbort = () => {
|
|
15480
15286
|
clearTimeout(timer);
|
|
15481
|
-
|
|
15287
|
+
resolve5();
|
|
15482
15288
|
};
|
|
15483
15289
|
const timer = setTimeout(() => {
|
|
15484
15290
|
signal?.removeEventListener("abort", onAbort);
|
|
15485
|
-
|
|
15291
|
+
resolve5();
|
|
15486
15292
|
}, delayMs);
|
|
15487
15293
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
15488
15294
|
});
|
|
@@ -15560,7 +15366,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
|
|
|
15560
15366
|
if (!approved) return false;
|
|
15561
15367
|
const commandText = typeof request.command === "string" ? request.command : "";
|
|
15562
15368
|
if (commandText) {
|
|
15563
|
-
const { runApprovedCredentialCommand } = await import("./hostCredentialCreate-
|
|
15369
|
+
const { runApprovedCredentialCommand } = await import("./hostCredentialCreate-3IA5IJFG.js");
|
|
15564
15370
|
const hostResult = await runApprovedCredentialCommand({
|
|
15565
15371
|
commandText,
|
|
15566
15372
|
approvalEventId: request.id,
|
|
@@ -17711,7 +17517,7 @@ async function compactDialog(options) {
|
|
|
17711
17517
|
fetchImpl,
|
|
17712
17518
|
agentRef: getActiveDialogAgentId(current) ?? void 0,
|
|
17713
17519
|
loadAdapter: async () => {
|
|
17714
|
-
const { createCliLocalRuntimeAdapter: createCliLocalRuntimeAdapter2 } = await import("./localRuntimeAdapter-
|
|
17520
|
+
const { createCliLocalRuntimeAdapter: createCliLocalRuntimeAdapter2 } = await import("./localRuntimeAdapter-SSG5ORLZ.js");
|
|
17715
17521
|
return createCliLocalRuntimeAdapter2({ env: { ...options.env ?? {}, AUTH_TOKEN: options.authToken, NOLO_SERVER: options.serverUrl }, fetchImpl });
|
|
17716
17522
|
}
|
|
17717
17523
|
}) : void 0);
|
|
@@ -18616,6 +18422,7 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
|
|
|
18616
18422
|
};
|
|
18617
18423
|
history.turns.length = 0;
|
|
18618
18424
|
history.toolDetails = [];
|
|
18425
|
+
history.lastTurnToolDetailStart = 0;
|
|
18619
18426
|
history.currentRole = null;
|
|
18620
18427
|
history.currentContent = "";
|
|
18621
18428
|
history.scrollTop = 0;
|
|
@@ -18957,6 +18764,7 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
|
|
|
18957
18764
|
const restored = loadedTurns.slice(-MAX_TUI_HISTORY_TURNS);
|
|
18958
18765
|
history.turns.length = 0;
|
|
18959
18766
|
history.toolDetails = [];
|
|
18767
|
+
history.lastTurnToolDetailStart = 0;
|
|
18960
18768
|
history.turns.push(...restored);
|
|
18961
18769
|
history.currentRole = null;
|
|
18962
18770
|
history.currentContent = "";
|
|
@@ -19518,7 +19326,7 @@ async function runTuiWorkspace(options) {
|
|
|
19518
19326
|
titleAnimTimer.unref?.();
|
|
19519
19327
|
}
|
|
19520
19328
|
const rawDialogLabel = state.dialogLabel?.trim();
|
|
19521
|
-
const rawLabel = !rawDialogLabel || rawDialogLabel === "new" ?
|
|
19329
|
+
const rawLabel = !rawDialogLabel || rawDialogLabel === "new" ? basename2(state.cwd) || "Nolo" : rawDialogLabel;
|
|
19522
19330
|
const label = stripAnsi(rawLabel).replace(/[\x00-\x1f\x7f-\x9f]+/g, " ");
|
|
19523
19331
|
const frame = ACTIVITY_FRAMES[titleFrameIndex % ACTIVITY_FRAMES.length];
|
|
19524
19332
|
const suffix = phase === "blocked" ? " \xB7 \u9700\u63A5\u7BA1 \u2014 Nolo" : phase === "error" ? " \xB7 \u5931\u8D25\u9700\u5904\u7406 \u2014 Nolo" : isWorking ? ` \xB7 ${frame} \u601D\u8003\u4E2D \u2014 Nolo` : label === "Nolo" ? "" : " \u2014 Nolo";
|
|
@@ -20482,9 +20290,10 @@ ${lines}` : lines;
|
|
|
20482
20290
|
}
|
|
20483
20291
|
};
|
|
20484
20292
|
const runSubmittedLine = async (line, actionGateHandler, confirmDestructiveAction, directUserSubmission = false) => {
|
|
20485
|
-
|
|
20293
|
+
const toolsCommand = line.trim().match(/^\/tools(?:\s+(last))?$/i);
|
|
20294
|
+
if (toolsCommand) {
|
|
20486
20295
|
emitCommandOutput(
|
|
20487
|
-
history
|
|
20296
|
+
formatToolDetails(history, Boolean(toolsCommand[1])) || themeText(t("noToolDetails"), "muted", resolveCliColorEnabled())
|
|
20488
20297
|
);
|
|
20489
20298
|
return false;
|
|
20490
20299
|
}
|
|
@@ -20845,7 +20654,7 @@ ${lines}` : lines;
|
|
|
20845
20654
|
onApprove: createSnapshotGuardedApproval("local", () => state.permissionGrants, approveLocalConfirms),
|
|
20846
20655
|
onApproved: async (approvedGate) => {
|
|
20847
20656
|
if (approvedGate.kind !== "confirm") return null;
|
|
20848
|
-
const { executeApprovedCredentialCreate } = await import("./hostCredentialCreate-
|
|
20657
|
+
const { executeApprovedCredentialCreate } = await import("./hostCredentialCreate-3IA5IJFG.js");
|
|
20849
20658
|
const hostResult = await executeApprovedCredentialCreate({
|
|
20850
20659
|
gate: approvedGate,
|
|
20851
20660
|
approvalGateId: approvedGate.id,
|
|
@@ -21741,7 +21550,8 @@ ${hint}` : hint;
|
|
|
21741
21550
|
const busySlashCommand = trimmedText.split(/\s+/)[0]?.toLowerCase();
|
|
21742
21551
|
if (busySlashCommand === "/tools") {
|
|
21743
21552
|
recordWorkspaceInputHistory(expandedSubmitForHistory);
|
|
21744
|
-
|
|
21553
|
+
const last = trimmedText.split(/\s+/)[1]?.toLowerCase() === "last";
|
|
21554
|
+
printStreamSafeNotice(formatToolDetails(history, last) || t("noToolDetails"));
|
|
21745
21555
|
bumpDraftEpoch();
|
|
21746
21556
|
buffer = "";
|
|
21747
21557
|
cursorPos = 0;
|
|
@@ -22060,9 +21870,9 @@ ${themeText(`! ${error instanceof Error ? error.message : String(error)}`, "dang
|
|
|
22060
21870
|
fixedInput.repaint(buffer, cursorPos);
|
|
22061
21871
|
if (!sawOsc11Reply && isTerminalDevice(input) && !isPtyxisTerminal()) requestTerminalBackgroundQuery();
|
|
22062
21872
|
refreshGitStatus();
|
|
22063
|
-
await new Promise((
|
|
22064
|
-
resolveDone =
|
|
22065
|
-
if (done)
|
|
21873
|
+
await new Promise((resolve5) => {
|
|
21874
|
+
resolveDone = resolve5;
|
|
21875
|
+
if (done) resolve5();
|
|
22066
21876
|
});
|
|
22067
21877
|
} finally {
|
|
22068
21878
|
finish();
|