@openclaw/msteams 2026.5.2 → 2026.5.3-beta.1
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/dist/api.js +3 -0
- package/dist/channel-D7hdreTh.js +984 -0
- package/dist/channel-config-api.js +2 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-BC1ruIfN.js +573 -0
- package/dist/config-schema-B8QezH6t.js +15 -0
- package/dist/contract-api.js +2 -0
- package/dist/graph-users-9uQJepqr.js +1354 -0
- package/dist/index.js +22 -0
- package/dist/oauth-BWJyilR1.js +114 -0
- package/dist/oauth.token-xxpoLWy5.js +115 -0
- package/dist/policy-DTnU2GR7.js +142 -0
- package/dist/probe-D_H8yFps.js +2194 -0
- package/dist/resolve-allowlist-D41JSziq.js +219 -0
- package/dist/runtime-api-DV1iVMn1.js +28 -0
- package/dist/runtime-api.js +2 -0
- package/dist/secret-contract-BuoEXmPS.js +35 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/setup-entry.js +15 -0
- package/dist/setup-plugin-api.js +64 -0
- package/dist/setup-surface-BLkFQYIQ.js +313 -0
- package/dist/src-CFp1QpFd.js +4064 -0
- package/dist/test-api.js +2 -0
- package/package.json +14 -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 -73
- 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 -461
- package/src/attachments/bot-framework.ts +0 -362
- package/src/attachments/download.ts +0 -311
- package/src/attachments/graph.test.ts +0 -416
- package/src/attachments/graph.ts +0 -484
- package/src/attachments/html.ts +0 -122
- package/src/attachments/payload.ts +0 -14
- package/src/attachments/remote-media.test.ts +0 -137
- package/src/attachments/remote-media.ts +0 -112
- package/src/attachments/shared.test.ts +0 -530
- package/src/attachments/shared.ts +0 -626
- package/src/attachments/types.ts +0 -47
- package/src/attachments.graph.test.ts +0 -342
- package/src/attachments.helpers.test.ts +0 -246
- package/src/attachments.test-helpers.ts +0 -17
- package/src/attachments.test.ts +0 -687
- 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 -742
- package/src/channel.directory.test.ts +0 -200
- package/src/channel.runtime.ts +0 -56
- package/src/channel.setup.ts +0 -77
- package/src/channel.test.ts +0 -128
- package/src/channel.ts +0 -1136
- package/src/config-schema.ts +0 -6
- package/src/config-ui-hints.ts +0 -12
- package/src/conversation-store-fs.test.ts +0 -74
- 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 -225
- 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 -133
- package/src/errors.ts +0 -246
- package/src/feedback-reflection-prompt.ts +0 -117
- package/src/feedback-reflection-store.ts +0 -114
- package/src/feedback-reflection.test.ts +0 -237
- package/src/feedback-reflection.ts +0 -283
- package/src/file-consent-helpers.test.ts +0 -326
- package/src/file-consent-helpers.ts +0 -126
- package/src/file-consent-invoke.ts +0 -150
- package/src/file-consent.test.ts +0 -363
- package/src/file-consent.ts +0 -287
- package/src/graph-chat.ts +0 -55
- package/src/graph-group-management.test.ts +0 -318
- 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 -243
- package/src/graph-messages.read.test.ts +0 -391
- package/src/graph-messages.search.test.ts +0 -213
- package/src/graph-messages.test-helpers.ts +0 -50
- package/src/graph-messages.ts +0 -534
- package/src/graph-teams.test.ts +0 -215
- package/src/graph-teams.ts +0 -114
- package/src/graph-thread.test.ts +0 -246
- package/src/graph-thread.ts +0 -146
- package/src/graph-upload.test.ts +0 -258
- package/src/graph-upload.ts +0 -531
- package/src/graph-users.ts +0 -29
- package/src/graph.test.ts +0 -516
- package/src/graph.ts +0 -293
- 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 -202
- package/src/media-helpers.ts +0 -105
- package/src/mentions.test.ts +0 -244
- package/src/mentions.ts +0 -114
- package/src/messenger.test.ts +0 -865
- package/src/messenger.ts +0 -605
- package/src/monitor-handler/access.ts +0 -125
- package/src/monitor-handler/inbound-media.test.ts +0 -289
- 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 -669
- package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
- package/src/monitor-handler/message-handler.test-support.ts +0 -100
- package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -223
- package/src/monitor-handler/message-handler.thread-session.test.ts +0 -77
- package/src/monitor-handler/message-handler.ts +0 -1000
- package/src/monitor-handler/reaction-handler.test.ts +0 -267
- package/src/monitor-handler/reaction-handler.ts +0 -210
- package/src/monitor-handler/thread-session.ts +0 -17
- package/src/monitor-handler.adaptive-card.test.ts +0 -162
- package/src/monitor-handler.feedback-authz.test.ts +0 -314
- package/src/monitor-handler.file-consent.test.ts +0 -423
- package/src/monitor-handler.sso.test.ts +0 -563
- package/src/monitor-handler.test-helpers.ts +0 -180
- package/src/monitor-handler.ts +0 -534
- package/src/monitor-handler.types.ts +0 -27
- package/src/monitor-types.ts +0 -6
- package/src/monitor.lifecycle.test.ts +0 -278
- package/src/monitor.test.ts +0 -119
- package/src/monitor.ts +0 -442
- package/src/oauth.flow.ts +0 -77
- package/src/oauth.shared.ts +0 -37
- package/src/oauth.test.ts +0 -305
- package/src/oauth.token.ts +0 -158
- package/src/oauth.ts +0 -130
- package/src/outbound.test.ts +0 -130
- package/src/outbound.ts +0 -71
- package/src/pending-uploads-fs.test.ts +0 -246
- package/src/pending-uploads-fs.ts +0 -235
- package/src/pending-uploads.test.ts +0 -173
- package/src/pending-uploads.ts +0 -121
- package/src/policy.test.ts +0 -240
- package/src/policy.ts +0 -262
- package/src/polls-store-memory.ts +0 -32
- package/src/polls.test.ts +0 -160
- package/src/polls.ts +0 -323
- package/src/presentation.ts +0 -68
- package/src/probe.test.ts +0 -77
- package/src/probe.ts +0 -132
- package/src/reply-dispatcher.test.ts +0 -437
- package/src/reply-dispatcher.ts +0 -346
- package/src/reply-stream-controller.test.ts +0 -235
- package/src/reply-stream-controller.ts +0 -147
- package/src/resolve-allowlist.test.ts +0 -250
- package/src/resolve-allowlist.ts +0 -309
- package/src/revoked-context.ts +0 -17
- package/src/runtime.ts +0 -9
- package/src/sdk-types.ts +0 -59
- package/src/sdk.test.ts +0 -666
- package/src/sdk.ts +0 -884
- package/src/secret-contract.ts +0 -49
- package/src/secret-input.ts +0 -7
- package/src/send-context.ts +0 -231
- package/src/send.test.ts +0 -493
- package/src/send.ts +0 -637
- package/src/sent-message-cache.test.ts +0 -15
- package/src/sent-message-cache.ts +0 -56
- package/src/session-route.ts +0 -40
- package/src/setup-core.ts +0 -160
- package/src/setup-surface.test.ts +0 -202
- package/src/setup-surface.ts +0 -320
- package/src/sso-token-store.test.ts +0 -72
- 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 -44
- package/src/streaming-message.test.ts +0 -262
- package/src/streaming-message.ts +0 -297
- 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 -259
- package/src/token.ts +0 -195
- package/src/user-agent.test.ts +0 -86
- package/src/user-agent.ts +0 -53
- package/src/webhook-timeouts.ts +0 -27
- package/src/welcome-card.test.ts +0 -81
- package/src/welcome-card.ts +0 -57
- package/test-api.ts +0 -1
- package/tsconfig.json +0 -16
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDirectoryTestRuntime,
|
|
3
|
-
expectDirectorySurface,
|
|
4
|
-
} from "openclaw/plugin-sdk/channel-test-helpers";
|
|
5
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import type { OpenClawConfig, 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 OpenClawConfig;
|
|
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 OpenClawConfig;
|
|
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 OpenClawConfig;
|
|
71
|
-
|
|
72
|
-
const directory = expectDirectorySurface(msteamsDirectoryAdapter);
|
|
73
|
-
|
|
74
|
-
await expect(
|
|
75
|
-
directory.listPeers({
|
|
76
|
-
cfg,
|
|
77
|
-
query: undefined,
|
|
78
|
-
limit: undefined,
|
|
79
|
-
runtime: runtimeEnv,
|
|
80
|
-
}),
|
|
81
|
-
).resolves.toEqual(
|
|
82
|
-
expect.arrayContaining([
|
|
83
|
-
{ kind: "user", id: "user:alice" },
|
|
84
|
-
{ kind: "user", id: "user:Bob" },
|
|
85
|
-
{ kind: "user", id: "user:carol" },
|
|
86
|
-
{ kind: "user", id: "user:bob" },
|
|
87
|
-
]),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
await expect(
|
|
91
|
-
directory.listGroups({
|
|
92
|
-
cfg,
|
|
93
|
-
query: undefined,
|
|
94
|
-
limit: undefined,
|
|
95
|
-
runtime: runtimeEnv,
|
|
96
|
-
}),
|
|
97
|
-
).resolves.toEqual(
|
|
98
|
-
expect.arrayContaining([
|
|
99
|
-
{ kind: "group", id: "conversation:chan1" },
|
|
100
|
-
{ kind: "group", id: "conversation:chan2" },
|
|
101
|
-
]),
|
|
102
|
-
);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("normalizes spaced allowlist and dm entries", async () => {
|
|
106
|
-
const cfg = {
|
|
107
|
-
channels: {
|
|
108
|
-
msteams: {
|
|
109
|
-
allowFrom: [" user:Bob ", " Alice "],
|
|
110
|
-
dms: { " Carol ": {}, "user:Dave": {} },
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
} as unknown as OpenClawConfig;
|
|
114
|
-
|
|
115
|
-
const directory = expectDirectorySurface(msteamsDirectoryAdapter);
|
|
116
|
-
|
|
117
|
-
await expect(
|
|
118
|
-
directory.listPeers({
|
|
119
|
-
cfg,
|
|
120
|
-
query: undefined,
|
|
121
|
-
limit: undefined,
|
|
122
|
-
runtime: runtimeEnv,
|
|
123
|
-
}),
|
|
124
|
-
).resolves.toEqual(
|
|
125
|
-
expect.arrayContaining([
|
|
126
|
-
{ kind: "user", id: "user:Bob" },
|
|
127
|
-
{ kind: "user", id: "user:Alice" },
|
|
128
|
-
{ kind: "user", id: "user:Carol" },
|
|
129
|
-
{ kind: "user", id: "user:Dave" },
|
|
130
|
-
]),
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe("msteams session route", () => {
|
|
136
|
-
it("builds direct routes for explicit user targets", () => {
|
|
137
|
-
const route = resolveMSTeamsOutboundSessionRoute({
|
|
138
|
-
cfg: {},
|
|
139
|
-
agentId: "main",
|
|
140
|
-
accountId: "default",
|
|
141
|
-
target: "msteams:user:alice-id",
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
expect(route).toMatchObject({
|
|
145
|
-
peer: {
|
|
146
|
-
kind: "direct",
|
|
147
|
-
id: "alice-id",
|
|
148
|
-
},
|
|
149
|
-
from: "msteams:alice-id",
|
|
150
|
-
to: "user:alice-id",
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("builds channel routes for thread conversations and strips suffix metadata", () => {
|
|
155
|
-
const route = resolveMSTeamsOutboundSessionRoute({
|
|
156
|
-
cfg: {},
|
|
157
|
-
agentId: "main",
|
|
158
|
-
accountId: "default",
|
|
159
|
-
target: "teams:19:abc123@thread.tacv2;messageid=42",
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
expect(route).toMatchObject({
|
|
163
|
-
peer: {
|
|
164
|
-
kind: "channel",
|
|
165
|
-
id: "19:abc123@thread.tacv2",
|
|
166
|
-
},
|
|
167
|
-
from: "msteams:channel:19:abc123@thread.tacv2",
|
|
168
|
-
to: "conversation:19:abc123@thread.tacv2",
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("returns group routes for non-user, non-channel conversations", () => {
|
|
173
|
-
const route = resolveMSTeamsOutboundSessionRoute({
|
|
174
|
-
cfg: {},
|
|
175
|
-
agentId: "main",
|
|
176
|
-
accountId: "default",
|
|
177
|
-
target: "msteams:conversation:19:groupchat",
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
expect(route).toMatchObject({
|
|
181
|
-
peer: {
|
|
182
|
-
kind: "group",
|
|
183
|
-
id: "19:groupchat",
|
|
184
|
-
},
|
|
185
|
-
from: "msteams:group:19:groupchat",
|
|
186
|
-
to: "conversation:19:groupchat",
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("returns null when the target cannot be normalized", () => {
|
|
191
|
-
expect(
|
|
192
|
-
resolveMSTeamsOutboundSessionRoute({
|
|
193
|
-
cfg: {},
|
|
194
|
-
agentId: "main",
|
|
195
|
-
accountId: "default",
|
|
196
|
-
target: "msteams:",
|
|
197
|
-
}),
|
|
198
|
-
).toBeNull();
|
|
199
|
-
});
|
|
200
|
-
});
|
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 "openclaw/plugin-sdk/account-helpers";
|
|
2
|
-
import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from";
|
|
3
|
-
import { createTopLevelChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
4
|
-
import type { ChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
5
|
-
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
|
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: OpenClawConfig) => ({
|
|
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,128 +0,0 @@
|
|
|
1
|
-
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
|
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(): OpenClawConfig {
|
|
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
|
-
expect.arrayContaining([
|
|
31
|
-
"upload-file",
|
|
32
|
-
"member-info",
|
|
33
|
-
"channel-list",
|
|
34
|
-
"channel-info",
|
|
35
|
-
"addParticipant",
|
|
36
|
-
"removeParticipant",
|
|
37
|
-
"renameGroup",
|
|
38
|
-
]),
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("reuses the shared Teams target-id matcher for explicit targets", () => {
|
|
43
|
-
const looksLikeId = msteamsPlugin.messaging?.targetResolver?.looksLikeId;
|
|
44
|
-
|
|
45
|
-
expect(looksLikeId?.("29:1a2b3c4d5e6f")).toBe(true);
|
|
46
|
-
expect(looksLikeId?.("a:1bfPersonalChat")).toBe(true);
|
|
47
|
-
expect(looksLikeId?.("user:Jane Doe")).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe("msteams config schema", () => {
|
|
52
|
-
it("defaults groupPolicy to allowlist", () => {
|
|
53
|
-
const res = MSTeamsConfigSchema.safeParse({});
|
|
54
|
-
|
|
55
|
-
expect(res.success).toBe(true);
|
|
56
|
-
if (res.success) {
|
|
57
|
-
expect(res.data.groupPolicy).toBe("allowlist");
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("accepts historyLimit", () => {
|
|
62
|
-
const res = MSTeamsConfigSchema.safeParse({ historyLimit: 4 });
|
|
63
|
-
|
|
64
|
-
expect(res.success).toBe(true);
|
|
65
|
-
if (res.success) {
|
|
66
|
-
expect(res.data.historyLimit).toBe(4);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("accepts replyStyle at global/team/channel levels", () => {
|
|
71
|
-
const res = MSTeamsConfigSchema.safeParse({
|
|
72
|
-
replyStyle: "top-level",
|
|
73
|
-
teams: {
|
|
74
|
-
team123: {
|
|
75
|
-
replyStyle: "thread",
|
|
76
|
-
channels: {
|
|
77
|
-
chan456: { replyStyle: "top-level" },
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
expect(res.success).toBe(true);
|
|
84
|
-
if (res.success) {
|
|
85
|
-
expect(res.data.replyStyle).toBe("top-level");
|
|
86
|
-
expect(res.data.teams?.team123?.replyStyle).toBe("thread");
|
|
87
|
-
expect(res.data.teams?.team123?.channels?.chan456?.replyStyle).toBe("top-level");
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("rejects invalid replyStyle", () => {
|
|
92
|
-
const res = MSTeamsConfigSchema.safeParse({
|
|
93
|
-
replyStyle: "nope",
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
expect(res.success).toBe(false);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe("msTeamsApprovalAuth", () => {
|
|
101
|
-
it("authorizes stable Teams user ids and ignores display-name allowlists", () => {
|
|
102
|
-
expect(
|
|
103
|
-
msTeamsApprovalAuth.authorizeActorAction({
|
|
104
|
-
cfg: {
|
|
105
|
-
channels: {
|
|
106
|
-
msteams: {
|
|
107
|
-
allowFrom: ["user:123e4567-e89b-12d3-a456-426614174000"],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
senderId: "123e4567-e89b-12d3-a456-426614174000",
|
|
112
|
-
action: "approve",
|
|
113
|
-
approvalKind: "exec",
|
|
114
|
-
}),
|
|
115
|
-
).toEqual({ authorized: true });
|
|
116
|
-
|
|
117
|
-
expect(
|
|
118
|
-
msTeamsApprovalAuth.authorizeActorAction({
|
|
119
|
-
cfg: {
|
|
120
|
-
channels: { msteams: { allowFrom: ["Owner Display"] } },
|
|
121
|
-
},
|
|
122
|
-
senderId: "attacker-aad",
|
|
123
|
-
action: "approve",
|
|
124
|
-
approvalKind: "exec",
|
|
125
|
-
}),
|
|
126
|
-
).toEqual({ authorized: true });
|
|
127
|
-
});
|
|
128
|
-
});
|