@adhdev/daemon-standalone 0.9.82-rc.117 → 0.9.82-rc.118

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
@@ -38946,6 +38946,7 @@ ${effect.notification.body || ""}`.trim();
38946
38946
  }
38947
38947
  function buildNativeHistoryFallbackReason(args) {
38948
38948
  if (!supportsCliNativeTranscript(args.providerType, args.provider)) return "provider_native_transcript_not_supported";
38949
+ if (args.unavailableReason) return `native_history_unavailable:${args.unavailableReason}`;
38949
38950
  if (args.nativeSource === "native-unavailable") return "native_history_unavailable";
38950
38951
  if (args.nativeHistoryCoverage === "partial") return "native_history_partial";
38951
38952
  if (args.nativeHistoryCoverage === "unavailable") return "native_history_unavailable";
@@ -39020,6 +39021,15 @@ ${effect.notification.body || ""}`.trim();
39020
39021
  return hasOverlappingVisibleConversationText(args.nativeMessages, args.ptyMessages || []);
39021
39022
  }
39022
39023
  function readCliProviderNativeHistory(agentStr, args) {
39024
+ if (!args.historySessionId) {
39025
+ return {
39026
+ messages: [],
39027
+ hasMore: false,
39028
+ source: "native-unavailable",
39029
+ unavailableReason: "native_history_workspace_only_lookup_unsafe",
39030
+ lookup: "session"
39031
+ };
39032
+ }
39023
39033
  const sessionHistory = readProviderChatHistory(agentStr, {
39024
39034
  canonicalHistory: args.canonicalHistory,
39025
39035
  historySessionId: args.historySessionId,
@@ -39030,20 +39040,7 @@ ${effect.notification.body || ""}`.trim();
39030
39040
  historyBehavior: args.historyBehavior,
39031
39041
  scripts: args.scripts
39032
39042
  });
39033
- if (sessionHistory.source !== "native-unavailable" || args.exactSessionScoped || !args.historySessionId || !args.workspace) {
39034
- return { ...sessionHistory, lookup: args.historySessionId ? "session" : "workspace" };
39035
- }
39036
- const workspaceHistory = readProviderChatHistory(agentStr, {
39037
- canonicalHistory: args.canonicalHistory,
39038
- historySessionId: void 0,
39039
- workspace: args.workspace,
39040
- offset: args.offset,
39041
- limit: args.limit,
39042
- excludeRecentCount: args.excludeRecentCount,
39043
- historyBehavior: args.historyBehavior,
39044
- scripts: args.scripts
39045
- });
39046
- return { ...workspaceHistory, lookup: "workspace" };
39043
+ return { ...sessionHistory, lookup: "session" };
39047
39044
  }
39048
39045
  function isNativeHistoryFreshEnough(args) {
39049
39046
  const nativeNewest = getMessageNewestReceivedAt(args.nativeMessages);
@@ -39786,6 +39783,7 @@ ${effect.notification.body || ""}`.trim();
39786
39783
  provider,
39787
39784
  nativeSource: nativeHistory.source,
39788
39785
  nativeHistoryCoverage,
39786
+ unavailableReason,
39789
39787
  nativeMessageCount: nativeMessages.length,
39790
39788
  safeMapping,
39791
39789
  freshEnough
@@ -39885,6 +39883,7 @@ ${effect.notification.body || ""}`.trim();
39885
39883
  provider,
39886
39884
  nativeSource: history.source,
39887
39885
  nativeHistoryCoverage,
39886
+ unavailableReason,
39888
39887
  nativeMessageCount: historyMessages.length,
39889
39888
  safeMapping,
39890
39889
  freshEnough: true
@@ -49941,9 +49940,12 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49941
49940
  isCached: false
49942
49941
  };
49943
49942
  }
49944
- function liveSessionRecordMatchesMeshNode(record2, meshId, nodeId) {
49943
+ function liveSessionRecordMatchesMeshNode(record2, meshId, nodeId, nodeWorkspace = "", nodeIsMissingLocalWorktree = false) {
49945
49944
  const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
49946
49945
  if (!recordNodeId || recordNodeId !== nodeId) return false;
49946
+ if (nodeIsMissingLocalWorktree) return false;
49947
+ const recordWorkspace = readStringValue(record2?.workspace);
49948
+ if (nodeWorkspace && recordWorkspace && recordWorkspace !== nodeWorkspace) return false;
49947
49949
  const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
49948
49950
  return !recordMeshId || recordMeshId === meshId;
49949
49951
  }
@@ -49968,9 +49970,13 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49968
49970
  return "";
49969
49971
  }
49970
49972
  function collectLiveMeshSessionRecords(args) {
49973
+ const nodeWorkspace = readStringValue(args.node?.workspace);
49974
+ const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs11.existsSync(nodeWorkspace);
49971
49975
  const matches = args.liveSessionRecords.filter((record2) => {
49972
- const nodeWorkspace = readStringValue(args.node?.workspace);
49973
- if (liveSessionRecordMatchesMeshNode(record2, args.meshId, args.nodeId)) return true;
49976
+ const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
49977
+ if (recordNodeId && recordNodeId !== args.nodeId) return false;
49978
+ if (liveSessionRecordMatchesMeshNode(record2, args.meshId, args.nodeId, nodeWorkspace || "", nodeIsMissingLocalWorktree)) return true;
49979
+ if (nodeIsMissingLocalWorktree) return false;
49974
49980
  return !!nodeWorkspace && liveSessionRecordMatchesMeshWorkspace(record2, args.meshId, nodeWorkspace);
49975
49981
  });
49976
49982
  if (args.allowCoordinatorSession) {
@@ -49986,11 +49992,15 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49986
49992
  function buildHistoricalMeshSessions(args) {
49987
49993
  const liveNodeIds = /* @__PURE__ */ new Set();
49988
49994
  const liveWorkspaces = /* @__PURE__ */ new Set();
49995
+ const missingLocalWorktreeNodeIds = /* @__PURE__ */ new Set();
49989
49996
  for (const node of args.nodes || []) {
49990
49997
  const nodeId = readStringValue(node?.id, node?.nodeId);
49991
49998
  const workspace = readStringValue(node?.workspace);
49992
49999
  if (nodeId) liveNodeIds.add(nodeId);
49993
50000
  if (workspace) liveWorkspaces.add(workspace);
50001
+ if (nodeId && node?.isLocalWorktree === true && workspace && !fs11.existsSync(workspace)) {
50002
+ missingLocalWorktreeNodeIds.add(nodeId);
50003
+ }
49994
50004
  }
49995
50005
  const sessions = [];
49996
50006
  for (const record2 of args.liveSessionRecords || []) {
@@ -49999,7 +50009,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
49999
50009
  if (recordMeshId !== args.meshId) continue;
50000
50010
  const recordNodeId = readStringValue(meta3.meshNodeId);
50001
50011
  const workspace = readStringValue(record2?.workspace);
50002
- const removedNode = !!recordNodeId && !liveNodeIds.has(recordNodeId);
50012
+ const removedNode = !!recordNodeId && (!liveNodeIds.has(recordNodeId) || missingLocalWorktreeNodeIds.has(recordNodeId));
50003
50013
  const orphanedWorkspace = !!workspace && !liveWorkspaces.has(workspace) && meta3.meshCoordinatorFor !== args.meshId;
50004
50014
  if (!removedNode && !orphanedWorkspace) continue;
50005
50015
  sessions.push({
@@ -53753,12 +53763,18 @@ ${block2}`);
53753
53763
  for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
53754
53764
  const nodeId = String(node.id || node.nodeId || "");
53755
53765
  const daemonId = readStringValue(node.daemonId);
53766
+ const nodeMachineId = readMeshNodeMachineId(node);
53767
+ const nodeHostname = readMeshNodeHostname(node);
53756
53768
  const providerPriority = readProviderPriorityFromPolicy(node.policy);
53769
+ const configuredCoordinatorNode = Boolean(
53770
+ nodeId && selectedCoordinatorNodeId && nodeId === selectedCoordinatorNodeId
53771
+ );
53772
+ const sparseConfiguredCoordinatorNode = configuredCoordinatorNode && !daemonId && !nodeMachineId && !nodeHostname;
53757
53773
  const isSelfNode = Boolean(
53758
53774
  nodeId && inlineCoordinatorNodeId && nodeId === inlineCoordinatorNodeId
53759
53775
  ) || Boolean(
53760
53776
  daemonId && (daemonId === localMachineId || daemonId === this.deps.statusInstanceId)
53761
- ) || Boolean(meshRecord?.inline && nodeIndex === 0);
53777
+ ) || Boolean(meshRecord?.inline && nodeIndex === 0) || sparseConfiguredCoordinatorNode;
53762
53778
  const machineIdentity = buildMeshNodeMachineIdentity(node, {
53763
53779
  localMachineId,
53764
53780
  localDaemonId: this.deps.statusInstanceId,
@@ -53775,7 +53791,7 @@ ${block2}`);
53775
53791
  worktreeBranch: node.worktreeBranch,
53776
53792
  role: normalizeMeshDaemonRole(node.role) || (meshHost.hostNodeId && nodeId === meshHost.hostNodeId ? "host" : void 0),
53777
53793
  daemonId,
53778
- machineId: readMeshNodeMachineId(node) || node.machineId,
53794
+ machineId: nodeMachineId || node.machineId,
53779
53795
  machine: machineIdentity,
53780
53796
  machineStatus: node.machineStatus,
53781
53797
  health: "unknown",