@openclaw/msteams 2026.8.1-beta.2 → 2026.8.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/{adapter.runtime-DEYjslFX.cjs → adapter.runtime-8g-MOPfb.cjs} +4 -2
- package/dist/api.cjs +6 -6
- package/dist/approval-card-B6ZIMO83.cjs +303 -0
- package/dist/approval-handler.runtime-B-ZA6Vjp.cjs +107 -0
- package/dist/{channel-DfCbi0d_.cjs → channel-ChmCvkuA.cjs} +174 -106
- package/dist/channel-config-api.cjs +1 -1
- package/dist/channel-plugin-api.cjs +1 -1
- package/dist/{channel.runtime-BJmueA4q.cjs → channel.runtime-D3qqruU3.cjs} +38 -598
- package/dist/{setup-surface-DAhGL2h8.cjs → channel.setup-CKb8aKCV.cjs} +89 -36
- package/dist/{config-schema-C4CszdDi.cjs → config-schema-MyN2lamA.cjs} +12 -11
- package/dist/configured-state.cjs +20 -0
- package/dist/directory-contract-api.cjs +1 -1
- package/dist/doctor-contract-api.cjs +76 -39
- package/dist/{messenger-BqA8G3pY.cjs → messenger-Ctb9_CO7.cjs} +46 -188
- package/dist/{oauth-DktsbN22.cjs → oauth-BV7HWGe0.cjs} +2 -2
- package/dist/qa-runner-api.cjs +1 -1
- package/dist/reaction-types-DtWOWuDN.cjs +149 -0
- package/dist/{resolve-allowlist-C6YcNC9a.cjs → resolve-allowlist-CWbvAW4v.cjs} +90 -114
- package/dist/runtime-api.cjs +3 -2
- package/dist/secret-input-C65t6kjM.cjs +1 -0
- package/dist/send-Bym7IH-v.cjs +627 -0
- package/dist/setup-plugin-api.cjs +2 -36
- package/dist/{src-Bz9wY0Mr.cjs → src-BGhvpEOP.cjs} +244 -110
- package/dist/thread-session-Br3R0ovy.cjs +63 -0
- package/package.json +13 -11
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
|
|
2
2
|
let openclaw_plugin_sdk_ssrf_runtime = require("openclaw/plugin-sdk/ssrf-runtime");
|
|
3
|
-
let openclaw_plugin_sdk_error_runtime = require("openclaw/plugin-sdk/error-runtime");
|
|
4
3
|
let node_crypto = require("node:crypto");
|
|
5
4
|
let node_fs_promises = require("node:fs/promises");
|
|
6
5
|
node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises, 1);
|
|
7
6
|
let node_path = require("node:path");
|
|
8
7
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
8
|
+
let openclaw_plugin_sdk_error_runtime = require("openclaw/plugin-sdk/error-runtime");
|
|
9
9
|
let node_timers_promises = require("node:timers/promises");
|
|
10
10
|
let node_url = require("node:url");
|
|
11
11
|
let node_events = require("node:events");
|
|
12
12
|
let node_http = require("node:http");
|
|
13
13
|
//#region extensions/msteams/src/qa/bot-framework-server.ts
|
|
14
|
+
const AMBIGUOUS_GATEWAY_TIMEOUT_MARKER = "QA-MSTEAMS-AMBIGUOUS-504";
|
|
14
15
|
async function readJson(request) {
|
|
15
16
|
const chunks = [];
|
|
16
17
|
for await (const chunk of request) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
@@ -53,7 +54,8 @@ async function startMSTeamsQaBotFrameworkServer(options) {
|
|
|
53
54
|
conversationId: route.conversationId,
|
|
54
55
|
...route.threadId ? { threadId: route.threadId } : {}
|
|
55
56
|
});
|
|
56
|
-
|
|
57
|
+
const acceptedButTimedOut = typeof activity.text === "string" && activity.text.includes(AMBIGUOUS_GATEWAY_TIMEOUT_MARKER);
|
|
58
|
+
sendJson(response, acceptedButTimedOut ? 504 : 200, acceptedButTimedOut ? { error: "gateway timeout after acceptance" } : { id: activityId });
|
|
57
59
|
})().catch((error) => {
|
|
58
60
|
sendJson(response, 500, { error: (0, openclaw_plugin_sdk_error_runtime.coerceErrorMessage)(error) });
|
|
59
61
|
});
|
package/dist/api.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_channel = require("./channel-
|
|
3
|
-
const
|
|
4
|
-
exports.createMSTeamsSetupWizardBase =
|
|
2
|
+
const require_channel = require("./channel-ChmCvkuA.cjs");
|
|
3
|
+
const require_channel_setup = require("./channel.setup-CKb8aKCV.cjs");
|
|
4
|
+
exports.createMSTeamsSetupWizardBase = require_channel_setup.createMSTeamsSetupWizardBase;
|
|
5
5
|
exports.msteamsPlugin = require_channel.msteamsPlugin;
|
|
6
|
-
exports.msteamsSetupAdapter =
|
|
7
|
-
exports.msteamsSetupWizard =
|
|
8
|
-
exports.openDelegatedOAuthUrl =
|
|
6
|
+
exports.msteamsSetupAdapter = require_channel_setup.msteamsSetupAdapter;
|
|
7
|
+
exports.msteamsSetupWizard = require_channel_setup.msteamsSetupWizard;
|
|
8
|
+
exports.openDelegatedOAuthUrl = require_channel_setup.openDelegatedOAuthUrl;
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
|
|
2
|
+
let openclaw_plugin_sdk_string_coerce_runtime = require("openclaw/plugin-sdk/string-coerce-runtime");
|
|
3
|
+
let node_crypto = require("node:crypto");
|
|
4
|
+
node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
|
|
5
|
+
let openclaw_plugin_sdk_collection_runtime = require("openclaw/plugin-sdk/collection-runtime");
|
|
6
|
+
//#region extensions/msteams/src/approval-card-actions.ts
|
|
7
|
+
const approvalCardBindings = /* @__PURE__ */ new Map();
|
|
8
|
+
const approvalCardResolvingTokens = /* @__PURE__ */ new Set();
|
|
9
|
+
const MSTEAMS_APPROVAL_CARD_BINDING_MAX_ENTRIES = 1024;
|
|
10
|
+
function createMSTeamsApprovalToken() {
|
|
11
|
+
return node_crypto.default.randomBytes(18).toString("base64url");
|
|
12
|
+
}
|
|
13
|
+
function readMSTeamsApprovalActionToken(value) {
|
|
14
|
+
if (!(0, openclaw_plugin_sdk_string_coerce_runtime.isRecord)(value)) return null;
|
|
15
|
+
const action = (0, openclaw_plugin_sdk_string_coerce_runtime.isRecord)(value.action) ? value.action : void 0;
|
|
16
|
+
const submitted = action && (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeOptionalLowercaseString)(action.type) === "action.submit" && (0, openclaw_plugin_sdk_string_coerce_runtime.isRecord)(action.data) ? action.data : value;
|
|
17
|
+
if (submitted.openclawAction !== "approval") return null;
|
|
18
|
+
return (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeOptionalString)(submitted.token) ?? null;
|
|
19
|
+
}
|
|
20
|
+
function registerMSTeamsApprovalCardBinding(binding) {
|
|
21
|
+
if (binding.expiresAtMs <= Date.now()) return false;
|
|
22
|
+
approvalCardBindings.delete(binding.token);
|
|
23
|
+
approvalCardBindings.set(binding.token, binding);
|
|
24
|
+
(0, openclaw_plugin_sdk_collection_runtime.pruneMapToMaxSize)(approvalCardBindings, MSTEAMS_APPROVAL_CARD_BINDING_MAX_ENTRIES);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
function getMSTeamsApprovalCardBinding(token) {
|
|
28
|
+
const binding = approvalCardBindings.get(token);
|
|
29
|
+
if (!binding) return null;
|
|
30
|
+
if (binding.expiresAtMs <= Date.now()) {
|
|
31
|
+
approvalCardBindings.delete(token);
|
|
32
|
+
approvalCardResolvingTokens.delete(token);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return binding;
|
|
36
|
+
}
|
|
37
|
+
function claimMSTeamsApprovalCardBinding(token) {
|
|
38
|
+
const binding = getMSTeamsApprovalCardBinding(token);
|
|
39
|
+
if (!binding) return { kind: "missing" };
|
|
40
|
+
if (approvalCardResolvingTokens.has(token)) return { kind: "in-flight" };
|
|
41
|
+
approvalCardResolvingTokens.add(token);
|
|
42
|
+
return {
|
|
43
|
+
kind: "claimed",
|
|
44
|
+
binding
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function completeMSTeamsApprovalCardBinding(token) {
|
|
48
|
+
approvalCardResolvingTokens.delete(token);
|
|
49
|
+
approvalCardBindings.delete(token);
|
|
50
|
+
}
|
|
51
|
+
function releaseMSTeamsApprovalCardBinding(token) {
|
|
52
|
+
approvalCardResolvingTokens.delete(token);
|
|
53
|
+
}
|
|
54
|
+
function unregisterMSTeamsApprovalCardBindings(tokens) {
|
|
55
|
+
for (const token of tokens) completeMSTeamsApprovalCardBinding(token);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region extensions/msteams/src/approval-card.ts
|
|
59
|
+
function buildCardHeading(title, subtitle) {
|
|
60
|
+
return [{
|
|
61
|
+
type: "TextBlock",
|
|
62
|
+
text: title,
|
|
63
|
+
weight: "Bolder",
|
|
64
|
+
size: "Medium",
|
|
65
|
+
wrap: true
|
|
66
|
+
}, {
|
|
67
|
+
type: "TextBlock",
|
|
68
|
+
text: subtitle,
|
|
69
|
+
isSubtle: true,
|
|
70
|
+
wrap: true
|
|
71
|
+
}];
|
|
72
|
+
}
|
|
73
|
+
function buildApprovalSubject(view) {
|
|
74
|
+
if (view.approvalKind === "exec") return [
|
|
75
|
+
{
|
|
76
|
+
type: "TextBlock",
|
|
77
|
+
text: "Command",
|
|
78
|
+
weight: "Bolder",
|
|
79
|
+
wrap: true
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: "TextBlock",
|
|
83
|
+
text: view.commandText,
|
|
84
|
+
fontType: "Monospace",
|
|
85
|
+
wrap: true
|
|
86
|
+
},
|
|
87
|
+
...view.commandPreview && view.commandPreview !== view.commandText ? [{
|
|
88
|
+
type: "TextBlock",
|
|
89
|
+
text: "Preview",
|
|
90
|
+
weight: "Bolder",
|
|
91
|
+
wrap: true
|
|
92
|
+
}, {
|
|
93
|
+
type: "TextBlock",
|
|
94
|
+
text: view.commandPreview,
|
|
95
|
+
fontType: "Monospace",
|
|
96
|
+
wrap: true
|
|
97
|
+
}] : []
|
|
98
|
+
];
|
|
99
|
+
return [
|
|
100
|
+
{
|
|
101
|
+
type: "TextBlock",
|
|
102
|
+
text: "Request",
|
|
103
|
+
weight: "Bolder",
|
|
104
|
+
wrap: true
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: "TextBlock",
|
|
108
|
+
text: view.title,
|
|
109
|
+
weight: "Bolder",
|
|
110
|
+
wrap: true
|
|
111
|
+
},
|
|
112
|
+
...view.description ? [{
|
|
113
|
+
type: "TextBlock",
|
|
114
|
+
text: view.description,
|
|
115
|
+
wrap: true
|
|
116
|
+
}] : []
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
function buildApprovalMetadata(approvalId, metadata) {
|
|
120
|
+
return {
|
|
121
|
+
type: "FactSet",
|
|
122
|
+
facts: [{
|
|
123
|
+
title: "Approval ID:",
|
|
124
|
+
value: approvalId
|
|
125
|
+
}].concat(metadata.map(({ label, value }) => ({
|
|
126
|
+
title: `${label}:`,
|
|
127
|
+
value
|
|
128
|
+
})))
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function buildAdaptiveCard(body, actions) {
|
|
132
|
+
return {
|
|
133
|
+
type: "AdaptiveCard",
|
|
134
|
+
version: "1.5",
|
|
135
|
+
body,
|
|
136
|
+
...actions?.length ? { actions } : {}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function formatApprovalDecision(decision) {
|
|
140
|
+
return decision === "allow-once" ? "Allowed once" : decision === "allow-always" ? "Allowed always" : "Denied";
|
|
141
|
+
}
|
|
142
|
+
function buildMSTeamsPendingApprovalCard(params) {
|
|
143
|
+
const { view, nowMs } = params;
|
|
144
|
+
const kindLabel = view.approvalKind === "plugin" ? "Plugin" : "Exec";
|
|
145
|
+
const actionTokens = [];
|
|
146
|
+
const actions = view.actions.map(({ decision, label }) => {
|
|
147
|
+
const token = createMSTeamsApprovalToken();
|
|
148
|
+
actionTokens.push({
|
|
149
|
+
token,
|
|
150
|
+
decision
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
type: "Action.Submit",
|
|
154
|
+
title: label,
|
|
155
|
+
data: {
|
|
156
|
+
openclawAction: "approval",
|
|
157
|
+
token
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
const remainingSeconds = Math.max(0, Math.ceil((view.expiresAtMs - nowMs) / 1e3));
|
|
162
|
+
const body = [
|
|
163
|
+
...buildCardHeading(`${kindLabel} Approval Required`, `Expires in ${remainingSeconds}s`),
|
|
164
|
+
...buildApprovalSubject(view),
|
|
165
|
+
buildApprovalMetadata(view.approvalId, view.metadata)
|
|
166
|
+
];
|
|
167
|
+
return {
|
|
168
|
+
approvalId: view.approvalId,
|
|
169
|
+
approvalKind: view.approvalKind,
|
|
170
|
+
expiresAtMs: view.expiresAtMs,
|
|
171
|
+
card: buildAdaptiveCard(body, actions),
|
|
172
|
+
actionTokens,
|
|
173
|
+
allowedDecisions: view.actions.map(({ decision }) => decision)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function buildMSTeamsResolvedApprovalCard(view) {
|
|
177
|
+
const kindLabel = view.approvalKind === "plugin" ? "Plugin" : "Exec";
|
|
178
|
+
const resolvedBy = (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeOptionalString)(view.resolvedBy);
|
|
179
|
+
return buildAdaptiveCard([
|
|
180
|
+
...buildCardHeading(`${kindLabel} Approval: ${formatApprovalDecision(view.decision)}`, resolvedBy ? `Resolved by ${resolvedBy}` : "Resolved"),
|
|
181
|
+
...buildApprovalSubject(view),
|
|
182
|
+
buildApprovalMetadata(view.approvalId, view.metadata)
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
function buildMSTeamsExpiredApprovalCard(view) {
|
|
186
|
+
return buildAdaptiveCard([
|
|
187
|
+
...buildCardHeading(`${view.approvalKind === "plugin" ? "Plugin" : "Exec"} Approval Expired`, "This approval request expired before it was resolved."),
|
|
188
|
+
...buildApprovalSubject(view),
|
|
189
|
+
buildApprovalMetadata(view.approvalId, view.metadata)
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
function buildMSTeamsCanonicalApprovalTerminalCard(result) {
|
|
193
|
+
const { approval } = result;
|
|
194
|
+
const { presentation } = approval;
|
|
195
|
+
const kindLabel = presentation.kind === "exec" ? "Exec" : presentation.kind === "plugin" ? "Plugin" : "System Agent";
|
|
196
|
+
const outcome = approval.status === "allowed" ? formatApprovalDecision(approval.decision) : approval.status === "denied" ? "Denied" : approval.status === "expired" ? "Expired" : "Cancelled";
|
|
197
|
+
const subject = presentation.kind === "exec" ? [{
|
|
198
|
+
type: "TextBlock",
|
|
199
|
+
text: "Command",
|
|
200
|
+
weight: "Bolder",
|
|
201
|
+
wrap: true
|
|
202
|
+
}, {
|
|
203
|
+
type: "TextBlock",
|
|
204
|
+
text: presentation.commandPreview ?? presentation.commandText,
|
|
205
|
+
fontType: "Monospace",
|
|
206
|
+
wrap: true
|
|
207
|
+
}] : [{
|
|
208
|
+
type: "TextBlock",
|
|
209
|
+
text: presentation.title,
|
|
210
|
+
weight: "Bolder",
|
|
211
|
+
wrap: true
|
|
212
|
+
}, {
|
|
213
|
+
type: "TextBlock",
|
|
214
|
+
text: presentation.description,
|
|
215
|
+
wrap: true
|
|
216
|
+
}];
|
|
217
|
+
const metadata = [
|
|
218
|
+
{
|
|
219
|
+
label: "Status",
|
|
220
|
+
value: approval.status
|
|
221
|
+
},
|
|
222
|
+
..."decision" in approval ? [{
|
|
223
|
+
label: "Decision",
|
|
224
|
+
value: approval.decision
|
|
225
|
+
}] : [],
|
|
226
|
+
{
|
|
227
|
+
label: "Reason",
|
|
228
|
+
value: approval.reason
|
|
229
|
+
}
|
|
230
|
+
];
|
|
231
|
+
return buildAdaptiveCard([
|
|
232
|
+
...buildCardHeading(`${kindLabel} Approval: ${outcome}`, result.applied ? "Resolved by this action" : "Already resolved"),
|
|
233
|
+
...subject,
|
|
234
|
+
buildApprovalMetadata(approval.id, metadata)
|
|
235
|
+
]);
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
Object.defineProperty(exports, "buildMSTeamsCanonicalApprovalTerminalCard", {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
get: function() {
|
|
241
|
+
return buildMSTeamsCanonicalApprovalTerminalCard;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
Object.defineProperty(exports, "buildMSTeamsExpiredApprovalCard", {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: function() {
|
|
247
|
+
return buildMSTeamsExpiredApprovalCard;
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
Object.defineProperty(exports, "buildMSTeamsPendingApprovalCard", {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
get: function() {
|
|
253
|
+
return buildMSTeamsPendingApprovalCard;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(exports, "buildMSTeamsResolvedApprovalCard", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function() {
|
|
259
|
+
return buildMSTeamsResolvedApprovalCard;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(exports, "claimMSTeamsApprovalCardBinding", {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: function() {
|
|
265
|
+
return claimMSTeamsApprovalCardBinding;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(exports, "completeMSTeamsApprovalCardBinding", {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
get: function() {
|
|
271
|
+
return completeMSTeamsApprovalCardBinding;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(exports, "getMSTeamsApprovalCardBinding", {
|
|
275
|
+
enumerable: true,
|
|
276
|
+
get: function() {
|
|
277
|
+
return getMSTeamsApprovalCardBinding;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
Object.defineProperty(exports, "readMSTeamsApprovalActionToken", {
|
|
281
|
+
enumerable: true,
|
|
282
|
+
get: function() {
|
|
283
|
+
return readMSTeamsApprovalActionToken;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
Object.defineProperty(exports, "registerMSTeamsApprovalCardBinding", {
|
|
287
|
+
enumerable: true,
|
|
288
|
+
get: function() {
|
|
289
|
+
return registerMSTeamsApprovalCardBinding;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
Object.defineProperty(exports, "releaseMSTeamsApprovalCardBinding", {
|
|
293
|
+
enumerable: true,
|
|
294
|
+
get: function() {
|
|
295
|
+
return releaseMSTeamsApprovalCardBinding;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
Object.defineProperty(exports, "unregisterMSTeamsApprovalCardBindings", {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
get: function() {
|
|
301
|
+
return unregisterMSTeamsApprovalCardBindings;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const require_resolve_allowlist = require("./resolve-allowlist-CWbvAW4v.cjs");
|
|
2
|
+
const require_channel = require("./channel-ChmCvkuA.cjs");
|
|
3
|
+
const require_approval_card = require("./approval-card-B6ZIMO83.cjs");
|
|
4
|
+
const require_send = require("./send-Bym7IH-v.cjs");
|
|
5
|
+
let openclaw_plugin_sdk_account_id = require("openclaw/plugin-sdk/account-id");
|
|
6
|
+
let openclaw_plugin_sdk_approval_native_runtime = require("openclaw/plugin-sdk/approval-native-runtime");
|
|
7
|
+
let openclaw_plugin_sdk_approval_handler_runtime = require("openclaw/plugin-sdk/approval-handler-runtime");
|
|
8
|
+
//#region extensions/msteams/src/approval-handler.runtime.ts
|
|
9
|
+
const log = (0, require("openclaw/plugin-sdk/runtime-env").createSubsystemLogger)("msteams/approvals");
|
|
10
|
+
const msTeamsApprovalNativeRuntime = (0, openclaw_plugin_sdk_approval_handler_runtime.createChannelApprovalNativeRuntimeAdapter)({
|
|
11
|
+
eventKinds: ["exec", "plugin"],
|
|
12
|
+
availability: {
|
|
13
|
+
isConfigured: ({ cfg, accountId }) => require_channel.isMSTeamsNativeApprovalClientEnabled({
|
|
14
|
+
cfg,
|
|
15
|
+
accountId
|
|
16
|
+
}),
|
|
17
|
+
shouldHandle: ({ cfg, accountId, approvalKind, request }) => require_channel.shouldHandleMSTeamsNativeApprovalRequest({
|
|
18
|
+
cfg,
|
|
19
|
+
accountId,
|
|
20
|
+
approvalKind,
|
|
21
|
+
request
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
presentation: {
|
|
25
|
+
buildPendingPayload: ({ view, nowMs }) => require_approval_card.buildMSTeamsPendingApprovalCard({
|
|
26
|
+
view,
|
|
27
|
+
nowMs
|
|
28
|
+
}),
|
|
29
|
+
buildResolvedResult: ({ view }) => ({
|
|
30
|
+
kind: "update",
|
|
31
|
+
payload: require_approval_card.buildMSTeamsResolvedApprovalCard(view)
|
|
32
|
+
}),
|
|
33
|
+
buildExpiredResult: ({ view }) => ({
|
|
34
|
+
kind: "update",
|
|
35
|
+
payload: require_approval_card.buildMSTeamsExpiredApprovalCard(view)
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
transport: {
|
|
39
|
+
prepareTarget: ({ plannedTarget }) => {
|
|
40
|
+
const normalizedTarget = require_resolve_allowlist.normalizeMSTeamsMessagingTarget(plannedTarget.target.to);
|
|
41
|
+
if (!normalizedTarget) throw new Error("Microsoft Teams approval delivery target is missing");
|
|
42
|
+
const threadId = plannedTarget.target.threadId;
|
|
43
|
+
const to = threadId != null && require_channel.inferMSTeamsTargetChatType(normalizedTarget) === "channel" && !require_resolve_allowlist.extractMSTeamsConversationMessageId(normalizedTarget) ? `${normalizedTarget};messageid=${threadId}` : normalizedTarget;
|
|
44
|
+
return {
|
|
45
|
+
dedupeKey: (0, openclaw_plugin_sdk_approval_native_runtime.buildChannelApprovalNativeTargetKey)({
|
|
46
|
+
...plannedTarget.target,
|
|
47
|
+
to: normalizedTarget
|
|
48
|
+
}),
|
|
49
|
+
target: { to }
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
deliverPending: async ({ cfg, accountId, preparedTarget, pendingPayload }) => {
|
|
53
|
+
const sent = await require_send.sendAdaptiveCardMSTeams({
|
|
54
|
+
cfg,
|
|
55
|
+
to: preparedTarget.to,
|
|
56
|
+
card: pendingPayload.card
|
|
57
|
+
});
|
|
58
|
+
if (!sent.messageId || sent.messageId === "unknown" || !sent.conversationId) return null;
|
|
59
|
+
return {
|
|
60
|
+
accountId: accountId ?? openclaw_plugin_sdk_account_id.DEFAULT_ACCOUNT_ID,
|
|
61
|
+
conversationId: sent.conversationId,
|
|
62
|
+
activityId: sent.messageId,
|
|
63
|
+
actionTokens: pendingPayload.actionTokens
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
updateEntry: async ({ cfg, entry, payload }) => {
|
|
67
|
+
await require_send.editAdaptiveCardMSTeams({
|
|
68
|
+
cfg,
|
|
69
|
+
to: entry.conversationId,
|
|
70
|
+
activityId: entry.activityId,
|
|
71
|
+
card: payload
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
interactions: {
|
|
76
|
+
bindPending: ({ entry, request, approvalKind, view, pendingPayload }) => {
|
|
77
|
+
const tokens = [];
|
|
78
|
+
for (const actionToken of entry.actionTokens) if (require_approval_card.registerMSTeamsApprovalCardBinding({
|
|
79
|
+
token: actionToken.token,
|
|
80
|
+
accountId: entry.accountId,
|
|
81
|
+
approvalId: request.id,
|
|
82
|
+
approvalKind,
|
|
83
|
+
decision: actionToken.decision,
|
|
84
|
+
allowedDecisions: pendingPayload.allowedDecisions,
|
|
85
|
+
conversationId: entry.conversationId,
|
|
86
|
+
activityId: entry.activityId,
|
|
87
|
+
expiresAtMs: view.expiresAtMs
|
|
88
|
+
})) tokens.push(actionToken.token);
|
|
89
|
+
return tokens.length > 0 ? tokens : null;
|
|
90
|
+
},
|
|
91
|
+
unbindPending: ({ binding }) => require_approval_card.unregisterMSTeamsApprovalCardBindings(binding),
|
|
92
|
+
cancelDelivered: ({ entry }) => require_approval_card.unregisterMSTeamsApprovalCardBindings(entry.actionTokens.map(({ token }) => token))
|
|
93
|
+
},
|
|
94
|
+
observe: { onDeliveryError: ({ cfg, error, plannedTarget, request, approvalKind, pendingPayload }) => {
|
|
95
|
+
log.error(`msteams approvals: failed to deliver request ${request.id}: ${String(error)}`);
|
|
96
|
+
const decisions = pendingPayload.allowedDecisions.join("|");
|
|
97
|
+
require_send.sendMessageMSTeams({
|
|
98
|
+
cfg,
|
|
99
|
+
to: plannedTarget.target.to,
|
|
100
|
+
text: `⚠️ Could not deliver the ${approvalKind} approval card for ${request.id}. Reply "/approve ${request.id} <${decisions}>" to resolve it.`
|
|
101
|
+
}).catch((fallbackError) => {
|
|
102
|
+
log.error(`msteams approvals: fallback prompt for ${request.id} also failed: ${String(fallbackError)}`);
|
|
103
|
+
});
|
|
104
|
+
} }
|
|
105
|
+
});
|
|
106
|
+
//#endregion
|
|
107
|
+
exports.msTeamsApprovalNativeRuntime = msTeamsApprovalNativeRuntime;
|