@agentvault/agentvault 0.14.30 → 0.15.1

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
@@ -46465,7 +46465,7 @@ async function handleSendRequest(parsed, channel) {
46465
46465
  const hubAddr = channel.resolveA2AChannelHub(parsed.channel_id);
46466
46466
  if (hubAddr) a2aTarget = hubAddr;
46467
46467
  }
46468
- const roomId = parsed.room_id ?? channel.lastInboundRoomId;
46468
+ const roomId = (typeof parsed.room_id === "string" ? parsed.room_id : void 0) ?? channel.lastInboundRoomId;
46469
46469
  if (a2aTarget && typeof a2aTarget === "string") {
46470
46470
  await channel.sendToAgent(a2aTarget, text);
46471
46471
  } else if (roomId) {
@@ -46826,6 +46826,11 @@ var init_channel = __esm({
46826
46826
  get lastInboundRoomId() {
46827
46827
  return this._lastInboundRoomId;
46828
46828
  }
46829
+ /** Returns all persisted room IDs and names (for outbound target registration). */
46830
+ get roomIds() {
46831
+ if (!this._persisted?.rooms) return [];
46832
+ return Object.values(this._persisted.rooms).map((r2) => ({ roomId: r2.roomId, name: r2.name }));
46833
+ }
46829
46834
  /** Returns hub addresses of all persisted A2A peer channels. */
46830
46835
  get a2aPeerAddresses() {
46831
46836
  if (!this._persisted?.a2aChannels) return [];
@@ -46854,6 +46859,7 @@ var init_channel = __esm({
46854
46859
  this._deviceJwt = this._persisted.deviceJwt;
46855
46860
  this._primaryConversationId = this._persisted.primaryConversationId;
46856
46861
  this._fingerprint = this._persisted.fingerprint;
46862
+ this._lastInboundRoomId = this._persisted.lastInboundRoomId;
46857
46863
  for (const [convId, sessionData] of Object.entries(
46858
46864
  this._persisted.sessions
46859
46865
  )) {
@@ -48761,7 +48767,7 @@ ${messageText}`;
48761
48767
  }
48762
48768
  }
48763
48769
  }
48764
- if (!roomId) this._lastInboundRoomId = void 0;
48770
+ if (roomId) this._lastInboundRoomId = roomId;
48765
48771
  const metadata = {
48766
48772
  messageId: msgData.message_id,
48767
48773
  conversationId: convId,
@@ -49427,6 +49433,7 @@ ${messageText}`;
49427
49433
  */
49428
49434
  async _handleRoomMessageSK(msgData) {
49429
49435
  if (msgData.sender_device_id === this._deviceId) return;
49436
+ this._lastInboundRoomId = msgData.room_id;
49430
49437
  const peerState = this._senderKeyStates.get(msgData.room_id);
49431
49438
  if (!peerState) {
49432
49439
  console.warn(
@@ -49468,6 +49475,9 @@ ${messageText}`;
49468
49475
  if (msgData.message_id) {
49469
49476
  this._sendAck(msgData.message_id);
49470
49477
  }
49478
+ if (msgData.created_at && this._persisted) {
49479
+ this._persisted.lastMessageTimestamp = msgData.created_at;
49480
+ }
49471
49481
  await this._persistState();
49472
49482
  const metadata = {
49473
49483
  messageId: msgData.message_id ?? "",
@@ -49515,35 +49525,35 @@ ${messageText}`;
49515
49525
  if (msg.sender_device_id === this._deviceId) continue;
49516
49526
  if (this._syncMessageIds.has(msg.id)) continue;
49517
49527
  this._syncMessageIds.add(msg.id);
49518
- if (this._persisted?.rooms) {
49519
- let roomId;
49528
+ let roomId = msg.room_id;
49529
+ if (!roomId && this._persisted?.rooms) {
49520
49530
  for (const room of Object.values(this._persisted.rooms)) {
49521
49531
  if (room.conversationIds?.includes(msg.conversation_id)) {
49522
49532
  roomId = room.roomId;
49523
49533
  break;
49524
49534
  }
49525
49535
  }
49526
- if (roomId) {
49527
- try {
49528
- await this._handleRoomMessage({
49529
- room_id: roomId,
49530
- sender_device_id: msg.sender_device_id,
49531
- conversation_id: msg.conversation_id,
49532
- header_blob: msg.header_blob,
49533
- ciphertext: msg.ciphertext,
49534
- message_id: msg.id,
49535
- created_at: msg.created_at
49536
- });
49537
- } catch (roomErr) {
49538
- console.warn(
49539
- `[SecureChannel] Sync room message failed for ${msg.conversation_id.slice(0, 8)}...:`,
49540
- roomErr
49541
- );
49542
- }
49543
- this._persisted.lastMessageTimestamp = msg.created_at;
49544
- since = msg.created_at;
49545
- continue;
49536
+ }
49537
+ if (roomId) {
49538
+ try {
49539
+ await this._handleRoomMessage({
49540
+ room_id: roomId,
49541
+ sender_device_id: msg.sender_device_id,
49542
+ conversation_id: msg.conversation_id,
49543
+ header_blob: msg.header_blob,
49544
+ ciphertext: msg.ciphertext,
49545
+ message_id: msg.id,
49546
+ created_at: msg.created_at
49547
+ });
49548
+ } catch (roomErr) {
49549
+ console.warn(
49550
+ `[SecureChannel] Sync room message failed for ${msg.conversation_id.slice(0, 8)}...:`,
49551
+ roomErr
49552
+ );
49546
49553
  }
49554
+ this._persisted.lastMessageTimestamp = msg.created_at;
49555
+ since = msg.created_at;
49556
+ continue;
49547
49557
  }
49548
49558
  const session = this._sessions.get(msg.conversation_id);
49549
49559
  if (!session) {
@@ -49904,6 +49914,7 @@ ${messageText}`;
49904
49914
  const hasOwnerSessions = this._sessions.size > 0;
49905
49915
  const hasA2AChannels = !!this._persisted.a2aChannels && Object.keys(this._persisted.a2aChannels).length > 0;
49906
49916
  if (!hasOwnerSessions && !hasA2AChannels) return;
49917
+ this._persisted.lastInboundRoomId = this._lastInboundRoomId;
49907
49918
  for (const [convId, session] of this._sessions) {
49908
49919
  this._persisted.sessions[convId] = {
49909
49920
  ownerDeviceId: session.ownerDeviceId,