xiaozuoassistant 0.2.24 → 0.2.26

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.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🍇</text></svg>" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>xiaozuoAssistant</title>
8
- <script type="module" crossorigin src="/assets/index-BfvHy-SS.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-DKSwzT6T.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-u0lXmgyZ.css">
10
10
  </head>
11
11
  <body>
@@ -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)`);
@@ -228,6 +228,7 @@ app.post('/api/fs/list', async (req, res) => {
228
228
  app.get('/api/config', async (req, res) => {
229
229
  res.json({
230
230
  userId: config.userId,
231
+ provider: config.llm.provider,
231
232
  apiKey: config.llm.apiKey,
232
233
  baseURL: config.llm.baseURL,
233
234
  model: config.llm.model,
@@ -247,11 +248,13 @@ app.get('/api/config', async (req, res) => {
247
248
  // 更新配置并写入 config.json
248
249
  app.post('/api/config', async (req, res) => {
249
250
  try {
250
- const { userId, apiKey, baseURL, model, embeddingModel, temperature, systemPrompt, memoryMaintenanceCron, sessionRetentionDays, workspace, maxHistoryMessages, maxToolIterations, feishu, feishuAppId, feishuAppSecret } = req.body;
251
+ const { userId, provider, apiKey, baseURL, model, embeddingModel, temperature, systemPrompt, memoryMaintenanceCron, sessionRetentionDays, workspace, maxHistoryMessages, maxToolIterations, feishu, feishuAppId, feishuAppSecret } = req.body;
251
252
  // 更新配置对象
252
- const newConfig = { ...config };
253
+ const newConfig = JSON.parse(JSON.stringify(config));
253
254
  if (userId !== undefined)
254
255
  newConfig.userId = String(userId || 'default').trim() || 'default';
256
+ if (provider !== undefined)
257
+ newConfig.llm.provider = provider;
255
258
  if (apiKey !== undefined)
256
259
  newConfig.llm.apiKey = apiKey;
257
260
  if (baseURL !== undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaozuoassistant",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
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",