Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]
import { resolveSessionFilePath } from "./paths.js";
import type { ResolvedSessionMaintenanceConfig } from "./store-maintenance.js";
import { updateSessionStore } from "./store.js";
import type { SessionEntry } from "./types.js";
export async function resolveAndPersistSessionFile(params: {
sessionId: string;
sessionKey: string;
sessionStore: Record<string, SessionEntry>;
storePath: string;
sessionEntry?: SessionEntry;
agentId?: string;
sessionsDir?: string;
fallbackSessionFile?: string;
activeSessionKey?: string;
maintenanceConfig?: ResolvedSessionMaintenanceConfig;
}): Promise<{ sessionFile: string; sessionEntry: SessionEntry }> {
const { sessionId, sessionKey, sessionStore, storePath } = params;
const baseEntry = params.sessionEntry ??
sessionStore[sessionKey] ?? { sessionId, updatedAt: Date.now() };
const shouldReusePersistedSessionFile = baseEntry.sessionId === sessionId;
const fallbackSessionFile = params.fallbackSessionFile?.trim();
const entryForResolve = !shouldReusePersistedSessionFile
? fallbackSessionFile
? { ...baseEntry, sessionFile: fallbackSessionFile }
: { ...baseEntry, sessionFile: undefined }
: !baseEntry.sessionFile && fallbackSessionFile
? { ...baseEntry, sessionFile: fallbackSessionFile }
: baseEntry;
const sessionFile = resolveSessionFilePath(sessionId, entryForResolve, {
agentId: params.agentId,
sessionsDir: params.sessionsDir,
});
const persistedEntry: SessionEntry = {
...baseEntry,
sessionId,
updatedAt: Date.now(),
sessionFile,
};
if (baseEntry.sessionId !== sessionId || baseEntry.sessionFile !== sessionFile) {
sessionStore[sessionKey] = persistedEntry;
await updateSessionStore(
storePath,
(store) => {
store[sessionKey] = {
...store[sessionKey],
...persistedEntry,
};
},
params.activeSessionKey || params.maintenanceConfig
? {
...(params.activeSessionKey ? { activeSessionKey: params.activeSessionKey } : {}),
...(params.maintenanceConfig ? { maintenanceConfig: params.maintenanceConfig } : {}),
}
: undefined,
);
return { sessionFile, sessionEntry: persistedEntry };
}
sessionStore[sessionKey] = persistedEntry;
return { sessionFile, sessionEntry: persistedEntry };
}
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-04-27)
¤
*© Formatika GbR, Deutschland