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
|
@@ -12,10 +12,6 @@ import {
|
|
|
12
12
|
formatImageSummary,
|
|
13
13
|
readLocalImage
|
|
14
14
|
} from "./chunk-AL3TYDIF.js";
|
|
15
|
-
import {
|
|
16
|
-
evaluateFileWritePolicy,
|
|
17
|
-
summarizeToolArguments
|
|
18
|
-
} from "./chunk-CHOZJMJS.js";
|
|
19
15
|
import {
|
|
20
16
|
applyChatCompletionDelta,
|
|
21
17
|
applyResponsesToolEvent,
|
|
@@ -28,6 +24,10 @@ import {
|
|
|
28
24
|
import {
|
|
29
25
|
readSseFrames
|
|
30
26
|
} from "./chunk-HNUWUO75.js";
|
|
27
|
+
import {
|
|
28
|
+
evaluateFileWritePolicy,
|
|
29
|
+
summarizeToolArguments
|
|
30
|
+
} from "./chunk-CHOZJMJS.js";
|
|
31
31
|
import {
|
|
32
32
|
resolveToolExecutionContract
|
|
33
33
|
} from "./chunk-DMPZMYH4.js";
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
evaluateRequestBudget,
|
|
36
36
|
hasImageInRuntimeMessages,
|
|
37
37
|
stripImagePartsFromMessages
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-MLK3FEXG.js";
|
|
39
39
|
import {
|
|
40
40
|
resolveAgentImageInputSupport,
|
|
41
41
|
resolveToolImagePolicy
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
projectUserPartForModel,
|
|
51
51
|
resolveOutboundDiagnosticSink,
|
|
52
52
|
writeThinkingFacts
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-AIFQKNPP.js";
|
|
54
54
|
import {
|
|
55
55
|
createThinkParserState,
|
|
56
56
|
createToolCallAccumulator,
|
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
hashStablePrefixContent,
|
|
73
73
|
resolveResponseGuidelines,
|
|
74
74
|
resolveToolGuidedSections
|
|
75
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-BXGU6274.js";
|
|
76
76
|
import {
|
|
77
77
|
BRIDGE_STREAM_MAX_CHARS,
|
|
78
78
|
CLI_NOLO_WORKSPACE_TOOL_NAMES,
|
|
@@ -86,9 +86,8 @@ import {
|
|
|
86
86
|
noloStringArg,
|
|
87
87
|
parseNoloWorkspaceToolArguments,
|
|
88
88
|
readTextStreamUpToChars,
|
|
89
|
-
resolveModelTier,
|
|
90
89
|
resolveNoloDialogInput
|
|
91
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-Q2MPKE4B.js";
|
|
92
91
|
import {
|
|
93
92
|
classifyUnparsableToolArgs,
|
|
94
93
|
collectStablePromptPrefix,
|
|
@@ -131,8 +130,10 @@ import {
|
|
|
131
130
|
isQuotaExhaustedError
|
|
132
131
|
} from "./chunk-TLE77UJ5.js";
|
|
133
132
|
import {
|
|
133
|
+
MAX_CONTROL_SEQUENCE_CHARS,
|
|
134
134
|
PROJECT_INSTRUCTION_MAX_BYTES,
|
|
135
135
|
PROJECT_INSTRUCTION_MAX_CHARS,
|
|
136
|
+
SANITIZE_REPLACEMENT_CHAR,
|
|
136
137
|
SECRET_PATTERNS,
|
|
137
138
|
clipToolText,
|
|
138
139
|
hasPotentialSecrets,
|
|
@@ -144,7 +145,7 @@ import {
|
|
|
144
145
|
sanitizeToolOutputText,
|
|
145
146
|
scrubObjectSecrets,
|
|
146
147
|
scrubSecrets
|
|
147
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-KO5GO2BC.js";
|
|
148
149
|
import {
|
|
149
150
|
buildDialogFallbackTitleFromUserInput
|
|
150
151
|
} from "./chunk-2MBTWINN.js";
|
|
@@ -156,7 +157,7 @@ import {
|
|
|
156
157
|
resolveEmptyAssistantFallbackMessage,
|
|
157
158
|
resolveEmptyAssistantOutcome,
|
|
158
159
|
resolveTruncatedReasoningTailLog
|
|
159
|
-
} from "./chunk-
|
|
160
|
+
} from "./chunk-7WHCIA5V.js";
|
|
160
161
|
import {
|
|
161
162
|
COMPACTION_SUMMARY_SCHEMA_VERSION,
|
|
162
163
|
COMPACTION_SUMMARY_SYSTEM_PROMPT,
|
|
@@ -189,12 +190,12 @@ import {
|
|
|
189
190
|
observeMeaningfulProviderResponse,
|
|
190
191
|
withProviderCallTimingFields
|
|
191
192
|
} from "./chunk-H57T64RA.js";
|
|
192
|
-
import {
|
|
193
|
-
clipCompactText
|
|
194
|
-
} from "./chunk-5MMAK75Q.js";
|
|
195
193
|
import {
|
|
196
194
|
sha256Hex
|
|
197
195
|
} from "./chunk-SR4FE5VD.js";
|
|
196
|
+
import {
|
|
197
|
+
clipCompactText
|
|
198
|
+
} from "./chunk-5MMAK75Q.js";
|
|
198
199
|
import {
|
|
199
200
|
asRecordOrEmpty
|
|
200
201
|
} from "./chunk-KX6YBIHG.js";
|
|
@@ -226,7 +227,10 @@ import {
|
|
|
226
227
|
toProcessTaskView,
|
|
227
228
|
truncateToolOutput,
|
|
228
229
|
workspaceChildEnv
|
|
229
|
-
} from "./chunk-
|
|
230
|
+
} from "./chunk-6N4IKMTH.js";
|
|
231
|
+
import {
|
|
232
|
+
resolveModelTier
|
|
233
|
+
} from "./chunk-HEVRQGGH.js";
|
|
230
234
|
import {
|
|
231
235
|
estimateTokenCount
|
|
232
236
|
} from "./chunk-PSCNXBYA.js";
|
|
@@ -244,11 +248,11 @@ import {
|
|
|
244
248
|
buildAgentsMdLayerHeader,
|
|
245
249
|
buildDialogSummaryLayer,
|
|
246
250
|
hasMemoryTools
|
|
247
|
-
} from "./chunk-
|
|
251
|
+
} from "./chunk-YQLAFJRQ.js";
|
|
248
252
|
import {
|
|
249
253
|
MEMORY_USE_GUIDANCE,
|
|
250
254
|
buildUserResponseLanguageContext
|
|
251
|
-
} from "./chunk-
|
|
255
|
+
} from "./chunk-GYX6XTAI.js";
|
|
252
256
|
import {
|
|
253
257
|
resolveNoloStateDir
|
|
254
258
|
} from "./chunk-6UBGXX2W.js";
|
|
@@ -264,7 +268,7 @@ import {
|
|
|
264
268
|
} from "./chunk-OJKUU3LP.js";
|
|
265
269
|
import {
|
|
266
270
|
resolveLocalUserId
|
|
267
|
-
} from "./chunk-
|
|
271
|
+
} from "./chunk-QGFLVQ6E.js";
|
|
268
272
|
import {
|
|
269
273
|
applyToolSurfaceConstraints
|
|
270
274
|
} from "./chunk-JCQ3WCQ3.js";
|
|
@@ -913,7 +917,7 @@ function buildExecShellToolDefinition(toolName = "execShell") {
|
|
|
913
917
|
type: "function",
|
|
914
918
|
function: {
|
|
915
919
|
name: toolName,
|
|
916
|
-
description: `Execute a shell command from the workspace root. Prefer one compound command (e.g. 'git status && git diff --stat') to
|
|
920
|
+
description: `Execute a shell command from the workspace root. Prefer one compound command (e.g. 'git status && git diff --stat') to finish verification in one step; do not cd into guessed paths. Commands block until exit; long-running ones (sleep over ${IMMEDIATE_DETACH_SLEEP_THRESHOLD_SECONDS}s, dev servers, watchers) auto-detach returning {detached: true, pid, label}; for persistent services prefer launchProcess.${WINDOWS_SHELL_NOTE} LIFECYCLE: (1) A normal command waits synchronously for at most 120 seconds; a result carrying exitCode means it already finished \u2014 parse it immediately, never read it as "still running". (2) Only metadata.detached === true AND a taskId yields an automatic completion turn; that taskId is NOT a file path and NOT a result file \u2014 never rerun the command just to obtain its output; that turn delivers the result inline, and when truncated it carries a full-output path in its overflow marker, read it with readFile only when present; meanwhile continue independent work on other parts of the task. (3) Text the command itself prints (STARTED, ...) has zero lifecycle meaning. (4) Shell-level backgrounding (&, nohup, disown, setsid, Start-Process) is NOT tracked: no completion notice. Use background: true to make a finite job tracked; no standalone sleeps to pause. When a synchronous result's core output was redirected to a file, read it in the same turn.`,
|
|
917
921
|
parameters: {
|
|
918
922
|
type: "object",
|
|
919
923
|
properties: {
|
|
@@ -1339,6 +1343,38 @@ ${entry.line}`;
|
|
|
1339
1343
|
}
|
|
1340
1344
|
return rendered;
|
|
1341
1345
|
};
|
|
1346
|
+
function buildAgentsMdLayerFromContent(raw, name, filePath) {
|
|
1347
|
+
const content = raw.trim();
|
|
1348
|
+
if (!content) return null;
|
|
1349
|
+
const totalBytes = Buffer.byteLength(raw, "utf8");
|
|
1350
|
+
const trimmedBytes = Buffer.byteLength(content, "utf8");
|
|
1351
|
+
const headerBytes = Buffer.byteLength(buildAgentsMdLayerHeader(name), "utf8");
|
|
1352
|
+
if (headerBytes + trimmedBytes <= AGENTS_MD_MAX_BYTES) {
|
|
1353
|
+
return buildAgentsMdLayer(content, name);
|
|
1354
|
+
}
|
|
1355
|
+
const summaryBody = buildAgentsMdSummaryBody(content, filePath, {
|
|
1356
|
+
// 正文预算 = 摘要上限 − 块头部:buildAgentsMdLayer 会再拼一次头部,
|
|
1357
|
+
// 因此「头部 + 正文」才等于最终注入字节,不得超过摘要上限。
|
|
1358
|
+
budgetBytes: AGENTS_MD_SUMMARY_MAX_BYTES - headerBytes,
|
|
1359
|
+
fileName: name
|
|
1360
|
+
});
|
|
1361
|
+
if (summaryBody) return buildAgentsMdLayer(summaryBody, name);
|
|
1362
|
+
const buildMarker = (omitted2, withPath) => {
|
|
1363
|
+
const pathPart = withPath ? `\u5B8C\u6574\u6587\u4EF6\uFF1A${filePath}` : `\u5B8C\u6574\u6587\u4EF6\uFF1A\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7684 ${name}`;
|
|
1364
|
+
return `<!-- AGENTS.md truncated: \u539F\u6587\u4EF6 ${totalBytes} \u5B57\u8282\uFF0C\u6CE8\u5165\u9884\u7B97 ${AGENTS_MD_MAX_BYTES} \u5B57\u8282\uFF0C\u5DF2\u7701\u7565 ${omitted2} \u5B57\u8282\uFF08\u4E0A\u6587\u53EF\u80FD\u7F3A\u5C11\u6587\u4EF6\u672B\u5C3E\u7684 commit/review \u95E8\u7981\u7EC6\u5219\uFF0C\u63D0\u4EA4/\u8BC4\u5BA1\u524D\u8BF7\u8BFB\u5B8C\u6574\u6587\u4EF6\uFF09\u3002${pathPart} -->`;
|
|
1365
|
+
};
|
|
1366
|
+
const bodyBudget = AGENTS_MD_MAX_BYTES - AGENTS_MD_MARKER_RESERVE_BYTES - 2 - headerBytes;
|
|
1367
|
+
const body = truncateAgentsMdContent(content, bodyBudget);
|
|
1368
|
+
const bodyBytes = Buffer.byteLength(body, "utf8");
|
|
1369
|
+
const omitted = Math.max(0, totalBytes - bodyBytes);
|
|
1370
|
+
let marker = buildMarker(omitted, true);
|
|
1371
|
+
if (Buffer.byteLength(marker, "utf8") > AGENTS_MD_MARKER_RESERVE_BYTES) {
|
|
1372
|
+
marker = buildMarker(omitted, false);
|
|
1373
|
+
}
|
|
1374
|
+
return buildAgentsMdLayer(`${body}
|
|
1375
|
+
|
|
1376
|
+
${marker}`, name);
|
|
1377
|
+
}
|
|
1342
1378
|
function readAgentsMdLayerFromDisk(cwd) {
|
|
1343
1379
|
if (!cwd) return null;
|
|
1344
1380
|
let root;
|
|
@@ -1357,34 +1393,7 @@ function readAgentsMdLayerFromDisk(cwd) {
|
|
|
1357
1393
|
const raw = readFileSync(target, "utf8");
|
|
1358
1394
|
const content = raw.trim();
|
|
1359
1395
|
if (!content) continue;
|
|
1360
|
-
|
|
1361
|
-
const trimmedBytes = Buffer.byteLength(content, "utf8");
|
|
1362
|
-
const headerBytes = Buffer.byteLength(buildAgentsMdLayerHeader(name), "utf8");
|
|
1363
|
-
if (headerBytes + trimmedBytes <= AGENTS_MD_MAX_BYTES) {
|
|
1364
|
-
return buildAgentsMdLayer(content, name);
|
|
1365
|
-
}
|
|
1366
|
-
const summaryBody = buildAgentsMdSummaryBody(content, filePath, {
|
|
1367
|
-
// 正文预算 = 摘要上限 − 块头部:buildAgentsMdLayer 会再拼一次头部,
|
|
1368
|
-
// 因此「头部 + 正文」才等于最终注入字节,不得超过摘要上限。
|
|
1369
|
-
budgetBytes: AGENTS_MD_SUMMARY_MAX_BYTES - headerBytes,
|
|
1370
|
-
fileName: name
|
|
1371
|
-
});
|
|
1372
|
-
if (summaryBody) return buildAgentsMdLayer(summaryBody, name);
|
|
1373
|
-
const buildMarker = (omitted2, withPath) => {
|
|
1374
|
-
const pathPart = withPath ? `\u5B8C\u6574\u6587\u4EF6\uFF1A${filePath}` : `\u5B8C\u6574\u6587\u4EF6\uFF1A\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7684 ${name}`;
|
|
1375
|
-
return `<!-- AGENTS.md truncated: \u539F\u6587\u4EF6 ${totalBytes} \u5B57\u8282\uFF0C\u6CE8\u5165\u9884\u7B97 ${AGENTS_MD_MAX_BYTES} \u5B57\u8282\uFF0C\u5DF2\u7701\u7565 ${omitted2} \u5B57\u8282\uFF08\u4E0A\u6587\u53EF\u80FD\u7F3A\u5C11\u6587\u4EF6\u672B\u5C3E\u7684 commit/review \u95E8\u7981\u7EC6\u5219\uFF0C\u63D0\u4EA4/\u8BC4\u5BA1\u524D\u8BF7\u8BFB\u5B8C\u6574\u6587\u4EF6\uFF09\u3002${pathPart} -->`;
|
|
1376
|
-
};
|
|
1377
|
-
const bodyBudget = AGENTS_MD_MAX_BYTES - AGENTS_MD_MARKER_RESERVE_BYTES - 2 - headerBytes;
|
|
1378
|
-
const body = truncateAgentsMdContent(content, bodyBudget);
|
|
1379
|
-
const bodyBytes = Buffer.byteLength(body, "utf8");
|
|
1380
|
-
const omitted = Math.max(0, totalBytes - bodyBytes);
|
|
1381
|
-
let marker = buildMarker(omitted, true);
|
|
1382
|
-
if (Buffer.byteLength(marker, "utf8") > AGENTS_MD_MARKER_RESERVE_BYTES) {
|
|
1383
|
-
marker = buildMarker(omitted, false);
|
|
1384
|
-
}
|
|
1385
|
-
return buildAgentsMdLayer(`${body}
|
|
1386
|
-
|
|
1387
|
-
${marker}`, name);
|
|
1396
|
+
return buildAgentsMdLayerFromContent(raw, name, filePath);
|
|
1388
1397
|
} catch {
|
|
1389
1398
|
}
|
|
1390
1399
|
}
|
|
@@ -2899,135 +2908,1833 @@ function runTasks(args2) {
|
|
|
2899
2908
|
return { tasks, count: tasks.length };
|
|
2900
2909
|
}
|
|
2901
2910
|
|
|
2902
|
-
// packages/agent-runtime/
|
|
2903
|
-
var
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
];
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
description: "Path relative to the workspace root. Absolute paths and ~/ (home directory) are also accepted. Defaults to workspace root when omitted."
|
|
2911
|
+
// packages/agent-runtime/linearRegex.ts
|
|
2912
|
+
var LINEAR_REGEX_MAX_PATTERN_LENGTH = 512;
|
|
2913
|
+
var LINEAR_REGEX_MAX_STATES = 512;
|
|
2914
|
+
var LINEAR_REGEX_MAX_REPEAT = 64;
|
|
2915
|
+
var LINEAR_REGEX_MAX_LINE_SCAN_CHARS = 8192;
|
|
2916
|
+
var LINEAR_REGEX_MAX_STEPS = 1e6;
|
|
2917
|
+
function codeIsDigit(code) {
|
|
2918
|
+
return code >= 48 && code <= 57;
|
|
2919
|
+
}
|
|
2920
|
+
function codeIsWord(code) {
|
|
2921
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code === 95 || code >= 97 && code <= 122;
|
|
2922
|
+
}
|
|
2923
|
+
function codeIsSpace(code) {
|
|
2924
|
+
return code === 32 || code === 9 || code === 10 || code === 11 || code === 12 || code === 13 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
|
|
2925
|
+
}
|
|
2926
|
+
function codeIsAnyExceptLineTerminator(code) {
|
|
2927
|
+
return code !== 10 && code !== 13;
|
|
2928
|
+
}
|
|
2929
|
+
function charEquals(expected) {
|
|
2930
|
+
return (code) => code === expected;
|
|
2931
|
+
}
|
|
2932
|
+
function unionPredicates(predicates) {
|
|
2933
|
+
if (predicates.length === 0) return () => false;
|
|
2934
|
+
if (predicates.length === 1) return predicates[0];
|
|
2935
|
+
return (code) => {
|
|
2936
|
+
for (const predicate of predicates) {
|
|
2937
|
+
if (predicate(code)) return true;
|
|
2938
|
+
}
|
|
2939
|
+
return false;
|
|
2932
2940
|
};
|
|
2933
2941
|
}
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
}
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2942
|
+
var LinearRegexError = class extends Error {
|
|
2943
|
+
};
|
|
2944
|
+
var EMPTY_AST = { type: "empty" };
|
|
2945
|
+
var PatternParser = class {
|
|
2946
|
+
constructor(source) {
|
|
2947
|
+
this.source = source;
|
|
2948
|
+
}
|
|
2949
|
+
i = 0;
|
|
2950
|
+
parse() {
|
|
2951
|
+
const node = this.parseAlternation();
|
|
2952
|
+
if (this.i < this.source.length) {
|
|
2953
|
+
const rest = this.source[this.i];
|
|
2954
|
+
throw new LinearRegexError(
|
|
2955
|
+
rest === ")" ? `unmatched ")" at position ${this.i}` : `unexpected "${rest}" at position ${this.i}`
|
|
2956
|
+
);
|
|
2957
|
+
}
|
|
2958
|
+
return node;
|
|
2959
|
+
}
|
|
2960
|
+
peek(offset = 0) {
|
|
2961
|
+
return this.source[this.i + offset];
|
|
2962
|
+
}
|
|
2963
|
+
parseAlternation() {
|
|
2964
|
+
const options = [this.parseSequence()];
|
|
2965
|
+
while (this.peek() === "|") {
|
|
2966
|
+
this.i += 1;
|
|
2967
|
+
options.push(this.parseSequence());
|
|
2968
|
+
}
|
|
2969
|
+
return options.length === 1 ? options[0] : { type: "alt", options };
|
|
2970
|
+
}
|
|
2971
|
+
parseSequence() {
|
|
2972
|
+
const items = [];
|
|
2973
|
+
while (this.i < this.source.length) {
|
|
2974
|
+
const c = this.source[this.i];
|
|
2975
|
+
if (c === "|" || c === ")") break;
|
|
2976
|
+
items.push(this.parseQuantified());
|
|
2977
|
+
}
|
|
2978
|
+
if (items.length === 0) return EMPTY_AST;
|
|
2979
|
+
return items.length === 1 ? items[0] : { type: "seq", items };
|
|
2980
|
+
}
|
|
2981
|
+
parseQuantified() {
|
|
2982
|
+
const atom = this.parseAtom();
|
|
2983
|
+
const c = this.peek();
|
|
2984
|
+
let min4;
|
|
2985
|
+
let max4;
|
|
2986
|
+
if (c === "*") {
|
|
2987
|
+
min4 = 0;
|
|
2988
|
+
max4 = Number.POSITIVE_INFINITY;
|
|
2989
|
+
this.i += 1;
|
|
2990
|
+
} else if (c === "+") {
|
|
2991
|
+
min4 = 1;
|
|
2992
|
+
max4 = Number.POSITIVE_INFINITY;
|
|
2993
|
+
this.i += 1;
|
|
2994
|
+
} else if (c === "?") {
|
|
2995
|
+
min4 = 0;
|
|
2996
|
+
max4 = 1;
|
|
2997
|
+
this.i += 1;
|
|
2998
|
+
} else if (c === "{") {
|
|
2999
|
+
const quantifier = this.tryParseBraceQuantifier();
|
|
3000
|
+
if (!quantifier) return atom;
|
|
3001
|
+
min4 = quantifier.min;
|
|
3002
|
+
max4 = quantifier.max;
|
|
3003
|
+
} else {
|
|
3004
|
+
return atom;
|
|
3005
|
+
}
|
|
3006
|
+
if (this.peek() === "?") this.i += 1;
|
|
3007
|
+
return { type: "repeat", node: atom, min: min4, max: max4 };
|
|
3008
|
+
}
|
|
3009
|
+
tryParseBraceQuantifier() {
|
|
3010
|
+
const match7 = /^\{(\d+)(,(\d*))?\}/.exec(this.source.slice(this.i));
|
|
3011
|
+
if (!match7) return null;
|
|
3012
|
+
const min4 = Number(match7[1]);
|
|
3013
|
+
const hasComma = match7[2] !== void 0;
|
|
3014
|
+
const max4 = !hasComma ? min4 : match7[3] ? Number(match7[3]) : Number.POSITIVE_INFINITY;
|
|
3015
|
+
if (!Number.isSafeInteger(min4) || min4 > LINEAR_REGEX_MAX_REPEAT || max4 !== Number.POSITIVE_INFINITY && max4 > LINEAR_REGEX_MAX_REPEAT) {
|
|
3016
|
+
throw new LinearRegexError(
|
|
3017
|
+
`repetition count above ${LINEAR_REGEX_MAX_REPEAT} is not supported (bounded to keep matching linear-time)`
|
|
3018
|
+
);
|
|
3019
|
+
}
|
|
3020
|
+
if (max4 < min4) {
|
|
3021
|
+
throw new LinearRegexError(`invalid repetition range {${min4},${max4}}`);
|
|
3022
|
+
}
|
|
3023
|
+
this.i += match7[0].length;
|
|
3024
|
+
return { min: min4, max: max4 };
|
|
3025
|
+
}
|
|
3026
|
+
parseAtom() {
|
|
3027
|
+
const c = this.source[this.i];
|
|
3028
|
+
if (c === void 0) throw new LinearRegexError("unexpected end of pattern");
|
|
3029
|
+
if (c === "(") return this.parseGroup();
|
|
3030
|
+
if (c === "[") return this.parseCharClass();
|
|
3031
|
+
if (c === ".") {
|
|
3032
|
+
this.i += 1;
|
|
3033
|
+
return { type: "char", pred: codeIsAnyExceptLineTerminator };
|
|
3034
|
+
}
|
|
3035
|
+
if (c === "^") {
|
|
3036
|
+
this.i += 1;
|
|
3037
|
+
return { type: "lineStart" };
|
|
3038
|
+
}
|
|
3039
|
+
if (c === "$") {
|
|
3040
|
+
this.i += 1;
|
|
3041
|
+
return { type: "lineEnd" };
|
|
3042
|
+
}
|
|
3043
|
+
if (c === "\\") return this.parseEscapeAtom();
|
|
3044
|
+
if (c === "*" || c === "+" || c === "?") {
|
|
3045
|
+
throw new LinearRegexError(`nothing to repeat before "${c}" at position ${this.i}`);
|
|
3046
|
+
}
|
|
3047
|
+
if (c === ")") throw new LinearRegexError(`unmatched ")" at position ${this.i}`);
|
|
3048
|
+
this.i += 1;
|
|
3049
|
+
return { type: "char", pred: charEquals(c.charCodeAt(0)) };
|
|
3050
|
+
}
|
|
3051
|
+
parseGroup() {
|
|
3052
|
+
this.i += 1;
|
|
3053
|
+
if (this.peek() === "?") {
|
|
3054
|
+
const kind = this.peek(1);
|
|
3055
|
+
if (kind === ":") {
|
|
3056
|
+
this.i += 2;
|
|
3057
|
+
} else if (kind === "=" || kind === "!") {
|
|
3058
|
+
throw new LinearRegexError(
|
|
3059
|
+
"lookahead assertions ((?=...), (?!...)) are not supported; rewrite the pattern without lookahead"
|
|
3060
|
+
);
|
|
3061
|
+
} else if (kind === "<") {
|
|
3062
|
+
throw new LinearRegexError(
|
|
3063
|
+
"lookbehind assertions / named groups ((?<=...), (?<!...), (?<name>...)) are not supported"
|
|
3064
|
+
);
|
|
3065
|
+
} else {
|
|
3066
|
+
throw new LinearRegexError(`unsupported group syntax "(?${kind ?? ""}"`);
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
const inner = this.parseAlternation();
|
|
3070
|
+
if (this.peek() !== ")") throw new LinearRegexError('unclosed group: missing ")"');
|
|
3071
|
+
this.i += 1;
|
|
3072
|
+
return inner;
|
|
3073
|
+
}
|
|
3074
|
+
parseEscapeAtom() {
|
|
3075
|
+
const next = this.peek(1);
|
|
3076
|
+
if (next === void 0) throw new LinearRegexError("trailing backslash");
|
|
3077
|
+
const escaped = escapePredicate(next);
|
|
3078
|
+
this.i += 2;
|
|
3079
|
+
if (typeof escaped === "number") return { type: "char", pred: charEquals(escaped) };
|
|
3080
|
+
return { type: "char", pred: escaped };
|
|
3081
|
+
}
|
|
3082
|
+
parseCharClass() {
|
|
3083
|
+
this.i += 1;
|
|
3084
|
+
let negated = false;
|
|
3085
|
+
if (this.peek() === "^") {
|
|
3086
|
+
negated = true;
|
|
3087
|
+
this.i += 1;
|
|
3088
|
+
}
|
|
3089
|
+
const predicates = [];
|
|
3090
|
+
let first = true;
|
|
3091
|
+
let closed = false;
|
|
3092
|
+
while (this.i < this.source.length) {
|
|
3093
|
+
const c = this.source[this.i];
|
|
3094
|
+
if (c === "]" && !first) {
|
|
3095
|
+
this.i += 1;
|
|
3096
|
+
closed = true;
|
|
3097
|
+
break;
|
|
2956
3098
|
}
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
3099
|
+
first = false;
|
|
3100
|
+
const head3 = this.parseCharClassAtom();
|
|
3101
|
+
const isRange = this.peek() === "-" && this.peek(1) !== void 0 && this.peek(1) !== "]";
|
|
3102
|
+
if (isRange) {
|
|
3103
|
+
this.i += 1;
|
|
3104
|
+
const tail = this.parseCharClassAtom();
|
|
3105
|
+
if (head3.code !== void 0 && tail.code !== void 0) {
|
|
3106
|
+
const lo = Math.min(head3.code, tail.code);
|
|
3107
|
+
const hi = Math.max(head3.code, tail.code);
|
|
3108
|
+
predicates.push((code) => code >= lo && code <= hi);
|
|
3109
|
+
} else {
|
|
3110
|
+
predicates.push(head3.pred, tail.pred, charEquals(45));
|
|
3111
|
+
}
|
|
3112
|
+
continue;
|
|
3113
|
+
}
|
|
3114
|
+
predicates.push(head3.pred);
|
|
3115
|
+
}
|
|
3116
|
+
if (!closed) throw new LinearRegexError('unclosed character class: missing "]"');
|
|
3117
|
+
const union = unionPredicates(predicates);
|
|
3118
|
+
return { type: "char", pred: negated ? (code) => !union(code) : union };
|
|
3119
|
+
}
|
|
3120
|
+
parseCharClassAtom() {
|
|
3121
|
+
const c = this.source[this.i];
|
|
3122
|
+
if (c === void 0) throw new LinearRegexError('unclosed character class: missing "]"');
|
|
3123
|
+
if (c === "\\") {
|
|
3124
|
+
const next = this.peek(1);
|
|
3125
|
+
if (next === void 0) throw new LinearRegexError("trailing backslash in character class");
|
|
3126
|
+
const escaped = escapePredicate(next);
|
|
3127
|
+
this.i += 2;
|
|
3128
|
+
if (typeof escaped === "number") return { code: escaped, pred: charEquals(escaped) };
|
|
3129
|
+
return { pred: escaped };
|
|
3130
|
+
}
|
|
3131
|
+
this.i += 1;
|
|
3132
|
+
const code = c.charCodeAt(0);
|
|
3133
|
+
return { code, pred: charEquals(code) };
|
|
3134
|
+
}
|
|
3135
|
+
};
|
|
3136
|
+
function escapePredicate(next) {
|
|
3137
|
+
switch (next) {
|
|
3138
|
+
case "d":
|
|
3139
|
+
return codeIsDigit;
|
|
3140
|
+
case "D":
|
|
3141
|
+
return (code) => !codeIsDigit(code);
|
|
3142
|
+
case "w":
|
|
3143
|
+
return codeIsWord;
|
|
3144
|
+
case "W":
|
|
3145
|
+
return (code) => !codeIsWord(code);
|
|
3146
|
+
case "s":
|
|
3147
|
+
return codeIsSpace;
|
|
3148
|
+
case "S":
|
|
3149
|
+
return (code) => !codeIsSpace(code);
|
|
3150
|
+
case "n":
|
|
3151
|
+
return 10;
|
|
3152
|
+
case "r":
|
|
3153
|
+
return 13;
|
|
3154
|
+
case "t":
|
|
3155
|
+
return 9;
|
|
3156
|
+
case "f":
|
|
3157
|
+
return 12;
|
|
3158
|
+
case "v":
|
|
3159
|
+
return 11;
|
|
3160
|
+
case "0":
|
|
3161
|
+
return 0;
|
|
3162
|
+
case "b":
|
|
3163
|
+
case "B":
|
|
3164
|
+
throw new LinearRegexError(
|
|
3165
|
+
`word-boundary assertions (\\${next}) are not supported by the linear-time matcher`
|
|
3166
|
+
);
|
|
3167
|
+
case "k":
|
|
3168
|
+
throw new LinearRegexError("named backreferences (\\k<name>) are not supported");
|
|
3169
|
+
default:
|
|
3170
|
+
if (next >= "1" && next <= "9") {
|
|
3171
|
+
throw new LinearRegexError(
|
|
3172
|
+
`backreference \\${next} is not supported by the linear-time matcher`
|
|
3173
|
+
);
|
|
3174
|
+
}
|
|
3175
|
+
return next.charCodeAt(0);
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
var K_BYPASS = 0;
|
|
3179
|
+
var K_SPLIT = 1;
|
|
3180
|
+
var K_CHAR = 2;
|
|
3181
|
+
var K_ASSERT_LINE_START = 3;
|
|
3182
|
+
var K_ASSERT_LINE_END = 4;
|
|
3183
|
+
var K_MATCH = 5;
|
|
3184
|
+
var StateLimitError = class extends Error {
|
|
3185
|
+
};
|
|
3186
|
+
var NfaBuilder = class {
|
|
3187
|
+
kind = [];
|
|
3188
|
+
out1 = [];
|
|
3189
|
+
out2 = [];
|
|
3190
|
+
pred = [];
|
|
3191
|
+
newState(kind, out1 = -1, out2 = -1) {
|
|
3192
|
+
if (this.kind.length >= LINEAR_REGEX_MAX_STATES) {
|
|
3193
|
+
throw new StateLimitError(
|
|
3194
|
+
`pattern needs more than ${LINEAR_REGEX_MAX_STATES} NFA states (bounded for linear-time matching)`
|
|
3195
|
+
);
|
|
2968
3196
|
}
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3197
|
+
this.kind.push(kind);
|
|
3198
|
+
this.out1.push(out1);
|
|
3199
|
+
this.out2.push(out2);
|
|
3200
|
+
this.pred.push(null);
|
|
3201
|
+
return this.kind.length - 1;
|
|
3202
|
+
}
|
|
3203
|
+
patch(outs, target) {
|
|
3204
|
+
for (const out of outs) {
|
|
3205
|
+
if (out.slot === 0) this.out1[out.state] = target;
|
|
3206
|
+
else this.out2[out.state] = target;
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
build(node) {
|
|
3210
|
+
switch (node.type) {
|
|
3211
|
+
case "empty": {
|
|
3212
|
+
const state = this.newState(K_BYPASS);
|
|
3213
|
+
return { start: state, outs: [{ state, slot: 0 }] };
|
|
3214
|
+
}
|
|
3215
|
+
case "char": {
|
|
3216
|
+
const state = this.newState(K_CHAR);
|
|
3217
|
+
this.pred[state] = node.pred;
|
|
3218
|
+
return { start: state, outs: [{ state, slot: 0 }] };
|
|
3219
|
+
}
|
|
3220
|
+
case "lineStart": {
|
|
3221
|
+
const state = this.newState(K_ASSERT_LINE_START);
|
|
3222
|
+
return { start: state, outs: [{ state, slot: 0 }] };
|
|
3223
|
+
}
|
|
3224
|
+
case "lineEnd": {
|
|
3225
|
+
const state = this.newState(K_ASSERT_LINE_END);
|
|
3226
|
+
return { start: state, outs: [{ state, slot: 0 }] };
|
|
3227
|
+
}
|
|
3228
|
+
case "seq": {
|
|
3229
|
+
if (node.items.length === 0) return this.build(EMPTY_AST);
|
|
3230
|
+
let fragment = this.build(node.items[0]);
|
|
3231
|
+
for (let index = 1; index < node.items.length; index += 1) {
|
|
3232
|
+
const next = this.build(node.items[index]);
|
|
3233
|
+
this.patch(fragment.outs, next.start);
|
|
3234
|
+
fragment = { start: fragment.start, outs: next.outs };
|
|
3235
|
+
}
|
|
3236
|
+
return fragment;
|
|
3237
|
+
}
|
|
3238
|
+
case "alt": {
|
|
3239
|
+
if (node.options.length === 0) return this.build(EMPTY_AST);
|
|
3240
|
+
if (node.options.length === 1) return this.build(node.options[0]);
|
|
3241
|
+
const fragments = node.options.map((option3) => this.build(option3));
|
|
3242
|
+
const splits = [];
|
|
3243
|
+
for (let index = 0; index < fragments.length - 1; index += 1) {
|
|
3244
|
+
splits.push(this.newState(K_SPLIT));
|
|
3245
|
+
}
|
|
3246
|
+
const outs = [];
|
|
3247
|
+
for (let index = 0; index < fragments.length; index += 1) {
|
|
3248
|
+
const split2 = splits[index];
|
|
3249
|
+
if (split2 !== void 0) this.out1[split2] = fragments[index].start;
|
|
3250
|
+
outs.push(...fragments[index].outs);
|
|
3251
|
+
}
|
|
3252
|
+
for (let index = 0; index < splits.length; index += 1) {
|
|
3253
|
+
const fallback2 = splits[index + 1] ?? fragments[fragments.length - 1].start;
|
|
3254
|
+
this.out2[splits[index]] = fallback2;
|
|
3255
|
+
}
|
|
3256
|
+
return { start: splits[0], outs };
|
|
3257
|
+
}
|
|
3258
|
+
case "repeat": {
|
|
3259
|
+
let fragment = null;
|
|
3260
|
+
const append2 = (next) => {
|
|
3261
|
+
if (!fragment) {
|
|
3262
|
+
fragment = next;
|
|
3263
|
+
return;
|
|
2984
3264
|
}
|
|
2985
|
-
|
|
2986
|
-
|
|
3265
|
+
this.patch(fragment.outs, next.start);
|
|
3266
|
+
fragment = { start: fragment.start, outs: next.outs };
|
|
3267
|
+
};
|
|
3268
|
+
for (let index = 0; index < node.min; index += 1) append2(this.build(node.node));
|
|
3269
|
+
if (node.max === Number.POSITIVE_INFINITY) {
|
|
3270
|
+
const splitState = this.newState(K_SPLIT);
|
|
3271
|
+
const inner = this.build(node.node);
|
|
3272
|
+
this.out1[splitState] = inner.start;
|
|
3273
|
+
this.patch(inner.outs, splitState);
|
|
3274
|
+
append2({ start: splitState, outs: [{ state: splitState, slot: 1 }] });
|
|
3275
|
+
} else {
|
|
3276
|
+
for (let index = node.min; index < node.max; index += 1) {
|
|
3277
|
+
const splitState = this.newState(K_SPLIT);
|
|
3278
|
+
const inner = this.build(node.node);
|
|
3279
|
+
this.out1[splitState] = inner.start;
|
|
3280
|
+
append2({
|
|
3281
|
+
start: splitState,
|
|
3282
|
+
outs: [...inner.outs, { state: splitState, slot: 1 }]
|
|
3283
|
+
});
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
return fragment ?? this.build(EMPTY_AST);
|
|
2987
3287
|
}
|
|
2988
3288
|
}
|
|
2989
|
-
}
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3291
|
+
var LinearNfaMatcher = class {
|
|
3292
|
+
constructor(source, builder, startState) {
|
|
3293
|
+
this.source = source;
|
|
3294
|
+
this.kind = Uint8Array.from(builder.kind);
|
|
3295
|
+
this.out1 = Int32Array.from(builder.out1);
|
|
3296
|
+
this.out2 = Int32Array.from(builder.out2);
|
|
3297
|
+
this.pred = builder.pred;
|
|
3298
|
+
this.startState = startState;
|
|
3299
|
+
this.visited = new Int32Array(builder.kind.length).fill(-1);
|
|
3300
|
+
}
|
|
3301
|
+
kind;
|
|
3302
|
+
out1;
|
|
3303
|
+
out2;
|
|
3304
|
+
pred;
|
|
3305
|
+
startState;
|
|
3306
|
+
visited;
|
|
3307
|
+
/** Scratch stack reused across scans (single-threaded, never re-entrant). */
|
|
3308
|
+
stack = [];
|
|
3309
|
+
/**
|
|
3310
|
+
* Monotonic "already visited in this position's closure" stamp. It MUST keep
|
|
3311
|
+
* increasing across `test()` calls: restarting at 1 would make states stamped
|
|
3312
|
+
* `1` by the previous scan look visited, and every anchored pattern (`^…`)
|
|
3313
|
+
* would silently stop matching after the first call.
|
|
3314
|
+
*/
|
|
3315
|
+
generation = 0;
|
|
3316
|
+
test(line) {
|
|
3317
|
+
return this.testBounded(line).status === "matched";
|
|
3318
|
+
}
|
|
3319
|
+
testBounded(line, opts) {
|
|
3320
|
+
if (this.generation > 1073741824) {
|
|
3321
|
+
this.visited.fill(-1);
|
|
3322
|
+
this.generation = 0;
|
|
3323
|
+
}
|
|
3324
|
+
const fullLength = line.length;
|
|
3325
|
+
const length = Math.min(fullLength, LINEAR_REGEX_MAX_LINE_SCAN_CHARS);
|
|
3326
|
+
const lineEndPos = fullLength > length ? -1 : length;
|
|
3327
|
+
const deadlineMs = opts?.deadlineMs;
|
|
3328
|
+
const now = opts?.now ?? Date.now;
|
|
3329
|
+
let steps = 0;
|
|
3330
|
+
let aborted = false;
|
|
3331
|
+
let abortReason = "line-budget-exceeded";
|
|
3332
|
+
const lineTruncated = fullLength > length;
|
|
3333
|
+
const matchedResult = { status: "matched" };
|
|
3334
|
+
const abortResult = () => lineTruncated ? { status: abortReason, lineTruncated: true } : { status: abortReason };
|
|
3335
|
+
const noMatchResult = () => lineTruncated ? { status: "no-match", lineTruncated: true } : { status: "no-match" };
|
|
3336
|
+
const visited = this.visited;
|
|
3337
|
+
const stack = this.stack;
|
|
3338
|
+
const outOfBudget = () => {
|
|
3339
|
+
if (steps > LINEAR_REGEX_MAX_STEPS) {
|
|
3340
|
+
abortReason = "line-budget-exceeded";
|
|
3341
|
+
return true;
|
|
3342
|
+
}
|
|
3343
|
+
if (deadlineMs !== void 0 && (steps & 1023) === 0 && now() >= deadlineMs) {
|
|
3344
|
+
abortReason = "deadline-exceeded";
|
|
3345
|
+
return true;
|
|
3346
|
+
}
|
|
3347
|
+
return false;
|
|
3348
|
+
};
|
|
3349
|
+
const closureInto = (seeds, position, target) => {
|
|
3350
|
+
const generation = this.generation;
|
|
3351
|
+
let hit = false;
|
|
3352
|
+
stack.length = 0;
|
|
3353
|
+
for (const seed of seeds) stack.push(seed);
|
|
3354
|
+
while (stack.length > 0) {
|
|
3355
|
+
steps += 1;
|
|
3356
|
+
if (outOfBudget()) {
|
|
3357
|
+
aborted = true;
|
|
3358
|
+
return false;
|
|
3359
|
+
}
|
|
3360
|
+
const state = stack.pop();
|
|
3361
|
+
if (state < 0 || visited[state] === generation) continue;
|
|
3362
|
+
visited[state] = generation;
|
|
3363
|
+
switch (this.kind[state]) {
|
|
3364
|
+
case K_CHAR:
|
|
3365
|
+
target.push(state);
|
|
3366
|
+
break;
|
|
3367
|
+
case K_MATCH:
|
|
3368
|
+
hit = true;
|
|
3369
|
+
break;
|
|
3370
|
+
case K_BYPASS:
|
|
3371
|
+
stack.push(this.out1[state]);
|
|
3372
|
+
break;
|
|
3373
|
+
case K_SPLIT:
|
|
3374
|
+
stack.push(this.out1[state]);
|
|
3375
|
+
if (this.out2[state] >= 0) stack.push(this.out2[state]);
|
|
3376
|
+
break;
|
|
3377
|
+
case K_ASSERT_LINE_START:
|
|
3378
|
+
if (position === 0) stack.push(this.out1[state]);
|
|
3379
|
+
break;
|
|
3380
|
+
case K_ASSERT_LINE_END:
|
|
3381
|
+
if (position === lineEndPos) stack.push(this.out1[state]);
|
|
3382
|
+
break;
|
|
3383
|
+
default:
|
|
3384
|
+
break;
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
return hit;
|
|
3388
|
+
};
|
|
3389
|
+
this.generation += 1;
|
|
3390
|
+
let current = [];
|
|
3391
|
+
if (closureInto([this.startState], 0, current)) return matchedResult;
|
|
3392
|
+
if (aborted) return abortResult();
|
|
3393
|
+
for (let position = 0; position < length; position += 1) {
|
|
3394
|
+
const code = line.charCodeAt(position);
|
|
3395
|
+
const followed = [];
|
|
3396
|
+
for (const state of current) {
|
|
3397
|
+
steps += 1;
|
|
3398
|
+
const predicate = this.pred[state];
|
|
3399
|
+
if (predicate && predicate(code)) followed.push(this.out1[state]);
|
|
3400
|
+
}
|
|
3401
|
+
if (outOfBudget()) return abortResult();
|
|
3402
|
+
followed.push(this.startState);
|
|
3403
|
+
this.generation += 1;
|
|
3404
|
+
const next = [];
|
|
3405
|
+
if (closureInto(followed, position + 1, next)) return matchedResult;
|
|
3406
|
+
if (aborted) return abortResult();
|
|
3407
|
+
current = next;
|
|
3408
|
+
}
|
|
3409
|
+
return noMatchResult();
|
|
3410
|
+
}
|
|
3411
|
+
};
|
|
3412
|
+
function compileLinearRegex(source) {
|
|
3413
|
+
if (typeof source !== "string" || source.length === 0) {
|
|
3414
|
+
return { ok: false, detail: "pattern must be a non-empty string" };
|
|
3415
|
+
}
|
|
3416
|
+
if (source.length > LINEAR_REGEX_MAX_PATTERN_LENGTH) {
|
|
3417
|
+
return {
|
|
3418
|
+
ok: false,
|
|
3419
|
+
detail: `pattern exceeds maximum length of ${LINEAR_REGEX_MAX_PATTERN_LENGTH} characters`
|
|
3420
|
+
};
|
|
3421
|
+
}
|
|
3422
|
+
let ast;
|
|
3423
|
+
try {
|
|
3424
|
+
ast = new PatternParser(source).parse();
|
|
3425
|
+
} catch (error) {
|
|
3426
|
+
if (error instanceof LinearRegexError) return { ok: false, detail: error.message };
|
|
3427
|
+
throw error;
|
|
3428
|
+
}
|
|
3429
|
+
const builder = new NfaBuilder();
|
|
3430
|
+
try {
|
|
3431
|
+
const root = builder.build(ast);
|
|
3432
|
+
const matchState = builder.newState(K_MATCH);
|
|
3433
|
+
builder.patch(root.outs, matchState);
|
|
3434
|
+
return { ok: true, matcher: new LinearNfaMatcher(source, builder, root.start) };
|
|
3435
|
+
} catch (error) {
|
|
3436
|
+
if (error instanceof StateLimitError) return { ok: false, detail: error.message };
|
|
3437
|
+
throw error;
|
|
3438
|
+
}
|
|
2990
3439
|
}
|
|
2991
|
-
|
|
3440
|
+
|
|
3441
|
+
// packages/agent-runtime/processOutput.ts
|
|
3442
|
+
var LAUNCH_PROCESS_STREAM_RING_CHARS = 65536;
|
|
3443
|
+
var LAUNCH_PROCESS_STREAM_CAPTURE_MAX_CHARS = 1e6;
|
|
3444
|
+
var PROCESS_LIVE_MAX_LINES = 500;
|
|
3445
|
+
var PROCESS_LIVE_MAX_CHARS = LAUNCH_PROCESS_STREAM_RING_CHARS;
|
|
3446
|
+
var PROCESS_PENDING_LINE_MAX_CHARS = 16384;
|
|
3447
|
+
var OVERFLOW_LINE_PLACEHOLDER = `[line omitted: exceeded ${PROCESS_PENDING_LINE_MAX_CHARS} chars before newline]`;
|
|
3448
|
+
var PROCESS_OUTPUT_DEFAULT_MAX_CHARS = 8e3;
|
|
3449
|
+
var PROCESS_OUTPUT_MIN_MAX_CHARS = 256;
|
|
3450
|
+
var PROCESS_OUTPUT_MAX_MAX_CHARS = 32e3;
|
|
3451
|
+
var PROCESS_OUTPUT_DEFAULT_WAIT_MS = 3e4;
|
|
3452
|
+
var PROCESS_OUTPUT_MIN_READY_WAIT_MS = 100;
|
|
3453
|
+
var PROCESS_OUTPUT_MAX_WAIT_MS = 12e4;
|
|
3454
|
+
var PROCESS_OUTPUT_MAX_PATTERN_LENGTH = 512;
|
|
3455
|
+
var ANSI_ESCAPE_RE = /\x1b(?:\[[0-?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\-_])/g;
|
|
3456
|
+
function stripAnsi(text2) {
|
|
3457
|
+
if (!text2.includes("\x1B")) return text2;
|
|
3458
|
+
return text2.replace(ANSI_ESCAPE_RE, "");
|
|
3459
|
+
}
|
|
3460
|
+
function createLaunchProcessStreamCapture() {
|
|
3461
|
+
let ring = "";
|
|
3462
|
+
let full = [];
|
|
3463
|
+
let hasEvicted = false;
|
|
3464
|
+
let capturedChars = 0;
|
|
3465
|
+
let totalChars = 0;
|
|
3466
|
+
let totalNewlines = 0;
|
|
2992
3467
|
return {
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
description: "Expected replacement count. Defaults to 1."
|
|
3013
|
-
}
|
|
3014
|
-
// 刻意保持单一声明(integer),不引入 anyOf/oneOf 组合 schema:
|
|
3015
|
-
// provider 对组合 schema 的处理不一致——Gemini 会把无顶层 type 的联合
|
|
3016
|
-
// 节点归并成 type:"object",连原本合法的整数输入都不再符合它的声明;
|
|
3017
|
-
// Fireworks 直接剥掉组合子、只剩描述。
|
|
3018
|
-
},
|
|
3019
|
-
required: ["path", "oldText", "newText"]
|
|
3468
|
+
push(chunk) {
|
|
3469
|
+
const str = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
3470
|
+
if (!str) return;
|
|
3471
|
+
totalChars += str.length;
|
|
3472
|
+
for (let i = 0; i < str.length; i += 1) {
|
|
3473
|
+
if (str.charCodeAt(i) === 10) totalNewlines += 1;
|
|
3474
|
+
}
|
|
3475
|
+
const combined = ring + str;
|
|
3476
|
+
if (combined.length > LAUNCH_PROCESS_STREAM_RING_CHARS) hasEvicted = true;
|
|
3477
|
+
ring = combined.slice(-LAUNCH_PROCESS_STREAM_RING_CHARS);
|
|
3478
|
+
if (full !== null && capturedChars < LAUNCH_PROCESS_STREAM_CAPTURE_MAX_CHARS) {
|
|
3479
|
+
const room = LAUNCH_PROCESS_STREAM_CAPTURE_MAX_CHARS - capturedChars;
|
|
3480
|
+
if (str.length <= room) {
|
|
3481
|
+
full.push(str);
|
|
3482
|
+
capturedChars += str.length;
|
|
3483
|
+
} else {
|
|
3484
|
+
full.push(str.slice(0, room));
|
|
3485
|
+
capturedChars = LAUNCH_PROCESS_STREAM_CAPTURE_MAX_CHARS;
|
|
3486
|
+
}
|
|
3020
3487
|
}
|
|
3488
|
+
},
|
|
3489
|
+
text() {
|
|
3490
|
+
return full === null ? ring : full.join("");
|
|
3491
|
+
},
|
|
3492
|
+
tailText() {
|
|
3493
|
+
return ring;
|
|
3494
|
+
},
|
|
3495
|
+
evicted() {
|
|
3496
|
+
return hasEvicted;
|
|
3497
|
+
},
|
|
3498
|
+
totalChars() {
|
|
3499
|
+
return totalChars;
|
|
3500
|
+
},
|
|
3501
|
+
totalLines() {
|
|
3502
|
+
return totalChars > 0 ? totalNewlines + 1 : 0;
|
|
3503
|
+
},
|
|
3504
|
+
releaseFullCapture() {
|
|
3505
|
+
full = null;
|
|
3021
3506
|
}
|
|
3022
3507
|
};
|
|
3023
3508
|
}
|
|
3024
|
-
|
|
3025
|
-
|
|
3509
|
+
var PRIVATE_KEY_PLACEHOLDER = "[REDACTED:PRIVATE_KEY]";
|
|
3510
|
+
var PEM_BEGIN_RE = /-----BEGIN (?:[A-Z0-9 ]+)?PRIVATE KEY-----/;
|
|
3511
|
+
var PEM_END_RE = /-----END (?:[A-Z0-9 ]+)?PRIVATE KEY-----/;
|
|
3512
|
+
var PEM_MARKER_SOURCE = "-----BEGIN (?:[A-Z0-9 ]+)?PRIVATE KEY-----|-----END (?:[A-Z0-9 ]+)?PRIVATE KEY-----";
|
|
3513
|
+
var OVERFLOW_SECRET_WINDOW = 64;
|
|
3514
|
+
var OVERFLOW_WHITESPACE_RE = /\s/;
|
|
3515
|
+
function createProcessOutputStreamSanitizerState() {
|
|
3516
|
+
return { inPrivateKey: false };
|
|
3517
|
+
}
|
|
3518
|
+
function scrubLine(text2) {
|
|
3519
|
+
if (!text2) return text2;
|
|
3520
|
+
return scrubSecrets(text2).cleaned;
|
|
3521
|
+
}
|
|
3522
|
+
function sanitizeStreamLine(rawLine, state) {
|
|
3523
|
+
const visible = stripAnsi(sanitizeToolOutputText(rawLine));
|
|
3524
|
+
const startedInsidePrivateKey = state.inPrivateKey;
|
|
3525
|
+
let out = "";
|
|
3526
|
+
let cursor = 0;
|
|
3527
|
+
let droppedBodyOnly = false;
|
|
3528
|
+
while (cursor < visible.length) {
|
|
3529
|
+
const rest = visible.slice(cursor);
|
|
3530
|
+
if (state.inPrivateKey) {
|
|
3531
|
+
const end4 = PEM_END_RE.exec(rest);
|
|
3532
|
+
if (!end4) {
|
|
3533
|
+
droppedBodyOnly = true;
|
|
3534
|
+
cursor = visible.length;
|
|
3535
|
+
break;
|
|
3536
|
+
}
|
|
3537
|
+
state.inPrivateKey = false;
|
|
3538
|
+
cursor += end4.index + end4[0].length;
|
|
3539
|
+
continue;
|
|
3540
|
+
}
|
|
3541
|
+
const begin = PEM_BEGIN_RE.exec(rest);
|
|
3542
|
+
const end3 = PEM_END_RE.exec(rest);
|
|
3543
|
+
if (end3 && (!begin || end3.index < begin.index)) {
|
|
3544
|
+
out += PRIVATE_KEY_PLACEHOLDER;
|
|
3545
|
+
cursor += end3.index + end3[0].length;
|
|
3546
|
+
continue;
|
|
3547
|
+
}
|
|
3548
|
+
if (!begin) {
|
|
3549
|
+
out += scrubLine(rest);
|
|
3550
|
+
cursor = visible.length;
|
|
3551
|
+
break;
|
|
3552
|
+
}
|
|
3553
|
+
out += scrubLine(rest.slice(0, begin.index));
|
|
3554
|
+
out += PRIVATE_KEY_PLACEHOLDER;
|
|
3555
|
+
const afterBegin = rest.slice(begin.index + begin[0].length);
|
|
3556
|
+
const closingEnd = PEM_END_RE.exec(afterBegin);
|
|
3557
|
+
if (!closingEnd) {
|
|
3558
|
+
state.inPrivateKey = true;
|
|
3559
|
+
cursor = visible.length;
|
|
3560
|
+
break;
|
|
3561
|
+
}
|
|
3562
|
+
state.inPrivateKey = false;
|
|
3563
|
+
cursor += begin.index + begin[0].length + closingEnd.index + closingEnd[0].length;
|
|
3564
|
+
}
|
|
3565
|
+
if (out.trim().length === 0) {
|
|
3566
|
+
if (droppedBodyOnly || startedInsidePrivateKey && out.length === 0) return null;
|
|
3567
|
+
return out;
|
|
3568
|
+
}
|
|
3569
|
+
return startedInsidePrivateKey ? `${PRIVATE_KEY_PLACEHOLDER}${out}` : out;
|
|
3026
3570
|
}
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3571
|
+
var SECRET_CONTEXT_BEARER_TAIL_RE = /\bBearer\s*$/i;
|
|
3572
|
+
var SECRET_CONTEXT_PASSWORD_TAIL_RE = /\b(?:(?:DB_|DATABASE_|ADMIN_|ROOT_|MYSQL_|POSTGRES_)?(?:PASSWORD|PASSWD|SECRET_KEY))\s*=\s*['"]?$/i;
|
|
3573
|
+
var SECRET_CONTEXT_BEARER_HEAD_RE = /^(\s*)([a-zA-Z0-9_\-\.]{25,})\b/;
|
|
3574
|
+
var SECRET_CONTEXT_PASSWORD_HEAD_RE = /^(\s*)(['"]?)([^\s'"]{4,})(['"]?)/;
|
|
3575
|
+
function applyPendingSecretContext(context3, line) {
|
|
3576
|
+
if (context3 === null || line.length === 0) return line;
|
|
3577
|
+
if (context3 === "bearer") {
|
|
3578
|
+
return line.replace(SECRET_CONTEXT_BEARER_HEAD_RE, "$1[REDACTED:BEARER_TOKEN]");
|
|
3579
|
+
}
|
|
3580
|
+
return line.replace(SECRET_CONTEXT_PASSWORD_HEAD_RE, "$1[REDACTED:PASSWORD]");
|
|
3581
|
+
}
|
|
3582
|
+
function nextPendingSecretContext(line) {
|
|
3583
|
+
if (line.length === 0) return null;
|
|
3584
|
+
if (SECRET_CONTEXT_BEARER_TAIL_RE.test(line)) return "bearer";
|
|
3585
|
+
if (SECRET_CONTEXT_PASSWORD_TAIL_RE.test(line)) return "password";
|
|
3586
|
+
return null;
|
|
3587
|
+
}
|
|
3588
|
+
function skipToAfterLineTerminator(text2) {
|
|
3589
|
+
for (let i = 0; i < text2.length; i += 1) {
|
|
3590
|
+
const code = text2.charCodeAt(i);
|
|
3591
|
+
if (code !== 10 && code !== 13) continue;
|
|
3592
|
+
return code === 13 && text2.charCodeAt(i + 1) === 10 ? i + 2 : i + 1;
|
|
3593
|
+
}
|
|
3594
|
+
return -1;
|
|
3595
|
+
}
|
|
3596
|
+
var STRIPPER_ESC = 27;
|
|
3597
|
+
var STRIPPER_BEL = 7;
|
|
3598
|
+
var STRIPPER_LINE_FEED = 10;
|
|
3599
|
+
var STRIPPER_TAB = 9;
|
|
3600
|
+
var STRIPPER_DEL = 127;
|
|
3601
|
+
var STRIPPER_C1_DCS = 144;
|
|
3602
|
+
var STRIPPER_C1_SOS = 152;
|
|
3603
|
+
var STRIPPER_C1_CSI = 155;
|
|
3604
|
+
var STRIPPER_C1_ST = 156;
|
|
3605
|
+
var STRIPPER_C1_OSC = 157;
|
|
3606
|
+
var STRIPPER_C1_PM = 158;
|
|
3607
|
+
var STRIPPER_C1_APC = 159;
|
|
3608
|
+
var STRIPPER_HIGH_SURROGATE_MIN = 55296;
|
|
3609
|
+
var STRIPPER_HIGH_SURROGATE_MAX = 56319;
|
|
3610
|
+
var STRIPPER_LOW_SURROGATE_MIN = 56320;
|
|
3611
|
+
var STRIPPER_LOW_SURROGATE_MAX = 57343;
|
|
3612
|
+
function createOverflowControlStripper() {
|
|
3613
|
+
let state = "normal";
|
|
3614
|
+
let seqLen = 0;
|
|
3615
|
+
let seqBody = "";
|
|
3616
|
+
let pendingHighSurrogate = "";
|
|
3617
|
+
let out = [];
|
|
3618
|
+
const reset = () => {
|
|
3619
|
+
state = "normal";
|
|
3620
|
+
seqLen = 0;
|
|
3621
|
+
seqBody = "";
|
|
3622
|
+
};
|
|
3623
|
+
const replayBody = () => {
|
|
3624
|
+
const body = seqBody;
|
|
3625
|
+
reset();
|
|
3626
|
+
return body;
|
|
3627
|
+
};
|
|
3628
|
+
const step = (code, ch) => {
|
|
3629
|
+
if (pendingHighSurrogate) {
|
|
3630
|
+
const held = pendingHighSurrogate;
|
|
3631
|
+
pendingHighSurrogate = "";
|
|
3632
|
+
if (code >= STRIPPER_LOW_SURROGATE_MIN && code <= STRIPPER_LOW_SURROGATE_MAX) {
|
|
3633
|
+
out.push(held + ch);
|
|
3634
|
+
return "";
|
|
3635
|
+
}
|
|
3636
|
+
out.push(SANITIZE_REPLACEMENT_CHAR);
|
|
3637
|
+
}
|
|
3638
|
+
switch (state) {
|
|
3639
|
+
case "normal": {
|
|
3640
|
+
if (code === STRIPPER_LINE_FEED || code === STRIPPER_TAB) {
|
|
3641
|
+
out.push(ch);
|
|
3642
|
+
return "";
|
|
3643
|
+
}
|
|
3644
|
+
if (code === STRIPPER_ESC) {
|
|
3645
|
+
state = "esc";
|
|
3646
|
+
seqLen = 1;
|
|
3647
|
+
seqBody = "";
|
|
3648
|
+
return "";
|
|
3649
|
+
}
|
|
3650
|
+
if (code === STRIPPER_C1_CSI) {
|
|
3651
|
+
state = "csi";
|
|
3652
|
+
seqLen = 1;
|
|
3653
|
+
seqBody = "";
|
|
3654
|
+
return "";
|
|
3655
|
+
}
|
|
3656
|
+
if (code === STRIPPER_C1_OSC || code === STRIPPER_C1_DCS || code === STRIPPER_C1_SOS || code === STRIPPER_C1_PM || code === STRIPPER_C1_APC) {
|
|
3657
|
+
state = "st_str";
|
|
3658
|
+
seqLen = 1;
|
|
3659
|
+
seqBody = "";
|
|
3660
|
+
return "";
|
|
3661
|
+
}
|
|
3662
|
+
if (code < 32 || code === STRIPPER_DEL || code >= 128 && code <= 159) {
|
|
3663
|
+
return "";
|
|
3664
|
+
}
|
|
3665
|
+
if (code >= STRIPPER_HIGH_SURROGATE_MIN && code <= STRIPPER_HIGH_SURROGATE_MAX) {
|
|
3666
|
+
pendingHighSurrogate = ch;
|
|
3667
|
+
return "";
|
|
3668
|
+
}
|
|
3669
|
+
if (code >= STRIPPER_LOW_SURROGATE_MIN && code <= STRIPPER_LOW_SURROGATE_MAX) {
|
|
3670
|
+
out.push(SANITIZE_REPLACEMENT_CHAR);
|
|
3671
|
+
return "";
|
|
3672
|
+
}
|
|
3673
|
+
out.push(ch);
|
|
3674
|
+
return "";
|
|
3675
|
+
}
|
|
3676
|
+
case "esc": {
|
|
3677
|
+
seqLen += 1;
|
|
3678
|
+
if (code === 91) {
|
|
3679
|
+
state = "csi";
|
|
3680
|
+
seqBody = ch;
|
|
3681
|
+
return "";
|
|
3682
|
+
}
|
|
3683
|
+
if (code === 93 || code === 80 || code === 88 || code === 94 || code === 95) {
|
|
3684
|
+
state = "st_str";
|
|
3685
|
+
seqBody = ch;
|
|
3686
|
+
return "";
|
|
3687
|
+
}
|
|
3688
|
+
if (code >= 32 && code <= 47) {
|
|
3689
|
+
seqBody += ch;
|
|
3690
|
+
return seqLen >= MAX_CONTROL_SEQUENCE_CHARS ? replayBody() : "";
|
|
3691
|
+
}
|
|
3692
|
+
if (code >= 48 && code <= 126) {
|
|
3693
|
+
reset();
|
|
3694
|
+
return "";
|
|
3695
|
+
}
|
|
3696
|
+
const rescued = seqBody + ch;
|
|
3697
|
+
reset();
|
|
3698
|
+
return rescued;
|
|
3699
|
+
}
|
|
3700
|
+
case "csi": {
|
|
3701
|
+
seqLen += 1;
|
|
3702
|
+
if (code >= 64 && code <= 126) {
|
|
3703
|
+
reset();
|
|
3704
|
+
return "";
|
|
3705
|
+
}
|
|
3706
|
+
if (code >= 32 && code <= 63) {
|
|
3707
|
+
seqBody += ch;
|
|
3708
|
+
return seqLen >= MAX_CONTROL_SEQUENCE_CHARS ? replayBody() : "";
|
|
3709
|
+
}
|
|
3710
|
+
reset();
|
|
3711
|
+
return ch;
|
|
3712
|
+
}
|
|
3713
|
+
case "st_str": {
|
|
3714
|
+
seqLen += 1;
|
|
3715
|
+
if (code === STRIPPER_BEL || code === STRIPPER_C1_ST) {
|
|
3716
|
+
reset();
|
|
3717
|
+
return "";
|
|
3718
|
+
}
|
|
3719
|
+
if (code === STRIPPER_ESC) {
|
|
3720
|
+
seqBody += ch;
|
|
3721
|
+
state = "st_esc";
|
|
3722
|
+
return "";
|
|
3723
|
+
}
|
|
3724
|
+
seqBody += ch;
|
|
3725
|
+
return seqLen >= MAX_CONTROL_SEQUENCE_CHARS ? replayBody() : "";
|
|
3726
|
+
}
|
|
3727
|
+
case "st_esc": {
|
|
3728
|
+
seqLen += 1;
|
|
3729
|
+
const exceedsLimit = seqLen > MAX_CONTROL_SEQUENCE_CHARS;
|
|
3730
|
+
if (code === 92) {
|
|
3731
|
+
const strayBackslash = exceedsLimit ? ch : "";
|
|
3732
|
+
reset();
|
|
3733
|
+
return strayBackslash;
|
|
3734
|
+
}
|
|
3735
|
+
if (exceedsLimit) {
|
|
3736
|
+
return `${replayBody()}${ch}`;
|
|
3737
|
+
}
|
|
3738
|
+
if (code === STRIPPER_BEL || code === STRIPPER_C1_ST) {
|
|
3739
|
+
reset();
|
|
3740
|
+
return "";
|
|
3741
|
+
}
|
|
3742
|
+
if (code === STRIPPER_ESC) {
|
|
3743
|
+
seqBody += "\x1B";
|
|
3744
|
+
return "";
|
|
3745
|
+
}
|
|
3746
|
+
seqBody += ch;
|
|
3747
|
+
state = "st_str";
|
|
3748
|
+
return "";
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
return "";
|
|
3752
|
+
};
|
|
3753
|
+
const processText = (text2) => {
|
|
3754
|
+
let rest = text2;
|
|
3755
|
+
let index = 0;
|
|
3756
|
+
while (index < rest.length) {
|
|
3757
|
+
const code = rest.charCodeAt(index);
|
|
3758
|
+
const replay = step(code, rest[index]);
|
|
3759
|
+
index += 1;
|
|
3760
|
+
if (replay) rest = `${rest.slice(0, index)}${replay}${rest.slice(index)}`;
|
|
3761
|
+
}
|
|
3762
|
+
};
|
|
3763
|
+
return {
|
|
3764
|
+
push(chunk) {
|
|
3765
|
+
if (!chunk) return "";
|
|
3766
|
+
out = [];
|
|
3767
|
+
processText(chunk);
|
|
3768
|
+
const visible = out.join("");
|
|
3769
|
+
out = [];
|
|
3770
|
+
return visible;
|
|
3771
|
+
},
|
|
3772
|
+
end() {
|
|
3773
|
+
out = [];
|
|
3774
|
+
if (pendingHighSurrogate) {
|
|
3775
|
+
pendingHighSurrogate = "";
|
|
3776
|
+
out.push(SANITIZE_REPLACEMENT_CHAR);
|
|
3777
|
+
}
|
|
3778
|
+
for (let guard = 0; state !== "normal" && guard <= MAX_CONTROL_SEQUENCE_CHARS; guard += 1) {
|
|
3779
|
+
const body = seqBody;
|
|
3780
|
+
reset();
|
|
3781
|
+
if (body) processText(body);
|
|
3782
|
+
}
|
|
3783
|
+
reset();
|
|
3784
|
+
const visible = out.join("");
|
|
3785
|
+
out = [];
|
|
3786
|
+
return visible;
|
|
3787
|
+
}
|
|
3788
|
+
};
|
|
3789
|
+
}
|
|
3790
|
+
function createSanitizedLineRing() {
|
|
3791
|
+
const lines = [];
|
|
3792
|
+
let totalCharsInRing = 0;
|
|
3793
|
+
let nextSeq = 1;
|
|
3794
|
+
let inPrivateKey = false;
|
|
3795
|
+
let pendingRaw = "";
|
|
3796
|
+
let pendingOverflowed = false;
|
|
3797
|
+
let evictedLines = 0;
|
|
3798
|
+
let omittedLines = 0;
|
|
3799
|
+
let secretContext = null;
|
|
3800
|
+
let overflowVisibleTail = "";
|
|
3801
|
+
let overflowCredTail = "";
|
|
3802
|
+
let overflowSawTrailingSpace = false;
|
|
3803
|
+
let overflowStripper = createOverflowControlStripper();
|
|
3804
|
+
const resetOverflowWindows = () => {
|
|
3805
|
+
overflowVisibleTail = "";
|
|
3806
|
+
overflowCredTail = "";
|
|
3807
|
+
overflowSawTrailingSpace = false;
|
|
3808
|
+
overflowStripper = createOverflowControlStripper();
|
|
3809
|
+
};
|
|
3810
|
+
const enqueue = (text2, matchable = true) => {
|
|
3811
|
+
lines.push(matchable ? { seq: nextSeq, text: text2 } : { seq: nextSeq, text: text2, matchable: false });
|
|
3812
|
+
nextSeq += 1;
|
|
3813
|
+
totalCharsInRing += text2.length + 1;
|
|
3814
|
+
while (lines.length > PROCESS_LIVE_MAX_LINES || totalCharsInRing > PROCESS_LIVE_MAX_CHARS && lines.length > 1) {
|
|
3815
|
+
const dropped = lines.shift();
|
|
3816
|
+
totalCharsInRing -= dropped.text.length + 1;
|
|
3817
|
+
evictedLines += 1;
|
|
3818
|
+
}
|
|
3819
|
+
};
|
|
3820
|
+
const enqueueRawLine = (rawLine) => {
|
|
3821
|
+
if (rawLine.length > PROCESS_PENDING_LINE_MAX_CHARS) {
|
|
3822
|
+
resetOverflowWindows();
|
|
3823
|
+
scanOverflowVisible(rawLine);
|
|
3824
|
+
closeOverflow(true);
|
|
3825
|
+
return;
|
|
3826
|
+
}
|
|
3827
|
+
const state = { inPrivateKey };
|
|
3828
|
+
const sanitized = sanitizeStreamLine(rawLine, state);
|
|
3829
|
+
inPrivateKey = state.inPrivateKey;
|
|
3830
|
+
if (sanitized === null) return;
|
|
3831
|
+
const visible = applyPendingSecretContext(secretContext, sanitized);
|
|
3832
|
+
enqueue(visible);
|
|
3833
|
+
if (visible.trim() === "") return;
|
|
3834
|
+
secretContext = nextPendingSecretContext(visible);
|
|
3835
|
+
};
|
|
3836
|
+
const absorbOverflowCredTail = (visible) => {
|
|
3837
|
+
let next = overflowCredTail;
|
|
3838
|
+
let sawSpace = overflowSawTrailingSpace;
|
|
3839
|
+
for (const ch of visible) {
|
|
3840
|
+
if (OVERFLOW_WHITESPACE_RE.test(ch)) {
|
|
3841
|
+
sawSpace = true;
|
|
3842
|
+
continue;
|
|
3843
|
+
}
|
|
3844
|
+
if (sawSpace) {
|
|
3845
|
+
next += " ";
|
|
3846
|
+
sawSpace = false;
|
|
3847
|
+
}
|
|
3848
|
+
next += ch;
|
|
3849
|
+
if (next.length >= OVERFLOW_SECRET_WINDOW * 4) next = next.slice(-OVERFLOW_SECRET_WINDOW);
|
|
3850
|
+
}
|
|
3851
|
+
overflowCredTail = next.length > OVERFLOW_SECRET_WINDOW ? next.slice(-OVERFLOW_SECRET_WINDOW) : next;
|
|
3852
|
+
overflowSawTrailingSpace = sawSpace;
|
|
3853
|
+
};
|
|
3854
|
+
const absorbOverflowVisible = (visible) => {
|
|
3855
|
+
if (!visible) return;
|
|
3856
|
+
absorbOverflowCredTail(visible);
|
|
3857
|
+
const window = `${overflowVisibleTail}${visible}`;
|
|
3858
|
+
const markerRe = new RegExp(PEM_MARKER_SOURCE, "g");
|
|
3859
|
+
let matched;
|
|
3860
|
+
while ((matched = markerRe.exec(window)) !== null) {
|
|
3861
|
+
inPrivateKey = matched[0].startsWith("-----BEGIN");
|
|
3862
|
+
}
|
|
3863
|
+
overflowVisibleTail = window.length > OVERFLOW_SECRET_WINDOW ? window.slice(-OVERFLOW_SECRET_WINDOW) : window;
|
|
3864
|
+
};
|
|
3865
|
+
const scanOverflowVisible = (raw) => {
|
|
3866
|
+
if (!raw) return;
|
|
3867
|
+
absorbOverflowVisible(overflowStripper.push(raw));
|
|
3868
|
+
};
|
|
3869
|
+
const closeOverflow = (force = false) => {
|
|
3870
|
+
if (!pendingOverflowed && !force) return;
|
|
3871
|
+
absorbOverflowVisible(overflowStripper.end());
|
|
3872
|
+
secretContext = nextPendingSecretContext(
|
|
3873
|
+
overflowSawTrailingSpace ? `${overflowCredTail} ` : overflowCredTail
|
|
3874
|
+
);
|
|
3875
|
+
resetOverflowWindows();
|
|
3876
|
+
pendingOverflowed = false;
|
|
3877
|
+
pendingRaw = "";
|
|
3878
|
+
omittedLines += 1;
|
|
3879
|
+
enqueue(OVERFLOW_LINE_PLACEHOLDER, false);
|
|
3880
|
+
};
|
|
3881
|
+
const pushText = (raw) => {
|
|
3882
|
+
if (!raw) return;
|
|
3883
|
+
let rest = raw;
|
|
3884
|
+
if (pendingOverflowed) {
|
|
3885
|
+
const afterTerminator = skipToAfterLineTerminator(rest);
|
|
3886
|
+
if (afterTerminator < 0) {
|
|
3887
|
+
scanOverflowVisible(rest);
|
|
3888
|
+
return;
|
|
3889
|
+
}
|
|
3890
|
+
const beforeTerminator = rest.slice(0, afterTerminator);
|
|
3891
|
+
let scanEnd = beforeTerminator.length;
|
|
3892
|
+
while (scanEnd > 0) {
|
|
3893
|
+
const code = beforeTerminator.charCodeAt(scanEnd - 1);
|
|
3894
|
+
if (code !== 10 && code !== 13) break;
|
|
3895
|
+
scanEnd -= 1;
|
|
3896
|
+
}
|
|
3897
|
+
if (scanEnd > 0) scanOverflowVisible(beforeTerminator.slice(0, scanEnd));
|
|
3898
|
+
closeOverflow();
|
|
3899
|
+
rest = rest.slice(afterTerminator);
|
|
3900
|
+
if (rest.length === 0) return;
|
|
3901
|
+
}
|
|
3902
|
+
const buffer3 = pendingRaw + rest;
|
|
3903
|
+
pendingRaw = "";
|
|
3904
|
+
let start = 0;
|
|
3905
|
+
for (let i = 0; i < buffer3.length; i += 1) {
|
|
3906
|
+
const code = buffer3.charCodeAt(i);
|
|
3907
|
+
if (code !== 10 && code !== 13) continue;
|
|
3908
|
+
const line = buffer3.slice(start, i);
|
|
3909
|
+
const terminator = code === 13 && buffer3.charCodeAt(i + 1) === 10 ? 2 : 1;
|
|
3910
|
+
i += terminator - 1;
|
|
3911
|
+
start = i + 1;
|
|
3912
|
+
enqueueRawLine(line);
|
|
3913
|
+
}
|
|
3914
|
+
pendingRaw = buffer3.slice(start);
|
|
3915
|
+
if (pendingRaw.length > PROCESS_PENDING_LINE_MAX_CHARS) {
|
|
3916
|
+
pendingRaw = "";
|
|
3917
|
+
pendingOverflowed = true;
|
|
3918
|
+
resetOverflowWindows();
|
|
3919
|
+
scanOverflowVisible(buffer3.slice(start));
|
|
3920
|
+
}
|
|
3921
|
+
};
|
|
3922
|
+
return {
|
|
3923
|
+
push(chunk) {
|
|
3924
|
+
pushText(typeof chunk === "string" ? chunk : chunk.toString("utf8"));
|
|
3925
|
+
},
|
|
3926
|
+
flush() {
|
|
3927
|
+
if (pendingOverflowed) {
|
|
3928
|
+
closeOverflow();
|
|
3929
|
+
return;
|
|
3930
|
+
}
|
|
3931
|
+
if (pendingRaw.length === 0) return;
|
|
3932
|
+
const rest = pendingRaw;
|
|
3933
|
+
pendingRaw = "";
|
|
3934
|
+
enqueueRawLine(rest);
|
|
3935
|
+
},
|
|
3936
|
+
entries() {
|
|
3937
|
+
return lines;
|
|
3938
|
+
},
|
|
3939
|
+
linesAfter(afterSeq) {
|
|
3940
|
+
if (lines.length === 0) return [];
|
|
3941
|
+
const first = lines[0];
|
|
3942
|
+
if (afterSeq < first.seq - 1) return lines;
|
|
3943
|
+
const offset = Math.max(0, afterSeq + 1 - first.seq);
|
|
3944
|
+
if (offset >= lines.length) return [];
|
|
3945
|
+
return lines.slice(offset);
|
|
3946
|
+
},
|
|
3947
|
+
latestSeq() {
|
|
3948
|
+
return lines.length === 0 ? 0 : lines[lines.length - 1].seq;
|
|
3949
|
+
},
|
|
3950
|
+
evicted() {
|
|
3951
|
+
return evictedLines > 0;
|
|
3952
|
+
},
|
|
3953
|
+
scanIncomplete() {
|
|
3954
|
+
return omittedLines > 0 || pendingOverflowed;
|
|
3955
|
+
},
|
|
3956
|
+
pendingChars() {
|
|
3957
|
+
return pendingOverflowed ? 0 : pendingRaw.length;
|
|
3958
|
+
}
|
|
3959
|
+
};
|
|
3960
|
+
}
|
|
3961
|
+
function splitSanitizedLines(raw) {
|
|
3962
|
+
const lines = [];
|
|
3963
|
+
const state = createProcessOutputStreamSanitizerState();
|
|
3964
|
+
let seq = 1;
|
|
3965
|
+
const pushLine = (rawLine) => {
|
|
3966
|
+
const sanitized = sanitizeStreamLine(rawLine, state);
|
|
3967
|
+
if (sanitized === null) return;
|
|
3968
|
+
lines.push({ seq, text: sanitized });
|
|
3969
|
+
seq += 1;
|
|
3970
|
+
};
|
|
3971
|
+
let start = 0;
|
|
3972
|
+
let endsWithNewline = false;
|
|
3973
|
+
for (let i = 0; i < raw.length; i += 1) {
|
|
3974
|
+
const code = raw.charCodeAt(i);
|
|
3975
|
+
if (code !== 10 && code !== 13) continue;
|
|
3976
|
+
const line = raw.slice(start, i);
|
|
3977
|
+
const terminator = code === 13 && raw.charCodeAt(i + 1) === 10 ? 2 : 1;
|
|
3978
|
+
i += terminator - 1;
|
|
3979
|
+
start = i + 1;
|
|
3980
|
+
endsWithNewline = true;
|
|
3981
|
+
pushLine(line);
|
|
3982
|
+
}
|
|
3983
|
+
const rest = raw.slice(start);
|
|
3984
|
+
if (rest.length > 0) {
|
|
3985
|
+
pushLine(rest);
|
|
3986
|
+
endsWithNewline = false;
|
|
3987
|
+
}
|
|
3988
|
+
return { lines, endsWithNewline };
|
|
3989
|
+
}
|
|
3990
|
+
function joinRingLines(entries, endsWithNewline) {
|
|
3991
|
+
if (entries.length === 0) return "";
|
|
3992
|
+
const body = entries.map((entry) => entry.text).join("\n");
|
|
3993
|
+
return endsWithNewline || entries.length > 1 ? `${body}
|
|
3994
|
+
` : body;
|
|
3995
|
+
}
|
|
3996
|
+
function formatProcessOutputCursor(stdoutSeq, stderrSeq) {
|
|
3997
|
+
return `${Math.max(0, Math.floor(stdoutSeq))}:${Math.max(0, Math.floor(stderrSeq))}`;
|
|
3998
|
+
}
|
|
3999
|
+
function parseProcessOutputCursor(raw) {
|
|
4000
|
+
if (typeof raw !== "string") {
|
|
4001
|
+
return {
|
|
4002
|
+
ok: false,
|
|
4003
|
+
detail: 'cursor must be a string in "<stdoutLines>:<stderrLines>" format (as returned by readProcessOutput or launchProcess).'
|
|
4004
|
+
};
|
|
4005
|
+
}
|
|
4006
|
+
const trimmed = raw.trim();
|
|
4007
|
+
const match7 = /^(\d+):(\d+)$/.exec(trimmed);
|
|
4008
|
+
if (!match7) {
|
|
4009
|
+
return {
|
|
4010
|
+
ok: false,
|
|
4011
|
+
detail: `Invalid cursor "${trimmed.slice(0, 64)}": expected "<stdoutLines>:<stderrLines>" (e.g. "0:0").`
|
|
4012
|
+
};
|
|
4013
|
+
}
|
|
4014
|
+
const stdoutSeq = Number(match7[1]);
|
|
4015
|
+
const stderrSeq = Number(match7[2]);
|
|
4016
|
+
if (!Number.isSafeInteger(stdoutSeq) || !Number.isSafeInteger(stderrSeq)) {
|
|
4017
|
+
return {
|
|
4018
|
+
ok: false,
|
|
4019
|
+
detail: "Invalid cursor: line number exceeds safe integer range."
|
|
4020
|
+
};
|
|
4021
|
+
}
|
|
4022
|
+
return { ok: true, stdoutSeq, stderrSeq };
|
|
4023
|
+
}
|
|
4024
|
+
function readRing(ring, sinceSeq, maxChars) {
|
|
4025
|
+
const entries = ring.entries();
|
|
4026
|
+
const latestSeq = ring.latestSeq();
|
|
4027
|
+
let selected = entries;
|
|
4028
|
+
let cursorEvicted = false;
|
|
4029
|
+
if (sinceSeq !== void 0) {
|
|
4030
|
+
if (entries.length > 0) {
|
|
4031
|
+
const oldest = entries[0].seq;
|
|
4032
|
+
if (sinceSeq < oldest - 1) cursorEvicted = true;
|
|
4033
|
+
} else if (sinceSeq < latestSeq) {
|
|
4034
|
+
cursorEvicted = true;
|
|
4035
|
+
}
|
|
4036
|
+
selected = ring.linesAfter(sinceSeq);
|
|
4037
|
+
}
|
|
4038
|
+
const full = joinRingLines(selected, true);
|
|
4039
|
+
const tailTrimmed = full.length > maxChars;
|
|
4040
|
+
const text2 = tailTrimmed ? full.slice(-maxChars) : full;
|
|
4041
|
+
return {
|
|
4042
|
+
text: text2,
|
|
4043
|
+
// 内容本身已脱敏,截尾只影响完整性,不可能破坏脱敏。
|
|
4044
|
+
truncated: tailTrimmed || cursorEvicted || sinceSeq === void 0 && ring.evicted(),
|
|
4045
|
+
cursorEvicted,
|
|
4046
|
+
totalLines: latestSeq
|
|
4047
|
+
};
|
|
4048
|
+
}
|
|
4049
|
+
function createProcessLiveOutput(args2) {
|
|
4050
|
+
const stdoutCapture = args2?.stdout ?? createLaunchProcessStreamCapture();
|
|
4051
|
+
const stderrCapture = args2?.stderr ?? createLaunchProcessStreamCapture();
|
|
4052
|
+
const stdoutRing = createSanitizedLineRing();
|
|
4053
|
+
const stderrRing = createSanitizedLineRing();
|
|
4054
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4055
|
+
let closed = false;
|
|
4056
|
+
const notify = () => {
|
|
4057
|
+
for (const listener of [...listeners]) {
|
|
4058
|
+
try {
|
|
4059
|
+
listener();
|
|
4060
|
+
} catch {
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
};
|
|
4064
|
+
return {
|
|
4065
|
+
stdout: stdoutCapture,
|
|
4066
|
+
stderr: stderrCapture,
|
|
4067
|
+
pushStdout(chunk) {
|
|
4068
|
+
stdoutCapture.push(chunk);
|
|
4069
|
+
stdoutRing.push(chunk);
|
|
4070
|
+
notify();
|
|
4071
|
+
},
|
|
4072
|
+
pushStderr(chunk) {
|
|
4073
|
+
stderrCapture.push(chunk);
|
|
4074
|
+
stderrRing.push(chunk);
|
|
4075
|
+
notify();
|
|
4076
|
+
},
|
|
4077
|
+
subscribe(listener) {
|
|
4078
|
+
if (closed) return () => {
|
|
4079
|
+
};
|
|
4080
|
+
listeners.add(listener);
|
|
4081
|
+
return () => {
|
|
4082
|
+
listeners.delete(listener);
|
|
4083
|
+
};
|
|
4084
|
+
},
|
|
4085
|
+
markClosed() {
|
|
4086
|
+
if (closed) return;
|
|
4087
|
+
closed = true;
|
|
4088
|
+
stdoutRing.flush();
|
|
4089
|
+
stderrRing.flush();
|
|
4090
|
+
notify();
|
|
4091
|
+
listeners.clear();
|
|
4092
|
+
},
|
|
4093
|
+
isClosed() {
|
|
4094
|
+
return closed;
|
|
4095
|
+
},
|
|
4096
|
+
releaseFullCapture() {
|
|
4097
|
+
stdoutCapture.releaseFullCapture();
|
|
4098
|
+
stderrCapture.releaseFullCapture();
|
|
4099
|
+
},
|
|
4100
|
+
cursor() {
|
|
4101
|
+
return formatProcessOutputCursor(stdoutRing.latestSeq(), stderrRing.latestSeq());
|
|
4102
|
+
},
|
|
4103
|
+
readSnapshot(opts) {
|
|
4104
|
+
const includeStdout = opts.stream === "both" || opts.stream === "stdout";
|
|
4105
|
+
const includeStderr = opts.stream === "both" || opts.stream === "stderr";
|
|
4106
|
+
const stdoutRead = includeStdout ? readRing(stdoutRing, opts.stdoutSeq, opts.maxChars) : { text: "", truncated: false, cursorEvicted: false, totalLines: stdoutRing.latestSeq() };
|
|
4107
|
+
const stderrRead = includeStderr ? readRing(stderrRing, opts.stderrSeq, opts.maxChars) : { text: "", truncated: false, cursorEvicted: false, totalLines: stderrRing.latestSeq() };
|
|
4108
|
+
return {
|
|
4109
|
+
cursor: formatProcessOutputCursor(stdoutRing.latestSeq(), stderrRing.latestSeq()),
|
|
4110
|
+
stdout: stdoutRead.text,
|
|
4111
|
+
stderr: stderrRead.text,
|
|
4112
|
+
truncated: stdoutRead.truncated || stderrRead.truncated,
|
|
4113
|
+
stdoutTruncated: stdoutRead.truncated,
|
|
4114
|
+
stderrTruncated: stderrRead.truncated,
|
|
4115
|
+
cursorEvicted: stdoutRead.cursorEvicted || stderrRead.cursorEvicted,
|
|
4116
|
+
stdoutTotalLines: stdoutRead.totalLines,
|
|
4117
|
+
stderrTotalLines: stderrRead.totalLines
|
|
4118
|
+
};
|
|
4119
|
+
},
|
|
4120
|
+
ring(stream) {
|
|
4121
|
+
return stream === "stdout" ? stdoutRing : stderrRing;
|
|
4122
|
+
}
|
|
4123
|
+
};
|
|
4124
|
+
}
|
|
4125
|
+
function compileProcessOutputPattern(pattern, fieldName = "waitForPattern") {
|
|
4126
|
+
if (typeof pattern !== "string" || pattern.length === 0) {
|
|
4127
|
+
return {
|
|
4128
|
+
ok: false,
|
|
4129
|
+
detail: `${fieldName} must be a non-empty regular expression string.`
|
|
4130
|
+
};
|
|
4131
|
+
}
|
|
4132
|
+
if (pattern.length > PROCESS_OUTPUT_MAX_PATTERN_LENGTH) {
|
|
4133
|
+
return {
|
|
4134
|
+
ok: false,
|
|
4135
|
+
detail: `${fieldName} exceeds maximum length of ${PROCESS_OUTPUT_MAX_PATTERN_LENGTH} characters.`
|
|
4136
|
+
};
|
|
4137
|
+
}
|
|
4138
|
+
const compiled = compileLinearRegex(pattern);
|
|
4139
|
+
if (!compiled.ok) {
|
|
4140
|
+
return { ok: false, detail: `Invalid ${fieldName} regex: ${compiled.detail}` };
|
|
4141
|
+
}
|
|
4142
|
+
return { ok: true, regex: compiled.matcher, pattern };
|
|
4143
|
+
}
|
|
4144
|
+
function resolveProcessOutputStream(raw) {
|
|
4145
|
+
if (raw === void 0 || raw === null || raw === "") {
|
|
4146
|
+
return { ok: true, stream: "both" };
|
|
4147
|
+
}
|
|
4148
|
+
if (raw === "both" || raw === "stdout" || raw === "stderr") {
|
|
4149
|
+
return { ok: true, stream: raw };
|
|
4150
|
+
}
|
|
4151
|
+
return {
|
|
4152
|
+
ok: false,
|
|
4153
|
+
detail: 'stream must be one of "both", "stdout", or "stderr".'
|
|
4154
|
+
};
|
|
4155
|
+
}
|
|
4156
|
+
function resolveProcessOutputMaxChars(raw) {
|
|
4157
|
+
const n = typeof raw === "number" ? raw : Number(raw);
|
|
4158
|
+
if (!Number.isFinite(n)) return PROCESS_OUTPUT_DEFAULT_MAX_CHARS;
|
|
4159
|
+
return Math.min(
|
|
4160
|
+
PROCESS_OUTPUT_MAX_MAX_CHARS,
|
|
4161
|
+
Math.max(PROCESS_OUTPUT_MIN_MAX_CHARS, Math.floor(n))
|
|
4162
|
+
);
|
|
4163
|
+
}
|
|
4164
|
+
function resolveProcessOutputWaitTimeoutMs(raw, opts) {
|
|
4165
|
+
const minMs = opts?.minMs ?? 0;
|
|
4166
|
+
const defaultMs = opts?.defaultMs ?? PROCESS_OUTPUT_DEFAULT_WAIT_MS;
|
|
4167
|
+
const maxMs = opts?.maxMs ?? PROCESS_OUTPUT_MAX_WAIT_MS;
|
|
4168
|
+
if (raw === void 0 || raw === null || raw === "") {
|
|
4169
|
+
return { timeoutMs: defaultMs, clamped: false };
|
|
4170
|
+
}
|
|
4171
|
+
const n = typeof raw === "number" ? raw : Number(raw);
|
|
4172
|
+
if (!Number.isFinite(n)) {
|
|
4173
|
+
return { timeoutMs: defaultMs, clamped: false };
|
|
4174
|
+
}
|
|
4175
|
+
const floored = Math.floor(n);
|
|
4176
|
+
if (floored < minMs) return { timeoutMs: minMs, clamped: true };
|
|
4177
|
+
if (floored > maxMs) return { timeoutMs: maxMs, clamped: true };
|
|
4178
|
+
return { timeoutMs: floored, clamped: false };
|
|
4179
|
+
}
|
|
4180
|
+
async function waitForLivePattern(args2) {
|
|
4181
|
+
const {
|
|
4182
|
+
taskId,
|
|
4183
|
+
liveOutput,
|
|
4184
|
+
registry,
|
|
4185
|
+
regex,
|
|
4186
|
+
stream,
|
|
4187
|
+
stdoutSeq,
|
|
4188
|
+
stderrSeq,
|
|
4189
|
+
timeoutMs,
|
|
4190
|
+
abortSignal: abortSignal3,
|
|
4191
|
+
now
|
|
4192
|
+
} = args2;
|
|
4193
|
+
const startedAt = now();
|
|
4194
|
+
const elapsed = () => Math.max(0, now() - startedAt);
|
|
4195
|
+
const deadlineMs = startedAt + Math.max(0, timeoutMs);
|
|
4196
|
+
const streams = stream === "both" ? ["stdout", "stderr"] : [stream];
|
|
4197
|
+
const scanned = /* @__PURE__ */ new Map();
|
|
4198
|
+
for (const name of streams) {
|
|
4199
|
+
scanned.set(name, (name === "stdout" ? stdoutSeq : stderrSeq) ?? 0);
|
|
4200
|
+
}
|
|
4201
|
+
let scanIncomplete = false;
|
|
4202
|
+
const isTerminal = () => {
|
|
4203
|
+
if (liveOutput.isClosed()) return true;
|
|
4204
|
+
const record2 = registry.getByTaskId(taskId);
|
|
4205
|
+
return !record2 || isProcessTaskTerminalStatus(record2.status);
|
|
4206
|
+
};
|
|
4207
|
+
const scan2 = () => {
|
|
4208
|
+
const terminal = isTerminal();
|
|
4209
|
+
for (const name of streams) {
|
|
4210
|
+
const ring = liveOutput.ring(name);
|
|
4211
|
+
if (terminal) ring.flush();
|
|
4212
|
+
if (ring.scanIncomplete()) scanIncomplete = true;
|
|
4213
|
+
let lastScanned = scanned.get(name) ?? 0;
|
|
4214
|
+
for (const entry of ring.linesAfter(lastScanned)) {
|
|
4215
|
+
if (entry.matchable === false) {
|
|
4216
|
+
scanIncomplete = true;
|
|
4217
|
+
lastScanned = entry.seq;
|
|
4218
|
+
continue;
|
|
4219
|
+
}
|
|
4220
|
+
const result4 = regex.testBounded(entry.text, { deadlineMs, now });
|
|
4221
|
+
if (result4.lineTruncated) scanIncomplete = true;
|
|
4222
|
+
if (result4.status === "deadline-exceeded") {
|
|
4223
|
+
scanned.set(name, lastScanned);
|
|
4224
|
+
return { match: null, deadline: true };
|
|
4225
|
+
}
|
|
4226
|
+
if (result4.status === "line-budget-exceeded") {
|
|
4227
|
+
scanIncomplete = true;
|
|
4228
|
+
lastScanned = entry.seq;
|
|
4229
|
+
continue;
|
|
4230
|
+
}
|
|
4231
|
+
if (result4.status === "matched") {
|
|
4232
|
+
scanned.set(name, entry.seq);
|
|
4233
|
+
return { match: { stream: name, matchedLine: entry.text }, deadline: false };
|
|
4234
|
+
}
|
|
4235
|
+
lastScanned = entry.seq;
|
|
4236
|
+
}
|
|
4237
|
+
scanned.set(name, lastScanned);
|
|
4238
|
+
}
|
|
4239
|
+
return { match: null, deadline: false };
|
|
4240
|
+
};
|
|
4241
|
+
if (abortSignal3?.aborted) {
|
|
4242
|
+
return { kind: "aborted", waitedMs: elapsed() };
|
|
4243
|
+
}
|
|
4244
|
+
const terminalAtEntry = isTerminal();
|
|
4245
|
+
const immediate = scan2();
|
|
4246
|
+
if (immediate.deadline) {
|
|
4247
|
+
return {
|
|
4248
|
+
kind: abortSignal3?.aborted ? "aborted" : "timeout",
|
|
4249
|
+
waitedMs: elapsed(),
|
|
4250
|
+
...scanIncomplete ? { scanIncomplete: true } : {}
|
|
4251
|
+
};
|
|
4252
|
+
}
|
|
4253
|
+
if (immediate.match) {
|
|
4254
|
+
return {
|
|
4255
|
+
kind: "matched",
|
|
4256
|
+
match: immediate.match,
|
|
4257
|
+
waitedMs: elapsed(),
|
|
4258
|
+
...scanIncomplete ? { scanIncomplete: true } : {}
|
|
4259
|
+
};
|
|
4260
|
+
}
|
|
4261
|
+
if (terminalAtEntry) {
|
|
4262
|
+
return {
|
|
4263
|
+
kind: "exited",
|
|
4264
|
+
waitedMs: elapsed(),
|
|
4265
|
+
...scanIncomplete ? { scanIncomplete: true } : {}
|
|
4266
|
+
};
|
|
4267
|
+
}
|
|
4268
|
+
if (timeoutMs <= 0) {
|
|
4269
|
+
return {
|
|
4270
|
+
kind: "timeout",
|
|
4271
|
+
waitedMs: elapsed(),
|
|
4272
|
+
...scanIncomplete ? { scanIncomplete: true } : {}
|
|
4273
|
+
};
|
|
4274
|
+
}
|
|
4275
|
+
return await new Promise((resolve7) => {
|
|
4276
|
+
let settled = false;
|
|
4277
|
+
let unsubOutput;
|
|
4278
|
+
let unsubTerminal;
|
|
4279
|
+
let timer;
|
|
4280
|
+
const cleanup = () => {
|
|
4281
|
+
unsubOutput?.();
|
|
4282
|
+
unsubTerminal?.();
|
|
4283
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
4284
|
+
abortSignal3?.removeEventListener("abort", onAbort);
|
|
4285
|
+
};
|
|
4286
|
+
const finish = (outcome) => {
|
|
4287
|
+
if (settled) return;
|
|
4288
|
+
settled = true;
|
|
4289
|
+
cleanup();
|
|
4290
|
+
resolve7(outcome);
|
|
4291
|
+
};
|
|
4292
|
+
const incomplete = () => scanIncomplete ? { scanIncomplete: true } : {};
|
|
4293
|
+
const check = () => {
|
|
4294
|
+
if (settled) return;
|
|
4295
|
+
const result4 = scan2();
|
|
4296
|
+
if (result4.match) {
|
|
4297
|
+
finish({ kind: "matched", match: result4.match, waitedMs: elapsed(), ...incomplete() });
|
|
4298
|
+
return;
|
|
4299
|
+
}
|
|
4300
|
+
if (result4.deadline) {
|
|
4301
|
+
finish({
|
|
4302
|
+
kind: abortSignal3?.aborted ? "aborted" : "timeout",
|
|
4303
|
+
waitedMs: elapsed(),
|
|
4304
|
+
...incomplete()
|
|
4305
|
+
});
|
|
4306
|
+
return;
|
|
4307
|
+
}
|
|
4308
|
+
if (isTerminal()) {
|
|
4309
|
+
finish({ kind: "exited", waitedMs: elapsed(), ...incomplete() });
|
|
4310
|
+
}
|
|
4311
|
+
};
|
|
4312
|
+
function onAbort() {
|
|
4313
|
+
finish({ kind: "aborted", waitedMs: elapsed() });
|
|
4314
|
+
}
|
|
4315
|
+
const onTimeout = () => {
|
|
4316
|
+
const result4 = scan2();
|
|
4317
|
+
if (result4.match) {
|
|
4318
|
+
finish({ kind: "matched", match: result4.match, waitedMs: elapsed(), ...incomplete() });
|
|
4319
|
+
} else {
|
|
4320
|
+
finish({ kind: "timeout", waitedMs: elapsed(), ...incomplete() });
|
|
4321
|
+
}
|
|
4322
|
+
};
|
|
4323
|
+
unsubOutput = liveOutput.subscribe(check);
|
|
4324
|
+
unsubTerminal = registry.onProcessTerminal?.((notice) => {
|
|
4325
|
+
if (notice.taskId === taskId) check();
|
|
4326
|
+
});
|
|
4327
|
+
abortSignal3?.addEventListener("abort", onAbort, { once: true });
|
|
4328
|
+
timer = setTimeout(onTimeout, timeoutMs);
|
|
4329
|
+
check();
|
|
4330
|
+
});
|
|
4331
|
+
}
|
|
4332
|
+
async function waitForProcessReady(args2) {
|
|
4333
|
+
const now = args2.now ?? Date.now;
|
|
4334
|
+
const tailMaxChars = args2.tailMaxChars ?? 4e3;
|
|
4335
|
+
const { timeoutMs, clamped } = resolveProcessOutputWaitTimeoutMs(args2.timeoutMs, {
|
|
4336
|
+
minMs: PROCESS_OUTPUT_MIN_READY_WAIT_MS,
|
|
4337
|
+
defaultMs: PROCESS_OUTPUT_DEFAULT_WAIT_MS,
|
|
4338
|
+
maxMs: PROCESS_OUTPUT_MAX_WAIT_MS
|
|
4339
|
+
});
|
|
4340
|
+
const outcome = await waitForLivePattern({
|
|
4341
|
+
taskId: args2.taskId,
|
|
4342
|
+
liveOutput: args2.liveOutput,
|
|
4343
|
+
registry: args2.registry,
|
|
4344
|
+
regex: args2.regex,
|
|
4345
|
+
stream: "both",
|
|
4346
|
+
timeoutMs,
|
|
4347
|
+
abortSignal: args2.abortSignal,
|
|
4348
|
+
now
|
|
4349
|
+
});
|
|
4350
|
+
const record2 = args2.registry.getByTaskId(args2.taskId);
|
|
4351
|
+
const status = record2?.status ?? "exited";
|
|
4352
|
+
const snapshot = args2.liveOutput.readSnapshot({ stream: "both", maxChars: tailMaxChars });
|
|
4353
|
+
return {
|
|
4354
|
+
ready: outcome.kind === "matched",
|
|
4355
|
+
readyOutcome: outcome.kind,
|
|
4356
|
+
status,
|
|
4357
|
+
...record2?.exitCode !== void 0 ? { exitCode: record2.exitCode } : {},
|
|
4358
|
+
...outcome.kind === "matched" ? {
|
|
4359
|
+
matchedStream: outcome.match.stream,
|
|
4360
|
+
matchedLine: outcome.match.matchedLine
|
|
4361
|
+
} : {},
|
|
4362
|
+
waitedMs: outcome.waitedMs,
|
|
4363
|
+
...outcome.kind === "timeout" ? { timeoutMs, ...clamped ? { timeoutClamped: true } : {} } : {},
|
|
4364
|
+
...outcome.kind !== "aborted" && outcome.scanIncomplete ? { scanIncomplete: true } : {},
|
|
4365
|
+
cursor: snapshot.cursor,
|
|
4366
|
+
stdoutTail: snapshot.stdout,
|
|
4367
|
+
stderrTail: snapshot.stderr,
|
|
4368
|
+
truncated: snapshot.truncated
|
|
4369
|
+
};
|
|
4370
|
+
}
|
|
4371
|
+
function scanCapsuleStream(raw, sinceSeq, regex, maxChars) {
|
|
4372
|
+
const clean = stripAnsi(sanitizeToolOutputText(raw));
|
|
4373
|
+
const scrubbed = scrubSecrets(clean).cleaned;
|
|
4374
|
+
const { lines, endsWithNewline } = splitSanitizedLines(scrubbed);
|
|
4375
|
+
const totalLines = lines.length === 0 ? 0 : lines[lines.length - 1].seq;
|
|
4376
|
+
const selected = sinceSeq === void 0 ? lines : lines.filter((line) => line.seq > sinceSeq);
|
|
4377
|
+
const cursorEvicted = sinceSeq !== void 0 && lines.length > 0 && sinceSeq < lines[0].seq - 1;
|
|
4378
|
+
let matchedLine = null;
|
|
4379
|
+
let scanIncomplete = false;
|
|
4380
|
+
if (regex) {
|
|
4381
|
+
for (const line of selected) {
|
|
4382
|
+
const result4 = regex.testBounded(line.text);
|
|
4383
|
+
if (result4.lineTruncated) scanIncomplete = true;
|
|
4384
|
+
if (result4.status === "line-budget-exceeded") {
|
|
4385
|
+
scanIncomplete = true;
|
|
4386
|
+
continue;
|
|
4387
|
+
}
|
|
4388
|
+
if (result4.status === "matched") {
|
|
4389
|
+
matchedLine = line.text;
|
|
4390
|
+
break;
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
}
|
|
4394
|
+
const full = joinRingLines(selected, endsWithNewline);
|
|
4395
|
+
const trimmed = full.length > maxChars;
|
|
4396
|
+
return {
|
|
4397
|
+
matchedLine,
|
|
4398
|
+
text: trimmed ? full.slice(-maxChars) : full,
|
|
4399
|
+
truncated: trimmed || cursorEvicted,
|
|
4400
|
+
cursorEvicted,
|
|
4401
|
+
totalLines,
|
|
4402
|
+
scanIncomplete
|
|
4403
|
+
};
|
|
4404
|
+
}
|
|
4405
|
+
async function runReadProcessOutput(args2) {
|
|
4406
|
+
const now = args2.now ?? Date.now;
|
|
4407
|
+
const { taskId, registry } = args2;
|
|
4408
|
+
const streamParsed = resolveProcessOutputStream(args2.stream);
|
|
4409
|
+
if (!streamParsed.ok) {
|
|
4410
|
+
return { outcome: "invalid-arguments", taskId, detail: streamParsed.detail };
|
|
4411
|
+
}
|
|
4412
|
+
const stream = streamParsed.stream;
|
|
4413
|
+
let stdoutSeq;
|
|
4414
|
+
let stderrSeq;
|
|
4415
|
+
if (args2.cursor !== void 0 && args2.cursor !== null && args2.cursor !== "") {
|
|
4416
|
+
const parsedCursor = parseProcessOutputCursor(args2.cursor);
|
|
4417
|
+
if (!parsedCursor.ok) {
|
|
4418
|
+
return { outcome: "invalid-arguments", taskId, detail: parsedCursor.detail };
|
|
4419
|
+
}
|
|
4420
|
+
stdoutSeq = parsedCursor.stdoutSeq;
|
|
4421
|
+
stderrSeq = parsedCursor.stderrSeq;
|
|
4422
|
+
}
|
|
4423
|
+
let compiledPattern;
|
|
4424
|
+
if (args2.waitForPattern !== void 0 && args2.waitForPattern !== null && args2.waitForPattern !== "") {
|
|
4425
|
+
const compiled = compileProcessOutputPattern(args2.waitForPattern, "waitForPattern");
|
|
4426
|
+
if (!compiled.ok) {
|
|
4427
|
+
return { outcome: "invalid-arguments", taskId, detail: compiled.detail };
|
|
4428
|
+
}
|
|
4429
|
+
compiledPattern = { regex: compiled.regex, pattern: compiled.pattern };
|
|
4430
|
+
}
|
|
4431
|
+
const maxChars = resolveProcessOutputMaxChars(args2.maxChars);
|
|
4432
|
+
const record2 = registry.getByTaskId(taskId);
|
|
4433
|
+
if (!record2) {
|
|
4434
|
+
return {
|
|
4435
|
+
outcome: "not-found",
|
|
4436
|
+
taskId,
|
|
4437
|
+
detail: `No task ${taskId} is known: it was never started or its record was dropped. Call listProcesses to inspect active handles.`
|
|
4438
|
+
};
|
|
4439
|
+
}
|
|
4440
|
+
const liveOutput = registry.getLiveOutput(taskId);
|
|
4441
|
+
if (!liveOutput) {
|
|
4442
|
+
const capsule = record2.resultCapsule;
|
|
4443
|
+
if (!capsule) {
|
|
4444
|
+
return {
|
|
4445
|
+
outcome: "no-live-stream",
|
|
4446
|
+
taskId,
|
|
4447
|
+
status: record2.status,
|
|
4448
|
+
detail: record2.promoted ? `Task ${taskId} is a promoted execShell job without live output streaming; its final output is delivered automatically when it finishes.` : `Task ${taskId} does not have a live output stream attached.`
|
|
4449
|
+
};
|
|
4450
|
+
}
|
|
4451
|
+
const includeStdout = stream === "both" || stream === "stdout";
|
|
4452
|
+
const includeStderr = stream === "both" || stream === "stderr";
|
|
4453
|
+
const hasCursor = stdoutSeq !== void 0 || stderrSeq !== void 0;
|
|
4454
|
+
if (capsule.truncated && hasCursor) {
|
|
4455
|
+
return {
|
|
4456
|
+
outcome: "invalid-arguments",
|
|
4457
|
+
taskId,
|
|
4458
|
+
...capsule.spill ? { outputRef: capsule.spill.displayPath } : {},
|
|
4459
|
+
detail: capsule.spill ? "Cannot align an incremental cursor against a truncated completed-task capsule because exact stream offsets are unavailable, and a truncated capsule tail is never published (pre-truncation context is unknown); read outputRef with readFile instead." : "Cannot align an incremental cursor against a truncated completed-task capsule because exact stream offsets are unavailable, and a truncated capsule tail is never published (pre-truncation context is unknown); no outputRef exists for this task, so no saved tail can be read."
|
|
4460
|
+
};
|
|
4461
|
+
}
|
|
4462
|
+
if (capsule.truncated) {
|
|
4463
|
+
return {
|
|
4464
|
+
outcome: "no-live-stream",
|
|
4465
|
+
taskId,
|
|
4466
|
+
status: record2.status,
|
|
4467
|
+
...record2.exitCode !== void 0 ? { exitCode: record2.exitCode } : {},
|
|
4468
|
+
...capsule.spill ? { outputRef: capsule.spill.displayPath } : {},
|
|
4469
|
+
detail: capsule.spill ? "Task output was truncated before capture; read outputRef with readFile instead of truncated capsule fallback." : "Task output was truncated before capture and no saved tail exists for this task, so the truncated capsule cannot be published or recovered."
|
|
4470
|
+
};
|
|
4471
|
+
}
|
|
4472
|
+
const stdoutView = includeStdout ? scanCapsuleStream(
|
|
4473
|
+
capsule.stdout,
|
|
4474
|
+
stdoutSeq,
|
|
4475
|
+
compiledPattern?.regex ?? null,
|
|
4476
|
+
maxChars
|
|
4477
|
+
) : null;
|
|
4478
|
+
const stderrView = includeStderr ? scanCapsuleStream(
|
|
4479
|
+
capsule.stderr,
|
|
4480
|
+
stderrSeq,
|
|
4481
|
+
compiledPattern?.regex ?? null,
|
|
4482
|
+
maxChars
|
|
4483
|
+
) : null;
|
|
4484
|
+
const capsuleScanIncomplete = Boolean(stdoutView?.scanIncomplete) || Boolean(stderrView?.scanIncomplete);
|
|
4485
|
+
const base = {
|
|
4486
|
+
taskId,
|
|
4487
|
+
status: record2.status,
|
|
4488
|
+
...record2.exitCode !== void 0 ? { exitCode: record2.exitCode } : {},
|
|
4489
|
+
cursor: formatProcessOutputCursor(
|
|
4490
|
+
splitSanitizedLines(capsule.stdout).lines.length,
|
|
4491
|
+
splitSanitizedLines(capsule.stderr).lines.length
|
|
4492
|
+
),
|
|
4493
|
+
stdout: stdoutView?.text ?? "",
|
|
4494
|
+
stderr: stderrView?.text ?? "",
|
|
4495
|
+
truncated: capsule.truncated || Boolean(stdoutView?.truncated) || Boolean(stderrView?.truncated),
|
|
4496
|
+
stdoutTruncated: capsule.truncated || Boolean(stdoutView?.truncated),
|
|
4497
|
+
stderrTruncated: capsule.truncated || Boolean(stderrView?.truncated),
|
|
4498
|
+
cursorEvicted: Boolean(stdoutView?.cursorEvicted) || Boolean(stderrView?.cursorEvicted),
|
|
4499
|
+
stdoutTotalLines: stdoutView?.totalLines ?? 0,
|
|
4500
|
+
stderrTotalLines: stderrView?.totalLines ?? 0,
|
|
4501
|
+
...capsule.spill ? { outputRef: capsule.spill.displayPath } : {},
|
|
4502
|
+
fromCapsule: true
|
|
4503
|
+
};
|
|
4504
|
+
if (!compiledPattern) return { outcome: "ok", ...base };
|
|
4505
|
+
if (stdoutView?.matchedLine != null) {
|
|
4506
|
+
return {
|
|
4507
|
+
outcome: "matched",
|
|
4508
|
+
...base,
|
|
4509
|
+
matchedStream: "stdout",
|
|
4510
|
+
matchedLine: stdoutView.matchedLine,
|
|
4511
|
+
waitedMs: 0,
|
|
4512
|
+
...capsuleScanIncomplete ? { scanIncomplete: true } : {}
|
|
4513
|
+
};
|
|
4514
|
+
}
|
|
4515
|
+
if (stderrView?.matchedLine != null) {
|
|
4516
|
+
return {
|
|
4517
|
+
outcome: "matched",
|
|
4518
|
+
...base,
|
|
4519
|
+
matchedStream: "stderr",
|
|
4520
|
+
matchedLine: stderrView.matchedLine,
|
|
4521
|
+
waitedMs: 0,
|
|
4522
|
+
...capsuleScanIncomplete ? { scanIncomplete: true } : {}
|
|
4523
|
+
};
|
|
4524
|
+
}
|
|
4525
|
+
return {
|
|
4526
|
+
outcome: "exited",
|
|
4527
|
+
...base,
|
|
4528
|
+
waitedMs: 0,
|
|
4529
|
+
...capsuleScanIncomplete ? { scanIncomplete: true } : {}
|
|
4530
|
+
};
|
|
4531
|
+
}
|
|
4532
|
+
if (!compiledPattern) {
|
|
4533
|
+
const snapshot2 = liveOutput.readSnapshot({ stream, stdoutSeq, stderrSeq, maxChars });
|
|
4534
|
+
const outputRef2 = record2.resultCapsule?.spill?.displayPath;
|
|
4535
|
+
return {
|
|
4536
|
+
outcome: "ok",
|
|
4537
|
+
taskId,
|
|
4538
|
+
status: record2.status,
|
|
4539
|
+
...record2.exitCode !== void 0 ? { exitCode: record2.exitCode } : {},
|
|
4540
|
+
...snapshot2,
|
|
4541
|
+
...outputRef2 ? { outputRef: outputRef2 } : {}
|
|
4542
|
+
};
|
|
4543
|
+
}
|
|
4544
|
+
const { timeoutMs, clamped } = resolveProcessOutputWaitTimeoutMs(args2.timeoutMs);
|
|
4545
|
+
const waitResult = await waitForLivePattern({
|
|
4546
|
+
taskId,
|
|
4547
|
+
liveOutput,
|
|
4548
|
+
registry,
|
|
4549
|
+
regex: compiledPattern.regex,
|
|
4550
|
+
stream,
|
|
4551
|
+
stdoutSeq,
|
|
4552
|
+
stderrSeq,
|
|
4553
|
+
timeoutMs,
|
|
4554
|
+
abortSignal: args2.abortSignal,
|
|
4555
|
+
now
|
|
4556
|
+
});
|
|
4557
|
+
const latestRecord = registry.getByTaskId(taskId) ?? record2;
|
|
4558
|
+
const snapshot = liveOutput.readSnapshot({ stream, stdoutSeq, stderrSeq, maxChars });
|
|
4559
|
+
const outputRef = latestRecord.resultCapsule?.spill?.displayPath;
|
|
4560
|
+
if (waitResult.kind === "matched") {
|
|
4561
|
+
return {
|
|
4562
|
+
outcome: "matched",
|
|
4563
|
+
taskId,
|
|
4564
|
+
status: latestRecord.status,
|
|
4565
|
+
...latestRecord.exitCode !== void 0 ? { exitCode: latestRecord.exitCode } : {},
|
|
4566
|
+
matchedStream: waitResult.match.stream,
|
|
4567
|
+
matchedLine: waitResult.match.matchedLine,
|
|
4568
|
+
waitedMs: waitResult.waitedMs,
|
|
4569
|
+
...waitResult.scanIncomplete ? { scanIncomplete: true } : {},
|
|
4570
|
+
...snapshot,
|
|
4571
|
+
...outputRef ? { outputRef } : {}
|
|
4572
|
+
};
|
|
4573
|
+
}
|
|
4574
|
+
if (waitResult.kind === "exited") {
|
|
4575
|
+
return {
|
|
4576
|
+
outcome: "exited",
|
|
4577
|
+
taskId,
|
|
4578
|
+
status: latestRecord.status,
|
|
4579
|
+
...latestRecord.exitCode !== void 0 ? { exitCode: latestRecord.exitCode } : {},
|
|
4580
|
+
waitedMs: waitResult.waitedMs,
|
|
4581
|
+
...waitResult.scanIncomplete ? { scanIncomplete: true } : {},
|
|
4582
|
+
...snapshot,
|
|
4583
|
+
...outputRef ? { outputRef } : {}
|
|
4584
|
+
};
|
|
4585
|
+
}
|
|
4586
|
+
if (waitResult.kind === "aborted") {
|
|
4587
|
+
return {
|
|
4588
|
+
outcome: "aborted",
|
|
4589
|
+
taskId,
|
|
4590
|
+
status: latestRecord.status,
|
|
4591
|
+
waitedMs: waitResult.waitedMs,
|
|
4592
|
+
...snapshot
|
|
4593
|
+
};
|
|
4594
|
+
}
|
|
4595
|
+
return {
|
|
4596
|
+
outcome: "timeout",
|
|
4597
|
+
taskId,
|
|
4598
|
+
status: latestRecord.status,
|
|
4599
|
+
waitedMs: waitResult.waitedMs,
|
|
4600
|
+
timeoutMs,
|
|
4601
|
+
...clamped ? { timeoutClamped: true } : {},
|
|
4602
|
+
...waitResult.scanIncomplete ? { scanIncomplete: true } : {},
|
|
4603
|
+
...snapshot
|
|
4604
|
+
};
|
|
4605
|
+
}
|
|
4606
|
+
|
|
4607
|
+
// packages/agent-runtime/localWorkspaceToolDefs.ts
|
|
4608
|
+
var WORKSPACE_TOOL_NAMES = [
|
|
4609
|
+
"readFile",
|
|
4610
|
+
"read_image",
|
|
4611
|
+
"captureHostWindow",
|
|
4612
|
+
"writeFile",
|
|
4613
|
+
"editFile",
|
|
4614
|
+
"globFiles",
|
|
4615
|
+
"searchFiles",
|
|
4616
|
+
"captureVisualState",
|
|
4617
|
+
"execShell",
|
|
4618
|
+
"launchProcess",
|
|
4619
|
+
"listProcesses",
|
|
4620
|
+
"readProcessOutput",
|
|
4621
|
+
"taskWait",
|
|
4622
|
+
"taskStop",
|
|
4623
|
+
"openDesktopPreview"
|
|
4624
|
+
];
|
|
4625
|
+
var SHELL_TOOL_NAMES = [
|
|
4626
|
+
"execShell",
|
|
4627
|
+
"launchProcess",
|
|
4628
|
+
"listProcesses",
|
|
4629
|
+
"readProcessOutput",
|
|
4630
|
+
"taskWait",
|
|
4631
|
+
"taskStop"
|
|
4632
|
+
];
|
|
4633
|
+
var WORKSPACE_TOOL_NAME_SET = new Set(WORKSPACE_TOOL_NAMES);
|
|
4634
|
+
function buildWorkspacePathProperty() {
|
|
4635
|
+
return {
|
|
4636
|
+
type: "string",
|
|
4637
|
+
minLength: 1,
|
|
4638
|
+
description: "Path relative to the workspace root. Absolute paths and ~/ (home directory) are also accepted. Defaults to workspace root when omitted."
|
|
4639
|
+
};
|
|
4640
|
+
}
|
|
4641
|
+
function buildReadWorkspaceDescription() {
|
|
4642
|
+
return "Read a UTF-8 text file inside the workspace. For multiple known targets, call readFile concurrently in the same turn (use available search or glob tools first when paths or line ranges are uncertain). Absolute paths and ~/ are also accepted (runtime spill files can be read directly). Use lines for focused range reads after search to save tokens. A range already delivered earlier for an unchanged file answers with a short notice instead of resending (force:true refetches).";
|
|
4643
|
+
}
|
|
4644
|
+
function buildReadWorkspaceParameters() {
|
|
4645
|
+
const path = buildWorkspacePathProperty();
|
|
4646
|
+
const lines = {
|
|
4647
|
+
type: "string",
|
|
4648
|
+
description: 'Line slice: "40-120" (range, 1-based, inclusive), "120-" (from line to end), "-50" (tail N lines), "50" (head N lines). Omit to read from the start; large results return a bounded window. Continue from metadata endLine + 1.'
|
|
4649
|
+
};
|
|
4650
|
+
const force = {
|
|
4651
|
+
type: "boolean",
|
|
4652
|
+
description: "Refetch even when the requested range was already delivered earlier and the file is unchanged (e.g. after context compaction)."
|
|
4653
|
+
};
|
|
4654
|
+
return {
|
|
4655
|
+
type: "object",
|
|
4656
|
+
properties: {
|
|
4657
|
+
path,
|
|
4658
|
+
lines,
|
|
4659
|
+
force,
|
|
4660
|
+
raw: {
|
|
4661
|
+
type: "boolean",
|
|
4662
|
+
description: "Read original bytes including full runtime acceptance observations in *.result.md. Default compacts only machine observations; report text and physical line numbers are unchanged."
|
|
4663
|
+
}
|
|
4664
|
+
},
|
|
4665
|
+
required: ["path"]
|
|
4666
|
+
};
|
|
4667
|
+
}
|
|
4668
|
+
function buildReadWorkspaceFileTool() {
|
|
4669
|
+
return {
|
|
4670
|
+
type: "function",
|
|
4671
|
+
function: {
|
|
4672
|
+
name: "readFile",
|
|
4673
|
+
description: buildReadWorkspaceDescription(),
|
|
4674
|
+
parameters: buildReadWorkspaceParameters()
|
|
4675
|
+
}
|
|
4676
|
+
};
|
|
4677
|
+
}
|
|
4678
|
+
function buildWriteWorkspaceFileTool() {
|
|
4679
|
+
return {
|
|
4680
|
+
type: "function",
|
|
4681
|
+
function: {
|
|
4682
|
+
name: "writeFile",
|
|
4683
|
+
description: "Write full UTF-8 file content inside the workspace (new files or whole-file rewrites). Prefer editFile for targeted edits.",
|
|
4684
|
+
parameters: {
|
|
4685
|
+
type: "object",
|
|
4686
|
+
properties: {
|
|
4687
|
+
path: buildWorkspacePathProperty(),
|
|
4688
|
+
content: {
|
|
4689
|
+
type: "string",
|
|
4690
|
+
description: "Full UTF-8 file content to write."
|
|
4691
|
+
}
|
|
4692
|
+
},
|
|
4693
|
+
required: ["path", "content"]
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
};
|
|
4697
|
+
}
|
|
4698
|
+
function buildReplaceWorkspaceTextTool() {
|
|
4699
|
+
return {
|
|
4700
|
+
type: "function",
|
|
4701
|
+
function: {
|
|
4702
|
+
name: "editFile",
|
|
4703
|
+
description: "Replace exact text occurrences in a workspace file. If expected replacement count fails, report the error instead of falling back to a whole-file rewrite.",
|
|
4704
|
+
parameters: {
|
|
4705
|
+
type: "object",
|
|
4706
|
+
properties: {
|
|
4707
|
+
path: buildWorkspacePathProperty(),
|
|
4708
|
+
oldText: {
|
|
4709
|
+
type: "string",
|
|
4710
|
+
description: "Exact text currently present in the file."
|
|
4711
|
+
},
|
|
4712
|
+
newText: {
|
|
4713
|
+
type: "string",
|
|
4714
|
+
description: "Replacement text to write in place of oldText."
|
|
4715
|
+
},
|
|
4716
|
+
expectedReplacements: {
|
|
4717
|
+
type: "integer",
|
|
4718
|
+
minimum: 1,
|
|
4719
|
+
description: "Expected replacement count. Defaults to 1."
|
|
4720
|
+
}
|
|
4721
|
+
// 刻意保持单一声明(integer),不引入 anyOf/oneOf 组合 schema:
|
|
4722
|
+
// provider 对组合 schema 的处理不一致——Gemini 会把无顶层 type 的联合
|
|
4723
|
+
// 节点归并成 type:"object",连原本合法的整数输入都不再符合它的声明;
|
|
4724
|
+
// Fireworks 直接剥掉组合子、只剩描述。
|
|
4725
|
+
},
|
|
4726
|
+
required: ["path", "oldText", "newText"]
|
|
4727
|
+
}
|
|
4728
|
+
}
|
|
4729
|
+
};
|
|
4730
|
+
}
|
|
4731
|
+
function buildGlobWorkspaceDescription() {
|
|
4732
|
+
return "Find file paths by glob pattern without reading file contents. Use brace groups (e.g. '**/*.{ts,tsx}') to match multiple patterns in one call.";
|
|
4733
|
+
}
|
|
4734
|
+
function buildGlobWorkspaceParameters() {
|
|
4735
|
+
const pattern = {
|
|
4736
|
+
type: "string",
|
|
4737
|
+
description: "Glob pattern for files (supports brace groups like '**/*.{ts,tsx}', '**/{package.json,tsconfig*.json}')."
|
|
3031
4738
|
};
|
|
3032
4739
|
const path = buildWorkspacePathProperty();
|
|
3033
4740
|
const includeIgnored = {
|
|
@@ -3120,7 +4827,7 @@ function buildLaunchProcessTool() {
|
|
|
3120
4827
|
type: "function",
|
|
3121
4828
|
function: {
|
|
3122
4829
|
name: "launchProcess",
|
|
3123
|
-
description: "Start a long-running ambient background process (dev server, watcher, REPL) and return immediately with {pid, label, taskId, status}.
|
|
4830
|
+
description: "Start a long-running ambient background process (dev server, watcher, REPL) and return immediately with {pid, label, taskId, status}; with readyPattern it first waits for that regex in stdout/stderr (ANSI stripped) and returns ready/readyOutcome/matchedLine/waitedMs/tails. Boundaries: it registers a tracked background task, but completion does NOT automatically start a new turn \u2014 notice-only by design (an exited dev server must not burn a model turn). A terminal state records the bounded result (exitCode, duration, tails) and it is surfaced as a notice injected only on your next real turn in the same conversation. Inspect with listProcesses, read live logs with readProcessOutput, block for terminal state with taskWait, stop with taskStop. For a finite job (tests, builds, batch) whose result must resume the conversation automatically, use execShell with background: true instead.",
|
|
3124
4831
|
parameters: {
|
|
3125
4832
|
type: "object",
|
|
3126
4833
|
properties: {
|
|
@@ -3135,6 +4842,17 @@ function buildLaunchProcessTool() {
|
|
|
3135
4842
|
persist: {
|
|
3136
4843
|
type: "boolean",
|
|
3137
4844
|
description: "Keep process alive after session/conversation closes. Defaults to false."
|
|
4845
|
+
},
|
|
4846
|
+
readyPattern: {
|
|
4847
|
+
type: "string",
|
|
4848
|
+
minLength: 1,
|
|
4849
|
+
description: "Optional regex to wait for in stdout/stderr (ANSI stripped, line by line) before returning \u2014 e.g. a dev server ready banner. Omit to return immediately. Compiled into a linear-time matcher: backreferences (\\1-\\9) and lookarounds are rejected with `invalid-arguments`; while the process runs only newline-terminated lines are matched."
|
|
4850
|
+
},
|
|
4851
|
+
readyTimeoutMs: {
|
|
4852
|
+
type: "integer",
|
|
4853
|
+
minimum: 100,
|
|
4854
|
+
maximum: 12e4,
|
|
4855
|
+
description: "Optional timeout in milliseconds for readyPattern (default 30000, clamped to 100..120000); on timeout the process keeps running and recent output tails are returned."
|
|
3138
4856
|
}
|
|
3139
4857
|
},
|
|
3140
4858
|
required: ["command"]
|
|
@@ -3174,12 +4892,58 @@ function buildListProcessesTool() {
|
|
|
3174
4892
|
}
|
|
3175
4893
|
};
|
|
3176
4894
|
}
|
|
4895
|
+
function buildReadProcessOutputTool() {
|
|
4896
|
+
return {
|
|
4897
|
+
type: "function",
|
|
4898
|
+
function: {
|
|
4899
|
+
name: "readProcessOutput",
|
|
4900
|
+
description: 'Read live or final stdout/stderr output from a tracked background process (launchProcess dev servers/watchers, promoted execShell tasks), and optionally wait for a regex pattern. Returns {outcome, taskId, status, exitCode?, cursor, stdout, stderr, truncated, cursorEvicted, matchedStream?, matchedLine?, waitedMs?, outputRef?}. Pass the returned `cursor` ("<stdoutLines>:<stderrLines>") to read or wait only on newer output; `cursorEvicted: true` means the 64KB live ring dropped earlier bytes. For inspecting running services and readiness logs \u2014 not for polling finite execShell background jobs (those wake the conversation on completion).',
|
|
4901
|
+
parameters: {
|
|
4902
|
+
type: "object",
|
|
4903
|
+
properties: {
|
|
4904
|
+
taskId: {
|
|
4905
|
+
type: "string",
|
|
4906
|
+
minLength: 1,
|
|
4907
|
+
description: 'Task id from launchProcess or listProcesses (e.g. "ptask-...").'
|
|
4908
|
+
},
|
|
4909
|
+
cursor: {
|
|
4910
|
+
type: "string",
|
|
4911
|
+
description: 'Optional incremental cursor ("<stdoutLines>:<stderrLines>") from a previous read or launchProcess call; omit to read the current tail.'
|
|
4912
|
+
},
|
|
4913
|
+
stream: {
|
|
4914
|
+
type: "string",
|
|
4915
|
+
enum: ["both", "stdout", "stderr"],
|
|
4916
|
+
description: 'Which stream(s) to read or match. Defaults to "both".'
|
|
4917
|
+
},
|
|
4918
|
+
maxChars: {
|
|
4919
|
+
type: "integer",
|
|
4920
|
+
minimum: 256,
|
|
4921
|
+
maximum: 32e3,
|
|
4922
|
+
description: "Maximum characters per stream (default 8000, clamped to 256..32000)."
|
|
4923
|
+
},
|
|
4924
|
+
waitForPattern: {
|
|
4925
|
+
type: "string",
|
|
4926
|
+
minLength: 1,
|
|
4927
|
+
description: "Optional regex to wait for (matched line-by-line, ANSI stripped) until matched, the process exits, or timeoutMs elapses. Linear-time matcher: backreferences (\\1-\\9) and lookarounds are rejected with `invalid-arguments`; while running only newline-terminated lines match."
|
|
4928
|
+
},
|
|
4929
|
+
timeoutMs: {
|
|
4930
|
+
type: "integer",
|
|
4931
|
+
minimum: 0,
|
|
4932
|
+
maximum: 12e4,
|
|
4933
|
+
description: "Wait budget in milliseconds when waitForPattern is set (default 30000, clamped to 0..120000)."
|
|
4934
|
+
}
|
|
4935
|
+
},
|
|
4936
|
+
required: ["taskId"]
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
};
|
|
4940
|
+
}
|
|
3177
4941
|
function buildTaskWaitTool() {
|
|
3178
4942
|
return {
|
|
3179
4943
|
type: "function",
|
|
3180
4944
|
function: {
|
|
3181
4945
|
name: "taskWait",
|
|
3182
|
-
description: 'Block until a background task (from launchProcess, or an execShell command that detached) reaches a terminal state, or until timeoutMs elapses. Returns {outcome, status, exitCode?, cursor, events}: outcome "terminal" with status exited|failed|stopped when it finished, outcome "timeout" with status "running" when it outlived the whole budget, outcome "not-found" for an unknown taskId, or outcome "evicted" when the event trail aged out (never wait again in that case). One call already waits the maximum budget and returns the moment the task ends, so a "timeout" means the task is genuinely longer
|
|
4946
|
+
description: 'Block until a background task (from launchProcess, or an execShell command that detached) reaches a terminal state, or until timeoutMs elapses. Returns {outcome, status, exitCode?, cursor, events}: outcome "terminal" with status exited|failed|stopped when it finished, outcome "timeout" with status "running" when it outlived the whole budget, outcome "not-found" for an unknown taskId, or outcome "evicted" when the event trail aged out (never wait again in that case). One call already waits the maximum budget and returns the moment the task ends, so a "timeout" means the task is genuinely longer \u2014 go do other work and come back rather than re-waiting in a loop (each re-wait costs a full model round-trip). Pass a small timeoutMs for a cheap liveness peek. `cursor` is the highest event seq covered by this response.',
|
|
3183
4947
|
parameters: {
|
|
3184
4948
|
type: "object",
|
|
3185
4949
|
properties: {
|
|
@@ -3290,6 +5054,7 @@ function buildWorkspaceToolDefinition(toolName) {
|
|
|
3290
5054
|
if (toolName === "launchProcess") return buildLaunchProcessTool();
|
|
3291
5055
|
if (toolName === "openDesktopPreview") return buildOpenDesktopPreviewTool();
|
|
3292
5056
|
if (toolName === "listProcesses") return buildListProcessesTool();
|
|
5057
|
+
if (toolName === "readProcessOutput") return buildReadProcessOutputTool();
|
|
3293
5058
|
if (toolName === "taskWait") return buildTaskWaitTool();
|
|
3294
5059
|
if (toolName === "taskStop") return buildTaskStopTool();
|
|
3295
5060
|
return null;
|
|
@@ -4796,54 +6561,9 @@ async function execShellTool(args2) {
|
|
|
4796
6561
|
}
|
|
4797
6562
|
);
|
|
4798
6563
|
}
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
let ring = "";
|
|
4803
|
-
let full = null;
|
|
4804
|
-
let capturedChars = 0;
|
|
4805
|
-
let totalChars = 0;
|
|
4806
|
-
let totalNewlines = 0;
|
|
4807
|
-
return {
|
|
4808
|
-
push(chunk) {
|
|
4809
|
-
const str = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
4810
|
-
if (!str) return;
|
|
4811
|
-
totalChars += str.length;
|
|
4812
|
-
for (let i = 0; i < str.length; i += 1) {
|
|
4813
|
-
if (str.charCodeAt(i) === 10) totalNewlines += 1;
|
|
4814
|
-
}
|
|
4815
|
-
const combined = ring + str;
|
|
4816
|
-
if (combined.length <= LAUNCH_PROCESS_STREAM_RING_CHARS) {
|
|
4817
|
-
ring = combined;
|
|
4818
|
-
return;
|
|
4819
|
-
}
|
|
4820
|
-
if (full === null) {
|
|
4821
|
-
full = [combined];
|
|
4822
|
-
capturedChars = combined.length;
|
|
4823
|
-
} else if (capturedChars < LAUNCH_PROCESS_STREAM_CAPTURE_MAX_CHARS) {
|
|
4824
|
-
const room = LAUNCH_PROCESS_STREAM_CAPTURE_MAX_CHARS - capturedChars;
|
|
4825
|
-
const slice = str.length <= room ? str : str.slice(0, room);
|
|
4826
|
-
full.push(slice);
|
|
4827
|
-
capturedChars += slice.length;
|
|
4828
|
-
}
|
|
4829
|
-
ring = combined.slice(-LAUNCH_PROCESS_STREAM_RING_CHARS);
|
|
4830
|
-
},
|
|
4831
|
-
text() {
|
|
4832
|
-
return full === null ? ring : full.join("");
|
|
4833
|
-
},
|
|
4834
|
-
tailText() {
|
|
4835
|
-
return ring;
|
|
4836
|
-
},
|
|
4837
|
-
evicted() {
|
|
4838
|
-
return full !== null;
|
|
4839
|
-
},
|
|
4840
|
-
totalChars() {
|
|
4841
|
-
return totalChars;
|
|
4842
|
-
},
|
|
4843
|
-
totalLines() {
|
|
4844
|
-
return totalChars > 0 ? totalNewlines + 1 : 0;
|
|
4845
|
-
}
|
|
4846
|
-
};
|
|
6564
|
+
function sanitizeProcessOutputField(text2) {
|
|
6565
|
+
if (!text2) return text2;
|
|
6566
|
+
return scrubSecrets(sanitizeToolOutputText(text2)).cleaned;
|
|
4847
6567
|
}
|
|
4848
6568
|
async function launchProcessTool(args2) {
|
|
4849
6569
|
const parsed = parseWorkspaceToolArguments(args2.call.arguments);
|
|
@@ -4854,7 +6574,22 @@ async function launchProcessTool(args2) {
|
|
|
4854
6574
|
return buildWorkspaceShellEscapeBlockedResult({ command, token: escapeToken });
|
|
4855
6575
|
}
|
|
4856
6576
|
}
|
|
4857
|
-
const
|
|
6577
|
+
const parsedRecord = parsed;
|
|
6578
|
+
let compiledReadyPattern;
|
|
6579
|
+
if (parsedRecord.readyPattern !== void 0 && parsedRecord.readyPattern !== null) {
|
|
6580
|
+
const compiled = compileProcessOutputPattern(parsedRecord.readyPattern, "readyPattern");
|
|
6581
|
+
if (!compiled.ok) {
|
|
6582
|
+
return {
|
|
6583
|
+
content: JSON.stringify({
|
|
6584
|
+
outcome: "invalid-arguments",
|
|
6585
|
+
detail: compiled.detail
|
|
6586
|
+
}),
|
|
6587
|
+
metadata: { command, status: "invalid-arguments", tool: args2.call.name }
|
|
6588
|
+
};
|
|
6589
|
+
}
|
|
6590
|
+
compiledReadyPattern = { regex: compiled.regex, pattern: compiled.pattern };
|
|
6591
|
+
}
|
|
6592
|
+
const labelArg = readTrimmedString(parsedRecord.label);
|
|
4858
6593
|
const label = labelArg || deriveLabel(command);
|
|
4859
6594
|
const persist = readBoolean(parsed, "persist");
|
|
4860
6595
|
const fullCommand = buildWorkspaceShellCommand({
|
|
@@ -4876,14 +6611,19 @@ async function launchProcessTool(args2) {
|
|
|
4876
6611
|
});
|
|
4877
6612
|
const stdoutCapture = createLaunchProcessStreamCapture();
|
|
4878
6613
|
const stderrCapture = createLaunchProcessStreamCapture();
|
|
4879
|
-
|
|
4880
|
-
|
|
6614
|
+
const liveOutput = createProcessLiveOutput({
|
|
6615
|
+
stdout: stdoutCapture,
|
|
6616
|
+
stderr: stderrCapture
|
|
6617
|
+
});
|
|
6618
|
+
proc.stdout?.on("data", (chunk) => liveOutput.pushStdout(chunk));
|
|
6619
|
+
proc.stderr?.on("data", (chunk) => liveOutput.pushStderr(chunk));
|
|
4881
6620
|
proc.stdout?.on("error", () => {
|
|
4882
6621
|
});
|
|
4883
6622
|
proc.stderr?.on("error", () => {
|
|
4884
6623
|
});
|
|
4885
6624
|
const pid = proc.pid;
|
|
4886
6625
|
if (typeof pid !== "number") {
|
|
6626
|
+
liveOutput.markClosed();
|
|
4887
6627
|
return {
|
|
4888
6628
|
content: JSON.stringify({ error: "Failed to spawn child process" }),
|
|
4889
6629
|
metadata: { command, status: "failed" }
|
|
@@ -4901,6 +6641,7 @@ async function launchProcessTool(args2) {
|
|
|
4901
6641
|
// task. Terminal-time resume reads this record, never "current dialog".
|
|
4902
6642
|
owner: readProcessOwner(args2.call.runtimeContext)
|
|
4903
6643
|
});
|
|
6644
|
+
registry.attachLiveOutput(envelope.taskId, liveOutput);
|
|
4904
6645
|
const cleanupChildOnHostSignal = (signal) => {
|
|
4905
6646
|
try {
|
|
4906
6647
|
if (detached) {
|
|
@@ -4953,9 +6694,60 @@ async function launchProcessTool(args2) {
|
|
|
4953
6694
|
});
|
|
4954
6695
|
} catch {
|
|
4955
6696
|
}
|
|
4956
|
-
|
|
6697
|
+
liveOutput.releaseFullCapture();
|
|
6698
|
+
registry.markExited(pid, exitCode, capsule, envelope.taskId);
|
|
4957
6699
|
});
|
|
4958
6700
|
const activity = extractActivity(parsed);
|
|
6701
|
+
if (compiledReadyPattern) {
|
|
6702
|
+
const readyResult = await waitForProcessReady({
|
|
6703
|
+
taskId: envelope.taskId,
|
|
6704
|
+
liveOutput,
|
|
6705
|
+
registry,
|
|
6706
|
+
regex: compiledReadyPattern.regex,
|
|
6707
|
+
timeoutMs: parsedRecord.readyTimeoutMs,
|
|
6708
|
+
abortSignal: args2.abortSignal
|
|
6709
|
+
});
|
|
6710
|
+
const safeMatchedLine = readyResult.matchedLine !== void 0 ? sanitizeProcessOutputField(readyResult.matchedLine) : void 0;
|
|
6711
|
+
const safeStdoutTail = sanitizeProcessOutputField(readyResult.stdoutTail);
|
|
6712
|
+
const safeStderrTail = sanitizeProcessOutputField(readyResult.stderrTail);
|
|
6713
|
+
const resultData2 = {
|
|
6714
|
+
pid,
|
|
6715
|
+
label,
|
|
6716
|
+
taskId: envelope.taskId,
|
|
6717
|
+
status: readyResult.status,
|
|
6718
|
+
...readyResult.exitCode !== void 0 ? { exitCode: readyResult.exitCode } : {},
|
|
6719
|
+
ready: readyResult.ready,
|
|
6720
|
+
readyOutcome: readyResult.readyOutcome,
|
|
6721
|
+
...readyResult.matchedStream ? { matchedStream: readyResult.matchedStream } : {},
|
|
6722
|
+
...safeMatchedLine !== void 0 ? { matchedLine: safeMatchedLine } : {},
|
|
6723
|
+
waitedMs: readyResult.waitedMs,
|
|
6724
|
+
...readyResult.timeoutMs !== void 0 ? { timeoutMs: readyResult.timeoutMs } : {},
|
|
6725
|
+
...readyResult.timeoutClamped ? { timeoutClamped: true } : {},
|
|
6726
|
+
cursor: readyResult.cursor,
|
|
6727
|
+
stdoutTail: safeStdoutTail,
|
|
6728
|
+
stderrTail: safeStderrTail,
|
|
6729
|
+
truncated: readyResult.truncated,
|
|
6730
|
+
...readyResult.scanIncomplete ? { scanIncomplete: true } : {}
|
|
6731
|
+
};
|
|
6732
|
+
return {
|
|
6733
|
+
content: JSON.stringify(resultData2),
|
|
6734
|
+
metadata: {
|
|
6735
|
+
command,
|
|
6736
|
+
pid,
|
|
6737
|
+
label,
|
|
6738
|
+
status: readyResult.status,
|
|
6739
|
+
taskId: envelope.taskId,
|
|
6740
|
+
ready: readyResult.ready,
|
|
6741
|
+
readyOutcome: readyResult.readyOutcome,
|
|
6742
|
+
waitedMs: readyResult.waitedMs,
|
|
6743
|
+
executionState: readyResult.status === "running" ? "background" : "terminal",
|
|
6744
|
+
trackedBackgroundTask: true,
|
|
6745
|
+
completionNotification: "next-turn-notice",
|
|
6746
|
+
processLaunch: { pid, label, taskId: envelope.taskId, status: readyResult.status },
|
|
6747
|
+
...activity ? { activity } : {}
|
|
6748
|
+
}
|
|
6749
|
+
};
|
|
6750
|
+
}
|
|
4959
6751
|
const resultData = { pid, label, taskId: envelope.taskId, status: "running" };
|
|
4960
6752
|
return {
|
|
4961
6753
|
content: JSON.stringify(resultData),
|
|
@@ -4987,6 +6779,38 @@ async function listProcessesTool(args2) {
|
|
|
4987
6779
|
}
|
|
4988
6780
|
};
|
|
4989
6781
|
}
|
|
6782
|
+
async function readProcessOutputTool(args2) {
|
|
6783
|
+
const parsed = parseWorkspaceToolArguments(args2.call.arguments);
|
|
6784
|
+
const taskId = requireTaskId(parsed);
|
|
6785
|
+
if (!taskId) return missingTaskIdResult(args2.call.name);
|
|
6786
|
+
const result4 = await runReadProcessOutput({
|
|
6787
|
+
taskId,
|
|
6788
|
+
cursor: parsed.cursor,
|
|
6789
|
+
stream: parsed.stream,
|
|
6790
|
+
maxChars: parsed.maxChars,
|
|
6791
|
+
waitForPattern: parsed.waitForPattern,
|
|
6792
|
+
timeoutMs: parsed.timeoutMs,
|
|
6793
|
+
registry: getProcessRegistry(),
|
|
6794
|
+
abortSignal: args2.abortSignal
|
|
6795
|
+
});
|
|
6796
|
+
const sanitized = "stdout" in result4 ? {
|
|
6797
|
+
...result4,
|
|
6798
|
+
stdout: sanitizeProcessOutputField(result4.stdout),
|
|
6799
|
+
stderr: sanitizeProcessOutputField(result4.stderr),
|
|
6800
|
+
..."matchedLine" in result4 && result4.matchedLine !== void 0 ? { matchedLine: sanitizeProcessOutputField(result4.matchedLine) } : {}
|
|
6801
|
+
} : result4;
|
|
6802
|
+
return {
|
|
6803
|
+
content: JSON.stringify(sanitized),
|
|
6804
|
+
metadata: {
|
|
6805
|
+
taskId,
|
|
6806
|
+
outcome: sanitized.outcome,
|
|
6807
|
+
..."status" in sanitized && sanitized.status ? { status: sanitized.status } : {},
|
|
6808
|
+
..."cursor" in sanitized && sanitized.cursor ? { cursor: sanitized.cursor } : {},
|
|
6809
|
+
..."exitCode" in sanitized && sanitized.exitCode !== void 0 ? { exitCode: sanitized.exitCode } : {},
|
|
6810
|
+
..."waitedMs" in sanitized && sanitized.waitedMs !== void 0 ? { waitedMs: sanitized.waitedMs } : {}
|
|
6811
|
+
}
|
|
6812
|
+
};
|
|
6813
|
+
}
|
|
4990
6814
|
function requireTaskId(parsed) {
|
|
4991
6815
|
return readTrimmedString(parsed.taskId);
|
|
4992
6816
|
}
|
|
@@ -5276,11 +7100,16 @@ function createLocalWorkspaceToolExecutors(args2) {
|
|
|
5276
7100
|
call,
|
|
5277
7101
|
workspaceRoot: args2.workspaceRoot,
|
|
5278
7102
|
commandPrefix: args2.commandPrefix,
|
|
5279
|
-
restrictToWorkspace: args2.restrictShellToWorkspace
|
|
7103
|
+
restrictToWorkspace: args2.restrictShellToWorkspace,
|
|
7104
|
+
abortSignal: args2.abortSignal
|
|
5280
7105
|
}),
|
|
5281
7106
|
listProcesses: (call) => listProcessesTool({
|
|
5282
7107
|
call
|
|
5283
7108
|
}),
|
|
7109
|
+
readProcessOutput: (call) => readProcessOutputTool({
|
|
7110
|
+
call,
|
|
7111
|
+
abortSignal: args2.abortSignal
|
|
7112
|
+
}),
|
|
5284
7113
|
taskWait: (call) => taskWaitTool({ call }),
|
|
5285
7114
|
taskLogs: (call) => taskLogsTool({
|
|
5286
7115
|
call,
|
|
@@ -5493,6 +7322,7 @@ var DEFAULT_LOCAL_TOOLS = /* @__PURE__ */ new Set([
|
|
|
5493
7322
|
"execShell",
|
|
5494
7323
|
"launchProcess",
|
|
5495
7324
|
"listProcesses",
|
|
7325
|
+
"readProcessOutput",
|
|
5496
7326
|
// ProcessTask follow-up tools. Same tier as listProcesses: they observe/stop
|
|
5497
7327
|
// tasks the agent itself already spawned, so their blast radius is strictly
|
|
5498
7328
|
// narrower than launchProcess (which is default-enabled). Model-facing
|
|
@@ -20982,6 +22812,7 @@ var CONCURRENT_READONLY_TOOLS = /* @__PURE__ */ new Set([
|
|
|
20982
22812
|
"cliWhoami",
|
|
20983
22813
|
"cliDoctor",
|
|
20984
22814
|
"listProcesses",
|
|
22815
|
+
"readProcessOutput",
|
|
20985
22816
|
"fetchWebpage",
|
|
20986
22817
|
"exa_search"
|
|
20987
22818
|
]);
|
|
@@ -21342,7 +23173,10 @@ async function runLocalAgentTurn(input) {
|
|
|
21342
23173
|
// 主 Agent 强弱姿态:本地宿主能直读当前会话模型(agentConfig.model,会话内
|
|
21343
23174
|
// 恒定),显式透传后由 resolveToolGuidedSections 按档位追加一句短指引;
|
|
21344
23175
|
// 模型缺失/推不出档位时不追加文本,前缀缓存稳定性不受影响。
|
|
21345
|
-
callerModel: agentConfig.model
|
|
23176
|
+
callerModel: agentConfig.model,
|
|
23177
|
+
// 池顶姿态:宿主启动会话时按内存中已有的候选池算一次(零网络 I/O),
|
|
23178
|
+
// 会话内恒定;不传时不改动任何既有字节。
|
|
23179
|
+
callerIsPoolTop: input.callerIsPoolTop
|
|
21346
23180
|
});
|
|
21347
23181
|
const callerScopes = normalizeContextBlockScopes(
|
|
21348
23182
|
input.contextBlocks,
|
|
@@ -23889,7 +25723,7 @@ async function saveCliPendingUserMessages(args2) {
|
|
|
23889
25723
|
if (ops.length) await args2.store.batch(ops);
|
|
23890
25724
|
}
|
|
23891
25725
|
async function readCliPendingUserMessages(store, dialogId) {
|
|
23892
|
-
const { readDialogMessageRecords } = await import("./cliLocalAgentRecordReader-
|
|
25726
|
+
const { readDialogMessageRecords } = await import("./cliLocalAgentRecordReader-Q6677YID.js");
|
|
23893
25727
|
const rows = await readDialogMessageRecords({ store, dialogId });
|
|
23894
25728
|
const uncertain = rows.filter(({ record: record2 }) => record2.metadata?.cliBatchPhase === "requested" && !record2.metadata?.cliBatchResolution);
|
|
23895
25729
|
const recovery = uncertain.length ? {
|
|
@@ -24188,10 +26022,10 @@ function buildLoadSkillExecutor(args2) {
|
|
|
24188
26022
|
metadata: { loadSkill: true, resolved: false }
|
|
24189
26023
|
};
|
|
24190
26024
|
}
|
|
24191
|
-
const { resolveSkillByName } = await import("./skillDiscovery-
|
|
26025
|
+
const { resolveSkillByName } = await import("./skillDiscovery-5GEGWJ6N.js");
|
|
24192
26026
|
const resolved = resolveSkillByName(args2.cwd, name);
|
|
24193
26027
|
if (!resolved) {
|
|
24194
|
-
const { resolveBuiltinSkillByName } = await import("./builtinSkillRegistry-
|
|
26028
|
+
const { resolveBuiltinSkillByName } = await import("./builtinSkillRegistry-FVEEO4U2.js");
|
|
24195
26029
|
const builtin = resolveBuiltinSkillByName(name);
|
|
24196
26030
|
if (builtin) {
|
|
24197
26031
|
const denied = await rejectDisabledBuiltin(args2.agentSkillSource, builtin.slug, name, args2.resolveAgentSkillSource);
|
|
@@ -24270,7 +26104,7 @@ async function loadPreciseSkill(cwd, parsed, agentSkillSource, resolveAgentSkill
|
|
|
24270
26104
|
if (!nonEmpty(parsed.slug) || has2("projectBinding") || has2("relativePath")) {
|
|
24271
26105
|
return reject("builtin requires only an exact slug.");
|
|
24272
26106
|
}
|
|
24273
|
-
const { listBuiltinSkills } = await import("./builtinSkillRegistry-
|
|
26107
|
+
const { listBuiltinSkills } = await import("./builtinSkillRegistry-FVEEO4U2.js");
|
|
24274
26108
|
const builtin = listBuiltinSkills().find((entry) => entry.slug === parsed.slug);
|
|
24275
26109
|
if (!builtin) return reject("builtin slug not found.");
|
|
24276
26110
|
const denied = await rejectDisabledBuiltin(agentSkillSource, builtin.slug, builtin.slug, resolveAgentSkillSource);
|
|
@@ -24336,7 +26170,7 @@ ${body}`,
|
|
|
24336
26170
|
}
|
|
24337
26171
|
}
|
|
24338
26172
|
async function formatUnknownSkillMessage(cwd, requestedName) {
|
|
24339
|
-
const { discoverSkills } = await import("./skillDiscovery-
|
|
26173
|
+
const { discoverSkills } = await import("./skillDiscovery-5GEGWJ6N.js");
|
|
24340
26174
|
let available = [];
|
|
24341
26175
|
try {
|
|
24342
26176
|
available = discoverSkills(cwd).map((s) => s.name);
|