chore: drop Clawdis legacy references
This commit is contained in:
@@ -240,7 +240,7 @@ export function printDaemonStatus(status: DaemonStatus, opts: { json: boolean })
|
||||
}
|
||||
|
||||
if (legacyServices.length > 0) {
|
||||
defaultRuntime.error(errorText("Legacy Clawdis services detected:"));
|
||||
defaultRuntime.error(errorText("Legacy gateway services detected:"));
|
||||
for (const svc of legacyServices) {
|
||||
defaultRuntime.error(`- ${errorText(svc.label)} (${svc.detail})`);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ export function registerGatewayCli(program: Command) {
|
||||
program
|
||||
.command("gateway-daemon", { hidden: true })
|
||||
.description("Run the WebSocket Gateway as a long-lived daemon"),
|
||||
{ legacyTokenEnv: true },
|
||||
);
|
||||
|
||||
gatewayCallOpts(
|
||||
|
||||
@@ -48,13 +48,9 @@ type GatewayRunOpts = {
|
||||
reset?: boolean;
|
||||
};
|
||||
|
||||
type GatewayRunParams = {
|
||||
legacyTokenEnv?: boolean;
|
||||
};
|
||||
|
||||
const gatewayLog = createSubsystemLogger("gateway");
|
||||
|
||||
async function runGatewayCommand(opts: GatewayRunOpts, params: GatewayRunParams = {}) {
|
||||
async function runGatewayCommand(opts: GatewayRunOpts) {
|
||||
const isDevProfile = process.env.CLAWDBOT_PROFILE?.trim().toLowerCase() === "dev";
|
||||
const devMode = Boolean(opts.dev) || isDevProfile;
|
||||
if (opts.reset && !devMode) {
|
||||
@@ -62,12 +58,6 @@ async function runGatewayCommand(opts: GatewayRunOpts, params: GatewayRunParams
|
||||
defaultRuntime.exit(1);
|
||||
return;
|
||||
}
|
||||
if (params.legacyTokenEnv) {
|
||||
const legacyToken = process.env.CLAWDIS_GATEWAY_TOKEN;
|
||||
if (legacyToken && !process.env.CLAWDBOT_GATEWAY_TOKEN) {
|
||||
process.env.CLAWDBOT_GATEWAY_TOKEN = legacyToken;
|
||||
}
|
||||
}
|
||||
|
||||
setVerbose(Boolean(opts.verbose));
|
||||
if (opts.claudeCliLogs) {
|
||||
@@ -306,7 +296,7 @@ async function runGatewayCommand(opts: GatewayRunOpts, params: GatewayRunParams
|
||||
}
|
||||
}
|
||||
|
||||
export function addGatewayRunCommand(cmd: Command, params: GatewayRunParams = {}): Command {
|
||||
export function addGatewayRunCommand(cmd: Command): Command {
|
||||
return cmd
|
||||
.option("--port <port>", "Port for the gateway WebSocket")
|
||||
.option(
|
||||
@@ -348,6 +338,6 @@ export function addGatewayRunCommand(cmd: Command, params: GatewayRunParams = {}
|
||||
.option("--raw-stream", "Log raw model stream events to jsonl", false)
|
||||
.option("--raw-stream-path <path>", "Raw stream jsonl path")
|
||||
.action(async (opts) => {
|
||||
await runGatewayCommand(opts, params);
|
||||
await runGatewayCommand(opts);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ export async function maybeMigrateLegacyGatewayService(
|
||||
|
||||
note(
|
||||
legacyServices.map((svc) => `- ${svc.label} (${svc.platform}, ${svc.detail})`).join("\n"),
|
||||
"Legacy Clawdis services detected",
|
||||
"Legacy gateway services detected",
|
||||
);
|
||||
|
||||
const migrate = await prompter.confirmSkipInNonInteractive({
|
||||
message: "Migrate legacy Clawdis services to Clawdbot now?",
|
||||
message: "Migrate legacy gateway services to Clawdbot now?",
|
||||
initialValue: true,
|
||||
});
|
||||
if (!migrate) return;
|
||||
|
||||
@@ -1,59 +1,6 @@
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import {
|
||||
CONFIG_PATH_CLAWDBOT,
|
||||
createConfigIO,
|
||||
migrateLegacyConfig,
|
||||
readConfigFileSnapshot,
|
||||
writeConfigFile,
|
||||
} from "../config/config.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { note } from "../terminal/note.js";
|
||||
import { resolveUserPath } from "../utils.js";
|
||||
import { hasAnyWhatsAppAuth } from "../web/accounts.js";
|
||||
|
||||
function resolveLegacyConfigPath(env: NodeJS.ProcessEnv): string {
|
||||
const override = env.CLAWDIS_CONFIG_PATH?.trim();
|
||||
if (override) return override;
|
||||
return path.join(os.homedir(), ".clawdis", "clawdis.json");
|
||||
}
|
||||
|
||||
function normalizeDefaultWorkspacePath(value: string | undefined): string | undefined {
|
||||
if (!value) return value;
|
||||
|
||||
const resolved = resolveUserPath(value);
|
||||
const home = os.homedir();
|
||||
|
||||
const next = [
|
||||
["clawdis", "clawd"],
|
||||
["clawdbot", "clawd"],
|
||||
].reduce((acc, [from, to]) => {
|
||||
const fromPrefix = path.join(home, from);
|
||||
if (acc === fromPrefix) return path.join(home, to);
|
||||
const withSep = `${fromPrefix}${path.sep}`;
|
||||
if (acc.startsWith(withSep)) {
|
||||
return path.join(home, to).concat(acc.slice(fromPrefix.length));
|
||||
}
|
||||
return acc;
|
||||
}, resolved);
|
||||
|
||||
return next === resolved ? value : next;
|
||||
}
|
||||
|
||||
export function replaceLegacyName(value: string | undefined): string | undefined {
|
||||
if (!value) return value;
|
||||
const replacedClawdis = value.replace(/clawdis/g, "clawdbot");
|
||||
return replacedClawdis.replace(/clawd(?!bot)/g, "clawdbot");
|
||||
}
|
||||
|
||||
export function replaceModernName(value: string | undefined): string | undefined {
|
||||
if (!value) return value;
|
||||
if (!value.includes("clawdbot")) return value;
|
||||
return value.replace(/clawdbot/g, "clawdis");
|
||||
}
|
||||
|
||||
export function normalizeLegacyConfigValues(cfg: ClawdbotConfig): {
|
||||
config: ClawdbotConfig;
|
||||
changes: string[];
|
||||
@@ -61,164 +8,6 @@ export function normalizeLegacyConfigValues(cfg: ClawdbotConfig): {
|
||||
const changes: string[] = [];
|
||||
let next: ClawdbotConfig = cfg;
|
||||
|
||||
const defaults = cfg.agents?.defaults;
|
||||
if (defaults) {
|
||||
let updatedDefaults = defaults;
|
||||
let defaultsChanged = false;
|
||||
|
||||
const updatedWorkspace = normalizeDefaultWorkspacePath(defaults.workspace);
|
||||
if (updatedWorkspace && updatedWorkspace !== defaults.workspace) {
|
||||
updatedDefaults = { ...updatedDefaults, workspace: updatedWorkspace };
|
||||
defaultsChanged = true;
|
||||
changes.push(`Updated agents.defaults.workspace → ${updatedWorkspace}`);
|
||||
}
|
||||
|
||||
const sandbox = defaults.sandbox;
|
||||
if (sandbox) {
|
||||
let updatedSandbox = sandbox;
|
||||
let sandboxChanged = false;
|
||||
|
||||
const updatedWorkspaceRoot = normalizeDefaultWorkspacePath(sandbox.workspaceRoot);
|
||||
if (updatedWorkspaceRoot && updatedWorkspaceRoot !== sandbox.workspaceRoot) {
|
||||
updatedSandbox = {
|
||||
...updatedSandbox,
|
||||
workspaceRoot: updatedWorkspaceRoot,
|
||||
};
|
||||
sandboxChanged = true;
|
||||
changes.push(`Updated agents.defaults.sandbox.workspaceRoot → ${updatedWorkspaceRoot}`);
|
||||
}
|
||||
|
||||
const dockerImage = sandbox.docker?.image;
|
||||
const updatedDockerImage = replaceLegacyName(dockerImage);
|
||||
if (updatedDockerImage && updatedDockerImage !== dockerImage) {
|
||||
updatedSandbox = {
|
||||
...updatedSandbox,
|
||||
docker: {
|
||||
...updatedSandbox.docker,
|
||||
image: updatedDockerImage,
|
||||
},
|
||||
};
|
||||
sandboxChanged = true;
|
||||
changes.push(`Updated agents.defaults.sandbox.docker.image → ${updatedDockerImage}`);
|
||||
}
|
||||
|
||||
const containerPrefix = sandbox.docker?.containerPrefix;
|
||||
const updatedContainerPrefix = replaceLegacyName(containerPrefix);
|
||||
if (updatedContainerPrefix && updatedContainerPrefix !== containerPrefix) {
|
||||
updatedSandbox = {
|
||||
...updatedSandbox,
|
||||
docker: {
|
||||
...updatedSandbox.docker,
|
||||
containerPrefix: updatedContainerPrefix,
|
||||
},
|
||||
};
|
||||
sandboxChanged = true;
|
||||
changes.push(
|
||||
`Updated agents.defaults.sandbox.docker.containerPrefix → ${updatedContainerPrefix}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (sandboxChanged) {
|
||||
updatedDefaults = { ...updatedDefaults, sandbox: updatedSandbox };
|
||||
defaultsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultsChanged) {
|
||||
next = {
|
||||
...next,
|
||||
agents: {
|
||||
...next.agents,
|
||||
defaults: updatedDefaults,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const list = Array.isArray(cfg.agents?.list) ? cfg.agents.list : [];
|
||||
if (list.length > 0) {
|
||||
let listChanged = false;
|
||||
const nextList = list.map((agent) => {
|
||||
let updatedAgent = agent;
|
||||
let agentChanged = false;
|
||||
|
||||
const updatedWorkspace = normalizeDefaultWorkspacePath(agent.workspace);
|
||||
if (updatedWorkspace && updatedWorkspace !== agent.workspace) {
|
||||
updatedAgent = { ...updatedAgent, workspace: updatedWorkspace };
|
||||
agentChanged = true;
|
||||
changes.push(`Updated agents.list (id "${agent.id}") workspace → ${updatedWorkspace}`);
|
||||
}
|
||||
|
||||
const sandbox = agent.sandbox;
|
||||
if (sandbox) {
|
||||
let updatedSandbox = sandbox;
|
||||
let sandboxChanged = false;
|
||||
|
||||
const updatedWorkspaceRoot = normalizeDefaultWorkspacePath(sandbox.workspaceRoot);
|
||||
if (updatedWorkspaceRoot && updatedWorkspaceRoot !== sandbox.workspaceRoot) {
|
||||
updatedSandbox = {
|
||||
...updatedSandbox,
|
||||
workspaceRoot: updatedWorkspaceRoot,
|
||||
};
|
||||
sandboxChanged = true;
|
||||
changes.push(
|
||||
`Updated agents.list (id "${agent.id}") sandbox.workspaceRoot → ${updatedWorkspaceRoot}`,
|
||||
);
|
||||
}
|
||||
|
||||
const dockerImage = sandbox.docker?.image;
|
||||
const updatedDockerImage = replaceLegacyName(dockerImage);
|
||||
if (updatedDockerImage && updatedDockerImage !== dockerImage) {
|
||||
updatedSandbox = {
|
||||
...updatedSandbox,
|
||||
docker: {
|
||||
...updatedSandbox.docker,
|
||||
image: updatedDockerImage,
|
||||
},
|
||||
};
|
||||
sandboxChanged = true;
|
||||
changes.push(
|
||||
`Updated agents.list (id "${agent.id}") sandbox.docker.image → ${updatedDockerImage}`,
|
||||
);
|
||||
}
|
||||
|
||||
const containerPrefix = sandbox.docker?.containerPrefix;
|
||||
const updatedContainerPrefix = replaceLegacyName(containerPrefix);
|
||||
if (updatedContainerPrefix && updatedContainerPrefix !== containerPrefix) {
|
||||
updatedSandbox = {
|
||||
...updatedSandbox,
|
||||
docker: {
|
||||
...updatedSandbox.docker,
|
||||
containerPrefix: updatedContainerPrefix,
|
||||
},
|
||||
};
|
||||
sandboxChanged = true;
|
||||
changes.push(
|
||||
`Updated agents.list (id "${agent.id}") sandbox.docker.containerPrefix → ${updatedContainerPrefix}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (sandboxChanged) {
|
||||
updatedAgent = { ...updatedAgent, sandbox: updatedSandbox };
|
||||
agentChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (agentChanged) listChanged = true;
|
||||
return agentChanged ? updatedAgent : agent;
|
||||
});
|
||||
|
||||
if (listChanged) {
|
||||
next = {
|
||||
...next,
|
||||
agents: {
|
||||
...next.agents,
|
||||
list: nextList,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const legacyAckReaction = cfg.messages?.ackReaction?.trim();
|
||||
const hasWhatsAppConfig = cfg.channels?.whatsapp !== undefined;
|
||||
const hasWhatsAppAuth = hasAnyWhatsAppAuth(cfg);
|
||||
@@ -259,83 +48,3 @@ export function normalizeLegacyConfigValues(cfg: ClawdbotConfig): {
|
||||
|
||||
return { config: next, changes };
|
||||
}
|
||||
|
||||
export async function maybeMigrateLegacyConfigFile(runtime: RuntimeEnv) {
|
||||
const legacyConfigPath = resolveLegacyConfigPath(process.env);
|
||||
if (legacyConfigPath === CONFIG_PATH_CLAWDBOT) return;
|
||||
|
||||
const legacyIo = createConfigIO({ configPath: legacyConfigPath });
|
||||
const legacySnapshot = await legacyIo.readConfigFileSnapshot();
|
||||
if (!legacySnapshot.exists) return;
|
||||
|
||||
const currentSnapshot = await readConfigFileSnapshot();
|
||||
if (currentSnapshot.exists) {
|
||||
note(
|
||||
`Legacy config still exists at ${legacyConfigPath}. Current config at ${CONFIG_PATH_CLAWDBOT}.`,
|
||||
"Legacy config",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const gatewayMode =
|
||||
typeof (legacySnapshot.parsed as ClawdbotConfig)?.gateway?.mode === "string"
|
||||
? (legacySnapshot.parsed as ClawdbotConfig).gateway?.mode
|
||||
: undefined;
|
||||
const gatewayBind =
|
||||
typeof (legacySnapshot.parsed as ClawdbotConfig)?.gateway?.bind === "string"
|
||||
? (legacySnapshot.parsed as ClawdbotConfig).gateway?.bind
|
||||
: undefined;
|
||||
const parsed = legacySnapshot.parsed as Record<string, unknown>;
|
||||
const parsedAgents =
|
||||
parsed.agents && typeof parsed.agents === "object"
|
||||
? (parsed.agents as Record<string, unknown>)
|
||||
: undefined;
|
||||
const parsedDefaults =
|
||||
parsedAgents?.defaults && typeof parsedAgents.defaults === "object"
|
||||
? (parsedAgents.defaults as Record<string, unknown>)
|
||||
: undefined;
|
||||
const parsedLegacyAgent =
|
||||
parsed.agent && typeof parsed.agent === "object"
|
||||
? (parsed.agent as Record<string, unknown>)
|
||||
: undefined;
|
||||
const defaultWorkspace =
|
||||
typeof parsedDefaults?.workspace === "string" ? parsedDefaults.workspace : undefined;
|
||||
const legacyWorkspace =
|
||||
typeof parsedLegacyAgent?.workspace === "string" ? parsedLegacyAgent.workspace : undefined;
|
||||
const agentWorkspace = defaultWorkspace ?? legacyWorkspace;
|
||||
const workspaceLabel = defaultWorkspace
|
||||
? "agents.defaults.workspace"
|
||||
: legacyWorkspace
|
||||
? "agent.workspace"
|
||||
: "agents.defaults.workspace";
|
||||
|
||||
note(
|
||||
[
|
||||
`- File exists at ${legacyConfigPath}`,
|
||||
gatewayMode ? `- gateway.mode: ${gatewayMode}` : undefined,
|
||||
gatewayBind ? `- gateway.bind: ${gatewayBind}` : undefined,
|
||||
agentWorkspace ? `- ${workspaceLabel}: ${agentWorkspace}` : undefined,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("\n"),
|
||||
"Legacy Clawdis config detected",
|
||||
);
|
||||
|
||||
let nextConfig = legacySnapshot.valid ? legacySnapshot.config : null;
|
||||
const { config: migratedConfig, changes } = migrateLegacyConfig(legacySnapshot.parsed);
|
||||
if (migratedConfig) {
|
||||
nextConfig = migratedConfig;
|
||||
} else if (!nextConfig) {
|
||||
note(`Legacy config at ${legacyConfigPath} is invalid; skipping migration.`, "Legacy config");
|
||||
return;
|
||||
}
|
||||
|
||||
const normalized = normalizeLegacyConfigValues(nextConfig);
|
||||
const mergedChanges = [...changes, ...normalized.changes];
|
||||
if (mergedChanges.length > 0) {
|
||||
note(mergedChanges.join("\n"), "Doctor changes");
|
||||
}
|
||||
|
||||
await writeConfigFile(normalized.config);
|
||||
runtime.log(`Migrated legacy config to ${CONFIG_PATH_CLAWDBOT}`);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import type { ClawdbotConfig } from "../config/config.js";
|
||||
import { runCommandWithTimeout, runExec } from "../process/exec.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { note } from "../terminal/note.js";
|
||||
import { replaceModernName } from "./doctor-legacy-config.js";
|
||||
import type { DoctorPrompter } from "./doctor-prompter.js";
|
||||
|
||||
type SandboxScriptInfo = {
|
||||
@@ -165,18 +164,6 @@ async function handleMissingSandboxImage(
|
||||
|
||||
if (built) return;
|
||||
|
||||
const legacyImage = replaceModernName(params.image);
|
||||
if (!legacyImage || legacyImage === params.image) return;
|
||||
const legacyExists = await dockerImageExists(legacyImage);
|
||||
if (!legacyExists) return;
|
||||
|
||||
const fallback = await prompter.confirmSkipInNonInteractive({
|
||||
message: `Switch config to legacy image ${legacyImage}?`,
|
||||
initialValue: false,
|
||||
});
|
||||
if (!fallback) return;
|
||||
|
||||
params.updateConfig(legacyImage);
|
||||
}
|
||||
|
||||
export async function maybeRepairSandboxImages(
|
||||
|
||||
@@ -9,7 +9,7 @@ export function noteWorkspaceStatus(cfg: ClawdbotConfig) {
|
||||
const workspaceDir = resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg));
|
||||
const legacyWorkspace = detectLegacyWorkspaceDirs({ workspaceDir });
|
||||
if (legacyWorkspace.legacyDirs.length > 0) {
|
||||
note(formatLegacyWorkspaceWarning(legacyWorkspace), "Legacy workspace");
|
||||
note(formatLegacyWorkspaceWarning(legacyWorkspace), "Extra workspace");
|
||||
}
|
||||
|
||||
const skillsReport = buildWorkspaceSkillStatus(workspaceDir, { config: cfg });
|
||||
|
||||
@@ -20,10 +20,10 @@ describe("detectLegacyWorkspaceDirs", () => {
|
||||
expect(detection.legacyDirs).toEqual([]);
|
||||
});
|
||||
|
||||
it("flags ~/clawdis when it contains workspace markers", () => {
|
||||
it("flags ~/clawdbot when it contains workspace markers", () => {
|
||||
const home = "/home/user";
|
||||
const workspaceDir = "/home/user/clawd";
|
||||
const candidate = path.join(home, "clawdis");
|
||||
const candidate = path.join(home, "clawdbot");
|
||||
const agentsPath = path.join(candidate, "AGENTS.md");
|
||||
|
||||
const detection = detectLegacyWorkspaceDirs({
|
||||
|
||||
@@ -65,7 +65,7 @@ export function detectLegacyWorkspaceDirs(params: {
|
||||
const exists = params.exists ?? fs.existsSync;
|
||||
const home = homedir();
|
||||
const activeWorkspace = path.resolve(params.workspaceDir);
|
||||
const candidates = [path.join(home, "clawdis"), path.join(home, "clawdbot")];
|
||||
const candidates = [path.join(home, "clawdbot")];
|
||||
const legacyDirs = candidates
|
||||
.filter((candidate) => {
|
||||
if (!exists(candidate)) return false;
|
||||
@@ -79,9 +79,9 @@ export function detectLegacyWorkspaceDirs(params: {
|
||||
|
||||
export function formatLegacyWorkspaceWarning(detection: LegacyWorkspaceDetection): string {
|
||||
return [
|
||||
"Legacy workspace directories detected (may contain old agent files):",
|
||||
"Extra workspace directories detected (may contain old agent files):",
|
||||
...detection.legacyDirs.map((dir) => `- ${dir}`),
|
||||
`Active workspace: ${detection.activeWorkspace}`,
|
||||
"If unused, archive or move to Trash (e.g. trash ~/clawdis).",
|
||||
"If unused, archive or move to Trash (e.g. trash ~/clawdbot).",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ beforeEach(() => {
|
||||
durationMs: 0,
|
||||
});
|
||||
legacyReadConfigFileSnapshot.mockReset().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
@@ -133,7 +133,7 @@ const runCommandWithTimeout = vi.fn().mockResolvedValue({
|
||||
const ensureAuthProfileStore = vi.fn().mockReturnValue({ version: 1, profiles: {} });
|
||||
|
||||
const legacyReadConfigFileSnapshot = vi.fn().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
@@ -317,86 +317,6 @@ vi.mock("./doctor-state-migrations.js", () => ({
|
||||
}));
|
||||
|
||||
describe("doctor command", () => {
|
||||
it("falls back to legacy sandbox image when missing", async () => {
|
||||
readConfigFileSnapshot.mockResolvedValue({
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: true,
|
||||
raw: "{}",
|
||||
parsed: {
|
||||
agents: {
|
||||
defaults: {
|
||||
sandbox: {
|
||||
mode: "non-main",
|
||||
docker: {
|
||||
image: "clawdbot-sandbox-common:bookworm-slim",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
valid: true,
|
||||
config: {
|
||||
agents: {
|
||||
defaults: {
|
||||
sandbox: {
|
||||
mode: "non-main",
|
||||
docker: {
|
||||
image: "clawdbot-sandbox-common:bookworm-slim",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
issues: [],
|
||||
legacyIssues: [],
|
||||
});
|
||||
|
||||
runExec.mockImplementation((command: string, args: string[]) => {
|
||||
if (command !== "docker") {
|
||||
return Promise.resolve({ stdout: "", stderr: "" });
|
||||
}
|
||||
if (args[0] === "version") {
|
||||
return Promise.resolve({ stdout: "1", stderr: "" });
|
||||
}
|
||||
if (args[0] === "image" && args[1] === "inspect") {
|
||||
const image = args[2];
|
||||
if (image === "clawdbot-sandbox-common:bookworm-slim") {
|
||||
return Promise.reject(new Error("missing"));
|
||||
}
|
||||
if (image === "clawdis-sandbox-common:bookworm-slim") {
|
||||
return Promise.resolve({ stdout: "ok", stderr: "" });
|
||||
}
|
||||
}
|
||||
return Promise.resolve({ stdout: "", stderr: "" });
|
||||
});
|
||||
|
||||
confirm
|
||||
.mockResolvedValueOnce(false) // skip gateway token prompt
|
||||
.mockResolvedValueOnce(false) // skip build
|
||||
.mockResolvedValueOnce(true); // accept legacy fallback
|
||||
|
||||
const { doctorCommand } = await import("./doctor.js");
|
||||
const runtime = {
|
||||
log: vi.fn(),
|
||||
error: vi.fn(),
|
||||
exit: vi.fn(),
|
||||
};
|
||||
|
||||
await doctorCommand(runtime);
|
||||
|
||||
const written = writeConfigFile.mock.calls.at(-1)?.[0] as Record<string, unknown>;
|
||||
const agents = written.agents as Record<string, unknown>;
|
||||
const defaults = agents.defaults as Record<string, unknown>;
|
||||
const sandbox = defaults.sandbox as Record<string, unknown>;
|
||||
const docker = sandbox.docker as Record<string, unknown>;
|
||||
|
||||
expect(docker.image).toBe("clawdis-sandbox-common:bookworm-slim");
|
||||
const defaultsCalls = runCommandWithTimeout.mock.calls.filter(
|
||||
([args]) => Array.isArray(args) && args[0] === "/usr/bin/defaults",
|
||||
);
|
||||
expect(defaultsCalls.length).toBe(runCommandWithTimeout.mock.calls.length);
|
||||
}, 20_000);
|
||||
|
||||
it("runs legacy state migrations in non-interactive mode without prompting", async () => {
|
||||
readConfigFileSnapshot.mockResolvedValue({
|
||||
path: "/tmp/clawdbot.json",
|
||||
|
||||
@@ -34,7 +34,7 @@ beforeEach(() => {
|
||||
durationMs: 0,
|
||||
});
|
||||
legacyReadConfigFileSnapshot.mockReset().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
@@ -133,7 +133,7 @@ const runCommandWithTimeout = vi.fn().mockResolvedValue({
|
||||
const ensureAuthProfileStore = vi.fn().mockReturnValue({ version: 1, profiles: {} });
|
||||
|
||||
const legacyReadConfigFileSnapshot = vi.fn().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
@@ -361,7 +361,7 @@ describe("doctor command", () => {
|
||||
expect(written.routing).toBeUndefined();
|
||||
});
|
||||
|
||||
it("migrates legacy Clawdis services", async () => {
|
||||
it("migrates legacy gateway services", async () => {
|
||||
readConfigFileSnapshot.mockResolvedValue({
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: true,
|
||||
@@ -376,7 +376,7 @@ describe("doctor command", () => {
|
||||
findLegacyGatewayServices.mockResolvedValueOnce([
|
||||
{
|
||||
platform: "darwin",
|
||||
label: "com.clawdis.gateway",
|
||||
label: "com.steipete.clawdbot.gateway",
|
||||
detail: "loaded",
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -34,7 +34,7 @@ beforeEach(() => {
|
||||
durationMs: 0,
|
||||
});
|
||||
legacyReadConfigFileSnapshot.mockReset().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
@@ -133,7 +133,7 @@ const runCommandWithTimeout = vi.fn().mockResolvedValue({
|
||||
const ensureAuthProfileStore = vi.fn().mockReturnValue({ version: 1, profiles: {} });
|
||||
|
||||
const legacyReadConfigFileSnapshot = vi.fn().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
|
||||
@@ -26,7 +26,6 @@ import {
|
||||
maybeScanExtraGatewayServices,
|
||||
} from "./doctor-gateway-services.js";
|
||||
import { noteSourceInstallIssues } from "./doctor-install.js";
|
||||
import { maybeMigrateLegacyConfigFile } from "./doctor-legacy-config.js";
|
||||
import { noteMacLaunchAgentOverrides } from "./doctor-platform-notes.js";
|
||||
import { createDoctorPrompter, type DoctorOptions } from "./doctor-prompter.js";
|
||||
import { maybeRepairSandboxImages, noteSandboxScopeWarnings } from "./doctor-sandbox.js";
|
||||
@@ -76,8 +75,6 @@ export async function doctorCommand(
|
||||
await maybeRepairUiProtocolFreshness(runtime, prompter);
|
||||
noteSourceInstallIssues(root);
|
||||
|
||||
await maybeMigrateLegacyConfigFile(runtime);
|
||||
|
||||
const configResult = await loadAndMaybeMigrateDoctorConfig({
|
||||
options,
|
||||
confirm: (p) => prompter.confirm(p),
|
||||
|
||||
@@ -34,7 +34,7 @@ beforeEach(() => {
|
||||
durationMs: 0,
|
||||
});
|
||||
legacyReadConfigFileSnapshot.mockReset().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
@@ -133,7 +133,7 @@ const runCommandWithTimeout = vi.fn().mockResolvedValue({
|
||||
const ensureAuthProfileStore = vi.fn().mockReturnValue({ version: 1, profiles: {} });
|
||||
|
||||
const legacyReadConfigFileSnapshot = vi.fn().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
@@ -374,7 +374,7 @@ describe("doctor command", () => {
|
||||
).toBe(true);
|
||||
}, 10_000);
|
||||
|
||||
it("warns when legacy workspace directories exist", async () => {
|
||||
it("warns when extra workspace directories exist", async () => {
|
||||
readConfigFileSnapshot.mockResolvedValue({
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: true,
|
||||
@@ -391,10 +391,14 @@ describe("doctor command", () => {
|
||||
note.mockClear();
|
||||
const homedirSpy = vi.spyOn(os, "homedir").mockReturnValue("/Users/steipete");
|
||||
const realExists = fs.existsSync;
|
||||
const legacyPath = path.join("/Users/steipete", "clawdis");
|
||||
const legacyPath = path.join("/Users/steipete", "clawdbot");
|
||||
const legacyAgentsPath = path.join(legacyPath, "AGENTS.md");
|
||||
const existsSpy = vi.spyOn(fs, "existsSync").mockImplementation((value) => {
|
||||
if (value === "/Users/steipete/clawdis" || value === legacyPath || value === legacyAgentsPath)
|
||||
if (
|
||||
value === "/Users/steipete/clawdbot" ||
|
||||
value === legacyPath ||
|
||||
value === legacyAgentsPath
|
||||
)
|
||||
return true;
|
||||
return realExists(value as never);
|
||||
});
|
||||
@@ -411,9 +415,9 @@ describe("doctor command", () => {
|
||||
expect(
|
||||
note.mock.calls.some(
|
||||
([message, title]) =>
|
||||
title === "Legacy workspace" &&
|
||||
title === "Extra workspace" &&
|
||||
typeof message === "string" &&
|
||||
message.includes("clawdis"),
|
||||
message.includes("clawdbot"),
|
||||
),
|
||||
).toBe(true);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ beforeEach(() => {
|
||||
durationMs: 0,
|
||||
});
|
||||
legacyReadConfigFileSnapshot.mockReset().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
@@ -133,7 +133,7 @@ const runCommandWithTimeout = vi.fn().mockResolvedValue({
|
||||
const ensureAuthProfileStore = vi.fn().mockReturnValue({ version: 1, profiles: {} });
|
||||
|
||||
const legacyReadConfigFileSnapshot = vi.fn().mockResolvedValue({
|
||||
path: "/tmp/clawdis.json",
|
||||
path: "/tmp/clawdbot.json",
|
||||
exists: false,
|
||||
raw: null,
|
||||
parsed: {},
|
||||
|
||||
@@ -24,7 +24,7 @@ export function resolveStateDir(
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
homedir: () => string = os.homedir,
|
||||
): string {
|
||||
const override = env.CLAWDBOT_STATE_DIR?.trim() || env.CLAWDIS_STATE_DIR?.trim();
|
||||
const override = env.CLAWDBOT_STATE_DIR?.trim();
|
||||
if (override) return resolveUserPath(override);
|
||||
return path.join(homedir(), ".clawdbot");
|
||||
}
|
||||
@@ -41,9 +41,6 @@ function resolveUserPath(input: string): string {
|
||||
|
||||
export const STATE_DIR_CLAWDBOT = resolveStateDir();
|
||||
|
||||
// Legacy exports for backward compatibility during Clawdis → Clawdbot rebrand
|
||||
export const STATE_DIR_CLAWDIS = STATE_DIR_CLAWDBOT;
|
||||
|
||||
/**
|
||||
* Config file path (JSON5).
|
||||
* Can be overridden via CLAWDBOT_CONFIG_PATH environment variable.
|
||||
@@ -60,9 +57,6 @@ export function resolveConfigPath(
|
||||
|
||||
export const CONFIG_PATH_CLAWDBOT = resolveConfigPath();
|
||||
|
||||
// Legacy exports for backward compatibility during Clawdis → Clawdbot rebrand
|
||||
export const CONFIG_PATH_CLAWDIS = CONFIG_PATH_CLAWDBOT;
|
||||
|
||||
export const DEFAULT_GATEWAY_PORT = 18789;
|
||||
|
||||
const OAUTH_FILENAME = "oauth.json";
|
||||
|
||||
@@ -175,14 +175,6 @@ describe("sessions", () => {
|
||||
expect(dir).toBe(path.join(path.resolve("/custom/state"), "agents", "main", "sessions"));
|
||||
});
|
||||
|
||||
it("falls back to CLAWDIS_STATE_DIR for session transcripts dir", () => {
|
||||
const dir = resolveSessionTranscriptsDir(
|
||||
{ CLAWDIS_STATE_DIR: "/legacy/state" } as NodeJS.ProcessEnv,
|
||||
() => "/home/ignored",
|
||||
);
|
||||
expect(dir).toBe(path.join(path.resolve("/legacy/state"), "agents", "main", "sessions"));
|
||||
});
|
||||
|
||||
it("includes topic ids in session transcript filenames", () => {
|
||||
const prev = process.env.CLAWDBOT_STATE_DIR;
|
||||
process.env.CLAWDBOT_STATE_DIR = "/custom/state";
|
||||
|
||||
@@ -6,11 +6,9 @@ export const GATEWAY_SERVICE_MARKER = "clawdbot";
|
||||
export const GATEWAY_SERVICE_KIND = "gateway";
|
||||
export const LEGACY_GATEWAY_LAUNCH_AGENT_LABELS = [
|
||||
"com.steipete.clawdbot.gateway",
|
||||
"com.steipete.clawdis.gateway",
|
||||
"com.clawdis.gateway",
|
||||
];
|
||||
export const LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES = ["clawdis-gateway"];
|
||||
export const LEGACY_GATEWAY_WINDOWS_TASK_NAMES = ["Clawdis Gateway"];
|
||||
export const LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES: string[] = [];
|
||||
export const LEGACY_GATEWAY_WINDOWS_TASK_NAMES: string[] = [];
|
||||
|
||||
export function resolveGatewayLaunchAgentLabel(profile?: string): string {
|
||||
const trimmed = profile?.trim();
|
||||
|
||||
@@ -25,7 +25,7 @@ export type FindExtraGatewayServicesOptions = {
|
||||
deep?: boolean;
|
||||
};
|
||||
|
||||
const EXTRA_MARKERS = ["clawdbot", "clawdis"];
|
||||
const EXTRA_MARKERS = ["clawdbot"];
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
export function renderGatewayServiceCleanupHints(
|
||||
|
||||
@@ -57,7 +57,7 @@ export function resolveGatewayLogPaths(env: Record<string, string | undefined>):
|
||||
stderrPath: string;
|
||||
} {
|
||||
const home = resolveHomeDir(env);
|
||||
const stateOverride = env.CLAWDBOT_STATE_DIR?.trim() || env.CLAWDIS_STATE_DIR?.trim();
|
||||
const stateOverride = env.CLAWDBOT_STATE_DIR?.trim();
|
||||
const profile = env.CLAWDBOT_PROFILE?.trim();
|
||||
const suffix = profile && profile.toLowerCase() !== "default" ? `-${profile}` : "";
|
||||
const defaultStateDir = path.join(home, `.clawdbot${suffix}`);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { findLegacyLaunchAgents, uninstallLegacyLaunchAgents } from "./launchd.js";
|
||||
import { findLegacyScheduledTasks, uninstallLegacyScheduledTasks } from "./schtasks.js";
|
||||
import { findLegacySystemdUnits, uninstallLegacySystemdUnits } from "./systemd.js";
|
||||
|
||||
export type LegacyGatewayService = {
|
||||
@@ -34,19 +33,6 @@ function formatLegacySystemdUnits(
|
||||
}));
|
||||
}
|
||||
|
||||
function formatLegacyScheduledTasks(
|
||||
tasks: Awaited<ReturnType<typeof findLegacyScheduledTasks>>,
|
||||
): LegacyGatewayService[] {
|
||||
return tasks.map((task) => ({
|
||||
platform: "win32",
|
||||
label: task.name,
|
||||
detail: [
|
||||
task.installed ? "installed" : "not installed",
|
||||
task.scriptExists ? `script: ${task.scriptPath}` : "script missing",
|
||||
].join(", "),
|
||||
}));
|
||||
}
|
||||
|
||||
export async function findLegacyGatewayServices(
|
||||
env: Record<string, string | undefined>,
|
||||
): Promise<LegacyGatewayService[]> {
|
||||
@@ -60,11 +46,6 @@ export async function findLegacyGatewayServices(
|
||||
return formatLegacySystemdUnits(units);
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
const tasks = await findLegacyScheduledTasks(env);
|
||||
return formatLegacyScheduledTasks(tasks);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -85,10 +66,5 @@ export async function uninstallLegacyGatewayServices({
|
||||
return formatLegacySystemdUnits(units);
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
const tasks = await uninstallLegacyScheduledTasks({ env, stdout });
|
||||
return formatLegacyScheduledTasks(tasks);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -4,11 +4,7 @@ import path from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
import { colorize, isRich, theme } from "../terminal/theme.js";
|
||||
import {
|
||||
formatGatewayServiceDescription,
|
||||
LEGACY_GATEWAY_WINDOWS_TASK_NAMES,
|
||||
resolveGatewayWindowsTaskName,
|
||||
} from "./constants.js";
|
||||
import { formatGatewayServiceDescription, resolveGatewayWindowsTaskName } from "./constants.js";
|
||||
import { parseKeyValueOutput } from "./runtime-parse.js";
|
||||
import type { GatewayServiceRuntime } from "./service-runtime.js";
|
||||
|
||||
@@ -32,10 +28,6 @@ function resolveTaskScriptPath(env: Record<string, string | undefined>): string
|
||||
return path.join(home, `.clawdbot${suffix}`, "gateway.cmd");
|
||||
}
|
||||
|
||||
function resolveLegacyTaskScriptPath(env: Record<string, string | undefined>): string {
|
||||
const home = resolveHomeDir(env);
|
||||
return path.join(home, ".clawdis", "gateway.cmd");
|
||||
}
|
||||
|
||||
function quoteCmdArg(value: string): string {
|
||||
if (!/[ \t"]/g.test(value)) return value;
|
||||
@@ -351,77 +343,3 @@ export async function readScheduledTaskRuntime(
|
||||
lastRunResult: parsed.lastRunResult,
|
||||
};
|
||||
}
|
||||
export type LegacyScheduledTask = {
|
||||
name: string;
|
||||
scriptPath: string;
|
||||
installed: boolean;
|
||||
scriptExists: boolean;
|
||||
};
|
||||
|
||||
export async function findLegacyScheduledTasks(
|
||||
env: Record<string, string | undefined>,
|
||||
): Promise<LegacyScheduledTask[]> {
|
||||
const results: LegacyScheduledTask[] = [];
|
||||
let schtasksAvailable = true;
|
||||
try {
|
||||
await assertSchtasksAvailable();
|
||||
} catch {
|
||||
schtasksAvailable = false;
|
||||
}
|
||||
|
||||
for (const name of LEGACY_GATEWAY_WINDOWS_TASK_NAMES) {
|
||||
const scriptPath = resolveLegacyTaskScriptPath(env);
|
||||
let installed = false;
|
||||
if (schtasksAvailable) {
|
||||
const res = await execSchtasks(["/Query", "/TN", name]);
|
||||
installed = res.code === 0;
|
||||
}
|
||||
let scriptExists = false;
|
||||
try {
|
||||
await fs.access(scriptPath);
|
||||
scriptExists = true;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
if (installed || scriptExists) {
|
||||
results.push({ name, scriptPath, installed, scriptExists });
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
export async function uninstallLegacyScheduledTasks({
|
||||
env,
|
||||
stdout,
|
||||
}: {
|
||||
env: Record<string, string | undefined>;
|
||||
stdout: NodeJS.WritableStream;
|
||||
}): Promise<LegacyScheduledTask[]> {
|
||||
const tasks = await findLegacyScheduledTasks(env);
|
||||
if (tasks.length === 0) return tasks;
|
||||
|
||||
let schtasksAvailable = true;
|
||||
try {
|
||||
await assertSchtasksAvailable();
|
||||
} catch {
|
||||
schtasksAvailable = false;
|
||||
}
|
||||
|
||||
for (const task of tasks) {
|
||||
if (schtasksAvailable && task.installed) {
|
||||
await execSchtasks(["/Delete", "/F", "/TN", task.name]);
|
||||
} else if (!schtasksAvailable && task.installed) {
|
||||
stdout.write(`schtasks unavailable; unable to remove legacy task: ${task.name}\n`);
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.unlink(task.scriptPath);
|
||||
stdout.write(`${formatLine("Removed legacy task script", task.scriptPath)}\n`);
|
||||
} catch {
|
||||
stdout.write(`Legacy task script not found at ${task.scriptPath}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { PortListener, PortListenerKind, PortUsage } from "./ports-types.js
|
||||
|
||||
export function classifyPortListener(listener: PortListener, port: number): PortListenerKind {
|
||||
const raw = `${listener.commandLine ?? ""} ${listener.command ?? ""}`.trim().toLowerCase();
|
||||
if (raw.includes("clawdbot") || raw.includes("clawdis")) return "gateway";
|
||||
if (raw.includes("clawdbot")) return "gateway";
|
||||
if (raw.includes("ssh")) {
|
||||
const portToken = String(port);
|
||||
const tunnelPattern = new RegExp(
|
||||
|
||||
Reference in New Issue
Block a user