fix(tools): honor agent tool denylist without sandbox
This commit is contained in:
@@ -195,4 +195,12 @@ describe("createClawdbotCodingTools", () => {
|
|||||||
expect(tools.some((tool) => tool.name === "read")).toBe(false);
|
expect(tools.some((tool) => tool.name === "read")).toBe(false);
|
||||||
expect(tools.some((tool) => tool.name === "browser")).toBe(false);
|
expect(tools.some((tool) => tool.name === "browser")).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("filters tools by agent tool policy even without sandbox", () => {
|
||||||
|
const tools = createClawdbotCodingTools({
|
||||||
|
config: { agent: { tools: { deny: ["browser"] } } },
|
||||||
|
});
|
||||||
|
expect(tools.some((tool) => tool.name === "bash")).toBe(true);
|
||||||
|
expect(tools.some((tool) => tool.name === "browser")).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -509,8 +509,14 @@ export function createClawdbotCodingTools(options?: {
|
|||||||
if (tool.name === "slack") return allowSlack;
|
if (tool.name === "slack") return allowSlack;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
const globallyFiltered =
|
||||||
|
options?.config?.agent?.tools &&
|
||||||
|
(options.config.agent.tools.allow?.length ||
|
||||||
|
options.config.agent.tools.deny?.length)
|
||||||
|
? filterToolsByPolicy(filtered, options.config.agent.tools)
|
||||||
|
: filtered;
|
||||||
const sandboxed = sandbox
|
const sandboxed = sandbox
|
||||||
? filterToolsByPolicy(filtered, sandbox.tools)
|
? filterToolsByPolicy(globallyFiltered, sandbox.tools)
|
||||||
: filtered;
|
: globallyFiltered;
|
||||||
return sandboxed.map(normalizeToolParameters);
|
return sandboxed.map(normalizeToolParameters);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -816,6 +816,11 @@ export type ClawdbotConfig = {
|
|||||||
maxAgeDays?: number;
|
maxAgeDays?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
/** Global tool allow/deny policy for all providers (deny wins). */
|
||||||
|
tools?: {
|
||||||
|
allow?: string[];
|
||||||
|
deny?: string[];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
routing?: RoutingConfig;
|
routing?: RoutingConfig;
|
||||||
messages?: MessagesConfig;
|
messages?: MessagesConfig;
|
||||||
|
|||||||
@@ -370,6 +370,12 @@ export const ClawdbotSchema = z.object({
|
|||||||
modelFallbacks: z.array(z.string()).optional(),
|
modelFallbacks: z.array(z.string()).optional(),
|
||||||
imageModelFallbacks: z.array(z.string()).optional(),
|
imageModelFallbacks: z.array(z.string()).optional(),
|
||||||
contextTokens: z.number().int().positive().optional(),
|
contextTokens: z.number().int().positive().optional(),
|
||||||
|
tools: z
|
||||||
|
.object({
|
||||||
|
allow: z.array(z.string()).optional(),
|
||||||
|
deny: z.array(z.string()).optional(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
thinkingDefault: z
|
thinkingDefault: z
|
||||||
.union([
|
.union([
|
||||||
z.literal("off"),
|
z.literal("off"),
|
||||||
|
|||||||
Reference in New Issue
Block a user