adhdev 0.9.82-rc.6 → 0.9.82-rc.7

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/cli/index.js CHANGED
@@ -46493,26 +46493,57 @@ function buildCachedInlineMeshGitStatus(node) {
46493
46493
  ...submodules ? { submodules } : {}
46494
46494
  };
46495
46495
  }
46496
+ function hasGitWorktreeChanges(git) {
46497
+ if (!git) return false;
46498
+ return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
46499
+ }
46500
+ function getGitSubmoduleDriftState(git) {
46501
+ const submodules = Array.isArray(git?.submodules) ? git.submodules : [];
46502
+ let dirty = false;
46503
+ let outOfSync = false;
46504
+ for (const entry of submodules) {
46505
+ const submodule = readObjectRecord(entry);
46506
+ if (readBooleanValue(submodule.dirty) === true) dirty = true;
46507
+ if (readBooleanValue(submodule.outOfSync) === true || !!readStringValue(submodule.error)) outOfSync = true;
46508
+ }
46509
+ return { dirty, outOfSync };
46510
+ }
46511
+ function deriveMeshNodeHealthFromGit(git) {
46512
+ if (!git || readBooleanValue(git.isGitRepo) === false) return "degraded";
46513
+ const branch = readStringValue(git.branch);
46514
+ if (!branch) return "degraded";
46515
+ const submoduleDrift = getGitSubmoduleDriftState(git);
46516
+ if (submoduleDrift.outOfSync) return "degraded";
46517
+ if (submoduleDrift.dirty || hasGitWorktreeChanges(git)) return "dirty";
46518
+ return "online";
46519
+ }
46520
+ function readCachedInlineMeshActiveSessions(node) {
46521
+ const cachedStatus = readObjectRecord(node?.cachedStatus);
46522
+ const activeSession = readObjectRecord(cachedStatus.activeSession);
46523
+ const fallbackSession = Object.keys(activeSession).length ? activeSession : readObjectRecord(node?.activeSession ?? node?.active_session);
46524
+ const sessionId = readStringValue(fallbackSession.id, fallbackSession.sessionId, fallbackSession.session_id, node?.activeSessionId, node?.active_session_id, node?.sessionId, node?.session_id);
46525
+ return sessionId ? [sessionId] : [];
46526
+ }
46496
46527
  function applyCachedInlineMeshNodeStatus(status, node) {
46497
46528
  const cachedStatus = readObjectRecord(node?.cachedStatus);
46498
46529
  const git = buildCachedInlineMeshGitStatus(node);
46499
46530
  const error48 = readStringValue(cachedStatus.error, node?.error);
46500
46531
  const health = readStringValue(cachedStatus.health, node?.health);
46501
46532
  const machineStatus = readStringValue(cachedStatus.machineStatus, node?.machineStatus);
46502
- if (!git && !error48 && !health) return false;
46503
- if (!machineStatus && !git && !error48) return false;
46533
+ const activeSessions = readCachedInlineMeshActiveSessions(node);
46534
+ if (!git && !error48 && !health && !machineStatus && activeSessions.length === 0) return false;
46504
46535
  if (git) status.git = git;
46505
46536
  if (error48) status.error = error48;
46537
+ if (activeSessions.length > 0) status.activeSessions = activeSessions;
46506
46538
  if (health) {
46507
46539
  status.health = health;
46508
46540
  return true;
46509
46541
  }
46510
46542
  if (git) {
46511
- const dirty = Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
46512
- status.health = git.isGitRepo === false ? "degraded" : dirty ? "dirty" : "online";
46543
+ status.health = deriveMeshNodeHealthFromGit(git);
46513
46544
  return true;
46514
46545
  }
46515
- return false;
46546
+ return activeSessions.length > 0 || !!machineStatus;
46516
46547
  }
46517
46548
  async function resolveProviderTypeFromPriority(args) {
46518
46549
  if (!args.providerPriority.length) {
@@ -48789,6 +48820,8 @@ ${block}`);
48789
48820
  const { readLedgerEntries: readLedgerEntries2, getLedgerSummary: getLedgerSummary2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
48790
48821
  const ledgerEntries = readLedgerEntries2(meshId, { tail: 20 });
48791
48822
  const ledgerSummary = getLedgerSummary2(meshId);
48823
+ const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
48824
+ const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
48792
48825
  const nodeStatuses = [];
48793
48826
  for (const node of mesh.nodes || []) {
48794
48827
  const status = {
@@ -48804,6 +48837,11 @@ ${block}`);
48804
48837
  providers: node.providers || [],
48805
48838
  activeSessions: []
48806
48839
  };
48840
+ const nodeId = String(node.id || node.nodeId || "");
48841
+ const matchedLiveSessions = liveMeshSessions.filter((record2) => this.sessionMatchesMeshNode(record2, node, nodeId)).map((record2) => typeof record2?.sessionId === "string" ? record2.sessionId : "").filter(Boolean);
48842
+ if (matchedLiveSessions.length > 0) {
48843
+ status.activeSessions = matchedLiveSessions;
48844
+ }
48807
48845
  if (node.workspace && typeof node.workspace === "string") {
48808
48846
  if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
48809
48847
  nodeStatuses.push(status);
@@ -48813,8 +48851,7 @@ ${block}`);
48813
48851
  const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4 });
48814
48852
  status.git = gitStatus;
48815
48853
  if (gitStatus.isGitRepo) {
48816
- const dirty = gitStatus.staged + gitStatus.modified + gitStatus.untracked + gitStatus.deleted + gitStatus.renamed > 0;
48817
- status.health = gitStatus.branch ? dirty ? "dirty" : "online" : "degraded";
48854
+ status.health = deriveMeshNodeHealthFromGit(gitStatus);
48818
48855
  } else {
48819
48856
  status.health = "degraded";
48820
48857
  if (gitStatus.error && !status.error) status.error = gitStatus.error;
@@ -97794,7 +97831,7 @@ var init_adhdev_daemon = __esm({
97794
97831
  init_version();
97795
97832
  init_src();
97796
97833
  init_runtime_defaults();
97797
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.6" });
97834
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.7" });
97798
97835
  AdhdevDaemon = class _AdhdevDaemon {
97799
97836
  localHttpServer = null;
97800
97837
  localWss = null;