@adhdev/daemon-core 1.0.28-rc.15 → 1.0.28-rc.16
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 +120 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -23
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-queue-assignment.d.ts +1 -0
- package/dist/providers/cli-provider-instance.d.ts +15 -0
- package/package.json +3 -3
- package/src/cli-adapters/provider-cli-adapter.ts +7 -1
- package/src/commands/med-family/cli-agent.ts +32 -13
- package/src/mesh/mesh-event-forwarding.ts +104 -1
- package/src/mesh/mesh-queue-assignment.ts +19 -1
- package/src/providers/cli-provider-instance.ts +109 -7
package/dist/index.mjs
CHANGED
|
@@ -786,10 +786,10 @@ function readInjected(value) {
|
|
|
786
786
|
}
|
|
787
787
|
function getDaemonBuildInfo() {
|
|
788
788
|
if (cached) return cached;
|
|
789
|
-
const commit = readInjected(true ? "
|
|
790
|
-
const commitShort = readInjected(true ? "
|
|
791
|
-
const version = readInjected(true ? "1.0.28-rc.
|
|
792
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
789
|
+
const commit = readInjected(true ? "3a48f660f00c3bf2e42ba36df7789edbc654b99c" : void 0) ?? "unknown";
|
|
790
|
+
const commitShort = readInjected(true ? "3a48f660" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
791
|
+
const version = readInjected(true ? "1.0.28-rc.16" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
792
|
+
const builtAt = readInjected(true ? "2026-07-26T16:40:47.778Z" : void 0);
|
|
793
793
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
794
794
|
return cached;
|
|
795
795
|
}
|
|
@@ -19751,6 +19751,9 @@ function nodeHasActiveMeshWork(components, meshId, nodeId, currentSessionId) {
|
|
|
19751
19751
|
}
|
|
19752
19752
|
function isLaunchableNode(node) {
|
|
19753
19753
|
if (!node || node.status === "disabled" || node.status === "removed") return false;
|
|
19754
|
+
if (shouldDeferDispatchForBootstrap(node)) {
|
|
19755
|
+
return false;
|
|
19756
|
+
}
|
|
19754
19757
|
return isMeshNodeHealthLaunchable(node);
|
|
19755
19758
|
}
|
|
19756
19759
|
function isLocalAutoLaunchNode(node) {
|
|
@@ -22987,8 +22990,27 @@ function resolveActiveDirectDispatchTaskId(meshId, sessionId) {
|
|
|
22987
22990
|
return void 0;
|
|
22988
22991
|
}
|
|
22989
22992
|
}
|
|
22993
|
+
function findInWindowUnclaimedAutoLaunchTask(meshId, sessionId, nowMs) {
|
|
22994
|
+
return getQueue(meshId, { status: ["pending"] }).find((task) => {
|
|
22995
|
+
const al = task.autoLaunch;
|
|
22996
|
+
if (!al || al.status !== "completed" || !al.sessionId) return false;
|
|
22997
|
+
if (!sessionIdsEquivalent(al.sessionId, sessionId)) return false;
|
|
22998
|
+
const launchedAtMs = Date.parse(al.updatedAt);
|
|
22999
|
+
return Number.isFinite(launchedAtMs) && nowMs - launchedAtMs < AUTO_LAUNCH_AWAIT_CLAIM_MS;
|
|
23000
|
+
});
|
|
23001
|
+
}
|
|
23002
|
+
function hasMatchingTaskDispatchedLedgerEntry(meshId, taskId, sessionId) {
|
|
23003
|
+
const entries = readLedgerEntries(meshId, { tail: 200 });
|
|
23004
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
23005
|
+
const entry = entries[i];
|
|
23006
|
+
if (entry.kind !== "task_dispatched") continue;
|
|
23007
|
+
if (!sessionIdsEquivalent(entry.sessionId, sessionId)) continue;
|
|
23008
|
+
if (readNonEmptyString(entry.payload?.taskId) === taskId) return true;
|
|
23009
|
+
}
|
|
23010
|
+
return false;
|
|
23011
|
+
}
|
|
22990
23012
|
function evaluateMeshEventSuppression(args, ctx) {
|
|
22991
|
-
const { traceCtx, eventSessionId, eventNodeId, eventTimestamp, workerCoordinatorDaemonId } = ctx;
|
|
23013
|
+
const { traceCtx, eventSessionId, eventNodeId, eventTimestamp, workerCoordinatorDaemonId, components } = ctx;
|
|
22992
23014
|
const intentionalCleanupStop = shouldSuppressIntentionalCleanupStop({
|
|
22993
23015
|
event: args.event,
|
|
22994
23016
|
meshId: args.meshId,
|
|
@@ -23055,6 +23077,34 @@ function evaluateMeshEventSuppression(args, ctx) {
|
|
|
23055
23077
|
}
|
|
23056
23078
|
}
|
|
23057
23079
|
if (args.event === "agent:generating_completed" && eventSessionId) {
|
|
23080
|
+
const liveInstance = components.instanceManager?.getInstance?.(eventSessionId);
|
|
23081
|
+
if (typeof liveInstance?.hasLiveTurnPendingEvidence === "function") {
|
|
23082
|
+
let midTurnPending = false;
|
|
23083
|
+
try {
|
|
23084
|
+
midTurnPending = liveInstance.hasLiveTurnPendingEvidence() === true;
|
|
23085
|
+
} catch {
|
|
23086
|
+
}
|
|
23087
|
+
if (midTurnPending) {
|
|
23088
|
+
LOG.info("MeshEvents", `Suppressed agent:generating_completed for session ${eventSessionId} (mesh ${args.meshId}): live adapter re-check shows the turn is still pending (mid-tool / streaming / modal) \u2014 treating as a premature/redraw-race emit; the adapter's own finalization retry or the reconcile loop's transcript evidence will surface the real completion`);
|
|
23089
|
+
traceMeshEventDrop("mid_turn_live_state_pending", traceCtx);
|
|
23090
|
+
return {
|
|
23091
|
+
kind: "suppress",
|
|
23092
|
+
result: { success: true, forwarded: 0, suppressed: true, midTurnLiveStatePending: true }
|
|
23093
|
+
};
|
|
23094
|
+
}
|
|
23095
|
+
}
|
|
23096
|
+
const inWindowTask = findInWindowUnclaimedAutoLaunchTask(args.meshId, eventSessionId, Date.now());
|
|
23097
|
+
if (inWindowTask) {
|
|
23098
|
+
const causalEvidence = MeshRuntimeStore.getInstance().taskDeliveryConsumed(args.meshId, inWindowTask.id) || hasMatchingTaskDispatchedLedgerEntry(args.meshId, inWindowTask.id, eventSessionId);
|
|
23099
|
+
if (!causalEvidence) {
|
|
23100
|
+
LOG.warn("MeshEvents", `Suppressed premature agent:generating_completed for auto-launch session ${eventSessionId} (mesh ${args.meshId}): task ${inWindowTask.id} delivery not yet consumed and no turn-start evidence \u2014 likely a boot artifact before the task was ever dispatched`);
|
|
23101
|
+
traceMeshEventDrop("autolaunch_completion_before_causal_evidence", traceCtx, `taskId=${inWindowTask.id}`);
|
|
23102
|
+
return {
|
|
23103
|
+
kind: "suppress",
|
|
23104
|
+
result: { success: true, forwarded: 0, suppressed: true, autoLaunchCausalGateFailed: true, taskId: inWindowTask.id }
|
|
23105
|
+
};
|
|
23106
|
+
}
|
|
23107
|
+
}
|
|
23058
23108
|
const terminal = findRecentTerminalLedgerEvidence({
|
|
23059
23109
|
meshId: args.meshId,
|
|
23060
23110
|
sessionId: eventSessionId,
|
|
@@ -23287,7 +23337,8 @@ function injectMeshSystemMessage(components, args) {
|
|
|
23287
23337
|
eventSessionId,
|
|
23288
23338
|
eventNodeId,
|
|
23289
23339
|
eventTimestamp,
|
|
23290
|
-
workerCoordinatorDaemonId
|
|
23340
|
+
workerCoordinatorDaemonId,
|
|
23341
|
+
components
|
|
23291
23342
|
});
|
|
23292
23343
|
if (suppression) {
|
|
23293
23344
|
if (suppression.kind === "reconcile") {
|
|
@@ -31100,7 +31151,9 @@ ${lastSnapshot}`;
|
|
|
31100
31151
|
const requiredStreak = this.isAutonomousMeshSession() ? _ProviderCliAdapter.STATIC_IDLE_POLL_CONFIRM_COUNT : 1;
|
|
31101
31152
|
this.staticIdlePollStreak += 1;
|
|
31102
31153
|
if (this.staticIdlePollStreak >= requiredStreak) {
|
|
31103
|
-
this.engine.confirmPollStaticIdle("poll_static_idle")
|
|
31154
|
+
if (this.engine.confirmPollStaticIdle("poll_static_idle")) {
|
|
31155
|
+
this.onStatusChange?.();
|
|
31156
|
+
}
|
|
31104
31157
|
this.staticIdlePollStreak = 0;
|
|
31105
31158
|
}
|
|
31106
31159
|
} else {
|
|
@@ -51121,6 +51174,23 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51121
51174
|
isModalParked() {
|
|
51122
51175
|
return this.resolveModalParkStatus() !== null;
|
|
51123
51176
|
}
|
|
51177
|
+
/**
|
|
51178
|
+
* MID-TURN-LIVE-STATE-GATE (broader false-idle RCA, mid-turn follow-up): a live,
|
|
51179
|
+
* synchronous re-check of whether this session's CURRENT turn genuinely still has
|
|
51180
|
+
* unresolved work. Public wrapper so the coordinator (mesh-event-forwarding) can
|
|
51181
|
+
* independently re-verify an incoming agent:generating_completed for a LOCAL session
|
|
51182
|
+
* before trusting it — defense-in-depth against a race where the completion emit and the
|
|
51183
|
+
* coordinator's receipt straddle a state change (screen-redraw parse artifact, decoupled-
|
|
51184
|
+
* immediate emit). Reuses the EXACT same discriminators this instance's own finalization
|
|
51185
|
+
* gate (getCompletedFinalizationBlock) uses — hasAdapterPendingResponse() (adapter
|
|
51186
|
+
* isWaitingForResponse / currentTurnScope / isProcessing() / a non-empty partial response)
|
|
51187
|
+
* OR isModalParked() (a live approval/choice modal) — so a session this method reports
|
|
51188
|
+
* pending is, by construction, one the local finalization gate would also refuse to
|
|
51189
|
+
* finalize right now.
|
|
51190
|
+
*/
|
|
51191
|
+
hasLiveTurnPendingEvidence() {
|
|
51192
|
+
return this.hasAdapterPendingResponse() || this.isModalParked();
|
|
51193
|
+
}
|
|
51124
51194
|
/**
|
|
51125
51195
|
* PTY-OVERTRUST-DRAIN (Defect B). The deliverability/drain status the mesh
|
|
51126
51196
|
* reconcile loop must consult — the RAW adapter turn-state, with the
|
|
@@ -51611,7 +51681,8 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51611
51681
|
}
|
|
51612
51682
|
completionFinalAssistantEvidence(parsedMessages, turnStartedAt) {
|
|
51613
51683
|
const turnClosed = !this.hasAdapterPendingResponse();
|
|
51614
|
-
|
|
51684
|
+
const preferNativeOverParsed = this.adapter?.chatMessagesOwnedExternally === true && this.busyLeaseGateEnabled();
|
|
51685
|
+
if (!preferNativeOverParsed && this.completionHasFinalAssistantMessage(parsedMessages, turnStartedAt)) {
|
|
51615
51686
|
return {
|
|
51616
51687
|
present: turnClosed,
|
|
51617
51688
|
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
@@ -51621,7 +51692,8 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51621
51692
|
const externalMessages = this.readExternalCompletionMessages();
|
|
51622
51693
|
if (externalMessages) {
|
|
51623
51694
|
const injectedTaskGenerating = this.injectedTaskHasStartedGenerating();
|
|
51624
|
-
const
|
|
51695
|
+
const trailingToolActivity = hasTrailingToolActivityAfterFinalAssistant(externalMessages);
|
|
51696
|
+
const present = injectedTaskGenerating && turnClosed && !trailingToolActivity && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
|
|
51625
51697
|
const lastVisibleAssistant = this.lastVisibleAssistantSummaryDetail(externalMessages);
|
|
51626
51698
|
if (lastVisibleAssistant.content) {
|
|
51627
51699
|
this.lastCompletionSummary = { content: lastVisibleAssistant.content, receivedAt: Date.now(), sourceTimestampMs: lastVisibleAssistant.timestampMs };
|
|
@@ -51632,6 +51704,13 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51632
51704
|
source: "external-native"
|
|
51633
51705
|
};
|
|
51634
51706
|
}
|
|
51707
|
+
if (preferNativeOverParsed && this.completionHasFinalAssistantMessage(parsedMessages, turnStartedAt)) {
|
|
51708
|
+
return {
|
|
51709
|
+
present: turnClosed,
|
|
51710
|
+
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
51711
|
+
source: "parsed"
|
|
51712
|
+
};
|
|
51713
|
+
}
|
|
51635
51714
|
return {
|
|
51636
51715
|
present: false,
|
|
51637
51716
|
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
@@ -51859,6 +51938,18 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51859
51938
|
} catch {
|
|
51860
51939
|
}
|
|
51861
51940
|
}
|
|
51941
|
+
if (adapterOwnsMessagesElsewhere && finalAssistantEvidence.source === "external-native" && this.busyLeaseGateEnabled()) {
|
|
51942
|
+
try {
|
|
51943
|
+
const snapshot = this.lastTranscriptSignalSnapshot;
|
|
51944
|
+
const transcriptAgeMs = snapshot?.available === true && typeof snapshot.detail?.ageMs === "number" && Number.isFinite(snapshot.detail.ageMs) ? snapshot.detail.ageMs : void 0;
|
|
51945
|
+
if (typeof transcriptAgeMs === "number") {
|
|
51946
|
+
if (transcriptAgeMs < PTY_PARSED_FINAL_ASSISTANT_QUIET_DWELL_MS) {
|
|
51947
|
+
return { reason: "native_source_final_assistant_quiet_dwell", terminal: false };
|
|
51948
|
+
}
|
|
51949
|
+
}
|
|
51950
|
+
} catch {
|
|
51951
|
+
}
|
|
51952
|
+
}
|
|
51862
51953
|
return null;
|
|
51863
51954
|
}
|
|
51864
51955
|
// (FALSEIDLE-a) Positive, structural proof that the latest approval entry was resolved
|
|
@@ -52486,7 +52577,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52486
52577
|
return;
|
|
52487
52578
|
}
|
|
52488
52579
|
const latestOutputAt = typeof latestStatus?.lastOutputAt === "number" ? latestStatus.lastOutputAt : void 0;
|
|
52489
|
-
if (typeof pending.lastOutputAtArm === "number" && typeof latestOutputAt === "number" && latestOutputAt > pending.lastOutputAtArm) {
|
|
52580
|
+
if (!pending.loggedBlockReason && typeof pending.lastOutputAtArm === "number" && typeof latestOutputAt === "number" && latestOutputAt > pending.lastOutputAtArm) {
|
|
52490
52581
|
LOG.info("CLI", `[${this.type}] cancelled pending completed (new PTY output during settle: ${pending.lastOutputAtArm}\u2192${latestOutputAt})`);
|
|
52491
52582
|
if (this.completionTraceOn()) this.recordCompletionGateTrace("cancel", {
|
|
52492
52583
|
blockReason: "new_pty_output",
|
|
@@ -56480,6 +56571,7 @@ init_state_store();
|
|
|
56480
56571
|
init_recent_activity();
|
|
56481
56572
|
init_chat_history();
|
|
56482
56573
|
init_mesh_events_utils();
|
|
56574
|
+
init_mesh_queue_assignment();
|
|
56483
56575
|
init_logger();
|
|
56484
56576
|
async function forwardConversationPrefsToCoordinator(ctx, sessionId, patch) {
|
|
56485
56577
|
const dispatch = ctx.deps.dispatchMeshCommand;
|
|
@@ -56594,8 +56686,8 @@ var cliAgentHandlers = {
|
|
|
56594
56686
|
};
|
|
56595
56687
|
},
|
|
56596
56688
|
agent_command: async (ctx, args) => {
|
|
56689
|
+
const dispatchSessionId = readStringValue(args?.targetSessionId, args?.sessionId, args?.instanceId);
|
|
56597
56690
|
{
|
|
56598
|
-
const dispatchSessionId = readStringValue(args?.targetSessionId, args?.sessionId, args?.instanceId);
|
|
56599
56691
|
const dispatchMeshContext = args?.meshContext;
|
|
56600
56692
|
if (dispatchSessionId && dispatchMeshContext) {
|
|
56601
56693
|
try {
|
|
@@ -56629,18 +56721,23 @@ var cliAgentHandlers = {
|
|
|
56629
56721
|
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => meshNodeIdMatches(n, dispatchNodeId)) : void 0;
|
|
56630
56722
|
const { shouldDeferDispatchForBootstrap: shouldDeferDispatchForBootstrap2 } = await Promise.resolve().then(() => (init_worktree_bootstrap_config(), worktree_bootstrap_config_exports));
|
|
56631
56723
|
if (shouldDeferDispatchForBootstrap2(nodeObj)) {
|
|
56632
|
-
|
|
56633
|
-
|
|
56634
|
-
|
|
56635
|
-
|
|
56636
|
-
|
|
56637
|
-
|
|
56638
|
-
|
|
56639
|
-
|
|
56640
|
-
|
|
56641
|
-
|
|
56642
|
-
|
|
56643
|
-
|
|
56724
|
+
const dispatchSessionState = dispatchSessionId ? ctx.deps.instanceManager?.getInstance?.(dispatchSessionId)?.getState?.() : void 0;
|
|
56725
|
+
const sessionConfirmedReady = !!dispatchSessionState && isIdleSessionState(dispatchSessionState);
|
|
56726
|
+
if (!sessionConfirmedReady) {
|
|
56727
|
+
return {
|
|
56728
|
+
success: false,
|
|
56729
|
+
recoverable: true,
|
|
56730
|
+
dispatched: false,
|
|
56731
|
+
code: "mesh_node_bootstrap_pending",
|
|
56732
|
+
reason: "bootstrap_still_running",
|
|
56733
|
+
nodeId: dispatchNodeId,
|
|
56734
|
+
meshId: dispatchMeshId,
|
|
56735
|
+
...readStringValue(meshCtx?.taskId) ? { taskId: readStringValue(meshCtx?.taskId) } : {},
|
|
56736
|
+
error: `Node '${dispatchNodeId}' worktree bootstrap is still running; a task injected now would land in the session input buffer before the provider is ready to consume it and be silently lost. Dispatch deferred.`,
|
|
56737
|
+
nextAction: "Wait for the worktree_bootstrap_complete event (or poll mesh_status until the node session is ready), then re-send the task with mesh_send_task. Alternatively use mesh_enqueue_task so the queue auto-assigns it once a ready session is available."
|
|
56738
|
+
};
|
|
56739
|
+
}
|
|
56740
|
+
LOG.info("MeshQueue", `Overriding stale worktreeBootstrap 'running' flag for node ${dispatchNodeId}: explicit target session ${dispatchSessionId} is independently confirmed idle/ready \u2014 dispatching mesh_send_task directly.`);
|
|
56644
56741
|
}
|
|
56645
56742
|
} catch {
|
|
56646
56743
|
}
|