mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
fix: use target session entry for export
This commit is contained in:
@@ -164,4 +164,28 @@ describe("buildExportSessionReply", () => {
|
||||
storePath: "/tmp/custom-store/sessions.json",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the target store entry even when the wrapper sessionEntry is missing", async () => {
|
||||
const { buildExportSessionReply } = await import("./commands-export-session.js");
|
||||
hoisted.loadSessionStoreMock.mockReturnValue({
|
||||
"agent:target:session": {
|
||||
sessionId: "session-from-store",
|
||||
updatedAt: 2,
|
||||
},
|
||||
});
|
||||
|
||||
const reply = await buildExportSessionReply({
|
||||
...makeParams(),
|
||||
sessionEntry: undefined,
|
||||
});
|
||||
|
||||
expect(reply.text).toContain("✅ Session exported!");
|
||||
expect(hoisted.resolveCommandsSystemPromptBundleMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
sessionEntry: expect.objectContaining({
|
||||
sessionId: "session-from-store",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -114,12 +114,7 @@ function parseExportArgs(commandBodyNormalized: string): { outputPath?: string }
|
||||
export async function buildExportSessionReply(params: HandleCommandsParams): Promise<ReplyPayload> {
|
||||
const args = parseExportArgs(params.command.commandBodyNormalized);
|
||||
|
||||
// 1. Resolve session file
|
||||
const sessionEntry = params.sessionEntry;
|
||||
if (!sessionEntry?.sessionId) {
|
||||
return { text: "❌ No active session found." };
|
||||
}
|
||||
|
||||
// 1. Resolve target session entry and session file from the canonical target store.
|
||||
const targetAgentId = resolveAgentIdFromSessionKey(params.sessionKey) || params.agentId;
|
||||
const storePath = params.storePath ?? resolveDefaultSessionStorePath(targetAgentId);
|
||||
const store = loadSessionStore(storePath, { skipCache: true });
|
||||
@@ -152,7 +147,10 @@ export async function buildExportSessionReply(params: HandleCommandsParams): Pro
|
||||
const leafId = sessionManager.getLeafId();
|
||||
|
||||
// 3. Build full system prompt
|
||||
const { systemPrompt, tools } = await resolveCommandsSystemPromptBundle(params);
|
||||
const { systemPrompt, tools } = await resolveCommandsSystemPromptBundle({
|
||||
...params,
|
||||
sessionEntry: entry as HandleCommandsParams["sessionEntry"],
|
||||
});
|
||||
|
||||
// 4. Prepare session data
|
||||
const sessionData: SessionData = {
|
||||
|
||||
Reference in New Issue
Block a user