@agentvault/agentvault 0.20.18 → 0.20.20

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
@@ -65198,24 +65198,40 @@ var init_channel = __esm({
65198
65198
  }
65199
65199
  }
65200
65200
  }
65201
- if (chState.role === "member" && !chState.mlsGroupId) {
65201
+ const memberMlsGroup = chState.mlsGroupId ? this._mlsGroups.get(`a2a:${chId}`) : void 0;
65202
+ if (chState.role === "member" && !memberMlsGroup?.isInitialized) {
65202
65203
  try {
65203
- const groupRes = await fetch(
65204
- `${this.config.apiUrl}/api/v1/mls/a2a/${chId}/group`,
65205
- { headers: { Authorization: `Bearer ${this._deviceJwt}` } }
65206
- );
65207
- if (!groupRes.ok) {
65208
- continue;
65204
+ let groupId = chState.mlsGroupId;
65205
+ let memberIds = [];
65206
+ if (!groupId) {
65207
+ const groupRes = await fetch(
65208
+ `${this.config.apiUrl}/api/v1/mls/a2a/${chId}/group`,
65209
+ { headers: { Authorization: `Bearer ${this._deviceJwt}` } }
65210
+ );
65211
+ if (!groupRes.ok) {
65212
+ continue;
65213
+ }
65214
+ const groupData = await groupRes.json();
65215
+ groupId = groupData.group_id;
65216
+ if (!groupId) continue;
65217
+ memberIds = groupData.member_device_ids || [];
65218
+ chState.mlsGroupId = groupId;
65219
+ await this._persistState();
65220
+ } else {
65221
+ try {
65222
+ const groupRes = await fetch(
65223
+ `${this.config.apiUrl}/api/v1/mls/groups/${groupId}`,
65224
+ { headers: { Authorization: `Bearer ${this._deviceJwt}` } }
65225
+ );
65226
+ if (groupRes.ok) {
65227
+ const groupData = await groupRes.json();
65228
+ memberIds = groupData.member_device_ids || [];
65229
+ }
65230
+ } catch {
65231
+ }
65209
65232
  }
65210
- const groupData = await groupRes.json();
65211
- const groupId = groupData.group_id;
65212
- if (!groupId) continue;
65213
- chState.mlsGroupId = groupId;
65214
- await this._persistState();
65215
- const memberIds = groupData.member_device_ids || [];
65216
65233
  if (memberIds.includes(this._persisted.deviceId)) {
65217
- console.log(`[SecureChannel] A2A ${chId.slice(0, 8)} member already in MLS group, skipping Welcome request`);
65218
- continue;
65234
+ console.log(`[SecureChannel] A2A ${chId.slice(0, 8)} member in server membership but no local MLS state \u2014 requesting Welcome`);
65219
65235
  }
65220
65236
  const mgr = new MLSGroupManager();
65221
65237
  const identity = new TextEncoder().encode(this._persisted.deviceId);
@@ -67545,7 +67561,24 @@ ${messageText}`;
67545
67561
  console.warn(`[SecureChannel] No A2A channel for MLS group ${groupId?.slice(0, 8)}`);
67546
67562
  return;
67547
67563
  }
67548
- const mlsGroup = this._mlsGroups.get(`a2a:${a2aChannelId}`);
67564
+ let mlsGroup = this._mlsGroups.get(`a2a:${a2aChannelId}`);
67565
+ if (!mlsGroup?.isInitialized) {
67566
+ const entry = this._persisted?.a2aChannels?.[a2aChannelId];
67567
+ const mlsGroupId = entry?.mlsGroupId || groupId;
67568
+ if (mlsGroupId) {
67569
+ try {
67570
+ const savedState = await loadMlsState(this.config.dataDir, mlsGroupId);
67571
+ if (savedState) {
67572
+ const mgr = new MLSGroupManager();
67573
+ mgr.importState(JSON.parse(savedState));
67574
+ this._mlsGroups.set(`a2a:${a2aChannelId}`, mgr);
67575
+ mlsGroup = mgr;
67576
+ console.log(`[SecureChannel] Restored A2A MLS state for ${a2aChannelId.slice(0, 8)} on message receive (epoch=${mgr.epoch})`);
67577
+ }
67578
+ } catch {
67579
+ }
67580
+ }
67581
+ }
67549
67582
  if (!mlsGroup?.isInitialized) {
67550
67583
  console.warn(`[SecureChannel] MLS group not loaded for A2A ${a2aChannelId.slice(0, 8)}`);
67551
67584
  return;
@@ -94743,7 +94776,7 @@ var init_index = __esm({
94743
94776
  init_skill_invoker();
94744
94777
  await init_skill_telemetry();
94745
94778
  await init_policy_enforcer();
94746
- VERSION = true ? "0.20.18" : "0.0.0-dev";
94779
+ VERSION = true ? "0.20.20" : "0.0.0-dev";
94747
94780
  }
94748
94781
  });
94749
94782
  await init_index();