refactor: share gateway session store migration

This commit is contained in:
Peter Steinberger
2026-03-13 17:52:00 +00:00
parent 6464149031
commit 198c2482ee
6 changed files with 46 additions and 85 deletions

View File

@@ -16,11 +16,7 @@ import { defaultRuntime } from "../runtime.js";
import { parseMessageWithAttachments } from "./chat-attachments.js";
import { normalizeRpcAttachmentsToChatAttachments } from "./server-methods/attachment-normalize.js";
import type { NodeEvent, NodeEventContext } from "./server-node-events-types.js";
import {
loadSessionEntry,
pruneLegacyStoreKeys,
resolveGatewaySessionStoreTarget,
} from "./session-utils.js";
import { loadSessionEntry, migrateAndPruneGatewaySessionStoreKey } from "./session-utils.js";
import { formatForLog } from "./ws-log.js";
const MAX_EXEC_EVENT_OUTPUT_CHARS = 180;
@@ -152,17 +148,12 @@ async function touchSessionStore(params: {
return;
}
await updateSessionStore(storePath, (store) => {
const target = resolveGatewaySessionStoreTarget({
const { primaryKey } = migrateAndPruneGatewaySessionStoreKey({
cfg: params.cfg,
key: params.sessionKey,
store,
});
pruneLegacyStoreKeys({
store,
canonicalKey: target.canonicalKey,
candidates: target.storeKeys,
});
store[params.canonicalKey] = {
store[primaryKey] = {
sessionId: params.sessionId,
updatedAt: params.now,
thinkingLevel: params.entry?.thinkingLevel,