




















@@ -11,19 +11,18 @@ const scriptPath = path.join(repoRoot, "scripts/e2e/lib/run-with-pty.mjs");
1111function runPtyProbe(
1212logPath: string,
1313env: Record<string, string> = {},
14+command: string[] = [
15+"/bin/bash",
16+"-lc",
17+'printf "prompt\\n"; IFS= read -r value; printf "got:%s\\n" "$value"',
18+],
19+input = "abc\n",
1420): Promise<{ code: number | null; stdout: string; stderr: string }> {
1521return new Promise((resolve, reject) => {
16-const child = spawn(
17-process.execPath,
18-[
19-scriptPath,
20-logPath,
21-"/bin/bash",
22-"-lc",
23-'printf "prompt\\n"; IFS= read -r value; printf "got:%s\\n" "$value"',
24-],
25-{ env: { ...process.env, ...env }, stdio: ["pipe", "pipe", "pipe"] },
26-);
22+const child = spawn(process.execPath, [scriptPath, logPath, ...command], {
23+env: { ...process.env, ...env },
24+stdio: ["pipe", "pipe", "pipe"],
25+});
2726let stdout = "";
2827let stderr = "";
2928const timeout = setTimeout(() => {
@@ -47,7 +46,7 @@ function runPtyProbe(
4746clearTimeout(timeout);
4847resolve({ code, stdout, stderr });
4948});
50-child.stdin.end("abc\n");
49+child.stdin.end(input);
5150});
5251}
5352@@ -81,4 +80,27 @@ describe("run-with-pty", () => {
8180await rm(tempRoot, { recursive: true, force: true });
8281}
8382});
83+84+it("caps noisy PTY output in stdout and transcript logs", async () => {
85+const tempRoot = await mkdtemp(path.join(os.tmpdir(), "openclaw-run-with-pty-"));
86+const logPath = path.join(tempRoot, "pty.log");
87+try {
88+const result = await runPtyProbe(
89+logPath,
90+{ OPENCLAW_E2E_PTY_OUTPUT_MAX_BYTES: "64" },
91+[process.execPath, "-e", "process.stdout.write('x'.repeat(2048))"],
92+"",
93+);
94+const log = await readFile(logPath, "utf8");
95+const marker = "[run-with-pty output truncated after 64 bytes]";
96+97+expect(result).toMatchObject({ code: 0, stderr: "" });
98+expect(result.stdout).toContain(marker);
99+expect(log).toContain(marker);
100+expect(result.stdout.length).toBeLessThan(512);
101+expect(log.length).toBeLessThan(512);
102+} finally {
103+await rm(tempRoot, { recursive: true, force: true });
104+}
105+});
84106});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。