mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-22 06:08:13 +00:00
fix: keep sqlite transcript locators virtual
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import path from "node:path";
|
||||
import { isSqliteSessionTranscriptLocator } from "../../config/sessions.js";
|
||||
import {
|
||||
appendSqliteSessionTranscriptEvent,
|
||||
hasSqliteSessionTranscriptEvents,
|
||||
@@ -256,7 +257,10 @@ export async function ensureSessionHeader(params: {
|
||||
agentId?: string;
|
||||
env?: OpenClawStateDatabaseOptions["env"];
|
||||
}) {
|
||||
const transcriptPath = path.resolve(params.sessionFile);
|
||||
const trimmedSessionFile = params.sessionFile.trim();
|
||||
const transcriptPath = isSqliteSessionTranscriptLocator(trimmedSessionFile)
|
||||
? trimmedSessionFile
|
||||
: path.resolve(trimmedSessionFile);
|
||||
const existingScope = resolveSqliteSessionTranscriptScopeForPath({
|
||||
transcriptPath,
|
||||
env: params.env,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import path from "node:path";
|
||||
import {
|
||||
createSqliteSessionTranscriptLocator,
|
||||
isSqliteSessionTranscriptLocator,
|
||||
} from "../../config/sessions.js";
|
||||
import {
|
||||
loadSqliteSessionTranscriptEvents,
|
||||
replaceSqliteSessionTranscriptEvents,
|
||||
@@ -358,6 +362,15 @@ function resolveSuccessorTranscriptPath(params: {
|
||||
sessionId: string;
|
||||
timestamp: string;
|
||||
}): string {
|
||||
if (isSqliteSessionTranscriptLocator(params.transcriptPath)) {
|
||||
const existing = resolveSqliteSessionTranscriptScopeForPath({
|
||||
transcriptPath: params.transcriptPath,
|
||||
});
|
||||
return createSqliteSessionTranscriptLocator({
|
||||
agentId: existing?.agentId,
|
||||
sessionId: params.sessionId,
|
||||
});
|
||||
}
|
||||
const fileTimestamp = params.timestamp.replace(/[:.]/g, "-");
|
||||
return path.join(
|
||||
path.dirname(params.transcriptPath),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import path from "node:path";
|
||||
import { isSqliteSessionTranscriptLocator } from "../../config/sessions.js";
|
||||
import {
|
||||
appendSqliteSessionTranscriptEvent,
|
||||
loadSqliteSessionTranscriptEvents,
|
||||
@@ -82,8 +83,11 @@ function resolveTranscriptWriteScope(
|
||||
sessionFile: string,
|
||||
entries: Array<SessionHeader | SessionEntry>,
|
||||
): { agentId: string; sessionId: string; transcriptPath: string } | undefined {
|
||||
const transcriptPath = isSqliteSessionTranscriptLocator(sessionFile)
|
||||
? sessionFile
|
||||
: path.resolve(sessionFile);
|
||||
const header = entries.find((entry): entry is SessionHeader => entry.type === "session");
|
||||
const existing = resolveSqliteSessionTranscriptScopeForPath({ transcriptPath: sessionFile });
|
||||
const existing = resolveSqliteSessionTranscriptScopeForPath({ transcriptPath });
|
||||
const sessionId = header?.id ?? existing?.sessionId;
|
||||
if (!sessionId) {
|
||||
return undefined;
|
||||
@@ -91,7 +95,7 @@ function resolveTranscriptWriteScope(
|
||||
return {
|
||||
agentId: existing?.agentId ?? resolveAgentIdFromTranscriptPath(sessionFile),
|
||||
sessionId,
|
||||
transcriptPath: path.resolve(sessionFile),
|
||||
transcriptPath,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
resolveMainSessionKey,
|
||||
resolveSessionFilePath,
|
||||
resolveSessionFilePathOptions,
|
||||
isSqliteSessionTranscriptLocator,
|
||||
type SessionEntry,
|
||||
upsertSessionEntry,
|
||||
} from "../../config/sessions.js";
|
||||
@@ -1345,7 +1346,10 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
agentId: target.agentId,
|
||||
sourceFile: checkpoint.preCompaction.sessionFile,
|
||||
sourceSessionId: checkpoint.preCompaction.sessionId,
|
||||
sessionDir: entry.sessionFile ? path.dirname(entry.sessionFile) : undefined,
|
||||
sessionDir:
|
||||
entry.sessionFile && !isSqliteSessionTranscriptLocator(entry.sessionFile)
|
||||
? path.dirname(entry.sessionFile)
|
||||
: undefined,
|
||||
});
|
||||
if (!branchedSession?.sessionFile) {
|
||||
respond(
|
||||
@@ -1463,7 +1467,10 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
agentId: target.agentId,
|
||||
sourceFile: checkpoint.preCompaction.sessionFile,
|
||||
sourceSessionId: checkpoint.preCompaction.sessionId,
|
||||
sessionDir: entry.sessionFile ? path.dirname(entry.sessionFile) : undefined,
|
||||
sessionDir:
|
||||
entry.sessionFile && !isSqliteSessionTranscriptLocator(entry.sessionFile)
|
||||
? path.dirname(entry.sessionFile)
|
||||
: undefined,
|
||||
});
|
||||
if (!restoredSession?.sessionFile) {
|
||||
respond(
|
||||
|
||||
Reference in New Issue
Block a user