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,7 +1,7 @@
import type {
ChannelOnboardingAdapter,
ChannelOnboardingDmPolicy,
ClawdbotConfig,
MoltbotConfig,
WizardPrompter,
} from "clawdbot/plugin-sdk";
import {
@@ -24,9 +24,9 @@ import type { ZcaFriend, ZcaGroup } from "./types.js";
const channel = "zalouser" as const;
function setZalouserDmPolicy(
cfg: ClawdbotConfig,
cfg: MoltbotConfig,
dmPolicy: "pairing" | "allowlist" | "open" | "disabled",
): ClawdbotConfig {
): MoltbotConfig {
const allowFrom =
dmPolicy === "open"
? addWildcardAllowFrom(cfg.channels?.zalouser?.allowFrom)
@@ -41,7 +41,7 @@ function setZalouserDmPolicy(
...(allowFrom ? { allowFrom } : {}),
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
}
async function noteZalouserHelp(prompter: WizardPrompter): Promise<void> {
@@ -60,10 +60,10 @@ async function noteZalouserHelp(prompter: WizardPrompter): Promise<void> {
}
async function promptZalouserAllowFrom(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
prompter: WizardPrompter;
accountId: string;
}): Promise<ClawdbotConfig> {
}): Promise<MoltbotConfig> {
const { cfg, prompter, accountId } = params;
const resolved = resolveZalouserAccountSync({ cfg, accountId });
const existingAllowFrom = resolved.config.allowFrom ?? [];
@@ -131,7 +131,7 @@ async function promptZalouserAllowFrom(params: {
allowFrom: unique,
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
}
return {
@@ -152,15 +152,15 @@ async function promptZalouserAllowFrom(params: {
},
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
}
}
function setZalouserGroupPolicy(
cfg: ClawdbotConfig,
cfg: MoltbotConfig,
accountId: string,
groupPolicy: "open" | "allowlist" | "disabled",
): ClawdbotConfig {
): MoltbotConfig {
if (accountId === DEFAULT_ACCOUNT_ID) {
return {
...cfg,
@@ -172,7 +172,7 @@ function setZalouserGroupPolicy(
groupPolicy,
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
}
return {
...cfg,
@@ -191,14 +191,14 @@ function setZalouserGroupPolicy(
},
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
}
function setZalouserGroupAllowlist(
cfg: ClawdbotConfig,
cfg: MoltbotConfig,
accountId: string,
groupKeys: string[],
): ClawdbotConfig {
): MoltbotConfig {
const groups = Object.fromEntries(groupKeys.map((key) => [key, { allow: true }]));
if (accountId === DEFAULT_ACCOUNT_ID) {
return {
@@ -211,7 +211,7 @@ function setZalouserGroupAllowlist(
groups,
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
}
return {
...cfg,
@@ -230,11 +230,11 @@ function setZalouserGroupAllowlist(
},
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
}
async function resolveZalouserGroups(params: {
cfg: ClawdbotConfig;
cfg: MoltbotConfig;
accountId: string;
entries: string[];
}): Promise<Array<{ input: string; resolved: boolean; id?: string }>> {
@@ -270,15 +270,15 @@ const dmPolicy: ChannelOnboardingDmPolicy = {
channel,
policyKey: "channels.zalouser.dmPolicy",
allowFromKey: "channels.zalouser.allowFrom",
getCurrent: (cfg) => ((cfg as ClawdbotConfig).channels?.zalouser?.dmPolicy ?? "pairing") as "pairing",
setPolicy: (cfg, policy) => setZalouserDmPolicy(cfg as ClawdbotConfig, policy),
getCurrent: (cfg) => ((cfg as MoltbotConfig).channels?.zalouser?.dmPolicy ?? "pairing") as "pairing",
setPolicy: (cfg, policy) => setZalouserDmPolicy(cfg as MoltbotConfig, policy),
promptAllowFrom: async ({ cfg, prompter, accountId }) => {
const id =
accountId && normalizeAccountId(accountId)
? normalizeAccountId(accountId) ?? DEFAULT_ACCOUNT_ID
: resolveDefaultZalouserAccountId(cfg as ClawdbotConfig);
: resolveDefaultZalouserAccountId(cfg as MoltbotConfig);
return promptZalouserAllowFrom({
cfg: cfg as ClawdbotConfig,
cfg: cfg as MoltbotConfig,
prompter,
accountId: id,
});
@@ -289,10 +289,10 @@ export const zalouserOnboardingAdapter: ChannelOnboardingAdapter = {
channel,
dmPolicy,
getStatus: async ({ cfg }) => {
const ids = listZalouserAccountIds(cfg as ClawdbotConfig);
const ids = listZalouserAccountIds(cfg as MoltbotConfig);
let configured = false;
for (const accountId of ids) {
const account = resolveZalouserAccountSync({ cfg: cfg as ClawdbotConfig, accountId });
const account = resolveZalouserAccountSync({ cfg: cfg as MoltbotConfig, accountId });
const isAuth = await checkZcaAuthenticated(account.profile);
if (isAuth) {
configured = true;
@@ -324,14 +324,14 @@ export const zalouserOnboardingAdapter: ChannelOnboardingAdapter = {
}
const zalouserOverride = accountOverrides.zalouser?.trim();
const defaultAccountId = resolveDefaultZalouserAccountId(cfg as ClawdbotConfig);
const defaultAccountId = resolveDefaultZalouserAccountId(cfg as MoltbotConfig);
let accountId = zalouserOverride
? normalizeAccountId(zalouserOverride)
: defaultAccountId;
if (shouldPromptAccountIds && !zalouserOverride) {
accountId = await promptAccountId({
cfg: cfg as ClawdbotConfig,
cfg: cfg as MoltbotConfig,
prompter,
label: "Zalo Personal",
currentId: accountId,
@@ -340,7 +340,7 @@ export const zalouserOnboardingAdapter: ChannelOnboardingAdapter = {
});
}
let next = cfg as ClawdbotConfig;
let next = cfg as MoltbotConfig;
const account = resolveZalouserAccountSync({ cfg: next, accountId });
const alreadyAuthenticated = await checkZcaAuthenticated(account.profile);
@@ -398,7 +398,7 @@ export const zalouserOnboardingAdapter: ChannelOnboardingAdapter = {
profile: account.profile !== "default" ? account.profile : undefined,
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
} else {
next = {
...next,
@@ -417,7 +417,7 @@ export const zalouserOnboardingAdapter: ChannelOnboardingAdapter = {
},
},
},
} as ClawdbotConfig;
} as MoltbotConfig;
}
if (forceAllowFrom) {