@agentvault/agentvault 0.20.13 → 0.20.15

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
@@ -67261,7 +67261,49 @@ ${messageText}`;
67261
67261
  const kpBytes = new Uint8Array(Buffer.from(kpHex, "hex"));
67262
67262
  const memberKp = MLSGroupManager.deserializeKeyPackage(kpBytes);
67263
67263
  console.log(`[SecureChannel] A2A addMembers for ${req.requesting_device_id.slice(0, 8)} group=${chState.mlsGroupId.slice(0, 8)} epoch=${mlsGroup.epoch}`);
67264
- const { commit, welcome } = await mlsGroup.addMembers([memberKp]);
67264
+ let commit;
67265
+ let welcome;
67266
+ try {
67267
+ const result = await mlsGroup.addMembers([memberKp]);
67268
+ commit = result.commit;
67269
+ welcome = result.welcome;
67270
+ } catch (addErr) {
67271
+ const errMsg = addErr instanceof Error ? addErr.message : String(addErr);
67272
+ if (errMsg.includes("already in the group")) {
67273
+ console.log(`[SecureChannel] A2A member already in group \u2014 removing and re-adding ${req.requesting_device_id.slice(0, 8)}`);
67274
+ try {
67275
+ const identityBytes = new TextEncoder().encode(req.requesting_device_id);
67276
+ await mlsGroup.removeMember(identityBytes);
67277
+ const kpRes2 = await fetch(
67278
+ `${this.config.apiUrl}/api/v1/mls/key-packages/batch?device_ids=${req.requesting_device_id}`,
67279
+ { headers: { Authorization: `Bearer ${this._deviceJwt}` } }
67280
+ );
67281
+ if (kpRes2.ok) {
67282
+ const kpData2 = await kpRes2.json();
67283
+ const kpHex2 = kpData2[req.requesting_device_id];
67284
+ if (kpHex2) {
67285
+ const kpBytes2 = new Uint8Array(Buffer.from(kpHex2, "hex"));
67286
+ const memberKp2 = MLSGroupManager.deserializeKeyPackage(kpBytes2);
67287
+ const result2 = await mlsGroup.addMembers([memberKp2]);
67288
+ commit = result2.commit;
67289
+ welcome = result2.welcome;
67290
+ } else {
67291
+ console.log(`[SecureChannel] A2A re-add: no fresh KeyPackage for ${req.requesting_device_id.slice(0, 8)}`);
67292
+ continue;
67293
+ }
67294
+ } else {
67295
+ console.log(`[SecureChannel] A2A re-add: KeyPackage fetch failed (${kpRes2.status})`);
67296
+ continue;
67297
+ }
67298
+ } catch (readdErr) {
67299
+ console.log(`[SecureChannel] A2A remove+re-add FAILED: ${readdErr instanceof Error ? readdErr.message : String(readdErr)}`);
67300
+ continue;
67301
+ }
67302
+ } else {
67303
+ console.log(`[SecureChannel] A2A addMembers FAILED: ${errMsg}`);
67304
+ continue;
67305
+ }
67306
+ }
67265
67307
  if (!welcome) {
67266
67308
  console.warn(`[SecureChannel] A2A addMembers produced no Welcome for ${req.requesting_device_id.slice(0, 8)}`);
67267
67309
  continue;
@@ -67324,7 +67366,7 @@ ${messageText}`;
67324
67366
  await saveMlsState(this.config.dataDir, chState.mlsGroupId, JSON.stringify(mlsGroup.exportState()));
67325
67367
  console.log(`[SecureChannel] Fulfilled A2A Welcome for ${req.requesting_device_id.slice(0, 8)} in channel ${chId.slice(0, 8)}`);
67326
67368
  } catch (fulfillErr) {
67327
- console.warn(`[SecureChannel] A2A Welcome fulfill failed:`, fulfillErr);
67369
+ console.log(`[SecureChannel] A2A Welcome fulfill failed: ${fulfillErr instanceof Error ? fulfillErr.message : String(fulfillErr)}`);
67328
67370
  }
67329
67371
  }
67330
67372
  } catch {
@@ -94567,7 +94609,7 @@ var init_index = __esm({
94567
94609
  init_skill_invoker();
94568
94610
  await init_skill_telemetry();
94569
94611
  await init_policy_enforcer();
94570
- VERSION = true ? "0.20.13" : "0.0.0-dev";
94612
+ VERSION = true ? "0.20.15" : "0.0.0-dev";
94571
94613
  }
94572
94614
  });
94573
94615
  await init_index();