import fs from "node:fs"; import path from "node:path"; import { describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import { withTempDir } from "../test-helpers/temp-dir.js"; import { migrateOrphanedSessionKeys } from "./state-migrations.js";
expect(result2.changes).toHaveLength(0); const store = readStore(storePath);
expect((store["agent:ops:work"] as { sessionId: string }).sessionId).toBe("abc-123");
});
});
it("preserves legitimate agent:main:* keys in shared stores with both main and non-main agents", async () => {
await withStateFixture(async ({ tmpDir, stateDir }) => { // When session.store lacks {agentId}, all agents resolve to the same file. // The "main" agent's keys must not be remapped into the "ops" namespace. const sharedStorePath = path.join(tmpDir, "shared-sessions.json");
writeStore(sharedStorePath, { "agent:main:main": { sessionId: "main-session", updatedAt: 2000 }, "agent:ops:work": { sessionId: "ops-session", updatedAt: 1000 },
});
const store = readStore(sharedStorePath); // main agent's session is canonicalised to use configured mainKey ("work"), // but stays in the "main" agent namespace — NOT remapped into "ops".
expect(store["agent:main:work"]).toBeDefined();
expect((store["agent:main:work"] as { sessionId: string }).sessionId).toBe("main-session");
expect(store["agent:ops:work"]).toBeDefined();
expect((store["agent:ops:work"] as { sessionId: string }).sessionId).toBe("ops-session"); // The key must NOT have been merged into ops namespace
expect(Object.keys(store).filter((k) => k.startsWith("agent:ops:")).length).toBe(1);
});
});
it("lets the main agent claim bare main aliases in shared stores", async () => {
await withStateFixture(async ({ tmpDir, stateDir }) => { const sharedStorePath = path.join(tmpDir, "shared-sessions.json");
writeStore(sharedStorePath, {
main: { sessionId: "main-session", updatedAt: 2000 }, "agent:ops:work": { sessionId: "ops-session", updatedAt: 1000 },
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.