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/cli/index.js CHANGED
@@ -46664,6 +46664,36 @@ function summarizeMeshSessionRecord(record2) {
46664
46664
  isCached: false
46665
46665
  };
46666
46666
  }
46667
+ function readLiveMeshNodeWorkspace(args) {
46668
+ const directNodeWorkspace = args.liveSessionRecords.find((record2) => readStringValue(record2?.meta?.meshNodeId) === args.nodeId && readStringValue(record2?.workspace));
46669
+ if (directNodeWorkspace) {
46670
+ return readStringValue(directNodeWorkspace.workspace) || "";
46671
+ }
46672
+ if (args.allowCoordinatorSession) {
46673
+ const coordinatorWorkspace = args.liveSessionRecords.find((record2) => readStringValue(record2?.meta?.meshCoordinatorFor) === args.meshId && readStringValue(record2?.workspace));
46674
+ if (coordinatorWorkspace) {
46675
+ return readStringValue(coordinatorWorkspace.workspace) || "";
46676
+ }
46677
+ }
46678
+ return "";
46679
+ }
46680
+ function collectLiveMeshSessionRecords(args) {
46681
+ const matches = args.liveSessionRecords.filter((record2) => {
46682
+ if (readStringValue(record2?.meta?.meshNodeId) === args.nodeId) return true;
46683
+ const recordWorkspace = readStringValue(record2?.workspace);
46684
+ const nodeWorkspace = readStringValue(args.node?.workspace);
46685
+ return !!recordWorkspace && !!nodeWorkspace && recordWorkspace === nodeWorkspace;
46686
+ });
46687
+ if (args.allowCoordinatorSession) {
46688
+ for (const record2 of args.liveSessionRecords) {
46689
+ if (readStringValue(record2?.meta?.meshCoordinatorFor) !== args.meshId) continue;
46690
+ const sessionId = readStringValue(record2?.sessionId);
46691
+ if (sessionId && matches.some((entry) => readStringValue(entry?.sessionId) === sessionId)) continue;
46692
+ matches.push(record2);
46693
+ }
46694
+ }
46695
+ return matches;
46696
+ }
46667
46697
  function applyCachedInlineMeshNodeStatus(status, node) {
46668
46698
  const cachedStatus = readObjectRecord(node?.cachedStatus);
46669
46699
  const git = buildCachedInlineMeshGitStatus(node);
@@ -48653,7 +48683,14 @@ var init_router = __esm({
48653
48683
  cliType
48654
48684
  };
48655
48685
  }
48656
- const workspace = typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "";
48686
+ const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
48687
+ const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
48688
+ const workspace = readLiveMeshNodeWorkspace({
48689
+ meshId,
48690
+ nodeId: String(coordinatorNode.id || coordinatorNode.nodeId || preferredCoordinatorNodeId || ""),
48691
+ liveSessionRecords: liveMeshSessions,
48692
+ allowCoordinatorSession: true
48693
+ }) || (typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "");
48657
48694
  if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
48658
48695
  if (!cliType) {
48659
48696
  const resolved = await resolveProviderTypeFromPriority({
@@ -48964,7 +49001,12 @@ ${block}`);
48964
49001
  const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
48965
49002
  const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
48966
49003
  const localMachineId = loadConfig().machineId || "";
48967
- const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? readStringValue(mesh.nodes[0]?.id, mesh.nodes[0]?.nodeId) : void 0;
49004
+ const selectedCoordinatorNodeId = readStringValue(
49005
+ mesh.coordinator?.preferredNodeId,
49006
+ mesh.nodes?.[0]?.id,
49007
+ mesh.nodes?.[0]?.nodeId
49008
+ );
49009
+ const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? selectedCoordinatorNodeId : void 0;
48968
49010
  const refreshedAt = (/* @__PURE__ */ new Date()).toISOString();
48969
49011
  const nodeStatuses = [];
48970
49012
  for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
@@ -49023,7 +49065,20 @@ ${block}`);
49023
49065
  reason: "Node has no daemon id, so mesh transport cannot be reported from the selected coordinator."
49024
49066
  };
49025
49067
  }
49026
- const matchedLiveSessionRecords = liveMeshSessions.filter((record2) => this.sessionMatchesMeshNode(record2, node, nodeId));
49068
+ const matchedLiveSessionRecords = collectLiveMeshSessionRecords({
49069
+ meshId,
49070
+ node,
49071
+ nodeId,
49072
+ liveSessionRecords: liveMeshSessions,
49073
+ allowCoordinatorSession: nodeId === selectedCoordinatorNodeId
49074
+ });
49075
+ const workspace = readLiveMeshNodeWorkspace({
49076
+ meshId,
49077
+ nodeId,
49078
+ liveSessionRecords: matchedLiveSessionRecords,
49079
+ allowCoordinatorSession: nodeId === selectedCoordinatorNodeId
49080
+ }) || (typeof node.workspace === "string" ? node.workspace : "");
49081
+ status.workspace = workspace || node.workspace;
49027
49082
  if (matchedLiveSessionRecords.length > 0) {
49028
49083
  const sessionIds = matchedLiveSessionRecords.map((record2) => typeof record2?.sessionId === "string" ? record2.sessionId : "").filter(Boolean);
49029
49084
  const providerTypes = matchedLiveSessionRecords.map((record2) => readStringValue(record2?.providerType)).filter(Boolean);
@@ -49033,14 +49088,14 @@ ${block}`);
49033
49088
  status.providers = Array.from(/* @__PURE__ */ new Set([...Array.isArray(status.providers) ? status.providers : [], ...providerTypes]));
49034
49089
  }
49035
49090
  }
49036
- if (node.workspace && typeof node.workspace === "string") {
49037
- if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
49091
+ if (workspace) {
49092
+ if (!fs10.existsSync(workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
49038
49093
  status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
49039
49094
  nodeStatuses.push(status);
49040
49095
  continue;
49041
49096
  }
49042
49097
  try {
49043
- const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4, refreshUpstream: true });
49098
+ const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
49044
49099
  status.git = gitStatus;
49045
49100
  if (gitStatus.isGitRepo) {
49046
49101
  status.health = deriveMeshNodeHealthFromGit(gitStatus);
@@ -98094,7 +98149,7 @@ var init_adhdev_daemon = __esm({
98094
98149
  init_version();
98095
98150
  init_src();
98096
98151
  init_runtime_defaults();
98097
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.16" });
98152
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.18" });
98098
98153
  AdhdevDaemon = class _AdhdevDaemon {
98099
98154
  localHttpServer = null;
98100
98155
  localWss = null;