weacpx 0.7.0 → 0.8.0

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 (124) hide show
  1. package/README.md +10 -564
  2. package/package.json +10 -72
  3. package/plugin-api.d.ts +2 -0
  4. package/plugin-api.js +5 -0
  5. package/LICENSE +0 -21
  6. package/config.example.json +0 -44
  7. package/dist/bridge/bridge-main.js +0 -2126
  8. package/dist/channels/channel-scope.d.ts +0 -17
  9. package/dist/channels/cli/provider.d.ts +0 -73
  10. package/dist/channels/cli/registry.d.ts +0 -7
  11. package/dist/channels/cli/weixin-provider.d.ts +0 -2
  12. package/dist/channels/create-channel.d.ts +0 -16
  13. package/dist/channels/media-store.d.ts +0 -29
  14. package/dist/channels/media-types.d.ts +0 -28
  15. package/dist/channels/outbound-media-safety.d.ts +0 -7
  16. package/dist/channels/plugin.d.ts +0 -9
  17. package/dist/channels/types.d.ts +0 -124
  18. package/dist/channels/weixin-channel.d.ts +0 -25
  19. package/dist/cli.js +0 -47662
  20. package/dist/commands/command-hints.d.ts +0 -11
  21. package/dist/commands/command-list.d.ts +0 -3
  22. package/dist/commands/config-clone.d.ts +0 -2
  23. package/dist/commands/handlers/agent-handler.d.ts +0 -6
  24. package/dist/commands/handlers/config-handler.d.ts +0 -5
  25. package/dist/commands/handlers/later-handler.d.ts +0 -21
  26. package/dist/commands/handlers/orchestration-handler.d.ts +0 -16
  27. package/dist/commands/handlers/permission-handler.d.ts +0 -9
  28. package/dist/commands/handlers/session-handler.d.ts +0 -39
  29. package/dist/commands/handlers/session-list-marker.d.ts +0 -1
  30. package/dist/commands/handlers/workspace-handler.d.ts +0 -8
  31. package/dist/commands/help/help-registry.d.ts +0 -4
  32. package/dist/commands/help/help-types.d.ts +0 -12
  33. package/dist/commands/parse-command.d.ts +0 -178
  34. package/dist/commands/router-types.d.ts +0 -144
  35. package/dist/commands/workspace-name.d.ts +0 -4
  36. package/dist/commands/workspace-path.d.ts +0 -4
  37. package/dist/config/agent-templates.d.ts +0 -4
  38. package/dist/config/config-store.d.ts +0 -13
  39. package/dist/config/load-config.d.ts +0 -10
  40. package/dist/config/resolve-agent-command.d.ts +0 -2
  41. package/dist/config/types.d.ts +0 -85
  42. package/dist/formatting/render-text.d.ts +0 -23
  43. package/dist/logging/app-logger.d.ts +0 -23
  44. package/dist/logging/rotating-file-writer.d.ts +0 -2
  45. package/dist/orchestration/async-mutex.d.ts +0 -4
  46. package/dist/orchestration/build-coordinator-prompt.d.ts +0 -66
  47. package/dist/orchestration/orchestration-service.d.ts +0 -471
  48. package/dist/orchestration/orchestration-types.d.ts +0 -181
  49. package/dist/orchestration/progress-line-parser.d.ts +0 -19
  50. package/dist/orchestration/render-delegate-group-result.d.ts +0 -6
  51. package/dist/orchestration/render-delegate-question-package.d.ts +0 -21
  52. package/dist/orchestration/render-delegate-result.d.ts +0 -2
  53. package/dist/orchestration/task-watch-timeouts.d.ts +0 -5
  54. package/dist/perf/perf-log-writer.d.ts +0 -25
  55. package/dist/perf/perf-tracer.d.ts +0 -54
  56. package/dist/plugin-api.d.ts +0 -18
  57. package/dist/plugin-api.js +0 -337
  58. package/dist/plugins/compatibility.d.ts +0 -16
  59. package/dist/plugins/known-plugins.d.ts +0 -9
  60. package/dist/plugins/types.d.ts +0 -18
  61. package/dist/runtime/conversation-executor.d.ts +0 -7
  62. package/dist/runtime/core-home.d.ts +0 -26
  63. package/dist/runtime/turn-lane.d.ts +0 -2
  64. package/dist/scheduled/parse-later-time.d.ts +0 -11
  65. package/dist/scheduled/scheduled-render.d.ts +0 -7
  66. package/dist/scheduled/scheduled-service.d.ts +0 -41
  67. package/dist/scheduled/scheduled-types.d.ts +0 -29
  68. package/dist/sessions/active-turn-registry.d.ts +0 -6
  69. package/dist/sessions/session-service.d.ts +0 -118
  70. package/dist/state/state-store.d.ts +0 -8
  71. package/dist/state/types.d.ts +0 -51
  72. package/dist/transport/tool-event-mode.d.ts +0 -14
  73. package/dist/transport/types.d.ts +0 -129
  74. package/dist/util/path.d.ts +0 -4
  75. package/dist/util/private-file.d.ts +0 -26
  76. package/dist/util/sanitize.d.ts +0 -10
  77. package/dist/util/text.d.ts +0 -3
  78. package/dist/version.d.ts +0 -3
  79. package/dist/weixin/agent/interface.d.ts +0 -79
  80. package/dist/weixin/api/api.d.ts +0 -76
  81. package/dist/weixin/api/config-cache.d.ts +0 -35
  82. package/dist/weixin/api/session-guard.d.ts +0 -17
  83. package/dist/weixin/api/types.d.ts +0 -203
  84. package/dist/weixin/auth/accounts.d.ts +0 -69
  85. package/dist/weixin/auth/login-qr.d.ts +0 -37
  86. package/dist/weixin/bot.d.ts +0 -67
  87. package/dist/weixin/cdn/aes-ecb.d.ts +0 -6
  88. package/dist/weixin/cdn/cdn-upload.d.ts +0 -17
  89. package/dist/weixin/cdn/cdn-url.d.ts +0 -11
  90. package/dist/weixin/cdn/pic-decrypt.d.ts +0 -9
  91. package/dist/weixin/cdn/upload.d.ts +0 -42
  92. package/dist/weixin/index.d.ts +0 -6
  93. package/dist/weixin/media/media-download.d.ts +0 -18
  94. package/dist/weixin/media/mime.d.ts +0 -6
  95. package/dist/weixin/media/silk-transcode.d.ts +0 -8
  96. package/dist/weixin/messaging/completion-notice.d.ts +0 -2
  97. package/dist/weixin/messaging/debug-mode.d.ts +0 -9
  98. package/dist/weixin/messaging/deliver-coordinator-message.d.ts +0 -22
  99. package/dist/weixin/messaging/deliver-orchestration-task-notice.d.ts +0 -18
  100. package/dist/weixin/messaging/deliver-orchestration-task-progress.d.ts +0 -16
  101. package/dist/weixin/messaging/error-notice.d.ts +0 -13
  102. package/dist/weixin/messaging/execute-chat-turn.d.ts +0 -12
  103. package/dist/weixin/messaging/final-heads-up.d.ts +0 -5
  104. package/dist/weixin/messaging/foreground-gate.d.ts +0 -3
  105. package/dist/weixin/messaging/handle-weixin-message-turn.d.ts +0 -36
  106. package/dist/weixin/messaging/inbound.d.ts +0 -87
  107. package/dist/weixin/messaging/markdown-filter.d.ts +0 -45
  108. package/dist/weixin/messaging/orchestration-notice-accounts.d.ts +0 -2
  109. package/dist/weixin/messaging/quota-errors.d.ts +0 -8
  110. package/dist/weixin/messaging/quota-manager.d.ts +0 -58
  111. package/dist/weixin/messaging/scheduled-turn.d.ts +0 -22
  112. package/dist/weixin/messaging/send-errors.d.ts +0 -39
  113. package/dist/weixin/messaging/send-media.d.ts +0 -23
  114. package/dist/weixin/messaging/send-orchestration-notice.d.ts +0 -10
  115. package/dist/weixin/messaging/send.d.ts +0 -73
  116. package/dist/weixin/messaging/slash-commands.d.ts +0 -40
  117. package/dist/weixin/monitor/consumer-lock.d.ts +0 -24
  118. package/dist/weixin/monitor/monitor.d.ts +0 -38
  119. package/dist/weixin/storage/ensure-dir.d.ts +0 -1
  120. package/dist/weixin/storage/state-dir.d.ts +0 -2
  121. package/dist/weixin/storage/sync-buf.d.ts +0 -20
  122. package/dist/weixin/util/logger.d.ts +0 -14
  123. package/dist/weixin/util/random.d.ts +0 -10
  124. package/dist/weixin/util/redact.d.ts +0 -21
@@ -1,76 +0,0 @@
1
- import type { BaseInfo, GetUploadUrlReq, GetUploadUrlResp, GetUpdatesReq, GetUpdatesResp, SendMessageReq, SendTypingReq, GetConfigResp } from "./types.js";
2
- export type WeixinApiOptions = {
3
- baseUrl: string;
4
- token?: string;
5
- timeoutMs?: number;
6
- /** Long-poll timeout for getUpdates (server may hold the request up to this). */
7
- longPollTimeoutMs?: number;
8
- };
9
- /**
10
- * Sanitize a user-supplied `botAgent` config value into a wire-safe string.
11
- *
12
- * Grammar (UA-style):
13
- * bot_agent = product *( SP product )
14
- * product = name "/" version [ SP "(" comment ")" ]
15
- * name = 1*32( ALPHA / DIGIT / "_" / "." / "-" )
16
- * version = 1*32( ALPHA / DIGIT / "_" / "." / "+" / "-" )
17
- * comment = 1*64( printable ASCII minus "(" ")" )
18
- *
19
- * Tokens that fail to parse are dropped silently (no partial tokens kept).
20
- * Returns `DEFAULT_BOT_AGENT` when the input is empty / all tokens dropped /
21
- * the result exceeds the length cap after truncation.
22
- */
23
- export declare function sanitizeBotAgent(raw: string | undefined): string;
24
- /** Build the `base_info` payload included in every API request. */
25
- export declare function buildBaseInfo(): BaseInfo;
26
- /**
27
- * GET fetch wrapper: send a GET request to a Weixin API endpoint with timeout + abort.
28
- * Query parameters should already be encoded in `endpoint`.
29
- * Returns the raw response text on success; throws on HTTP error or timeout.
30
- */
31
- export declare function apiGetFetch(params: {
32
- baseUrl: string;
33
- endpoint: string;
34
- timeoutMs: number;
35
- label: string;
36
- }): Promise<string>;
37
- /**
38
- * Simple POST fetch wrapper for login/auth endpoints.
39
- * Returns the raw response text on success; throws on HTTP error or timeout.
40
- */
41
- export declare function apiPostFetch(params: {
42
- baseUrl: string;
43
- endpoint: string;
44
- body: string;
45
- token?: string;
46
- timeoutMs?: number;
47
- label: string;
48
- abortSignal?: AbortSignal;
49
- }): Promise<string>;
50
- /**
51
- * Long-poll getUpdates. Server should hold the request until new messages or timeout.
52
- *
53
- * On client-side timeout (no server response within timeoutMs), returns an empty response
54
- * with ret=0 so the caller can simply retry. This is normal for long-poll.
55
- */
56
- export declare function getUpdates(params: GetUpdatesReq & {
57
- baseUrl: string;
58
- token?: string;
59
- timeoutMs?: number;
60
- abortSignal?: AbortSignal;
61
- }): Promise<GetUpdatesResp>;
62
- /** Get a pre-signed CDN upload URL for a file. */
63
- export declare function getUploadUrl(params: GetUploadUrlReq & WeixinApiOptions): Promise<GetUploadUrlResp>;
64
- /** Send a single message downstream. */
65
- export declare function sendMessage(params: WeixinApiOptions & {
66
- body: SendMessageReq;
67
- }): Promise<void>;
68
- /** Fetch bot config (includes typing_ticket) for a given user. */
69
- export declare function getConfig(params: WeixinApiOptions & {
70
- ilinkUserId: string;
71
- contextToken?: string;
72
- }): Promise<GetConfigResp>;
73
- /** Send a typing indicator to a user. */
74
- export declare function sendTyping(params: WeixinApiOptions & {
75
- body: SendTypingReq;
76
- }): Promise<void>;
@@ -1,35 +0,0 @@
1
- import { getConfig } from "./api.js";
2
- /** Subset of getConfig fields that we actually need; add new fields here as needed. */
3
- export interface CachedConfig {
4
- typingTicket: string;
5
- }
6
- type GetConfigFn = typeof getConfig;
7
- export interface WeixinConfigManagerOptions {
8
- maxEntries?: number;
9
- entryTtlMs?: number;
10
- now?: () => number;
11
- getConfig?: GetConfigFn;
12
- }
13
- /**
14
- * Per-user getConfig cache with periodic random refresh (within 24h) and
15
- * exponential-backoff retry (up to 1h) on failure.
16
- */
17
- export declare class WeixinConfigManager {
18
- private apiOpts;
19
- private log;
20
- private cache;
21
- private readonly maxEntries;
22
- private readonly entryTtlMs;
23
- private readonly now;
24
- private readonly fetchConfig;
25
- constructor(apiOpts: {
26
- baseUrl: string;
27
- token?: string;
28
- }, log: (msg: string) => void, options?: WeixinConfigManagerOptions);
29
- getForUser(userId: string, contextToken?: string): Promise<CachedConfig>;
30
- cacheSizeForTests(): number;
31
- hasCachedUserForTests(userId: string): boolean;
32
- private prune;
33
- private enforceMaxEntries;
34
- }
35
- export {};
@@ -1,17 +0,0 @@
1
- /** Error code returned by the server when the bot session has expired. */
2
- export declare const SESSION_EXPIRED_ERRCODE = -14;
3
- /** Pause all inbound/outbound API calls for `accountId` for one hour. */
4
- export declare function pauseSession(accountId: string): void;
5
- /** Returns `true` when the bot is still within its one-hour cooldown window. */
6
- export declare function isSessionPaused(accountId: string): boolean;
7
- /** Milliseconds remaining until the pause expires (0 when not paused). */
8
- export declare function getRemainingPauseMs(accountId: string): number;
9
- /** Clear the session pause for a specific account. Used when fresh credentials are detected. */
10
- export declare function resetSessionPause(accountId: string): void;
11
- /** Throw if the session is currently paused. Call before any API request. */
12
- export declare function assertSessionActive(accountId: string): void;
13
- /**
14
- * Reset internal state — only for tests.
15
- * @internal
16
- */
17
- export declare function _resetForTest(): void;
@@ -1,203 +0,0 @@
1
- /**
2
- * Weixin protocol types (mirrors proto: GetUpdatesReq/Resp, WeixinMessage, SendMessageReq).
3
- * API uses JSON over HTTP; bytes fields are base64 strings in JSON.
4
- */
5
- /** Common request metadata attached to every CGI request. */
6
- export interface BaseInfo {
7
- channel_version?: string;
8
- /** UA-style identifier for the upstream app embedding this channel. */
9
- bot_agent?: string;
10
- }
11
- /** proto: UploadMediaType */
12
- export declare const UploadMediaType: {
13
- readonly IMAGE: 1;
14
- readonly VIDEO: 2;
15
- readonly FILE: 3;
16
- readonly VOICE: 4;
17
- };
18
- export interface GetUploadUrlReq {
19
- filekey?: string;
20
- /** proto field 2: media_type, see UploadMediaType */
21
- media_type?: number;
22
- to_user_id?: string;
23
- /** 原文件明文大小 */
24
- rawsize?: number;
25
- /** 原文件明文 MD5 */
26
- rawfilemd5?: string;
27
- /** 原文件密文大小(AES-128-ECB 加密后) */
28
- filesize?: number;
29
- /** 缩略图明文大小(IMAGE/VIDEO 时必填) */
30
- thumb_rawsize?: number;
31
- /** 缩略图明文 MD5(IMAGE/VIDEO 时必填) */
32
- thumb_rawfilemd5?: string;
33
- /** 缩略图密文大小(IMAGE/VIDEO 时必填) */
34
- thumb_filesize?: number;
35
- /** 不需要缩略图上传 URL,默认 false */
36
- no_need_thumb?: boolean;
37
- /** 加密 key */
38
- aeskey?: string;
39
- }
40
- export interface GetUploadUrlResp {
41
- /** 原图上传加密参数 */
42
- upload_param?: string;
43
- /** 缩略图上传加密参数,无缩略图时为空 */
44
- thumb_upload_param?: string;
45
- /** 完整上传 URL(服务端直接返回,无需客户端拼接) */
46
- upload_full_url?: string;
47
- }
48
- export declare const MessageType: {
49
- readonly NONE: 0;
50
- readonly USER: 1;
51
- readonly BOT: 2;
52
- };
53
- export declare const MessageItemType: {
54
- readonly NONE: 0;
55
- readonly TEXT: 1;
56
- readonly IMAGE: 2;
57
- readonly VOICE: 3;
58
- readonly FILE: 4;
59
- readonly VIDEO: 5;
60
- };
61
- export declare const MessageState: {
62
- readonly NEW: 0;
63
- readonly GENERATING: 1;
64
- readonly FINISH: 2;
65
- };
66
- export interface TextItem {
67
- text?: string;
68
- }
69
- /** CDN media reference; aes_key is base64-encoded bytes in JSON. */
70
- export interface CDNMedia {
71
- encrypt_query_param?: string;
72
- aes_key?: string;
73
- /** 加密类型: 0=只加密fileid, 1=打包缩略图/中图等信息 */
74
- encrypt_type?: number;
75
- /** 完整下载 URL(服务端直接返回,无需客户端拼接) */
76
- full_url?: string;
77
- }
78
- export interface ImageItem {
79
- /** 原图 CDN 引用 */
80
- media?: CDNMedia;
81
- /** 缩略图 CDN 引用 */
82
- thumb_media?: CDNMedia;
83
- /** Raw AES-128 key as hex string (16 bytes); preferred over media.aes_key for inbound decryption. */
84
- aeskey?: string;
85
- url?: string;
86
- mid_size?: number;
87
- thumb_size?: number;
88
- thumb_height?: number;
89
- thumb_width?: number;
90
- hd_size?: number;
91
- }
92
- export interface VoiceItem {
93
- media?: CDNMedia;
94
- /** 语音编码类型:1=pcm 2=adpcm 3=feature 4=speex 5=amr 6=silk 7=mp3 8=ogg-speex */
95
- encode_type?: number;
96
- bits_per_sample?: number;
97
- /** 采样率 (Hz) */
98
- sample_rate?: number;
99
- /** 语音长度 (毫秒) */
100
- playtime?: number;
101
- /** 语音转文字内容 */
102
- text?: string;
103
- }
104
- export interface FileItem {
105
- media?: CDNMedia;
106
- file_name?: string;
107
- md5?: string;
108
- len?: string;
109
- }
110
- export interface VideoItem {
111
- media?: CDNMedia;
112
- video_size?: number;
113
- play_length?: number;
114
- video_md5?: string;
115
- thumb_media?: CDNMedia;
116
- thumb_size?: number;
117
- thumb_height?: number;
118
- thumb_width?: number;
119
- }
120
- export interface RefMessage {
121
- message_item?: MessageItem;
122
- title?: string;
123
- }
124
- export interface MessageItem {
125
- type?: number;
126
- create_time_ms?: number;
127
- update_time_ms?: number;
128
- is_completed?: boolean;
129
- msg_id?: string;
130
- ref_msg?: RefMessage;
131
- text_item?: TextItem;
132
- image_item?: ImageItem;
133
- voice_item?: VoiceItem;
134
- file_item?: FileItem;
135
- video_item?: VideoItem;
136
- }
137
- /** Unified message (proto: WeixinMessage). Replaces the old split Message + MessageContent + FullMessage. */
138
- export interface WeixinMessage {
139
- seq?: number;
140
- message_id?: number;
141
- from_user_id?: string;
142
- to_user_id?: string;
143
- client_id?: string;
144
- create_time_ms?: number;
145
- update_time_ms?: number;
146
- delete_time_ms?: number;
147
- session_id?: string;
148
- group_id?: string;
149
- message_type?: number;
150
- message_state?: number;
151
- item_list?: MessageItem[];
152
- context_token?: string;
153
- }
154
- /** GetUpdates request: bytes fields are base64 strings in JSON. */
155
- export interface GetUpdatesReq {
156
- /** @deprecated compat only, will be removed */
157
- sync_buf?: string;
158
- /** Full context buf cached locally; send "" when none (first request or after reset). */
159
- get_updates_buf?: string;
160
- }
161
- /** GetUpdates response: bytes fields are base64 strings in JSON. */
162
- export interface GetUpdatesResp {
163
- ret?: number;
164
- /** Error code returned by the server (e.g. -14 = session timeout). Present when request fails. */
165
- errcode?: number;
166
- errmsg?: string;
167
- msgs?: WeixinMessage[];
168
- /** @deprecated compat only */
169
- sync_buf?: string;
170
- /** Full context buf to cache locally and send on next request. */
171
- get_updates_buf?: string;
172
- /** Server-suggested timeout (ms) for the next getUpdates long-poll. */
173
- longpolling_timeout_ms?: number;
174
- }
175
- /** SendMessage request: wraps a single WeixinMessage. */
176
- export interface SendMessageReq {
177
- msg?: WeixinMessage;
178
- }
179
- export interface SendMessageResp {
180
- }
181
- /** Typing status: 1 = typing (default), 2 = cancel typing. */
182
- export declare const TypingStatus: {
183
- readonly TYPING: 1;
184
- readonly CANCEL: 2;
185
- };
186
- /** SendTyping request: send a typing indicator to a user. */
187
- export interface SendTypingReq {
188
- ilink_user_id?: string;
189
- typing_ticket?: string;
190
- /** 1=typing (default), 2=cancel typing */
191
- status?: number;
192
- }
193
- export interface SendTypingResp {
194
- ret?: number;
195
- errmsg?: string;
196
- }
197
- /** GetConfig response: bot config including typing_ticket. */
198
- export interface GetConfigResp {
199
- ret?: number;
200
- errmsg?: string;
201
- /** Base64-encoded typing ticket for sendTyping. */
202
- typing_ticket?: string;
203
- }
@@ -1,69 +0,0 @@
1
- export declare const DEFAULT_BASE_URL = "https://ilinkai.weixin.qq.com";
2
- export declare const CDN_BASE_URL = "https://novac2c.cdn.weixin.qq.com/c2c";
3
- export declare function normalizeAccountId(raw: string): string;
4
- /**
5
- * Pattern-based reverse of normalizeWeixinAccountId for known weixin ID suffixes.
6
- * Used only as a compatibility fallback when loading accounts / sync bufs stored
7
- * under the old raw ID.
8
- * e.g. "b0f5860fdecb-im-bot" → "b0f5860fdecb@im.bot"
9
- */
10
- export declare function deriveRawAccountId(normalizedId: string): string | undefined;
11
- /** Returns all accountIds registered via QR login. */
12
- export declare function listIndexedWeixinAccountIds(): string[];
13
- /** Register accountId as the sole account in the persistent index. */
14
- export declare function registerWeixinAccountId(accountId: string): void;
15
- /** Unified per-account data: token + baseUrl in one file. */
16
- export type WeixinAccountData = {
17
- token?: string;
18
- savedAt?: string;
19
- baseUrl?: string;
20
- /** Last linked Weixin user id from QR login (optional). */
21
- userId?: string;
22
- };
23
- /** Load account data by ID, with compatibility fallbacks. */
24
- export declare function loadWeixinAccount(accountId: string): WeixinAccountData | null;
25
- /**
26
- * Persist account data after QR login (merges into existing file).
27
- * - token: overwritten when provided.
28
- * - baseUrl: stored when non-empty; resolveWeixinAccount falls back to DEFAULT_BASE_URL.
29
- * - userId: set when `update.userId` is provided; omitted from file when cleared to empty.
30
- */
31
- export declare function saveWeixinAccount(accountId: string, update: {
32
- token?: string;
33
- baseUrl?: string;
34
- userId?: string;
35
- }): void;
36
- /** Remove account data file. */
37
- export declare function clearWeixinAccount(accountId: string): void;
38
- /** Remove all account data files and clear the account index. */
39
- export declare function clearAllWeixinAccounts(): void;
40
- /**
41
- * Read `routeTag` from openclaw.json (for callers without an `OpenClawConfig` object).
42
- * Checks per-account `channels.<id>.accounts[accountId].routeTag` first, then section-level
43
- * `channels.<id>.routeTag`. Matches `feat_weixin_extension` behavior; channel key is `"openclaw-weixin"`.
44
- */
45
- export declare function loadConfigRouteTag(accountId?: string): string | undefined;
46
- /**
47
- * Read `botAgent` from openclaw.json (for callers without an `OpenClawConfig` object).
48
- * Checks per-account `channels.<id>.accounts[accountId].botAgent` first, then section-level
49
- * `channels.<id>.botAgent`. Channel key is `"openclaw-weixin"`. Caller is responsible for
50
- * sanitization (see `sanitizeBotAgent`).
51
- */
52
- export declare function loadConfigBotAgent(accountId?: string): string | undefined;
53
- /**
54
- * No-op stub — config reload is now handled externally via `openclaw gateway restart`.
55
- */
56
- export declare function triggerWeixinChannelReload(): Promise<void>;
57
- export type ResolvedWeixinAccount = {
58
- accountId: string;
59
- baseUrl: string;
60
- cdnBaseUrl: string;
61
- token?: string;
62
- enabled: boolean;
63
- /** true when a token has been obtained via QR login. */
64
- configured: boolean;
65
- };
66
- /** List accountIds from the index file (written at QR login), with a credential-file fallback for legacy/broken indexes. */
67
- export declare function listWeixinAccountIds(): string[];
68
- /** Resolve a weixin account by ID, reading stored credentials. */
69
- export declare function resolveWeixinAccount(accountId?: string | null): ResolvedWeixinAccount;
@@ -1,37 +0,0 @@
1
- /** Default `bot_type` for ilink get_bot_qrcode / get_qrcode_status (this channel build). */
2
- export declare const DEFAULT_ILINK_BOT_TYPE = "3";
3
- /**
4
- * Build the URL-encoded endpoint for the QR status long-poll. Exported for
5
- * unit testing — `pollQRStatus` uses this exact helper, so a test on the
6
- * helper covers the real production path.
7
- */
8
- export declare function buildPollQRStatusEndpoint(qrcode: string, verifyCode?: string): string;
9
- export type WeixinQrStartResult = {
10
- qrcodeUrl?: string;
11
- message: string;
12
- sessionKey: string;
13
- };
14
- export type WeixinQrWaitResult = {
15
- connected: boolean;
16
- botToken?: string;
17
- accountId?: string;
18
- baseUrl?: string;
19
- /** The user ID of the person who scanned the QR code; add to allowFrom. */
20
- userId?: string;
21
- message: string;
22
- };
23
- export declare function startWeixinLoginWithQr(opts: {
24
- verbose?: boolean;
25
- timeoutMs?: number;
26
- force?: boolean;
27
- accountId?: string;
28
- apiBaseUrl: string;
29
- botType?: string;
30
- }): Promise<WeixinQrStartResult>;
31
- export declare function waitForWeixinLogin(opts: {
32
- timeoutMs?: number;
33
- verbose?: boolean;
34
- sessionKey: string;
35
- apiBaseUrl: string;
36
- botType?: string;
37
- }): Promise<WeixinQrWaitResult>;
@@ -1,67 +0,0 @@
1
- import type { Agent } from "./agent/interface.js";
2
- import type { PendingFinalChunk } from "./messaging/quota-manager.js";
3
- import type { RuntimeMediaStore } from "../channels/media-store.js";
4
- import type { PerfTracer } from "../perf/perf-tracer.js";
5
- import type { ActiveTurnRegistry } from "../sessions/active-turn-registry.js";
6
- export type LoginOptions = {
7
- /** Override the API base URL. */
8
- baseUrl?: string;
9
- /** Log callback (defaults to console.log). */
10
- log?: (msg: string) => void;
11
- };
12
- export type StartOptions = {
13
- /** Account ID to use. Auto-selects the first registered account if omitted. */
14
- accountId?: string;
15
- /** Additional allowed root directories for outbound media paths. */
16
- allowedMediaRoots?: string[];
17
- /** AbortSignal to stop the bot. */
18
- abortSignal?: AbortSignal;
19
- /** Log callback (defaults to console.log). */
20
- log?: (msg: string) => void;
21
- /** Reset outbound quota when an inbound message arrives. */
22
- onInbound?: (chatKey: string) => void;
23
- /** Reserve the per-chat final-tier slot before sending the final reply.
24
- * Returns false when the final tier (FINAL_BUDGET) is exhausted; callers
25
- * must drop the send and log when this happens. */
26
- reserveFinal?: (chatKey: string) => boolean;
27
- finalRemaining?: (chatKey: string) => number;
28
- hasPendingFinal?: (chatKey: string) => boolean;
29
- drainPendingFinal?: (chatKey: string, available: number) => PendingFinalChunk[];
30
- prependPendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
31
- enqueuePendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
32
- dropPendingFinal?: (chatKey: string) => void;
33
- mediaStore?: RuntimeMediaStore;
34
- perfTracer?: PerfTracer;
35
- /** Read the chat's current session synchronously for dispatch-time binding. */
36
- peekCurrentSessionAlias?: (chatKey: string) => string | undefined;
37
- /** Persist a background turn's final result for later replay. */
38
- setBackgroundResult?: (chatKey: string, alias: string, result: {
39
- text: string;
40
- status: "done" | "error";
41
- finished_at: string;
42
- }) => Promise<void>;
43
- /** Shared in-flight turn registry for dispatch-time foreground tracking. */
44
- activeTurns?: ActiveTurnRegistry;
45
- };
46
- /**
47
- * Interactive QR-code login. Prints the QR code to the terminal and waits
48
- * for the user to scan it with WeChat.
49
- *
50
- * Returns the normalized account ID on success.
51
- */
52
- export declare function login(opts?: LoginOptions): Promise<string>;
53
- /**
54
- * Remove all stored WeChat account credentials.
55
- */
56
- export declare function logout(opts?: {
57
- log?: (msg: string) => void;
58
- }): void;
59
- /**
60
- * Check whether at least one WeChat account is logged in and configured.
61
- */
62
- export declare function isLoggedIn(): boolean;
63
- /**
64
- * Start the bot — long-polls for new messages and dispatches them to the agent.
65
- * Blocks until the abort signal fires or an unrecoverable error occurs.
66
- */
67
- export declare function start(agent: Agent, opts?: StartOptions): Promise<void>;
@@ -1,6 +0,0 @@
1
- /** Encrypt buffer with AES-128-ECB (PKCS7 padding is default). */
2
- export declare function encryptAesEcb(plaintext: Buffer, key: Buffer): Buffer;
3
- /** Decrypt buffer with AES-128-ECB (PKCS7 padding). */
4
- export declare function decryptAesEcb(ciphertext: Buffer, key: Buffer): Buffer;
5
- /** Compute AES-128-ECB ciphertext size (PKCS7 padding to 16-byte boundary). */
6
- export declare function aesEcbPaddedSize(plaintextSize: number): number;
@@ -1,17 +0,0 @@
1
- /**
2
- * Upload one buffer to the Weixin CDN with AES-128-ECB encryption.
3
- * Returns the download encrypted_query_param from the CDN response.
4
- * Retries up to UPLOAD_MAX_RETRIES times on server errors; client errors (4xx) abort immediately.
5
- */
6
- export declare function uploadBufferToCdn(params: {
7
- buf: Buffer;
8
- /** From getUploadUrl.upload_full_url; POST target when set (takes precedence over uploadParam). */
9
- uploadFullUrl?: string;
10
- uploadParam?: string;
11
- filekey: string;
12
- cdnBaseUrl: string;
13
- label: string;
14
- aeskey: Buffer;
15
- }): Promise<{
16
- downloadParam: string;
17
- }>;
@@ -1,11 +0,0 @@
1
- /**
2
- * Unified CDN URL construction for Weixin CDN upload/download.
3
- */
4
- /** Build a CDN download URL from encrypt_query_param. */
5
- export declare function buildCdnDownloadUrl(encryptedQueryParam: string, cdnBaseUrl: string): string;
6
- /** Build a CDN upload URL from upload_param and filekey. */
7
- export declare function buildCdnUploadUrl(params: {
8
- cdnBaseUrl: string;
9
- uploadParam: string;
10
- filekey: string;
11
- }): string;
@@ -1,9 +0,0 @@
1
- /**
2
- * Download and AES-128-ECB decrypt a CDN media file. Returns plaintext Buffer.
3
- * aesKeyBase64: CDNMedia.aes_key JSON field (see parseAesKey for supported formats).
4
- */
5
- export declare function downloadAndDecryptBuffer(encryptedQueryParam: string, aesKeyBase64: string, cdnBaseUrl: string, label: string, fullUrl?: string, maxBytes?: number): Promise<Buffer>;
6
- /**
7
- * Download plain (unencrypted) bytes from the CDN. Returns the raw Buffer.
8
- */
9
- export declare function downloadPlainCdnBuffer(encryptedQueryParam: string, cdnBaseUrl: string, label: string, fullUrl?: string, maxBytes?: number): Promise<Buffer>;
@@ -1,42 +0,0 @@
1
- import type { WeixinApiOptions } from "../api/api.js";
2
- export type UploadedFileInfo = {
3
- filekey: string;
4
- /** 由 upload_param 上传后 CDN 返回的下载加密参数; fill into ImageItem.media.encrypt_query_param */
5
- downloadEncryptedQueryParam: string;
6
- /** AES-128-ECB key, hex-encoded; convert to base64 for CDNMedia.aes_key */
7
- aeskey: string;
8
- /** Plaintext file size in bytes */
9
- fileSize: number;
10
- /** Ciphertext file size in bytes (AES-128-ECB with PKCS7 padding); use for ImageItem.hd_size / mid_size */
11
- fileSizeCiphertext: number;
12
- };
13
- /**
14
- * Download a remote media URL (image, video, file) to a local temp file in destDir.
15
- * Returns the local file path; extension is inferred from Content-Type / URL.
16
- */
17
- export declare function downloadRemoteImageToTemp(url: string, destDir: string): Promise<string>;
18
- /** Upload a local image file to the Weixin CDN with AES-128-ECB encryption. */
19
- export declare function uploadFileToWeixin(params: {
20
- filePath: string;
21
- toUserId: string;
22
- opts: WeixinApiOptions;
23
- cdnBaseUrl: string;
24
- }): Promise<UploadedFileInfo>;
25
- /** Upload a local video file to the Weixin CDN. */
26
- export declare function uploadVideoToWeixin(params: {
27
- filePath: string;
28
- toUserId: string;
29
- opts: WeixinApiOptions;
30
- cdnBaseUrl: string;
31
- }): Promise<UploadedFileInfo>;
32
- /**
33
- * Upload a local file attachment (non-image, non-video) to the Weixin CDN.
34
- * Uses media_type=FILE; no thumbnail required.
35
- */
36
- export declare function uploadFileAttachmentToWeixin(params: {
37
- filePath: string;
38
- fileName: string;
39
- toUserId: string;
40
- opts: WeixinApiOptions;
41
- cdnBaseUrl: string;
42
- }): Promise<UploadedFileInfo>;
@@ -1,6 +0,0 @@
1
- export type { Agent, ChatRequest, ChatResponse } from "./agent/interface.js";
2
- export { login, start, logout, isLoggedIn } from "./bot.js";
3
- export type { LoginOptions, StartOptions } from "./bot.js";
4
- export { sendMessageWeixin, markdownToPlainText } from "./messaging/send.js";
5
- export { getContextToken, setContextToken, restoreContextTokens, clearContextTokensForAccount, findAccountIdsByContextToken, } from "./messaging/inbound.js";
6
- export { resolveWeixinAccount, listWeixinAccountIds, clearAllWeixinAccounts } from "./auth/accounts.js";
@@ -1,18 +0,0 @@
1
- import type { WeixinInboundMediaOpts } from "../messaging/inbound.js";
2
- import type { WeixinMessage } from "../api/types.js";
3
- /** Persist a buffer via the framework's unified media store. */
4
- type SaveMediaFn = (buffer: Buffer, contentType?: string, subdir?: string, maxBytes?: number, originalFilename?: string) => Promise<{
5
- path: string;
6
- }>;
7
- /**
8
- * Download and decrypt media from a single MessageItem.
9
- * Returns the populated WeixinInboundMediaOpts fields; empty object on unsupported type or failure.
10
- */
11
- export declare function downloadMediaFromItem(item: WeixinMessage["item_list"] extends (infer T)[] | undefined ? T : never, deps: {
12
- cdnBaseUrl: string;
13
- saveMedia: SaveMediaFn;
14
- log: (msg: string) => void;
15
- errLog: (msg: string) => void;
16
- label: string;
17
- }): Promise<WeixinInboundMediaOpts>;
18
- export {};
@@ -1,6 +0,0 @@
1
- /** Get MIME type from filename extension. Returns "application/octet-stream" for unknown extensions. */
2
- export declare function getMimeFromFilename(filename: string): string;
3
- /** Get file extension from MIME type. Returns ".bin" for unknown types. */
4
- export declare function getExtensionFromMime(mimeType: string): string;
5
- /** Get file extension from Content-Type header or URL path. Returns ".bin" for unknown. */
6
- export declare function getExtensionFromContentTypeOrUrl(contentType: string | null, url: string): string;
@@ -1,8 +0,0 @@
1
- /**
2
- * Try to transcode a SILK audio buffer to WAV using silk-wasm.
3
- * silk-wasm's decode() returns { data: Uint8Array (pcm_s16le), duration: number }.
4
- *
5
- * Returns a WAV Buffer on success, or null if silk-wasm is unavailable or decoding fails.
6
- * Callers should fall back to passing the raw SILK file when null is returned.
7
- */
8
- export declare function silkToWav(silkBuf: Buffer): Promise<Buffer | null>;
@@ -1,2 +0,0 @@
1
- export declare function buildBackgroundCompletionNotice(internalAlias: string, status: "done" | "error"): string;
2
- export declare function shouldSendBackgroundNotice(reserve: (() => boolean) | undefined): boolean;
@@ -1,9 +0,0 @@
1
- /** Toggle debug mode for a bot account. Returns the new state. */
2
- export declare function toggleDebugMode(accountId: string): boolean;
3
- /** Check whether debug mode is active for a bot account. */
4
- export declare function isDebugMode(accountId: string): boolean;
5
- /**
6
- * Reset internal state — only for tests.
7
- * @internal
8
- */
9
- export declare function _resetForTest(): void;