mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-22 03:51:18 +00:00
fix(export): preserve explicit trajectory session keys (#83308)
This commit is contained in:
parent
567fe2957d
commit
87aa319568
2 changed files with 48 additions and 7 deletions
|
|
@ -57,6 +57,32 @@ describe("exportTrajectoryCommand", () => {
|
|||
expect(runtime.exit).toHaveBeenCalledWith(1);
|
||||
});
|
||||
|
||||
it("preserves direct options when an encoded request omits them", async () => {
|
||||
const runtime = createRuntime();
|
||||
const requestJsonBase64 = Buffer.from(
|
||||
JSON.stringify({ output: "/tmp/export.json" }),
|
||||
"utf8",
|
||||
).toString("base64url");
|
||||
|
||||
await exportTrajectoryCommand(
|
||||
{
|
||||
requestJsonBase64,
|
||||
sessionKey: "agent:main:telegram:direct:123",
|
||||
store: "/tmp/direct-store.json",
|
||||
},
|
||||
runtime,
|
||||
);
|
||||
|
||||
expect(mocks.resolveDefaultSessionStorePath).not.toHaveBeenCalled();
|
||||
expect(mocks.loadSessionStore).toHaveBeenCalledWith("/tmp/direct-store.json", {
|
||||
skipCache: true,
|
||||
});
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
"Session not found: agent:main:telegram:direct:123. Run openclaw sessions to see available sessions.",
|
||||
);
|
||||
expect(runtime.exit).toHaveBeenCalledWith(1);
|
||||
});
|
||||
|
||||
it("points missing session users at the sessions command", async () => {
|
||||
const runtime = createRuntime();
|
||||
|
||||
|
|
|
|||
|
|
@ -56,13 +56,28 @@ function decodeExportTrajectoryRequest(encoded: string): Partial<ExportTrajector
|
|||
throw new Error("Encoded trajectory export request must be a JSON object");
|
||||
}
|
||||
const request = decoded as EncodedExportTrajectoryRequest;
|
||||
return {
|
||||
sessionKey: readOptionalString(request.sessionKey) ?? "",
|
||||
output: readOptionalString(request.output),
|
||||
store: readOptionalString(request.store),
|
||||
agent: readOptionalString(request.agent),
|
||||
workspace: readOptionalString(request.workspace),
|
||||
};
|
||||
const opts: Partial<ExportTrajectoryCommandOptions> = {};
|
||||
const sessionKey = readOptionalString(request.sessionKey);
|
||||
if (sessionKey !== undefined) {
|
||||
opts.sessionKey = sessionKey;
|
||||
}
|
||||
const output = readOptionalString(request.output);
|
||||
if (output !== undefined) {
|
||||
opts.output = output;
|
||||
}
|
||||
const store = readOptionalString(request.store);
|
||||
if (store !== undefined) {
|
||||
opts.store = store;
|
||||
}
|
||||
const agent = readOptionalString(request.agent);
|
||||
if (agent !== undefined) {
|
||||
opts.agent = agent;
|
||||
}
|
||||
const workspace = readOptionalString(request.workspace);
|
||||
if (workspace !== undefined) {
|
||||
opts.workspace = workspace;
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
|
||||
function resolveExportTrajectoryOptions(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue