@kodelyth/msteams 2026.5.42 → 2026.6.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 (177) hide show
  1. package/klaw.plugin.json +726 -2
  2. package/package.json +18 -6
  3. package/api.ts +0 -3
  4. package/channel-config-api.ts +0 -1
  5. package/channel-plugin-api.ts +0 -2
  6. package/config-api.ts +0 -4
  7. package/contract-api.ts +0 -4
  8. package/index.ts +0 -20
  9. package/runtime-api.ts +0 -66
  10. package/secret-contract-api.ts +0 -5
  11. package/setup-entry.ts +0 -13
  12. package/setup-plugin-api.ts +0 -3
  13. package/src/ai-entity.ts +0 -7
  14. package/src/approval-auth.ts +0 -44
  15. package/src/attachments/bot-framework.test.ts +0 -506
  16. package/src/attachments/bot-framework.ts +0 -348
  17. package/src/attachments/download.ts +0 -328
  18. package/src/attachments/graph.test.ts +0 -441
  19. package/src/attachments/graph.ts +0 -489
  20. package/src/attachments/html.ts +0 -122
  21. package/src/attachments/payload.ts +0 -14
  22. package/src/attachments/remote-media.test.ts +0 -187
  23. package/src/attachments/remote-media.ts +0 -86
  24. package/src/attachments/shared.test.ts +0 -547
  25. package/src/attachments/shared.ts +0 -655
  26. package/src/attachments/types.ts +0 -47
  27. package/src/attachments.graph.test.ts +0 -414
  28. package/src/attachments.helpers.test.ts +0 -245
  29. package/src/attachments.test-helpers.ts +0 -17
  30. package/src/attachments.test.ts +0 -754
  31. package/src/attachments.ts +0 -18
  32. package/src/block-streaming-config.test.ts +0 -61
  33. package/src/channel-api.ts +0 -1
  34. package/src/channel.actions.test.ts +0 -797
  35. package/src/channel.directory.test.ts +0 -176
  36. package/src/channel.message-adapter.test.ts +0 -227
  37. package/src/channel.runtime.ts +0 -56
  38. package/src/channel.setup.ts +0 -77
  39. package/src/channel.test.ts +0 -136
  40. package/src/channel.ts +0 -1176
  41. package/src/config-schema.ts +0 -6
  42. package/src/config-ui-hints.ts +0 -40
  43. package/src/conversation-store-fs.test.ts +0 -81
  44. package/src/conversation-store-fs.ts +0 -149
  45. package/src/conversation-store-helpers.test.ts +0 -202
  46. package/src/conversation-store-helpers.ts +0 -105
  47. package/src/conversation-store-memory.ts +0 -51
  48. package/src/conversation-store.shared.test.ts +0 -260
  49. package/src/conversation-store.ts +0 -71
  50. package/src/directory-live.test.ts +0 -156
  51. package/src/directory-live.ts +0 -111
  52. package/src/doctor.ts +0 -27
  53. package/src/errors.test.ts +0 -154
  54. package/src/errors.ts +0 -270
  55. package/src/feedback-reflection-prompt.ts +0 -117
  56. package/src/feedback-reflection-store.ts +0 -113
  57. package/src/feedback-reflection.test.ts +0 -237
  58. package/src/feedback-reflection.ts +0 -268
  59. package/src/file-consent-helpers.test.ts +0 -328
  60. package/src/file-consent-helpers.ts +0 -115
  61. package/src/file-consent-invoke.ts +0 -150
  62. package/src/file-consent.test.ts +0 -378
  63. package/src/file-consent.ts +0 -223
  64. package/src/graph-chat.ts +0 -36
  65. package/src/graph-group-management.test.ts +0 -332
  66. package/src/graph-group-management.ts +0 -168
  67. package/src/graph-members.test.ts +0 -89
  68. package/src/graph-members.ts +0 -48
  69. package/src/graph-messages.actions.test.ts +0 -253
  70. package/src/graph-messages.read.test.ts +0 -391
  71. package/src/graph-messages.search.test.ts +0 -227
  72. package/src/graph-messages.test-helpers.ts +0 -50
  73. package/src/graph-messages.ts +0 -534
  74. package/src/graph-teams.test.ts +0 -222
  75. package/src/graph-teams.ts +0 -114
  76. package/src/graph-thread.test.ts +0 -252
  77. package/src/graph-thread.ts +0 -146
  78. package/src/graph-upload.test.ts +0 -253
  79. package/src/graph-upload.ts +0 -531
  80. package/src/graph-users.ts +0 -29
  81. package/src/graph.test.ts +0 -540
  82. package/src/graph.ts +0 -308
  83. package/src/inbound.test.ts +0 -221
  84. package/src/inbound.ts +0 -148
  85. package/src/index.ts +0 -4
  86. package/src/media-helpers.test.ts +0 -220
  87. package/src/media-helpers.ts +0 -105
  88. package/src/mentions.test.ts +0 -254
  89. package/src/mentions.ts +0 -114
  90. package/src/messenger.test.ts +0 -961
  91. package/src/messenger.ts +0 -608
  92. package/src/monitor-handler/access.ts +0 -136
  93. package/src/monitor-handler/inbound-media.test.ts +0 -314
  94. package/src/monitor-handler/inbound-media.ts +0 -180
  95. package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
  96. package/src/monitor-handler/message-handler.authz.test.ts +0 -739
  97. package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
  98. package/src/monitor-handler/message-handler.test-support.ts +0 -99
  99. package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -225
  100. package/src/monitor-handler/message-handler.thread-session.test.ts +0 -132
  101. package/src/monitor-handler/message-handler.ts +0 -1003
  102. package/src/monitor-handler/reaction-handler.test.ts +0 -325
  103. package/src/monitor-handler/reaction-handler.ts +0 -122
  104. package/src/monitor-handler/thread-session.ts +0 -30
  105. package/src/monitor-handler.adaptive-card.test.ts +0 -158
  106. package/src/monitor-handler.feedback-authz.test.ts +0 -357
  107. package/src/monitor-handler.file-consent.test.ts +0 -443
  108. package/src/monitor-handler.sso.test.ts +0 -576
  109. package/src/monitor-handler.test-helpers.ts +0 -181
  110. package/src/monitor-handler.ts +0 -538
  111. package/src/monitor-handler.types.ts +0 -27
  112. package/src/monitor-types.ts +0 -6
  113. package/src/monitor.lifecycle.test.ts +0 -457
  114. package/src/monitor.test.ts +0 -119
  115. package/src/monitor.ts +0 -476
  116. package/src/oauth.flow.ts +0 -77
  117. package/src/oauth.shared.ts +0 -37
  118. package/src/oauth.test.ts +0 -350
  119. package/src/oauth.token.ts +0 -162
  120. package/src/oauth.ts +0 -130
  121. package/src/outbound.test.ts +0 -400
  122. package/src/outbound.ts +0 -198
  123. package/src/pending-uploads-fs.test.ts +0 -261
  124. package/src/pending-uploads-fs.ts +0 -235
  125. package/src/pending-uploads.test.ts +0 -186
  126. package/src/pending-uploads.ts +0 -121
  127. package/src/policy.test.ts +0 -156
  128. package/src/policy.ts +0 -245
  129. package/src/polls-store-memory.ts +0 -32
  130. package/src/polls.test.ts +0 -169
  131. package/src/polls.ts +0 -312
  132. package/src/presentation.ts +0 -93
  133. package/src/probe.test.ts +0 -79
  134. package/src/probe.ts +0 -132
  135. package/src/reply-dispatcher.test.ts +0 -543
  136. package/src/reply-dispatcher.ts +0 -523
  137. package/src/reply-stream-controller.test.ts +0 -424
  138. package/src/reply-stream-controller.ts +0 -334
  139. package/src/resolve-allowlist.test.ts +0 -253
  140. package/src/resolve-allowlist.ts +0 -309
  141. package/src/revoked-context.ts +0 -17
  142. package/src/runtime.ts +0 -12
  143. package/src/sdk-types.ts +0 -59
  144. package/src/sdk.test.ts +0 -727
  145. package/src/sdk.ts +0 -916
  146. package/src/secret-contract.ts +0 -49
  147. package/src/secret-input.ts +0 -7
  148. package/src/send-context.test.ts +0 -93
  149. package/src/send-context.ts +0 -269
  150. package/src/send.test.ts +0 -588
  151. package/src/send.ts +0 -697
  152. package/src/sent-message-cache.test.ts +0 -106
  153. package/src/sent-message-cache.ts +0 -174
  154. package/src/session-route.ts +0 -40
  155. package/src/setup-core.ts +0 -162
  156. package/src/setup-surface.test.ts +0 -175
  157. package/src/setup-surface.ts +0 -319
  158. package/src/sso-token-store.test.ts +0 -74
  159. package/src/sso-token-store.ts +0 -166
  160. package/src/sso.ts +0 -300
  161. package/src/storage.ts +0 -25
  162. package/src/store-fs.ts +0 -42
  163. package/src/streaming-message.test.ts +0 -323
  164. package/src/streaming-message.ts +0 -327
  165. package/src/test-runtime.ts +0 -16
  166. package/src/thread-parent-context.test.ts +0 -224
  167. package/src/thread-parent-context.ts +0 -159
  168. package/src/token-response.ts +0 -11
  169. package/src/token.test.ts +0 -268
  170. package/src/token.ts +0 -194
  171. package/src/user-agent.test.ts +0 -121
  172. package/src/user-agent.ts +0 -53
  173. package/src/webhook-timeouts.ts +0 -27
  174. package/src/welcome-card.test.ts +0 -104
  175. package/src/welcome-card.ts +0 -57
  176. package/test-api.ts +0 -1
  177. package/tsconfig.json +0 -16
@@ -1,227 +0,0 @@
1
- import { beforeAll, describe, expect, it } from "vitest";
2
- import type { KlawConfig } from "../runtime-api.js";
3
- import {
4
- CHANNEL_TO,
5
- CHAT_ID,
6
- type GraphMessagesTestModule,
7
- getGraphMessagesMockState,
8
- installGraphMessagesMockDefaults,
9
- loadGraphMessagesTestModule,
10
- } from "./graph-messages.test-helpers.js";
11
-
12
- const mockState = getGraphMessagesMockState();
13
- installGraphMessagesMockDefaults();
14
- let searchMessagesMSTeams: GraphMessagesTestModule["searchMessagesMSTeams"];
15
-
16
- beforeAll(async () => {
17
- ({ searchMessagesMSTeams } = await loadGraphMessagesTestModule());
18
- });
19
-
20
- function readFirstGraphPath(): string {
21
- const [call] = mockState.fetchGraphJson.mock.calls;
22
- if (!call) {
23
- throw new Error("Expected Graph fetch call");
24
- }
25
- const [request] = call;
26
- if (!request || typeof request !== "object" || typeof request.path !== "string") {
27
- throw new Error("Expected Graph fetch request path");
28
- }
29
- return request.path;
30
- }
31
-
32
- describe("searchMessagesMSTeams", () => {
33
- it("searches chat messages with query string", async () => {
34
- mockState.fetchGraphJson.mockResolvedValue({
35
- value: [
36
- {
37
- id: "msg-1",
38
- body: { content: "Meeting notes from Monday" },
39
- from: { user: { id: "u1", displayName: "Alice" } },
40
- createdDateTime: "2026-03-25T10:00:00Z",
41
- },
42
- ],
43
- });
44
-
45
- const result = await searchMessagesMSTeams({
46
- cfg: {} as KlawConfig,
47
- to: CHAT_ID,
48
- query: "meeting notes",
49
- });
50
-
51
- expect(result.messages).toEqual([
52
- {
53
- id: "msg-1",
54
- text: "Meeting notes from Monday",
55
- from: { user: { id: "u1", displayName: "Alice" } },
56
- createdAt: "2026-03-25T10:00:00Z",
57
- },
58
- ]);
59
- const calledPath = readFirstGraphPath();
60
- expect(calledPath).toContain(`/chats/${encodeURIComponent(CHAT_ID)}/messages?`);
61
- expect(calledPath).toContain("$search=");
62
- expect(calledPath).toContain("$top=25");
63
- const decoded = decodeURIComponent(calledPath);
64
- expect(decoded).toContain('$search="meeting notes"');
65
- });
66
-
67
- it("searches channel messages", async () => {
68
- mockState.fetchGraphJson.mockResolvedValue({
69
- value: [
70
- {
71
- id: "msg-2",
72
- body: { content: "Sprint review" },
73
- from: { user: { id: "u2", displayName: "Bob" } },
74
- createdDateTime: "2026-03-25T11:00:00Z",
75
- },
76
- ],
77
- });
78
-
79
- const result = await searchMessagesMSTeams({
80
- cfg: {} as KlawConfig,
81
- to: CHANNEL_TO,
82
- query: "sprint",
83
- });
84
-
85
- expect(result.messages).toHaveLength(1);
86
- const calledPath = readFirstGraphPath();
87
- expect(calledPath).toContain("/teams/team-id-1/channels/channel-id-1/messages?");
88
- });
89
-
90
- it("applies limit parameter", async () => {
91
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
92
-
93
- await searchMessagesMSTeams({
94
- cfg: {} as KlawConfig,
95
- to: CHAT_ID,
96
- query: "test",
97
- limit: 10,
98
- });
99
-
100
- const calledPath = readFirstGraphPath();
101
- expect(calledPath).toContain("$top=10");
102
- });
103
-
104
- it("clamps limit to max 50", async () => {
105
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
106
-
107
- await searchMessagesMSTeams({
108
- cfg: {} as KlawConfig,
109
- to: CHAT_ID,
110
- query: "test",
111
- limit: 100,
112
- });
113
-
114
- const calledPath = readFirstGraphPath();
115
- expect(calledPath).toContain("$top=50");
116
- });
117
-
118
- it("clamps limit to min 1", async () => {
119
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
120
-
121
- await searchMessagesMSTeams({
122
- cfg: {} as KlawConfig,
123
- to: CHAT_ID,
124
- query: "test",
125
- limit: 0,
126
- });
127
-
128
- const calledPath = readFirstGraphPath();
129
- expect(calledPath).toContain("$top=1");
130
- });
131
-
132
- it("applies from filter", async () => {
133
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
134
-
135
- await searchMessagesMSTeams({
136
- cfg: {} as KlawConfig,
137
- to: CHAT_ID,
138
- query: "budget",
139
- from: "Alice",
140
- });
141
-
142
- const calledPath = readFirstGraphPath();
143
- expect(calledPath).toContain("$filter=");
144
- const decoded = decodeURIComponent(calledPath);
145
- expect(decoded).toContain("from/user/displayName eq 'Alice'");
146
- });
147
-
148
- it("escapes single quotes in from filter", async () => {
149
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
150
-
151
- await searchMessagesMSTeams({
152
- cfg: {} as KlawConfig,
153
- to: CHAT_ID,
154
- query: "test",
155
- from: "O'Brien",
156
- });
157
-
158
- const calledPath = readFirstGraphPath();
159
- const decoded = decodeURIComponent(calledPath);
160
- expect(decoded).toContain("O''Brien");
161
- });
162
-
163
- it("strips double quotes from query to prevent injection", async () => {
164
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
165
-
166
- await searchMessagesMSTeams({
167
- cfg: {} as KlawConfig,
168
- to: CHAT_ID,
169
- query: 'say "hello" world',
170
- });
171
-
172
- const calledPath = readFirstGraphPath();
173
- const decoded = decodeURIComponent(calledPath);
174
- expect(decoded).toContain('$search="say hello world"');
175
- expect(decoded).not.toContain('""');
176
- });
177
-
178
- it("passes ConsistencyLevel: eventual header", async () => {
179
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
180
-
181
- await searchMessagesMSTeams({
182
- cfg: {} as KlawConfig,
183
- to: CHAT_ID,
184
- query: "test",
185
- });
186
-
187
- expect(mockState.fetchGraphJson).toHaveBeenCalledWith({
188
- token: "test-graph-token",
189
- path: `/chats/${encodeURIComponent(CHAT_ID)}/messages?$search=${encodeURIComponent(
190
- '"test"',
191
- )}&$top=25`,
192
- headers: { ConsistencyLevel: "eventual" },
193
- });
194
- });
195
-
196
- it("returns empty array when no messages match", async () => {
197
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
198
-
199
- const result = await searchMessagesMSTeams({
200
- cfg: {} as KlawConfig,
201
- to: CHAT_ID,
202
- query: "nonexistent",
203
- });
204
-
205
- expect(result.messages).toStrictEqual([]);
206
- });
207
-
208
- it("resolves user: target through conversation store", async () => {
209
- mockState.findPreferredDmByUserId.mockResolvedValue({
210
- conversationId: "a:bot-id",
211
- reference: { graphChatId: "19:dm-chat@thread.tacv2" },
212
- });
213
- mockState.fetchGraphJson.mockResolvedValue({ value: [] });
214
-
215
- await searchMessagesMSTeams({
216
- cfg: {} as KlawConfig,
217
- to: "user:aad-user-1",
218
- query: "hello",
219
- });
220
-
221
- expect(mockState.findPreferredDmByUserId).toHaveBeenCalledWith("aad-user-1");
222
- const calledPath = readFirstGraphPath();
223
- expect(calledPath).toContain(
224
- `/chats/${encodeURIComponent("19:dm-chat@thread.tacv2")}/messages?`,
225
- );
226
- });
227
- });
@@ -1,50 +0,0 @@
1
- import { beforeEach, vi } from "vitest";
2
-
3
- const graphMessagesMockState = vi.hoisted(() => ({
4
- resolveGraphToken: vi.fn(),
5
- fetchGraphJson: vi.fn(),
6
- fetchGraphAbsoluteUrl: vi.fn(),
7
- postGraphJson: vi.fn(),
8
- postGraphBetaJson: vi.fn(),
9
- deleteGraphRequest: vi.fn(),
10
- findPreferredDmByUserId: vi.fn(),
11
- }));
12
-
13
- vi.mock("./graph.js", () => {
14
- return {
15
- resolveGraphToken: graphMessagesMockState.resolveGraphToken,
16
- fetchGraphJson: graphMessagesMockState.fetchGraphJson,
17
- fetchGraphAbsoluteUrl: graphMessagesMockState.fetchGraphAbsoluteUrl,
18
- postGraphJson: graphMessagesMockState.postGraphJson,
19
- postGraphBetaJson: graphMessagesMockState.postGraphBetaJson,
20
- deleteGraphRequest: graphMessagesMockState.deleteGraphRequest,
21
- escapeOData: vi.fn((value: string) => value.replaceAll("'", "''")),
22
- };
23
- });
24
-
25
- vi.mock("./conversation-store-fs.js", () => ({
26
- createMSTeamsConversationStoreFs: () => ({
27
- findPreferredDmByUserId: graphMessagesMockState.findPreferredDmByUserId,
28
- }),
29
- }));
30
-
31
- export const TOKEN = "test-graph-token";
32
- export const CHAT_ID = "19:abc@thread.tacv2";
33
- export const CHANNEL_TO = "team-id-1/channel-id-1";
34
-
35
- export function getGraphMessagesMockState(): typeof graphMessagesMockState {
36
- return graphMessagesMockState;
37
- }
38
-
39
- export type GraphMessagesTestModule = typeof import("./graph-messages.js");
40
-
41
- export function loadGraphMessagesTestModule(): Promise<GraphMessagesTestModule> {
42
- return import("./graph-messages.js");
43
- }
44
-
45
- export function installGraphMessagesMockDefaults(): void {
46
- beforeEach(() => {
47
- vi.clearAllMocks();
48
- graphMessagesMockState.resolveGraphToken.mockResolvedValue(TOKEN);
49
- });
50
- }