@agentvault/agentvault 0.20.11 → 0.20.13

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
@@ -67255,48 +67255,63 @@ ${messageText}`;
67255
67255
  { headers: { Authorization: `Bearer ${this._deviceJwt}` } }
67256
67256
  );
67257
67257
  if (!kpRes.ok) continue;
67258
- const kpArr = await kpRes.json();
67259
- if (kpArr.length === 0) continue;
67260
- const kpBytes = new Uint8Array(Buffer.from(kpArr[0].key_package, "hex"));
67258
+ const kpData = await kpRes.json();
67259
+ const kpHex = kpData[req.requesting_device_id];
67260
+ if (!kpHex) continue;
67261
+ const kpBytes = new Uint8Array(Buffer.from(kpHex, "hex"));
67261
67262
  const memberKp = MLSGroupManager.deserializeKeyPackage(kpBytes);
67263
+ console.log(`[SecureChannel] A2A addMembers for ${req.requesting_device_id.slice(0, 8)} group=${chState.mlsGroupId.slice(0, 8)} epoch=${mlsGroup.epoch}`);
67262
67264
  const { commit, welcome } = await mlsGroup.addMembers([memberKp]);
67263
- if (welcome) {
67264
- const commitHex = Buffer.from(commit).toString("hex");
67265
- const welcomeHex = Buffer.from(welcome).toString("hex");
67266
- try {
67267
- await fetch(
67268
- `${this.config.apiUrl}/api/v1/mls/groups/${chState.mlsGroupId}/distribute`,
67269
- {
67270
- method: "POST",
67271
- headers: { Authorization: `Bearer ${this._deviceJwt}`, "Content-Type": "application/json" },
67272
- body: JSON.stringify({
67273
- device_id: this._deviceId,
67274
- commit: commitHex,
67275
- commit_epoch: Number(mlsGroup.epoch),
67276
- welcomes: [{ target_device_id: req.requesting_device_id, payload: welcomeHex }],
67277
- member_device_ids: [this._deviceId, req.requesting_device_id]
67278
- })
67279
- }
67280
- );
67281
- } catch (distErr) {
67282
- if (this._ws) {
67283
- this._ws.send(JSON.stringify({
67284
- event: "mls_commit",
67285
- data: { group_id: chState.mlsGroupId, epoch: Number(mlsGroup.epoch), payload: commitHex }
67286
- }));
67287
- this._ws.send(JSON.stringify({
67288
- event: "mls_welcome",
67289
- data: {
67290
- target_device_id: req.requesting_device_id,
67291
- group_id: chState.mlsGroupId,
67292
- a2a_channel_id: chId,
67293
- payload: welcomeHex
67294
- }
67295
- }));
67296
- } else {
67297
- console.warn(`[SecureChannel] Cannot deliver Welcome \u2014 HTTP distribute and WS both unavailable`);
67265
+ if (!welcome) {
67266
+ console.warn(`[SecureChannel] A2A addMembers produced no Welcome for ${req.requesting_device_id.slice(0, 8)}`);
67267
+ continue;
67268
+ }
67269
+ const commitHex = Buffer.from(commit).toString("hex");
67270
+ const welcomeHex = Buffer.from(welcome).toString("hex");
67271
+ let distributed = false;
67272
+ try {
67273
+ const distResp = await fetch(
67274
+ `${this.config.apiUrl}/api/v1/mls/groups/${chState.mlsGroupId}/distribute`,
67275
+ {
67276
+ method: "POST",
67277
+ headers: { Authorization: `Bearer ${this._deviceJwt}`, "Content-Type": "application/json" },
67278
+ body: JSON.stringify({
67279
+ device_id: this._deviceId,
67280
+ commit: commitHex,
67281
+ commit_epoch: Number(mlsGroup.epoch),
67282
+ welcomes: [{ target_device_id: req.requesting_device_id, payload: welcomeHex }],
67283
+ member_device_ids: [this._deviceId, req.requesting_device_id]
67284
+ })
67298
67285
  }
67286
+ );
67287
+ if (distResp.ok) {
67288
+ distributed = true;
67289
+ } else {
67290
+ const detail = await distResp.text().catch(() => "");
67291
+ console.warn(`[SecureChannel] A2A distribute failed (${distResp.status}): ${detail}`);
67299
67292
  }
67293
+ } catch (distErr) {
67294
+ console.warn(`[SecureChannel] A2A distribute network error:`, distErr);
67295
+ }
67296
+ if (!distributed && this._ws) {
67297
+ this._ws.send(JSON.stringify({
67298
+ event: "mls_commit",
67299
+ data: { group_id: chState.mlsGroupId, epoch: Number(mlsGroup.epoch), payload: commitHex }
67300
+ }));
67301
+ this._ws.send(JSON.stringify({
67302
+ event: "mls_welcome",
67303
+ data: {
67304
+ target_device_id: req.requesting_device_id,
67305
+ group_id: chState.mlsGroupId,
67306
+ a2a_channel_id: chId,
67307
+ payload: welcomeHex
67308
+ }
67309
+ }));
67310
+ distributed = true;
67311
+ }
67312
+ if (!distributed) {
67313
+ console.warn(`[SecureChannel] Cannot deliver Welcome \u2014 HTTP distribute and WS both unavailable`);
67314
+ continue;
67300
67315
  }
67301
67316
  await fetch(
67302
67317
  `${this.config.apiUrl}/api/v1/mls/groups/${chState.mlsGroupId}/fulfill-welcome`,
@@ -94552,7 +94567,7 @@ var init_index = __esm({
94552
94567
  init_skill_invoker();
94553
94568
  await init_skill_telemetry();
94554
94569
  await init_policy_enforcer();
94555
- VERSION = true ? "0.20.11" : "0.0.0-dev";
94570
+ VERSION = true ? "0.20.13" : "0.0.0-dev";
94556
94571
  }
94557
94572
  });
94558
94573
  await init_index();