@agentvault/agentvault 0.23.62 → 0.23.63

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
@@ -64540,11 +64540,11 @@ var init_mls_kp_pool = __esm({
64540
64540
 
64541
64541
  // src/client-version.ts
64542
64542
  function ownIdentity() {
64543
- const v2 = true ? "0.23.62" : FALLBACK;
64543
+ const v2 = true ? "0.23.63" : FALLBACK;
64544
64544
  return `${PACKAGE}@${v2}`;
64545
64545
  }
64546
64546
  function buildSha() {
64547
- const raw = true ? "4db8d51" : "";
64547
+ const raw = true ? "52249f2" : "";
64548
64548
  const cleaned = (raw ?? "").trim();
64549
64549
  return !cleaned || cleaned === "unknown" ? null : cleaned;
64550
64550
  }
@@ -66931,6 +66931,16 @@ var init_channel = __esm({
66931
66931
  */
66932
66932
  static _KP_REPLENISH_INTERVAL_MS = 6 * 60 * 60 * 1e3;
66933
66933
  _kpReplenishTimer = null;
66934
+ /**
66935
+ * #1094: how often each live group's key proof is re-reported — the web
66936
+ * reporter's cadence (`use-key-proof-reporter.ts`), against the server's 24h
66937
+ * staleness window. Re-reading the CURRENT epoch on a timer is self-correcting
66938
+ * whatever moved it, which is why no commit site is hooked.
66939
+ */
66940
+ static _KEY_PROOF_INTERVAL_MS = 10 * 60 * 1e3;
66941
+ /** #1094: never let one slow report hold up the rest. */
66942
+ static _KEY_PROOF_FETCH_TIMEOUT_MS = 1e4;
66943
+ _keyProofTimer = null;
66934
66944
  _a2aReconcileTimer = null;
66935
66945
  _deliveryPulling = false;
66936
66946
  _drDeliveryPulling = false;
@@ -69172,7 +69182,7 @@ ${text}`,
69172
69182
  */
69173
69183
  sendActivitySpan(spanData) {
69174
69184
  if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
69175
- const pluginVersion = true ? "0.23.62" : "0.0.0-dev";
69185
+ const pluginVersion = true ? "0.23.63" : "0.0.0-dev";
69176
69186
  const agentName = this.config.agentName ?? "Agent";
69177
69187
  const resource = {
69178
69188
  "service.name": "agentvault-agent",
@@ -70376,6 +70386,7 @@ ${text}`,
70376
70386
  this._telemetryReporter = null;
70377
70387
  }
70378
70388
  this._stopA2aReconcileTimer();
70389
+ this._stopKeyProofTimer();
70379
70390
  if (this._ws) {
70380
70391
  this._ws.removeAllListeners();
70381
70392
  this._ws.close();
@@ -71382,7 +71393,7 @@ ${text}`,
71382
71393
  agentVersion: this.config.agentVersion ?? "0.0.0",
71383
71394
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
71384
71395
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
71385
- pluginVersion: true ? "0.23.62" : "0.0.0-dev"
71396
+ pluginVersion: true ? "0.23.63" : "0.0.0-dev"
71386
71397
  });
71387
71398
  this._telemetryReporter.startAutoFlush(3e4);
71388
71399
  }
@@ -71393,6 +71404,7 @@ ${text}`,
71393
71404
  if (aborted2()) return;
71394
71405
  await this._ensureKpPoolPublished();
71395
71406
  this._startKpReplenishTimer();
71407
+ this._startKeyProofTimer();
71396
71408
  this._pullDeliveryQueue().catch((err) => {
71397
71409
  console.warn("[SecureChannel] Initial delivery pull failed:", err);
71398
71410
  });
@@ -71714,7 +71726,7 @@ ${text}`,
71714
71726
  agentVersion: this.config.agentVersion ?? "0.0.0",
71715
71727
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
71716
71728
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
71717
- pluginVersion: true ? "0.23.62" : "0.0.0-dev"
71729
+ pluginVersion: true ? "0.23.63" : "0.0.0-dev"
71718
71730
  });
71719
71731
  this._telemetryReporter.startAutoFlush(3e4);
71720
71732
  }
@@ -72093,6 +72105,7 @@ ${text}`,
72093
72105
  }
72094
72106
  this._stopA2aReconcileTimer();
72095
72107
  this._stopKpReplenishTimer();
72108
+ this._stopKeyProofTimer();
72096
72109
  if (this._stopped) return;
72097
72110
  this._setState("disconnected");
72098
72111
  this._scheduleReconnect();
@@ -74583,6 +74596,82 @@ ${baseText}`;
74583
74596
  this._kpReplenishTimer = null;
74584
74597
  }
74585
74598
  }
74599
+ /** #1094: start reporting key proofs (now, then every interval). Idempotent. */
74600
+ _startKeyProofTimer() {
74601
+ this._stopKeyProofTimer();
74602
+ void this._reportKeyProofs();
74603
+ this._keyProofTimer = setInterval(() => {
74604
+ void this._reportKeyProofs();
74605
+ }, _SecureChannel._KEY_PROOF_INTERVAL_MS);
74606
+ }
74607
+ _stopKeyProofTimer() {
74608
+ if (this._keyProofTimer) {
74609
+ clearInterval(this._keyProofTimer);
74610
+ this._keyProofTimer = null;
74611
+ }
74612
+ }
74613
+ /**
74614
+ * #1094: prove, per live MLS group, that this agent can read it.
74615
+ *
74616
+ * `mls_key_proofs` answers "can this roster member actually decrypt?" — the
74617
+ * question nothing else can — but until now only browsers ever wrote one, so
74618
+ * a stuck agent (smartcode sat at epoch 1 in a group at 71 for two days,
74619
+ * #991) was invisible to the server. Same payload as the web reporter: the
74620
+ * epoch and RFC 9420 §8.2's `epoch_authenticator`, which only a holder of
74621
+ * the group's current state can compute and every member computes alike.
74622
+ *
74623
+ * A manager with no usable state reports nothing: the server reads that
74624
+ * absence as "cannot be shown to read", which is the honest signal. Each
74625
+ * group is reported once even when several keys share one manager. Never
74626
+ * throws; a failed report is logged at debug and changes nothing.
74627
+ */
74628
+ async _reportKeyProofs() {
74629
+ const deviceId = this._deviceId;
74630
+ const jwt = this._deviceJwt;
74631
+ if (!deviceId || !jwt) return;
74632
+ const best = /* @__PURE__ */ new Map();
74633
+ for (const mgr of this._mlsGroups.values()) {
74634
+ try {
74635
+ if (!mgr.isInitialized) continue;
74636
+ const epoch = Number(mgr.epoch);
74637
+ if (epoch <= 0) continue;
74638
+ const groupId = _SecureChannel._mlsGroupIdString(mgr.groupId);
74639
+ if (!groupId) continue;
74640
+ const prev = best.get(groupId);
74641
+ if (prev && epoch <= prev.epoch) continue;
74642
+ best.set(groupId, { epoch, authenticator: Buffer.from(mgr.epochAuthenticator).toString("hex") });
74643
+ } catch {
74644
+ continue;
74645
+ }
74646
+ }
74647
+ for (const [groupId, { epoch, authenticator }] of best) {
74648
+ try {
74649
+ const res = await fetch(`${this.config.apiUrl}/api/v1/mls/groups/${groupId}/key-proof`, {
74650
+ method: "POST",
74651
+ headers: { Authorization: `Bearer ${jwt}`, "Content-Type": "application/json" },
74652
+ body: JSON.stringify({ device_id: deviceId, epoch, authenticator }),
74653
+ signal: AbortSignal.timeout(_SecureChannel._KEY_PROOF_FETCH_TIMEOUT_MS)
74654
+ });
74655
+ if (!res.ok) console.debug(`[key-proof] ${groupId.slice(0, 8)}: HTTP ${res.status}`);
74656
+ } catch (err) {
74657
+ console.debug(`[key-proof] ${groupId.slice(0, 8)}: report failed (non-critical):`, err);
74658
+ }
74659
+ }
74660
+ }
74661
+ /**
74662
+ * The wire MLS group id as a UUID string, or null. Every founder today —
74663
+ * ts-mls and Hermes alike — uses the server's UUID string as UTF-8 (36
74664
+ * bytes). A 16-byte id (the UUID's raw bytes) is mapped too, defensively:
74665
+ * dropping one would leave this agent "never proved" in that group.
74666
+ */
74667
+ static _mlsGroupIdString(raw) {
74668
+ if (raw.length === 16) {
74669
+ const h2 = Buffer.from(raw).toString("hex");
74670
+ return `${h2.slice(0, 8)}-${h2.slice(8, 12)}-${h2.slice(12, 16)}-${h2.slice(16, 20)}-${h2.slice(20)}`;
74671
+ }
74672
+ const s2 = new TextDecoder().decode(raw).toLowerCase();
74673
+ return UUID_RE4.test(s2) ? s2 : null;
74674
+ }
74586
74675
  /**
74587
74676
  * The server's EXPIRY-AWARE usable KeyPackage count, or null when unknown.
74588
74677
  *
@@ -103969,7 +104058,7 @@ var init_index = __esm({
103969
104058
  await init_policy_enforcer();
103970
104059
  init_room_protocol();
103971
104060
  init_tool_telemetry();
103972
- VERSION = true ? "0.23.62" : "0.0.0-dev";
104061
+ VERSION = true ? "0.23.63" : "0.0.0-dev";
103973
104062
  }
103974
104063
  });
103975
104064
  await init_index();