@agentvault/agentvault 0.20.38 → 0.20.40

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
@@ -64203,6 +64203,38 @@ var init_channel = __esm({
64203
64203
  }
64204
64204
  }
64205
64205
  }
64206
+ if (this._persisted?.mlsGroups && this._state === "ready" && this._ws) {
64207
+ for (const [gid, entry] of Object.entries(this._persisted.mlsGroups)) {
64208
+ if (sentSharedGroupIds.has(gid)) continue;
64209
+ if (!entry.mlsGroupId) continue;
64210
+ const mlsGroup = this._mlsGroups.get(`1to1-group:${gid}`);
64211
+ if (!mlsGroup?.isInitialized || Number(mlsGroup.epoch) <= 0) continue;
64212
+ try {
64213
+ const plaintextBytes = new TextEncoder().encode(plaintext);
64214
+ const cipherBytes = await mlsGroup.encrypt(plaintextBytes);
64215
+ await saveMlsState(this.config.dataDir, entry.mlsGroupId, JSON.stringify(mlsGroup.exportState()));
64216
+ const payload = {
64217
+ group_id: entry.mlsGroupId,
64218
+ epoch: Number(mlsGroup.epoch),
64219
+ payload: Buffer.from(cipherBytes).toString("hex"),
64220
+ topic_id: topicId,
64221
+ client_message_id: clientMessageId,
64222
+ message_type: messageType,
64223
+ priority,
64224
+ parent_span_id: parentSpanId,
64225
+ metadata: envelopeMetadata
64226
+ };
64227
+ if (this._persisted?.hubAddress) payload.hub_address = this._persisted.hubAddress;
64228
+ if (this._persisted?.hubId) payload.sender_hub_id = this._persisted.hubId;
64229
+ pendingWsSends.push(JSON.stringify({ event: "message_mls", data: payload }));
64230
+ sentSharedGroupIds.add(gid);
64231
+ sentCount++;
64232
+ console.log(`[SecureChannel] Shared MLS group send for group ${gid.slice(0, 8)} (${entry.mlsGroupId.slice(0, 8)})`);
64233
+ } catch (err) {
64234
+ console.error(`[SecureChannel] Shared MLS group send failed for ${gid.slice(0, 8)}:`, err);
64235
+ }
64236
+ }
64237
+ }
64206
64238
  if (sentCount === 0 && this._sessions.size > 0) {
64207
64239
  console.warn("[SecureChannel] send() delivered to 0 sessions (all skipped or failed)");
64208
64240
  }
@@ -66336,15 +66368,29 @@ var init_channel = __esm({
66336
66368
  */
66337
66369
  async _handleMessageMLS(data) {
66338
66370
  const convId = data.conversation_id;
66371
+ const convGroupId = data.conversation_group_id;
66339
66372
  const groupId = data.group_id;
66340
66373
  const senderDeviceId = data.sender_device_id;
66341
66374
  if (senderDeviceId === this._deviceId) return;
66342
66375
  let mgr;
66343
66376
  let mgrKey;
66344
- if (convId) {
66377
+ if (convGroupId) {
66378
+ mgrKey = `1to1-group:${convGroupId}`;
66379
+ mgr = this._mlsGroups.get(mgrKey);
66380
+ }
66381
+ if (!mgr && convId) {
66345
66382
  mgrKey = `conv:${convId}`;
66346
66383
  mgr = this._mlsGroups.get(mgrKey);
66347
66384
  }
66385
+ if (!mgr && groupId) {
66386
+ for (const [gid, entry] of Object.entries(this._persisted?.mlsGroups ?? {})) {
66387
+ if (entry.mlsGroupId === groupId) {
66388
+ mgrKey = `1to1-group:${gid}`;
66389
+ mgr = this._mlsGroups.get(mgrKey);
66390
+ break;
66391
+ }
66392
+ }
66393
+ }
66348
66394
  if (!mgr && groupId) {
66349
66395
  for (const [cid, entry] of Object.entries(this._persisted?.mlsConversations ?? {})) {
66350
66396
  if (entry.mlsGroupId === groupId) {
@@ -66361,7 +66407,7 @@ var init_channel = __esm({
66361
66407
  try {
66362
66408
  const cipherBytes = new Uint8Array(Buffer.from(data.payload, "hex"));
66363
66409
  const result = await mgr.decrypt(cipherBytes);
66364
- const mlsGroupId = this._persisted?.mlsConversations?.[convId]?.mlsGroupId ?? groupId;
66410
+ const mlsGroupId = (convGroupId ? this._persisted?.mlsGroups?.[convGroupId]?.mlsGroupId : null) ?? this._persisted?.mlsConversations?.[convId]?.mlsGroupId ?? groupId;
66365
66411
  if (mlsGroupId) {
66366
66412
  await saveMlsState(this.config.dataDir, mlsGroupId, JSON.stringify(mgr.exportState()));
66367
66413
  }
@@ -67532,6 +67578,7 @@ ${messageText}`;
67532
67578
  payload: msg.payload,
67533
67579
  room_id: msg.room_id,
67534
67580
  conversation_id: msg.conversation_id,
67581
+ conversation_group_id: msg.conversation_group_id,
67535
67582
  a2a_channel_id: msg.a2a_channel_id
67536
67583
  });
67537
67584
  } else if (msg.message_type === "commit") {
@@ -67562,7 +67609,7 @@ ${messageText}`;
67562
67609
  a2a_channel_id: msg.a2a_channel_id,
67563
67610
  created_at: msg.created_at
67564
67611
  });
67565
- } else if (msg.conversation_id) {
67612
+ } else if (msg.conversation_id || msg.conversation_group_id) {
67566
67613
  await this._handleMessageMLS({
67567
67614
  message_id: msg.message_id,
67568
67615
  group_id: msg.group_id,
@@ -67570,6 +67617,7 @@ ${messageText}`;
67570
67617
  epoch: msg.epoch,
67571
67618
  payload: msg.payload,
67572
67619
  conversation_id: msg.conversation_id,
67620
+ conversation_group_id: msg.conversation_group_id,
67573
67621
  created_at: msg.created_at
67574
67622
  });
67575
67623
  }
@@ -95410,7 +95458,7 @@ var init_index = __esm({
95410
95458
  init_skill_invoker();
95411
95459
  await init_skill_telemetry();
95412
95460
  await init_policy_enforcer();
95413
- VERSION = true ? "0.20.38" : "0.0.0-dev";
95461
+ VERSION = true ? "0.20.40" : "0.0.0-dev";
95414
95462
  }
95415
95463
  });
95416
95464
  await init_index();