@adhdev/daemon-standalone 1.0.41-rc.7 → 1.0.41-rc.8

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
@@ -36556,10 +36556,10 @@ var require_dist3 = __commonJS({
36556
36556
  }
36557
36557
  function getDaemonBuildInfo() {
36558
36558
  if (cached2) return cached2;
36559
- const commit = readInjected(true ? "95386596964cf9654126f78b31c6f7a917789dda" : void 0) ?? "unknown";
36560
- const commitShort = readInjected(true ? "95386596" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36561
- const version2 = readInjected(true ? "1.0.41-rc.7" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36562
- const builtAt = readInjected(true ? "2026-08-09T16:45:57.944Z" : void 0);
36559
+ const commit = readInjected(true ? "e76abaa7f3aa697fff411260da07b222bbc57117" : void 0) ?? "unknown";
36560
+ const commitShort = readInjected(true ? "e76abaa7" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36561
+ const version2 = readInjected(true ? "1.0.41-rc.8" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36562
+ const builtAt = readInjected(true ? "2026-08-09T23:59:15.763Z" : void 0);
36563
36563
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
36564
36564
  return cached2;
36565
36565
  }
@@ -91617,7 +91617,13 @@ ${marker}`,
91617
91617
  version: ctx.deps.statusVersion || "unknown",
91618
91618
  profile: "metadata"
91619
91619
  });
91620
- return { success: true, status: snapshot, daemonBuild: getDaemonBuildInfo(), upgradeFailure: readUpgradeFailureNotice() };
91620
+ return {
91621
+ success: true,
91622
+ status: snapshot,
91623
+ daemonBuild: getDaemonBuildInfo(),
91624
+ upgradeFailure: readUpgradeFailureNotice(),
91625
+ providerChannelStaleness: ctx.deps.providerLoader?.getChannelStalenessSnapshot?.() ?? null
91626
+ };
91621
91627
  },
91622
91628
  get_machine_runtime_stats: async (_ctx, _args) => {
91623
91629
  const quota = readQuotaCache();
@@ -105701,6 +105707,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
105701
105707
  allowUnverifiedTarball;
105702
105708
  channelStore;
105703
105709
  channelSyncIO;
105710
+ /** Running daemon version (normalized, no leading 'v'); '' when unknown. */
105711
+ daemonVersion = "";
105712
+ /** Last read-only staleness probe result (checkVerifiedChannelStaleness). */
105713
+ channelStalenessSnapshot = null;
105704
105714
  probeStarts = [];
105705
105715
  siblingLogged = false;
105706
105716
  /** Active verified-channel object dirs, refreshed by loadAll(). */
@@ -105795,6 +105805,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
105795
105805
  this.allowUnverifiedTarball = options?.allowUnverifiedTarball === true || process.env[_ProviderLoader.UNVERIFIED_TARBALL_ENV_VAR] === "1";
105796
105806
  this.channelStore = options?.channelStore === null ? null : options?.channelStore ?? new ProviderChannelStore(ProviderChannelStore.defaultRoot(), this.logFn);
105797
105807
  this.channelSyncIO = options?.channelSyncIO;
105808
+ this.daemonVersion = (options?.daemonVersion || "").trim().replace(/^v/, "");
105798
105809
  this.defaultProvidersDir = path45.join(getConfigDir2(), "providers");
105799
105810
  const detected = this.detectDefaultUserDir();
105800
105811
  this.userDir = detected.path;
@@ -106081,6 +106092,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
106081
106092
  if (report.activated.length > 0) {
106082
106093
  this.loadAll();
106083
106094
  }
106095
+ if (report.status !== "error") {
106096
+ this.writeChannelActivationStamp();
106097
+ }
106084
106098
  return report;
106085
106099
  }
106086
106100
  /**
@@ -106128,6 +106142,122 @@ Run 'adhdev doctor' for detailed diagnostics.`
106128
106142
  }
106129
106143
  return this.syncVerifiedChannel({ bootstrapAll: true });
106130
106144
  }
106145
+ /** Stamp path recording which daemon version last ran a successful verified sync. */
106146
+ channelActivationStampPath() {
106147
+ return path45.join(this.defaultProvidersDir, ".channel-activation-stamp.json");
106148
+ }
106149
+ readChannelActivationStamp() {
106150
+ try {
106151
+ return JSON.parse(fs41.readFileSync(this.channelActivationStampPath(), "utf-8"));
106152
+ } catch {
106153
+ return null;
106154
+ }
106155
+ }
106156
+ writeChannelActivationStamp() {
106157
+ if (!this.daemonVersion) return;
106158
+ try {
106159
+ fs41.mkdirSync(this.defaultProvidersDir, { recursive: true });
106160
+ fs41.writeFileSync(this.channelActivationStampPath(), JSON.stringify({
106161
+ daemonVersion: this.daemonVersion,
106162
+ channel: this.channel,
106163
+ syncedAt: (/* @__PURE__ */ new Date()).toISOString()
106164
+ }, null, 2));
106165
+ } catch {
106166
+ }
106167
+ }
106168
+ /**
106169
+ * DAEMON-UPDATE = PROVIDER ACTIVATION (owner decision 2026-08-10, option C).
106170
+ *
106171
+ * The verified-channel pin deliberately only advances on an explicit
106172
+ * activation ("the user saying now"), which left published provider fixes
106173
+ * invisible on every machine where nobody pressed the button — live 08-10
106174
+ * measurement: every fleet pin still carried the 08-07 bootstrap timestamp
106175
+ * after a publish AND a full fleet restart. The daemon upgrade is the one
106176
+ * update moment the user already trusts, so ride it: on the FIRST boot of a
106177
+ * new daemon version (or after a channel switch), run one full verified
106178
+ * sync. Every other boot stays network-free — the stamp written by the last
106179
+ * successful sync short-circuits same-version boots. Fail-closed: an
106180
+ * errored sync writes no stamp, so the next boot retries; last-known-good
106181
+ * activations are untouched throughout (syncVerifiedChannel semantics).
106182
+ *
106183
+ * Empty stores are excluded — maybeFirstSyncVerifiedChannel owns bootstrap,
106184
+ * and its successful sync writes the same stamp (both paths converge in
106185
+ * syncVerifiedChannel), so a fresh install does not double-sync.
106186
+ *
106187
+ * Note this advances EXISTING targets (active pins + installed set) only. A
106188
+ * provider type first published after bootstrap still needs an explicit
106189
+ * catalog install — surfaced by checkVerifiedChannelStaleness as newTypes.
106190
+ */
106191
+ async maybeSyncVerifiedChannelOnDaemonUpdate() {
106192
+ if (!this.channelStore || !this.daemonVersion) return null;
106193
+ if (this.countVerifiedChannelPointers() === 0) return null;
106194
+ const stamp = this.readChannelActivationStamp();
106195
+ if (stamp?.daemonVersion === this.daemonVersion && stamp?.channel === this.channel) return null;
106196
+ this.log(`Daemon version transition detected (stamp=${stamp?.daemonVersion ?? "none"}@${stamp?.channel ?? "-"} \u2192 ${this.daemonVersion}@${this.channel}) \u2014 running verified channel sync`);
106197
+ return this.syncVerifiedChannel();
106198
+ }
106199
+ /**
106200
+ * Read-only staleness probe (owner decision 2026-08-10, option A).
106201
+ *
106202
+ * ONE channel-listing request, no downloads, no pointer writes: compares the
106203
+ * channel's current entries against the local active pins and reports
106204
+ * - staleTypes: pinned providers whose channel entry moved past the pin
106205
+ * - newTypes: activatable channel entries this machine has never
106206
+ * activated NOR installed — the class that made kimi
106207
+ * invisible (published after bootstrap, unreachable even by
106208
+ * activate_provider_updates because the sync target set is
106209
+ * pins+installed).
106210
+ * The result is cached on the loader for get_status_metadata so dashboards
106211
+ * can badge without triggering network from a status path. Fail-closed: on
106212
+ * any transport/shape error the previous snapshot is kept and the error is
106213
+ * recorded on it.
106214
+ */
106215
+ async checkVerifiedChannelStaleness() {
106216
+ const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
106217
+ if (!this.channelStore) {
106218
+ return this.channelStalenessSnapshot = { checkedAt, channel: this.channel, staleTypes: [], newTypes: [], error: "verified channel store is disabled" };
106219
+ }
106220
+ const runtime = new ProviderChannelRuntime({
106221
+ store: this.channelStore,
106222
+ registryBaseUrl: this.registryBaseUrl,
106223
+ providerTarballUrl: this.providerTarballUrl,
106224
+ logFn: this.logFn,
106225
+ ...this.channelSyncIO
106226
+ });
106227
+ let entries;
106228
+ try {
106229
+ entries = await runtime.fetchChannelEntries(this.channel);
106230
+ } catch (e) {
106231
+ const prev = this.channelStalenessSnapshot;
106232
+ return this.channelStalenessSnapshot = {
106233
+ checkedAt,
106234
+ channel: this.channel,
106235
+ staleTypes: prev?.staleTypes ?? [],
106236
+ newTypes: prev?.newTypes ?? [],
106237
+ error: e?.message || String(e)
106238
+ };
106239
+ }
106240
+ const pins = this.listVerifiedChannelPins();
106241
+ const installedTargets = collectSyncTargetTypes(this.upstreamDir, this.channelStore, this.channel);
106242
+ const staleTypes = [];
106243
+ const newTypes = [];
106244
+ for (const entry of entries) {
106245
+ if (!entry.bundleDigest) continue;
106246
+ const pin = pins.get(entry.providerType);
106247
+ if (pin) {
106248
+ if (pin.active?.digest !== entry.bundleDigest) staleTypes.push(entry.providerType);
106249
+ } else if (!installedTargets.has(entry.providerType)) {
106250
+ newTypes.push(entry.providerType);
106251
+ }
106252
+ }
106253
+ staleTypes.sort();
106254
+ newTypes.sort();
106255
+ return this.channelStalenessSnapshot = { checkedAt, channel: this.channel, staleTypes, newTypes };
106256
+ }
106257
+ /** Last probe result (null until the first checkVerifiedChannelStaleness run). Pure read. */
106258
+ getChannelStalenessSnapshot() {
106259
+ return this.channelStalenessSnapshot;
106260
+ }
106131
106261
  /**
106132
106262
  * The verified-channel PIN for each provider: what this daemon actually
106133
106263
  * loads, as opposed to what is sitting in `.upstream`.
@@ -125189,12 +125319,16 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
125189
125319
  providerTarballUrl: appConfig.providerTarballUrl,
125190
125320
  channel: appConfig.providerChannel,
125191
125321
  updateChannel: appConfig.updateChannel,
125192
- allowUnverifiedTarball: appConfig.providerAllowUnverifiedTarball
125322
+ allowUnverifiedTarball: appConfig.providerAllowUnverifiedTarball,
125323
+ // Enables the daemon-update = provider-activation stamp (option C):
125324
+ // a boot on a NEW daemon version runs one verified sync; same-version
125325
+ // boots stay network-free.
125326
+ daemonVersion: config2.statusVersion
125193
125327
  });
125194
125328
  providerLoader.loadAll();
125195
125329
  providerLoader.registerToDetector();
125196
125330
  void providerLoader.maybeFirstSyncVerifiedChannel().then(async (report) => {
125197
- if (!report) return;
125331
+ if (!report) return null;
125198
125332
  if (report.status === "error") {
125199
125333
  LOG2.warn("Init", `Verified channel first-sync failed (last-known-good preserved): ${report.errors.map((e) => e.code).join(", ") || "unknown"}`);
125200
125334
  } else if (report.activated.length > 0) {
@@ -125203,7 +125337,47 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
125203
125337
  await refreshProviderAvailability();
125204
125338
  config2.onStatusChange?.();
125205
125339
  }
125206
- }).catch((e) => LOG2.warn("Init", `Verified channel first-sync error: ${e?.message || e}`));
125340
+ return report;
125341
+ }).then(async (firstSyncReport) => {
125342
+ if (firstSyncReport) return;
125343
+ const report = await providerLoader.maybeSyncVerifiedChannelOnDaemonUpdate();
125344
+ if (!report) return;
125345
+ if (report.status === "error") {
125346
+ LOG2.warn("Init", `Daemon-update channel sync failed (last-known-good preserved, retries next boot): ${report.errors.map((e) => e.code).join(", ") || "unknown"}`);
125347
+ } else if (report.activated.length > 0) {
125348
+ LOG2.info("Init", `Daemon-update channel sync activated ${report.activated.length} providers (${providerLoader.channel})`);
125349
+ providerLoader.registerToDetector();
125350
+ await refreshProviderAvailability();
125351
+ config2.onStatusChange?.();
125352
+ }
125353
+ }).catch((e) => LOG2.warn("Init", `Verified channel boot sync error: ${e?.message || e}`));
125354
+ const runStalenessProbe = async () => {
125355
+ try {
125356
+ const snap = await providerLoader.checkVerifiedChannelStaleness();
125357
+ if (snap.error) {
125358
+ LOG2.debug("Provider", `Channel staleness probe failed (kept previous snapshot): ${snap.error}`);
125359
+ } else if (snap.staleTypes.length > 0 || snap.newTypes.length > 0) {
125360
+ LOG2.info("Provider", `Channel staleness: ${snap.staleTypes.length} stale [${snap.staleTypes.join(", ")}], ${snap.newTypes.length} never-installed [${snap.newTypes.join(", ")}] (${snap.channel})`);
125361
+ config2.onStatusChange?.();
125362
+ }
125363
+ } catch (e) {
125364
+ LOG2.debug("Provider", `Channel staleness probe error: ${e?.message || e}`);
125365
+ }
125366
+ };
125367
+ const stalenessInitialTimer = setTimeout(() => {
125368
+ void runStalenessProbe();
125369
+ }, 10 * 6e4);
125370
+ stalenessInitialTimer.unref?.();
125371
+ const stalenessIntervalTimer = setInterval(() => {
125372
+ void runStalenessProbe();
125373
+ }, 24 * 60 * 6e4);
125374
+ stalenessIntervalTimer.unref?.();
125375
+ const providerStalenessProbe = {
125376
+ stop() {
125377
+ clearTimeout(stalenessInitialTimer);
125378
+ clearInterval(stalenessIntervalTimer);
125379
+ }
125380
+ };
125207
125381
  setDefaultProviderLoader(providerLoader);
125208
125382
  const versionArchive = new VersionArchive();
125209
125383
  providerLoader.setVersionArchive(versionArchive);
@@ -125396,6 +125570,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
125396
125570
  components.meshReconcileLoop = setupMeshReconcileLoop(components);
125397
125571
  components.quotaRefreshLoop = setupQuotaRefreshLoop(components);
125398
125572
  components.quotaEventRefresh = setupQuotaEventRefresh(components);
125573
+ components.providerStalenessProbe = providerStalenessProbe;
125399
125574
  setImmediate(() => {
125400
125575
  const isQuotaProviderEnabled = quotaProviderEnabledFromLoader(components.providerLoader);
125401
125576
  try {
@@ -125433,7 +125608,8 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
125433
125608
  cdpManagers,
125434
125609
  meshReconcileLoop,
125435
125610
  quotaRefreshLoop,
125436
- quotaEventRefresh
125611
+ quotaEventRefresh,
125612
+ providerStalenessProbe
125437
125613
  } = components;
125438
125614
  poller.stop();
125439
125615
  cdpInitializer.stop();
@@ -125449,6 +125625,10 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
125449
125625
  quotaEventRefresh?.stop();
125450
125626
  } catch {
125451
125627
  }
125628
+ try {
125629
+ providerStalenessProbe?.stop();
125630
+ } catch {
125631
+ }
125452
125632
  try {
125453
125633
  if (agentStreamManager) {
125454
125634
  await agentStreamManager.dispose(cdpManagers);