@adhdev/daemon-core 0.9.82-rc.56 → 0.9.82-rc.58
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 +73 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -11
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +1 -0
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-runtime.ts +3 -1
- package/src/commands/router.ts +8 -8
- package/src/mesh/mesh-events.ts +14 -0
- package/src/providers/cli-provider-instance.ts +66 -1
package/dist/index.js
CHANGED
|
@@ -2284,10 +2284,15 @@ function isMeshCoordinatorEvent(eventName) {
|
|
|
2284
2284
|
return typeof eventName === "string" && MESH_COORDINATOR_EVENTS.has(eventName);
|
|
2285
2285
|
}
|
|
2286
2286
|
function formatCompletionMetadata(event) {
|
|
2287
|
+
const completionDiagnostic = event.completionDiagnostic && typeof event.completionDiagnostic === "object" ? event.completionDiagnostic : null;
|
|
2288
|
+
const diagnosticReason = completionDiagnostic ? readNonEmptyString(completionDiagnostic.blockReason) || "present" : "";
|
|
2289
|
+
const finalAssistantPresent = typeof completionDiagnostic?.finalAssistantPresent === "boolean" ? String(completionDiagnostic.finalAssistantPresent) : "";
|
|
2287
2290
|
const parts = [
|
|
2288
2291
|
readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
|
|
2289
2292
|
readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
|
|
2290
|
-
readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
|
|
2293
|
+
readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : "",
|
|
2294
|
+
diagnosticReason ? `completion_diagnostic=${diagnosticReason}` : "",
|
|
2295
|
+
finalAssistantPresent ? `final_assistant=${finalAssistantPresent}` : ""
|
|
2291
2296
|
].filter(Boolean);
|
|
2292
2297
|
return parts.length > 0 ? ` (${parts.join("; ")})` : "";
|
|
2293
2298
|
}
|
|
@@ -2831,6 +2836,7 @@ function injectMeshSystemMessage(components, args) {
|
|
|
2831
2836
|
taskId: completedTaskForLedger?.id || void 0,
|
|
2832
2837
|
providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0,
|
|
2833
2838
|
finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || void 0,
|
|
2839
|
+
completionDiagnostic: args.metadataEvent.completionDiagnostic && typeof args.metadataEvent.completionDiagnostic === "object" ? args.metadataEvent.completionDiagnostic : void 0,
|
|
2834
2840
|
evidence: completionEvidence
|
|
2835
2841
|
}
|
|
2836
2842
|
});
|
|
@@ -3912,7 +3918,9 @@ function resolveCliSpawnPlan(options) {
|
|
|
3912
3918
|
const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
|
|
3913
3919
|
const binaryPath = findBinary(configuredCommand);
|
|
3914
3920
|
const isWin = os10.platform() === "win32";
|
|
3915
|
-
const allArgs = [...spawnConfig.args, ...extraArgs]
|
|
3921
|
+
const allArgs = [...spawnConfig.args, ...extraArgs].map(
|
|
3922
|
+
(arg) => typeof arg === "string" ? arg.replace(/\{\{workingDir\}\}/g, workingDir) : arg
|
|
3923
|
+
);
|
|
3916
3924
|
let shellCmd;
|
|
3917
3925
|
let shellArgs;
|
|
3918
3926
|
const useShellUnix = !isWin && (!!spawnConfig.shell || !path15.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
@@ -18777,6 +18785,44 @@ var CliProviderInstance = class {
|
|
|
18777
18785
|
const content = lastVisible ? flattenContent(lastVisible.content).trim() : "";
|
|
18778
18786
|
return role === "assistant" && !!content;
|
|
18779
18787
|
}
|
|
18788
|
+
buildCompletedFinalizationDiagnostic(args) {
|
|
18789
|
+
let parsed = null;
|
|
18790
|
+
let parseError;
|
|
18791
|
+
try {
|
|
18792
|
+
parsed = this.adapter.getScriptParsedStatus();
|
|
18793
|
+
} catch (error) {
|
|
18794
|
+
parseError = error?.message || String(error);
|
|
18795
|
+
}
|
|
18796
|
+
const visibleMessages = (Array.isArray(parsed?.messages) ? parsed.messages : []).filter((message) => isUserFacingChatMessage(message));
|
|
18797
|
+
const lastVisible = visibleMessages[visibleMessages.length - 1];
|
|
18798
|
+
const lastVisibleRole = typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : null;
|
|
18799
|
+
const lastVisibleKind = typeof lastVisible?.kind === "string" ? lastVisible.kind : null;
|
|
18800
|
+
const lastVisibleContentLength = lastVisible ? flattenContent(lastVisible.content).trim().length : 0;
|
|
18801
|
+
return {
|
|
18802
|
+
providerType: this.type,
|
|
18803
|
+
sessionId: this.instanceId,
|
|
18804
|
+
providerSessionId: this.providerSessionId || null,
|
|
18805
|
+
workspace: this.workingDir,
|
|
18806
|
+
blockReason: args.blockReason,
|
|
18807
|
+
emittedAfterFinalizationTimeout: args.emittedAfterFinalizationTimeout,
|
|
18808
|
+
waitedMs: args.waitedMs,
|
|
18809
|
+
maxWaitMs: COMPLETED_FINALIZATION_MAX_WAIT_MS,
|
|
18810
|
+
adapterStatus: typeof args.latestStatus?.status === "string" ? args.latestStatus.status : null,
|
|
18811
|
+
latestVisibleStatus: args.latestVisibleStatus,
|
|
18812
|
+
parsedStatus: typeof parsed?.status === "string" ? parsed.status : parseError ? "parse_error" : "unknown",
|
|
18813
|
+
parseError: parseError || void 0,
|
|
18814
|
+
finalAssistantPresent: this.completionHasFinalAssistantMessage(parsed?.messages),
|
|
18815
|
+
visibleMessageCount: visibleMessages.length,
|
|
18816
|
+
lastVisibleRole,
|
|
18817
|
+
lastVisibleKind,
|
|
18818
|
+
lastVisibleContentLength,
|
|
18819
|
+
pendingStartedAt: this.generatingStartedAt || null,
|
|
18820
|
+
pendingFirstObservedAt: args.pending.firstObservedAt,
|
|
18821
|
+
pendingTimestamp: args.pending.timestamp,
|
|
18822
|
+
pendingDurationSec: args.pending.duration,
|
|
18823
|
+
previousBlockReason: args.pending.loggedBlockReason || null
|
|
18824
|
+
};
|
|
18825
|
+
}
|
|
18780
18826
|
hasAdapterPendingResponse() {
|
|
18781
18827
|
const adapterAny = this.adapter;
|
|
18782
18828
|
if (adapterAny?.isWaitingForResponse === true) return true;
|
|
@@ -18849,7 +18895,23 @@ var CliProviderInstance = class {
|
|
|
18849
18895
|
this.scheduleCompletedDebounceFlush(COMPLETED_FINALIZATION_RETRY_MS);
|
|
18850
18896
|
return;
|
|
18851
18897
|
}
|
|
18852
|
-
|
|
18898
|
+
const completionDiagnostic = this.buildCompletedFinalizationDiagnostic({
|
|
18899
|
+
blockReason,
|
|
18900
|
+
latestStatus,
|
|
18901
|
+
latestVisibleStatus,
|
|
18902
|
+
waitedMs,
|
|
18903
|
+
pending,
|
|
18904
|
+
emittedAfterFinalizationTimeout: true
|
|
18905
|
+
});
|
|
18906
|
+
LOG.warn("CLI", `[${this.type}] emitting completed event after ${waitedMs}ms without finalized assistant turn (${blockReason})`);
|
|
18907
|
+
this.pushEvent({
|
|
18908
|
+
event: "agent:generating_completed",
|
|
18909
|
+
chatTitle: pending.chatTitle,
|
|
18910
|
+
duration: pending.duration,
|
|
18911
|
+
timestamp: pending.timestamp,
|
|
18912
|
+
finalSummary: extractFinalSummaryFromMessages(this.adapter?.getScriptParsedStatus()?.messages),
|
|
18913
|
+
completionDiagnostic
|
|
18914
|
+
});
|
|
18853
18915
|
this.completedDebouncePending = null;
|
|
18854
18916
|
this.completedDebounceTimer = null;
|
|
18855
18917
|
this.generatingStartedAt = 0;
|
|
@@ -25215,15 +25277,15 @@ function reconcileInlineMeshCache(cached, incoming) {
|
|
|
25215
25277
|
const cachedNodes = Array.isArray(cached.nodes) ? cached.nodes : [];
|
|
25216
25278
|
const incomingNodes = Array.isArray(incoming.nodes) ? incoming.nodes : [];
|
|
25217
25279
|
if (!cachedNodes.length || !incomingNodes.length) return { ...cached, ...incoming };
|
|
25218
|
-
const
|
|
25219
|
-
for (const node of
|
|
25280
|
+
const cachedById = /* @__PURE__ */ new Map();
|
|
25281
|
+
for (const node of cachedNodes) {
|
|
25220
25282
|
const nodeId = readInlineMeshNodeId(node);
|
|
25221
|
-
if (nodeId)
|
|
25283
|
+
if (nodeId) cachedById.set(nodeId, node);
|
|
25222
25284
|
}
|
|
25223
|
-
const nodes =
|
|
25224
|
-
const nodeId = readInlineMeshNodeId(
|
|
25225
|
-
const
|
|
25226
|
-
if (!
|
|
25285
|
+
const nodes = incomingNodes.map((incomingNode) => {
|
|
25286
|
+
const nodeId = readInlineMeshNodeId(incomingNode);
|
|
25287
|
+
const cachedNode = nodeId ? cachedById.get(nodeId) : void 0;
|
|
25288
|
+
if (!cachedNode) return incomingNode;
|
|
25227
25289
|
if (hasInlineMeshTransientNodeState(incomingNode)) {
|
|
25228
25290
|
return { ...cachedNode, ...incomingNode };
|
|
25229
25291
|
}
|
|
@@ -25378,7 +25440,7 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
25378
25440
|
if (!isSelfNode && daemonId) unavailableNodeIds.push(nodeId);
|
|
25379
25441
|
continue;
|
|
25380
25442
|
}
|
|
25381
|
-
if (
|
|
25443
|
+
if (fs10.existsSync(workspace)) {
|
|
25382
25444
|
try {
|
|
25383
25445
|
const localGit = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
25384
25446
|
if (localGit?.isGitRepo) {
|