@adhdev/daemon-core 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
@@ -16920,6 +16920,7 @@ function buildCliMessageSourceProvenance(args) {
16920
16920
  }
16921
16921
  function buildNativeHistoryFallbackReason(args) {
16922
16922
  if (!supportsCliNativeTranscript(args.providerType, args.provider)) return "provider_native_transcript_not_supported";
16923
+ if (args.unavailableReason) return `native_history_unavailable:${args.unavailableReason}`;
16923
16924
  if (args.nativeSource === "native-unavailable") return "native_history_unavailable";
16924
16925
  if (args.nativeHistoryCoverage === "partial") return "native_history_partial";
16925
16926
  if (args.nativeHistoryCoverage === "unavailable") return "native_history_unavailable";
@@ -16994,6 +16995,15 @@ function hasSafeNativeHistoryMapping(args) {
16994
16995
  return hasOverlappingVisibleConversationText(args.nativeMessages, args.ptyMessages || []);
16995
16996
  }
16996
16997
  function readCliProviderNativeHistory(agentStr, args) {
16998
+ if (!args.historySessionId) {
16999
+ return {
17000
+ messages: [],
17001
+ hasMore: false,
17002
+ source: "native-unavailable",
17003
+ unavailableReason: "native_history_workspace_only_lookup_unsafe",
17004
+ lookup: "session"
17005
+ };
17006
+ }
16997
17007
  const sessionHistory = readProviderChatHistory(agentStr, {
16998
17008
  canonicalHistory: args.canonicalHistory,
16999
17009
  historySessionId: args.historySessionId,
@@ -17004,20 +17014,7 @@ function readCliProviderNativeHistory(agentStr, args) {
17004
17014
  historyBehavior: args.historyBehavior,
17005
17015
  scripts: args.scripts
17006
17016
  });
17007
- if (sessionHistory.source !== "native-unavailable" || args.exactSessionScoped || !args.historySessionId || !args.workspace) {
17008
- return { ...sessionHistory, lookup: args.historySessionId ? "session" : "workspace" };
17009
- }
17010
- const workspaceHistory = readProviderChatHistory(agentStr, {
17011
- canonicalHistory: args.canonicalHistory,
17012
- historySessionId: void 0,
17013
- workspace: args.workspace,
17014
- offset: args.offset,
17015
- limit: args.limit,
17016
- excludeRecentCount: args.excludeRecentCount,
17017
- historyBehavior: args.historyBehavior,
17018
- scripts: args.scripts
17019
- });
17020
- return { ...workspaceHistory, lookup: "workspace" };
17017
+ return { ...sessionHistory, lookup: "session" };
17021
17018
  }
17022
17019
  function isNativeHistoryFreshEnough(args) {
17023
17020
  const nativeNewest = getMessageNewestReceivedAt(args.nativeMessages);
@@ -17760,6 +17757,7 @@ async function handleReadChat(h, args) {
17760
17757
  provider,
17761
17758
  nativeSource: nativeHistory.source,
17762
17759
  nativeHistoryCoverage,
17760
+ unavailableReason,
17763
17761
  nativeMessageCount: nativeMessages.length,
17764
17762
  safeMapping,
17765
17763
  freshEnough
@@ -17859,6 +17857,7 @@ async function handleReadChat(h, args) {
17859
17857
  provider,
17860
17858
  nativeSource: history.source,
17861
17859
  nativeHistoryCoverage,
17860
+ unavailableReason,
17862
17861
  nativeMessageCount: historyMessages.length,
17863
17862
  safeMapping,
17864
17863
  freshEnough: true
@@ -27975,9 +27974,12 @@ function summarizeMeshSessionRecord(record) {
27975
27974
  isCached: false
27976
27975
  };
27977
27976
  }
27978
- function liveSessionRecordMatchesMeshNode(record, meshId, nodeId) {
27977
+ function liveSessionRecordMatchesMeshNode(record, meshId, nodeId, nodeWorkspace = "", nodeIsMissingLocalWorktree = false) {
27979
27978
  const recordNodeId = readStringValue(record?.meta?.meshNodeId);
27980
27979
  if (!recordNodeId || recordNodeId !== nodeId) return false;
27980
+ if (nodeIsMissingLocalWorktree) return false;
27981
+ const recordWorkspace = readStringValue(record?.workspace);
27982
+ if (nodeWorkspace && recordWorkspace && recordWorkspace !== nodeWorkspace) return false;
27981
27983
  const recordMeshId = readStringValue(record?.meta?.meshNodeFor);
27982
27984
  return !recordMeshId || recordMeshId === meshId;
27983
27985
  }
@@ -28002,9 +28004,13 @@ function readLiveMeshNodeWorkspace(args) {
28002
28004
  return "";
28003
28005
  }
28004
28006
  function collectLiveMeshSessionRecords(args) {
28007
+ const nodeWorkspace = readStringValue(args.node?.workspace);
28008
+ const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs11.existsSync(nodeWorkspace);
28005
28009
  const matches = args.liveSessionRecords.filter((record) => {
28006
- const nodeWorkspace = readStringValue(args.node?.workspace);
28007
- if (liveSessionRecordMatchesMeshNode(record, args.meshId, args.nodeId)) return true;
28010
+ const recordNodeId = readStringValue(record?.meta?.meshNodeId);
28011
+ if (recordNodeId && recordNodeId !== args.nodeId) return false;
28012
+ if (liveSessionRecordMatchesMeshNode(record, args.meshId, args.nodeId, nodeWorkspace || "", nodeIsMissingLocalWorktree)) return true;
28013
+ if (nodeIsMissingLocalWorktree) return false;
28008
28014
  return !!nodeWorkspace && liveSessionRecordMatchesMeshWorkspace(record, args.meshId, nodeWorkspace);
28009
28015
  });
28010
28016
  if (args.allowCoordinatorSession) {
@@ -28020,11 +28026,15 @@ function collectLiveMeshSessionRecords(args) {
28020
28026
  function buildHistoricalMeshSessions(args) {
28021
28027
  const liveNodeIds = /* @__PURE__ */ new Set();
28022
28028
  const liveWorkspaces = /* @__PURE__ */ new Set();
28029
+ const missingLocalWorktreeNodeIds = /* @__PURE__ */ new Set();
28023
28030
  for (const node of args.nodes || []) {
28024
28031
  const nodeId = readStringValue(node?.id, node?.nodeId);
28025
28032
  const workspace = readStringValue(node?.workspace);
28026
28033
  if (nodeId) liveNodeIds.add(nodeId);
28027
28034
  if (workspace) liveWorkspaces.add(workspace);
28035
+ if (nodeId && node?.isLocalWorktree === true && workspace && !fs11.existsSync(workspace)) {
28036
+ missingLocalWorktreeNodeIds.add(nodeId);
28037
+ }
28028
28038
  }
28029
28039
  const sessions = [];
28030
28040
  for (const record of args.liveSessionRecords || []) {
@@ -28033,7 +28043,7 @@ function buildHistoricalMeshSessions(args) {
28033
28043
  if (recordMeshId !== args.meshId) continue;
28034
28044
  const recordNodeId = readStringValue(meta.meshNodeId);
28035
28045
  const workspace = readStringValue(record?.workspace);
28036
- const removedNode = !!recordNodeId && !liveNodeIds.has(recordNodeId);
28046
+ const removedNode = !!recordNodeId && (!liveNodeIds.has(recordNodeId) || missingLocalWorktreeNodeIds.has(recordNodeId));
28037
28047
  const orphanedWorkspace = !!workspace && !liveWorkspaces.has(workspace) && meta.meshCoordinatorFor !== args.meshId;
28038
28048
  if (!removedNode && !orphanedWorkspace) continue;
28039
28049
  sessions.push({
@@ -31787,12 +31797,18 @@ ${block2}`);
31787
31797
  for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
31788
31798
  const nodeId = String(node.id || node.nodeId || "");
31789
31799
  const daemonId = readStringValue(node.daemonId);
31800
+ const nodeMachineId = readMeshNodeMachineId(node);
31801
+ const nodeHostname = readMeshNodeHostname(node);
31790
31802
  const providerPriority = readProviderPriorityFromPolicy(node.policy);
31803
+ const configuredCoordinatorNode = Boolean(
31804
+ nodeId && selectedCoordinatorNodeId && nodeId === selectedCoordinatorNodeId
31805
+ );
31806
+ const sparseConfiguredCoordinatorNode = configuredCoordinatorNode && !daemonId && !nodeMachineId && !nodeHostname;
31791
31807
  const isSelfNode = Boolean(
31792
31808
  nodeId && inlineCoordinatorNodeId && nodeId === inlineCoordinatorNodeId
31793
31809
  ) || Boolean(
31794
31810
  daemonId && (daemonId === localMachineId || daemonId === this.deps.statusInstanceId)
31795
- ) || Boolean(meshRecord?.inline && nodeIndex === 0);
31811
+ ) || Boolean(meshRecord?.inline && nodeIndex === 0) || sparseConfiguredCoordinatorNode;
31796
31812
  const machineIdentity = buildMeshNodeMachineIdentity(node, {
31797
31813
  localMachineId,
31798
31814
  localDaemonId: this.deps.statusInstanceId,
@@ -31809,7 +31825,7 @@ ${block2}`);
31809
31825
  worktreeBranch: node.worktreeBranch,
31810
31826
  role: normalizeMeshDaemonRole(node.role) || (meshHost.hostNodeId && nodeId === meshHost.hostNodeId ? "host" : void 0),
31811
31827
  daemonId,
31812
- machineId: readMeshNodeMachineId(node) || node.machineId,
31828
+ machineId: nodeMachineId || node.machineId,
31813
31829
  machine: machineIdentity,
31814
31830
  machineStatus: node.machineStatus,
31815
31831
  health: "unknown",