@sideboard-ai/core 0.1.348 → 0.1.350

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.
Files changed (84) hide show
  1. package/dist/{abletime-CGFJZB7L.js → abletime-TX7BTTR2.js} +5 -5
  2. package/dist/{abletime-3HRWLQZJ.js → abletime-URSRZW7P.js} +4 -4
  3. package/dist/{abletime-oauth-QNJQLHR4.js → abletime-oauth-QS3WPSCC.js} +3 -3
  4. package/dist/{abletime-oauth-JQDSH5OL.js → abletime-oauth-SL3NMNEC.js} +4 -4
  5. package/dist/{abletime-rest-TANL5TMY.js → abletime-rest-GGQLUO55.js} +3 -3
  6. package/dist/{abletime-rest-UQA2CRZN.js → abletime-rest-JZU6JJCV.js} +4 -4
  7. package/dist/agents/acp-runner.cjs +491 -0
  8. package/dist/agents/acp-runner.d.cts +46 -0
  9. package/dist/agents/acp-runner.d.ts +46 -0
  10. package/dist/agents/acp-runner.js +323 -0
  11. package/dist/agents/cursor-runner.js +3 -3
  12. package/dist/{agents-T4XBZZDA.js → agents-P5QIV24I.js} +38 -8
  13. package/dist/{agents-5MFGVK7C.js → agents-RGAV5OHD.js} +44 -13
  14. package/dist/{app-settings-SNOPJ7P5.js → app-settings-IA7ZZKWQ.js} +2 -2
  15. package/dist/{app-settings-PPIMYJKS.js → app-settings-XILTSD6L.js} +1 -1
  16. package/dist/{chunk-UGUWFONI.js → chunk-2E2HMJDU.js} +1 -1
  17. package/dist/{chunk-OH3BAUMC.js → chunk-2MESZ5XR.js} +273 -84
  18. package/dist/{chunk-RUIHNWRV.js → chunk-37ZBEBP6.js} +6 -6
  19. package/dist/{chunk-Y6VQX2LY.js → chunk-5AHWUJRT.js} +1927 -1718
  20. package/dist/{chunk-7B2OUQON.js → chunk-5TCMXEYL.js} +48 -3
  21. package/dist/{chunk-FDYMVJFU.js → chunk-5WF54R3B.js} +5 -5
  22. package/dist/{chunk-PVCECFJK.js → chunk-7ZD4OK6G.js} +1 -1
  23. package/dist/{chunk-RYPD7XWV.js → chunk-B4EFQTMP.js} +5 -5
  24. package/dist/chunk-BF6INES4.js +144 -0
  25. package/dist/{chunk-IVRWRYTH.js → chunk-BZK62VPT.js} +2 -2
  26. package/dist/{chunk-AJMERXZP.js → chunk-CCWQ65VD.js} +2 -2
  27. package/dist/{chunk-62ALWH3T.js → chunk-DL4OHDBV.js} +3 -3
  28. package/dist/{chunk-6TV6L2DD.js → chunk-EZ2MUWNW.js} +7 -6
  29. package/dist/{chunk-4NXGVJA6.js → chunk-F4RFFE2H.js} +48 -3
  30. package/dist/{chunk-E77SRVVO.js → chunk-FCKTBE26.js} +1 -1
  31. package/dist/{chunk-NTY5WGRD.js → chunk-FQ3JYUKI.js} +2 -2
  32. package/dist/{chunk-CEQ4Z32M.js → chunk-J4EA5SHF.js} +3 -3
  33. package/dist/{chunk-ORO4ENZR.js → chunk-LESWJ7L4.js} +1 -0
  34. package/dist/{chunk-XNGW4OYD.js → chunk-LFSTOECH.js} +7 -6
  35. package/dist/{chunk-OHUAAX3O.js → chunk-M45WGODR.js} +2 -2
  36. package/dist/{chunk-ZJMYCDYQ.js → chunk-MANERA6F.js} +55 -10
  37. package/dist/{chunk-Q4TZA4MN.js → chunk-NDEVAA34.js} +1629 -1486
  38. package/dist/{chunk-OPXEJJBM.js → chunk-PWOFUPYM.js} +1 -0
  39. package/dist/{chunk-UJMCTGV7.js → chunk-PXSWVZIL.js} +2 -2
  40. package/dist/{chunk-MOUAM6ZC.js → chunk-SMSD6U3N.js} +135 -3
  41. package/dist/{chunk-ATS7SYHG.js → chunk-TCEUNSLX.js} +135 -3
  42. package/dist/chunk-TRMPDDVL.js +232 -0
  43. package/dist/{chunk-6WMNIX2U.js → chunk-UFUAIVNV.js} +9 -5
  44. package/dist/{chunk-2HPVGTHF.js → chunk-VHQ6OG3U.js} +2 -2
  45. package/dist/{chunk-WWU4SYZR.js → chunk-VL6F2KRE.js} +5 -1
  46. package/dist/{chunk-WMD77UCY.js → chunk-W5GHFT7E.js} +279 -87
  47. package/dist/{chunk-5FUAOU3G.js → chunk-WB3G2LQO.js} +1 -1
  48. package/dist/{chunk-JCYGQKER.js → chunk-WFX4ZVSZ.js} +1 -1
  49. package/dist/{chunk-F7WP2U5I.js → chunk-WJURGCBR.js} +1 -1
  50. package/dist/{chunk-BIM24I3O.js → chunk-WWBPK7GB.js} +1 -1
  51. package/dist/chunk-YE7Z5WH3.js +142 -0
  52. package/dist/{chunk-5YCKATG6.js → chunk-YVN7L4KG.js} +1 -1
  53. package/dist/{chunk-GAGTEI6B.js → chunk-ZBSEJIOV.js} +56 -11
  54. package/dist/{conductor-LYQKONSA.js → conductor-HVOGBK63.js} +7 -6
  55. package/dist/{conductor-EMGMDNHL.js → conductor-VGCXUUG6.js} +9 -8
  56. package/dist/connected-teams-2YDE2EZ2.js +1 -1
  57. package/dist/{coordinator-prompt-DLY3FS2L.js → coordinator-prompt-DPO7L2JO.js} +5 -5
  58. package/dist/{coordinator-prompt-WALVMGKI.js → coordinator-prompt-E736TJBS.js} +4 -4
  59. package/dist/{global-workspace-UG2A3CEM.js → global-workspace-4RDPAOTT.js} +5 -5
  60. package/dist/{global-workspace-7OQ5O6JT.js → global-workspace-TG2TVLUF.js} +4 -4
  61. package/dist/index.cjs +2881 -1761
  62. package/dist/index.d.cts +140 -877
  63. package/dist/index.d.ts +140 -877
  64. package/dist/index.js +865 -559
  65. package/dist/{linear-PKYJH4WK.js → linear-E3BX5PX5.js} +2 -2
  66. package/dist/{linear-MIJO6DCV.js → linear-WG23LBCX.js} +3 -3
  67. package/dist/{linear-list-JPQ27RXG.js → linear-list-OINZWVV5.js} +1 -1
  68. package/dist/{linear-list-N57PR6JM.js → linear-list-VU47BNUV.js} +1 -1
  69. package/dist/mcp/run-stdio.cjs +2112 -1287
  70. package/dist/mcp/run-stdio.js +318 -230
  71. package/dist/{optional-cli-4GTEDEYJ.js → optional-cli-K6HX2X5O.js} +4 -3
  72. package/dist/{optional-cli-RPJIQBDX.js → optional-cli-SA3EQYML.js} +6 -5
  73. package/dist/{orchestrator-KNOMW5CZ.js → orchestrator-3I2FLEZL.js} +20 -18
  74. package/dist/{orchestrator-4SXTORD2.js → orchestrator-QDHZ56LA.js} +12 -11
  75. package/dist/thread-CJRchYLj.d.cts +856 -0
  76. package/dist/thread-CJRchYLj.d.ts +856 -0
  77. package/dist/{thread-store-R3G5VBII.js → thread-store-4YTOV2HL.js} +3 -3
  78. package/dist/{thread-store-MEUWZDVV.js → thread-store-LME2ICZP.js} +2 -2
  79. package/dist/{workspaces-KWGTP7DI.js → workspaces-4PA24IX6.js} +4 -4
  80. package/dist/{workspaces-35T6FW57.js → workspaces-6TMYV4N2.js} +5 -5
  81. package/dist/{worktree-ROJXGBWS.js → worktree-4ATMCYIE.js} +3 -3
  82. package/dist/{worktree-5P7SCST3.js → worktree-DA6SKIU5.js} +4 -4
  83. package/package.json +3 -3
  84. /package/dist/{chunk-XOEKCE6L.js → chunk-OHXNGBC4.js} +0 -0
@@ -14,7 +14,7 @@ import {
14
14
  parseSessionQuotaResetAt,
15
15
  planModeTurnInstruction,
16
16
  resolveQuotaFallbackAgent
17
- } from "./chunk-Y6VQX2LY.js";
17
+ } from "./chunk-5AHWUJRT.js";
18
18
  import {
19
19
  applyWorktreePkgCacheEnv,
20
20
  askBlockStillWaiting,
@@ -54,7 +54,7 @@ import {
54
54
  worktreeDevProcessKey,
55
55
  worktreeRunProcessKey,
56
56
  worktreeSetupProcessKey
57
- } from "./chunk-ZJMYCDYQ.js";
57
+ } from "./chunk-MANERA6F.js";
58
58
  import {
59
59
  applyAgentEvent,
60
60
  clipAgentEventForPaint,
@@ -81,14 +81,18 @@ import {
81
81
  summarizeTurnStderr,
82
82
  toolDescription,
83
83
  turnFailChatText
84
- } from "./chunk-ORO4ENZR.js";
84
+ } from "./chunk-LESWJ7L4.js";
85
85
  import {
86
86
  titleFromPrompt
87
87
  } from "./chunk-LX5R5JOR.js";
88
88
  import {
89
89
  formatOptionalServicesDirectiveForTurn,
90
90
  formatOptionalServicesReminderForTurn
91
- } from "./chunk-F7WP2U5I.js";
91
+ } from "./chunk-WJURGCBR.js";
92
+ import {
93
+ defaultAcpHarness,
94
+ detectAcpHarness
95
+ } from "./chunk-BF6INES4.js";
92
96
  import {
93
97
  extractPresentedPlan,
94
98
  isPresentPlanToolName,
@@ -121,7 +125,7 @@ import {
121
125
  stageAbsolutePathsAsAttachments,
122
126
  stageBuffersAsAttachments,
123
127
  syncWorkspacesFromThreads
124
- } from "./chunk-6TV6L2DD.js";
128
+ } from "./chunk-EZ2MUWNW.js";
125
129
  import {
126
130
  addPrStackLayer,
127
131
  allocateTeamSlug,
@@ -172,7 +176,7 @@ import {
172
176
  resolveRepoRoot,
173
177
  switchWorktreeBranch,
174
178
  withRepoGitLock
175
- } from "./chunk-2HPVGTHF.js";
179
+ } from "./chunk-VHQ6OG3U.js";
176
180
  import {
177
181
  issueActivityKind
178
182
  } from "./chunk-OYRN356W.js";
@@ -188,7 +192,9 @@ import {
188
192
  REVIEW_TAB_TITLE,
189
193
  agentNicknameFromWorktreePath,
190
194
  appendMessage,
195
+ ciChecksSettled,
191
196
  createEmptyThread,
197
+ decideFollowUps,
192
198
  deleteSchedule,
193
199
  deleteThreadRecord,
194
200
  findThreadByRef,
@@ -200,6 +206,8 @@ import {
200
206
  isWorktreeIdentityTitle,
201
207
  listSchedules,
202
208
  listThreads,
209
+ mergeFollowUpPoll,
210
+ normalizeChatFollowUps,
203
211
  normalizeWorkspaceTags,
204
212
  normalizeWorktreePath,
205
213
  readThread,
@@ -215,7 +223,7 @@ import {
215
223
  worktreeNameFromPath,
216
224
  worktreeSlugForTicket,
217
225
  writeThread
218
- } from "./chunk-MOUAM6ZC.js";
226
+ } from "./chunk-SMSD6U3N.js";
219
227
  import {
220
228
  HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT,
221
229
  applyTurnUsage,
@@ -252,7 +260,7 @@ import {
252
260
  wakeOrchestratorOnGithubEdgesEnabled,
253
261
  withTurnScopedCost,
254
262
  writeViewerContext
255
- } from "./chunk-WWU4SYZR.js";
263
+ } from "./chunk-VL6F2KRE.js";
256
264
  import {
257
265
  writePrivateFile
258
266
  } from "./chunk-NSTQ6QKD.js";
@@ -379,19 +387,19 @@ function traceTurn(phase, extra) {
379
387
  }
380
388
  }
381
389
  async function withTimeout(promise, ms, label) {
382
- let timer2;
390
+ let timer3;
383
391
  try {
384
392
  return await Promise.race([
385
393
  promise,
386
394
  new Promise((_, reject) => {
387
- timer2 = setTimeout(
395
+ timer3 = setTimeout(
388
396
  () => reject(new Error(`${label} timed out after ${ms}ms`)),
389
397
  ms
390
398
  );
391
399
  })
392
400
  ]);
393
401
  } finally {
394
- if (timer2) clearTimeout(timer2);
402
+ if (timer3) clearTimeout(timer3);
395
403
  }
396
404
  }
397
405
 
@@ -504,11 +512,11 @@ function parentKey(event) {
504
512
  function createAgentStreamCoalescer(emit, opts) {
505
513
  const intervalMs = opts?.intervalMs ?? 32;
506
514
  let pending = null;
507
- let timer2 = null;
515
+ let timer3 = null;
508
516
  const flush2 = () => {
509
- if (timer2) {
510
- clearTimeout(timer2);
511
- timer2 = null;
517
+ if (timer3) {
518
+ clearTimeout(timer3);
519
+ timer3 = null;
512
520
  }
513
521
  if (!pending) return;
514
522
  const event = pending;
@@ -520,9 +528,9 @@ function createAgentStreamCoalescer(emit, opts) {
520
528
  });
521
529
  };
522
530
  const schedule = () => {
523
- if (timer2) return;
524
- timer2 = setTimeout(flush2, intervalMs);
525
- timer2.unref?.();
531
+ if (timer3) return;
532
+ timer3 = setTimeout(flush2, intervalMs);
533
+ timer3.unref?.();
526
534
  };
527
535
  return {
528
536
  push(event) {
@@ -571,9 +579,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
571
579
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
572
580
  );
573
581
  }
574
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-7OQ5O6JT.js");
582
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-TG2TVLUF.js");
575
583
  if (isGlobalThread2(thread)) {
576
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-WALVMGKI.js");
584
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-E736TJBS.js");
577
585
  ensureGlobalCoordinatorCwd2(
578
586
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
579
587
  );
@@ -771,14 +779,97 @@ async function spawnAgentTurn(thread, input, onEvent) {
771
779
  }
772
780
  };
773
781
  signal("SIGTERM");
774
- const timer2 = setTimeout(() => signal("SIGKILL"), 5e3);
775
- timer2.unref?.();
776
- child.once("exit", () => clearTimeout(timer2));
782
+ const timer3 = setTimeout(() => signal("SIGKILL"), 5e3);
783
+ timer3.unref?.();
784
+ child.once("exit", () => clearTimeout(timer3));
777
785
  },
778
786
  done
779
787
  };
780
788
  }
781
789
 
790
+ // src/git/worktree-leftovers.ts
791
+ var LEFTOVER_REF_PREFIX = "refs/sideboard/leftovers/";
792
+ function leftoverRefName(branch) {
793
+ const safe = branch.trim().replace(/[^A-Za-z0-9._/-]+/g, "-") || "branch";
794
+ return `${LEFTOVER_REF_PREFIX}${safe}`;
795
+ }
796
+ function gitFailure(result, fallback) {
797
+ const text3 = (result.stderr || result.stdout).trim();
798
+ return text3 || fallback;
799
+ }
800
+ async function restoreIndex(worktreePath, treeSha) {
801
+ await git(["read-tree", "--reset", treeSha], worktreePath, { reject: false });
802
+ }
803
+ async function saveWorktreeLeftovers(repoPath, worktreePath, branch) {
804
+ const status = await git(["status", "--porcelain"], worktreePath, { reject: false });
805
+ if (status.exitCode !== 0) {
806
+ return { ok: false, error: gitFailure(status, "git status failed") };
807
+ }
808
+ if (!status.stdout.trim()) return { ok: true, ref: null };
809
+ const indexBefore = await git(["write-tree"], worktreePath, { reject: false });
810
+ const indexSha = indexBefore.stdout.trim();
811
+ if (indexBefore.exitCode !== 0 || !/^[0-9a-f]{7,64}$/i.test(indexSha)) {
812
+ return { ok: false, error: gitFailure(indexBefore, "git write-tree failed") };
813
+ }
814
+ const fail = async (result, fallback) => {
815
+ await restoreIndex(worktreePath, indexSha);
816
+ return { ok: false, error: gitFailure(result, fallback) };
817
+ };
818
+ const added = await git(["add", "-A"], worktreePath, { reject: false });
819
+ if (added.exitCode !== 0) return fail(added, "git add failed");
820
+ const tree = await git(["write-tree"], worktreePath, { reject: false });
821
+ const treeSha = tree.stdout.trim();
822
+ if (tree.exitCode !== 0 || !/^[0-9a-f]{7,64}$/i.test(treeSha)) {
823
+ return fail(tree, "git write-tree failed");
824
+ }
825
+ const head = await git(["rev-parse", "HEAD"], worktreePath, { reject: false });
826
+ const parent = head.stdout.trim();
827
+ if (head.exitCode !== 0 || !parent) return fail(head, "git rev-parse HEAD failed");
828
+ const commit = await git(
829
+ ["commit-tree", treeSha, "-p", parent, "-m", "sideboard leftover"],
830
+ worktreePath,
831
+ { reject: false }
832
+ );
833
+ const sha = commit.stdout.trim();
834
+ if (commit.exitCode !== 0 || !/^[0-9a-f]{7,64}$/i.test(sha)) {
835
+ return fail(commit, "git commit-tree failed");
836
+ }
837
+ const ref = leftoverRefName(branch);
838
+ const updated = await git(["update-ref", ref, sha], repoPath, { reject: false });
839
+ if (updated.exitCode !== 0) return fail(updated, "git update-ref failed");
840
+ await git(["reset"], worktreePath, { reject: false });
841
+ return { ok: true, ref };
842
+ }
843
+ async function applyWorktreeLeftovers(repoPath, worktreePath, branch) {
844
+ const ref = leftoverRefName(branch);
845
+ const shown = await git(["rev-parse", "--verify", "--quiet", ref], repoPath, { reject: false });
846
+ const sha = shown.stdout.trim();
847
+ if (shown.exitCode !== 0 || !sha) return false;
848
+ const restored = await git(["restore", "--source", sha, "--worktree", "--", "."], worktreePath, {
849
+ reject: false
850
+ });
851
+ if (restored.exitCode !== 0) return false;
852
+ await git(["update-ref", "-d", ref], repoPath, { reject: false });
853
+ return true;
854
+ }
855
+ async function deleteWorktreeLeftovers(repoPath, branch) {
856
+ await git(["update-ref", "-d", leftoverRefName(branch)], repoPath, { reject: false });
857
+ }
858
+ function archiveClearingFollowUps(id) {
859
+ const archived = setStatus(id, "archived");
860
+ if ((archived.followUps?.length ?? 0) === 0) return archived;
861
+ return updateThread(archived.id, { followUps: [] });
862
+ }
863
+ async function removeWorktreeSavingLeftovers(thread) {
864
+ const saved = await saveWorktreeLeftovers(thread.repoPath, thread.worktreePath, thread.branchName);
865
+ if (!saved.ok) throw new Error(`Could not save uncommitted files: ${saved.error}`);
866
+ await removeWorktree(thread.repoPath, thread.worktreePath);
867
+ }
868
+ async function removeWorktreeDroppingLeftovers(thread, deleteBranch) {
869
+ await removeWorktree(thread.repoPath, thread.worktreePath, { deleteBranch });
870
+ await deleteWorktreeLeftovers(thread.repoPath, thread.branchName).catch(() => void 0);
871
+ }
872
+
782
873
  // src/git/agent-git-actions.ts
783
874
  var AGENT_GIT_ACTIONS = [
784
875
  "commit-push",
@@ -1115,9 +1206,9 @@ function emptySetupLog() {
1115
1206
  }
1116
1207
  var PERSIST_DEBOUNCE_MS = 500;
1117
1208
  function persistNow(threadId) {
1118
- const timer2 = persistTimers.get(threadId);
1119
- if (timer2) {
1120
- clearTimeout(timer2);
1209
+ const timer3 = persistTimers.get(threadId);
1210
+ if (timer3) {
1211
+ clearTimeout(timer3);
1121
1212
  persistTimers.delete(threadId);
1122
1213
  }
1123
1214
  const mem = memory.get(threadId);
@@ -1266,9 +1357,9 @@ function sliceRunLogOutput(output, tailChars = DEFAULT_RUN_LOG_TAIL_CHARS) {
1266
1357
  }
1267
1358
  var PERSIST_DEBOUNCE_MS2 = 500;
1268
1359
  function persistNow2(key) {
1269
- const timer2 = persistTimers2.get(key);
1270
- if (timer2) {
1271
- clearTimeout(timer2);
1360
+ const timer3 = persistTimers2.get(key);
1361
+ if (timer3) {
1362
+ clearTimeout(timer3);
1272
1363
  persistTimers2.delete(key);
1273
1364
  }
1274
1365
  const mem = memory2.get(key);
@@ -2367,7 +2458,7 @@ async function requireAgent(agent, opts) {
2367
2458
  ensureAgentPath();
2368
2459
  enrichPathWithNpmGlobalBin();
2369
2460
  const status = await Promise.race([
2370
- getAdapter(agent).detect(),
2461
+ agent === "acp" ? detectAcpHarness(opts?.acpHarness ?? defaultAcpHarness()) : getAdapter(agent).detect(),
2371
2462
  new Promise((_, reject) => {
2372
2463
  setTimeout(() => {
2373
2464
  reject(
@@ -3008,9 +3099,10 @@ async function createThread(input, _onSetupLine) {
3008
3099
  fast: input.fast,
3009
3100
  autonomy: input.autonomy
3010
3101
  });
3011
- await requireAgent(resolved.agent);
3102
+ const acpHarness = resolved.agent === "acp" ? input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : defaultAcpHarness() : void 0;
3103
+ await requireAgent(resolved.agent, { acpHarness });
3012
3104
  if (input.cowboy) {
3013
- const { cowboyModeEnabled } = await import("./app-settings-PPIMYJKS.js");
3105
+ const { cowboyModeEnabled } = await import("./app-settings-XILTSD6L.js");
3014
3106
  if (!cowboyModeEnabled()) {
3015
3107
  throw new Error(
3016
3108
  "Cowboy mode is off. Enable it in Settings \u2192 Advanced."
@@ -3045,6 +3137,7 @@ async function createThread(input, _onSetupLine) {
3045
3137
  worktreePath: repoPath,
3046
3138
  repoPath,
3047
3139
  agent: resolved.agent,
3140
+ ...acpHarness ? { acpHarness } : {},
3048
3141
  autonomy: resolved.autonomy,
3049
3142
  model: resolved.model,
3050
3143
  effort: resolved.effort,
@@ -3069,7 +3162,7 @@ async function createThread(input, _onSetupLine) {
3069
3162
  let sourceIsFork = false;
3070
3163
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
3071
3164
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
3072
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-3HRWLQZJ.js");
3165
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-URSRZW7P.js");
3073
3166
  const task = await ensureAbleTimeTask({
3074
3167
  title: title?.trim() || "Untitled work",
3075
3168
  description: input.prompt?.trim() || void 0
@@ -3159,6 +3252,7 @@ async function createThread(input, _onSetupLine) {
3159
3252
  worktreePath,
3160
3253
  repoPath,
3161
3254
  agent: resolved.agent,
3255
+ ...acpHarness ? { acpHarness } : {},
3162
3256
  autonomy: resolved.autonomy,
3163
3257
  model: resolved.model,
3164
3258
  effort: resolved.effort,
@@ -3203,6 +3297,28 @@ function shouldRemoveWorktreeOnTeardown(thread) {
3203
3297
  return !isCowboyThread(thread) && !isPrimaryCheckoutThread(thread);
3204
3298
  }
3205
3299
 
3300
+ // src/orchestrator/thread-agent-patch.ts
3301
+ function applyThreadAgentPatch(thread, patch, next) {
3302
+ const agent = patch.agent ?? thread.agent;
3303
+ const harness = agent === "acp" ? patch.acpHarness === "gemini" || patch.acpHarness === "copilot" ? patch.acpHarness : thread.acpHarness === "gemini" || thread.acpHarness === "copilot" ? thread.acpHarness : defaultAcpHarness() : null;
3304
+ const providerChanged = agent !== thread.agent || agent === "acp" && harness !== (thread.acpHarness ?? null);
3305
+ if (providerChanged) {
3306
+ if (thread.messages.length > 0) {
3307
+ const from = thread.agent === "acp" ? thread.acpHarness === "copilot" ? "copilot" : "gemini" : thread.agent;
3308
+ const to = agent === "acp" ? harness === "copilot" ? "copilot" : "gemini" : agent;
3309
+ throw new Error(
3310
+ `Cannot switch agent provider mid-chat (${from} \u2192 ${to}). Start a new chat tab instead.`
3311
+ );
3312
+ }
3313
+ if (isOrchestratorThread(thread)) assertOrchestratorCapableAgent(agent);
3314
+ next.agent = agent;
3315
+ if (agent !== "claude" && patch.model === void 0) next.model = null;
3316
+ next.sessionId = null;
3317
+ }
3318
+ if (agent === "acp") next.acpHarness = harness;
3319
+ else if (thread.acpHarness) next.acpHarness = null;
3320
+ }
3321
+
3206
3322
  // src/archive/fleet-archive.ts
3207
3323
  import { basename as basename2 } from "path";
3208
3324
  var DEFAULT_LIMIT = 40;
@@ -3473,11 +3589,11 @@ function createLineCoalescer(onChunk, opts) {
3473
3589
  const delayMs = opts?.delayMs ?? 50;
3474
3590
  const maxLines = opts?.maxLines ?? 200;
3475
3591
  let buffer = [];
3476
- let timer2 = null;
3592
+ let timer3 = null;
3477
3593
  const flush2 = () => {
3478
- if (timer2) {
3479
- clearTimeout(timer2);
3480
- timer2 = null;
3594
+ if (timer3) {
3595
+ clearTimeout(timer3);
3596
+ timer3 = null;
3481
3597
  }
3482
3598
  if (buffer.length === 0) return;
3483
3599
  const chunk = buffer.join("\n");
@@ -3490,7 +3606,7 @@ function createLineCoalescer(onChunk, opts) {
3490
3606
  flush2();
3491
3607
  return;
3492
3608
  }
3493
- if (!timer2) timer2 = setTimeout(flush2, delayMs);
3609
+ if (!timer3) timer3 = setTimeout(flush2, delayMs);
3494
3610
  };
3495
3611
  return { push, flush: flush2 };
3496
3612
  }
@@ -3668,6 +3784,7 @@ async function forkThreadWorktree(input, onSetupLine) {
3668
3784
  sourceRef: from.branchName,
3669
3785
  repoPath: from.repoPath,
3670
3786
  agent: nextAgent,
3787
+ acpHarness: nextAgent === "acp" ? input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : from.acpHarness : void 0,
3671
3788
  autonomy: from.autonomy,
3672
3789
  model: nextModel,
3673
3790
  effort: from.effort,
@@ -3947,11 +4064,14 @@ async function adoptThread(input) {
3947
4064
  worktreePath: input.worktreePath,
3948
4065
  repoPath,
3949
4066
  agent: input.agent,
4067
+ ...input.agent === "acp" ? {
4068
+ acpHarness: input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : void 0
4069
+ } : {},
3950
4070
  sessionId: input.sessionId ?? null,
3951
4071
  messages: input.messages ?? []
3952
4072
  });
3953
4073
  writeThread(thread);
3954
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-KWGTP7DI.js");
4074
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-4PA24IX6.js");
3955
4075
  await addWorkspace2(repoPath);
3956
4076
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-KMZQXZKP.js");
3957
4077
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -6058,6 +6178,9 @@ function livePartsShowAgentReply(parts) {
6058
6178
  }
6059
6179
 
6060
6180
  // src/orchestrator/enqueue-thread-send.ts
6181
+ function sendFollowUpInterrupts(followUp, busy) {
6182
+ return followUp === "steer" && busy;
6183
+ }
6061
6184
  function resolveSendFollowUp(thread, requested) {
6062
6185
  if (requested === "steer" || requested === "queue") return requested;
6063
6186
  return isOrchestratorThread(thread) ? followUpBehavior() : "queue";
@@ -6144,14 +6267,20 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
6144
6267
  if (current.status === "archived") {
6145
6268
  throw new Error(`Thread is archived: ${thread.id}`);
6146
6269
  }
6147
- const followUp = resolveSendFollowUp(current, opts?.followUp);
6270
+ const requested = opts?.followUp;
6271
+ const join15 = requested === "join";
6272
+ const followUp = resolveSendFollowUp(
6273
+ current,
6274
+ join15 ? "steer" : requested
6275
+ );
6148
6276
  const explicit = opts?.attachments;
6149
6277
  const consumed = explicit !== void 0 ? { attachments: current.attachments, consumed: explicit } : consumeComposerAttachments(current);
6150
6278
  const inFlightEarly = host.activeTurns.has(thread.id) || host.startingTurns.has(thread.id) || current.status === "running";
6151
6279
  const agentHasRepliedEarly = livePartsShowAgentReply(readTurnLiveParts(current.id));
6152
6280
  const draft = host.openSteerPrompt.get(current.id);
6153
6281
  const queuedHead = !inFlightEarly && current.status === "queued" && current.queue.length > 0 ? current.queue[0] : null;
6154
- const unanswered = followUp === "steer" && !agentHasRepliedEarly ? draft?.text ?? (inFlightEarly ? trailingUnansweredUserText(current.messages) : queuedHead) : null;
6282
+ const joinCanMerge = draft != null && !draft.spawned || !inFlightEarly && queuedHead != null;
6283
+ const unanswered = followUp === "steer" && !agentHasRepliedEarly && (!join15 || joinCanMerge) ? draft?.text ?? (inFlightEarly ? trailingUnansweredUserText(current.messages) : queuedHead) : null;
6155
6284
  if (unanswered != null && (draft ? !draft.spawned : queuedHead != null)) {
6156
6285
  clearSendBookkeeping(host, thread.id);
6157
6286
  const combined = joinSteerPrompt(unanswered, prompt);
@@ -6202,7 +6331,10 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
6202
6331
  );
6203
6332
  clearSendBookkeeping(host, thread.id);
6204
6333
  const inFlight = host.activeTurns.has(thread.id) || host.startingTurns.has(thread.id) || current.status === "running";
6205
- shouldSteer = followUp === "steer" && (inFlight || current.queue.length > 0);
6334
+ shouldSteer = sendFollowUpInterrupts(
6335
+ join15 ? "join" : followUp,
6336
+ inFlight || current.queue.length > 0
6337
+ );
6206
6338
  const patch = queued;
6207
6339
  if (explicit === void 0 && consumed.consumed.length > 0) {
6208
6340
  patch.attachments = consumed.attachments;
@@ -6423,7 +6555,7 @@ function formatWorktreeDirective(thread, opts) {
6423
6555
  lines.push(formatDevAccessHint(opts?.activeRuns));
6424
6556
  lines.push("");
6425
6557
  lines.push(
6426
- "Automations (sidebar, after Board): `create_schedule` / `list_schedules` (`at` / `every` / `cron` / `time`+`days`). `archiveChat=false` keeps the new chat. `chatId=self` is removed when this chat is archived. Fires only while Sideboard.app is running. Future jobs turn on Caffeinate."
6558
+ "Automations (sidebar, after Board): `create_schedule` / `list_schedules` (`at` / `every` / `cron` / `time`+`days`). `archiveChat=false` keeps the new chat. `chatId=self` is removed when this chat is archived. Fires only while Sideboard.app is running. Future jobs turn on Caffeinate. `create_follow_up` (ci|at) waits behind this turn."
6427
6559
  );
6428
6560
  lines.push(
6429
6561
  "`set_workspace_tags` labels this checkout (omit ref). `set_wake_on_github_edges` opts this checkout in when Advanced is already on (omit ref)."
@@ -7541,11 +7673,11 @@ function realDeps() {
7541
7673
  parentIdForThread,
7542
7674
  designatedId: designatedOrchestratorId,
7543
7675
  send: async (threadId, prompt) => {
7544
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-4SXTORD2.js");
7676
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-QDHZ56LA.js");
7545
7677
  await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
7546
7678
  },
7547
7679
  startOrchestration: async (prompt) => {
7548
- const { startOrchestration: startOrchestration2 } = await import("./orchestrator-4SXTORD2.js");
7680
+ const { startOrchestration: startOrchestration2 } = await import("./orchestrator-QDHZ56LA.js");
7549
7681
  const defaults = resolveOrchestratorDefaults();
7550
7682
  await startOrchestration2({
7551
7683
  goal: prompt,
@@ -7572,7 +7704,7 @@ function formatScheduledPrompt(name, prompt) {
7572
7704
  ${prompt}`;
7573
7705
  }
7574
7706
  async function defaultDeps() {
7575
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-4SXTORD2.js");
7707
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-QDHZ56LA.js");
7576
7708
  const orch = getOrchestrator2();
7577
7709
  return {
7578
7710
  findThread: (id) => findThreadByRef(id),
@@ -7672,8 +7804,8 @@ async function fireSchedule(id) {
7672
7804
  }
7673
7805
  }
7674
7806
  function clearTimer(id) {
7675
- const timer2 = timers.get(id);
7676
- if (timer2) clearTimeout(timer2);
7807
+ const timer3 = timers.get(id);
7808
+ if (timer3) clearTimeout(timer3);
7677
7809
  timers.delete(id);
7678
7810
  }
7679
7811
  function armOne(schedule) {
@@ -7689,7 +7821,7 @@ function armOne(schedule) {
7689
7821
  return;
7690
7822
  }
7691
7823
  const capped = Math.min(delay, SET_TIMEOUT_MAX);
7692
- const timer2 = setTimeout(() => {
7824
+ const timer3 = setTimeout(() => {
7693
7825
  timers.delete(schedule.id);
7694
7826
  const live = getSchedule(schedule.id);
7695
7827
  if (!live?.enabled) return;
@@ -7702,7 +7834,7 @@ function armOne(schedule) {
7702
7834
  if (isThisProcessDesktopHost()) armSchedules();
7703
7835
  });
7704
7836
  }, capped);
7705
- timers.set(schedule.id, timer2);
7837
+ timers.set(schedule.id, timer3);
7706
7838
  }
7707
7839
  function armSchedules() {
7708
7840
  if (!isThisProcessDesktopHost()) return;
@@ -7719,6 +7851,75 @@ function armSchedules() {
7719
7851
  }
7720
7852
  }
7721
7853
 
7854
+ // src/orchestrator/chat-follow-up-runner.ts
7855
+ var POLL_MS = 6e4;
7856
+ var timer2 = null;
7857
+ var polling2 = false;
7858
+ async function ciPhase(thread) {
7859
+ const selector = resolvePrSelector(thread);
7860
+ if (!selector || !thread.worktreePath?.trim()) return "none";
7861
+ try {
7862
+ const checks = await getPrCiChecks(thread.worktreePath, selector);
7863
+ return ciChecksSettled(checks);
7864
+ } catch {
7865
+ return "unknown";
7866
+ }
7867
+ }
7868
+ async function pollChatFollowUps(send = defaultSend) {
7869
+ if (polling2) return;
7870
+ polling2 = true;
7871
+ try {
7872
+ const threads = listThreads().filter(
7873
+ (thread) => thread.status !== "archived" && (thread.followUps?.length ?? 0) > 0
7874
+ );
7875
+ for (const thread of threads) {
7876
+ const followUps = thread.followUps ?? [];
7877
+ const ci = followUps.some((item) => item.kind === "ci") ? await ciPhase(thread) : "none";
7878
+ const decision = decideFollowUps({ followUps, now: /* @__PURE__ */ new Date(), ci });
7879
+ const kept = [...decision.keep];
7880
+ const firedIds = [];
7881
+ for (const item of decision.fire) {
7882
+ try {
7883
+ await send(thread.id, `[Follow-up]
7884
+ ${item.prompt}`);
7885
+ firedIds.push(item.id);
7886
+ } catch {
7887
+ kept.push(item);
7888
+ }
7889
+ }
7890
+ const fresh = readThread(thread.id);
7891
+ if (!fresh || fresh.status === "archived") continue;
7892
+ const after = normalizeChatFollowUps(fresh.followUps);
7893
+ const next = mergeFollowUpPoll({
7894
+ before: followUps,
7895
+ after,
7896
+ firedIds,
7897
+ keep: kept
7898
+ });
7899
+ if (JSON.stringify(next) !== JSON.stringify(after)) {
7900
+ updateThread(thread.id, { followUps: next });
7901
+ }
7902
+ }
7903
+ } finally {
7904
+ polling2 = false;
7905
+ }
7906
+ }
7907
+ async function defaultSend(id, prompt) {
7908
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-QDHZ56LA.js");
7909
+ await getOrchestrator2().send(id, prompt, { followUp: "join" });
7910
+ }
7911
+ function armChatFollowUps() {
7912
+ if (!isThisProcessDesktopHost()) return;
7913
+ if (timer2) return;
7914
+ const tick = () => {
7915
+ timer2 = setTimeout(() => {
7916
+ void pollChatFollowUps().finally(tick);
7917
+ }, POLL_MS);
7918
+ };
7919
+ void pollChatFollowUps();
7920
+ tick();
7921
+ }
7922
+
7722
7923
  // src/orchestrator/orchestrator.ts
7723
7924
  var LIVE_TURN_SPAWN_GRACE_MS = 15e3;
7724
7925
  var RUN_SCRIPT_DESKTOP_ADOPT_MS = 2e4;
@@ -7916,6 +8117,7 @@ var Orchestrator = class {
7916
8117
  }
7917
8118
  this.schedulePendingQuotaResumes();
7918
8119
  armSchedules();
8120
+ armChatFollowUps();
7919
8121
  armGithubEdgeWatch();
7920
8122
  }
7921
8123
  /** Surface (and, when enabled, clean up) worktrees git knows about but no thread owns. */
@@ -7928,7 +8130,7 @@ var Orchestrator = class {
7928
8130
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
7929
8131
  });
7930
8132
  }
7931
- const { autoCleanupOrphansEnabled } = await import("./app-settings-PPIMYJKS.js");
8133
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-XILTSD6L.js");
7932
8134
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
7933
8135
  await cleanupOrphanWorktrees({ repoPaths });
7934
8136
  }
@@ -8055,8 +8257,8 @@ var Orchestrator = class {
8055
8257
  }
8056
8258
  }
8057
8259
  clearQuotaResumeTimer(threadId) {
8058
- const timer2 = this.quotaResumeTimers.get(threadId);
8059
- if (timer2) clearTimeout(timer2);
8260
+ const timer3 = this.quotaResumeTimers.get(threadId);
8261
+ if (timer3) clearTimeout(timer3);
8060
8262
  this.quotaResumeTimers.delete(threadId);
8061
8263
  }
8062
8264
  /** Schedule (or fire) auto-retry after a provider session/usage limit reset. */
@@ -8065,11 +8267,11 @@ var Orchestrator = class {
8065
8267
  updateThread(threadId, { quotaResumeAt: resumeAt.toISOString() });
8066
8268
  const delay = Math.max(5e3, resumeAt.getTime() - Date.now());
8067
8269
  const capped = Math.min(delay, 2147483647);
8068
- const timer2 = setTimeout(() => {
8270
+ const timer3 = setTimeout(() => {
8069
8271
  this.quotaResumeTimers.delete(threadId);
8070
8272
  void this.resumeAfterQuotaWait(threadId);
8071
8273
  }, capped);
8072
- this.quotaResumeTimers.set(threadId, timer2);
8274
+ this.quotaResumeTimers.set(threadId, timer3);
8073
8275
  }
8074
8276
  schedulePendingQuotaResumes() {
8075
8277
  for (const thread of listThreads({ includeArchived: false })) {
@@ -8318,7 +8520,7 @@ var Orchestrator = class {
8318
8520
  }
8319
8521
  await setup;
8320
8522
  if (skipSetup) return;
8321
- const { autoRunAfterSetupEnabled } = await import("./app-settings-PPIMYJKS.js");
8523
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-XILTSD6L.js");
8322
8524
  if (autoRunAfterSetupEnabled()) {
8323
8525
  try {
8324
8526
  await this.startDev(threadId);
@@ -8702,7 +8904,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8702
8904
  }
8703
8905
  const isBrightsy = fresh.agent === "brightsy";
8704
8906
  const isOrchestration = isOrchestratorThread(fresh);
8705
- const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-PPIMYJKS.js");
8907
+ const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-XILTSD6L.js");
8706
8908
  const gitAuthMode = getGithubGitAuthMode();
8707
8909
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
8708
8910
  githubSlug: turnOrigin?.forge === "github" ? turnOrigin.slug : await withTimeout(resolveGithubRepoSlug(fresh.worktreePath), 8e3, "resolveGithubRepoSlug").catch(() => null),
@@ -9714,11 +9916,11 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9714
9916
  const start = Date.now();
9715
9917
  return new Promise((resolve, reject) => {
9716
9918
  let settled = false;
9717
- let timer2;
9919
+ let timer3;
9718
9920
  const finish = (fn) => {
9719
9921
  if (settled) return;
9720
9922
  settled = true;
9721
- if (timer2) clearInterval(timer2);
9923
+ if (timer3) clearInterval(timer3);
9722
9924
  off();
9723
9925
  fn();
9724
9926
  };
@@ -9744,7 +9946,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9744
9946
  }
9745
9947
  }
9746
9948
  });
9747
- timer2 = setInterval(() => {
9949
+ timer3 = setInterval(() => {
9748
9950
  const raw = readThread(thread.id);
9749
9951
  if (!raw) {
9750
9952
  finish(() => reject(new Error(`Thread not found: ${thread.id}`)));
@@ -10043,7 +10245,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10043
10245
  if (Object.keys(patch).length === 0) continue;
10044
10246
  updateThread(t.id, patch);
10045
10247
  }
10046
- const { autoArchiveOnMergeEnabled } = await import("./app-settings-PPIMYJKS.js");
10248
+ const { autoArchiveOnMergeEnabled } = await import("./app-settings-XILTSD6L.js");
10047
10249
  const latest = this.requireThread(thread.id);
10048
10250
  if (!shouldAutoArchiveOnPrMerge({
10049
10251
  previousPrState: prevState || null,
@@ -10217,20 +10419,8 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10217
10419
  if (patch.fast !== void 0) next.fast = patch.fast;
10218
10420
  if (patch.planMode !== void 0) next.planMode = patch.planMode;
10219
10421
  if (patch.model !== void 0) next.model = patch.model;
10220
- if (patch.agent !== void 0) {
10221
- if (patch.agent !== thread.agent) {
10222
- if (thread.messages.length > 0) {
10223
- throw new Error(
10224
- `Cannot switch agent provider mid-chat (${thread.agent} \u2192 ${patch.agent}). Start a new chat tab instead.`
10225
- );
10226
- }
10227
- if (isOrchestratorThread(thread)) {
10228
- assertOrchestratorCapableAgent(patch.agent);
10229
- }
10230
- next.agent = patch.agent;
10231
- if (patch.agent !== "claude" && patch.model === void 0) next.model = null;
10232
- next.sessionId = null;
10233
- }
10422
+ if (patch.agent !== void 0 || patch.acpHarness !== void 0) {
10423
+ applyThreadAgentPatch(thread, patch, next);
10234
10424
  }
10235
10425
  return updateThread(thread.id, next);
10236
10426
  }
@@ -10317,7 +10507,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10317
10507
  this.stop(thread.id, { notifyParent: false });
10318
10508
  this.releaseOrchestratorCaffeinate(thread);
10319
10509
  if (isGlobalThread(thread)) {
10320
- const archived2 = setStatus(thread.id, "archived");
10510
+ const archived2 = archiveClearingFollowUps(thread.id);
10321
10511
  this.emit({ type: "status_changed", threadId: archived2.id, status: "archived" });
10322
10512
  this.enforceHistoryRetention();
10323
10513
  return archived2;
@@ -10336,10 +10526,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10336
10526
  });
10337
10527
  } catch {
10338
10528
  }
10339
- await removeWorktree(thread.repoPath, thread.worktreePath);
10529
+ await removeWorktreeSavingLeftovers(thread);
10340
10530
  }
10341
10531
  }
10342
- const archived = setStatus(thread.id, "archived");
10532
+ const archived = archiveClearingFollowUps(thread.id);
10343
10533
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
10344
10534
  this.enforceHistoryRetention();
10345
10535
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
@@ -10367,11 +10557,9 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10367
10557
  await runArchiveScript(thread.repoPath, thread.worktreePath);
10368
10558
  } catch {
10369
10559
  }
10370
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-PPIMYJKS.js");
10560
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-XILTSD6L.js");
10371
10561
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
10372
- await removeWorktree(thread.repoPath, thread.worktreePath, {
10373
- deleteBranch: deleteBranch ? thread.branchName : void 0
10374
- });
10562
+ await removeWorktreeDroppingLeftovers(thread, deleteBranch ? thread.branchName : void 0);
10375
10563
  }
10376
10564
  }
10377
10565
  deleteThreadRecord(thread.id);
@@ -10401,6 +10589,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10401
10589
  });
10402
10590
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-KMZQXZKP.js");
10403
10591
  await ensureWorktreeSideboardIgnored(dest);
10592
+ await applyWorktreeLeftovers(thread.repoPath, dest, thread.branchName).catch(() => false);
10404
10593
  }
10405
10594
  const restorePatch = {};
10406
10595
  let alreadyMerged = normalizePrState(thread.prState) === "MERGED";
@@ -10505,7 +10694,7 @@ async function startOrchestration(opts) {
10505
10694
  sourceRef: "default",
10506
10695
  ...createOpts
10507
10696
  }).catch(async () => {
10508
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-ROJXGBWS.js");
10697
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-4ATMCYIE.js");
10509
10698
  const repo = await resolveRepoRoot2(repoPath);
10510
10699
  const def = await resolveDefaultBranch2(repo);
10511
10700
  return orch.createThread({
@@ -10515,7 +10704,7 @@ async function startOrchestration(opts) {
10515
10704
  repoPath: repo
10516
10705
  });
10517
10706
  });
10518
- const { updateThread: upd } = await import("./thread-store-MEUWZDVV.js");
10707
+ const { updateThread: upd } = await import("./thread-store-LME2ICZP.js");
10519
10708
  const updated = upd(thread.id, {
10520
10709
  sourceType: "orchestration",
10521
10710
  sourceRef: goal