mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 22:46:39 +00:00
refactor: unify tools.fs workspaceOnly resolution
This commit is contained in:
50
src/agents/tool-fs-policy.test.ts
Normal file
50
src/agents/tool-fs-policy.test.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user