xiaozuoassistant 0.2.39 → 0.2.41

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.
@@ -67,30 +67,44 @@ export class FeishuChannel extends BaseChannel {
67
67
  const originalDo = eventDispatcher.do;
68
68
  // @ts-ignore
69
69
  eventDispatcher.do = function (data) {
70
- console.log(`[Feishu-${botName}] WS payload received:`, JSON.stringify(data).substring(0, 200));
71
70
  return originalDo.call(this, data);
72
71
  };
73
72
  eventDispatcher.register({
74
73
  'im.message.receive_v1': async (data) => {
75
- console.log(`[Feishu-${botName}] Received message event:`, data);
76
74
  const event = data.message;
77
75
  const sender = data.sender;
78
76
  if (!event || !sender) {
79
- console.log(`[Feishu-${botName}] Invalid event structure:`, data);
80
77
  return;
81
78
  }
82
79
  // Ignore bot messages
83
80
  if (sender.sender_type !== 'user') {
84
- console.log(`[Feishu-${botName}] Ignoring bot message`);
85
81
  return;
86
82
  }
87
83
  try {
88
84
  const content = JSON.parse(event.content).text;
89
- console.log(`[Feishu-${botName}] Received message: ${content}`);
90
85
  // Use chat_id for group chats, open_id/user_id for p2p?
91
86
  // Actually message.chat_id is universal for where the message comes from.
92
87
  const sessionId = `feishu:${botName}:${event.chat_id}`;
93
- console.log(`[Feishu-${botName}] Emitting message with sessionId: ${sessionId}`);
88
+ // 支持飞书端发送 /archive 触发手动归档
89
+ if (content.trim().toLowerCase() === '/archive') {
90
+ console.log(`[Feishu-${botName}] Manual archive command triggered for sessionId: ${sessionId}`);
91
+ this.emitMessage(sessionId, '正在为您整理并归档当前会话的长期记忆,请稍候...');
92
+ // We can't directly call memoryManager here as it breaks architecture,
93
+ // emit a special command or let Brain handle it.
94
+ // The simplest way is to emit the command, and let the backend API handle it via event or intercept it.
95
+ // For MVP: We intercept it here and make a local HTTP request to the archive endpoint
96
+ try {
97
+ const axios = require('axios');
98
+ const configLoader = require('../config/loader.js').config;
99
+ const port = configLoader.server?.port || 3001;
100
+ await axios.post(`http://127.0.0.1:${port}/api/sessions/${encodeURIComponent(sessionId)}/archive`);
101
+ this.emitMessage(sessionId, '✅ 归档完成!我已经记住了这个会话的关键信息。');
102
+ }
103
+ catch (e) {
104
+ this.emitMessage(sessionId, `❌ 归档失败: ${e.message}`);
105
+ }
106
+ return;
107
+ }
94
108
  this.emitMessage(sessionId, content);
95
109
  }
96
110
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaozuoassistant",
3
- "version": "0.2.39",
3
+ "version": "0.2.41",
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",