@adhdev/daemon-standalone 0.9.82-rc.400 → 0.9.82-rc.401

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
@@ -30127,10 +30127,10 @@ var require_dist3 = __commonJS({
30127
30127
  }
30128
30128
  function getDaemonBuildInfo() {
30129
30129
  if (cached2) return cached2;
30130
- const commit = readInjected(true ? "2350563490670c1c560cc5cf6f863a9e61ef3f89" : void 0) ?? "unknown";
30131
- const commitShort = readInjected(true ? "23505634" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30132
- const version2 = readInjected(true ? "0.9.82-rc.400" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30133
- const builtAt = readInjected(true ? "2026-06-27T13:16:19.563Z" : void 0);
30130
+ const commit = readInjected(true ? "c31eb449e8febc28e378bd25394830a96a67594e" : void 0) ?? "unknown";
30131
+ const commitShort = readInjected(true ? "c31eb449" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30132
+ const version2 = readInjected(true ? "0.9.82-rc.401" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30133
+ const builtAt = readInjected(true ? "2026-06-27T16:15:03.175Z" : void 0);
30134
30134
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30135
30135
  return cached2;
30136
30136
  }
@@ -31173,16 +31173,103 @@ var require_dist3 = __commonJS({
31173
31173
  const parentDir = path42.dirname(repoRoot);
31174
31174
  return path42.join(parentDir, WORKTREE_DIR_NAME, safeMeshName, safeBranch);
31175
31175
  }
31176
+ async function tryGit(cwd, args) {
31177
+ try {
31178
+ const { stdout, stderr } = await execFileAsync2("git", args, {
31179
+ cwd,
31180
+ encoding: "utf8",
31181
+ timeout: GIT_TIMEOUT_MS,
31182
+ maxBuffer: GIT_MAX_BUFFER,
31183
+ windowsHide: true
31184
+ });
31185
+ return { ok: true, stdout: (stdout || "").trim(), stderr: (stderr || "").trim() };
31186
+ } catch (error48) {
31187
+ return {
31188
+ ok: false,
31189
+ stdout: typeof error48?.stdout === "string" ? error48.stdout.trim() : "",
31190
+ stderr: typeof error48?.stderr === "string" ? error48.stderr.trim() : error48?.message || ""
31191
+ };
31192
+ }
31193
+ }
31194
+ async function resolveWorktreeBaseStartPoint(repoRoot, baseBranch, remote) {
31195
+ const fetchResult = await tryGit(repoRoot, ["fetch", remote, baseBranch]);
31196
+ const fetched = fetchResult.ok;
31197
+ const localRev = await tryGit(repoRoot, ["rev-parse", "--verify", "--quiet", `refs/heads/${baseBranch}`]);
31198
+ const remoteRev = await tryGit(repoRoot, ["rev-parse", "--verify", "--quiet", `refs/remotes/${remote}/${baseBranch}`]);
31199
+ const localSha = localRev.ok && localRev.stdout ? localRev.stdout : void 0;
31200
+ const remoteSha = remoteRev.ok && remoteRev.stdout ? remoteRev.stdout : void 0;
31201
+ const remoteRef = `${remote}/${baseBranch}`;
31202
+ const base = {
31203
+ branch: baseBranch,
31204
+ remote,
31205
+ startRef: baseBranch,
31206
+ fetched,
31207
+ localSha,
31208
+ remoteSha,
31209
+ behindBy: 0,
31210
+ aheadBy: 0,
31211
+ action: "up_to_date"
31212
+ };
31213
+ const fetchWarn = fetched ? "" : ` (warning: git fetch ${remote} ${baseBranch} failed: ${fetchResult.stderr || "unknown error"})`;
31214
+ if (!remoteSha) {
31215
+ return {
31216
+ ...base,
31217
+ action: "no_remote_ref_used_local",
31218
+ ...fetched ? {} : { warning: `Could not fetch ${remoteRef}${fetchWarn}; worktree branched from local ${baseBranch}.` }
31219
+ };
31220
+ }
31221
+ if (!localSha) {
31222
+ return {
31223
+ ...base,
31224
+ startRef: remoteRef,
31225
+ action: "no_local_ref_used_remote"
31226
+ };
31227
+ }
31228
+ if (localSha === remoteSha) {
31229
+ return base;
31230
+ }
31231
+ const localIsAncestor = (await tryGit(repoRoot, ["merge-base", "--is-ancestor", localSha, remoteSha])).ok;
31232
+ const remoteIsAncestor = (await tryGit(repoRoot, ["merge-base", "--is-ancestor", remoteSha, localSha])).ok;
31233
+ const behindBy = Number((await tryGit(repoRoot, ["rev-list", "--count", `${localSha}..${remoteSha}`])).stdout) || 0;
31234
+ const aheadBy = Number((await tryGit(repoRoot, ["rev-list", "--count", `${remoteSha}..${localSha}`])).stdout) || 0;
31235
+ if (localIsAncestor && !remoteIsAncestor) {
31236
+ return {
31237
+ ...base,
31238
+ startRef: remoteRef,
31239
+ behindBy,
31240
+ aheadBy,
31241
+ action: "local_behind_used_remote",
31242
+ warning: `Base node local ${baseBranch} was behind ${remoteRef} by ${behindBy} commit(s); worktree branched from ${remoteRef} (${remoteSha.slice(0, 8)}) instead of stale local ${localSha.slice(0, 8)}.${fetchWarn}`
31243
+ };
31244
+ }
31245
+ if (remoteIsAncestor) {
31246
+ return { ...base, behindBy, aheadBy, action: "local_ahead_used_local" };
31247
+ }
31248
+ return {
31249
+ ...base,
31250
+ behindBy,
31251
+ aheadBy,
31252
+ action: "diverged_used_local",
31253
+ warning: `Base node local ${baseBranch} (${localSha.slice(0, 8)}) has DIVERGED from ${remoteRef} (${remoteSha.slice(0, 8)}): behind ${behindBy}, ahead ${aheadBy}. Worktree branched from local; a rebase onto ${remoteRef} will be required before its push can fast-forward.${fetchWarn}`
31254
+ };
31255
+ }
31176
31256
  async function createWorktree(opts) {
31177
31257
  const { repoRoot, branch, baseBranch, meshName } = opts;
31258
+ const remote = (opts.remote || "origin").trim() || "origin";
31178
31259
  const targetDir = opts.targetDir || resolveWorktreePath(repoRoot, meshName, branch);
31179
31260
  if ((0, import_node_fs2.existsSync)(targetDir)) {
31180
31261
  throw new Error(`Worktree target directory already exists: ${targetDir}`);
31181
31262
  }
31182
31263
  await (0, import_promises3.mkdir)(path42.dirname(targetDir), { recursive: true });
31264
+ let baseSync;
31265
+ let startRef = baseBranch;
31266
+ if (baseBranch && opts.syncBaseFromRemote !== false) {
31267
+ baseSync = await resolveWorktreeBaseStartPoint(repoRoot, baseBranch, remote);
31268
+ startRef = baseSync.startRef;
31269
+ }
31183
31270
  const args = ["worktree", "add", targetDir, "-b", branch];
31184
- if (baseBranch) {
31185
- args.push(baseBranch);
31271
+ if (startRef) {
31272
+ args.push(startRef);
31186
31273
  }
31187
31274
  try {
31188
31275
  await execFileAsync2("git", args, {
@@ -31205,7 +31292,8 @@ var require_dist3 = __commonJS({
31205
31292
  return {
31206
31293
  success: true,
31207
31294
  worktreePath: targetDir,
31208
- branch
31295
+ branch,
31296
+ ...baseSync ? { baseSync } : {}
31209
31297
  };
31210
31298
  }
31211
31299
  async function removeWorktree(repoRoot, worktreePath, opts = {}) {
@@ -35437,11 +35525,14 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
35437
35525
  }
35438
35526
  /** A node may only execute one write task at a time (worktree isolation). */
35439
35527
  hasActiveNodeAssignment(meshId, nodeId) {
35528
+ const nodeIdForms = expandDaemonIdForms(nodeId);
35529
+ if (nodeIdForms.length === 0) return false;
35530
+ const placeholders = nodeIdForms.map(() => "?").join(", ");
35440
35531
  const row = this.db.prepare(`
35441
35532
  SELECT 1 FROM mesh_queue
35442
- WHERE mesh_id = ? AND status = 'assigned' AND assigned_node_id = ?
35533
+ WHERE mesh_id = ? AND status = 'assigned' AND assigned_node_id IN (${placeholders})
35443
35534
  LIMIT 1
35444
- `).get(meshId, nodeId);
35535
+ `).get(meshId, ...nodeIdForms);
35445
35536
  return row !== void 0;
35446
35537
  }
35447
35538
  /**
@@ -41683,7 +41774,14 @@ Next step: ${nextStep}`;
41683
41774
  targetSessionId: sessionId,
41684
41775
  cliType: providerType,
41685
41776
  action: "send_chat",
41686
- message: task.message
41777
+ message: task.message,
41778
+ meshContext: {
41779
+ meshId,
41780
+ nodeId,
41781
+ taskId: task.id,
41782
+ ...readNonEmptyString2(loadConfig2().machineId) ? { coordinatorDaemonId: readNonEmptyString2(loadConfig2().machineId) } : {},
41783
+ ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { coordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {}
41784
+ }
41687
41785
  }),
41688
41786
  {
41689
41787
  meshId,
@@ -49373,6 +49471,15 @@ ${cont}` : cont;
49373
49471
  currentStatus = "starting";
49374
49472
  isWaitingForResponse = false;
49375
49473
  currentTurnScope = null;
49474
+ // ARCH-REFACTOR R1 (per-turn task identity): the mesh taskId bound to the most
49475
+ // recently STARTED turn. Unlike currentTurnScope (nulled the moment the turn
49476
+ // settles, before the completion event is even built), this persists past
49477
+ // completion and is only overwritten when the NEXT turn starts. That window is
49478
+ // exactly what the completion path needs: when a turn settles to idle, this still
49479
+ // holds THAT turn's taskId (the next task's turn cannot have started yet — it is
49480
+ // queued in pendingOutbound and only flushed asynchronously after idle), so the
49481
+ // completion event carries the correct id instead of the racy session scalar.
49482
+ currentTurnTaskId = null;
49376
49483
  activeModal = null;
49377
49484
  // ── Approval ─────────────────────────────────────
49378
49485
  lastApprovalResolvedAt = 0;
@@ -49482,6 +49589,7 @@ ${cont}` : cont;
49482
49589
  this.finishRetryCount = 0;
49483
49590
  this.clearIdleFinishCandidate("send_message");
49484
49591
  this.currentTurnScope = turnScope;
49592
+ this.currentTurnTaskId = typeof turnScope.taskId === "string" && turnScope.taskId.trim() ? turnScope.taskId : null;
49485
49593
  this.responseEpoch += 1;
49486
49594
  }
49487
49595
  /** Called when PTY exits */
@@ -51433,15 +51541,18 @@ ${lastSnapshot}`;
51433
51541
  }
51434
51542
  async sendMessage(text, options = {}) {
51435
51543
  if (options.force === true) {
51436
- await this.forceSendMessage(text);
51544
+ await this.forceSendMessage(text, options.meshTaskId);
51437
51545
  return;
51438
51546
  }
51439
- await this.sendMessageNow(text, true);
51547
+ await this.sendMessageNow(text, true, options.meshTaskId);
51440
51548
  }
51441
- async forceSendMessage(text) {
51549
+ async forceSendMessage(text, meshTaskId) {
51442
51550
  if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
51443
51551
  const content = String(text || "");
51444
51552
  if (!content.trim()) return;
51553
+ if (typeof meshTaskId === "string" && meshTaskId.trim()) {
51554
+ this.engine.currentTurnTaskId = meshTaskId;
51555
+ }
51445
51556
  if (this.engine.currentStatus === "waiting_approval" || this.engine.hasActionableApproval()) {
51446
51557
  LOG2.info("CLI", `[${this.cliType}] force-send held \u2014 session parked on approval modal (status=${this.engine.currentStatus})`);
51447
51558
  return;
@@ -51454,7 +51565,7 @@ ${lastSnapshot}`;
51454
51565
  async waitForForceSubmitSettle() {
51455
51566
  await new Promise((resolve24) => setTimeout(resolve24, FORCE_SUBMIT_SETTLE_MS));
51456
51567
  }
51457
- enqueuePendingOutboundMessage(text, reason) {
51568
+ enqueuePendingOutboundMessage(text, reason, meshTaskId) {
51458
51569
  const content = String(text || "");
51459
51570
  const duplicate = this.pendingOutboundQueue.some((message2) => message2.content === content);
51460
51571
  if (duplicate) {
@@ -51466,7 +51577,8 @@ ${lastSnapshot}`;
51466
51577
  role: "user",
51467
51578
  content,
51468
51579
  queuedAt,
51469
- source: "sendMessage"
51580
+ source: "sendMessage",
51581
+ ...typeof meshTaskId === "string" && meshTaskId.trim() ? { meshTaskId } : {}
51470
51582
  };
51471
51583
  this.pendingOutboundQueue.push(message);
51472
51584
  LOG2.info("CLI", `[${this.cliType}] queued outbound message while busy (${reason}); queue=${this.pendingOutboundQueue.length}`);
@@ -51509,7 +51621,7 @@ ${lastSnapshot}`;
51509
51621
  if (this.engine.currentStatus !== "idle" || this.engine.isWaitingForResponse || this.engine.hasActionableApproval()) break;
51510
51622
  const next = this.pendingOutboundQueue[0];
51511
51623
  try {
51512
- await this.sendMessageNow(next.content, false);
51624
+ await this.sendMessageNow(next.content, false, next.meshTaskId);
51513
51625
  this.pendingOutboundQueue.shift();
51514
51626
  this.onStatusChange?.();
51515
51627
  } catch (error48) {
@@ -51522,7 +51634,7 @@ ${lastSnapshot}`;
51522
51634
  this.pendingOutboundFlushInFlight = false;
51523
51635
  }
51524
51636
  }
51525
- async sendMessageNow(text, allowQueue) {
51637
+ async sendMessageNow(text, allowQueue, meshTaskId) {
51526
51638
  if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
51527
51639
  const allowInputDuringGeneration = this.provider.allowInputDuringGeneration === true;
51528
51640
  const allowInterventionPrompt = allowInputDuringGeneration && this.engine.isWaitingForResponse && !this.engine.hasActionableApproval();
@@ -51542,7 +51654,7 @@ ${lastSnapshot}`;
51542
51654
  })() : null;
51543
51655
  const queueReason = this.shouldQueuePendingOutboundMessage(parsedStatusBeforeSend);
51544
51656
  if (allowQueue && queueReason) {
51545
- this.enqueuePendingOutboundMessage(text, queueReason);
51657
+ this.enqueuePendingOutboundMessage(text, queueReason, meshTaskId);
51546
51658
  return;
51547
51659
  }
51548
51660
  if (!allowInterventionPrompt) {
@@ -51559,7 +51671,7 @@ ${lastSnapshot}`;
51559
51671
  }
51560
51672
  if (!this.ready) {
51561
51673
  if (allowQueue) {
51562
- this.enqueuePendingOutboundMessage(text, "not_ready_pending_prompt");
51674
+ this.enqueuePendingOutboundMessage(text, "not_ready_pending_prompt", meshTaskId);
51563
51675
  return;
51564
51676
  }
51565
51677
  throw new Error(`${this.cliName} not ready (status: ${this.engine.currentStatus})`);
@@ -51573,7 +51685,7 @@ ${lastSnapshot}`;
51573
51685
  const terminalLooksIdle = this.engine.currentStatus === "idle" && this.runDetectStatus(this.recentOutputBuffer) === "idle" && !this.engine.isWaitingForResponse && !this.engine.currentTurnScope && !this.engine.hasActionableApproval() && !parsedHasActionableModal;
51574
51686
  if (!terminalLooksIdle) {
51575
51687
  if (allowQueue) {
51576
- this.enqueuePendingOutboundMessage(text, `parsed_status_${parsedSessionStatus}`);
51688
+ this.enqueuePendingOutboundMessage(text, `parsed_status_${parsedSessionStatus}`, meshTaskId);
51577
51689
  return;
51578
51690
  }
51579
51691
  throw new Error(`${this.cliName} is still processing the previous prompt`);
@@ -51583,7 +51695,7 @@ ${lastSnapshot}`;
51583
51695
  const snap = this.getSnapshot();
51584
51696
  if (!this.engine.clearStaleIdleResponseGuard("send_message_guard", snap) && !this.engine.clearParsedIdleResponseGuard("send_message_parsed_idle_guard", parsedStatusBeforeSend, snap)) {
51585
51697
  if (allowQueue) {
51586
- this.enqueuePendingOutboundMessage(text, "waiting_for_response");
51698
+ this.enqueuePendingOutboundMessage(text, "waiting_for_response", meshTaskId);
51587
51699
  return;
51588
51700
  }
51589
51701
  throw new Error(`${this.cliName} is still processing the previous prompt`);
@@ -51594,7 +51706,11 @@ ${lastSnapshot}`;
51594
51706
  prompt: text,
51595
51707
  startedAt: Date.now(),
51596
51708
  bufferStart: this.accumulatedBuffer.length,
51597
- rawBufferStart: this.accumulatedRawBuffer.length
51709
+ rawBufferStart: this.accumulatedRawBuffer.length,
51710
+ // ARCH-REFACTOR R1: bind this turn to its mesh task. engine.onTurnStarted
51711
+ // copies this into currentTurnTaskId so the turn's completion event carries
51712
+ // the right id even if a later task overwrites the session scalar meanwhile.
51713
+ ...typeof meshTaskId === "string" && meshTaskId.trim() ? { taskId: meshTaskId } : {}
51598
51714
  };
51599
51715
  LOG2.info("CLI", `[${this.cliType}] sendMessage turn scope buffer=${turnScope.bufferStart} raw=${turnScope.rawBufferStart} prompt=${JSON.stringify(text).slice(0, 120)}`);
51600
51716
  if (this.submitRetryTimer) {
@@ -51944,6 +52060,13 @@ ${lastSnapshot}`;
51944
52060
  set currentTurnScope(v) {
51945
52061
  this.engine.currentTurnScope = v;
51946
52062
  }
52063
+ // ARCH-REFACTOR R1: the mesh taskId bound to the most recently started turn,
52064
+ // surviving past turn settle until the next turn starts. The provider instance
52065
+ // reads this when stamping completion events so they carry the completing turn's
52066
+ // task rather than the racy last-write-wins session scalar.
52067
+ get currentTurnTaskId() {
52068
+ return this.engine.currentTurnTaskId;
52069
+ }
51947
52070
  get responseEpoch() {
51948
52071
  return this.engine.responseEpoch;
51949
52072
  }
@@ -70350,11 +70473,28 @@ ${body}
70350
70473
  isMeshWorkerSession() {
70351
70474
  return !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.meshNodeId || this.settings.launchedByCoordinator);
70352
70475
  }
70476
+ /**
70477
+ * ARCH-REFACTOR R1: the taskId to attribute the CURRENTLY-completing turn to.
70478
+ * Prefers the per-turn binding (engine.currentTurnTaskId, set when the turn was
70479
+ * submitted and surviving until the next turn starts) over the last-write-wins
70480
+ * session scalar (settings.meshActiveTaskId). The scalar is retained only as a
70481
+ * backward-compat alias for the "current/last assignment" and is the source of the
70482
+ * NOTIF-MISDELIVER / TASK-MSG-MISROUTE race: a second task attaching before this
70483
+ * turn completes overwrites it. Returns undefined for a non-task ad-hoc turn.
70484
+ */
70485
+ completingTurnTaskId() {
70486
+ const turnTaskId = this.adapter?.currentTurnTaskId;
70487
+ if (typeof turnTaskId === "string" && turnTaskId.trim()) return turnTaskId;
70488
+ const scalar = this.settings.meshActiveTaskId;
70489
+ return typeof scalar === "string" && scalar.trim() ? scalar : void 0;
70490
+ }
70353
70491
  // EVTTRACE correlation context for this session's completion lifecycle. taskId is
70354
70492
  // the primary grep anchor; instanceId is the session fallback.
70355
70493
  meshTraceCtx(event = "agent:generating_completed") {
70356
70494
  return {
70357
- taskId: this.settings.meshActiveTaskId,
70495
+ // ARCH-REFACTOR R1: trace the per-turn taskId (falling back to the scalar) so
70496
+ // EvtTrace anchors on the same id the completion event actually carries.
70497
+ taskId: this.completingTurnTaskId(),
70358
70498
  sessionId: this.instanceId,
70359
70499
  nodeId: this.settings.meshNodeId,
70360
70500
  meshId: this.settings.meshNodeFor,
@@ -70413,6 +70553,8 @@ ${body}
70413
70553
  chatTitle: pending.chatTitle,
70414
70554
  duration: pending.duration,
70415
70555
  timestamp: pending.timestamp,
70556
+ // ARCH-REFACTOR R1: attribute to the turn captured at idle-transition.
70557
+ ...pending.taskId ? { taskId: pending.taskId } : {},
70416
70558
  // When finalization is forced past the timeout on a `parsed_status:` block
70417
70559
  // (the parser never confirmed a final assistant turn) we previously rode an
70418
70560
  // empty `finalSummary` unconditionally. That empty value propagates to the
@@ -70438,6 +70580,8 @@ ${body}
70438
70580
  chatTitle: pending.chatTitle,
70439
70581
  duration: pending.duration,
70440
70582
  timestamp: pending.timestamp,
70583
+ // ARCH-REFACTOR R1: attribute to the turn captured at idle-transition.
70584
+ ...pending.taskId ? { taskId: pending.taskId } : {},
70441
70585
  finalSummary: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages)
70442
70586
  });
70443
70587
  this.completedDebouncePending = null;
@@ -70714,7 +70858,11 @@ ${body}
70714
70858
  duration: duration3,
70715
70859
  timestamp: now,
70716
70860
  firstObservedAt: now,
70717
- previousStatus: this.lastStatus
70861
+ previousStatus: this.lastStatus,
70862
+ // ARCH-REFACTOR R1: snapshot the completing turn's taskId NOW (sync),
70863
+ // before any follow-up task's flush can start a new turn and move
70864
+ // engine.currentTurnTaskId.
70865
+ ...this.completingTurnTaskId() ? { taskId: this.completingTurnTaskId() } : {}
70718
70866
  };
70719
70867
  const ownsExternalHistory = !!this.adapter?.chatMessagesOwnedExternally;
70720
70868
  const meshWorkerSession = this.isMeshWorkerSession();
@@ -70817,10 +70965,11 @@ ${body}
70817
70965
  workspace: typeof event.workspace === "string" && event.workspace.trim() ? event.workspace : this.workingDir,
70818
70966
  providerSessionId: typeof event.providerSessionId === "string" && event.providerSessionId.trim() ? event.providerSessionId : this.providerSessionId
70819
70967
  };
70820
- if (this.isMeshWorkerSession() && this.settings.meshActiveTaskId) {
70968
+ if (this.isMeshWorkerSession()) {
70821
70969
  const existingTaskId = typeof enrichedEvent.taskId === "string" && enrichedEvent.taskId.trim() ? enrichedEvent.taskId : void 0;
70822
70970
  if (!existingTaskId) {
70823
- enrichedEvent.taskId = this.settings.meshActiveTaskId;
70971
+ const resolved = this.completingTurnTaskId();
70972
+ if (resolved) enrichedEvent.taskId = resolved;
70824
70973
  }
70825
70974
  }
70826
70975
  if (this.context?.emitProviderEvent) {
@@ -73692,11 +73841,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
73692
73841
  }
73693
73842
  const message = input.textFallback;
73694
73843
  if (!message) throw new Error("message required for send_chat");
73844
+ const meshTaskId = meshContext && typeof meshContext === "object" && typeof meshContext.taskId === "string" && meshContext.taskId.trim() ? meshContext.taskId : void 0;
73695
73845
  const forceSend = args?.force === true || args?.forceSend === true;
73696
73846
  if (forceSend && typeof adapter.forceSendMessage === "function") {
73697
- await adapter.forceSendMessage(message);
73847
+ if (meshTaskId) await adapter.forceSendMessage(message, meshTaskId);
73848
+ else await adapter.forceSendMessage(message);
73698
73849
  } else if (forceSend) {
73699
- await adapter.sendMessage(message, { force: true });
73850
+ await adapter.sendMessage(message, meshTaskId ? { force: true, meshTaskId } : { force: true });
73851
+ } else if (meshTaskId) {
73852
+ await adapter.sendMessage(message, { meshTaskId });
73700
73853
  } else {
73701
73854
  await adapter.sendMessage(message);
73702
73855
  }
@@ -78192,6 +78345,11 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
78192
78345
  baseBranch,
78193
78346
  meshName: mesh.name
78194
78347
  });
78348
+ if (result.baseSync?.warning) {
78349
+ console.warn(`[mesh] clone_mesh_node base sync (${result.baseSync.action}): ${result.baseSync.warning}`);
78350
+ } else if (result.baseSync && result.baseSync.action !== "up_to_date") {
78351
+ console.log(`[mesh] clone_mesh_node base sync: ${result.baseSync.action} (startRef=${result.baseSync.startRef})`);
78352
+ }
78195
78353
  let node;
78196
78354
  if (meshRecord.inline) {
78197
78355
  const { randomUUID: randomUUID15 } = await import("crypto");
@@ -78382,6 +78540,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
78382
78540
  node,
78383
78541
  worktreePath: result.worktreePath,
78384
78542
  branch: result.branch,
78543
+ ...result.baseSync ? { baseSync: result.baseSync } : {},
78544
+ ...result.baseSync?.warning ? { baseStaleWarning: result.baseSync.warning } : {},
78385
78545
  worktreeBootstrap: runningBootstrapState,
78386
78546
  worktreeSetup: {
78387
78547
  status: "running",
@@ -78397,6 +78557,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
78397
78557
  node,
78398
78558
  worktreePath: result.worktreePath,
78399
78559
  branch: result.branch,
78560
+ ...result.baseSync ? { baseSync: result.baseSync } : {},
78561
+ ...result.baseSync?.warning ? { baseStaleWarning: result.baseSync.warning } : {},
78400
78562
  submodulesInitialized,
78401
78563
  worktreeBootstrap: bootstrapState
78402
78564
  };