@agentvault/agentvault 0.23.61 → 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/channel.d.ts +51 -2
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +171 -28
- package/dist/cli.js.map +3 -3
- package/dist/index.js +157 -14
- package/dist/index.js.map +3 -3
- package/dist/mls-state.d.ts +2 -0
- package/dist/mls-state.d.ts.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
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
|
-
|
|
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.
|
|
64543
|
+
const v2 = true ? "0.23.63" : FALLBACK;
|
|
64530
64544
|
return `${PACKAGE}@${v2}`;
|
|
64531
64545
|
}
|
|
64532
64546
|
function buildSha() {
|
|
64533
|
-
const raw = true ? "
|
|
64547
|
+
const raw = true ? "52249f2" : "";
|
|
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";
|
|
@@ -66917,6 +66931,16 @@ var init_channel = __esm({
|
|
|
66917
66931
|
*/
|
|
66918
66932
|
static _KP_REPLENISH_INTERVAL_MS = 6 * 60 * 60 * 1e3;
|
|
66919
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;
|
|
66920
66944
|
_a2aReconcileTimer = null;
|
|
66921
66945
|
_deliveryPulling = false;
|
|
66922
66946
|
_drDeliveryPulling = false;
|
|
@@ -66946,6 +66970,13 @@ var init_channel = __esm({
|
|
|
66946
66970
|
*/
|
|
66947
66971
|
_decryptedMessageIds = /* @__PURE__ */ new Map();
|
|
66948
66972
|
static DECRYPTED_ID_CAP = 5e3;
|
|
66973
|
+
/** #1518 follow-up: the ids survive a restart. A fleet roll restarts every
|
|
66974
|
+
* agent, and the replay after it was counted again (wren, live 2026-10-29:
|
|
66975
|
+
* 4/3 and two #1084 no-op strikes from one restart). Loaded once, lazily;
|
|
66976
|
+
* saved at most every DECRYPTED_IDS_SAVE_MS. */
|
|
66977
|
+
_decryptedIdsLoaded = false;
|
|
66978
|
+
_decryptedIdsSaveTimer = null;
|
|
66979
|
+
static DECRYPTED_IDS_SAVE_MS = 2e3;
|
|
66949
66980
|
/**
|
|
66950
66981
|
* #1084: consecutive resyncs that found NOTHING to apply, per group.
|
|
66951
66982
|
*
|
|
@@ -69151,7 +69182,7 @@ ${text}`,
|
|
|
69151
69182
|
*/
|
|
69152
69183
|
sendActivitySpan(spanData) {
|
|
69153
69184
|
if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
|
|
69154
|
-
const pluginVersion = true ? "0.23.
|
|
69185
|
+
const pluginVersion = true ? "0.23.63" : "0.0.0-dev";
|
|
69155
69186
|
const agentName = this.config.agentName ?? "Agent";
|
|
69156
69187
|
const resource = {
|
|
69157
69188
|
"service.name": "agentvault-agent",
|
|
@@ -70355,6 +70386,7 @@ ${text}`,
|
|
|
70355
70386
|
this._telemetryReporter = null;
|
|
70356
70387
|
}
|
|
70357
70388
|
this._stopA2aReconcileTimer();
|
|
70389
|
+
this._stopKeyProofTimer();
|
|
70358
70390
|
if (this._ws) {
|
|
70359
70391
|
this._ws.removeAllListeners();
|
|
70360
70392
|
this._ws.close();
|
|
@@ -71361,7 +71393,7 @@ ${text}`,
|
|
|
71361
71393
|
agentVersion: this.config.agentVersion ?? "0.0.0",
|
|
71362
71394
|
// __AV_VERSION__ is injected by esbuild from package.json at build time.
|
|
71363
71395
|
// Falls back to "0.0.0-dev" in non-bundled contexts (tests).
|
|
71364
|
-
pluginVersion: true ? "0.23.
|
|
71396
|
+
pluginVersion: true ? "0.23.63" : "0.0.0-dev"
|
|
71365
71397
|
});
|
|
71366
71398
|
this._telemetryReporter.startAutoFlush(3e4);
|
|
71367
71399
|
}
|
|
@@ -71372,6 +71404,7 @@ ${text}`,
|
|
|
71372
71404
|
if (aborted2()) return;
|
|
71373
71405
|
await this._ensureKpPoolPublished();
|
|
71374
71406
|
this._startKpReplenishTimer();
|
|
71407
|
+
this._startKeyProofTimer();
|
|
71375
71408
|
this._pullDeliveryQueue().catch((err) => {
|
|
71376
71409
|
console.warn("[SecureChannel] Initial delivery pull failed:", err);
|
|
71377
71410
|
});
|
|
@@ -71693,7 +71726,7 @@ ${text}`,
|
|
|
71693
71726
|
agentVersion: this.config.agentVersion ?? "0.0.0",
|
|
71694
71727
|
// __AV_VERSION__ is injected by esbuild from package.json at build time.
|
|
71695
71728
|
// Falls back to "0.0.0-dev" in non-bundled contexts (tests).
|
|
71696
|
-
pluginVersion: true ? "0.23.
|
|
71729
|
+
pluginVersion: true ? "0.23.63" : "0.0.0-dev"
|
|
71697
71730
|
});
|
|
71698
71731
|
this._telemetryReporter.startAutoFlush(3e4);
|
|
71699
71732
|
}
|
|
@@ -72072,6 +72105,7 @@ ${text}`,
|
|
|
72072
72105
|
}
|
|
72073
72106
|
this._stopA2aReconcileTimer();
|
|
72074
72107
|
this._stopKpReplenishTimer();
|
|
72108
|
+
this._stopKeyProofTimer();
|
|
72075
72109
|
if (this._stopped) return;
|
|
72076
72110
|
this._setState("disconnected");
|
|
72077
72111
|
this._scheduleReconnect();
|
|
@@ -72138,6 +72172,7 @@ ${text}`,
|
|
|
72138
72172
|
const result = await mgr.decrypt(cipherBytes);
|
|
72139
72173
|
this._rememberDecrypted(data.message_id);
|
|
72140
72174
|
if (mgrKey) this._mlsDecryptFailCounts.delete(mgrKey);
|
|
72175
|
+
if (mgrKey) this._resyncNoOpStrikes.delete(mgrKey);
|
|
72141
72176
|
const mlsGroupId = (convGroupId ? this._persisted?.mlsGroups?.[convGroupId]?.mlsGroupId : null) ?? this._persisted?.mlsConversations?.[convId]?.mlsGroupId ?? groupId;
|
|
72142
72177
|
if (mlsGroupId) {
|
|
72143
72178
|
await saveMlsState(this.config.dataDir, mlsGroupId, JSON.stringify(mgr.exportState()));
|
|
@@ -72770,7 +72805,7 @@ ${baseText}`;
|
|
|
72770
72805
|
}
|
|
72771
72806
|
try {
|
|
72772
72807
|
const configPath = join6(homedir2, ".openclaw", "openclaw.json");
|
|
72773
|
-
const raw =
|
|
72808
|
+
const raw = readFileSync2(configPath, "utf-8");
|
|
72774
72809
|
const config2 = JSON.parse(raw);
|
|
72775
72810
|
const agents = config2?.agents?.list;
|
|
72776
72811
|
if (Array.isArray(agents) && agentName) {
|
|
@@ -73168,6 +73203,7 @@ ${baseText}`;
|
|
|
73168
73203
|
const result = await mlsGroup.decrypt(new Uint8Array(ciphertext));
|
|
73169
73204
|
this._rememberDecrypted(data.message_id);
|
|
73170
73205
|
this._mlsDecryptFailCounts.delete(resolvedRoomId);
|
|
73206
|
+
this._resyncNoOpStrikes.delete(resolvedRoomId);
|
|
73171
73207
|
await saveMlsState(this.config.dataDir, groupId, JSON.stringify(mlsGroup.exportState()));
|
|
73172
73208
|
if (result.isHandshake || !result.plaintext) {
|
|
73173
73209
|
return;
|
|
@@ -74362,18 +74398,48 @@ ${baseText}`;
|
|
|
74362
74398
|
);
|
|
74363
74399
|
return true;
|
|
74364
74400
|
}
|
|
74365
|
-
/** #1518:
|
|
74401
|
+
/** #1518: load the remembered ids once from this agent's data dir. A
|
|
74402
|
+
* missing or unreadable file is an empty set — never a throw. */
|
|
74403
|
+
_loadDecryptedIds() {
|
|
74404
|
+
if (this._decryptedIdsLoaded) return;
|
|
74405
|
+
this._decryptedIdsLoaded = true;
|
|
74406
|
+
try {
|
|
74407
|
+
for (const id of loadDecryptedMessageIdsSync(this.config.dataDir).slice(-_SecureChannel.DECRYPTED_ID_CAP)) {
|
|
74408
|
+
if (!this._decryptedMessageIds.has(id)) this._decryptedMessageIds.set(id, true);
|
|
74409
|
+
}
|
|
74410
|
+
} catch {
|
|
74411
|
+
}
|
|
74412
|
+
}
|
|
74413
|
+
/** #1518: has this agent already decrypted the frame with this id? */
|
|
74366
74414
|
_alreadyDecrypted(messageId) {
|
|
74367
|
-
|
|
74415
|
+
if (typeof messageId !== "string" || messageId === "") return false;
|
|
74416
|
+
this._loadDecryptedIds();
|
|
74417
|
+
return this._decryptedMessageIds.has(messageId);
|
|
74368
74418
|
}
|
|
74369
|
-
/** #1518: remember a decrypted frame's id (bounded; oldest dropped)
|
|
74419
|
+
/** #1518: remember a decrypted frame's id (bounded; oldest dropped) and
|
|
74420
|
+
* schedule a save. */
|
|
74370
74421
|
_rememberDecrypted(messageId) {
|
|
74371
74422
|
if (typeof messageId !== "string" || messageId === "") return;
|
|
74423
|
+
this._loadDecryptedIds();
|
|
74372
74424
|
this._decryptedMessageIds.set(messageId, true);
|
|
74373
74425
|
if (this._decryptedMessageIds.size > _SecureChannel.DECRYPTED_ID_CAP) {
|
|
74374
74426
|
const oldest = this._decryptedMessageIds.keys().next().value;
|
|
74375
74427
|
if (oldest !== void 0) this._decryptedMessageIds.delete(oldest);
|
|
74376
74428
|
}
|
|
74429
|
+
if (this._decryptedIdsSaveTimer) return;
|
|
74430
|
+
this._decryptedIdsSaveTimer = setTimeout(() => {
|
|
74431
|
+
this._decryptedIdsSaveTimer = null;
|
|
74432
|
+
void this._saveDecryptedIds();
|
|
74433
|
+
}, _SecureChannel.DECRYPTED_IDS_SAVE_MS);
|
|
74434
|
+
this._decryptedIdsSaveTimer.unref?.();
|
|
74435
|
+
}
|
|
74436
|
+
/** #1518: best-effort; a failed save only costs a recount later. */
|
|
74437
|
+
async _saveDecryptedIds() {
|
|
74438
|
+
try {
|
|
74439
|
+
await saveDecryptedMessageIds(this.config.dataDir, [...this._decryptedMessageIds.keys()]);
|
|
74440
|
+
} catch (err) {
|
|
74441
|
+
console.warn("[SecureChannel] could not save decrypted message ids (#1518):", err);
|
|
74442
|
+
}
|
|
74377
74443
|
}
|
|
74378
74444
|
async _resyncOnDivergence(groupKey, groupId) {
|
|
74379
74445
|
const mgr = this._mlsGroups.get(groupKey);
|
|
@@ -74530,6 +74596,82 @@ ${baseText}`;
|
|
|
74530
74596
|
this._kpReplenishTimer = null;
|
|
74531
74597
|
}
|
|
74532
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
|
+
}
|
|
74533
74675
|
/**
|
|
74534
74676
|
* The server's EXPIRY-AWARE usable KeyPackage count, or null when unknown.
|
|
74535
74677
|
*
|
|
@@ -75518,6 +75660,7 @@ ${baseText}`;
|
|
|
75518
75660
|
const result = await mlsGroup.decrypt(ciphertext);
|
|
75519
75661
|
this._rememberDecrypted(data.message_id);
|
|
75520
75662
|
this._mlsDecryptFailCounts.delete(`a2a:${a2aChannelId}`);
|
|
75663
|
+
this._resyncNoOpStrikes.delete(`a2a:${a2aChannelId}`);
|
|
75521
75664
|
await saveMlsState(this.config.dataDir, groupId, JSON.stringify(mlsGroup.exportState()));
|
|
75522
75665
|
if (result.isHandshake || !result.plaintext) {
|
|
75523
75666
|
return;
|
|
@@ -103375,7 +103518,7 @@ var init_mcp_handlers = __esm({
|
|
|
103375
103518
|
});
|
|
103376
103519
|
|
|
103377
103520
|
// src/skill-manifest.ts
|
|
103378
|
-
import { readFileSync as
|
|
103521
|
+
import { readFileSync as readFileSync3, existsSync, readdirSync } from "node:fs";
|
|
103379
103522
|
import { resolve as resolve3, join as join7 } from "node:path";
|
|
103380
103523
|
function parseSkillMd(content) {
|
|
103381
103524
|
const lines = content.split("\n");
|
|
@@ -103484,7 +103627,7 @@ function loadSkillsFromDirectory(dir) {
|
|
|
103484
103627
|
if (seen.has(filePath)) return;
|
|
103485
103628
|
seen.add(filePath);
|
|
103486
103629
|
try {
|
|
103487
|
-
const content =
|
|
103630
|
+
const content = readFileSync3(filePath, "utf-8");
|
|
103488
103631
|
const skill = parseSkillMd(content);
|
|
103489
103632
|
if (skill) skills.push(skill);
|
|
103490
103633
|
} catch {
|
|
@@ -103915,7 +104058,7 @@ var init_index = __esm({
|
|
|
103915
104058
|
await init_policy_enforcer();
|
|
103916
104059
|
init_room_protocol();
|
|
103917
104060
|
init_tool_telemetry();
|
|
103918
|
-
VERSION = true ? "0.23.
|
|
104061
|
+
VERSION = true ? "0.23.63" : "0.0.0-dev";
|
|
103919
104062
|
}
|
|
103920
104063
|
});
|
|
103921
104064
|
await init_index();
|