@adhdev/daemon-core 1.0.18-rc.14 → 1.0.18-rc.15

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.mjs CHANGED
@@ -437,10 +437,10 @@ function readInjected(value) {
437
437
  }
438
438
  function getDaemonBuildInfo() {
439
439
  if (cached) return cached;
440
- const commit = readInjected(true ? "a44f4a2814c4db171a9ebb0f6fcfb0798203aebb" : void 0) ?? "unknown";
441
- const commitShort = readInjected(true ? "a44f4a28" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
442
- const version = readInjected(true ? "1.0.18-rc.14" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
443
- const builtAt = readInjected(true ? "2026-07-22T17:37:52.683Z" : void 0);
440
+ const commit = readInjected(true ? "64f056340da99d3b28464efcf5c05fe643e5db63" : void 0) ?? "unknown";
441
+ const commitShort = readInjected(true ? "64f05634" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
442
+ const version = readInjected(true ? "1.0.18-rc.15" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
443
+ const builtAt = readInjected(true ? "2026-07-23T00:51:36.808Z" : void 0);
444
444
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
445
445
  return cached;
446
446
  }
@@ -12929,6 +12929,12 @@ var init_spawn_env = __esm({
12929
12929
  // src/cli-adapters/provider-cli-shared.ts
12930
12930
  import * as os5 from "os";
12931
12931
  import * as path11 from "path";
12932
+ function isPurePtyTranscriptProvider(provider) {
12933
+ if (provider.transcriptAuthority === "provider") return false;
12934
+ if (provider.nativeHistory) return false;
12935
+ const transcriptPty = provider.tui?.transcriptPty;
12936
+ return transcriptPty?.scope === "buffer";
12937
+ }
12932
12938
  function stripAnsi(str) {
12933
12939
  return str.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
12934
12940
  }
@@ -23180,10 +23186,54 @@ async function recoverStrandedAssignedDispatches(components, mesh, store, localD
23180
23186
  for (const key2 of [...deliveredUnconsumedUnknownStreak.keys()]) {
23181
23187
  if (key2.startsWith(meshKeyPrefix) && !assignedKeys.has(key2)) deliveredUnconsumedUnknownStreak.delete(key2);
23182
23188
  }
23189
+ for (const key2 of [...assignedIdleFinalAssistantSince.keys()]) {
23190
+ if (key2.startsWith(meshKeyPrefix) && !assignedKeys.has(key2)) assignedIdleFinalAssistantSince.delete(key2);
23191
+ }
23183
23192
  for (const row of assigned) {
23184
23193
  const dispatchedAtMs = Date.parse(row.dispatchTimestamp ?? "");
23185
23194
  if (!Number.isFinite(dispatchedAtMs)) continue;
23186
23195
  const ageMs = nowMs - dispatchedAtMs;
23196
+ const idleTranscriptStreakKey = `${meshId}::${row.id}`;
23197
+ if (store.taskHasConfirmedDelivery(meshId, row.id) && !findTerminalLedgerEvidenceForTask({ meshId, taskId: row.id }) && readNonEmptyString(row.assignedSessionId) && resolveSessionBusyVerdict(components, row.assignedSessionId) !== "GENERATING") {
23198
+ const since = assignedIdleFinalAssistantSince.get(idleTranscriptStreakKey);
23199
+ if (since === void 0) {
23200
+ assignedIdleFinalAssistantSince.set(idleTranscriptStreakKey, nowMs);
23201
+ } else if (nowMs - since >= ASSIGNED_IDLE_TRANSCRIPT_COMPLETE_MS) {
23202
+ const terminalEvidence = await pollAssignedTaskTerminalEvidence(components, mesh, row);
23203
+ if (terminalEvidence) {
23204
+ assignedIdleFinalAssistantSince.delete(idleTranscriptStreakKey);
23205
+ updateTaskStatus(meshId, row.id, terminalEvidence);
23206
+ if (!findTerminalLedgerEvidenceForTask({ meshId, taskId: row.id })) {
23207
+ try {
23208
+ appendLedgerEntry(meshId, {
23209
+ kind: terminalEvidence === "completed" ? "task_completed" : "task_failed",
23210
+ nodeId: row.assignedNodeId,
23211
+ sessionId: row.assignedSessionId,
23212
+ providerType: row.assignedProviderType,
23213
+ payload: {
23214
+ taskId: row.id,
23215
+ event: "agent:generating_completed",
23216
+ source: "early_idle_transcript_evidence"
23217
+ }
23218
+ });
23219
+ } catch {
23220
+ }
23221
+ }
23222
+ LOG.warn("MeshReconcile", `Early-completed assigned task ${row.id} on mesh ${meshId} (node=${row.assignedNodeId ?? "?"} session=${row.assignedSessionId ?? "?"}): worker idle with a final assistant message after dispatch for \u2265${Math.round(ASSIGNED_IDLE_TRANSCRIPT_COMPLETE_MS / 1e3)}s \u2014 the completion event was lost/late (pure-PTY provider), task is ${terminalEvidence} without waiting the 15-min deadline`);
23223
+ traceMeshEventDrop("assigned_early_transcript_completed", {
23224
+ taskId: row.id,
23225
+ sessionId: row.assignedSessionId,
23226
+ nodeId: row.assignedNodeId,
23227
+ meshId,
23228
+ event: "agent:generating_completed"
23229
+ }, terminalEvidence);
23230
+ continue;
23231
+ }
23232
+ assignedIdleFinalAssistantSince.delete(idleTranscriptStreakKey);
23233
+ }
23234
+ } else {
23235
+ assignedIdleFinalAssistantSince.delete(idleTranscriptStreakKey);
23236
+ }
23187
23237
  if (ageMs >= ASSIGNED_DELIVERED_UNCONSUMED_REDRIVE_MS && ageMs < ASSIGNED_STRANDED_DEADLINE_MS && store.taskHasConfirmedDelivery(meshId, row.id) && !store.taskDeliveryConsumed(meshId, row.id)) {
23188
23238
  const terminal2 = findTerminalLedgerEvidenceForTask({ meshId, taskId: row.id });
23189
23239
  if (terminal2) {
@@ -23859,7 +23909,7 @@ function setupMeshReconcileLoop(components) {
23859
23909
  }
23860
23910
  };
23861
23911
  }
23862
- var coordinatorModalParkState, DISK_RETENTION_INTERVAL_MS, lastDiskRetentionRunAt, heldEventLedgerRecorded, ASSIGNED_STRANDED_DEADLINE_MS, DELIVERED_NO_TURN_DEADLINE_MS, ASSIGNED_DELIVERED_UNCONSUMED_REDRIVE_MS, RECLAIM_UNKNOWN_GRACE_TICKS, deliveredNoTurnUnknownStreak, deliveredUnconsumedUnknownStreak, ZOMBIE_ASSIGNED_MIN_AGE_MS, STRICT_SESSION_MATCH_TTL_MS, unresolvedForwardRejectionCounts, MAX_FORWARD_REJECTIONS, UNRESOLVED_FORWARD_NUDGE_DELAY_MS, unresolvedForwardNudgeTimer, unresolvedForwardNudgeRunning;
23912
+ var coordinatorModalParkState, DISK_RETENTION_INTERVAL_MS, lastDiskRetentionRunAt, heldEventLedgerRecorded, ASSIGNED_STRANDED_DEADLINE_MS, DELIVERED_NO_TURN_DEADLINE_MS, ASSIGNED_DELIVERED_UNCONSUMED_REDRIVE_MS, RECLAIM_UNKNOWN_GRACE_TICKS, deliveredNoTurnUnknownStreak, deliveredUnconsumedUnknownStreak, ASSIGNED_IDLE_TRANSCRIPT_COMPLETE_MS, assignedIdleFinalAssistantSince, ZOMBIE_ASSIGNED_MIN_AGE_MS, STRICT_SESSION_MATCH_TTL_MS, unresolvedForwardRejectionCounts, MAX_FORWARD_REJECTIONS, UNRESOLVED_FORWARD_NUDGE_DELAY_MS, unresolvedForwardNudgeTimer, unresolvedForwardNudgeRunning;
23863
23913
  var init_mesh_reconcile_loop = __esm({
23864
23914
  "src/mesh/mesh-reconcile-loop.ts"() {
23865
23915
  "use strict";
@@ -23897,6 +23947,8 @@ var init_mesh_reconcile_loop = __esm({
23897
23947
  RECLAIM_UNKNOWN_GRACE_TICKS = 3;
23898
23948
  deliveredNoTurnUnknownStreak = /* @__PURE__ */ new Map();
23899
23949
  deliveredUnconsumedUnknownStreak = /* @__PURE__ */ new Map();
23950
+ ASSIGNED_IDLE_TRANSCRIPT_COMPLETE_MS = 8e3;
23951
+ assignedIdleFinalAssistantSince = /* @__PURE__ */ new Map();
23900
23952
  ZOMBIE_ASSIGNED_MIN_AGE_MS = 30 * 60 * 1e3;
23901
23953
  STRICT_SESSION_MATCH_TTL_MS = 6e4;
23902
23954
  unresolvedForwardRejectionCounts = /* @__PURE__ */ new Map();
@@ -26665,7 +26717,8 @@ var init_cli_state_engine = __esm({
26665
26717
  this.currentTurnStartedAt = Date.now();
26666
26718
  this.responseEpoch += 1;
26667
26719
  this.clearApprovalResolutionMemory();
26668
- if (this.provider.transcriptAuthority === "provider" && this.currentStatus !== "waiting_approval") {
26720
+ const promoteOnTurnStart = this.provider.transcriptAuthority === "provider" || isPurePtyTranscriptProvider(this.provider);
26721
+ if (promoteOnTurnStart && this.currentStatus !== "waiting_approval") {
26669
26722
  this.setStatus("generating", "turn_started");
26670
26723
  this.callbacks.onStatusChange();
26671
26724
  }
@@ -28195,10 +28248,7 @@ ${lastSnapshot}`;
28195
28248
  * provider-owned) so no other provider's turn-scoped parse changes.
28196
28249
  */
28197
28250
  parsesFullPtyTranscriptFromBuffer() {
28198
- if (this.providerOwnsTranscript()) return false;
28199
- if (this.provider.nativeHistory) return false;
28200
- const transcriptPty = this.provider.tui?.transcriptPty;
28201
- return transcriptPty?.scope === "buffer";
28251
+ return isPurePtyTranscriptProvider(this.provider);
28202
28252
  }
28203
28253
  /**
28204
28254
  * The turn scope to feed the transcript parser. Normally the live turn scope
@@ -44930,6 +44980,7 @@ import * as os21 from "os";
44930
44980
  import * as crypto5 from "crypto";
44931
44981
  import * as fs24 from "fs";
44932
44982
  init_hash();
44983
+ init_provider_cli_shared();
44933
44984
 
44934
44985
  // src/providers/spec/route.ts
44935
44986
  init_provider_cli_adapter();
@@ -50606,6 +50657,10 @@ var CliProviderInstance = class _CliProviderInstance {
50606
50657
  return;
50607
50658
  }
50608
50659
  }
50660
+ if (this.tryReconcilePurePtyCompletionForStall(observedStatus)) {
50661
+ this.meshStallEmittedForAnchor = true;
50662
+ return;
50663
+ }
50609
50664
  this.meshStallEmittedForAnchor = true;
50610
50665
  if (this.meshStallLastFiredAt >= 0 && now - this.meshStallLastFiredAt < _CliProviderInstance.MESH_WORKER_STALL_REFIRE_COOLDOWN_MS) {
50611
50666
  return;
@@ -50736,6 +50791,70 @@ var CliProviderInstance = class _CliProviderInstance {
50736
50791
  });
50737
50792
  return true;
50738
50793
  }
50794
+ /**
50795
+ * KIMI-PURE-PTY-COMPLETION-EMIT (Fix 3): stall-path completion reconcile for the
50796
+ * PURE-PTY transcript class (kimi and kin — no native transcript, no provider
50797
+ * authority; see isPurePtyTranscriptProvider). Such a worker whose
50798
+ * generating_completed never emitted (the onTurnStarted idle→idle collapse Fix 1
50799
+ * fixes at the source) sits at a STATIC idle prompt: its PTY output stops the
50800
+ * instant the answer is rendered, so the status-agnostic no-progress watchdog
50801
+ * (checkMeshWorkerStall) reads the finished-but-quiet session as a stall and would
50802
+ * false-fire monitor:no_progress. The native-transcript reconcile
50803
+ * (sampleNativeTranscriptProgress) does NOT cover this class (no native source →
50804
+ * null sample), so the stall path needs its own guard.
50805
+ *
50806
+ * Called from checkMeshWorkerStall just before the fire. Returns true when the
50807
+ * session is a finished pure-PTY turn — idle, no pending response, and a PTY-parsed
50808
+ * in-turn final assistant summary — in which case it emits the missing
50809
+ * generating_completed (idempotent: a real/late emit writes the terminal ledger and
50810
+ * the coordinator's reconcile makes any duplicate a no-op) and the caller SUPPRESSES
50811
+ * the stall. Returns false for every other class/state (native-source provider, a
50812
+ * genuinely mid-turn or wedged worker with no final assistant), so a real stall still
50813
+ * fires unchanged.
50814
+ *
50815
+ * Evidence bar is identical to flushMeshCompletionBeforeCleanup: injected task's turn
50816
+ * genuinely started + an in-turn final assistant summary. Conservative by
50817
+ * construction — no summary ⇒ no proof of completion ⇒ return false and let the real
50818
+ * stall fire.
50819
+ */
50820
+ tryReconcilePurePtyCompletionForStall(observedStatus) {
50821
+ if (!isPurePtyTranscriptProvider(this.provider)) return false;
50822
+ if (observedStatus !== "idle") return false;
50823
+ if (this.hasAdapterPendingResponse()) return false;
50824
+ const taskId = this.completingTurnTaskId();
50825
+ if (this.lastEmittedCompletion && this.lastEmittedCompletion.taskId === (taskId ?? "")) {
50826
+ return false;
50827
+ }
50828
+ if (!this.injectedTaskHasStartedGenerating()) return false;
50829
+ const turnStartedAt = typeof this.adapter?.currentTurnStartedAt === "number" ? this.adapter.currentTurnStartedAt : this.meshTaskInjectedAt || void 0;
50830
+ let parsedMessages;
50831
+ try {
50832
+ parsedMessages = this.adapter?.getScriptParsedStatus?.()?.messages;
50833
+ } catch {
50834
+ parsedMessages = void 0;
50835
+ }
50836
+ let finalSummary;
50837
+ try {
50838
+ finalSummary = this.completionFinalSummary(parsedMessages, turnStartedAt);
50839
+ } catch {
50840
+ finalSummary = void 0;
50841
+ }
50842
+ if (!finalSummary) return false;
50843
+ LOG.warn("CLI", `[${this.type}] reconciling pure-PTY mesh completion from the stall path for session ${this.instanceId} task=${taskId ?? "(none)"} \u2014 PTY is idle-quiet with an in-turn final assistant message but the completion event never fired (pure-PTY provider); emitting it instead of a false monitor:no_progress.`);
50844
+ if (this.isMeshWorkerSession()) {
50845
+ traceMeshEventStage("fired", this.meshTraceCtx(), "stall_pure_pty_transcript_completion");
50846
+ }
50847
+ this.emitGeneratingCompleted({
50848
+ chatTitle: "",
50849
+ duration: void 0,
50850
+ timestamp: Date.now(),
50851
+ taskId,
50852
+ finalSummary,
50853
+ evidenceLevel: "transcript",
50854
+ completionDiagnostic: { source: "stall_pure_pty_transcript_completion" }
50855
+ });
50856
+ return true;
50857
+ }
50739
50858
  /**
50740
50859
  * AUTOAPPROVE-FLAP-RECUR (Fix A+B): how long a busy blip / modal scroll-out may
50741
50860
  * persist before the in-progress settle gate is torn down. For a delegated