@adhdev/daemon-core 0.9.82-rc.403 → 0.9.82-rc.405
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 +94 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -40
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +30 -0
- package/package.json +2 -2
- package/src/providers/cli-provider-instance.ts +152 -48
package/dist/index.mjs
CHANGED
|
@@ -394,10 +394,10 @@ function readInjected(value) {
|
|
|
394
394
|
}
|
|
395
395
|
function getDaemonBuildInfo() {
|
|
396
396
|
if (cached) return cached;
|
|
397
|
-
const commit = readInjected(true ? "
|
|
398
|
-
const commitShort = readInjected(true ? "
|
|
399
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
400
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
397
|
+
const commit = readInjected(true ? "4e4b5f468d194f630073a66359898bce97fadf4b" : void 0) ?? "unknown";
|
|
398
|
+
const commitShort = readInjected(true ? "4e4b5f46" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
399
|
+
const version = readInjected(true ? "0.9.82-rc.405" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
400
|
+
const builtAt = readInjected(true ? "2026-06-28T03:54:34.483Z" : void 0);
|
|
401
401
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
402
402
|
return cached;
|
|
403
403
|
}
|
|
@@ -39310,6 +39310,7 @@ var COMPLETED_FINALIZATION_RETRY_MS = 1e3;
|
|
|
39310
39310
|
var COMPLETED_FINALIZATION_MAX_WAIT_MS = 3e4;
|
|
39311
39311
|
var NATIVE_HISTORY_MESH_IDLE_SETTLE_MS = 4e3;
|
|
39312
39312
|
var USER_INPUT_ACK_DEDUP_WINDOW_MS = 6e4;
|
|
39313
|
+
var STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS = 12e3;
|
|
39313
39314
|
var TERMINAL_MESH_EVENTS = /* @__PURE__ */ new Set([
|
|
39314
39315
|
"agent:generating_completed",
|
|
39315
39316
|
"agent:stopped",
|
|
@@ -39575,6 +39576,23 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
39575
39576
|
// first sets it; the other becomes a no-op.
|
|
39576
39577
|
agentReadyEmitted = false;
|
|
39577
39578
|
generatingStartedAt = 0;
|
|
39579
|
+
// GENERATING-BOUNDARY (R4b): the per-turn taskId for which a startup-grace
|
|
39580
|
+
// started+completed pair was already synthesized. Both fast-collapse callers
|
|
39581
|
+
// (starting→idle transition AND the idle-stayed no-status-change poll) route
|
|
39582
|
+
// through maybeSynthesizeStartupGraceCollapse; the idle-stayed caller re-polls
|
|
39583
|
+
// steadily while the session sits idle, so this guard makes the synthesis fire
|
|
39584
|
+
// AT MOST ONCE per collapsed turn.
|
|
39585
|
+
fastCollapseSynthesizedTaskId = null;
|
|
39586
|
+
// GENERATING-BOUNDARY (R4c): the wall-clock moment the FSM's starting→idle
|
|
39587
|
+
// startup-grace collapse was observed (set ONCE, on the first starting→idle
|
|
39588
|
+
// transition this boot). The idle-stayed collapse window is anchored on THIS,
|
|
39589
|
+
// not on instance/boot time (this.startedAt): the FSM spends the full 8s
|
|
39590
|
+
// startup-grace sitting in 'starting' before collapsing, and a turn can be
|
|
39591
|
+
// dispatched a few seconds AFTER the collapse — measuring the window from boot
|
|
39592
|
+
// would have it already closed by the time that turn lands+completes (the live
|
|
39593
|
+
// R4b miss: collapse at boot+8s, dispatch at boot+12.4s > the 12s boot window).
|
|
39594
|
+
// Anchoring on the collapse moment makes the window cover dispatch-delay+turn.
|
|
39595
|
+
startupGraceCollapseAt = null;
|
|
39578
39596
|
settings = {};
|
|
39579
39597
|
monitor;
|
|
39580
39598
|
generatingDebounceTimer = null;
|
|
@@ -40701,6 +40719,73 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
40701
40719
|
this.agentReadyEmitted = true;
|
|
40702
40720
|
this.pushEvent({ event: "agent:ready", chatTitle, timestamp: now });
|
|
40703
40721
|
}
|
|
40722
|
+
/**
|
|
40723
|
+
* GENERATING-BOUNDARY synthetic emit for a first turn that started AND finished
|
|
40724
|
+
* inside the startup-grace window without the FSM ever observing a 'generating'
|
|
40725
|
+
* frame (an unobservably-fast turn). Synthesizes the agent:generating_started +
|
|
40726
|
+
* agent:generating_completed pair so the mesh coordinator learns the worker went
|
|
40727
|
+
* idle. Returns true iff it synthesized.
|
|
40728
|
+
*
|
|
40729
|
+
* Two callers share this defense line:
|
|
40730
|
+
* - 'startup_grace_fast_collapse' — the starting→idle transition (the FSM whose
|
|
40731
|
+
* spec lacks/hadn't-synced the starting→busy edge collapses starting→idle
|
|
40732
|
+
* directly, with no intervening 'generating' frame).
|
|
40733
|
+
* - 'startup_grace_idle_turn_collapse' — the idle→idle no-status-change poll
|
|
40734
|
+
* (the launch settle already drained starting→idle BEFORE the first turn, so
|
|
40735
|
+
* the turn runs+completes while status stays 'idle' the whole time and
|
|
40736
|
+
* detectStatusTransition never re-enters its change block — the live rc.403
|
|
40737
|
+
* Probe1 miss).
|
|
40738
|
+
*
|
|
40739
|
+
* False-positive safety (must NOT fire on a benign boot): currentTurnTaskId is
|
|
40740
|
+
* set ONLY by onTurnStarted (a real turn STARTED this boot) and persists past
|
|
40741
|
+
* completion, so it excludes a true idle boot (null) and a queued-pending first
|
|
40742
|
+
* turn that only runs after grace (onTurnStarted not yet called → null).
|
|
40743
|
+
* !hasAdapterPendingResponse() excludes a turn still mid-flight. generating
|
|
40744
|
+
* never armed (generatingStartedAt===0 && !generatingDebouncePending) means the
|
|
40745
|
+
* whole idle→busy→idle never happened for this turn. The once-per-turn guard
|
|
40746
|
+
* (fastCollapseSynthesizedTaskId) keeps the re-polled idle-stayed caller from
|
|
40747
|
+
* re-emitting every poll.
|
|
40748
|
+
*/
|
|
40749
|
+
maybeSynthesizeStartupGraceCollapse(chatTitle, now, reason) {
|
|
40750
|
+
const startedTurnTaskId = typeof this.adapter?.currentTurnTaskId === "string" && this.adapter.currentTurnTaskId.trim() ? this.adapter.currentTurnTaskId : void 0;
|
|
40751
|
+
const fastCollapsed = !!startedTurnTaskId && !this.hasAdapterPendingResponse() && !this.generatingStartedAt && !this.generatingDebouncePending;
|
|
40752
|
+
if (!fastCollapsed) return false;
|
|
40753
|
+
if (this.fastCollapseSynthesizedTaskId === startedTurnTaskId) return false;
|
|
40754
|
+
let fcFinalSummary;
|
|
40755
|
+
let fcEvidenceSource = "unavailable";
|
|
40756
|
+
try {
|
|
40757
|
+
const parsedMessages = this.adapter?.getScriptParsedStatus()?.messages;
|
|
40758
|
+
const evidence = this.completionFinalAssistantEvidence(parsedMessages);
|
|
40759
|
+
fcEvidenceSource = evidence.source;
|
|
40760
|
+
fcFinalSummary = extractFinalSummaryFromMessages(evidence.messages);
|
|
40761
|
+
} catch {
|
|
40762
|
+
}
|
|
40763
|
+
const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || fcEvidenceSource === "external-native") && !fcFinalSummary;
|
|
40764
|
+
const hasMeshContext = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
|
|
40765
|
+
if (missingEvidence && !hasMeshContext) {
|
|
40766
|
+
LOG.info("CLI", `[${this.type}] ${reason} suppressed: missing final assistant evidence, no mesh context (source=${fcEvidenceSource})`);
|
|
40767
|
+
return false;
|
|
40768
|
+
}
|
|
40769
|
+
this.fastCollapseSynthesizedTaskId = startedTurnTaskId;
|
|
40770
|
+
LOG.info("CLI", `[${this.type}] ${reason}: synthesizing started+completed (taskId=${startedTurnTaskId} source=${fcEvidenceSource} hadFinalSummary=${!!fcFinalSummary})`);
|
|
40771
|
+
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
|
|
40772
|
+
if (this.isMeshWorkerSession()) {
|
|
40773
|
+
traceMeshEventStage("fired", this.meshTraceCtx(), `${reason} (source=${fcEvidenceSource})`);
|
|
40774
|
+
}
|
|
40775
|
+
this.pushEvent({
|
|
40776
|
+
event: "agent:generating_completed",
|
|
40777
|
+
chatTitle,
|
|
40778
|
+
duration: 0,
|
|
40779
|
+
timestamp: now,
|
|
40780
|
+
finalSummary: fcFinalSummary,
|
|
40781
|
+
completionDiagnostic: {
|
|
40782
|
+
reason,
|
|
40783
|
+
finalAssistantEvidenceSource: fcEvidenceSource,
|
|
40784
|
+
...missingEvidence ? { blockReason: "missing_final_assistant" } : {}
|
|
40785
|
+
}
|
|
40786
|
+
});
|
|
40787
|
+
return true;
|
|
40788
|
+
}
|
|
40704
40789
|
detectStatusTransition() {
|
|
40705
40790
|
const now = Date.now();
|
|
40706
40791
|
const adapterStatus = this.adapter.getStatus({ allowParse: false });
|
|
@@ -40859,42 +40944,8 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
40859
40944
|
}
|
|
40860
40945
|
} else if (newStatus === "idle" && this.lastStatus === "starting") {
|
|
40861
40946
|
this.emitAgentReadyOnce(chatTitle, now);
|
|
40862
|
-
|
|
40863
|
-
|
|
40864
|
-
if (fastCollapsed) {
|
|
40865
|
-
let fcFinalSummary;
|
|
40866
|
-
let fcEvidenceSource = "unavailable";
|
|
40867
|
-
try {
|
|
40868
|
-
const parsedMessages = this.adapter?.getScriptParsedStatus()?.messages;
|
|
40869
|
-
const evidence = this.completionFinalAssistantEvidence(parsedMessages);
|
|
40870
|
-
fcEvidenceSource = evidence.source;
|
|
40871
|
-
fcFinalSummary = extractFinalSummaryFromMessages(evidence.messages);
|
|
40872
|
-
} catch {
|
|
40873
|
-
}
|
|
40874
|
-
const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || fcEvidenceSource === "external-native") && !fcFinalSummary;
|
|
40875
|
-
const hasMeshContext = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
|
|
40876
|
-
if (missingEvidence && !hasMeshContext) {
|
|
40877
|
-
LOG.info("CLI", `[${this.type}] startup-grace fast-collapse suppressed: missing final assistant evidence, no mesh context (source=${fcEvidenceSource})`);
|
|
40878
|
-
} else {
|
|
40879
|
-
LOG.info("CLI", `[${this.type}] startup-grace fast-collapse: synthesizing started+completed (taskId=${startedTurnTaskId} source=${fcEvidenceSource} hadFinalSummary=${!!fcFinalSummary})`);
|
|
40880
|
-
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
|
|
40881
|
-
if (this.isMeshWorkerSession()) {
|
|
40882
|
-
traceMeshEventStage("fired", this.meshTraceCtx(), `startup-grace fast-collapse (source=${fcEvidenceSource})`);
|
|
40883
|
-
}
|
|
40884
|
-
this.pushEvent({
|
|
40885
|
-
event: "agent:generating_completed",
|
|
40886
|
-
chatTitle,
|
|
40887
|
-
duration: 0,
|
|
40888
|
-
timestamp: now,
|
|
40889
|
-
finalSummary: fcFinalSummary,
|
|
40890
|
-
completionDiagnostic: {
|
|
40891
|
-
reason: "startup_grace_fast_collapse",
|
|
40892
|
-
finalAssistantEvidenceSource: fcEvidenceSource,
|
|
40893
|
-
...missingEvidence ? { blockReason: "missing_final_assistant" } : {}
|
|
40894
|
-
}
|
|
40895
|
-
});
|
|
40896
|
-
}
|
|
40897
|
-
}
|
|
40947
|
+
if (this.startupGraceCollapseAt === null) this.startupGraceCollapseAt = now;
|
|
40948
|
+
this.maybeSynthesizeStartupGraceCollapse(chatTitle, now, "startup_grace_fast_collapse");
|
|
40898
40949
|
} else if (newStatus === "error") {
|
|
40899
40950
|
if (this.generatingDebounceTimer) {
|
|
40900
40951
|
clearTimeout(this.generatingDebounceTimer);
|
|
@@ -40933,6 +40984,9 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
40933
40984
|
}
|
|
40934
40985
|
this.lastStatus = newStatus;
|
|
40935
40986
|
}
|
|
40987
|
+
if (newStatus === "idle" && previousStatus === "idle" && this.startupGraceCollapseAt !== null && now - this.startupGraceCollapseAt < STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS) {
|
|
40988
|
+
this.maybeSynthesizeStartupGraceCollapse(chatTitle, now, "startup_grace_idle_turn_collapse");
|
|
40989
|
+
}
|
|
40936
40990
|
if (newStatus === "idle" && adapterStatus.fsmReadySeen === true && !this.agentReadyEmitted) {
|
|
40937
40991
|
this.emitAgentReadyOnce(chatTitle, now);
|
|
40938
40992
|
}
|