This commit is contained in:
Robby 2026-01-29 21:53:38 -05:00 committed by GitHub
commit 01d793f103
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,11 +56,24 @@ function resolveTranscriptPath(params: {
sessionFile?: string;
}): string | null {
const { sessionId, storePath, sessionFile } = params;
if (sessionFile) return sessionFile;
if (sessionFile) {
if (storePath) {
const storeDir = path.dirname(storePath);
const absSessionFile = path.resolve(storeDir, sessionFile);
const rel = path.relative(storeDir, absSessionFile);
if (rel.startsWith("..") || path.isAbsolute(rel)) {
throw new Error("sessionFile escapes store directory");
}
return absSessionFile;
}
if (!path.isAbsolute(sessionFile)) {
throw new Error("sessionFile must be absolute when storePath is not set");
}
return sessionFile;
}
if (!storePath) return null;
return path.join(path.dirname(storePath), `${sessionId}.jsonl`);
}
function ensureTranscriptFile(params: { transcriptPath: string; sessionId: string }): {
ok: boolean;
error?: string;