@openclaw-china/wecom 2026.3.3 → 2026.3.4-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.d.ts +20 -0
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -456,11 +456,31 @@ declare function getWecomRuntime(): PluginRuntime;
|
|
|
456
456
|
/**
|
|
457
457
|
* Moltbot 插件 API 接口
|
|
458
458
|
*/
|
|
459
|
+
type HttpRouteMatch = "exact" | "prefix";
|
|
460
|
+
type HttpRouteAuth = "gateway" | "plugin";
|
|
461
|
+
type HttpRouteParams = {
|
|
462
|
+
path: string;
|
|
463
|
+
auth: HttpRouteAuth;
|
|
464
|
+
match?: HttpRouteMatch;
|
|
465
|
+
handler: (req: IncomingMessage, res: ServerResponse) => Promise<boolean> | boolean;
|
|
466
|
+
};
|
|
467
|
+
type WecomRouteConfig = {
|
|
468
|
+
webhookPath?: string;
|
|
469
|
+
accounts?: Record<string, {
|
|
470
|
+
webhookPath?: string;
|
|
471
|
+
}>;
|
|
472
|
+
};
|
|
459
473
|
interface MoltbotPluginApi {
|
|
460
474
|
registerChannel: (opts: {
|
|
461
475
|
plugin: unknown;
|
|
462
476
|
}) => void;
|
|
463
477
|
registerHttpHandler?: (handler: (req: IncomingMessage, res: ServerResponse) => Promise<boolean> | boolean) => void;
|
|
478
|
+
registerHttpRoute?: (params: HttpRouteParams) => void;
|
|
479
|
+
config?: {
|
|
480
|
+
channels?: {
|
|
481
|
+
wecom?: WecomRouteConfig;
|
|
482
|
+
};
|
|
483
|
+
};
|
|
464
484
|
runtime?: unknown;
|
|
465
485
|
[key: string]: unknown;
|
|
466
486
|
}
|
package/dist/index.js
CHANGED
|
@@ -8639,6 +8639,20 @@ var wecomPlugin = {
|
|
|
8639
8639
|
};
|
|
8640
8640
|
|
|
8641
8641
|
// index.ts
|
|
8642
|
+
function normalizeRoutePath(path5, fallback) {
|
|
8643
|
+
const trimmed = path5?.trim() ?? "";
|
|
8644
|
+
const candidate = trimmed || fallback;
|
|
8645
|
+
return candidate.startsWith("/") ? candidate : `/${candidate}`;
|
|
8646
|
+
}
|
|
8647
|
+
function collectWecomRoutePaths(config) {
|
|
8648
|
+
const routes = /* @__PURE__ */ new Set([normalizeRoutePath(config?.webhookPath, "/wecom"), "/wecom-media"]);
|
|
8649
|
+
for (const accountConfig of Object.values(config?.accounts ?? {})) {
|
|
8650
|
+
const customPath = accountConfig?.webhookPath?.trim();
|
|
8651
|
+
if (!customPath) continue;
|
|
8652
|
+
routes.add(normalizeRoutePath(customPath, "/wecom"));
|
|
8653
|
+
}
|
|
8654
|
+
return [...routes];
|
|
8655
|
+
}
|
|
8642
8656
|
var plugin = {
|
|
8643
8657
|
id: "wecom",
|
|
8644
8658
|
name: "WeCom",
|
|
@@ -8655,7 +8669,16 @@ var plugin = {
|
|
|
8655
8669
|
setWecomRuntime(api.runtime);
|
|
8656
8670
|
}
|
|
8657
8671
|
api.registerChannel({ plugin: wecomPlugin });
|
|
8658
|
-
if (api.
|
|
8672
|
+
if (api.registerHttpRoute) {
|
|
8673
|
+
for (const path5 of collectWecomRoutePaths(api.config?.channels?.wecom)) {
|
|
8674
|
+
api.registerHttpRoute({
|
|
8675
|
+
path: path5,
|
|
8676
|
+
auth: "plugin",
|
|
8677
|
+
match: "prefix",
|
|
8678
|
+
handler: handleWecomWebhookRequest
|
|
8679
|
+
});
|
|
8680
|
+
}
|
|
8681
|
+
} else if (api.registerHttpHandler) {
|
|
8659
8682
|
api.registerHttpHandler(handleWecomWebhookRequest);
|
|
8660
8683
|
}
|
|
8661
8684
|
}
|