|
| 1 | +import path from "node:path"; |
1 | 2 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | import { |
3 | 4 | addSubagentRunForTests, |
@@ -171,6 +172,46 @@ describe("sessions tools", () => { |
171 | 172 | expect(cronDetails.sessions?.[0]?.kind).toBe("cron"); |
172 | 173 | }); |
173 | 174 |
|
| 175 | + it("sessions_list resolves transcriptPath from agent state dir for multi-store listings", async () => { |
| 176 | + callGatewayMock.mockImplementation(async (opts: unknown) => { |
| 177 | + const request = opts as { method?: string }; |
| 178 | + if (request.method === "sessions.list") { |
| 179 | + return { |
| 180 | + path: "(multiple)", |
| 181 | + sessions: [ |
| 182 | + { |
| 183 | + key: "main", |
| 184 | + kind: "direct", |
| 185 | + sessionId: "sess-main", |
| 186 | + updatedAt: 12, |
| 187 | + }, |
| 188 | + ], |
| 189 | + }; |
| 190 | + } |
| 191 | + return {}; |
| 192 | + }); |
| 193 | + |
| 194 | + const tool = createOpenClawTools().find((candidate) => candidate.name === "sessions_list"); |
| 195 | + expect(tool).toBeDefined(); |
| 196 | + if (!tool) { |
| 197 | + throw new Error("missing sessions_list tool"); |
| 198 | + } |
| 199 | + |
| 200 | + const result = await tool.execute("call2b", {}); |
| 201 | + const details = result.details as { |
| 202 | + sessions?: Array<{ |
| 203 | + key?: string; |
| 204 | + transcriptPath?: string; |
| 205 | + }>; |
| 206 | + }; |
| 207 | + const main = details.sessions?.find((session) => session.key === "main"); |
| 208 | + expect(typeof main?.transcriptPath).toBe("string"); |
| 209 | + expect(main?.transcriptPath).not.toContain("(multiple)"); |
| 210 | + expect(main?.transcriptPath).toContain( |
| 211 | + path.join("agents", "main", "sessions", "sess-main.jsonl"), |
| 212 | + ); |
| 213 | + }); |
| 214 | + |
174 | 215 | it("sessions_history filters tool messages by default", async () => { |
175 | 216 | callGatewayMock.mockImplementation(async (opts: unknown) => { |
176 | 217 | const request = opts as { method?: string }; |
|
0 commit comments