@wu529778790/open-im 1.8.3-beta.1 → 1.8.3-beta.10
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/channels/capabilities.js +0 -5
- package/dist/channels/capabilities.test.js +1 -1
- package/dist/commands/handler.d.ts +2 -2
- package/dist/config-web.js +0 -1
- package/dist/config.d.ts +2 -36
- package/dist/config.js +23 -101
- package/dist/index.js +0 -22
- package/dist/setup.js +150 -73
- package/dist/shared/ai-task.test.js +0 -4
- package/dist/workbuddy/centrifuge-client.js +13 -5
- package/dist/workbuddy/client.d.ts +4 -16
- package/dist/workbuddy/client.js +133 -93
- package/dist/workbuddy/oauth.d.ts +1 -1
- package/dist/workbuddy/oauth.js +4 -3
- package/package.json +1 -1
- package/dist/wechat/auth/device-bind.d.ts +0 -13
- package/dist/wechat/auth/device-bind.js +0 -75
- package/dist/wechat/auth/device-guid.d.ts +0 -5
- package/dist/wechat/auth/device-guid.js +0 -28
- package/dist/wechat/auth/environments.d.ts +0 -5
- package/dist/wechat/auth/environments.js +0 -21
- package/dist/wechat/auth/index.d.ts +0 -7
- package/dist/wechat/auth/index.js +0 -5
- package/dist/wechat/auth/qclaw-api.d.ts +0 -26
- package/dist/wechat/auth/qclaw-api.js +0 -100
- package/dist/wechat/auth/types.d.ts +0 -18
- package/dist/wechat/auth/types.js +0 -4
- package/dist/wechat/auth/wechat-login.d.ts +0 -17
- package/dist/wechat/auth/wechat-login.js +0 -168
- package/dist/wechat/client.d.ts +0 -33
- package/dist/wechat/client.js +0 -187
- package/dist/wechat/client.test.d.ts +0 -1
- package/dist/wechat/client.test.js +0 -30
- package/dist/wechat/event-handler.d.ts +0 -11
- package/dist/wechat/event-handler.js +0 -286
- package/dist/wechat/message-sender.d.ts +0 -11
- package/dist/wechat/message-sender.js +0 -151
- package/dist/wechat/message-sender.test.d.ts +0 -1
- package/dist/wechat/message-sender.test.js +0 -35
- package/dist/wechat/qclaw-transport.d.ts +0 -66
- package/dist/wechat/qclaw-transport.js +0 -303
- package/dist/wechat/transport.d.ts +0 -41
- package/dist/wechat/transport.js +0 -5
- package/dist/wechat/types.d.ts +0 -94
- package/dist/wechat/types.js +0 -5
- package/dist/wechat/workbuddy-transport.d.ts +0 -33
- package/dist/wechat/workbuddy-transport.js +0 -145
|
@@ -2,7 +2,6 @@ const PLATFORM_LABELS = {
|
|
|
2
2
|
telegram: "Telegram",
|
|
3
3
|
feishu: "Feishu",
|
|
4
4
|
qq: "QQ",
|
|
5
|
-
wechat: "微信",
|
|
6
5
|
wework: "企业微信",
|
|
7
6
|
dingtalk: "钉钉",
|
|
8
7
|
workbuddy: "WorkBuddy",
|
|
@@ -20,10 +19,6 @@ export const CHANNEL_CAPABILITIES = {
|
|
|
20
19
|
inbound: { text: "native", image: "fallback", file: "fallback", voice: "fallback", video: "fallback" },
|
|
21
20
|
outbound: { streamEdit: "none", streamPush: "none", image: "fallback", card: "fallback", typing: "fallback" },
|
|
22
21
|
},
|
|
23
|
-
wechat: {
|
|
24
|
-
inbound: { text: "native", image: "fallback", file: "fallback", voice: "fallback", video: "fallback" },
|
|
25
|
-
outbound: { streamEdit: "native", streamPush: "fallback", image: "fallback", card: "native", typing: "native" },
|
|
26
|
-
},
|
|
27
22
|
wework: {
|
|
28
23
|
inbound: { text: "native", image: "fallback", file: "fallback", voice: "fallback", video: "fallback" },
|
|
29
24
|
outbound: { streamEdit: "native", streamPush: "fallback", image: "native", card: "native", typing: "native" },
|
|
@@ -10,7 +10,7 @@ describe("channel capabilities", () => {
|
|
|
10
10
|
expect(CHANNEL_CAPABILITIES.qq.inbound.video).toBe("fallback");
|
|
11
11
|
expect(CHANNEL_CAPABILITIES.qq.outbound.streamEdit).toBe("none");
|
|
12
12
|
expect(CHANNEL_CAPABILITIES.qq.outbound.streamPush).toBe("none");
|
|
13
|
-
expect(CHANNEL_CAPABILITIES.
|
|
13
|
+
expect(CHANNEL_CAPABILITIES.wework.inbound.image).toBe("fallback");
|
|
14
14
|
expect(CHANNEL_CAPABILITIES.wework.inbound.video).toBe("fallback");
|
|
15
15
|
expect(CHANNEL_CAPABILITIES.wework.outbound.image).toBe("native");
|
|
16
16
|
expect(CHANNEL_CAPABILITIES.dingtalk.inbound.file).toBe("fallback");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Config } from '../config.js';
|
|
1
|
+
import { type Config, type Platform } from '../config.js';
|
|
2
2
|
import type { SessionManager } from '../session/session-manager.js';
|
|
3
3
|
import type { RequestQueue } from '../queue/request-queue.js';
|
|
4
4
|
import type { ThreadContext } from '../shared/types.js';
|
|
@@ -18,7 +18,7 @@ export type ClaudeRequestHandler = (userId: string, chatId: string, prompt: stri
|
|
|
18
18
|
export declare class CommandHandler {
|
|
19
19
|
private deps;
|
|
20
20
|
constructor(deps: CommandHandlerDeps);
|
|
21
|
-
dispatch(text: string, chatId: string, userId: string, platform:
|
|
21
|
+
dispatch(text: string, chatId: string, userId: string, platform: Platform, handleClaudeRequest: ClaudeRequestHandler): Promise<boolean>;
|
|
22
22
|
private handleHelp;
|
|
23
23
|
private handleNew;
|
|
24
24
|
private handlePwd;
|
package/dist/config-web.js
CHANGED
package/dist/config.d.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { type LogLevel } from './logger.js';
|
|
2
|
-
export type Platform = 'dingtalk' | 'feishu' | 'qq' | 'telegram' | '
|
|
2
|
+
export type Platform = 'dingtalk' | 'feishu' | 'qq' | 'telegram' | 'wework' | 'workbuddy';
|
|
3
3
|
export type AiCommand = 'claude' | 'codex' | 'codebuddy';
|
|
4
4
|
export interface Config {
|
|
5
5
|
enabledPlatforms: Platform[];
|
|
6
6
|
telegramBotToken?: string;
|
|
7
7
|
feishuAppId?: string;
|
|
8
8
|
feishuAppSecret?: string;
|
|
9
|
-
wechatAppId?: string;
|
|
10
|
-
wechatAppSecret?: string;
|
|
11
|
-
wechatToken?: string;
|
|
12
|
-
wechatJwtToken?: string;
|
|
13
|
-
wechatLoginKey?: string;
|
|
14
|
-
wechatGuid?: string;
|
|
15
|
-
wechatUserId?: string;
|
|
16
|
-
wechatWsUrl?: string;
|
|
17
9
|
weworkCorpId?: string;
|
|
18
10
|
weworkSecret?: string;
|
|
19
11
|
weworkWsUrl?: string;
|
|
@@ -26,7 +18,6 @@ export interface Config {
|
|
|
26
18
|
telegramAllowedUserIds: string[];
|
|
27
19
|
feishuAllowedUserIds: string[];
|
|
28
20
|
qqAllowedUserIds: string[];
|
|
29
|
-
wechatAllowedUserIds: string[];
|
|
30
21
|
weworkAllowedUserIds: string[];
|
|
31
22
|
dingtalkAllowedUserIds: string[];
|
|
32
23
|
workbuddyAllowedUserIds: string[];
|
|
@@ -61,22 +52,6 @@ export interface Config {
|
|
|
61
52
|
aiCommand?: AiCommand;
|
|
62
53
|
allowedUserIds: string[];
|
|
63
54
|
};
|
|
64
|
-
wechat?: {
|
|
65
|
-
enabled: boolean;
|
|
66
|
-
aiCommand?: AiCommand;
|
|
67
|
-
loginMode?: 'qclaw' | 'workbuddy';
|
|
68
|
-
wsUrl?: string;
|
|
69
|
-
token?: string;
|
|
70
|
-
jwtToken?: string;
|
|
71
|
-
loginKey?: string;
|
|
72
|
-
guid?: string;
|
|
73
|
-
userId?: string;
|
|
74
|
-
allowedUserIds: string[];
|
|
75
|
-
workbuddyAccessToken?: string;
|
|
76
|
-
workbuddyRefreshToken?: string;
|
|
77
|
-
workbuddyBaseUrl?: string;
|
|
78
|
-
workbuddyHostId?: string;
|
|
79
|
-
};
|
|
80
55
|
wework?: {
|
|
81
56
|
enabled: boolean;
|
|
82
57
|
aiCommand?: AiCommand;
|
|
@@ -124,17 +99,8 @@ interface FilePlatformQQ {
|
|
|
124
99
|
}
|
|
125
100
|
interface FilePlatformWechat {
|
|
126
101
|
enabled?: boolean;
|
|
127
|
-
appId?: string;
|
|
128
|
-
appSecret?: string;
|
|
129
102
|
aiCommand?: AiCommand;
|
|
130
|
-
/** 连接模式:qclaw(QClaw JPRX 网关)或 workbuddy(Centrifuge) */
|
|
131
|
-
loginMode?: 'qclaw' | 'workbuddy';
|
|
132
|
-
token?: string;
|
|
133
|
-
jwtToken?: string;
|
|
134
|
-
loginKey?: string;
|
|
135
|
-
guid?: string;
|
|
136
103
|
userId?: string;
|
|
137
|
-
wsUrl?: string;
|
|
138
104
|
allowedUserIds?: string[];
|
|
139
105
|
workbuddyAccessToken?: string;
|
|
140
106
|
workbuddyRefreshToken?: string;
|
|
@@ -227,7 +193,7 @@ export declare function hasClaudeCredentials(): boolean;
|
|
|
227
193
|
/** 检测是否需要交互式配置(无 token 且无环境变量) */
|
|
228
194
|
export declare function needsSetup(): boolean;
|
|
229
195
|
export declare function loadConfig(): Config;
|
|
230
|
-
/**
|
|
196
|
+
/** 获取已配置凭证的平台列表 */
|
|
231
197
|
export declare function getPlatformsWithCredentials(config: Config): Platform[];
|
|
232
198
|
export declare function resolvePlatformAiCommand(config: Config, platform: Platform): AiCommand;
|
|
233
199
|
export declare function getConfiguredAiCommands(config: Config): AiCommand[];
|
package/dist/config.js
CHANGED
|
@@ -179,10 +179,10 @@ export function needsSetup() {
|
|
|
179
179
|
return false;
|
|
180
180
|
if (process.env.QQ_BOT_APPID && process.env.QQ_BOT_SECRET)
|
|
181
181
|
return false;
|
|
182
|
-
if (process.env.
|
|
183
|
-
|
|
184
|
-
if (process.env.WECHAT_TOKEN && process.env.WECHAT_GUID && process.env.WECHAT_USER_ID)
|
|
182
|
+
if (process.env.WECHAT_WORKBUDDY_ACCESS_TOKEN &&
|
|
183
|
+
process.env.WECHAT_WORKBUDDY_REFRESH_TOKEN) {
|
|
185
184
|
return false;
|
|
185
|
+
}
|
|
186
186
|
if (process.env.WEWORK_CORP_ID && process.env.WEWORK_SECRET)
|
|
187
187
|
return false;
|
|
188
188
|
if (process.env.DINGTALK_CLIENT_ID && process.env.DINGTALK_CLIENT_SECRET)
|
|
@@ -191,18 +191,19 @@ export function needsSetup() {
|
|
|
191
191
|
const tg = file.platforms?.telegram;
|
|
192
192
|
const fs = file.platforms?.feishu;
|
|
193
193
|
const qq = file.platforms?.qq;
|
|
194
|
-
const wc = file.platforms?.wechat;
|
|
195
194
|
const ww = file.platforms?.wework;
|
|
196
195
|
const dt = file.platforms?.dingtalk;
|
|
196
|
+
const wb = file.platforms?.workbuddy;
|
|
197
|
+
// Also check legacy platforms.wechat for migration path
|
|
198
|
+
const legacyWc = file.platforms?.wechat;
|
|
197
199
|
const hasTelegram = !!tg?.botToken;
|
|
198
200
|
const hasFeishu = !!(fs?.appId && fs?.appSecret);
|
|
199
201
|
const hasQQ = !!(qq?.appId && qq?.secret);
|
|
200
|
-
// 微信支持 AGP 协议(token + guid + userId)或标准协议(appId + appSecret)
|
|
201
|
-
const hasWechat = !!(wc?.token && wc?.guid && wc?.userId) || !!(wc?.appId && wc?.appSecret);
|
|
202
|
-
// 企业微信只需要 corpId 和 secret
|
|
203
202
|
const hasWework = !!(ww?.corpId && ww?.secret);
|
|
204
203
|
const hasDingtalk = !!(dt?.clientId && dt?.clientSecret);
|
|
205
|
-
|
|
204
|
+
const hasWorkBuddy = !!(wb?.accessToken && wb?.refreshToken && wb?.userId);
|
|
205
|
+
const hasLegacyWechat = !!(legacyWc?.workbuddyAccessToken && legacyWc?.workbuddyRefreshToken);
|
|
206
|
+
return !hasTelegram && !hasFeishu && !hasQQ && !hasWework && !hasDingtalk && !hasWorkBuddy && !hasLegacyWechat;
|
|
206
207
|
}
|
|
207
208
|
function parseCommaSeparated(value) {
|
|
208
209
|
return value.split(',').map((s) => s.trim()).filter(Boolean);
|
|
@@ -230,10 +231,18 @@ export function loadConfig() {
|
|
|
230
231
|
const fileTelegram = file.platforms?.telegram;
|
|
231
232
|
const fileFeishu = file.platforms?.feishu;
|
|
232
233
|
const fileQQ = file.platforms?.qq;
|
|
233
|
-
const fileWechat = file.platforms?.wechat;
|
|
234
234
|
const fileWework = file.platforms?.wework;
|
|
235
235
|
const fileDingtalk = file.platforms?.dingtalk;
|
|
236
|
-
|
|
236
|
+
// Auto-migrate legacy platforms.wechat WorkBuddy credentials → platforms.workbuddy
|
|
237
|
+
const legacyWechat = file.platforms?.wechat;
|
|
238
|
+
const fileWorkBuddy = file.platforms?.workbuddy ?? (legacyWechat?.workbuddyAccessToken && legacyWechat?.workbuddyRefreshToken
|
|
239
|
+
? {
|
|
240
|
+
accessToken: legacyWechat.workbuddyAccessToken,
|
|
241
|
+
refreshToken: legacyWechat.workbuddyRefreshToken,
|
|
242
|
+
userId: legacyWechat.userId,
|
|
243
|
+
baseUrl: legacyWechat.workbuddyBaseUrl,
|
|
244
|
+
}
|
|
245
|
+
: undefined);
|
|
237
246
|
// 1. 加载各平台凭证(env 优先,其次新结构,最后旧字段)
|
|
238
247
|
const telegramBotToken = process.env.TELEGRAM_BOT_TOKEN ??
|
|
239
248
|
fileTelegram?.botToken ??
|
|
@@ -248,33 +257,6 @@ export function loadConfig() {
|
|
|
248
257
|
fileQQ?.appId;
|
|
249
258
|
const qqSecret = process.env.QQ_BOT_SECRET ??
|
|
250
259
|
fileQQ?.secret;
|
|
251
|
-
// 微信支持两种协议:
|
|
252
|
-
// 1. AGP 协议:token + guid + userId(推荐)
|
|
253
|
-
// 2. 标准协议:appId + appSecret
|
|
254
|
-
const wechatLoginMode = fileWechat?.loginMode ?? 'qclaw';
|
|
255
|
-
const wechatToken = process.env.WECHAT_TOKEN ??
|
|
256
|
-
fileWechat?.token;
|
|
257
|
-
const wechatJwtToken = fileWechat?.jwtToken;
|
|
258
|
-
const wechatLoginKey = fileWechat?.loginKey;
|
|
259
|
-
const wechatGuid = process.env.WECHAT_GUID ??
|
|
260
|
-
fileWechat?.guid;
|
|
261
|
-
const wechatUserId = process.env.WECHAT_USER_ID ??
|
|
262
|
-
fileWechat?.userId;
|
|
263
|
-
const wechatAppId = process.env.WECHAT_APP_ID ??
|
|
264
|
-
fileWechat?.appId;
|
|
265
|
-
const wechatAppSecret = process.env.WECHAT_APP_SECRET ??
|
|
266
|
-
fileWechat?.appSecret;
|
|
267
|
-
const wechatWsUrl = process.env.WECHAT_WS_URL ??
|
|
268
|
-
fileWechat?.wsUrl;
|
|
269
|
-
// 微信 WorkBuddy 模式凭证(loginMode === 'workbuddy' 时使用)
|
|
270
|
-
const wechatWorkbuddyAccessToken = process.env.WECHAT_WORKBUDDY_ACCESS_TOKEN ??
|
|
271
|
-
fileWechat?.workbuddyAccessToken;
|
|
272
|
-
const wechatWorkbuddyRefreshToken = process.env.WECHAT_WORKBUDDY_REFRESH_TOKEN ??
|
|
273
|
-
fileWechat?.workbuddyRefreshToken;
|
|
274
|
-
const wechatWorkbuddyBaseUrl = process.env.WECHAT_WORKBUDDY_BASE_URL ??
|
|
275
|
-
fileWechat?.workbuddyBaseUrl;
|
|
276
|
-
const wechatWorkbuddyHostId = process.env.WECHAT_WORKBUDDY_HOST_ID ??
|
|
277
|
-
fileWechat?.workbuddyHostId;
|
|
278
260
|
const weworkCorpId = process.env.WEWORK_CORP_ID ??
|
|
279
261
|
fileWework?.corpId;
|
|
280
262
|
const weworkSecret = process.env.WEWORK_SECRET ??
|
|
@@ -305,26 +287,14 @@ export function loadConfig() {
|
|
|
305
287
|
const telegramEnabledFlag = fileTelegram?.enabled;
|
|
306
288
|
const feishuEnabledFlag = fileFeishu?.enabled;
|
|
307
289
|
const qqEnabledFlag = fileQQ?.enabled;
|
|
308
|
-
const wechatEnabledFlag = fileWechat?.enabled;
|
|
309
290
|
const weworkEnabledFlag = fileWework?.enabled;
|
|
310
291
|
const dingtalkEnabledFlag = fileDingtalk?.enabled;
|
|
311
292
|
const workbuddyEnabledFlag = fileWorkBuddy?.enabled;
|
|
312
293
|
const telegramEnabled = !!telegramBotToken && (telegramEnabledFlag !== false);
|
|
313
294
|
const feishuEnabled = !!(feishuAppId && feishuAppSecret) && (feishuEnabledFlag !== false);
|
|
314
295
|
const qqEnabled = !!(qqAppId && qqSecret) && (qqEnabledFlag !== false);
|
|
315
|
-
// 微信启用条件:
|
|
316
|
-
// - qclaw 模式:AGP 协议凭证(token + guid + userId)或 标准协议凭证(appId + appSecret)
|
|
317
|
-
// - workbuddy 模式:workbuddy OAuth 凭证
|
|
318
|
-
const hasWechatAGPCreds = !!(wechatToken && wechatGuid && wechatUserId);
|
|
319
|
-
const hasWechatStandardCreds = !!(wechatAppId && wechatAppSecret);
|
|
320
|
-
const hasWechatWorkbuddyCreds = !!(wechatWorkbuddyAccessToken && wechatWorkbuddyRefreshToken);
|
|
321
|
-
const wechatEnabled = (wechatLoginMode === 'workbuddy'
|
|
322
|
-
? hasWechatWorkbuddyCreds
|
|
323
|
-
: (hasWechatAGPCreds || hasWechatStandardCreds)) && (wechatEnabledFlag !== false);
|
|
324
|
-
// 企业微信只需要 corpId (botId) 和 secret
|
|
325
296
|
const weworkEnabled = !!(weworkCorpId && weworkSecret) && (weworkEnabledFlag !== false);
|
|
326
297
|
const dingtalkEnabled = !!(dingtalkClientId && dingtalkClientSecret) && (dingtalkEnabledFlag !== false);
|
|
327
|
-
// WorkBuddy 需要 OAuth 凭证
|
|
328
298
|
const workbuddyEnabled = !!(workbuddyAccessToken && workbuddyRefreshToken && workbuddyUserId) && (workbuddyEnabledFlag !== false);
|
|
329
299
|
if (telegramEnabled)
|
|
330
300
|
enabledPlatforms.push('telegram');
|
|
@@ -332,8 +302,6 @@ export function loadConfig() {
|
|
|
332
302
|
enabledPlatforms.push('feishu');
|
|
333
303
|
if (qqEnabled)
|
|
334
304
|
enabledPlatforms.push('qq');
|
|
335
|
-
if (wechatEnabled)
|
|
336
|
-
enabledPlatforms.push('wechat');
|
|
337
305
|
if (weworkEnabled)
|
|
338
306
|
enabledPlatforms.push('wework');
|
|
339
307
|
if (dingtalkEnabled)
|
|
@@ -357,9 +325,6 @@ export function loadConfig() {
|
|
|
357
325
|
const qqAllowedUserIds = process.env.QQ_ALLOWED_USER_IDS !== undefined
|
|
358
326
|
? parseCommaSeparated(process.env.QQ_ALLOWED_USER_IDS)
|
|
359
327
|
: fileQQ?.allowedUserIds ?? allowedUserIds;
|
|
360
|
-
const wechatAllowedUserIds = process.env.WECHAT_ALLOWED_USER_IDS !== undefined
|
|
361
|
-
? parseCommaSeparated(process.env.WECHAT_ALLOWED_USER_IDS)
|
|
362
|
-
: fileWechat?.allowedUserIds ?? allowedUserIds;
|
|
363
328
|
const weworkAllowedUserIds = process.env.WEWORK_ALLOWED_USER_IDS !== undefined
|
|
364
329
|
? parseCommaSeparated(process.env.WEWORK_ALLOWED_USER_IDS)
|
|
365
330
|
: fileWework?.allowedUserIds ?? allowedUserIds;
|
|
@@ -569,39 +534,6 @@ export function loadConfig() {
|
|
|
569
534
|
aiCommand: normalizeAiCommand(file.platforms?.qq?.aiCommand, aiCommand),
|
|
570
535
|
allowedUserIds: qqAllowedUserIds,
|
|
571
536
|
},
|
|
572
|
-
wechat: wechatEnabled
|
|
573
|
-
? {
|
|
574
|
-
enabled: true,
|
|
575
|
-
aiCommand: normalizeAiCommand(file.platforms?.wechat?.aiCommand, aiCommand),
|
|
576
|
-
loginMode: wechatLoginMode,
|
|
577
|
-
wsUrl: wechatWsUrl,
|
|
578
|
-
token: wechatToken,
|
|
579
|
-
jwtToken: wechatJwtToken,
|
|
580
|
-
loginKey: wechatLoginKey,
|
|
581
|
-
guid: wechatGuid,
|
|
582
|
-
userId: wechatUserId,
|
|
583
|
-
allowedUserIds: wechatAllowedUserIds,
|
|
584
|
-
workbuddyAccessToken: wechatWorkbuddyAccessToken,
|
|
585
|
-
workbuddyRefreshToken: wechatWorkbuddyRefreshToken,
|
|
586
|
-
workbuddyBaseUrl: wechatWorkbuddyBaseUrl,
|
|
587
|
-
workbuddyHostId: wechatWorkbuddyHostId,
|
|
588
|
-
}
|
|
589
|
-
: {
|
|
590
|
-
enabled: false,
|
|
591
|
-
aiCommand: normalizeAiCommand(file.platforms?.wechat?.aiCommand, aiCommand),
|
|
592
|
-
loginMode: wechatLoginMode,
|
|
593
|
-
wsUrl: wechatWsUrl,
|
|
594
|
-
token: wechatToken,
|
|
595
|
-
jwtToken: wechatJwtToken,
|
|
596
|
-
loginKey: wechatLoginKey,
|
|
597
|
-
guid: wechatGuid,
|
|
598
|
-
userId: wechatUserId,
|
|
599
|
-
allowedUserIds: wechatAllowedUserIds,
|
|
600
|
-
workbuddyAccessToken: wechatWorkbuddyAccessToken,
|
|
601
|
-
workbuddyRefreshToken: wechatWorkbuddyRefreshToken,
|
|
602
|
-
workbuddyBaseUrl: wechatWorkbuddyBaseUrl,
|
|
603
|
-
workbuddyHostId: wechatWorkbuddyHostId,
|
|
604
|
-
},
|
|
605
537
|
wework: weworkEnabled
|
|
606
538
|
? {
|
|
607
539
|
enabled: true,
|
|
@@ -657,14 +589,6 @@ export function loadConfig() {
|
|
|
657
589
|
feishuAppSecret: feishuAppSecret ?? '',
|
|
658
590
|
qqAppId: qqAppId ?? '',
|
|
659
591
|
qqSecret: qqSecret ?? '',
|
|
660
|
-
wechatAppId: wechatAppId ?? '',
|
|
661
|
-
wechatAppSecret: wechatAppSecret ?? '',
|
|
662
|
-
wechatToken: wechatToken,
|
|
663
|
-
wechatJwtToken: wechatJwtToken,
|
|
664
|
-
wechatLoginKey: wechatLoginKey,
|
|
665
|
-
wechatGuid: wechatGuid,
|
|
666
|
-
wechatUserId: wechatUserId,
|
|
667
|
-
wechatWsUrl: wechatWsUrl,
|
|
668
592
|
weworkCorpId: weworkCorpId ?? '',
|
|
669
593
|
weworkSecret: weworkSecret ?? '',
|
|
670
594
|
weworkWsUrl: weworkWsUrl,
|
|
@@ -675,7 +599,6 @@ export function loadConfig() {
|
|
|
675
599
|
telegramAllowedUserIds,
|
|
676
600
|
feishuAllowedUserIds,
|
|
677
601
|
qqAllowedUserIds,
|
|
678
|
-
wechatAllowedUserIds,
|
|
679
602
|
weworkAllowedUserIds,
|
|
680
603
|
dingtalkAllowedUserIds,
|
|
681
604
|
workbuddyAllowedUserIds,
|
|
@@ -694,7 +617,7 @@ export function loadConfig() {
|
|
|
694
617
|
platforms,
|
|
695
618
|
};
|
|
696
619
|
}
|
|
697
|
-
/**
|
|
620
|
+
/** 获取已配置凭证的平台列表 */
|
|
698
621
|
export function getPlatformsWithCredentials(config) {
|
|
699
622
|
const r = [];
|
|
700
623
|
if (config.telegramBotToken)
|
|
@@ -707,10 +630,9 @@ export function getPlatformsWithCredentials(config) {
|
|
|
707
630
|
r.push('wework');
|
|
708
631
|
if (config.dingtalkClientId && config.dingtalkClientSecret)
|
|
709
632
|
r.push('dingtalk');
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
r.push('wechat');
|
|
633
|
+
const wb = config.platforms.workbuddy;
|
|
634
|
+
if (wb?.accessToken && wb?.refreshToken)
|
|
635
|
+
r.push('workbuddy');
|
|
714
636
|
return r;
|
|
715
637
|
}
|
|
716
638
|
export function resolvePlatformAiCommand(config, platform) {
|
package/dist/index.js
CHANGED
|
@@ -15,9 +15,6 @@ import { sendTextReply as sendFeishuTextReply } from "./feishu/message-sender.js
|
|
|
15
15
|
import { initQQ, stopQQ } from "./qq/client.js";
|
|
16
16
|
import { setupQQHandlers } from "./qq/event-handler.js";
|
|
17
17
|
import { sendTextReply as sendQQTextReply } from "./qq/message-sender.js";
|
|
18
|
-
import { initWeChat, stopWeChat } from "./wechat/client.js";
|
|
19
|
-
import { setupWeChatHandlers } from "./wechat/event-handler.js";
|
|
20
|
-
import { sendTextReply as sendWeChatTextReply } from "./wechat/message-sender.js";
|
|
21
18
|
import { initWeWork, stopWeWork } from "./wework/client.js";
|
|
22
19
|
import { setupWeWorkHandlers } from "./wework/event-handler.js";
|
|
23
20
|
import { sendProactiveTextReply as sendWeWorkTextReply } from "./wework/message-sender.js";
|
|
@@ -42,7 +39,6 @@ async function sendLifecycleNotification(platform, message) {
|
|
|
42
39
|
const telegramChatId = getActiveChatId("telegram");
|
|
43
40
|
const feishuChatId = getActiveChatId("feishu");
|
|
44
41
|
const qqChatId = getActiveChatId("qq");
|
|
45
|
-
const wechatChatId = getActiveChatId("wechat");
|
|
46
42
|
const weworkChatId = getActiveChatId("wework");
|
|
47
43
|
const sendPromises = [];
|
|
48
44
|
if (platform === "telegram" && telegramChatId) {
|
|
@@ -60,11 +56,6 @@ async function sendLifecycleNotification(platform, message) {
|
|
|
60
56
|
log.debug("Failed to send QQ notification:", err);
|
|
61
57
|
}));
|
|
62
58
|
}
|
|
63
|
-
if (platform === "wechat" && wechatChatId) {
|
|
64
|
-
sendPromises.push(sendWeChatTextReply(wechatChatId, message).catch((err) => {
|
|
65
|
-
log.debug("Failed to send WeChat notification:", err);
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
59
|
if (platform === "wework" && weworkChatId) {
|
|
69
60
|
sendPromises.push(sendWeWorkTextReply(weworkChatId, message).catch((err) => {
|
|
70
61
|
log.debug("Failed to send WeWork notification:", err);
|
|
@@ -173,7 +164,6 @@ export async function main() {
|
|
|
173
164
|
let telegramHandle = null;
|
|
174
165
|
let feishuHandle = null;
|
|
175
166
|
let qqHandle = null;
|
|
176
|
-
let wechatHandle = null;
|
|
177
167
|
let weworkHandle = null;
|
|
178
168
|
let dingtalkHandle = null;
|
|
179
169
|
let workbuddyHandle = null;
|
|
@@ -210,16 +200,6 @@ export async function main() {
|
|
|
210
200
|
log.error("Failed to initialize QQ:", err);
|
|
211
201
|
}
|
|
212
202
|
}
|
|
213
|
-
if (config.enabledPlatforms.includes("wechat")) {
|
|
214
|
-
try {
|
|
215
|
-
wechatHandle = setupWeChatHandlers(config, sessionManager);
|
|
216
|
-
await initWeChat(config, wechatHandle.handleEvent);
|
|
217
|
-
successfulPlatforms.push("wechat");
|
|
218
|
-
}
|
|
219
|
-
catch (err) {
|
|
220
|
-
log.error("Failed to initialize WeChat:", err);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
203
|
if (config.enabledPlatforms.includes("wework")) {
|
|
224
204
|
try {
|
|
225
205
|
weworkHandle = setupWeWorkHandlers(config, sessionManager);
|
|
@@ -290,8 +270,6 @@ export async function main() {
|
|
|
290
270
|
stopFeishu();
|
|
291
271
|
qqHandle?.stop();
|
|
292
272
|
await stopQQ();
|
|
293
|
-
wechatHandle?.stop();
|
|
294
|
-
stopWeChat();
|
|
295
273
|
weworkHandle?.stop();
|
|
296
274
|
stopWeWork();
|
|
297
275
|
dingtalkHandle?.stop();
|