@agentvault/agentvault 0.23.67 → 0.23.68

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.
@@ -0,0 +1,61 @@
1
+ /**
2
+ * When to pull the delivery queue, and which groups to read for pending Welcomes.
3
+ *
4
+ * An idle agent used to pull every 30 s and read pending-welcomes for every group
5
+ * on each pull, and the answer was almost always nothing. GET /mls/delivery now
6
+ * carries a `sync` block (backend services/delivery_sync.py) saying how long this
7
+ * device may rest. The rules here keep that safe:
8
+ *
9
+ * - The default is the old 30 s. A pull moves the next one 30 s out BEFORE it
10
+ * asks anything, so a failed or hung pull can only ever leave the fast timer.
11
+ * - Rest is earned: only a pull that returned no rows, from a server that said
12
+ * rest is safe. Rows, an error, an old server, or a server that withholds
13
+ * rest all stay on 30 s.
14
+ * - A group is skipped only on the server's word, and a slow full sweep reads
15
+ * every group anyway, in case the server's list is ever wrong.
16
+ */
17
+ /** The old heartbeat, and the fallback whenever rest has not been earned. */
18
+ export declare const DELIVERY_PULL_MS = 30000;
19
+ /** Local check only, no request: decides whether a pull is due. */
20
+ export declare const DELIVERY_TICK_MS = 5000;
21
+ /** Backstop for a group the server's list missed. */
22
+ export declare const FULL_WELCOME_SWEEP_MS = 600000;
23
+ /** How often an agent in no A2A channel re-asks. Pushes still arrive at once. */
24
+ export declare const A2A_QUIET_RECONCILE_MS = 600000;
25
+ export interface DeliverySync {
26
+ /** null: stay on the 30 s pull. */
27
+ quietPullMs: number | null;
28
+ welcomeGroupIds: Set<string>;
29
+ }
30
+ /** The `sync` block, or null when absent or malformed: both mean old behaviour. */
31
+ export declare function parseDeliverySync(raw: unknown): DeliverySync | null;
32
+ export declare class DeliveryCadence {
33
+ private _nextPullAt;
34
+ private _nextFullSweepAt;
35
+ private _fullSweepRequested;
36
+ /** A new connection may have missed anything: pull now, read every group. */
37
+ reset(): void;
38
+ pullDue(now: number): boolean;
39
+ pullStarted(now: number): void;
40
+ /** Call after a pull that returned no rows. */
41
+ pullWasQuiet(now: number, sync: DeliverySync | null): void;
42
+ /** A wake named a request, so read every group on the next pull, as before. */
43
+ requestFullSweep(): void;
44
+ /** The groups this pull should read. null means all of them. */
45
+ welcomeTargets(now: number, sync: DeliverySync | null): Set<string> | null;
46
+ }
47
+ export declare function wantsWelcomeRead(targets: Set<string> | null, groupId: string): boolean;
48
+ /**
49
+ * The A2A reconcile re-runs a member's join fallback, so it matters only to an
50
+ * agent with a channel. Prod holds none and the routes that create them are
51
+ * closed, so every agent was asking every 30 s for an empty list. An agent the
52
+ * server lists in a channel keeps the 30 s reconcile.
53
+ */
54
+ export declare class A2aReconcileCadence {
55
+ private _nextAt;
56
+ due(now: number): boolean;
57
+ listed(now: number, channelCount: number, random?: () => number): void;
58
+ /** A channel event arrived: reconcile at the next tick. */
59
+ wake(): void;
60
+ }
61
+ //# sourceMappingURL=delivery-cadence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-cadence.d.ts","sourceRoot":"","sources":["../src/delivery-cadence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,QAAS,CAAC;AACvC,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,OAAQ,CAAC;AACtC,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,SAAU,CAAC;AAI7C,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,SAAU,CAAC;AAG9C,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAWnE;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,mBAAmB,CAAS;IAEpC,6EAA6E;IAC7E,KAAK,IAAI,IAAI;IAKb,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAM7B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI9B,+CAA+C;IAC/C,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI;IAI1D,+EAA+E;IAC/E,gBAAgB,IAAI,IAAI;IAIxB,gEAAgE;IAChE,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI;CAS3E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtF;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CAAK;IAEpB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,MAAoB,GAAG,IAAI;IAMnF,2DAA2D;IAC3D,IAAI,IAAI,IAAI;CAGb"}
package/dist/index.js CHANGED
@@ -64567,11 +64567,11 @@ var init_mls_kp_pool = __esm({
64567
64567
 
64568
64568
  // src/client-version.ts
64569
64569
  function ownIdentity() {
64570
- const v2 = true ? "0.23.67" : FALLBACK;
64570
+ const v2 = true ? "0.23.68" : FALLBACK;
64571
64571
  return `${PACKAGE}@${v2}`;
64572
64572
  }
64573
64573
  function buildSha() {
64574
- const raw = true ? "a3de03b" : "";
64574
+ const raw = true ? "c758a00" : "";
64575
64575
  const cleaned = (raw ?? "").trim();
64576
64576
  return !cleaned || cleaned === "unknown" ? null : cleaned;
64577
64577
  }
@@ -65598,6 +65598,80 @@ var init_welcome_kp_backoff = __esm({
65598
65598
  }
65599
65599
  });
65600
65600
 
65601
+ // src/delivery-cadence.ts
65602
+ function parseDeliverySync(raw) {
65603
+ if (typeof raw !== "object" || raw === null) return null;
65604
+ const { quiet_pull_seconds: quiet, welcome_group_ids: groups } = raw;
65605
+ if (!Array.isArray(groups) || !groups.every((g2) => typeof g2 === "string")) return null;
65606
+ if (quiet !== null && (typeof quiet !== "number" || !Number.isFinite(quiet))) return null;
65607
+ return {
65608
+ quietPullMs: quiet === null ? null : Math.min(Math.max(quiet * 1e3, DELIVERY_PULL_MS), MAX_QUIET_PULL_MS),
65609
+ welcomeGroupIds: new Set(groups.map((g2) => g2.toLowerCase()))
65610
+ };
65611
+ }
65612
+ function wantsWelcomeRead(targets, groupId) {
65613
+ return targets === null || targets.has(groupId.toLowerCase());
65614
+ }
65615
+ var DELIVERY_PULL_MS, DELIVERY_TICK_MS, FULL_WELCOME_SWEEP_MS, MAX_QUIET_PULL_MS, A2A_QUIET_RECONCILE_MS, A2A_QUIET_JITTER_MS, DeliveryCadence, A2aReconcileCadence;
65616
+ var init_delivery_cadence = __esm({
65617
+ "src/delivery-cadence.ts"() {
65618
+ "use strict";
65619
+ DELIVERY_PULL_MS = 3e4;
65620
+ DELIVERY_TICK_MS = 5e3;
65621
+ FULL_WELCOME_SWEEP_MS = 6e5;
65622
+ MAX_QUIET_PULL_MS = 3e5;
65623
+ A2A_QUIET_RECONCILE_MS = 6e5;
65624
+ A2A_QUIET_JITTER_MS = 6e4;
65625
+ DeliveryCadence = class {
65626
+ _nextPullAt = 0;
65627
+ _nextFullSweepAt = 0;
65628
+ _fullSweepRequested = false;
65629
+ /** A new connection may have missed anything: pull now, read every group. */
65630
+ reset() {
65631
+ this._nextPullAt = 0;
65632
+ this._nextFullSweepAt = 0;
65633
+ }
65634
+ pullDue(now) {
65635
+ return now >= this._nextPullAt || this._nextPullAt - now > MAX_QUIET_PULL_MS;
65636
+ }
65637
+ pullStarted(now) {
65638
+ this._nextPullAt = now + DELIVERY_PULL_MS;
65639
+ }
65640
+ /** Call after a pull that returned no rows. */
65641
+ pullWasQuiet(now, sync) {
65642
+ if (sync?.quietPullMs != null) this._nextPullAt = now + sync.quietPullMs;
65643
+ }
65644
+ /** A wake named a request, so read every group on the next pull, as before. */
65645
+ requestFullSweep() {
65646
+ this._fullSweepRequested = true;
65647
+ }
65648
+ /** The groups this pull should read. null means all of them. */
65649
+ welcomeTargets(now, sync) {
65650
+ if (sync === null) return null;
65651
+ if (this._fullSweepRequested || now >= this._nextFullSweepAt) {
65652
+ this._fullSweepRequested = false;
65653
+ this._nextFullSweepAt = now + FULL_WELCOME_SWEEP_MS;
65654
+ return null;
65655
+ }
65656
+ return sync.welcomeGroupIds;
65657
+ }
65658
+ };
65659
+ A2aReconcileCadence = class {
65660
+ _nextAt = 0;
65661
+ due(now) {
65662
+ return now >= this._nextAt;
65663
+ }
65664
+ listed(now, channelCount, random = Math.random) {
65665
+ this._nextAt = channelCount > 0 ? 0 : now + A2A_QUIET_RECONCILE_MS + Math.floor(random() * A2A_QUIET_JITTER_MS);
65666
+ }
65667
+ /** A channel event arrived: reconcile at the next tick. */
65668
+ wake() {
65669
+ this._nextAt = 0;
65670
+ }
65671
+ };
65672
+ }
65673
+ });
65674
+
65601
65675
  // src/history-backup-client.ts
65602
65676
  var history_backup_client_exports = {};
65603
65677
  __export(history_backup_client_exports, {
@@ -66826,7 +66900,7 @@ function historyErrorReason(error2) {
66826
66900
  }
66827
66901
  return typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599 ? `${name} (status ${status})` : name;
66828
66902
  }
66829
- var ROOM_AGENT_TYPES, CREDENTIAL_MESSAGE_TYPES, CATCHUP_MESSAGE_TYPES, POLL_INTERVAL_MS, RECONNECT_BASE_MS, UUID_RE4, RECONNECT_MAX_MS, PENDING_POLL_INTERVAL_MS, HISTORY_RESTORE_TIMEOUT_MS2, ROOM_ROSTER_REFRESH_TIMEOUT_MS, 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, PERSON_INVOLVED_WINDOW_MS, ATTESTED_INBOUND_MAX, UNMAPPED_RECONCILE_COOLDOWN_MS, TOPIC_ID_RE, ROOM_FULFIL_COOLDOWN_MS, SecureChannel;
66903
+ var ROOM_AGENT_TYPES, CREDENTIAL_MESSAGE_TYPES, CATCHUP_MESSAGE_TYPES, POLL_INTERVAL_MS, RECONNECT_BASE_MS, UUID_RE4, RECONNECT_MAX_MS, PENDING_POLL_INTERVAL_MS, PENDING_POLL_SILENCE_MS, HISTORY_RESTORE_TIMEOUT_MS2, ROOM_ROSTER_REFRESH_TIMEOUT_MS, 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, PERSON_INVOLVED_WINDOW_MS, ATTESTED_INBOUND_MAX, UNMAPPED_RECONCILE_COOLDOWN_MS, TOPIC_ID_RE, ROOM_FULFIL_COOLDOWN_MS, SecureChannel;
66830
66904
  var init_channel = __esm({
66831
66905
  async "src/channel.ts"() {
66832
66906
  "use strict";
@@ -66852,6 +66926,7 @@ var init_channel = __esm({
66852
66926
  await init_history_recovery_code();
66853
66927
  init_decision_reply();
66854
66928
  init_welcome_kp_backoff();
66929
+ init_delivery_cadence();
66855
66930
  ROOM_AGENT_TYPES = /* @__PURE__ */ new Set([
66856
66931
  "message",
66857
66932
  "text",
@@ -66873,6 +66948,7 @@ var init_channel = __esm({
66873
66948
  UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
66874
66949
  RECONNECT_MAX_MS = 3e4;
66875
66950
  PENDING_POLL_INTERVAL_MS = 15e3;
66951
+ PENDING_POLL_SILENCE_MS = 18e4;
66876
66952
  HISTORY_RESTORE_TIMEOUT_MS2 = 1e4;
66877
66953
  ROOM_ROSTER_REFRESH_TIMEOUT_MS = 1e4;
66878
66954
  HISTORY_UPLOAD_TIMEOUT_MS = 1e4;
@@ -66945,6 +67021,8 @@ var init_channel = __esm({
66945
67021
  _pendingPollTimer = null;
66946
67022
  _syncMessageIds = null;
66947
67023
  _deliveryHeartbeat = null;
67024
+ _deliveryCadence = new DeliveryCadence();
67025
+ _a2aCadence = new A2aReconcileCadence();
66948
67026
  /**
66949
67027
  * How often to re-check the KeyPackage pool against the server (#826).
66950
67028
  *
@@ -69253,7 +69331,7 @@ ${text}`,
69253
69331
  */
69254
69332
  sendActivitySpan(spanData) {
69255
69333
  if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
69256
- const pluginVersion = true ? "0.23.67" : "0.0.0-dev";
69334
+ const pluginVersion = true ? "0.23.68" : "0.0.0-dev";
69257
69335
  const agentName = this.config.agentName ?? "Agent";
69258
69336
  const resource = {
69259
69337
  "service.name": "agentvault-agent",
@@ -71051,7 +71129,7 @@ ${text}`,
71051
71129
  throw new Error(`A2A channel ${channelId.slice(0, 8)} has no initialized MLS group`);
71052
71130
  }
71053
71131
  /**
71054
- * Start the periodic A2A reconcile timer (30s), mirroring `_deliveryHeartbeat`.
71132
+ * Start the periodic A2A reconcile timer, mirroring `_deliveryHeartbeat`.
71055
71133
  *
71056
71134
  * A2A join-triggers (`a2a_channel_approved` etc.) are delivered best-effort by
71057
71135
  * the backend's local-only `send_to_device`; if this agent is briefly
@@ -71059,10 +71137,14 @@ ${text}`,
71059
71137
  * channel hangs until the next connect. Re-running `listA2AChannels()` on a
71060
71138
  * timer re-fires the idempotent member sync-fallback (publish KeyPackage +
71061
71139
  * request Welcome) so the channel self-heals while staying connected.
71140
+ *
71141
+ * It ticks every 30 s, and an agent the server lists in no channel asks far
71142
+ * less often: see `A2aReconcileCadence`.
71062
71143
  */
71063
71144
  _startA2aReconcileTimer() {
71064
71145
  if (this._a2aReconcileTimer) clearInterval(this._a2aReconcileTimer);
71065
71146
  this._a2aReconcileTimer = setInterval(() => {
71147
+ if (!this._a2aCadence.due(Date.now())) return;
71066
71148
  this.listA2AChannels().catch(() => {
71067
71149
  });
71068
71150
  }, 3e4);
@@ -71088,6 +71170,7 @@ ${text}`,
71088
71170
  throw new Error(`List A2A channels failed (${res.status}): ${detail}`);
71089
71171
  }
71090
71172
  const resp = await res.json();
71173
+ this._a2aCadence.listed(Date.now(), resp.length);
71091
71174
  const channels = resp.map((ch) => ({
71092
71175
  channelId: ch.channel_id || ch.id,
71093
71176
  creator_hub_id: ch.creator_hub_id || "",
@@ -71536,7 +71619,7 @@ ${text}`,
71536
71619
  agentVersion: this.config.agentVersion ?? "0.0.0",
71537
71620
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
71538
71621
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
71539
- pluginVersion: true ? "0.23.67" : "0.0.0-dev"
71622
+ pluginVersion: true ? "0.23.68" : "0.0.0-dev"
71540
71623
  });
71541
71624
  this._telemetryReporter.startAutoFlush(3e4);
71542
71625
  }
@@ -71548,14 +71631,7 @@ ${text}`,
71548
71631
  await this._ensureKpPoolPublished();
71549
71632
  this._startKpReplenishTimer();
71550
71633
  this._startKeyProofTimer();
71551
- this._pullDeliveryQueue().catch((err) => {
71552
- console.warn("[SecureChannel] Initial delivery pull failed:", err);
71553
- });
71554
- if (this._deliveryHeartbeat) clearInterval(this._deliveryHeartbeat);
71555
- this._deliveryHeartbeat = setInterval(() => {
71556
- this._pullDeliveryQueue().catch(() => {
71557
- });
71558
- }, 3e4);
71634
+ this._beginDeliveryPulls();
71559
71635
  this._startA2aReconcileTimer();
71560
71636
  for (const [convId, entry] of Object.entries(this._persisted?.mlsConversations ?? {})) {
71561
71637
  if (entry.mlsGroupId) {
@@ -71750,6 +71826,7 @@ ${text}`,
71750
71826
  }
71751
71827
  if (data.event === "mls_welcome_requested") {
71752
71828
  console.log(`[SecureChannel] mls_welcome_requested for group ${(data.data?.group_id || "").slice(0, 8)} \u2014 pulling deliveries`);
71829
+ this._deliveryCadence.requestFullSweep();
71753
71830
  this._pullDeliveryQueue().catch((err) => {
71754
71831
  console.warn("[SecureChannel] Delivery pull on welcome request failed:", err);
71755
71832
  });
@@ -71874,7 +71951,7 @@ ${text}`,
71874
71951
  agentVersion: this.config.agentVersion ?? "0.0.0",
71875
71952
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
71876
71953
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
71877
- pluginVersion: true ? "0.23.67" : "0.0.0-dev"
71954
+ pluginVersion: true ? "0.23.68" : "0.0.0-dev"
71878
71955
  });
71879
71956
  this._telemetryReporter.startAutoFlush(3e4);
71880
71957
  }
@@ -71945,6 +72022,7 @@ ${text}`,
71945
72022
  this.emit("hub_identity_removed", data.data);
71946
72023
  }
71947
72024
  if (data.event === "a2a_channel_approved") {
72025
+ this._a2aCadence.wake();
71948
72026
  const channelData = data.data || data;
71949
72027
  const channelId = channelData.channel_id;
71950
72028
  const convId = channelData.conversation_id;
@@ -72021,6 +72099,7 @@ ${text}`,
72021
72099
  this.emit("a2a_channel_revoked", channelData);
72022
72100
  }
72023
72101
  if (data.event === "a2a_channel_invited") {
72102
+ this._a2aCadence.wake();
72024
72103
  const channelData = data.data || data;
72025
72104
  const channelId = channelData.channel_id;
72026
72105
  const convId = channelData.conversation_id;
@@ -75096,9 +75175,31 @@ ${baseText}`;
75096
75175
  await this._persistState();
75097
75176
  await this._applyBufferedMlsCommits(groupId, mgr);
75098
75177
  }
75178
+ /** A new connection may have missed any signal, so it starts from fresh. */
75179
+ _beginDeliveryPulls() {
75180
+ this._deliveryCadence.reset();
75181
+ this._pullDeliveryQueue().catch((err) => {
75182
+ console.warn("[SecureChannel] Initial delivery pull failed:", err);
75183
+ });
75184
+ this._startDeliveryHeartbeat();
75185
+ }
75186
+ /**
75187
+ * Keep pulling while the socket is up. The tick costs nothing: it only asks
75188
+ * `_deliveryCadence` whether a pull is due, which is every 30 s until the
75189
+ * server says this device may rest. A signal that never arrives is recovered
75190
+ * here, within one rest.
75191
+ */
75192
+ _startDeliveryHeartbeat() {
75193
+ if (this._deliveryHeartbeat) clearInterval(this._deliveryHeartbeat);
75194
+ this._deliveryHeartbeat = setInterval(() => {
75195
+ if (!this._deliveryCadence.pullDue(Date.now())) return;
75196
+ this._pullDeliveryQueue().catch(() => {
75197
+ });
75198
+ }, DELIVERY_TICK_MS);
75199
+ }
75099
75200
  /**
75100
75201
  * Pull pending MLS messages from the delivery queue and process them.
75101
- * Called on WS connect, on mls_delivery ping, and every 30s heartbeat.
75202
+ * Called on WS connect, on mls_delivery ping, and by the delivery heartbeat.
75102
75203
  */
75103
75204
  async _pullDeliveryQueue() {
75104
75205
  if (!this._deviceId || !this._deviceJwt) return;
@@ -75107,6 +75208,7 @@ ${baseText}`;
75107
75208
  return;
75108
75209
  }
75109
75210
  this._deliveryPulling = true;
75211
+ this._deliveryCadence.pullStarted(Date.now());
75110
75212
  try {
75111
75213
  const res = await fetch(
75112
75214
  `${this.config.apiUrl}/api/v1/mls/delivery?device_id=${this._deviceId}`,
@@ -75116,7 +75218,9 @@ ${baseText}`;
75116
75218
  console.warn(`[SecureChannel] Delivery pull failed: ${res.status}`);
75117
75219
  return;
75118
75220
  }
75119
- let { messages } = await res.json();
75221
+ const pulled = await res.json();
75222
+ let { messages } = pulled;
75223
+ const sync = parseDeliverySync(pulled.sync);
75120
75224
  const hasMessages = messages && messages.length > 0;
75121
75225
  if (hasMessages) {
75122
75226
  messages = orderDeliveryBatch(messages);
@@ -75237,11 +75341,13 @@ ${baseText}`;
75237
75341
  }
75238
75342
  }
75239
75343
  }
75344
+ const welcomeTargets = this._deliveryCadence.welcomeTargets(Date.now(), sync);
75240
75345
  for (const [roomId, mlsGroup] of this._mlsGroups) {
75241
75346
  if (!mlsGroup?.isInitialized) continue;
75242
75347
  if (roomId.includes(":")) continue;
75243
75348
  const roomState = this._persisted?.rooms?.[roomId];
75244
75349
  if (!roomState?.mlsGroupId) continue;
75350
+ if (!wantsWelcomeRead(welcomeTargets, roomState.mlsGroupId)) continue;
75245
75351
  try {
75246
75352
  const roomLabel = `room ${roomId.slice(0, 8)}`;
75247
75353
  const pendingRes = await fetch(
@@ -75342,6 +75448,7 @@ ${baseText}`;
75342
75448
  if (!entry.mlsGroupId) continue;
75343
75449
  const mlsGroup = this._mlsGroups.get(`1to1-group:${gid}`);
75344
75450
  if (!mlsGroup?.isInitialized) continue;
75451
+ if (!wantsWelcomeRead(welcomeTargets, entry.mlsGroupId)) continue;
75345
75452
  try {
75346
75453
  const sharedLabel = `shared group ${gid.slice(0, 8)}`;
75347
75454
  const pendingRes = await fetch(
@@ -75438,6 +75545,7 @@ ${baseText}`;
75438
75545
  if (!convEntry.mlsGroupId) continue;
75439
75546
  const mlsGroup = this._mlsGroups.get(`conv:${convId}`);
75440
75547
  if (!mlsGroup?.isInitialized) continue;
75548
+ if (!wantsWelcomeRead(welcomeTargets, convEntry.mlsGroupId)) continue;
75441
75549
  try {
75442
75550
  const convLabel = `conv ${convId.slice(0, 8)}`;
75443
75551
  const pendingRes = await fetch(
@@ -75580,6 +75688,7 @@ ${baseText}`;
75580
75688
  } catch {
75581
75689
  }
75582
75690
  }
75691
+ if (!hasMessages) this._deliveryCadence.pullWasQuiet(Date.now(), sync);
75583
75692
  } catch (err) {
75584
75693
  console.warn("[SecureChannel] Delivery pull error:", err);
75585
75694
  } finally {
@@ -76469,6 +76578,7 @@ ${baseText}`;
76469
76578
  }
76470
76579
  async _checkPendingMessages() {
76471
76580
  if (this._state === "connecting" || !this._deviceId || !this._deviceJwt) return;
76581
+ if (this._state === "ready" && Date.now() - this._lastServerMessage <= PENDING_POLL_SILENCE_MS) return;
76472
76582
  try {
76473
76583
  const url2 = `${this.config.apiUrl}/api/v1/devices/${this._deviceId}/pending`;
76474
76584
  const resp = await fetch(url2, {
@@ -76488,7 +76598,7 @@ ${baseText}`;
76488
76598
  }
76489
76599
  } else if (data.pending > 0 && this._state === "ready") {
76490
76600
  const silence = Date.now() - this._lastServerMessage;
76491
- if (silence > 18e4) {
76601
+ if (silence > PENDING_POLL_SILENCE_MS) {
76492
76602
  console.log(
76493
76603
  `[SecureChannel] Poll: ${data.pending} pending + ${Math.round(silence / 1e3)}s silence \u2014 forcing reconnect`
76494
76604
  );
@@ -104475,7 +104585,7 @@ var init_index = __esm({
104475
104585
  init_room_protocol();
104476
104586
  init_tool_telemetry();
104477
104587
  init_turn_failure();
104478
- VERSION = true ? "0.23.67" : "0.0.0-dev";
104588
+ VERSION = true ? "0.23.68" : "0.0.0-dev";
104479
104589
  }
104480
104590
  });
104481
104591
  await init_index();