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.
- package/dist/client/assets/{browser-ponyfill-Bcpejndl.js → browser-ponyfill-D4avMlka.js} +1 -1
- package/dist/client/assets/{index-BfvHy-SS.js → index-DKSwzT6T.js} +11 -11
- package/dist/client/index.html +1 -1
- package/dist/server/channels/feishu.js +40 -31
- package/dist/server/index.js +5 -2
- package/package.json +1 -1
package/dist/client/index.html
CHANGED
|
@@ -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-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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/dist/server/index.js
CHANGED
|
@@ -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 =
|
|
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)
|