@adhdev/daemon-standalone 1.0.18-rc.12 → 1.0.18-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 CHANGED
@@ -30265,10 +30265,10 @@ var require_dist3 = __commonJS({
30265
30265
  }
30266
30266
  function getDaemonBuildInfo() {
30267
30267
  if (cached2) return cached2;
30268
- const commit = readInjected(true ? "8cce29137e6b62781be7645411736bd8d1a9e7a8" : void 0) ?? "unknown";
30269
- const commitShort = readInjected(true ? "8cce2913" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30270
- const version2 = readInjected(true ? "1.0.18-rc.12" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30271
- const builtAt = readInjected(true ? "2026-07-22T12:26:05.397Z" : void 0);
30268
+ const commit = readInjected(true ? "2a9ab536171fcf675788ac5b41596e740046bbfa" : void 0) ?? "unknown";
30269
+ const commitShort = readInjected(true ? "2a9ab536" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30270
+ const version2 = readInjected(true ? "1.0.18-rc.13" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30271
+ const builtAt = readInjected(true ? "2026-07-22T14:02:17.678Z" : void 0);
30272
30272
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30273
30273
  return cached2;
30274
30274
  }
@@ -79326,6 +79326,18 @@ ${body}
79326
79326
  // MESH_WORKER_STALL_REFIRE_COOLDOWN_MS between successive emissions across
79327
79327
  // anchor re-arms (the per-anchor guard only covers a single continuous stall).
79328
79328
  meshStallLastFiredAt = -1;
79329
+ // KIMI-MESH-COMPLETION-EMIT (axis 1): the native-source transcript progress
79330
+ // fingerprint (record count + source mtime) observed the LAST time the stall
79331
+ // watchdog checked a native-source provider (transcriptAuthority=provider — e.g.
79332
+ // kimi wire.jsonl). A pure-PTY native-source worker running a long, screen-quiet
79333
+ // tool (no viewport bytes for minutes) looks stalled by the lastOutputAt clock
79334
+ // even though its transcript file is still growing. Before firing the stall, we
79335
+ // compare the current transcript fingerprint against this snapshot; if the
79336
+ // transcript advanced, the "stall" is a false positive of PTY-render stasis, so
79337
+ // we re-arm the anchor instead of paging the coordinator (whose no_progress
79338
+ // handling can lead to the worker being stopped mid-work → completion never
79339
+ // emitted). null = not yet sampled for this session/anchor.
79340
+ meshStallNativeTranscriptSample = null;
79329
79341
  // FALSE-IDLE continuity epoch: monotonically bumped on EVERY entry into a busy
79330
79342
  // phase (→generating or →waiting_approval). The completedDebouncePending snapshots
79331
79343
  // this value at arm time (busyEpochAtArm); the flush guard requires it UNCHANGED
@@ -80135,6 +80147,14 @@ ${body}
80135
80147
  * once at completion). Reset on the next turn's start.
80136
80148
  */
80137
80149
  lastCompletionSummary = null;
80150
+ // KIMI-MESH-COMPLETION-EMIT (axis 2, double-emit guard): the (taskId, wall-clock)
80151
+ // of the most recent agent:generating_completed this instance emitted, stamped by
80152
+ // emitGeneratingCompleted. The pre-cleanup completion flush
80153
+ // (flushMeshCompletionBeforeCleanup, driven by cli-manager's exit monitor) reads
80154
+ // this to refuse a SECOND completion for a turn whose completion already fired —
80155
+ // so a worker that finished cleanly and is simply being auto-cleaned never emits a
80156
+ // duplicate. taskId '' covers an ad-hoc (no-task) turn. null = none emitted yet.
80157
+ lastEmittedCompletion = null;
80138
80158
  async enforceFreshSessionLaunchIfNeeded() {
80139
80159
  const scriptName = getForcedNewSessionScriptName(this.provider, this.launchMode);
80140
80160
  if (!scriptName) return;
@@ -80760,6 +80780,24 @@ ${body}
80760
80780
  const threshold = turnActive ? _CliProviderInstance.MESH_WORKER_STALL_TURN_THRESHOLD_MS : _CliProviderInstance.MESH_WORKER_STALL_IDLE_THRESHOLD_MS;
80761
80781
  const stalledMs = now - this.meshStallAnchorAt;
80762
80782
  if (stalledMs < threshold) return;
80783
+ const nativeSample = this.sampleNativeTranscriptProgress();
80784
+ if (nativeSample) {
80785
+ const prev = this.meshStallNativeTranscriptSample;
80786
+ const advanced = !prev || nativeSample.msgCount > prev.msgCount || nativeSample.sourceMtimeMs > prev.sourceMtimeMs;
80787
+ this.meshStallNativeTranscriptSample = nativeSample;
80788
+ if (advanced) {
80789
+ if (this.isMeshWorkerSession()) {
80790
+ traceMeshEventDrop(
80791
+ "mesh_worker_stall_transcript_advancing",
80792
+ this.meshTraceCtx("monitor:no_progress"),
80793
+ `msgCount=${nativeSample.msgCount} sourceMtime=${nativeSample.sourceMtimeMs} (PTY quiet ${Math.round(stalledMs / 1e3)}s but transcript advancing)`
80794
+ );
80795
+ }
80796
+ this.meshStallAnchorAt = now;
80797
+ this.meshStallEmittedForAnchor = false;
80798
+ return;
80799
+ }
80800
+ }
80763
80801
  this.meshStallEmittedForAnchor = true;
80764
80802
  if (this.meshStallLastFiredAt >= 0 && now - this.meshStallLastFiredAt < _CliProviderInstance.MESH_WORKER_STALL_REFIRE_COOLDOWN_MS) {
80765
80803
  return;
@@ -80796,6 +80834,99 @@ ${body}
80796
80834
  this.meshStallEmittedForAnchor = false;
80797
80835
  this.meshStallTurnActiveLast = void 0;
80798
80836
  this.meshStallLastFiredAt = -1;
80837
+ this.meshStallNativeTranscriptSample = null;
80838
+ }
80839
+ /**
80840
+ * KIMI-MESH-COMPLETION-EMIT (axis 1). For a native-source provider
80841
+ * (transcriptAuthority=provider — its authoritative history is an on-disk
80842
+ * transcript file, e.g. kimi's wire.jsonl), sample the transcript's current
80843
+ * progress fingerprint (record count + source-file mtime) WITHOUT parsing the
80844
+ * PTY. Used by the stall watchdog to distinguish "PTY render is quiet but the
80845
+ * worker is still doing long tool work (transcript growing)" from a genuine
80846
+ * wedge. Returns null for a pure-PTY provider (no native source) or when the
80847
+ * source cannot be resolved this tick — the caller then falls back to the
80848
+ * unchanged lastOutputAt-only judgment.
80849
+ *
80850
+ * Generalized on the provider's native-source flag, NOT a hardcoded provider
80851
+ * type, so every current and future pure-PTY long-tool native-source provider
80852
+ * benefits. Cheap enough for the stall path: it runs only at the stall threshold
80853
+ * (≥180s of PTY stasis), never on the routine 5s tick.
80854
+ */
80855
+ sampleNativeTranscriptProgress() {
80856
+ if (!isNativeSourceCanonicalHistory(this.provider?.nativeHistory)) return null;
80857
+ let messages = null;
80858
+ try {
80859
+ messages = this.readExternalCompletionMessages();
80860
+ } catch {
80861
+ return null;
80862
+ }
80863
+ const probe = this.lastExternalCompletionProbe;
80864
+ if (!probe) return null;
80865
+ return {
80866
+ msgCount: typeof probe.msgCount === "number" ? probe.msgCount : Array.isArray(messages) ? messages.length : 0,
80867
+ sourceMtimeMs: typeof probe.sourceMtimeMs === "number" ? probe.sourceMtimeMs : 0
80868
+ };
80869
+ }
80870
+ /**
80871
+ * KIMI-MESH-COMPLETION-EMIT (axis 2). Last-chance completion emit for a mesh
80872
+ * DELEGATED worker whose PTY has already exited (e.g. killed by a false stall)
80873
+ * and is about to be auto-cleaned (cli-manager.startCliExitMonitor →
80874
+ * removeInstance closes the event-emit window forever). If the worker actually
80875
+ * FINISHED its assigned turn — its authoritative native transcript holds a final
80876
+ * assistant message for the injected task — but the completion event never fired
80877
+ * (the stall-kill happened before the FSM's idle transition), emit it now so the
80878
+ * coordinator learns the task completed instead of waiting ~180s for the reconcile
80879
+ * transcript-poll to reclaim it.
80880
+ *
80881
+ * Scope & guards (must all hold to emit):
80882
+ * • mesh worker session only — a normal standalone session's ordinary exit is
80883
+ * never synthesized (isMeshWorkerSession()).
80884
+ * • DOUBLE-EMIT guard — refuse if this turn's completion already fired
80885
+ * (lastEmittedCompletion matches the current taskId). A worker that completed
80886
+ * cleanly and is merely being cleaned up never double-emits.
80887
+ * • evidence gate — reuse the same final-assistant/turn-scoped summary machinery
80888
+ * as the normal completion path (completionFinalSummary over the native
80889
+ * transcript). No in-turn assistant summary ⇒ no proof of completion ⇒ leave
80890
+ * the reclaim path to handle a genuinely-unfinished worker.
80891
+ *
80892
+ * Returns true when a synthetic completion was emitted, false otherwise. Safe to
80893
+ * call unconditionally from the cleanup path.
80894
+ */
80895
+ flushMeshCompletionBeforeCleanup() {
80896
+ if (!this.isMeshWorkerSession()) return false;
80897
+ const taskId = this.completingTurnTaskId();
80898
+ if (this.lastEmittedCompletion && this.lastEmittedCompletion.taskId === (taskId ?? "")) {
80899
+ return false;
80900
+ }
80901
+ if (!this.injectedTaskHasStartedGenerating()) return false;
80902
+ const turnStartedAt = typeof this.adapter?.currentTurnStartedAt === "number" ? this.adapter.currentTurnStartedAt : this.meshTaskInjectedAt || void 0;
80903
+ let parsedMessages;
80904
+ try {
80905
+ parsedMessages = this.adapter?.getScriptParsedStatus?.()?.messages;
80906
+ } catch {
80907
+ parsedMessages = void 0;
80908
+ }
80909
+ let finalSummary;
80910
+ try {
80911
+ finalSummary = this.completionFinalSummary(parsedMessages, turnStartedAt);
80912
+ } catch {
80913
+ finalSummary = void 0;
80914
+ }
80915
+ if (!finalSummary) return false;
80916
+ LOG2.warn("CLI", `[${this.type}] emitting pre-cleanup mesh completion for session ${this.instanceId} task=${taskId ?? "(none)"} \u2014 PTY exited before the completion event fired but the native transcript shows a finished turn; synthesizing completion so the coordinator is not left waiting for reclaim.`);
80917
+ if (this.isMeshWorkerSession()) {
80918
+ traceMeshEventStage("fired", this.meshTraceCtx(), "pre_cleanup_transcript_completion");
80919
+ }
80920
+ this.emitGeneratingCompleted({
80921
+ chatTitle: "",
80922
+ duration: void 0,
80923
+ timestamp: Date.now(),
80924
+ taskId,
80925
+ finalSummary,
80926
+ evidenceLevel: "transcript",
80927
+ completionDiagnostic: { source: "pre_cleanup_transcript_completion" }
80928
+ });
80929
+ return true;
80799
80930
  }
80800
80931
  /**
80801
80932
  * AUTOAPPROVE-FLAP-RECUR (Fix A+B): how long a busy blip / modal scroll-out may
@@ -81197,6 +81328,7 @@ ${body}
81197
81328
  if (summary) {
81198
81329
  this.lastCompletionSummary = { content: summary, receivedAt: opts.timestamp };
81199
81330
  }
81331
+ this.lastEmittedCompletion = { taskId: typeof opts.taskId === "string" ? opts.taskId : "", at: Date.now() };
81200
81332
  this.pushEvent({
81201
81333
  event: "agent:generating_completed",
81202
81334
  chatTitle: opts.chatTitle,
@@ -83980,6 +84112,15 @@ ${rawInput}` : rawInput;
83980
84112
  clearInterval(checkStopped);
83981
84113
  setTimeout(() => {
83982
84114
  if (this.adapters.has(key2)) {
84115
+ try {
84116
+ const inst = instanceManager?.getInstance(key2);
84117
+ if (typeof inst?.flushMeshCompletionBeforeCleanup === "function") {
84118
+ const emitted = inst.flushMeshCompletionBeforeCleanup();
84119
+ if (emitted) LOG2.info("CLI", `Emitted pre-cleanup mesh completion for ${cliType} session ${key2} before auto-clean`);
84120
+ }
84121
+ } catch (e) {
84122
+ LOG2.warn("CLI", `pre-cleanup mesh completion flush failed for ${key2}: ${e?.message || e}`);
84123
+ }
83983
84124
  this.adapters.delete(key2);
83984
84125
  this.deps.removeAgentTracking(key2);
83985
84126
  sessionRegistry?.unregisterByInstanceKey(key2);