@adhdev/daemon-standalone 0.9.82-rc.213 → 0.9.82-rc.215

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
@@ -40166,7 +40166,25 @@ ${cont}` : cont;
40166
40166
  "CLI",
40167
40167
  `[${this.provider.type}] settled diagnostics prompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 140)} status=${String(status || "")} parsedStatus=${String(parsedStatus || "")} parsedMsgCount=${parsedMessages.length} lastParsedAssistant=${JSON.stringify((lastParsedAssistant?.content || "").slice(0, 120)).slice(0, 160)} responseBuffer=${JSON.stringify((snap.responseBuffer || "").slice(0, 160)).slice(0, 220)} recentActivity=${recentInteractiveActivity}`
40168
40168
  );
40169
- const shouldHoldGenerating = status === "idle" && this.isWaitingForResponse && !!this.currentTurnScope && !modal && !(parsedStatus === "idle" && !!lastParsedAssistant);
40169
+ const hasFinalCurrentTurnAssistant = (() => {
40170
+ if (parsedStatus !== "idle") return false;
40171
+ const msgs = Array.isArray(parsedMessages) ? parsedMessages : [];
40172
+ let lastUserIdx = -1;
40173
+ for (let i = msgs.length - 1; i >= 0; i--) {
40174
+ if (msgs[i]?.role === "user") {
40175
+ lastUserIdx = i;
40176
+ break;
40177
+ }
40178
+ }
40179
+ const searchSlice = lastUserIdx >= 0 ? msgs.slice(lastUserIdx + 1) : msgs;
40180
+ return searchSlice.some((m) => {
40181
+ if (!m || m.role !== "assistant") return false;
40182
+ if (typeof m.content !== "string" || !m.content.trim()) return false;
40183
+ const kind = typeof m.kind === "string" && m.kind.trim() ? m.kind.trim() : "standard";
40184
+ return kind === "standard" && m.meta?.streaming !== true;
40185
+ });
40186
+ })();
40187
+ const shouldHoldGenerating = status === "idle" && this.isWaitingForResponse && !!this.currentTurnScope && !modal && !hasFinalCurrentTurnAssistant;
40170
40188
  if (shouldHoldGenerating) {
40171
40189
  this.applyHoldGenerating(ctx);
40172
40190
  return;
@@ -58829,6 +58847,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
58829
58847
  completionIdleKey = "";
58830
58848
  /** Previous screen lines — passed to evaluate() for `changed` condition detection. */
58831
58849
  prevScreenLines = [];
58850
+ /** Timestamp when idle was last committed (either direct or via idle_hold_ms).
58851
+ * Used to suppress immediate idle → busy re-entry from transient `changed`
58852
+ * condition blips (e.g. completion-marker counter "Completed for Xs" updating
58853
+ * every second, which triggers cursor_above:changed and bounces back to busy
58854
+ * right after an idle commit). */
58855
+ lastIdleCommittedAt = 0;
58832
58856
  /** Timestamp of the last PTY frame that changed the screen content.
58833
58857
  * Used by screen_active_hold_ms to suppress idle downshifts while
58834
58858
  * the terminal is still actively updating. */
@@ -58883,6 +58907,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
58883
58907
  this.adapter.resize(cmd.cols, cmd.rows);
58884
58908
  return;
58885
58909
  case "cancel":
58910
+ this.lastIdleCommittedAt = 0;
58886
58911
  this.adapter.send_keys("");
58887
58912
  return;
58888
58913
  case "shutdown":
@@ -59107,6 +59132,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
59107
59132
  if (screenIsActive && this.currentStateId === "busy" && evState.id === (this.spec.default_state ?? "idle")) {
59108
59133
  evState = this.lastBusyState ?? evState;
59109
59134
  }
59135
+ const idleReentryHoldMs = Math.max(screenActiveMs, 1500);
59136
+ if (evState.id === "busy" && this.currentStateId === (this.spec.default_state ?? "idle") && this.lastIdleCommittedAt > 0 && now - this.lastIdleCommittedAt < idleReentryHoldMs) {
59137
+ LOG2.debug("SpecDriver", `[${this.opts.specPath.split("/").slice(-3).join("/")}] idle\u2192busy suppressed (idle_reentry_hold ageMs=${now - this.lastIdleCommittedAt} holdMs=${idleReentryHoldMs})`);
59138
+ this.scheduleBusyExpiry(idleReentryHoldMs - (now - this.lastIdleCommittedAt) + 50);
59139
+ return;
59140
+ }
59110
59141
  if (evState.id === "busy") {
59111
59142
  this.lastBusyAt = Date.now();
59112
59143
  this.lastBusyState = evState;
@@ -59142,6 +59173,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
59142
59173
  this.pendingIdleState = null;
59143
59174
  if (!committed) return;
59144
59175
  LOG2.debug("SpecDriver", `[${this.opts.specPath.split("/").slice(-3).join("/")}] idleHold committed after ${idleHoldMs}ms`);
59176
+ this.lastIdleCommittedAt = Date.now();
59145
59177
  this.currentStateId = committed.id;
59146
59178
  this.currentEval = capturedEv;
59147
59179
  this.pushHistory(committed.id, committed.label, {
@@ -59184,6 +59216,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
59184
59216
  }
59185
59217
  }
59186
59218
  if (changed) {
59219
+ if (evState.id === (this.spec.default_state ?? "idle")) {
59220
+ this.lastIdleCommittedAt = Date.now();
59221
+ }
59187
59222
  this.currentStateId = evState.id;
59188
59223
  const matchedRules = extractMatchedRules(ev);
59189
59224
  let transitionReason;
@@ -59251,6 +59286,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
59251
59286
  this.pendingSends.push(text);
59252
59287
  return;
59253
59288
  }
59289
+ this.lastIdleCommittedAt = 0;
59254
59290
  this.actuallySendMessage(text);
59255
59291
  }
59256
59292
  actuallySendMessage(text) {
@@ -65362,6 +65398,35 @@ Run 'adhdev doctor' for detailed diagnostics.`
65362
65398
  }
65363
65399
  return "";
65364
65400
  }
65401
+ function hasAssistantStandardMessageSinceLastUser(records, content) {
65402
+ const normalized = content.trim();
65403
+ if (!normalized) return false;
65404
+ for (let i = records.length - 1; i >= 0; i--) {
65405
+ const record2 = records[i];
65406
+ if (record2.kind === "session_start") continue;
65407
+ if (record2.role === "user") return false;
65408
+ if (record2.role === "assistant" && record2.kind === "standard" && record2.content.trim() === normalized) {
65409
+ return true;
65410
+ }
65411
+ }
65412
+ return false;
65413
+ }
65414
+ function pushAssistantStandardMessage(records, sessionId, receivedAt, content, workspace) {
65415
+ const text = content.trim();
65416
+ if (!text) return;
65417
+ if (hasAssistantStandardMessageSinceLastUser(records, text)) return;
65418
+ const msg = {
65419
+ ts: new Date(receivedAt).toISOString(),
65420
+ receivedAt,
65421
+ role: "assistant",
65422
+ content: text,
65423
+ kind: "standard",
65424
+ agent: "codex-cli",
65425
+ historySessionId: sessionId
65426
+ };
65427
+ if (workspace) msg.workspace = workspace;
65428
+ records.push(msg);
65429
+ }
65365
65430
  function readSessionMeta(filePath) {
65366
65431
  try {
65367
65432
  const firstLine = fs15.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
@@ -65417,13 +65482,34 @@ Run 'adhdev doctor' for detailed diagnostics.`
65417
65482
  }
65418
65483
  continue;
65419
65484
  }
65420
- if (type !== "response_item") continue;
65421
65485
  const payloadType = String(payload.type ?? "").trim();
65486
+ if (type === "event_msg") {
65487
+ if (payloadType === "task_complete") {
65488
+ pushAssistantStandardMessage(
65489
+ records,
65490
+ sessionId,
65491
+ receivedAt,
65492
+ flattenCodexContent(payload.last_agent_message),
65493
+ detectedWorkspace
65494
+ );
65495
+ } else if (payloadType === "agent_message" && String(payload.phase ?? "").trim() === "final_answer") {
65496
+ pushAssistantStandardMessage(
65497
+ records,
65498
+ sessionId,
65499
+ receivedAt,
65500
+ flattenCodexContent(payload.message),
65501
+ detectedWorkspace
65502
+ );
65503
+ }
65504
+ continue;
65505
+ }
65506
+ if (type !== "response_item") continue;
65422
65507
  if (payloadType === "message") {
65423
65508
  const role = String(payload.role ?? "").trim();
65424
65509
  if (role !== "user" && role !== "assistant") continue;
65425
65510
  const content = flattenCodexContent(payload.content);
65426
65511
  if (!content) continue;
65512
+ if (role === "assistant" && hasAssistantStandardMessageSinceLastUser(records, content)) continue;
65427
65513
  const msg = {
65428
65514
  ts: new Date(receivedAt).toISOString(),
65429
65515
  receivedAt,
@@ -69328,6 +69414,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69328
69414
  }
69329
69415
  }
69330
69416
  init_mesh_work_queue();
69417
+ init_repo_mesh_types();
69331
69418
  var import_os3 = require("os");
69332
69419
  var import_path10 = require("path");
69333
69420
  var fs222 = __toESM2(require("fs"));
@@ -71887,7 +71974,8 @@ ${e?.stderr || ""}`
71887
71974
  ...result ? {
71888
71975
  success: result.success === true,
71889
71976
  result,
71890
- finalBranchConvergenceState: result.finalBranchConvergenceState
71977
+ finalBranchConvergenceState: result.finalBranchConvergenceState,
71978
+ ...result.blockerContext ? { blockerContext: result.blockerContext } : {}
71891
71979
  } : {}
71892
71980
  }
71893
71981
  });
@@ -72417,6 +72505,27 @@ ${e?.stderr || ""}`
72417
72505
  finalBranchConvergenceState
72418
72506
  };
72419
72507
  }
72508
+ const requireApprovalForPush = mesh?.policy?.requireApprovalForPush ?? DEFAULT_MESH_POLICY.requireApprovalForPush;
72509
+ let pushResult;
72510
+ if (!requireApprovalForPush) {
72511
+ const pushStarted = Date.now();
72512
+ try {
72513
+ await execFileAsync3("git", ["push", "origin", baseBranch], { cwd: repoRoot, encoding: "utf8" });
72514
+ pushResult = { pushed: true, remote: "origin", branch: baseBranch, durationMs: Date.now() - pushStarted };
72515
+ recordMeshRefineStage(refineStages, "push", "passed", pushStarted, pushResult);
72516
+ finalBranchConvergenceState.status = "merged_pushed";
72517
+ } catch (e) {
72518
+ pushResult = {
72519
+ pushed: false,
72520
+ remote: "origin",
72521
+ branch: baseBranch,
72522
+ error: e?.message || String(e),
72523
+ stderr: e?.stderr,
72524
+ durationMs: Date.now() - pushStarted
72525
+ };
72526
+ recordMeshRefineStage(refineStages, "push", "failed", pushStarted, pushResult);
72527
+ }
72528
+ }
72420
72529
  return {
72421
72530
  success: true,
72422
72531
  merged: true,
@@ -72430,7 +72539,13 @@ ${e?.stderr || ""}`
72430
72539
  mergeResult,
72431
72540
  refineStages,
72432
72541
  ...ledgerError ? { ledgerError } : {},
72433
- finalBranchConvergenceState
72542
+ finalBranchConvergenceState,
72543
+ // Push outcome or readiness info for coordinator.
72544
+ ...pushResult ? { pushResult } : {
72545
+ pushReady: true,
72546
+ pushCommand: `git push origin ${baseBranch}`,
72547
+ pushNote: "requireApprovalForPush is enabled \u2014 run the push command or obtain user approval before pushing."
72548
+ }
72434
72549
  };
72435
72550
  } catch (e) {
72436
72551
  return { success: false, error: e.message, refineStages };
@@ -72448,9 +72563,46 @@ ${e?.stderr || ""}`
72448
72563
  const refineCode = typeof result.code === "string" ? result.code : "";
72449
72564
  const refineTerminalKind = result.success === true ? "completed" : refineCode === "blocked_review" ? "blocked_review" : refineCode === "validation_failed" || refineCode === "validation_dependencies_missing" ? "validation_failed" : refineCode === "submodule_reachability_failed" ? "submodule_reachability_failed" : refineCode === "merge_failed" || refineCode === "patch_equivalence_failed" || refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "merge_failed" : refineCode === "cleanup_failed" ? "cleanup_failed" : "merge_failed";
72450
72565
  const isTerminalSuccess = refineTerminalKind === "completed";
72566
+ const blockerContext = isTerminalSuccess ? void 0 : (() => {
72567
+ const code = typeof result.code === "string" ? result.code : refineTerminalKind;
72568
+ const stage = refineTerminalKind === "validation_failed" ? "validation" : refineTerminalKind === "submodule_reachability_failed" ? "submodule_reachability" : refineCode === "patch_equivalence_failed" ? "patch_equivalence" : refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "patch_equivalence" : refineTerminalKind === "merge_failed" ? "merge" : refineTerminalKind === "cleanup_failed" ? "cleanup" : "unknown";
72569
+ const ctx = {
72570
+ stage,
72571
+ reason: code,
72572
+ terminalKind: refineTerminalKind
72573
+ };
72574
+ if (typeof result.error === "string") ctx.error = result.error;
72575
+ if (typeof result.blockedReason === "string") ctx.blockedReason = result.blockedReason;
72576
+ if (stage === "patch_equivalence" && result.patchEquivalence) {
72577
+ const pe = result.patchEquivalence;
72578
+ ctx.details = {
72579
+ expectedPatchId: pe.expectedPatchId,
72580
+ actualPatchId: pe.actualPatchId,
72581
+ status: pe.status,
72582
+ actionableHint: pe.actionableHint,
72583
+ error: pe.error
72584
+ };
72585
+ }
72586
+ if (stage === "submodule_reachability" && Array.isArray(result.unreachableSubmoduleCommits)) {
72587
+ ctx.details = {
72588
+ unreachableCount: result.unreachableSubmoduleCommits.length,
72589
+ paths: result.unreachableSubmoduleCommits.map((e) => e.path),
72590
+ autoPublishAllowed: result.unreachableSubmoduleCommits[0]?.autoPublishAllowed
72591
+ };
72592
+ }
72593
+ if (stage === "validation" && result.validationSummary) {
72594
+ const vs = result.validationSummary;
72595
+ ctx.details = {
72596
+ failureCode: vs.failureCode,
72597
+ commandsRun: Array.isArray(vs.commandsRun) ? vs.commandsRun.length : void 0
72598
+ };
72599
+ }
72600
+ return ctx;
72601
+ })();
72451
72602
  const normalizedResult = {
72452
72603
  ...result,
72453
72604
  terminalKind: refineTerminalKind,
72605
+ ...blockerContext ? { blockerContext } : {},
72454
72606
  ...result.nextStep === void 0 && !isTerminalSuccess ? {
72455
72607
  nextStep: refineTerminalKind === "blocked_review" ? "Request user review/approval before attempting to merge again." : refineTerminalKind === "validation_failed" ? "Fix failing tests or configure validation.bootstrapCommands and retry mesh_refine_node." : refineTerminalKind === "submodule_reachability_failed" ? "Push unreachable submodule commits to origin/main, then retry mesh_refine_node." : refineTerminalKind === "merge_failed" ? "Resolve merge conflicts or patch equivalence issues, then retry mesh_refine_node." : refineTerminalKind === "cleanup_failed" ? "Manually remove the worktree and retry or use mesh_remove_node." : "Inspect refineStages for the failing stage and retry."
72456
72608
  } : {}