@agentvault/agentvault 0.23.72 → 0.23.74
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/README.md +2 -2
- package/dist/channel.d.ts +64 -2
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +367 -94
- package/dist/cli.js.map +4 -4
- package/dist/create-agent.d.ts +17 -0
- package/dist/create-agent.d.ts.map +1 -1
- package/dist/dm-group-pins.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +360 -91
- package/dist/index.js.map +4 -4
- package/dist/openclaw-entry.d.ts +12 -4
- package/dist/openclaw-entry.d.ts.map +1 -1
- package/dist/openclaw-entry.js +8 -7
- package/dist/openclaw-entry.js.map +2 -2
- package/dist/openclaw-plugin.d.ts.map +1 -1
- package/dist/room-protocol.d.ts +22 -2
- package/dist/room-protocol.d.ts.map +1 -1
- package/dist/shell-word.d.ts +21 -0
- package/dist/shell-word.d.ts.map +1 -0
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -269,7 +269,8 @@ function resolveOwn(mention, names) {
|
|
|
269
269
|
}
|
|
270
270
|
return null;
|
|
271
271
|
}
|
|
272
|
-
function owesRoomReply(plaintext, agentName, accountId, senderIsAgent, roomDisplayName, ownDisplayName, selfResolved = true, roomAudience) {
|
|
272
|
+
function owesRoomReply(plaintext, agentName, accountId, senderIsAgent, roomDisplayName, ownDisplayName, selfResolved = true, roomAudience, senderBinding) {
|
|
273
|
+
if (senderBinding !== void 0 && senderBinding !== "bound") senderIsAgent = true;
|
|
273
274
|
if (isPrivatePairHumanMessage(senderIsAgent, roomAudience)) return true;
|
|
274
275
|
const mentions = parseMentions(plaintext);
|
|
275
276
|
if (senderIsAgent === false && namesAgentPlainly(plaintext, agentName, roomDisplayName, ownDisplayName)) {
|
|
@@ -279,7 +280,7 @@ function owesRoomReply(plaintext, agentName, accountId, senderIsAgent, roomDispl
|
|
|
279
280
|
const ownNames = ownRoomNames(agentName, accountId, roomDisplayName, ownDisplayName);
|
|
280
281
|
if (mentions.some((m2) => resolveOwn(m2, ownNames) !== null)) return true;
|
|
281
282
|
if (mentions.some((m2) => resolveOwn(m2, BROADCAST_NAMES) !== null)) {
|
|
282
|
-
return senderIsAgent !== true;
|
|
283
|
+
return senderBinding === "bound" && senderIsAgent !== true;
|
|
283
284
|
}
|
|
284
285
|
if (!selfResolved) return true;
|
|
285
286
|
return false;
|
|
@@ -24114,11 +24115,11 @@ var init_mls_kp_pool = __esm({
|
|
|
24114
24115
|
|
|
24115
24116
|
// src/client-version.ts
|
|
24116
24117
|
function ownIdentity() {
|
|
24117
|
-
const v2 = true ? "0.23.
|
|
24118
|
+
const v2 = true ? "0.23.74" : FALLBACK;
|
|
24118
24119
|
return `${PACKAGE}@${v2}`;
|
|
24119
24120
|
}
|
|
24120
24121
|
function buildSha() {
|
|
24121
|
-
const raw = true ? "
|
|
24122
|
+
const raw = true ? "91424d1" : "";
|
|
24122
24123
|
const cleaned = (raw ?? "").trim();
|
|
24123
24124
|
return !cleaned || cleaned === "unknown" ? null : cleaned;
|
|
24124
24125
|
}
|
|
@@ -26736,6 +26737,28 @@ var init_welcome_kp_backoff = __esm({
|
|
|
26736
26737
|
}
|
|
26737
26738
|
});
|
|
26738
26739
|
|
|
26740
|
+
// ../crypto/dist/invisible-text.js
|
|
26741
|
+
function replaceInvisible(value, replacement) {
|
|
26742
|
+
return value.replace(DEFAULT_IGNORABLE, (ch) => KEPT_IGNORABLE.has(ch.codePointAt(0)) ? ch : replacement).replace(OBJECT_REPLACEMENT, replacement).replace(CONTROL, (ch) => KEPT_CONTROL.has(ch.codePointAt(0)) ? ch : replacement);
|
|
26743
|
+
}
|
|
26744
|
+
function drawsNothing(value) {
|
|
26745
|
+
return value.replace(INVISIBLE2, "").split(BRAILLE_BLANK).join("").length === 0;
|
|
26746
|
+
}
|
|
26747
|
+
var ZWJ, DEFAULT_IGNORABLE, KEPT_IGNORABLE, OBJECT_REPLACEMENT, CONTROL, KEPT_CONTROL, INVISIBLE2, BRAILLE_BLANK;
|
|
26748
|
+
var init_invisible_text = __esm({
|
|
26749
|
+
"../crypto/dist/invisible-text.js"() {
|
|
26750
|
+
"use strict";
|
|
26751
|
+
ZWJ = 8205;
|
|
26752
|
+
DEFAULT_IGNORABLE = new RegExp("\\p{Default_Ignorable_Code_Point}", "gu");
|
|
26753
|
+
KEPT_IGNORABLE = /* @__PURE__ */ new Set([8204, ZWJ, 65039]);
|
|
26754
|
+
OBJECT_REPLACEMENT = new RegExp(String.fromCodePoint(65532), "g");
|
|
26755
|
+
CONTROL = new RegExp("\\p{Cc}", "gu");
|
|
26756
|
+
KEPT_CONTROL = /* @__PURE__ */ new Set([9, 10, 13]);
|
|
26757
|
+
INVISIBLE2 = /[\s\p{Cf}\p{Default_Ignorable_Code_Point}]/gu;
|
|
26758
|
+
BRAILLE_BLANK = String.fromCodePoint(10240);
|
|
26759
|
+
}
|
|
26760
|
+
});
|
|
26761
|
+
|
|
26739
26762
|
// src/dm-group-pins.ts
|
|
26740
26763
|
function isUuid(v2) {
|
|
26741
26764
|
return typeof v2 === "string" && UUID_RE3.test(v2);
|
|
@@ -26875,8 +26898,8 @@ function drOwnerClaimNotice(label) {
|
|
|
26875
26898
|
}
|
|
26876
26899
|
function sanitizeDeviceLabel(name) {
|
|
26877
26900
|
if (typeof name !== "string") return null;
|
|
26878
|
-
const clean8 = name
|
|
26879
|
-
if (clean8 === "") return null;
|
|
26901
|
+
const clean8 = replaceInvisible(name, " ").replace(/\s+/g, " ").trim();
|
|
26902
|
+
if (clean8 === "" || drawsNothing(clean8)) return null;
|
|
26880
26903
|
const points = Array.from(clean8);
|
|
26881
26904
|
return points.length > 64 ? `${points.slice(0, 63).join("")}\u2026` : clean8;
|
|
26882
26905
|
}
|
|
@@ -26885,6 +26908,7 @@ var init_dm_group_pins = __esm({
|
|
|
26885
26908
|
"src/dm-group-pins.ts"() {
|
|
26886
26909
|
"use strict";
|
|
26887
26910
|
init_mls_sender_binding();
|
|
26911
|
+
init_invisible_text();
|
|
26888
26912
|
UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
26889
26913
|
CANONICAL_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
26890
26914
|
WELCOME_ROUTING_FIELDS = [
|
|
@@ -29879,6 +29903,60 @@ function anySignal(signals) {
|
|
|
29879
29903
|
}
|
|
29880
29904
|
return c2.signal;
|
|
29881
29905
|
}
|
|
29906
|
+
function textCutEnd(value, budget) {
|
|
29907
|
+
const Segmenter = Intl.Segmenter;
|
|
29908
|
+
if (typeof Segmenter === "function") {
|
|
29909
|
+
const segmenter = new Segmenter(
|
|
29910
|
+
void 0,
|
|
29911
|
+
{ granularity: "grapheme" }
|
|
29912
|
+
);
|
|
29913
|
+
let end2 = 0;
|
|
29914
|
+
for (const { segment, index } of segmenter.segment(value.slice(0, budget + 64))) {
|
|
29915
|
+
if (index + segment.length > budget) break;
|
|
29916
|
+
end2 = index + segment.length;
|
|
29917
|
+
}
|
|
29918
|
+
return end2;
|
|
29919
|
+
}
|
|
29920
|
+
let end = budget;
|
|
29921
|
+
const last = value.charCodeAt(end - 1);
|
|
29922
|
+
if (last >= 55296 && last <= 56319) end -= 1;
|
|
29923
|
+
for (; ; ) {
|
|
29924
|
+
const before = end;
|
|
29925
|
+
while (end > 0 && value.charCodeAt(end - 1) === 8205) end -= 1;
|
|
29926
|
+
let regional = 0;
|
|
29927
|
+
for (let i2 = end; i2 >= 2; i2 -= 2) {
|
|
29928
|
+
const c2 = value.codePointAt(i2 - 2);
|
|
29929
|
+
if (c2 < 127462 || c2 > 127487) break;
|
|
29930
|
+
regional++;
|
|
29931
|
+
}
|
|
29932
|
+
if (regional % 2 === 1) end -= 2;
|
|
29933
|
+
if (end === before) return end;
|
|
29934
|
+
}
|
|
29935
|
+
}
|
|
29936
|
+
function capTextPart(value, max) {
|
|
29937
|
+
if (value.length <= max) return value;
|
|
29938
|
+
return `${value.slice(0, textCutEnd(value, max - 1))}\u2026`;
|
|
29939
|
+
}
|
|
29940
|
+
function statusAlertTextLine(alert) {
|
|
29941
|
+
const severity = STATUS_ALERT_SEVERITIES.has(alert.severity) ? String(alert.severity) : "info";
|
|
29942
|
+
const title = capTextPart(String(alert.title), STATUS_ALERT_TEXT_LIMITS.title);
|
|
29943
|
+
const message = capTextPart(String(alert.message), STATUS_ALERT_TEXT_LIMITS.message);
|
|
29944
|
+
return `[${severity.toUpperCase()}] ${title}: ${message}`;
|
|
29945
|
+
}
|
|
29946
|
+
function statusAlertEnvelope(alert, timestamp) {
|
|
29947
|
+
const envelope = {
|
|
29948
|
+
type: "status_alert",
|
|
29949
|
+
title: alert.title,
|
|
29950
|
+
message: alert.message,
|
|
29951
|
+
severity: alert.severity,
|
|
29952
|
+
timestamp
|
|
29953
|
+
};
|
|
29954
|
+
if (alert.detail !== void 0) envelope.detail = alert.detail;
|
|
29955
|
+
if (alert.detailFormat !== void 0) envelope.detail_format = alert.detailFormat;
|
|
29956
|
+
if (alert.category !== void 0) envelope.category = alert.category;
|
|
29957
|
+
envelope.text = statusAlertTextLine(alert);
|
|
29958
|
+
return envelope;
|
|
29959
|
+
}
|
|
29882
29960
|
function outboundDedupeKey(resolved, content, options) {
|
|
29883
29961
|
if (!OUTBOUND_DEDUPE_TYPES.has(content.type)) return null;
|
|
29884
29962
|
const base = [resolved.kind, resolved.id ?? "owner", options?.conversationId ?? "", options?.topicId ?? ""];
|
|
@@ -30019,7 +30097,7 @@ function historyErrorReason(error2) {
|
|
|
30019
30097
|
}
|
|
30020
30098
|
return typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599 ? `${name} (status ${status})` : name;
|
|
30021
30099
|
}
|
|
30022
|
-
var ROOM_AGENT_TYPES, CREDENTIAL_MESSAGE_TYPES, CATCHUP_MESSAGE_TYPES, ROOM_PROTOCOL_TYPES, POLL_INTERVAL_MS, RECONNECT_BASE_MS, UUID_RE5, KpIdentityRefused, RECONNECT_MAX_MS, PENDING_POLL_INTERVAL_MS, PENDING_POLL_SILENCE_MS, HISTORY_RESTORE_TIMEOUT_MS2, ROOM_ROSTER_REFRESH_TIMEOUT_MS, ROOM_ROSTER_OWNER_MAX_AGE_MS, TimedSet, HISTORY_UPLOAD_TIMEOUT_MS, CANONICAL_TIMESTAMP_RE, OUTBOUND_DEDUPE_WINDOW_MS, OUTBOUND_DEDUPE_MAX_SUPPRESS_MS, OUTBOUND_DEDUPE_MAX, OUTBOUND_DEDUPE_TYPES, RETRY_CANDIDATE_TTL_MS, RETRY_CANDIDATE_MAX, _turnConversation, _turnTokenStore, _drTurnStore, PERSON_INVOLVED_WINDOW_MS, ATTESTED_INBOUND_MAX, UNMAPPED_RECONCILE_COOLDOWN_MS, TOPIC_ID_RE, ROOM_FULFIL_COOLDOWN_MS, SecureChannel;
|
|
30100
|
+
var ROOM_AGENT_TYPES, STATUS_ALERT_TEXT_LIMITS, STATUS_ALERT_SEVERITIES, CREDENTIAL_MESSAGE_TYPES, CATCHUP_MESSAGE_TYPES, ROOM_PROTOCOL_TYPES, POLL_INTERVAL_MS, RECONNECT_BASE_MS, UUID_RE5, KpIdentityRefused, RECONNECT_MAX_MS, PENDING_POLL_INTERVAL_MS, PENDING_POLL_SILENCE_MS, HISTORY_RESTORE_TIMEOUT_MS2, ROOM_ROSTER_REFRESH_TIMEOUT_MS, ROOM_ROSTER_OWNER_MAX_AGE_MS, TimedSet, HISTORY_UPLOAD_TIMEOUT_MS, CANONICAL_TIMESTAMP_RE, OUTBOUND_DEDUPE_WINDOW_MS, OUTBOUND_DEDUPE_MAX_SUPPRESS_MS, OUTBOUND_DEDUPE_MAX, OUTBOUND_DEDUPE_TYPES, RETRY_CANDIDATE_TTL_MS, RETRY_CANDIDATE_MAX, _turnConversation, _turnTokenStore, _drTurnStore, PERSON_INVOLVED_WINDOW_MS, ATTESTED_INBOUND_MAX, UNMAPPED_RECONCILE_COOLDOWN_MS, TOPIC_ID_RE, ROOM_FULFIL_COOLDOWN_MS, SecureChannel;
|
|
30023
30101
|
var init_channel = __esm({
|
|
30024
30102
|
"src/channel.ts"() {
|
|
30025
30103
|
"use strict";
|
|
@@ -30071,6 +30149,8 @@ var init_channel = __esm({
|
|
|
30071
30149
|
"decision_response",
|
|
30072
30150
|
"artifact_share"
|
|
30073
30151
|
]);
|
|
30152
|
+
STATUS_ALERT_TEXT_LIMITS = { title: 120, message: 2e3 };
|
|
30153
|
+
STATUS_ALERT_SEVERITIES = /* @__PURE__ */ new Set(["info", "warning", "error", "critical"]);
|
|
30074
30154
|
CREDENTIAL_MESSAGE_TYPES = /* @__PURE__ */ new Set([
|
|
30075
30155
|
"credential_grant",
|
|
30076
30156
|
"credential_revoke",
|
|
@@ -30256,6 +30336,56 @@ var init_channel = __esm({
|
|
|
30256
30336
|
/** #1094: never let one slow report hold up the rest. */
|
|
30257
30337
|
static _KEY_PROOF_FETCH_TIMEOUT_MS = 1e4;
|
|
30258
30338
|
_keyProofTimer = null;
|
|
30339
|
+
/**
|
|
30340
|
+
* #1889: a group the server refuses a proof for — 404 "MLS group not found",
|
|
30341
|
+
* or 403 "Not a member of this group" outside the join grace — is not asked
|
|
30342
|
+
* again for this long (Hermes's #1543 window). A Welcome into the group, or a
|
|
30343
|
+
* `room_joined` for its room, ends the pause at once.
|
|
30344
|
+
*/
|
|
30345
|
+
static _KEY_PROOF_PAUSE_MS = 24 * 60 * 60 * 1e3;
|
|
30346
|
+
/**
|
|
30347
|
+
* #1889 review: a 403 pauses for ONE hour, not a day. A live member whose
|
|
30348
|
+
* roster entry lags still answers 403, and a paused proof reads as `stale`
|
|
30349
|
+
* to the lockout detector, which then cannot repair it on epoch_behind. An
|
|
30350
|
+
* hour bounds that while still cutting a dead room's 144 posts a day to 24.
|
|
30351
|
+
*/
|
|
30352
|
+
static _KEY_PROOF_403_PAUSE_MS = 60 * 60 * 1e3;
|
|
30353
|
+
/** When this process started: the join grace also covers a join made just before a restart. */
|
|
30354
|
+
_processStartedAt = Date.now();
|
|
30355
|
+
/**
|
|
30356
|
+
* #1889 review: one room's state is changed by one task at a time. The
|
|
30357
|
+
* reconcile's drop, `joinRoom` and a room Welcome's install all run under
|
|
30358
|
+
* the room's lock, so a re-admit can never be deleted half-way through.
|
|
30359
|
+
*/
|
|
30360
|
+
_roomLocks = /* @__PURE__ */ new Map();
|
|
30361
|
+
/**
|
|
30362
|
+
* #1889 review: `POST /mls/rooms/{id}/init` runs while `joinRoom` holds the
|
|
30363
|
+
* room's lock, and a delivery-queue Welcome for that room waits on the lock
|
|
30364
|
+
* (the pull is serial). Without a bound, a hung init stalled every group's
|
|
30365
|
+
* delivery for Node's 300 s default. It is the only network call made under
|
|
30366
|
+
* a room lock. Static and writable so a test can shorten it.
|
|
30367
|
+
*/
|
|
30368
|
+
static ROOM_INIT_FETCH_TIMEOUT_MS = 1e4;
|
|
30369
|
+
/**
|
|
30370
|
+
* #1889 / #1542: right after a join the server roster can lag this device,
|
|
30371
|
+
* and that lag answers 403 too. Inside this window a 403 pauses nothing: a
|
|
30372
|
+
* paused proof would read as never_proved.
|
|
30373
|
+
*/
|
|
30374
|
+
static _KEY_PROOF_JOIN_GRACE_MS = 30 * 60 * 1e3;
|
|
30375
|
+
/** The backend's detail for a device outside the roster (mls.py report_key_proof). */
|
|
30376
|
+
static KEY_PROOF_NOT_A_MEMBER_DETAIL = "Not a member of this group";
|
|
30377
|
+
/** #1889: group id -> ms until which its key proofs are paused. */
|
|
30378
|
+
_keyProofPausedUntil = /* @__PURE__ */ new Map();
|
|
30379
|
+
/** #1889: group id -> ms this device last joined it from a Welcome. */
|
|
30380
|
+
_mlsGroupJoinedAt = /* @__PURE__ */ new Map();
|
|
30381
|
+
/**
|
|
30382
|
+
* #1889: room id -> how many times `joinRoom` ran for it. A room reconcile
|
|
30383
|
+
* prunes nothing whose count moved while its GET was in flight: the
|
|
30384
|
+
* response predates that (re)join.
|
|
30385
|
+
*/
|
|
30386
|
+
_roomJoinGen = /* @__PURE__ */ new Map();
|
|
30387
|
+
/** #1889: the room reconcile in flight, so overlapping asks share one GET. */
|
|
30388
|
+
_roomReconcileInFlight = null;
|
|
30259
30389
|
_a2aReconcileTimer = null;
|
|
30260
30390
|
_deliveryPulling = false;
|
|
30261
30391
|
_drDeliveryPulling = false;
|
|
@@ -32518,7 +32648,7 @@ ${text}`,
|
|
|
32518
32648
|
* #952 — sends held because MLS is expected for this conversation but the
|
|
32519
32649
|
* group is not joined yet.
|
|
32520
32650
|
*
|
|
32521
|
-
*
|
|
32651
|
+
* ⚠ IN MEMORY ONLY. These entries hold PLAINTEXT. `_persisted` is written to
|
|
32522
32652
|
* disk, and the product's entire premise is that plaintext does not rest
|
|
32523
32653
|
* where it does not have to; a crash losing a held greeting is the correct
|
|
32524
32654
|
* trade. This is why the existing `outboundQueue` could not be reused — that
|
|
@@ -33427,7 +33557,7 @@ ${text}`,
|
|
|
33427
33557
|
*/
|
|
33428
33558
|
sendActivitySpan(spanData) {
|
|
33429
33559
|
if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
|
|
33430
|
-
const pluginVersion = true ? "0.23.
|
|
33560
|
+
const pluginVersion = true ? "0.23.74" : "0.0.0-dev";
|
|
33431
33561
|
const agentName = this.config.agentName ?? "Agent";
|
|
33432
33562
|
const resource = {
|
|
33433
33563
|
"service.name": "agentvault-agent",
|
|
@@ -33738,10 +33868,19 @@ ${text}`,
|
|
|
33738
33868
|
* Encryption is handled by MLS group operations, not per-member DR sessions.
|
|
33739
33869
|
*/
|
|
33740
33870
|
async joinRoom(roomData) {
|
|
33871
|
+
if (!this._persisted) {
|
|
33872
|
+
throw new Error("Channel not initialized");
|
|
33873
|
+
}
|
|
33874
|
+
this._roomJoinGen.set(roomData.roomId, (this._roomJoinGen.get(roomData.roomId) ?? 0) + 1);
|
|
33875
|
+
return this._withRoomLock(roomData.roomId, () => this._joinRoomLocked(roomData));
|
|
33876
|
+
}
|
|
33877
|
+
async _joinRoomLocked(roomData) {
|
|
33741
33878
|
if (!this._persisted) {
|
|
33742
33879
|
throw new Error("Channel not initialized");
|
|
33743
33880
|
}
|
|
33744
33881
|
this._roomRosterRefreshed.delete(roomData.roomId);
|
|
33882
|
+
const priorGroup = this._persisted?.rooms?.[roomData.roomId]?.mlsGroupId;
|
|
33883
|
+
if (priorGroup) this._keyProofPausedUntil.delete(priorGroup);
|
|
33745
33884
|
this._applyRoomAudience(roomData.roomId, roomData.audience);
|
|
33746
33885
|
await libsodium_wrappers_default.ready;
|
|
33747
33886
|
const myDeviceId = this._deviceId;
|
|
@@ -33797,7 +33936,11 @@ ${text}`,
|
|
|
33797
33936
|
},
|
|
33798
33937
|
body: JSON.stringify({
|
|
33799
33938
|
member_device_ids: roomData.members.map((m2) => m2.deviceId)
|
|
33800
|
-
})
|
|
33939
|
+
}),
|
|
33940
|
+
// #1889 review: bounded, because this runs under the room lock. A
|
|
33941
|
+
// timeout lands in the catch below: no group id is stored, so the
|
|
33942
|
+
// next room_joined (or the owner's Welcome) still completes the room.
|
|
33943
|
+
signal: AbortSignal.timeout(_SecureChannel.ROOM_INIT_FETCH_TIMEOUT_MS)
|
|
33801
33944
|
});
|
|
33802
33945
|
if (initRes.ok) {
|
|
33803
33946
|
const groupData = await initRes.json();
|
|
@@ -33941,10 +34084,41 @@ ${text}`,
|
|
|
33941
34084
|
* Fail-safe: a failed fetch / non-ok / non-array response prunes NOTHING, so a
|
|
33942
34085
|
* transient error can never over-prune a live room.
|
|
33943
34086
|
*/
|
|
33944
|
-
|
|
34087
|
+
/** Run `fn` holding room `roomId`'s lock (FIFO). */
|
|
34088
|
+
async _withRoomLock(roomId, fn) {
|
|
34089
|
+
const prev = this._roomLocks.get(roomId) ?? Promise.resolve();
|
|
34090
|
+
let release;
|
|
34091
|
+
const mine = new Promise((resolve7) => {
|
|
34092
|
+
release = resolve7;
|
|
34093
|
+
});
|
|
34094
|
+
const tail = prev.then(() => mine);
|
|
34095
|
+
this._roomLocks.set(roomId, tail);
|
|
34096
|
+
await prev;
|
|
34097
|
+
try {
|
|
34098
|
+
return await fn();
|
|
34099
|
+
} finally {
|
|
34100
|
+
release();
|
|
34101
|
+
if (this._roomLocks.get(roomId) === tail) this._roomLocks.delete(roomId);
|
|
34102
|
+
}
|
|
34103
|
+
}
|
|
34104
|
+
_reconcileRoomsWithServer() {
|
|
34105
|
+
if (this._roomReconcileInFlight) return this._roomReconcileInFlight;
|
|
34106
|
+
const run = this._reconcileRoomsOnce().finally(() => {
|
|
34107
|
+
this._roomReconcileInFlight = null;
|
|
34108
|
+
});
|
|
34109
|
+
this._roomReconcileInFlight = run;
|
|
34110
|
+
return run;
|
|
34111
|
+
}
|
|
34112
|
+
async _reconcileRoomsOnce() {
|
|
33945
34113
|
const local = this._persisted?.rooms;
|
|
33946
34114
|
if (!local || Object.keys(local).length === 0) return;
|
|
33947
34115
|
if (!this._deviceJwt) return;
|
|
34116
|
+
const before = new Map(
|
|
34117
|
+
Object.keys(local).map((rid) => [
|
|
34118
|
+
rid,
|
|
34119
|
+
{ mgr: this._mlsGroups.get(rid), gen: this._roomJoinGen.get(rid) ?? 0 }
|
|
34120
|
+
])
|
|
34121
|
+
);
|
|
33948
34122
|
let activeIds;
|
|
33949
34123
|
try {
|
|
33950
34124
|
const res = await fetch(`${this.config.apiUrl}/api/v1/rooms`, {
|
|
@@ -33953,38 +34127,59 @@ ${text}`,
|
|
|
33953
34127
|
if (!res.ok) return;
|
|
33954
34128
|
const list = await res.json();
|
|
33955
34129
|
if (!Array.isArray(list)) return;
|
|
33956
|
-
|
|
33957
|
-
|
|
33958
|
-
|
|
34130
|
+
if (!list.every((r2) => !!r2 && typeof r2 === "object" && typeof r2.id === "string" && r2.id)) {
|
|
34131
|
+
console.warn("[SecureChannel] room reconcile skipped: malformed item in GET /rooms (pruning nothing)");
|
|
34132
|
+
return;
|
|
34133
|
+
}
|
|
34134
|
+
activeIds = new Set(list.map((r2) => r2.id));
|
|
33959
34135
|
} catch (err) {
|
|
33960
34136
|
console.warn(
|
|
33961
34137
|
`[SecureChannel] room reconcile skipped (fetch failed, pruning nothing): ${err instanceof Error ? err.message : String(err)}`
|
|
33962
34138
|
);
|
|
33963
34139
|
return;
|
|
33964
34140
|
}
|
|
33965
|
-
const
|
|
34141
|
+
for (const rid of activeIds) {
|
|
34142
|
+
const gid = local[rid]?.mlsGroupId;
|
|
34143
|
+
if (gid) this._keyProofPausedUntil.delete(gid);
|
|
34144
|
+
}
|
|
34145
|
+
const stale = Object.keys(local).filter((rid) => {
|
|
34146
|
+
if (activeIds.has(rid)) return false;
|
|
34147
|
+
const snap = before.get(rid);
|
|
34148
|
+
if (!snap) return false;
|
|
34149
|
+
return this._mlsGroups.get(rid) === snap.mgr && (this._roomJoinGen.get(rid) ?? 0) === snap.gen;
|
|
34150
|
+
});
|
|
33966
34151
|
if (stale.length === 0) return;
|
|
34152
|
+
const pruned = [];
|
|
33967
34153
|
for (const rid of stale) {
|
|
33968
|
-
|
|
33969
|
-
|
|
33970
|
-
|
|
33971
|
-
|
|
33972
|
-
|
|
34154
|
+
await this._withRoomLock(rid, async () => {
|
|
34155
|
+
const snap = before.get(rid);
|
|
34156
|
+
const room = local[rid];
|
|
34157
|
+
if (!snap || !room) return;
|
|
34158
|
+
if (this._mlsGroups.get(rid) !== snap.mgr || (this._roomJoinGen.get(rid) ?? 0) !== snap.gen) return;
|
|
34159
|
+
this._mlsGroups.delete(rid);
|
|
34160
|
+
for (const convId of room.conversationIds ?? []) {
|
|
34161
|
+
this._sessions.delete(convId);
|
|
34162
|
+
if (this._persisted?.sessions) delete this._persisted.sessions[convId];
|
|
33973
34163
|
}
|
|
33974
|
-
|
|
33975
|
-
|
|
33976
|
-
|
|
33977
|
-
|
|
33978
|
-
|
|
33979
|
-
|
|
33980
|
-
|
|
33981
|
-
|
|
34164
|
+
delete local[rid];
|
|
34165
|
+
pruned.push(rid);
|
|
34166
|
+
if (room.mlsGroupId) {
|
|
34167
|
+
this._keyProofPausedUntil.delete(room.mlsGroupId);
|
|
34168
|
+
this._mlsGroupJoinedAt.delete(room.mlsGroupId);
|
|
34169
|
+
try {
|
|
34170
|
+
await deleteMlsState(this.config.dataDir, room.mlsGroupId);
|
|
34171
|
+
} catch {
|
|
34172
|
+
}
|
|
34173
|
+
}
|
|
34174
|
+
this._retireRoomFolder(rid);
|
|
34175
|
+
});
|
|
33982
34176
|
}
|
|
34177
|
+
if (pruned.length === 0) return;
|
|
33983
34178
|
await this._persistState();
|
|
33984
34179
|
console.log(
|
|
33985
|
-
`[SecureChannel] Room reconcile: pruned ${
|
|
34180
|
+
`[SecureChannel] Room reconcile: pruned ${pruned.length} disbanded/left room(s) from local state (${pruned.map((r2) => r2.slice(0, 8)).join(", ")})`
|
|
33986
34181
|
);
|
|
33987
|
-
this.emit("rooms_reconciled", { pruned
|
|
34182
|
+
this.emit("rooms_reconciled", { pruned });
|
|
33988
34183
|
}
|
|
33989
34184
|
/**
|
|
33990
34185
|
* #629 — quarantine MLS state for groups this device is no longer in.
|
|
@@ -34449,17 +34644,8 @@ ${text}`,
|
|
|
34449
34644
|
}
|
|
34450
34645
|
async sendStatusAlert(alert, routing) {
|
|
34451
34646
|
const priority = alert.severity === "error" || alert.severity === "critical" ? "high" : "normal";
|
|
34452
|
-
const envelope = {
|
|
34453
|
-
title: alert.title,
|
|
34454
|
-
message: alert.message,
|
|
34455
|
-
severity: alert.severity,
|
|
34456
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
34457
|
-
};
|
|
34458
|
-
if (alert.detail !== void 0) envelope.detail = alert.detail;
|
|
34459
|
-
if (alert.detailFormat !== void 0) envelope.detail_format = alert.detailFormat;
|
|
34460
|
-
if (alert.category !== void 0) envelope.category = alert.category;
|
|
34461
34647
|
await this.send(
|
|
34462
|
-
JSON.stringify(
|
|
34648
|
+
JSON.stringify(statusAlertEnvelope(alert, (/* @__PURE__ */ new Date()).toISOString())),
|
|
34463
34649
|
{
|
|
34464
34650
|
conversationId: routing?.conversationId,
|
|
34465
34651
|
audience: routing?.audience,
|
|
@@ -34676,16 +34862,7 @@ ${text}`,
|
|
|
34676
34862
|
decisionId = await this.sendDecisionRequest(content.request, ownerRouting);
|
|
34677
34863
|
} else if (content.type === "status_alert") {
|
|
34678
34864
|
if (resolved.kind === "room") {
|
|
34679
|
-
|
|
34680
|
-
title: content.alert.title,
|
|
34681
|
-
message: content.alert.message,
|
|
34682
|
-
severity: content.alert.severity,
|
|
34683
|
-
timestamp: ts
|
|
34684
|
-
};
|
|
34685
|
-
if (content.alert.detail !== void 0) envelope.detail = content.alert.detail;
|
|
34686
|
-
if (content.alert.detailFormat !== void 0) envelope.detail_format = content.alert.detailFormat;
|
|
34687
|
-
if (content.alert.category !== void 0) envelope.category = content.alert.category;
|
|
34688
|
-
await this.sendToRoom(resolved.id, JSON.stringify(envelope), {
|
|
34865
|
+
await this.sendToRoom(resolved.id, JSON.stringify(statusAlertEnvelope(content.alert, ts)), {
|
|
34689
34866
|
messageType: "status_alert",
|
|
34690
34867
|
priority: content.alert.severity === "error" || content.alert.severity === "critical" ? "high" : "normal",
|
|
34691
34868
|
metadata: { severity: content.alert.severity }
|
|
@@ -38314,6 +38491,8 @@ ${baseText}`;
|
|
|
38314
38491
|
// #1800 PR B: the bound sender only (undefined when unbound).
|
|
38315
38492
|
senderDeviceId: boundSender,
|
|
38316
38493
|
senderBinding: binding.verdict,
|
|
38494
|
+
// #1855: why it is unbound, as on the onMessage metadata above.
|
|
38495
|
+
...boundSender === void 0 ? { senderBindingReason: unverifiedReason(binding) } : {},
|
|
38317
38496
|
...claimedSender ? { claimedSenderDeviceId: claimedSender } : {},
|
|
38318
38497
|
senderName: senderLabel,
|
|
38319
38498
|
plaintext: messageText,
|
|
@@ -39774,13 +39953,17 @@ ${baseText}`;
|
|
|
39774
39953
|
const jwt = this._deviceJwt;
|
|
39775
39954
|
if (!deviceId || !jwt) return;
|
|
39776
39955
|
const best = /* @__PURE__ */ new Map();
|
|
39777
|
-
|
|
39956
|
+
const roomGroups = /* @__PURE__ */ new Set();
|
|
39957
|
+
const now = Date.now();
|
|
39958
|
+
for (const [key, mgr] of this._mlsGroups.entries()) {
|
|
39778
39959
|
try {
|
|
39779
39960
|
if (!mgr.isInitialized) continue;
|
|
39780
39961
|
const epoch = Number(mgr.epoch);
|
|
39781
39962
|
if (epoch <= 0) continue;
|
|
39782
39963
|
const groupId = _SecureChannel._mlsGroupIdString(mgr.groupId);
|
|
39783
39964
|
if (!groupId) continue;
|
|
39965
|
+
if (now < (this._keyProofPausedUntil.get(groupId) ?? 0)) continue;
|
|
39966
|
+
if (this._persisted?.rooms?.[key]) roomGroups.add(groupId);
|
|
39784
39967
|
const prev = best.get(groupId);
|
|
39785
39968
|
if (prev && epoch <= prev.epoch) continue;
|
|
39786
39969
|
best.set(groupId, { epoch, authenticator: Buffer.from(mgr.epochAuthenticator).toString("hex") });
|
|
@@ -39788,6 +39971,7 @@ ${baseText}`;
|
|
|
39788
39971
|
continue;
|
|
39789
39972
|
}
|
|
39790
39973
|
}
|
|
39974
|
+
let askRooms = false;
|
|
39791
39975
|
for (const [groupId, { epoch, authenticator }] of best) {
|
|
39792
39976
|
try {
|
|
39793
39977
|
const res = await fetch(`${this.config.apiUrl}/api/v1/mls/groups/${groupId}/key-proof`, {
|
|
@@ -39796,11 +39980,34 @@ ${baseText}`;
|
|
|
39796
39980
|
body: JSON.stringify({ device_id: deviceId, epoch, authenticator }),
|
|
39797
39981
|
signal: AbortSignal.timeout(_SecureChannel._KEY_PROOF_FETCH_TIMEOUT_MS)
|
|
39798
39982
|
});
|
|
39799
|
-
if (
|
|
39983
|
+
if (res.ok) continue;
|
|
39984
|
+
const detail = res.status === 403 ? await this._errorDetail(res) : null;
|
|
39985
|
+
if (res.status === 404 || detail === _SecureChannel.KEY_PROOF_NOT_A_MEMBER_DETAIL) {
|
|
39986
|
+
if (roomGroups.has(groupId)) askRooms = true;
|
|
39987
|
+
const graceFrom = Math.max(this._mlsGroupJoinedAt.get(groupId) ?? 0, this._processStartedAt);
|
|
39988
|
+
if (res.status === 403 && Date.now() - graceFrom < _SecureChannel._KEY_PROOF_JOIN_GRACE_MS) {
|
|
39989
|
+
console.debug(`[key-proof] ${groupId.slice(0, 8)}: HTTP 403 within the join grace (roster lag)`);
|
|
39990
|
+
continue;
|
|
39991
|
+
}
|
|
39992
|
+
const pauseMs = res.status === 404 ? _SecureChannel._KEY_PROOF_PAUSE_MS : _SecureChannel._KEY_PROOF_403_PAUSE_MS;
|
|
39993
|
+
this._keyProofPausedUntil.set(groupId, Date.now() + pauseMs);
|
|
39994
|
+
console.log(
|
|
39995
|
+
`[key-proof] ${groupId.slice(0, 8)}: HTTP ${res.status} (${res.status === 404 ? "group gone" : "not a member"}) \u2014 pausing its proofs for ${pauseMs / 36e5}h (#1889)`
|
|
39996
|
+
);
|
|
39997
|
+
continue;
|
|
39998
|
+
}
|
|
39999
|
+
console.debug(`[key-proof] ${groupId.slice(0, 8)}: HTTP ${res.status}`);
|
|
39800
40000
|
} catch (err) {
|
|
39801
40001
|
console.debug(`[key-proof] ${groupId.slice(0, 8)}: report failed (non-critical):`, err);
|
|
39802
40002
|
}
|
|
39803
40003
|
}
|
|
40004
|
+
if (askRooms) {
|
|
40005
|
+
try {
|
|
40006
|
+
await this._reconcileRoomsWithServer();
|
|
40007
|
+
} catch (err) {
|
|
40008
|
+
console.warn(`[key-proof] room reconcile after a refusal failed (ignored): ${err instanceof Error ? err.message : String(err)}`);
|
|
40009
|
+
}
|
|
40010
|
+
}
|
|
39804
40011
|
}
|
|
39805
40012
|
/**
|
|
39806
40013
|
* The wire MLS group id as a UUID string, or null. Every founder today —
|
|
@@ -39844,7 +40051,7 @@ ${baseText}`;
|
|
|
39844
40051
|
/**
|
|
39845
40052
|
* Top the pool up against the SERVER's count (#826).
|
|
39846
40053
|
*
|
|
39847
|
-
*
|
|
40054
|
+
* ⚠ DO NOT replace this with a periodic call to `_ensureKpPoolPublished()`.
|
|
39848
40055
|
* That function early-returns on `_pendingKpBundles.length >= _KP_POOL_TARGET`,
|
|
39849
40056
|
* and that array holds PRIVATE bundles which never expire locally — so on an
|
|
39850
40057
|
* agent that has been connected longer than the KeyPackage lifetime it is
|
|
@@ -40093,18 +40300,16 @@ ${baseText}`;
|
|
|
40093
40300
|
* limiter (per-conversation and global caps). The plaintext carries
|
|
40094
40301
|
* `type: "status_alert"`, so no agent in the room treats it as a turn
|
|
40095
40302
|
* (`status_alert` is not in ROOM_AGENT_TYPES). Fire-and-forget; never throws.
|
|
40303
|
+
* #1867: built by `statusAlertEnvelope`, like every other plugin alert, so
|
|
40304
|
+
* it carries the `text` line a room tab older than #1860 shows.
|
|
40096
40305
|
*/
|
|
40097
40306
|
_sendRoomSecurityNotice(noticeKey, roomId, title, text) {
|
|
40098
40307
|
try {
|
|
40099
40308
|
if (!this._securityNoticeLimiter.allow(noticeKey)) return;
|
|
40100
|
-
const envelope = JSON.stringify(
|
|
40101
|
-
|
|
40102
|
-
|
|
40103
|
-
|
|
40104
|
-
severity: "warning",
|
|
40105
|
-
category: "security",
|
|
40106
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
40107
|
-
});
|
|
40309
|
+
const envelope = JSON.stringify(statusAlertEnvelope(
|
|
40310
|
+
{ title, message: text(), severity: "warning", category: "security" },
|
|
40311
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
40312
|
+
));
|
|
40108
40313
|
Promise.resolve().then(() => this.sendToRoom(roomId, envelope, { messageType: "status_alert" })).catch((err) => {
|
|
40109
40314
|
console.warn(`[SecureChannel] #1800 security notice for room ${logId(roomId)} was not sent:`, err);
|
|
40110
40315
|
});
|
|
@@ -40137,7 +40342,7 @@ ${baseText}`;
|
|
|
40137
40342
|
agentVersion: this.config.agentVersion ?? "0.0.0",
|
|
40138
40343
|
// __AV_VERSION__ is injected by esbuild from package.json at build time.
|
|
40139
40344
|
// Falls back to "0.0.0-dev" in non-bundled contexts (tests).
|
|
40140
|
-
pluginVersion: true ? "0.23.
|
|
40345
|
+
pluginVersion: true ? "0.23.74" : "0.0.0-dev"
|
|
40141
40346
|
});
|
|
40142
40347
|
this._telemetryReporter.startAutoFlush(3e4);
|
|
40143
40348
|
}
|
|
@@ -40336,6 +40541,10 @@ ${baseText}`;
|
|
|
40336
40541
|
return;
|
|
40337
40542
|
}
|
|
40338
40543
|
const mgr = joined.mgr;
|
|
40544
|
+
if (groupId) {
|
|
40545
|
+
this._keyProofPausedUntil.delete(groupId);
|
|
40546
|
+
this._mlsGroupJoinedAt.set(groupId, Date.now());
|
|
40547
|
+
}
|
|
40339
40548
|
this._removeKpFromPool(joined.kp);
|
|
40340
40549
|
void this._ensureKpPoolPublished().catch((err) => {
|
|
40341
40550
|
console.warn("[SecureChannel] KeyPackage pool replenish after join failed:", err);
|
|
@@ -40399,34 +40608,8 @@ ${baseText}`;
|
|
|
40399
40608
|
return;
|
|
40400
40609
|
}
|
|
40401
40610
|
const welcomeRoomId = data.room_id;
|
|
40402
|
-
|
|
40403
|
-
|
|
40404
|
-
room.mlsGroupId = groupId;
|
|
40405
|
-
this._mlsGroups.set(roomId, mgr);
|
|
40406
|
-
this._invalidateRoomAudienceForGroup(groupId);
|
|
40407
|
-
await saveMlsState(this.config.dataDir, groupId, JSON.stringify(mgr.exportState()));
|
|
40408
|
-
await this._persistState();
|
|
40409
|
-
await this._applyBufferedMlsCommits(groupId, mgr);
|
|
40410
|
-
console.log(`[SecureChannel] Joined MLS group for room ${roomId.slice(0, 8)} via Welcome (epoch=${mgr.epoch})`);
|
|
40411
|
-
this._pendingMlsKpBundle = void 0;
|
|
40412
|
-
await releaseA2ASyncLock(this.config.dataDir, `room-kp-${groupId}`).catch(() => {
|
|
40413
|
-
});
|
|
40414
|
-
return;
|
|
40415
|
-
}
|
|
40416
|
-
}
|
|
40417
|
-
if (welcomeRoomId && this._persisted) {
|
|
40418
|
-
await this._registerRoomFromWelcome(
|
|
40419
|
-
welcomeRoomId,
|
|
40420
|
-
groupId,
|
|
40421
|
-
mgr,
|
|
40422
|
-
data.room_name
|
|
40423
|
-
);
|
|
40424
|
-
this._pendingMlsKpBundle = void 0;
|
|
40425
|
-
await releaseA2ASyncLock(this.config.dataDir, `room-kp-${groupId}`).catch(() => {
|
|
40426
|
-
});
|
|
40427
|
-
console.log(
|
|
40428
|
-
`[SecureChannel] Registered room ${welcomeRoomId.slice(0, 8)} from unmatched Welcome (epoch=${mgr.epoch})`
|
|
40429
|
-
);
|
|
40611
|
+
const lockRoom = typeof welcomeRoomId === "string" && welcomeRoomId ? welcomeRoomId : Object.entries(this._persisted?.rooms ?? {}).find(([, r2]) => r2.mlsGroupId === groupId)?.[0];
|
|
40612
|
+
if (lockRoom && await this._withRoomLock(lockRoom, () => this._installRoomWelcome(groupId, mgr, data))) {
|
|
40430
40613
|
return;
|
|
40431
40614
|
}
|
|
40432
40615
|
const a2aChannelId = data.a2a_channel_id;
|
|
@@ -40485,6 +40668,45 @@ ${baseText}`;
|
|
|
40485
40668
|
throw err;
|
|
40486
40669
|
}
|
|
40487
40670
|
}
|
|
40671
|
+
/**
|
|
40672
|
+
* The room half of `_handleMlsWelcome`: install `mgr` for the room this
|
|
40673
|
+
* Welcome names (by group or by room id), or register the room from the
|
|
40674
|
+
* Welcome. True when handled. Caller holds the room's lock (#1889 review).
|
|
40675
|
+
*/
|
|
40676
|
+
async _installRoomWelcome(groupId, mgr, data) {
|
|
40677
|
+
const welcomeRoomId = data.room_id;
|
|
40678
|
+
for (const [roomId, room] of Object.entries(this._persisted?.rooms ?? {})) {
|
|
40679
|
+
if (room.mlsGroupId === groupId || roomId === welcomeRoomId) {
|
|
40680
|
+
room.mlsGroupId = groupId;
|
|
40681
|
+
this._mlsGroups.set(roomId, mgr);
|
|
40682
|
+
this._invalidateRoomAudienceForGroup(groupId);
|
|
40683
|
+
await saveMlsState(this.config.dataDir, groupId, JSON.stringify(mgr.exportState()));
|
|
40684
|
+
await this._persistState();
|
|
40685
|
+
await this._applyBufferedMlsCommits(groupId, mgr);
|
|
40686
|
+
console.log(`[SecureChannel] Joined MLS group for room ${roomId.slice(0, 8)} via Welcome (epoch=${mgr.epoch})`);
|
|
40687
|
+
this._pendingMlsKpBundle = void 0;
|
|
40688
|
+
await releaseA2ASyncLock(this.config.dataDir, `room-kp-${groupId}`).catch(() => {
|
|
40689
|
+
});
|
|
40690
|
+
return true;
|
|
40691
|
+
}
|
|
40692
|
+
}
|
|
40693
|
+
if (welcomeRoomId && this._persisted) {
|
|
40694
|
+
await this._registerRoomFromWelcome(
|
|
40695
|
+
welcomeRoomId,
|
|
40696
|
+
groupId,
|
|
40697
|
+
mgr,
|
|
40698
|
+
data.room_name
|
|
40699
|
+
);
|
|
40700
|
+
this._pendingMlsKpBundle = void 0;
|
|
40701
|
+
await releaseA2ASyncLock(this.config.dataDir, `room-kp-${groupId}`).catch(() => {
|
|
40702
|
+
});
|
|
40703
|
+
console.log(
|
|
40704
|
+
`[SecureChannel] Registered room ${welcomeRoomId.slice(0, 8)} from unmatched Welcome (epoch=${mgr.epoch})`
|
|
40705
|
+
);
|
|
40706
|
+
return true;
|
|
40707
|
+
}
|
|
40708
|
+
return false;
|
|
40709
|
+
}
|
|
40488
40710
|
/**
|
|
40489
40711
|
* Self-bootstrap a room entry + MLS group mapping from a Welcome whose room is
|
|
40490
40712
|
* not yet persisted. Happens when we were added to an EXISTING room and the
|
|
@@ -43070,6 +43292,15 @@ function getActiveChannel(accountId = "default") {
|
|
|
43070
43292
|
async function _handleInbound(params) {
|
|
43071
43293
|
const { plaintext, metadata, channel, account, cfg, fileTurn } = params;
|
|
43072
43294
|
const core = _ocRuntime;
|
|
43295
|
+
if (metadata.roomId && metadata.senderBinding !== "bound") {
|
|
43296
|
+
const ownDisplayName = channel.ownDisplayName ?? "";
|
|
43297
|
+
const agentName = account.agentName ?? "";
|
|
43298
|
+
const selfResolved = !!ownDisplayName || !!agentName && agentName.toLowerCase() !== "default";
|
|
43299
|
+
if (!owesRoomReply(metadata.caption ?? plaintext, agentName, account.accountId ?? "", true, void 0, ownDisplayName, selfResolved, metadata.roomAudience, metadata.senderBinding)) {
|
|
43300
|
+
console.log(`[AgentVault] room message from an unverified sender not addressed to this agent \u2014 not dispatched (#1855) room=${String(metadata.roomId).slice(0, 8)}`);
|
|
43301
|
+
return;
|
|
43302
|
+
}
|
|
43303
|
+
}
|
|
43073
43304
|
const sessionKey = `agentvault:${account.accountId}:${(metadata.conversationId ?? "default").slice(0, 8)}`;
|
|
43074
43305
|
const identity = metadata.roomId ? { id: `agentvault:room:${metadata.roomId}`, name: "Room Member", owner: false } : metadata.a2aChannelId ? { id: `a2a:${metadata.a2aChannelId}`, name: "Agent", owner: false } : dmSenderIdentity(metadata);
|
|
43075
43306
|
const senderId = identity.id;
|
|
@@ -43191,6 +43422,7 @@ var init_openclaw_plugin = __esm({
|
|
|
43191
43422
|
init_file_send_failure();
|
|
43192
43423
|
init_openclaw_file_send();
|
|
43193
43424
|
init_openclaw_sender();
|
|
43425
|
+
init_room_protocol();
|
|
43194
43426
|
_ocRuntime = null;
|
|
43195
43427
|
_channels = /* @__PURE__ */ new Map();
|
|
43196
43428
|
_legacyTurnRuns = new OpenClawTurnRuns();
|
|
@@ -70505,6 +70737,41 @@ var init_policy_enforcer = __esm({
|
|
|
70505
70737
|
}
|
|
70506
70738
|
});
|
|
70507
70739
|
|
|
70740
|
+
// src/shell-word.ts
|
|
70741
|
+
function utf8Escapes(ch) {
|
|
70742
|
+
const cp = ch.codePointAt(0);
|
|
70743
|
+
const bytes = cp < 128 ? [cp] : cp < 2048 ? [192 | cp >> 6, 128 | cp & 63] : cp < 65536 ? [224 | cp >> 12, 128 | cp >> 6 & 63, 128 | cp & 63] : [240 | cp >> 18, 128 | cp >> 12 & 63, 128 | cp >> 6 & 63, 128 | cp & 63];
|
|
70744
|
+
return bytes.map((b2) => `\\x${b2.toString(16).padStart(2, "0")}`).join("");
|
|
70745
|
+
}
|
|
70746
|
+
function shellWord(value) {
|
|
70747
|
+
if (BARE.test(value)) return value;
|
|
70748
|
+
if (value === "") return "''";
|
|
70749
|
+
if (NEEDS_ESCAPE.test(value)) {
|
|
70750
|
+
let body = "";
|
|
70751
|
+
let afterEscape = false;
|
|
70752
|
+
for (const ch of value) {
|
|
70753
|
+
const literal2 = LITERAL_IN_ANSI_C.test(ch) && !(afterEscape && HEX.test(ch));
|
|
70754
|
+
body += literal2 ? ch : utf8Escapes(ch);
|
|
70755
|
+
afterEscape = !literal2;
|
|
70756
|
+
}
|
|
70757
|
+
return `$'${body}'`;
|
|
70758
|
+
}
|
|
70759
|
+
return value.split(/(['\\])/).filter((part) => part !== "").map((part) => part === "'" || part === "\\" ? `\\${part}` : `'${part}'`).join("");
|
|
70760
|
+
}
|
|
70761
|
+
var BARE, NEEDS_ESCAPE, LITERAL_IN_ANSI_C, HEX;
|
|
70762
|
+
var init_shell_word = __esm({
|
|
70763
|
+
"src/shell-word.ts"() {
|
|
70764
|
+
"use strict";
|
|
70765
|
+
BARE = /^[A-Za-z0-9_./:@+-]+$/;
|
|
70766
|
+
NEEDS_ESCAPE = new RegExp(
|
|
70767
|
+
`[\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\p{Default_Ignorable_Code_Point}${String.fromCodePoint(65532)}${String.fromCodePoint(10240)}]`,
|
|
70768
|
+
"u"
|
|
70769
|
+
);
|
|
70770
|
+
LITERAL_IN_ANSI_C = /^[A-Za-z0-9]$/;
|
|
70771
|
+
HEX = /^[0-9A-Fa-f]$/;
|
|
70772
|
+
}
|
|
70773
|
+
});
|
|
70774
|
+
|
|
70508
70775
|
// src/index.ts
|
|
70509
70776
|
var VERSION;
|
|
70510
70777
|
var init_index = __esm({
|
|
@@ -70535,7 +70802,8 @@ var init_index = __esm({
|
|
|
70535
70802
|
init_room_protocol();
|
|
70536
70803
|
init_tool_telemetry();
|
|
70537
70804
|
init_turn_failure();
|
|
70538
|
-
|
|
70805
|
+
init_shell_word();
|
|
70806
|
+
VERSION = true ? "0.23.74" : "0.0.0-dev";
|
|
70539
70807
|
}
|
|
70540
70808
|
});
|
|
70541
70809
|
init_index();
|
|
@@ -70622,6 +70890,7 @@ export {
|
|
|
70622
70890
|
sendToRoom,
|
|
70623
70891
|
sendToTarget,
|
|
70624
70892
|
setOcRuntime,
|
|
70893
|
+
shellWord,
|
|
70625
70894
|
stagingLineFor,
|
|
70626
70895
|
stripCaptionMentions,
|
|
70627
70896
|
stripMentions,
|