@yaoqi10012/wechat-kf 0.3.1 → 0.3.3

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.
Files changed (61) hide show
  1. package/dist/index.d.ts +17 -0
  2. package/dist/index.js +32 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/src/accounts.d.ts +38 -0
  5. package/dist/src/accounts.js +247 -0
  6. package/dist/src/accounts.js.map +1 -0
  7. package/dist/src/api.d.ts +58 -0
  8. package/dist/src/api.js +200 -0
  9. package/dist/src/api.js.map +1 -0
  10. package/dist/src/bot.d.ts +37 -0
  11. package/dist/src/bot.js +672 -0
  12. package/dist/src/bot.js.map +1 -0
  13. package/dist/src/channel.d.ts +14 -0
  14. package/dist/src/channel.js +320 -0
  15. package/dist/src/channel.js.map +1 -0
  16. package/dist/src/config-schema.d.ts +56 -0
  17. package/dist/src/config-schema.js +39 -0
  18. package/dist/src/config-schema.js.map +1 -0
  19. package/dist/src/constants.d.ts +41 -0
  20. package/dist/src/constants.js +51 -0
  21. package/dist/src/constants.js.map +1 -0
  22. package/dist/src/crypto.d.ts +18 -0
  23. package/dist/src/crypto.js +81 -0
  24. package/dist/src/crypto.js.map +1 -0
  25. package/dist/src/fs-utils.d.ts +7 -0
  26. package/dist/src/fs-utils.js +13 -0
  27. package/dist/src/fs-utils.js.map +1 -0
  28. package/dist/src/monitor.d.ts +31 -0
  29. package/dist/src/monitor.js +80 -0
  30. package/dist/src/monitor.js.map +1 -0
  31. package/dist/src/outbound.d.ts +32 -0
  32. package/dist/src/outbound.js +411 -0
  33. package/dist/src/outbound.js.map +1 -0
  34. package/dist/src/reply-dispatcher.d.ts +36 -0
  35. package/dist/src/reply-dispatcher.js +216 -0
  36. package/dist/src/reply-dispatcher.js.map +1 -0
  37. package/dist/src/runtime.d.ts +12 -0
  38. package/dist/src/runtime.js +23 -0
  39. package/dist/src/runtime.js.map +1 -0
  40. package/dist/src/send-utils.d.ts +52 -0
  41. package/dist/src/send-utils.js +217 -0
  42. package/dist/src/send-utils.js.map +1 -0
  43. package/dist/src/token.d.ts +8 -0
  44. package/dist/src/token.js +61 -0
  45. package/dist/src/token.js.map +1 -0
  46. package/dist/src/types.d.ts +236 -0
  47. package/dist/src/types.js +3 -0
  48. package/dist/src/types.js.map +1 -0
  49. package/dist/src/unicode-format.d.ts +26 -0
  50. package/dist/src/unicode-format.js +157 -0
  51. package/dist/src/unicode-format.js.map +1 -0
  52. package/dist/src/webhook.d.ts +22 -0
  53. package/dist/src/webhook.js +148 -0
  54. package/dist/src/webhook.js.map +1 -0
  55. package/dist/src/wechat-kf-directives.d.ts +157 -0
  56. package/dist/src/wechat-kf-directives.js +576 -0
  57. package/dist/src/wechat-kf-directives.js.map +1 -0
  58. package/index.d.ts +17 -0
  59. package/index.js +32 -0
  60. package/openclaw.plugin.json +1 -1
  61. package/package.json +5 -3
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Message processing — pull messages via sync_msg and dispatch to OpenClaw agent.
3
+ *
4
+ * Architecture:
5
+ * - Each openKfId is an independent account with its own cursor and session
6
+ * - sync_msg is called with open_kfid filter to only pull messages for that kf account
7
+ * - Plugin layer: download media, save via MediaPaths/MediaTypes
8
+ * - OpenClaw runner: handles media understanding (transcription, vision, etc.)
9
+ */
10
+ import type { ChannelLogSink, OpenClawConfig } from "openclaw/plugin-sdk";
11
+ import type { ResolvedWechatKfAccount, WechatKfMessage } from "./types.js";
12
+ /** Minimal runtime shape used only for error logging in the reply dispatcher. */
13
+ export type RuntimeErrorLogger = {
14
+ error?: (...args: unknown[]) => void;
15
+ [key: string]: unknown;
16
+ };
17
+ export type BotContext = {
18
+ cfg: OpenClawConfig;
19
+ runtime?: RuntimeErrorLogger;
20
+ stateDir: string;
21
+ log?: ChannelLogSink;
22
+ };
23
+ declare function isDuplicate(msgid: string): boolean;
24
+ /** Exposed for testing only — do not use in production code. */
25
+ export declare const _testing: {
26
+ kfLocks: Map<string, Promise<void>>;
27
+ processedMsgIds: Set<string>;
28
+ isDuplicate: typeof isDuplicate;
29
+ DEDUP_MAX_SIZE: number;
30
+ handleEvent: typeof handleEvent;
31
+ drainToLatestCursor: typeof drainToLatestCursor;
32
+ resetState(): void;
33
+ };
34
+ declare function handleEvent(ctx: BotContext, _account: ResolvedWechatKfAccount, msg: WechatKfMessage): Promise<void>;
35
+ declare function drainToLatestCursor(corpId: string, appSecret: string, openKfId: string, syncToken: string, stateDir: string, log?: ChannelLogSink): Promise<void>;
36
+ export declare function handleWebhookEvent(ctx: BotContext, openKfId: string, syncToken: string): Promise<void>;
37
+ export {};