@sideboard-ai/core 0.1.285 → 0.1.286

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 (27) hide show
  1. package/dist/{agents-ITNCZ6CA.js → agents-BHUXZ7XO.js} +2 -2
  2. package/dist/{agents-FKMYAKFD.js → agents-QNIFTZPN.js} +2 -2
  3. package/dist/{chunk-TXHZJESB.js → chunk-3H5U4QLD.js} +2 -2
  4. package/dist/{chunk-BMUVNTT4.js → chunk-ABOH7GBG.js} +2 -2
  5. package/dist/{chunk-2K723QZH.js → chunk-CBIUGGPI.js} +13 -12
  6. package/dist/{chunk-LMWPVC5L.js → chunk-ETZPTOK7.js} +2 -2
  7. package/dist/{chunk-C6NVTLZK.js → chunk-HJNFK5SP.js} +14 -13
  8. package/dist/{chunk-WY2IAB7J.js → chunk-MGJ7R7UX.js} +45 -1
  9. package/dist/{chunk-XSPOJFTV.js → chunk-PCNH74SF.js} +2 -2
  10. package/dist/{chunk-2SJXQ4UX.js → chunk-ULSY2BJF.js} +45 -1
  11. package/dist/{conductor-MU3TYVCD.js → conductor-RBJYEF7L.js} +2 -2
  12. package/dist/{conductor-GBX6LSP2.js → conductor-WYOWFB7I.js} +2 -2
  13. package/dist/{coordinator-prompt-SVVGU6AZ.js → coordinator-prompt-5DE3XBNT.js} +1 -1
  14. package/dist/{coordinator-prompt-4DJIHSE6.js → coordinator-prompt-R42WEL3T.js} +1 -1
  15. package/dist/{global-workspace-XON4YZXE.js → global-workspace-IPIEC6FM.js} +1 -1
  16. package/dist/{global-workspace-UPUDWIS6.js → global-workspace-NXMYLS34.js} +1 -1
  17. package/dist/index.cjs +91 -43
  18. package/dist/index.d.cts +7 -1
  19. package/dist/index.d.ts +7 -1
  20. package/dist/index.js +10 -6
  21. package/dist/mcp/run-stdio.cjs +85 -41
  22. package/dist/mcp/run-stdio.js +4 -4
  23. package/dist/{orchestrator-F7KXYDQW.js → orchestrator-65QGA6BB.js} +4 -4
  24. package/dist/{orchestrator-VUIRO6NC.js → orchestrator-YEZV35G7.js} +4 -4
  25. package/dist/{workspaces-F76BWCSI.js → workspaces-5C5ESWPU.js} +5 -1
  26. package/dist/{workspaces-7AJ5RZ3P.js → workspaces-LIFFWK23.js} +5 -1
  27. package/package.json +1 -1
@@ -47,10 +47,10 @@ import {
47
47
  resolveLoginCommand,
48
48
  resolveQuotaFallbackAgent,
49
49
  whichOnPath
50
- } from "./chunk-XSPOJFTV.js";
50
+ } from "./chunk-PCNH74SF.js";
51
51
  import "./chunk-VGNLMGBK.js";
52
52
  import "./chunk-XSDCLM3F.js";
53
- import "./chunk-WY2IAB7J.js";
53
+ import "./chunk-MGJ7R7UX.js";
54
54
  import "./chunk-K5XSTHHP.js";
55
55
  import "./chunk-N5UGX3JL.js";
56
56
  import "./chunk-2P4XKWV2.js";
@@ -56,12 +56,12 @@ import {
56
56
  resolveQuotaFallbackAgent,
57
57
  turnCostUsdFromCursorUsage,
58
58
  whichOnPath
59
- } from "./chunk-TXHZJESB.js";
59
+ } from "./chunk-3H5U4QLD.js";
60
60
  import "./chunk-7IAMHN2N.js";
61
61
  import "./chunk-PXMLMBMI.js";
62
62
  import "./chunk-2GPQZZLY.js";
63
63
  import "./chunk-5QOLFOAX.js";
64
- import "./chunk-2SJXQ4UX.js";
64
+ import "./chunk-ULSY2BJF.js";
65
65
  import "./chunk-5MGLNVNK.js";
66
66
  import "./chunk-N2WW62LF.js";
67
67
  import "./chunk-DD67JWTN.js";
@@ -24,7 +24,7 @@ import {
24
24
  } from "./chunk-5QOLFOAX.js";
25
25
  import {
26
26
  isOrchestratorThread
27
- } from "./chunk-2SJXQ4UX.js";
27
+ } from "./chunk-ULSY2BJF.js";
28
28
  import {
29
29
  codexUnattendedGitConfigArgs,
30
30
  mergeAgentGitAuthEnv,
@@ -2018,7 +2018,7 @@ var claudeAdapter = {
2018
2018
  );
2019
2019
  }
2020
2020
  const mode = permissionMode(thread);
2021
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-UPUDWIS6.js");
2021
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-NXMYLS34.js");
2022
2022
  const isOrchestrator = isOrchestratorThread2(thread);
2023
2023
  const rpc = worktreeAgentRpc(isOrchestrator);
2024
2024
  const injectedServers = await buildInjectedMcpServers({
@@ -8,7 +8,7 @@ import {
8
8
  isGlobalThread,
9
9
  isOrchestratorThread,
10
10
  isSlackCoordinatorThread
11
- } from "./chunk-WY2IAB7J.js";
11
+ } from "./chunk-MGJ7R7UX.js";
12
12
  import {
13
13
  mergeAgentGitAuthEnv,
14
14
  resolveAgentGitAuthEnv
@@ -1776,7 +1776,7 @@ var PORT_RANGE_SIZE = 10;
1776
1776
  var RECLAIM_RETRY_DELAY_MS = 40;
1777
1777
  var RECLAIM_TRIES = 8;
1778
1778
  async function killReclaimable(ports, worktreePath, signal) {
1779
- const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-GBX6LSP2.js");
1779
+ const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-WYOWFB7I.js");
1780
1780
  if (worktreePath) killStaleWorktreeListeners2(ports, worktreePath, signal);
1781
1781
  else killListenersOnPorts2(ports);
1782
1782
  }
@@ -23,7 +23,7 @@ import {
23
23
  parseSessionQuotaResetAt,
24
24
  planModeTurnInstruction,
25
25
  resolveQuotaFallbackAgent
26
- } from "./chunk-TXHZJESB.js";
26
+ } from "./chunk-3H5U4QLD.js";
27
27
  import {
28
28
  REVIEW_TAB_TITLE,
29
29
  applyWorktreePkgCacheEnv,
@@ -62,7 +62,7 @@ import {
62
62
  worktreeDevProcessKey,
63
63
  worktreeRunProcessKey,
64
64
  worktreeSetupProcessKey
65
- } from "./chunk-LMWPVC5L.js";
65
+ } from "./chunk-ETZPTOK7.js";
66
66
  import {
67
67
  applyAgentEvent,
68
68
  clipAgentEventForPaint,
@@ -93,6 +93,8 @@ import {
93
93
  import {
94
94
  SLACK_REPLY_FORMATTING,
95
95
  addWorkspace,
96
+ archiveRemovedWorkspaceChats,
97
+ archivesWithRemovedWorkspace,
96
98
  attachmentsFromWorktreePaths,
97
99
  coordinatorSystemPrompt,
98
100
  coordinatorTurnReminder,
@@ -109,11 +111,10 @@ import {
109
111
  orchestratorSessionPoisonedByBuiltins,
110
112
  persistPendingFileAttachments,
111
113
  removeWorkspace,
112
- sameWorkspacePath,
113
114
  stageAbsolutePathsAsAttachments,
114
115
  stageBuffersAsAttachments,
115
116
  syncWorkspacesFromThreads
116
- } from "./chunk-2SJXQ4UX.js";
117
+ } from "./chunk-ULSY2BJF.js";
117
118
  import {
118
119
  addPrStackLayer,
119
120
  allocateTeamSlug,
@@ -498,9 +499,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
498
499
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
499
500
  );
500
501
  }
501
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-UPUDWIS6.js");
502
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-NXMYLS34.js");
502
503
  if (isGlobalThread2(thread)) {
503
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-SVVGU6AZ.js");
504
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-5DE3XBNT.js");
504
505
  ensureGlobalCoordinatorCwd2(
505
506
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
506
507
  );
@@ -3114,7 +3115,7 @@ async function adoptThread(input) {
3114
3115
  messages: input.messages ?? []
3115
3116
  });
3116
3117
  writeThread(thread);
3117
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-F76BWCSI.js");
3118
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-5C5ESWPU.js");
3118
3119
  await addWorkspace2(repoPath);
3119
3120
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-5N2KTYIT.js");
3120
3121
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -6094,7 +6095,7 @@ function formatScheduledPrompt(name, prompt) {
6094
6095
  ${prompt}`;
6095
6096
  }
6096
6097
  async function defaultDeps() {
6097
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-VUIRO6NC.js");
6098
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-YEZV35G7.js");
6098
6099
  const orch = getOrchestrator2();
6099
6100
  return {
6100
6101
  findThread: (id) => findThreadByRef(id),
@@ -6833,10 +6834,10 @@ var Orchestrator = class {
6833
6834
  }
6834
6835
  async removeWorkspace(repoPath) {
6835
6836
  removeWorkspace(repoPath);
6836
- for (const thread of listThreads()) {
6837
- if (!sameWorkspacePath(thread.repoPath, repoPath)) continue;
6838
- await this.archive(thread.id).catch(() => void 0);
6839
- }
6837
+ await archiveRemovedWorkspaceChats(
6838
+ listThreads().filter((thread) => archivesWithRemovedWorkspace(thread.repoPath, repoPath)),
6839
+ (id) => this.archive(id)
6840
+ );
6840
6841
  }
6841
6842
  async adopt(input) {
6842
6843
  const thread = await adoptThread(input);
@@ -11,7 +11,7 @@ import {
11
11
  isGlobalThread,
12
12
  isOrchestratorThread,
13
13
  isSlackCoordinatorThread
14
- } from "./chunk-2SJXQ4UX.js";
14
+ } from "./chunk-ULSY2BJF.js";
15
15
  import {
16
16
  mergeAgentGitAuthEnv,
17
17
  resolveAgentGitAuthEnv
@@ -1674,7 +1674,7 @@ var PORT_RANGE_SIZE = 10;
1674
1674
  var RECLAIM_RETRY_DELAY_MS = 40;
1675
1675
  var RECLAIM_TRIES = 8;
1676
1676
  async function killReclaimable(ports, worktreePath, signal) {
1677
- const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-MU3TYVCD.js");
1677
+ const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-RBJYEF7L.js");
1678
1678
  if (worktreePath) killStaleWorktreeListeners2(ports, worktreePath, signal);
1679
1679
  else killListenersOnPorts2(ports);
1680
1680
  }
@@ -8,7 +8,7 @@ import {
8
8
  parseSessionQuotaResetAt,
9
9
  planModeTurnInstruction,
10
10
  resolveQuotaFallbackAgent
11
- } from "./chunk-XSPOJFTV.js";
11
+ } from "./chunk-PCNH74SF.js";
12
12
  import {
13
13
  REVIEW_TAB_TITLE,
14
14
  applyWorktreePkgCacheEnv,
@@ -47,7 +47,7 @@ import {
47
47
  worktreeDevProcessKey,
48
48
  worktreeRunProcessKey,
49
49
  worktreeSetupProcessKey
50
- } from "./chunk-BMUVNTT4.js";
50
+ } from "./chunk-ABOH7GBG.js";
51
51
  import {
52
52
  applyAgentEvent,
53
53
  clipAgentEventForPaint,
@@ -75,6 +75,8 @@ import {
75
75
  import {
76
76
  SLACK_REPLY_FORMATTING,
77
77
  addWorkspace,
78
+ archiveRemovedWorkspaceChats,
79
+ archivesWithRemovedWorkspace,
78
80
  attachmentsFromWorktreePaths,
79
81
  coordinatorSystemPrompt,
80
82
  coordinatorTurnReminder,
@@ -91,11 +93,10 @@ import {
91
93
  orchestratorSessionPoisonedByBuiltins,
92
94
  persistPendingFileAttachments,
93
95
  removeWorkspace,
94
- sameWorkspacePath,
95
96
  stageAbsolutePathsAsAttachments,
96
97
  stageBuffersAsAttachments,
97
98
  syncWorkspacesFromThreads
98
- } from "./chunk-WY2IAB7J.js";
99
+ } from "./chunk-MGJ7R7UX.js";
99
100
  import {
100
101
  addPrStackLayer,
101
102
  allocateTeamSlug,
@@ -450,9 +451,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
450
451
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
451
452
  );
452
453
  }
453
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-XON4YZXE.js");
454
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-IPIEC6FM.js");
454
455
  if (isGlobalThread2(thread)) {
455
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-4DJIHSE6.js");
456
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-R42WEL3T.js");
456
457
  ensureGlobalCoordinatorCwd2(
457
458
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
458
459
  );
@@ -2739,7 +2740,7 @@ async function createThread(input, _onSetupLine) {
2739
2740
  return readThread(thread.id) ?? thread;
2740
2741
  }
2741
2742
  async function listLinearIssues(agent, repoPath) {
2742
- const { getAdapter: getAdapter2 } = await import("./agents-ITNCZ6CA.js");
2743
+ const { getAdapter: getAdapter2 } = await import("./agents-BHUXZ7XO.js");
2743
2744
  await requireAgent(agent, { requireLinear: true });
2744
2745
  const adapter = getAdapter2(agent);
2745
2746
  if (!adapter.listLinearIssues) {
@@ -3250,7 +3251,7 @@ async function adoptThread(input) {
3250
3251
  messages: input.messages ?? []
3251
3252
  });
3252
3253
  writeThread(thread);
3253
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-7AJ5RZ3P.js");
3254
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-LIFFWK23.js");
3254
3255
  await addWorkspace2(repoPath);
3255
3256
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-RXZPTCNH.js");
3256
3257
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -6436,7 +6437,7 @@ function formatScheduledPrompt(name, prompt) {
6436
6437
  ${prompt}`;
6437
6438
  }
6438
6439
  async function defaultDeps() {
6439
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-F7KXYDQW.js");
6440
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-65QGA6BB.js");
6440
6441
  const orch = getOrchestrator2();
6441
6442
  return {
6442
6443
  findThread: (id) => findThreadByRef(id),
@@ -7175,10 +7176,10 @@ var Orchestrator = class {
7175
7176
  }
7176
7177
  async removeWorkspace(repoPath) {
7177
7178
  removeWorkspace(repoPath);
7178
- for (const thread of listThreads()) {
7179
- if (!sameWorkspacePath(thread.repoPath, repoPath)) continue;
7180
- await this.archive(thread.id).catch(() => void 0);
7181
- }
7179
+ await archiveRemovedWorkspaceChats(
7180
+ listThreads().filter((thread) => archivesWithRemovedWorkspace(thread.repoPath, repoPath)),
7181
+ (id) => this.archive(id)
7182
+ );
7182
7183
  }
7183
7184
  async adopt(input) {
7184
7185
  const thread = await adoptThread(input);
@@ -33,11 +33,13 @@ import {
33
33
  import {
34
34
  appDataDir,
35
35
  globalAgentCwd,
36
+ loadRepoSettings,
36
37
  sideboardReposDir
37
38
  } from "./chunk-EHT2DRT4.js";
38
39
 
39
40
  // src/store/workspaces.ts
40
41
  import { existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync3, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
42
+ import { homedir } from "os";
41
43
  import { basename as basename2, join as join3 } from "path";
42
44
 
43
45
  // src/brightsy/cloud-connect-constants.ts
@@ -874,10 +876,33 @@ function sameWorkspacePath(a, b) {
874
876
  if (primaryB && primaryB === left) return true;
875
877
  return false;
876
878
  }
879
+ function pathIsInside(parent, child) {
880
+ const root = parent.replace(/\/+$/, "");
881
+ const path = child.replace(/\/+$/, "");
882
+ if (!root || !path) return false;
883
+ return path === root || path.startsWith(`${root}/`);
884
+ }
885
+ function defaultWorktreesRoot(repoPath) {
886
+ const slug = basename2(repoPath.replace(/\/+$/, "")) || "repo";
887
+ return join3(homedir(), "sideboard", "workspaces", slug);
888
+ }
889
+ function removedWorktreeCoversRepo(saved, repoPath) {
890
+ if (!saved || !repoPath) return false;
891
+ if (pathIsInside(defaultWorktreesRoot(repoPath), saved)) return true;
892
+ try {
893
+ const custom = loadRepoSettings(repoPath)?.worktreesRoot;
894
+ if (custom && pathIsInside(custom, saved)) return true;
895
+ } catch {
896
+ }
897
+ return false;
898
+ }
877
899
  function removedMatches(saved, repoPath) {
878
900
  if (saved === repoPath || sameWorkspacePath(saved, repoPath)) return true;
879
901
  const primary = primaryCheckoutFromLinkedWorktree(repoPath);
880
- return Boolean(primary && sameWorkspacePath(saved, primary));
902
+ if (primary && (sameWorkspacePath(saved, primary) || removedWorktreeCoversRepo(saved, primary))) {
903
+ return true;
904
+ }
905
+ return removedWorktreeCoversRepo(saved, repoPath);
881
906
  }
882
907
  function isRemovedWorkspace(repoPath) {
883
908
  if (!repoPath) return false;
@@ -886,6 +911,10 @@ function isRemovedWorkspace(repoPath) {
886
911
  }
887
912
  return false;
888
913
  }
914
+ function archivesWithRemovedWorkspace(threadRepoPath, removedPath) {
915
+ if (!threadRepoPath || isGlobalRepoPath(threadRepoPath)) return false;
916
+ return isRemovedWorkspace(threadRepoPath) || sameWorkspacePath(threadRepoPath, removedPath);
917
+ }
889
918
  function rememberRemoved(repoPath) {
890
919
  const next = readRemoved();
891
920
  const before = next.size;
@@ -893,6 +922,8 @@ function rememberRemoved(repoPath) {
893
922
  next.add(canon);
894
923
  const raw = repoPath.replace(/\/+$/, "");
895
924
  if (raw && raw !== canon) next.add(raw);
925
+ const primary = primaryCheckoutFromLinkedWorktree(repoPath) ?? (canon !== repoPath ? primaryCheckoutFromLinkedWorktree(canon) : null);
926
+ if (primary) next.add(primary);
896
927
  if (next.size !== before) writeRemoved(next);
897
928
  }
898
929
  function forgetRemoved(repoPath) {
@@ -1025,6 +1056,17 @@ function syncWorkspacesFromThreads(repoPaths) {
1025
1056
  if (dirty) writeAll(next);
1026
1057
  return next.sort((a, b) => a.name.localeCompare(b.name));
1027
1058
  }
1059
+ async function archiveRemovedWorkspaceChats(threads, archive) {
1060
+ const failures = [];
1061
+ for (const thread of threads) {
1062
+ try {
1063
+ await archive(thread.id);
1064
+ } catch (err) {
1065
+ failures.push(err instanceof Error ? err.message : String(err));
1066
+ }
1067
+ }
1068
+ if (failures.length > 0) throw new Error(failures.join("\n"));
1069
+ }
1028
1070
 
1029
1071
  export {
1030
1072
  CLOUD_ORCHESTRATOR_GOAL,
@@ -1044,12 +1086,14 @@ export {
1044
1086
  attachmentsFromWorktreePaths,
1045
1087
  sameWorkspacePath,
1046
1088
  isRemovedWorkspace,
1089
+ archivesWithRemovedWorkspace,
1047
1090
  listWorkspaces,
1048
1091
  primaryCheckoutFromLinkedWorktree,
1049
1092
  addWorkspace,
1050
1093
  removeWorkspace,
1051
1094
  ensureWorkspace,
1052
1095
  syncWorkspacesFromThreads,
1096
+ archiveRemovedWorkspaceChats,
1053
1097
  formatWorkspaceInventory,
1054
1098
  enrichWorkspacesWithGithub,
1055
1099
  coordinatorGreenfieldPlaybook,
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-XSDCLM3F.js";
13
13
  import {
14
14
  isOrchestratorThread
15
- } from "./chunk-WY2IAB7J.js";
15
+ } from "./chunk-MGJ7R7UX.js";
16
16
  import {
17
17
  codexUnattendedGitConfigArgs,
18
18
  mergeAgentGitAuthEnv,
@@ -1755,7 +1755,7 @@ var claudeAdapter = {
1755
1755
  );
1756
1756
  }
1757
1757
  const mode = permissionMode(thread);
1758
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-XON4YZXE.js");
1758
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-IPIEC6FM.js");
1759
1759
  const isOrchestrator = isOrchestratorThread2(thread);
1760
1760
  const rpc = worktreeAgentRpc(isOrchestrator);
1761
1761
  const injectedServers = await buildInjectedMcpServers({
@@ -35,11 +35,13 @@ import {
35
35
  import {
36
36
  appDataDir,
37
37
  globalAgentCwd,
38
+ loadRepoSettings,
38
39
  sideboardReposDir
39
40
  } from "./chunk-H5XL4KUS.js";
40
41
 
41
42
  // src/store/workspaces.ts
42
43
  import { existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync3, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
44
+ import { homedir } from "os";
43
45
  import { basename as basename2, join as join3 } from "path";
44
46
 
45
47
  // src/brightsy/cloud-connect-constants.ts
@@ -829,10 +831,33 @@ function sameWorkspacePath(a, b) {
829
831
  if (primaryB && primaryB === left) return true;
830
832
  return false;
831
833
  }
834
+ function pathIsInside(parent, child) {
835
+ const root = parent.replace(/\/+$/, "");
836
+ const path = child.replace(/\/+$/, "");
837
+ if (!root || !path) return false;
838
+ return path === root || path.startsWith(`${root}/`);
839
+ }
840
+ function defaultWorktreesRoot(repoPath) {
841
+ const slug = basename2(repoPath.replace(/\/+$/, "")) || "repo";
842
+ return join3(homedir(), "sideboard", "workspaces", slug);
843
+ }
844
+ function removedWorktreeCoversRepo(saved, repoPath) {
845
+ if (!saved || !repoPath) return false;
846
+ if (pathIsInside(defaultWorktreesRoot(repoPath), saved)) return true;
847
+ try {
848
+ const custom = loadRepoSettings(repoPath)?.worktreesRoot;
849
+ if (custom && pathIsInside(custom, saved)) return true;
850
+ } catch {
851
+ }
852
+ return false;
853
+ }
832
854
  function removedMatches(saved, repoPath) {
833
855
  if (saved === repoPath || sameWorkspacePath(saved, repoPath)) return true;
834
856
  const primary = primaryCheckoutFromLinkedWorktree(repoPath);
835
- return Boolean(primary && sameWorkspacePath(saved, primary));
857
+ if (primary && (sameWorkspacePath(saved, primary) || removedWorktreeCoversRepo(saved, primary))) {
858
+ return true;
859
+ }
860
+ return removedWorktreeCoversRepo(saved, repoPath);
836
861
  }
837
862
  function isRemovedWorkspace(repoPath) {
838
863
  if (!repoPath) return false;
@@ -841,6 +866,10 @@ function isRemovedWorkspace(repoPath) {
841
866
  }
842
867
  return false;
843
868
  }
869
+ function archivesWithRemovedWorkspace(threadRepoPath, removedPath) {
870
+ if (!threadRepoPath || isGlobalRepoPath(threadRepoPath)) return false;
871
+ return isRemovedWorkspace(threadRepoPath) || sameWorkspacePath(threadRepoPath, removedPath);
872
+ }
844
873
  function rememberRemoved(repoPath) {
845
874
  const next = readRemoved();
846
875
  const before = next.size;
@@ -848,6 +877,8 @@ function rememberRemoved(repoPath) {
848
877
  next.add(canon);
849
878
  const raw = repoPath.replace(/\/+$/, "");
850
879
  if (raw && raw !== canon) next.add(raw);
880
+ const primary = primaryCheckoutFromLinkedWorktree(repoPath) ?? (canon !== repoPath ? primaryCheckoutFromLinkedWorktree(canon) : null);
881
+ if (primary) next.add(primary);
851
882
  if (next.size !== before) writeRemoved(next);
852
883
  }
853
884
  function forgetRemoved(repoPath) {
@@ -980,6 +1011,17 @@ function syncWorkspacesFromThreads(repoPaths) {
980
1011
  if (dirty) writeAll(next);
981
1012
  return next.sort((a, b) => a.name.localeCompare(b.name));
982
1013
  }
1014
+ async function archiveRemovedWorkspaceChats(threads, archive) {
1015
+ const failures = [];
1016
+ for (const thread of threads) {
1017
+ try {
1018
+ await archive(thread.id);
1019
+ } catch (err) {
1020
+ failures.push(err instanceof Error ? err.message : String(err));
1021
+ }
1022
+ }
1023
+ if (failures.length > 0) throw new Error(failures.join("\n"));
1024
+ }
983
1025
 
984
1026
  export {
985
1027
  stageAbsolutePathsAsAttachments,
@@ -988,12 +1030,14 @@ export {
988
1030
  attachmentsFromWorktreePaths,
989
1031
  sameWorkspacePath,
990
1032
  isRemovedWorkspace,
1033
+ archivesWithRemovedWorkspace,
991
1034
  listWorkspaces,
992
1035
  primaryCheckoutFromLinkedWorktree,
993
1036
  addWorkspace,
994
1037
  removeWorkspace,
995
1038
  ensureWorkspace,
996
1039
  syncWorkspacesFromThreads,
1040
+ archiveRemovedWorkspaceChats,
997
1041
  formatWorkspaceInventory,
998
1042
  enrichWorkspacesWithGithub,
999
1043
  coordinatorGreenfieldPlaybook,
@@ -33,9 +33,9 @@ import {
33
33
  tryReservePort,
34
34
  tryReservePorts,
35
35
  worktreeRunPortsPath
36
- } from "./chunk-LMWPVC5L.js";
36
+ } from "./chunk-ETZPTOK7.js";
37
37
  import "./chunk-5QOLFOAX.js";
38
- import "./chunk-2SJXQ4UX.js";
38
+ import "./chunk-ULSY2BJF.js";
39
39
  import "./chunk-5MGLNVNK.js";
40
40
  import "./chunk-N2WW62LF.js";
41
41
  import "./chunk-DD67JWTN.js";
@@ -31,9 +31,9 @@ import {
31
31
  tryReservePort,
32
32
  tryReservePorts,
33
33
  worktreeRunPortsPath
34
- } from "./chunk-BMUVNTT4.js";
34
+ } from "./chunk-ABOH7GBG.js";
35
35
  import "./chunk-XSDCLM3F.js";
36
- import "./chunk-WY2IAB7J.js";
36
+ import "./chunk-MGJ7R7UX.js";
37
37
  import "./chunk-K5XSTHHP.js";
38
38
  import "./chunk-N5UGX3JL.js";
39
39
  import "./chunk-2P4XKWV2.js";
@@ -9,7 +9,7 @@ import {
9
9
  enrichWorkspacesWithGithub,
10
10
  ensureGlobalCoordinatorCwd,
11
11
  formatWorkspaceInventory
12
- } from "./chunk-2SJXQ4UX.js";
12
+ } from "./chunk-ULSY2BJF.js";
13
13
  import "./chunk-5MGLNVNK.js";
14
14
  import "./chunk-N2WW62LF.js";
15
15
  import "./chunk-DD67JWTN.js";
@@ -7,7 +7,7 @@ import {
7
7
  enrichWorkspacesWithGithub,
8
8
  ensureGlobalCoordinatorCwd,
9
9
  formatWorkspaceInventory
10
- } from "./chunk-WY2IAB7J.js";
10
+ } from "./chunk-MGJ7R7UX.js";
11
11
  import "./chunk-K5XSTHHP.js";
12
12
  import "./chunk-N5UGX3JL.js";
13
13
  import "./chunk-2P4XKWV2.js";
@@ -18,7 +18,7 @@ import {
18
18
  remoteCoordinatorSourceRef,
19
19
  slackCoordinatorSourceRef,
20
20
  takenTeamSlugsForOrchestration
21
- } from "./chunk-WY2IAB7J.js";
21
+ } from "./chunk-MGJ7R7UX.js";
22
22
  import "./chunk-K5XSTHHP.js";
23
23
  import "./chunk-N5UGX3JL.js";
24
24
  import "./chunk-2P4XKWV2.js";
@@ -20,7 +20,7 @@ import {
20
20
  remoteCoordinatorSourceRef,
21
21
  slackCoordinatorSourceRef,
22
22
  takenTeamSlugsForOrchestration
23
- } from "./chunk-2SJXQ4UX.js";
23
+ } from "./chunk-ULSY2BJF.js";
24
24
  import "./chunk-5MGLNVNK.js";
25
25
  import "./chunk-N2WW62LF.js";
26
26
  import "./chunk-DD67JWTN.js";