@agentvault/agentvault 0.19.1 → 0.19.3

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/index.js CHANGED
@@ -47330,6 +47330,15 @@ var init_channel = __esm({
47330
47330
  this._persisted.messageHistory = this._persisted.messageHistory.slice(-maxSize);
47331
47331
  }
47332
47332
  }
47333
+ /**
47334
+ * Get recent message history for a specific room, for LLM context injection.
47335
+ * Returns the last N messages tagged with `room:{roomId}`.
47336
+ */
47337
+ getRoomHistory(roomId, maxMessages = 20) {
47338
+ const history = this._persisted?.messageHistory ?? [];
47339
+ const tag = `room:${roomId}`;
47340
+ return history.filter((e) => e.topicId === tag).slice(-maxMessages);
47341
+ }
47333
47342
  /**
47334
47343
  * Encrypt and send a message to ALL owner devices (fanout).
47335
47344
  * Each session gets the same plaintext encrypted independently.
@@ -47654,6 +47663,10 @@ var init_channel = __esm({
47654
47663
  if (!this._persisted?.rooms?.[roomId]) {
47655
47664
  throw new Error(`Room ${roomId} not found`);
47656
47665
  }
47666
+ const msgType = opts?.messageType ?? "text";
47667
+ if (msgType === "text" && plaintext) {
47668
+ this._appendHistory("agent", plaintext, `room:${roomId}`);
47669
+ }
47657
47670
  Promise.resolve().then(() => (init_openclaw_compat(), openclaw_compat_exports)).then(({ requestHeartbeatNow: requestHeartbeatNow2 }) => requestHeartbeatNow2({ reason: "channel-sendToRoom" })).catch(() => {
47658
47671
  });
47659
47672
  const room = this._persisted.rooms[roomId];
@@ -50048,6 +50061,7 @@ ${messageText}`;
50048
50061
  senderDeviceId: msgData.sender_device_id,
50049
50062
  roomName: this._persisted?.rooms?.[msgData.room_id]?.name
50050
50063
  };
50064
+ this._appendHistory("owner", messageText, `room:${msgData.room_id}`);
50051
50065
  this.emit("room_message", {
50052
50066
  roomId: msgData.room_id,
50053
50067
  senderDeviceId: msgData.sender_device_id,
@@ -50336,6 +50350,7 @@ ${messageText}`;
50336
50350
  senderDeviceId: msgData.sender_device_id,
50337
50351
  roomName: this._persisted?.rooms?.[msgData.room_id]?.name
50338
50352
  };
50353
+ this._appendHistory("owner", messageText, `room:${msgData.room_id}`);
50339
50354
  this.emit("room_message", {
50340
50355
  roomId: msgData.room_id,
50341
50356
  senderDeviceId: msgData.sender_device_id,
@@ -50374,7 +50389,13 @@ ${messageText}`;
50374
50389
  for (const msg of messages) {
50375
50390
  if (msg.sender_device_id === this._deviceId) continue;
50376
50391
  if (this._syncMessageIds.has(msg.id)) continue;
50392
+ if (this._seenMessageIds.has(msg.id)) continue;
50377
50393
  this._syncMessageIds.add(msg.id);
50394
+ if (this._seenMessageIds.size >= _SecureChannel.SEEN_MSG_MAX) {
50395
+ const first = this._seenMessageIds.values().next().value;
50396
+ if (first) this._seenMessageIds.delete(first);
50397
+ }
50398
+ this._seenMessageIds.add(msg.id);
50378
50399
  let roomId = msg.room_id;
50379
50400
  if (!roomId && this._persisted?.rooms) {
50380
50401
  for (const room of Object.values(this._persisted.rooms)) {
@@ -76812,7 +76833,7 @@ var init_mcp_server2 = __esm({
76812
76833
  };
76813
76834
  }
76814
76835
  try {
76815
- const result = await this.opts.onInvoke(name, args);
76836
+ const result = await this.opts.onInvoke(name, args, skill);
76816
76837
  const text = typeof result === "string" ? result : JSON.stringify(result, null, 2);
76817
76838
  return {
76818
76839
  content: [{ type: "text", text }]