Files
openclaw/src/agents/tool-fs-policy.test.ts
2026-02-24 15:14:05 +00:00

51 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { resolveEffectiveToolFsWorkspaceOnly } from "./tool-fs-policy.js";
describe("resolveEffectiveToolFsWorkspaceOnly", () => {
it("returns false by default when tools.fs.workspaceOnly is unset", () => {
expect(resolveEffectiveToolFsWorkspaceOnly({ cfg: {}, agentId: "main" })).toBe(false);
});
it("uses global tools.fs.workspaceOnly when no agent override exists", () => {
const cfg: OpenClawConfig = {
tools: { fs: { workspaceOnly: true } },
};
expect(resolveEffectiveToolFsWorkspaceOnly({ cfg, agentId: "main" })).toBe(true);
});
it("prefers agent-specific tools.fs.workspaceOnly override over global setting", () => {
const cfg: OpenClawConfig = {
tools: { fs: { workspaceOnly: true } },
agents: {
list: [
{
id: "main",
tools: {
fs: { workspaceOnly: false },
},
},
],
},
};
expect(resolveEffectiveToolFsWorkspaceOnly({ cfg, agentId: "main" })).toBe(false);
});
it("supports agent-specific enablement when global workspaceOnly is off", () => {
const cfg: OpenClawConfig = {
tools: { fs: { workspaceOnly: false } },
agents: {
list: [
{
id: "main",
tools: {
fs: { workspaceOnly: true },
},
},
],
},
};
expect(resolveEffectiveToolFsWorkspaceOnly({ cfg, agentId: "main" })).toBe(true);
});
});