mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
refactor: rename agent runtime state cleanup
This commit is contained in:
@@ -3,7 +3,7 @@ import { createNonExitingRuntime, type RuntimeEnv } from "../runtime.js";
|
||||
|
||||
const resolveCleanupPlanFromDisk = vi.fn();
|
||||
const removePath = vi.fn();
|
||||
const listAgentSessionStatePaths = vi.fn();
|
||||
const listAgentRuntimeStatePaths = vi.fn();
|
||||
const removeStateAndLinkedPaths = vi.fn();
|
||||
const removeWorkspaceDirs = vi.fn();
|
||||
|
||||
@@ -17,7 +17,7 @@ vi.mock("./cleanup-plan.js", () => ({
|
||||
|
||||
vi.mock("./cleanup-utils.js", () => ({
|
||||
removePath,
|
||||
listAgentSessionStatePaths,
|
||||
listAgentRuntimeStatePaths,
|
||||
removeStateAndLinkedPaths,
|
||||
removeWorkspaceDirs,
|
||||
}));
|
||||
@@ -37,7 +37,7 @@ export function resetCleanupCommandMocks() {
|
||||
workspaceDirs: ["/tmp/.openclaw/workspace"],
|
||||
});
|
||||
removePath.mockResolvedValue({ ok: true });
|
||||
listAgentSessionStatePaths.mockResolvedValue([
|
||||
listAgentRuntimeStatePaths.mockResolvedValue([
|
||||
"/tmp/.openclaw/agents/main/sessions",
|
||||
"/tmp/.openclaw/agents/main/agent/openclaw-agent.sqlite",
|
||||
]);
|
||||
|
||||
@@ -140,7 +140,7 @@ export async function removeWorkspaceDirs(
|
||||
}
|
||||
}
|
||||
|
||||
export async function listAgentSessionStatePaths(stateDir: string): Promise<string[]> {
|
||||
export async function listAgentRuntimeStatePaths(stateDir: string): Promise<string[]> {
|
||||
const root = path.join(stateDir, "agents");
|
||||
try {
|
||||
const entries = await fs.readdir(root, { withFileTypes: true });
|
||||
|
||||
@@ -22,7 +22,7 @@ import { normalizeOptionalString } from "../shared/string-coerce.js";
|
||||
import { stylePromptTitle } from "../terminal/prompt-style.js";
|
||||
import { resolveConfigDir, shortenHomeInString, shortenHomePath, sleep } from "../utils.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import { listAgentSessionStatePaths } from "./cleanup-utils.js";
|
||||
import { listAgentRuntimeStatePaths } from "./cleanup-utils.js";
|
||||
import type { NodeManagerChoice, OnboardMode, ResetScope } from "./onboard-types.js";
|
||||
export { randomToken } from "./random-token.js";
|
||||
|
||||
@@ -212,7 +212,7 @@ export async function handleReset(scope: ResetScope, workspaceDir: string, runti
|
||||
return;
|
||||
}
|
||||
await moveToTrash(path.join(resolveConfigDir(), "credentials"), runtime);
|
||||
for (const target of await listAgentSessionStatePaths(resolveStateDir())) {
|
||||
for (const target of await listAgentRuntimeStatePaths(resolveStateDir())) {
|
||||
await moveToTrash(target, runtime);
|
||||
}
|
||||
if (scope === "full") {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { selectStyled } from "../terminal/prompt-select-styled.js";
|
||||
import { stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js";
|
||||
import { resolveCleanupPlanFromDisk } from "./cleanup-plan.js";
|
||||
import {
|
||||
listAgentSessionStatePaths,
|
||||
listAgentRuntimeStatePaths,
|
||||
removePath,
|
||||
removeStateAndLinkedPaths,
|
||||
removeWorkspaceDirs,
|
||||
@@ -130,8 +130,8 @@ export async function resetCommand(runtime: RuntimeEnv, opts: ResetOptions) {
|
||||
if (scope === "config+creds+sessions") {
|
||||
await removePath(configPath, runtime, { dryRun, label: configPath });
|
||||
await removePath(oauthDir, runtime, { dryRun, label: oauthDir });
|
||||
const sessionPaths = await listAgentSessionStatePaths(stateDir);
|
||||
for (const target of sessionPaths) {
|
||||
const runtimeStatePaths = await listAgentRuntimeStatePaths(stateDir);
|
||||
for (const target of runtimeStatePaths) {
|
||||
await removePath(target, runtime, { dryRun, label: target });
|
||||
}
|
||||
runtime.log(`Next: ${formatCliCommand("openclaw onboard --install-daemon")}`);
|
||||
|
||||
Reference in New Issue
Block a user