@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
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  formatOptionalServicesDirectiveForTurn,
3
3
  formatOptionalServicesReminderForTurn
4
- } from "./chunk-IVRWRYTH.js";
4
+ } from "./chunk-BZK62VPT.js";
5
5
  import {
6
6
  extractPresentedPlan,
7
7
  isPresentPlanToolName,
@@ -21,7 +21,7 @@ import {
21
21
  parseSessionQuotaResetAt,
22
22
  planModeTurnInstruction,
23
23
  resolveQuotaFallbackAgent
24
- } from "./chunk-Q4TZA4MN.js";
24
+ } from "./chunk-NDEVAA34.js";
25
25
  import {
26
26
  applyWorktreePkgCacheEnv,
27
27
  buildBrightsySessionSeed,
@@ -56,7 +56,7 @@ import {
56
56
  worktreeDevProcessKey,
57
57
  worktreeRunProcessKey,
58
58
  worktreeSetupProcessKey
59
- } from "./chunk-GAGTEI6B.js";
59
+ } from "./chunk-ZBSEJIOV.js";
60
60
  import {
61
61
  applyAgentEvent,
62
62
  clipAgentEventForPaint,
@@ -71,10 +71,18 @@ import {
71
71
  partsToAssistantText,
72
72
  stripBrightsyNdjsonNoise,
73
73
  toolDescription
74
- } from "./chunk-BIM24I3O.js";
74
+ } from "./chunk-WWBPK7GB.js";
75
+ import {
76
+ defaultAcpHarness,
77
+ detectAcpHarness,
78
+ detectAcpHarnesses
79
+ } from "./chunk-YE7Z5WH3.js";
75
80
  import {
76
81
  titleFromPrompt
77
82
  } from "./chunk-7H655NEW.js";
83
+ import {
84
+ releaseCaffeinateHoldForThread
85
+ } from "./chunk-LAWLUOWQ.js";
78
86
  import {
79
87
  SLACK_REPLY_FORMATTING,
80
88
  addWorkspace,
@@ -101,7 +109,7 @@ import {
101
109
  stageAbsolutePathsAsAttachments,
102
110
  stageBuffersAsAttachments,
103
111
  syncWorkspacesFromThreads
104
- } from "./chunk-XNGW4OYD.js";
112
+ } from "./chunk-LFSTOECH.js";
105
113
  import {
106
114
  addPrStackLayer,
107
115
  allocateTeamSlug,
@@ -154,12 +162,14 @@ import {
154
162
  resolveRepoRoot,
155
163
  switchWorktreeBranch,
156
164
  withRepoGitLock
157
- } from "./chunk-NTY5WGRD.js";
165
+ } from "./chunk-FQ3JYUKI.js";
158
166
  import {
159
167
  REVIEW_TAB_TITLE,
160
168
  agentNicknameFromWorktreePath,
161
169
  appendMessage,
170
+ ciChecksSettled,
162
171
  createEmptyThread,
172
+ decideFollowUps,
163
173
  deleteSchedule,
164
174
  deleteThreadRecord,
165
175
  findThreadByRef,
@@ -171,6 +181,8 @@ import {
171
181
  isWorktreeIdentityTitle,
172
182
  listSchedules,
173
183
  listThreads,
184
+ mergeFollowUpPoll,
185
+ normalizeChatFollowUps,
174
186
  normalizeWorkspaceTags,
175
187
  normalizeWorktreePath,
176
188
  readThread,
@@ -186,7 +198,7 @@ import {
186
198
  worktreeNameFromPath,
187
199
  worktreeSlugForTicket,
188
200
  writeThread
189
- } from "./chunk-ATS7SYHG.js";
201
+ } from "./chunk-TCEUNSLX.js";
190
202
  import {
191
203
  askBlockStillWaiting,
192
204
  extractPendingPlanQuestions,
@@ -204,7 +216,7 @@ import {
204
216
  import {
205
217
  applyAgentRunnerHeapEnv,
206
218
  packagedMcpDir
207
- } from "./chunk-UGUWFONI.js";
219
+ } from "./chunk-2E2HMJDU.js";
208
220
  import {
209
221
  fallbackTurnFailDetail,
210
222
  formatAgentErrorContinuePrompt,
@@ -219,7 +231,7 @@ import {
219
231
  shouldRetryFailedAgentTurn,
220
232
  summarizeTurnStderr,
221
233
  turnFailChatText
222
- } from "./chunk-OPXEJJBM.js";
234
+ } from "./chunk-PWOFUPYM.js";
223
235
  import {
224
236
  clearStaleIndexLocks,
225
237
  enrichPathWithNpmGlobalBin,
@@ -264,7 +276,10 @@ import {
264
276
  wakeOrchestratorOnGithubEdgesEnabled,
265
277
  withTurnScopedCost,
266
278
  writeViewerContext
267
- } from "./chunk-6WMNIX2U.js";
279
+ } from "./chunk-UFUAIVNV.js";
280
+ import {
281
+ writePrivateFile
282
+ } from "./chunk-JT7R45JB.js";
268
283
  import {
269
284
  examplePrefixedBranch,
270
285
  sanitizeGitBranchPrefix
@@ -275,12 +290,6 @@ import {
275
290
  nextManagedAccount,
276
291
  resolveAccountForThread
277
292
  } from "./chunk-KI45T4DI.js";
278
- import {
279
- releaseCaffeinateHoldForThread
280
- } from "./chunk-LAWLUOWQ.js";
281
- import {
282
- writePrivateFile
283
- } from "./chunk-JT7R45JB.js";
284
293
  import {
285
294
  annotateDevAccessRuns,
286
295
  appDataDir,
@@ -394,19 +403,19 @@ function traceTurn(phase, extra) {
394
403
  }
395
404
  }
396
405
  async function withTimeout(promise, ms, label) {
397
- let timer2;
406
+ let timer3;
398
407
  try {
399
408
  return await Promise.race([
400
409
  promise,
401
410
  new Promise((_, reject) => {
402
- timer2 = setTimeout(
411
+ timer3 = setTimeout(
403
412
  () => reject(new Error(`${label} timed out after ${ms}ms`)),
404
413
  ms
405
414
  );
406
415
  })
407
416
  ]);
408
417
  } finally {
409
- if (timer2) clearTimeout(timer2);
418
+ if (timer3) clearTimeout(timer3);
410
419
  }
411
420
  }
412
421
 
@@ -527,9 +536,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
527
536
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
528
537
  );
529
538
  }
530
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-UG2A3CEM.js");
539
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-4RDPAOTT.js");
531
540
  if (isGlobalThread2(thread)) {
532
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-DLY3FS2L.js");
541
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-DPO7L2JO.js");
533
542
  ensureGlobalCoordinatorCwd2(
534
543
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
535
544
  );
@@ -727,14 +736,97 @@ async function spawnAgentTurn(thread, input, onEvent) {
727
736
  }
728
737
  };
729
738
  signal("SIGTERM");
730
- const timer2 = setTimeout(() => signal("SIGKILL"), 5e3);
731
- timer2.unref?.();
732
- child.once("exit", () => clearTimeout(timer2));
739
+ const timer3 = setTimeout(() => signal("SIGKILL"), 5e3);
740
+ timer3.unref?.();
741
+ child.once("exit", () => clearTimeout(timer3));
733
742
  },
734
743
  done
735
744
  };
736
745
  }
737
746
 
747
+ // src/git/worktree-leftovers.ts
748
+ var LEFTOVER_REF_PREFIX = "refs/sideboard/leftovers/";
749
+ function leftoverRefName(branch) {
750
+ const safe = branch.trim().replace(/[^A-Za-z0-9._/-]+/g, "-") || "branch";
751
+ return `${LEFTOVER_REF_PREFIX}${safe}`;
752
+ }
753
+ function gitFailure(result, fallback) {
754
+ const text3 = (result.stderr || result.stdout).trim();
755
+ return text3 || fallback;
756
+ }
757
+ async function restoreIndex(worktreePath, treeSha) {
758
+ await git(["read-tree", "--reset", treeSha], worktreePath, { reject: false });
759
+ }
760
+ async function saveWorktreeLeftovers(repoPath, worktreePath, branch) {
761
+ const status = await git(["status", "--porcelain"], worktreePath, { reject: false });
762
+ if (status.exitCode !== 0) {
763
+ return { ok: false, error: gitFailure(status, "git status failed") };
764
+ }
765
+ if (!status.stdout.trim()) return { ok: true, ref: null };
766
+ const indexBefore = await git(["write-tree"], worktreePath, { reject: false });
767
+ const indexSha = indexBefore.stdout.trim();
768
+ if (indexBefore.exitCode !== 0 || !/^[0-9a-f]{7,64}$/i.test(indexSha)) {
769
+ return { ok: false, error: gitFailure(indexBefore, "git write-tree failed") };
770
+ }
771
+ const fail = async (result, fallback) => {
772
+ await restoreIndex(worktreePath, indexSha);
773
+ return { ok: false, error: gitFailure(result, fallback) };
774
+ };
775
+ const added = await git(["add", "-A"], worktreePath, { reject: false });
776
+ if (added.exitCode !== 0) return fail(added, "git add failed");
777
+ const tree = await git(["write-tree"], worktreePath, { reject: false });
778
+ const treeSha = tree.stdout.trim();
779
+ if (tree.exitCode !== 0 || !/^[0-9a-f]{7,64}$/i.test(treeSha)) {
780
+ return fail(tree, "git write-tree failed");
781
+ }
782
+ const head = await git(["rev-parse", "HEAD"], worktreePath, { reject: false });
783
+ const parent = head.stdout.trim();
784
+ if (head.exitCode !== 0 || !parent) return fail(head, "git rev-parse HEAD failed");
785
+ const commit = await git(
786
+ ["commit-tree", treeSha, "-p", parent, "-m", "sideboard leftover"],
787
+ worktreePath,
788
+ { reject: false }
789
+ );
790
+ const sha = commit.stdout.trim();
791
+ if (commit.exitCode !== 0 || !/^[0-9a-f]{7,64}$/i.test(sha)) {
792
+ return fail(commit, "git commit-tree failed");
793
+ }
794
+ const ref = leftoverRefName(branch);
795
+ const updated = await git(["update-ref", ref, sha], repoPath, { reject: false });
796
+ if (updated.exitCode !== 0) return fail(updated, "git update-ref failed");
797
+ await git(["reset"], worktreePath, { reject: false });
798
+ return { ok: true, ref };
799
+ }
800
+ async function applyWorktreeLeftovers(repoPath, worktreePath, branch) {
801
+ const ref = leftoverRefName(branch);
802
+ const shown = await git(["rev-parse", "--verify", "--quiet", ref], repoPath, { reject: false });
803
+ const sha = shown.stdout.trim();
804
+ if (shown.exitCode !== 0 || !sha) return false;
805
+ const restored = await git(["restore", "--source", sha, "--worktree", "--", "."], worktreePath, {
806
+ reject: false
807
+ });
808
+ if (restored.exitCode !== 0) return false;
809
+ await git(["update-ref", "-d", ref], repoPath, { reject: false });
810
+ return true;
811
+ }
812
+ async function deleteWorktreeLeftovers(repoPath, branch) {
813
+ await git(["update-ref", "-d", leftoverRefName(branch)], repoPath, { reject: false });
814
+ }
815
+ function archiveClearingFollowUps(id) {
816
+ const archived = setStatus(id, "archived");
817
+ if ((archived.followUps?.length ?? 0) === 0) return archived;
818
+ return updateThread(archived.id, { followUps: [] });
819
+ }
820
+ async function removeWorktreeSavingLeftovers(thread) {
821
+ const saved = await saveWorktreeLeftovers(thread.repoPath, thread.worktreePath, thread.branchName);
822
+ if (!saved.ok) throw new Error(`Could not save uncommitted files: ${saved.error}`);
823
+ await removeWorktree(thread.repoPath, thread.worktreePath);
824
+ }
825
+ async function removeWorktreeDroppingLeftovers(thread, deleteBranch) {
826
+ await removeWorktree(thread.repoPath, thread.worktreePath, { deleteBranch });
827
+ await deleteWorktreeLeftovers(thread.repoPath, thread.branchName).catch(() => void 0);
828
+ }
829
+
738
830
  // src/git/agent-git-actions.ts
739
831
  var AGENT_GIT_ACTIONS = [
740
832
  "commit-push",
@@ -1079,9 +1171,9 @@ function mergeSetupOutput(prev, incoming) {
1079
1171
  }
1080
1172
  var PERSIST_DEBOUNCE_MS = 500;
1081
1173
  function persistNow(threadId) {
1082
- const timer2 = persistTimers.get(threadId);
1083
- if (timer2) {
1084
- clearTimeout(timer2);
1174
+ const timer3 = persistTimers.get(threadId);
1175
+ if (timer3) {
1176
+ clearTimeout(timer3);
1085
1177
  persistTimers.delete(threadId);
1086
1178
  }
1087
1179
  const mem = memory.get(threadId);
@@ -1230,9 +1322,9 @@ function sliceRunLogOutput(output, tailChars = DEFAULT_RUN_LOG_TAIL_CHARS) {
1230
1322
  }
1231
1323
  var PERSIST_DEBOUNCE_MS2 = 500;
1232
1324
  function persistNow2(key) {
1233
- const timer2 = persistTimers2.get(key);
1234
- if (timer2) {
1235
- clearTimeout(timer2);
1325
+ const timer3 = persistTimers2.get(key);
1326
+ if (timer3) {
1327
+ clearTimeout(timer3);
1236
1328
  persistTimers2.delete(key);
1237
1329
  }
1238
1330
  const mem = memory2.get(key);
@@ -2489,14 +2581,16 @@ import { existsSync as existsSync5 } from "fs";
2489
2581
  async function detectAgents() {
2490
2582
  ensureAgentPath();
2491
2583
  enrichPathWithNpmGlobalBin();
2492
- return Promise.all(allAdapters().map((a) => a.detect()));
2584
+ const adapters = allAdapters().filter((adapter) => adapter.kind !== "acp");
2585
+ const rows = await Promise.all(adapters.map((adapter) => adapter.detect()));
2586
+ return [...rows, ...await detectAcpHarnesses()];
2493
2587
  }
2494
2588
  var REQUIRE_AGENT_TIMEOUT_MS = 8e3;
2495
2589
  async function requireAgent(agent, opts) {
2496
2590
  ensureAgentPath();
2497
2591
  enrichPathWithNpmGlobalBin();
2498
2592
  const status = await Promise.race([
2499
- getAdapter(agent).detect(),
2593
+ agent === "acp" ? detectAcpHarness(opts?.acpHarness ?? defaultAcpHarness()) : getAdapter(agent).detect(),
2500
2594
  new Promise((_, reject) => {
2501
2595
  setTimeout(() => {
2502
2596
  reject(
@@ -3311,9 +3405,10 @@ async function createThread(input, _onSetupLine) {
3311
3405
  fast: input.fast,
3312
3406
  autonomy: input.autonomy
3313
3407
  });
3314
- await requireAgent(resolved.agent);
3408
+ const acpHarness = resolved.agent === "acp" ? input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : defaultAcpHarness() : void 0;
3409
+ await requireAgent(resolved.agent, { acpHarness });
3315
3410
  if (input.cowboy) {
3316
- const { cowboyModeEnabled } = await import("./app-settings-SNOPJ7P5.js");
3411
+ const { cowboyModeEnabled } = await import("./app-settings-IA7ZZKWQ.js");
3317
3412
  if (!cowboyModeEnabled()) {
3318
3413
  throw new Error(
3319
3414
  "Cowboy mode is off. Enable it in Settings \u2192 Advanced."
@@ -3348,6 +3443,7 @@ async function createThread(input, _onSetupLine) {
3348
3443
  worktreePath: repoPath,
3349
3444
  repoPath,
3350
3445
  agent: resolved.agent,
3446
+ ...acpHarness ? { acpHarness } : {},
3351
3447
  autonomy: resolved.autonomy,
3352
3448
  model: resolved.model,
3353
3449
  effort: resolved.effort,
@@ -3372,7 +3468,7 @@ async function createThread(input, _onSetupLine) {
3372
3468
  let sourceIsFork = false;
3373
3469
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
3374
3470
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
3375
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-CGFJZB7L.js");
3471
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-TX7BTTR2.js");
3376
3472
  const task = await ensureAbleTimeTask({
3377
3473
  title: title?.trim() || "Untitled work",
3378
3474
  description: input.prompt?.trim() || void 0
@@ -3462,6 +3558,7 @@ async function createThread(input, _onSetupLine) {
3462
3558
  worktreePath,
3463
3559
  repoPath,
3464
3560
  agent: resolved.agent,
3561
+ ...acpHarness ? { acpHarness } : {},
3465
3562
  autonomy: resolved.autonomy,
3466
3563
  model: resolved.model,
3467
3564
  effort: resolved.effort,
@@ -3483,7 +3580,7 @@ async function createThread(input, _onSetupLine) {
3483
3580
  return readThread(thread.id) ?? thread;
3484
3581
  }
3485
3582
  async function listLinearIssues(agent, repoPath) {
3486
- const { getAdapter: getAdapter2 } = await import("./agents-5MFGVK7C.js");
3583
+ const { getAdapter: getAdapter2 } = await import("./agents-RGAV5OHD.js");
3487
3584
  await requireAgent(agent, { requireLinear: true });
3488
3585
  const adapter = getAdapter2(agent);
3489
3586
  if (!adapter.listLinearIssues) {
@@ -3515,6 +3612,28 @@ function shouldRemoveWorktreeOnTeardown(thread) {
3515
3612
  return !isCowboyThread(thread) && !isPrimaryCheckoutThread(thread);
3516
3613
  }
3517
3614
 
3615
+ // src/orchestrator/thread-agent-patch.ts
3616
+ function applyThreadAgentPatch(thread, patch, next) {
3617
+ const agent = patch.agent ?? thread.agent;
3618
+ const harness = agent === "acp" ? patch.acpHarness === "gemini" || patch.acpHarness === "copilot" ? patch.acpHarness : thread.acpHarness === "gemini" || thread.acpHarness === "copilot" ? thread.acpHarness : defaultAcpHarness() : null;
3619
+ const providerChanged = agent !== thread.agent || agent === "acp" && harness !== (thread.acpHarness ?? null);
3620
+ if (providerChanged) {
3621
+ if (thread.messages.length > 0) {
3622
+ const from = thread.agent === "acp" ? thread.acpHarness === "copilot" ? "copilot" : "gemini" : thread.agent;
3623
+ const to = agent === "acp" ? harness === "copilot" ? "copilot" : "gemini" : agent;
3624
+ throw new Error(
3625
+ `Cannot switch agent provider mid-chat (${from} \u2192 ${to}). Start a new chat tab instead.`
3626
+ );
3627
+ }
3628
+ if (isOrchestratorThread(thread)) assertOrchestratorCapableAgent(agent);
3629
+ next.agent = agent;
3630
+ if (agent !== "claude" && patch.model === void 0) next.model = null;
3631
+ next.sessionId = null;
3632
+ }
3633
+ if (agent === "acp") next.acpHarness = harness;
3634
+ else if (thread.acpHarness) next.acpHarness = null;
3635
+ }
3636
+
3518
3637
  // src/archive/fleet-archive.ts
3519
3638
  import { basename as basename2 } from "path";
3520
3639
  var DEFAULT_LIMIT = 40;
@@ -3785,11 +3904,11 @@ function createLineCoalescer(onChunk, opts) {
3785
3904
  const delayMs = opts?.delayMs ?? 50;
3786
3905
  const maxLines = opts?.maxLines ?? 200;
3787
3906
  let buffer = [];
3788
- let timer2 = null;
3907
+ let timer3 = null;
3789
3908
  const flush2 = () => {
3790
- if (timer2) {
3791
- clearTimeout(timer2);
3792
- timer2 = null;
3909
+ if (timer3) {
3910
+ clearTimeout(timer3);
3911
+ timer3 = null;
3793
3912
  }
3794
3913
  if (buffer.length === 0) return;
3795
3914
  const chunk = buffer.join("\n");
@@ -3802,7 +3921,7 @@ function createLineCoalescer(onChunk, opts) {
3802
3921
  flush2();
3803
3922
  return;
3804
3923
  }
3805
- if (!timer2) timer2 = setTimeout(flush2, delayMs);
3924
+ if (!timer3) timer3 = setTimeout(flush2, delayMs);
3806
3925
  };
3807
3926
  return { push, flush: flush2 };
3808
3927
  }
@@ -3983,6 +4102,7 @@ async function forkThreadWorktree(input, onSetupLine) {
3983
4102
  sourceRef: from.branchName,
3984
4103
  repoPath: from.repoPath,
3985
4104
  agent: nextAgent,
4105
+ acpHarness: nextAgent === "acp" ? input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : from.acpHarness : void 0,
3986
4106
  autonomy: from.autonomy,
3987
4107
  model: nextModel,
3988
4108
  effort: from.effort,
@@ -4262,11 +4382,14 @@ async function adoptThread(input) {
4262
4382
  worktreePath: input.worktreePath,
4263
4383
  repoPath,
4264
4384
  agent: input.agent,
4385
+ ...input.agent === "acp" ? {
4386
+ acpHarness: input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : void 0
4387
+ } : {},
4265
4388
  sessionId: input.sessionId ?? null,
4266
4389
  messages: input.messages ?? []
4267
4390
  });
4268
4391
  writeThread(thread);
4269
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-35T6FW57.js");
4392
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-6TMYV4N2.js");
4270
4393
  await addWorkspace2(repoPath);
4271
4394
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-YQBN43QD.js");
4272
4395
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -6386,6 +6509,9 @@ function livePartsShowAgentReply(parts) {
6386
6509
  }
6387
6510
 
6388
6511
  // src/orchestrator/enqueue-thread-send.ts
6512
+ function sendFollowUpInterrupts(followUp, busy) {
6513
+ return followUp === "steer" && busy;
6514
+ }
6389
6515
  function resolveSendFollowUp(thread, requested) {
6390
6516
  if (requested === "steer" || requested === "queue") return requested;
6391
6517
  return isOrchestratorThread(thread) ? followUpBehavior() : "queue";
@@ -6472,14 +6598,20 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
6472
6598
  if (current.status === "archived") {
6473
6599
  throw new Error(`Thread is archived: ${thread.id}`);
6474
6600
  }
6475
- const followUp = resolveSendFollowUp(current, opts?.followUp);
6601
+ const requested = opts?.followUp;
6602
+ const join15 = requested === "join";
6603
+ const followUp = resolveSendFollowUp(
6604
+ current,
6605
+ join15 ? "steer" : requested
6606
+ );
6476
6607
  const explicit = opts?.attachments;
6477
6608
  const consumed = explicit !== void 0 ? { attachments: current.attachments, consumed: explicit } : consumeComposerAttachments(current);
6478
6609
  const inFlightEarly = host.activeTurns.has(thread.id) || host.startingTurns.has(thread.id) || current.status === "running";
6479
6610
  const agentHasRepliedEarly = livePartsShowAgentReply(readTurnLiveParts(current.id));
6480
6611
  const draft = host.openSteerPrompt.get(current.id);
6481
6612
  const queuedHead = !inFlightEarly && current.status === "queued" && current.queue.length > 0 ? current.queue[0] : null;
6482
- const unanswered = followUp === "steer" && !agentHasRepliedEarly ? draft?.text ?? (inFlightEarly ? trailingUnansweredUserText(current.messages) : queuedHead) : null;
6613
+ const joinCanMerge = draft != null && !draft.spawned || !inFlightEarly && queuedHead != null;
6614
+ const unanswered = followUp === "steer" && !agentHasRepliedEarly && (!join15 || joinCanMerge) ? draft?.text ?? (inFlightEarly ? trailingUnansweredUserText(current.messages) : queuedHead) : null;
6483
6615
  if (unanswered != null && (draft ? !draft.spawned : queuedHead != null)) {
6484
6616
  clearSendBookkeeping(host, thread.id);
6485
6617
  const combined = joinSteerPrompt(unanswered, prompt);
@@ -6530,7 +6662,10 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
6530
6662
  );
6531
6663
  clearSendBookkeeping(host, thread.id);
6532
6664
  const inFlight = host.activeTurns.has(thread.id) || host.startingTurns.has(thread.id) || current.status === "running";
6533
- shouldSteer = followUp === "steer" && (inFlight || current.queue.length > 0);
6665
+ shouldSteer = sendFollowUpInterrupts(
6666
+ join15 ? "join" : followUp,
6667
+ inFlight || current.queue.length > 0
6668
+ );
6534
6669
  const patch = queued;
6535
6670
  if (explicit === void 0 && consumed.consumed.length > 0) {
6536
6671
  patch.attachments = consumed.attachments;
@@ -6751,7 +6886,7 @@ function formatWorktreeDirective(thread, opts) {
6751
6886
  lines.push(formatDevAccessHint(opts?.activeRuns));
6752
6887
  lines.push("");
6753
6888
  lines.push(
6754
- "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."
6889
+ "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."
6755
6890
  );
6756
6891
  lines.push(
6757
6892
  "`set_workspace_tags` labels this checkout (omit ref). `set_wake_on_github_edges` opts this checkout in when Advanced is already on (omit ref)."
@@ -7891,11 +8026,11 @@ function realDeps() {
7891
8026
  parentIdForThread,
7892
8027
  designatedId: designatedOrchestratorId,
7893
8028
  send: async (threadId, prompt) => {
7894
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
8029
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-3I2FLEZL.js");
7895
8030
  await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
7896
8031
  },
7897
8032
  startOrchestration: async (prompt) => {
7898
- const { startOrchestration: startOrchestration2 } = await import("./orchestrator-KNOMW5CZ.js");
8033
+ const { startOrchestration: startOrchestration2 } = await import("./orchestrator-3I2FLEZL.js");
7899
8034
  const defaults = resolveOrchestratorDefaults();
7900
8035
  await startOrchestration2({
7901
8036
  goal: prompt,
@@ -7922,7 +8057,7 @@ function formatScheduledPrompt(name, prompt) {
7922
8057
  ${prompt}`;
7923
8058
  }
7924
8059
  async function defaultDeps() {
7925
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-KNOMW5CZ.js");
8060
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-3I2FLEZL.js");
7926
8061
  const orch = getOrchestrator2();
7927
8062
  return {
7928
8063
  findThread: (id) => findThreadByRef(id),
@@ -8022,8 +8157,8 @@ async function fireSchedule(id) {
8022
8157
  }
8023
8158
  }
8024
8159
  function clearTimer(id) {
8025
- const timer2 = timers.get(id);
8026
- if (timer2) clearTimeout(timer2);
8160
+ const timer3 = timers.get(id);
8161
+ if (timer3) clearTimeout(timer3);
8027
8162
  timers.delete(id);
8028
8163
  }
8029
8164
  function armOne(schedule) {
@@ -8039,7 +8174,7 @@ function armOne(schedule) {
8039
8174
  return;
8040
8175
  }
8041
8176
  const capped = Math.min(delay, SET_TIMEOUT_MAX);
8042
- const timer2 = setTimeout(() => {
8177
+ const timer3 = setTimeout(() => {
8043
8178
  timers.delete(schedule.id);
8044
8179
  const live = getSchedule(schedule.id);
8045
8180
  if (!live?.enabled) return;
@@ -8052,7 +8187,7 @@ function armOne(schedule) {
8052
8187
  if (isThisProcessDesktopHost()) armSchedules();
8053
8188
  });
8054
8189
  }, capped);
8055
- timers.set(schedule.id, timer2);
8190
+ timers.set(schedule.id, timer3);
8056
8191
  }
8057
8192
  function armSchedules() {
8058
8193
  if (!isThisProcessDesktopHost()) return;
@@ -8069,6 +8204,75 @@ function armSchedules() {
8069
8204
  }
8070
8205
  }
8071
8206
 
8207
+ // src/orchestrator/chat-follow-up-runner.ts
8208
+ var POLL_MS = 6e4;
8209
+ var timer2 = null;
8210
+ var polling2 = false;
8211
+ async function ciPhase(thread) {
8212
+ const selector = resolvePrSelector(thread);
8213
+ if (!selector || !thread.worktreePath?.trim()) return "none";
8214
+ try {
8215
+ const checks = await getPrCiChecks(thread.worktreePath, selector);
8216
+ return ciChecksSettled(checks);
8217
+ } catch {
8218
+ return "unknown";
8219
+ }
8220
+ }
8221
+ async function pollChatFollowUps(send = defaultSend) {
8222
+ if (polling2) return;
8223
+ polling2 = true;
8224
+ try {
8225
+ const threads = listThreads().filter(
8226
+ (thread) => thread.status !== "archived" && (thread.followUps?.length ?? 0) > 0
8227
+ );
8228
+ for (const thread of threads) {
8229
+ const followUps = thread.followUps ?? [];
8230
+ const ci = followUps.some((item) => item.kind === "ci") ? await ciPhase(thread) : "none";
8231
+ const decision = decideFollowUps({ followUps, now: /* @__PURE__ */ new Date(), ci });
8232
+ const kept = [...decision.keep];
8233
+ const firedIds = [];
8234
+ for (const item of decision.fire) {
8235
+ try {
8236
+ await send(thread.id, `[Follow-up]
8237
+ ${item.prompt}`);
8238
+ firedIds.push(item.id);
8239
+ } catch {
8240
+ kept.push(item);
8241
+ }
8242
+ }
8243
+ const fresh = readThread(thread.id);
8244
+ if (!fresh || fresh.status === "archived") continue;
8245
+ const after = normalizeChatFollowUps(fresh.followUps);
8246
+ const next = mergeFollowUpPoll({
8247
+ before: followUps,
8248
+ after,
8249
+ firedIds,
8250
+ keep: kept
8251
+ });
8252
+ if (JSON.stringify(next) !== JSON.stringify(after)) {
8253
+ updateThread(thread.id, { followUps: next });
8254
+ }
8255
+ }
8256
+ } finally {
8257
+ polling2 = false;
8258
+ }
8259
+ }
8260
+ async function defaultSend(id, prompt) {
8261
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-3I2FLEZL.js");
8262
+ await getOrchestrator2().send(id, prompt, { followUp: "join" });
8263
+ }
8264
+ function armChatFollowUps() {
8265
+ if (!isThisProcessDesktopHost()) return;
8266
+ if (timer2) return;
8267
+ const tick = () => {
8268
+ timer2 = setTimeout(() => {
8269
+ void pollChatFollowUps().finally(tick);
8270
+ }, POLL_MS);
8271
+ };
8272
+ void pollChatFollowUps();
8273
+ tick();
8274
+ }
8275
+
8072
8276
  // src/orchestrator/orchestrator.ts
8073
8277
  var LIVE_TURN_SPAWN_GRACE_MS = 15e3;
8074
8278
  var RUN_SCRIPT_DESKTOP_ADOPT_MS = 2e4;
@@ -8266,6 +8470,7 @@ var Orchestrator = class {
8266
8470
  }
8267
8471
  this.schedulePendingQuotaResumes();
8268
8472
  armSchedules();
8473
+ armChatFollowUps();
8269
8474
  armGithubEdgeWatch();
8270
8475
  }
8271
8476
  /** Surface (and, when enabled, clean up) worktrees git knows about but no thread owns. */
@@ -8278,7 +8483,7 @@ var Orchestrator = class {
8278
8483
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
8279
8484
  });
8280
8485
  }
8281
- const { autoCleanupOrphansEnabled } = await import("./app-settings-SNOPJ7P5.js");
8486
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-IA7ZZKWQ.js");
8282
8487
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
8283
8488
  await cleanupOrphanWorktrees({ repoPaths });
8284
8489
  }
@@ -8405,8 +8610,8 @@ var Orchestrator = class {
8405
8610
  }
8406
8611
  }
8407
8612
  clearQuotaResumeTimer(threadId) {
8408
- const timer2 = this.quotaResumeTimers.get(threadId);
8409
- if (timer2) clearTimeout(timer2);
8613
+ const timer3 = this.quotaResumeTimers.get(threadId);
8614
+ if (timer3) clearTimeout(timer3);
8410
8615
  this.quotaResumeTimers.delete(threadId);
8411
8616
  }
8412
8617
  /** Schedule (or fire) auto-retry after a provider session/usage limit reset. */
@@ -8415,11 +8620,11 @@ var Orchestrator = class {
8415
8620
  updateThread(threadId, { quotaResumeAt: resumeAt.toISOString() });
8416
8621
  const delay = Math.max(5e3, resumeAt.getTime() - Date.now());
8417
8622
  const capped = Math.min(delay, 2147483647);
8418
- const timer2 = setTimeout(() => {
8623
+ const timer3 = setTimeout(() => {
8419
8624
  this.quotaResumeTimers.delete(threadId);
8420
8625
  void this.resumeAfterQuotaWait(threadId);
8421
8626
  }, capped);
8422
- this.quotaResumeTimers.set(threadId, timer2);
8627
+ this.quotaResumeTimers.set(threadId, timer3);
8423
8628
  }
8424
8629
  schedulePendingQuotaResumes() {
8425
8630
  for (const thread of listThreads({ includeArchived: false })) {
@@ -8668,7 +8873,7 @@ var Orchestrator = class {
8668
8873
  }
8669
8874
  await setup;
8670
8875
  if (skipSetup) return;
8671
- const { autoRunAfterSetupEnabled } = await import("./app-settings-SNOPJ7P5.js");
8876
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-IA7ZZKWQ.js");
8672
8877
  if (autoRunAfterSetupEnabled()) {
8673
8878
  try {
8674
8879
  await this.startDev(threadId);
@@ -9052,7 +9257,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9052
9257
  }
9053
9258
  const isBrightsy = fresh.agent === "brightsy";
9054
9259
  const isOrchestration = isOrchestratorThread(fresh);
9055
- const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-SNOPJ7P5.js");
9260
+ const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-IA7ZZKWQ.js");
9056
9261
  const gitAuthMode = getGithubGitAuthMode();
9057
9262
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
9058
9263
  githubSlug: turnOrigin?.forge === "github" ? turnOrigin.slug : await withTimeout(resolveGithubRepoSlug(fresh.worktreePath), 8e3, "resolveGithubRepoSlug").catch(() => null),
@@ -10064,11 +10269,11 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10064
10269
  const start = Date.now();
10065
10270
  return new Promise((resolve, reject) => {
10066
10271
  let settled = false;
10067
- let timer2;
10272
+ let timer3;
10068
10273
  const finish2 = (fn) => {
10069
10274
  if (settled) return;
10070
10275
  settled = true;
10071
- if (timer2) clearInterval(timer2);
10276
+ if (timer3) clearInterval(timer3);
10072
10277
  off();
10073
10278
  fn();
10074
10279
  };
@@ -10094,7 +10299,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10094
10299
  }
10095
10300
  }
10096
10301
  });
10097
- timer2 = setInterval(() => {
10302
+ timer3 = setInterval(() => {
10098
10303
  const raw = readThread(thread.id);
10099
10304
  if (!raw) {
10100
10305
  finish2(() => reject(new Error(`Thread not found: ${thread.id}`)));
@@ -10393,7 +10598,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10393
10598
  if (Object.keys(patch).length === 0) continue;
10394
10599
  updateThread(t.id, patch);
10395
10600
  }
10396
- const { autoArchiveOnMergeEnabled } = await import("./app-settings-SNOPJ7P5.js");
10601
+ const { autoArchiveOnMergeEnabled } = await import("./app-settings-IA7ZZKWQ.js");
10397
10602
  const latest = this.requireThread(thread.id);
10398
10603
  if (!shouldAutoArchiveOnPrMerge({
10399
10604
  previousPrState: prevState || null,
@@ -10567,20 +10772,8 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10567
10772
  if (patch.fast !== void 0) next.fast = patch.fast;
10568
10773
  if (patch.planMode !== void 0) next.planMode = patch.planMode;
10569
10774
  if (patch.model !== void 0) next.model = patch.model;
10570
- if (patch.agent !== void 0) {
10571
- if (patch.agent !== thread.agent) {
10572
- if (thread.messages.length > 0) {
10573
- throw new Error(
10574
- `Cannot switch agent provider mid-chat (${thread.agent} \u2192 ${patch.agent}). Start a new chat tab instead.`
10575
- );
10576
- }
10577
- if (isOrchestratorThread(thread)) {
10578
- assertOrchestratorCapableAgent(patch.agent);
10579
- }
10580
- next.agent = patch.agent;
10581
- if (patch.agent !== "claude" && patch.model === void 0) next.model = null;
10582
- next.sessionId = null;
10583
- }
10775
+ if (patch.agent !== void 0 || patch.acpHarness !== void 0) {
10776
+ applyThreadAgentPatch(thread, patch, next);
10584
10777
  }
10585
10778
  return updateThread(thread.id, next);
10586
10779
  }
@@ -10667,7 +10860,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10667
10860
  this.stop(thread.id, { notifyParent: false });
10668
10861
  this.releaseOrchestratorCaffeinate(thread);
10669
10862
  if (isGlobalThread(thread)) {
10670
- const archived2 = setStatus(thread.id, "archived");
10863
+ const archived2 = archiveClearingFollowUps(thread.id);
10671
10864
  this.emit({ type: "status_changed", threadId: archived2.id, status: "archived" });
10672
10865
  this.enforceHistoryRetention();
10673
10866
  return archived2;
@@ -10686,10 +10879,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10686
10879
  });
10687
10880
  } catch {
10688
10881
  }
10689
- await removeWorktree(thread.repoPath, thread.worktreePath);
10882
+ await removeWorktreeSavingLeftovers(thread);
10690
10883
  }
10691
10884
  }
10692
- const archived = setStatus(thread.id, "archived");
10885
+ const archived = archiveClearingFollowUps(thread.id);
10693
10886
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
10694
10887
  this.enforceHistoryRetention();
10695
10888
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
@@ -10717,11 +10910,9 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10717
10910
  await runArchiveScript(thread.repoPath, thread.worktreePath);
10718
10911
  } catch {
10719
10912
  }
10720
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-SNOPJ7P5.js");
10913
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-IA7ZZKWQ.js");
10721
10914
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
10722
- await removeWorktree(thread.repoPath, thread.worktreePath, {
10723
- deleteBranch: deleteBranch ? thread.branchName : void 0
10724
- });
10915
+ await removeWorktreeDroppingLeftovers(thread, deleteBranch ? thread.branchName : void 0);
10725
10916
  }
10726
10917
  }
10727
10918
  deleteThreadRecord(thread.id);
@@ -10751,6 +10942,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10751
10942
  });
10752
10943
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-YQBN43QD.js");
10753
10944
  await ensureWorktreeSideboardIgnored(dest);
10945
+ await applyWorktreeLeftovers(thread.repoPath, dest, thread.branchName).catch(() => false);
10754
10946
  }
10755
10947
  const restorePatch = {};
10756
10948
  let alreadyMerged = normalizePrState(thread.prState) === "MERGED";
@@ -10855,7 +11047,7 @@ async function startOrchestration(opts) {
10855
11047
  sourceRef: "default",
10856
11048
  ...createOpts
10857
11049
  }).catch(async () => {
10858
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-5P7SCST3.js");
11050
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-DA6SKIU5.js");
10859
11051
  const repo = await resolveRepoRoot2(repoPath);
10860
11052
  const def = await resolveDefaultBranch2(repo);
10861
11053
  return orch.createThread({
@@ -10865,7 +11057,7 @@ async function startOrchestration(opts) {
10865
11057
  repoPath: repo
10866
11058
  });
10867
11059
  });
10868
- const { updateThread: upd } = await import("./thread-store-R3G5VBII.js");
11060
+ const { updateThread: upd } = await import("./thread-store-4YTOV2HL.js");
10869
11061
  const updated = upd(thread.id, {
10870
11062
  sourceType: "orchestration",
10871
11063
  sourceRef: goal