test(agents): share pi-tools sandbox fixture context

This commit is contained in:
Peter Steinberger
2026-02-19 09:21:33 +00:00
parent bf3f8ec428
commit b96419fab9
5 changed files with 97 additions and 72 deletions

View File

@@ -4,6 +4,7 @@ import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { createOpenClawCodingTools } from "./pi-tools.js";
import { createHostSandboxFsBridge } from "./test-helpers/host-sandbox-fs-bridge.js";
import { createPiToolsSandboxContext } from "./test-helpers/pi-tools-sandbox-context.js";
vi.mock("../infra/shell-env.js", async (importOriginal) => {
const mod = await importOriginal<typeof import("../infra/shell-env.js")>();
@@ -157,29 +158,13 @@ describe("sandboxed workspace paths", () => {
it("uses sandbox workspace for relative read/write/edit", async () => {
await withTempDir("openclaw-sandbox-", async (sandboxDir) => {
await withTempDir("openclaw-workspace-", async (workspaceDir) => {
const sandbox = {
enabled: true,
sessionKey: "sandbox:test",
const sandbox = createPiToolsSandboxContext({
workspaceDir: sandboxDir,
agentWorkspaceDir: workspaceDir,
workspaceAccess: "rw" as const,
containerName: "openclaw-sbx-test",
containerWorkdir: "/workspace",
fsBridge: createHostSandboxFsBridge(sandboxDir),
docker: {
image: "openclaw-sandbox:bookworm-slim",
containerPrefix: "openclaw-sbx-",
workdir: "/workspace",
readOnlyRoot: true,
tmpfs: [],
network: "none",
user: "1000:1000",
capDrop: ["ALL"],
env: { LANG: "C.UTF-8" },
},
tools: { allow: [], deny: [] },
browserAllowHostControl: false,
};
});
const testFile = "sandbox.txt";
await fs.writeFile(path.join(sandboxDir, testFile), "sandbox read", "utf8");