@openclaw/msteams 2026.10.5-beta.4 → 2026.10.10-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{adapter.runtime-JoPydWqP.cjs → adapter.runtime-B-6Q3nMI.cjs} +6 -4
- package/dist/.setup/{approval-handler.runtime-bUN9icMr.cjs → approval-handler.runtime-DccVf5AY.cjs} +16 -6
- package/dist/.setup/{bot-framework-service-url-CPp4d-Q6.cjs → bot-framework-service-url-B3FWn2SV.cjs} +13 -0
- package/dist/.setup/{channel-Cifn9fsv.cjs → channel-B7Gy3QUW.cjs} +261 -175
- package/dist/.setup/{channel.runtime-DWRAolil.cjs → channel.runtime-DzKeQAqd.cjs} +84 -49
- package/dist/.setup/channel.setup-B5ClEcNI.cjs +990 -0
- package/dist/.setup/config-schema-CkKdphSp.cjs +293 -0
- package/dist/.setup/{conversation-store-state-DprmOfl7.cjs → conversation-store-state-C3__T9mK.cjs} +79 -91
- package/dist/.setup/delegated-state-Bv5cWuec.cjs +110 -0
- package/dist/.setup/{monitor-C9x_CJhY.cjs → monitor-CzRI-Hsc.cjs} +283 -240
- package/dist/.setup/{oauth-CWJ85AMw.cjs → oauth-D9u8sPCD.cjs} +1 -1
- package/dist/.setup/{reaction-types-Ig9sQJuR.cjs → reaction-types-DSQWVA4Z.cjs} +15 -9
- package/dist/.setup/{resolve-allowlist-DdDBVCzl.cjs → resolve-allowlist-tYgAHx0t.cjs} +252 -38
- package/dist/.setup/{secret-contract-api-ChQdBeU1.cjs → secret-contract-api-YY3v6MP8.cjs} +1 -1
- package/dist/.setup/secret-contract-api-wAyY5UHv.cjs +85 -0
- package/dist/.setup/{send-rJpcVtRp.cjs → send-Bgm8RYUa.cjs} +45 -24
- package/dist/.setup/{setup-plugin-api-DfoVOqMJ.cjs → setup-plugin-api-BACfeF7_.cjs} +1 -1
- package/dist/.setup/{thread-session-B74FC1Id.cjs → thread-session-C7KTMwLU.cjs} +11 -4
- package/dist/.setup/token-config-bEpua_Q7.cjs +93 -0
- package/dist/api.cjs +2 -2
- package/dist/channel-config-api.cjs +1 -1
- package/dist/channel-plugin-api.cjs +1 -1
- package/dist/directory-contract-api.cjs +30 -22
- package/dist/doctor-contract-api.cjs +11 -10
- package/dist/qa-runner-api.cjs +1 -1
- package/dist/runtime-api.cjs +2 -2
- package/dist/secret-contract-api.cjs +1 -1
- package/dist/setup-entry.cjs +2 -2
- package/dist/setup-plugin-api.cjs +1 -1
- package/openclaw.plugin.json +715 -0
- package/package.json +57 -6
- package/dist/.setup/channel.setup-BjbHugkL.cjs +0 -632
- package/dist/.setup/config-schema-Dk0mRIam.cjs +0 -160
- package/dist/.setup/secret-contract-api-ipiUsANg.cjs +0 -28
- package/dist/.setup/token-config-CqIh8z7Q.cjs +0 -138
package/dist/.setup/{conversation-store-state-DprmOfl7.cjs → conversation-store-state-C3__T9mK.cjs}
RENAMED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BloeesfJ.cjs");
|
|
2
|
+
const require_bot_framework_service_url = require("./bot-framework-service-url-B3FWn2SV.cjs");
|
|
3
|
+
const require_resolve_allowlist = require("./resolve-allowlist-tYgAHx0t.cjs");
|
|
2
4
|
const require_runtime = require("./runtime-gZTAuFux.cjs");
|
|
3
5
|
require("../runtime-api.cjs");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require_channel_setup = require("./channel.setup-BjbHugkL.cjs");
|
|
6
|
+
const require_delegated_state = require("./delegated-state-Bv5cWuec.cjs");
|
|
7
|
+
const require_channel_setup = require("./channel.setup-B5ClEcNI.cjs");
|
|
7
8
|
let openclaw_plugin_sdk_lazy_runtime = require("openclaw/plugin-sdk/lazy-runtime");
|
|
8
9
|
let openclaw_plugin_sdk_string_coerce_runtime = require("openclaw/plugin-sdk/string-coerce-runtime");
|
|
10
|
+
let openclaw_plugin_sdk_account_id = require("openclaw/plugin-sdk/account-id");
|
|
9
11
|
let openclaw_plugin_sdk_fetch_runtime = require("openclaw/plugin-sdk/fetch-runtime");
|
|
10
12
|
let openclaw_plugin_sdk_provider_http = require("openclaw/plugin-sdk/provider-http");
|
|
11
13
|
let openclaw_plugin_sdk_reply_payload = require("openclaw/plugin-sdk/reply-payload");
|
|
@@ -16,16 +18,14 @@ let openclaw_plugin_sdk_ssrf_policy = require("openclaw/plugin-sdk/ssrf-policy")
|
|
|
16
18
|
let openclaw_plugin_sdk_number_runtime = require("openclaw/plugin-sdk/number-runtime");
|
|
17
19
|
let openclaw_plugin_sdk_text_utility_runtime = require("openclaw/plugin-sdk/text-utility-runtime");
|
|
18
20
|
let openclaw_plugin_sdk_error_runtime = require("openclaw/plugin-sdk/error-runtime");
|
|
19
|
-
let
|
|
21
|
+
let node_crypto = require("node:crypto");
|
|
22
|
+
node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
|
|
20
23
|
let node_path = require("node:path");
|
|
21
24
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
25
|
+
let openclaw_plugin_sdk_retry_runtime = require("openclaw/plugin-sdk/retry-runtime");
|
|
22
26
|
let openclaw_plugin_sdk_runtime_env = require("openclaw/plugin-sdk/runtime-env");
|
|
23
27
|
let openclaw_plugin_sdk_markdown_table_runtime = require("openclaw/plugin-sdk/markdown-table-runtime");
|
|
24
28
|
let openclaw_plugin_sdk_blob_runtime = require("openclaw/plugin-sdk/blob-runtime");
|
|
25
|
-
let node_crypto = require("node:crypto");
|
|
26
|
-
node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
|
|
27
|
-
let openclaw_plugin_sdk_file_lock = require("openclaw/plugin-sdk/file-lock");
|
|
28
|
-
let openclaw_plugin_sdk_keyed_async_queue = require("openclaw/plugin-sdk/keyed-async-queue");
|
|
29
29
|
let openclaw_plugin_sdk_global_singleton = require("openclaw/plugin-sdk/global-singleton");
|
|
30
30
|
let openclaw_plugin_sdk_expect_runtime = require("openclaw/plugin-sdk/expect-runtime");
|
|
31
31
|
let openclaw_plugin_sdk_reply_chunking = require("openclaw/plugin-sdk/reply-chunking");
|
|
@@ -133,27 +133,6 @@ async function uploadToConsentUrl(params) {
|
|
|
133
133
|
if (!res.ok) throw new Error(`File upload to consent URL failed: ${res.status} ${res.statusText}`);
|
|
134
134
|
}
|
|
135
135
|
//#endregion
|
|
136
|
-
//#region extensions/msteams/src/sqlite-state.ts
|
|
137
|
-
function toPluginJsonValue(value) {
|
|
138
|
-
const serialized = JSON.stringify(value);
|
|
139
|
-
return JSON.parse(serialized);
|
|
140
|
-
}
|
|
141
|
-
const sqliteMutationLocks = new openclaw_plugin_sdk_keyed_async_queue.KeyedAsyncQueue();
|
|
142
|
-
const MSTEAMS_MUTATION_LOCK_OPTIONS = {
|
|
143
|
-
retries: {
|
|
144
|
-
retries: 10,
|
|
145
|
-
factor: 2,
|
|
146
|
-
minTimeout: 100,
|
|
147
|
-
maxTimeout: 1e4,
|
|
148
|
-
randomize: true
|
|
149
|
-
},
|
|
150
|
-
stale: 3e4
|
|
151
|
-
};
|
|
152
|
-
async function withMSTeamsSqliteMutationLock(mutationKey, fn) {
|
|
153
|
-
const scopedMutationKey = node_path.default.join(require_runtime.getMSTeamsRuntime().state.resolveStateDir(), mutationKey);
|
|
154
|
-
return await sqliteMutationLocks.enqueue(scopedMutationKey, () => (0, openclaw_plugin_sdk_file_lock.withFileLock)(scopedMutationKey, MSTEAMS_MUTATION_LOCK_OPTIONS, fn));
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
136
|
//#region extensions/msteams/src/pending-uploads-fs.ts
|
|
158
137
|
/** TTL for persisted pending uploads (matches in-memory store). */
|
|
159
138
|
const PENDING_UPLOAD_TTL_MS$1 = 3e5;
|
|
@@ -213,13 +192,13 @@ async function registerUploadRows(record, metaStore, chunkStore) {
|
|
|
213
192
|
await pruneUploadStore(metaStore, chunkStore, chunkCount);
|
|
214
193
|
for (let index = 0; index < chunkCount; index += 1) {
|
|
215
194
|
const chunk = buffer.subarray(index * RAW_CHUNK_BYTES, (index + 1) * RAW_CHUNK_BYTES);
|
|
216
|
-
await chunkStore.register(buildChunkKey(record.id, index), toPluginJsonValue({
|
|
195
|
+
await chunkStore.register(buildChunkKey(record.id, index), require_delegated_state.toPluginJsonValue({
|
|
217
196
|
id: record.id,
|
|
218
197
|
index,
|
|
219
198
|
dataBase64: chunk.toString("base64")
|
|
220
199
|
}));
|
|
221
200
|
}
|
|
222
|
-
await metaStore.register(buildMetaKey(record.id), toPluginJsonValue({
|
|
201
|
+
await metaStore.register(buildMetaKey(record.id), require_delegated_state.toPluginJsonValue({
|
|
223
202
|
id: record.id,
|
|
224
203
|
filename: record.filename,
|
|
225
204
|
contentType: record.contentType,
|
|
@@ -275,7 +254,7 @@ async function pruneUploadStore(metaStore, chunkStore, extraChunkRows = 0) {
|
|
|
275
254
|
async function storePendingUploadFs(upload) {
|
|
276
255
|
const metaStore = createMetaStore();
|
|
277
256
|
const chunkStore = createChunkStore();
|
|
278
|
-
await withMSTeamsSqliteMutationLock(PENDING_UPLOAD_MUTATION_KEY, async () => {
|
|
257
|
+
await require_delegated_state.withMSTeamsSqliteMutationLock(PENDING_UPLOAD_MUTATION_KEY, async () => {
|
|
279
258
|
await registerUploadRows({
|
|
280
259
|
id: upload.id,
|
|
281
260
|
buffer: upload.buffer,
|
|
@@ -302,16 +281,16 @@ async function removePendingUploadFs(id) {
|
|
|
302
281
|
if (!id) return;
|
|
303
282
|
const metaStore = createMetaStore();
|
|
304
283
|
const chunkStore = createChunkStore();
|
|
305
|
-
await withMSTeamsSqliteMutationLock(PENDING_UPLOAD_MUTATION_KEY, async () => {
|
|
284
|
+
await require_delegated_state.withMSTeamsSqliteMutationLock(PENDING_UPLOAD_MUTATION_KEY, async () => {
|
|
306
285
|
await deleteUploadRows(id, metaStore, chunkStore);
|
|
307
286
|
});
|
|
308
287
|
}
|
|
309
288
|
async function setPendingUploadActivityIdFs(id, activityId) {
|
|
310
289
|
const metaStore = createMetaStore();
|
|
311
|
-
await withMSTeamsSqliteMutationLock(PENDING_UPLOAD_MUTATION_KEY, async () => {
|
|
290
|
+
await require_delegated_state.withMSTeamsSqliteMutationLock(PENDING_UPLOAD_MUTATION_KEY, async () => {
|
|
312
291
|
const record = await metaStore.lookup(buildMetaKey(id));
|
|
313
292
|
if (!record || Date.now() - record.createdAt > PENDING_UPLOAD_TTL_MS$1) return;
|
|
314
|
-
await metaStore.register(buildMetaKey(id), toPluginJsonValue({
|
|
293
|
+
await metaStore.register(buildMetaKey(id), require_delegated_state.toPluginJsonValue({
|
|
315
294
|
...record,
|
|
316
295
|
consentCardActivityId: activityId
|
|
317
296
|
}));
|
|
@@ -461,17 +440,6 @@ const MSTEAMS_MARKERS = {
|
|
|
461
440
|
close: "~~"
|
|
462
441
|
}
|
|
463
442
|
};
|
|
464
|
-
function createTokenPrefix(text, label) {
|
|
465
|
-
const normalized = /[\u{E000}&]/u.test(text) ? (0, openclaw_plugin_sdk_text_chunking.markdownToIR)(text, {
|
|
466
|
-
autolink: false,
|
|
467
|
-
linkify: false
|
|
468
|
-
}).text : "";
|
|
469
|
-
let prefix;
|
|
470
|
-
do
|
|
471
|
-
prefix = `\u{E000}${label}-${(0, node_crypto.randomUUID)()}\u{E001}`;
|
|
472
|
-
while (text.includes(prefix) || normalized.includes(prefix));
|
|
473
|
-
return prefix;
|
|
474
|
-
}
|
|
475
443
|
function restoreTokens(text, prefix, values) {
|
|
476
444
|
if (!text.includes(prefix)) return text;
|
|
477
445
|
const escapedPrefix = prefix.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
@@ -632,10 +600,17 @@ function protectMSTeamsCode(ir, tokenPrefix, code, protectedValues) {
|
|
|
632
600
|
}, codeSpans.map((span) => {
|
|
633
601
|
const codeStyle = span.style === "code_block" ? "code_block" : "code";
|
|
634
602
|
const source = protectedValues.reduce((text, protectedValue) => restoreTokens(text, protectedValue.prefix, protectedValue.values), ir.text.slice(span.start, span.end));
|
|
635
|
-
|
|
603
|
+
let quoteDepth = 0;
|
|
604
|
+
let hasTrailingQuotedText = false;
|
|
605
|
+
if (codeStyle === "code_block") {
|
|
606
|
+
for (const candidate of ir.styles) if (candidate.style === "blockquote" && span.start >= candidate.start) {
|
|
607
|
+
if (span.start < candidate.end) quoteDepth += 1;
|
|
608
|
+
hasTrailingQuotedText ||= candidate.end > span.end;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
636
611
|
const rendered = renderMSTeamsCode(codeStyle, source);
|
|
637
612
|
let quoted = quoteDepth > 0 ? `${"> ".repeat(quoteDepth)}${rendered.replaceAll("\n", `\n${"> ".repeat(quoteDepth)}`)}` : rendered;
|
|
638
|
-
if (
|
|
613
|
+
if (hasTrailingQuotedText && !quoted.endsWith("\n")) quoted += "\n";
|
|
639
614
|
const index = code.push(quoted) - 1;
|
|
640
615
|
return {
|
|
641
616
|
start: span.start,
|
|
@@ -656,7 +631,7 @@ function formatMSTeamsMarkdown(markdown, tableMode) {
|
|
|
656
631
|
const images = [];
|
|
657
632
|
const mentions = [];
|
|
658
633
|
const entities = [];
|
|
659
|
-
const tokenPrefix =
|
|
634
|
+
const tokenPrefix = `\u{E000}msteamsformat-${(0, node_crypto.randomUUID)()}\u{E001}`;
|
|
660
635
|
const mentionsProtected = protectDelimitedMarkdown(protectDelimitedMarkdown(markdown.replace(MARKDOWN_ENTITY_RE, (entity) => {
|
|
661
636
|
const index = entities.push(entity) - 1;
|
|
662
637
|
return `${tokenPrefix}h${index}${TOKEN_END}`;
|
|
@@ -997,18 +972,38 @@ async function withRevokedProxyFallback(params) {
|
|
|
997
972
|
}
|
|
998
973
|
//#endregion
|
|
999
974
|
//#region extensions/msteams/src/sent-message-cache.ts
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
975
|
+
const TTL_MS = 864e5;
|
|
976
|
+
const MAX_ENTRIES = 2e4;
|
|
977
|
+
const PERSISTENT_MAX_ENTRIES = 1e3;
|
|
978
|
+
const PERSISTENT_NAMESPACE = "msteams.sent-messages";
|
|
979
|
+
const MSTEAMS_SENT_MESSAGES_KEY = Symbol.for("openclaw.msteamsSentMessages");
|
|
980
|
+
const namedAccountCaches = /* @__PURE__ */ new Map();
|
|
981
|
+
function createSentMessageCache(accountId) {
|
|
982
|
+
const isDefault = accountId === "default";
|
|
983
|
+
const accountDigest = isDefault ? void 0 : (0, node_crypto.createHash)("sha256").update(accountId).digest("hex");
|
|
984
|
+
return (0, openclaw_plugin_sdk_dedupe_runtime.createPersistentDedupeCache)({
|
|
985
|
+
globalKey: isDefault ? MSTEAMS_SENT_MESSAGES_KEY : Symbol.for(`openclaw.msteamsSentMessages.account.v1.${accountDigest}`),
|
|
986
|
+
ttlMs: TTL_MS,
|
|
987
|
+
maxSize: MAX_ENTRIES,
|
|
988
|
+
persistent: {
|
|
989
|
+
namespace: isDefault ? PERSISTENT_NAMESPACE : `${PERSISTENT_NAMESPACE}.account.v1.${accountDigest}`,
|
|
990
|
+
maxEntries: PERSISTENT_MAX_ENTRIES,
|
|
991
|
+
openStore: (options) => require_runtime.getOptionalMSTeamsRuntime()?.state.openKeyedStoreV2(options),
|
|
992
|
+
logError: (0, openclaw_plugin_sdk_plugin_state_runtime.createPluginStateErrorReporter)(require_runtime.getOptionalMSTeamsRuntime, "msteams", "sent-message-state", "Microsoft Teams persistent sent-message state failed"),
|
|
993
|
+
readTimestamp: (record) => record.sentAt
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
const defaultSentMessages = createSentMessageCache("default");
|
|
998
|
+
function getSentMessageCache(accountId) {
|
|
999
|
+
if (accountId === "default") return defaultSentMessages;
|
|
1000
|
+
let cache = namedAccountCaches.get(accountId);
|
|
1001
|
+
if (!cache) {
|
|
1002
|
+
cache = createSentMessageCache(accountId);
|
|
1003
|
+
namedAccountCaches.set(accountId, cache);
|
|
1010
1004
|
}
|
|
1011
|
-
|
|
1005
|
+
return cache;
|
|
1006
|
+
}
|
|
1012
1007
|
function makeKey(conversationId, messageId, botId) {
|
|
1013
1008
|
return botId ? JSON.stringify([
|
|
1014
1009
|
botId,
|
|
@@ -1016,14 +1011,14 @@ function makeKey(conversationId, messageId, botId) {
|
|
|
1016
1011
|
messageId
|
|
1017
1012
|
]) : `${conversationId}:${messageId}`;
|
|
1018
1013
|
}
|
|
1019
|
-
function recordMSTeamsSentMessage(conversationId, messageId,
|
|
1014
|
+
function recordMSTeamsSentMessage(conversationId, messageId, options) {
|
|
1020
1015
|
if (!conversationId || !messageId || messageId === "unknown") return;
|
|
1021
1016
|
const sentAt = Date.now();
|
|
1022
|
-
|
|
1017
|
+
getSentMessageCache((0, openclaw_plugin_sdk_account_id.normalizeAccountId)(options?.accountId)).register(makeKey(conversationId, messageId, options?.botId), { sentAt }, { at: sentAt });
|
|
1023
1018
|
}
|
|
1024
1019
|
async function wasMSTeamsMessageSentWithPersistence(params) {
|
|
1025
1020
|
if (!params.conversationId || !params.messageId) return false;
|
|
1026
|
-
return await
|
|
1021
|
+
return await getSentMessageCache((0, openclaw_plugin_sdk_account_id.normalizeAccountId)(params.accountId)).lookup(makeKey(params.conversationId, params.messageId, params.botId));
|
|
1027
1022
|
}
|
|
1028
1023
|
//#endregion
|
|
1029
1024
|
//#region extensions/msteams/src/sdk-proactive.ts
|
|
@@ -1144,7 +1139,10 @@ async function sendMSTeamsActivityWithReference(app, source, activity, options)
|
|
|
1144
1139
|
}
|
|
1145
1140
|
const res = isTargeted && activities.createTargeted ? await activities.createTargeted(activityWithRef) : await activities.create(activityWithRef);
|
|
1146
1141
|
const conversationId = ref.conversation.id.split(";")[0] ?? ref.conversation.id;
|
|
1147
|
-
if (res.id && activityWithRef.type === "message" && ref.conversation.conversationType === "channel" && ref.conversation.id === conversationId) recordMSTeamsSentMessage(conversationId, res.id,
|
|
1142
|
+
if (res.id && activityWithRef.type === "message" && ref.conversation.conversationType === "channel" && ref.conversation.id === conversationId) recordMSTeamsSentMessage(conversationId, res.id, {
|
|
1143
|
+
accountId: options?.accountId,
|
|
1144
|
+
botId: ref.bot.id
|
|
1145
|
+
});
|
|
1148
1146
|
return {
|
|
1149
1147
|
...activityWithRef,
|
|
1150
1148
|
...res
|
|
@@ -1337,6 +1335,7 @@ async function sendMSTeamsMessages(params) {
|
|
|
1337
1335
|
}
|
|
1338
1336
|
const isChannel = params.conversationRef.conversation?.conversationType === "channel";
|
|
1339
1337
|
const sendFn = (activity) => sendMSTeamsActivityWithReference(params.app, baseRef, activity, {
|
|
1338
|
+
accountId: params.accountId,
|
|
1340
1339
|
assertDirectAdapterHandoff: params.assertDirectAdapterHandoff,
|
|
1341
1340
|
onPlatformSendDispatch: params.onPlatformSendDispatch,
|
|
1342
1341
|
threadActivityId: isChannel ? threadActivityId : void 0,
|
|
@@ -1520,13 +1519,14 @@ function selectMSTeamsPollVoteBucket(pollId, voterId) {
|
|
|
1520
1519
|
function buildMSTeamsPollVoteBucketKey(pollId, bucket) {
|
|
1521
1520
|
return `${buildMSTeamsPollStateKey(pollId)}:${bucket}`;
|
|
1522
1521
|
}
|
|
1523
|
-
function createMSTeamsPollStoreState() {
|
|
1522
|
+
function createMSTeamsPollStoreState(params) {
|
|
1523
|
+
const namespace = require_delegated_state.resolveMSTeamsAccountStateNamespace(MSTEAMS_POLLS_NAMESPACE, params?.accountId);
|
|
1524
1524
|
const pollStore = require_runtime.getMSTeamsRuntime().state.openKeyedStore({
|
|
1525
|
-
namespace
|
|
1525
|
+
namespace,
|
|
1526
1526
|
maxEntries: MSTEAMS_SQLITE_MAX_POLL_ROWS
|
|
1527
1527
|
});
|
|
1528
1528
|
const voteBucketStore = require_runtime.getMSTeamsRuntime().state.openKeyedStore({
|
|
1529
|
-
namespace: MSTEAMS_POLL_VOTE_BUCKETS_NAMESPACE,
|
|
1529
|
+
namespace: require_delegated_state.resolveMSTeamsAccountStateNamespace(MSTEAMS_POLL_VOTE_BUCKETS_NAMESPACE, params?.accountId),
|
|
1530
1530
|
maxEntries: MSTEAMS_MAX_POLL_VOTE_BUCKET_ROWS
|
|
1531
1531
|
});
|
|
1532
1532
|
const readPollVotes = async (pollId) => {
|
|
@@ -1551,7 +1551,7 @@ function createMSTeamsPollStoreState() {
|
|
|
1551
1551
|
for (const [bucket, bucketVotes] of buckets) {
|
|
1552
1552
|
const key = buildMSTeamsPollVoteBucketKey(pollId, bucket);
|
|
1553
1553
|
const existing = await voteBucketStore.lookup(key);
|
|
1554
|
-
await voteBucketStore.register(key, toPluginJsonValue({
|
|
1554
|
+
await voteBucketStore.register(key, require_delegated_state.toPluginJsonValue({
|
|
1555
1555
|
pollId,
|
|
1556
1556
|
bucket,
|
|
1557
1557
|
votes: {
|
|
@@ -1566,7 +1566,7 @@ function createMSTeamsPollStoreState() {
|
|
|
1566
1566
|
const bucket = selectMSTeamsPollVoteBucket(pollId, voterId);
|
|
1567
1567
|
const key = buildMSTeamsPollVoteBucketKey(pollId, bucket);
|
|
1568
1568
|
const existing = await voteBucketStore.lookup(key);
|
|
1569
|
-
await voteBucketStore.register(key, toPluginJsonValue({
|
|
1569
|
+
await voteBucketStore.register(key, require_delegated_state.toPluginJsonValue({
|
|
1570
1570
|
pollId,
|
|
1571
1571
|
bucket,
|
|
1572
1572
|
votes: {
|
|
@@ -1607,9 +1607,9 @@ function createMSTeamsPollStoreState() {
|
|
|
1607
1607
|
}
|
|
1608
1608
|
};
|
|
1609
1609
|
const createPoll = async (poll) => {
|
|
1610
|
-
await withMSTeamsSqliteMutationLock(
|
|
1610
|
+
await require_delegated_state.withMSTeamsSqliteMutationLock(namespace, async () => {
|
|
1611
1611
|
const { votes, ...metadata } = poll;
|
|
1612
|
-
await pollStore.register(buildMSTeamsPollStateKey(poll.id), toPluginJsonValue(metadata));
|
|
1612
|
+
await pollStore.register(buildMSTeamsPollStateKey(poll.id), require_delegated_state.toPluginJsonValue(metadata));
|
|
1613
1613
|
await deletePollVotes(poll.id);
|
|
1614
1614
|
await registerPollVotes(poll.id, votes, poll.updatedAt ?? poll.createdAt);
|
|
1615
1615
|
await prunePollStoreToLimit();
|
|
@@ -1622,7 +1622,7 @@ function createMSTeamsPollStoreState() {
|
|
|
1622
1622
|
return await reconstructPoll(poll);
|
|
1623
1623
|
};
|
|
1624
1624
|
const recordVote = async (vote) => {
|
|
1625
|
-
return await withMSTeamsSqliteMutationLock(
|
|
1625
|
+
return await require_delegated_state.withMSTeamsSqliteMutationLock(namespace, async () => {
|
|
1626
1626
|
const pollKey = buildMSTeamsPollStateKey(vote.pollId);
|
|
1627
1627
|
const poll = await pollStore.lookup(pollKey);
|
|
1628
1628
|
if (!poll) return null;
|
|
@@ -1634,7 +1634,7 @@ function createMSTeamsPollStoreState() {
|
|
|
1634
1634
|
const normalized = normalizeMSTeamsPollSelections(await reconstructPoll(poll), vote.selections);
|
|
1635
1635
|
const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1636
1636
|
poll.updatedAt = updatedAt;
|
|
1637
|
-
await pollStore.register(pollKey, toPluginJsonValue(poll));
|
|
1637
|
+
await pollStore.register(pollKey, require_delegated_state.toPluginJsonValue(poll));
|
|
1638
1638
|
await registerPollVote(vote.pollId, vote.voterId, normalized, updatedAt);
|
|
1639
1639
|
await prunePollStoreToLimit();
|
|
1640
1640
|
return await reconstructPoll(poll);
|
|
@@ -1683,7 +1683,6 @@ const MSTEAMS_CONVERSATIONS_NAMESPACE = "conversations";
|
|
|
1683
1683
|
const MSTEAMS_MAX_CONVERSATIONS = 1e3;
|
|
1684
1684
|
const MSTEAMS_SQLITE_MAX_CONVERSATION_ROWS = 2e3;
|
|
1685
1685
|
const MSTEAMS_CONVERSATION_TTL_MS = 31536e6;
|
|
1686
|
-
const CONVERSATION_MUTATION_KEY = "conversations";
|
|
1687
1686
|
function buildMSTeamsConversationStateKey(conversationId) {
|
|
1688
1687
|
return node_crypto.default.createHash("sha256").update(conversationId).digest("hex");
|
|
1689
1688
|
}
|
|
@@ -1691,9 +1690,10 @@ function getStoredConversationId(reference) {
|
|
|
1691
1690
|
const rawId = reference.conversation?.id;
|
|
1692
1691
|
return rawId ? require_resolve_allowlist.normalizeMSTeamsConversationId(rawId) : null;
|
|
1693
1692
|
}
|
|
1694
|
-
function createMSTeamsConversationStoreState() {
|
|
1693
|
+
function createMSTeamsConversationStoreState(params) {
|
|
1694
|
+
const namespace = require_delegated_state.resolveMSTeamsAccountStateNamespace(MSTEAMS_CONVERSATIONS_NAMESPACE, params?.accountId);
|
|
1695
1695
|
const conversationStore = require_runtime.getMSTeamsRuntime().state.openKeyedStore({
|
|
1696
|
-
namespace
|
|
1696
|
+
namespace,
|
|
1697
1697
|
maxEntries: MSTEAMS_SQLITE_MAX_CONVERSATION_ROWS
|
|
1698
1698
|
});
|
|
1699
1699
|
const isExpired = (reference) => {
|
|
@@ -1720,7 +1720,7 @@ function createMSTeamsConversationStoreState() {
|
|
|
1720
1720
|
};
|
|
1721
1721
|
const register = async (conversationId, reference) => {
|
|
1722
1722
|
const normalizedId = require_resolve_allowlist.normalizeMSTeamsConversationId(conversationId);
|
|
1723
|
-
await conversationStore.register(buildMSTeamsConversationStateKey(normalizedId), toPluginJsonValue({
|
|
1723
|
+
await conversationStore.register(buildMSTeamsConversationStateKey(normalizedId), require_delegated_state.toPluginJsonValue({
|
|
1724
1724
|
...reference,
|
|
1725
1725
|
conversation: {
|
|
1726
1726
|
...reference.conversation,
|
|
@@ -1750,14 +1750,14 @@ function createMSTeamsConversationStoreState() {
|
|
|
1750
1750
|
};
|
|
1751
1751
|
const upsert = async (conversationId, reference) => {
|
|
1752
1752
|
const normalizedId = require_resolve_allowlist.normalizeMSTeamsConversationId(conversationId);
|
|
1753
|
-
await withMSTeamsSqliteMutationLock(
|
|
1753
|
+
await require_delegated_state.withMSTeamsSqliteMutationLock(namespace, async () => {
|
|
1754
1754
|
const existing = await lookupStored(normalizedId);
|
|
1755
1755
|
await register(normalizedId, mergeStoredConversationReference(existing ?? void 0, reference, (/* @__PURE__ */ new Date()).toISOString()));
|
|
1756
1756
|
});
|
|
1757
1757
|
};
|
|
1758
1758
|
const remove = async (conversationId) => {
|
|
1759
1759
|
const normalizedId = require_resolve_allowlist.normalizeMSTeamsConversationId(conversationId);
|
|
1760
|
-
return await withMSTeamsSqliteMutationLock(
|
|
1760
|
+
return await require_delegated_state.withMSTeamsSqliteMutationLock(namespace, async () => {
|
|
1761
1761
|
return await conversationStore.delete(buildMSTeamsConversationStateKey(normalizedId));
|
|
1762
1762
|
});
|
|
1763
1763
|
};
|
|
@@ -1950,12 +1950,6 @@ Object.defineProperty(exports, "setPendingUploadActivityIdFs", {
|
|
|
1950
1950
|
return setPendingUploadActivityIdFs;
|
|
1951
1951
|
}
|
|
1952
1952
|
});
|
|
1953
|
-
Object.defineProperty(exports, "toPluginJsonValue", {
|
|
1954
|
-
enumerable: true,
|
|
1955
|
-
get: function() {
|
|
1956
|
-
return toPluginJsonValue;
|
|
1957
|
-
}
|
|
1958
|
-
});
|
|
1959
1953
|
Object.defineProperty(exports, "updateMSTeamsActivityWithReference", {
|
|
1960
1954
|
enumerable: true,
|
|
1961
1955
|
get: function() {
|
|
@@ -1980,12 +1974,6 @@ Object.defineProperty(exports, "wasMSTeamsMessageSentWithPersistence", {
|
|
|
1980
1974
|
return wasMSTeamsMessageSentWithPersistence;
|
|
1981
1975
|
}
|
|
1982
1976
|
});
|
|
1983
|
-
Object.defineProperty(exports, "withMSTeamsSqliteMutationLock", {
|
|
1984
|
-
enumerable: true,
|
|
1985
|
-
get: function() {
|
|
1986
|
-
return withMSTeamsSqliteMutationLock;
|
|
1987
|
-
}
|
|
1988
|
-
});
|
|
1989
1977
|
Object.defineProperty(exports, "withRevokedProxyFallback", {
|
|
1990
1978
|
enumerable: true,
|
|
1991
1979
|
get: function() {
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BloeesfJ.cjs");
|
|
2
|
+
const require_runtime = require("./runtime-gZTAuFux.cjs");
|
|
3
|
+
let openclaw_plugin_sdk_account_id = require("openclaw/plugin-sdk/account-id");
|
|
4
|
+
let node_crypto = require("node:crypto");
|
|
5
|
+
node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
8
|
+
let openclaw_plugin_sdk_keyed_async_queue = require("openclaw/plugin-sdk/keyed-async-queue");
|
|
9
|
+
//#region extensions/msteams/src/sqlite-state.ts
|
|
10
|
+
function resolveMSTeamsAccountStateNamespace(namespace, accountId) {
|
|
11
|
+
const normalizedAccountId = (0, openclaw_plugin_sdk_account_id.normalizeAccountId)(accountId);
|
|
12
|
+
if (normalizedAccountId === openclaw_plugin_sdk_account_id.DEFAULT_ACCOUNT_ID) return namespace;
|
|
13
|
+
return `${namespace}-${node_crypto.default.createHash("sha256").update(normalizedAccountId).digest("hex")}`;
|
|
14
|
+
}
|
|
15
|
+
function toPluginJsonValue(value) {
|
|
16
|
+
const serialized = JSON.stringify(value);
|
|
17
|
+
return JSON.parse(serialized);
|
|
18
|
+
}
|
|
19
|
+
const sqliteMutationLocks = new openclaw_plugin_sdk_keyed_async_queue.KeyedAsyncQueue();
|
|
20
|
+
async function withMSTeamsSqliteMutationLock(mutationKey, fn) {
|
|
21
|
+
const scopedMutationKey = node_path.default.join(require_runtime.getMSTeamsRuntime().state.resolveStateDir(), mutationKey);
|
|
22
|
+
return await sqliteMutationLocks.enqueue(scopedMutationKey, fn);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region extensions/msteams/src/delegated-state.ts
|
|
26
|
+
const MSTEAMS_DELEGATED_TOKEN_LEGACY_FILENAME = "msteams-delegated.json";
|
|
27
|
+
const MSTEAMS_DELEGATED_TOKEN_NAMESPACE = "delegated-token";
|
|
28
|
+
const MSTEAMS_DELEGATED_TOKEN_KEY = "current";
|
|
29
|
+
function openDelegatedTokenStore(accountId) {
|
|
30
|
+
return require_runtime.getMSTeamsRuntime().state.openKeyedStore({
|
|
31
|
+
namespace: resolveMSTeamsAccountStateNamespace(MSTEAMS_DELEGATED_TOKEN_NAMESPACE, accountId),
|
|
32
|
+
maxEntries: 1,
|
|
33
|
+
overflowPolicy: "reject-new"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function normalizeMSTeamsDelegatedTokens(value) {
|
|
37
|
+
if (!value || typeof value !== "object") return null;
|
|
38
|
+
const token = value;
|
|
39
|
+
if (typeof token.accessToken !== "string" || !token.accessToken || typeof token.refreshToken !== "string" || !token.refreshToken || typeof token.expiresAt !== "number" || !Number.isFinite(token.expiresAt) || !Array.isArray(token.scopes) || !token.scopes.every((scope) => typeof scope === "string" && scope.length > 0)) return null;
|
|
40
|
+
return {
|
|
41
|
+
accessToken: token.accessToken,
|
|
42
|
+
refreshToken: token.refreshToken,
|
|
43
|
+
expiresAt: token.expiresAt,
|
|
44
|
+
scopes: [...token.scopes],
|
|
45
|
+
...typeof token.userPrincipalName === "string" ? { userPrincipalName: token.userPrincipalName } : {}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function loadMSTeamsDelegatedTokens(accountId) {
|
|
49
|
+
return normalizeMSTeamsDelegatedTokens(await openDelegatedTokenStore(accountId).lookup("current")) ?? void 0;
|
|
50
|
+
}
|
|
51
|
+
async function saveMSTeamsDelegatedTokens(tokens, accountId) {
|
|
52
|
+
const normalized = normalizeMSTeamsDelegatedTokens(tokens);
|
|
53
|
+
if (!normalized) throw new Error("Invalid Microsoft Teams delegated token payload");
|
|
54
|
+
await openDelegatedTokenStore(accountId).register(MSTEAMS_DELEGATED_TOKEN_KEY, normalized);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
Object.defineProperty(exports, "MSTEAMS_DELEGATED_TOKEN_KEY", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function() {
|
|
60
|
+
return MSTEAMS_DELEGATED_TOKEN_KEY;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "MSTEAMS_DELEGATED_TOKEN_LEGACY_FILENAME", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function() {
|
|
66
|
+
return MSTEAMS_DELEGATED_TOKEN_LEGACY_FILENAME;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "MSTEAMS_DELEGATED_TOKEN_NAMESPACE", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function() {
|
|
72
|
+
return MSTEAMS_DELEGATED_TOKEN_NAMESPACE;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "loadMSTeamsDelegatedTokens", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function() {
|
|
78
|
+
return loadMSTeamsDelegatedTokens;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "normalizeMSTeamsDelegatedTokens", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function() {
|
|
84
|
+
return normalizeMSTeamsDelegatedTokens;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "resolveMSTeamsAccountStateNamespace", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function() {
|
|
90
|
+
return resolveMSTeamsAccountStateNamespace;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "saveMSTeamsDelegatedTokens", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function() {
|
|
96
|
+
return saveMSTeamsDelegatedTokens;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, "toPluginJsonValue", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function() {
|
|
102
|
+
return toPluginJsonValue;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "withMSTeamsSqliteMutationLock", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function() {
|
|
108
|
+
return withMSTeamsSqliteMutationLock;
|
|
109
|
+
}
|
|
110
|
+
});
|