@adhdev/daemon-core 0.9.82-rc.210 → 0.9.82-rc.212

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
@@ -5560,12 +5560,14 @@ function formatCompletionMetadata(event) {
5560
5560
  const completionDiagnostic = event.completionDiagnostic && typeof event.completionDiagnostic === "object" ? event.completionDiagnostic : null;
5561
5561
  const diagnosticReason = completionDiagnostic ? readNonEmptyString2(completionDiagnostic.blockReason) || "present" : "";
5562
5562
  const finalAssistantPresent = typeof completionDiagnostic?.finalAssistantPresent === "boolean" ? String(completionDiagnostic.finalAssistantPresent) : "";
5563
+ const evidenceLevel = readNonEmptyString2(event.evidenceLevel);
5563
5564
  const parts = [
5564
5565
  readNonEmptyString2(event.targetSessionId) ? `session_id=${readNonEmptyString2(event.targetSessionId)}` : "",
5565
5566
  readNonEmptyString2(event.providerType) ? `provider=${readNonEmptyString2(event.providerType)}` : "",
5566
5567
  readNonEmptyString2(event.providerSessionId) ? `provider_session_id=${readNonEmptyString2(event.providerSessionId)}` : "",
5567
5568
  diagnosticReason ? `completion_diagnostic=${diagnosticReason}` : "",
5568
- finalAssistantPresent ? `final_assistant=${finalAssistantPresent}` : ""
5569
+ finalAssistantPresent ? `final_assistant=${finalAssistantPresent}` : "",
5570
+ evidenceLevel && evidenceLevel !== "sufficient" ? `evidence_level=${evidenceLevel}` : ""
5569
5571
  ].filter(Boolean);
5570
5572
  return parts.length > 0 ? ` (${parts.join("; ")})` : "";
5571
5573
  }
@@ -5575,7 +5577,8 @@ function buildMeshSystemMessage(args) {
5575
5577
  if (args.metadataEvent.source === "long_generating_reconciliation") {
5576
5578
  return `[System] ${args.nodeLabel} already has completion evidence${metadata}. The long-generating monitor reconciled the terminal handoff and marked the session complete; wait for the queued completion event/status refresh before doing any manual transcript check.`;
5577
5579
  }
5578
- return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. This completion came from the agent status event path; use mesh_read_chat once to review its final progress, but do not poll repeatedly.`;
5580
+ const reviewNote = args.metadataEvent.reviewRecommended === true ? " 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.";
5581
+ return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. This completion came from the agent status event path;${reviewNote}`;
5579
5582
  }
5580
5583
  if (args.event === "agent:waiting_approval") {
5581
5584
  return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
@@ -28518,6 +28521,7 @@ var SCHEMA_V3 = {
28518
28521
  "busy_hold_ms": { "type": "integer", "minimum": 0 },
28519
28522
  "idle_hold_ms": { "type": "integer", "minimum": 0 },
28520
28523
  "startup_grace_ms": { "type": "integer", "minimum": 0 },
28524
+ "screen_active_hold_ms": { "type": "integer", "minimum": 0 },
28521
28525
  "completion_marker": {
28522
28526
  "type": "object",
28523
28527
  "additionalProperties": false,
@@ -28860,6 +28864,7 @@ function attachDebounceAlias(spec) {
28860
28864
  ...t.busy_hold_ms !== void 0 ? { busy_hold_ms: t.busy_hold_ms } : {},
28861
28865
  ...t.idle_hold_ms !== void 0 ? { idle_hold_ms: t.idle_hold_ms } : {},
28862
28866
  ...t.startup_grace_ms !== void 0 ? { startup_grace_ms: t.startup_grace_ms } : {},
28867
+ ...t.screen_active_hold_ms !== void 0 ? { screen_active_hold_ms: t.screen_active_hold_ms } : {},
28863
28868
  ...cm ? {
28864
28869
  completion_idle_after: {
28865
28870
  ...cm.section ? { section: cm.section } : {},
@@ -29163,6 +29168,10 @@ var SpecDriver = class {
29163
29168
  completionIdleKey = "";
29164
29169
  /** Previous screen lines — passed to evaluate() for `changed` condition detection. */
29165
29170
  prevScreenLines = [];
29171
+ /** Timestamp of the last PTY frame that changed the screen content.
29172
+ * Used by screen_active_hold_ms to suppress idle downshifts while
29173
+ * the terminal is still actively updating. */
29174
+ lastScreenChangedAt = 0;
29166
29175
  /** Timer that re-runs evaluate() once the hold window expires. Needed
29167
29176
  * because the PTY stops emitting once the agent finishes; without an
29168
29177
  * explicit wake-up there's nothing to trigger the busy → idle
@@ -29241,6 +29250,8 @@ var SpecDriver = class {
29241
29250
  if (this.idleHoldTimer) {
29242
29251
  clearTimeout(this.idleHoldTimer);
29243
29252
  this.idleHoldTimer = null;
29253
+ this.completionIdleKey = "";
29254
+ this.completionIdleFirstSeenAt = 0;
29244
29255
  }
29245
29256
  this.pendingIdleState = null;
29246
29257
  }
@@ -29362,8 +29373,12 @@ var SpecDriver = class {
29362
29373
  reevaluate(forceEmit = false) {
29363
29374
  const screen = this.adapter.snapshot();
29364
29375
  const cursor = this.adapter.getCursorPosition();
29376
+ const currentLines = screen.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
29365
29377
  const ev = evaluate(this.spec, screen, cursor, this.prevScreenLines.length > 0 ? this.prevScreenLines : void 0);
29366
- this.prevScreenLines = screen.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
29378
+ if (this.prevScreenLines.length > 0 && currentLines.join("\n") !== this.prevScreenLines.join("\n")) {
29379
+ this.lastScreenChangedAt = Date.now();
29380
+ }
29381
+ this.prevScreenLines = currentLines;
29367
29382
  let evState = ev.state;
29368
29383
  const busyHoldMs = this.spec.debounce?.busy_hold_ms ?? BUSY_HOLD_MS;
29369
29384
  if (this.currentStateId === "busy" && evState.id === "idle") {
@@ -29381,12 +29396,19 @@ var SpecDriver = class {
29381
29396
  }
29382
29397
  }
29383
29398
  const completionIdleRule = this.spec.debounce?.completion_idle_after;
29399
+ const screenActiveHoldMs = this.spec.debounce?.screen_active_hold_ms;
29384
29400
  let busyWakeMs = busyHoldMs;
29385
29401
  const postModalGraceMs = busyHoldMs;
29386
29402
  const now = Date.now();
29387
29403
  const recentlyInModal = isModalState(this.currentStateId) || this.lastModalAt > 0 && now - this.lastModalAt < postModalGraceMs;
29388
29404
  const recentlyLeftModal = !recentlyInModal && this.lastModalExitAt > 0 && now - this.lastModalExitAt < postModalGraceMs;
29389
- if (evState.id === "busy" && completionIdleRule && !recentlyInModal && !recentlyLeftModal) {
29405
+ const screenActiveMs = screenActiveHoldMs ?? 0;
29406
+ const screenStableMs = this.lastScreenChangedAt > 0 ? now - this.lastScreenChangedAt : Infinity;
29407
+ const screenIsActive = screenActiveMs > 0 && screenStableMs < screenActiveMs;
29408
+ if (screenIsActive) {
29409
+ busyWakeMs = Math.min(busyWakeMs, screenActiveMs - screenStableMs + 50);
29410
+ }
29411
+ if (evState.id === "busy" && completionIdleRule && !recentlyInModal && !recentlyLeftModal && !screenIsActive) {
29390
29412
  const completionKey = matchesCompletionIdleRule(this.spec, ev, screen);
29391
29413
  if (completionKey) {
29392
29414
  const now2 = Date.now();
@@ -29416,8 +29438,13 @@ var SpecDriver = class {
29416
29438
  this.completionIdleFirstSeenAt = 0;
29417
29439
  }
29418
29440
  } else if (evState.id !== "busy") {
29419
- this.completionIdleKey = "";
29420
- this.completionIdleFirstSeenAt = 0;
29441
+ if (!screenIsActive) {
29442
+ this.completionIdleKey = "";
29443
+ this.completionIdleFirstSeenAt = 0;
29444
+ }
29445
+ }
29446
+ if (screenIsActive && this.currentStateId === "busy" && evState.id === (this.spec.default_state ?? "idle")) {
29447
+ evState = this.lastBusyState ?? evState;
29421
29448
  }
29422
29449
  if (evState.id === "busy") {
29423
29450
  this.lastBusyAt = Date.now();
@@ -32124,7 +32151,7 @@ var CliProviderInstance = class {
32124
32151
  message: typeof modal?.message === "string" ? modal.message.trim() : "",
32125
32152
  buttons: Array.isArray(modal?.buttons) ? modal.buttons.map((button) => String(button).trim()) : []
32126
32153
  });
32127
- if (this.lastStatus !== "waiting_approval" && approvalFingerprint !== this.lastApprovalEventFingerprint) {
32154
+ if (approvalFingerprint !== this.lastApprovalEventFingerprint) {
32128
32155
  this.lastApprovalEventFingerprint = approvalFingerprint;
32129
32156
  this.appendRuntimeSystemMessage(
32130
32157
  this.formatApprovalRequestMessage(modal?.message, modal?.buttons),