acp-ts 1.2.3 → 1.2.4
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/agentcp.js +40 -36
- package/dist/agentws.d.ts +8 -2
- package/dist/agentws.js +22 -4
- package/dist/api.js +8 -8
- package/dist/cert.js +3 -2
- package/dist/cli.js +16 -15
- package/dist/datamanager.js +27 -11
- package/dist/filesync.js +11 -10
- package/dist/group/client.js +44 -36
- package/dist/group/cursor_store.d.ts +4 -9
- package/dist/group/cursor_store.js +12 -40
- package/dist/group/events.d.ts +2 -2
- package/dist/group/events.js +7 -27
- package/dist/group/index.d.ts +1 -1
- package/dist/group/index.js +2 -2
- package/dist/group/message_store.d.ts +5 -6
- package/dist/group/message_store.js +64 -72
- package/dist/group/operations.d.ts +1 -5
- package/dist/group/operations.js +5 -12
- package/dist/group/types.d.ts +3 -29
- package/dist/group/types.js +2 -6
- package/dist/heartbeat.js +24 -24
- package/dist/messagestore.js +9 -8
- package/dist/server.js +2053 -1699
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +19 -2
- package/dist/websocket.d.ts +12 -1
- package/dist/websocket.js +61 -28
- package/package.json +1 -1
package/dist/messagestore.js
CHANGED
|
@@ -37,6 +37,7 @@ exports.MessageStore = void 0;
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const datamanager_1 = require("./datamanager");
|
|
40
|
+
const utils_1 = require("./utils");
|
|
40
41
|
// ---- MessageStore 类 ----
|
|
41
42
|
class MessageStore {
|
|
42
43
|
constructor(options) {
|
|
@@ -90,7 +91,7 @@ class MessageStore {
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
catch (e) {
|
|
93
|
-
|
|
94
|
+
utils_1.logger.error('[MessageStore] 加载索引失败:', e);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
}
|
|
@@ -119,7 +120,7 @@ class MessageStore {
|
|
|
119
120
|
msgs.push(JSON.parse(l));
|
|
120
121
|
}
|
|
121
122
|
catch (e) {
|
|
122
|
-
|
|
123
|
+
utils_1.logger.error('[MessageStore] 解析消息行失败:', e);
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
return msgs;
|
|
@@ -141,10 +142,10 @@ class MessageStore {
|
|
|
141
142
|
}
|
|
142
143
|
// 写入新文件夹结构
|
|
143
144
|
await this.flush(ownerAid);
|
|
144
|
-
|
|
145
|
+
utils_1.logger.log(`[MessageStore] 已从旧格式迁移 ${records.length} 个会话 (AID: ${ownerAid})`);
|
|
145
146
|
}
|
|
146
147
|
catch (e) {
|
|
147
|
-
|
|
148
|
+
utils_1.logger.error('[MessageStore] 迁移旧数据失败:', e);
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
getOrCreateSession(sessionId, identifyingCode, peerAid, type, ownerAid) {
|
|
@@ -247,7 +248,7 @@ class MessageStore {
|
|
|
247
248
|
fs.writeFileSync(indexPath, JSON.stringify(records, null, 2));
|
|
248
249
|
}
|
|
249
250
|
catch (e) {
|
|
250
|
-
|
|
251
|
+
utils_1.logger.error('[MessageStore] 写入索引失败:', e);
|
|
251
252
|
}
|
|
252
253
|
}
|
|
253
254
|
/** 全量重写单个会话的消息文件(JSONL 格式) */
|
|
@@ -265,7 +266,7 @@ class MessageStore {
|
|
|
265
266
|
fs.writeFileSync(msgPath, lines ? lines + '\n' : '');
|
|
266
267
|
}
|
|
267
268
|
catch (e) {
|
|
268
|
-
|
|
269
|
+
utils_1.logger.error(`[MessageStore] 写入会话文件失败 (${sessionId}):`, e);
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
/** 追加单条消息到 JSONL 文件 */
|
|
@@ -279,7 +280,7 @@ class MessageStore {
|
|
|
279
280
|
fs.appendFileSync(msgPath, JSON.stringify(msg) + '\n');
|
|
280
281
|
}
|
|
281
282
|
catch (e) {
|
|
282
|
-
|
|
283
|
+
utils_1.logger.error(`[MessageStore] 追加消息失败 (${sessionId}):`, e);
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
286
|
/** 全量写入指定 AID 的索引 + 所有会话消息文件 */
|
|
@@ -316,7 +317,7 @@ class MessageStore {
|
|
|
316
317
|
fs.unlinkSync(msgPath);
|
|
317
318
|
}
|
|
318
319
|
catch (e) {
|
|
319
|
-
|
|
320
|
+
utils_1.logger.error('删除会话文件失败:', e);
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
await this.flushIndex(session.ownerAid);
|