@adhdev/daemon-core 0.9.82-rc.372 → 0.9.82-rc.373

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.mjs CHANGED
@@ -311,10 +311,10 @@ function readInjected(value) {
311
311
  }
312
312
  function getDaemonBuildInfo() {
313
313
  if (cached) return cached;
314
- const commit = readInjected(true ? "376a56400a2a60c210b7d8a2476b5d2a15604c7e" : void 0) ?? "unknown";
315
- const commitShort = readInjected(true ? "376a5640" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
316
- const version = readInjected(true ? "0.9.82-rc.372" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
317
- const builtAt = readInjected(true ? "2026-06-24T13:46:48.450Z" : void 0);
314
+ const commit = readInjected(true ? "f16b5e6cdf653b4258f8f44cb11fb6ad8c13329f" : void 0) ?? "unknown";
315
+ const commitShort = readInjected(true ? "f16b5e6c" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
316
+ const version = readInjected(true ? "0.9.82-rc.373" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
317
+ const builtAt = readInjected(true ? "2026-06-24T16:28:52.547Z" : void 0);
318
318
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
319
319
  return cached;
320
320
  }
@@ -34451,6 +34451,27 @@ function readByteBoundedTail(filePath, limitBytes) {
34451
34451
  fs13.closeSync(fd);
34452
34452
  }
34453
34453
  }
34454
+ function splitLogLines(text) {
34455
+ const lines = text.split("\n");
34456
+ if (lines.length && lines[lines.length - 1] === "") lines.pop();
34457
+ return lines;
34458
+ }
34459
+ function takeLastLinesWithinBytes(lines, limitBytes) {
34460
+ if (lines.length === 0) return { kept: [], truncated: false, bytesReturned: 0 };
34461
+ let total = 0;
34462
+ let firstKept = lines.length;
34463
+ for (let i = lines.length - 1; i >= 0; i--) {
34464
+ const lineBytes = Buffer.byteLength(lines[i], "utf-8") + 1;
34465
+ if (firstKept !== lines.length && total + lineBytes > limitBytes) break;
34466
+ total += lineBytes;
34467
+ firstKept = i;
34468
+ }
34469
+ return {
34470
+ kept: lines.slice(firstKept),
34471
+ truncated: firstKept > 0,
34472
+ bytesReturned: total
34473
+ };
34474
+ }
34454
34475
  function parseLineEpochMs(line, fileDate) {
34455
34476
  const m = line.match(/^\[(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?\]/);
34456
34477
  if (!m) {
@@ -34465,47 +34486,97 @@ function parseLineEpochMs(line, fileDate) {
34465
34486
  d.setHours(Number(m[1]), Number(m[2]), Number(m[3]), m[4] ? Number(m[4].padEnd(3, "0")) : 0);
34466
34487
  return d.getTime();
34467
34488
  }
34489
+ function buildGrepPredicate(grepSource) {
34490
+ let re = null;
34491
+ try {
34492
+ re = new RegExp(grepSource, "i");
34493
+ } catch {
34494
+ re = null;
34495
+ }
34496
+ if (re) {
34497
+ const compiled = re;
34498
+ return (line) => compiled.test(line);
34499
+ }
34500
+ const needle = grepSource.toLowerCase();
34501
+ return (line) => line.toLowerCase().includes(needle);
34502
+ }
34503
+ function fileDateFor(date) {
34504
+ if (date instanceof Date) return date;
34505
+ if (typeof date === "string" && date.trim()) return /* @__PURE__ */ new Date(`${date.trim()}T00:00:00.000Z`);
34506
+ return /* @__PURE__ */ new Date();
34507
+ }
34508
+ function errorResult(error, logPath, platform10) {
34509
+ return {
34510
+ success: false,
34511
+ error,
34512
+ lines: [],
34513
+ truncated: false,
34514
+ logPath,
34515
+ platform: platform10,
34516
+ bytesReturned: 0,
34517
+ filtered: false,
34518
+ fullScan: false,
34519
+ scannedBytes: 0,
34520
+ matchedLineCount: 0,
34521
+ excludedByFilter: 0
34522
+ };
34523
+ }
34468
34524
  function readDaemonLogTail(args = {}) {
34469
34525
  const platform10 = process.platform;
34470
34526
  const limitBytes = clampTailBytes(args.tailBytes);
34471
- let logPath = resolveLogPath(args.date);
34472
- if (!fs13.existsSync(logPath)) {
34473
- const backup = logPath.replace(/\.log$/, ".1.log");
34474
- if (fs13.existsSync(backup)) {
34475
- logPath = backup;
34476
- } else {
34477
- return {
34478
- success: false,
34479
- error: `No daemon log file at ${logPath} (dir: ${getDaemonLogDir()})`,
34480
- lines: [],
34481
- truncated: false,
34482
- logPath,
34483
- platform: platform10,
34484
- bytesReturned: 0,
34485
- filtered: false
34486
- };
34487
- }
34527
+ const primaryPath = resolveLogPath(args.date);
34528
+ const backupPath = primaryPath.replace(/\.log$/, ".1.log");
34529
+ const primaryExists = fs13.existsSync(primaryPath);
34530
+ const backupExists = fs13.existsSync(backupPath);
34531
+ if (!primaryExists && !backupExists) {
34532
+ return errorResult(
34533
+ `No daemon log file at ${primaryPath} (dir: ${getDaemonLogDir()})`,
34534
+ primaryPath,
34535
+ platform10
34536
+ );
34488
34537
  }
34489
- let raw;
34490
- try {
34491
- raw = readByteBoundedTail(logPath, limitBytes);
34492
- } catch (e) {
34538
+ const logPath = primaryExists ? primaryPath : backupPath;
34539
+ const hasGrep = typeof args.grep === "string" && args.grep.trim().length > 0;
34540
+ const hasSince = Number.isFinite(args.sinceMs);
34541
+ const filterMode = hasGrep || hasSince;
34542
+ if (!filterMode) {
34543
+ let raw;
34544
+ try {
34545
+ raw = readByteBoundedTail(logPath, limitBytes);
34546
+ } catch (e) {
34547
+ return errorResult(`Failed to read ${logPath}: ${e?.message ?? String(e)}`, logPath, platform10);
34548
+ }
34549
+ const lines2 = splitLogLines(raw.text);
34493
34550
  return {
34494
- success: false,
34495
- error: `Failed to read ${logPath}: ${e?.message ?? String(e)}`,
34496
- lines: [],
34497
- truncated: false,
34551
+ success: true,
34552
+ lines: lines2,
34553
+ truncated: raw.truncated,
34498
34554
  logPath,
34499
34555
  platform: platform10,
34500
- bytesReturned: 0,
34501
- filtered: false
34556
+ bytesReturned: raw.bytesReturned,
34557
+ filtered: false,
34558
+ fullScan: false,
34559
+ scannedBytes: raw.bytesReturned,
34560
+ matchedLineCount: lines2.length,
34561
+ excludedByFilter: 0
34502
34562
  };
34503
34563
  }
34504
- let lines = raw.text.split("\n");
34505
- if (lines.length && lines[lines.length - 1] === "") lines.pop();
34506
- const rawCount = lines.length;
34507
- if (Number.isFinite(args.sinceMs)) {
34508
- const fileDate = args.date instanceof Date ? args.date : typeof args.date === "string" && args.date.trim() ? /* @__PURE__ */ new Date(`${args.date.trim()}T00:00:00.000Z`) : /* @__PURE__ */ new Date();
34564
+ let scannedBytes = 0;
34565
+ let allLines = [];
34566
+ try {
34567
+ for (const p of [backupExists ? backupPath : null, primaryExists ? primaryPath : null]) {
34568
+ if (!p) continue;
34569
+ const buf = fs13.readFileSync(p);
34570
+ scannedBytes += buf.length;
34571
+ allLines = allLines.concat(splitLogLines(buf.toString("utf-8")));
34572
+ }
34573
+ } catch (e) {
34574
+ return errorResult(`Failed to read ${logPath}: ${e?.message ?? String(e)}`, logPath, platform10);
34575
+ }
34576
+ const scannedLineCount = allLines.length;
34577
+ let lines = allLines;
34578
+ if (hasSince) {
34579
+ const fileDate = fileDateFor(args.date);
34509
34580
  const floor = args.sinceMs;
34510
34581
  lines = lines.filter((line) => {
34511
34582
  const ts2 = parseLineEpochMs(line, fileDate);
@@ -34513,30 +34584,26 @@ function readDaemonLogTail(args = {}) {
34513
34584
  });
34514
34585
  }
34515
34586
  let appliedGrep;
34516
- if (typeof args.grep === "string" && args.grep.trim()) {
34587
+ if (hasGrep) {
34517
34588
  appliedGrep = args.grep.trim();
34518
- let re = null;
34519
- try {
34520
- re = new RegExp(appliedGrep, "i");
34521
- } catch {
34522
- re = null;
34523
- }
34524
- if (re) {
34525
- const compiled = re;
34526
- lines = lines.filter((line) => compiled.test(line));
34527
- } else {
34528
- const needle = appliedGrep.toLowerCase();
34529
- lines = lines.filter((line) => line.toLowerCase().includes(needle));
34530
- }
34589
+ const matches = buildGrepPredicate(appliedGrep);
34590
+ lines = lines.filter(matches);
34531
34591
  }
34592
+ const matchedLineCount = lines.length;
34593
+ const excludedByFilter = scannedLineCount - matchedLineCount;
34594
+ const capped = takeLastLinesWithinBytes(lines, limitBytes);
34532
34595
  return {
34533
34596
  success: true,
34534
- lines,
34535
- truncated: raw.truncated,
34597
+ lines: capped.kept,
34598
+ truncated: capped.truncated,
34536
34599
  logPath,
34537
34600
  platform: platform10,
34538
- bytesReturned: raw.bytesReturned,
34539
- filtered: lines.length !== rawCount,
34601
+ bytesReturned: capped.bytesReturned,
34602
+ filtered: excludedByFilter > 0,
34603
+ fullScan: true,
34604
+ scannedBytes,
34605
+ matchedLineCount,
34606
+ excludedByFilter,
34540
34607
  ...appliedGrep ? { grep: appliedGrep } : {}
34541
34608
  };
34542
34609
  }
@@ -34653,6 +34720,12 @@ var meshNodeLogsHandlers = {
34653
34720
  truncated: tail.truncated,
34654
34721
  filtered: tail.filtered,
34655
34722
  bytesReturned: tail.bytesReturned,
34723
+ // Transparency meta — lets the coordinator see that a full-file grep
34724
+ // ran past the recent tail window, and how much was scanned/excluded.
34725
+ fullScan: tail.fullScan,
34726
+ scannedBytes: tail.scannedBytes,
34727
+ matchedLineCount: tail.matchedLineCount,
34728
+ excludedByFilter: tail.excludedByFilter,
34656
34729
  ...tail.grep ? { grep: tail.grep } : {}
34657
34730
  };
34658
34731
  }
@@ -47778,7 +47851,7 @@ ${ptyResult.output.slice(-2e3)}`);
47778
47851
  workspace
47779
47852
  };
47780
47853
  }
47781
- const { existsSync: existsSync49, readFileSync: readFileSync39, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
47854
+ const { existsSync: existsSync49, readFileSync: readFileSync40, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
47782
47855
  const { dirname: dirname17 } = await import("path");
47783
47856
  const mcpConfigPath = coordinatorSetup.configPath;
47784
47857
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -47828,7 +47901,7 @@ ${ptyResult.output.slice(-2e3)}`);
47828
47901
  }
47829
47902
  if (hadExistingMcpConfig) {
47830
47903
  try {
47831
- const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync39(mcpConfigPath, "utf-8"), configFormat);
47904
+ const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync40(mcpConfigPath, "utf-8"), configFormat);
47832
47905
  const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
47833
47906
  existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
47834
47907
  copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
@@ -47956,7 +48029,7 @@ import { hostname as osHostname } from "os";
47956
48029
 
47957
48030
  // src/mesh/preview-freshness.ts
47958
48031
  import { execFileSync as execFileSync5 } from "child_process";
47959
- import { existsSync as existsSync39, readFileSync as readFileSync29 } from "fs";
48032
+ import { existsSync as existsSync39, readFileSync as readFileSync30 } from "fs";
47960
48033
  import { resolve as resolve19 } from "path";
47961
48034
  var PREVIEW_DEPLOY_RECORD = ".adhdev/preview-deploy.json";
47962
48035
  function runGit2(repoRoot, args) {
@@ -47975,7 +48048,7 @@ function readRecord5(repoRoot) {
47975
48048
  const path42 = resolve19(repoRoot, PREVIEW_DEPLOY_RECORD);
47976
48049
  if (!existsSync39(path42)) return null;
47977
48050
  try {
47978
- const parsed = JSON.parse(readFileSync29(path42, "utf8"));
48051
+ const parsed = JSON.parse(readFileSync30(path42, "utf8"));
47979
48052
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
47980
48053
  } catch {
47981
48054
  return null;
@@ -49548,6 +49621,23 @@ function buildMeshNodeDataFreshness(args) {
49548
49621
  staleness
49549
49622
  };
49550
49623
  }
49624
+ function buildMeshNodeProbeFreshness(args) {
49625
+ const { git, liveTruthProbed, isSelfNode, daemonId, node, now } = args;
49626
+ const status = {
49627
+ git,
49628
+ connection: { state: liveTruthProbed ? "connected" : "disconnected" }
49629
+ };
49630
+ if (liveTruthProbed) status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
49631
+ return buildMeshNodeDataFreshness({
49632
+ status,
49633
+ node,
49634
+ isSelfNode,
49635
+ daemonId,
49636
+ liveTruthProbed,
49637
+ directTruthUnavailable: !liveTruthProbed && !!daemonId,
49638
+ now
49639
+ });
49640
+ }
49551
49641
  function finalizeMeshNodeStatus(args) {
49552
49642
  const { status, node, daemonId, isSelfNode, directTruthUnavailable } = args;
49553
49643
  if (!readStringValue(status.machineStatus)) {
@@ -61525,11 +61615,11 @@ init_parse_session();
61525
61615
 
61526
61616
  // src/providers/sdk/v1/fixture-tooling/replay.ts
61527
61617
  init_provider_cli_shared();
61528
- import { readFileSync as readFileSync37 } from "fs";
61618
+ import { readFileSync as readFileSync38 } from "fs";
61529
61619
  import { dirname as dirname15, resolve as resolve22 } from "path";
61530
61620
 
61531
61621
  // src/providers/sdk/v1/validators/taint.ts
61532
- import { readFileSync as readFileSync38, existsSync as existsSync48 } from "fs";
61622
+ import { readFileSync as readFileSync39, existsSync as existsSync48 } from "fs";
61533
61623
  import { resolve as resolve23, dirname as dirname16, join as join47 } from "path";
61534
61624
 
61535
61625
  // src/providers/sdk/v1/validators/index.ts
@@ -61707,6 +61797,7 @@ export {
61707
61797
  buildMeshLedgerReplicaEvidence,
61708
61798
  buildMeshNodeCapabilityTags,
61709
61799
  buildMeshNodeDataFreshness,
61800
+ buildMeshNodeProbeFreshness,
61710
61801
  buildMissionPromptSection,
61711
61802
  buildP2pRelayFailurePayload,
61712
61803
  buildPinnedGlobalInstallCommand,