@agentvault/agentvault 0.20.16 → 0.20.18

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,6 +65198,56 @@ var init_channel = __esm({
65198
65198
  }
65199
65199
  }
65200
65200
  }
65201
+ if (chState.role === "member" && !chState.mlsGroupId) {
65202
+ 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;
65209
+ }
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
+ 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;
65219
+ }
65220
+ const mgr = new MLSGroupManager();
65221
+ const identity = new TextEncoder().encode(this._persisted.deviceId);
65222
+ const kp = await mgr.generateKeyPackage(identity);
65223
+ this._pendingMlsKpBundle = kp;
65224
+ const kpBytes = MLSGroupManager.serializeKeyPackage(kp.publicPackage);
65225
+ await fetch(`${this.config.apiUrl}/api/v1/mls/key-packages`, {
65226
+ method: "POST",
65227
+ headers: {
65228
+ Authorization: `Bearer ${this._deviceJwt}`,
65229
+ "Content-Type": "application/json"
65230
+ },
65231
+ body: JSON.stringify({
65232
+ key_package: Buffer.from(kpBytes).toString("hex"),
65233
+ device_id: this._persisted.deviceId
65234
+ })
65235
+ });
65236
+ await fetch(`${this.config.apiUrl}/api/v1/mls/groups/${groupId}/request-welcome`, {
65237
+ method: "POST",
65238
+ headers: {
65239
+ Authorization: `Bearer ${this._deviceJwt}`,
65240
+ "Content-Type": "application/json"
65241
+ },
65242
+ body: JSON.stringify({ device_id: this._persisted.deviceId })
65243
+ });
65244
+ console.log(
65245
+ `[SecureChannel] A2A ${chId.slice(0, 8)} member sync fallback: published KeyPackage + requested Welcome (group=${groupId.slice(0, 8)})`
65246
+ );
65247
+ } catch (err) {
65248
+ console.warn(`[AgentVault] Sync fallback member MLS join failed for ${chId.slice(0, 8)}:`, err);
65249
+ }
65250
+ }
65201
65251
  }
65202
65252
  }
65203
65253
  return channels;
@@ -67372,6 +67422,7 @@ ${messageText}`;
67372
67422
  const commitHex = Buffer.from(commit).toString("hex");
67373
67423
  const welcomeHex = Buffer.from(welcome).toString("hex");
67374
67424
  let distributed = false;
67425
+ const updatedMembers = [this._deviceId, req.requesting_device_id];
67375
67426
  try {
67376
67427
  const distResp = await fetch(
67377
67428
  `${this.config.apiUrl}/api/v1/mls/groups/${chState.mlsGroupId}/distribute`,
@@ -67379,11 +67430,12 @@ ${messageText}`;
67379
67430
  method: "POST",
67380
67431
  headers: { Authorization: `Bearer ${this._deviceJwt}`, "Content-Type": "application/json" },
67381
67432
  body: JSON.stringify({
67433
+ group_id: chState.mlsGroupId,
67382
67434
  device_id: this._deviceId,
67383
67435
  commit: commitHex,
67384
67436
  commit_epoch: Number(mlsGroup.epoch),
67385
67437
  welcomes: [{ target_device_id: req.requesting_device_id, payload: welcomeHex }],
67386
- member_device_ids: [this._deviceId, req.requesting_device_id]
67438
+ member_device_ids: updatedMembers
67387
67439
  })
67388
67440
  }
67389
67441
  );
@@ -67410,6 +67462,22 @@ ${messageText}`;
67410
67462
  payload: welcomeHex
67411
67463
  }
67412
67464
  }));
67465
+ try {
67466
+ await fetch(
67467
+ `${this.config.apiUrl}/api/v1/mls/groups/${chState.mlsGroupId}/distribute`,
67468
+ {
67469
+ method: "POST",
67470
+ headers: { Authorization: `Bearer ${this._deviceJwt}`, "Content-Type": "application/json" },
67471
+ body: JSON.stringify({
67472
+ group_id: chState.mlsGroupId,
67473
+ device_id: this._deviceId,
67474
+ commit_epoch: Number(mlsGroup.epoch),
67475
+ member_device_ids: updatedMembers
67476
+ })
67477
+ }
67478
+ );
67479
+ } catch {
67480
+ }
67413
67481
  distributed = true;
67414
67482
  }
67415
67483
  if (!distributed) {
@@ -94675,7 +94743,7 @@ var init_index = __esm({
94675
94743
  init_skill_invoker();
94676
94744
  await init_skill_telemetry();
94677
94745
  await init_policy_enforcer();
94678
- VERSION = true ? "0.20.16" : "0.0.0-dev";
94746
+ VERSION = true ? "0.20.18" : "0.0.0-dev";
94679
94747
  }
94680
94748
  });
94681
94749
  await init_index();