nolo-cli 0.254.0-alpha.1 → 0.255.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_executeModel-OMDET3E2.js → _executeModel-XD2EAFVG.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-AI2AAFA4.js} +59 -58
- package/{agentEmailCommands-3QWBB2JL.js → agentEmailCommands-I544I2MU.js} +60 -59
- package/{agentListCommands-WTEF5RKJ.js → agentListCommands-3NB4FDIJ.js} +26 -25
- package/{agentMachineCommands-DP44GKA6.js → agentMachineCommands-RZEHM6NS.js} +22 -21
- package/{agentRecordCommands-4I7P34GJ.js → agentRecordCommands-X2AVD6Y2.js} +59 -58
- package/{agentRunCommand-VAKWFXJV.js → agentRunCommand-XU5TL3WO.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-ZFY3PT3D.js} +9 -9
- package/{appDeleteCommands-ZQ4ZEKTC.js → appDeleteCommands-J5BTYVPC.js} +24 -23
- package/{appDeployCommands-4XT7PFW5.js → appDeployCommands-I3JIN7TN.js} +24 -23
- package/{appDeployStatusCommands-5RVMRYQW.js → appDeployStatusCommands-BKJVLIOV.js} +24 -23
- package/{appGetCommands-VH5W3RFK.js → appGetCommands-67JTU36H.js} +24 -23
- package/{appListCommands-TAHZLAL3.js → appListCommands-HF4GFCN4.js} +24 -23
- package/{authCommand-HBO5G6RL.js → authCommand-Y3CXNAYM.js} +4 -4
- package/{builtinSkillRegistry-66PEOD4Y.js → builtinSkillRegistry-FVEEO4U2.js} +3 -3
- package/{chromeOpsCommands-AA555ANS.js → chromeOpsCommands-W5I2AEOV.js} +1 -1
- package/{chunk-D3WOFN6N.js → chunk-223KZUJ6.js} +1 -1
- package/{chunk-MICGEDCN.js → chunk-24Z44WHO.js} +27 -27
- package/{chunk-MR72IIX5.js → chunk-2BHHT2TR.js} +4 -4
- package/{chunk-NXNHG3QT.js → chunk-3W2J3LFB.js} +21 -10
- package/{chunk-2RCMFPUZ.js → chunk-46FETNLF.js} +2 -2
- package/{chunk-CO6E7YK6.js → chunk-5P3PPQVP.js} +1 -1
- package/{chunk-KR4W72OK.js → chunk-6FONTXR7.js} +45 -25
- 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-GK772DEV.js → chunk-7BIJFGKS.js} +3 -3
- package/{chunk-3SEBCWLD.js → chunk-7EUJ65PF.js} +2057 -223
- package/{chunk-4GWNEPY6.js → chunk-7PTWFSZZ.js} +1 -1
- package/{chunk-CIAV4WK2.js → chunk-7WHCIA5V.js} +2 -2
- package/{chunk-MCQXBKC6.js → chunk-AAYDROBM.js} +2 -2
- 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-HEUHCHAR.js → chunk-BD22OFDQ.js} +3 -3
- package/{chunk-SID2TFMV.js → chunk-BXGU6274.js} +104 -55
- package/{chunk-SCY2O7CU.js → chunk-BZMDWGQQ.js} +2 -2
- package/{chunk-YYHWEVBI.js → chunk-CAPHUP3M.js} +2 -2
- package/{chunk-JKO32CCL.js → chunk-CBIGMWMI.js} +1 -1
- package/{chunk-JP2BH4NC.js → chunk-CEKRIR22.js} +1 -1
- package/{chunk-6AJIU6OC.js → chunk-D53SPVAC.js} +3 -3
- package/{chunk-HS4JGZQH.js → chunk-DWES4SXY.js} +1 -1
- package/{chunk-3272HU62.js → chunk-E47JZP2R.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-HKPIFK7F.js → chunk-H3KLIPAL.js} +5 -5
- package/{chunk-NEDBPW44.js → chunk-H6EKTB6X.js} +2 -2
- 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-YW5L3XOO.js → chunk-HZQGCFPJ.js} +10 -10
- package/{chunk-7STRX24O.js → chunk-JAAYO52G.js} +8 -7
- package/{chunk-QV32GSVO.js → chunk-JPZKKSGT.js} +1 -1
- package/{chunk-Z2ZCKNKX.js → chunk-JW6OURKM.js} +261 -228
- package/{chunk-TA2JQUWA.js → chunk-K5X4D2TS.js} +156 -1767
- package/{chunk-IGK4OXAO.js → chunk-KF7M2UEK.js} +499 -7
- package/{chunk-VZCBYCHV.js → chunk-KG27JIG4.js} +2 -2
- package/{chunk-PTY2VZM5.js → chunk-KO5GO2BC.js} +6 -8
- package/{chunk-GJKEOBCV.js → chunk-KRDG2XCI.js} +10 -10
- package/{chunk-OLS2J3WE.js → chunk-LLUBUHNT.js} +1 -1
- package/{chunk-ZAKWT4XQ.js → chunk-LQ4CQKTS.js} +3 -3
- package/{chunk-52M4RYVP.js → chunk-MDHI2LWF.js} +1 -1
- package/{chunk-XWR2YD4L.js → chunk-MLK3FEXG.js} +1 -1
- package/{chunk-KQBGXCKM.js → chunk-MNFUKRRU.js} +3 -3
- package/{chunk-FRC2DNTN.js → chunk-NAW2SN54.js} +1 -1
- 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-MW3XUUYS.js → chunk-PVHY7Y6T.js} +6 -6
- package/{chunk-K4LLTJUO.js → chunk-Q2MPKE4B.js} +5 -105
- package/{chunk-AX63ZU2W.js → chunk-Q66O5LN3.js} +4 -4
- package/{chunk-6WI4PFPP.js → chunk-QEVT4LQ3.js} +68 -54
- package/{chunk-OMIXG25B.js → chunk-QGFLVQ6E.js} +1 -1
- package/{chunk-25BDZGD7.js → chunk-QJKDHR4Y.js} +2 -2
- package/{chunk-IDCGMZLC.js → chunk-QNZRR3NT.js} +9 -9
- package/{chunk-WMMKHEGQ.js → chunk-R3FZHW4Q.js} +12 -12
- package/{chunk-KZAT2M2V.js → chunk-RIWKZT7E.js} +22 -0
- package/{chunk-OWXOXKH7.js → chunk-SCAC3NM5.js} +2 -2
- package/{chunk-EG3JTV7H.js → chunk-TCAAHWCY.js} +2 -2
- package/{chunk-NMGG3NUB.js → chunk-U6QNVOR5.js} +1 -1
- package/{chunk-5UYDG6HP.js → chunk-V5NK6KMF.js} +8 -13
- package/{chunk-AIHNB5QH.js → chunk-VQR2ACSC.js} +6 -4
- 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-4Z7Q4QZF.js → chunk-YKCFDOO4.js} +765 -29
- package/{chunk-DNY33GGQ.js → chunk-YN23INFZ.js} +1 -1
- package/{chunk-5HUO7SEX.js → chunk-YQLAFJRQ.js} +1 -1
- 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-YCKR4SWB.js} +82 -78
- package/{contentThunks-THSXC6WQ.js → contentThunks-R2ZLM2Z3.js} +20 -20
- package/{cooldownCommands-PT5L4LNB.js → cooldownCommands-TVZBWUN3.js} +1 -1
- package/{createAgentAutomationAction-WNQOJ4DG.js → createAgentAutomationAction-Q665HFZS.js} +20 -20
- package/{createDialogAction-YORDQFFC.js → createDialogAction-VOGA6VXH.js} +21 -21
- package/{createPageAction-2S7V5OCW.js → createPageAction-FICG35GF.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-TCIB4AMT.js} +28 -25
- package/{dialogNotifyCommand-JKYVSR6K.js → dialogNotifyCommand-IASQGEMW.js} +3 -3
- package/{dialogSlice-JOICDGQU.js → dialogSlice-SCZJH2Q3.js} +18 -18
- package/dialogTraceCommand-E3BYXL3D.js +961 -0
- package/dialogUsageCommand-WJ3U6KZU.js +27 -0
- package/{docCreateCommands-MVAYVGQ5.js → docCreateCommands-UHY2QSEL.js} +23 -22
- package/{docDeleteCommands-TKXPRA3O.js → docDeleteCommands-JX53B6VB.js} +24 -23
- package/{docReadCommands-MR2YKCZP.js → docReadCommands-H5XZBEYD.js} +23 -22
- package/{docStore-NKVLWCXX.js → docStore-KTTOVQLL.js} +8 -8
- package/{docUpdateCommands-VJ6A6F7F.js → docUpdateCommands-YYYU6CHT.js} +23 -22
- package/{handleSendMessageAction-SNNYOQ4P.js → handleSendMessageAction-FRGNSG6B.js} +32 -32
- package/{hostCredentialCreate-SDQUFL23.js → hostCredentialCreate-V5EDFPAV.js} +59 -58
- package/index.js +7 -7
- package/{localRuntimeAdapter-JHYH5ZIR.js → localRuntimeAdapter-VMGFXQOJ.js} +58 -57
- package/{machineCommands-BXSBRM7L.js → machineCommands-AUPY2QB6.js} +59 -58
- package/{machineWsRunDispatch-KEXSHGSD.js → machineWsRunDispatch-KNOARY66.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-KON534LA.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-MHYNJR5O.js} +599 -840
- package/{removeDialogAgentAction-MXJEB77K.js → removeDialogAgentAction-EEVSOQOJ.js} +9 -9
- package/{runAgentClientLoop-UAGXVYW5.js → runAgentClientLoop-YRGQCRC4.js} +51 -40
- package/{secretCommands-BXAQEOES.js → secretCommands-POD67M6Y.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-USN52WYJ.js} +22 -21
- package/{streamAgentChatTurn-RZUB6JTH.js → streamAgentChatTurn-EQO3ULUB.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-UME4HYSH.js} +36 -35
- package/{tuiRestart-7IKI6JZK.js → tuiRestart-VN5F4GYU.js} +4 -3
- package/tuiSummaryLlmCaller-HROLGN4F.js +1 -1
- package/{updateCommands-BZ4YDHNM.js → updateCommands-L32TVOI7.js} +3 -3
- package/{updateDialogTitleAction-TJWT4LXL.js → updateDialogTitleAction-NZIGJL5Q.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-AGVLDVQS.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-D53SPVAC.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-E47JZP2R.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-YKCFDOO4.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-QEVT4LQ3.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-JPZKKSGT.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-MDHI2LWF.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-AAYDROBM.js";
|
|
218
220
|
import "./chunk-KZ4A7EIV.js";
|
|
219
|
-
import "./chunk-
|
|
220
|
-
import "./chunk-
|
|
221
|
+
import "./chunk-K5X4D2TS.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-KRDG2XCI.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-LQ4CQKTS.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-H3KLIPAL.js";
|
|
236
|
+
import "./chunk-HZQGCFPJ.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-24Z44WHO.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-QNZRR3NT.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-JAAYO52G.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-TCAAHWCY.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-NAW2SN54.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-V5NK6KMF.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";
|
|
@@ -3219,12 +2626,12 @@ function getAllTurnEntries(history, contentWidth) {
|
|
|
3219
2626
|
colorEnabled,
|
|
3220
2627
|
themeFingerprint
|
|
3221
2628
|
);
|
|
3222
|
-
const
|
|
3223
|
-
const startRow = finalizedLines +
|
|
2629
|
+
const sep2 = currentTurnSeparator(history);
|
|
2630
|
+
const startRow = finalizedLines + sep2;
|
|
3224
2631
|
entries.push({
|
|
3225
2632
|
startRow,
|
|
3226
2633
|
lineCount: streamingLines.length,
|
|
3227
|
-
separatorAbove:
|
|
2634
|
+
separatorAbove: sep2
|
|
3228
2635
|
});
|
|
3229
2636
|
turns.push({
|
|
3230
2637
|
role: history.currentRole,
|
|
@@ -3376,8 +2783,8 @@ function renderHistory(output, history, inputLines, selection, reservedRows = 0,
|
|
|
3376
2783
|
themeFingerprint
|
|
3377
2784
|
);
|
|
3378
2785
|
currentLines = currentLayoutRows.map((r) => r.rendered);
|
|
3379
|
-
const
|
|
3380
|
-
currentStart = finalizedLines +
|
|
2786
|
+
const sep2 = currentTurnSeparator(history);
|
|
2787
|
+
currentStart = finalizedLines + sep2;
|
|
3381
2788
|
}
|
|
3382
2789
|
const totalLines = currentStart >= 0 ? currentStart + currentLines.length : finalizedLines;
|
|
3383
2790
|
if (history.followBottom) {
|
|
@@ -3712,13 +3119,13 @@ function createDialogHost(args) {
|
|
|
3712
3119
|
};
|
|
3713
3120
|
let operationRunning = false;
|
|
3714
3121
|
const operations = [];
|
|
3715
|
-
const exclusive = (body, cancellation) => new Promise((
|
|
3122
|
+
const exclusive = (body, cancellation) => new Promise((resolve5, reject) => {
|
|
3716
3123
|
const abortQueued = () => {
|
|
3717
3124
|
const index = operations.indexOf(start);
|
|
3718
3125
|
if (index < 0) return;
|
|
3719
3126
|
operations.splice(index, 1);
|
|
3720
3127
|
cancellation?.signal.removeEventListener("abort", abortQueued);
|
|
3721
|
-
|
|
3128
|
+
resolve5(cancellation.cancelled());
|
|
3722
3129
|
};
|
|
3723
3130
|
const start = () => {
|
|
3724
3131
|
cancellation?.signal.removeEventListener("abort", abortQueued);
|
|
@@ -3739,7 +3146,7 @@ function createDialogHost(args) {
|
|
|
3739
3146
|
void Promise.resolve(result).then(
|
|
3740
3147
|
(value) => {
|
|
3741
3148
|
release();
|
|
3742
|
-
|
|
3149
|
+
resolve5(value);
|
|
3743
3150
|
},
|
|
3744
3151
|
(error) => {
|
|
3745
3152
|
release();
|
|
@@ -3748,7 +3155,7 @@ function createDialogHost(args) {
|
|
|
3748
3155
|
);
|
|
3749
3156
|
};
|
|
3750
3157
|
if (cancellation?.signal.aborted) {
|
|
3751
|
-
|
|
3158
|
+
resolve5(cancellation.cancelled());
|
|
3752
3159
|
return;
|
|
3753
3160
|
}
|
|
3754
3161
|
if (operationRunning) {
|
|
@@ -4125,9 +3532,9 @@ function createRawKeyReader(input, options) {
|
|
|
4125
3532
|
};
|
|
4126
3533
|
const resolveWaiter = (value) => {
|
|
4127
3534
|
if (!waiter) return;
|
|
4128
|
-
const
|
|
3535
|
+
const resolve5 = waiter;
|
|
4129
3536
|
waiter = null;
|
|
4130
|
-
|
|
3537
|
+
resolve5(value);
|
|
4131
3538
|
};
|
|
4132
3539
|
const tryDeliver = () => {
|
|
4133
3540
|
if (!waiter) return;
|
|
@@ -4186,12 +3593,12 @@ function createRawKeyReader(input, options) {
|
|
|
4186
3593
|
input.on("close", onClose);
|
|
4187
3594
|
input.on("end", onClose);
|
|
4188
3595
|
input.resume?.();
|
|
4189
|
-
const reader = () => new Promise((
|
|
3596
|
+
const reader = () => new Promise((resolve5) => {
|
|
4190
3597
|
if (closed) {
|
|
4191
|
-
|
|
3598
|
+
resolve5(drainClosed());
|
|
4192
3599
|
return;
|
|
4193
3600
|
}
|
|
4194
|
-
waiter =
|
|
3601
|
+
waiter = resolve5;
|
|
4195
3602
|
tryDeliver();
|
|
4196
3603
|
});
|
|
4197
3604
|
reader.dispose = () => {
|
|
@@ -4226,8 +3633,8 @@ async function runSelectDialog(args) {
|
|
|
4226
3633
|
const input = args.input ?? process.stdin;
|
|
4227
3634
|
const readKey = args.readKey ?? createRawKeyReader(input, hotkeys ? { preserveBracketedPaste: true } : void 0);
|
|
4228
3635
|
let cancelRead;
|
|
4229
|
-
const cancelled = new Promise((
|
|
4230
|
-
cancelRead = () =>
|
|
3636
|
+
const cancelled = new Promise((resolve5) => {
|
|
3637
|
+
cancelRead = () => resolve5(STREAM_CLOSED);
|
|
4231
3638
|
});
|
|
4232
3639
|
args.signal?.addEventListener("abort", cancelRead, { once: true });
|
|
4233
3640
|
if (args.signal?.aborted) cancelRead();
|
|
@@ -4662,7 +4069,7 @@ function createShellApprovalSession(confirm, isAutoConfirm = () => false) {
|
|
|
4662
4069
|
|
|
4663
4070
|
// packages/cli/tui/readlineWorkspace.ts
|
|
4664
4071
|
import { createInterface } from "node:readline";
|
|
4665
|
-
import { basename } from "node:path";
|
|
4072
|
+
import { basename as basename2 } from "node:path";
|
|
4666
4073
|
import { PassThrough } from "node:stream";
|
|
4667
4074
|
import { stdin as defaultInput, stdout as defaultOutput } from "node:process";
|
|
4668
4075
|
|
|
@@ -6136,11 +5543,11 @@ function createSecretInputCoordinator() {
|
|
|
6136
5543
|
};
|
|
6137
5544
|
return {
|
|
6138
5545
|
enqueue(start, options) {
|
|
6139
|
-
return new Promise((
|
|
6140
|
-
const entry = { start, settle:
|
|
5546
|
+
return new Promise((resolve5) => {
|
|
5547
|
+
const entry = { start, settle: resolve5, cancelled: options.cancelled, controller: new AbortController(), detach: () => options.signal?.removeEventListener("abort", abort) };
|
|
6141
5548
|
const abort = () => cancel(entry);
|
|
6142
5549
|
if (closed || options.signal?.aborted) {
|
|
6143
|
-
|
|
5550
|
+
resolve5(options.cancelled());
|
|
6144
5551
|
return;
|
|
6145
5552
|
}
|
|
6146
5553
|
queue.push(entry);
|
|
@@ -6152,9 +5559,9 @@ function createSecretInputCoordinator() {
|
|
|
6152
5559
|
if (active) {
|
|
6153
5560
|
if (!active.controller.signal.aborted) {
|
|
6154
5561
|
if (waiter) {
|
|
6155
|
-
const
|
|
5562
|
+
const resolve5 = waiter;
|
|
6156
5563
|
waiter = null;
|
|
6157
|
-
|
|
5564
|
+
resolve5(token);
|
|
6158
5565
|
} else inbox.push(token);
|
|
6159
5566
|
}
|
|
6160
5567
|
return true;
|
|
@@ -6163,10 +5570,10 @@ function createSecretInputCoordinator() {
|
|
|
6163
5570
|
const entry = queue[0];
|
|
6164
5571
|
active = entry;
|
|
6165
5572
|
inbox = [];
|
|
6166
|
-
const readKey = () => new Promise((
|
|
6167
|
-
if (entry.controller.signal.aborted)
|
|
6168
|
-
else if (inbox.length)
|
|
6169
|
-
else waiter =
|
|
5573
|
+
const readKey = () => new Promise((resolve5) => {
|
|
5574
|
+
if (entry.controller.signal.aborted) resolve5(STREAM_CLOSED);
|
|
5575
|
+
else if (inbox.length) resolve5(inbox.shift());
|
|
5576
|
+
else waiter = resolve5;
|
|
6170
5577
|
});
|
|
6171
5578
|
readKey.dispose = closeInbox;
|
|
6172
5579
|
let operation;
|
|
@@ -6243,8 +5650,8 @@ async function runSecretInputDialog(args) {
|
|
|
6243
5650
|
wakeAbort?.();
|
|
6244
5651
|
readKey?.dispose?.();
|
|
6245
5652
|
};
|
|
6246
|
-
const aborted = new Promise((
|
|
6247
|
-
wakeAbort = () =>
|
|
5653
|
+
const aborted = new Promise((resolve5) => {
|
|
5654
|
+
wakeAbort = () => resolve5(STREAM_CLOSED);
|
|
6248
5655
|
});
|
|
6249
5656
|
try {
|
|
6250
5657
|
readKey = args.readKey ?? createRawKeyReader(input, { preserveBracketedPaste: true });
|
|
@@ -6544,14 +5951,14 @@ function createInlineHostApprovalPrompt(args) {
|
|
|
6544
5951
|
} catch {
|
|
6545
5952
|
}
|
|
6546
5953
|
};
|
|
6547
|
-
const presentOne = (card, context, anchor) => new Promise((
|
|
5954
|
+
const presentOne = (card, context, anchor) => new Promise((resolve5) => {
|
|
6548
5955
|
if (disposed || context.signal?.aborted) {
|
|
6549
|
-
|
|
5956
|
+
resolve5(disposed ? "deny" : "cancelled");
|
|
6550
5957
|
return;
|
|
6551
5958
|
}
|
|
6552
5959
|
const expiresAt = Math.min(card.expiresAt, context.expiresAt ?? Infinity);
|
|
6553
5960
|
if (expiresAt <= now()) {
|
|
6554
|
-
|
|
5961
|
+
resolve5("expired");
|
|
6555
5962
|
return;
|
|
6556
5963
|
}
|
|
6557
5964
|
const abort = () => settle(context.signal?.reason === "expired" ? "expired" : "cancelled", "\u2716 approval ended \u2014 the action was not run");
|
|
@@ -6609,7 +6016,7 @@ function createInlineHostApprovalPrompt(args) {
|
|
|
6609
6016
|
painter?.clear();
|
|
6610
6017
|
} catch {
|
|
6611
6018
|
} finally {
|
|
6612
|
-
|
|
6019
|
+
resolve5(result);
|
|
6613
6020
|
}
|
|
6614
6021
|
}
|
|
6615
6022
|
};
|
|
@@ -7833,7 +7240,19 @@ function createRunRegistryPoller(deps) {
|
|
|
7833
7240
|
}
|
|
7834
7241
|
|
|
7835
7242
|
// packages/cli/tui/runCompletionWatcher.ts
|
|
7243
|
+
import {
|
|
7244
|
+
closeSync,
|
|
7245
|
+
constants as fsConstants,
|
|
7246
|
+
fstatSync,
|
|
7247
|
+
lstatSync,
|
|
7248
|
+
openSync,
|
|
7249
|
+
readSync,
|
|
7250
|
+
realpathSync
|
|
7251
|
+
} from "node:fs";
|
|
7252
|
+
import { basename, dirname, resolve as resolve2, sep } from "node:path";
|
|
7836
7253
|
var WAKE_NOTE_MAX_CHARS = 300;
|
|
7254
|
+
var WAKE_TITLE_MAX_CHARS = 120;
|
|
7255
|
+
var WAKE_AGENT_MAX_CHARS = 80;
|
|
7837
7256
|
function runDuration(record, nowMs = Date.now()) {
|
|
7838
7257
|
return formatRunAge(
|
|
7839
7258
|
{
|
|
@@ -7847,6 +7266,7 @@ function isFailureStatus(status) {
|
|
|
7847
7266
|
return typeof status === "string" && status !== "done";
|
|
7848
7267
|
}
|
|
7849
7268
|
var WAKE_ERROR_PAYLOAD_TOKEN_BUDGET = 500;
|
|
7269
|
+
var WAKE_ERROR_MIN_PAYLOAD_TOKEN_BUDGET = 120;
|
|
7850
7270
|
var WAKE_TOTAL_TOKEN_BUDGET = 2e3;
|
|
7851
7271
|
var escapeXmlAttribute = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
7852
7272
|
function clipTextToTokenBudget(text, budgetTokens) {
|
|
@@ -7870,23 +7290,270 @@ function failureErrorPayload(record, budgetTokens) {
|
|
|
7870
7290
|
const raw = typeof record.note === "string" && record.note.trim() ? record.note : typeof recordError === "string" && recordError.trim() ? recordError : "";
|
|
7871
7291
|
return clipTextToTokenBudget(clipText(raw, 2e3), budgetTokens);
|
|
7872
7292
|
}
|
|
7873
|
-
|
|
7293
|
+
var RESULT_HEAD_MAX_BYTES = 16 * 1024;
|
|
7294
|
+
var WAKE_SUMMARY_MAX_LINES = 25;
|
|
7295
|
+
var WAKE_SUMMARY_MAX_CHARS = 1e3;
|
|
7296
|
+
var WAKE_TOTAL_SUMMARY_CHAR_BUDGET = 2400;
|
|
7297
|
+
var RESULT_FILE_SUFFIX = ".result.md";
|
|
7298
|
+
function isSafeRunId(runId) {
|
|
7299
|
+
if (!runId) return false;
|
|
7300
|
+
if (runId.includes("/") || runId.includes("\\") || runId.includes("\0")) return false;
|
|
7301
|
+
if (runId === "." || runId === ".." || runId.includes("..")) return false;
|
|
7302
|
+
return true;
|
|
7303
|
+
}
|
|
7304
|
+
function canonicalDir(dir) {
|
|
7305
|
+
try {
|
|
7306
|
+
return realpathSync(dir);
|
|
7307
|
+
} catch {
|
|
7308
|
+
return resolve2(dir);
|
|
7309
|
+
}
|
|
7310
|
+
}
|
|
7311
|
+
function isUnderTrustedDir(path3, dir) {
|
|
7312
|
+
const parent = canonicalDir(dirname(path3));
|
|
7313
|
+
const root = canonicalDir(dir);
|
|
7314
|
+
return parent === root || parent.startsWith(root.endsWith(sep) ? root : `${root}${sep}`);
|
|
7315
|
+
}
|
|
7316
|
+
function resolveTrustedResultDirs(explicit) {
|
|
7317
|
+
if (Array.isArray(explicit) && explicit.length > 0) return explicit;
|
|
7318
|
+
return [resolveRunsDir(process.env)];
|
|
7319
|
+
}
|
|
7320
|
+
function resolveTrustedResultPath(resultFile, options = {}) {
|
|
7321
|
+
const raw = typeof resultFile === "string" ? resultFile.trim() : "";
|
|
7322
|
+
if (!raw) return null;
|
|
7323
|
+
if (options.runId !== void 0) {
|
|
7324
|
+
if (!isSafeRunId(options.runId)) return null;
|
|
7325
|
+
if (basename(raw) !== `${options.runId}${RESULT_FILE_SUFFIX}`) return null;
|
|
7326
|
+
}
|
|
7327
|
+
const dirs = resolveTrustedResultDirs(options.trustedResultDirs);
|
|
7328
|
+
const trusted = dirs.some(
|
|
7329
|
+
(dir) => typeof dir === "string" && dir.length > 0 && isUnderTrustedDir(raw, dir)
|
|
7330
|
+
);
|
|
7331
|
+
if (!trusted) return null;
|
|
7332
|
+
return raw;
|
|
7333
|
+
}
|
|
7334
|
+
function trimIncompleteUtf8Tail(buf) {
|
|
7335
|
+
if (buf.length === 0) return buf;
|
|
7336
|
+
let start = buf.length - 1;
|
|
7337
|
+
while (start >= 0 && (buf[start] & 192) === 128) start -= 1;
|
|
7338
|
+
if (start < 0) return buf;
|
|
7339
|
+
const lead = buf[start];
|
|
7340
|
+
let need = 1;
|
|
7341
|
+
if (lead < 128) need = 1;
|
|
7342
|
+
else if ((lead & 224) === 192) need = 2;
|
|
7343
|
+
else if ((lead & 240) === 224) need = 3;
|
|
7344
|
+
else if ((lead & 248) === 240) need = 4;
|
|
7345
|
+
const have = buf.length - start;
|
|
7346
|
+
if (have >= need) return buf;
|
|
7347
|
+
return buf.subarray(0, start);
|
|
7348
|
+
}
|
|
7349
|
+
function readResultFileHead(path3, maxBytes = RESULT_HEAD_MAX_BYTES) {
|
|
7350
|
+
let fd = null;
|
|
7351
|
+
try {
|
|
7352
|
+
const flags = fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0) | (fsConstants.O_NONBLOCK ?? 0);
|
|
7353
|
+
if (!fsConstants.O_NOFOLLOW) {
|
|
7354
|
+
let lst;
|
|
7355
|
+
try {
|
|
7356
|
+
lst = lstatSync(path3);
|
|
7357
|
+
} catch {
|
|
7358
|
+
return null;
|
|
7359
|
+
}
|
|
7360
|
+
if (!lst.isFile()) return null;
|
|
7361
|
+
}
|
|
7362
|
+
fd = openSync(path3, flags);
|
|
7363
|
+
const stat3 = fstatSync(fd);
|
|
7364
|
+
if (!stat3.isFile()) return null;
|
|
7365
|
+
const want = Math.min(stat3.size, maxBytes);
|
|
7366
|
+
if (want <= 0) return null;
|
|
7367
|
+
const buf = Buffer.alloc(want);
|
|
7368
|
+
let read = 0;
|
|
7369
|
+
while (read < want) {
|
|
7370
|
+
const n = readSync(fd, buf, read, want - read, read);
|
|
7371
|
+
if (n <= 0) break;
|
|
7372
|
+
read += n;
|
|
7373
|
+
}
|
|
7374
|
+
if (read <= 0) return null;
|
|
7375
|
+
const sliced = buf.subarray(0, read);
|
|
7376
|
+
const safe = stat3.size > read ? trimIncompleteUtf8Tail(sliced) : sliced;
|
|
7377
|
+
return {
|
|
7378
|
+
head: safe.toString("utf8"),
|
|
7379
|
+
bytesRead: safe.length,
|
|
7380
|
+
bytesTotal: stat3.size
|
|
7381
|
+
};
|
|
7382
|
+
} catch {
|
|
7383
|
+
return null;
|
|
7384
|
+
} finally {
|
|
7385
|
+
if (fd !== null) {
|
|
7386
|
+
try {
|
|
7387
|
+
closeSync(fd);
|
|
7388
|
+
} catch {
|
|
7389
|
+
}
|
|
7390
|
+
}
|
|
7391
|
+
}
|
|
7392
|
+
}
|
|
7393
|
+
function stripLeadingFrontMatter(text) {
|
|
7394
|
+
const open = /^---\r?\n/.exec(text);
|
|
7395
|
+
if (!open) return text;
|
|
7396
|
+
const rest = text.slice(open[0].length);
|
|
7397
|
+
const immediate = /^---\r?\n/.exec(rest);
|
|
7398
|
+
if (immediate) return rest.slice(immediate[0].length);
|
|
7399
|
+
const close = /\r?\n---\r?\n/.exec(rest);
|
|
7400
|
+
if (!close) return text;
|
|
7401
|
+
return rest.slice(close.index + close[0].length);
|
|
7402
|
+
}
|
|
7403
|
+
function hasUnclosedFrontMatter(text) {
|
|
7404
|
+
const open = /^---\r?\n/.exec(text);
|
|
7405
|
+
if (!open) return false;
|
|
7406
|
+
const rest = text.slice(open[0].length);
|
|
7407
|
+
if (/^---\r?\n/.test(rest)) return false;
|
|
7408
|
+
return !/\r?\n---\r?(\n|$)/.test(rest);
|
|
7409
|
+
}
|
|
7410
|
+
function escapeXmlText(text) {
|
|
7411
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
7412
|
+
}
|
|
7413
|
+
var PEM_PRIVATE_KEY_MARKER = /-----(BEGIN|END) (?:[A-Z0-9 ]+)?PRIVATE KEY-----/g;
|
|
7414
|
+
function hasUnpairedPrivateKeyMarker(text) {
|
|
7415
|
+
if (typeof text !== "string" || !text.includes("PRIVATE KEY")) return false;
|
|
7416
|
+
let open = 0;
|
|
7417
|
+
for (const marker of text.matchAll(PEM_PRIVATE_KEY_MARKER)) {
|
|
7418
|
+
if (marker[1] === "BEGIN") open += 1;
|
|
7419
|
+
else if (open === 0) return true;
|
|
7420
|
+
else open -= 1;
|
|
7421
|
+
}
|
|
7422
|
+
return open > 0;
|
|
7423
|
+
}
|
|
7424
|
+
function trimTrailingNewline(text) {
|
|
7425
|
+
return text.replace(/(?:\r?\n)$/, "");
|
|
7426
|
+
}
|
|
7427
|
+
function normalizeNewlines(text) {
|
|
7428
|
+
return text.includes("\r") ? text.replace(/\r\n/g, "\n") : text;
|
|
7429
|
+
}
|
|
7430
|
+
function newlineCount(text) {
|
|
7431
|
+
let count = 0;
|
|
7432
|
+
for (let i = text.indexOf("\n"); i !== -1; i = text.indexOf("\n", i + 1)) count += 1;
|
|
7433
|
+
return count;
|
|
7434
|
+
}
|
|
7435
|
+
function scrubWakeBody(body) {
|
|
7436
|
+
const sanitized = trimTrailingNewline(sanitizeToolOutputText(body));
|
|
7437
|
+
if (hasUnpairedPrivateKeyMarker(sanitized)) return null;
|
|
7438
|
+
const scrubbed = scrubSecrets(sanitized).cleaned;
|
|
7439
|
+
return {
|
|
7440
|
+
lines: scrubbed.split("\n"),
|
|
7441
|
+
// 99.9% 的报告换行数不变 → 物理行 1:1,行号可信;折叠/跨行控制串被删就没法保证。
|
|
7442
|
+
lineAligned: newlineCount(normalizeNewlines(trimTrailingNewline(body))) === newlineCount(scrubbed)
|
|
7443
|
+
};
|
|
7444
|
+
}
|
|
7445
|
+
function escapedCharCost(ch) {
|
|
7446
|
+
if (ch === "&") return "&".length;
|
|
7447
|
+
if (ch === "<" || ch === ">") return "<".length;
|
|
7448
|
+
return ch.length;
|
|
7449
|
+
}
|
|
7450
|
+
function cutToEscapedBudget(text, budget) {
|
|
7451
|
+
if (budget <= 0) return { text: "", truncated: text.length > 0 };
|
|
7452
|
+
let used = 0;
|
|
7453
|
+
let i = 0;
|
|
7454
|
+
while (i < text.length) {
|
|
7455
|
+
const cp = text.codePointAt(i);
|
|
7456
|
+
const ch = String.fromCodePoint(cp);
|
|
7457
|
+
const cost = escapedCharCost(ch);
|
|
7458
|
+
if (used + cost > budget) return { text: text.slice(0, i), truncated: true };
|
|
7459
|
+
used += cost;
|
|
7460
|
+
i += ch.length;
|
|
7461
|
+
}
|
|
7462
|
+
return { text, truncated: false };
|
|
7463
|
+
}
|
|
7464
|
+
function extractWakeSummary(resultFile, maxChars = WAKE_SUMMARY_MAX_CHARS, options = {}) {
|
|
7465
|
+
if (typeof resultFile !== "string" || !resultFile.trim() || maxChars <= 0) {
|
|
7466
|
+
return null;
|
|
7467
|
+
}
|
|
7468
|
+
const trustedPath = resolveTrustedResultPath(resultFile, options);
|
|
7469
|
+
if (!trustedPath) return null;
|
|
7470
|
+
const read = readResultFileHead(trustedPath);
|
|
7471
|
+
if (!read) return null;
|
|
7472
|
+
if (hasUnclosedFrontMatter(read.head)) return null;
|
|
7473
|
+
if (hasUnpairedPrivateKeyMarker(read.head)) return null;
|
|
7474
|
+
const body = stripLeadingFrontMatter(read.head);
|
|
7475
|
+
const frontMatterChars = read.head.length - body.length;
|
|
7476
|
+
const frontMatterLines = frontMatterChars > 0 ? read.head.slice(0, frontMatterChars).split("\n").length - 1 : 0;
|
|
7477
|
+
const sourceLines = scrubWakeBody(body);
|
|
7478
|
+
if (!sourceLines) return null;
|
|
7479
|
+
const lines = sourceLines.lines;
|
|
7480
|
+
let start = 0;
|
|
7481
|
+
while (start < lines.length && lines[start].trim() === "") start++;
|
|
7482
|
+
if (start >= lines.length) return null;
|
|
7483
|
+
const lineLimited = lines.length - start > WAKE_SUMMARY_MAX_LINES;
|
|
7484
|
+
const picked = lines.slice(start, start + WAKE_SUMMARY_MAX_LINES);
|
|
7485
|
+
while (picked.length > 1 && picked[picked.length - 1].trim() === "") picked.pop();
|
|
7486
|
+
const joined = picked.join("\n").replace(/\s+$/, "");
|
|
7487
|
+
if (!joined.trim()) return null;
|
|
7488
|
+
const cut = cutToEscapedBudget(joined, maxChars);
|
|
7489
|
+
const finalText = cut.text.replace(/\s+$/, "");
|
|
7490
|
+
if (!finalText.trim()) return null;
|
|
7491
|
+
const retainedLines = Math.min(finalText.split("\n").length, picked.length);
|
|
7492
|
+
const firstSourceLine = frontMatterLines + 1 + start;
|
|
7493
|
+
return {
|
|
7494
|
+
text: escapeXmlText(finalText),
|
|
7495
|
+
...sourceLines.lineAligned ? { startLine: firstSourceLine, endLine: firstSourceLine + retainedLines - 1 } : {},
|
|
7496
|
+
truncated: lineLimited || cut.truncated || read.bytesTotal > read.bytesRead
|
|
7497
|
+
};
|
|
7498
|
+
}
|
|
7499
|
+
function renderSummaryBlock(summary) {
|
|
7500
|
+
const linesAttr = typeof summary.startLine === "number" && typeof summary.endLine === "number" ? ` lines="${summary.startLine}-${summary.endLine}"` : "";
|
|
7501
|
+
return [
|
|
7502
|
+
`<summary${linesAttr} truncated="${summary.truncated ? "true" : "false"}">`,
|
|
7503
|
+
summary.text,
|
|
7504
|
+
`</summary>`
|
|
7505
|
+
].join("\n");
|
|
7506
|
+
}
|
|
7507
|
+
var WAKE_SUMMARY_MIN_CHARS = 24;
|
|
7508
|
+
function planWakeSummaries(runs, readSummary = extractWakeSummary, options = {}) {
|
|
7509
|
+
const out = /* @__PURE__ */ new Map();
|
|
7510
|
+
const eligible = runs.filter(
|
|
7511
|
+
(r) => !isFailureStatus(r.status) && typeof r.resultFile === "string" && r.resultFile.trim()
|
|
7512
|
+
);
|
|
7513
|
+
if (!eligible.length) return out;
|
|
7514
|
+
const totalBudget = Math.max(
|
|
7515
|
+
0,
|
|
7516
|
+
options.totalCharBudget ?? WAKE_TOTAL_SUMMARY_CHAR_BUDGET
|
|
7517
|
+
);
|
|
7518
|
+
const perRunChars = Math.min(
|
|
7519
|
+
WAKE_SUMMARY_MAX_CHARS,
|
|
7520
|
+
Math.floor(totalBudget / eligible.length)
|
|
7521
|
+
);
|
|
7522
|
+
if (perRunChars < WAKE_SUMMARY_MIN_CHARS) return out;
|
|
7523
|
+
for (const r of eligible) {
|
|
7524
|
+
try {
|
|
7525
|
+
const summary = readSummary(r.resultFile.trim(), perRunChars, {
|
|
7526
|
+
runId: r.runId,
|
|
7527
|
+
trustedResultDirs: options.trustedResultDirs
|
|
7528
|
+
});
|
|
7529
|
+
if (summary && summary.text.trim()) out.set(r.runId, summary);
|
|
7530
|
+
} catch {
|
|
7531
|
+
}
|
|
7532
|
+
}
|
|
7533
|
+
return out;
|
|
7534
|
+
}
|
|
7535
|
+
function buildRunElement(record, nowMs, errorBudgetTokens, summary) {
|
|
7874
7536
|
const attrs = [
|
|
7875
7537
|
`runId="${escapeXmlAttribute(String(record.runId))}"`,
|
|
7876
7538
|
// Same rule as describeRun: this attribute is parsed by the model, so the
|
|
7877
7539
|
// label keeps the agentKey correlation — title never substitutes for it.
|
|
7878
7540
|
`agent="${escapeXmlAttribute(
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7541
|
+
clipText(
|
|
7542
|
+
resolveRunLabel({
|
|
7543
|
+
agentName: record.agentName,
|
|
7544
|
+
agentKey: record.agentKey,
|
|
7545
|
+
runId: record.runId
|
|
7546
|
+
}),
|
|
7547
|
+
WAKE_AGENT_MAX_CHARS
|
|
7548
|
+
)
|
|
7884
7549
|
)}"`,
|
|
7885
7550
|
`status="${escapeXmlAttribute(String(record.status))}"`
|
|
7886
7551
|
];
|
|
7887
7552
|
const rawTitle = record.title;
|
|
7888
7553
|
if (typeof rawTitle === "string" && rawTitle.trim()) {
|
|
7889
|
-
attrs.push(
|
|
7554
|
+
attrs.push(
|
|
7555
|
+
`title="${escapeXmlAttribute(clipText(rawTitle.trim(), WAKE_TITLE_MAX_CHARS))}"`
|
|
7556
|
+
);
|
|
7890
7557
|
}
|
|
7891
7558
|
if (record.continuedFrom) attrs.push(`continuedFrom="${escapeXmlAttribute(record.continuedFrom)}"`);
|
|
7892
7559
|
const verbose = isFailureStatus(record.status);
|
|
@@ -7910,51 +7577,133 @@ function buildRunElement(record, nowMs, errorBudgetTokens) {
|
|
|
7910
7577
|
if (!verbose) {
|
|
7911
7578
|
const note = typeof record.note === "string" && record.note.trim() ? clipText(record.note, WAKE_NOTE_MAX_CHARS) : "";
|
|
7912
7579
|
if (note) attrs.push(`note="${escapeXmlAttribute(note)}"`);
|
|
7913
|
-
return `<run ${attrs.join(" ")} />`;
|
|
7914
7580
|
}
|
|
7915
7581
|
const body = [];
|
|
7916
|
-
|
|
7917
|
-
if (
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7582
|
+
if (summary) body.push(renderSummaryBlock(summary));
|
|
7583
|
+
if (verbose) {
|
|
7584
|
+
const errorText = failureErrorPayload(record, errorBudgetTokens);
|
|
7585
|
+
if (errorText) body.push(`error: ${errorText}`);
|
|
7586
|
+
const counters = record.activity?.counters;
|
|
7587
|
+
if (counters && typeof counters.toolCalls === "number" && typeof counters.llmCalls === "number" && typeof counters.fileEdits === "number") {
|
|
7588
|
+
body.push(
|
|
7589
|
+
`activity: ${counters.toolCalls} tool calls \xB7 ${counters.llmCalls} llm calls \xB7 ${counters.fileEdits} edits`
|
|
7590
|
+
);
|
|
7591
|
+
}
|
|
7923
7592
|
}
|
|
7924
7593
|
if (body.length === 0) return `<run ${attrs.join(" ")} />`;
|
|
7925
7594
|
return `<run ${attrs.join(" ")}>
|
|
7926
7595
|
${body.join("\n")}
|
|
7927
7596
|
</run>`;
|
|
7928
7597
|
}
|
|
7929
|
-
function renderWakeMessage(elements, count) {
|
|
7598
|
+
function renderWakeMessage(elements, count, omittedCount = 0) {
|
|
7599
|
+
const omittedLine = omittedCount > 0 ? `\u2026 \u53CA\u53E6\u5916 ${omittedCount} \u6761\u5DF2\u5B8C\u6210 run\uFF0C\u7528 controlAgentRun(list) \u67E5\u770B` : null;
|
|
7930
7600
|
return [
|
|
7931
7601
|
`<background_run_completion count="${count}">`,
|
|
7932
7602
|
...elements,
|
|
7933
|
-
|
|
7603
|
+
...omittedLine ? [omittedLine] : [],
|
|
7604
|
+
`\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
7605
|
`</background_run_completion>`
|
|
7935
7606
|
].join("\n");
|
|
7936
7607
|
}
|
|
7937
|
-
function
|
|
7938
|
-
const
|
|
7939
|
-
const
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
)
|
|
7956
|
-
|
|
7957
|
-
|
|
7608
|
+
function allocateErrorBudgets(failures, availableTokens, needTokens) {
|
|
7609
|
+
const out = /* @__PURE__ */ new Map();
|
|
7610
|
+
const needs = failures.map((r) => ({ runId: r.runId, need: Math.max(0, needTokens(r)) })).sort((a, b) => a.need - b.need);
|
|
7611
|
+
let pool = Math.max(0, availableTokens);
|
|
7612
|
+
for (let i = 0; i < needs.length; i++) {
|
|
7613
|
+
const share = Math.floor(pool / (needs.length - i));
|
|
7614
|
+
const granted = Math.min(needs[i].need, share);
|
|
7615
|
+
out.set(needs[i].runId, granted);
|
|
7616
|
+
pool -= granted;
|
|
7617
|
+
}
|
|
7618
|
+
return out;
|
|
7619
|
+
}
|
|
7620
|
+
function buildWakeMessage(finished, nowMs = Date.now(), options = {}) {
|
|
7621
|
+
const ordered = [
|
|
7622
|
+
...finished.filter((r) => isFailureStatus(r.status)),
|
|
7623
|
+
...finished.filter((r) => !isFailureStatus(r.status))
|
|
7624
|
+
];
|
|
7625
|
+
const attempt = (subset, omittedCount) => {
|
|
7626
|
+
const errorNeed = (r) => Math.min(
|
|
7627
|
+
WAKE_ERROR_PAYLOAD_TOKEN_BUDGET,
|
|
7628
|
+
estimateTokenCount(failureErrorPayload(r, WAKE_ERROR_PAYLOAD_TOKEN_BUDGET)) + 1
|
|
7629
|
+
);
|
|
7630
|
+
const render = (errorBudgets2, summaries) => renderWakeMessage(
|
|
7631
|
+
subset.map(
|
|
7632
|
+
(r) => buildRunElement(
|
|
7633
|
+
r,
|
|
7634
|
+
nowMs,
|
|
7635
|
+
isFailureStatus(r.status) ? errorBudgets2.get(r.runId) ?? 0 : 0,
|
|
7636
|
+
summaries.get(r.runId) ?? null
|
|
7637
|
+
)
|
|
7638
|
+
),
|
|
7639
|
+
finished.length,
|
|
7640
|
+
omittedCount
|
|
7641
|
+
);
|
|
7642
|
+
const bareTokens = estimateTokenCount(render(/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()));
|
|
7643
|
+
if (bareTokens > WAKE_TOTAL_TOKEN_BUDGET) return null;
|
|
7644
|
+
const failures = subset.filter((r) => isFailureStatus(r.status));
|
|
7645
|
+
const errorBudgets = allocateErrorBudgets(
|
|
7646
|
+
failures,
|
|
7647
|
+
WAKE_TOTAL_TOKEN_BUDGET - bareTokens,
|
|
7648
|
+
errorNeed
|
|
7649
|
+
);
|
|
7650
|
+
const includedSuccessCount = subset.length - failures.length;
|
|
7651
|
+
for (const r of failures) {
|
|
7652
|
+
const granted = errorBudgets.get(r.runId) ?? 0;
|
|
7653
|
+
if (includedSuccessCount > 0) {
|
|
7654
|
+
const floor = Math.min(errorNeed(r), WAKE_ERROR_MIN_PAYLOAD_TOKEN_BUDGET);
|
|
7655
|
+
if (granted < floor) return null;
|
|
7656
|
+
} else if (granted <= 0) {
|
|
7657
|
+
return null;
|
|
7658
|
+
}
|
|
7659
|
+
}
|
|
7660
|
+
let withErrors = render(errorBudgets, /* @__PURE__ */ new Map());
|
|
7661
|
+
let withErrorsTokens = estimateTokenCount(withErrors);
|
|
7662
|
+
if (includedSuccessCount === 0) {
|
|
7663
|
+
for (let round = 0; round < 6 && withErrorsTokens > WAKE_TOTAL_TOKEN_BUDGET; round++) {
|
|
7664
|
+
const excess = withErrorsTokens - WAKE_TOTAL_TOKEN_BUDGET;
|
|
7665
|
+
let victim = null;
|
|
7666
|
+
for (const r of failures) {
|
|
7667
|
+
if (!victim || (errorBudgets.get(r.runId) ?? 0) > (errorBudgets.get(victim.runId) ?? 0)) {
|
|
7668
|
+
victim = r;
|
|
7669
|
+
}
|
|
7670
|
+
}
|
|
7671
|
+
const current = victim ? errorBudgets.get(victim.runId) ?? 0 : 0;
|
|
7672
|
+
if (!victim || current <= 0) break;
|
|
7673
|
+
errorBudgets.set(victim.runId, Math.max(0, current - Math.max(1, excess + 2)));
|
|
7674
|
+
withErrors = render(errorBudgets, /* @__PURE__ */ new Map());
|
|
7675
|
+
withErrorsTokens = estimateTokenCount(withErrors);
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7678
|
+
if (withErrorsTokens > WAKE_TOTAL_TOKEN_BUDGET) return null;
|
|
7679
|
+
let summaryCharBudget = Math.min(
|
|
7680
|
+
WAKE_TOTAL_SUMMARY_CHAR_BUDGET,
|
|
7681
|
+
// 最坏情况 1.5 token/字符(中文),据此把剩余 token 折成摘要字符预算。
|
|
7682
|
+
Math.floor(Math.max(0, WAKE_TOTAL_TOKEN_BUDGET - withErrorsTokens) / 1.5)
|
|
7683
|
+
);
|
|
7684
|
+
let message = withErrors;
|
|
7685
|
+
for (let round = 0; round < 8; round++) {
|
|
7686
|
+
const summaries = summaryCharBudget >= WAKE_SUMMARY_MIN_CHARS ? planWakeSummaries(subset, extractWakeSummary, {
|
|
7687
|
+
totalCharBudget: summaryCharBudget,
|
|
7688
|
+
trustedResultDirs: options.trustedResultDirs
|
|
7689
|
+
}) : /* @__PURE__ */ new Map();
|
|
7690
|
+
message = render(errorBudgets, summaries);
|
|
7691
|
+
if (summaries.size === 0) break;
|
|
7692
|
+
if (estimateTokenCount(message) <= WAKE_TOTAL_TOKEN_BUDGET) break;
|
|
7693
|
+
summaryCharBudget = Math.floor(summaryCharBudget / 2);
|
|
7694
|
+
if (summaryCharBudget < WAKE_SUMMARY_MIN_CHARS) {
|
|
7695
|
+
summaryCharBudget = 0;
|
|
7696
|
+
}
|
|
7697
|
+
}
|
|
7698
|
+
return estimateTokenCount(message) <= WAKE_TOTAL_TOKEN_BUDGET ? message : null;
|
|
7699
|
+
};
|
|
7700
|
+
const direct = attempt(finished, 0);
|
|
7701
|
+
if (direct) return direct;
|
|
7702
|
+
for (let keep = ordered.length - 1; keep >= 0; keep--) {
|
|
7703
|
+
const trimmed = attempt(ordered.slice(0, keep), ordered.length - keep);
|
|
7704
|
+
if (trimmed) return trimmed;
|
|
7705
|
+
}
|
|
7706
|
+
return renderWakeMessage([], finished.length, ordered.length);
|
|
7958
7707
|
}
|
|
7959
7708
|
function buildWakeDisplayText(finished, nowMs = Date.now()) {
|
|
7960
7709
|
const tasks = finished.map((record) => ({
|
|
@@ -8087,7 +7836,9 @@ function createRunCompletionWatcher(deps) {
|
|
|
8087
7836
|
}
|
|
8088
7837
|
if (finished.length === 0 || now() < retryAt) return;
|
|
8089
7838
|
const shapes = finished.map((r) => normalizeRunCompletionShape(r));
|
|
8090
|
-
const summaryText = buildWakeMessage(finished, now()
|
|
7839
|
+
const summaryText = buildWakeMessage(finished, now(), {
|
|
7840
|
+
trustedResultDirs: [resolveRunsDir(deps.env)]
|
|
7841
|
+
});
|
|
8091
7842
|
const event = {
|
|
8092
7843
|
kind: "child-run-completed",
|
|
8093
7844
|
runs: shapes,
|
|
@@ -8170,7 +7921,7 @@ function createRunCompletionWatcher(deps) {
|
|
|
8170
7921
|
import { readFileSync, statSync as statSync2 } from "node:fs";
|
|
8171
7922
|
import { readFile, stat } from "node:fs/promises";
|
|
8172
7923
|
import { homedir as homedir2 } from "node:os";
|
|
8173
|
-
import { isAbsolute, resolve as
|
|
7924
|
+
import { isAbsolute, resolve as resolve3 } from "node:path";
|
|
8174
7925
|
|
|
8175
7926
|
// packages/cli/tui/compressImage.ts
|
|
8176
7927
|
var MAX_IMAGE_DIMENSION = 1568;
|
|
@@ -8460,7 +8211,7 @@ function resolveImageSource(rawPath, cwd) {
|
|
|
8460
8211
|
return homedir2() + candidate.slice(1);
|
|
8461
8212
|
}
|
|
8462
8213
|
if (isAbsolute(candidate)) return candidate;
|
|
8463
|
-
return
|
|
8214
|
+
return resolve3(cwd, candidate);
|
|
8464
8215
|
}
|
|
8465
8216
|
function isImagePath(path3) {
|
|
8466
8217
|
return IMAGE_EXTENSION_SET.has(extnameOf(path3));
|
|
@@ -8793,12 +8544,12 @@ function mergeAttachedImages(existing, incoming) {
|
|
|
8793
8544
|
return out;
|
|
8794
8545
|
}
|
|
8795
8546
|
async function readImagePaths(paths, options = {}) {
|
|
8796
|
-
const
|
|
8547
|
+
const resolve5 = options.resolve ?? ((p) => p);
|
|
8797
8548
|
const reportedFailures = /* @__PURE__ */ new Set();
|
|
8798
8549
|
const images = [];
|
|
8799
8550
|
const failures = [];
|
|
8800
8551
|
for (const raw of paths) {
|
|
8801
|
-
const absolute =
|
|
8552
|
+
const absolute = resolve5(raw);
|
|
8802
8553
|
try {
|
|
8803
8554
|
const img = await readImageAsDataUrl(absolute, {
|
|
8804
8555
|
...options.maxBytes !== void 0 ? { maxBytes: options.maxBytes } : {}
|
|
@@ -8904,7 +8655,7 @@ async function probeMedia(filePath, opts = {}) {
|
|
|
8904
8655
|
const runner = opts.execFileImpl ?? execFile;
|
|
8905
8656
|
const ffmpegPath = opts.ffmpegPath ?? DEFAULT_FFMPEG_PATH;
|
|
8906
8657
|
const ffprobePath = ffmpegPath.replace(/ffmpeg$/, "ffprobe");
|
|
8907
|
-
return new Promise((
|
|
8658
|
+
return new Promise((resolve5, reject) => {
|
|
8908
8659
|
runner(
|
|
8909
8660
|
ffprobePath,
|
|
8910
8661
|
[
|
|
@@ -8935,7 +8686,7 @@ async function probeMedia(filePath, opts = {}) {
|
|
|
8935
8686
|
const hasAudio = /^codec_type=audio$/m.test(text);
|
|
8936
8687
|
const rateMatch = text.match(/sample_rate=(\d+)/);
|
|
8937
8688
|
const sampleRate = rateMatch ? parseInt(rateMatch[1], 10) : null;
|
|
8938
|
-
|
|
8689
|
+
resolve5({ durationSec, hasAudio, sampleRate });
|
|
8939
8690
|
}
|
|
8940
8691
|
);
|
|
8941
8692
|
});
|
|
@@ -9022,7 +8773,7 @@ async function preprocessMedia(inputPath, opts = {}) {
|
|
|
9022
8773
|
args.push("-af", filter);
|
|
9023
8774
|
}
|
|
9024
8775
|
args.push("-c:a", "libopus", "-b:a", OPUS_BITRATE, outPath);
|
|
9025
|
-
await new Promise((
|
|
8776
|
+
await new Promise((resolve5, reject) => {
|
|
9026
8777
|
runner(ffmpegPath, args, { encoding: "utf8", maxBuffer: 8 * 1024 * 1024 }, (error, _stdout, stderr) => {
|
|
9027
8778
|
if (error) {
|
|
9028
8779
|
reject(
|
|
@@ -9032,7 +8783,7 @@ async function preprocessMedia(inputPath, opts = {}) {
|
|
|
9032
8783
|
);
|
|
9033
8784
|
return;
|
|
9034
8785
|
}
|
|
9035
|
-
|
|
8786
|
+
resolve5();
|
|
9036
8787
|
});
|
|
9037
8788
|
}).catch((err) => {
|
|
9038
8789
|
if (ownOutDir) {
|
|
@@ -9730,7 +9481,7 @@ function parseStatusOutput(branch, status) {
|
|
|
9730
9481
|
return { branch, modified, untracked };
|
|
9731
9482
|
}
|
|
9732
9483
|
function execFileUtf8(file, args, cwd) {
|
|
9733
|
-
return new Promise((
|
|
9484
|
+
return new Promise((resolve5, reject) => {
|
|
9734
9485
|
execFile3(
|
|
9735
9486
|
file,
|
|
9736
9487
|
args,
|
|
@@ -9740,7 +9491,7 @@ function execFileUtf8(file, args, cwd) {
|
|
|
9740
9491
|
reject(err);
|
|
9741
9492
|
return;
|
|
9742
9493
|
}
|
|
9743
|
-
|
|
9494
|
+
resolve5(typeof stdout === "string" ? stdout : String(stdout ?? ""));
|
|
9744
9495
|
}
|
|
9745
9496
|
);
|
|
9746
9497
|
});
|
|
@@ -9824,7 +9575,7 @@ function renderConversationLinks(extracted, t3, target = "pipe") {
|
|
|
9824
9575
|
// packages/cli/tui/sessionDispatch.ts
|
|
9825
9576
|
import { statSync as statSync5 } from "node:fs";
|
|
9826
9577
|
import { homedir as homedir4 } from "node:os";
|
|
9827
|
-
import { resolve as
|
|
9578
|
+
import { resolve as resolve4 } from "node:path";
|
|
9828
9579
|
|
|
9829
9580
|
// packages/cli/tui/agentPicker.ts
|
|
9830
9581
|
function toAgentPickerItems(entries) {
|
|
@@ -9951,29 +9702,35 @@ function renderRecentDiagnostics(env, events = getProcessRingBuffer()?.drain() ?
|
|
|
9951
9702
|
}
|
|
9952
9703
|
|
|
9953
9704
|
// packages/cli/client/estimateCliContext.ts
|
|
9954
|
-
var
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
"
|
|
9958
|
-
|
|
9705
|
+
var CLI_ESTIMATE_ENV = { [RUN_WAKE_CHANNEL_ENV]: "1" };
|
|
9706
|
+
function resolveEstimateEnv(env) {
|
|
9707
|
+
const source = env ?? process.env;
|
|
9708
|
+
const exposeMcp = String(source[MCP_EXPOSURE_ENV] ?? "").trim();
|
|
9709
|
+
return {
|
|
9710
|
+
...CLI_ESTIMATE_ENV,
|
|
9711
|
+
...exposeMcp ? { [MCP_EXPOSURE_ENV]: exposeMcp } : {}
|
|
9712
|
+
};
|
|
9713
|
+
}
|
|
9714
|
+
function resolveDefaultCliToolNames(env) {
|
|
9715
|
+
return canonicalizeToolNames(
|
|
9716
|
+
resolveCliRequestedToolNames(
|
|
9717
|
+
{ key: BUILTIN_NOLO_AGENT_KEY },
|
|
9718
|
+
env,
|
|
9719
|
+
null
|
|
9720
|
+
)
|
|
9721
|
+
);
|
|
9722
|
+
}
|
|
9959
9723
|
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
9724
|
function readAgentsMd(cwd) {
|
|
9961
9725
|
return readAgentsMdLayerFromDisk(cwd)?.content ?? "";
|
|
9962
9726
|
}
|
|
9963
|
-
function estimateToolSchemas(toolNames) {
|
|
9964
|
-
const
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
const workspaceTools = buildLocalWorkspaceOpenAiTools({
|
|
9969
|
-
toolNames: toolset.toolNames,
|
|
9970
|
-
exposeShellTools: true
|
|
9727
|
+
function estimateToolSchemas(toolNames, env) {
|
|
9728
|
+
const tools = buildOpenAiTools({
|
|
9729
|
+
agentKey: BUILTIN_NOLO_AGENT_KEY,
|
|
9730
|
+
toolNames,
|
|
9731
|
+
env
|
|
9971
9732
|
});
|
|
9972
|
-
|
|
9973
|
-
(name) => toolNames.includes(name)
|
|
9974
|
-
);
|
|
9975
|
-
const platformTools = platformNames.length > 0 ? prepareTools([...platformNames]) : [];
|
|
9976
|
-
return estimateTokenCount(JSON.stringify([...workspaceTools, ...platformTools]));
|
|
9733
|
+
return estimateTokenCount(JSON.stringify(tools));
|
|
9977
9734
|
}
|
|
9978
9735
|
function buildCliEstimateSystemText(opts = {}) {
|
|
9979
9736
|
const cwd = opts.cwd?.trim() || process.cwd();
|
|
@@ -9981,16 +9738,11 @@ function buildCliEstimateSystemText(opts = {}) {
|
|
|
9981
9738
|
const agentName = opts.agentName?.trim() || BUILTIN_NOLO_AGENT_NAME;
|
|
9982
9739
|
const agentKey = opts.agentKey?.trim() || BUILTIN_NOLO_AGENT_KEY;
|
|
9983
9740
|
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
|
-
]);
|
|
9741
|
+
const toolNames = resolveDefaultCliToolNames(resolveEstimateEnv(opts.env));
|
|
9991
9742
|
const guidance = buildRuntimeGuidanceBlocks(toolNames);
|
|
9992
9743
|
const toolSections = resolveToolGuidedSections(toolNames, {
|
|
9993
|
-
callerModel: opts.model?.trim() || void 0
|
|
9744
|
+
callerModel: opts.model?.trim() || void 0,
|
|
9745
|
+
callerIsPoolTop: opts.callerIsPoolTop
|
|
9994
9746
|
});
|
|
9995
9747
|
const responseGuidelines = resolveResponseGuidelines(
|
|
9996
9748
|
opts.responseViewport ?? "unknown"
|
|
@@ -10020,12 +9772,10 @@ function buildCliEstimateSystemText(opts = {}) {
|
|
|
10020
9772
|
return systemParts.filter((part) => part?.trim()).join("\n\n");
|
|
10021
9773
|
}
|
|
10022
9774
|
function estimateDefaultCliContextTokens(opts = {}) {
|
|
10023
|
-
const
|
|
10024
|
-
|
|
10025
|
-
...DEFAULT_CLI_PLATFORM_TOOLS
|
|
10026
|
-
]);
|
|
9775
|
+
const env = resolveEstimateEnv(opts.env);
|
|
9776
|
+
const toolNames = resolveDefaultCliToolNames(env);
|
|
10027
9777
|
const systemTokens = estimateTokenCount(buildCliEstimateSystemText(opts));
|
|
10028
|
-
const toolTokens = estimateToolSchemas(toolNames);
|
|
9778
|
+
const toolTokens = estimateToolSchemas(toolNames, env);
|
|
10029
9779
|
const historyTokens = opts.messages && opts.messages.length > 0 ? estimateMessagesTokens(opts.messages) : opts.historyText ? estimateTokenCount(opts.historyText) : 0;
|
|
10030
9780
|
return Math.max(0, systemTokens + toolTokens + historyTokens);
|
|
10031
9781
|
}
|
|
@@ -10109,7 +9859,7 @@ function renderPermissionGrantChip(state) {
|
|
|
10109
9859
|
}
|
|
10110
9860
|
function renderStatusLine(state, maxWidth) {
|
|
10111
9861
|
const colorEnabled = resolveCliColorEnabled();
|
|
10112
|
-
const
|
|
9862
|
+
const sep2 = themeText(" \xB7 ", "chrome", colorEnabled);
|
|
10113
9863
|
const agentDisplayName = state.agentName;
|
|
10114
9864
|
const modeSuffix = state.modeLabel && state.modeLabel !== "auto" ? ` \xB7 ${state.modeLabel}` : "";
|
|
10115
9865
|
const agentLabel = `\u2726 ${agentDisplayName}${modeSuffix}`;
|
|
@@ -10266,7 +10016,7 @@ function renderStatusLine(state, maxWidth) {
|
|
|
10266
10016
|
visibleParts = fitted ? [fitted.join(" ")] : [overflowMark];
|
|
10267
10017
|
}
|
|
10268
10018
|
}
|
|
10269
|
-
let body = visibleParts.filter(Boolean).join(
|
|
10019
|
+
let body = visibleParts.filter(Boolean).join(sep2);
|
|
10270
10020
|
if (maxWidth && maxWidth > 0) {
|
|
10271
10021
|
const budget = Math.max(0, maxWidth - padWidth);
|
|
10272
10022
|
if (displayWidth(stripAnsi(body)) > budget) {
|
|
@@ -10578,6 +10328,9 @@ function createInitialTuiState(env = process.env) {
|
|
|
10578
10328
|
agentKey,
|
|
10579
10329
|
userLanguage: asOptionalTrimmedString(env.NOLO_LANG),
|
|
10580
10330
|
responseViewport: TUI_RESPONSE_VIEWPORT,
|
|
10331
|
+
// 估算必须看运行时那同一份 env:`NOLO_EXPOSE_MCP_TOOLS=1` 会让 local 装配
|
|
10332
|
+
// 多出 3 个 MCP 工具 schema,估算器若只看写死的 wake 开关就会低报。
|
|
10333
|
+
env,
|
|
10581
10334
|
...resolveAgentModelIdentity({ agentKey, agentName })
|
|
10582
10335
|
})
|
|
10583
10336
|
};
|
|
@@ -10812,8 +10565,8 @@ ${t("cdUsage")}`
|
|
|
10812
10565
|
};
|
|
10813
10566
|
}
|
|
10814
10567
|
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 =
|
|
10568
|
+
const expanded = unquoted === "~" ? homedir4() : unquoted.startsWith("~/") || unquoted.startsWith("~\\") ? resolve4(homedir4(), unquoted.slice(2)) : unquoted;
|
|
10569
|
+
const target = resolve4(state.cwd, expanded);
|
|
10817
10570
|
try {
|
|
10818
10571
|
if (!statSync5(target).isDirectory()) {
|
|
10819
10572
|
return { nextState: state, output: t("cdNotDir", target) };
|
|
@@ -11584,7 +11337,7 @@ async function probeTerminalBackground(args = {}) {
|
|
|
11584
11337
|
if (typeof stdin.setRawMode !== "function") return null;
|
|
11585
11338
|
if (!isTerminal(stdin)) return null;
|
|
11586
11339
|
const wasRaw = Boolean(stdin.isRaw);
|
|
11587
|
-
return await new Promise((
|
|
11340
|
+
return await new Promise((resolve5) => {
|
|
11588
11341
|
let buffer = "";
|
|
11589
11342
|
let settled = false;
|
|
11590
11343
|
let timer;
|
|
@@ -11602,7 +11355,7 @@ async function probeTerminalBackground(args = {}) {
|
|
|
11602
11355
|
if (!wasRaw) stdin.setRawMode?.(false);
|
|
11603
11356
|
} catch {
|
|
11604
11357
|
}
|
|
11605
|
-
|
|
11358
|
+
resolve5(result);
|
|
11606
11359
|
};
|
|
11607
11360
|
const onData = (chunk) => {
|
|
11608
11361
|
buffer += chunk.toString("latin1");
|
|
@@ -11809,13 +11562,13 @@ function startCiDeployEventStream(args) {
|
|
|
11809
11562
|
let controller = null;
|
|
11810
11563
|
const timers = /* @__PURE__ */ new Set();
|
|
11811
11564
|
const sleepWaiters = /* @__PURE__ */ new Set();
|
|
11812
|
-
const sleepWithRegisteredTimer = (ms) => new Promise((
|
|
11565
|
+
const sleepWithRegisteredTimer = (ms) => new Promise((resolve5) => {
|
|
11813
11566
|
let settled = false;
|
|
11814
11567
|
const wake = () => {
|
|
11815
11568
|
if (settled) return;
|
|
11816
11569
|
settled = true;
|
|
11817
11570
|
sleepWaiters.delete(wake);
|
|
11818
|
-
|
|
11571
|
+
resolve5();
|
|
11819
11572
|
};
|
|
11820
11573
|
const timer = setTimeout(() => {
|
|
11821
11574
|
timers.delete(timer);
|
|
@@ -12133,7 +11886,10 @@ function prepareChildRunConsumption(event, host) {
|
|
|
12133
11886
|
return {
|
|
12134
11887
|
...event,
|
|
12135
11888
|
runs: remainingRuns,
|
|
12136
|
-
text: buildWakeMessage(remainingRuns, now
|
|
11889
|
+
text: buildWakeMessage(remainingRuns, now, {
|
|
11890
|
+
// 与 run 注册表同一个有效 runs 目录(自定义 NOLO_HOME 也要内联)。
|
|
11891
|
+
trustedResultDirs: [resolveRunsDir(host.env)]
|
|
11892
|
+
}),
|
|
12137
11893
|
displayText: buildWakeDisplayText(remainingRuns, now)
|
|
12138
11894
|
};
|
|
12139
11895
|
}
|
|
@@ -12857,11 +12613,11 @@ async function runAskChoiceDialog(args) {
|
|
|
12857
12613
|
}
|
|
12858
12614
|
paint();
|
|
12859
12615
|
while (state.phase === "active") {
|
|
12860
|
-
const sequence = await new Promise((
|
|
12861
|
-
const abort = () =>
|
|
12616
|
+
const sequence = await new Promise((resolve5, reject) => {
|
|
12617
|
+
const abort = () => resolve5(STREAM_CLOSED);
|
|
12862
12618
|
if (request.signal?.aborted) return abort();
|
|
12863
12619
|
request.signal?.addEventListener("abort", abort, { once: true });
|
|
12864
|
-
Promise.resolve(readKey()).then(
|
|
12620
|
+
Promise.resolve(readKey()).then(resolve5, reject).finally(() => request.signal?.removeEventListener("abort", abort));
|
|
12865
12621
|
});
|
|
12866
12622
|
if (sequence === STREAM_CLOSED) {
|
|
12867
12623
|
state = askChoiceReducer(state, { type: "CANCEL" });
|
|
@@ -13785,12 +13541,12 @@ async function detectTrailingSilenceSuggestion(filePath, durationSec, opts = {})
|
|
|
13785
13541
|
"-"
|
|
13786
13542
|
];
|
|
13787
13543
|
try {
|
|
13788
|
-
const stderr = await new Promise((
|
|
13544
|
+
const stderr = await new Promise((resolve5, reject) => {
|
|
13789
13545
|
runner(
|
|
13790
13546
|
opts.ffmpegPath ?? resolveFfmpegPath(),
|
|
13791
13547
|
args,
|
|
13792
13548
|
{ encoding: "utf8", maxBuffer: 16 * 1024 * 1024 },
|
|
13793
|
-
(error, _stdout, stderrText) => error ? reject(error) :
|
|
13549
|
+
(error, _stdout, stderrText) => error ? reject(error) : resolve5(String(stderrText ?? ""))
|
|
13794
13550
|
);
|
|
13795
13551
|
});
|
|
13796
13552
|
return buildTrailingSilenceSuggestion(
|
|
@@ -14960,7 +14716,10 @@ async function runAgentChat(scriptDir, state, message, env, output, agentRunner
|
|
|
14960
14716
|
(r) => !!r.parentDialogId && r.parentDialogId === state.dialogId
|
|
14961
14717
|
);
|
|
14962
14718
|
const childRunNoticeBlocks = injectedChildRunNoticeItems.length > 0 ? [{
|
|
14963
|
-
content: buildWakeMessage(injectedChildRunNoticeItems, Date.now()
|
|
14719
|
+
content: buildWakeMessage(injectedChildRunNoticeItems, Date.now(), {
|
|
14720
|
+
// WAKE-003-CONFIG:与 run 注册表同一有效 runs 目录(尊重自定义 NOLO_HOME)。
|
|
14721
|
+
trustedResultDirs: [resolveRunsDir(env)]
|
|
14722
|
+
}),
|
|
14964
14723
|
cacheScope: "turn"
|
|
14965
14724
|
}] : [];
|
|
14966
14725
|
const contextBlockScopes = partitionScopedBlocks([
|
|
@@ -15161,14 +14920,14 @@ function waitForActionGate(rl, input, output, gate, spawnRunner) {
|
|
|
15161
14920
|
const meta = deriveGateMeta(gate);
|
|
15162
14921
|
const { commandPayload, isConfirmation, displayCommand } = meta;
|
|
15163
14922
|
writeGatePrompt(output, meta);
|
|
15164
|
-
return new Promise((
|
|
14923
|
+
return new Promise((resolve5) => {
|
|
15165
14924
|
let settled = false;
|
|
15166
14925
|
const finish = (result) => {
|
|
15167
14926
|
if (settled) return;
|
|
15168
14927
|
settled = true;
|
|
15169
14928
|
rl.off("close", onClose);
|
|
15170
14929
|
rl.off("SIGINT", onSigint);
|
|
15171
|
-
|
|
14930
|
+
resolve5(result);
|
|
15172
14931
|
};
|
|
15173
14932
|
const cancelResult = (reason) => buildGateCancelledResult(gate, reason);
|
|
15174
14933
|
const failResult = (message) => buildGateFailedResult(gate, message);
|
|
@@ -15232,7 +14991,7 @@ function waitForRawActionGate(input, output, gate, spawnRunner, hooks) {
|
|
|
15232
14991
|
const meta = deriveGateMeta(gate);
|
|
15233
14992
|
const { commandPayload, isConfirmation, displayCommand } = meta;
|
|
15234
14993
|
writeGatePrompt(output, meta);
|
|
15235
|
-
return new Promise((
|
|
14994
|
+
return new Promise((resolve5) => {
|
|
15236
14995
|
const rawInput = input;
|
|
15237
14996
|
let settled = false;
|
|
15238
14997
|
let commandRunning = false;
|
|
@@ -15244,7 +15003,7 @@ function waitForRawActionGate(input, output, gate, spawnRunner, hooks) {
|
|
|
15244
15003
|
input.off("data", onData);
|
|
15245
15004
|
input.off?.("end", onEnd);
|
|
15246
15005
|
input.off?.("close", onEnd);
|
|
15247
|
-
|
|
15006
|
+
resolve5(result);
|
|
15248
15007
|
};
|
|
15249
15008
|
const cancel = (reason) => finish(buildGateCancelledResult(gate, reason));
|
|
15250
15009
|
const fail = (message) => finish(buildGateFailedResult(gate, message));
|
|
@@ -15475,14 +15234,14 @@ function buildWakeRetryContinuationMessage(event) {
|
|
|
15475
15234
|
}
|
|
15476
15235
|
function waitForWakeRetryBackoff(delayMs, signal) {
|
|
15477
15236
|
if (delayMs <= 0 || signal?.aborted) return Promise.resolve();
|
|
15478
|
-
return new Promise((
|
|
15237
|
+
return new Promise((resolve5) => {
|
|
15479
15238
|
const onAbort = () => {
|
|
15480
15239
|
clearTimeout(timer);
|
|
15481
|
-
|
|
15240
|
+
resolve5();
|
|
15482
15241
|
};
|
|
15483
15242
|
const timer = setTimeout(() => {
|
|
15484
15243
|
signal?.removeEventListener("abort", onAbort);
|
|
15485
|
-
|
|
15244
|
+
resolve5();
|
|
15486
15245
|
}, delayMs);
|
|
15487
15246
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
15488
15247
|
});
|
|
@@ -15560,7 +15319,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
|
|
|
15560
15319
|
if (!approved) return false;
|
|
15561
15320
|
const commandText = typeof request.command === "string" ? request.command : "";
|
|
15562
15321
|
if (commandText) {
|
|
15563
|
-
const { runApprovedCredentialCommand } = await import("./hostCredentialCreate-
|
|
15322
|
+
const { runApprovedCredentialCommand } = await import("./hostCredentialCreate-V5EDFPAV.js");
|
|
15564
15323
|
const hostResult = await runApprovedCredentialCommand({
|
|
15565
15324
|
commandText,
|
|
15566
15325
|
approvalEventId: request.id,
|
|
@@ -17711,7 +17470,7 @@ async function compactDialog(options) {
|
|
|
17711
17470
|
fetchImpl,
|
|
17712
17471
|
agentRef: getActiveDialogAgentId(current) ?? void 0,
|
|
17713
17472
|
loadAdapter: async () => {
|
|
17714
|
-
const { createCliLocalRuntimeAdapter: createCliLocalRuntimeAdapter2 } = await import("./localRuntimeAdapter-
|
|
17473
|
+
const { createCliLocalRuntimeAdapter: createCliLocalRuntimeAdapter2 } = await import("./localRuntimeAdapter-VMGFXQOJ.js");
|
|
17715
17474
|
return createCliLocalRuntimeAdapter2({ env: { ...options.env ?? {}, AUTH_TOKEN: options.authToken, NOLO_SERVER: options.serverUrl }, fetchImpl });
|
|
17716
17475
|
}
|
|
17717
17476
|
}) : void 0);
|
|
@@ -19518,7 +19277,7 @@ async function runTuiWorkspace(options) {
|
|
|
19518
19277
|
titleAnimTimer.unref?.();
|
|
19519
19278
|
}
|
|
19520
19279
|
const rawDialogLabel = state.dialogLabel?.trim();
|
|
19521
|
-
const rawLabel = !rawDialogLabel || rawDialogLabel === "new" ?
|
|
19280
|
+
const rawLabel = !rawDialogLabel || rawDialogLabel === "new" ? basename2(state.cwd) || "Nolo" : rawDialogLabel;
|
|
19522
19281
|
const label = stripAnsi(rawLabel).replace(/[\x00-\x1f\x7f-\x9f]+/g, " ");
|
|
19523
19282
|
const frame = ACTIVITY_FRAMES[titleFrameIndex % ACTIVITY_FRAMES.length];
|
|
19524
19283
|
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";
|
|
@@ -20845,7 +20604,7 @@ ${lines}` : lines;
|
|
|
20845
20604
|
onApprove: createSnapshotGuardedApproval("local", () => state.permissionGrants, approveLocalConfirms),
|
|
20846
20605
|
onApproved: async (approvedGate) => {
|
|
20847
20606
|
if (approvedGate.kind !== "confirm") return null;
|
|
20848
|
-
const { executeApprovedCredentialCreate } = await import("./hostCredentialCreate-
|
|
20607
|
+
const { executeApprovedCredentialCreate } = await import("./hostCredentialCreate-V5EDFPAV.js");
|
|
20849
20608
|
const hostResult = await executeApprovedCredentialCreate({
|
|
20850
20609
|
gate: approvedGate,
|
|
20851
20610
|
approvalGateId: approvedGate.id,
|
|
@@ -22060,9 +21819,9 @@ ${themeText(`! ${error instanceof Error ? error.message : String(error)}`, "dang
|
|
|
22060
21819
|
fixedInput.repaint(buffer, cursorPos);
|
|
22061
21820
|
if (!sawOsc11Reply && isTerminalDevice(input) && !isPtyxisTerminal()) requestTerminalBackgroundQuery();
|
|
22062
21821
|
refreshGitStatus();
|
|
22063
|
-
await new Promise((
|
|
22064
|
-
resolveDone =
|
|
22065
|
-
if (done)
|
|
21822
|
+
await new Promise((resolve5) => {
|
|
21823
|
+
resolveDone = resolve5;
|
|
21824
|
+
if (done) resolve5();
|
|
22066
21825
|
});
|
|
22067
21826
|
} finally {
|
|
22068
21827
|
finish();
|