|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 | import { sanitizeChatHistoryMessages } from "./chat-display-projection.js"; |
| 3 | +import { mirrorMessageToolVisibleReplies } from "./chat-display-projection.message-tool.js"; |
| 4 | + |
| 5 | +describe("chat display message-tool projection", () => { |
| 6 | + it("mirrors an automatic-mode send confirmed for the current source", () => { |
| 7 | + const sourceReply = "Visible reply delivered to Slack."; |
| 8 | + const projected = mirrorMessageToolVisibleReplies([ |
| 9 | + { |
| 10 | + role: "assistant", |
| 11 | + content: [ |
| 12 | + { |
| 13 | + type: "toolCall", |
| 14 | + id: "call-message-current-source", |
| 15 | + name: "message", |
| 16 | + arguments: { |
| 17 | + action: "send", |
| 18 | + channel: "slack", |
| 19 | + target: "channel:C123", |
| 20 | + message: sourceReply, |
| 21 | + }, |
| 22 | + }, |
| 23 | + ], |
| 24 | + }, |
| 25 | + { |
| 26 | + role: "toolResult", |
| 27 | + toolName: "message", |
| 28 | + toolCallId: "call-message-current-source", |
| 29 | + content: { ok: true, messageId: "slack-242" }, |
| 30 | + details: { |
| 31 | + ok: true, |
| 32 | + messageId: "slack-242", |
| 33 | + sourceReplyRoute: "current-source", |
| 34 | + }, |
| 35 | + }, |
| 36 | + { role: "assistant", content: [{ type: "text", text: "NO_REPLY" }] }, |
| 37 | + ]); |
| 38 | + |
| 39 | + expect(projected).toContainEqual( |
| 40 | + expect.objectContaining({ |
| 41 | + role: "assistant", |
| 42 | + content: [{ type: "text", text: sourceReply }], |
| 43 | + openclawMessageToolMirror: expect.objectContaining({ |
| 44 | + toolCallId: "call-message-current-source", |
| 45 | + }), |
| 46 | + }), |
| 47 | + ); |
| 48 | + }); |
| 49 | +}); |
3 | 50 |
|
4 | 51 | describe("chat display tool-result detail projection", () => { |
5 | 52 | it("keeps authoritative write booleans and strips unrelated details", () => { |
|
0 commit comments