@adhdev/daemon-core 0.9.82-rc.117 → 0.9.82-rc.119
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 +41 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +40 -30
- package/src/commands/router.ts +29 -6
package/dist/index.mjs
CHANGED
|
@@ -16654,6 +16654,7 @@ function buildCliMessageSourceProvenance(args) {
|
|
|
16654
16654
|
}
|
|
16655
16655
|
function buildNativeHistoryFallbackReason(args) {
|
|
16656
16656
|
if (!supportsCliNativeTranscript(args.providerType, args.provider)) return "provider_native_transcript_not_supported";
|
|
16657
|
+
if (args.unavailableReason) return `native_history_unavailable:${args.unavailableReason}`;
|
|
16657
16658
|
if (args.nativeSource === "native-unavailable") return "native_history_unavailable";
|
|
16658
16659
|
if (args.nativeHistoryCoverage === "partial") return "native_history_partial";
|
|
16659
16660
|
if (args.nativeHistoryCoverage === "unavailable") return "native_history_unavailable";
|
|
@@ -16706,10 +16707,9 @@ function hasSafeNativeHistoryMapping(args) {
|
|
|
16706
16707
|
const text = typeof m?.content === "string" ? m.content : JSON.stringify(m?.content || "");
|
|
16707
16708
|
return text.includes("mesh_send_task") || text.includes("mesh_status") || text.includes("mesh_read_chat");
|
|
16708
16709
|
});
|
|
16709
|
-
|
|
16710
|
-
return false;
|
|
16711
|
-
}
|
|
16710
|
+
return ptyHasCoordinator;
|
|
16712
16711
|
}
|
|
16712
|
+
return false;
|
|
16713
16713
|
}
|
|
16714
16714
|
const workspace = String(args.workspace || "").trim();
|
|
16715
16715
|
if (!workspace) return false;
|
|
@@ -16728,6 +16728,15 @@ function hasSafeNativeHistoryMapping(args) {
|
|
|
16728
16728
|
return hasOverlappingVisibleConversationText(args.nativeMessages, args.ptyMessages || []);
|
|
16729
16729
|
}
|
|
16730
16730
|
function readCliProviderNativeHistory(agentStr, args) {
|
|
16731
|
+
if (!args.historySessionId) {
|
|
16732
|
+
return {
|
|
16733
|
+
messages: [],
|
|
16734
|
+
hasMore: false,
|
|
16735
|
+
source: "native-unavailable",
|
|
16736
|
+
unavailableReason: "native_history_workspace_only_lookup_unsafe",
|
|
16737
|
+
lookup: "session"
|
|
16738
|
+
};
|
|
16739
|
+
}
|
|
16731
16740
|
const sessionHistory = readProviderChatHistory(agentStr, {
|
|
16732
16741
|
canonicalHistory: args.canonicalHistory,
|
|
16733
16742
|
historySessionId: args.historySessionId,
|
|
@@ -16738,20 +16747,7 @@ function readCliProviderNativeHistory(agentStr, args) {
|
|
|
16738
16747
|
historyBehavior: args.historyBehavior,
|
|
16739
16748
|
scripts: args.scripts
|
|
16740
16749
|
});
|
|
16741
|
-
|
|
16742
|
-
return { ...sessionHistory, lookup: args.historySessionId ? "session" : "workspace" };
|
|
16743
|
-
}
|
|
16744
|
-
const workspaceHistory = readProviderChatHistory(agentStr, {
|
|
16745
|
-
canonicalHistory: args.canonicalHistory,
|
|
16746
|
-
historySessionId: void 0,
|
|
16747
|
-
workspace: args.workspace,
|
|
16748
|
-
offset: args.offset,
|
|
16749
|
-
limit: args.limit,
|
|
16750
|
-
excludeRecentCount: args.excludeRecentCount,
|
|
16751
|
-
historyBehavior: args.historyBehavior,
|
|
16752
|
-
scripts: args.scripts
|
|
16753
|
-
});
|
|
16754
|
-
return { ...workspaceHistory, lookup: "workspace" };
|
|
16750
|
+
return { ...sessionHistory, lookup: "session" };
|
|
16755
16751
|
}
|
|
16756
16752
|
function isNativeHistoryFreshEnough(args) {
|
|
16757
16753
|
const nativeNewest = getMessageNewestReceivedAt(args.nativeMessages);
|
|
@@ -17322,8 +17318,7 @@ async function handleChatHistory(h, args) {
|
|
|
17322
17318
|
limit: limit || 30,
|
|
17323
17319
|
excludeRecentCount,
|
|
17324
17320
|
historyBehavior: provider?.historyBehavior,
|
|
17325
|
-
scripts: provider?.scripts
|
|
17326
|
-
exactSessionScoped: exactNativeHistoryScope
|
|
17321
|
+
scripts: provider?.scripts
|
|
17327
17322
|
}) : readProviderChatHistory(agentStr, {
|
|
17328
17323
|
canonicalHistory: provider?.canonicalHistory,
|
|
17329
17324
|
historySessionId,
|
|
@@ -17428,8 +17423,7 @@ async function handleReadChat(h, args) {
|
|
|
17428
17423
|
limit: nativeHistoryLimit,
|
|
17429
17424
|
excludeRecentCount: 0,
|
|
17430
17425
|
historyBehavior: provider?.historyBehavior,
|
|
17431
|
-
scripts: provider?.scripts
|
|
17432
|
-
exactSessionScoped: exactNativeHistoryScope
|
|
17426
|
+
scripts: provider?.scripts
|
|
17433
17427
|
});
|
|
17434
17428
|
} catch (error) {
|
|
17435
17429
|
const fallbackReason = `native_history_error:${error?.message || String(error)}`;
|
|
@@ -17494,6 +17488,7 @@ async function handleReadChat(h, args) {
|
|
|
17494
17488
|
provider,
|
|
17495
17489
|
nativeSource: nativeHistory.source,
|
|
17496
17490
|
nativeHistoryCoverage,
|
|
17491
|
+
unavailableReason,
|
|
17497
17492
|
nativeMessageCount: nativeMessages.length,
|
|
17498
17493
|
safeMapping,
|
|
17499
17494
|
freshEnough
|
|
@@ -17559,8 +17554,7 @@ async function handleReadChat(h, args) {
|
|
|
17559
17554
|
limit: historyLimit,
|
|
17560
17555
|
excludeRecentCount: 0,
|
|
17561
17556
|
historyBehavior: provider?.historyBehavior,
|
|
17562
|
-
scripts: provider?.scripts
|
|
17563
|
-
exactSessionScoped: exactNativeHistoryScope
|
|
17557
|
+
scripts: provider?.scripts
|
|
17564
17558
|
}) : readProviderChatHistory(agentStr, {
|
|
17565
17559
|
canonicalHistory: provider?.canonicalHistory,
|
|
17566
17560
|
historySessionId,
|
|
@@ -17593,6 +17587,7 @@ async function handleReadChat(h, args) {
|
|
|
17593
17587
|
provider,
|
|
17594
17588
|
nativeSource: history.source,
|
|
17595
17589
|
nativeHistoryCoverage,
|
|
17590
|
+
unavailableReason,
|
|
17596
17591
|
nativeMessageCount: historyMessages.length,
|
|
17597
17592
|
safeMapping,
|
|
17598
17593
|
freshEnough: true
|
|
@@ -27714,9 +27709,12 @@ function summarizeMeshSessionRecord(record) {
|
|
|
27714
27709
|
isCached: false
|
|
27715
27710
|
};
|
|
27716
27711
|
}
|
|
27717
|
-
function liveSessionRecordMatchesMeshNode(record, meshId, nodeId) {
|
|
27712
|
+
function liveSessionRecordMatchesMeshNode(record, meshId, nodeId, nodeWorkspace = "", nodeIsMissingLocalWorktree = false) {
|
|
27718
27713
|
const recordNodeId = readStringValue(record?.meta?.meshNodeId);
|
|
27719
27714
|
if (!recordNodeId || recordNodeId !== nodeId) return false;
|
|
27715
|
+
if (nodeIsMissingLocalWorktree) return false;
|
|
27716
|
+
const recordWorkspace = readStringValue(record?.workspace);
|
|
27717
|
+
if (nodeWorkspace && recordWorkspace && recordWorkspace !== nodeWorkspace) return false;
|
|
27720
27718
|
const recordMeshId = readStringValue(record?.meta?.meshNodeFor);
|
|
27721
27719
|
return !recordMeshId || recordMeshId === meshId;
|
|
27722
27720
|
}
|
|
@@ -27741,9 +27739,13 @@ function readLiveMeshNodeWorkspace(args) {
|
|
|
27741
27739
|
return "";
|
|
27742
27740
|
}
|
|
27743
27741
|
function collectLiveMeshSessionRecords(args) {
|
|
27742
|
+
const nodeWorkspace = readStringValue(args.node?.workspace);
|
|
27743
|
+
const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs11.existsSync(nodeWorkspace);
|
|
27744
27744
|
const matches = args.liveSessionRecords.filter((record) => {
|
|
27745
|
-
const
|
|
27746
|
-
if (
|
|
27745
|
+
const recordNodeId = readStringValue(record?.meta?.meshNodeId);
|
|
27746
|
+
if (recordNodeId && recordNodeId !== args.nodeId) return false;
|
|
27747
|
+
if (liveSessionRecordMatchesMeshNode(record, args.meshId, args.nodeId, nodeWorkspace || "", nodeIsMissingLocalWorktree)) return true;
|
|
27748
|
+
if (nodeIsMissingLocalWorktree) return false;
|
|
27747
27749
|
return !!nodeWorkspace && liveSessionRecordMatchesMeshWorkspace(record, args.meshId, nodeWorkspace);
|
|
27748
27750
|
});
|
|
27749
27751
|
if (args.allowCoordinatorSession) {
|
|
@@ -27759,11 +27761,15 @@ function collectLiveMeshSessionRecords(args) {
|
|
|
27759
27761
|
function buildHistoricalMeshSessions(args) {
|
|
27760
27762
|
const liveNodeIds = /* @__PURE__ */ new Set();
|
|
27761
27763
|
const liveWorkspaces = /* @__PURE__ */ new Set();
|
|
27764
|
+
const missingLocalWorktreeNodeIds = /* @__PURE__ */ new Set();
|
|
27762
27765
|
for (const node of args.nodes || []) {
|
|
27763
27766
|
const nodeId = readStringValue(node?.id, node?.nodeId);
|
|
27764
27767
|
const workspace = readStringValue(node?.workspace);
|
|
27765
27768
|
if (nodeId) liveNodeIds.add(nodeId);
|
|
27766
27769
|
if (workspace) liveWorkspaces.add(workspace);
|
|
27770
|
+
if (nodeId && node?.isLocalWorktree === true && workspace && !fs11.existsSync(workspace)) {
|
|
27771
|
+
missingLocalWorktreeNodeIds.add(nodeId);
|
|
27772
|
+
}
|
|
27767
27773
|
}
|
|
27768
27774
|
const sessions = [];
|
|
27769
27775
|
for (const record of args.liveSessionRecords || []) {
|
|
@@ -27772,7 +27778,7 @@ function buildHistoricalMeshSessions(args) {
|
|
|
27772
27778
|
if (recordMeshId !== args.meshId) continue;
|
|
27773
27779
|
const recordNodeId = readStringValue(meta.meshNodeId);
|
|
27774
27780
|
const workspace = readStringValue(record?.workspace);
|
|
27775
|
-
const removedNode = !!recordNodeId && !liveNodeIds.has(recordNodeId);
|
|
27781
|
+
const removedNode = !!recordNodeId && (!liveNodeIds.has(recordNodeId) || missingLocalWorktreeNodeIds.has(recordNodeId));
|
|
27776
27782
|
const orphanedWorkspace = !!workspace && !liveWorkspaces.has(workspace) && meta.meshCoordinatorFor !== args.meshId;
|
|
27777
27783
|
if (!removedNode && !orphanedWorkspace) continue;
|
|
27778
27784
|
sessions.push({
|
|
@@ -31526,12 +31532,18 @@ ${block2}`);
|
|
|
31526
31532
|
for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
|
|
31527
31533
|
const nodeId = String(node.id || node.nodeId || "");
|
|
31528
31534
|
const daemonId = readStringValue(node.daemonId);
|
|
31535
|
+
const nodeMachineId = readMeshNodeMachineId(node);
|
|
31536
|
+
const nodeHostname = readMeshNodeHostname(node);
|
|
31529
31537
|
const providerPriority = readProviderPriorityFromPolicy(node.policy);
|
|
31538
|
+
const configuredCoordinatorNode = Boolean(
|
|
31539
|
+
nodeId && selectedCoordinatorNodeId && nodeId === selectedCoordinatorNodeId
|
|
31540
|
+
);
|
|
31541
|
+
const sparseConfiguredCoordinatorNode = configuredCoordinatorNode && !daemonId && !nodeMachineId && !nodeHostname;
|
|
31530
31542
|
const isSelfNode = Boolean(
|
|
31531
31543
|
nodeId && inlineCoordinatorNodeId && nodeId === inlineCoordinatorNodeId
|
|
31532
31544
|
) || Boolean(
|
|
31533
31545
|
daemonId && (daemonId === localMachineId || daemonId === this.deps.statusInstanceId)
|
|
31534
|
-
) || Boolean(meshRecord?.inline && nodeIndex === 0);
|
|
31546
|
+
) || Boolean(meshRecord?.inline && nodeIndex === 0) || sparseConfiguredCoordinatorNode;
|
|
31535
31547
|
const machineIdentity = buildMeshNodeMachineIdentity(node, {
|
|
31536
31548
|
localMachineId,
|
|
31537
31549
|
localDaemonId: this.deps.statusInstanceId,
|
|
@@ -31548,7 +31560,7 @@ ${block2}`);
|
|
|
31548
31560
|
worktreeBranch: node.worktreeBranch,
|
|
31549
31561
|
role: normalizeMeshDaemonRole(node.role) || (meshHost.hostNodeId && nodeId === meshHost.hostNodeId ? "host" : void 0),
|
|
31550
31562
|
daemonId,
|
|
31551
|
-
machineId:
|
|
31563
|
+
machineId: nodeMachineId || node.machineId,
|
|
31552
31564
|
machine: machineIdentity,
|
|
31553
31565
|
machineStatus: node.machineStatus,
|
|
31554
31566
|
health: "unknown",
|