xiaozuoassistant 0.2.25 → 0.2.27

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.
@@ -59,38 +59,47 @@ export class FeishuChannel extends BaseChannel {
59
59
  console.log(`Starting WebSocket client for Feishu Bot: ${name}`);
60
60
  // MUST capture botName and client references within this loop closure to prevent overriding
61
61
  const botName = name;
62
- await wsClient.start({
63
- eventDispatcher: new lark.EventDispatcher({
64
- encryptKey: botConfig.encryptKey || '',
65
- verificationToken: botConfig.verificationToken || ''
66
- }).register({
67
- 'im.message.receive_v1': async (data) => {
68
- console.log(`[Feishu-${botName}] Received message event:`, data);
69
- const event = data.message;
70
- const sender = data.sender;
71
- if (!event || !sender) {
72
- console.log(`[Feishu-${botName}] Invalid event structure:`, data);
73
- return;
74
- }
75
- // Ignore bot messages
76
- if (sender.sender_type !== 'user') {
77
- console.log(`[Feishu-${botName}] Ignoring bot message`);
78
- return;
79
- }
80
- try {
81
- const content = JSON.parse(event.content).text;
82
- console.log(`[Feishu-${botName}] Received message: ${content}`);
83
- // Use chat_id for group chats, open_id/user_id for p2p?
84
- // Actually message.chat_id is universal for where the message comes from.
85
- const sessionId = `feishu:${botName}:${event.chat_id}`;
86
- console.log(`[Feishu-${botName}] Emitting message with sessionId: ${sessionId}`);
87
- this.emitMessage(sessionId, content);
88
- }
89
- catch (e) {
90
- console.error(`[Feishu-${botName}] Failed to parse message content:`, e);
91
- }
62
+ const eventDispatcher = new lark.EventDispatcher({
63
+ encryptKey: botConfig.encryptKey || '',
64
+ verificationToken: botConfig.verificationToken || ''
65
+ });
66
+ // @ts-ignore
67
+ const originalDo = eventDispatcher.do;
68
+ // @ts-ignore
69
+ eventDispatcher.do = function (data) {
70
+ console.log(`[Feishu-${botName}] WS payload received:`, JSON.stringify(data).substring(0, 200));
71
+ return originalDo.call(this, data);
72
+ };
73
+ eventDispatcher.register({
74
+ 'im.message.receive_v1': async (data) => {
75
+ console.log(`[Feishu-${botName}] Received message event:`, data);
76
+ const event = data.message;
77
+ const sender = data.sender;
78
+ if (!event || !sender) {
79
+ console.log(`[Feishu-${botName}] Invalid event structure:`, data);
80
+ return;
81
+ }
82
+ // Ignore bot messages
83
+ if (sender.sender_type !== 'user') {
84
+ console.log(`[Feishu-${botName}] Ignoring bot message`);
85
+ return;
86
+ }
87
+ try {
88
+ const content = JSON.parse(event.content).text;
89
+ console.log(`[Feishu-${botName}] Received message: ${content}`);
90
+ // Use chat_id for group chats, open_id/user_id for p2p?
91
+ // Actually message.chat_id is universal for where the message comes from.
92
+ const sessionId = `feishu:${botName}:${event.chat_id}`;
93
+ console.log(`[Feishu-${botName}] Emitting message with sessionId: ${sessionId}`);
94
+ this.emitMessage(sessionId, content);
92
95
  }
93
- })
96
+ catch (e) {
97
+ console.error(`[Feishu-${botName}] Failed to parse message content:`, e);
98
+ }
99
+ }
100
+ });
101
+ await wsClient.start({
102
+ eventDispatcher: eventDispatcher
94
103
  });
95
104
  this.bots.push({ name, client, wsClient });
96
105
  console.log(`Feishu Bot ${name} Started (WebSocket Mode)`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaozuoassistant",
3
- "version": "0.2.25",
3
+ "version": "0.2.27",
4
4
  "description": "A local-first personal AI assistant with multi-channel support and enhanced memory.",
5
5
  "author": "mantle.lau",
6
6
  "license": "MIT",