@openclaw/msteams 2026.5.2 → 2026.5.3-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/dist/api.js +3 -0
  2. package/dist/channel-D7hdreTh.js +984 -0
  3. package/dist/channel-config-api.js +2 -0
  4. package/dist/channel-plugin-api.js +2 -0
  5. package/dist/channel.runtime-BC1ruIfN.js +573 -0
  6. package/dist/config-schema-B8QezH6t.js +15 -0
  7. package/dist/contract-api.js +2 -0
  8. package/dist/graph-users-9uQJepqr.js +1354 -0
  9. package/dist/index.js +22 -0
  10. package/dist/oauth-BWJyilR1.js +114 -0
  11. package/dist/oauth.token-xxpoLWy5.js +115 -0
  12. package/dist/policy-DTnU2GR7.js +142 -0
  13. package/dist/probe-D_H8yFps.js +2194 -0
  14. package/dist/resolve-allowlist-D41JSziq.js +219 -0
  15. package/dist/runtime-api-DV1iVMn1.js +28 -0
  16. package/dist/runtime-api.js +2 -0
  17. package/dist/secret-contract-BuoEXmPS.js +35 -0
  18. package/dist/secret-contract-api.js +2 -0
  19. package/dist/setup-entry.js +15 -0
  20. package/dist/setup-plugin-api.js +64 -0
  21. package/dist/setup-surface-BLkFQYIQ.js +313 -0
  22. package/dist/src-CFp1QpFd.js +4064 -0
  23. package/dist/test-api.js +2 -0
  24. package/package.json +14 -6
  25. package/api.ts +0 -3
  26. package/channel-config-api.ts +0 -1
  27. package/channel-plugin-api.ts +0 -2
  28. package/config-api.ts +0 -4
  29. package/contract-api.ts +0 -4
  30. package/index.ts +0 -20
  31. package/runtime-api.ts +0 -73
  32. package/secret-contract-api.ts +0 -5
  33. package/setup-entry.ts +0 -13
  34. package/setup-plugin-api.ts +0 -3
  35. package/src/ai-entity.ts +0 -7
  36. package/src/approval-auth.ts +0 -44
  37. package/src/attachments/bot-framework.test.ts +0 -461
  38. package/src/attachments/bot-framework.ts +0 -362
  39. package/src/attachments/download.ts +0 -311
  40. package/src/attachments/graph.test.ts +0 -416
  41. package/src/attachments/graph.ts +0 -484
  42. package/src/attachments/html.ts +0 -122
  43. package/src/attachments/payload.ts +0 -14
  44. package/src/attachments/remote-media.test.ts +0 -137
  45. package/src/attachments/remote-media.ts +0 -112
  46. package/src/attachments/shared.test.ts +0 -530
  47. package/src/attachments/shared.ts +0 -626
  48. package/src/attachments/types.ts +0 -47
  49. package/src/attachments.graph.test.ts +0 -342
  50. package/src/attachments.helpers.test.ts +0 -246
  51. package/src/attachments.test-helpers.ts +0 -17
  52. package/src/attachments.test.ts +0 -687
  53. package/src/attachments.ts +0 -18
  54. package/src/block-streaming-config.test.ts +0 -61
  55. package/src/channel-api.ts +0 -1
  56. package/src/channel.actions.test.ts +0 -742
  57. package/src/channel.directory.test.ts +0 -200
  58. package/src/channel.runtime.ts +0 -56
  59. package/src/channel.setup.ts +0 -77
  60. package/src/channel.test.ts +0 -128
  61. package/src/channel.ts +0 -1136
  62. package/src/config-schema.ts +0 -6
  63. package/src/config-ui-hints.ts +0 -12
  64. package/src/conversation-store-fs.test.ts +0 -74
  65. package/src/conversation-store-fs.ts +0 -149
  66. package/src/conversation-store-helpers.test.ts +0 -202
  67. package/src/conversation-store-helpers.ts +0 -105
  68. package/src/conversation-store-memory.ts +0 -51
  69. package/src/conversation-store.shared.test.ts +0 -225
  70. package/src/conversation-store.ts +0 -71
  71. package/src/directory-live.test.ts +0 -156
  72. package/src/directory-live.ts +0 -111
  73. package/src/doctor.ts +0 -27
  74. package/src/errors.test.ts +0 -133
  75. package/src/errors.ts +0 -246
  76. package/src/feedback-reflection-prompt.ts +0 -117
  77. package/src/feedback-reflection-store.ts +0 -114
  78. package/src/feedback-reflection.test.ts +0 -237
  79. package/src/feedback-reflection.ts +0 -283
  80. package/src/file-consent-helpers.test.ts +0 -326
  81. package/src/file-consent-helpers.ts +0 -126
  82. package/src/file-consent-invoke.ts +0 -150
  83. package/src/file-consent.test.ts +0 -363
  84. package/src/file-consent.ts +0 -287
  85. package/src/graph-chat.ts +0 -55
  86. package/src/graph-group-management.test.ts +0 -318
  87. package/src/graph-group-management.ts +0 -168
  88. package/src/graph-members.test.ts +0 -89
  89. package/src/graph-members.ts +0 -48
  90. package/src/graph-messages.actions.test.ts +0 -243
  91. package/src/graph-messages.read.test.ts +0 -391
  92. package/src/graph-messages.search.test.ts +0 -213
  93. package/src/graph-messages.test-helpers.ts +0 -50
  94. package/src/graph-messages.ts +0 -534
  95. package/src/graph-teams.test.ts +0 -215
  96. package/src/graph-teams.ts +0 -114
  97. package/src/graph-thread.test.ts +0 -246
  98. package/src/graph-thread.ts +0 -146
  99. package/src/graph-upload.test.ts +0 -258
  100. package/src/graph-upload.ts +0 -531
  101. package/src/graph-users.ts +0 -29
  102. package/src/graph.test.ts +0 -516
  103. package/src/graph.ts +0 -293
  104. package/src/inbound.test.ts +0 -221
  105. package/src/inbound.ts +0 -148
  106. package/src/index.ts +0 -4
  107. package/src/media-helpers.test.ts +0 -202
  108. package/src/media-helpers.ts +0 -105
  109. package/src/mentions.test.ts +0 -244
  110. package/src/mentions.ts +0 -114
  111. package/src/messenger.test.ts +0 -865
  112. package/src/messenger.ts +0 -605
  113. package/src/monitor-handler/access.ts +0 -125
  114. package/src/monitor-handler/inbound-media.test.ts +0 -289
  115. package/src/monitor-handler/inbound-media.ts +0 -180
  116. package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
  117. package/src/monitor-handler/message-handler.authz.test.ts +0 -669
  118. package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
  119. package/src/monitor-handler/message-handler.test-support.ts +0 -100
  120. package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -223
  121. package/src/monitor-handler/message-handler.thread-session.test.ts +0 -77
  122. package/src/monitor-handler/message-handler.ts +0 -1000
  123. package/src/monitor-handler/reaction-handler.test.ts +0 -267
  124. package/src/monitor-handler/reaction-handler.ts +0 -210
  125. package/src/monitor-handler/thread-session.ts +0 -17
  126. package/src/monitor-handler.adaptive-card.test.ts +0 -162
  127. package/src/monitor-handler.feedback-authz.test.ts +0 -314
  128. package/src/monitor-handler.file-consent.test.ts +0 -423
  129. package/src/monitor-handler.sso.test.ts +0 -563
  130. package/src/monitor-handler.test-helpers.ts +0 -180
  131. package/src/monitor-handler.ts +0 -534
  132. package/src/monitor-handler.types.ts +0 -27
  133. package/src/monitor-types.ts +0 -6
  134. package/src/monitor.lifecycle.test.ts +0 -278
  135. package/src/monitor.test.ts +0 -119
  136. package/src/monitor.ts +0 -442
  137. package/src/oauth.flow.ts +0 -77
  138. package/src/oauth.shared.ts +0 -37
  139. package/src/oauth.test.ts +0 -305
  140. package/src/oauth.token.ts +0 -158
  141. package/src/oauth.ts +0 -130
  142. package/src/outbound.test.ts +0 -130
  143. package/src/outbound.ts +0 -71
  144. package/src/pending-uploads-fs.test.ts +0 -246
  145. package/src/pending-uploads-fs.ts +0 -235
  146. package/src/pending-uploads.test.ts +0 -173
  147. package/src/pending-uploads.ts +0 -121
  148. package/src/policy.test.ts +0 -240
  149. package/src/policy.ts +0 -262
  150. package/src/polls-store-memory.ts +0 -32
  151. package/src/polls.test.ts +0 -160
  152. package/src/polls.ts +0 -323
  153. package/src/presentation.ts +0 -68
  154. package/src/probe.test.ts +0 -77
  155. package/src/probe.ts +0 -132
  156. package/src/reply-dispatcher.test.ts +0 -437
  157. package/src/reply-dispatcher.ts +0 -346
  158. package/src/reply-stream-controller.test.ts +0 -235
  159. package/src/reply-stream-controller.ts +0 -147
  160. package/src/resolve-allowlist.test.ts +0 -250
  161. package/src/resolve-allowlist.ts +0 -309
  162. package/src/revoked-context.ts +0 -17
  163. package/src/runtime.ts +0 -9
  164. package/src/sdk-types.ts +0 -59
  165. package/src/sdk.test.ts +0 -666
  166. package/src/sdk.ts +0 -884
  167. package/src/secret-contract.ts +0 -49
  168. package/src/secret-input.ts +0 -7
  169. package/src/send-context.ts +0 -231
  170. package/src/send.test.ts +0 -493
  171. package/src/send.ts +0 -637
  172. package/src/sent-message-cache.test.ts +0 -15
  173. package/src/sent-message-cache.ts +0 -56
  174. package/src/session-route.ts +0 -40
  175. package/src/setup-core.ts +0 -160
  176. package/src/setup-surface.test.ts +0 -202
  177. package/src/setup-surface.ts +0 -320
  178. package/src/sso-token-store.test.ts +0 -72
  179. package/src/sso-token-store.ts +0 -166
  180. package/src/sso.ts +0 -300
  181. package/src/storage.ts +0 -25
  182. package/src/store-fs.ts +0 -44
  183. package/src/streaming-message.test.ts +0 -262
  184. package/src/streaming-message.ts +0 -297
  185. package/src/test-runtime.ts +0 -16
  186. package/src/thread-parent-context.test.ts +0 -224
  187. package/src/thread-parent-context.ts +0 -159
  188. package/src/token-response.ts +0 -11
  189. package/src/token.test.ts +0 -259
  190. package/src/token.ts +0 -195
  191. package/src/user-agent.test.ts +0 -86
  192. package/src/user-agent.ts +0 -53
  193. package/src/webhook-timeouts.ts +0 -27
  194. package/src/welcome-card.test.ts +0 -81
  195. package/src/welcome-card.ts +0 -57
  196. package/test-api.ts +0 -1
  197. package/tsconfig.json +0 -16
package/src/send.test.ts DELETED
@@ -1,493 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import type { OpenClawConfig } from "../runtime-api.js";
3
- import { deleteMessageMSTeams, editMessageMSTeams, sendMessageMSTeams } from "./send.js";
4
-
5
- const mockState = vi.hoisted(() => ({
6
- loadOutboundMediaFromUrl: vi.fn(),
7
- resolveMSTeamsSendContext: vi.fn(),
8
- resolveMarkdownTableMode: vi.fn(() => "off"),
9
- convertMarkdownTables: vi.fn((text: string) => text),
10
- runtimeResolveMarkdownTableMode: vi.fn(() => "off"),
11
- runtimeConvertMarkdownTables: vi.fn((text: string) => text),
12
- requiresFileConsent: vi.fn(),
13
- prepareFileConsentActivity: vi.fn(),
14
- prepareFileConsentActivityFs: vi.fn(),
15
- extractFilename: vi.fn(async () => "fallback.bin"),
16
- sendMSTeamsMessages: vi.fn(),
17
- uploadAndShareSharePoint: vi.fn(),
18
- getDriveItemProperties: vi.fn(),
19
- buildTeamsFileInfoCard: vi.fn(),
20
- }));
21
-
22
- vi.mock("openclaw/plugin-sdk/outbound-media", () => ({
23
- loadOutboundMediaFromUrl: mockState.loadOutboundMediaFromUrl,
24
- }));
25
-
26
- vi.mock("openclaw/plugin-sdk/markdown-table-runtime", () => ({
27
- resolveMarkdownTableMode: mockState.resolveMarkdownTableMode,
28
- }));
29
-
30
- vi.mock("openclaw/plugin-sdk/text-runtime", async (importOriginal) => {
31
- const actual = await importOriginal<typeof import("openclaw/plugin-sdk/text-runtime")>();
32
- return {
33
- ...actual,
34
- convertMarkdownTables: mockState.convertMarkdownTables,
35
- };
36
- });
37
-
38
- vi.mock("./send-context.js", () => ({
39
- resolveMSTeamsSendContext: mockState.resolveMSTeamsSendContext,
40
- }));
41
-
42
- vi.mock("./file-consent-helpers.js", () => ({
43
- requiresFileConsent: mockState.requiresFileConsent,
44
- prepareFileConsentActivity: mockState.prepareFileConsentActivity,
45
- prepareFileConsentActivityFs: mockState.prepareFileConsentActivityFs,
46
- }));
47
-
48
- vi.mock("./media-helpers.js", () => ({
49
- extractFilename: mockState.extractFilename,
50
- extractMessageId: () => "message-1",
51
- }));
52
-
53
- vi.mock("./messenger.js", () => ({
54
- sendMSTeamsMessages: mockState.sendMSTeamsMessages,
55
- buildConversationReference: () => ({}),
56
- }));
57
-
58
- vi.mock("./runtime.js", () => ({
59
- getMSTeamsRuntime: () => ({
60
- channel: {
61
- text: {
62
- resolveMarkdownTableMode: mockState.runtimeResolveMarkdownTableMode,
63
- convertMarkdownTables: mockState.runtimeConvertMarkdownTables,
64
- },
65
- },
66
- }),
67
- }));
68
-
69
- vi.mock("./graph-upload.js", () => ({
70
- uploadAndShareSharePoint: mockState.uploadAndShareSharePoint,
71
- getDriveItemProperties: mockState.getDriveItemProperties,
72
- uploadAndShareOneDrive: vi.fn(),
73
- }));
74
-
75
- vi.mock("./graph-chat.js", () => ({
76
- buildTeamsFileInfoCard: mockState.buildTeamsFileInfoCard,
77
- }));
78
-
79
- function mockContinueConversationFailure(error: string) {
80
- const mockContinueConversation = vi.fn().mockRejectedValue(new Error(error));
81
- mockState.resolveMSTeamsSendContext.mockResolvedValue({
82
- adapter: { continueConversation: mockContinueConversation },
83
- appId: "app-id",
84
- conversationId: "19:conversation@thread.tacv2",
85
- ref: {
86
- user: { id: "user-1" },
87
- agent: { id: "agent-1" },
88
- conversation: { id: "19:conversation@thread.tacv2" },
89
- channelId: "msteams",
90
- },
91
- log: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
92
- conversationType: "personal",
93
- tokenProvider: {},
94
- });
95
- return mockContinueConversation;
96
- }
97
-
98
- function createSharePointSendContext(params: {
99
- conversationId: string;
100
- graphChatId: string | null;
101
- siteId: string;
102
- }) {
103
- return {
104
- adapter: {
105
- continueConversation: vi.fn(
106
- async (
107
- _id: string,
108
- _ref: unknown,
109
- fn: (ctx: { sendActivity: () => { id: "msg-1" } }) => Promise<void>,
110
- ) => fn({ sendActivity: () => ({ id: "msg-1" }) }),
111
- ),
112
- },
113
- appId: "app-id",
114
- conversationId: params.conversationId,
115
- graphChatId: params.graphChatId,
116
- ref: {},
117
- log: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
118
- conversationType: "groupChat" as const,
119
- tokenProvider: { getAccessToken: vi.fn(async () => "token") },
120
- mediaMaxBytes: 8 * 1024 * 1024,
121
- sharePointSiteId: params.siteId,
122
- };
123
- }
124
-
125
- function mockSharePointPdfUpload(params: {
126
- bufferSize: number;
127
- fileName: string;
128
- itemId: string;
129
- uniqueId: string;
130
- }) {
131
- mockState.loadOutboundMediaFromUrl.mockResolvedValueOnce({
132
- buffer: Buffer.alloc(params.bufferSize, "pdf"),
133
- contentType: "application/pdf",
134
- fileName: params.fileName,
135
- kind: "file",
136
- });
137
- mockState.requiresFileConsent.mockReturnValue(false);
138
- mockState.uploadAndShareSharePoint.mockResolvedValue({
139
- itemId: params.itemId,
140
- webUrl: `https://sp.example.com/${params.fileName}`,
141
- shareUrl: `https://sp.example.com/share/${params.fileName}`,
142
- name: params.fileName,
143
- });
144
- mockState.getDriveItemProperties.mockResolvedValue({
145
- eTag: `"${params.uniqueId},1"`,
146
- webDavUrl: `https://sp.example.com/dav/${params.fileName}`,
147
- name: params.fileName,
148
- });
149
- mockState.buildTeamsFileInfoCard.mockReturnValue({
150
- contentType: "application/vnd.microsoft.teams.card.file.info",
151
- contentUrl: `https://sp.example.com/dav/${params.fileName}`,
152
- name: params.fileName,
153
- content: { uniqueId: params.uniqueId, fileType: "pdf" },
154
- });
155
- }
156
-
157
- describe("sendMessageMSTeams", () => {
158
- beforeEach(() => {
159
- mockState.loadOutboundMediaFromUrl.mockReset();
160
- mockState.resolveMSTeamsSendContext.mockReset();
161
- mockState.resolveMarkdownTableMode.mockReset();
162
- mockState.resolveMarkdownTableMode.mockReturnValue("off");
163
- mockState.convertMarkdownTables.mockReset();
164
- mockState.convertMarkdownTables.mockImplementation((text: string) => text);
165
- mockState.runtimeResolveMarkdownTableMode.mockReset();
166
- mockState.runtimeResolveMarkdownTableMode.mockReturnValue("off");
167
- mockState.runtimeConvertMarkdownTables.mockReset();
168
- mockState.runtimeConvertMarkdownTables.mockImplementation((text: string) => text);
169
- mockState.requiresFileConsent.mockReset();
170
- mockState.prepareFileConsentActivity.mockReset();
171
- mockState.prepareFileConsentActivityFs.mockReset();
172
- mockState.extractFilename.mockReset();
173
- mockState.sendMSTeamsMessages.mockReset();
174
- mockState.uploadAndShareSharePoint.mockReset();
175
- mockState.getDriveItemProperties.mockReset();
176
- mockState.buildTeamsFileInfoCard.mockReset();
177
-
178
- mockState.extractFilename.mockResolvedValue("fallback.bin");
179
- mockState.requiresFileConsent.mockReturnValue(false);
180
- mockState.resolveMSTeamsSendContext.mockResolvedValue({
181
- adapter: {},
182
- appId: "app-id",
183
- conversationId: "19:conversation@thread.tacv2",
184
- ref: {},
185
- log: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
186
- conversationType: "personal",
187
- tokenProvider: { getAccessToken: vi.fn(async () => "token") },
188
- mediaMaxBytes: 8 * 1024,
189
- sharePointSiteId: undefined,
190
- });
191
- mockState.sendMSTeamsMessages.mockResolvedValue(["message-1"]);
192
- });
193
-
194
- it("loads media through shared helper and forwards mediaLocalRoots", async () => {
195
- const mediaBuffer = Buffer.from("tiny-image");
196
- mockState.loadOutboundMediaFromUrl.mockResolvedValueOnce({
197
- buffer: mediaBuffer,
198
- contentType: "image/png",
199
- fileName: "inline.png",
200
- kind: "image",
201
- });
202
-
203
- await sendMessageMSTeams({
204
- cfg: {} as OpenClawConfig,
205
- to: "conversation:19:conversation@thread.tacv2",
206
- text: "hello",
207
- mediaUrl: "file:///tmp/agent-workspace/inline.png",
208
- mediaLocalRoots: ["/tmp/agent-workspace"],
209
- });
210
-
211
- expect(mockState.loadOutboundMediaFromUrl).toHaveBeenCalledWith(
212
- "file:///tmp/agent-workspace/inline.png",
213
- {
214
- maxBytes: 8 * 1024,
215
- mediaLocalRoots: ["/tmp/agent-workspace"],
216
- },
217
- );
218
-
219
- expect(mockState.sendMSTeamsMessages).toHaveBeenCalledWith(
220
- expect.objectContaining({
221
- messages: [
222
- expect.objectContaining({
223
- text: "hello",
224
- mediaUrl: `data:image/png;base64,${mediaBuffer.toString("base64")}`,
225
- }),
226
- ],
227
- }),
228
- );
229
- });
230
-
231
- it("sends with provided cfg even when Teams runtime text helpers are unavailable", async () => {
232
- mockState.runtimeResolveMarkdownTableMode.mockImplementation(() => {
233
- throw new Error("MSTeams runtime not initialized");
234
- });
235
- mockState.runtimeConvertMarkdownTables.mockImplementation(() => {
236
- throw new Error("MSTeams runtime not initialized");
237
- });
238
- mockState.resolveMarkdownTableMode.mockReturnValue("off");
239
- mockState.convertMarkdownTables.mockReturnValue("hello");
240
-
241
- await expect(
242
- sendMessageMSTeams({
243
- cfg: {} as OpenClawConfig,
244
- to: "conversation:19:conversation@thread.tacv2",
245
- text: "hello",
246
- }),
247
- ).resolves.toEqual({
248
- messageId: "message-1",
249
- conversationId: "19:conversation@thread.tacv2",
250
- });
251
-
252
- expect(mockState.resolveMarkdownTableMode).toHaveBeenCalledWith({
253
- cfg: {},
254
- channel: "msteams",
255
- });
256
- expect(mockState.convertMarkdownTables).toHaveBeenCalledWith("hello", "off");
257
- });
258
-
259
- it("uses graphChatId instead of conversationId when uploading to SharePoint", async () => {
260
- // Simulates a group chat where Bot Framework conversationId is valid but we have
261
- // a resolved Graph chat ID cached from a prior send.
262
- const graphChatId = "19:graph-native-chat-id@thread.tacv2";
263
- const botFrameworkConversationId = "19:bot-framework-id@thread.tacv2";
264
-
265
- mockState.resolveMSTeamsSendContext.mockResolvedValue(
266
- createSharePointSendContext({
267
- conversationId: botFrameworkConversationId,
268
- graphChatId,
269
- siteId: "site-123",
270
- }),
271
- );
272
- mockSharePointPdfUpload({
273
- bufferSize: 100,
274
- fileName: "doc.pdf",
275
- itemId: "item-1",
276
- uniqueId: "{GUID-123}",
277
- });
278
-
279
- await sendMessageMSTeams({
280
- cfg: {} as OpenClawConfig,
281
- to: "conversation:19:bot-framework-id@thread.tacv2",
282
- text: "here is a file",
283
- mediaUrl: "https://example.com/doc.pdf",
284
- });
285
-
286
- // The Graph-native chatId must be passed to SharePoint upload, not the Bot Framework ID
287
- expect(mockState.uploadAndShareSharePoint).toHaveBeenCalledWith(
288
- expect.objectContaining({
289
- chatId: graphChatId,
290
- siteId: "site-123",
291
- }),
292
- );
293
- });
294
-
295
- it("falls back to conversationId when graphChatId is not available", async () => {
296
- const botFrameworkConversationId = "19:fallback-id@thread.tacv2";
297
-
298
- mockState.resolveMSTeamsSendContext.mockResolvedValue(
299
- createSharePointSendContext({
300
- conversationId: botFrameworkConversationId,
301
- graphChatId: null,
302
- siteId: "site-456",
303
- }),
304
- );
305
- mockSharePointPdfUpload({
306
- bufferSize: 50,
307
- fileName: "report.pdf",
308
- itemId: "item-2",
309
- uniqueId: "{GUID-456}",
310
- });
311
-
312
- await sendMessageMSTeams({
313
- cfg: {} as OpenClawConfig,
314
- to: "conversation:19:fallback-id@thread.tacv2",
315
- text: "report",
316
- mediaUrl: "https://example.com/report.pdf",
317
- });
318
-
319
- // Falls back to conversationId when graphChatId is null
320
- expect(mockState.uploadAndShareSharePoint).toHaveBeenCalledWith(
321
- expect.objectContaining({
322
- chatId: botFrameworkConversationId,
323
- siteId: "site-456",
324
- }),
325
- );
326
- });
327
- });
328
-
329
- describe("editMessageMSTeams", () => {
330
- beforeEach(() => {
331
- mockState.resolveMSTeamsSendContext.mockReset();
332
- });
333
-
334
- it("calls continueConversation and updateActivity with correct params", async () => {
335
- const mockUpdateActivity = vi.fn();
336
- const mockContinueConversation = vi.fn(
337
- async (_appId: string, _ref: unknown, logic: (ctx: unknown) => Promise<void>) => {
338
- await logic({
339
- sendActivity: vi.fn(),
340
- updateActivity: mockUpdateActivity,
341
- deleteActivity: vi.fn(),
342
- });
343
- },
344
- );
345
- mockState.resolveMSTeamsSendContext.mockResolvedValue({
346
- adapter: { continueConversation: mockContinueConversation },
347
- appId: "app-id",
348
- conversationId: "19:conversation@thread.tacv2",
349
- ref: {
350
- user: { id: "user-1" },
351
- agent: { id: "agent-1" },
352
- conversation: { id: "19:conversation@thread.tacv2", conversationType: "personal" },
353
- channelId: "msteams",
354
- },
355
- log: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
356
- conversationType: "personal",
357
- tokenProvider: {},
358
- });
359
-
360
- const result = await editMessageMSTeams({
361
- cfg: {} as OpenClawConfig,
362
- to: "conversation:19:conversation@thread.tacv2",
363
- activityId: "activity-123",
364
- text: "Updated message text",
365
- });
366
-
367
- expect(result.conversationId).toBe("19:conversation@thread.tacv2");
368
- expect(mockContinueConversation).toHaveBeenCalledTimes(1);
369
- expect(mockContinueConversation).toHaveBeenCalledWith(
370
- "app-id",
371
- expect.objectContaining({ activityId: undefined }),
372
- expect.any(Function),
373
- );
374
- expect(mockUpdateActivity).toHaveBeenCalledWith({
375
- type: "message",
376
- id: "activity-123",
377
- text: "Updated message text",
378
- });
379
- });
380
-
381
- it("throws a descriptive error when continueConversation fails", async () => {
382
- mockContinueConversationFailure("Service unavailable");
383
-
384
- await expect(
385
- editMessageMSTeams({
386
- cfg: {} as OpenClawConfig,
387
- to: "conversation:19:conversation@thread.tacv2",
388
- activityId: "activity-123",
389
- text: "Updated text",
390
- }),
391
- ).rejects.toThrow("msteams edit failed");
392
- });
393
- });
394
-
395
- describe("deleteMessageMSTeams", () => {
396
- beforeEach(() => {
397
- mockState.resolveMSTeamsSendContext.mockReset();
398
- });
399
-
400
- it("calls continueConversation and deleteActivity with correct activityId", async () => {
401
- const mockDeleteActivity = vi.fn();
402
- const mockContinueConversation = vi.fn(
403
- async (_appId: string, _ref: unknown, logic: (ctx: unknown) => Promise<void>) => {
404
- await logic({
405
- sendActivity: vi.fn(),
406
- updateActivity: vi.fn(),
407
- deleteActivity: mockDeleteActivity,
408
- });
409
- },
410
- );
411
- mockState.resolveMSTeamsSendContext.mockResolvedValue({
412
- adapter: { continueConversation: mockContinueConversation },
413
- appId: "app-id",
414
- conversationId: "19:conversation@thread.tacv2",
415
- ref: {
416
- user: { id: "user-1" },
417
- agent: { id: "agent-1" },
418
- conversation: { id: "19:conversation@thread.tacv2", conversationType: "groupChat" },
419
- channelId: "msteams",
420
- },
421
- log: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
422
- conversationType: "groupChat",
423
- tokenProvider: {},
424
- });
425
-
426
- const result = await deleteMessageMSTeams({
427
- cfg: {} as OpenClawConfig,
428
- to: "conversation:19:conversation@thread.tacv2",
429
- activityId: "activity-456",
430
- });
431
-
432
- expect(result.conversationId).toBe("19:conversation@thread.tacv2");
433
- expect(mockContinueConversation).toHaveBeenCalledTimes(1);
434
- expect(mockContinueConversation).toHaveBeenCalledWith(
435
- "app-id",
436
- expect.objectContaining({ activityId: undefined }),
437
- expect.any(Function),
438
- );
439
- expect(mockDeleteActivity).toHaveBeenCalledWith("activity-456");
440
- });
441
-
442
- it("throws a descriptive error when continueConversation fails", async () => {
443
- mockContinueConversationFailure("Not found");
444
-
445
- await expect(
446
- deleteMessageMSTeams({
447
- cfg: {} as OpenClawConfig,
448
- to: "conversation:19:conversation@thread.tacv2",
449
- activityId: "activity-456",
450
- }),
451
- ).rejects.toThrow("msteams delete failed");
452
- });
453
-
454
- it("passes the appId and proactive ref to continueConversation", async () => {
455
- const mockContinueConversation = vi.fn(
456
- async (_appId: string, _ref: unknown, logic: (ctx: unknown) => Promise<void>) => {
457
- await logic({
458
- sendActivity: vi.fn(),
459
- updateActivity: vi.fn(),
460
- deleteActivity: vi.fn(),
461
- });
462
- },
463
- );
464
- mockState.resolveMSTeamsSendContext.mockResolvedValue({
465
- adapter: { continueConversation: mockContinueConversation },
466
- appId: "my-app-id",
467
- conversationId: "19:conv@thread.tacv2",
468
- ref: {
469
- activityId: "original-activity",
470
- user: { id: "user-1" },
471
- agent: { id: "agent-1" },
472
- conversation: { id: "19:conv@thread.tacv2" },
473
- channelId: "msteams",
474
- },
475
- log: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
476
- conversationType: "personal",
477
- tokenProvider: {},
478
- });
479
-
480
- await deleteMessageMSTeams({
481
- cfg: {} as OpenClawConfig,
482
- to: "conversation:19:conv@thread.tacv2",
483
- activityId: "activity-789",
484
- });
485
-
486
- // appId should be forwarded correctly
487
- expect(mockContinueConversation.mock.calls[0]?.[0]).toBe("my-app-id");
488
- // activityId on the proactive ref should be cleared (undefined) — proactive pattern
489
- expect(mockContinueConversation.mock.calls[0]?.[1]).toMatchObject({
490
- activityId: undefined,
491
- });
492
- });
493
- });