@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.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";
|
|
@@ -16972,10 +16973,9 @@ function hasSafeNativeHistoryMapping(args) {
|
|
|
16972
16973
|
const text = typeof m?.content === "string" ? m.content : JSON.stringify(m?.content || "");
|
|
16973
16974
|
return text.includes("mesh_send_task") || text.includes("mesh_status") || text.includes("mesh_read_chat");
|
|
16974
16975
|
});
|
|
16975
|
-
|
|
16976
|
-
return false;
|
|
16977
|
-
}
|
|
16976
|
+
return ptyHasCoordinator;
|
|
16978
16977
|
}
|
|
16978
|
+
return false;
|
|
16979
16979
|
}
|
|
16980
16980
|
const workspace = String(args.workspace || "").trim();
|
|
16981
16981
|
if (!workspace) return false;
|
|
@@ -16994,6 +16994,15 @@ function hasSafeNativeHistoryMapping(args) {
|
|
|
16994
16994
|
return hasOverlappingVisibleConversationText(args.nativeMessages, args.ptyMessages || []);
|
|
16995
16995
|
}
|
|
16996
16996
|
function readCliProviderNativeHistory(agentStr, args) {
|
|
16997
|
+
if (!args.historySessionId) {
|
|
16998
|
+
return {
|
|
16999
|
+
messages: [],
|
|
17000
|
+
hasMore: false,
|
|
17001
|
+
source: "native-unavailable",
|
|
17002
|
+
unavailableReason: "native_history_workspace_only_lookup_unsafe",
|
|
17003
|
+
lookup: "session"
|
|
17004
|
+
};
|
|
17005
|
+
}
|
|
16997
17006
|
const sessionHistory = readProviderChatHistory(agentStr, {
|
|
16998
17007
|
canonicalHistory: args.canonicalHistory,
|
|
16999
17008
|
historySessionId: args.historySessionId,
|
|
@@ -17004,20 +17013,7 @@ function readCliProviderNativeHistory(agentStr, args) {
|
|
|
17004
17013
|
historyBehavior: args.historyBehavior,
|
|
17005
17014
|
scripts: args.scripts
|
|
17006
17015
|
});
|
|
17007
|
-
|
|
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" };
|
|
17016
|
+
return { ...sessionHistory, lookup: "session" };
|
|
17021
17017
|
}
|
|
17022
17018
|
function isNativeHistoryFreshEnough(args) {
|
|
17023
17019
|
const nativeNewest = getMessageNewestReceivedAt(args.nativeMessages);
|
|
@@ -17588,8 +17584,7 @@ async function handleChatHistory(h, args) {
|
|
|
17588
17584
|
limit: limit || 30,
|
|
17589
17585
|
excludeRecentCount,
|
|
17590
17586
|
historyBehavior: provider?.historyBehavior,
|
|
17591
|
-
scripts: provider?.scripts
|
|
17592
|
-
exactSessionScoped: exactNativeHistoryScope
|
|
17587
|
+
scripts: provider?.scripts
|
|
17593
17588
|
}) : readProviderChatHistory(agentStr, {
|
|
17594
17589
|
canonicalHistory: provider?.canonicalHistory,
|
|
17595
17590
|
historySessionId,
|
|
@@ -17694,8 +17689,7 @@ async function handleReadChat(h, args) {
|
|
|
17694
17689
|
limit: nativeHistoryLimit,
|
|
17695
17690
|
excludeRecentCount: 0,
|
|
17696
17691
|
historyBehavior: provider?.historyBehavior,
|
|
17697
|
-
scripts: provider?.scripts
|
|
17698
|
-
exactSessionScoped: exactNativeHistoryScope
|
|
17692
|
+
scripts: provider?.scripts
|
|
17699
17693
|
});
|
|
17700
17694
|
} catch (error) {
|
|
17701
17695
|
const fallbackReason = `native_history_error:${error?.message || String(error)}`;
|
|
@@ -17760,6 +17754,7 @@ async function handleReadChat(h, args) {
|
|
|
17760
17754
|
provider,
|
|
17761
17755
|
nativeSource: nativeHistory.source,
|
|
17762
17756
|
nativeHistoryCoverage,
|
|
17757
|
+
unavailableReason,
|
|
17763
17758
|
nativeMessageCount: nativeMessages.length,
|
|
17764
17759
|
safeMapping,
|
|
17765
17760
|
freshEnough
|
|
@@ -17825,8 +17820,7 @@ async function handleReadChat(h, args) {
|
|
|
17825
17820
|
limit: historyLimit,
|
|
17826
17821
|
excludeRecentCount: 0,
|
|
17827
17822
|
historyBehavior: provider?.historyBehavior,
|
|
17828
|
-
scripts: provider?.scripts
|
|
17829
|
-
exactSessionScoped: exactNativeHistoryScope
|
|
17823
|
+
scripts: provider?.scripts
|
|
17830
17824
|
}) : readProviderChatHistory(agentStr, {
|
|
17831
17825
|
canonicalHistory: provider?.canonicalHistory,
|
|
17832
17826
|
historySessionId,
|
|
@@ -17859,6 +17853,7 @@ async function handleReadChat(h, args) {
|
|
|
17859
17853
|
provider,
|
|
17860
17854
|
nativeSource: history.source,
|
|
17861
17855
|
nativeHistoryCoverage,
|
|
17856
|
+
unavailableReason,
|
|
17862
17857
|
nativeMessageCount: historyMessages.length,
|
|
17863
17858
|
safeMapping,
|
|
17864
17859
|
freshEnough: true
|
|
@@ -27975,9 +27970,12 @@ function summarizeMeshSessionRecord(record) {
|
|
|
27975
27970
|
isCached: false
|
|
27976
27971
|
};
|
|
27977
27972
|
}
|
|
27978
|
-
function liveSessionRecordMatchesMeshNode(record, meshId, nodeId) {
|
|
27973
|
+
function liveSessionRecordMatchesMeshNode(record, meshId, nodeId, nodeWorkspace = "", nodeIsMissingLocalWorktree = false) {
|
|
27979
27974
|
const recordNodeId = readStringValue(record?.meta?.meshNodeId);
|
|
27980
27975
|
if (!recordNodeId || recordNodeId !== nodeId) return false;
|
|
27976
|
+
if (nodeIsMissingLocalWorktree) return false;
|
|
27977
|
+
const recordWorkspace = readStringValue(record?.workspace);
|
|
27978
|
+
if (nodeWorkspace && recordWorkspace && recordWorkspace !== nodeWorkspace) return false;
|
|
27981
27979
|
const recordMeshId = readStringValue(record?.meta?.meshNodeFor);
|
|
27982
27980
|
return !recordMeshId || recordMeshId === meshId;
|
|
27983
27981
|
}
|
|
@@ -28002,9 +28000,13 @@ function readLiveMeshNodeWorkspace(args) {
|
|
|
28002
28000
|
return "";
|
|
28003
28001
|
}
|
|
28004
28002
|
function collectLiveMeshSessionRecords(args) {
|
|
28003
|
+
const nodeWorkspace = readStringValue(args.node?.workspace);
|
|
28004
|
+
const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs11.existsSync(nodeWorkspace);
|
|
28005
28005
|
const matches = args.liveSessionRecords.filter((record) => {
|
|
28006
|
-
const
|
|
28007
|
-
if (
|
|
28006
|
+
const recordNodeId = readStringValue(record?.meta?.meshNodeId);
|
|
28007
|
+
if (recordNodeId && recordNodeId !== args.nodeId) return false;
|
|
28008
|
+
if (liveSessionRecordMatchesMeshNode(record, args.meshId, args.nodeId, nodeWorkspace || "", nodeIsMissingLocalWorktree)) return true;
|
|
28009
|
+
if (nodeIsMissingLocalWorktree) return false;
|
|
28008
28010
|
return !!nodeWorkspace && liveSessionRecordMatchesMeshWorkspace(record, args.meshId, nodeWorkspace);
|
|
28009
28011
|
});
|
|
28010
28012
|
if (args.allowCoordinatorSession) {
|
|
@@ -28020,11 +28022,15 @@ function collectLiveMeshSessionRecords(args) {
|
|
|
28020
28022
|
function buildHistoricalMeshSessions(args) {
|
|
28021
28023
|
const liveNodeIds = /* @__PURE__ */ new Set();
|
|
28022
28024
|
const liveWorkspaces = /* @__PURE__ */ new Set();
|
|
28025
|
+
const missingLocalWorktreeNodeIds = /* @__PURE__ */ new Set();
|
|
28023
28026
|
for (const node of args.nodes || []) {
|
|
28024
28027
|
const nodeId = readStringValue(node?.id, node?.nodeId);
|
|
28025
28028
|
const workspace = readStringValue(node?.workspace);
|
|
28026
28029
|
if (nodeId) liveNodeIds.add(nodeId);
|
|
28027
28030
|
if (workspace) liveWorkspaces.add(workspace);
|
|
28031
|
+
if (nodeId && node?.isLocalWorktree === true && workspace && !fs11.existsSync(workspace)) {
|
|
28032
|
+
missingLocalWorktreeNodeIds.add(nodeId);
|
|
28033
|
+
}
|
|
28028
28034
|
}
|
|
28029
28035
|
const sessions = [];
|
|
28030
28036
|
for (const record of args.liveSessionRecords || []) {
|
|
@@ -28033,7 +28039,7 @@ function buildHistoricalMeshSessions(args) {
|
|
|
28033
28039
|
if (recordMeshId !== args.meshId) continue;
|
|
28034
28040
|
const recordNodeId = readStringValue(meta.meshNodeId);
|
|
28035
28041
|
const workspace = readStringValue(record?.workspace);
|
|
28036
|
-
const removedNode = !!recordNodeId && !liveNodeIds.has(recordNodeId);
|
|
28042
|
+
const removedNode = !!recordNodeId && (!liveNodeIds.has(recordNodeId) || missingLocalWorktreeNodeIds.has(recordNodeId));
|
|
28037
28043
|
const orphanedWorkspace = !!workspace && !liveWorkspaces.has(workspace) && meta.meshCoordinatorFor !== args.meshId;
|
|
28038
28044
|
if (!removedNode && !orphanedWorkspace) continue;
|
|
28039
28045
|
sessions.push({
|
|
@@ -31787,12 +31793,18 @@ ${block2}`);
|
|
|
31787
31793
|
for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
|
|
31788
31794
|
const nodeId = String(node.id || node.nodeId || "");
|
|
31789
31795
|
const daemonId = readStringValue(node.daemonId);
|
|
31796
|
+
const nodeMachineId = readMeshNodeMachineId(node);
|
|
31797
|
+
const nodeHostname = readMeshNodeHostname(node);
|
|
31790
31798
|
const providerPriority = readProviderPriorityFromPolicy(node.policy);
|
|
31799
|
+
const configuredCoordinatorNode = Boolean(
|
|
31800
|
+
nodeId && selectedCoordinatorNodeId && nodeId === selectedCoordinatorNodeId
|
|
31801
|
+
);
|
|
31802
|
+
const sparseConfiguredCoordinatorNode = configuredCoordinatorNode && !daemonId && !nodeMachineId && !nodeHostname;
|
|
31791
31803
|
const isSelfNode = Boolean(
|
|
31792
31804
|
nodeId && inlineCoordinatorNodeId && nodeId === inlineCoordinatorNodeId
|
|
31793
31805
|
) || Boolean(
|
|
31794
31806
|
daemonId && (daemonId === localMachineId || daemonId === this.deps.statusInstanceId)
|
|
31795
|
-
) || Boolean(meshRecord?.inline && nodeIndex === 0);
|
|
31807
|
+
) || Boolean(meshRecord?.inline && nodeIndex === 0) || sparseConfiguredCoordinatorNode;
|
|
31796
31808
|
const machineIdentity = buildMeshNodeMachineIdentity(node, {
|
|
31797
31809
|
localMachineId,
|
|
31798
31810
|
localDaemonId: this.deps.statusInstanceId,
|
|
@@ -31809,7 +31821,7 @@ ${block2}`);
|
|
|
31809
31821
|
worktreeBranch: node.worktreeBranch,
|
|
31810
31822
|
role: normalizeMeshDaemonRole(node.role) || (meshHost.hostNodeId && nodeId === meshHost.hostNodeId ? "host" : void 0),
|
|
31811
31823
|
daemonId,
|
|
31812
|
-
machineId:
|
|
31824
|
+
machineId: nodeMachineId || node.machineId,
|
|
31813
31825
|
machine: machineIdentity,
|
|
31814
31826
|
machineStatus: node.machineStatus,
|
|
31815
31827
|
health: "unknown",
|