mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-25 01:08:38 +00:00
refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { ClawdbotConfig } from "./config.js";
|
||||
import type { MoltbotConfig } from "./config.js";
|
||||
import {
|
||||
getChatChannelMeta,
|
||||
listChatChannels,
|
||||
@@ -17,7 +17,7 @@ type PluginEnableChange = {
|
||||
};
|
||||
|
||||
export type PluginAutoEnableResult = {
|
||||
config: ClawdbotConfig;
|
||||
config: MoltbotConfig;
|
||||
changes: string[];
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ function accountsHaveKeys(value: unknown, keys: string[]): boolean {
|
||||
}
|
||||
|
||||
function resolveChannelConfig(
|
||||
cfg: ClawdbotConfig,
|
||||
cfg: MoltbotConfig,
|
||||
channelId: string,
|
||||
): Record<string, unknown> | null {
|
||||
const channels = cfg.channels as Record<string, unknown> | undefined;
|
||||
@@ -67,7 +67,7 @@ function resolveChannelConfig(
|
||||
return isRecord(entry) ? entry : null;
|
||||
}
|
||||
|
||||
function isTelegramConfigured(cfg: ClawdbotConfig, env: NodeJS.ProcessEnv): boolean {
|
||||
function isTelegramConfigured(cfg: MoltbotConfig, env: NodeJS.ProcessEnv): boolean {
|
||||
if (hasNonEmptyString(env.TELEGRAM_BOT_TOKEN)) return true;
|
||||
const entry = resolveChannelConfig(cfg, "telegram");
|
||||
if (!entry) return false;
|
||||
@@ -76,7 +76,7 @@ function isTelegramConfigured(cfg: ClawdbotConfig, env: NodeJS.ProcessEnv): bool
|
||||
return recordHasKeys(entry);
|
||||
}
|
||||
|
||||
function isDiscordConfigured(cfg: ClawdbotConfig, env: NodeJS.ProcessEnv): boolean {
|
||||
function isDiscordConfigured(cfg: MoltbotConfig, env: NodeJS.ProcessEnv): boolean {
|
||||
if (hasNonEmptyString(env.DISCORD_BOT_TOKEN)) return true;
|
||||
const entry = resolveChannelConfig(cfg, "discord");
|
||||
if (!entry) return false;
|
||||
@@ -85,7 +85,7 @@ function isDiscordConfigured(cfg: ClawdbotConfig, env: NodeJS.ProcessEnv): boole
|
||||
return recordHasKeys(entry);
|
||||
}
|
||||
|
||||
function isSlackConfigured(cfg: ClawdbotConfig, env: NodeJS.ProcessEnv): boolean {
|
||||
function isSlackConfigured(cfg: MoltbotConfig, env: NodeJS.ProcessEnv): boolean {
|
||||
if (
|
||||
hasNonEmptyString(env.SLACK_BOT_TOKEN) ||
|
||||
hasNonEmptyString(env.SLACK_APP_TOKEN) ||
|
||||
@@ -106,7 +106,7 @@ function isSlackConfigured(cfg: ClawdbotConfig, env: NodeJS.ProcessEnv): boolean
|
||||
return recordHasKeys(entry);
|
||||
}
|
||||
|
||||
function isSignalConfigured(cfg: ClawdbotConfig): boolean {
|
||||
function isSignalConfigured(cfg: MoltbotConfig): boolean {
|
||||
const entry = resolveChannelConfig(cfg, "signal");
|
||||
if (!entry) return false;
|
||||
if (
|
||||
@@ -122,27 +122,27 @@ function isSignalConfigured(cfg: ClawdbotConfig): boolean {
|
||||
return recordHasKeys(entry);
|
||||
}
|
||||
|
||||
function isIMessageConfigured(cfg: ClawdbotConfig): boolean {
|
||||
function isIMessageConfigured(cfg: MoltbotConfig): boolean {
|
||||
const entry = resolveChannelConfig(cfg, "imessage");
|
||||
if (!entry) return false;
|
||||
if (hasNonEmptyString(entry.cliPath)) return true;
|
||||
return recordHasKeys(entry);
|
||||
}
|
||||
|
||||
function isWhatsAppConfigured(cfg: ClawdbotConfig): boolean {
|
||||
function isWhatsAppConfigured(cfg: MoltbotConfig): boolean {
|
||||
if (hasAnyWhatsAppAuth(cfg)) return true;
|
||||
const entry = resolveChannelConfig(cfg, "whatsapp");
|
||||
if (!entry) return false;
|
||||
return recordHasKeys(entry);
|
||||
}
|
||||
|
||||
function isGenericChannelConfigured(cfg: ClawdbotConfig, channelId: string): boolean {
|
||||
function isGenericChannelConfigured(cfg: MoltbotConfig, channelId: string): boolean {
|
||||
const entry = resolveChannelConfig(cfg, channelId);
|
||||
return recordHasKeys(entry);
|
||||
}
|
||||
|
||||
export function isChannelConfigured(
|
||||
cfg: ClawdbotConfig,
|
||||
cfg: MoltbotConfig,
|
||||
channelId: string,
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
): boolean {
|
||||
@@ -164,7 +164,7 @@ export function isChannelConfigured(
|
||||
}
|
||||
}
|
||||
|
||||
function collectModelRefs(cfg: ClawdbotConfig): string[] {
|
||||
function collectModelRefs(cfg: MoltbotConfig): string[] {
|
||||
const refs: string[] = [];
|
||||
const pushModelRef = (value: unknown) => {
|
||||
if (typeof value === "string" && value.trim()) refs.push(value.trim());
|
||||
@@ -208,7 +208,7 @@ function extractProviderFromModelRef(value: string): string | null {
|
||||
return normalizeProviderId(trimmed.slice(0, slash));
|
||||
}
|
||||
|
||||
function isProviderConfigured(cfg: ClawdbotConfig, providerId: string): boolean {
|
||||
function isProviderConfigured(cfg: MoltbotConfig, providerId: string): boolean {
|
||||
const normalized = normalizeProviderId(providerId);
|
||||
|
||||
const profiles = cfg.auth?.profiles;
|
||||
@@ -237,7 +237,7 @@ function isProviderConfigured(cfg: ClawdbotConfig, providerId: string): boolean
|
||||
}
|
||||
|
||||
function resolveConfiguredPlugins(
|
||||
cfg: ClawdbotConfig,
|
||||
cfg: MoltbotConfig,
|
||||
env: NodeJS.ProcessEnv,
|
||||
): PluginEnableChange[] {
|
||||
const changes: PluginEnableChange[] = [];
|
||||
@@ -269,12 +269,12 @@ function resolveConfiguredPlugins(
|
||||
return changes;
|
||||
}
|
||||
|
||||
function isPluginExplicitlyDisabled(cfg: ClawdbotConfig, pluginId: string): boolean {
|
||||
function isPluginExplicitlyDisabled(cfg: MoltbotConfig, pluginId: string): boolean {
|
||||
const entry = cfg.plugins?.entries?.[pluginId];
|
||||
return entry?.enabled === false;
|
||||
}
|
||||
|
||||
function isPluginDenied(cfg: ClawdbotConfig, pluginId: string): boolean {
|
||||
function isPluginDenied(cfg: MoltbotConfig, pluginId: string): boolean {
|
||||
const deny = cfg.plugins?.deny;
|
||||
return Array.isArray(deny) && deny.includes(pluginId);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ function resolvePreferredOverIds(pluginId: string): string[] {
|
||||
}
|
||||
|
||||
function shouldSkipPreferredPluginAutoEnable(
|
||||
cfg: ClawdbotConfig,
|
||||
cfg: MoltbotConfig,
|
||||
entry: PluginEnableChange,
|
||||
configured: PluginEnableChange[],
|
||||
): boolean {
|
||||
@@ -305,7 +305,7 @@ function shouldSkipPreferredPluginAutoEnable(
|
||||
return false;
|
||||
}
|
||||
|
||||
function ensureAllowlisted(cfg: ClawdbotConfig, pluginId: string): ClawdbotConfig {
|
||||
function ensureAllowlisted(cfg: MoltbotConfig, pluginId: string): MoltbotConfig {
|
||||
const allow = cfg.plugins?.allow;
|
||||
if (!Array.isArray(allow) || allow.includes(pluginId)) return cfg;
|
||||
return {
|
||||
@@ -317,7 +317,7 @@ function ensureAllowlisted(cfg: ClawdbotConfig, pluginId: string): ClawdbotConfi
|
||||
};
|
||||
}
|
||||
|
||||
function enablePluginEntry(cfg: ClawdbotConfig, pluginId: string): ClawdbotConfig {
|
||||
function enablePluginEntry(cfg: MoltbotConfig, pluginId: string): MoltbotConfig {
|
||||
const entries = {
|
||||
...cfg.plugins?.entries,
|
||||
[pluginId]: {
|
||||
@@ -346,7 +346,7 @@ function formatAutoEnableChange(entry: PluginEnableChange): string {
|
||||
}
|
||||
|
||||
export function applyPluginAutoEnable(params: {
|
||||
config: ClawdbotConfig;
|
||||
config: MoltbotConfig;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): PluginAutoEnableResult {
|
||||
const env = params.env ?? process.env;
|
||||
|
||||
Reference in New Issue
Block a user