refactor: rename to openclaw

This commit is contained in:
Peter Steinberger
2026-01-30 03:15:10 +01:00
parent 4583f88626
commit 9a7160786a
2357 changed files with 16688 additions and 16788 deletions

View File

@@ -95,10 +95,10 @@ const spawnGatewayInstance = async (name: string): Promise<GatewayInstance> => {
const port = await getFreePort();
const hookToken = `token-${name}-${randomUUID()}`;
const gatewayToken = `gateway-${name}-${randomUUID()}`;
const homeDir = await fs.mkdtemp(path.join(os.tmpdir(), `moltbot-e2e-${name}-`));
const configDir = path.join(homeDir, ".clawdbot");
const homeDir = await fs.mkdtemp(path.join(os.tmpdir(), `openclaw-e2e-${name}-`));
const configDir = path.join(homeDir, ".openclaw");
await fs.mkdir(configDir, { recursive: true });
const configPath = path.join(configDir, "moltbot.json");
const configPath = path.join(configDir, "openclaw.json");
const stateDir = path.join(configDir, "state");
const config = {
gateway: { port, auth: { mode: "token", token: gatewayToken } },
@@ -127,13 +127,13 @@ const spawnGatewayInstance = async (name: string): Promise<GatewayInstance> => {
env: {
...process.env,
HOME: homeDir,
CLAWDBOT_CONFIG_PATH: configPath,
CLAWDBOT_STATE_DIR: stateDir,
CLAWDBOT_GATEWAY_TOKEN: "",
CLAWDBOT_GATEWAY_PASSWORD: "",
CLAWDBOT_SKIP_CHANNELS: "1",
CLAWDBOT_SKIP_BROWSER_CONTROL_SERVER: "1",
CLAWDBOT_SKIP_CANVAS_HOST: "1",
OPENCLAW_CONFIG_PATH: configPath,
OPENCLAW_STATE_DIR: stateDir,
OPENCLAW_GATEWAY_TOKEN: "",
OPENCLAW_GATEWAY_PASSWORD: "",
OPENCLAW_SKIP_CHANNELS: "1",
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
OPENCLAW_SKIP_CANVAS_HOST: "1",
},
stdio: ["ignore", "pipe", "pipe"],
},
@@ -335,8 +335,8 @@ const waitForNodeStatus = async (inst: GatewayInstance, nodeId: string, timeoutM
const list = (await runCliJson(
["nodes", "status", "--json", "--url", `ws://127.0.0.1:${inst.port}`],
{
CLAWDBOT_GATEWAY_TOKEN: inst.gatewayToken,
CLAWDBOT_GATEWAY_PASSWORD: "",
OPENCLAW_GATEWAY_TOKEN: inst.gatewayToken,
OPENCLAW_GATEWAY_PASSWORD: "",
},
)) as NodeListPayload;
const match = list.nodes?.find((n) => n.nodeId === nodeId);
@@ -370,14 +370,14 @@ describe("gateway multi-instance e2e", () => {
const [healthA, healthB] = (await Promise.all([
runCliJson(["health", "--json", "--timeout", "10000"], {
CLAWDBOT_GATEWAY_PORT: String(gwA.port),
CLAWDBOT_GATEWAY_TOKEN: gwA.gatewayToken,
CLAWDBOT_GATEWAY_PASSWORD: "",
OPENCLAW_GATEWAY_PORT: String(gwA.port),
OPENCLAW_GATEWAY_TOKEN: gwA.gatewayToken,
OPENCLAW_GATEWAY_PASSWORD: "",
}),
runCliJson(["health", "--json", "--timeout", "10000"], {
CLAWDBOT_GATEWAY_PORT: String(gwB.port),
CLAWDBOT_GATEWAY_TOKEN: gwB.gatewayToken,
CLAWDBOT_GATEWAY_PASSWORD: "",
OPENCLAW_GATEWAY_PORT: String(gwB.port),
OPENCLAW_GATEWAY_TOKEN: gwB.gatewayToken,
OPENCLAW_GATEWAY_PASSWORD: "",
}),
])) as [HealthPayload, HealthPayload];
expect(healthA.ok).toBe(true);

View File

@@ -18,7 +18,7 @@ function snapshotEnv(): EnvSnapshot {
userProfile: process.env.USERPROFILE,
homeDrive: process.env.HOMEDRIVE,
homePath: process.env.HOMEPATH,
stateDir: process.env.CLAWDBOT_STATE_DIR,
stateDir: process.env.OPENCLAW_STATE_DIR,
};
}
@@ -31,7 +31,7 @@ function restoreEnv(snapshot: EnvSnapshot) {
restoreKey("USERPROFILE", snapshot.userProfile);
restoreKey("HOMEDRIVE", snapshot.homeDrive);
restoreKey("HOMEPATH", snapshot.homePath);
restoreKey("CLAWDBOT_STATE_DIR", snapshot.stateDir);
restoreKey("OPENCLAW_STATE_DIR", snapshot.stateDir);
}
function snapshotExtraEnv(keys: string[]): Record<string, string | undefined> {
@@ -50,7 +50,7 @@ function restoreExtraEnv(snapshot: Record<string, string | undefined>) {
function setTempHome(base: string) {
process.env.HOME = base;
process.env.USERPROFILE = base;
process.env.CLAWDBOT_STATE_DIR = path.join(base, ".clawdbot");
process.env.OPENCLAW_STATE_DIR = path.join(base, ".openclaw");
if (process.platform !== "win32") return;
const match = base.match(/^([A-Za-z]:)(.*)$/);
@@ -63,7 +63,7 @@ export async function withTempHome<T>(
fn: (home: string) => Promise<T>,
opts: { env?: Record<string, EnvValue>; prefix?: string } = {},
): Promise<T> {
const base = await fs.mkdtemp(path.join(os.tmpdir(), opts.prefix ?? "moltbot-test-home-"));
const base = await fs.mkdtemp(path.join(os.tmpdir(), opts.prefix ?? "openclaw-test-home-"));
const snapshot = snapshotEnv();
const envKeys = Object.keys(opts.env ?? {});
for (const key of envKeys) {
@@ -74,7 +74,7 @@ export async function withTempHome<T>(
const envSnapshot = snapshotExtraEnv(envKeys);
setTempHome(base);
await fs.mkdir(path.join(base, ".clawdbot", "agents", "main", "sessions"), { recursive: true });
await fs.mkdir(path.join(base, ".openclaw", "agents", "main", "sessions"), { recursive: true });
if (opts.env) {
for (const [key, raw] of Object.entries(opts.env)) {
const value = typeof raw === "function" ? raw(base) : raw;

View File

@@ -4,7 +4,7 @@ import path from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { MoltbotConfig } from "../src/config/config.js";
import type { OpenClawConfig } from "../src/config/config.js";
import type { MsgContext } from "../src/auto-reply/templating.js";
const makeTempDir = async (prefix: string) => await fs.mkdtemp(path.join(os.tmpdir(), prefix));
@@ -16,7 +16,7 @@ const writeExecutable = async (dir: string, name: string, content: string) => {
};
const makeTempMedia = async (ext: string) => {
const dir = await makeTempDir("moltbot-media-e2e-");
const dir = await makeTempDir("openclaw-media-e2e-");
const filePath = path.join(dir, `sample${ext}`);
await fs.writeFile(filePath, "audio");
return { dir, filePath };
@@ -52,8 +52,8 @@ describe("media understanding auto-detect (e2e)", () => {
it("uses sherpa-onnx-offline when available", async () => {
const snapshot = envSnapshot();
try {
const binDir = await makeTempDir("moltbot-bin-sherpa-");
const modelDir = await makeTempDir("moltbot-sherpa-model-");
const binDir = await makeTempDir("openclaw-bin-sherpa-");
const modelDir = await makeTempDir("openclaw-sherpa-model-");
tempPaths.push(binDir, modelDir);
await fs.writeFile(path.join(modelDir, "tokens.txt"), "a");
@@ -79,7 +79,7 @@ describe("media understanding auto-detect (e2e)", () => {
MediaPath: filePath,
MediaType: "audio/wav",
};
const cfg: MoltbotConfig = { tools: { media: { audio: {} } } };
const cfg: OpenClawConfig = { tools: { media: { audio: {} } } };
await applyMediaUnderstanding({ ctx, cfg });
@@ -92,8 +92,8 @@ describe("media understanding auto-detect (e2e)", () => {
it("uses whisper-cli when sherpa is missing", async () => {
const snapshot = envSnapshot();
try {
const binDir = await makeTempDir("moltbot-bin-whispercpp-");
const modelDir = await makeTempDir("moltbot-whispercpp-model-");
const binDir = await makeTempDir("openclaw-bin-whispercpp-");
const modelDir = await makeTempDir("openclaw-whispercpp-model-");
tempPaths.push(binDir, modelDir);
const modelPath = path.join(modelDir, "tiny.bin");
@@ -124,7 +124,7 @@ describe("media understanding auto-detect (e2e)", () => {
MediaPath: filePath,
MediaType: "audio/wav",
};
const cfg: MoltbotConfig = { tools: { media: { audio: {} } } };
const cfg: OpenClawConfig = { tools: { media: { audio: {} } } };
await applyMediaUnderstanding({ ctx, cfg });
@@ -137,7 +137,7 @@ describe("media understanding auto-detect (e2e)", () => {
it("uses gemini CLI for images when available", async () => {
const snapshot = envSnapshot();
try {
const binDir = await makeTempDir("moltbot-bin-gemini-");
const binDir = await makeTempDir("openclaw-bin-gemini-");
tempPaths.push(binDir);
await writeExecutable(
@@ -157,7 +157,7 @@ describe("media understanding auto-detect (e2e)", () => {
MediaPath: filePath,
MediaType: "image/png",
};
const cfg: MoltbotConfig = { tools: { media: { image: {} } } };
const cfg: OpenClawConfig = { tools: { media: { image: {} } } };
await applyMediaUnderstanding({ ctx, cfg });

View File

@@ -118,12 +118,12 @@ describe("provider timeouts (e2e)", () => {
async () => {
const prev = {
home: process.env.HOME,
configPath: process.env.CLAWDBOT_CONFIG_PATH,
token: process.env.CLAWDBOT_GATEWAY_TOKEN,
skipChannels: process.env.CLAWDBOT_SKIP_CHANNELS,
skipGmail: process.env.CLAWDBOT_SKIP_GMAIL_WATCHER,
skipCron: process.env.CLAWDBOT_SKIP_CRON,
skipCanvas: process.env.CLAWDBOT_SKIP_CANVAS_HOST,
configPath: process.env.OPENCLAW_CONFIG_PATH,
token: process.env.OPENCLAW_GATEWAY_TOKEN,
skipChannels: process.env.OPENCLAW_SKIP_CHANNELS,
skipGmail: process.env.OPENCLAW_SKIP_GMAIL_WATCHER,
skipCron: process.env.OPENCLAW_SKIP_CRON,
skipCanvas: process.env.OPENCLAW_SKIP_CANVAS_HOST,
};
const originalFetch = globalThis.fetch;
@@ -151,19 +151,19 @@ describe("provider timeouts (e2e)", () => {
};
(globalThis as unknown as { fetch: unknown }).fetch = fetchImpl;
const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-timeout-e2e-"));
const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-timeout-e2e-"));
process.env.HOME = tempHome;
process.env.CLAWDBOT_SKIP_CHANNELS = "1";
process.env.CLAWDBOT_SKIP_GMAIL_WATCHER = "1";
process.env.CLAWDBOT_SKIP_CRON = "1";
process.env.CLAWDBOT_SKIP_CANVAS_HOST = "1";
process.env.OPENCLAW_SKIP_CHANNELS = "1";
process.env.OPENCLAW_SKIP_GMAIL_WATCHER = "1";
process.env.OPENCLAW_SKIP_CRON = "1";
process.env.OPENCLAW_SKIP_CANVAS_HOST = "1";
const token = `test-${randomUUID()}`;
process.env.CLAWDBOT_GATEWAY_TOKEN = token;
process.env.OPENCLAW_GATEWAY_TOKEN = token;
const configDir = path.join(tempHome, ".clawdbot");
const configDir = path.join(tempHome, ".openclaw");
await fs.mkdir(configDir, { recursive: true });
const configPath = path.join(configDir, "moltbot.json");
const configPath = path.join(configDir, "openclaw.json");
const cfg = {
agents: {
@@ -217,7 +217,7 @@ describe("provider timeouts (e2e)", () => {
};
await fs.writeFile(configPath, `${JSON.stringify(cfg, null, 2)}\n`);
process.env.CLAWDBOT_CONFIG_PATH = configPath;
process.env.OPENCLAW_CONFIG_PATH = configPath;
const port = await getFreeGatewayPort();
const server = await startGatewayServer(port, {
@@ -265,18 +265,18 @@ describe("provider timeouts (e2e)", () => {
(globalThis as unknown as { fetch: unknown }).fetch = originalFetch;
if (prev.home === undefined) delete process.env.HOME;
else process.env.HOME = prev.home;
if (prev.configPath === undefined) delete process.env.CLAWDBOT_CONFIG_PATH;
else process.env.CLAWDBOT_CONFIG_PATH = prev.configPath;
if (prev.token === undefined) delete process.env.CLAWDBOT_GATEWAY_TOKEN;
else process.env.CLAWDBOT_GATEWAY_TOKEN = prev.token;
if (prev.skipChannels === undefined) delete process.env.CLAWDBOT_SKIP_CHANNELS;
else process.env.CLAWDBOT_SKIP_CHANNELS = prev.skipChannels;
if (prev.skipGmail === undefined) delete process.env.CLAWDBOT_SKIP_GMAIL_WATCHER;
else process.env.CLAWDBOT_SKIP_GMAIL_WATCHER = prev.skipGmail;
if (prev.skipCron === undefined) delete process.env.CLAWDBOT_SKIP_CRON;
else process.env.CLAWDBOT_SKIP_CRON = prev.skipCron;
if (prev.skipCanvas === undefined) delete process.env.CLAWDBOT_SKIP_CANVAS_HOST;
else process.env.CLAWDBOT_SKIP_CANVAS_HOST = prev.skipCanvas;
if (prev.configPath === undefined) delete process.env.OPENCLAW_CONFIG_PATH;
else process.env.OPENCLAW_CONFIG_PATH = prev.configPath;
if (prev.token === undefined) delete process.env.OPENCLAW_GATEWAY_TOKEN;
else process.env.OPENCLAW_GATEWAY_TOKEN = prev.token;
if (prev.skipChannels === undefined) delete process.env.OPENCLAW_SKIP_CHANNELS;
else process.env.OPENCLAW_SKIP_CHANNELS = prev.skipChannels;
if (prev.skipGmail === undefined) delete process.env.OPENCLAW_SKIP_GMAIL_WATCHER;
else process.env.OPENCLAW_SKIP_GMAIL_WATCHER = prev.skipGmail;
if (prev.skipCron === undefined) delete process.env.OPENCLAW_SKIP_CRON;
else process.env.OPENCLAW_SKIP_CRON = prev.skipCron;
if (prev.skipCanvas === undefined) delete process.env.OPENCLAW_SKIP_CANVAS_HOST;
else process.env.OPENCLAW_SKIP_CANVAS_HOST = prev.skipCanvas;
}
},
);

View File

@@ -8,7 +8,7 @@ import type {
ChannelOutboundAdapter,
ChannelPlugin,
} from "../src/channels/plugins/types.js";
import type { MoltbotConfig } from "../src/config/config.js";
import type { OpenClawConfig } from "../src/config/config.js";
import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js";
import { installProcessWarningFilter } from "../src/infra/warnings.js";
import { setActivePluginRegistry } from "../src/plugins/runtime.js";
@@ -80,7 +80,7 @@ const createStubPlugin = (params: {
},
capabilities: { chatTypes: ["direct", "group"] },
config: {
listAccountIds: (cfg: MoltbotConfig) => {
listAccountIds: (cfg: OpenClawConfig) => {
const channels = cfg.channels as Record<string, unknown> | undefined;
const entry = channels?.[params.id];
if (!entry || typeof entry !== "object") return [];
@@ -88,7 +88,7 @@ const createStubPlugin = (params: {
const ids = accounts ? Object.keys(accounts).filter(Boolean) : [];
return ids.length > 0 ? ids : ["default"];
},
resolveAccount: (cfg: MoltbotConfig, accountId: string) => {
resolveAccount: (cfg: OpenClawConfig, accountId: string) => {
const channels = cfg.channels as Record<string, unknown> | undefined;
const entry = channels?.[params.id];
if (!entry || typeof entry !== "object") return {};
@@ -96,7 +96,7 @@ const createStubPlugin = (params: {
const match = accounts?.[accountId];
return (match && typeof match === "object") || typeof match === "string" ? match : entry;
},
isConfigured: async (_account, cfg: MoltbotConfig) => {
isConfigured: async (_account, cfg: OpenClawConfig) => {
const channels = cfg.channels as Record<string, unknown> | undefined;
return Boolean(channels?.[params.id]);
},

View File

@@ -43,8 +43,8 @@ function loadProfileEnv(): void {
export function installTestEnv(): { cleanup: () => void; tempHome: string } {
const live =
process.env.LIVE === "1" ||
process.env.CLAWDBOT_LIVE_TEST === "1" ||
process.env.CLAWDBOT_LIVE_GATEWAY === "1";
process.env.OPENCLAW_LIVE_TEST === "1" ||
process.env.OPENCLAW_LIVE_GATEWAY === "1";
// Live tests must use the real user environment (keys, profiles, config).
// The default test env isolates HOME to avoid touching real state.
@@ -54,21 +54,21 @@ export function installTestEnv(): { cleanup: () => void; tempHome: string } {
}
const restore: RestoreEntry[] = [
{ key: "CLAWDBOT_TEST_FAST", value: process.env.CLAWDBOT_TEST_FAST },
{ key: "OPENCLAW_TEST_FAST", value: process.env.OPENCLAW_TEST_FAST },
{ key: "HOME", value: process.env.HOME },
{ key: "USERPROFILE", value: process.env.USERPROFILE },
{ key: "XDG_CONFIG_HOME", value: process.env.XDG_CONFIG_HOME },
{ key: "XDG_DATA_HOME", value: process.env.XDG_DATA_HOME },
{ key: "XDG_STATE_HOME", value: process.env.XDG_STATE_HOME },
{ key: "XDG_CACHE_HOME", value: process.env.XDG_CACHE_HOME },
{ key: "CLAWDBOT_STATE_DIR", value: process.env.CLAWDBOT_STATE_DIR },
{ key: "CLAWDBOT_CONFIG_PATH", value: process.env.CLAWDBOT_CONFIG_PATH },
{ key: "CLAWDBOT_GATEWAY_PORT", value: process.env.CLAWDBOT_GATEWAY_PORT },
{ key: "CLAWDBOT_BRIDGE_ENABLED", value: process.env.CLAWDBOT_BRIDGE_ENABLED },
{ key: "CLAWDBOT_BRIDGE_HOST", value: process.env.CLAWDBOT_BRIDGE_HOST },
{ key: "CLAWDBOT_BRIDGE_PORT", value: process.env.CLAWDBOT_BRIDGE_PORT },
{ key: "CLAWDBOT_CANVAS_HOST_PORT", value: process.env.CLAWDBOT_CANVAS_HOST_PORT },
{ key: "CLAWDBOT_TEST_HOME", value: process.env.CLAWDBOT_TEST_HOME },
{ key: "OPENCLAW_STATE_DIR", value: process.env.OPENCLAW_STATE_DIR },
{ key: "OPENCLAW_CONFIG_PATH", value: process.env.OPENCLAW_CONFIG_PATH },
{ key: "OPENCLAW_GATEWAY_PORT", value: process.env.OPENCLAW_GATEWAY_PORT },
{ key: "OPENCLAW_BRIDGE_ENABLED", value: process.env.OPENCLAW_BRIDGE_ENABLED },
{ key: "OPENCLAW_BRIDGE_HOST", value: process.env.OPENCLAW_BRIDGE_HOST },
{ key: "OPENCLAW_BRIDGE_PORT", value: process.env.OPENCLAW_BRIDGE_PORT },
{ key: "OPENCLAW_CANVAS_HOST_PORT", value: process.env.OPENCLAW_CANVAS_HOST_PORT },
{ key: "OPENCLAW_TEST_HOME", value: process.env.OPENCLAW_TEST_HOME },
{ key: "TELEGRAM_BOT_TOKEN", value: process.env.TELEGRAM_BOT_TOKEN },
{ key: "DISCORD_BOT_TOKEN", value: process.env.DISCORD_BOT_TOKEN },
{ key: "SLACK_BOT_TOKEN", value: process.env.SLACK_BOT_TOKEN },
@@ -80,23 +80,23 @@ export function installTestEnv(): { cleanup: () => void; tempHome: string } {
{ key: "NODE_OPTIONS", value: process.env.NODE_OPTIONS },
];
const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "moltbot-test-home-"));
const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-test-home-"));
process.env.HOME = tempHome;
process.env.USERPROFILE = tempHome;
process.env.CLAWDBOT_TEST_HOME = tempHome;
process.env.CLAWDBOT_TEST_FAST = "1";
process.env.OPENCLAW_TEST_HOME = tempHome;
process.env.OPENCLAW_TEST_FAST = "1";
// Ensure test runs never touch the developer's real config/state, even if they have overrides set.
delete process.env.CLAWDBOT_CONFIG_PATH;
delete process.env.OPENCLAW_CONFIG_PATH;
// Prefer deriving state dir from HOME so nested tests that change HOME also isolate correctly.
delete process.env.CLAWDBOT_STATE_DIR;
delete process.env.OPENCLAW_STATE_DIR;
// Prefer test-controlled ports over developer overrides (avoid port collisions across tests/workers).
delete process.env.CLAWDBOT_GATEWAY_PORT;
delete process.env.CLAWDBOT_BRIDGE_ENABLED;
delete process.env.CLAWDBOT_BRIDGE_HOST;
delete process.env.CLAWDBOT_BRIDGE_PORT;
delete process.env.CLAWDBOT_CANVAS_HOST_PORT;
delete process.env.OPENCLAW_GATEWAY_PORT;
delete process.env.OPENCLAW_BRIDGE_ENABLED;
delete process.env.OPENCLAW_BRIDGE_HOST;
delete process.env.OPENCLAW_BRIDGE_PORT;
delete process.env.OPENCLAW_CANVAS_HOST_PORT;
// Avoid leaking real GitHub/Copilot tokens into non-live test runs.
delete process.env.TELEGRAM_BOT_TOKEN;
delete process.env.DISCORD_BOT_TOKEN;
@@ -109,9 +109,9 @@ export function installTestEnv(): { cleanup: () => void; tempHome: string } {
// Avoid leaking local dev tooling flags into tests (e.g. --inspect).
delete process.env.NODE_OPTIONS;
// Windows: prefer the legacy default state dir so auth/profile tests match real paths.
// Windows: prefer the default state dir so auth/profile tests match real paths.
if (process.platform === "win32") {
process.env.CLAWDBOT_STATE_DIR = path.join(tempHome, ".clawdbot");
process.env.OPENCLAW_STATE_DIR = path.join(tempHome, ".openclaw");
}
process.env.XDG_CONFIG_HOME = path.join(tempHome, ".config");