2026-01-17 04:57:04 +00:00
|
|
|
import { afterEach, expect, test } from "vitest";
|
2026-02-17 14:33:38 +09:00
|
|
|
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
|
|
|
|
|
import { createExecTool } from "./bash-tools.exec.js";
|
2026-01-17 04:57:04 +00:00
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
resetProcessRegistryForTests();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("exec supports pty output", async () => {
|
2026-02-22 10:37:44 +00:00
|
|
|
const tool = createExecTool({ allowBackground: false, security: "full", ask: "off" });
|
2026-01-17 04:57:04 +00:00
|
|
|
const result = await tool.execute("toolcall", {
|
2026-01-17 08:10:44 +00:00
|
|
|
command: 'node -e "process.stdout.write(String.fromCharCode(111,107))"',
|
2026-01-17 04:57:04 +00:00
|
|
|
pty: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(result.details.status).toBe("completed");
|
2026-02-17 15:49:00 +09:00
|
|
|
const text = result.content?.find((item) => item.type === "text")?.text ?? "";
|
2026-01-17 04:57:04 +00:00
|
|
|
expect(text).toContain("ok");
|
|
|
|
|
});
|
2026-03-01 20:31:06 -08:00
|
|
|
|
|
|
|
|
test("exec sets OPENCLAW_SHELL in pty mode", async () => {
|
|
|
|
|
const tool = createExecTool({ allowBackground: false, security: "full", ask: "off" });
|
|
|
|
|
const result = await tool.execute("toolcall-openclaw-shell", {
|
|
|
|
|
command: "node -e \"process.stdout.write(process.env.OPENCLAW_SHELL || '')\"",
|
|
|
|
|
pty: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(result.details.status).toBe("completed");
|
|
|
|
|
const text = result.content?.find((item) => item.type === "text")?.text ?? "";
|
|
|
|
|
expect(text).toContain("exec");
|
|
|
|
|
});
|