refactor!: drop clawdis_ tool prefix
This commit is contained in:
@@ -2,17 +2,17 @@ import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { createClawdisTools } from "./clawdis-tools.js";
|
||||
|
||||
describe("clawdis_gateway tool", () => {
|
||||
describe("gateway tool", () => {
|
||||
it("schedules SIGUSR1 restart", async () => {
|
||||
vi.useFakeTimers();
|
||||
const kill = vi.spyOn(process, "kill").mockImplementation(() => true);
|
||||
|
||||
try {
|
||||
const tool = createClawdisTools().find(
|
||||
(candidate) => candidate.name === "clawdis_gateway",
|
||||
(candidate) => candidate.name === "gateway",
|
||||
);
|
||||
expect(tool).toBeDefined();
|
||||
if (!tool) throw new Error("missing clawdis_gateway tool");
|
||||
if (!tool) throw new Error("missing gateway tool");
|
||||
|
||||
const result = await tool.execute("call1", {
|
||||
action: "restart",
|
||||
|
||||
@@ -12,7 +12,7 @@ vi.mock("../media/image-ops.js", () => ({
|
||||
|
||||
import { createClawdisTools } from "./clawdis-tools.js";
|
||||
|
||||
describe("clawdis_nodes camera_snap", () => {
|
||||
describe("nodes camera_snap", () => {
|
||||
beforeEach(() => {
|
||||
callGateway.mockReset();
|
||||
});
|
||||
@@ -36,9 +36,9 @@ describe("clawdis_nodes camera_snap", () => {
|
||||
});
|
||||
|
||||
const tool = createClawdisTools().find(
|
||||
(candidate) => candidate.name === "clawdis_nodes",
|
||||
(candidate) => candidate.name === "nodes",
|
||||
);
|
||||
if (!tool) throw new Error("missing clawdis_nodes tool");
|
||||
if (!tool) throw new Error("missing nodes tool");
|
||||
|
||||
const result = await tool.execute("call1", {
|
||||
action: "camera_snap",
|
||||
@@ -76,9 +76,9 @@ describe("clawdis_nodes camera_snap", () => {
|
||||
});
|
||||
|
||||
const tool = createClawdisTools().find(
|
||||
(candidate) => candidate.name === "clawdis_nodes",
|
||||
(candidate) => candidate.name === "nodes",
|
||||
);
|
||||
if (!tool) throw new Error("missing clawdis_nodes tool");
|
||||
if (!tool) throw new Error("missing nodes tool");
|
||||
|
||||
await tool.execute("call1", {
|
||||
action: "camera_snap",
|
||||
|
||||
@@ -577,8 +577,8 @@ const BrowserToolSchema = Type.Union([
|
||||
|
||||
function createBrowserTool(): AnyAgentTool {
|
||||
return {
|
||||
label: "Clawdis Browser",
|
||||
name: "clawdis_browser",
|
||||
label: "Browser",
|
||||
name: "browser",
|
||||
description:
|
||||
"Control clawd's dedicated browser (status/start/stop/tabs/open/snapshot/screenshot/actions). Use snapshot+act for UI automation. Avoid act:wait by default; use only in exceptional cases when no reliable UI state exists.",
|
||||
parameters: BrowserToolSchema,
|
||||
@@ -837,8 +837,8 @@ const CanvasToolSchema = Type.Union([
|
||||
|
||||
function createCanvasTool(): AnyAgentTool {
|
||||
return {
|
||||
label: "Clawdis Canvas",
|
||||
name: "clawdis_canvas",
|
||||
label: "Canvas",
|
||||
name: "canvas",
|
||||
description:
|
||||
"Control node canvases (present/hide/navigate/eval/snapshot/A2UI). Use snapshot to capture the rendered UI.",
|
||||
parameters: CanvasToolSchema,
|
||||
@@ -1088,8 +1088,8 @@ const NodesToolSchema = Type.Union([
|
||||
|
||||
function createNodesTool(): AnyAgentTool {
|
||||
return {
|
||||
label: "Clawdis Nodes",
|
||||
name: "clawdis_nodes",
|
||||
label: "Nodes",
|
||||
name: "nodes",
|
||||
description:
|
||||
"Discover and control paired nodes (status/describe/pairing/notify/camera/screen).",
|
||||
parameters: NodesToolSchema,
|
||||
@@ -1454,8 +1454,8 @@ const CronToolSchema = Type.Union([
|
||||
|
||||
function createCronTool(): AnyAgentTool {
|
||||
return {
|
||||
label: "Clawdis Cron",
|
||||
name: "clawdis_cron",
|
||||
label: "Cron",
|
||||
name: "cron",
|
||||
description:
|
||||
"Manage Gateway cron jobs (status/list/add/update/remove/run/runs) and send wake events.",
|
||||
parameters: CronToolSchema,
|
||||
@@ -1736,7 +1736,7 @@ const DiscordToolSchema = Type.Union([
|
||||
|
||||
function createDiscordTool(): AnyAgentTool {
|
||||
return {
|
||||
label: "Clawdis Discord",
|
||||
label: "Discord",
|
||||
name: "discord",
|
||||
description: "Manage Discord messages, reactions, and moderation.",
|
||||
parameters: DiscordToolSchema,
|
||||
@@ -2264,8 +2264,8 @@ function createDiscordTool(): AnyAgentTool {
|
||||
|
||||
function createGatewayTool(): AnyAgentTool {
|
||||
return {
|
||||
label: "Clawdis Gateway",
|
||||
name: "clawdis_gateway",
|
||||
label: "Gateway",
|
||||
name: "gateway",
|
||||
description:
|
||||
"Restart the running gateway process in-place (SIGUSR1) without needing an external supervisor. Use delayMs to avoid interrupting an in-flight reply.",
|
||||
parameters: GatewayToolSchema,
|
||||
|
||||
@@ -9,7 +9,7 @@ import { createClawdisCodingTools } from "./pi-tools.js";
|
||||
describe("createClawdisCodingTools", () => {
|
||||
it("merges properties for union tool schemas", () => {
|
||||
const tools = createClawdisCodingTools();
|
||||
const browser = tools.find((tool) => tool.name === "clawdis_browser");
|
||||
const browser = tools.find((tool) => tool.name === "browser");
|
||||
expect(browser).toBeDefined();
|
||||
const parameters = browser?.parameters as {
|
||||
anyOf?: unknown[];
|
||||
@@ -26,9 +26,7 @@ describe("createClawdisCodingTools", () => {
|
||||
|
||||
it("preserves union action values in merged schema", () => {
|
||||
const tools = createClawdisCodingTools();
|
||||
const toolNames = tools
|
||||
.filter((tool) => tool.name.startsWith("clawdis_"))
|
||||
.map((tool) => tool.name);
|
||||
const toolNames = ["browser", "canvas", "nodes", "cron", "gateway"];
|
||||
|
||||
for (const name of toolNames) {
|
||||
const tool = tools.find((candidate) => candidate.name === name);
|
||||
|
||||
@@ -62,10 +62,10 @@ export function buildAgentSystemPromptAppend(params: {
|
||||
"- bash: run shell commands (supports background via yieldMs/background)",
|
||||
"- process: manage background bash sessions",
|
||||
"- whatsapp_login: generate a WhatsApp QR code and wait for linking",
|
||||
"- clawdis_browser: control clawd's dedicated browser",
|
||||
"- clawdis_canvas: present/eval/snapshot the Canvas",
|
||||
"- clawdis_nodes: list/describe/notify/camera/screen on paired nodes",
|
||||
"- clawdis_cron: manage cron jobs and wake events",
|
||||
"- browser: control clawd's dedicated browser",
|
||||
"- canvas: present/eval/snapshot the Canvas",
|
||||
"- nodes: list/describe/notify/camera/screen on paired nodes",
|
||||
"- cron: manage cron jobs and wake events",
|
||||
"TOOLS.md does not control tool availability; it is user guidance for how to use external tools.",
|
||||
"",
|
||||
"## Workspace",
|
||||
|
||||
@@ -24,6 +24,7 @@ describe("tool meta formatting", () => {
|
||||
vi.stubEnv("HOME", "/Users/test");
|
||||
expect(shortenMeta("/Users/test/a.txt")).toBe("~/a.txt");
|
||||
expect(shortenMeta("/Users/test/a.txt:12")).toBe("~/a.txt:12");
|
||||
expect(shortenMeta("cd /Users/test/dir && ls")).toBe("cd ~/dir && ls");
|
||||
expect(shortenMeta("")).toBe("");
|
||||
});
|
||||
|
||||
@@ -35,7 +36,7 @@ describe("tool meta formatting", () => {
|
||||
"note",
|
||||
"a→b",
|
||||
]);
|
||||
expect(out).toMatch(/^🛠️ fs/);
|
||||
expect(out).toMatch(/^🧩 fs/);
|
||||
expect(out).toContain("~/dir/{a.txt, b.txt}");
|
||||
expect(out).toContain("note");
|
||||
expect(out).toContain("a→b");
|
||||
@@ -43,8 +44,8 @@ describe("tool meta formatting", () => {
|
||||
|
||||
it("formats prefixes with default labels", () => {
|
||||
vi.stubEnv("HOME", "/Users/test");
|
||||
expect(formatToolPrefix(undefined, undefined)).toBe("🛠️ tool");
|
||||
expect(formatToolPrefix("x", "/Users/test/a.txt")).toBe("🛠️ x: ~/a.txt");
|
||||
expect(formatToolPrefix(undefined, undefined)).toBe("🧩 tool");
|
||||
expect(formatToolPrefix("x", "/Users/test/a.txt")).toBe("🧩 x: ~/a.txt");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@ export const TOOL_RESULT_DEBOUNCE_MS = 500;
|
||||
export const TOOL_RESULT_FLUSH_COUNT = 5;
|
||||
|
||||
const TOOL_EMOJI_BY_NAME: Record<string, string> = {
|
||||
bash: "💻",
|
||||
bash: "🛠️",
|
||||
process: "🧰",
|
||||
read: "📖",
|
||||
write: "✍️",
|
||||
edit: "📝",
|
||||
attach: "📎",
|
||||
clawdis_browser: "🌐",
|
||||
clawdis_canvas: "🖼️",
|
||||
clawdis_nodes: "📱",
|
||||
clawdis_cron: "⏰",
|
||||
clawdis_gateway: "🔌",
|
||||
browser: "🌐",
|
||||
canvas: "🖼️",
|
||||
nodes: "📱",
|
||||
cron: "⏰",
|
||||
gateway: "🔌",
|
||||
whatsapp_login: "🟢",
|
||||
discord: "💬",
|
||||
};
|
||||
@@ -20,7 +20,13 @@ const TOOL_EMOJI_BY_NAME: Record<string, string> = {
|
||||
function resolveToolEmoji(toolName?: string): string {
|
||||
const key = toolName?.trim().toLowerCase();
|
||||
if (key && TOOL_EMOJI_BY_NAME[key]) return TOOL_EMOJI_BY_NAME[key];
|
||||
return "🛠️";
|
||||
return "🧩";
|
||||
}
|
||||
|
||||
function shortenHomeInString(input: string): string {
|
||||
const home = process.env.HOME;
|
||||
if (!home) return input;
|
||||
return input.split(home).join("~");
|
||||
}
|
||||
|
||||
export function shortenPath(p: string): string {
|
||||
@@ -33,10 +39,10 @@ export function shortenPath(p: string): string {
|
||||
export function shortenMeta(meta: string): string {
|
||||
if (!meta) return meta;
|
||||
const colonIdx = meta.indexOf(":");
|
||||
if (colonIdx === -1) return shortenPath(meta);
|
||||
if (colonIdx === -1) return shortenHomeInString(meta);
|
||||
const base = meta.slice(0, colonIdx);
|
||||
const rest = meta.slice(colonIdx);
|
||||
return `${shortenPath(base)}${rest}`;
|
||||
return `${shortenHomeInString(base)}${rest}`;
|
||||
}
|
||||
|
||||
export function formatToolAggregate(
|
||||
|
||||
@@ -1591,8 +1591,8 @@ describe("web auto-reply", () => {
|
||||
_ctx,
|
||||
opts?: { onToolResult?: (r: { text: string }) => Promise<void> },
|
||||
) => {
|
||||
await opts?.onToolResult?.({ text: "🛠️ tool1" });
|
||||
await opts?.onToolResult?.({ text: "🛠️ tool2" });
|
||||
await opts?.onToolResult?.({ text: "🧩 tool1" });
|
||||
await opts?.onToolResult?.({ text: "🧩 tool2" });
|
||||
return { text: "final" };
|
||||
},
|
||||
);
|
||||
@@ -1611,7 +1611,7 @@ describe("web auto-reply", () => {
|
||||
});
|
||||
|
||||
const replies = reply.mock.calls.map((call) => call[0]);
|
||||
expect(replies).toEqual(["🦞 🛠️ tool1", "🦞 🛠️ tool2", "🦞 final"]);
|
||||
expect(replies).toEqual(["🦞 🧩 tool1", "🦞 🧩 tool2", "🦞 final"]);
|
||||
resetLoadConfigMock();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user