mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:20:43 +00:00
fix: tighten session entry slot cleanup checks
This commit is contained in:
@@ -162,8 +162,11 @@ describe("plugin session extension SessionEntry projection", () => {
|
||||
}),
|
||||
).resolves.toMatchObject({ ok: true });
|
||||
expect(
|
||||
(loadSessionStore(storePath, { skipCache: true })["agent:main:main"] as never)
|
||||
.approvalSnapshot,
|
||||
(
|
||||
loadSessionStore(storePath, { skipCache: true })[
|
||||
"agent:main:main"
|
||||
] as unknown as Record<string, unknown>
|
||||
).approvalSnapshot,
|
||||
).toEqual({ state: "ready" });
|
||||
|
||||
await expect(
|
||||
@@ -195,8 +198,11 @@ describe("plugin session extension SessionEntry projection", () => {
|
||||
}),
|
||||
).resolves.toMatchObject({ ok: true });
|
||||
expect(
|
||||
(loadSessionStore(storePath, { skipCache: true })["agent:main:main"] as never)
|
||||
.approvalSnapshot,
|
||||
(
|
||||
loadSessionStore(storePath, { skipCache: true })[
|
||||
"agent:main:main"
|
||||
] as unknown as Record<string, unknown>
|
||||
).approvalSnapshot,
|
||||
).toEqual({ state: "ready-again" });
|
||||
|
||||
await expect(
|
||||
|
||||
@@ -159,7 +159,11 @@ function collectSessionEntrySlotKeys(
|
||||
if (!shouldCleanPlugin(registration.pluginId, pluginId)) {
|
||||
continue;
|
||||
}
|
||||
const normalized = normalizeSessionEntrySlotKey(registration.extension.sessionEntrySlotKey);
|
||||
const slotKey = registration.extension.sessionEntrySlotKey;
|
||||
if (slotKey === undefined) {
|
||||
continue;
|
||||
}
|
||||
const normalized = normalizeSessionEntrySlotKey(slotKey);
|
||||
if (normalized.ok) {
|
||||
slotKeys.add(normalized.key);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,14 @@ const SESSION_ENTRY_RESERVED_SLOT_KEY_LIST = [
|
||||
"acp",
|
||||
] as const satisfies ReadonlyArray<keyof SessionEntry | "__proto__" | "constructor" | "prototype">;
|
||||
|
||||
type ReservedSessionEntrySlotKey = Extract<
|
||||
(typeof SESSION_ENTRY_RESERVED_SLOT_KEY_LIST)[number],
|
||||
keyof SessionEntry
|
||||
>;
|
||||
type MissingSessionEntryReservedSlotKeys = Exclude<keyof SessionEntry, ReservedSessionEntrySlotKey>;
|
||||
type AssertNever<T extends never> = T;
|
||||
type _AssertAllSessionEntryKeysAreReserved = AssertNever<MissingSessionEntryReservedSlotKeys>;
|
||||
|
||||
const SESSION_ENTRY_RESERVED_SLOT_KEYS = new Set<string>(SESSION_ENTRY_RESERVED_SLOT_KEY_LIST);
|
||||
|
||||
const SESSION_ENTRY_SLOT_KEY_RE = /^[A-Za-z][A-Za-z0-9_]*$/u;
|
||||
|
||||
Reference in New Issue
Block a user