@adhdev/daemon-standalone 0.9.82-rc.316 → 0.9.82-rc.317

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
@@ -30075,10 +30075,10 @@ var require_dist3 = __commonJS({
30075
30075
  }
30076
30076
  function getDaemonBuildInfo() {
30077
30077
  if (cached2) return cached2;
30078
- const commit = readInjected(true ? "930909642b3f28668483159d3a8f39d0a796c61a" : void 0) ?? "unknown";
30079
- const commitShort = readInjected(true ? "93090964" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30080
- const version2 = readInjected(true ? "0.9.82-rc.316" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30081
- const builtAt = readInjected(true ? "2026-06-18T07:23:33.672Z" : void 0);
30078
+ const commit = readInjected(true ? "b4484284652748bf8096f40a00eb5cb463963576" : void 0) ?? "unknown";
30079
+ const commitShort = readInjected(true ? "b4484284" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30080
+ const version2 = readInjected(true ? "0.9.82-rc.317" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30081
+ const builtAt = readInjected(true ? "2026-06-18T08:56:20.224Z" : void 0);
30082
30082
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30083
30083
  return cached2;
30084
30084
  }
@@ -30402,14 +30402,79 @@ var require_dist3 = __commonJS({
30402
30402
  async function getSubmoduleStatuses(repo, options) {
30403
30403
  if (!repo.repoRoot) return [];
30404
30404
  try {
30405
- const result = await runGit(repo, ["submodule", "status"], options);
30406
- const submodules = parseSubmoduleStatusOutput(result.stdout, repo.repoRoot, options.submoduleIgnorePaths);
30405
+ const submodules = await deriveSubmoduleGitlinkStatuses(repo, options);
30407
30406
  await Promise.all(submodules.map((submodule) => enrichSubmoduleWorktreeStatus(repo, submodule, options)));
30408
30407
  return submodules;
30409
30408
  } catch {
30410
30409
  return [];
30411
30410
  }
30412
30411
  }
30412
+ async function deriveSubmoduleGitlinkStatuses(repo, options) {
30413
+ if (!repo.repoRoot) return [];
30414
+ const paths = await readSubmodulePaths(repo, options);
30415
+ const ignoreSet = new Set(options.submoduleIgnorePaths || []);
30416
+ const lastCheckedAt = Date.now();
30417
+ const entries = await Promise.all(
30418
+ paths.filter((path41) => !ignoreSet.has(path41)).map(async (path41) => {
30419
+ const repoPath = repo.repoRoot + "/" + path41;
30420
+ const expected = await readGitlinkExpectedSha(repo, path41, options);
30421
+ const actual = await readSubmoduleHeadSha(repo, repoPath, options);
30422
+ const outOfSync = actual === null ? true : expected !== null && expected !== actual;
30423
+ return {
30424
+ path: path41,
30425
+ // Prefer the recorded gitlink SHA (matches the legacy column); fall back
30426
+ // to the checked-out SHA so the field is never empty when both are known.
30427
+ commit: expected ?? actual ?? "",
30428
+ repoPath,
30429
+ dirty: false,
30430
+ outOfSync,
30431
+ lastCheckedAt
30432
+ };
30433
+ })
30434
+ );
30435
+ return entries;
30436
+ }
30437
+ async function readSubmodulePaths(repo, options) {
30438
+ if (!repo.repoRoot) return [];
30439
+ const gitmodulesPath = repo.repoRoot + "/.gitmodules";
30440
+ try {
30441
+ const result = await runGit(
30442
+ repo,
30443
+ ["config", "--file", gitmodulesPath, "--get-regexp", "^submodule\\..*\\.path$"],
30444
+ options
30445
+ );
30446
+ const paths = [];
30447
+ for (const line of result.stdout.split("\n")) {
30448
+ const spaceIdx = line.indexOf(" ");
30449
+ if (spaceIdx < 0) continue;
30450
+ const value = line.slice(spaceIdx + 1).trim();
30451
+ if (value) paths.push(value);
30452
+ }
30453
+ return paths;
30454
+ } catch {
30455
+ return [];
30456
+ }
30457
+ }
30458
+ async function readGitlinkExpectedSha(repo, submodulePath, options) {
30459
+ try {
30460
+ const result = await runGit(repo, ["ls-tree", "HEAD", submodulePath], options);
30461
+ const line = result.stdout.split("\n").find((l) => l.trim().length > 0);
30462
+ if (!line) return null;
30463
+ const match = line.match(/^\s*\d+\s+commit\s+([0-9a-f]{40})\b/);
30464
+ return match ? match[1] : null;
30465
+ } catch {
30466
+ return null;
30467
+ }
30468
+ }
30469
+ async function readSubmoduleHeadSha(repo, repoPath, options) {
30470
+ try {
30471
+ const result = await runGit(repo, ["rev-parse", "HEAD"], { ...options, cwd: repoPath });
30472
+ const sha = result.stdout.trim();
30473
+ return /^[0-9a-f]{40}$/.test(sha) ? sha : null;
30474
+ } catch {
30475
+ return null;
30476
+ }
30477
+ }
30413
30478
  async function enrichSubmoduleWorktreeStatus(repo, submodule, options) {
30414
30479
  try {
30415
30480
  const result = await runGit(repo, ["status", "--porcelain=v2", "--branch"], {
@@ -30424,28 +30489,6 @@ var require_dist3 = __commonJS({
30424
30489
  submodule.error = formatGitError(error48);
30425
30490
  }
30426
30491
  }
30427
- function parseSubmoduleStatusOutput(output, repoRoot, ignorePaths) {
30428
- const submodules = [];
30429
- const ignoreSet = new Set(ignorePaths || []);
30430
- for (const line of output.split("\n")) {
30431
- if (!line.trim()) continue;
30432
- const match = line.match(/^([\-+U\s])([0-9a-f]{40})\s+(\S+)(?:\s+\(([^)]+)\))?/);
30433
- if (!match) continue;
30434
- const prefix = match[1];
30435
- const commit = match[2];
30436
- const path41 = match[3];
30437
- if (ignoreSet.has(path41)) continue;
30438
- submodules.push({
30439
- path: path41,
30440
- commit,
30441
- repoPath: repoRoot + "/" + path41,
30442
- dirty: prefix === "U",
30443
- outOfSync: prefix === "-" || prefix === "+",
30444
- lastCheckedAt: Date.now()
30445
- });
30446
- }
30447
- return submodules;
30448
- }
30449
30492
  var lastKnownGoodStatus;
30450
30493
  var DAEMON_RUNTIME_PACKAGES;
30451
30494
  var WEB_ONLY_PACKAGES;
@@ -33713,6 +33756,18 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
33713
33756
  `).get(meshId, nodeId);
33714
33757
  return row?.count ?? 0;
33715
33758
  }
33759
+ /**
33760
+ * O(1) count of queue tasks in 'pending' status for a mesh. A COUNT(*) over the
33761
+ * indexed status column, so it avoids JSON.parse-ing every queue row — used as a
33762
+ * cheap guard before the reconcile loop runs a full triggerMeshQueue scan.
33763
+ */
33764
+ pendingQueueTaskCount(meshId) {
33765
+ const row = this.db.prepare(`
33766
+ SELECT COUNT(*) as count FROM mesh_queue
33767
+ WHERE mesh_id = ? AND status = 'pending'
33768
+ `).get(meshId);
33769
+ return row?.count ?? 0;
33770
+ }
33716
33771
  /**
33717
33772
  * Read the current per-mesh round-robin cursor (0 when unset). Used to rotate
33718
33773
  * the tie-break winner among nodes tied at the least load.
@@ -38660,7 +38715,7 @@ Next step: ${nextStep}`;
38660
38715
  }
38661
38716
  const remoteCandidates = [];
38662
38717
  for (const idle of remoteSessions) {
38663
- const node = mesh.nodes.find((n) => n.id === idle.nodeId);
38718
+ const node = mesh.nodes.find((n) => meshNodeIdMatches(n, idle.nodeId));
38664
38719
  if (node) {
38665
38720
  remoteIdleSessionsChecked += 1;
38666
38721
  remoteCandidates.push({ nodeId: idle.nodeId, sessionId: idle.sessionId, providerType: idle.providerType, origin: "remote", node });
@@ -39475,6 +39530,21 @@ Next step: ${nextStep}`;
39475
39530
  }
39476
39531
  }
39477
39532
  }
39533
+ for (const mesh of listMeshes()) {
39534
+ const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
39535
+ if (!daemonHostsMesh(mesh, selfIds)) continue;
39536
+ if (store) {
39537
+ try {
39538
+ if (store.pendingQueueTaskCount(mesh.id) === 0) continue;
39539
+ } catch {
39540
+ }
39541
+ }
39542
+ try {
39543
+ await triggerMeshQueue(components, mesh.id);
39544
+ } catch (e) {
39545
+ LOG2.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
39546
+ }
39547
+ }
39478
39548
  const coordinators = findLiveCoordinators(components);
39479
39549
  if (coordinators.length === 0) {
39480
39550
  return;
@@ -72844,7 +72914,15 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72844
72914
  function readMeshConnectionState(connection) {
72845
72915
  return readStringValue(connection?.state);
72846
72916
  }
72917
+ function isMeshConnectionDefinitivelyDown(connection) {
72918
+ if (!connection) return true;
72919
+ const state = readMeshConnectionState(connection);
72920
+ return state === "failed" || state === "closed" || state === "disconnected";
72921
+ }
72847
72922
  async function probeRemoteMeshGitStatusWithRetry(args) {
72923
+ if (args.getConnection && isMeshConnectionDefinitivelyDown(args.getConnection(args.daemonId))) {
72924
+ return null;
72925
+ }
72848
72926
  for (let attempt = 0; attempt <= MESH_DIRECT_PROBE_MAX_RETRIES; attempt += 1) {
72849
72927
  if (attempt > 0) {
72850
72928
  const connection = args.getConnection?.(args.daemonId);