@adhdev/daemon-core 1.0.28-rc.14 → 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.js
CHANGED
|
@@ -791,10 +791,10 @@ function readInjected(value) {
|
|
|
791
791
|
}
|
|
792
792
|
function getDaemonBuildInfo() {
|
|
793
793
|
if (cached) return cached;
|
|
794
|
-
const commit = readInjected(true ? "
|
|
795
|
-
const commitShort = readInjected(true ? "
|
|
796
|
-
const version = readInjected(true ? "1.0.28-rc.
|
|
797
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
794
|
+
const commit = readInjected(true ? "3a48f660f00c3bf2e42ba36df7789edbc654b99c" : void 0) ?? "unknown";
|
|
795
|
+
const commitShort = readInjected(true ? "3a48f660" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
796
|
+
const version = readInjected(true ? "1.0.28-rc.16" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
797
|
+
const builtAt = readInjected(true ? "2026-07-26T16:40:47.778Z" : void 0);
|
|
798
798
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
799
799
|
return cached;
|
|
800
800
|
}
|
|
@@ -19748,6 +19748,9 @@ function nodeHasActiveMeshWork(components, meshId, nodeId, currentSessionId) {
|
|
|
19748
19748
|
}
|
|
19749
19749
|
function isLaunchableNode(node) {
|
|
19750
19750
|
if (!node || node.status === "disabled" || node.status === "removed") return false;
|
|
19751
|
+
if (shouldDeferDispatchForBootstrap(node)) {
|
|
19752
|
+
return false;
|
|
19753
|
+
}
|
|
19751
19754
|
return isMeshNodeHealthLaunchable(node);
|
|
19752
19755
|
}
|
|
19753
19756
|
function isLocalAutoLaunchNode(node) {
|
|
@@ -22985,8 +22988,27 @@ function resolveActiveDirectDispatchTaskId(meshId, sessionId) {
|
|
|
22985
22988
|
return void 0;
|
|
22986
22989
|
}
|
|
22987
22990
|
}
|
|
22991
|
+
function findInWindowUnclaimedAutoLaunchTask(meshId, sessionId, nowMs) {
|
|
22992
|
+
return getQueue(meshId, { status: ["pending"] }).find((task) => {
|
|
22993
|
+
const al = task.autoLaunch;
|
|
22994
|
+
if (!al || al.status !== "completed" || !al.sessionId) return false;
|
|
22995
|
+
if (!sessionIdsEquivalent(al.sessionId, sessionId)) return false;
|
|
22996
|
+
const launchedAtMs = Date.parse(al.updatedAt);
|
|
22997
|
+
return Number.isFinite(launchedAtMs) && nowMs - launchedAtMs < AUTO_LAUNCH_AWAIT_CLAIM_MS;
|
|
22998
|
+
});
|
|
22999
|
+
}
|
|
23000
|
+
function hasMatchingTaskDispatchedLedgerEntry(meshId, taskId, sessionId) {
|
|
23001
|
+
const entries = readLedgerEntries(meshId, { tail: 200 });
|
|
23002
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
23003
|
+
const entry = entries[i];
|
|
23004
|
+
if (entry.kind !== "task_dispatched") continue;
|
|
23005
|
+
if (!sessionIdsEquivalent(entry.sessionId, sessionId)) continue;
|
|
23006
|
+
if (readNonEmptyString(entry.payload?.taskId) === taskId) return true;
|
|
23007
|
+
}
|
|
23008
|
+
return false;
|
|
23009
|
+
}
|
|
22988
23010
|
function evaluateMeshEventSuppression(args, ctx) {
|
|
22989
|
-
const { traceCtx, eventSessionId, eventNodeId, eventTimestamp, workerCoordinatorDaemonId } = ctx;
|
|
23011
|
+
const { traceCtx, eventSessionId, eventNodeId, eventTimestamp, workerCoordinatorDaemonId, components } = ctx;
|
|
22990
23012
|
const intentionalCleanupStop = shouldSuppressIntentionalCleanupStop({
|
|
22991
23013
|
event: args.event,
|
|
22992
23014
|
meshId: args.meshId,
|
|
@@ -23053,6 +23075,34 @@ function evaluateMeshEventSuppression(args, ctx) {
|
|
|
23053
23075
|
}
|
|
23054
23076
|
}
|
|
23055
23077
|
if (args.event === "agent:generating_completed" && eventSessionId) {
|
|
23078
|
+
const liveInstance = components.instanceManager?.getInstance?.(eventSessionId);
|
|
23079
|
+
if (typeof liveInstance?.hasLiveTurnPendingEvidence === "function") {
|
|
23080
|
+
let midTurnPending = false;
|
|
23081
|
+
try {
|
|
23082
|
+
midTurnPending = liveInstance.hasLiveTurnPendingEvidence() === true;
|
|
23083
|
+
} catch {
|
|
23084
|
+
}
|
|
23085
|
+
if (midTurnPending) {
|
|
23086
|
+
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`);
|
|
23087
|
+
traceMeshEventDrop("mid_turn_live_state_pending", traceCtx);
|
|
23088
|
+
return {
|
|
23089
|
+
kind: "suppress",
|
|
23090
|
+
result: { success: true, forwarded: 0, suppressed: true, midTurnLiveStatePending: true }
|
|
23091
|
+
};
|
|
23092
|
+
}
|
|
23093
|
+
}
|
|
23094
|
+
const inWindowTask = findInWindowUnclaimedAutoLaunchTask(args.meshId, eventSessionId, Date.now());
|
|
23095
|
+
if (inWindowTask) {
|
|
23096
|
+
const causalEvidence = MeshRuntimeStore.getInstance().taskDeliveryConsumed(args.meshId, inWindowTask.id) || hasMatchingTaskDispatchedLedgerEntry(args.meshId, inWindowTask.id, eventSessionId);
|
|
23097
|
+
if (!causalEvidence) {
|
|
23098
|
+
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`);
|
|
23099
|
+
traceMeshEventDrop("autolaunch_completion_before_causal_evidence", traceCtx, `taskId=${inWindowTask.id}`);
|
|
23100
|
+
return {
|
|
23101
|
+
kind: "suppress",
|
|
23102
|
+
result: { success: true, forwarded: 0, suppressed: true, autoLaunchCausalGateFailed: true, taskId: inWindowTask.id }
|
|
23103
|
+
};
|
|
23104
|
+
}
|
|
23105
|
+
}
|
|
23056
23106
|
const terminal = findRecentTerminalLedgerEvidence({
|
|
23057
23107
|
meshId: args.meshId,
|
|
23058
23108
|
sessionId: eventSessionId,
|
|
@@ -23285,7 +23335,8 @@ function injectMeshSystemMessage(components, args) {
|
|
|
23285
23335
|
eventSessionId,
|
|
23286
23336
|
eventNodeId,
|
|
23287
23337
|
eventTimestamp,
|
|
23288
|
-
workerCoordinatorDaemonId
|
|
23338
|
+
workerCoordinatorDaemonId,
|
|
23339
|
+
components
|
|
23289
23340
|
});
|
|
23290
23341
|
if (suppression) {
|
|
23291
23342
|
if (suppression.kind === "reconcile") {
|
|
@@ -31094,7 +31145,9 @@ ${lastSnapshot}`;
|
|
|
31094
31145
|
const requiredStreak = this.isAutonomousMeshSession() ? _ProviderCliAdapter.STATIC_IDLE_POLL_CONFIRM_COUNT : 1;
|
|
31095
31146
|
this.staticIdlePollStreak += 1;
|
|
31096
31147
|
if (this.staticIdlePollStreak >= requiredStreak) {
|
|
31097
|
-
this.engine.confirmPollStaticIdle("poll_static_idle")
|
|
31148
|
+
if (this.engine.confirmPollStaticIdle("poll_static_idle")) {
|
|
31149
|
+
this.onStatusChange?.();
|
|
31150
|
+
}
|
|
31098
31151
|
this.staticIdlePollStreak = 0;
|
|
31099
31152
|
}
|
|
31100
31153
|
} else {
|
|
@@ -51563,6 +51616,23 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51563
51616
|
isModalParked() {
|
|
51564
51617
|
return this.resolveModalParkStatus() !== null;
|
|
51565
51618
|
}
|
|
51619
|
+
/**
|
|
51620
|
+
* MID-TURN-LIVE-STATE-GATE (broader false-idle RCA, mid-turn follow-up): a live,
|
|
51621
|
+
* synchronous re-check of whether this session's CURRENT turn genuinely still has
|
|
51622
|
+
* unresolved work. Public wrapper so the coordinator (mesh-event-forwarding) can
|
|
51623
|
+
* independently re-verify an incoming agent:generating_completed for a LOCAL session
|
|
51624
|
+
* before trusting it — defense-in-depth against a race where the completion emit and the
|
|
51625
|
+
* coordinator's receipt straddle a state change (screen-redraw parse artifact, decoupled-
|
|
51626
|
+
* immediate emit). Reuses the EXACT same discriminators this instance's own finalization
|
|
51627
|
+
* gate (getCompletedFinalizationBlock) uses — hasAdapterPendingResponse() (adapter
|
|
51628
|
+
* isWaitingForResponse / currentTurnScope / isProcessing() / a non-empty partial response)
|
|
51629
|
+
* OR isModalParked() (a live approval/choice modal) — so a session this method reports
|
|
51630
|
+
* pending is, by construction, one the local finalization gate would also refuse to
|
|
51631
|
+
* finalize right now.
|
|
51632
|
+
*/
|
|
51633
|
+
hasLiveTurnPendingEvidence() {
|
|
51634
|
+
return this.hasAdapterPendingResponse() || this.isModalParked();
|
|
51635
|
+
}
|
|
51566
51636
|
/**
|
|
51567
51637
|
* PTY-OVERTRUST-DRAIN (Defect B). The deliverability/drain status the mesh
|
|
51568
51638
|
* reconcile loop must consult — the RAW adapter turn-state, with the
|
|
@@ -52053,7 +52123,8 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52053
52123
|
}
|
|
52054
52124
|
completionFinalAssistantEvidence(parsedMessages, turnStartedAt) {
|
|
52055
52125
|
const turnClosed = !this.hasAdapterPendingResponse();
|
|
52056
|
-
|
|
52126
|
+
const preferNativeOverParsed = this.adapter?.chatMessagesOwnedExternally === true && this.busyLeaseGateEnabled();
|
|
52127
|
+
if (!preferNativeOverParsed && this.completionHasFinalAssistantMessage(parsedMessages, turnStartedAt)) {
|
|
52057
52128
|
return {
|
|
52058
52129
|
present: turnClosed,
|
|
52059
52130
|
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
@@ -52063,7 +52134,8 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52063
52134
|
const externalMessages = this.readExternalCompletionMessages();
|
|
52064
52135
|
if (externalMessages) {
|
|
52065
52136
|
const injectedTaskGenerating = this.injectedTaskHasStartedGenerating();
|
|
52066
|
-
const
|
|
52137
|
+
const trailingToolActivity = hasTrailingToolActivityAfterFinalAssistant(externalMessages);
|
|
52138
|
+
const present = injectedTaskGenerating && turnClosed && !trailingToolActivity && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
|
|
52067
52139
|
const lastVisibleAssistant = this.lastVisibleAssistantSummaryDetail(externalMessages);
|
|
52068
52140
|
if (lastVisibleAssistant.content) {
|
|
52069
52141
|
this.lastCompletionSummary = { content: lastVisibleAssistant.content, receivedAt: Date.now(), sourceTimestampMs: lastVisibleAssistant.timestampMs };
|
|
@@ -52074,6 +52146,13 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52074
52146
|
source: "external-native"
|
|
52075
52147
|
};
|
|
52076
52148
|
}
|
|
52149
|
+
if (preferNativeOverParsed && this.completionHasFinalAssistantMessage(parsedMessages, turnStartedAt)) {
|
|
52150
|
+
return {
|
|
52151
|
+
present: turnClosed,
|
|
52152
|
+
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
52153
|
+
source: "parsed"
|
|
52154
|
+
};
|
|
52155
|
+
}
|
|
52077
52156
|
return {
|
|
52078
52157
|
present: false,
|
|
52079
52158
|
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
@@ -52301,6 +52380,18 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52301
52380
|
} catch {
|
|
52302
52381
|
}
|
|
52303
52382
|
}
|
|
52383
|
+
if (adapterOwnsMessagesElsewhere && finalAssistantEvidence.source === "external-native" && this.busyLeaseGateEnabled()) {
|
|
52384
|
+
try {
|
|
52385
|
+
const snapshot = this.lastTranscriptSignalSnapshot;
|
|
52386
|
+
const transcriptAgeMs = snapshot?.available === true && typeof snapshot.detail?.ageMs === "number" && Number.isFinite(snapshot.detail.ageMs) ? snapshot.detail.ageMs : void 0;
|
|
52387
|
+
if (typeof transcriptAgeMs === "number") {
|
|
52388
|
+
if (transcriptAgeMs < PTY_PARSED_FINAL_ASSISTANT_QUIET_DWELL_MS) {
|
|
52389
|
+
return { reason: "native_source_final_assistant_quiet_dwell", terminal: false };
|
|
52390
|
+
}
|
|
52391
|
+
}
|
|
52392
|
+
} catch {
|
|
52393
|
+
}
|
|
52394
|
+
}
|
|
52304
52395
|
return null;
|
|
52305
52396
|
}
|
|
52306
52397
|
// (FALSEIDLE-a) Positive, structural proof that the latest approval entry was resolved
|
|
@@ -52928,7 +53019,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52928
53019
|
return;
|
|
52929
53020
|
}
|
|
52930
53021
|
const latestOutputAt = typeof latestStatus?.lastOutputAt === "number" ? latestStatus.lastOutputAt : void 0;
|
|
52931
|
-
if (typeof pending.lastOutputAtArm === "number" && typeof latestOutputAt === "number" && latestOutputAt > pending.lastOutputAtArm) {
|
|
53022
|
+
if (!pending.loggedBlockReason && typeof pending.lastOutputAtArm === "number" && typeof latestOutputAt === "number" && latestOutputAt > pending.lastOutputAtArm) {
|
|
52932
53023
|
LOG.info("CLI", `[${this.type}] cancelled pending completed (new PTY output during settle: ${pending.lastOutputAtArm}\u2192${latestOutputAt})`);
|
|
52933
53024
|
if (this.completionTraceOn()) this.recordCompletionGateTrace("cancel", {
|
|
52934
53025
|
blockReason: "new_pty_output",
|
|
@@ -56917,6 +57008,7 @@ init_state_store();
|
|
|
56917
57008
|
init_recent_activity();
|
|
56918
57009
|
init_chat_history();
|
|
56919
57010
|
init_mesh_events_utils();
|
|
57011
|
+
init_mesh_queue_assignment();
|
|
56920
57012
|
init_logger();
|
|
56921
57013
|
async function forwardConversationPrefsToCoordinator(ctx, sessionId, patch) {
|
|
56922
57014
|
const dispatch = ctx.deps.dispatchMeshCommand;
|
|
@@ -57031,8 +57123,8 @@ var cliAgentHandlers = {
|
|
|
57031
57123
|
};
|
|
57032
57124
|
},
|
|
57033
57125
|
agent_command: async (ctx, args) => {
|
|
57126
|
+
const dispatchSessionId = readStringValue(args?.targetSessionId, args?.sessionId, args?.instanceId);
|
|
57034
57127
|
{
|
|
57035
|
-
const dispatchSessionId = readStringValue(args?.targetSessionId, args?.sessionId, args?.instanceId);
|
|
57036
57128
|
const dispatchMeshContext = args?.meshContext;
|
|
57037
57129
|
if (dispatchSessionId && dispatchMeshContext) {
|
|
57038
57130
|
try {
|
|
@@ -57066,18 +57158,23 @@ var cliAgentHandlers = {
|
|
|
57066
57158
|
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => meshNodeIdMatches(n, dispatchNodeId)) : void 0;
|
|
57067
57159
|
const { shouldDeferDispatchForBootstrap: shouldDeferDispatchForBootstrap2 } = await Promise.resolve().then(() => (init_worktree_bootstrap_config(), worktree_bootstrap_config_exports));
|
|
57068
57160
|
if (shouldDeferDispatchForBootstrap2(nodeObj)) {
|
|
57069
|
-
|
|
57070
|
-
|
|
57071
|
-
|
|
57072
|
-
|
|
57073
|
-
|
|
57074
|
-
|
|
57075
|
-
|
|
57076
|
-
|
|
57077
|
-
|
|
57078
|
-
|
|
57079
|
-
|
|
57080
|
-
|
|
57161
|
+
const dispatchSessionState = dispatchSessionId ? ctx.deps.instanceManager?.getInstance?.(dispatchSessionId)?.getState?.() : void 0;
|
|
57162
|
+
const sessionConfirmedReady = !!dispatchSessionState && isIdleSessionState(dispatchSessionState);
|
|
57163
|
+
if (!sessionConfirmedReady) {
|
|
57164
|
+
return {
|
|
57165
|
+
success: false,
|
|
57166
|
+
recoverable: true,
|
|
57167
|
+
dispatched: false,
|
|
57168
|
+
code: "mesh_node_bootstrap_pending",
|
|
57169
|
+
reason: "bootstrap_still_running",
|
|
57170
|
+
nodeId: dispatchNodeId,
|
|
57171
|
+
meshId: dispatchMeshId,
|
|
57172
|
+
...readStringValue(meshCtx?.taskId) ? { taskId: readStringValue(meshCtx?.taskId) } : {},
|
|
57173
|
+
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.`,
|
|
57174
|
+
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."
|
|
57175
|
+
};
|
|
57176
|
+
}
|
|
57177
|
+
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.`);
|
|
57081
57178
|
}
|
|
57082
57179
|
} catch {
|
|
57083
57180
|
}
|