@adhdev/daemon-standalone 0.9.82-rc.362 → 0.9.82-rc.363

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
@@ -30036,10 +30036,10 @@ var require_dist3 = __commonJS({
30036
30036
  }
30037
30037
  function getDaemonBuildInfo() {
30038
30038
  if (cached2) return cached2;
30039
- const commit = readInjected(true ? "4b7c1b0d781f263663369085c4dde301d3b5cd2e" : void 0) ?? "unknown";
30040
- const commitShort = readInjected(true ? "4b7c1b0d" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30041
- const version2 = readInjected(true ? "0.9.82-rc.362" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30042
- const builtAt = readInjected(true ? "2026-06-23T12:54:51.128Z" : void 0);
30039
+ const commit = readInjected(true ? "4c5b30b1b0527ec5234c037893ba4fc24b88a8a0" : void 0) ?? "unknown";
30040
+ const commitShort = readInjected(true ? "4c5b30b1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30041
+ const version2 = readInjected(true ? "0.9.82-rc.363" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30042
+ const builtAt = readInjected(true ? "2026-06-23T16:14:01.927Z" : void 0);
30043
30043
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30044
30044
  return cached2;
30045
30045
  }
@@ -38374,6 +38374,13 @@ ${rendered}`, "utf-8");
38374
38374
  }
38375
38375
  return 0;
38376
38376
  }
38377
+ function isWeakCompletionMetadata(metadataEvent) {
38378
+ const evidenceLevel = readNonEmptyString2(metadataEvent.evidenceLevel);
38379
+ if (evidenceLevel === "insufficient" || evidenceLevel === "weak") return true;
38380
+ if (metadataEvent.reviewRecommended === true) return true;
38381
+ const diag = readRecord4(metadataEvent.completionDiagnostic);
38382
+ return diag?.finalAssistantPresent === false || diag?.blockReason === "missing_final_assistant";
38383
+ }
38377
38384
  function formatCompletionMetadata(event) {
38378
38385
  const completionDiagnostic = event.completionDiagnostic && typeof event.completionDiagnostic === "object" ? event.completionDiagnostic : null;
38379
38386
  const diagnosticReason = completionDiagnostic ? readNonEmptyString2(completionDiagnostic.blockReason) || "present" : "";
@@ -38396,17 +38403,19 @@ ${rendered}`, "utf-8");
38396
38403
  return `[System] ${args.nodeLabel} already has completion evidence${metadata}. The no-progress monitor reconciled the terminal handoff and marked the session complete; wait for the queued completion event/status refresh before doing any manual transcript check.`;
38397
38404
  }
38398
38405
  const reviewRecommended = args.metadataEvent.reviewRecommended === true;
38406
+ const weakCompletion = isWeakCompletionMetadata(args.metadataEvent);
38407
+ const verifyTextNote = " Completion evidence is weak \u2014 verify via mesh_read_chat or git status before declaring the task done; the worker may still be parked on an approval/modal.";
38399
38408
  const completionSummary = readMeshCompletionSummary(args.metadataEvent);
38400
38409
  if (completionSummary) {
38401
38410
  const truncationSuffix = "\n\u2026[truncated \u2014 call mesh_read_chat once for the full transcript]";
38402
38411
  const surfaced = completionSummary.length > MESH_COMPLETION_SURFACE_MAX_CHARS ? `${completionSummary.slice(0, MESH_COMPLETION_SURFACE_MAX_CHARS - truncationSuffix.length)}${truncationSuffix}` : completionSummary;
38403
- const verifyNote = reviewRecommended ? " Completion evidence is insufficient \u2014 verify via git status or provider_session_id before assuming the task is done." : "";
38412
+ const verifyNote = reviewRecommended ? " Completion evidence is insufficient \u2014 verify via git status or provider_session_id before assuming the task is done." : weakCompletion ? verifyTextNote : "";
38404
38413
  return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. Its final summary is included below \u2014 read it directly and only call mesh_read_chat if you need the full transcript.${verifyNote}
38405
38414
 
38406
38415
  --- ${args.nodeLabel} final summary ---
38407
38416
  ${surfaced}`;
38408
38417
  }
38409
- const reviewNote = reviewRecommended ? " Completion evidence is insufficient \u2014 verify via git status or provider_session_id before assuming the task is done. Use mesh_read_chat once if needed, but do not poll repeatedly." : " Use mesh_read_chat once to review its final progress, but do not poll repeatedly.";
38418
+ const reviewNote = reviewRecommended ? " Completion evidence is insufficient \u2014 verify via git status or provider_session_id before assuming the task is done. Use mesh_read_chat once if needed, but do not poll repeatedly." : weakCompletion ? `${verifyTextNote} Use mesh_read_chat once if needed, but do not poll repeatedly.` : " Use mesh_read_chat once to review its final progress, but do not poll repeatedly.";
38410
38419
  return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. This completion came from the agent status event path;${reviewNote}`;
38411
38420
  }
38412
38421
  if (args.event === "agent:waiting_approval") {
@@ -38540,7 +38549,7 @@ Next step: ${nextStep}`;
38540
38549
  (pending) => pending.event === event.event && readRefineJobId2(pending) === jobId
38541
38550
  );
38542
38551
  }
38543
- function isWeakCompletionMetadata(metadata) {
38552
+ function isWeakCompletionMetadata2(metadata) {
38544
38553
  const evidenceLevel = readNonEmptyString2(metadata.evidenceLevel);
38545
38554
  if (evidenceLevel === "insufficient" || evidenceLevel === "weak") return true;
38546
38555
  if (metadata.reviewRecommended === true) return true;
@@ -38559,7 +38568,7 @@ Next step: ${nextStep}`;
38559
38568
  event.meshId,
38560
38569
  event.event,
38561
38570
  terminalTaskId,
38562
- isWeakCompletionMetadata(metadata) ? "weak" : "genuine"
38571
+ isWeakCompletionMetadata2(metadata) ? "weak" : "genuine"
38563
38572
  ].join("::");
38564
38573
  }
38565
38574
  }
@@ -42652,9 +42661,22 @@ ${cleanBody}`;
42652
42661
  }
42653
42662
  });
42654
42663
  }
42664
+ function normalizeMeshWorkspaceForCompare(dir) {
42665
+ if (typeof dir !== "string") return "";
42666
+ return dir.trim().replace(/[\\/]+/g, "/").replace(/\/+$/, "").toLowerCase();
42667
+ }
42655
42668
  function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType) {
42656
42669
  const mesh = getMeshWithCache(components, meshId);
42657
42670
  const node = mesh?.nodes.find((n) => readMeshNodeId(n) === nodeId);
42671
+ const localClaimAdapter = components.cliManager?.adapters?.get(sessionId);
42672
+ if (localClaimAdapter) {
42673
+ const sessionWorkspace = normalizeMeshWorkspaceForCompare(localClaimAdapter.workingDir);
42674
+ const nodeWorkspace = normalizeMeshWorkspaceForCompare(readNonEmptyString2(node?.workspace));
42675
+ if (sessionWorkspace && nodeWorkspace && sessionWorkspace !== nodeWorkspace) {
42676
+ LOG2.info("MeshQueue", `WTCLAIM: refusing claim for node ${nodeId} (${sessionId}) \u2014 session workspace "${sessionWorkspace}" \u2260 node workspace "${nodeWorkspace}" (cross-workspace dispatch blocked)`);
42677
+ return false;
42678
+ }
42679
+ }
42658
42680
  const capabilityTags = buildMeshNodeCapabilityTags(node, providerType);
42659
42681
  const providerMaxParallel = resolveProviderMaxParallel(node?.policy, providerType);
42660
42682
  const task = claimNextTask(meshId, nodeId, sessionId, capabilityTags, {
@@ -47174,6 +47196,12 @@ ${cont}` : cont;
47174
47196
  * seq) is always a real, distinct approval and must be written.
47175
47197
  */
47176
47198
  approvalEntrySeq = 0;
47199
+ // Records which approval entry the last resolveModal() handled. Set unconditionally on
47200
+ // every resolveModal (auto-approve fire, dashboard/mesh_approve, dev-cli-debug), so
47201
+ // `lastResolvedEntrySeq >= approvalEntrySeq` is positive, ADHDev-side proof that the
47202
+ // current/latest approval entry was actually resolved. Exposed via getStatus so the
47203
+ // completion finalization gate (FALSEIDLE-a) can require resolution evidence before
47204
+ // confirming a waiting_approval→idle transition. Public (read-only by convention).
47177
47205
  lastResolvedEntrySeq = -1;
47178
47206
  /**
47179
47207
  * When the engine previously held a modal but the latest parse failed
@@ -48890,6 +48918,7 @@ ${lastSnapshot}`;
48890
48918
  workingDir: this.workingDir,
48891
48919
  activeModal: effectiveModal,
48892
48920
  approvalEntrySeq: this.engine.approvalEntrySeq,
48921
+ lastResolvedEntrySeq: this.engine.lastResolvedEntrySeq,
48893
48922
  pendingOutboundCount: this.pendingOutboundQueue.length,
48894
48923
  pendingOutboundMessages: this.pendingOutboundQueue.map((message) => ({
48895
48924
  id: message.id,
@@ -68272,6 +68301,8 @@ ${body}
68272
68301
  };
68273
68302
  }
68274
68303
  }
68304
+ const approvalResolutionBlock = this.approvalResolutionFinalizationBlock(pending);
68305
+ if (approvalResolutionBlock) return approvalResolutionBlock;
68275
68306
  try {
68276
68307
  const screenText = typeof this.adapter.getScreenText === "function" ? String(this.adapter.getScreenText() || "") : "";
68277
68308
  if (screenText) {
@@ -68284,6 +68315,44 @@ ${body}
68284
68315
  }
68285
68316
  return null;
68286
68317
  }
68318
+ // (FALSEIDLE-a) Positive, structural proof that the latest approval entry was resolved
68319
+ // through ADHDev. resolveModal() — driven by auto-approve, dashboard/mesh_approve, and
68320
+ // dev-cli-debug alike — advances the engine's lastResolvedEntrySeq to the current
68321
+ // approvalEntrySeq. So `lastResolvedEntrySeq >= approvalEntrySeq` (with a real entry,
68322
+ // approvalEntrySeq > 0) means the modal we last saw was actually answered. Absence of this
68323
+ // evidence after a waiting_approval→idle transition means the idle is suspect: the spec's
68324
+ // text-based approval→idle rule false-tripped while the modal is still unresolved.
68325
+ // Fails OPEN (returns true) when the seq fields are unavailable, so the gate can never wedge
68326
+ // a session on a provider/adapter that does not surface the counters.
68327
+ hasApprovalResolutionEvidence() {
68328
+ try {
68329
+ const status = this.adapter.getStatus({ allowParse: false });
68330
+ const entrySeq = typeof status?.approvalEntrySeq === "number" ? status.approvalEntrySeq : 0;
68331
+ if (entrySeq <= 0) return true;
68332
+ const resolvedSeq = typeof status?.lastResolvedEntrySeq === "number" ? status.lastResolvedEntrySeq : void 0;
68333
+ if (resolvedSeq === void 0) return true;
68334
+ return resolvedSeq >= entrySeq;
68335
+ } catch {
68336
+ return true;
68337
+ }
68338
+ }
68339
+ // (FALSEIDLE-a) Hold a completion that is the anomalous DIRECT waiting_approval→idle
68340
+ // transition with no positive resolution evidence. A genuinely resolved approval routes
68341
+ // through resolveModal → setStatus('generating'), so its completion's previousStatus is
68342
+ // 'generating' (not 'waiting_approval') and this gate never fires for it. Scoped to
68343
+ // delegated mesh/coordinator sessions — whose only modal-resolution path is auto-approve /
68344
+ // mesh_approve (both advance lastResolvedEntrySeq) — so an interactive local session, where
68345
+ // a human may answer the PTY prompt directly and leave no resolveModal record, is untouched.
68346
+ // Non-terminal: the hold is bounded by COMPLETED_FINALIZATION_MAX_WAIT_MS (30s), giving a
68347
+ // settling auto-approve time to fire and advance the seq, and guaranteeing no permanent wedge
68348
+ // if resolution ever happens via a path that does not record evidence.
68349
+ approvalResolutionFinalizationBlock(pending) {
68350
+ if (pending.previousStatus !== "waiting_approval") return null;
68351
+ const meshContext = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
68352
+ if (!meshContext) return null;
68353
+ if (this.hasApprovalResolutionEvidence()) return null;
68354
+ return { reason: "approval_resolution_unconfirmed", terminal: false };
68355
+ }
68287
68356
  scheduleCompletedDebounceFlush(delayMs) {
68288
68357
  if (this.completedDebounceTimer) clearTimeout(this.completedDebounceTimer);
68289
68358
  this.completedDebounceTimer = setTimeout(() => this.flushCompletedDebounceIfFinalized(), delayMs);