@kyan-du/agent-wechat-openclaw 0.14.6 → 0.15.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/index.js +34 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1158,6 +1158,14 @@ function getWeChatRuntime() {
|
|
|
1158
1158
|
// src/monitor.ts
|
|
1159
1159
|
import { unlink } from "node:fs/promises";
|
|
1160
1160
|
|
|
1161
|
+
// src/monitor-open-chat.ts
|
|
1162
|
+
function requireVerifiedChatOpen(result, chatId) {
|
|
1163
|
+
if (result?.ok !== true || result.verified !== true || result.username !== chatId) {
|
|
1164
|
+
const code = result?.errorCode ?? "TARGET_CONFIRMATION_FAILED";
|
|
1165
|
+
throw new Error(`Chat open not confirmed: ${code}`);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1161
1169
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
1162
1170
|
var external_exports = {};
|
|
1163
1171
|
__export(external_exports, {
|
|
@@ -6325,8 +6333,7 @@ import {
|
|
|
6325
6333
|
import {
|
|
6326
6334
|
resolveAllowlistProviderRuntimeGroupPolicy,
|
|
6327
6335
|
resolveDefaultGroupPolicy
|
|
6328
|
-
} from "openclaw/plugin-sdk/
|
|
6329
|
-
import { resolveSenderCommandAuthorization } from "openclaw/plugin-sdk/command-auth";
|
|
6336
|
+
} from "openclaw/plugin-sdk/runtime-group-policy";
|
|
6330
6337
|
var INVISIBLE_TEXT_RE = /[\u200b-\u200f\u202a-\u202e\u2060-\u206f]/g;
|
|
6331
6338
|
var WECHAT_MENTION_START_RE = /^[@@]/u;
|
|
6332
6339
|
function unique(values) {
|
|
@@ -6501,17 +6508,23 @@ function resolveWeChatInboundAccessDecision(params) {
|
|
|
6501
6508
|
}
|
|
6502
6509
|
async function resolveWeChatCommandAuthorization(params) {
|
|
6503
6510
|
const normalizedSenderId = normalizeWeChatId(params.senderId ?? "");
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6511
|
+
if (!params.deps.shouldComputeCommandAuthorized(params.rawBody, params.cfg)) {
|
|
6512
|
+
return void 0;
|
|
6513
|
+
}
|
|
6514
|
+
const isSenderAllowed = (allowFrom) => isWeChatSenderAllowed(normalizedSenderId, normalizeWeChatAllowFrom(allowFrom));
|
|
6515
|
+
const configuredAllowFrom = normalizeAllowEntries(params.allowFromForCommands);
|
|
6516
|
+
const storeAllowFrom = !params.isGroup && params.dmPolicy !== "allowlist" && params.dmPolicy !== "open" ? normalizeWeChatAllowFrom(await params.deps.readAllowFromStore().catch(() => [])) : [];
|
|
6517
|
+
const effectiveAllowFrom = normalizeAllowEntries([...configuredAllowFrom, ...storeAllowFrom]);
|
|
6518
|
+
const effectiveGroupAllowFrom = configuredAllowFrom;
|
|
6519
|
+
const commandAuthorized = params.deps.resolveCommandAuthorizedFromAuthorizers({
|
|
6520
|
+
useAccessGroups: params.cfg.commands?.useAccessGroups !== false,
|
|
6521
|
+
authorizers: [
|
|
6522
|
+
{ configured: effectiveAllowFrom.length > 0, allowed: isSenderAllowed(effectiveAllowFrom) },
|
|
6523
|
+
{
|
|
6524
|
+
configured: effectiveGroupAllowFrom.length > 0,
|
|
6525
|
+
allowed: isSenderAllowed(effectiveGroupAllowFrom)
|
|
6526
|
+
}
|
|
6527
|
+
]
|
|
6515
6528
|
});
|
|
6516
6529
|
return commandAuthorized;
|
|
6517
6530
|
}
|
|
@@ -6523,6 +6536,9 @@ function resolveWeChatMentionGate(params) {
|
|
|
6523
6536
|
const shouldSkip = params.requireMention && params.canDetectMention && !effectiveWasMentioned;
|
|
6524
6537
|
return { effectiveWasMentioned, shouldSkip, shouldBypassMention };
|
|
6525
6538
|
}
|
|
6539
|
+
function normalizeAllowEntries(entries) {
|
|
6540
|
+
return (entries ?? []).map((entry) => String(entry).trim()).filter(Boolean);
|
|
6541
|
+
}
|
|
6526
6542
|
|
|
6527
6543
|
// src/catchup.ts
|
|
6528
6544
|
var DEFAULT_STALE_AFTER_MS = 3 * 60 * 60 * 1e3;
|
|
@@ -8578,16 +8594,18 @@ async function processUnreadChat(client, chat, lastSeenId, equalCursorUnreadHand
|
|
|
8578
8594
|
});
|
|
8579
8595
|
let opened = false;
|
|
8580
8596
|
const openChatIfNeeded = async () => {
|
|
8581
|
-
if (skipOpen || opened) return;
|
|
8582
|
-
opened = true;
|
|
8597
|
+
if (skipOpen || opened) return true;
|
|
8583
8598
|
log?.info?.(`[wechat:${liveAccount.accountId}] Opening chat ${chatId}...`);
|
|
8584
8599
|
try {
|
|
8585
|
-
await client.openChat(chatId, true);
|
|
8600
|
+
requireVerifiedChatOpen(await client.openChat(chatId, true), chatId);
|
|
8601
|
+
opened = true;
|
|
8586
8602
|
log?.info?.(`[wechat:${liveAccount.accountId}] Opened chat ${chatId}`);
|
|
8603
|
+
return true;
|
|
8587
8604
|
} catch (err) {
|
|
8588
8605
|
log?.error?.(
|
|
8589
8606
|
`[wechat:${liveAccount.accountId}] Failed to open chat ${chatId}: ${err}`
|
|
8590
8607
|
);
|
|
8608
|
+
return false;
|
|
8591
8609
|
}
|
|
8592
8610
|
};
|
|
8593
8611
|
const firstPoll = !lastSeenId.has(chatId);
|