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

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;
@@ -65362,6 +65380,35 @@ Run 'adhdev doctor' for detailed diagnostics.`
65362
65380
  }
65363
65381
  return "";
65364
65382
  }
65383
+ function hasAssistantStandardMessageSinceLastUser(records, content) {
65384
+ const normalized = content.trim();
65385
+ if (!normalized) return false;
65386
+ for (let i = records.length - 1; i >= 0; i--) {
65387
+ const record2 = records[i];
65388
+ if (record2.kind === "session_start") continue;
65389
+ if (record2.role === "user") return false;
65390
+ if (record2.role === "assistant" && record2.kind === "standard" && record2.content.trim() === normalized) {
65391
+ return true;
65392
+ }
65393
+ }
65394
+ return false;
65395
+ }
65396
+ function pushAssistantStandardMessage(records, sessionId, receivedAt, content, workspace) {
65397
+ const text = content.trim();
65398
+ if (!text) return;
65399
+ if (hasAssistantStandardMessageSinceLastUser(records, text)) return;
65400
+ const msg = {
65401
+ ts: new Date(receivedAt).toISOString(),
65402
+ receivedAt,
65403
+ role: "assistant",
65404
+ content: text,
65405
+ kind: "standard",
65406
+ agent: "codex-cli",
65407
+ historySessionId: sessionId
65408
+ };
65409
+ if (workspace) msg.workspace = workspace;
65410
+ records.push(msg);
65411
+ }
65365
65412
  function readSessionMeta(filePath) {
65366
65413
  try {
65367
65414
  const firstLine = fs15.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
@@ -65417,13 +65464,34 @@ Run 'adhdev doctor' for detailed diagnostics.`
65417
65464
  }
65418
65465
  continue;
65419
65466
  }
65420
- if (type !== "response_item") continue;
65421
65467
  const payloadType = String(payload.type ?? "").trim();
65468
+ if (type === "event_msg") {
65469
+ if (payloadType === "task_complete") {
65470
+ pushAssistantStandardMessage(
65471
+ records,
65472
+ sessionId,
65473
+ receivedAt,
65474
+ flattenCodexContent(payload.last_agent_message),
65475
+ detectedWorkspace
65476
+ );
65477
+ } else if (payloadType === "agent_message" && String(payload.phase ?? "").trim() === "final_answer") {
65478
+ pushAssistantStandardMessage(
65479
+ records,
65480
+ sessionId,
65481
+ receivedAt,
65482
+ flattenCodexContent(payload.message),
65483
+ detectedWorkspace
65484
+ );
65485
+ }
65486
+ continue;
65487
+ }
65488
+ if (type !== "response_item") continue;
65422
65489
  if (payloadType === "message") {
65423
65490
  const role = String(payload.role ?? "").trim();
65424
65491
  if (role !== "user" && role !== "assistant") continue;
65425
65492
  const content = flattenCodexContent(payload.content);
65426
65493
  if (!content) continue;
65494
+ if (role === "assistant" && hasAssistantStandardMessageSinceLastUser(records, content)) continue;
65427
65495
  const msg = {
65428
65496
  ts: new Date(receivedAt).toISOString(),
65429
65497
  receivedAt,
@@ -69328,6 +69396,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69328
69396
  }
69329
69397
  }
69330
69398
  init_mesh_work_queue();
69399
+ init_repo_mesh_types();
69331
69400
  var import_os3 = require("os");
69332
69401
  var import_path10 = require("path");
69333
69402
  var fs222 = __toESM2(require("fs"));
@@ -71887,7 +71956,8 @@ ${e?.stderr || ""}`
71887
71956
  ...result ? {
71888
71957
  success: result.success === true,
71889
71958
  result,
71890
- finalBranchConvergenceState: result.finalBranchConvergenceState
71959
+ finalBranchConvergenceState: result.finalBranchConvergenceState,
71960
+ ...result.blockerContext ? { blockerContext: result.blockerContext } : {}
71891
71961
  } : {}
71892
71962
  }
71893
71963
  });
@@ -72417,6 +72487,27 @@ ${e?.stderr || ""}`
72417
72487
  finalBranchConvergenceState
72418
72488
  };
72419
72489
  }
72490
+ const requireApprovalForPush = mesh?.policy?.requireApprovalForPush ?? DEFAULT_MESH_POLICY.requireApprovalForPush;
72491
+ let pushResult;
72492
+ if (!requireApprovalForPush) {
72493
+ const pushStarted = Date.now();
72494
+ try {
72495
+ await execFileAsync3("git", ["push", "origin", baseBranch], { cwd: repoRoot, encoding: "utf8" });
72496
+ pushResult = { pushed: true, remote: "origin", branch: baseBranch, durationMs: Date.now() - pushStarted };
72497
+ recordMeshRefineStage(refineStages, "push", "passed", pushStarted, pushResult);
72498
+ finalBranchConvergenceState.status = "merged_pushed";
72499
+ } catch (e) {
72500
+ pushResult = {
72501
+ pushed: false,
72502
+ remote: "origin",
72503
+ branch: baseBranch,
72504
+ error: e?.message || String(e),
72505
+ stderr: e?.stderr,
72506
+ durationMs: Date.now() - pushStarted
72507
+ };
72508
+ recordMeshRefineStage(refineStages, "push", "failed", pushStarted, pushResult);
72509
+ }
72510
+ }
72420
72511
  return {
72421
72512
  success: true,
72422
72513
  merged: true,
@@ -72430,7 +72521,13 @@ ${e?.stderr || ""}`
72430
72521
  mergeResult,
72431
72522
  refineStages,
72432
72523
  ...ledgerError ? { ledgerError } : {},
72433
- finalBranchConvergenceState
72524
+ finalBranchConvergenceState,
72525
+ // Push outcome or readiness info for coordinator.
72526
+ ...pushResult ? { pushResult } : {
72527
+ pushReady: true,
72528
+ pushCommand: `git push origin ${baseBranch}`,
72529
+ pushNote: "requireApprovalForPush is enabled \u2014 run the push command or obtain user approval before pushing."
72530
+ }
72434
72531
  };
72435
72532
  } catch (e) {
72436
72533
  return { success: false, error: e.message, refineStages };
@@ -72448,9 +72545,46 @@ ${e?.stderr || ""}`
72448
72545
  const refineCode = typeof result.code === "string" ? result.code : "";
72449
72546
  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
72547
  const isTerminalSuccess = refineTerminalKind === "completed";
72548
+ const blockerContext = isTerminalSuccess ? void 0 : (() => {
72549
+ const code = typeof result.code === "string" ? result.code : refineTerminalKind;
72550
+ 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";
72551
+ const ctx = {
72552
+ stage,
72553
+ reason: code,
72554
+ terminalKind: refineTerminalKind
72555
+ };
72556
+ if (typeof result.error === "string") ctx.error = result.error;
72557
+ if (typeof result.blockedReason === "string") ctx.blockedReason = result.blockedReason;
72558
+ if (stage === "patch_equivalence" && result.patchEquivalence) {
72559
+ const pe = result.patchEquivalence;
72560
+ ctx.details = {
72561
+ expectedPatchId: pe.expectedPatchId,
72562
+ actualPatchId: pe.actualPatchId,
72563
+ status: pe.status,
72564
+ actionableHint: pe.actionableHint,
72565
+ error: pe.error
72566
+ };
72567
+ }
72568
+ if (stage === "submodule_reachability" && Array.isArray(result.unreachableSubmoduleCommits)) {
72569
+ ctx.details = {
72570
+ unreachableCount: result.unreachableSubmoduleCommits.length,
72571
+ paths: result.unreachableSubmoduleCommits.map((e) => e.path),
72572
+ autoPublishAllowed: result.unreachableSubmoduleCommits[0]?.autoPublishAllowed
72573
+ };
72574
+ }
72575
+ if (stage === "validation" && result.validationSummary) {
72576
+ const vs = result.validationSummary;
72577
+ ctx.details = {
72578
+ failureCode: vs.failureCode,
72579
+ commandsRun: Array.isArray(vs.commandsRun) ? vs.commandsRun.length : void 0
72580
+ };
72581
+ }
72582
+ return ctx;
72583
+ })();
72451
72584
  const normalizedResult = {
72452
72585
  ...result,
72453
72586
  terminalKind: refineTerminalKind,
72587
+ ...blockerContext ? { blockerContext } : {},
72454
72588
  ...result.nextStep === void 0 && !isTerminalSuccess ? {
72455
72589
  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
72590
  } : {}