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,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import { resolveTelegramAccount } from "./accounts.js";
describe("resolveTelegramAccount", () => {
@@ -8,7 +8,7 @@ describe("resolveTelegramAccount", () => {
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN = "";
try {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
telegram: { accounts: { work: { botToken: "tok-work" } } },
},
@@ -31,7 +31,7 @@ describe("resolveTelegramAccount", () => {
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN = "tok-env";
try {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
telegram: { accounts: { work: { botToken: "tok-work" } } },
},
@@ -54,7 +54,7 @@ describe("resolveTelegramAccount", () => {
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN = "tok-env";
try {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
telegram: { botToken: "tok-config" },
},
@@ -77,7 +77,7 @@ describe("resolveTelegramAccount", () => {
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN = "";
try {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
telegram: { accounts: { work: { botToken: "tok-work" } } },
},

View File

@@ -1,4 +1,4 @@
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import type { TelegramAccountConfig } from "../config/types.js";
import { isTruthyEnvValue } from "../infra/env.js";
import { listBoundAccountIds, resolveDefaultAgentBoundAccountId } from "../routing/bindings.js";
@@ -20,7 +20,7 @@ export type ResolvedTelegramAccount = {
config: TelegramAccountConfig;
};
function listConfiguredAccountIds(cfg: ClawdbotConfig): string[] {
function listConfiguredAccountIds(cfg: MoltbotConfig): string[] {
const accounts = cfg.channels?.telegram?.accounts;
if (!accounts || typeof accounts !== "object") return [];
const ids = new Set<string>();
@@ -31,7 +31,7 @@ function listConfiguredAccountIds(cfg: ClawdbotConfig): string[] {
return [...ids];
}
export function listTelegramAccountIds(cfg: ClawdbotConfig): string[] {
export function listTelegramAccountIds(cfg: MoltbotConfig): string[] {
const ids = Array.from(
new Set([...listConfiguredAccountIds(cfg), ...listBoundAccountIds(cfg, "telegram")]),
);
@@ -40,7 +40,7 @@ export function listTelegramAccountIds(cfg: ClawdbotConfig): string[] {
return ids.sort((a, b) => a.localeCompare(b));
}
export function resolveDefaultTelegramAccountId(cfg: ClawdbotConfig): string {
export function resolveDefaultTelegramAccountId(cfg: MoltbotConfig): string {
const boundDefault = resolveDefaultAgentBoundAccountId(cfg, "telegram");
if (boundDefault) return boundDefault;
const ids = listTelegramAccountIds(cfg);
@@ -49,7 +49,7 @@ export function resolveDefaultTelegramAccountId(cfg: ClawdbotConfig): string {
}
function resolveAccountConfig(
cfg: ClawdbotConfig,
cfg: MoltbotConfig,
accountId: string,
): TelegramAccountConfig | undefined {
const accounts = cfg.channels?.telegram?.accounts;
@@ -61,7 +61,7 @@ function resolveAccountConfig(
return matchKey ? (accounts[matchKey] as TelegramAccountConfig | undefined) : undefined;
}
function mergeTelegramAccountConfig(cfg: ClawdbotConfig, accountId: string): TelegramAccountConfig {
function mergeTelegramAccountConfig(cfg: MoltbotConfig, accountId: string): TelegramAccountConfig {
const { accounts: _ignored, ...base } = (cfg.channels?.telegram ??
{}) as TelegramAccountConfig & { accounts?: unknown };
const account = resolveAccountConfig(cfg, accountId) ?? {};
@@ -69,7 +69,7 @@ function mergeTelegramAccountConfig(cfg: ClawdbotConfig, accountId: string): Tel
}
export function resolveTelegramAccount(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
accountId?: string | null;
}): ResolvedTelegramAccount {
const hasExplicitAccountId = Boolean(params.accountId?.trim());
@@ -110,7 +110,7 @@ export function resolveTelegramAccount(params: {
return fallback;
}
export function listEnabledTelegramAccounts(cfg: ClawdbotConfig): ResolvedTelegramAccount[] {
export function listEnabledTelegramAccounts(cfg: MoltbotConfig): ResolvedTelegramAccount[] {
return listTelegramAccountIds(cfg)
.map((accountId) => resolveTelegramAccount({ cfg, accountId }))
.filter((account) => account.enabled);

View File

@@ -21,7 +21,7 @@ import { formatLocationText, toLocationContext } from "../channels/location.js";
import { recordInboundSession } from "../channels/session.js";
import { formatCliCommand } from "../cli/command-format.js";
import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js";
import { logVerbose, shouldLogVerbose } from "../globals.js";
import { recordChannelActivity } from "../infra/channel-activity.js";
@@ -96,7 +96,7 @@ type BuildTelegramMessageContextParams = {
storeAllowFrom: string[];
options?: TelegramMessageContextOptions;
bot: Bot;
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
account: { accountId: string };
historyLimit: number;
groupHistories: Map<string, HistoryEntry[]>;
@@ -111,7 +111,7 @@ type BuildTelegramMessageContextParams = {
};
async function resolveStickerVisionSupport(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
agentId?: string;
}): Promise<boolean> {
try {
@@ -271,14 +271,14 @@ export const buildTelegramMessageContext = async ({
bot.api.sendMessage(
chatId,
[
"Clawdbot: access not configured.",
"Moltbot: access not configured.",
"",
`Your Telegram user id: ${telegramUserId}`,
"",
`Pairing code: ${code}`,
"",
"Ask the bot owner to approve with:",
formatCliCommand("clawdbot pairing approve telegram <code>"),
formatCliCommand("moltbot pairing approve telegram <code>"),
].join("\n"),
),
});

View File

@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import type { ChannelGroupPolicy } from "../config/group-policy.js";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import type { TelegramAccountConfig } from "../config/types.js";
import type { RuntimeEnv } from "../runtime.js";
import { registerTelegramNativeCommands } from "./bot-native-commands.js";
@@ -47,7 +47,7 @@ describe("registerTelegramNativeCommands (plugin auth)", () => {
},
} as const;
const cfg = {} as ClawdbotConfig;
const cfg = {} as MoltbotConfig;
const telegramCfg = {} as TelegramAccountConfig;
const resolveGroupPolicy = () =>
({

View File

@@ -37,7 +37,7 @@ import type {
TelegramGroupConfig,
TelegramTopicConfig,
} from "../config/types.js";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import type { RuntimeEnv } from "../runtime.js";
import { deliverReplies } from "./bot/delivery.js";
import { buildInlineKeyboard } from "./send.js";
@@ -66,7 +66,7 @@ type TelegramCommandAuthResult = {
type RegisterTelegramNativeCommandsParams = {
bot: Bot;
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
runtime: RuntimeEnv;
accountId: string;
telegramCfg: TelegramAccountConfig;
@@ -90,7 +90,7 @@ type RegisterTelegramNativeCommandsParams = {
async function resolveTelegramCommandAuth(params: {
msg: NonNullable<TelegramNativeCommandContext["message"]>;
bot: Bot;
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
telegramCfg: TelegramAccountConfig;
allowFrom?: Array<string | number>;
groupAllowFrom?: Array<string | number>;

View File

@@ -5,7 +5,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -196,7 +196,7 @@ describe("createTelegramBot", () => {
message_id: 1,
from: { id: 9, first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -245,7 +245,7 @@ describe("createTelegramBot", () => {
message_id: 3,
from: { id: 9, first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -287,7 +287,7 @@ describe("createTelegramBot", () => {
username: "ada",
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -333,7 +333,7 @@ describe("createTelegramBot", () => {
message_id: 123,
from: { id: 9, first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -374,7 +374,7 @@ describe("createTelegramBot", () => {
message_id: 2,
from: { id: 9, first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -434,7 +434,7 @@ describe("createTelegramBot", () => {
from: { first_name: "Ada" },
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -201,7 +201,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -245,7 +245,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -365,7 +365,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
};

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -178,10 +178,10 @@ describe("createTelegramBot", () => {
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 123456789, username: "testuser" },
text: "@clawdbot_bot hello",
text: "@moltbot_bot hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -208,10 +208,10 @@ describe("createTelegramBot", () => {
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 999999, username: "notallowed" }, // Not in allowFrom
text: "@clawdbot_bot hello",
text: "@moltbot_bot hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -241,7 +241,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -271,7 +271,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -301,7 +301,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -331,7 +331,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -360,7 +360,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -186,7 +186,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
};
@@ -222,7 +222,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
});
@@ -237,7 +237,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
});

View File

@@ -7,7 +7,7 @@ let getTelegramSequentialKey: typeof import("./bot.js").getTelegramSequentialKey
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-throttler-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-throttler-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
loadWebMedia: vi.fn(),
@@ -289,7 +289,7 @@ describe("createTelegramBot", () => {
message_id: 10,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -323,7 +323,7 @@ describe("createTelegramBot", () => {
};
await handler({
message,
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -366,7 +366,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
from: { id: 999, username: "random" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -403,12 +403,12 @@ describe("createTelegramBot", () => {
await handler({
message,
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
await handler({
message: { ...message, text: "hello again" },
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -423,7 +423,7 @@ describe("createTelegramBot", () => {
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
await handler({
message: { chat: { id: 42, type: "private" }, text: "hi" },
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -182,7 +182,7 @@ describe("createTelegramBot", () => {
text: "hello from prefixed user",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -212,7 +212,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -242,7 +242,7 @@ describe("createTelegramBot", () => {
text: "/status",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -280,7 +280,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -325,7 +325,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -366,7 +366,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -182,7 +182,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -211,7 +211,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -239,7 +239,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -267,7 +267,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -297,7 +297,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -326,7 +326,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -356,7 +356,7 @@ describe("createTelegramBot", () => {
text: "hello from prefixed user",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -193,7 +193,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -227,7 +227,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -269,7 +269,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -297,7 +297,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -357,7 +357,7 @@ describe("createTelegramBot", () => {
message_id: 5,
from: { first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -7,7 +7,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-reply-threading-${Math.random()
sessionStorePath: `/tmp/moltbot-telegram-reply-threading-${Math.random()
.toString(16)
.slice(2)}.json`,
}));
@@ -179,7 +179,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -207,7 +207,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -239,7 +239,7 @@ describe("createTelegramBot", () => {
text: "hi",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -265,7 +265,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -294,10 +294,10 @@ describe("createTelegramBot", () => {
await handler({
message: {
chat: { id: 456, type: "group", title: "Ops" },
text: "@clawdbot_bot hello",
text: "@moltbot_bot hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -322,7 +322,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -332,7 +332,7 @@ describe("createTelegramBot", () => {
onSpy.mockReset();
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
replySpy.mockReset();
const storeDir = fs.mkdtempSync(path.join(os.tmpdir(), "clawdbot-telegram-"));
const storeDir = fs.mkdtempSync(path.join(os.tmpdir(), "moltbot-telegram-"));
const storePath = path.join(storeDir, "sessions.json");
fs.writeFileSync(
storePath,
@@ -369,7 +369,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -151,7 +151,7 @@ describe("telegram inbound media", () => {
photo: [{ file_id: "fid" }],
date: 1736380800, // 2025-01-09T00:00:00Z
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "photos/1.jpg" }),
});
@@ -206,7 +206,7 @@ describe("telegram inbound media", () => {
chat: { id: 1234, type: "private" },
photo: [{ file_id: "fid" }],
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "photos/2.jpg" }),
});
@@ -249,7 +249,7 @@ describe("telegram inbound media", () => {
chat: { id: 1234, type: "private" },
photo: [{ file_id: "fid" }],
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
});
@@ -319,7 +319,7 @@ describe("telegram media groups", () => {
media_group_id: "album123",
photo: [{ file_id: "photo1" }],
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "photos/photo1.jpg" }),
});
@@ -331,7 +331,7 @@ describe("telegram media groups", () => {
media_group_id: "album123",
photo: [{ file_id: "photo2" }],
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "photos/photo2.jpg" }),
});
@@ -385,7 +385,7 @@ describe("telegram media groups", () => {
media_group_id: "albumA",
photo: [{ file_id: "photoA1" }],
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "photos/photoA1.jpg" }),
});
@@ -398,7 +398,7 @@ describe("telegram media groups", () => {
media_group_id: "albumB",
photo: [{ file_id: "photoB1" }],
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "photos/photoB1.jpg" }),
});
@@ -477,7 +477,7 @@ describe("telegram stickers", () => {
},
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "stickers/sticker.webp" }),
});
@@ -558,7 +558,7 @@ describe("telegram stickers", () => {
},
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "stickers/sticker.webp" }),
});
@@ -624,7 +624,7 @@ describe("telegram stickers", () => {
},
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "stickers/animated.tgs" }),
});
@@ -684,7 +684,7 @@ describe("telegram stickers", () => {
},
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "stickers/video.webm" }),
});
@@ -737,7 +737,7 @@ describe("telegram text fragments", () => {
date: 1736380800,
text: part1,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
});
@@ -748,7 +748,7 @@ describe("telegram text fragments", () => {
date: 1736380801,
text: part2,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
});

View File

@@ -123,7 +123,7 @@ describe("telegram inbound media", () => {
horizontal_accuracy: 12,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "unused" }),
});
@@ -166,7 +166,7 @@ describe("telegram inbound media", () => {
location: { latitude: 48.858844, longitude: 2.294351 },
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ file_path: "unused" }),
});

View File

@@ -22,7 +22,7 @@ vi.mock("../auto-reply/skill-commands.js", () => ({
}));
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/clawdbot-telegram-bot-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/moltbot-telegram-bot-${Math.random().toString(16).slice(2)}.json`,
}));
function resolveSkillCommands(config: Parameters<typeof listNativeCommandSpecsForConfig>[0]) {
@@ -377,7 +377,7 @@ describe("createTelegramBot", () => {
message_id: 10,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -420,7 +420,7 @@ describe("createTelegramBot", () => {
message_id: 11,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -449,7 +449,7 @@ describe("createTelegramBot", () => {
message_id: 12,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -501,7 +501,7 @@ describe("createTelegramBot", () => {
message_id: 13,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -534,7 +534,7 @@ describe("createTelegramBot", () => {
};
await handler({
message,
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -578,7 +578,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
from: { id: 999, username: "random" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -616,12 +616,12 @@ describe("createTelegramBot", () => {
await handler({
message,
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
await handler({
message: { ...message, text: "hello again" },
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -637,7 +637,7 @@ describe("createTelegramBot", () => {
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
await handler({
message: { chat: { id: 42, type: "private" }, text: "hi" },
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -676,7 +676,7 @@ describe("createTelegramBot", () => {
message_id: 1,
from: { id: 9, first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -728,7 +728,7 @@ describe("createTelegramBot", () => {
username: "ada",
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -776,7 +776,7 @@ describe("createTelegramBot", () => {
message_id: 123,
from: { id: 9, first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -819,7 +819,7 @@ describe("createTelegramBot", () => {
message_id: 2,
from: { id: 9, first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -881,7 +881,7 @@ describe("createTelegramBot", () => {
from: { first_name: "Ada" },
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -910,7 +910,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -939,7 +939,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -972,7 +972,7 @@ describe("createTelegramBot", () => {
text: "hi",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -999,7 +999,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1029,10 +1029,10 @@ describe("createTelegramBot", () => {
await handler({
message: {
chat: { id: 456, type: "group", title: "Ops" },
text: "@clawdbot_bot hello",
text: "@moltbot_bot hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1058,7 +1058,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1086,10 +1086,10 @@ describe("createTelegramBot", () => {
reply_to_message: {
message_id: 42,
text: "original reply",
from: { id: 999, first_name: "Clawdbot" },
from: { id: 999, first_name: "Moltbot" },
},
},
me: { id: 999, username: "clawdbot_bot" },
me: { id: 999, username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1102,7 +1102,7 @@ describe("createTelegramBot", () => {
onSpy.mockReset();
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
replySpy.mockReset();
const storeDir = fs.mkdtempSync(path.join(os.tmpdir(), "clawdbot-telegram-"));
const storeDir = fs.mkdtempSync(path.join(os.tmpdir(), "moltbot-telegram-"));
const storePath = path.join(storeDir, "sessions.json");
fs.writeFileSync(
storePath,
@@ -1139,7 +1139,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1181,7 +1181,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1216,7 +1216,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1259,7 +1259,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1303,7 +1303,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1346,7 +1346,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1375,7 +1375,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1437,7 +1437,7 @@ describe("createTelegramBot", () => {
message_id: 5,
from: { first_name: "Ada" },
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1471,10 +1471,10 @@ describe("createTelegramBot", () => {
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 123456789, username: "testuser" },
text: "@clawdbot_bot hello",
text: "@moltbot_bot hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1502,10 +1502,10 @@ describe("createTelegramBot", () => {
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 999999, username: "notallowed" }, // Not in allowFrom
text: "@clawdbot_bot hello",
text: "@moltbot_bot hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1536,7 +1536,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1567,7 +1567,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1598,7 +1598,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1629,7 +1629,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1659,7 +1659,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1690,7 +1690,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1720,7 +1720,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1749,7 +1749,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1778,7 +1778,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1809,7 +1809,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1839,7 +1839,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1870,7 +1870,7 @@ describe("createTelegramBot", () => {
text: "hello from prefixed user",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1902,7 +1902,7 @@ describe("createTelegramBot", () => {
text: "hello from prefixed user",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1933,7 +1933,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1964,7 +1964,7 @@ describe("createTelegramBot", () => {
text: "/status",
date: 1736380800,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2003,7 +2003,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2049,7 +2049,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2091,7 +2091,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2143,7 +2143,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2188,7 +2188,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2435,7 +2435,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
};
@@ -2473,7 +2473,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
};
@@ -2510,7 +2510,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
});
@@ -2525,7 +2525,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "clawdbot_bot" },
me: { username: "moltbot_bot" },
getFile: async () => ({}),
});

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 {
resolveChannelGroupPolicy,
@@ -57,7 +57,7 @@ export type TelegramBotOptions = {
mediaMaxMb?: number;
replyToMode?: ReplyToMode;
proxyFetch?: typeof fetch;
config?: ClawdbotConfig;
config?: MoltbotConfig;
updateOffset?: {
lastUpdateId?: number | null;
onUpdateId?: (updateId: number) => void | Promise<void>;

View File

@@ -65,8 +65,8 @@ describe("normalizeForwardedContext", () => {
it("handles legacy forwards with signatures", () => {
const ctx = normalizeForwardedContext({
forward_from_chat: {
title: "Clawdbot Updates",
username: "clawdbot",
title: "Moltbot Updates",
username: "moltbot",
id: 99,
type: "channel",
},
@@ -74,11 +74,11 @@ describe("normalizeForwardedContext", () => {
forward_date: 789,
} as any);
expect(ctx).not.toBeNull();
expect(ctx?.from).toBe("Clawdbot Updates (Stan)");
expect(ctx?.from).toBe("Moltbot Updates (Stan)");
expect(ctx?.fromType).toBe("legacy_channel");
expect(ctx?.fromId).toBe("99");
expect(ctx?.fromUsername).toBe("clawdbot");
expect(ctx?.fromTitle).toBe("Clawdbot Updates");
expect(ctx?.fromUsername).toBe("moltbot");
expect(ctx?.fromTitle).toBe("Moltbot Updates");
expect(ctx?.fromSignature).toBe("Stan");
expect(ctx?.date).toBe(789);
});

View File

@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { ClawdbotConfig } from "../../config/config.js";
import type { MoltbotConfig } from "../../config/config.js";
import { resolveTelegramDraftStreamingChunking } from "./draft-chunking.js";
describe("resolveTelegramDraftStreamingChunking", () => {
@@ -14,7 +14,7 @@ describe("resolveTelegramDraftStreamingChunking", () => {
});
it("clamps to telegram.textChunkLimit", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: { telegram: { allowFrom: ["*"], textChunkLimit: 150 } },
};
const chunking = resolveTelegramDraftStreamingChunking(cfg, "default");
@@ -26,7 +26,7 @@ describe("resolveTelegramDraftStreamingChunking", () => {
});
it("supports per-account overrides", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
telegram: {
allowFrom: ["*"],

View File

@@ -1,13 +1,13 @@
import { resolveTextChunkLimit } from "../auto-reply/chunk.js";
import { getChannelDock } from "../channels/dock.js";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import { normalizeAccountId } from "../routing/session-key.js";
const DEFAULT_TELEGRAM_DRAFT_STREAM_MIN = 200;
const DEFAULT_TELEGRAM_DRAFT_STREAM_MAX = 800;
export function resolveTelegramDraftStreamingChunking(
cfg: ClawdbotConfig | undefined,
cfg: MoltbotConfig | undefined,
accountId?: string | null,
): {
minChars: number;

View File

@@ -1,4 +1,4 @@
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import type { TelegramGroupConfig } from "../config/types.telegram.js";
import { normalizeAccountId } from "../routing/session-key.js";
@@ -13,7 +13,7 @@ export type TelegramGroupMigrationResult = {
};
function resolveAccountGroups(
cfg: ClawdbotConfig,
cfg: MoltbotConfig,
accountId?: string | null,
): { groups?: TelegramGroups } {
if (!accountId) return {};
@@ -43,7 +43,7 @@ export function migrateTelegramGroupsInPlace(
}
export function migrateTelegramGroupConfig(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
accountId?: string | null;
oldChatId: string;
newChatId: string;

View File

@@ -1,4 +1,4 @@
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import type { TelegramInlineButtonsScope } from "../config/types.telegram.js";
import { listTelegramAccountIds, resolveTelegramAccount } from "./accounts.js";
import { parseTelegramTarget } from "./targets.js";
@@ -38,7 +38,7 @@ function resolveInlineButtonsScopeFromCapabilities(
}
export function resolveTelegramInlineButtonsScope(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
accountId?: string | null;
}): TelegramInlineButtonsScope {
const account = resolveTelegramAccount({ cfg: params.cfg, accountId: params.accountId });
@@ -46,7 +46,7 @@ export function resolveTelegramInlineButtonsScope(params: {
}
export function isTelegramInlineButtonsEnabled(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
accountId?: string | null;
}): boolean {
if (params.accountId) {

View File

@@ -1,5 +1,5 @@
import { type RunOptions, run } from "@grammyjs/runner";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import { loadConfig } from "../config/config.js";
import { resolveAgentMaxConcurrent } from "../config/agent-limits.js";
import { computeBackoff, sleepWithAbort } from "../infra/backoff.js";
@@ -17,7 +17,7 @@ import { startTelegramWebhook } from "./webhook.js";
export type MonitorTelegramOpts = {
token?: string;
accountId?: string;
config?: ClawdbotConfig;
config?: MoltbotConfig;
runtime?: RuntimeEnv;
abortSignal?: AbortSignal;
useWebhook?: boolean;
@@ -28,7 +28,7 @@ export type MonitorTelegramOpts = {
webhookUrl?: string;
};
export function createTelegramRunnerOptions(cfg: ClawdbotConfig): RunOptions<unknown> {
export function createTelegramRunnerOptions(cfg: MoltbotConfig): RunOptions<unknown> {
return {
sink: {
concurrency: resolveAgentMaxConcurrent(cfg),

View File

@@ -13,7 +13,7 @@ import {
async function withTempStateDir<T>(fn: (stateDir: string) => Promise<T>) {
const previous = process.env.CLAWDBOT_STATE_DIR;
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-pairing-"));
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-pairing-"));
process.env.CLAWDBOT_STATE_DIR = dir;
try {
return await fn(dir);

View File

@@ -1,4 +1,4 @@
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import {
addChannelAllowFromStoreEntry,
approveChannelPairingCode,
@@ -95,7 +95,7 @@ export async function approveTelegramPairingCode(params: {
}
export async function resolveTelegramEffectiveAllowFrom(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
env?: NodeJS.ProcessEnv;
}): Promise<{ dm: string[]; group: string[] }> {
const env = params.env ?? process.env;

View File

@@ -1,6 +1,6 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import { resolveTelegramReactionLevel } from "./reaction-level.js";
describe("resolveTelegramReactionLevel", () => {
@@ -19,7 +19,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("defaults to minimal level when reactionLevel is not set", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: { telegram: {} },
};
@@ -31,7 +31,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("returns off level with no reactions enabled", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: { telegram: { reactionLevel: "off" } },
};
@@ -43,7 +43,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("returns ack level with only ackEnabled", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: { telegram: { reactionLevel: "ack" } },
};
@@ -55,7 +55,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("returns minimal level with agent reactions enabled and minimal guidance", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: { telegram: { reactionLevel: "minimal" } },
};
@@ -67,7 +67,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("returns extensive level with agent reactions enabled and extensive guidance", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: { telegram: { reactionLevel: "extensive" } },
};
@@ -79,7 +79,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("resolves reaction level from a specific account", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
telegram: {
reactionLevel: "ack",
@@ -98,7 +98,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("falls back to global level when account has no reactionLevel", () => {
const cfg: ClawdbotConfig = {
const cfg: MoltbotConfig = {
channels: {
telegram: {
reactionLevel: "minimal",

View File

@@ -1,4 +1,4 @@
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import { resolveTelegramAccount } from "./accounts.js";
export type TelegramReactionLevel = "off" | "ack" | "minimal" | "extensive";
@@ -17,7 +17,7 @@ export type ResolvedReactionLevel = {
* Resolve the effective reaction level and its implications.
*/
export function resolveTelegramReactionLevel(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
accountId?: string;
}): ResolvedReactionLevel {
const account = resolveTelegramAccount({

View File

@@ -11,10 +11,10 @@ import {
// Mock the state directory to use a temp location
vi.mock("../config/paths.js", () => ({
STATE_DIR_CLAWDBOT: "/tmp/clawdbot-test-sticker-cache",
STATE_DIR: "/tmp/moltbot-test-sticker-cache",
}));
const TEST_CACHE_DIR = "/tmp/clawdbot-test-sticker-cache/telegram";
const TEST_CACHE_DIR = "/tmp/moltbot-test-sticker-cache/telegram";
const TEST_CACHE_FILE = path.join(TEST_CACHE_DIR, "sticker-cache.json");
describe("sticker-cache", () => {

View File

@@ -1,7 +1,7 @@
import fs from "node:fs/promises";
import path from "node:path";
import type { ClawdbotConfig } from "../config/config.js";
import { STATE_DIR_CLAWDBOT } from "../config/paths.js";
import type { MoltbotConfig } from "../config/config.js";
import { STATE_DIR } from "../config/paths.js";
import { loadJsonFile, saveJsonFile } from "../infra/json-file.js";
import { logVerbose } from "../globals.js";
import type { ModelCatalogEntry } from "../agents/model-catalog.js";
@@ -14,7 +14,7 @@ import { resolveApiKeyForProvider } from "../agents/model-auth.js";
import { resolveDefaultModelForAgent } from "../agents/model-selection.js";
import { resolveAutoImageModel } from "../media-understanding/runner.js";
const CACHE_FILE = path.join(STATE_DIR_CLAWDBOT, "telegram", "sticker-cache.json");
const CACHE_FILE = path.join(STATE_DIR, "telegram", "sticker-cache.json");
const CACHE_VERSION = 1;
export interface CachedSticker {
@@ -146,7 +146,7 @@ const VISION_PROVIDERS = ["openai", "anthropic", "google", "minimax"] as const;
export interface DescribeStickerParams {
imagePath: string;
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
agentDir?: string;
agentId?: string;
}

View File

@@ -4,11 +4,11 @@ import path from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import { resolveTelegramToken } from "./token.js";
function withTempDir(): string {
return fs.mkdtempSync(path.join(os.tmpdir(), "clawdbot-telegram-token-"));
return fs.mkdtempSync(path.join(os.tmpdir(), "moltbot-telegram-token-"));
}
describe("resolveTelegramToken", () => {
@@ -20,7 +20,7 @@ describe("resolveTelegramToken", () => {
vi.stubEnv("TELEGRAM_BOT_TOKEN", "env-token");
const cfg = {
channels: { telegram: { botToken: "cfg-token" } },
} as ClawdbotConfig;
} as MoltbotConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("cfg-token");
expect(res.source).toBe("config");
@@ -30,7 +30,7 @@ describe("resolveTelegramToken", () => {
vi.stubEnv("TELEGRAM_BOT_TOKEN", "env-token");
const cfg = {
channels: { telegram: {} },
} as ClawdbotConfig;
} as MoltbotConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("env-token");
expect(res.source).toBe("env");
@@ -41,7 +41,7 @@ describe("resolveTelegramToken", () => {
const dir = withTempDir();
const tokenFile = path.join(dir, "token.txt");
fs.writeFileSync(tokenFile, "file-token\n", "utf-8");
const cfg = { channels: { telegram: { tokenFile } } } as ClawdbotConfig;
const cfg = { channels: { telegram: { tokenFile } } } as MoltbotConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("file-token");
expect(res.source).toBe("tokenFile");
@@ -52,7 +52,7 @@ describe("resolveTelegramToken", () => {
vi.stubEnv("TELEGRAM_BOT_TOKEN", "");
const cfg = {
channels: { telegram: { botToken: "cfg-token" } },
} as ClawdbotConfig;
} as MoltbotConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("cfg-token");
expect(res.source).toBe("config");
@@ -64,7 +64,7 @@ describe("resolveTelegramToken", () => {
const tokenFile = path.join(dir, "missing-token.txt");
const cfg = {
channels: { telegram: { tokenFile, botToken: "cfg-token" } },
} as ClawdbotConfig;
} as MoltbotConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("");
expect(res.source).toBe("none");

View File

@@ -1,6 +1,6 @@
import fs from "node:fs";
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 TelegramTokenSource = "env" | "tokenFile" | "config" | "none";
@@ -17,7 +17,7 @@ type ResolveTelegramTokenOpts = {
};
export function resolveTelegramToken(
cfg?: ClawdbotConfig,
cfg?: MoltbotConfig,
opts: ResolveTelegramTokenOpts = {},
): TelegramTokenResolution {
const accountId = normalizeAccountId(opts.accountId);

View File

@@ -8,7 +8,7 @@ import { readTelegramUpdateOffset, writeTelegramUpdateOffset } from "./update-of
async function withTempStateDir<T>(fn: (dir: string) => Promise<T>) {
const previous = process.env.CLAWDBOT_STATE_DIR;
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-telegram-"));
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-telegram-"));
process.env.CLAWDBOT_STATE_DIR = dir;
try {
return await fn(dir);

View File

@@ -1,7 +1,7 @@
import { createServer } from "node:http";
import { webhookCallback } from "grammy";
import type { ClawdbotConfig } from "../config/config.js";
import type { MoltbotConfig } from "../config/config.js";
import { isDiagnosticsEnabled } from "../infra/diagnostic-events.js";
import { formatErrorMessage } from "../infra/errors.js";
import type { RuntimeEnv } from "../runtime.js";
@@ -20,7 +20,7 @@ import { withTelegramApiErrorLogging } from "./api-logging.js";
export async function startTelegramWebhook(opts: {
token: string;
accountId?: string;
config?: ClawdbotConfig;
config?: MoltbotConfig;
path?: string;
port?: number;
host?: string;