refactor: rename clawdbot to moltbot with legacy compat

This commit is contained in:
Peter Steinberger
2026-01-27 12:19:58 +00:00
parent 83460df96f
commit 6d16a658e5
1839 changed files with 11250 additions and 11199 deletions

View File

@@ -1,12 +1,12 @@
import { describe, expect, it } from "vitest";
import "./test-helpers/fast-coding-tools.js";
import type { ClawdbotConfig } from "../config/config.js";
import { createClawdbotCodingTools } from "./pi-tools.js";
import type { MoltbotConfig } from "../config/config.js";
import { createMoltbotCodingTools } from "./pi-tools.js";
import type { SandboxDockerConfig } from "./sandbox.js";
describe("Agent-specific tool filtering", () => {
it("should apply global tool policy when no agent-specific policy exists", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
tools: {
allow: ["read", "write"],
deny: ["bash"],
@@ -21,7 +21,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:main",
workspaceDir: "/tmp/test",
@@ -36,7 +36,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should keep global tool policy when agent only sets tools.elevated", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
tools: {
deny: ["write"],
},
@@ -56,7 +56,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:main",
workspaceDir: "/tmp/test",
@@ -71,7 +71,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should allow apply_patch when exec is allow-listed and applyPatch is enabled", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
tools: {
allow: ["read", "exec"],
exec: {
@@ -80,7 +80,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:main",
workspaceDir: "/tmp/test",
@@ -96,7 +96,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should apply agent-specific tool policy", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
tools: {
allow: ["read", "write", "exec"],
deny: [],
@@ -115,7 +115,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:restricted:main",
workspaceDir: "/tmp/test-restricted",
@@ -131,7 +131,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should apply provider-specific tool policy", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
tools: {
allow: ["read", "write", "exec"],
byProvider: {
@@ -142,7 +142,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:main",
workspaceDir: "/tmp/test-provider",
@@ -159,7 +159,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should apply provider-specific tool profile overrides", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
tools: {
profile: "coding",
byProvider: {
@@ -170,7 +170,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:main",
workspaceDir: "/tmp/test-provider-profile",
@@ -184,7 +184,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should allow different tool policies for different agents", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
agents: {
list: [
{
@@ -205,7 +205,7 @@ describe("Agent-specific tool filtering", () => {
};
// main agent: all tools
const mainTools = createClawdbotCodingTools({
const mainTools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:main",
workspaceDir: "/tmp/test-main",
@@ -218,7 +218,7 @@ describe("Agent-specific tool filtering", () => {
expect(mainToolNames).not.toContain("apply_patch");
// family agent: restricted
const familyTools = createClawdbotCodingTools({
const familyTools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:family:whatsapp:group:123",
workspaceDir: "/tmp/test-family",
@@ -233,7 +233,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should apply group tool policy overrides (group-specific beats wildcard)", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
whatsapp: {
groups: {
@@ -248,7 +248,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const trustedTools = createClawdbotCodingTools({
const trustedTools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:whatsapp:group:trusted",
messageProvider: "whatsapp",
@@ -259,7 +259,7 @@ describe("Agent-specific tool filtering", () => {
expect(trustedNames).toContain("read");
expect(trustedNames).toContain("exec");
const defaultTools = createClawdbotCodingTools({
const defaultTools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:whatsapp:group:unknown",
messageProvider: "whatsapp",
@@ -272,7 +272,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should apply per-sender tool policies for group tools", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
whatsapp: {
groups: {
@@ -287,7 +287,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const aliceTools = createClawdbotCodingTools({
const aliceTools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:whatsapp:group:family",
senderId: "alice",
@@ -298,7 +298,7 @@ describe("Agent-specific tool filtering", () => {
expect(aliceNames).toContain("read");
expect(aliceNames).toContain("exec");
const bobTools = createClawdbotCodingTools({
const bobTools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:whatsapp:group:family",
senderId: "bob",
@@ -311,7 +311,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should not let default sender policy override group tools", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
whatsapp: {
groups: {
@@ -328,7 +328,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const adminTools = createClawdbotCodingTools({
const adminTools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:whatsapp:group:locked",
senderId: "admin",
@@ -341,7 +341,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should resolve telegram group tool policy for topic session keys", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
telegram: {
groups: {
@@ -353,7 +353,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:telegram:group:123:topic:456",
messageProvider: "telegram",
@@ -366,7 +366,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should inherit group tool policy for subagents from spawnedBy session keys", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
whatsapp: {
groups: {
@@ -378,7 +378,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:subagent:test",
spawnedBy: "agent:main:whatsapp:group:trusted",
@@ -391,7 +391,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should apply global tool policy before agent-specific policy", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
tools: {
deny: ["browser"], // Global deny
},
@@ -408,7 +408,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:work:slack:dm:user123",
workspaceDir: "/tmp/test-work",
@@ -424,7 +424,7 @@ describe("Agent-specific tool filtering", () => {
});
it("should work with sandbox tools filtering", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
agents: {
defaults: {
sandbox: {
@@ -457,7 +457,7 @@ describe("Agent-specific tool filtering", () => {
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:restricted:main",
workspaceDir: "/tmp/test-restricted",
@@ -497,13 +497,13 @@ describe("Agent-specific tool filtering", () => {
});
it("should run exec synchronously when process is denied", async () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
tools: {
deny: ["process"],
},
};
const tools = createClawdbotCodingTools({
const tools = createMoltbotCodingTools({
config: cfg,
sessionKey: "agent:main:main",
workspaceDir: "/tmp/test-main",