@agentvault/agentvault 0.20.17 → 0.20.19

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);
@@ -67422,6 +67438,7 @@ ${messageText}`;
67422
67438
  const commitHex = Buffer.from(commit).toString("hex");
67423
67439
  const welcomeHex = Buffer.from(welcome).toString("hex");
67424
67440
  let distributed = false;
67441
+ const updatedMembers = [this._deviceId, req.requesting_device_id];
67425
67442
  try {
67426
67443
  const distResp = await fetch(
67427
67444
  `${this.config.apiUrl}/api/v1/mls/groups/${chState.mlsGroupId}/distribute`,
@@ -67429,11 +67446,12 @@ ${messageText}`;
67429
67446
  method: "POST",
67430
67447
  headers: { Authorization: `Bearer ${this._deviceJwt}`, "Content-Type": "application/json" },
67431
67448
  body: JSON.stringify({
67449
+ group_id: chState.mlsGroupId,
67432
67450
  device_id: this._deviceId,
67433
67451
  commit: commitHex,
67434
67452
  commit_epoch: Number(mlsGroup.epoch),
67435
67453
  welcomes: [{ target_device_id: req.requesting_device_id, payload: welcomeHex }],
67436
- member_device_ids: [this._deviceId, req.requesting_device_id]
67454
+ member_device_ids: updatedMembers
67437
67455
  })
67438
67456
  }
67439
67457
  );
@@ -67460,6 +67478,22 @@ ${messageText}`;
67460
67478
  payload: welcomeHex
67461
67479
  }
67462
67480
  }));
67481
+ try {
67482
+ await fetch(
67483
+ `${this.config.apiUrl}/api/v1/mls/groups/${chState.mlsGroupId}/distribute`,
67484
+ {
67485
+ method: "POST",
67486
+ headers: { Authorization: `Bearer ${this._deviceJwt}`, "Content-Type": "application/json" },
67487
+ body: JSON.stringify({
67488
+ group_id: chState.mlsGroupId,
67489
+ device_id: this._deviceId,
67490
+ commit_epoch: Number(mlsGroup.epoch),
67491
+ member_device_ids: updatedMembers
67492
+ })
67493
+ }
67494
+ );
67495
+ } catch {
67496
+ }
67463
67497
  distributed = true;
67464
67498
  }
67465
67499
  if (!distributed) {
@@ -94725,7 +94759,7 @@ var init_index = __esm({
94725
94759
  init_skill_invoker();
94726
94760
  await init_skill_telemetry();
94727
94761
  await init_policy_enforcer();
94728
- VERSION = true ? "0.20.17" : "0.0.0-dev";
94762
+ VERSION = true ? "0.20.19" : "0.0.0-dev";
94729
94763
  }
94730
94764
  });
94731
94765
  await init_index();