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,4 +1,4 @@
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } 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: ClawdbotConfig): string[] {
function listConfiguredAccountIds(cfg: MoltbotConfig): string[] {
const accounts = cfg.channels?.discord?.accounts;
if (!accounts || typeof accounts !== "object") return [];
return Object.keys(accounts).filter(Boolean);
}
export function listDiscordAccountIds(cfg: ClawdbotConfig): string[] {
export function listDiscordAccountIds(cfg: MoltbotConfig): 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: ClawdbotConfig): string {
export function resolveDefaultDiscordAccountId(cfg: MoltbotConfig): string {
const ids = listDiscordAccountIds(cfg);
if (ids.includes(DEFAULT_ACCOUNT_ID)) return DEFAULT_ACCOUNT_ID;
return ids[0] ?? DEFAULT_ACCOUNT_ID;
}
function resolveAccountConfig(
cfg: ClawdbotConfig,
cfg: MoltbotConfig,
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: ClawdbotConfig, accountId: string): DiscordAccountConfig {
function mergeDiscordAccountConfig(cfg: MoltbotConfig, accountId: string): DiscordAccountConfig {
const { accounts: _ignored, ...base } = (cfg.channels?.discord ?? {}) as DiscordAccountConfig & {
accounts?: unknown;
};
@@ -48,7 +48,7 @@ function mergeDiscordAccountConfig(cfg: ClawdbotConfig, accountId: string): Disc
}
export function resolveDiscordAccount(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
accountId?: string | null;
}): ResolvedDiscordAccount {
const accountId = normalizeAccountId(params.accountId);
@@ -67,7 +67,7 @@ export function resolveDiscordAccount(params: {
};
}
export function listEnabledDiscordAccounts(cfg: ClawdbotConfig): ResolvedDiscordAccount[] {
export function listEnabledDiscordAccounts(cfg: MoltbotConfig): 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").ClawdbotConfig;
} as unknown as import("../config/config.js").MoltbotConfig;
const collected = collectDiscordAuditChannelIds({
cfg,

View File

@@ -1,4 +1,4 @@
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } 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: ClawdbotConfig;
cfg: MoltbotConfig;
accountId?: string | null;
}) {
const account = resolveDiscordAccount({

View File

@@ -64,7 +64,7 @@ describe("discord native commands", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
discord: { dm: { enabled: true, policy: "open" } },
} as ReturnType<typeof import("../config/config.js").loadConfig>;

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/clawdbot-sessions.json"),
resolveStorePath: vi.fn(() => "/tmp/moltbot-sessions.json"),
updateLastRoute: (...args: unknown[]) => updateLastRouteMock(...args),
resolveSessionKey: vi.fn(),
};
@@ -64,7 +64,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -144,7 +144,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -224,7 +224,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-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: "Clawdbot" },
author: { id: "bot-id", bot: true, username: "Moltbot" },
},
},
author: { id: "u1", bot: false, username: "Ada" },
@@ -338,7 +338,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
messages: { responsePrefix: "PFX" },
channels: {
discord: {
@@ -447,7 +447,7 @@ describe("discord tool result dispatch", () => {
const cfg = {
agent: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/clawd" },
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -556,7 +556,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-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/clawdbot-sessions.json"),
resolveStorePath: vi.fn(() => "/tmp/moltbot-sessions.json"),
updateLastRoute: (...args: unknown[]) => updateLastRouteMock(...args),
resolveSessionKey: vi.fn(),
};
@@ -63,7 +63,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
messages: { responsePrefix: "PFX" },
channels: { discord: { dm: { enabled: true, policy: "open" } } },
} as ReturnType<typeof import("../config/config.js").loadConfig>;
@@ -132,7 +132,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
channels: { discord: { dm: { enabled: true, policy: "open" } } },
} as ReturnType<typeof import("../config/config.js").loadConfig>;
@@ -211,7 +211,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
channels: { discord: { dm: { enabled: true, policy: "open" } } },
} as ReturnType<typeof import("../config/config.js").loadConfig>;
@@ -301,7 +301,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -392,7 +392,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-sessions.json" },
channels: {
discord: {
dm: { enabled: true, policy: "open" },
@@ -476,7 +476,7 @@ describe("discord tool result dispatch", () => {
workspace: "/tmp/clawd",
},
},
session: { store: "/tmp/clawdbot-sessions.json" },
session: { store: "/tmp/moltbot-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 { ClawdbotConfig } from "../../config/config.js";
import type { MoltbotConfig } 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: ClawdbotConfig;
cfg: MoltbotConfig;
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(), "clawdbot-discord-"));
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-discord-"));
const storePath = path.join(dir, "sessions.json");
await processDiscordMessage({

View File

@@ -13,9 +13,7 @@ export type DiscordMessageEvent = import("./listeners.js").DiscordMessageEvent;
export type DiscordMessagePreflightContext = {
cfg: LoadedConfig;
discordConfig: NonNullable<
import("../../config/config.js").ClawdbotConfig["channels"]
>["discord"];
discordConfig: NonNullable<import("../../config/config.js").MoltbotConfig["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(), "clawdbot-discord-"));
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-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").ClawdbotConfig["channels"]
import("../../config/config.js").MoltbotConfig["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 { ClawdbotConfig, loadConfig } from "../../config/config.js";
import type { MoltbotConfig, 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<ClawdbotConfig["channels"]>["discord"];
type DiscordConfig = NonNullable<MoltbotConfig["channels"]>["discord"];
function buildDiscordCommandOptions(params: {
command: ChatCommandDefinition;

View File

@@ -12,7 +12,7 @@ import {
resolveNativeCommandsEnabled,
resolveNativeSkillsEnabled,
} from "../../config/commands.js";
import type { ClawdbotConfig, ReplyToMode } from "../../config/config.js";
import type { MoltbotConfig, 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?: ClawdbotConfig;
config?: MoltbotConfig;
runtime?: RuntimeEnv;
abortSignal?: AbortSignal;
mediaMaxMb?: number;

View File

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

View File

@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } 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 ClawdbotConfig;
} as MoltbotConfig;
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 ClawdbotConfig;
} as MoltbotConfig;
const res = resolveDiscordToken(cfg);
expect(res.token).toBe("env-token");
expect(res.source).toBe("env");
@@ -39,7 +39,7 @@ describe("resolveDiscordToken", () => {
},
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
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 { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } 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?: ClawdbotConfig,
cfg?: MoltbotConfig,
opts: { accountId?: string | null; envToken?: string | null } = {},
): DiscordTokenResolution {
const accountId = normalizeAccountId(opts.accountId);