mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-11 16:56:07 +00:00
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
/**
|
|
* Tests baseline tool availability for assembled agent tools.
|
|
* Ensures control-plane tools remain present and node-originated runs receive
|
|
* the restricted node-safe subset.
|
|
*/
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import "./test-helpers/fast-coding-tools.js";
|
|
import "./test-helpers/fast-openclaw-tools.js";
|
|
import { createOpenClawCodingTools } from "./agent-tools.js";
|
|
|
|
vi.mock("./channel-tools.js", () => {
|
|
const passthrough = <T>(tool: T) => tool;
|
|
const stubTool = (name: string) => ({
|
|
name,
|
|
description: `${name} stub`,
|
|
parameters: { type: "object", properties: {} },
|
|
execute: vi.fn(),
|
|
});
|
|
return {
|
|
listChannelAgentTools: () => [stubTool("plugin_login")],
|
|
copyChannelAgentToolMeta: passthrough,
|
|
getChannelAgentToolMeta: () => undefined,
|
|
};
|
|
});
|
|
|
|
describe("tool availability", () => {
|
|
it("keeps control-plane tools available", () => {
|
|
const tools = createOpenClawCodingTools();
|
|
const toolNames = tools.map((tool) => tool.name);
|
|
expect(toolNames).toContain("plugin_login");
|
|
expect(toolNames).toContain("cron");
|
|
expect(toolNames).toContain("gateway");
|
|
expect(toolNames).toContain("nodes");
|
|
});
|
|
|
|
it("keeps canvas available by current trust model", () => {
|
|
const tools = createOpenClawCodingTools();
|
|
const toolNames = tools.map((tool) => tool.name);
|
|
expect(toolNames).toContain("canvas");
|
|
});
|
|
|
|
it("restricts node-originated runs to the node-safe tool subset", () => {
|
|
const tools = createOpenClawCodingTools({ messageProvider: "node" });
|
|
const toolNames = tools.map((tool) => tool.name);
|
|
expect(toolNames).toContain("canvas");
|
|
expect(toolNames).not.toContain("exec");
|
|
expect(toolNames).not.toContain("read");
|
|
expect(toolNames).not.toContain("write");
|
|
expect(toolNames).not.toContain("edit");
|
|
expect(toolNames).not.toContain("message");
|
|
expect(toolNames).not.toContain("sessions_send");
|
|
expect(toolNames).not.toContain("subagents");
|
|
});
|
|
});
|