





















@@ -17,6 +17,16 @@ function currentEnv(): Record<string, string> {
1717return env;
1818}
191920+function shellQuote(value: string): string {
21+return `'${value.replaceAll("'", process.platform === "win32" ? "''" : "'\\''")}'`;
22+}
23+24+function currentNodeEvalCommand(source: string): string {
25+const node = shellQuote(process.execPath);
26+const script = shellQuote(source);
27+return process.platform === "win32" ? `& ${node} -e ${script}` : `${node} -e ${script}`;
28+}
29+2030async function startPtySession(command: string) {
2131const processTool = createProcessTool();
2232const run = await runExecProcess({
@@ -64,7 +74,9 @@ async function waitForSessionCompletion(params: {
64746575test("process send-keys encodes Enter for pty sessions", async () => {
6676const { processTool, sessionId } = await startPtySession(
67-'node -e "const dataEvent=String.fromCharCode(100,97,116,97);process.stdin.on(dataEvent,d=>{process.stdout.write(d);if(d.includes(10)||d.includes(13))process.exit(0);});"',
77+currentNodeEvalCommand(
78+"const dataEvent=String.fromCharCode(100,97,116,97);process.stdin.on(dataEvent,d=>{process.stdout.write(d);if(d.includes(10)||d.includes(13))process.exit(0);});",
79+),
6880);
69817082await processTool.execute("toolcall", {
@@ -78,7 +90,9 @@ test("process send-keys encodes Enter for pty sessions", async () => {
78907991test("process submit sends Enter for pty sessions", async () => {
8092const { processTool, sessionId } = await startPtySession(
81-'node -e "const dataEvent=String.fromCharCode(100,97,116,97);const submitted=String.fromCharCode(115,117,98,109,105,116,116,101,100);process.stdin.on(dataEvent,d=>{if(d.includes(10)||d.includes(13)){process.stdout.write(submitted);process.exit(0);}});"',
93+currentNodeEvalCommand(
94+"const dataEvent=String.fromCharCode(100,97,116,97);const submitted=String.fromCharCode(115,117,98,109,105,116,116,101,100);process.stdin.on(dataEvent,d=>{if(d.includes(10)||d.includes(13)){process.stdout.write(submitted);process.exit(0);}});",
95+),
8296);
83978498await processTool.execute("toolcall", {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。