@adhdev/daemon-standalone 1.0.58-rc.20 → 1.0.58-rc.23

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
@@ -36885,10 +36885,10 @@ var require_dist3 = __commonJS({
36885
36885
  }
36886
36886
  function getDaemonBuildInfo() {
36887
36887
  if (cached2) return cached2;
36888
- const commit = readInjected(true ? "079b401790e71ed1ad71665990e7acd3747efd78" : void 0) ?? "unknown";
36889
- const commitShort = readInjected(true ? "079b4017" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36890
- const version2 = readInjected(true ? "1.0.58-rc.20" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36891
- const builtAt = readInjected(true ? "2026-08-26T18:21:35.498Z" : void 0);
36888
+ const commit = readInjected(true ? "c1b69b8ef74605a27371c94c695f647d450185b5" : void 0) ?? "unknown";
36889
+ const commitShort = readInjected(true ? "c1b69b8e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36890
+ const version2 = readInjected(true ? "1.0.58-rc.23" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36891
+ const builtAt = readInjected(true ? "2026-08-27T00:01:09.317Z" : void 0);
36892
36892
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
36893
36893
  return cached2;
36894
36894
  }
@@ -88884,7 +88884,7 @@ ${e?.stderr || ""}`;
88884
88884
  }
88885
88885
  });
88886
88886
  var require_canonicalize = __commonJS2({
88887
- "../../vendor/seqscribe/node_modules/canonicalize/lib/canonicalize.js"(exports22, module22) {
88887
+ "../../node_modules/canonicalize/lib/canonicalize.js"(exports22, module22) {
88888
88888
  "use strict";
88889
88889
  module22.exports = function serialize(object2) {
88890
88890
  if (typeof object2 === "number" && isNaN(object2)) {
@@ -89075,6 +89075,9 @@ ${e?.stderr || ""}`;
89075
89075
  PARKED_TASK_RETENTION_MS: () => PARKED_TASK_RETENTION_MS,
89076
89076
  PARK_REASON_PIN_EXPIRED: () => PARK_REASON_PIN_EXPIRED,
89077
89077
  PARK_RETENTION_EXPIRED_REASON: () => PARK_RETENTION_EXPIRED_REASON,
89078
+ PROBE_CONSUMER: () => PROBE_CONSUMER,
89079
+ PROBE_ENTRY_KIND: () => PROBE_ENTRY_KIND,
89080
+ PROBE_INTERVAL_MS: () => PROBE_INTERVAL_MS,
89078
89081
  PROVIDER_CHANNEL_ENV_VAR: () => PROVIDER_CHANNEL_ENV_VAR,
89079
89082
  PRUNABLE_ORPHAN_STALE_REASONS: () => PRUNABLE_ORPHAN_STALE_REASONS,
89080
89083
  ProviderChannelError: () => ProviderChannelError,
@@ -89580,6 +89583,7 @@ ${e?.stderr || ""}`;
89580
89583
  shouldWarnForMissingSession: () => shouldWarnForMissingSession,
89581
89584
  shutdownDaemonComponents: () => shutdownDaemonComponents2,
89582
89585
  spawnDetachedDaemonUpgradeHelper: () => spawnDetachedDaemonUpgradeHelper,
89586
+ startConvergenceProbe: () => startConvergenceProbe,
89583
89587
  startDaemonDevSupport: () => startDaemonDevSupport2,
89584
89588
  startFleetFinalityLoop: () => startFleetFinalityLoop,
89585
89589
  startLocalIpcServer: () => startLocalIpcServer2,
@@ -104499,7 +104503,23 @@ ${marker}`,
104499
104503
  // untouched). A coordinator that called restart_daemon_node can
104500
104504
  // read this before and after (per the clientHint retry delay) and
104501
104505
  // compare: same id means the daemon never actually exited/re-spawned.
104502
- bootId: currentRefineExecutorBootId()
104506
+ bootId: currentRefineExecutorBootId(),
104507
+ // Local read surface for seqscribe replication health. Until now
104508
+ // `getSeqscribeStats` was reachable only through the status report
104509
+ // to the cloud server, so an operator on the machine had no way to
104510
+ // see whether replication was healthy — `adhdev`/mesh_status can
104511
+ // now answer it without a round trip through the server.
104512
+ //
104513
+ // ★This is the SAME aggregate-only summary the status path carries
104514
+ // (seqscribe/stats.ts): counters, booleans and bucket ordinals.
104515
+ // The server content boundary is untouched — nothing is added to
104516
+ // status_report here, and this field must never widen into topic
104517
+ // names, peer ids, or anything derived from an entry payload.
104518
+ //
104519
+ // null = replication unavailable (node failed to open, or stats
104520
+ // threw); the key is always present so a caller can tell "no node"
104521
+ // from an older daemon that never reported the field at all.
104522
+ seqscribe: ctx.deps.getSeqscribeStats?.() ?? null
104503
104523
  };
104504
104524
  },
104505
104525
  /**
@@ -139227,6 +139247,7 @@ data: ${JSON.stringify(msg.data)}
139227
139247
  init_refresh();
139228
139248
  init_mesh_runtime_store();
139229
139249
  init_coordinator_registry();
139250
+ init_mesh_refine_executor_liveness();
139230
139251
  var _hardened = false;
139231
139252
  var HARDENED_PROTOS = [
139232
139253
  { name: "Object", proto: Object.prototype },
@@ -145448,6 +145469,148 @@ CREATE TABLE IF NOT EXISTS sq_archive (
145448
145469
  close
145449
145470
  };
145450
145471
  }
145472
+ init_logger();
145473
+ async function appendAssistantJournal(handle, kind, payload) {
145474
+ if (!handle.topics.some((d) => d.topic === ASSISTANT_JOURNAL_TOPIC)) {
145475
+ throw new Error(
145476
+ `cannot append to ${ASSISTANT_JOURNAL_TOPIC}: the topic is not defined on this node. Content topics require the fleet secret (ADHDEV_SEQSCRIBE_FLEET_SECRET env var or the auth_ok-delivered store); without it the node runs metadata-topics-only.`
145477
+ );
145478
+ }
145479
+ return handle.node.log(ASSISTANT_JOURNAL_TOPIC).append(kind, payload);
145480
+ }
145481
+ function consumeAssistantJournal(handle, consumer, cb) {
145482
+ if (typeof consumer !== "string" || consumer.trim().length === 0) {
145483
+ throw new Error("consumeAssistantJournal requires a non-empty consumer name");
145484
+ }
145485
+ return handle.node.onEntry(ASSISTANT_JOURNAL_TOPIC, consumer, cb);
145486
+ }
145487
+ var PROBE_ENTRY_KIND = "adhdev.probe.heartbeat";
145488
+ var PROBE_CONSUMER = "stage1-convergence-probe";
145489
+ var PROBE_INTERVAL_MS = 30 * 60 * 1e3;
145490
+ function shortId(id) {
145491
+ return id.length <= 12 ? id : `${id.slice(0, 12)}\u2026`;
145492
+ }
145493
+ function startConvergenceProbe(handle, opts = {}) {
145494
+ if (!handle.topics.some((d) => d.topic === ASSISTANT_JOURNAL_TOPIC)) {
145495
+ LOG2.info(
145496
+ "Seqscribe",
145497
+ "convergence probe idle \u2014 assistant.journal is not defined on this node (no fleet secret; metadata-topics-only mode)"
145498
+ );
145499
+ return null;
145500
+ }
145501
+ const version2 = opts.version ?? "unknown";
145502
+ const bootId = opts.bootId ?? "unknown";
145503
+ let remoteSeen = 0;
145504
+ let stopped = false;
145505
+ let unsub = null;
145506
+ try {
145507
+ unsub = consumeAssistantJournal(handle, PROBE_CONSUMER, (entry) => {
145508
+ if (entry.kind !== PROBE_ENTRY_KIND) return;
145509
+ if (entry.writer === handle.writerId) return;
145510
+ remoteSeen++;
145511
+ const payload = entry.payload;
145512
+ const version22 = typeof payload?.version === "string" ? payload.version : "unknown";
145513
+ LOG2.info(
145514
+ "Seqscribe",
145515
+ `converge writer=${shortId(entry.writer)} seq=${entry.seq} version=${version22} total=${remoteSeen}`
145516
+ );
145517
+ });
145518
+ } catch (err) {
145519
+ LOG2.warn(
145520
+ "Seqscribe",
145521
+ `convergence probe consumer failed: ${err instanceof Error ? err.message : String(err)}`
145522
+ );
145523
+ return null;
145524
+ }
145525
+ const emit = (reason) => {
145526
+ if (stopped) return;
145527
+ const payload = {
145528
+ writerId: handle.writerId,
145529
+ daemonId: handle.daemonId,
145530
+ version: version2,
145531
+ bootId,
145532
+ at: Date.now()
145533
+ };
145534
+ void appendAssistantJournal(handle, PROBE_ENTRY_KIND, { ...payload }).then(
145535
+ () => {
145536
+ if (reason === "boot") {
145537
+ LOG2.info(
145538
+ "Seqscribe",
145539
+ `convergence probe armed writer=${shortId(handle.writerId)} topic=${ASSISTANT_JOURNAL_TOPIC}`
145540
+ );
145541
+ }
145542
+ },
145543
+ (err) => {
145544
+ LOG2.warn(
145545
+ "Seqscribe",
145546
+ `convergence probe append failed (${reason}): ${err instanceof Error ? err.message : String(err)}`
145547
+ );
145548
+ }
145549
+ );
145550
+ };
145551
+ emit("boot");
145552
+ let timer = null;
145553
+ if (!opts.once) {
145554
+ timer = setInterval(() => emit("tick"), opts.intervalMs ?? PROBE_INTERVAL_MS);
145555
+ timer.unref?.();
145556
+ }
145557
+ return {
145558
+ stop() {
145559
+ if (stopped) return;
145560
+ stopped = true;
145561
+ if (timer) clearInterval(timer);
145562
+ try {
145563
+ unsub?.();
145564
+ } catch {
145565
+ }
145566
+ },
145567
+ remoteSeen: () => remoteSeen
145568
+ };
145569
+ }
145570
+ var FGEN_AGE_BUCKETS_H = [2, 6, 24, 72];
145571
+ var BACKLOG_BUCKETS = [1, 10, 100, 1e3];
145572
+ function bucket(value, thresholds) {
145573
+ if (!Number.isFinite(value) || value <= 0) return 0;
145574
+ for (let i = 0; i < thresholds.length; i++) {
145575
+ if (value < thresholds[i]) return i + 1;
145576
+ }
145577
+ return thresholds.length + 1;
145578
+ }
145579
+ function summarizeSeqscribeStats(stats, opts) {
145580
+ let maxPending = 0;
145581
+ let maxLag = 0;
145582
+ let maxCertAgeMs = 0;
145583
+ let quarantined = false;
145584
+ let topics = 0;
145585
+ for (const topic of Object.values(stats.topics)) {
145586
+ topics++;
145587
+ if (topic.pending > maxPending) maxPending = topic.pending;
145588
+ if (topic.quarantined > 0) quarantined = true;
145589
+ if (topic.certOrderAgeMs !== null && topic.certOrderAgeMs > maxCertAgeMs) {
145590
+ maxCertAgeMs = topic.certOrderAgeMs;
145591
+ }
145592
+ for (const consumer of Object.values(topic.consumers)) {
145593
+ if (consumer.lagRows > maxLag) maxLag = consumer.lagRows;
145594
+ }
145595
+ }
145596
+ let maxQueued = 0;
145597
+ let peersReady = 0;
145598
+ for (const peer of stats.peers) {
145599
+ if (peer.queuedData > maxQueued) maxQueued = peer.queuedData;
145600
+ if (peer.state === "ready") peersReady++;
145601
+ }
145602
+ return {
145603
+ topics,
145604
+ peers: stats.peers.length,
145605
+ peersReady,
145606
+ pendingBucket: bucket(maxPending, BACKLOG_BUCKETS),
145607
+ consumerLagBucket: bucket(maxLag, BACKLOG_BUCKETS),
145608
+ queueBucket: bucket(maxQueued, BACKLOG_BUCKETS),
145609
+ fgenAgeBucket: bucket(maxCertAgeMs / (60 * 60 * 1e3), FGEN_AGE_BUCKETS_H),
145610
+ quarantined,
145611
+ authority: opts.authorityEnabled
145612
+ };
145613
+ }
145451
145614
  function tryOpenDaemonSeqscribeNode(options = {}) {
145452
145615
  const env2 = options.env ?? process.env;
145453
145616
  try {
@@ -145700,6 +145863,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
145700
145863
  sessionRegistry
145701
145864
  );
145702
145865
  commandHandler.setAgentStreamManager(agentStreamManager);
145866
+ let seqscribeNodeRef;
145703
145867
  const router = new DaemonCommandRouter({
145704
145868
  commandHandler,
145705
145869
  cliManager,
@@ -145722,7 +145886,25 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
145722
145886
  getMeshPeerConnectionStatus: config2.getMeshPeerConnectionStatus,
145723
145887
  dispatchMeshCommand: config2.dispatchMeshCommand,
145724
145888
  updateLocalMeshOwnedSession: config2.updateLocalMeshOwnedSession,
145725
- getCdpLogFn: config2.getCdpLogFn || ((ideType) => LOG2.forComponent(`CDP:${ideType}`).asLogFn())
145889
+ getCdpLogFn: config2.getCdpLogFn || ((ideType) => LOG2.forComponent(`CDP:${ideType}`).asLogFn()),
145890
+ // Local read surface for replication health (get_status_metadata).
145891
+ // Aggregate-only by construction — summarizeSeqscribeStats is the same
145892
+ // allow-list projection the status report uses, and nothing here
145893
+ // touches the status_report payload itself.
145894
+ getSeqscribeStats: () => {
145895
+ if (!seqscribeNodeRef) return null;
145896
+ try {
145897
+ return summarizeSeqscribeStats(seqscribeNodeRef.node.stats(), {
145898
+ authorityEnabled: seqscribeNodeRef.authorityEnabled
145899
+ });
145900
+ } catch (error48) {
145901
+ LOG2.warn(
145902
+ "Seqscribe",
145903
+ `stats unavailable for get_status_metadata: ${error48 instanceof Error ? error48.message : String(error48)}`
145904
+ );
145905
+ return null;
145906
+ }
145907
+ }
145726
145908
  });
145727
145909
  poller = new AgentStreamPoller({
145728
145910
  agentStreamManager,
@@ -145753,6 +145935,20 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
145753
145935
  statusInstanceId: config2.statusInstanceId
145754
145936
  };
145755
145937
  components.seqscribeNode = tryOpenDaemonSeqscribeNode({ daemonId: config2.statusInstanceId });
145938
+ seqscribeNodeRef = components.seqscribeNode;
145939
+ if (components.seqscribeNode) {
145940
+ try {
145941
+ components.seqscribeProbe = startConvergenceProbe(components.seqscribeNode, {
145942
+ version: config2.statusVersion ?? getDaemonBuildInfo().version,
145943
+ bootId: currentRefineExecutorBootId()
145944
+ });
145945
+ } catch (error48) {
145946
+ LOG2.warn(
145947
+ "Seqscribe",
145948
+ `convergence probe unavailable: ${error48 instanceof Error ? error48.message : String(error48)}`
145949
+ );
145950
+ }
145951
+ }
145756
145952
  setupMeshEventForwarding(components);
145757
145953
  try {
145758
145954
  migratePendingEventsJsonlToSqlite();
@@ -145803,7 +145999,8 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
145803
145999
  quotaEventRefresh,
145804
146000
  providerStalenessProbe,
145805
146001
  eventLoopMonitor,
145806
- seqscribeNode
146002
+ seqscribeNode,
146003
+ seqscribeProbe
145807
146004
  } = components;
145808
146005
  poller.stop();
145809
146006
  cdpInitializer.stop();
@@ -145827,6 +146024,10 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
145827
146024
  providerStalenessProbe?.stop();
145828
146025
  } catch {
145829
146026
  }
146027
+ try {
146028
+ seqscribeProbe?.stop();
146029
+ } catch {
146030
+ }
145830
146031
  try {
145831
146032
  if (agentStreamManager) {
145832
146033
  await agentStreamManager.dispose(cdpManagers);
@@ -146302,64 +146503,6 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
146302
146503
  \u2717 ${message}
146303
146504
  `));
146304
146505
  }
146305
- async function appendAssistantJournal(handle, kind, payload) {
146306
- if (!handle.topics.some((d) => d.topic === ASSISTANT_JOURNAL_TOPIC)) {
146307
- throw new Error(
146308
- `cannot append to ${ASSISTANT_JOURNAL_TOPIC}: the topic is not defined on this node. Content topics require the fleet secret (ADHDEV_SEQSCRIBE_FLEET_SECRET env var or the auth_ok-delivered store); without it the node runs metadata-topics-only.`
146309
- );
146310
- }
146311
- return handle.node.log(ASSISTANT_JOURNAL_TOPIC).append(kind, payload);
146312
- }
146313
- function consumeAssistantJournal(handle, consumer, cb) {
146314
- if (typeof consumer !== "string" || consumer.trim().length === 0) {
146315
- throw new Error("consumeAssistantJournal requires a non-empty consumer name");
146316
- }
146317
- return handle.node.onEntry(ASSISTANT_JOURNAL_TOPIC, consumer, cb);
146318
- }
146319
- var FGEN_AGE_BUCKETS_H = [2, 6, 24, 72];
146320
- var BACKLOG_BUCKETS = [1, 10, 100, 1e3];
146321
- function bucket(value, thresholds) {
146322
- if (!Number.isFinite(value) || value <= 0) return 0;
146323
- for (let i = 0; i < thresholds.length; i++) {
146324
- if (value < thresholds[i]) return i + 1;
146325
- }
146326
- return thresholds.length + 1;
146327
- }
146328
- function summarizeSeqscribeStats(stats, opts) {
146329
- let maxPending = 0;
146330
- let maxLag = 0;
146331
- let maxCertAgeMs = 0;
146332
- let quarantined = false;
146333
- let topics = 0;
146334
- for (const topic of Object.values(stats.topics)) {
146335
- topics++;
146336
- if (topic.pending > maxPending) maxPending = topic.pending;
146337
- if (topic.quarantined > 0) quarantined = true;
146338
- if (topic.certOrderAgeMs !== null && topic.certOrderAgeMs > maxCertAgeMs) {
146339
- maxCertAgeMs = topic.certOrderAgeMs;
146340
- }
146341
- for (const consumer of Object.values(topic.consumers)) {
146342
- if (consumer.lagRows > maxLag) maxLag = consumer.lagRows;
146343
- }
146344
- }
146345
- let maxQueued = 0;
146346
- let peersReady = 0;
146347
- for (const peer of stats.peers) {
146348
- if (peer.queuedData > maxQueued) maxQueued = peer.queuedData;
146349
- if (peer.state === "ready") peersReady++;
146350
- }
146351
- return {
146352
- topics,
146353
- peers: stats.peers.length,
146354
- peersReady,
146355
- pendingBucket: bucket(maxPending, BACKLOG_BUCKETS),
146356
- consumerLagBucket: bucket(maxLag, BACKLOG_BUCKETS),
146357
- queueBucket: bucket(maxQueued, BACKLOG_BUCKETS),
146358
- fgenAgeBucket: bucket(maxCertAgeMs / (60 * 60 * 1e3), FGEN_AGE_BUCKETS_H),
146359
- quarantined,
146360
- authority: opts.authorityEnabled
146361
- };
146362
- }
146363
146506
  }
146364
146507
  });
146365
146508