fix(export): preserve explicit trajectory session keys (#83308) · openclaw/openclaw@87aa319
giodl73-repo
·
2026-05-19
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -57,6 +57,32 @@ describe("exportTrajectoryCommand", () => {
|
57 | 57 | expect(runtime.exit).toHaveBeenCalledWith(1); |
58 | 58 | }); |
59 | 59 | |
| 60 | +it("preserves direct options when an encoded request omits them", async () => { |
| 61 | +const runtime = createRuntime(); |
| 62 | +const requestJsonBase64 = Buffer.from( |
| 63 | +JSON.stringify({ output: "/tmp/export.json" }), |
| 64 | +"utf8", |
| 65 | +).toString("base64url"); |
| 66 | + |
| 67 | +await exportTrajectoryCommand( |
| 68 | +{ |
| 69 | + requestJsonBase64, |
| 70 | +sessionKey: "agent:main:telegram:direct:123", |
| 71 | +store: "/tmp/direct-store.json", |
| 72 | +}, |
| 73 | +runtime, |
| 74 | +); |
| 75 | + |
| 76 | +expect(mocks.resolveDefaultSessionStorePath).not.toHaveBeenCalled(); |
| 77 | +expect(mocks.loadSessionStore).toHaveBeenCalledWith("/tmp/direct-store.json", { |
| 78 | +skipCache: true, |
| 79 | +}); |
| 80 | +expect(runtime.error).toHaveBeenCalledWith( |
| 81 | +"Session not found: agent:main:telegram:direct:123. Run openclaw sessions to see available sessions.", |
| 82 | +); |
| 83 | +expect(runtime.exit).toHaveBeenCalledWith(1); |
| 84 | +}); |
| 85 | + |
60 | 86 | it("points missing session users at the sessions command", async () => { |
61 | 87 | const runtime = createRuntime(); |
62 | 88 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -56,13 +56,28 @@ function decodeExportTrajectoryRequest(encoded: string): Partial<ExportTrajector
|
56 | 56 | throw new Error("Encoded trajectory export request must be a JSON object"); |
57 | 57 | } |
58 | 58 | const request = decoded as EncodedExportTrajectoryRequest; |
59 | | -return { |
60 | | -sessionKey: readOptionalString(request.sessionKey) ?? "", |
61 | | -output: readOptionalString(request.output), |
62 | | -store: readOptionalString(request.store), |
63 | | -agent: readOptionalString(request.agent), |
64 | | -workspace: readOptionalString(request.workspace), |
65 | | -}; |
| 59 | +const opts: Partial<ExportTrajectoryCommandOptions> = {}; |
| 60 | +const sessionKey = readOptionalString(request.sessionKey); |
| 61 | +if (sessionKey !== undefined) { |
| 62 | +opts.sessionKey = sessionKey; |
| 63 | +} |
| 64 | +const output = readOptionalString(request.output); |
| 65 | +if (output !== undefined) { |
| 66 | +opts.output = output; |
| 67 | +} |
| 68 | +const store = readOptionalString(request.store); |
| 69 | +if (store !== undefined) { |
| 70 | +opts.store = store; |
| 71 | +} |
| 72 | +const agent = readOptionalString(request.agent); |
| 73 | +if (agent !== undefined) { |
| 74 | +opts.agent = agent; |
| 75 | +} |
| 76 | +const workspace = readOptionalString(request.workspace); |
| 77 | +if (workspace !== undefined) { |
| 78 | +opts.workspace = workspace; |
| 79 | +} |
| 80 | +return opts; |
66 | 81 | } |
67 | 82 | |
68 | 83 | function resolveExportTrajectoryOptions( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。