@agentvault/agentvault 0.20.35 → 0.20.37

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
@@ -64141,6 +64141,39 @@ var init_channel = __esm({
64141
64141
  console.error(`[SecureChannel] send() failed for conv ${convId.slice(0, 8)}...:`, err);
64142
64142
  }
64143
64143
  }
64144
+ if (this._persisted?.mlsConversations && this._state === "ready" && this._ws) {
64145
+ for (const [mlsConvId, entry] of Object.entries(this._persisted.mlsConversations)) {
64146
+ if (targetConvId && mlsConvId !== targetConvId) continue;
64147
+ if (this._sessions.has(mlsConvId)) continue;
64148
+ if (roomConvIds.has(mlsConvId)) continue;
64149
+ const mlsGroup = this._mlsGroups.get(`conv:${mlsConvId}`);
64150
+ if (!mlsGroup?.isInitialized || !entry.mlsGroupId || Number(mlsGroup.epoch) <= 0) continue;
64151
+ try {
64152
+ const plaintextBytes = new TextEncoder().encode(plaintext);
64153
+ const cipherBytes = await mlsGroup.encrypt(plaintextBytes);
64154
+ await saveMlsState(this.config.dataDir, entry.mlsGroupId, JSON.stringify(mlsGroup.exportState()));
64155
+ const payload = {
64156
+ conversation_id: mlsConvId,
64157
+ group_id: entry.mlsGroupId,
64158
+ epoch: Number(mlsGroup.epoch),
64159
+ payload: Buffer.from(cipherBytes).toString("hex"),
64160
+ topic_id: topicId,
64161
+ client_message_id: clientMessageId,
64162
+ message_type: messageType,
64163
+ priority,
64164
+ parent_span_id: parentSpanId,
64165
+ metadata: envelopeMetadata
64166
+ };
64167
+ if (this._persisted?.hubAddress) payload.hub_address = this._persisted.hubAddress;
64168
+ if (this._persisted?.hubId) payload.sender_hub_id = this._persisted.hubId;
64169
+ pendingWsSends.push(JSON.stringify({ event: "message_mls", data: payload }));
64170
+ sentCount++;
64171
+ console.log(`[SecureChannel] MLS-only send for conv ${mlsConvId.slice(0, 8)} (no DR session)`);
64172
+ } catch (err) {
64173
+ console.error(`[SecureChannel] MLS-only send failed for conv ${mlsConvId.slice(0, 8)}:`, err);
64174
+ }
64175
+ }
64176
+ }
64144
64177
  if (sentCount === 0 && this._sessions.size > 0) {
64145
64178
  console.warn("[SecureChannel] send() delivered to 0 sessions (all skipped or failed)");
64146
64179
  }
@@ -67589,6 +67622,70 @@ ${messageText}`;
67589
67622
  } catch {
67590
67623
  }
67591
67624
  }
67625
+ for (const [convId, convEntry] of Object.entries(this._persisted?.mlsConversations ?? {})) {
67626
+ if (!convEntry.mlsGroupId) continue;
67627
+ const mlsGroup = this._mlsGroups.get(`conv:${convId}`);
67628
+ if (!mlsGroup?.isInitialized) continue;
67629
+ try {
67630
+ const pendingRes = await fetch(
67631
+ `${this.config.apiUrl}/api/v1/mls/groups/${convEntry.mlsGroupId}/pending-welcomes`,
67632
+ { headers: { Authorization: `Bearer ${this._deviceJwt}` } }
67633
+ );
67634
+ if (!pendingRes.ok) continue;
67635
+ const pending = await pendingRes.json();
67636
+ if (pending.length === 0) continue;
67637
+ console.log(`[SecureChannel] ${pending.length} pending Welcome requests for conv ${convId.slice(0, 8)}`);
67638
+ for (const req of pending) {
67639
+ try {
67640
+ const kpRes = await fetch(
67641
+ `${this.config.apiUrl}/api/v1/mls/key-packages/batch?device_ids=${req.requesting_device_id}`,
67642
+ { headers: { Authorization: `Bearer ${this._deviceJwt}` } }
67643
+ );
67644
+ if (!kpRes.ok) continue;
67645
+ const kpData = await kpRes.json();
67646
+ const kpHex = kpData[req.requesting_device_id];
67647
+ if (!kpHex) continue;
67648
+ const kpBytes = new Uint8Array(Buffer.from(kpHex, "hex"));
67649
+ const memberKp = MLSGroupManager.deserializeKeyPackage(kpBytes);
67650
+ const { commit, welcome } = await mlsGroup.addMembers([memberKp]);
67651
+ if (this._ws) {
67652
+ this._ws.send(JSON.stringify({
67653
+ event: "mls_commit",
67654
+ data: {
67655
+ group_id: convEntry.mlsGroupId,
67656
+ epoch: Number(mlsGroup.epoch),
67657
+ payload: Buffer.from(commit).toString("hex")
67658
+ }
67659
+ }));
67660
+ }
67661
+ if (welcome && this._ws) {
67662
+ this._ws.send(JSON.stringify({
67663
+ event: "mls_welcome",
67664
+ data: {
67665
+ target_device_id: req.requesting_device_id,
67666
+ group_id: convEntry.mlsGroupId,
67667
+ conversation_id: convId,
67668
+ payload: Buffer.from(welcome).toString("hex")
67669
+ }
67670
+ }));
67671
+ }
67672
+ await fetch(
67673
+ `${this.config.apiUrl}/api/v1/mls/groups/${convEntry.mlsGroupId}/fulfill-welcome`,
67674
+ {
67675
+ method: "POST",
67676
+ headers: { Authorization: `Bearer ${this._deviceJwt}`, "Content-Type": "application/json" },
67677
+ body: JSON.stringify({ request_id: req.id })
67678
+ }
67679
+ );
67680
+ await saveMlsState(this.config.dataDir, convEntry.mlsGroupId, JSON.stringify(mlsGroup.exportState()));
67681
+ console.log(`[SecureChannel] Fulfilled Welcome for ${req.requesting_device_id.slice(0, 8)} in conv ${convId.slice(0, 8)}`);
67682
+ } catch (fulfillErr) {
67683
+ console.warn(`[SecureChannel] Conv Welcome fulfill failed for ${req.requesting_device_id.slice(0, 8)}:`, fulfillErr);
67684
+ }
67685
+ }
67686
+ } catch {
67687
+ }
67688
+ }
67592
67689
  for (const [chId, chState] of Object.entries(this._persisted?.a2aChannels ?? {})) {
67593
67690
  if (!chState.mlsGroupId && chState.role === "creator") {
67594
67691
  try {
@@ -89299,7 +89396,7 @@ var init_index = __esm({
89299
89396
  init_skill_invoker();
89300
89397
  await init_skill_telemetry();
89301
89398
  await init_policy_enforcer();
89302
- VERSION = true ? "0.20.35" : "0.0.0-dev";
89399
+ VERSION = true ? "0.20.37" : "0.0.0-dev";
89303
89400
  }
89304
89401
  });
89305
89402