mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:47:41 +00:00
refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -30,9 +30,9 @@ import { findLegacyConfigIssues } from "./legacy.js";
|
||||
import { normalizeConfigPaths } from "./normalize-paths.js";
|
||||
import { resolveConfigPath, resolveStateDir } from "./paths.js";
|
||||
import { applyConfigOverrides } from "./runtime-overrides.js";
|
||||
import type { ClawdbotConfig, ConfigFileSnapshot, LegacyConfigIssue } from "./types.js";
|
||||
import type { MoltbotConfig, ConfigFileSnapshot, LegacyConfigIssue } from "./types.js";
|
||||
import { validateConfigObjectWithPlugins } from "./validation.js";
|
||||
import { compareClawdbotVersions } from "./version.js";
|
||||
import { compareMoltbotVersions } from "./version.js";
|
||||
|
||||
// Re-export for backwards compatibility
|
||||
export { CircularIncludeError, ConfigIncludeError } from "./includes.js";
|
||||
@@ -81,11 +81,11 @@ export function resolveConfigSnapshotHash(snapshot: {
|
||||
return hashConfigRaw(snapshot.raw);
|
||||
}
|
||||
|
||||
function coerceConfig(value: unknown): ClawdbotConfig {
|
||||
function coerceConfig(value: unknown): MoltbotConfig {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
||||
return {};
|
||||
}
|
||||
return value as ClawdbotConfig;
|
||||
return value as MoltbotConfig;
|
||||
}
|
||||
|
||||
async function rotateConfigBackups(configPath: string, ioFs: typeof fs.promises): Promise<void> {
|
||||
@@ -125,7 +125,7 @@ function warnOnConfigMiskeys(raw: unknown, logger: Pick<typeof console, "warn">)
|
||||
}
|
||||
}
|
||||
|
||||
function stampConfigVersion(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
function stampConfigVersion(cfg: MoltbotConfig): MoltbotConfig {
|
||||
const now = new Date().toISOString();
|
||||
return {
|
||||
...cfg,
|
||||
@@ -137,19 +137,19 @@ function stampConfigVersion(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
};
|
||||
}
|
||||
|
||||
function warnIfConfigFromFuture(cfg: ClawdbotConfig, logger: Pick<typeof console, "warn">): void {
|
||||
function warnIfConfigFromFuture(cfg: MoltbotConfig, logger: Pick<typeof console, "warn">): void {
|
||||
const touched = cfg.meta?.lastTouchedVersion;
|
||||
if (!touched) return;
|
||||
const cmp = compareClawdbotVersions(VERSION, touched);
|
||||
const cmp = compareMoltbotVersions(VERSION, touched);
|
||||
if (cmp === null) return;
|
||||
if (cmp < 0) {
|
||||
logger.warn(
|
||||
`Config was last written by a newer Clawdbot (${touched}); current version is ${VERSION}.`,
|
||||
`Config was last written by a newer Moltbot (${touched}); current version is ${VERSION}.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function applyConfigEnv(cfg: ClawdbotConfig, env: NodeJS.ProcessEnv): void {
|
||||
function applyConfigEnv(cfg: MoltbotConfig, env: NodeJS.ProcessEnv): void {
|
||||
const entries = collectConfigEnvVars(cfg);
|
||||
for (const [key, value] of Object.entries(entries)) {
|
||||
if (env[key]?.trim()) continue;
|
||||
@@ -188,7 +188,7 @@ export function createConfigIO(overrides: ConfigIoDeps = {}) {
|
||||
const deps = normalizeDeps(overrides);
|
||||
const configPath = resolveConfigPathForDeps(deps);
|
||||
|
||||
function loadConfig(): ClawdbotConfig {
|
||||
function loadConfig(): MoltbotConfig {
|
||||
try {
|
||||
if (!deps.fs.existsSync(configPath)) {
|
||||
if (shouldEnableShellEnvFallback(deps.env) && !shouldDeferShellEnvFallback(deps.env)) {
|
||||
@@ -213,7 +213,7 @@ export function createConfigIO(overrides: ConfigIoDeps = {}) {
|
||||
|
||||
// Apply config.env to process.env BEFORE substitution so ${VAR} can reference config-defined vars
|
||||
if (resolved && typeof resolved === "object" && "env" in resolved) {
|
||||
applyConfigEnv(resolved as ClawdbotConfig, deps.env);
|
||||
applyConfigEnv(resolved as MoltbotConfig, deps.env);
|
||||
}
|
||||
|
||||
// Substitute ${VAR} env var references
|
||||
@@ -222,7 +222,7 @@ export function createConfigIO(overrides: ConfigIoDeps = {}) {
|
||||
const resolvedConfig = substituted;
|
||||
warnOnConfigMiskeys(resolvedConfig, deps.logger);
|
||||
if (typeof resolvedConfig !== "object" || resolvedConfig === null) return {};
|
||||
const preValidationDuplicates = findDuplicateAgentDirs(resolvedConfig as ClawdbotConfig, {
|
||||
const preValidationDuplicates = findDuplicateAgentDirs(resolvedConfig as MoltbotConfig, {
|
||||
env: deps.env,
|
||||
homedir: deps.homedir,
|
||||
});
|
||||
@@ -372,7 +372,7 @@ export function createConfigIO(overrides: ConfigIoDeps = {}) {
|
||||
|
||||
// Apply config.env to process.env BEFORE substitution so ${VAR} can reference config-defined vars
|
||||
if (resolved && typeof resolved === "object" && "env" in resolved) {
|
||||
applyConfigEnv(resolved as ClawdbotConfig, deps.env);
|
||||
applyConfigEnv(resolved as MoltbotConfig, deps.env);
|
||||
}
|
||||
|
||||
// Substitute ${VAR} env var references
|
||||
@@ -454,7 +454,7 @@ export function createConfigIO(overrides: ConfigIoDeps = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
async function writeConfigFile(cfg: ClawdbotConfig) {
|
||||
async function writeConfigFile(cfg: MoltbotConfig) {
|
||||
clearConfigCache();
|
||||
const validated = validateConfigObjectWithPlugins(cfg);
|
||||
if (!validated.ok) {
|
||||
@@ -528,7 +528,7 @@ const DEFAULT_CONFIG_CACHE_MS = 200;
|
||||
let configCache: {
|
||||
configPath: string;
|
||||
expiresAt: number;
|
||||
config: ClawdbotConfig;
|
||||
config: MoltbotConfig;
|
||||
} | null = null;
|
||||
|
||||
function resolveConfigCacheMs(env: NodeJS.ProcessEnv): number {
|
||||
@@ -549,7 +549,7 @@ function clearConfigCache(): void {
|
||||
configCache = null;
|
||||
}
|
||||
|
||||
export function loadConfig(): ClawdbotConfig {
|
||||
export function loadConfig(): MoltbotConfig {
|
||||
const configPath = resolveConfigPath();
|
||||
const now = Date.now();
|
||||
if (shouldUseConfigCache(process.env)) {
|
||||
@@ -578,7 +578,7 @@ export async function readConfigFileSnapshot(): Promise<ConfigFileSnapshot> {
|
||||
}).readConfigFileSnapshot();
|
||||
}
|
||||
|
||||
export async function writeConfigFile(cfg: ClawdbotConfig): Promise<void> {
|
||||
export async function writeConfigFile(cfg: MoltbotConfig): Promise<void> {
|
||||
clearConfigCache();
|
||||
await createConfigIO({ configPath: resolveConfigPath() }).writeConfigFile(cfg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user