mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-21 21:56:46 +00:00
refactor: name sqlite transcript locators explicitly
This commit is contained in:
@@ -260,7 +260,7 @@ function listSqliteTranscriptRecords(): SqliteTranscriptRecord[] {
|
||||
agentId: entry.agentId,
|
||||
sessionId: entry.sessionId,
|
||||
path:
|
||||
entry.path ??
|
||||
entry.locator ??
|
||||
createSqliteSessionTranscriptLocator({
|
||||
agentId: entry.agentId,
|
||||
sessionId: entry.sessionId,
|
||||
|
||||
@@ -241,12 +241,12 @@ function resolveSqliteSessionTranscriptPath(params: {
|
||||
}
|
||||
const explicit = normalizeOptionalString(params.sessionEntry?.sessionFile);
|
||||
if (explicit) {
|
||||
const matched = candidates.find((entry) => entry.path === explicit);
|
||||
const matched = candidates.find((entry) => entry.locator === explicit);
|
||||
if (matched) {
|
||||
return matched.path;
|
||||
return matched.locator;
|
||||
}
|
||||
}
|
||||
return candidates[0]?.path;
|
||||
return candidates[0]?.locator;
|
||||
}
|
||||
|
||||
function deriveTranscriptUsageSnapshot(
|
||||
|
||||
@@ -196,7 +196,10 @@ describe("SQLite session transcript store", () => {
|
||||
{
|
||||
agentId: "main",
|
||||
sessionId: "session-1",
|
||||
path: createSqliteSessionTranscriptLocator({ agentId: "main", sessionId: "session-1" }),
|
||||
locator: createSqliteSessionTranscriptLocator({
|
||||
agentId: "main",
|
||||
sessionId: "session-1",
|
||||
}),
|
||||
updatedAt: 200,
|
||||
eventCount: 2,
|
||||
},
|
||||
|
||||
@@ -58,12 +58,12 @@ export type SqliteSessionTranscriptScope = {
|
||||
};
|
||||
|
||||
export type SqliteSessionTranscriptLocator = SqliteSessionTranscriptScope & {
|
||||
path: string;
|
||||
locator: string;
|
||||
updatedAt: number;
|
||||
};
|
||||
|
||||
export type SqliteSessionTranscript = SqliteSessionTranscriptScope & {
|
||||
path?: string;
|
||||
locator?: string;
|
||||
updatedAt: number;
|
||||
eventCount: number;
|
||||
};
|
||||
@@ -277,8 +277,8 @@ export function listSqliteSessionTranscriptLocators(
|
||||
return listSqliteSessionTranscripts(options).map((transcript) => ({
|
||||
agentId: transcript.agentId,
|
||||
sessionId: transcript.sessionId,
|
||||
path:
|
||||
transcript.path ??
|
||||
locator:
|
||||
transcript.locator ??
|
||||
createSqliteSessionTranscriptLocator({
|
||||
agentId: transcript.agentId,
|
||||
sessionId: transcript.sessionId,
|
||||
@@ -335,7 +335,7 @@ export function listSqliteSessionTranscripts(
|
||||
{
|
||||
agentId: agentDatabase.agentId,
|
||||
sessionId: normalizeSessionId(record.session_id),
|
||||
path: createSqliteSessionTranscriptLocator({
|
||||
locator: createSqliteSessionTranscriptLocator({
|
||||
agentId: agentDatabase.agentId,
|
||||
sessionId: normalizeSessionId(record.session_id),
|
||||
}),
|
||||
|
||||
@@ -265,7 +265,7 @@ const applyCostTotal = (totals: CostUsageTotals, costTotal: number | undefined)
|
||||
function getRememberedTranscriptPath(agentId: string, sessionId: string): string | undefined {
|
||||
return listSqliteSessionTranscriptLocators().find(
|
||||
(entry) => entry.agentId === agentId && entry.sessionId === sessionId,
|
||||
)?.path;
|
||||
)?.locator;
|
||||
}
|
||||
|
||||
function resolveSyntheticSessionFile(params: {
|
||||
@@ -590,7 +590,7 @@ export async function discoverAllSessions(params?: {
|
||||
sessionFile: resolveSyntheticSessionFile({
|
||||
agentId: transcript.agentId,
|
||||
sessionId: transcript.sessionId,
|
||||
rememberedPath: transcript.path,
|
||||
rememberedPath: transcript.locator,
|
||||
}),
|
||||
mtime: transcript.updatedAt,
|
||||
firstUserMessage,
|
||||
|
||||
Reference in New Issue
Block a user