mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 05:24:32 +00:00
refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -4,7 +4,7 @@ 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 {
|
||||
autoMigrateLegacyState,
|
||||
detectLegacyStateMigrations,
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
let tempRoot: string | null = null;
|
||||
|
||||
async function makeTempRoot() {
|
||||
const root = await fs.promises.mkdtemp(path.join(os.tmpdir(), "clawdbot-doctor-"));
|
||||
const root = await fs.promises.mkdtemp(path.join(os.tmpdir(), "moltbot-doctor-"));
|
||||
tempRoot = root;
|
||||
return root;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ function writeJson5(filePath: string, value: unknown) {
|
||||
describe("doctor legacy state migrations", () => {
|
||||
it("migrates legacy sessions into agents/<id>/sessions", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
const legacySessionsDir = path.join(root, "sessions");
|
||||
fs.mkdirSync(legacySessionsDir, { recursive: true });
|
||||
|
||||
@@ -79,7 +79,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("migrates legacy agent dir with conflict fallback", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
|
||||
const legacyAgentDir = path.join(root, "agent");
|
||||
fs.mkdirSync(legacyAgentDir, { recursive: true });
|
||||
@@ -103,7 +103,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("auto-migrates legacy agent dir on startup", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
|
||||
const legacyAgentDir = path.join(root, "agent");
|
||||
fs.mkdirSync(legacyAgentDir, { recursive: true });
|
||||
@@ -125,7 +125,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("auto-migrates legacy sessions on startup", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
|
||||
const legacySessionsDir = path.join(root, "sessions");
|
||||
fs.mkdirSync(legacySessionsDir, { recursive: true });
|
||||
@@ -154,7 +154,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("migrates legacy WhatsApp auth files without touching oauth.json", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
|
||||
const oauthDir = path.join(root, "credentials");
|
||||
fs.mkdirSync(oauthDir, { recursive: true });
|
||||
@@ -177,7 +177,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("no-ops when nothing detected", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
const detected = await detectLegacyStateMigrations({
|
||||
cfg,
|
||||
env: { CLAWDBOT_STATE_DIR: root } as NodeJS.ProcessEnv,
|
||||
@@ -188,7 +188,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("routes legacy state to the default agent entry", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {
|
||||
const cfg: MoltbotConfig = {
|
||||
agents: { list: [{ id: "alpha", default: true }] },
|
||||
};
|
||||
const legacySessionsDir = path.join(root, "sessions");
|
||||
@@ -212,7 +212,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("honors session.mainKey when seeding the direct-chat bucket", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = { session: { mainKey: "work" } };
|
||||
const cfg: MoltbotConfig = { session: { mainKey: "work" } };
|
||||
const legacySessionsDir = path.join(root, "sessions");
|
||||
fs.mkdirSync(legacySessionsDir, { recursive: true });
|
||||
writeJson5(path.join(legacySessionsDir, "sessions.json"), {
|
||||
@@ -236,7 +236,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("canonicalizes legacy main keys inside the target sessions store", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
const targetDir = path.join(root, "agents", "main", "sessions");
|
||||
writeJson5(path.join(targetDir, "sessions.json"), {
|
||||
main: { sessionId: "legacy", updatedAt: 10 },
|
||||
@@ -258,7 +258,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("prefers the newest entry when collapsing main aliases", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = { session: { mainKey: "work" } };
|
||||
const cfg: MoltbotConfig = { session: { mainKey: "work" } };
|
||||
const targetDir = path.join(root, "agents", "main", "sessions");
|
||||
writeJson5(path.join(targetDir, "sessions.json"), {
|
||||
"agent:main:main": { sessionId: "legacy", updatedAt: 50 },
|
||||
@@ -280,7 +280,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("lowercases agent session keys during canonicalization", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
const targetDir = path.join(root, "agents", "main", "sessions");
|
||||
writeJson5(path.join(targetDir, "sessions.json"), {
|
||||
"agent:main:slack:channel:C123": { sessionId: "legacy", updatedAt: 10 },
|
||||
@@ -301,7 +301,7 @@ describe("doctor legacy state migrations", () => {
|
||||
|
||||
it("auto-migrates when only target sessions contain legacy keys", async () => {
|
||||
const root = await makeTempRoot();
|
||||
const cfg: ClawdbotConfig = {};
|
||||
const cfg: MoltbotConfig = {};
|
||||
const targetDir = path.join(root, "agents", "main", "sessions");
|
||||
writeJson5(path.join(targetDir, "sessions.json"), {
|
||||
main: { sessionId: "legacy", updatedAt: 10 },
|
||||
|
||||
Reference in New Issue
Block a user