@openclaw-china/wecom-app 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 CHANGED
@@ -909,11 +909,31 @@ declare function sendWecom(account: ResolvedWecomAppAccount, target: string, opt
909
909
  /**
910
910
  * Moltbot 插件 API 接口
911
911
  */
912
+ type HttpRouteMatch = "exact" | "prefix";
913
+ type HttpRouteAuth = "gateway" | "plugin";
914
+ type HttpRouteParams = {
915
+ path: string;
916
+ auth: HttpRouteAuth;
917
+ match?: HttpRouteMatch;
918
+ handler: (req: IncomingMessage, res: ServerResponse) => Promise<boolean> | boolean;
919
+ };
920
+ type WecomAppRouteConfig = {
921
+ webhookPath?: string;
922
+ accounts?: Record<string, {
923
+ webhookPath?: string;
924
+ }>;
925
+ };
912
926
  interface MoltbotPluginApi {
913
927
  registerChannel: (opts: {
914
928
  plugin: unknown;
915
929
  }) => void;
916
930
  registerHttpHandler?: (handler: (req: IncomingMessage, res: ServerResponse) => Promise<boolean> | boolean) => void;
931
+ registerHttpRoute?: (params: HttpRouteParams) => void;
932
+ config?: {
933
+ channels?: {
934
+ "wecom-app"?: WecomAppRouteConfig;
935
+ };
936
+ };
917
937
  runtime?: unknown;
918
938
  [key: string]: unknown;
919
939
  }
package/dist/index.js CHANGED
@@ -8933,6 +8933,20 @@ async function sendWecom(account, target, options) {
8933
8933
  }
8934
8934
 
8935
8935
  // index.ts
8936
+ function normalizeRoutePath(path, fallback) {
8937
+ const trimmed = path?.trim() ?? "";
8938
+ const candidate = trimmed || fallback;
8939
+ return candidate.startsWith("/") ? candidate : `/${candidate}`;
8940
+ }
8941
+ function collectWecomAppRoutePaths(config) {
8942
+ const routes = /* @__PURE__ */ new Set([normalizeRoutePath(config?.webhookPath, "/wecom-app")]);
8943
+ for (const accountConfig of Object.values(config?.accounts ?? {})) {
8944
+ const customPath = accountConfig?.webhookPath?.trim();
8945
+ if (!customPath) continue;
8946
+ routes.add(normalizeRoutePath(customPath, "/wecom-app"));
8947
+ }
8948
+ return [...routes];
8949
+ }
8936
8950
  var plugin = {
8937
8951
  id: "wecom-app",
8938
8952
  name: "WeCom App",
@@ -8949,7 +8963,16 @@ var plugin = {
8949
8963
  setWecomAppRuntime(api.runtime);
8950
8964
  }
8951
8965
  api.registerChannel({ plugin: wecomAppPlugin });
8952
- if (api.registerHttpHandler) {
8966
+ if (api.registerHttpRoute) {
8967
+ for (const path of collectWecomAppRoutePaths(api.config?.channels?.["wecom-app"])) {
8968
+ api.registerHttpRoute({
8969
+ path,
8970
+ auth: "plugin",
8971
+ match: "prefix",
8972
+ handler: handleWecomAppWebhookRequest
8973
+ });
8974
+ }
8975
+ } else if (api.registerHttpHandler) {
8953
8976
  api.registerHttpHandler(handleWecomAppWebhookRequest);
8954
8977
  }
8955
8978
  }