@adhdev/daemon-standalone 0.9.82-rc.566 → 0.9.82-rc.567

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
@@ -30217,10 +30217,10 @@ var require_dist3 = __commonJS({
30217
30217
  }
30218
30218
  function getDaemonBuildInfo() {
30219
30219
  if (cached2) return cached2;
30220
- const commit = readInjected(true ? "d0d245e6363e5bdeee369f7e28132ff8ca989184" : void 0) ?? "unknown";
30221
- const commitShort = readInjected(true ? "d0d245e6" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30222
- const version2 = readInjected(true ? "0.9.82-rc.566" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30223
- const builtAt = readInjected(true ? "2026-07-18T07:11:26.746Z" : void 0);
30220
+ const commit = readInjected(true ? "86f8d403efe203d7ff1d9b6997ede5f30620a485" : void 0) ?? "unknown";
30221
+ const commitShort = readInjected(true ? "86f8d403" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30222
+ const version2 = readInjected(true ? "0.9.82-rc.567" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30223
+ const builtAt = readInjected(true ? "2026-07-18T09:04:52.949Z" : void 0);
30224
30224
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30225
30225
  return cached2;
30226
30226
  }
@@ -44898,12 +44898,16 @@ ${rendered}`, "utf-8");
44898
44898
  for (const task of opts.queue || []) {
44899
44899
  if (task.status !== "pending" && task.status !== "assigned") continue;
44900
44900
  const { title, summary: summary2 } = summarizeMessage(task.message || "");
44901
+ const queueNodeId = task.assignedNodeId || task.targetNodeId;
44902
+ const queueSessionId = task.assignedSessionId || task.targetSessionId;
44903
+ const queueLive = task.status === "assigned" ? sessionStatusFromNodes(opts.nodes, queueNodeId ?? void 0, queueSessionId ?? void 0) : {};
44904
+ const queueStatus = queueLive.status === "awaiting_approval" || queueLive.status === "generating" ? queueLive.status : task.status;
44901
44905
  records.push({
44902
44906
  taskId: task.id,
44903
44907
  source: "queue",
44904
- status: task.status,
44905
- nodeId: task.assignedNodeId || task.targetNodeId,
44906
- sessionId: task.assignedSessionId || task.targetSessionId,
44908
+ status: queueStatus,
44909
+ nodeId: queueNodeId,
44910
+ sessionId: queueSessionId,
44907
44911
  taskTitle: title,
44908
44912
  taskSummary: summary2,
44909
44913
  message: task.message,
@@ -50511,12 +50515,15 @@ ${cleanBody}`;
50511
50515
  }
50512
50516
  return null;
50513
50517
  }
50514
- function sourceWorkerAutoApproves(components, sessionId) {
50518
+ function shouldSuppressAutoApprovingWorkerApproval(components, sessionId) {
50515
50519
  if (!sessionId) return false;
50516
50520
  try {
50517
- const state = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
50521
+ const instance = components.instanceManager?.getInstance?.(sessionId);
50522
+ const state = instance?.getState?.();
50518
50523
  const settings = state?.settings || {};
50519
- return settings.autoApprove === true;
50524
+ if (settings.autoApprove !== true) return false;
50525
+ const resolvedLocally = instance?.approvalRecentlyResolvedLocally;
50526
+ return typeof resolvedLocally === "function" ? resolvedLocally.call(instance) === true : false;
50520
50527
  } catch {
50521
50528
  return false;
50522
50529
  }
@@ -50661,8 +50668,8 @@ ${cleanBody}`;
50661
50668
  }
50662
50669
  }
50663
50670
  const eventTimestamp = readEventTimestamp(args.metadataEvent.timestamp);
50664
- if (args.event === "agent:waiting_approval" && sourceWorkerAutoApproves(components, eventSessionId)) {
50665
- LOG2.info("MeshEvents", `Suppressed agent:waiting_approval for auto-approving worker session ${eventSessionId || "(unknown)"} (mesh ${args.meshId}) \u2014 modal is resolved locally, coordinator not notified`);
50671
+ if (args.event === "agent:waiting_approval" && shouldSuppressAutoApprovingWorkerApproval(components, eventSessionId)) {
50672
+ LOG2.info("MeshEvents", `Suppressed agent:waiting_approval for auto-approving worker session ${eventSessionId || "(unknown)"} (mesh ${args.meshId}) \u2014 modal resolved locally within cooldown, coordinator not notified`);
50666
50673
  traceMeshEventDrop("waiting_approval_auto_approving_worker", traceCtx);
50667
50674
  return { success: true, forwarded: 0, suppressed: true, autoApprovingWorkerApproval: true };
50668
50675
  }
@@ -52356,6 +52363,14 @@ ${cleanBody}`;
52356
52363
  }
52357
52364
  return delivered;
52358
52365
  }
52366
+ function assignedRowLiveStatusIsAwaitingApproval(mesh, nodeId, sessionId) {
52367
+ if (!nodeId || !sessionId) return false;
52368
+ try {
52369
+ return sessionStatusFromNodes(mesh.nodes, nodeId, sessionId).status === "awaiting_approval";
52370
+ } catch {
52371
+ return false;
52372
+ }
52373
+ }
52359
52374
  async function recoverStrandedAssignedDispatches(components, mesh, store) {
52360
52375
  const meshId = mesh.id;
52361
52376
  const assigned = getQueue(meshId, { status: ["assigned"] });
@@ -52387,6 +52402,15 @@ ${cleanBody}`;
52387
52402
  } else {
52388
52403
  if (verdict === "IDLE_CONFIRMED") {
52389
52404
  deliveredUnconsumedUnknownStreak.delete(shortStreakKey);
52405
+ } else if (assignedRowLiveStatusIsAwaitingApproval(mesh, row.assignedNodeId, row.assignedSessionId)) {
52406
+ traceMeshEventDrop("short_redrive_deferred_awaiting_approval", {
52407
+ taskId: row.id,
52408
+ sessionId: row.assignedSessionId,
52409
+ nodeId: row.assignedNodeId,
52410
+ meshId,
52411
+ event: "agent:waiting_approval"
52412
+ }, "live_awaiting_approval");
52413
+ continue;
52390
52414
  } else {
52391
52415
  const streak = (deliveredUnconsumedUnknownStreak.get(shortStreakKey) ?? 0) + 1;
52392
52416
  deliveredUnconsumedUnknownStreak.set(shortStreakKey, streak);
@@ -52449,6 +52473,15 @@ ${cleanBody}`;
52449
52473
  if (verdict === "IDLE_CONFIRMED") {
52450
52474
  deliveredNoTurnUnknownStreak.delete(streakKey);
52451
52475
  reclaimReason = "delivered_no_turn_deadline";
52476
+ } else if (assignedRowLiveStatusIsAwaitingApproval(mesh, row.assignedNodeId, row.assignedSessionId)) {
52477
+ traceMeshEventDrop("reclaim_deferred_awaiting_approval", {
52478
+ taskId: row.id,
52479
+ sessionId: row.assignedSessionId,
52480
+ nodeId: row.assignedNodeId,
52481
+ meshId,
52482
+ event: "agent:waiting_approval"
52483
+ }, "live_awaiting_approval");
52484
+ continue;
52452
52485
  } else {
52453
52486
  const streak = (deliveredNoTurnUnknownStreak.get(streakKey) ?? 0) + 1;
52454
52487
  deliveredNoTurnUnknownStreak.set(streakKey, streak);
@@ -53030,6 +53063,7 @@ ${cleanBody}`;
53030
53063
  init_mesh_reconcile_config();
53031
53064
  init_mesh_remote_event_pull();
53032
53065
  init_mesh_completion_synthesis();
53066
+ init_mesh_active_work();
53033
53067
  init_mesh_reconcile_v2_backstop();
53034
53068
  init_mesh_reconcile_acked_hold();
53035
53069
  coordinatorModalParkState = /* @__PURE__ */ new Map();
@@ -69288,7 +69322,13 @@ ${effect.notification.body || ""}`.trim();
69288
69322
  LOG2.info("Command", `[resolveAction] CLI PTY \u2192 stale_prompt (already resolved within cooldown)`);
69289
69323
  return { success: true, stalePrompt: true, buttonIndex, button: buttons[buttonIndex] ?? button };
69290
69324
  }
69291
- if (typeof adapter.resolveModal === "function") {
69325
+ if (typeof adapter.resolveModalMatched === "function") {
69326
+ const matched = adapter.resolveModalMatched(buttonIndex);
69327
+ if (!matched) {
69328
+ LOG2.warn("Command", `[resolveAction] CLI PTY \u2192 no button matched for buttonIndex=${buttonIndex} "${buttons[buttonIndex] ?? "?"}" (modal not resolved)`);
69329
+ return { success: false, error: "Approval button index did not map to a visible modal button", buttonIndex, button: buttons[buttonIndex] ?? button };
69330
+ }
69331
+ } else if (typeof adapter.resolveModal === "function") {
69292
69332
  adapter.resolveModal(buttonIndex);
69293
69333
  } else {
69294
69334
  const keys = "\x1B[B".repeat(Math.max(0, buttonIndex)) + "\r";
@@ -73817,7 +73857,7 @@ ${body}
73817
73857
  this.handleClickControl(cmd.control_id, cmd.payload);
73818
73858
  return;
73819
73859
  case "click_modal_button":
73820
- this.handleClickModalButton(cmd.index);
73860
+ this.clickModalButton(cmd.index);
73821
73861
  return;
73822
73862
  case "attach_image":
73823
73863
  this.handleAttachImage(cmd.blob, cmd.mime);
@@ -74560,11 +74600,24 @@ ${body}
74560
74600
  }
74561
74601
  }
74562
74602
  }
74603
+ /**
74604
+ * BUTTON-INDEX-MISMAP (Fix C.3): public modal-click entry that returns whether a button
74605
+ * matching the requested FSM display index was actually found and its confirm keys were
74606
+ * dispatched. The old private handleClickModalButton silently `return`ed on a miss (no
74607
+ * modal captured, or no button whose `.index` equals the requested display index), so a
74608
+ * mis-mapped index looked identical to a successful press. Callers that need to know
74609
+ * whether the click landed (mesh_approve → resolveModal) can now observe the miss instead
74610
+ * of reporting success into the void. The generic `dispatch('click_modal_button')` path
74611
+ * keeps ignoring the return (fire-and-forget UI clicks).
74612
+ */
74613
+ clickModalButton(index) {
74614
+ return this.handleClickModalButton(index);
74615
+ }
74563
74616
  handleClickModalButton(index) {
74564
74617
  const m = this.currentEval?.modal;
74565
- if (!m) return;
74618
+ if (!m) return false;
74566
74619
  const btn = m.buttons.find((b) => b.index === index);
74567
- if (!btn) return;
74620
+ if (!btn) return false;
74568
74621
  const rule = stateById(this.spec, this.currentStateId)?.extract?.buttons;
74569
74622
  if (rule?.select_mode === "arrow_keys") {
74570
74623
  const from = m.buttons.find((b) => b.current)?.index ?? 1;
@@ -74576,9 +74629,10 @@ ${body}
74576
74629
  const confirm = (rule.key_for_index || "\r").replace(/\{index\}/g, "") || "\r";
74577
74630
  if (nav) this.adapter.send_keys(nav);
74578
74631
  this.submitModalConfirm(confirm);
74579
- return;
74632
+ return true;
74580
74633
  }
74581
74634
  this.submitModalConfirm(btn.key);
74635
+ return true;
74582
74636
  }
74583
74637
  /**
74584
74638
  * Submit a modal-confirm key sequence (the choice key + its trailing CR).
@@ -75998,7 +76052,20 @@ ${body}
75998
76052
  // modal this frame still stays waiting_approval (no activeModal yet).
75999
76053
  // `kind` carries the semantic modal class through to the auto-approve
76000
76054
  // gate so a /model picker (kind='picker') is never auto-answered.
76001
- activeModal: modal ? { message: modal.title ?? state.label, buttons: modal.buttons.map((b) => b.label), kind: modal.kind ?? null } : null,
76055
+ // BUTTON-INDEX-MISMAP (Fix C.1): keep `buttons` as the label list every
76056
+ // existing consumer (pickApprovalButton, mesh_approve, auto-approve) reads,
76057
+ // but ALSO surface `buttonMeta` carrying each button's real FSM display index
76058
+ // alongside its label. A partial/non-contiguous modal (display indices [1,3,4]
76059
+ // at array positions [0,1,2]) then no longer loses the index → label mapping
76060
+ // once it leaves the adapter: a consumer that has an array position can recover
76061
+ // the true FSM index without re-parsing. resolveModal() below relies on the same
76062
+ // ordered list to translate an array position to the correct FSM index.
76063
+ activeModal: modal ? {
76064
+ message: modal.title ?? state.label,
76065
+ buttons: modal.buttons.map((b) => b.label),
76066
+ buttonMeta: modal.buttons.map((b) => ({ index: b.index, label: b.label })),
76067
+ kind: modal.kind ?? null
76068
+ } : null,
76002
76069
  activeInteractivePrompt: this.activeInteractivePrompt,
76003
76070
  ...sessionFields
76004
76071
  };
@@ -76170,7 +76237,12 @@ ${body}
76170
76237
  this.driver.dispatch({ kind: "resize", cols, rows });
76171
76238
  }
76172
76239
  resolveModal(buttonIndex) {
76173
- this.driver.dispatch({ kind: "click_modal_button", index: buttonIndex + 1 });
76240
+ this.resolveModalMatched(buttonIndex);
76241
+ }
76242
+ resolveModalMatched(buttonIndex) {
76243
+ const buttons = this.latestModal?.buttons ?? [];
76244
+ const target = buttonIndex >= 0 && buttonIndex < buttons.length ? buttons[buttonIndex].index : buttonIndex + 1;
76245
+ return this.driver.clickModalButton(target);
76174
76246
  }
76175
76247
  async resolveAction(data) {
76176
76248
  const args = data && typeof data === "object" ? data : {};
@@ -77306,6 +77378,15 @@ ${body}
77306
77378
  * keystroke until the modal *content* has settled.
77307
77379
  */
77308
77380
  static AUTO_APPROVE_SETTLE_MS = 600;
77381
+ /**
77382
+ * APPROVAL-INBOX-BLINDSPOT (Fix A): how long after a LOCAL auto-approve fire the mesh
77383
+ * event forwarder still treats the modal as "being resolved locally" and suppresses the
77384
+ * coordinator notification. Chosen to comfortably cover the resolveModal → PTY absorb →
77385
+ * status-leaves-approval round trip (incl. the win32 CR-resend loop) while staying short
77386
+ * enough that a modal which auto-approve fired at but did NOT resolve re-surfaces to the
77387
+ * coordinator on the next event. Aligned with the adapter's own approval cooldown scale.
77388
+ */
77389
+ static APPROVAL_LOCAL_RESOLUTION_COOLDOWN_MS = 8e3;
77309
77390
  /**
77310
77391
  * Busy-side hysteresis for the settle gate. A momentary `generating` flip
77311
77392
  * while the SAME approval modal's button block is still on screen (its
@@ -77578,6 +77659,16 @@ ${body}
77578
77659
  // signature) while a genuinely closed modal — buttons empty continuously past
77579
77660
  // the continuity window — is still recognised and resets the gate.
77580
77661
  autoApproveLastModalSeenAt = 0;
77662
+ // APPROVAL-INBOX-BLINDSPOT (Fix A): wall-clock of the last time this session actually
77663
+ // FIRED a local auto-approve resolveModal (the settle gate passed → resolveModal
77664
+ // dispatched). The mesh event forwarder keys its agent:waiting_approval suppression on
77665
+ // this + a cooldown so it only drops the coordinator notification when we can positively
77666
+ // confirm the modal was (or is being) resolved LOCALLY. If auto-approve is merely
77667
+ // *configured* on but has NOT recently fired for this modal, the raw waiting_approval is
77668
+ // forwarded so a task_approval_needed ledger row is created and the coordinator/inbox is
77669
+ // told — closing the blind spot where a never-resolving worker approval was silently
77670
+ // dropped just because settings.autoApprove===true.
77671
+ lastAutoApproveFiredAt = 0;
77581
77672
  // AUTOAPPROVE-FLAP-INBOX-MISSING sticky-approval overlay (see APPROVAL_STICKY_FLAP_MS).
77582
77673
  // The wall-clock of the last frame where the RAW adapter reported waiting_approval with
77583
77674
  // a CONCRETE modal (buttons present), the cached modal to re-present across a busy blip,
@@ -78063,6 +78154,33 @@ ${body}
78063
78154
  }
78064
78155
  return null;
78065
78156
  }
78157
+ /**
78158
+ * APPROVAL-INBOX-BLINDSPOT (Fix A): true when this session's approval modal was — or is
78159
+ * being — resolved LOCALLY within the recent cooldown. Two independent positive signals:
78160
+ * (1) auto-approve fired its resolveModal within APPROVAL_LOCAL_RESOLUTION_COOLDOWN_MS
78161
+ * (lastAutoApproveFiredAt), or
78162
+ * (2) the underlying adapter reports isApprovalRecentlyResolved() — its own resolve
78163
+ * cooldown, which also covers a dashboard / mesh_approve resolution.
78164
+ * The mesh event forwarder uses this to decide whether an agent:waiting_approval from an
78165
+ * auto-approving worker can be safely SUPPRESSED (a local resolution is in flight) or must
78166
+ * be FORWARDED (auto-approve is configured but has NOT actually resolved this modal, so the
78167
+ * coordinator/inbox must be told). Keying suppression on real resolution — not just the
78168
+ * autoApprove *intent* — is the blind-spot fix: a never-resolving worker approval is no
78169
+ * longer silently dropped.
78170
+ */
78171
+ approvalRecentlyResolvedLocally(now = Date.now()) {
78172
+ if (this.lastAutoApproveFiredAt && now - this.lastAutoApproveFiredAt < _CliProviderInstance.APPROVAL_LOCAL_RESOLUTION_COOLDOWN_MS) {
78173
+ return true;
78174
+ }
78175
+ try {
78176
+ const adapter = this.adapter;
78177
+ if (typeof adapter.isApprovalRecentlyResolved === "function") {
78178
+ return adapter.isApprovalRecentlyResolved() === true;
78179
+ }
78180
+ } catch {
78181
+ }
78182
+ return false;
78183
+ }
78066
78184
  /**
78067
78185
  * NOTIF-HELD-DRAIN: true when this `waiting_approval` is a routine, transient tool-consent
78068
78186
  * of an autonomously-progressing mesh session rather than a genuine human-await modal —
@@ -79413,8 +79531,18 @@ ${buttons.join("\n")}`;
79413
79531
  this.lastAutoApprovalSignature = "";
79414
79532
  }, 5e3);
79415
79533
  this.recordAutoApproval(modal?.message, buttonLabel, now);
79534
+ this.lastAutoApproveFiredAt = now;
79416
79535
  setTimeout(() => {
79417
- this.adapter.resolveModal(buttonIndex);
79536
+ const adapter = this.adapter;
79537
+ if (typeof adapter.resolveModalMatched === "function") {
79538
+ const matched = adapter.resolveModalMatched(buttonIndex);
79539
+ if (!matched) {
79540
+ if (this.lastAutoApproveFiredAt === now) this.lastAutoApproveFiredAt = 0;
79541
+ LOG2.warn("CLI", `[${this.type}] auto-approve resolveModal matched no button (index ${buttonIndex}) \u2014 surfacing approval to coordinator`);
79542
+ }
79543
+ } else {
79544
+ adapter.resolveModal?.(buttonIndex);
79545
+ }
79418
79546
  }, 0);
79419
79547
  return autoApproveActive;
79420
79548
  }