diff --git a/src/plugins/conversation-binding.ts b/src/plugins/conversation-binding.ts index 6a680622526..0da3bada691 100644 --- a/src/plugins/conversation-binding.ts +++ b/src/plugins/conversation-binding.ts @@ -35,7 +35,7 @@ import { getActivePluginRegistry } from "./runtime.js"; const log = createSubsystemLogger("plugins/binding"); -const APPROVALS_PATH = "~/.openclaw/plugin-binding-approvals.json"; +const LEGACY_APPROVALS_PATH = "~/.openclaw/plugin-binding-approvals.json"; const APPROVALS_KV_SCOPE = "plugin_binding_approvals"; const APPROVALS_KV_KEY = "current"; const PLUGIN_BINDING_CUSTOM_ID_PREFIX = "pluginbind"; @@ -163,16 +163,16 @@ function getPluginBindingGlobalState(): PluginBindingGlobalState { return pluginBindingGlobalState; } -function resolveApprovalsPath(): string { +function resolveLegacyApprovalsPath(): string { if (process.env.OPENCLAW_STATE_DIR?.trim()) { return path.join(resolveStateDir(process.env), "plugin-binding-approvals.json"); } - return expandHomePrefix(APPROVALS_PATH); + return expandHomePrefix(LEGACY_APPROVALS_PATH); } function pluginBindingApprovalDbOptions(): OpenClawStateDatabaseOptions { return { - env: { ...process.env, OPENCLAW_STATE_DIR: path.dirname(resolveApprovalsPath()) }, + env: { ...process.env, OPENCLAW_STATE_DIR: path.dirname(resolveLegacyApprovalsPath()) }, }; } @@ -451,7 +451,7 @@ async function addPersistentApproval(entry: PluginBindingApprovalEntry): Promise export function legacyPluginBindingApprovalFileExists(): boolean { try { - return fs.statSync(resolveApprovalsPath()).isFile(); + return fs.statSync(resolveLegacyApprovalsPath()).isFile(); } catch (error) { if ((error as NodeJS.ErrnoException)?.code === "ENOENT") { return false; @@ -464,7 +464,7 @@ export function importLegacyPluginBindingApprovalFileToSqlite(): { imported: boolean; approvals: number; } { - const filePath = resolveApprovalsPath(); + const filePath = resolveLegacyApprovalsPath(); if (!legacyPluginBindingApprovalFileExists()) { return { imported: false, approvals: 0 }; } diff --git a/src/tui/tui-last-session.test.ts b/src/tui/tui-last-session.test.ts index 54fd7044923..826b800c770 100644 --- a/src/tui/tui-last-session.test.ts +++ b/src/tui/tui-last-session.test.ts @@ -10,7 +10,7 @@ import { isHeartbeatLikeTuiSession, readTuiLastSessionKey, resolveRememberedTuiSessionKey, - resolveTuiLastSessionStatePath, + resolveLegacyTuiLastSessionStatePath, writeTuiLastSessionKey, } from "./tui-last-session.js"; @@ -43,7 +43,7 @@ describe("tui last session state", () => { }); await expect(readTuiLastSessionKey({ scopeKey, stateDir })).resolves.toBe("agent:main:tui-123"); - await expect(fs.access(resolveTuiLastSessionStatePath(stateDir))).rejects.toMatchObject({ + await expect(fs.access(resolveLegacyTuiLastSessionStatePath(stateDir))).rejects.toMatchObject({ code: "ENOENT", }); }); @@ -61,7 +61,7 @@ describe("tui last session state", () => { sessionKey: "agent:main:tui-sqlite", stateDir, }); - await expect(fs.access(resolveTuiLastSessionStatePath(stateDir))).rejects.toMatchObject({ + await expect(fs.access(resolveLegacyTuiLastSessionStatePath(stateDir))).rejects.toMatchObject({ code: "ENOENT", }); @@ -77,7 +77,7 @@ describe("tui last session state", () => { agentId: "main", sessionScope: "per-sender", }); - const statePath = resolveTuiLastSessionStatePath(stateDir); + const statePath = resolveLegacyTuiLastSessionStatePath(stateDir); await fs.mkdir(path.dirname(statePath), { recursive: true }); await fs.writeFile( statePath, @@ -97,7 +97,7 @@ describe("tui last session state", () => { it("removes empty legacy JSON through the doctor migration helper", async () => { const stateDir = await makeTempStateDir(); - const statePath = resolveTuiLastSessionStatePath(stateDir); + const statePath = resolveLegacyTuiLastSessionStatePath(stateDir); await fs.mkdir(path.dirname(statePath), { recursive: true }); await fs.writeFile(statePath, "{}\n", "utf8"); @@ -135,7 +135,7 @@ describe("tui last session state", () => { agentId: "main", sessionScope: "per-sender", }); - const statePath = resolveTuiLastSessionStatePath(stateDir); + const statePath = resolveLegacyTuiLastSessionStatePath(stateDir); await fs.mkdir(path.dirname(statePath), { recursive: true }); await fs.writeFile( statePath, diff --git a/src/tui/tui-last-session.ts b/src/tui/tui-last-session.ts index 4547cf78a30..a995b1e743e 100644 --- a/src/tui/tui-last-session.ts +++ b/src/tui/tui-last-session.ts @@ -22,7 +22,7 @@ type LastSessionRecord = { type LastSessionStore = Record; const TUI_LAST_SESSION_KV_SCOPE = "tui:last-session"; -export function resolveTuiLastSessionStatePath(stateDir = resolveStateDir()): string { +export function resolveLegacyTuiLastSessionStatePath(stateDir = resolveStateDir()): string { return path.join(stateDir, "tui", "last-session.json"); } @@ -89,7 +89,7 @@ function writeTuiLastSessionKv(params: { async function readLegacyTuiLastSessionStore(params: { stateDir?: string; }): Promise { - const filePath = resolveTuiLastSessionStatePath(params.stateDir); + const filePath = resolveLegacyTuiLastSessionStatePath(params.stateDir); return await readStore(filePath); } @@ -99,7 +99,7 @@ export async function legacyTuiLastSessionFileExists( } = {}, ): Promise { try { - await fs.access(resolveTuiLastSessionStatePath(params.stateDir)); + await fs.access(resolveLegacyTuiLastSessionStatePath(params.stateDir)); return true; } catch { return false; @@ -111,7 +111,7 @@ export async function importLegacyTuiLastSessionStoreToSqlite( stateDir?: string; } = {}, ): Promise<{ imported: boolean; pointers: number }> { - const filePath = resolveTuiLastSessionStatePath(params.stateDir); + const filePath = resolveLegacyTuiLastSessionStatePath(params.stateDir); const exists = await legacyTuiLastSessionFileExists(params); if (!exists) { return { imported: false, pointers: 0 };