@agentvault/agentvault 0.23.61 → 0.23.62

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
@@ -64354,6 +64354,7 @@ var init_secure_file = __esm({
64354
64354
  });
64355
64355
 
64356
64356
  // src/mls-state.ts
64357
+ import { readFileSync } from "node:fs";
64357
64358
  import { readdir, readFile, rename, rm } from "node:fs/promises";
64358
64359
  import { join } from "node:path";
64359
64360
  function syncLockPath(dataDir, channelId) {
@@ -64488,13 +64489,26 @@ async function quarantineOrphanedMlsState(dataDir, isStillMember, opts = {}) {
64488
64489
  }
64489
64490
  return quarantined;
64490
64491
  }
64491
- var SYNC_LOCK_STALE_MS, pendingKpPath;
64492
+ function loadDecryptedMessageIdsSync(dataDir) {
64493
+ try {
64494
+ const raw = JSON.parse(readFileSync(join(dataDir, DECRYPTED_IDS_FILE), "utf8"));
64495
+ return Array.isArray(raw) ? raw.filter((id) => typeof id === "string" && id !== "") : [];
64496
+ } catch {
64497
+ return [];
64498
+ }
64499
+ }
64500
+ async function saveDecryptedMessageIds(dataDir, ids) {
64501
+ await ensureSecureDir(dataDir);
64502
+ await writeSecureFile(join(dataDir, DECRYPTED_IDS_FILE), JSON.stringify(ids));
64503
+ }
64504
+ var SYNC_LOCK_STALE_MS, pendingKpPath, DECRYPTED_IDS_FILE;
64492
64505
  var init_mls_state = __esm({
64493
64506
  "src/mls-state.ts"() {
64494
64507
  "use strict";
64495
64508
  init_secure_file();
64496
64509
  SYNC_LOCK_STALE_MS = 5 * 60 * 1e3;
64497
64510
  pendingKpPath = (dataDir, groupId) => join(dataDir, `mls-kp-pending-${groupId.replace(/[^a-zA-Z0-9_-]/g, "_")}.json`);
64511
+ DECRYPTED_IDS_FILE = "decrypted-message-ids.json";
64498
64512
  }
64499
64513
  });
64500
64514
 
@@ -64526,11 +64540,11 @@ var init_mls_kp_pool = __esm({
64526
64540
 
64527
64541
  // src/client-version.ts
64528
64542
  function ownIdentity() {
64529
- const v2 = true ? "0.23.61" : FALLBACK;
64543
+ const v2 = true ? "0.23.62" : FALLBACK;
64530
64544
  return `${PACKAGE}@${v2}`;
64531
64545
  }
64532
64546
  function buildSha() {
64533
- const raw = true ? "129e537" : "";
64547
+ const raw = true ? "4db8d51" : "";
64534
64548
  const cleaned = (raw ?? "").trim();
64535
64549
  return !cleaned || cleaned === "unknown" ? null : cleaned;
64536
64550
  }
@@ -66658,7 +66672,7 @@ import { EventEmitter } from "node:events";
66658
66672
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
66659
66673
  import { createServer } from "node:http";
66660
66674
  import { randomUUID as randomUUID4, createHash } from "node:crypto";
66661
- import { readFileSync } from "node:fs";
66675
+ import { readFileSync as readFileSync2 } from "node:fs";
66662
66676
  import { homedir as osHomedir } from "node:os";
66663
66677
  import { writeFile as writeFile3, mkdir as mkdir4 } from "node:fs/promises";
66664
66678
  import { join as join6 } from "node:path";
@@ -66946,6 +66960,13 @@ var init_channel = __esm({
66946
66960
  */
66947
66961
  _decryptedMessageIds = /* @__PURE__ */ new Map();
66948
66962
  static DECRYPTED_ID_CAP = 5e3;
66963
+ /** #1518 follow-up: the ids survive a restart. A fleet roll restarts every
66964
+ * agent, and the replay after it was counted again (wren, live 2026-10-29:
66965
+ * 4/3 and two #1084 no-op strikes from one restart). Loaded once, lazily;
66966
+ * saved at most every DECRYPTED_IDS_SAVE_MS. */
66967
+ _decryptedIdsLoaded = false;
66968
+ _decryptedIdsSaveTimer = null;
66969
+ static DECRYPTED_IDS_SAVE_MS = 2e3;
66949
66970
  /**
66950
66971
  * #1084: consecutive resyncs that found NOTHING to apply, per group.
66951
66972
  *
@@ -69151,7 +69172,7 @@ ${text}`,
69151
69172
  */
69152
69173
  sendActivitySpan(spanData) {
69153
69174
  if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
69154
- const pluginVersion = true ? "0.23.61" : "0.0.0-dev";
69175
+ const pluginVersion = true ? "0.23.62" : "0.0.0-dev";
69155
69176
  const agentName = this.config.agentName ?? "Agent";
69156
69177
  const resource = {
69157
69178
  "service.name": "agentvault-agent",
@@ -71361,7 +71382,7 @@ ${text}`,
71361
71382
  agentVersion: this.config.agentVersion ?? "0.0.0",
71362
71383
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
71363
71384
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
71364
- pluginVersion: true ? "0.23.61" : "0.0.0-dev"
71385
+ pluginVersion: true ? "0.23.62" : "0.0.0-dev"
71365
71386
  });
71366
71387
  this._telemetryReporter.startAutoFlush(3e4);
71367
71388
  }
@@ -71693,7 +71714,7 @@ ${text}`,
71693
71714
  agentVersion: this.config.agentVersion ?? "0.0.0",
71694
71715
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
71695
71716
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
71696
- pluginVersion: true ? "0.23.61" : "0.0.0-dev"
71717
+ pluginVersion: true ? "0.23.62" : "0.0.0-dev"
71697
71718
  });
71698
71719
  this._telemetryReporter.startAutoFlush(3e4);
71699
71720
  }
@@ -72138,6 +72159,7 @@ ${text}`,
72138
72159
  const result = await mgr.decrypt(cipherBytes);
72139
72160
  this._rememberDecrypted(data.message_id);
72140
72161
  if (mgrKey) this._mlsDecryptFailCounts.delete(mgrKey);
72162
+ if (mgrKey) this._resyncNoOpStrikes.delete(mgrKey);
72141
72163
  const mlsGroupId = (convGroupId ? this._persisted?.mlsGroups?.[convGroupId]?.mlsGroupId : null) ?? this._persisted?.mlsConversations?.[convId]?.mlsGroupId ?? groupId;
72142
72164
  if (mlsGroupId) {
72143
72165
  await saveMlsState(this.config.dataDir, mlsGroupId, JSON.stringify(mgr.exportState()));
@@ -72770,7 +72792,7 @@ ${baseText}`;
72770
72792
  }
72771
72793
  try {
72772
72794
  const configPath = join6(homedir2, ".openclaw", "openclaw.json");
72773
- const raw = readFileSync(configPath, "utf-8");
72795
+ const raw = readFileSync2(configPath, "utf-8");
72774
72796
  const config2 = JSON.parse(raw);
72775
72797
  const agents = config2?.agents?.list;
72776
72798
  if (Array.isArray(agents) && agentName) {
@@ -73168,6 +73190,7 @@ ${baseText}`;
73168
73190
  const result = await mlsGroup.decrypt(new Uint8Array(ciphertext));
73169
73191
  this._rememberDecrypted(data.message_id);
73170
73192
  this._mlsDecryptFailCounts.delete(resolvedRoomId);
73193
+ this._resyncNoOpStrikes.delete(resolvedRoomId);
73171
73194
  await saveMlsState(this.config.dataDir, groupId, JSON.stringify(mlsGroup.exportState()));
73172
73195
  if (result.isHandshake || !result.plaintext) {
73173
73196
  return;
@@ -74362,18 +74385,48 @@ ${baseText}`;
74362
74385
  );
74363
74386
  return true;
74364
74387
  }
74365
- /** #1518: has this process already decrypted the frame with this id? */
74388
+ /** #1518: load the remembered ids once from this agent's data dir. A
74389
+ * missing or unreadable file is an empty set — never a throw. */
74390
+ _loadDecryptedIds() {
74391
+ if (this._decryptedIdsLoaded) return;
74392
+ this._decryptedIdsLoaded = true;
74393
+ try {
74394
+ for (const id of loadDecryptedMessageIdsSync(this.config.dataDir).slice(-_SecureChannel.DECRYPTED_ID_CAP)) {
74395
+ if (!this._decryptedMessageIds.has(id)) this._decryptedMessageIds.set(id, true);
74396
+ }
74397
+ } catch {
74398
+ }
74399
+ }
74400
+ /** #1518: has this agent already decrypted the frame with this id? */
74366
74401
  _alreadyDecrypted(messageId) {
74367
- return typeof messageId === "string" && messageId !== "" && this._decryptedMessageIds.has(messageId);
74402
+ if (typeof messageId !== "string" || messageId === "") return false;
74403
+ this._loadDecryptedIds();
74404
+ return this._decryptedMessageIds.has(messageId);
74368
74405
  }
74369
- /** #1518: remember a decrypted frame's id (bounded; oldest dropped). */
74406
+ /** #1518: remember a decrypted frame's id (bounded; oldest dropped) and
74407
+ * schedule a save. */
74370
74408
  _rememberDecrypted(messageId) {
74371
74409
  if (typeof messageId !== "string" || messageId === "") return;
74410
+ this._loadDecryptedIds();
74372
74411
  this._decryptedMessageIds.set(messageId, true);
74373
74412
  if (this._decryptedMessageIds.size > _SecureChannel.DECRYPTED_ID_CAP) {
74374
74413
  const oldest = this._decryptedMessageIds.keys().next().value;
74375
74414
  if (oldest !== void 0) this._decryptedMessageIds.delete(oldest);
74376
74415
  }
74416
+ if (this._decryptedIdsSaveTimer) return;
74417
+ this._decryptedIdsSaveTimer = setTimeout(() => {
74418
+ this._decryptedIdsSaveTimer = null;
74419
+ void this._saveDecryptedIds();
74420
+ }, _SecureChannel.DECRYPTED_IDS_SAVE_MS);
74421
+ this._decryptedIdsSaveTimer.unref?.();
74422
+ }
74423
+ /** #1518: best-effort; a failed save only costs a recount later. */
74424
+ async _saveDecryptedIds() {
74425
+ try {
74426
+ await saveDecryptedMessageIds(this.config.dataDir, [...this._decryptedMessageIds.keys()]);
74427
+ } catch (err) {
74428
+ console.warn("[SecureChannel] could not save decrypted message ids (#1518):", err);
74429
+ }
74377
74430
  }
74378
74431
  async _resyncOnDivergence(groupKey, groupId) {
74379
74432
  const mgr = this._mlsGroups.get(groupKey);
@@ -75518,6 +75571,7 @@ ${baseText}`;
75518
75571
  const result = await mlsGroup.decrypt(ciphertext);
75519
75572
  this._rememberDecrypted(data.message_id);
75520
75573
  this._mlsDecryptFailCounts.delete(`a2a:${a2aChannelId}`);
75574
+ this._resyncNoOpStrikes.delete(`a2a:${a2aChannelId}`);
75521
75575
  await saveMlsState(this.config.dataDir, groupId, JSON.stringify(mlsGroup.exportState()));
75522
75576
  if (result.isHandshake || !result.plaintext) {
75523
75577
  return;
@@ -103375,7 +103429,7 @@ var init_mcp_handlers = __esm({
103375
103429
  });
103376
103430
 
103377
103431
  // src/skill-manifest.ts
103378
- import { readFileSync as readFileSync2, existsSync, readdirSync } from "node:fs";
103432
+ import { readFileSync as readFileSync3, existsSync, readdirSync } from "node:fs";
103379
103433
  import { resolve as resolve3, join as join7 } from "node:path";
103380
103434
  function parseSkillMd(content) {
103381
103435
  const lines = content.split("\n");
@@ -103484,7 +103538,7 @@ function loadSkillsFromDirectory(dir) {
103484
103538
  if (seen.has(filePath)) return;
103485
103539
  seen.add(filePath);
103486
103540
  try {
103487
- const content = readFileSync2(filePath, "utf-8");
103541
+ const content = readFileSync3(filePath, "utf-8");
103488
103542
  const skill = parseSkillMd(content);
103489
103543
  if (skill) skills.push(skill);
103490
103544
  } catch {
@@ -103915,7 +103969,7 @@ var init_index = __esm({
103915
103969
  await init_policy_enforcer();
103916
103970
  init_room_protocol();
103917
103971
  init_tool_telemetry();
103918
- VERSION = true ? "0.23.61" : "0.0.0-dev";
103972
+ VERSION = true ? "0.23.62" : "0.0.0-dev";
103919
103973
  }
103920
103974
  });
103921
103975
  await init_index();