adhdev 0.9.82-rc.21 → 0.9.82-rc.23

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
@@ -45582,6 +45582,96 @@ function buildCachedInlineMeshGitStatus(node) {
45582
45582
  ...submodules ? { submodules } : {}
45583
45583
  };
45584
45584
  }
45585
+ function shouldDiscardCachedInlineMeshStatus(node) {
45586
+ const cachedStatus = readObjectRecord(node?.cachedStatus);
45587
+ if (!Object.keys(cachedStatus).length) return false;
45588
+ const cachedGit = readObjectRecord(cachedStatus.git);
45589
+ const workspaceError = readStringValue(cachedStatus.error, node?.error);
45590
+ if (workspaceError && /workspace must be an existing directory/i.test(workspaceError)) return true;
45591
+ const isGitRepo = readBooleanValue(cachedGit.isGitRepo);
45592
+ const branch = readStringValue(cachedGit.branch);
45593
+ const headCommit = readStringValue(cachedGit.headCommit);
45594
+ return isGitRepo === false && !branch && !headCommit;
45595
+ }
45596
+ function stripInlineMeshTransientNodeState(node) {
45597
+ if (!node || typeof node !== "object" || Array.isArray(node)) return node;
45598
+ const {
45599
+ cachedStatus,
45600
+ lastGit: _lastGit,
45601
+ last_git: _lastGitLegacy,
45602
+ lastProbe: _lastProbe,
45603
+ last_probe: _lastProbeLegacy,
45604
+ error: _error,
45605
+ health: _health,
45606
+ machineStatus: _machineStatus,
45607
+ lastSeenAt: _lastSeenAt,
45608
+ last_seen_at: _lastSeenAtLegacy,
45609
+ updatedAt: _updatedAt,
45610
+ updated_at: _updatedAtLegacy,
45611
+ activeSession: _activeSession,
45612
+ active_session: _activeSessionLegacy,
45613
+ activeSessionId: _activeSessionId,
45614
+ active_session_id: _activeSessionIdLegacy,
45615
+ sessionId: _sessionId,
45616
+ session_id: _sessionIdLegacy,
45617
+ providerType: _providerType,
45618
+ provider_type: _providerTypeLegacy,
45619
+ providers: _providers,
45620
+ ...rest
45621
+ } = node;
45622
+ if (cachedStatus && !shouldDiscardCachedInlineMeshStatus(node)) {
45623
+ return { ...rest, cachedStatus };
45624
+ }
45625
+ return rest;
45626
+ }
45627
+ function hasInlineMeshTransientNodeState(node) {
45628
+ if (!node || typeof node !== "object" || Array.isArray(node)) return false;
45629
+ return "cachedStatus" in node || "lastGit" in node || "last_git" in node || "lastProbe" in node || "last_probe" in node || "error" in node || "health" in node || "machineStatus" in node || "lastSeenAt" in node || "last_seen_at" in node || "updatedAt" in node || "updated_at" in node || "activeSession" in node || "active_session" in node || "activeSessionId" in node || "active_session_id" in node || "sessionId" in node || "session_id" in node || "providerType" in node || "provider_type" in node || "providers" in node;
45630
+ }
45631
+ function readInlineMeshNodeId(node) {
45632
+ return readStringValue(node?.id, node?.nodeId) || "";
45633
+ }
45634
+ function sanitizeInlineMesh(inlineMesh) {
45635
+ if (!inlineMesh || typeof inlineMesh !== "object" || Array.isArray(inlineMesh)) return inlineMesh;
45636
+ if (!Array.isArray(inlineMesh.nodes)) return inlineMesh;
45637
+ let changed = false;
45638
+ const nodes = inlineMesh.nodes.map((node) => {
45639
+ if (!hasInlineMeshTransientNodeState(node)) return node;
45640
+ changed = true;
45641
+ return stripInlineMeshTransientNodeState(node);
45642
+ });
45643
+ if (!changed) return inlineMesh;
45644
+ return {
45645
+ ...inlineMesh,
45646
+ nodes
45647
+ };
45648
+ }
45649
+ function reconcileInlineMeshCache(cached2, incoming) {
45650
+ if (!cached2 || typeof cached2 !== "object" || Array.isArray(cached2)) return incoming;
45651
+ if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) return cached2;
45652
+ const cachedNodes = Array.isArray(cached2.nodes) ? cached2.nodes : [];
45653
+ const incomingNodes = Array.isArray(incoming.nodes) ? incoming.nodes : [];
45654
+ if (!cachedNodes.length || !incomingNodes.length) return { ...cached2, ...incoming };
45655
+ const incomingById = /* @__PURE__ */ new Map();
45656
+ for (const node of incomingNodes) {
45657
+ const nodeId = readInlineMeshNodeId(node);
45658
+ if (nodeId) incomingById.set(nodeId, node);
45659
+ }
45660
+ const nodes = cachedNodes.map((cachedNode) => {
45661
+ const nodeId = readInlineMeshNodeId(cachedNode);
45662
+ const incomingNode = nodeId ? incomingById.get(nodeId) : void 0;
45663
+ if (!incomingNode) return cachedNode;
45664
+ if (hasInlineMeshTransientNodeState(incomingNode)) {
45665
+ return { ...cachedNode, ...incomingNode };
45666
+ }
45667
+ return { ...stripInlineMeshTransientNodeState(cachedNode), ...incomingNode };
45668
+ });
45669
+ return {
45670
+ ...cached2,
45671
+ ...incoming,
45672
+ nodes
45673
+ };
45674
+ }
45585
45675
  function hasGitWorktreeChanges(git) {
45586
45676
  if (!git) return false;
45587
45677
  return Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
@@ -45676,8 +45766,21 @@ function summarizeMeshSessionRecord(record2) {
45676
45766
  isCached: false
45677
45767
  };
45678
45768
  }
45769
+ function liveSessionRecordMatchesMeshNode(record2, meshId, nodeId) {
45770
+ const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
45771
+ if (!recordNodeId || recordNodeId !== nodeId) return false;
45772
+ const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
45773
+ return !recordMeshId || recordMeshId === meshId;
45774
+ }
45775
+ function liveSessionRecordMatchesMeshWorkspace(record2, meshId, workspace) {
45776
+ const recordWorkspace = readStringValue(record2?.workspace);
45777
+ if (!recordWorkspace || !workspace || recordWorkspace !== workspace) return false;
45778
+ const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
45779
+ if (recordMeshId) return recordMeshId === meshId;
45780
+ return record2?.meta?.launchedByCoordinator === true || !!readStringValue(record2?.meta?.meshNodeId);
45781
+ }
45679
45782
  function readLiveMeshNodeWorkspace(args) {
45680
- const directNodeWorkspace = args.liveSessionRecords.find((record2) => readStringValue(record2?.meta?.meshNodeId) === args.nodeId && readStringValue(record2?.workspace));
45783
+ const directNodeWorkspace = args.liveSessionRecords.find((record2) => liveSessionRecordMatchesMeshNode(record2, args.meshId, args.nodeId) && readStringValue(record2?.workspace));
45681
45784
  if (directNodeWorkspace) {
45682
45785
  return readStringValue(directNodeWorkspace.workspace) || "";
45683
45786
  }
@@ -45691,10 +45794,9 @@ function readLiveMeshNodeWorkspace(args) {
45691
45794
  }
45692
45795
  function collectLiveMeshSessionRecords(args) {
45693
45796
  const matches = args.liveSessionRecords.filter((record2) => {
45694
- if (readStringValue(record2?.meta?.meshNodeId) === args.nodeId) return true;
45695
- const recordWorkspace = readStringValue(record2?.workspace);
45696
45797
  const nodeWorkspace = readStringValue(args.node?.workspace);
45697
- return !!recordWorkspace && !!nodeWorkspace && recordWorkspace === nodeWorkspace;
45798
+ if (liveSessionRecordMatchesMeshNode(record2, args.meshId, args.nodeId)) return true;
45799
+ return !!nodeWorkspace && liveSessionRecordMatchesMeshWorkspace(record2, args.meshId, nodeWorkspace);
45698
45800
  });
45699
45801
  if (args.allowCoordinatorSession) {
45700
45802
  for (const record2 of args.liveSessionRecords) {
@@ -46173,10 +46275,15 @@ var init_router = __esm({
46173
46275
  }
46174
46276
  warmInlineMeshCache(meshId, inlineMesh) {
46175
46277
  if (!inlineMesh || typeof inlineMesh !== "object") return void 0;
46278
+ const sanitizedInlineMesh = sanitizeInlineMesh(inlineMesh);
46176
46279
  const cached2 = this.inlineMeshCache.get(meshId);
46177
- if (cached2) return cached2;
46178
- this.inlineMeshCache.set(meshId, inlineMesh);
46179
- return inlineMesh;
46280
+ if (cached2) {
46281
+ const merged = reconcileInlineMeshCache(cached2, sanitizedInlineMesh);
46282
+ this.inlineMeshCache.set(meshId, merged);
46283
+ return merged;
46284
+ }
46285
+ this.inlineMeshCache.set(meshId, sanitizedInlineMesh);
46286
+ return sanitizedInlineMesh;
46180
46287
  }
46181
46288
  async getMeshForCommand(meshId, inlineMesh, options) {
46182
46289
  const preferInline = options?.preferInline === true;
@@ -48119,10 +48226,17 @@ ${block}`);
48119
48226
  }
48120
48227
  }
48121
48228
  if (workspace) {
48122
- if (!fs10.existsSync(workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
48123
- status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48124
- nodeStatuses.push(status);
48125
- continue;
48229
+ if (!fs10.existsSync(workspace)) {
48230
+ if (applyCachedInlineMeshNodeStatus(status, node)) {
48231
+ status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48232
+ nodeStatuses.push(status);
48233
+ continue;
48234
+ }
48235
+ if (meshRecord?.source === "inline_cache" && !isSelfNode) {
48236
+ status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48237
+ nodeStatuses.push(status);
48238
+ continue;
48239
+ }
48126
48240
  }
48127
48241
  try {
48128
48242
  const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
@@ -66999,7 +67113,7 @@ var init_adhdev_daemon = __esm({
66999
67113
  init_version();
67000
67114
  init_src();
67001
67115
  init_runtime_defaults();
67002
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.21" });
67116
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.23" });
67003
67117
  AdhdevDaemon = class _AdhdevDaemon {
67004
67118
  localHttpServer = null;
67005
67119
  localWss = null;