adhdev 0.9.82-rc.16 → 0.9.82-rc.18

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
@@ -45676,6 +45676,36 @@ function summarizeMeshSessionRecord(record2) {
45676
45676
  isCached: false
45677
45677
  };
45678
45678
  }
45679
+ function readLiveMeshNodeWorkspace(args) {
45680
+ const directNodeWorkspace = args.liveSessionRecords.find((record2) => readStringValue(record2?.meta?.meshNodeId) === args.nodeId && readStringValue(record2?.workspace));
45681
+ if (directNodeWorkspace) {
45682
+ return readStringValue(directNodeWorkspace.workspace) || "";
45683
+ }
45684
+ if (args.allowCoordinatorSession) {
45685
+ const coordinatorWorkspace = args.liveSessionRecords.find((record2) => readStringValue(record2?.meta?.meshCoordinatorFor) === args.meshId && readStringValue(record2?.workspace));
45686
+ if (coordinatorWorkspace) {
45687
+ return readStringValue(coordinatorWorkspace.workspace) || "";
45688
+ }
45689
+ }
45690
+ return "";
45691
+ }
45692
+ function collectLiveMeshSessionRecords(args) {
45693
+ const matches = args.liveSessionRecords.filter((record2) => {
45694
+ if (readStringValue(record2?.meta?.meshNodeId) === args.nodeId) return true;
45695
+ const recordWorkspace = readStringValue(record2?.workspace);
45696
+ const nodeWorkspace = readStringValue(args.node?.workspace);
45697
+ return !!recordWorkspace && !!nodeWorkspace && recordWorkspace === nodeWorkspace;
45698
+ });
45699
+ if (args.allowCoordinatorSession) {
45700
+ for (const record2 of args.liveSessionRecords) {
45701
+ if (readStringValue(record2?.meta?.meshCoordinatorFor) !== args.meshId) continue;
45702
+ const sessionId = readStringValue(record2?.sessionId);
45703
+ if (sessionId && matches.some((entry) => readStringValue(entry?.sessionId) === sessionId)) continue;
45704
+ matches.push(record2);
45705
+ }
45706
+ }
45707
+ return matches;
45708
+ }
45679
45709
  function applyCachedInlineMeshNodeStatus(status, node) {
45680
45710
  const cachedStatus = readObjectRecord(node?.cachedStatus);
45681
45711
  const git = buildCachedInlineMeshGitStatus(node);
@@ -47665,7 +47695,14 @@ var init_router = __esm({
47665
47695
  cliType
47666
47696
  };
47667
47697
  }
47668
- const workspace = typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "";
47698
+ const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
47699
+ const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
47700
+ const workspace = readLiveMeshNodeWorkspace({
47701
+ meshId,
47702
+ nodeId: String(coordinatorNode.id || coordinatorNode.nodeId || preferredCoordinatorNodeId || ""),
47703
+ liveSessionRecords: liveMeshSessions,
47704
+ allowCoordinatorSession: true
47705
+ }) || (typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "");
47669
47706
  if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
47670
47707
  if (!cliType) {
47671
47708
  const resolved = await resolveProviderTypeFromPriority({
@@ -47976,7 +48013,12 @@ ${block}`);
47976
48013
  const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
47977
48014
  const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
47978
48015
  const localMachineId = loadConfig().machineId || "";
47979
- const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? readStringValue(mesh.nodes[0]?.id, mesh.nodes[0]?.nodeId) : void 0;
48016
+ const selectedCoordinatorNodeId = readStringValue(
48017
+ mesh.coordinator?.preferredNodeId,
48018
+ mesh.nodes?.[0]?.id,
48019
+ mesh.nodes?.[0]?.nodeId
48020
+ );
48021
+ const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? selectedCoordinatorNodeId : void 0;
47980
48022
  const refreshedAt = (/* @__PURE__ */ new Date()).toISOString();
47981
48023
  const nodeStatuses = [];
47982
48024
  for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
@@ -48035,7 +48077,20 @@ ${block}`);
48035
48077
  reason: "Node has no daemon id, so mesh transport cannot be reported from the selected coordinator."
48036
48078
  };
48037
48079
  }
48038
- const matchedLiveSessionRecords = liveMeshSessions.filter((record2) => this.sessionMatchesMeshNode(record2, node, nodeId));
48080
+ const matchedLiveSessionRecords = collectLiveMeshSessionRecords({
48081
+ meshId,
48082
+ node,
48083
+ nodeId,
48084
+ liveSessionRecords: liveMeshSessions,
48085
+ allowCoordinatorSession: nodeId === selectedCoordinatorNodeId
48086
+ });
48087
+ const workspace = readLiveMeshNodeWorkspace({
48088
+ meshId,
48089
+ nodeId,
48090
+ liveSessionRecords: matchedLiveSessionRecords,
48091
+ allowCoordinatorSession: nodeId === selectedCoordinatorNodeId
48092
+ }) || (typeof node.workspace === "string" ? node.workspace : "");
48093
+ status.workspace = workspace || node.workspace;
48039
48094
  if (matchedLiveSessionRecords.length > 0) {
48040
48095
  const sessionIds = matchedLiveSessionRecords.map((record2) => typeof record2?.sessionId === "string" ? record2.sessionId : "").filter(Boolean);
48041
48096
  const providerTypes = matchedLiveSessionRecords.map((record2) => readStringValue(record2?.providerType)).filter(Boolean);
@@ -48045,14 +48100,14 @@ ${block}`);
48045
48100
  status.providers = Array.from(/* @__PURE__ */ new Set([...Array.isArray(status.providers) ? status.providers : [], ...providerTypes]));
48046
48101
  }
48047
48102
  }
48048
- if (node.workspace && typeof node.workspace === "string") {
48049
- if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
48103
+ if (workspace) {
48104
+ if (!fs10.existsSync(workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
48050
48105
  status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48051
48106
  nodeStatuses.push(status);
48052
48107
  continue;
48053
48108
  }
48054
48109
  try {
48055
- const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4, refreshUpstream: true });
48110
+ const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
48056
48111
  status.git = gitStatus;
48057
48112
  if (gitStatus.isGitRepo) {
48058
48113
  status.health = deriveMeshNodeHealthFromGit(gitStatus);
@@ -66921,7 +66976,7 @@ var init_adhdev_daemon = __esm({
66921
66976
  init_version();
66922
66977
  init_src();
66923
66978
  init_runtime_defaults();
66924
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.16" });
66979
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.18" });
66925
66980
  AdhdevDaemon = class _AdhdevDaemon {
66926
66981
  localHttpServer = null;
66927
66982
  localWss = null;