@adhdev/daemon-core 1.0.28-rc.11 → 1.0.28-rc.13
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 +124 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -77
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +65 -28
- package/package.json +3 -3
- package/src/providers/cli-provider-instance.ts +175 -104
- package/src/providers/transcript-signal-source.ts +14 -6
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 ? "200c050e12084938c52f329a7531fd59a7cf5064" : void 0) ?? "unknown";
|
|
795
|
+
const commitShort = readInjected(true ? "200c050e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
796
|
+
const version = readInjected(true ? "1.0.28-rc.13" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
797
|
+
const builtAt = readInjected(true ? "2026-07-26T08:47:54.956Z" : void 0);
|
|
798
798
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
799
799
|
return cached;
|
|
800
800
|
}
|
|
@@ -50879,18 +50879,20 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
50879
50879
|
// MESH_WORKER_STALL_REFIRE_COOLDOWN_MS between successive emissions across
|
|
50880
50880
|
// anchor re-arms (the per-anchor guard only covers a single continuous stall).
|
|
50881
50881
|
meshStallLastFiredAt = -1;
|
|
50882
|
-
// KIMI-MESH-COMPLETION-EMIT (axis 1)
|
|
50883
|
-
//
|
|
50884
|
-
//
|
|
50885
|
-
//
|
|
50886
|
-
//
|
|
50887
|
-
//
|
|
50888
|
-
//
|
|
50889
|
-
//
|
|
50890
|
-
//
|
|
50891
|
-
// handling can lead to the worker being stopped mid-work → completion
|
|
50892
|
-
// emitted).
|
|
50893
|
-
|
|
50882
|
+
// KIMI-MESH-COMPLETION-EMIT (axis 1) — TX-FSM Stage 1: whether the stall
|
|
50883
|
+
// watchdog has consumed a usable native-transcript SIGNAL SNAPSHOT for the
|
|
50884
|
+
// current stall episode. A pure-PTY native-source worker running a long,
|
|
50885
|
+
// screen-quiet tool (no viewport bytes for minutes) looks stalled by the
|
|
50886
|
+
// lastOutputAt clock even though its transcript file is still growing.
|
|
50887
|
+
// Before firing the stall, the watchdog consults the shared
|
|
50888
|
+
// TranscriptSignalSource's in_turn_progress signal; if the transcript is
|
|
50889
|
+
// advancing, the "stall" is a false positive of PTY-render stasis, so we
|
|
50890
|
+
// re-arm the anchor instead of paging the coordinator (whose no_progress
|
|
50891
|
+
// handling can lead to the worker being stopped mid-work → completion
|
|
50892
|
+
// never emitted). The FIRST usable sample of an episode still re-arms
|
|
50893
|
+
// unconditionally (no episode-scoped baseline exists yet to prove stasis
|
|
50894
|
+
// against) — the historical `!prev → advanced` semantics, preserved.
|
|
50895
|
+
meshStallTranscriptSignalSampled = false;
|
|
50894
50896
|
// FALSE-IDLE continuity epoch: monotonically bumped on EVERY entry into a busy
|
|
50895
50897
|
// phase (→generating or →waiting_approval). The completedDebouncePending snapshots
|
|
50896
50898
|
// this value at arm time (busyEpochAtArm); the flush guard requires it UNCHANGED
|
|
@@ -51688,10 +51690,17 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51688
51690
|
completedDebounceTimer = null;
|
|
51689
51691
|
completedDebouncePending = null;
|
|
51690
51692
|
lastExternalCompletionProbe = null;
|
|
51691
|
-
/** TX-FSM
|
|
51692
|
-
*
|
|
51693
|
-
*
|
|
51693
|
+
/** TX-FSM: lazily-created transcript signal normalizer. Fed ONLY by
|
|
51694
|
+
* transcript reads this instance already performs — it adds zero I/O.
|
|
51695
|
+
* Stage 0: its output was a pure shadow observation for the FSM driver.
|
|
51696
|
+
* Stage 1: the instance's own stall/growth-hold judgments consume the
|
|
51697
|
+
* normalized snapshot too (single source of truth). */
|
|
51694
51698
|
transcriptSignalSource = null;
|
|
51699
|
+
/** TX-FSM Stage 1: the latest snapshot the source produced (set inside
|
|
51700
|
+
* publishTranscriptSignalObservation). Consumed the same tick by the
|
|
51701
|
+
* stall-path / growth-hold judgments via probeNativeTranscriptSignals —
|
|
51702
|
+
* never treated as fresh across ticks. */
|
|
51703
|
+
lastTranscriptSignalSnapshot = null;
|
|
51695
51704
|
/**
|
|
51696
51705
|
* The final assistant summary of the last completed turn, cached at
|
|
51697
51706
|
* completion-emit time. For a native-source provider (antigravity) whose
|
|
@@ -51869,19 +51878,21 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51869
51878
|
return restoredHistory.messages;
|
|
51870
51879
|
}
|
|
51871
51880
|
/**
|
|
51872
|
-
* TX-FSM
|
|
51873
|
-
*
|
|
51874
|
-
*
|
|
51875
|
-
*
|
|
51876
|
-
*
|
|
51877
|
-
*
|
|
51878
|
-
*
|
|
51879
|
-
*
|
|
51880
|
-
*
|
|
51881
|
+
* TX-FSM: normalize the transcript read that JUST happened into a
|
|
51882
|
+
* SignalSnapshot. Stage 0 injected it into the FSM driver as a pure
|
|
51883
|
+
* shadow observation (daemon → SpecCliAdapter → FsmDriver); Stage 1
|
|
51884
|
+
* additionally caches it (lastTranscriptSignalSnapshot) so the instance's
|
|
51885
|
+
* OWN stall/growth-hold judgments consume the SAME normalized snapshot
|
|
51886
|
+
* instead of re-running private transcript scans. Fed ONLY by reads this
|
|
51887
|
+
* method's caller already performs — it adds zero I/O, so the getState()
|
|
51888
|
+
* zero-native-read invariant and the stall-path read cadence are
|
|
51889
|
+
* untouched. The source update runs regardless of the adapter hook so a
|
|
51890
|
+
* non-spec provider still produces the instance-side snapshot (the FSM
|
|
51891
|
+
* injection is simply skipped there). Fail-open end to end — an
|
|
51892
|
+
* unresolved transcript or any throw degrades to "no observation", never
|
|
51893
|
+
* to a wedge.
|
|
51881
51894
|
*/
|
|
51882
51895
|
publishTranscriptSignalObservation(messages, error = false) {
|
|
51883
|
-
const adapter = this.adapter;
|
|
51884
|
-
if (typeof adapter?.setSignalObservation !== "function") return;
|
|
51885
51896
|
try {
|
|
51886
51897
|
if (!this.transcriptSignalSource) {
|
|
51887
51898
|
this.transcriptSignalSource = new TranscriptSignalSource({
|
|
@@ -51891,7 +51902,8 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51891
51902
|
profile: resolveTranscriptAuthorityProfile(this.provider),
|
|
51892
51903
|
turnStartedAt: () => {
|
|
51893
51904
|
const t = this.adapter?.currentTurnStartedAt;
|
|
51894
|
-
|
|
51905
|
+
if (typeof t === "number" && Number.isFinite(t)) return t;
|
|
51906
|
+
return this.meshTaskInjectedAt > 0 ? this.meshTaskInjectedAt : void 0;
|
|
51895
51907
|
},
|
|
51896
51908
|
// Reuse the exact completion machinery (I1) for the
|
|
51897
51909
|
// final_assistant_present signal rather than duplicating
|
|
@@ -51903,7 +51915,11 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51903
51915
|
const snapshot = this.transcriptSignalSource.update(
|
|
51904
51916
|
{ messages, probe: this.lastExternalCompletionProbe, error }
|
|
51905
51917
|
);
|
|
51906
|
-
|
|
51918
|
+
this.lastTranscriptSignalSnapshot = snapshot;
|
|
51919
|
+
const adapter = this.adapter;
|
|
51920
|
+
if (typeof adapter?.setSignalObservation === "function") {
|
|
51921
|
+
adapter.setSignalObservation(snapshot);
|
|
51922
|
+
}
|
|
51907
51923
|
} catch {
|
|
51908
51924
|
}
|
|
51909
51925
|
}
|
|
@@ -52396,17 +52412,17 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52396
52412
|
const threshold = turnActive ? _CliProviderInstance.MESH_WORKER_STALL_TURN_THRESHOLD_MS : _CliProviderInstance.MESH_WORKER_STALL_IDLE_THRESHOLD_MS;
|
|
52397
52413
|
const stalledMs = now - this.meshStallAnchorAt;
|
|
52398
52414
|
if (stalledMs < threshold) return;
|
|
52399
|
-
const
|
|
52400
|
-
if (
|
|
52401
|
-
const
|
|
52402
|
-
|
|
52403
|
-
|
|
52404
|
-
if (
|
|
52415
|
+
const transcriptSignals = this.probeNativeTranscriptSignals();
|
|
52416
|
+
if (transcriptSignals?.snapshot?.available === true) {
|
|
52417
|
+
const firstSampleThisEpisode = !this.meshStallTranscriptSignalSampled;
|
|
52418
|
+
this.meshStallTranscriptSignalSampled = true;
|
|
52419
|
+
const signalDetail = transcriptSignals.snapshot.detail;
|
|
52420
|
+
if (firstSampleThisEpisode || transcriptSignals.snapshot.signals.in_turn_progress === true) {
|
|
52405
52421
|
if (this.isMeshWorkerSession()) {
|
|
52406
52422
|
traceMeshEventDrop(
|
|
52407
52423
|
"mesh_worker_stall_transcript_advancing",
|
|
52408
52424
|
this.meshTraceCtx("monitor:no_progress"),
|
|
52409
|
-
`msgCount=${
|
|
52425
|
+
`msgCount=${signalDetail.msgCount} sourceMtime=${signalDetail.sourceMtimeMs} (PTY quiet ${Math.round(stalledMs / 1e3)}s but transcript advancing)`
|
|
52410
52426
|
);
|
|
52411
52427
|
}
|
|
52412
52428
|
this.meshStallAnchorAt = now;
|
|
@@ -52414,7 +52430,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52414
52430
|
return;
|
|
52415
52431
|
}
|
|
52416
52432
|
}
|
|
52417
|
-
if (this.tryReconcileTranscriptCompletionForStall(observedStatus)) {
|
|
52433
|
+
if (this.tryReconcileTranscriptCompletionForStall(observedStatus, transcriptSignals)) {
|
|
52418
52434
|
this.meshStallEmittedForAnchor = true;
|
|
52419
52435
|
return;
|
|
52420
52436
|
}
|
|
@@ -52454,38 +52470,45 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52454
52470
|
this.meshStallEmittedForAnchor = false;
|
|
52455
52471
|
this.meshStallTurnActiveLast = void 0;
|
|
52456
52472
|
this.meshStallLastFiredAt = -1;
|
|
52457
|
-
this.
|
|
52473
|
+
this.meshStallTranscriptSignalSampled = false;
|
|
52458
52474
|
}
|
|
52475
|
+
/** The result of one native-transcript signal probe: the normalized
|
|
52476
|
+
* snapshot the shared TranscriptSignalSource produced from the read, and
|
|
52477
|
+
* the very messages it was normalized from (so a judgment site can pull
|
|
52478
|
+
* a payload — e.g. the final summary — from the SAME read with zero
|
|
52479
|
+
* added I/O). */
|
|
52459
52480
|
/**
|
|
52460
|
-
*
|
|
52461
|
-
*
|
|
52462
|
-
*
|
|
52463
|
-
*
|
|
52464
|
-
*
|
|
52465
|
-
*
|
|
52466
|
-
*
|
|
52467
|
-
*
|
|
52468
|
-
*
|
|
52481
|
+
* TX-FSM Stage 1 — the single native-transcript signal probe (replaces
|
|
52482
|
+
* the Stage-0 sampleNativeTranscriptProgress fingerprint sampler). For a
|
|
52483
|
+
* native-source provider (its authoritative history is an on-disk
|
|
52484
|
+
* transcript file, e.g. kimi's wire.jsonl), perform the read this
|
|
52485
|
+
* judgment point already owns — SAME cadence as before, one
|
|
52486
|
+
* readExternalCompletionMessages() per call, never more — and return the
|
|
52487
|
+
* NORMALIZED SignalSnapshot the shared TranscriptSignalSource produced
|
|
52488
|
+
* from it (publishTranscriptSignalObservation runs inside the read), plus
|
|
52489
|
+
* the messages that read returned. Judgment sites (the stall watchdog's
|
|
52490
|
+
* transcript-advancing axis, the completion growth-hold, the stall-path
|
|
52491
|
+
* completion rescue) consume the snapshot's SIGNALS instead of running
|
|
52492
|
+
* their own fingerprint/freshness/final-assistant scans — one source of
|
|
52493
|
+
* truth for "what does the transcript say right now".
|
|
52469
52494
|
*
|
|
52470
|
-
*
|
|
52471
|
-
*
|
|
52472
|
-
*
|
|
52473
|
-
* (
|
|
52495
|
+
* Class gating goes through resolveTranscriptAuthorityProfile ONLY.
|
|
52496
|
+
* Returns null for a non-native-source class (nothing to signal from) and
|
|
52497
|
+
* a null snapshot when the read threw — callers keep their fail-open
|
|
52498
|
+
* fallbacks ("couldn't tell" never blocks an idle verdict and never
|
|
52499
|
+
* fabricates a completion). Cheap enough for the stall path: it runs
|
|
52500
|
+
* only at the stall threshold (≥180s of PTY stasis) or during an armed
|
|
52501
|
+
* completion-debounce retry, never on the routine 5s tick.
|
|
52474
52502
|
*/
|
|
52475
|
-
|
|
52476
|
-
if (
|
|
52503
|
+
probeNativeTranscriptSignals() {
|
|
52504
|
+
if (resolveTranscriptAuthorityProfile(this.provider).class !== "native-source") return null;
|
|
52477
52505
|
let messages = null;
|
|
52478
52506
|
try {
|
|
52479
52507
|
messages = this.readExternalCompletionMessages();
|
|
52480
52508
|
} catch {
|
|
52481
|
-
return null;
|
|
52509
|
+
return { snapshot: null, messages: null };
|
|
52482
52510
|
}
|
|
52483
|
-
|
|
52484
|
-
if (!probe) return null;
|
|
52485
|
-
return {
|
|
52486
|
-
msgCount: typeof probe.msgCount === "number" ? probe.msgCount : Array.isArray(messages) ? messages.length : 0,
|
|
52487
|
-
sourceMtimeMs: typeof probe.sourceMtimeMs === "number" ? probe.sourceMtimeMs : 0
|
|
52488
|
-
};
|
|
52511
|
+
return { snapshot: this.lastTranscriptSignalSnapshot, messages };
|
|
52489
52512
|
}
|
|
52490
52513
|
/**
|
|
52491
52514
|
* KIMI-MESH-COMPLETION-EMIT (axis 2). Last-chance completion emit for a mesh
|
|
@@ -52574,8 +52597,22 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52574
52597
|
* false for a daemon-owned provider and for a genuinely mid-turn / wedged
|
|
52575
52598
|
* worker with no in-turn final assistant, so a real stall still fires
|
|
52576
52599
|
* unchanged. Evidence bar is identical to flushMeshCompletionBeforeCleanup.
|
|
52600
|
+
*
|
|
52601
|
+
* TX-FSM Stage 1 (FIX 3 probe delegation): for a native-source class the
|
|
52602
|
+
* completion VERDICT is the shared TranscriptSignalSource's
|
|
52603
|
+
* final_assistant_present signal, normalized from the ONE transcript read
|
|
52604
|
+
* the stall watchdog already performed this tick (passed in as
|
|
52605
|
+
* `transcriptSignals`) — not a second private read + scan. The emit
|
|
52606
|
+
* payload (finalSummary) is extracted from the SAME messages the signal
|
|
52607
|
+
* was normalized from, with the SAME turn boundary the legacy path used,
|
|
52608
|
+
* so the extraction re-proves the turn scope the signal checked. Fail-open
|
|
52609
|
+
* both ways: no usable snapshot (read failed / unresolved / a pure-PTY
|
|
52610
|
+
* class, which has no native signal by construction) → the legacy
|
|
52611
|
+
* class-appropriate evidence path (completionFinalSummary), unchanged; and
|
|
52612
|
+
* a present-but-unextractable signal yields false rather than a
|
|
52613
|
+
* payload-less emit.
|
|
52577
52614
|
*/
|
|
52578
|
-
tryReconcileTranscriptCompletionForStall(observedStatus) {
|
|
52615
|
+
tryReconcileTranscriptCompletionForStall(observedStatus, transcriptSignals) {
|
|
52579
52616
|
const profile = resolveTranscriptAuthorityProfile(this.provider);
|
|
52580
52617
|
if (profile.class === "daemon-owned") return false;
|
|
52581
52618
|
if (observedStatus !== "idle") return false;
|
|
@@ -52593,10 +52630,19 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52593
52630
|
parsedMessages = void 0;
|
|
52594
52631
|
}
|
|
52595
52632
|
let finalSummary;
|
|
52596
|
-
|
|
52597
|
-
|
|
52598
|
-
|
|
52599
|
-
finalSummary =
|
|
52633
|
+
const signalSnapshot = transcriptSignals?.snapshot;
|
|
52634
|
+
if (profile.class === "native-source" && signalSnapshot?.available === true) {
|
|
52635
|
+
if (signalSnapshot.signals.final_assistant_present !== true) return false;
|
|
52636
|
+
finalSummary = extractFinalSummaryFromMessagesAfter(
|
|
52637
|
+
Array.isArray(transcriptSignals?.messages) ? transcriptSignals.messages : [],
|
|
52638
|
+
turnStartedAt
|
|
52639
|
+
) || void 0;
|
|
52640
|
+
} else {
|
|
52641
|
+
try {
|
|
52642
|
+
finalSummary = this.completionFinalSummary(parsedMessages, turnStartedAt);
|
|
52643
|
+
} catch {
|
|
52644
|
+
finalSummary = void 0;
|
|
52645
|
+
}
|
|
52600
52646
|
}
|
|
52601
52647
|
if (!finalSummary) return false;
|
|
52602
52648
|
const diagnosticSource = profile.class === "pure-pty" ? "stall_pure_pty_transcript_completion" : "stall_native_source_transcript_completion";
|
|
@@ -52863,24 +52909,25 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
52863
52909
|
const isTranscriptEvidenceGate = block2.allowTimeout === true;
|
|
52864
52910
|
LOG.debug("CLI", `[${this.type}] finalization block: reason=${blockReason} terminal=${block2.terminal} allowTimeout=${isTranscriptEvidenceGate} waitedMs=${waitedMs} maxWait=${COMPLETED_FINALIZATION_MAX_WAIT_MS}`);
|
|
52865
52911
|
if (blockReason === "missing_final_assistant" && block2.noExternalTranscriptSource === true) {
|
|
52866
|
-
let
|
|
52912
|
+
let growthSnapshot = null;
|
|
52867
52913
|
try {
|
|
52868
|
-
|
|
52914
|
+
growthSnapshot = this.probeNativeTranscriptSignals()?.snapshot ?? null;
|
|
52869
52915
|
} catch {
|
|
52870
|
-
|
|
52916
|
+
growthSnapshot = null;
|
|
52871
52917
|
}
|
|
52872
|
-
|
|
52873
|
-
|
|
52918
|
+
if (growthSnapshot?.available === true && growthSnapshot.signals.transcript_growing === true) {
|
|
52919
|
+
const growthDetail = growthSnapshot.detail;
|
|
52920
|
+
const mtimeAgeMs = growthDetail.ageMs ?? 0;
|
|
52874
52921
|
if (pending.loggedBlockReason !== "native_transcript_advancing") {
|
|
52875
|
-
LOG.info("CLI", `[${this.type}] holding pending completed (native_transcript_advancing: msgCount=${
|
|
52922
|
+
LOG.info("CLI", `[${this.type}] holding pending completed (native_transcript_advancing: msgCount=${growthDetail.msgCount} mtimeAge=${mtimeAgeMs}ms < ${MISSING_ASSISTANT_TRANSCRIPT_GROWTH_QUIET_MS}ms) \u2014 transcript still growing, screen-idle verdict not trusted`);
|
|
52876
52923
|
if (this.isMeshWorkerSession()) {
|
|
52877
|
-
traceMeshEventDrop("completion_gate_hold", this.meshTraceCtx(), `native_transcript_advancing msgCount=${
|
|
52924
|
+
traceMeshEventDrop("completion_gate_hold", this.meshTraceCtx(), `native_transcript_advancing msgCount=${growthDetail.msgCount} mtimeAge=${mtimeAgeMs}ms`);
|
|
52878
52925
|
}
|
|
52879
52926
|
if (this.completionTraceOn()) this.recordCompletionGateTrace("hold", {
|
|
52880
52927
|
blockReason: "native_transcript_advancing",
|
|
52881
52928
|
latestVisibleStatus,
|
|
52882
|
-
msgCount:
|
|
52883
|
-
sourceMtimeAgeMs:
|
|
52929
|
+
msgCount: growthDetail.msgCount,
|
|
52930
|
+
sourceMtimeAgeMs: mtimeAgeMs,
|
|
52884
52931
|
growthQuietMs: MISSING_ASSISTANT_TRANSCRIPT_GROWTH_QUIET_MS,
|
|
52885
52932
|
waitedMs
|
|
52886
52933
|
});
|