@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.
- package/klaw.plugin.json +726 -2
- package/package.json +18 -6
- package/api.ts +0 -3
- package/channel-config-api.ts +0 -1
- package/channel-plugin-api.ts +0 -2
- package/config-api.ts +0 -4
- package/contract-api.ts +0 -4
- package/index.ts +0 -20
- package/runtime-api.ts +0 -66
- package/secret-contract-api.ts +0 -5
- package/setup-entry.ts +0 -13
- package/setup-plugin-api.ts +0 -3
- package/src/ai-entity.ts +0 -7
- package/src/approval-auth.ts +0 -44
- package/src/attachments/bot-framework.test.ts +0 -506
- package/src/attachments/bot-framework.ts +0 -348
- package/src/attachments/download.ts +0 -328
- package/src/attachments/graph.test.ts +0 -441
- package/src/attachments/graph.ts +0 -489
- package/src/attachments/html.ts +0 -122
- package/src/attachments/payload.ts +0 -14
- package/src/attachments/remote-media.test.ts +0 -187
- package/src/attachments/remote-media.ts +0 -86
- package/src/attachments/shared.test.ts +0 -547
- package/src/attachments/shared.ts +0 -655
- package/src/attachments/types.ts +0 -47
- package/src/attachments.graph.test.ts +0 -414
- package/src/attachments.helpers.test.ts +0 -245
- package/src/attachments.test-helpers.ts +0 -17
- package/src/attachments.test.ts +0 -754
- package/src/attachments.ts +0 -18
- package/src/block-streaming-config.test.ts +0 -61
- package/src/channel-api.ts +0 -1
- package/src/channel.actions.test.ts +0 -797
- package/src/channel.directory.test.ts +0 -176
- package/src/channel.message-adapter.test.ts +0 -227
- package/src/channel.runtime.ts +0 -56
- package/src/channel.setup.ts +0 -77
- package/src/channel.test.ts +0 -136
- package/src/channel.ts +0 -1176
- package/src/config-schema.ts +0 -6
- package/src/config-ui-hints.ts +0 -40
- package/src/conversation-store-fs.test.ts +0 -81
- package/src/conversation-store-fs.ts +0 -149
- package/src/conversation-store-helpers.test.ts +0 -202
- package/src/conversation-store-helpers.ts +0 -105
- package/src/conversation-store-memory.ts +0 -51
- package/src/conversation-store.shared.test.ts +0 -260
- package/src/conversation-store.ts +0 -71
- package/src/directory-live.test.ts +0 -156
- package/src/directory-live.ts +0 -111
- package/src/doctor.ts +0 -27
- package/src/errors.test.ts +0 -154
- package/src/errors.ts +0 -270
- package/src/feedback-reflection-prompt.ts +0 -117
- package/src/feedback-reflection-store.ts +0 -113
- package/src/feedback-reflection.test.ts +0 -237
- package/src/feedback-reflection.ts +0 -268
- package/src/file-consent-helpers.test.ts +0 -328
- package/src/file-consent-helpers.ts +0 -115
- package/src/file-consent-invoke.ts +0 -150
- package/src/file-consent.test.ts +0 -378
- package/src/file-consent.ts +0 -223
- package/src/graph-chat.ts +0 -36
- package/src/graph-group-management.test.ts +0 -332
- package/src/graph-group-management.ts +0 -168
- package/src/graph-members.test.ts +0 -89
- package/src/graph-members.ts +0 -48
- package/src/graph-messages.actions.test.ts +0 -253
- package/src/graph-messages.read.test.ts +0 -391
- package/src/graph-messages.search.test.ts +0 -227
- package/src/graph-messages.test-helpers.ts +0 -50
- package/src/graph-messages.ts +0 -534
- package/src/graph-teams.test.ts +0 -222
- package/src/graph-teams.ts +0 -114
- package/src/graph-thread.test.ts +0 -252
- package/src/graph-thread.ts +0 -146
- package/src/graph-upload.test.ts +0 -253
- package/src/graph-upload.ts +0 -531
- package/src/graph-users.ts +0 -29
- package/src/graph.test.ts +0 -540
- package/src/graph.ts +0 -308
- package/src/inbound.test.ts +0 -221
- package/src/inbound.ts +0 -148
- package/src/index.ts +0 -4
- package/src/media-helpers.test.ts +0 -220
- package/src/media-helpers.ts +0 -105
- package/src/mentions.test.ts +0 -254
- package/src/mentions.ts +0 -114
- package/src/messenger.test.ts +0 -961
- package/src/messenger.ts +0 -608
- package/src/monitor-handler/access.ts +0 -136
- package/src/monitor-handler/inbound-media.test.ts +0 -314
- package/src/monitor-handler/inbound-media.ts +0 -180
- package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
- package/src/monitor-handler/message-handler.authz.test.ts +0 -739
- package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
- package/src/monitor-handler/message-handler.test-support.ts +0 -99
- package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -225
- package/src/monitor-handler/message-handler.thread-session.test.ts +0 -132
- package/src/monitor-handler/message-handler.ts +0 -1003
- package/src/monitor-handler/reaction-handler.test.ts +0 -325
- package/src/monitor-handler/reaction-handler.ts +0 -122
- package/src/monitor-handler/thread-session.ts +0 -30
- package/src/monitor-handler.adaptive-card.test.ts +0 -158
- package/src/monitor-handler.feedback-authz.test.ts +0 -357
- package/src/monitor-handler.file-consent.test.ts +0 -443
- package/src/monitor-handler.sso.test.ts +0 -576
- package/src/monitor-handler.test-helpers.ts +0 -181
- package/src/monitor-handler.ts +0 -538
- package/src/monitor-handler.types.ts +0 -27
- package/src/monitor-types.ts +0 -6
- package/src/monitor.lifecycle.test.ts +0 -457
- package/src/monitor.test.ts +0 -119
- package/src/monitor.ts +0 -476
- package/src/oauth.flow.ts +0 -77
- package/src/oauth.shared.ts +0 -37
- package/src/oauth.test.ts +0 -350
- package/src/oauth.token.ts +0 -162
- package/src/oauth.ts +0 -130
- package/src/outbound.test.ts +0 -400
- package/src/outbound.ts +0 -198
- package/src/pending-uploads-fs.test.ts +0 -261
- package/src/pending-uploads-fs.ts +0 -235
- package/src/pending-uploads.test.ts +0 -186
- package/src/pending-uploads.ts +0 -121
- package/src/policy.test.ts +0 -156
- package/src/policy.ts +0 -245
- package/src/polls-store-memory.ts +0 -32
- package/src/polls.test.ts +0 -169
- package/src/polls.ts +0 -312
- package/src/presentation.ts +0 -93
- package/src/probe.test.ts +0 -79
- package/src/probe.ts +0 -132
- package/src/reply-dispatcher.test.ts +0 -543
- package/src/reply-dispatcher.ts +0 -523
- package/src/reply-stream-controller.test.ts +0 -424
- package/src/reply-stream-controller.ts +0 -334
- package/src/resolve-allowlist.test.ts +0 -253
- package/src/resolve-allowlist.ts +0 -309
- package/src/revoked-context.ts +0 -17
- package/src/runtime.ts +0 -12
- package/src/sdk-types.ts +0 -59
- package/src/sdk.test.ts +0 -727
- package/src/sdk.ts +0 -916
- package/src/secret-contract.ts +0 -49
- package/src/secret-input.ts +0 -7
- package/src/send-context.test.ts +0 -93
- package/src/send-context.ts +0 -269
- package/src/send.test.ts +0 -588
- package/src/send.ts +0 -697
- package/src/sent-message-cache.test.ts +0 -106
- package/src/sent-message-cache.ts +0 -174
- package/src/session-route.ts +0 -40
- package/src/setup-core.ts +0 -162
- package/src/setup-surface.test.ts +0 -175
- package/src/setup-surface.ts +0 -319
- package/src/sso-token-store.test.ts +0 -74
- package/src/sso-token-store.ts +0 -166
- package/src/sso.ts +0 -300
- package/src/storage.ts +0 -25
- package/src/store-fs.ts +0 -42
- package/src/streaming-message.test.ts +0 -323
- package/src/streaming-message.ts +0 -327
- package/src/test-runtime.ts +0 -16
- package/src/thread-parent-context.test.ts +0 -224
- package/src/thread-parent-context.ts +0 -159
- package/src/token-response.ts +0 -11
- package/src/token.test.ts +0 -268
- package/src/token.ts +0 -194
- package/src/user-agent.test.ts +0 -121
- package/src/user-agent.ts +0 -53
- package/src/webhook-timeouts.ts +0 -27
- package/src/welcome-card.test.ts +0 -104
- package/src/welcome-card.ts +0 -57
- package/test-api.ts +0 -1
- package/tsconfig.json +0 -16
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDirectoryTestRuntime,
|
|
3
|
-
expectDirectorySurface,
|
|
4
|
-
} from "klaw/plugin-sdk/channel-test-helpers";
|
|
5
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import type { KlawConfig, RuntimeEnv } from "../runtime-api.js";
|
|
7
|
-
import { msteamsPlugin } from "./channel.js";
|
|
8
|
-
import { resolveMSTeamsOutboundSessionRoute } from "./session-route.js";
|
|
9
|
-
|
|
10
|
-
const msteamsDirectoryAdapter = msteamsPlugin.directory;
|
|
11
|
-
|
|
12
|
-
function requireDirectorySelf(): NonNullable<NonNullable<typeof msteamsDirectoryAdapter>["self"]> {
|
|
13
|
-
const directorySelf = msteamsDirectoryAdapter?.self;
|
|
14
|
-
if (!directorySelf) {
|
|
15
|
-
throw new Error("expected msteams directory.self");
|
|
16
|
-
}
|
|
17
|
-
return directorySelf;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe("msteams directory", () => {
|
|
21
|
-
const runtimeEnv = createDirectoryTestRuntime() as RuntimeEnv;
|
|
22
|
-
const directorySelf = requireDirectorySelf();
|
|
23
|
-
|
|
24
|
-
afterEach(() => {
|
|
25
|
-
vi.unstubAllEnvs();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe("self()", () => {
|
|
29
|
-
it("returns bot identity when credentials are configured", async () => {
|
|
30
|
-
const cfg = {
|
|
31
|
-
channels: {
|
|
32
|
-
msteams: {
|
|
33
|
-
appId: "test-app-id-1234",
|
|
34
|
-
appPassword: "secret",
|
|
35
|
-
tenantId: "tenant-id-5678",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
} as unknown as KlawConfig;
|
|
39
|
-
|
|
40
|
-
const result = await directorySelf({ cfg, runtime: runtimeEnv });
|
|
41
|
-
expect(result).toEqual({ kind: "user", id: "test-app-id-1234", name: "test-app-id-1234" });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("returns null when credentials are not configured", async () => {
|
|
45
|
-
vi.stubEnv("MSTEAMS_APP_ID", "");
|
|
46
|
-
vi.stubEnv("MSTEAMS_APP_PASSWORD", "");
|
|
47
|
-
vi.stubEnv("MSTEAMS_TENANT_ID", "");
|
|
48
|
-
const cfg = { channels: {} } as unknown as KlawConfig;
|
|
49
|
-
const result = await directorySelf({ cfg, runtime: runtimeEnv });
|
|
50
|
-
expect(result).toBeNull();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("lists peers and groups from config", async () => {
|
|
55
|
-
const cfg = {
|
|
56
|
-
channels: {
|
|
57
|
-
msteams: {
|
|
58
|
-
allowFrom: ["alice", "user:Bob"],
|
|
59
|
-
dms: { carol: {}, bob: {} },
|
|
60
|
-
teams: {
|
|
61
|
-
team1: {
|
|
62
|
-
channels: {
|
|
63
|
-
"conversation:chan1": {},
|
|
64
|
-
chan2: {},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
} as unknown as KlawConfig;
|
|
71
|
-
|
|
72
|
-
const directory = expectDirectorySurface(msteamsDirectoryAdapter);
|
|
73
|
-
|
|
74
|
-
const peers = await directory.listPeers({
|
|
75
|
-
cfg,
|
|
76
|
-
query: undefined,
|
|
77
|
-
limit: undefined,
|
|
78
|
-
runtime: runtimeEnv,
|
|
79
|
-
});
|
|
80
|
-
expect(peers).toStrictEqual([
|
|
81
|
-
{ kind: "user", id: "user:alice" },
|
|
82
|
-
{ kind: "user", id: "user:Bob" },
|
|
83
|
-
{ kind: "user", id: "user:carol" },
|
|
84
|
-
{ kind: "user", id: "user:bob" },
|
|
85
|
-
]);
|
|
86
|
-
|
|
87
|
-
const groups = await directory.listGroups({
|
|
88
|
-
cfg,
|
|
89
|
-
query: undefined,
|
|
90
|
-
limit: undefined,
|
|
91
|
-
runtime: runtimeEnv,
|
|
92
|
-
});
|
|
93
|
-
expect(groups).toStrictEqual([
|
|
94
|
-
{ kind: "group", id: "conversation:chan1" },
|
|
95
|
-
{ kind: "group", id: "conversation:chan2" },
|
|
96
|
-
]);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("normalizes spaced allowlist and dm entries", async () => {
|
|
100
|
-
const cfg = {
|
|
101
|
-
channels: {
|
|
102
|
-
msteams: {
|
|
103
|
-
allowFrom: [" user:Bob ", " Alice "],
|
|
104
|
-
dms: { " Carol ": {}, "user:Dave": {} },
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
} as unknown as KlawConfig;
|
|
108
|
-
|
|
109
|
-
const directory = expectDirectorySurface(msteamsDirectoryAdapter);
|
|
110
|
-
|
|
111
|
-
const peers = await directory.listPeers({
|
|
112
|
-
cfg,
|
|
113
|
-
query: undefined,
|
|
114
|
-
limit: undefined,
|
|
115
|
-
runtime: runtimeEnv,
|
|
116
|
-
});
|
|
117
|
-
expect(peers).toStrictEqual([
|
|
118
|
-
{ kind: "user", id: "user:Bob" },
|
|
119
|
-
{ kind: "user", id: "user:Alice" },
|
|
120
|
-
{ kind: "user", id: "user:Carol" },
|
|
121
|
-
{ kind: "user", id: "user:Dave" },
|
|
122
|
-
]);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe("msteams session route", () => {
|
|
127
|
-
it("builds direct routes for explicit user targets", () => {
|
|
128
|
-
const route = resolveMSTeamsOutboundSessionRoute({
|
|
129
|
-
cfg: {},
|
|
130
|
-
agentId: "main",
|
|
131
|
-
accountId: "default",
|
|
132
|
-
target: "msteams:user:alice-id",
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
expect(route?.peer).toEqual({ kind: "direct", id: "alice-id" });
|
|
136
|
-
expect(route?.from).toBe("msteams:alice-id");
|
|
137
|
-
expect(route?.to).toBe("user:alice-id");
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("builds channel routes for thread conversations and strips suffix metadata", () => {
|
|
141
|
-
const route = resolveMSTeamsOutboundSessionRoute({
|
|
142
|
-
cfg: {},
|
|
143
|
-
agentId: "main",
|
|
144
|
-
accountId: "default",
|
|
145
|
-
target: "teams:19:abc123@thread.tacv2;messageid=42",
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
expect(route?.peer).toEqual({ kind: "channel", id: "19:abc123@thread.tacv2" });
|
|
149
|
-
expect(route?.from).toBe("msteams:channel:19:abc123@thread.tacv2");
|
|
150
|
-
expect(route?.to).toBe("conversation:19:abc123@thread.tacv2");
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("returns group routes for non-user, non-channel conversations", () => {
|
|
154
|
-
const route = resolveMSTeamsOutboundSessionRoute({
|
|
155
|
-
cfg: {},
|
|
156
|
-
agentId: "main",
|
|
157
|
-
accountId: "default",
|
|
158
|
-
target: "msteams:conversation:19:groupchat",
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
expect(route?.peer).toEqual({ kind: "group", id: "19:groupchat" });
|
|
162
|
-
expect(route?.from).toBe("msteams:group:19:groupchat");
|
|
163
|
-
expect(route?.to).toBe("conversation:19:groupchat");
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it("returns null when the target cannot be normalized", () => {
|
|
167
|
-
expect(
|
|
168
|
-
resolveMSTeamsOutboundSessionRoute({
|
|
169
|
-
cfg: {},
|
|
170
|
-
agentId: "main",
|
|
171
|
-
accountId: "default",
|
|
172
|
-
target: "msteams:",
|
|
173
|
-
}),
|
|
174
|
-
).toBeNull();
|
|
175
|
-
});
|
|
176
|
-
});
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
verifyChannelMessageAdapterCapabilityProofs,
|
|
3
|
-
verifyChannelMessageLiveCapabilityAdapterProofs,
|
|
4
|
-
verifyChannelMessageLiveFinalizerProofs,
|
|
5
|
-
} from "klaw/plugin-sdk/channel-message";
|
|
6
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
-
import type { KlawConfig } from "../runtime-api.js";
|
|
8
|
-
|
|
9
|
-
const mocks = vi.hoisted(() => ({
|
|
10
|
-
sendText: vi.fn(),
|
|
11
|
-
sendMedia: vi.fn(),
|
|
12
|
-
sendPayload: vi.fn(),
|
|
13
|
-
sendPoll: vi.fn(),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
vi.mock("./channel.runtime.js", () => ({
|
|
17
|
-
msTeamsChannelRuntime: {
|
|
18
|
-
msteamsOutbound: {
|
|
19
|
-
sendText: mocks.sendText,
|
|
20
|
-
sendMedia: mocks.sendMedia,
|
|
21
|
-
sendPayload: mocks.sendPayload,
|
|
22
|
-
sendPoll: mocks.sendPoll,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
import { msteamsPlugin } from "./channel.js";
|
|
28
|
-
|
|
29
|
-
type MSTeamsMessageAdapter = NonNullable<typeof msteamsPlugin.message>;
|
|
30
|
-
type MSTeamsMessageSender = NonNullable<MSTeamsMessageAdapter["send"]>;
|
|
31
|
-
|
|
32
|
-
function requireMSTeamsMessageAdapter(): MSTeamsMessageAdapter {
|
|
33
|
-
const adapter = msteamsPlugin.message;
|
|
34
|
-
if (!adapter) {
|
|
35
|
-
throw new Error("Expected msteams channel message adapter");
|
|
36
|
-
}
|
|
37
|
-
return adapter;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function requireTextSender(
|
|
41
|
-
adapter: MSTeamsMessageAdapter,
|
|
42
|
-
): NonNullable<MSTeamsMessageSender["text"]> {
|
|
43
|
-
const text = adapter.send?.text;
|
|
44
|
-
if (!text) {
|
|
45
|
-
throw new Error("Expected msteams message adapter text sender");
|
|
46
|
-
}
|
|
47
|
-
return text;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function requireMediaSender(
|
|
51
|
-
adapter: MSTeamsMessageAdapter,
|
|
52
|
-
): NonNullable<MSTeamsMessageSender["media"]> {
|
|
53
|
-
const media = adapter.send?.media;
|
|
54
|
-
if (!media) {
|
|
55
|
-
throw new Error("Expected msteams message adapter media sender");
|
|
56
|
-
}
|
|
57
|
-
return media;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function requirePayloadSender(
|
|
61
|
-
adapter: MSTeamsMessageAdapter,
|
|
62
|
-
): NonNullable<MSTeamsMessageSender["payload"]> {
|
|
63
|
-
const payload = adapter.send?.payload;
|
|
64
|
-
if (!payload) {
|
|
65
|
-
throw new Error("Expected msteams message adapter payload sender");
|
|
66
|
-
}
|
|
67
|
-
return payload;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const cfg = {
|
|
71
|
-
channels: {
|
|
72
|
-
msteams: {
|
|
73
|
-
appId: "resolved-app-id",
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
} as KlawConfig;
|
|
77
|
-
|
|
78
|
-
describe("msteams channel message adapter", () => {
|
|
79
|
-
beforeEach(() => {
|
|
80
|
-
mocks.sendText.mockReset();
|
|
81
|
-
mocks.sendMedia.mockReset();
|
|
82
|
-
mocks.sendPayload.mockReset();
|
|
83
|
-
mocks.sendPoll.mockReset();
|
|
84
|
-
mocks.sendText.mockResolvedValue({
|
|
85
|
-
channel: "msteams",
|
|
86
|
-
messageId: "msg-1",
|
|
87
|
-
conversationId: "conv-1",
|
|
88
|
-
});
|
|
89
|
-
mocks.sendMedia.mockResolvedValue({
|
|
90
|
-
channel: "msteams",
|
|
91
|
-
messageId: "msg-media-1",
|
|
92
|
-
conversationId: "conv-1",
|
|
93
|
-
});
|
|
94
|
-
mocks.sendPayload.mockResolvedValue({
|
|
95
|
-
channel: "msteams",
|
|
96
|
-
messageId: "msg-payload-1",
|
|
97
|
-
conversationId: "conv-1",
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("backs declared durable-final capabilities with outbound send proofs", async () => {
|
|
102
|
-
const adapter = requireMSTeamsMessageAdapter();
|
|
103
|
-
const sendText = requireTextSender(adapter);
|
|
104
|
-
const sendMedia = requireMediaSender(adapter);
|
|
105
|
-
const sendPayload = requirePayloadSender(adapter);
|
|
106
|
-
expect(adapter.durableFinal?.capabilities?.replyTo).toBeUndefined();
|
|
107
|
-
expect(adapter.durableFinal?.capabilities?.thread).toBeUndefined();
|
|
108
|
-
|
|
109
|
-
const proveText = async () => {
|
|
110
|
-
mocks.sendText.mockClear();
|
|
111
|
-
const result = await sendText({
|
|
112
|
-
cfg,
|
|
113
|
-
to: "conversation:abc",
|
|
114
|
-
text: "hello",
|
|
115
|
-
accountId: "default",
|
|
116
|
-
});
|
|
117
|
-
expect(mocks.sendText).toHaveBeenLastCalledWith({
|
|
118
|
-
cfg,
|
|
119
|
-
to: "conversation:abc",
|
|
120
|
-
text: "hello",
|
|
121
|
-
accountId: "default",
|
|
122
|
-
});
|
|
123
|
-
expect(result.receipt.platformMessageIds).toEqual(["msg-1"]);
|
|
124
|
-
expect(result.receipt.parts[0]?.kind).toBe("text");
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const proveMedia = async () => {
|
|
128
|
-
mocks.sendMedia.mockClear();
|
|
129
|
-
const result = await sendMedia({
|
|
130
|
-
cfg,
|
|
131
|
-
to: "conversation:abc",
|
|
132
|
-
text: "photo",
|
|
133
|
-
mediaUrl: "file:///tmp/photo.png",
|
|
134
|
-
mediaLocalRoots: ["/tmp"],
|
|
135
|
-
accountId: "default",
|
|
136
|
-
});
|
|
137
|
-
expect(mocks.sendMedia).toHaveBeenLastCalledWith({
|
|
138
|
-
cfg,
|
|
139
|
-
to: "conversation:abc",
|
|
140
|
-
text: "photo",
|
|
141
|
-
mediaUrl: "file:///tmp/photo.png",
|
|
142
|
-
mediaLocalRoots: ["/tmp"],
|
|
143
|
-
accountId: "default",
|
|
144
|
-
});
|
|
145
|
-
expect(result.receipt.platformMessageIds).toEqual(["msg-media-1"]);
|
|
146
|
-
expect(result.receipt.parts[0]?.kind).toBe("media");
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const provePayload = async () => {
|
|
150
|
-
mocks.sendPayload.mockClear();
|
|
151
|
-
const payload = {
|
|
152
|
-
presentation: {
|
|
153
|
-
blocks: [{ type: "text" as const, text: "card body" }],
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
const result = await sendPayload({
|
|
157
|
-
cfg,
|
|
158
|
-
to: "conversation:abc",
|
|
159
|
-
text: "",
|
|
160
|
-
payload,
|
|
161
|
-
accountId: "default",
|
|
162
|
-
});
|
|
163
|
-
expect(mocks.sendPayload).toHaveBeenLastCalledWith({
|
|
164
|
-
cfg,
|
|
165
|
-
to: "conversation:abc",
|
|
166
|
-
text: "",
|
|
167
|
-
payload,
|
|
168
|
-
accountId: "default",
|
|
169
|
-
});
|
|
170
|
-
expect(result.receipt.platformMessageIds).toEqual(["msg-payload-1"]);
|
|
171
|
-
expect(result.receipt.parts[0]?.kind).toBe("card");
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
await verifyChannelMessageAdapterCapabilityProofs({
|
|
175
|
-
adapterName: "msteamsMessageAdapter",
|
|
176
|
-
adapter,
|
|
177
|
-
proofs: {
|
|
178
|
-
text: proveText,
|
|
179
|
-
media: proveMedia,
|
|
180
|
-
payload: provePayload,
|
|
181
|
-
messageSendingHooks: () => {
|
|
182
|
-
expect(sendText).toBeTypeOf("function");
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("backs declared live preview finalizer capabilities with adapter proofs", async () => {
|
|
189
|
-
const adapter = requireMSTeamsMessageAdapter();
|
|
190
|
-
const sendText = requireTextSender(adapter);
|
|
191
|
-
|
|
192
|
-
await verifyChannelMessageLiveCapabilityAdapterProofs({
|
|
193
|
-
adapterName: "msteamsMessageAdapter",
|
|
194
|
-
adapter,
|
|
195
|
-
proofs: {
|
|
196
|
-
draftPreview: () => {
|
|
197
|
-
expect(adapter.live?.capabilities?.nativeStreaming).toBe(true);
|
|
198
|
-
},
|
|
199
|
-
previewFinalization: () => {
|
|
200
|
-
expect(adapter.live?.finalizer?.capabilities?.finalEdit).toBe(true);
|
|
201
|
-
},
|
|
202
|
-
progressUpdates: () => {
|
|
203
|
-
expect(adapter.live?.capabilities?.draftPreview).toBe(true);
|
|
204
|
-
},
|
|
205
|
-
nativeStreaming: () => {
|
|
206
|
-
expect(adapter.live?.finalizer?.capabilities?.previewReceipt).toBe(true);
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
await verifyChannelMessageLiveFinalizerProofs({
|
|
212
|
-
adapterName: "msteamsMessageAdapter",
|
|
213
|
-
adapter,
|
|
214
|
-
proofs: {
|
|
215
|
-
finalEdit: () => {
|
|
216
|
-
expect(adapter.live?.capabilities?.previewFinalization).toBe(true);
|
|
217
|
-
},
|
|
218
|
-
normalFallback: () => {
|
|
219
|
-
expect(sendText).toBeTypeOf("function");
|
|
220
|
-
},
|
|
221
|
-
previewReceipt: () => {
|
|
222
|
-
expect(adapter.live?.capabilities?.nativeStreaming).toBe(true);
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
});
|
package/src/channel.runtime.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
listMSTeamsDirectoryGroupsLive as listMSTeamsDirectoryGroupsLiveImpl,
|
|
3
|
-
listMSTeamsDirectoryPeersLive as listMSTeamsDirectoryPeersLiveImpl,
|
|
4
|
-
} from "./directory-live.js";
|
|
5
|
-
import {
|
|
6
|
-
addParticipantMSTeams as addParticipantMSTeamsImpl,
|
|
7
|
-
removeParticipantMSTeams as removeParticipantMSTeamsImpl,
|
|
8
|
-
renameGroupMSTeams as renameGroupMSTeamsImpl,
|
|
9
|
-
} from "./graph-group-management.js";
|
|
10
|
-
import { getMemberInfoMSTeams as getMemberInfoMSTeamsImpl } from "./graph-members.js";
|
|
11
|
-
import {
|
|
12
|
-
getMessageMSTeams as getMessageMSTeamsImpl,
|
|
13
|
-
listPinsMSTeams as listPinsMSTeamsImpl,
|
|
14
|
-
listReactionsMSTeams as listReactionsMSTeamsImpl,
|
|
15
|
-
pinMessageMSTeams as pinMessageMSTeamsImpl,
|
|
16
|
-
reactMessageMSTeams as reactMessageMSTeamsImpl,
|
|
17
|
-
searchMessagesMSTeams as searchMessagesMSTeamsImpl,
|
|
18
|
-
unpinMessageMSTeams as unpinMessageMSTeamsImpl,
|
|
19
|
-
unreactMessageMSTeams as unreactMessageMSTeamsImpl,
|
|
20
|
-
} from "./graph-messages.js";
|
|
21
|
-
import {
|
|
22
|
-
listChannelsMSTeams as listChannelsMSTeamsImpl,
|
|
23
|
-
getChannelInfoMSTeams as getChannelInfoMSTeamsImpl,
|
|
24
|
-
} from "./graph-teams.js";
|
|
25
|
-
import { msteamsOutbound as msteamsOutboundImpl } from "./outbound.js";
|
|
26
|
-
import { probeMSTeams as probeMSTeamsImpl } from "./probe.js";
|
|
27
|
-
import {
|
|
28
|
-
deleteMessageMSTeams as deleteMessageMSTeamsImpl,
|
|
29
|
-
editMessageMSTeams as editMessageMSTeamsImpl,
|
|
30
|
-
sendAdaptiveCardMSTeams as sendAdaptiveCardMSTeamsImpl,
|
|
31
|
-
sendMessageMSTeams as sendMessageMSTeamsImpl,
|
|
32
|
-
} from "./send.js";
|
|
33
|
-
export const msTeamsChannelRuntime = {
|
|
34
|
-
addParticipantMSTeams: addParticipantMSTeamsImpl,
|
|
35
|
-
deleteMessageMSTeams: deleteMessageMSTeamsImpl,
|
|
36
|
-
editMessageMSTeams: editMessageMSTeamsImpl,
|
|
37
|
-
getChannelInfoMSTeams: getChannelInfoMSTeamsImpl,
|
|
38
|
-
getMemberInfoMSTeams: getMemberInfoMSTeamsImpl,
|
|
39
|
-
getMessageMSTeams: getMessageMSTeamsImpl,
|
|
40
|
-
listChannelsMSTeams: listChannelsMSTeamsImpl,
|
|
41
|
-
listPinsMSTeams: listPinsMSTeamsImpl,
|
|
42
|
-
listReactionsMSTeams: listReactionsMSTeamsImpl,
|
|
43
|
-
pinMessageMSTeams: pinMessageMSTeamsImpl,
|
|
44
|
-
reactMessageMSTeams: reactMessageMSTeamsImpl,
|
|
45
|
-
removeParticipantMSTeams: removeParticipantMSTeamsImpl,
|
|
46
|
-
renameGroupMSTeams: renameGroupMSTeamsImpl,
|
|
47
|
-
searchMessagesMSTeams: searchMessagesMSTeamsImpl,
|
|
48
|
-
unpinMessageMSTeams: unpinMessageMSTeamsImpl,
|
|
49
|
-
unreactMessageMSTeams: unreactMessageMSTeamsImpl,
|
|
50
|
-
listMSTeamsDirectoryGroupsLive: listMSTeamsDirectoryGroupsLiveImpl,
|
|
51
|
-
listMSTeamsDirectoryPeersLive: listMSTeamsDirectoryPeersLiveImpl,
|
|
52
|
-
msteamsOutbound: { ...msteamsOutboundImpl },
|
|
53
|
-
probeMSTeams: probeMSTeamsImpl,
|
|
54
|
-
sendAdaptiveCardMSTeams: sendAdaptiveCardMSTeamsImpl,
|
|
55
|
-
sendMessageMSTeams: sendMessageMSTeamsImpl,
|
|
56
|
-
};
|
package/src/channel.setup.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { describeAccountSnapshot } from "klaw/plugin-sdk/account-helpers";
|
|
2
|
-
import { formatAllowFromLowercase } from "klaw/plugin-sdk/allow-from";
|
|
3
|
-
import { createTopLevelChannelConfigAdapter } from "klaw/plugin-sdk/channel-config-helpers";
|
|
4
|
-
import type { ChannelPlugin } from "klaw/plugin-sdk/channel-core";
|
|
5
|
-
import type { KlawConfig } from "klaw/plugin-sdk/config-contracts";
|
|
6
|
-
import { MSTeamsChannelConfigSchema } from "./config-schema.js";
|
|
7
|
-
import { msteamsSetupAdapter } from "./setup-core.js";
|
|
8
|
-
import { msteamsSetupWizard } from "./setup-surface.js";
|
|
9
|
-
import { resolveMSTeamsCredentials } from "./token.js";
|
|
10
|
-
|
|
11
|
-
type ResolvedMSTeamsAccount = {
|
|
12
|
-
accountId: string;
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
configured: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const meta = {
|
|
18
|
-
id: "msteams",
|
|
19
|
-
label: "Microsoft Teams",
|
|
20
|
-
selectionLabel: "Microsoft Teams (Bot Framework)",
|
|
21
|
-
docsPath: "/channels/msteams",
|
|
22
|
-
docsLabel: "msteams",
|
|
23
|
-
blurb: "Teams SDK; enterprise support.",
|
|
24
|
-
aliases: ["teams"],
|
|
25
|
-
order: 60,
|
|
26
|
-
} as const;
|
|
27
|
-
|
|
28
|
-
const resolveMSTeamsChannelConfig = (cfg: KlawConfig) => ({
|
|
29
|
-
allowFrom: cfg.channels?.msteams?.allowFrom,
|
|
30
|
-
defaultTo: cfg.channels?.msteams?.defaultTo,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const msteamsConfigAdapter = createTopLevelChannelConfigAdapter<
|
|
34
|
-
ResolvedMSTeamsAccount,
|
|
35
|
-
{
|
|
36
|
-
allowFrom?: Array<string | number>;
|
|
37
|
-
defaultTo?: string;
|
|
38
|
-
}
|
|
39
|
-
>({
|
|
40
|
-
sectionKey: "msteams",
|
|
41
|
-
resolveAccount: (cfg) => ({
|
|
42
|
-
accountId: "default",
|
|
43
|
-
enabled: cfg.channels?.msteams?.enabled !== false,
|
|
44
|
-
configured: Boolean(resolveMSTeamsCredentials(cfg.channels?.msteams)),
|
|
45
|
-
}),
|
|
46
|
-
resolveAccessorAccount: ({ cfg }) => resolveMSTeamsChannelConfig(cfg),
|
|
47
|
-
resolveAllowFrom: (account) => account.allowFrom,
|
|
48
|
-
formatAllowFrom: (allowFrom) => formatAllowFromLowercase({ allowFrom }),
|
|
49
|
-
resolveDefaultTo: (account) => account.defaultTo,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
export const msteamsSetupPlugin: ChannelPlugin<ResolvedMSTeamsAccount> = {
|
|
53
|
-
id: "msteams",
|
|
54
|
-
meta: {
|
|
55
|
-
...meta,
|
|
56
|
-
aliases: [...meta.aliases],
|
|
57
|
-
},
|
|
58
|
-
capabilities: {
|
|
59
|
-
chatTypes: ["direct", "channel", "thread"],
|
|
60
|
-
polls: true,
|
|
61
|
-
threads: true,
|
|
62
|
-
media: true,
|
|
63
|
-
},
|
|
64
|
-
reload: { configPrefixes: ["channels.msteams"] },
|
|
65
|
-
configSchema: MSTeamsChannelConfigSchema,
|
|
66
|
-
config: {
|
|
67
|
-
...msteamsConfigAdapter,
|
|
68
|
-
isConfigured: (_account, cfg) => Boolean(resolveMSTeamsCredentials(cfg.channels?.msteams)),
|
|
69
|
-
describeAccount: (account) =>
|
|
70
|
-
describeAccountSnapshot({
|
|
71
|
-
account,
|
|
72
|
-
configured: account.configured,
|
|
73
|
-
}),
|
|
74
|
-
},
|
|
75
|
-
setupWizard: msteamsSetupWizard,
|
|
76
|
-
setup: msteamsSetupAdapter,
|
|
77
|
-
};
|
package/src/channel.test.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import type { KlawConfig } from "klaw/plugin-sdk/config-contracts";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { MSTeamsConfigSchema } from "../config-api.js";
|
|
4
|
-
import { msTeamsApprovalAuth } from "./approval-auth.js";
|
|
5
|
-
import { msteamsPlugin } from "./channel.js";
|
|
6
|
-
|
|
7
|
-
function createConfiguredMSTeamsCfg(): KlawConfig {
|
|
8
|
-
return {
|
|
9
|
-
channels: {
|
|
10
|
-
msteams: {
|
|
11
|
-
appId: "app-id",
|
|
12
|
-
appPassword: "secret",
|
|
13
|
-
tenantId: "tenant-id",
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
describe("msteamsPlugin", () => {
|
|
20
|
-
it("exposes approval auth through approvalCapability", () => {
|
|
21
|
-
expect(msteamsPlugin.approvalCapability).toBe(msTeamsApprovalAuth);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("advertises legacy and group-management message-tool actions together", () => {
|
|
25
|
-
const actions = msteamsPlugin.actions?.describeMessageTool?.({
|
|
26
|
-
cfg: createConfiguredMSTeamsCfg(),
|
|
27
|
-
})?.actions;
|
|
28
|
-
|
|
29
|
-
expect(actions).toEqual([
|
|
30
|
-
"upload-file",
|
|
31
|
-
"poll",
|
|
32
|
-
"edit",
|
|
33
|
-
"delete",
|
|
34
|
-
"pin",
|
|
35
|
-
"unpin",
|
|
36
|
-
"list-pins",
|
|
37
|
-
"read",
|
|
38
|
-
"react",
|
|
39
|
-
"reactions",
|
|
40
|
-
"search",
|
|
41
|
-
"member-info",
|
|
42
|
-
"channel-list",
|
|
43
|
-
"channel-info",
|
|
44
|
-
"addParticipant",
|
|
45
|
-
"removeParticipant",
|
|
46
|
-
"renameGroup",
|
|
47
|
-
]);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("reuses the shared Teams target-id matcher for explicit targets", () => {
|
|
51
|
-
const looksLikeId = msteamsPlugin.messaging?.targetResolver?.looksLikeId;
|
|
52
|
-
|
|
53
|
-
expect(looksLikeId?.("29:1a2b3c4d5e6f")).toBe(true);
|
|
54
|
-
expect(looksLikeId?.("a:1bfPersonalChat")).toBe(true);
|
|
55
|
-
expect(looksLikeId?.("user:Jane Doe")).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe("msteams config schema", () => {
|
|
60
|
-
it("defaults groupPolicy to allowlist", () => {
|
|
61
|
-
const res = MSTeamsConfigSchema.safeParse({});
|
|
62
|
-
|
|
63
|
-
expect(res.success).toBe(true);
|
|
64
|
-
if (res.success) {
|
|
65
|
-
expect(res.data.groupPolicy).toBe("allowlist");
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("accepts historyLimit", () => {
|
|
70
|
-
const res = MSTeamsConfigSchema.safeParse({ historyLimit: 4 });
|
|
71
|
-
|
|
72
|
-
expect(res.success).toBe(true);
|
|
73
|
-
if (res.success) {
|
|
74
|
-
expect(res.data.historyLimit).toBe(4);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("accepts replyStyle at global/team/channel levels", () => {
|
|
79
|
-
const res = MSTeamsConfigSchema.safeParse({
|
|
80
|
-
replyStyle: "top-level",
|
|
81
|
-
teams: {
|
|
82
|
-
team123: {
|
|
83
|
-
replyStyle: "thread",
|
|
84
|
-
channels: {
|
|
85
|
-
chan456: { replyStyle: "top-level" },
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
expect(res.success).toBe(true);
|
|
92
|
-
if (res.success) {
|
|
93
|
-
expect(res.data.replyStyle).toBe("top-level");
|
|
94
|
-
expect(res.data.teams?.team123?.replyStyle).toBe("thread");
|
|
95
|
-
expect(res.data.teams?.team123?.channels?.chan456?.replyStyle).toBe("top-level");
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("rejects invalid replyStyle", () => {
|
|
100
|
-
const res = MSTeamsConfigSchema.safeParse({
|
|
101
|
-
replyStyle: "nope",
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
expect(res.success).toBe(false);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe("msTeamsApprovalAuth", () => {
|
|
109
|
-
it("authorizes stable Teams user ids and ignores display-name allowlists", () => {
|
|
110
|
-
expect(
|
|
111
|
-
msTeamsApprovalAuth.authorizeActorAction({
|
|
112
|
-
cfg: {
|
|
113
|
-
channels: {
|
|
114
|
-
msteams: {
|
|
115
|
-
allowFrom: ["user:123e4567-e89b-12d3-a456-426614174000"],
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
senderId: "123e4567-e89b-12d3-a456-426614174000",
|
|
120
|
-
action: "approve",
|
|
121
|
-
approvalKind: "exec",
|
|
122
|
-
}),
|
|
123
|
-
).toEqual({ authorized: true });
|
|
124
|
-
|
|
125
|
-
expect(
|
|
126
|
-
msTeamsApprovalAuth.authorizeActorAction({
|
|
127
|
-
cfg: {
|
|
128
|
-
channels: { msteams: { allowFrom: ["Owner Display"] } },
|
|
129
|
-
},
|
|
130
|
-
senderId: "attacker-aad",
|
|
131
|
-
action: "approve",
|
|
132
|
-
approvalKind: "exec",
|
|
133
|
-
}),
|
|
134
|
-
).toEqual({ authorized: true });
|
|
135
|
-
});
|
|
136
|
-
});
|