refactor: rename to openclaw

This commit is contained in:
Peter Steinberger
2026-01-30 03:15:10 +01:00
parent 4583f88626
commit 9a7160786a
2357 changed files with 16688 additions and 16788 deletions

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { DiscordAccountConfig } from "../config/types.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
import { resolveDiscordToken } from "./token.js";
@@ -12,26 +12,26 @@ export type ResolvedDiscordAccount = {
config: DiscordAccountConfig;
};
function listConfiguredAccountIds(cfg: MoltbotConfig): string[] {
function listConfiguredAccountIds(cfg: OpenClawConfig): string[] {
const accounts = cfg.channels?.discord?.accounts;
if (!accounts || typeof accounts !== "object") return [];
return Object.keys(accounts).filter(Boolean);
}
export function listDiscordAccountIds(cfg: MoltbotConfig): string[] {
export function listDiscordAccountIds(cfg: OpenClawConfig): string[] {
const ids = listConfiguredAccountIds(cfg);
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
return ids.sort((a, b) => a.localeCompare(b));
}
export function resolveDefaultDiscordAccountId(cfg: MoltbotConfig): string {
export function resolveDefaultDiscordAccountId(cfg: OpenClawConfig): string {
const ids = listDiscordAccountIds(cfg);
if (ids.includes(DEFAULT_ACCOUNT_ID)) return DEFAULT_ACCOUNT_ID;
return ids[0] ?? DEFAULT_ACCOUNT_ID;
}
function resolveAccountConfig(
cfg: MoltbotConfig,
cfg: OpenClawConfig,
accountId: string,
): DiscordAccountConfig | undefined {
const accounts = cfg.channels?.discord?.accounts;
@@ -39,7 +39,7 @@ function resolveAccountConfig(
return accounts[accountId] as DiscordAccountConfig | undefined;
}
function mergeDiscordAccountConfig(cfg: MoltbotConfig, accountId: string): DiscordAccountConfig {
function mergeDiscordAccountConfig(cfg: OpenClawConfig, accountId: string): DiscordAccountConfig {
const { accounts: _ignored, ...base } = (cfg.channels?.discord ?? {}) as DiscordAccountConfig & {
accounts?: unknown;
};
@@ -48,7 +48,7 @@ function mergeDiscordAccountConfig(cfg: MoltbotConfig, accountId: string): Disco
}
export function resolveDiscordAccount(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
accountId?: string | null;
}): ResolvedDiscordAccount {
const accountId = normalizeAccountId(params.accountId);
@@ -67,7 +67,7 @@ export function resolveDiscordAccount(params: {
};
}
export function listEnabledDiscordAccounts(cfg: MoltbotConfig): ResolvedDiscordAccount[] {
export function listEnabledDiscordAccounts(cfg: OpenClawConfig): ResolvedDiscordAccount[] {
return listDiscordAccountIds(cfg)
.map((accountId) => resolveDiscordAccount({ cfg, accountId }))
.filter((account) => account.enabled);

View File

@@ -27,7 +27,7 @@ describe("discord audit", () => {
},
},
},
} as unknown as import("../config/config.js").MoltbotConfig;
} as unknown as import("../config/config.js").OpenClawConfig;
const collected = collectDiscordAuditChannelIds({
cfg,

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { DiscordGuildChannelConfig, DiscordGuildEntry } from "../config/types.js";
import { resolveDiscordAccount } from "./accounts.js";
import { fetchChannelPermissionsDiscord } from "./send.js";
@@ -53,7 +53,7 @@ function listConfiguredGuildChannelKeys(
}
export function collectDiscordAuditChannelIds(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
accountId?: string | null;
}) {
const account = resolveDiscordAccount({

View File

@@ -61,10 +61,10 @@ describe("discord native commands", () => {
defaults: {
model: "anthropic/claude-opus-4-5",
humanDelay: { mode: "off" },
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
discord: { dm: { enabled: true, policy: "open" } },
} as ReturnType<typeof import("../config/config.js").loadConfig>;

View File

@@ -130,14 +130,14 @@ describe("DiscordMessageListener", () => {
describe("discord allowlist helpers", () => {
it("normalizes slugs", () => {
expect(normalizeDiscordSlug("Friends of Clawd")).toBe("friends-of-clawd");
expect(normalizeDiscordSlug("Friends of OpenClaw")).toBe("friends-of-openclaw");
expect(normalizeDiscordSlug("#General")).toBe("general");
expect(normalizeDiscordSlug("Dev__Chat")).toBe("dev-chat");
});
it("matches ids or names", () => {
const allow = normalizeDiscordAllowList(
["123", "steipete", "Friends of Clawd"],
["123", "steipete", "Friends of OpenClaw"],
["discord:", "user:", "guild:", "channel:"],
);
expect(allow).not.toBeNull();
@@ -146,7 +146,7 @@ describe("discord allowlist helpers", () => {
}
expect(allowListMatches(allow, { id: "123" })).toBe(true);
expect(allowListMatches(allow, { name: "steipete" })).toBe(true);
expect(allowListMatches(allow, { name: "friends-of-clawd" })).toBe(true);
expect(allowListMatches(allow, { name: "friends-of-openclaw" })).toBe(true);
expect(allowListMatches(allow, { name: "other" })).toBe(false);
});
});
@@ -154,26 +154,26 @@ describe("discord allowlist helpers", () => {
describe("discord guild/channel resolution", () => {
it("resolves guild entry by id", () => {
const guildEntries = makeEntries({
"123": { slug: "friends-of-clawd" },
"123": { slug: "friends-of-openclaw" },
});
const resolved = resolveDiscordGuildEntry({
guild: fakeGuild("123", "Friends of Clawd"),
guild: fakeGuild("123", "Friends of OpenClaw"),
guildEntries,
});
expect(resolved?.id).toBe("123");
expect(resolved?.slug).toBe("friends-of-clawd");
expect(resolved?.slug).toBe("friends-of-openclaw");
});
it("resolves guild entry by slug key", () => {
const guildEntries = makeEntries({
"friends-of-clawd": { slug: "friends-of-clawd" },
"friends-of-openclaw": { slug: "friends-of-openclaw" },
});
const resolved = resolveDiscordGuildEntry({
guild: fakeGuild("123", "Friends of Clawd"),
guild: fakeGuild("123", "Friends of OpenClaw"),
guildEntries,
});
expect(resolved?.id).toBe("123");
expect(resolved?.slug).toBe("friends-of-clawd");
expect(resolved?.slug).toBe("friends-of-openclaw");
});
it("falls back to wildcard guild entry", () => {
@@ -181,7 +181,7 @@ describe("discord guild/channel resolution", () => {
"*": { requireMention: false },
});
const resolved = resolveDiscordGuildEntry({
guild: fakeGuild("123", "Friends of Clawd"),
guild: fakeGuild("123", "Friends of OpenClaw"),
guildEntries,
});
expect(resolved?.id).toBe("123");
@@ -547,15 +547,15 @@ describe("discord group DM gating", () => {
it("matches group DM allowlist", () => {
expect(
resolveGroupDmAllow({
channels: ["clawd-dm"],
channels: ["openclaw-dm"],
channelId: "1",
channelName: "Clawd DM",
channelSlug: "clawd-dm",
channelName: "OpenClaw DM",
channelSlug: "openclaw-dm",
}),
).toBe(true);
expect(
resolveGroupDmAllow({
channels: ["clawd-dm"],
channels: ["openclaw-dm"],
channelId: "1",
channelName: "Other",
channelSlug: "other",

View File

@@ -35,7 +35,7 @@ vi.mock("../config/sessions.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../config/sessions.js")>();
return {
...actual,
resolveStorePath: vi.fn(() => "/tmp/moltbot-sessions.json"),
resolveStorePath: vi.fn(() => "/tmp/openclaw-sessions.json"),
updateLastRoute: (...args: unknown[]) => updateLastRouteMock(...args),
resolveSessionKey: vi.fn(),
};
@@ -61,10 +61,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -74,7 +74,7 @@ describe("discord tool result dispatch", () => {
},
messages: {
responsePrefix: "PFX",
groupChat: { mentionPatterns: ["\\bclawd\\b"] },
groupChat: { mentionPatterns: ["\\bopenclaw\\b"] },
},
} as ReturnType<typeof import("../config/config.js").loadConfig>;
@@ -112,7 +112,7 @@ describe("discord tool result dispatch", () => {
{
message: {
id: "m2",
content: "clawd: hello",
content: "openclaw: hello",
channelId: "c1",
timestamp: new Date().toISOString(),
type: MessageType.Default,
@@ -141,10 +141,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -154,7 +154,7 @@ describe("discord tool result dispatch", () => {
},
messages: {
responsePrefix: "PFX",
groupChat: { mentionPatterns: ["\\bclawd\\b"] },
groupChat: { mentionPatterns: ["\\bopenclaw\\b"] },
},
} as ReturnType<typeof import("../config/config.js").loadConfig>;
@@ -192,7 +192,7 @@ describe("discord tool result dispatch", () => {
{
message: {
id: "m2",
content: "clawd: hello",
content: "openclaw: hello",
channelId: "c1",
timestamp: new Date().toISOString(),
type: MessageType.Default,
@@ -221,10 +221,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -289,7 +289,7 @@ describe("discord tool result dispatch", () => {
mentionedEveryone: false,
mentionedUsers: [],
mentionedRoles: [],
author: { id: "bot-id", bot: true, username: "Moltbot" },
author: { id: "bot-id", bot: true, username: "OpenClaw" },
},
},
author: { id: "u1", bot: false, username: "Ada" },
@@ -335,10 +335,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
messages: { responsePrefix: "PFX" },
channels: {
discord: {
@@ -446,8 +446,8 @@ describe("discord tool result dispatch", () => {
});
const cfg = {
agent: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/clawd" },
session: { store: "/tmp/moltbot-sessions.json" },
agent: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -553,10 +553,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
messages: { responsePrefix: "PFX" },
channels: {
discord: {

View File

@@ -35,7 +35,7 @@ vi.mock("../config/sessions.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../config/sessions.js")>();
return {
...actual,
resolveStorePath: vi.fn(() => "/tmp/moltbot-sessions.json"),
resolveStorePath: vi.fn(() => "/tmp/openclaw-sessions.json"),
updateLastRoute: (...args: unknown[]) => updateLastRouteMock(...args),
resolveSessionKey: vi.fn(),
};
@@ -60,10 +60,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
messages: { responsePrefix: "PFX" },
channels: { discord: { dm: { enabled: true, policy: "open" } } },
} as ReturnType<typeof import("../config/config.js").loadConfig>;
@@ -129,10 +129,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: { discord: { dm: { enabled: true, policy: "open" } } },
} as ReturnType<typeof import("../config/config.js").loadConfig>;
@@ -208,10 +208,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: { discord: { dm: { enabled: true, policy: "open" } } },
} as ReturnType<typeof import("../config/config.js").loadConfig>;
@@ -298,10 +298,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -389,10 +389,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -473,10 +473,10 @@ describe("discord tool result dispatch", () => {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: "/tmp/clawd",
workspace: "/tmp/openclaw",
},
},
session: { store: "/tmp/moltbot-sessions.json" },
session: { store: "/tmp/openclaw-sessions.json" },
channels: {
discord: { dm: { enabled: true, policy: "pairing", allowFrom: [] } },
},

View File

@@ -1,6 +1,6 @@
import { Button, type ButtonInteraction, type ComponentData } from "@buape/carbon";
import { ButtonStyle, Routes } from "discord-api-types/v10";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { GatewayClient } from "../../gateway/client.js";
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
import type { EventFrame } from "../../gateway/protocol/index.js";
@@ -187,7 +187,7 @@ export type DiscordExecApprovalHandlerOpts = {
accountId: string;
config: DiscordExecApprovalConfig;
gatewayUrl?: string;
cfg: MoltbotConfig;
cfg: OpenClawConfig;
runtime?: RuntimeEnv;
onResolve?: (id: string, decision: ExecApprovalDecision) => Promise<void>;
};

View File

@@ -29,7 +29,7 @@ describe("discord processDiscordMessage inbound contract", () => {
it("passes a finalized MsgContext to dispatchInboundMessage", async () => {
capturedCtx = undefined;
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-discord-"));
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-discord-"));
const storePath = path.join(dir, "sessions.json");
await processDiscordMessage({

View File

@@ -13,7 +13,9 @@ export type DiscordMessageEvent = import("./listeners.js").DiscordMessageEvent;
export type DiscordMessagePreflightContext = {
cfg: LoadedConfig;
discordConfig: NonNullable<import("../../config/config.js").MoltbotConfig["channels"]>["discord"];
discordConfig: NonNullable<
import("../../config/config.js").OpenClawConfig["channels"]
>["discord"];
accountId: string;
token: string;
runtime: RuntimeEnv;

View File

@@ -30,7 +30,7 @@ vi.mock("../../auto-reply/reply/reply-dispatcher.js", () => ({
import { processDiscordMessage } from "./message-handler.process.js";
async function createBaseContext(overrides: Record<string, unknown> = {}) {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-discord-"));
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-discord-"));
const storePath = path.join(dir, "sessions.json");
return {
cfg: { messages: { ackReaction: "👀" }, session: { store: storePath } },

View File

@@ -17,7 +17,7 @@ import { resolveDiscordMessageText } from "./message-utils.js";
type LoadedConfig = ReturnType<typeof import("../../config/config.js").loadConfig>;
type DiscordConfig = NonNullable<
import("../../config/config.js").MoltbotConfig["channels"]
import("../../config/config.js").OpenClawConfig["channels"]
>["discord"];
export function createDiscordMessageHandler(params: {

View File

@@ -32,7 +32,7 @@ import type {
import { dispatchReplyWithDispatcher } from "../../auto-reply/reply/provider-dispatcher.js";
import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js";
import type { ReplyPayload } from "../../auto-reply/types.js";
import type { MoltbotConfig, loadConfig } from "../../config/config.js";
import type { OpenClawConfig, loadConfig } from "../../config/config.js";
import { buildPairingReply } from "../../pairing/pairing-messages.js";
import {
readChannelAllowFromStore,
@@ -55,7 +55,7 @@ import { formatDiscordUserTag } from "./format.js";
import { resolveDiscordChannelInfo } from "./message-utils.js";
import { resolveDiscordThreadParentInfo } from "./threading.js";
type DiscordConfig = NonNullable<MoltbotConfig["channels"]>["discord"];
type DiscordConfig = NonNullable<OpenClawConfig["channels"]>["discord"];
function buildDiscordCommandOptions(params: {
command: ChatCommandDefinition;

View File

@@ -12,7 +12,7 @@ import {
resolveNativeCommandsEnabled,
resolveNativeSkillsEnabled,
} from "../../config/commands.js";
import type { MoltbotConfig, ReplyToMode } from "../../config/config.js";
import type { OpenClawConfig, ReplyToMode } from "../../config/config.js";
import { loadConfig } from "../../config/config.js";
import { danger, logVerbose, shouldLogVerbose, warn } from "../../globals.js";
import { formatErrorMessage } from "../../infra/errors.js";
@@ -43,7 +43,7 @@ import { createExecApprovalButton, DiscordExecApprovalHandler } from "./exec-app
export type MonitorDiscordOpts = {
token?: string;
accountId?: string;
config?: MoltbotConfig;
config?: OpenClawConfig;
runtime?: RuntimeEnv;
abortSignal?: AbortSignal;
mediaMaxMb?: number;

View File

@@ -172,8 +172,8 @@ describe("uploadStickerDiscord", () => {
await uploadStickerDiscord(
{
guildId: "g1",
name: "moltbot_wave",
description: "Moltbot waving",
name: "openclaw_wave",
description: "OpenClaw waving",
tags: "👋",
mediaUrl: "file:///tmp/wave.png",
},
@@ -183,8 +183,8 @@ describe("uploadStickerDiscord", () => {
Routes.guildStickers("g1"),
expect.objectContaining({
body: {
name: "moltbot_wave",
description: "Moltbot waving",
name: "openclaw_wave",
description: "OpenClaw waving",
tags: "👋",
files: [
expect.objectContaining({

View File

@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { ClawdbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { normalizeDiscordMessagingTarget } from "../channels/plugins/normalize/discord.js";
import { listDiscordDirectoryPeersLive } from "./directory-live.js";
import { parseDiscordTarget, resolveDiscordChannelId, resolveDiscordTarget } from "./targets.js";
@@ -75,7 +75,7 @@ describe("resolveDiscordChannelId", () => {
});
describe("resolveDiscordTarget", () => {
const cfg = { channels: { discord: {} } } as ClawdbotConfig;
const cfg = { channels: { discord: {} } } as OpenClawConfig;
const listPeers = vi.mocked(listDiscordDirectoryPeersLive);
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveDiscordToken } from "./token.js";
describe("resolveDiscordToken", () => {
@@ -12,7 +12,7 @@ describe("resolveDiscordToken", () => {
vi.stubEnv("DISCORD_BOT_TOKEN", "env-token");
const cfg = {
channels: { discord: { token: "cfg-token" } },
} as MoltbotConfig;
} as OpenClawConfig;
const res = resolveDiscordToken(cfg);
expect(res.token).toBe("cfg-token");
expect(res.source).toBe("config");
@@ -22,7 +22,7 @@ describe("resolveDiscordToken", () => {
vi.stubEnv("DISCORD_BOT_TOKEN", "env-token");
const cfg = {
channels: { discord: {} },
} as MoltbotConfig;
} as OpenClawConfig;
const res = resolveDiscordToken(cfg);
expect(res.token).toBe("env-token");
expect(res.source).toBe("env");
@@ -39,7 +39,7 @@ describe("resolveDiscordToken", () => {
},
},
},
} as MoltbotConfig;
} as OpenClawConfig;
const res = resolveDiscordToken(cfg, { accountId: "work" });
expect(res.token).toBe("acct-token");
expect(res.source).toBe("config");

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export type DiscordTokenSource = "env" | "config" | "none";
@@ -16,7 +16,7 @@ export function normalizeDiscordToken(raw?: string | null): string | undefined {
}
export function resolveDiscordToken(
cfg?: MoltbotConfig,
cfg?: OpenClawConfig,
opts: { accountId?: string | null; envToken?: string | null } = {},
): DiscordTokenResolution {
const accountId = normalizeAccountId(opts.accountId);