@adhdev/daemon-standalone 0.9.82-rc.326 → 0.9.82-rc.328
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 +528 -332
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +7 -42
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -30033,10 +30033,10 @@ var require_dist3 = __commonJS({
|
|
|
30033
30033
|
}
|
|
30034
30034
|
function getDaemonBuildInfo() {
|
|
30035
30035
|
if (cached2) return cached2;
|
|
30036
|
-
const commit = readInjected(true ? "
|
|
30037
|
-
const commitShort = readInjected(true ? "
|
|
30038
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30039
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
30036
|
+
const commit = readInjected(true ? "38ede5a48ea8a2e21b5ea014880b9af37c6e3537" : void 0) ?? "unknown";
|
|
30037
|
+
const commitShort = readInjected(true ? "38ede5a4" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30038
|
+
const version2 = readInjected(true ? "0.9.82-rc.328" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30039
|
+
const builtAt = readInjected(true ? "2026-06-19T13:57:56.784Z" : void 0);
|
|
30040
30040
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30041
30041
|
return cached2;
|
|
30042
30042
|
}
|
|
@@ -31669,6 +31669,8 @@ ${error48.message || ""}`;
|
|
|
31669
31669
|
const node = mesh.nodes.find((n) => n.id === nodeId);
|
|
31670
31670
|
if (!node) return void 0;
|
|
31671
31671
|
if (opts.userOverrides) node.userOverrides = { ...node.userOverrides, ...opts.userOverrides };
|
|
31672
|
+
if (opts.reportedPlatform && opts.reportedPlatform.trim()) node.reportedPlatform = opts.reportedPlatform.trim();
|
|
31673
|
+
if (opts.reportedArch && opts.reportedArch.trim()) node.reportedArch = opts.reportedArch.trim();
|
|
31672
31674
|
if (opts.policy) node.policy = { ...node.policy, ...opts.policy };
|
|
31673
31675
|
if (opts.worktreeBootstrap) node.worktreeBootstrap = opts.worktreeBootstrap;
|
|
31674
31676
|
if (Object.prototype.hasOwnProperty.call(opts, "systemPrompt")) {
|
|
@@ -32854,11 +32856,15 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
32854
32856
|
const value = overrides[key];
|
|
32855
32857
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
32856
32858
|
}
|
|
32859
|
+
function readNodeReporter(node, key) {
|
|
32860
|
+
const value = key === "platform" ? node?.reportedPlatform : node?.reportedArch;
|
|
32861
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
32862
|
+
}
|
|
32857
32863
|
function buildMeshNodeCapabilityTags(node, providerType) {
|
|
32858
32864
|
const provider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : firstProviderPriority(node?.policy);
|
|
32859
32865
|
const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
|
|
32860
|
-
const os30 = readNodeOverride(node, "platform") ?? process.platform;
|
|
32861
|
-
const arch2 = readNodeOverride(node, "arch") ?? process.arch;
|
|
32866
|
+
const os30 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
|
|
32867
|
+
const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
|
|
32862
32868
|
return normalizeMeshCapabilityTags([
|
|
32863
32869
|
...Array.isArray(node?.capabilities) ? node.capabilities : [],
|
|
32864
32870
|
`os=${os30}`,
|
|
@@ -36742,6 +36748,410 @@ ${rendered}`, "utf-8");
|
|
|
36742
36748
|
"use strict";
|
|
36743
36749
|
}
|
|
36744
36750
|
});
|
|
36751
|
+
function readString6(value) {
|
|
36752
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
36753
|
+
}
|
|
36754
|
+
function summarizeMessage(message) {
|
|
36755
|
+
const oneLine2 = message.replace(/\s+/g, " ").trim();
|
|
36756
|
+
const title = oneLine2.length > 96 ? `${oneLine2.slice(0, 93)}...` : oneLine2;
|
|
36757
|
+
return { title: title || "(untitled task)", summary: oneLine2 };
|
|
36758
|
+
}
|
|
36759
|
+
function elapsedSince(value, now) {
|
|
36760
|
+
const started = value ? new Date(value).getTime() : Number.NaN;
|
|
36761
|
+
return Number.isFinite(started) ? Math.max(0, now - started) : 0;
|
|
36762
|
+
}
|
|
36763
|
+
function sessionStatusFromNodes(nodes, nodeId, sessionId) {
|
|
36764
|
+
if (!Array.isArray(nodes)) return {};
|
|
36765
|
+
if (!nodeId) return { staleReason: "direct task has no node id" };
|
|
36766
|
+
const node = nodes.find((item) => meshNodeIdMatches(item, nodeId));
|
|
36767
|
+
if (!node) return { staleReason: "direct task node is no longer in the live mesh" };
|
|
36768
|
+
if (!sessionId) return {};
|
|
36769
|
+
const candidates = [];
|
|
36770
|
+
for (const value of [
|
|
36771
|
+
node.sessions,
|
|
36772
|
+
node.activeSessions,
|
|
36773
|
+
node.active_sessions,
|
|
36774
|
+
node.activeSessionDetails,
|
|
36775
|
+
node.active_session_details,
|
|
36776
|
+
node.sessionDetails,
|
|
36777
|
+
node.session_details,
|
|
36778
|
+
node.lastProbe?.sessions,
|
|
36779
|
+
node.last_probe?.sessions,
|
|
36780
|
+
node.lastProbe?.status?.sessions,
|
|
36781
|
+
node.last_probe?.status?.sessions
|
|
36782
|
+
]) {
|
|
36783
|
+
if (Array.isArray(value)) candidates.push(...value);
|
|
36784
|
+
}
|
|
36785
|
+
for (const value of [node.activeSession, node.active_session, node.currentSession, node.current_session, node.runtimeSession, node.runtime_session, node.session]) {
|
|
36786
|
+
if (value && typeof value === "object") candidates.push(value);
|
|
36787
|
+
}
|
|
36788
|
+
const session = candidates.find((item) => {
|
|
36789
|
+
if (typeof item === "string") return item === sessionId;
|
|
36790
|
+
const id = readString6(item?.id) || readString6(item?.sessionId) || readString6(item?.session_id) || readString6(item?.runtimeSessionId) || readString6(item?.instanceId);
|
|
36791
|
+
return id === sessionId;
|
|
36792
|
+
});
|
|
36793
|
+
if (!session) return { staleReason: "direct task session is not present in live session records" };
|
|
36794
|
+
if (typeof session === "string") return {};
|
|
36795
|
+
const raw = `${readString6(session.status) || ""} ${readString6(session.lifecycle) || ""} ${readString6(session.state) || ""} ${readString6(session.activeChat?.status) || ""}`.toLowerCase();
|
|
36796
|
+
if (raw.includes("approval")) return { status: "awaiting_approval" };
|
|
36797
|
+
if (raw.includes("generating") || raw.includes("running") || raw.includes("busy")) return { status: "generating" };
|
|
36798
|
+
if (raw.includes("failed") || raw.includes("stopped") || raw.includes("terminated") || raw.includes("exited")) return { status: "failed" };
|
|
36799
|
+
if (raw.includes("idle") || raw.includes("waiting_input") || raw.includes("ready")) return { status: "idle" };
|
|
36800
|
+
return {};
|
|
36801
|
+
}
|
|
36802
|
+
function isDirectDispatch(entry) {
|
|
36803
|
+
if (entry.kind !== "task_dispatched") return false;
|
|
36804
|
+
const payload = entry.payload || {};
|
|
36805
|
+
if (payload.source === "direct") return true;
|
|
36806
|
+
const via = readString6(payload.via);
|
|
36807
|
+
return Boolean(via && DIRECT_DISPATCH_VIA.has(via) && payload.source !== "queue");
|
|
36808
|
+
}
|
|
36809
|
+
function directDispatchTaskId(entry) {
|
|
36810
|
+
return readString6(entry.payload?.taskId) || entry.id;
|
|
36811
|
+
}
|
|
36812
|
+
function terminalMatchesDispatch(terminal, dispatch, taskId) {
|
|
36813
|
+
const terminalTaskId = readString6(terminal.payload?.taskId);
|
|
36814
|
+
if (terminalTaskId && terminalTaskId === taskId) return true;
|
|
36815
|
+
if (terminalTaskId && terminalTaskId !== taskId) return false;
|
|
36816
|
+
if (dispatch.sessionId && terminal.sessionId === dispatch.sessionId) return true;
|
|
36817
|
+
return Boolean(dispatch.nodeId && terminal.nodeId === dispatch.nodeId && !dispatch.sessionId);
|
|
36818
|
+
}
|
|
36819
|
+
function statusFromTerminal(entry) {
|
|
36820
|
+
if (entry.kind === "task_approval_needed") return "awaiting_approval";
|
|
36821
|
+
if (entry.kind === "task_completed") return "idle";
|
|
36822
|
+
return "failed";
|
|
36823
|
+
}
|
|
36824
|
+
function buildMeshActiveWorkSummary(activeWork) {
|
|
36825
|
+
const statusCounts = {
|
|
36826
|
+
pending: 0,
|
|
36827
|
+
assigned: 0,
|
|
36828
|
+
generating: 0,
|
|
36829
|
+
idle: 0,
|
|
36830
|
+
failed: 0,
|
|
36831
|
+
awaiting_approval: 0
|
|
36832
|
+
};
|
|
36833
|
+
const sourceCounts = { queue: 0, direct: 0 };
|
|
36834
|
+
for (const item of activeWork) {
|
|
36835
|
+
sourceCounts[item.source] += 1;
|
|
36836
|
+
statusCounts[item.status] += 1;
|
|
36837
|
+
}
|
|
36838
|
+
const staleDirectCount = activeWork.filter((item) => item.source === "direct" && item.staleReason).length;
|
|
36839
|
+
const staleDirectUnacknowledgedCount = activeWork.filter((item) => item.source === "direct" && item.staleDispatchUnacknowledged).length;
|
|
36840
|
+
return {
|
|
36841
|
+
totalActiveCount: activeWork.length,
|
|
36842
|
+
queueActiveCount: sourceCounts.queue,
|
|
36843
|
+
directActiveCount: sourceCounts.direct,
|
|
36844
|
+
awaitingApprovalCount: statusCounts.awaiting_approval,
|
|
36845
|
+
generatingCount: statusCounts.generating,
|
|
36846
|
+
failedCount: statusCounts.failed,
|
|
36847
|
+
idleCount: statusCounts.idle,
|
|
36848
|
+
sourceCounts,
|
|
36849
|
+
statusCounts,
|
|
36850
|
+
staleDirectCount,
|
|
36851
|
+
...staleDirectUnacknowledgedCount > 0 ? { staleDirectUnacknowledgedCount } : {},
|
|
36852
|
+
...staleDirectCount > 0 ? { staleDirectNote: "Stale direct records are orphaned ledger entries whose node/session no longer exists. They are historical recovery evidence only \u2014 not active or unresolved work. The queue (source: queue) is authoritative for pending/assigned tasks." } : {}
|
|
36853
|
+
};
|
|
36854
|
+
}
|
|
36855
|
+
function buildMeshActiveWork(opts) {
|
|
36856
|
+
const now = opts.now ?? Date.now();
|
|
36857
|
+
const records = [];
|
|
36858
|
+
const staleDirectWork = [];
|
|
36859
|
+
const terminalDirectWork = [];
|
|
36860
|
+
for (const task of opts.queue || []) {
|
|
36861
|
+
if (task.status !== "pending" && task.status !== "assigned") continue;
|
|
36862
|
+
const { title, summary: summary2 } = summarizeMessage(task.message || "");
|
|
36863
|
+
records.push({
|
|
36864
|
+
taskId: task.id,
|
|
36865
|
+
source: "queue",
|
|
36866
|
+
status: task.status,
|
|
36867
|
+
nodeId: task.assignedNodeId || task.targetNodeId,
|
|
36868
|
+
sessionId: task.assignedSessionId || task.targetSessionId,
|
|
36869
|
+
taskTitle: title,
|
|
36870
|
+
taskSummary: summary2,
|
|
36871
|
+
message: task.message,
|
|
36872
|
+
taskMode: task.taskMode,
|
|
36873
|
+
createdAt: task.createdAt,
|
|
36874
|
+
updatedAt: task.updatedAt,
|
|
36875
|
+
dispatchedAt: task.dispatchTimestamp,
|
|
36876
|
+
elapsedMs: elapsedSince(task.dispatchTimestamp || task.createdAt, now)
|
|
36877
|
+
});
|
|
36878
|
+
}
|
|
36879
|
+
if (opts.directDispatches !== void 0) {
|
|
36880
|
+
const dbTaskIds = new Set(opts.directDispatches.map((d) => d.taskId));
|
|
36881
|
+
for (const dispatch of opts.directDispatches) {
|
|
36882
|
+
const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId ?? void 0, dispatch.sessionId ?? void 0);
|
|
36883
|
+
const dbStatus = dispatch.status;
|
|
36884
|
+
const isTerminal = dbStatus === "completed" || dbStatus === "failed" || dbStatus === "stale";
|
|
36885
|
+
const status = isTerminal ? dbStatus === "completed" ? "idle" : "failed" : live.status || (dbStatus === "acked" ? "generating" : "assigned");
|
|
36886
|
+
const isNoTransition = !isTerminal && !live.status;
|
|
36887
|
+
const isIdleUnacknowledged = status === "idle" && !isTerminal;
|
|
36888
|
+
const ledgerOnlyStaleReason = !isTerminal && (isIdleUnacknowledged || isNoTransition || dispatch.dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
36889
|
+
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
36890
|
+
const { title, summary: summary2 } = summarizeMessage(dispatch.message || "");
|
|
36891
|
+
const record2 = {
|
|
36892
|
+
taskId: dispatch.taskId,
|
|
36893
|
+
source: "direct",
|
|
36894
|
+
status,
|
|
36895
|
+
nodeId: dispatch.nodeId ?? void 0,
|
|
36896
|
+
sessionId: dispatch.sessionId ?? void 0,
|
|
36897
|
+
providerType: dispatch.providerType ?? void 0,
|
|
36898
|
+
taskTitle: title,
|
|
36899
|
+
taskSummary: summary2,
|
|
36900
|
+
message: dispatch.message,
|
|
36901
|
+
taskMode: dispatch.taskMode ?? void 0,
|
|
36902
|
+
createdAt: dispatch.dispatchedAt,
|
|
36903
|
+
updatedAt: dispatch.updatedAt,
|
|
36904
|
+
dispatchedAt: dispatch.dispatchedAt,
|
|
36905
|
+
elapsedMs: elapsedSince(dispatch.dispatchedAt, now),
|
|
36906
|
+
terminal: isTerminal,
|
|
36907
|
+
terminalKind: isTerminal ? dbStatus === "completed" ? "task_completed" : "task_failed" : void 0,
|
|
36908
|
+
terminalAt: isTerminal ? dispatch.updatedAt : void 0,
|
|
36909
|
+
staleReason: live.staleReason || ledgerOnlyStaleReason,
|
|
36910
|
+
...isFreshUnacknowledged ? { staleDispatchUnacknowledged: true } : {}
|
|
36911
|
+
};
|
|
36912
|
+
if (isTerminal) {
|
|
36913
|
+
terminalDirectWork.push(record2);
|
|
36914
|
+
if (opts.includeTerminalDirect !== true) continue;
|
|
36915
|
+
}
|
|
36916
|
+
if ((live.staleReason || ledgerOnlyStaleReason) && !isTerminal) {
|
|
36917
|
+
staleDirectWork.push(record2);
|
|
36918
|
+
continue;
|
|
36919
|
+
}
|
|
36920
|
+
records.push(record2);
|
|
36921
|
+
}
|
|
36922
|
+
const ledgerEntries = (opts.ledgerEntries || []).slice().sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
36923
|
+
const terminals = ledgerEntries.filter((entry) => TERMINAL_LEDGER_KINDS.has(entry.kind) || entry.kind === "task_approval_needed");
|
|
36924
|
+
for (const dispatch of ledgerEntries.filter(isDirectDispatch)) {
|
|
36925
|
+
const taskId = directDispatchTaskId(dispatch);
|
|
36926
|
+
if (dbTaskIds.has(taskId)) continue;
|
|
36927
|
+
const terminal = terminals.filter((entry) => new Date(entry.timestamp).getTime() >= new Date(dispatch.timestamp).getTime()).find((entry) => terminalMatchesDispatch(entry, dispatch, taskId));
|
|
36928
|
+
const terminalStatus = terminal ? statusFromTerminal(terminal) : void 0;
|
|
36929
|
+
const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId, dispatch.sessionId);
|
|
36930
|
+
const status = terminalStatus || live.status || "assigned";
|
|
36931
|
+
const terminalRow = Boolean(terminal && terminal.kind !== "task_approval_needed");
|
|
36932
|
+
const dispatchedToIdleSession = dispatch.payload?.dispatchedToIdleSession === true;
|
|
36933
|
+
const isNoTransition = !terminalStatus && !live.status;
|
|
36934
|
+
const isIdleUnacknowledged = status === "idle";
|
|
36935
|
+
const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
36936
|
+
const message = readString6(dispatch.payload?.message) || readString6(dispatch.payload?.summary) || "";
|
|
36937
|
+
const { title, summary: summary2 } = summarizeMessage(message);
|
|
36938
|
+
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
36939
|
+
const record2 = {
|
|
36940
|
+
taskId,
|
|
36941
|
+
source: "direct",
|
|
36942
|
+
status,
|
|
36943
|
+
nodeId: dispatch.nodeId,
|
|
36944
|
+
sessionId: dispatch.sessionId,
|
|
36945
|
+
providerType: dispatch.providerType || readString6(dispatch.payload?.providerType),
|
|
36946
|
+
taskTitle: readString6(dispatch.payload?.taskTitle) || title,
|
|
36947
|
+
taskSummary: readString6(dispatch.payload?.taskSummary) || summary2,
|
|
36948
|
+
message,
|
|
36949
|
+
taskMode: readString6(dispatch.payload?.taskMode),
|
|
36950
|
+
createdAt: dispatch.timestamp,
|
|
36951
|
+
updatedAt: terminal?.timestamp || dispatch.timestamp,
|
|
36952
|
+
dispatchedAt: dispatch.timestamp,
|
|
36953
|
+
elapsedMs: elapsedSince(dispatch.timestamp, now),
|
|
36954
|
+
terminal: terminalRow,
|
|
36955
|
+
terminalKind: terminal?.kind,
|
|
36956
|
+
terminalAt: terminal?.timestamp,
|
|
36957
|
+
staleReason: live.staleReason || ledgerOnlyStaleReason,
|
|
36958
|
+
...isFreshUnacknowledged ? { staleDispatchUnacknowledged: true } : {}
|
|
36959
|
+
};
|
|
36960
|
+
if (terminalRow) {
|
|
36961
|
+
terminalDirectWork.push(record2);
|
|
36962
|
+
if (opts.includeTerminalDirect !== true) continue;
|
|
36963
|
+
}
|
|
36964
|
+
if ((live.staleReason || ledgerOnlyStaleReason) && !terminalRow) {
|
|
36965
|
+
staleDirectWork.push(record2);
|
|
36966
|
+
continue;
|
|
36967
|
+
}
|
|
36968
|
+
records.push(record2);
|
|
36969
|
+
}
|
|
36970
|
+
} else {
|
|
36971
|
+
const ledgerEntries = (opts.ledgerEntries || []).slice().sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
36972
|
+
const terminals = ledgerEntries.filter((entry) => TERMINAL_LEDGER_KINDS.has(entry.kind) || entry.kind === "task_approval_needed");
|
|
36973
|
+
for (const dispatch of ledgerEntries.filter(isDirectDispatch)) {
|
|
36974
|
+
const taskId = directDispatchTaskId(dispatch);
|
|
36975
|
+
const terminal = terminals.filter((entry) => new Date(entry.timestamp).getTime() >= new Date(dispatch.timestamp).getTime()).find((entry) => terminalMatchesDispatch(entry, dispatch, taskId));
|
|
36976
|
+
const terminalStatus = terminal ? statusFromTerminal(terminal) : void 0;
|
|
36977
|
+
const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId, dispatch.sessionId);
|
|
36978
|
+
const status = terminalStatus || live.status || "assigned";
|
|
36979
|
+
const terminalRow = Boolean(terminal && terminal.kind !== "task_approval_needed");
|
|
36980
|
+
const dispatchedToIdleSession = dispatch.payload?.dispatchedToIdleSession === true;
|
|
36981
|
+
const isNoTransition = !terminalStatus && !live.status;
|
|
36982
|
+
const isIdleUnacknowledged = status === "idle";
|
|
36983
|
+
const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
36984
|
+
const message = readString6(dispatch.payload?.message) || readString6(dispatch.payload?.summary) || "";
|
|
36985
|
+
const { title, summary: summary2 } = summarizeMessage(message);
|
|
36986
|
+
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
36987
|
+
const record2 = {
|
|
36988
|
+
taskId,
|
|
36989
|
+
source: "direct",
|
|
36990
|
+
status,
|
|
36991
|
+
nodeId: dispatch.nodeId,
|
|
36992
|
+
sessionId: dispatch.sessionId,
|
|
36993
|
+
providerType: dispatch.providerType || readString6(dispatch.payload?.providerType),
|
|
36994
|
+
taskTitle: readString6(dispatch.payload?.taskTitle) || title,
|
|
36995
|
+
taskSummary: readString6(dispatch.payload?.taskSummary) || summary2,
|
|
36996
|
+
message,
|
|
36997
|
+
taskMode: readString6(dispatch.payload?.taskMode),
|
|
36998
|
+
createdAt: dispatch.timestamp,
|
|
36999
|
+
updatedAt: terminal?.timestamp || dispatch.timestamp,
|
|
37000
|
+
dispatchedAt: dispatch.timestamp,
|
|
37001
|
+
elapsedMs: elapsedSince(dispatch.timestamp, now),
|
|
37002
|
+
terminal: terminalRow,
|
|
37003
|
+
terminalKind: terminal?.kind,
|
|
37004
|
+
terminalAt: terminal?.timestamp,
|
|
37005
|
+
staleReason: live.staleReason || ledgerOnlyStaleReason,
|
|
37006
|
+
...isFreshUnacknowledged ? { staleDispatchUnacknowledged: true } : {}
|
|
37007
|
+
};
|
|
37008
|
+
if (terminalRow) {
|
|
37009
|
+
terminalDirectWork.push(record2);
|
|
37010
|
+
if (opts.includeTerminalDirect !== true) continue;
|
|
37011
|
+
}
|
|
37012
|
+
if ((live.staleReason || ledgerOnlyStaleReason) && !terminalRow) {
|
|
37013
|
+
staleDirectWork.push(record2);
|
|
37014
|
+
continue;
|
|
37015
|
+
}
|
|
37016
|
+
records.push(record2);
|
|
37017
|
+
}
|
|
37018
|
+
}
|
|
37019
|
+
records.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
37020
|
+
staleDirectWork.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
37021
|
+
terminalDirectWork.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
37022
|
+
const summary = buildMeshActiveWorkSummary(records);
|
|
37023
|
+
summary.staleDirectCount = staleDirectWork.length;
|
|
37024
|
+
const unacknowledgedCount = staleDirectWork.filter((r) => r.staleDispatchUnacknowledged).length;
|
|
37025
|
+
if (unacknowledgedCount > 0) {
|
|
37026
|
+
summary.staleDirectUnacknowledgedCount = unacknowledgedCount;
|
|
37027
|
+
}
|
|
37028
|
+
const staleDirectWorkNote = staleDirectWork.length > 0 ? unacknowledgedCount > 0 && unacknowledgedCount === staleDirectWork.length ? `${unacknowledgedCount} direct dispatch(es) were not acknowledged by the target session \u2014 the session received the agent_command but never transitioned to generating. This is a fresh dispatch failure, not historical noise. Recovery: launch a fresh session on the same node and retry the task, or use mesh_enqueue_task for queue-based assignment.` : unacknowledgedCount > 0 ? `${unacknowledgedCount} of ${staleDirectWork.length} stale direct record(s) are fresh unacknowledged dispatch failures (session still live but never transitioned to generating); the rest are orphaned historical entries whose node/session no longer exists. Fresh unacknowledged dispatches need recovery: launch a fresh session and retry. Orphaned entries are historical evidence only \u2014 not active or unresolved work.` : "These are orphaned ledger entries whose original node or session no longer exists in the live mesh. They are historical/recovery evidence only \u2014 not active or unresolved work. Do not treat staleDirectCount as a status mismatch; use the queue (source: queue) as authoritative for pending/assigned tasks." : void 0;
|
|
37029
|
+
if (staleDirectWorkNote) {
|
|
37030
|
+
summary.staleDirectNote = staleDirectWorkNote;
|
|
37031
|
+
}
|
|
37032
|
+
return { activeWork: records, staleDirectWork, staleDirectWorkNote, terminalDirectWork, summary };
|
|
37033
|
+
}
|
|
37034
|
+
function classifyStaleDirectForPrune(record2, opts = {}) {
|
|
37035
|
+
if (record2.staleDispatchUnacknowledged === true) return "preserve_unacknowledged";
|
|
37036
|
+
if (record2.terminal === true) return opts.includeTerminal ? "prunable_terminal" : "preserve_active";
|
|
37037
|
+
if (record2.staleReason && PRUNABLE_ORPHAN_STALE_REASONS.has(record2.staleReason)) return "prunable_orphan";
|
|
37038
|
+
return "preserve_active";
|
|
37039
|
+
}
|
|
37040
|
+
function pruneStaleDirectDispatches(opts) {
|
|
37041
|
+
const now = opts.now ?? Date.now();
|
|
37042
|
+
const includeTerminal = opts.includeTerminal === true;
|
|
37043
|
+
const execute = opts.execute === true;
|
|
37044
|
+
const minAgeMs = Math.max(0, opts.minAgeMs ?? 0);
|
|
37045
|
+
const activeWorkEvidence = buildMeshActiveWork({
|
|
37046
|
+
meshId: opts.meshId,
|
|
37047
|
+
queue: opts.queue,
|
|
37048
|
+
ledgerEntries: opts.ledgerEntries,
|
|
37049
|
+
directDispatches: opts.directDispatches,
|
|
37050
|
+
nodes: opts.nodes,
|
|
37051
|
+
now,
|
|
37052
|
+
includeTerminalDirect: includeTerminal
|
|
37053
|
+
});
|
|
37054
|
+
const candidates = [
|
|
37055
|
+
...activeWorkEvidence.staleDirectWork,
|
|
37056
|
+
...includeTerminal ? activeWorkEvidence.terminalDirectWork : []
|
|
37057
|
+
];
|
|
37058
|
+
const storeTaskIds = new Set(opts.directDispatches.map((d) => d.taskId));
|
|
37059
|
+
const prunable = [];
|
|
37060
|
+
const skippedTooYoung = [];
|
|
37061
|
+
const preservedUnacknowledged = [];
|
|
37062
|
+
const preservedLedgerOnly = [];
|
|
37063
|
+
const preservedNotOrphan = [];
|
|
37064
|
+
for (const record2 of candidates) {
|
|
37065
|
+
const classification = classifyStaleDirectForPrune(record2, { includeTerminal });
|
|
37066
|
+
if (classification === "preserve_unacknowledged") {
|
|
37067
|
+
preservedUnacknowledged.push(record2);
|
|
37068
|
+
continue;
|
|
37069
|
+
}
|
|
37070
|
+
if (classification === "preserve_active") {
|
|
37071
|
+
preservedNotOrphan.push(record2);
|
|
37072
|
+
continue;
|
|
37073
|
+
}
|
|
37074
|
+
if (!storeTaskIds.has(record2.taskId)) {
|
|
37075
|
+
preservedLedgerOnly.push(record2);
|
|
37076
|
+
continue;
|
|
37077
|
+
}
|
|
37078
|
+
if (minAgeMs > 0) {
|
|
37079
|
+
const ageRef = record2.dispatchedAt || record2.createdAt;
|
|
37080
|
+
const ageMs = elapsedSince(ageRef, now);
|
|
37081
|
+
if (ageMs < minAgeMs) {
|
|
37082
|
+
skippedTooYoung.push(record2);
|
|
37083
|
+
continue;
|
|
37084
|
+
}
|
|
37085
|
+
}
|
|
37086
|
+
prunable.push(record2);
|
|
37087
|
+
}
|
|
37088
|
+
let prunedCount = 0;
|
|
37089
|
+
if (execute && prunable.length) {
|
|
37090
|
+
prunedCount = deleteDirectDispatchesByTaskId(opts.meshId, prunable.map((r) => r.taskId));
|
|
37091
|
+
appendLedgerEntry(opts.meshId, {
|
|
37092
|
+
kind: "direct_dispatch_pruned",
|
|
37093
|
+
payload: {
|
|
37094
|
+
source: opts.source || "prune_stale_direct",
|
|
37095
|
+
prunedCount,
|
|
37096
|
+
taskIds: prunable.map((r) => r.taskId),
|
|
37097
|
+
reasons: Array.from(new Set(prunable.map((r) => r.staleReason || (r.terminal ? "terminal" : "unknown"))))
|
|
37098
|
+
}
|
|
37099
|
+
});
|
|
37100
|
+
}
|
|
37101
|
+
return {
|
|
37102
|
+
mode: execute ? "execute" : "dry_run",
|
|
37103
|
+
includeTerminal,
|
|
37104
|
+
candidateCount: candidates.length,
|
|
37105
|
+
prunable,
|
|
37106
|
+
prunedCount,
|
|
37107
|
+
skippedTooYoung,
|
|
37108
|
+
preservedUnacknowledged,
|
|
37109
|
+
preservedLedgerOnly,
|
|
37110
|
+
preservedNotOrphan
|
|
37111
|
+
};
|
|
37112
|
+
}
|
|
37113
|
+
function buildCompactStaleDirectWorkSummary(staleDirectWork, opts = {}) {
|
|
37114
|
+
const sampleLimit = Math.max(0, Math.min(10, Math.floor(opts.sampleLimit ?? 3)));
|
|
37115
|
+
const reasonCounts = {};
|
|
37116
|
+
for (const entry of staleDirectWork) {
|
|
37117
|
+
const reason = entry.staleReason || "unknown";
|
|
37118
|
+
reasonCounts[reason] = (reasonCounts[reason] || 0) + 1;
|
|
37119
|
+
}
|
|
37120
|
+
return {
|
|
37121
|
+
count: staleDirectWork.length,
|
|
37122
|
+
sampleLimit,
|
|
37123
|
+
sample: staleDirectWork.slice(0, sampleLimit).map((entry) => ({
|
|
37124
|
+
taskId: entry.taskId,
|
|
37125
|
+
status: entry.status,
|
|
37126
|
+
nodeId: entry.nodeId,
|
|
37127
|
+
sessionId: entry.sessionId,
|
|
37128
|
+
taskTitle: entry.taskTitle,
|
|
37129
|
+
createdAt: entry.createdAt,
|
|
37130
|
+
staleReason: entry.staleReason
|
|
37131
|
+
})),
|
|
37132
|
+
reasonCounts,
|
|
37133
|
+
detailHint: opts.detailHint || "Stale direct records are historical recovery evidence only. Use mesh_task_history for full ledger details, or request includeStaleDirectWorkDetails when supported by the caller.",
|
|
37134
|
+
...opts.note ? { note: opts.note } : {}
|
|
37135
|
+
};
|
|
37136
|
+
}
|
|
37137
|
+
var DIRECT_DISPATCH_VIA;
|
|
37138
|
+
var TERMINAL_LEDGER_KINDS;
|
|
37139
|
+
var PRUNABLE_ORPHAN_STALE_REASONS;
|
|
37140
|
+
var init_mesh_active_work = __esm2({
|
|
37141
|
+
"src/mesh/mesh-active-work.ts"() {
|
|
37142
|
+
"use strict";
|
|
37143
|
+
init_mesh_ledger();
|
|
37144
|
+
init_mesh_work_queue();
|
|
37145
|
+
init_dist();
|
|
37146
|
+
DIRECT_DISPATCH_VIA = /* @__PURE__ */ new Set(["p2p_direct", "local_direct", "mesh_send_task"]);
|
|
37147
|
+
TERMINAL_LEDGER_KINDS = /* @__PURE__ */ new Set(["task_completed", "task_failed", "task_stalled"]);
|
|
37148
|
+
PRUNABLE_ORPHAN_STALE_REASONS = /* @__PURE__ */ new Set([
|
|
37149
|
+
"direct task node is no longer in the live mesh",
|
|
37150
|
+
"direct task session is not present in live session records",
|
|
37151
|
+
"direct task has no node id"
|
|
37152
|
+
]);
|
|
37153
|
+
}
|
|
37154
|
+
});
|
|
36745
37155
|
function readNonEmptyString2(value) {
|
|
36746
37156
|
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
36747
37157
|
}
|
|
@@ -40566,6 +40976,14 @@ Next step: ${nextStep}`;
|
|
|
40566
40976
|
INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
|
|
40567
40977
|
}
|
|
40568
40978
|
});
|
|
40979
|
+
function resolveAutoPruneMinAgeMs() {
|
|
40980
|
+
const raw = readNonEmptyString2(process.env.MESH_AUTO_PRUNE_MIN_AGE_MS);
|
|
40981
|
+
if (raw) {
|
|
40982
|
+
const parsed = Number.parseInt(raw, 10);
|
|
40983
|
+
if (Number.isFinite(parsed) && parsed >= 60 * 6e4 && parsed <= 30 * 24 * 60 * 6e4) return parsed;
|
|
40984
|
+
}
|
|
40985
|
+
return DEFAULT_AUTO_PRUNE_MIN_AGE_MS;
|
|
40986
|
+
}
|
|
40569
40987
|
function resolveReconcileIntervalMs() {
|
|
40570
40988
|
const raw = readNonEmptyString2(process.env.MESH_RECONCILE_INTERVAL_MS);
|
|
40571
40989
|
if (raw) {
|
|
@@ -40677,6 +41095,18 @@ Next step: ${nextStep}`;
|
|
|
40677
41095
|
LOG2.warn("MeshReconcile", `Completion reconcile failed for mesh ${mesh.id}: ${e?.message || e}`);
|
|
40678
41096
|
}
|
|
40679
41097
|
}
|
|
41098
|
+
{
|
|
41099
|
+
const minAgeMs = resolveAutoPruneMinAgeMs();
|
|
41100
|
+
for (const mesh of listMeshes()) {
|
|
41101
|
+
const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
|
|
41102
|
+
if (!daemonHostsMesh(mesh, selfIds)) continue;
|
|
41103
|
+
try {
|
|
41104
|
+
await autoPruneStaleDirectDispatches(components, mesh, selfIds, localDaemonId, minAgeMs);
|
|
41105
|
+
} catch (e) {
|
|
41106
|
+
LOG2.warn("MeshReconcile", `Auto-prune stale direct failed for mesh ${mesh.id}: ${e?.message || e}`);
|
|
41107
|
+
}
|
|
41108
|
+
}
|
|
41109
|
+
}
|
|
40680
41110
|
const coordinators = findLiveCoordinators(components);
|
|
40681
41111
|
if (coordinators.length === 0) {
|
|
40682
41112
|
return;
|
|
@@ -40859,6 +41289,68 @@ Next step: ${nextStep}`;
|
|
|
40859
41289
|
}
|
|
40860
41290
|
}
|
|
40861
41291
|
}
|
|
41292
|
+
async function autoPruneStaleDirectDispatches(components, mesh, selfIds, localDaemonId, minAgeMs) {
|
|
41293
|
+
const directDispatches = getActiveDirectDispatches(mesh.id);
|
|
41294
|
+
if (directDispatches.length === 0) return;
|
|
41295
|
+
const liveNodes = await collectLiveNodesWithSessions(components, mesh, selfIds, localDaemonId);
|
|
41296
|
+
const result = pruneStaleDirectDispatches({
|
|
41297
|
+
meshId: mesh.id,
|
|
41298
|
+
queue: getQueue(mesh.id),
|
|
41299
|
+
ledgerEntries: readLedgerEntries(mesh.id, { tail: 500 }),
|
|
41300
|
+
directDispatches,
|
|
41301
|
+
nodes: liveNodes,
|
|
41302
|
+
execute: true,
|
|
41303
|
+
minAgeMs,
|
|
41304
|
+
source: "daemon_reconcile_auto_prune"
|
|
41305
|
+
});
|
|
41306
|
+
if (result.prunedCount > 0) {
|
|
41307
|
+
LOG2.info("MeshReconcile", `Auto-pruned ${result.prunedCount} orphaned direct dispatch record(s) for mesh ${mesh.id}`);
|
|
41308
|
+
}
|
|
41309
|
+
}
|
|
41310
|
+
async function collectLiveNodesWithSessions(components, mesh, selfIds, localDaemonId) {
|
|
41311
|
+
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
41312
|
+
return Promise.all(mesh.nodes.map(async (node) => {
|
|
41313
|
+
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
41314
|
+
const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || localDaemonId !== void 0 && nodeDaemonId === localDaemonId;
|
|
41315
|
+
let statusResult;
|
|
41316
|
+
try {
|
|
41317
|
+
if (isLocalNode) {
|
|
41318
|
+
statusResult = await components.commandHandler.handle("get_status_metadata", {});
|
|
41319
|
+
} else if (dispatchMeshCommand) {
|
|
41320
|
+
statusResult = await dispatchMeshCommand(nodeDaemonId, "get_status_metadata", {});
|
|
41321
|
+
} else {
|
|
41322
|
+
return node;
|
|
41323
|
+
}
|
|
41324
|
+
} catch {
|
|
41325
|
+
return node;
|
|
41326
|
+
}
|
|
41327
|
+
const sessions = extractStatusMetadataSessions(statusResult);
|
|
41328
|
+
return sessions.length > 0 ? { ...node, sessions } : node;
|
|
41329
|
+
}));
|
|
41330
|
+
}
|
|
41331
|
+
function extractStatusMetadataSessions(raw) {
|
|
41332
|
+
let cursor = raw;
|
|
41333
|
+
for (let depth = 0; depth < 4 && cursor && typeof cursor === "object"; depth++) {
|
|
41334
|
+
const record2 = cursor;
|
|
41335
|
+
const status = record2.status && typeof record2.status === "object" ? record2.status : void 0;
|
|
41336
|
+
if (status && Array.isArray(status.sessions)) return status.sessions;
|
|
41337
|
+
if (Array.isArray(record2.sessions)) return record2.sessions;
|
|
41338
|
+
if (record2.payload && typeof record2.payload === "object") {
|
|
41339
|
+
cursor = record2.payload;
|
|
41340
|
+
continue;
|
|
41341
|
+
}
|
|
41342
|
+
if (record2.result && typeof record2.result === "object") {
|
|
41343
|
+
cursor = record2.result;
|
|
41344
|
+
continue;
|
|
41345
|
+
}
|
|
41346
|
+
if (record2.data && typeof record2.data === "object") {
|
|
41347
|
+
cursor = record2.data;
|
|
41348
|
+
continue;
|
|
41349
|
+
}
|
|
41350
|
+
break;
|
|
41351
|
+
}
|
|
41352
|
+
return [];
|
|
41353
|
+
}
|
|
40862
41354
|
function extractPendingEvents(raw) {
|
|
40863
41355
|
if (Array.isArray(raw)) return raw;
|
|
40864
41356
|
if (raw && typeof raw === "object") {
|
|
@@ -40897,6 +41389,7 @@ Next step: ${nextStep}`;
|
|
|
40897
41389
|
};
|
|
40898
41390
|
}
|
|
40899
41391
|
var DEFAULT_RECONCILE_INTERVAL_MS;
|
|
41392
|
+
var DEFAULT_AUTO_PRUNE_MIN_AGE_MS;
|
|
40900
41393
|
var init_mesh_reconcile_loop = __esm2({
|
|
40901
41394
|
"src/mesh/mesh-reconcile-loop.ts"() {
|
|
40902
41395
|
"use strict";
|
|
@@ -40909,9 +41402,12 @@ Next step: ${nextStep}`;
|
|
|
40909
41402
|
init_mesh_unresolved_forward_outbox();
|
|
40910
41403
|
init_mesh_events_utils();
|
|
40911
41404
|
init_mesh_work_queue();
|
|
41405
|
+
init_mesh_ledger();
|
|
41406
|
+
init_mesh_active_work();
|
|
40912
41407
|
init_mesh_events_stale();
|
|
40913
41408
|
init_chat_message_normalization();
|
|
40914
41409
|
DEFAULT_RECONCILE_INTERVAL_MS = 4e3;
|
|
41410
|
+
DEFAULT_AUTO_PRUNE_MIN_AGE_MS = 24 * 60 * 6e4;
|
|
40915
41411
|
}
|
|
40916
41412
|
});
|
|
40917
41413
|
var mesh_events_exports = {};
|
|
@@ -46827,6 +47323,7 @@ ${lastSnapshot}`;
|
|
|
46827
47323
|
prepareSessionChatTailUpdate: () => prepareSessionChatTailUpdate2,
|
|
46828
47324
|
prepareSessionModalUpdate: () => prepareSessionModalUpdate2,
|
|
46829
47325
|
probeCdpPort: () => probeCdpPort,
|
|
47326
|
+
pruneStaleDirectDispatches: () => pruneStaleDirectDispatches,
|
|
46830
47327
|
queuePendingMeshCoordinatorEvent: () => queuePendingMeshCoordinatorEvent,
|
|
46831
47328
|
readAntigravityCliSession: () => readSession3,
|
|
46832
47329
|
readCachedInlineMeshActiveSessionDetails: () => readCachedInlineMeshActiveSessionDetails2,
|
|
@@ -49185,327 +49682,7 @@ ${lastSnapshot}`;
|
|
|
49185
49682
|
};
|
|
49186
49683
|
}
|
|
49187
49684
|
init_mesh_work_queue();
|
|
49188
|
-
|
|
49189
|
-
var DIRECT_DISPATCH_VIA = /* @__PURE__ */ new Set(["p2p_direct", "local_direct", "mesh_send_task"]);
|
|
49190
|
-
var TERMINAL_LEDGER_KINDS = /* @__PURE__ */ new Set(["task_completed", "task_failed", "task_stalled"]);
|
|
49191
|
-
function readString6(value) {
|
|
49192
|
-
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
49193
|
-
}
|
|
49194
|
-
function summarizeMessage(message) {
|
|
49195
|
-
const oneLine2 = message.replace(/\s+/g, " ").trim();
|
|
49196
|
-
const title = oneLine2.length > 96 ? `${oneLine2.slice(0, 93)}...` : oneLine2;
|
|
49197
|
-
return { title: title || "(untitled task)", summary: oneLine2 };
|
|
49198
|
-
}
|
|
49199
|
-
function elapsedSince(value, now) {
|
|
49200
|
-
const started = value ? new Date(value).getTime() : Number.NaN;
|
|
49201
|
-
return Number.isFinite(started) ? Math.max(0, now - started) : 0;
|
|
49202
|
-
}
|
|
49203
|
-
function sessionStatusFromNodes(nodes, nodeId, sessionId) {
|
|
49204
|
-
if (!Array.isArray(nodes)) return {};
|
|
49205
|
-
if (!nodeId) return { staleReason: "direct task has no node id" };
|
|
49206
|
-
const node = nodes.find((item) => meshNodeIdMatches(item, nodeId));
|
|
49207
|
-
if (!node) return { staleReason: "direct task node is no longer in the live mesh" };
|
|
49208
|
-
if (!sessionId) return {};
|
|
49209
|
-
const candidates = [];
|
|
49210
|
-
for (const value of [
|
|
49211
|
-
node.sessions,
|
|
49212
|
-
node.activeSessions,
|
|
49213
|
-
node.active_sessions,
|
|
49214
|
-
node.activeSessionDetails,
|
|
49215
|
-
node.active_session_details,
|
|
49216
|
-
node.sessionDetails,
|
|
49217
|
-
node.session_details,
|
|
49218
|
-
node.lastProbe?.sessions,
|
|
49219
|
-
node.last_probe?.sessions,
|
|
49220
|
-
node.lastProbe?.status?.sessions,
|
|
49221
|
-
node.last_probe?.status?.sessions
|
|
49222
|
-
]) {
|
|
49223
|
-
if (Array.isArray(value)) candidates.push(...value);
|
|
49224
|
-
}
|
|
49225
|
-
for (const value of [node.activeSession, node.active_session, node.currentSession, node.current_session, node.runtimeSession, node.runtime_session, node.session]) {
|
|
49226
|
-
if (value && typeof value === "object") candidates.push(value);
|
|
49227
|
-
}
|
|
49228
|
-
const session = candidates.find((item) => {
|
|
49229
|
-
if (typeof item === "string") return item === sessionId;
|
|
49230
|
-
const id = readString6(item?.id) || readString6(item?.sessionId) || readString6(item?.session_id) || readString6(item?.runtimeSessionId) || readString6(item?.instanceId);
|
|
49231
|
-
return id === sessionId;
|
|
49232
|
-
});
|
|
49233
|
-
if (!session) return { staleReason: "direct task session is not present in live session records" };
|
|
49234
|
-
if (typeof session === "string") return {};
|
|
49235
|
-
const raw = `${readString6(session.status) || ""} ${readString6(session.lifecycle) || ""} ${readString6(session.state) || ""} ${readString6(session.activeChat?.status) || ""}`.toLowerCase();
|
|
49236
|
-
if (raw.includes("approval")) return { status: "awaiting_approval" };
|
|
49237
|
-
if (raw.includes("generating") || raw.includes("running") || raw.includes("busy")) return { status: "generating" };
|
|
49238
|
-
if (raw.includes("failed") || raw.includes("stopped") || raw.includes("terminated") || raw.includes("exited")) return { status: "failed" };
|
|
49239
|
-
if (raw.includes("idle") || raw.includes("waiting_input") || raw.includes("ready")) return { status: "idle" };
|
|
49240
|
-
return {};
|
|
49241
|
-
}
|
|
49242
|
-
function isDirectDispatch(entry) {
|
|
49243
|
-
if (entry.kind !== "task_dispatched") return false;
|
|
49244
|
-
const payload = entry.payload || {};
|
|
49245
|
-
if (payload.source === "direct") return true;
|
|
49246
|
-
const via = readString6(payload.via);
|
|
49247
|
-
return Boolean(via && DIRECT_DISPATCH_VIA.has(via) && payload.source !== "queue");
|
|
49248
|
-
}
|
|
49249
|
-
function directDispatchTaskId(entry) {
|
|
49250
|
-
return readString6(entry.payload?.taskId) || entry.id;
|
|
49251
|
-
}
|
|
49252
|
-
function terminalMatchesDispatch(terminal, dispatch, taskId) {
|
|
49253
|
-
const terminalTaskId = readString6(terminal.payload?.taskId);
|
|
49254
|
-
if (terminalTaskId && terminalTaskId === taskId) return true;
|
|
49255
|
-
if (terminalTaskId && terminalTaskId !== taskId) return false;
|
|
49256
|
-
if (dispatch.sessionId && terminal.sessionId === dispatch.sessionId) return true;
|
|
49257
|
-
return Boolean(dispatch.nodeId && terminal.nodeId === dispatch.nodeId && !dispatch.sessionId);
|
|
49258
|
-
}
|
|
49259
|
-
function statusFromTerminal(entry) {
|
|
49260
|
-
if (entry.kind === "task_approval_needed") return "awaiting_approval";
|
|
49261
|
-
if (entry.kind === "task_completed") return "idle";
|
|
49262
|
-
return "failed";
|
|
49263
|
-
}
|
|
49264
|
-
function buildMeshActiveWorkSummary(activeWork) {
|
|
49265
|
-
const statusCounts = {
|
|
49266
|
-
pending: 0,
|
|
49267
|
-
assigned: 0,
|
|
49268
|
-
generating: 0,
|
|
49269
|
-
idle: 0,
|
|
49270
|
-
failed: 0,
|
|
49271
|
-
awaiting_approval: 0
|
|
49272
|
-
};
|
|
49273
|
-
const sourceCounts = { queue: 0, direct: 0 };
|
|
49274
|
-
for (const item of activeWork) {
|
|
49275
|
-
sourceCounts[item.source] += 1;
|
|
49276
|
-
statusCounts[item.status] += 1;
|
|
49277
|
-
}
|
|
49278
|
-
const staleDirectCount = activeWork.filter((item) => item.source === "direct" && item.staleReason).length;
|
|
49279
|
-
const staleDirectUnacknowledgedCount = activeWork.filter((item) => item.source === "direct" && item.staleDispatchUnacknowledged).length;
|
|
49280
|
-
return {
|
|
49281
|
-
totalActiveCount: activeWork.length,
|
|
49282
|
-
queueActiveCount: sourceCounts.queue,
|
|
49283
|
-
directActiveCount: sourceCounts.direct,
|
|
49284
|
-
awaitingApprovalCount: statusCounts.awaiting_approval,
|
|
49285
|
-
generatingCount: statusCounts.generating,
|
|
49286
|
-
failedCount: statusCounts.failed,
|
|
49287
|
-
idleCount: statusCounts.idle,
|
|
49288
|
-
sourceCounts,
|
|
49289
|
-
statusCounts,
|
|
49290
|
-
staleDirectCount,
|
|
49291
|
-
...staleDirectUnacknowledgedCount > 0 ? { staleDirectUnacknowledgedCount } : {},
|
|
49292
|
-
...staleDirectCount > 0 ? { staleDirectNote: "Stale direct records are orphaned ledger entries whose node/session no longer exists. They are historical recovery evidence only \u2014 not active or unresolved work. The queue (source: queue) is authoritative for pending/assigned tasks." } : {}
|
|
49293
|
-
};
|
|
49294
|
-
}
|
|
49295
|
-
function buildMeshActiveWork(opts) {
|
|
49296
|
-
const now = opts.now ?? Date.now();
|
|
49297
|
-
const records = [];
|
|
49298
|
-
const staleDirectWork = [];
|
|
49299
|
-
const terminalDirectWork = [];
|
|
49300
|
-
for (const task of opts.queue || []) {
|
|
49301
|
-
if (task.status !== "pending" && task.status !== "assigned") continue;
|
|
49302
|
-
const { title, summary: summary2 } = summarizeMessage(task.message || "");
|
|
49303
|
-
records.push({
|
|
49304
|
-
taskId: task.id,
|
|
49305
|
-
source: "queue",
|
|
49306
|
-
status: task.status,
|
|
49307
|
-
nodeId: task.assignedNodeId || task.targetNodeId,
|
|
49308
|
-
sessionId: task.assignedSessionId || task.targetSessionId,
|
|
49309
|
-
taskTitle: title,
|
|
49310
|
-
taskSummary: summary2,
|
|
49311
|
-
message: task.message,
|
|
49312
|
-
taskMode: task.taskMode,
|
|
49313
|
-
createdAt: task.createdAt,
|
|
49314
|
-
updatedAt: task.updatedAt,
|
|
49315
|
-
dispatchedAt: task.dispatchTimestamp,
|
|
49316
|
-
elapsedMs: elapsedSince(task.dispatchTimestamp || task.createdAt, now)
|
|
49317
|
-
});
|
|
49318
|
-
}
|
|
49319
|
-
if (opts.directDispatches !== void 0) {
|
|
49320
|
-
const dbTaskIds = new Set(opts.directDispatches.map((d) => d.taskId));
|
|
49321
|
-
for (const dispatch of opts.directDispatches) {
|
|
49322
|
-
const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId ?? void 0, dispatch.sessionId ?? void 0);
|
|
49323
|
-
const dbStatus = dispatch.status;
|
|
49324
|
-
const isTerminal = dbStatus === "completed" || dbStatus === "failed" || dbStatus === "stale";
|
|
49325
|
-
const status = isTerminal ? dbStatus === "completed" ? "idle" : "failed" : live.status || (dbStatus === "acked" ? "generating" : "assigned");
|
|
49326
|
-
const isNoTransition = !isTerminal && !live.status;
|
|
49327
|
-
const isIdleUnacknowledged = status === "idle" && !isTerminal;
|
|
49328
|
-
const ledgerOnlyStaleReason = !isTerminal && (isIdleUnacknowledged || isNoTransition || dispatch.dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
49329
|
-
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
49330
|
-
const { title, summary: summary2 } = summarizeMessage(dispatch.message || "");
|
|
49331
|
-
const record2 = {
|
|
49332
|
-
taskId: dispatch.taskId,
|
|
49333
|
-
source: "direct",
|
|
49334
|
-
status,
|
|
49335
|
-
nodeId: dispatch.nodeId ?? void 0,
|
|
49336
|
-
sessionId: dispatch.sessionId ?? void 0,
|
|
49337
|
-
providerType: dispatch.providerType ?? void 0,
|
|
49338
|
-
taskTitle: title,
|
|
49339
|
-
taskSummary: summary2,
|
|
49340
|
-
message: dispatch.message,
|
|
49341
|
-
taskMode: dispatch.taskMode ?? void 0,
|
|
49342
|
-
createdAt: dispatch.dispatchedAt,
|
|
49343
|
-
updatedAt: dispatch.updatedAt,
|
|
49344
|
-
dispatchedAt: dispatch.dispatchedAt,
|
|
49345
|
-
elapsedMs: elapsedSince(dispatch.dispatchedAt, now),
|
|
49346
|
-
terminal: isTerminal,
|
|
49347
|
-
terminalKind: isTerminal ? dbStatus === "completed" ? "task_completed" : "task_failed" : void 0,
|
|
49348
|
-
terminalAt: isTerminal ? dispatch.updatedAt : void 0,
|
|
49349
|
-
staleReason: live.staleReason || ledgerOnlyStaleReason,
|
|
49350
|
-
...isFreshUnacknowledged ? { staleDispatchUnacknowledged: true } : {}
|
|
49351
|
-
};
|
|
49352
|
-
if (isTerminal) {
|
|
49353
|
-
terminalDirectWork.push(record2);
|
|
49354
|
-
if (opts.includeTerminalDirect !== true) continue;
|
|
49355
|
-
}
|
|
49356
|
-
if ((live.staleReason || ledgerOnlyStaleReason) && !isTerminal) {
|
|
49357
|
-
staleDirectWork.push(record2);
|
|
49358
|
-
continue;
|
|
49359
|
-
}
|
|
49360
|
-
records.push(record2);
|
|
49361
|
-
}
|
|
49362
|
-
const ledgerEntries = (opts.ledgerEntries || []).slice().sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
49363
|
-
const terminals = ledgerEntries.filter((entry) => TERMINAL_LEDGER_KINDS.has(entry.kind) || entry.kind === "task_approval_needed");
|
|
49364
|
-
for (const dispatch of ledgerEntries.filter(isDirectDispatch)) {
|
|
49365
|
-
const taskId = directDispatchTaskId(dispatch);
|
|
49366
|
-
if (dbTaskIds.has(taskId)) continue;
|
|
49367
|
-
const terminal = terminals.filter((entry) => new Date(entry.timestamp).getTime() >= new Date(dispatch.timestamp).getTime()).find((entry) => terminalMatchesDispatch(entry, dispatch, taskId));
|
|
49368
|
-
const terminalStatus = terminal ? statusFromTerminal(terminal) : void 0;
|
|
49369
|
-
const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId, dispatch.sessionId);
|
|
49370
|
-
const status = terminalStatus || live.status || "assigned";
|
|
49371
|
-
const terminalRow = Boolean(terminal && terminal.kind !== "task_approval_needed");
|
|
49372
|
-
const dispatchedToIdleSession = dispatch.payload?.dispatchedToIdleSession === true;
|
|
49373
|
-
const isNoTransition = !terminalStatus && !live.status;
|
|
49374
|
-
const isIdleUnacknowledged = status === "idle";
|
|
49375
|
-
const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
49376
|
-
const message = readString6(dispatch.payload?.message) || readString6(dispatch.payload?.summary) || "";
|
|
49377
|
-
const { title, summary: summary2 } = summarizeMessage(message);
|
|
49378
|
-
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
49379
|
-
const record2 = {
|
|
49380
|
-
taskId,
|
|
49381
|
-
source: "direct",
|
|
49382
|
-
status,
|
|
49383
|
-
nodeId: dispatch.nodeId,
|
|
49384
|
-
sessionId: dispatch.sessionId,
|
|
49385
|
-
providerType: dispatch.providerType || readString6(dispatch.payload?.providerType),
|
|
49386
|
-
taskTitle: readString6(dispatch.payload?.taskTitle) || title,
|
|
49387
|
-
taskSummary: readString6(dispatch.payload?.taskSummary) || summary2,
|
|
49388
|
-
message,
|
|
49389
|
-
taskMode: readString6(dispatch.payload?.taskMode),
|
|
49390
|
-
createdAt: dispatch.timestamp,
|
|
49391
|
-
updatedAt: terminal?.timestamp || dispatch.timestamp,
|
|
49392
|
-
dispatchedAt: dispatch.timestamp,
|
|
49393
|
-
elapsedMs: elapsedSince(dispatch.timestamp, now),
|
|
49394
|
-
terminal: terminalRow,
|
|
49395
|
-
terminalKind: terminal?.kind,
|
|
49396
|
-
terminalAt: terminal?.timestamp,
|
|
49397
|
-
staleReason: live.staleReason || ledgerOnlyStaleReason,
|
|
49398
|
-
...isFreshUnacknowledged ? { staleDispatchUnacknowledged: true } : {}
|
|
49399
|
-
};
|
|
49400
|
-
if (terminalRow) {
|
|
49401
|
-
terminalDirectWork.push(record2);
|
|
49402
|
-
if (opts.includeTerminalDirect !== true) continue;
|
|
49403
|
-
}
|
|
49404
|
-
if ((live.staleReason || ledgerOnlyStaleReason) && !terminalRow) {
|
|
49405
|
-
staleDirectWork.push(record2);
|
|
49406
|
-
continue;
|
|
49407
|
-
}
|
|
49408
|
-
records.push(record2);
|
|
49409
|
-
}
|
|
49410
|
-
} else {
|
|
49411
|
-
const ledgerEntries = (opts.ledgerEntries || []).slice().sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
49412
|
-
const terminals = ledgerEntries.filter((entry) => TERMINAL_LEDGER_KINDS.has(entry.kind) || entry.kind === "task_approval_needed");
|
|
49413
|
-
for (const dispatch of ledgerEntries.filter(isDirectDispatch)) {
|
|
49414
|
-
const taskId = directDispatchTaskId(dispatch);
|
|
49415
|
-
const terminal = terminals.filter((entry) => new Date(entry.timestamp).getTime() >= new Date(dispatch.timestamp).getTime()).find((entry) => terminalMatchesDispatch(entry, dispatch, taskId));
|
|
49416
|
-
const terminalStatus = terminal ? statusFromTerminal(terminal) : void 0;
|
|
49417
|
-
const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId, dispatch.sessionId);
|
|
49418
|
-
const status = terminalStatus || live.status || "assigned";
|
|
49419
|
-
const terminalRow = Boolean(terminal && terminal.kind !== "task_approval_needed");
|
|
49420
|
-
const dispatchedToIdleSession = dispatch.payload?.dispatchedToIdleSession === true;
|
|
49421
|
-
const isNoTransition = !terminalStatus && !live.status;
|
|
49422
|
-
const isIdleUnacknowledged = status === "idle";
|
|
49423
|
-
const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
49424
|
-
const message = readString6(dispatch.payload?.message) || readString6(dispatch.payload?.summary) || "";
|
|
49425
|
-
const { title, summary: summary2 } = summarizeMessage(message);
|
|
49426
|
-
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
49427
|
-
const record2 = {
|
|
49428
|
-
taskId,
|
|
49429
|
-
source: "direct",
|
|
49430
|
-
status,
|
|
49431
|
-
nodeId: dispatch.nodeId,
|
|
49432
|
-
sessionId: dispatch.sessionId,
|
|
49433
|
-
providerType: dispatch.providerType || readString6(dispatch.payload?.providerType),
|
|
49434
|
-
taskTitle: readString6(dispatch.payload?.taskTitle) || title,
|
|
49435
|
-
taskSummary: readString6(dispatch.payload?.taskSummary) || summary2,
|
|
49436
|
-
message,
|
|
49437
|
-
taskMode: readString6(dispatch.payload?.taskMode),
|
|
49438
|
-
createdAt: dispatch.timestamp,
|
|
49439
|
-
updatedAt: terminal?.timestamp || dispatch.timestamp,
|
|
49440
|
-
dispatchedAt: dispatch.timestamp,
|
|
49441
|
-
elapsedMs: elapsedSince(dispatch.timestamp, now),
|
|
49442
|
-
terminal: terminalRow,
|
|
49443
|
-
terminalKind: terminal?.kind,
|
|
49444
|
-
terminalAt: terminal?.timestamp,
|
|
49445
|
-
staleReason: live.staleReason || ledgerOnlyStaleReason,
|
|
49446
|
-
...isFreshUnacknowledged ? { staleDispatchUnacknowledged: true } : {}
|
|
49447
|
-
};
|
|
49448
|
-
if (terminalRow) {
|
|
49449
|
-
terminalDirectWork.push(record2);
|
|
49450
|
-
if (opts.includeTerminalDirect !== true) continue;
|
|
49451
|
-
}
|
|
49452
|
-
if ((live.staleReason || ledgerOnlyStaleReason) && !terminalRow) {
|
|
49453
|
-
staleDirectWork.push(record2);
|
|
49454
|
-
continue;
|
|
49455
|
-
}
|
|
49456
|
-
records.push(record2);
|
|
49457
|
-
}
|
|
49458
|
-
}
|
|
49459
|
-
records.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
49460
|
-
staleDirectWork.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
49461
|
-
terminalDirectWork.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
49462
|
-
const summary = buildMeshActiveWorkSummary(records);
|
|
49463
|
-
summary.staleDirectCount = staleDirectWork.length;
|
|
49464
|
-
const unacknowledgedCount = staleDirectWork.filter((r) => r.staleDispatchUnacknowledged).length;
|
|
49465
|
-
if (unacknowledgedCount > 0) {
|
|
49466
|
-
summary.staleDirectUnacknowledgedCount = unacknowledgedCount;
|
|
49467
|
-
}
|
|
49468
|
-
const staleDirectWorkNote = staleDirectWork.length > 0 ? unacknowledgedCount > 0 && unacknowledgedCount === staleDirectWork.length ? `${unacknowledgedCount} direct dispatch(es) were not acknowledged by the target session \u2014 the session received the agent_command but never transitioned to generating. This is a fresh dispatch failure, not historical noise. Recovery: launch a fresh session on the same node and retry the task, or use mesh_enqueue_task for queue-based assignment.` : unacknowledgedCount > 0 ? `${unacknowledgedCount} of ${staleDirectWork.length} stale direct record(s) are fresh unacknowledged dispatch failures (session still live but never transitioned to generating); the rest are orphaned historical entries whose node/session no longer exists. Fresh unacknowledged dispatches need recovery: launch a fresh session and retry. Orphaned entries are historical evidence only \u2014 not active or unresolved work.` : "These are orphaned ledger entries whose original node or session no longer exists in the live mesh. They are historical/recovery evidence only \u2014 not active or unresolved work. Do not treat staleDirectCount as a status mismatch; use the queue (source: queue) as authoritative for pending/assigned tasks." : void 0;
|
|
49469
|
-
if (staleDirectWorkNote) {
|
|
49470
|
-
summary.staleDirectNote = staleDirectWorkNote;
|
|
49471
|
-
}
|
|
49472
|
-
return { activeWork: records, staleDirectWork, staleDirectWorkNote, terminalDirectWork, summary };
|
|
49473
|
-
}
|
|
49474
|
-
var PRUNABLE_ORPHAN_STALE_REASONS = /* @__PURE__ */ new Set([
|
|
49475
|
-
"direct task node is no longer in the live mesh",
|
|
49476
|
-
"direct task session is not present in live session records",
|
|
49477
|
-
"direct task has no node id"
|
|
49478
|
-
]);
|
|
49479
|
-
function classifyStaleDirectForPrune(record2, opts = {}) {
|
|
49480
|
-
if (record2.staleDispatchUnacknowledged === true) return "preserve_unacknowledged";
|
|
49481
|
-
if (record2.terminal === true) return opts.includeTerminal ? "prunable_terminal" : "preserve_active";
|
|
49482
|
-
if (record2.staleReason && PRUNABLE_ORPHAN_STALE_REASONS.has(record2.staleReason)) return "prunable_orphan";
|
|
49483
|
-
return "preserve_active";
|
|
49484
|
-
}
|
|
49485
|
-
function buildCompactStaleDirectWorkSummary(staleDirectWork, opts = {}) {
|
|
49486
|
-
const sampleLimit = Math.max(0, Math.min(10, Math.floor(opts.sampleLimit ?? 3)));
|
|
49487
|
-
const reasonCounts = {};
|
|
49488
|
-
for (const entry of staleDirectWork) {
|
|
49489
|
-
const reason = entry.staleReason || "unknown";
|
|
49490
|
-
reasonCounts[reason] = (reasonCounts[reason] || 0) + 1;
|
|
49491
|
-
}
|
|
49492
|
-
return {
|
|
49493
|
-
count: staleDirectWork.length,
|
|
49494
|
-
sampleLimit,
|
|
49495
|
-
sample: staleDirectWork.slice(0, sampleLimit).map((entry) => ({
|
|
49496
|
-
taskId: entry.taskId,
|
|
49497
|
-
status: entry.status,
|
|
49498
|
-
nodeId: entry.nodeId,
|
|
49499
|
-
sessionId: entry.sessionId,
|
|
49500
|
-
taskTitle: entry.taskTitle,
|
|
49501
|
-
createdAt: entry.createdAt,
|
|
49502
|
-
staleReason: entry.staleReason
|
|
49503
|
-
})),
|
|
49504
|
-
reasonCounts,
|
|
49505
|
-
detailHint: opts.detailHint || "Stale direct records are historical recovery evidence only. Use mesh_task_history for full ledger details, or request includeStaleDirectWorkDetails when supported by the caller.",
|
|
49506
|
-
...opts.note ? { note: opts.note } : {}
|
|
49507
|
-
};
|
|
49508
|
-
}
|
|
49685
|
+
init_mesh_active_work();
|
|
49509
49686
|
init_mesh_refine_status();
|
|
49510
49687
|
init_mesh_host_ownership();
|
|
49511
49688
|
init_mesh_events();
|
|
@@ -72755,7 +72932,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72755
72932
|
};
|
|
72756
72933
|
}
|
|
72757
72934
|
function recordInlineMeshDirectGitTruth(node, git, source) {
|
|
72758
|
-
if (!node || typeof node !== "object" || Array.isArray(node))
|
|
72935
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
72936
|
+
return { reporterPlatform: null, reporterArch: null };
|
|
72937
|
+
}
|
|
72759
72938
|
const checkedAt = readNumberValue(git.lastCheckedAt) ?? Date.now();
|
|
72760
72939
|
const updatedAt = new Date(checkedAt).toISOString();
|
|
72761
72940
|
const nextGit = {
|
|
@@ -72777,6 +72956,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72777
72956
|
const reporterPlatform = readStringValue(git.reporterPlatform) ?? (isLocalSource ? process.platform : null);
|
|
72778
72957
|
const reporterArch = readStringValue(git.reporterArch) ?? (isLocalSource ? process.arch : null);
|
|
72779
72958
|
stampNodeReporterPlatform(node, reporterPlatform, reporterArch);
|
|
72959
|
+
if (reporterPlatform) node.reportedPlatform = reporterPlatform;
|
|
72960
|
+
if (reporterArch) node.reportedArch = reporterArch;
|
|
72961
|
+
return { reporterPlatform, reporterArch };
|
|
72780
72962
|
}
|
|
72781
72963
|
function stampNodeReporterPlatform(node, platform10, arch2) {
|
|
72782
72964
|
if (!node || typeof node !== "object" || Array.isArray(node)) return;
|
|
@@ -72793,6 +72975,16 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72793
72975
|
}
|
|
72794
72976
|
if (changed) node.userOverrides = overrides;
|
|
72795
72977
|
}
|
|
72978
|
+
function persistNodeReporterPlatform(meshSource, mesh, nodeId, reporter) {
|
|
72979
|
+
if (meshSource !== "local_config") return;
|
|
72980
|
+
const meshId = readStringValue(mesh?.id);
|
|
72981
|
+
if (!meshId || !nodeId) return;
|
|
72982
|
+
const reportedPlatform = reporter.reporterPlatform ?? void 0;
|
|
72983
|
+
const reportedArch = reporter.reporterArch ?? void 0;
|
|
72984
|
+
if (!reportedPlatform && !reportedArch) return;
|
|
72985
|
+
void Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports)).then(({ updateNode: updateNode2 }) => updateNode2(meshId, nodeId, { reportedPlatform, reportedArch })).catch(() => {
|
|
72986
|
+
});
|
|
72987
|
+
}
|
|
72796
72988
|
function buildCachedInlineMeshGitStatus(node) {
|
|
72797
72989
|
const liveGit = buildInlineMeshTransitGitStatus(node);
|
|
72798
72990
|
if (liveGit) return liveGit;
|
|
@@ -73374,7 +73566,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73374
73566
|
try {
|
|
73375
73567
|
const localGit = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
73376
73568
|
if (localGit?.isGitRepo) {
|
|
73377
|
-
recordInlineMeshDirectGitTruth(node, localGit, "selected_coordinator_local_git");
|
|
73569
|
+
const reporter = recordInlineMeshDirectGitTruth(node, localGit, "selected_coordinator_local_git");
|
|
73570
|
+
persistNodeReporterPlatform(args.meshSource, args.mesh, nodeId, reporter);
|
|
73378
73571
|
localConfirmedCount += 1;
|
|
73379
73572
|
continue;
|
|
73380
73573
|
}
|
|
@@ -73404,7 +73597,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73404
73597
|
});
|
|
73405
73598
|
const remoteGit = args.probeCache ? await args.probeCache.probe(daemonId, workspace, runProbe) : await runProbe();
|
|
73406
73599
|
if (remoteGit) {
|
|
73407
|
-
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
73600
|
+
const reporter = recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
73601
|
+
persistNodeReporterPlatform(args.meshSource, args.mesh, nodeId, reporter);
|
|
73408
73602
|
peerConfirmedCount += 1;
|
|
73409
73603
|
continue;
|
|
73410
73604
|
}
|
|
@@ -79621,7 +79815,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79621
79815
|
if (!connectionReported || connectionState === "unknown") {
|
|
79622
79816
|
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
79623
79817
|
}
|
|
79624
|
-
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
79818
|
+
const reporter = recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
79819
|
+
persistNodeReporterPlatform(meshRecord.source, mesh, nodeId, reporter);
|
|
79625
79820
|
remoteProbeApplied = true;
|
|
79626
79821
|
}
|
|
79627
79822
|
}
|
|
@@ -79653,7 +79848,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79653
79848
|
try {
|
|
79654
79849
|
const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
79655
79850
|
status.git = gitStatus;
|
|
79656
|
-
recordInlineMeshDirectGitTruth(node, gitStatus, "selected_coordinator_local_git");
|
|
79851
|
+
const reporter = recordInlineMeshDirectGitTruth(node, gitStatus, "selected_coordinator_local_git");
|
|
79852
|
+
persistNodeReporterPlatform(meshRecord.source, mesh, nodeId, reporter);
|
|
79657
79853
|
if (gitStatus.isGitRepo) {
|
|
79658
79854
|
status.health = deriveMeshNodeHealthFromGit(gitStatus);
|
|
79659
79855
|
} else {
|