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/index.js CHANGED
@@ -45505,26 +45505,57 @@ function buildCachedInlineMeshGitStatus(node) {
45505
45505
  ...submodules ? { submodules } : {}
45506
45506
  };
45507
45507
  }
45508
+ function hasGitWorktreeChanges(git) {
45509
+ if (!git) return false;
45510
+ return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
45511
+ }
45512
+ function getGitSubmoduleDriftState(git) {
45513
+ const submodules = Array.isArray(git?.submodules) ? git.submodules : [];
45514
+ let dirty = false;
45515
+ let outOfSync = false;
45516
+ for (const entry of submodules) {
45517
+ const submodule = readObjectRecord(entry);
45518
+ if (readBooleanValue(submodule.dirty) === true) dirty = true;
45519
+ if (readBooleanValue(submodule.outOfSync) === true || !!readStringValue(submodule.error)) outOfSync = true;
45520
+ }
45521
+ return { dirty, outOfSync };
45522
+ }
45523
+ function deriveMeshNodeHealthFromGit(git) {
45524
+ if (!git || readBooleanValue(git.isGitRepo) === false) return "degraded";
45525
+ const branch = readStringValue(git.branch);
45526
+ if (!branch) return "degraded";
45527
+ const submoduleDrift = getGitSubmoduleDriftState(git);
45528
+ if (submoduleDrift.outOfSync) return "degraded";
45529
+ if (submoduleDrift.dirty || hasGitWorktreeChanges(git)) return "dirty";
45530
+ return "online";
45531
+ }
45532
+ function readCachedInlineMeshActiveSessions(node) {
45533
+ const cachedStatus = readObjectRecord(node?.cachedStatus);
45534
+ const activeSession = readObjectRecord(cachedStatus.activeSession);
45535
+ const fallbackSession = Object.keys(activeSession).length ? activeSession : readObjectRecord(node?.activeSession ?? node?.active_session);
45536
+ const sessionId = readStringValue(fallbackSession.id, fallbackSession.sessionId, fallbackSession.session_id, node?.activeSessionId, node?.active_session_id, node?.sessionId, node?.session_id);
45537
+ return sessionId ? [sessionId] : [];
45538
+ }
45508
45539
  function applyCachedInlineMeshNodeStatus(status, node) {
45509
45540
  const cachedStatus = readObjectRecord(node?.cachedStatus);
45510
45541
  const git = buildCachedInlineMeshGitStatus(node);
45511
45542
  const error48 = readStringValue(cachedStatus.error, node?.error);
45512
45543
  const health = readStringValue(cachedStatus.health, node?.health);
45513
45544
  const machineStatus = readStringValue(cachedStatus.machineStatus, node?.machineStatus);
45514
- if (!git && !error48 && !health) return false;
45515
- if (!machineStatus && !git && !error48) return false;
45545
+ const activeSessions = readCachedInlineMeshActiveSessions(node);
45546
+ if (!git && !error48 && !health && !machineStatus && activeSessions.length === 0) return false;
45516
45547
  if (git) status.git = git;
45517
45548
  if (error48) status.error = error48;
45549
+ if (activeSessions.length > 0) status.activeSessions = activeSessions;
45518
45550
  if (health) {
45519
45551
  status.health = health;
45520
45552
  return true;
45521
45553
  }
45522
45554
  if (git) {
45523
- const dirty = Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
45524
- status.health = git.isGitRepo === false ? "degraded" : dirty ? "dirty" : "online";
45555
+ status.health = deriveMeshNodeHealthFromGit(git);
45525
45556
  return true;
45526
45557
  }
45527
- return false;
45558
+ return activeSessions.length > 0 || !!machineStatus;
45528
45559
  }
45529
45560
  async function resolveProviderTypeFromPriority(args) {
45530
45561
  if (!args.providerPriority.length) {
@@ -47801,6 +47832,8 @@ ${block}`);
47801
47832
  const { readLedgerEntries: readLedgerEntries2, getLedgerSummary: getLedgerSummary2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
47802
47833
  const ledgerEntries = readLedgerEntries2(meshId, { tail: 20 });
47803
47834
  const ledgerSummary = getLedgerSummary2(meshId);
47835
+ const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
47836
+ const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
47804
47837
  const nodeStatuses = [];
47805
47838
  for (const node of mesh.nodes || []) {
47806
47839
  const status = {
@@ -47816,6 +47849,11 @@ ${block}`);
47816
47849
  providers: node.providers || [],
47817
47850
  activeSessions: []
47818
47851
  };
47852
+ const nodeId = String(node.id || node.nodeId || "");
47853
+ const matchedLiveSessions = liveMeshSessions.filter((record2) => this.sessionMatchesMeshNode(record2, node, nodeId)).map((record2) => typeof record2?.sessionId === "string" ? record2.sessionId : "").filter(Boolean);
47854
+ if (matchedLiveSessions.length > 0) {
47855
+ status.activeSessions = matchedLiveSessions;
47856
+ }
47819
47857
  if (node.workspace && typeof node.workspace === "string") {
47820
47858
  if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
47821
47859
  nodeStatuses.push(status);
@@ -47825,8 +47863,7 @@ ${block}`);
47825
47863
  const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4 });
47826
47864
  status.git = gitStatus;
47827
47865
  if (gitStatus.isGitRepo) {
47828
- const dirty = gitStatus.staged + gitStatus.modified + gitStatus.untracked + gitStatus.deleted + gitStatus.renamed > 0;
47829
- status.health = gitStatus.branch ? dirty ? "dirty" : "online" : "degraded";
47866
+ status.health = deriveMeshNodeHealthFromGit(gitStatus);
47830
47867
  } else {
47831
47868
  status.health = "degraded";
47832
47869
  if (gitStatus.error && !status.error) status.error = gitStatus.error;
@@ -66621,7 +66658,7 @@ var init_adhdev_daemon = __esm({
66621
66658
  init_version();
66622
66659
  init_src();
66623
66660
  init_runtime_defaults();
66624
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.6" });
66661
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.7" });
66625
66662
  AdhdevDaemon = class _AdhdevDaemon {
66626
66663
  localHttpServer = null;
66627
66664
  localWss = null;