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