mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 15:54:32 +00:00
Sessions: fix sessions_list transcriptPath path resolution
This commit is contained in:
@@ -39,13 +39,15 @@ export type SessionFilePathOptions = {
|
||||
sessionsDir?: string;
|
||||
};
|
||||
|
||||
const MULTI_STORE_PATH_SENTINEL = "(multiple)";
|
||||
|
||||
export function resolveSessionFilePathOptions(params: {
|
||||
agentId?: string;
|
||||
storePath?: string;
|
||||
}): SessionFilePathOptions | undefined {
|
||||
const agentId = params.agentId?.trim();
|
||||
const storePath = params.storePath?.trim();
|
||||
if (storePath) {
|
||||
if (storePath && storePath !== MULTI_STORE_PATH_SENTINEL) {
|
||||
const sessionsDir = path.dirname(path.resolve(storePath));
|
||||
return agentId ? { sessionsDir, agentId } : { sessionsDir };
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import type { SessionConfig } from "../types.base.js";
|
||||
import {
|
||||
resolveSessionFilePath,
|
||||
resolveSessionFilePathOptions,
|
||||
resolveSessionTranscriptPathInDir,
|
||||
validateSessionId,
|
||||
} from "./paths.js";
|
||||
@@ -68,6 +69,13 @@ describe("session path safety", () => {
|
||||
expect(resolved).toBe(path.resolve(sessionsDir, "sess-1.jsonl"));
|
||||
});
|
||||
|
||||
it("ignores multi-store sentinel paths when deriving session file options", () => {
|
||||
expect(resolveSessionFilePathOptions({ agentId: "worker", storePath: "(multiple)" })).toEqual({
|
||||
agentId: "worker",
|
||||
});
|
||||
expect(resolveSessionFilePathOptions({ storePath: "(multiple)" })).toBeUndefined();
|
||||
});
|
||||
|
||||
it("accepts symlink-alias session paths that resolve under the sessions dir", () => {
|
||||
if (process.platform === "win32") {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user