@sideboard-ai/core 0.1.208 → 0.1.209

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 (51) hide show
  1. package/dist/{abletime-I4IYZBKU.js → abletime-G3MWSZVM.js} +4 -4
  2. package/dist/{abletime-UWSSLXH3.js → abletime-SQREWITG.js} +4 -4
  3. package/dist/{abletime-oauth-UZHPB3W2.js → abletime-oauth-7AOE4KJL.js} +3 -3
  4. package/dist/{abletime-oauth-C3BQXKW3.js → abletime-oauth-SQD6K47H.js} +3 -3
  5. package/dist/{abletime-rest-5YPPEOKK.js → abletime-rest-BXL7QHCX.js} +3 -3
  6. package/dist/{abletime-rest-HYNYDYK3.js → abletime-rest-QRTJH42S.js} +3 -3
  7. package/dist/agents/cursor-runner.js +3 -3
  8. package/dist/{agents-QHQXR55O.js → agents-KA6HDNNP.js} +6 -5
  9. package/dist/{agents-CCS5IEBV.js → agents-U2NVCYGC.js} +6 -5
  10. package/dist/{app-settings-R2KNCT37.js → app-settings-6SZLZNA7.js} +7 -1
  11. package/dist/{app-settings-GJ6KDYEF.js → app-settings-VBQHGX5Z.js} +7 -1
  12. package/dist/{chunk-OP6CFVTB.js → chunk-22A45QOI.js} +2 -2
  13. package/dist/{chunk-NJ2CCLV6.js → chunk-42VGWRSE.js} +2 -2
  14. package/dist/{chunk-X45BV4VX.js → chunk-5LFD3KCJ.js} +5 -5
  15. package/dist/{chunk-F4LZUEIO.js → chunk-B2RPIHNJ.js} +2 -2
  16. package/dist/{chunk-6YZLSZLK.js → chunk-CQZCXRVG.js} +3 -3
  17. package/dist/{chunk-4EGK47WV.js → chunk-FUC3XFE2.js} +215 -0
  18. package/dist/{chunk-C6ZNQV5W.js → chunk-HBL7ILQA.js} +117 -25
  19. package/dist/{chunk-TEDEVD4O.js → chunk-IIENQFJ6.js} +2 -2
  20. package/dist/{chunk-6J4OQ6TF.js → chunk-IOOL3T7Q.js} +3 -3
  21. package/dist/{chunk-A6SOSLUV.js → chunk-KJAHVQL6.js} +24 -94
  22. package/dist/{chunk-7PEIIN7P.js → chunk-MS2P5GXL.js} +24 -87
  23. package/dist/{chunk-C5MNMITQ.js → chunk-MZP2C4KE.js} +119 -25
  24. package/dist/{chunk-7DKX5JLT.js → chunk-OY7THBLG.js} +10 -2
  25. package/dist/{chunk-DNTPX6HV.js → chunk-PTOIWKDU.js} +3 -3
  26. package/dist/{chunk-W6X4GZJG.js → chunk-QVVJO4GN.js} +3 -3
  27. package/dist/{chunk-ZHCB4CKR.js → chunk-RPZFNKND.js} +10 -2
  28. package/dist/{chunk-HA4EZKFY.js → chunk-TZCWNRMC.js} +3 -3
  29. package/dist/{chunk-Y4CF7LHH.js → chunk-VJQDUD24.js} +230 -0
  30. package/dist/chunk-X5B3OS5I.js +34 -0
  31. package/dist/{chunk-WXWJ5MJ4.js → chunk-XRIF6M5H.js} +5 -5
  32. package/dist/{coordinator-prompt-TUHB6ZFA.js → coordinator-prompt-2YCOE5R4.js} +5 -4
  33. package/dist/{coordinator-prompt-WOTJQMD5.js → coordinator-prompt-EO2X2EYW.js} +5 -4
  34. package/dist/{cursor-recover-TXVTLAMA.js → cursor-recover-4PQAADAU.js} +3 -28
  35. package/dist/{global-workspace-V6G2KH2V.js → global-workspace-H2ANUSGR.js} +5 -4
  36. package/dist/{global-workspace-5UUUNA4A.js → global-workspace-JEKMVE42.js} +5 -4
  37. package/dist/index.cjs +671 -384
  38. package/dist/index.d.cts +93 -4
  39. package/dist/index.d.ts +93 -4
  40. package/dist/index.js +52 -19
  41. package/dist/mcp/run-stdio.cjs +637 -384
  42. package/dist/mcp/run-stdio.js +12 -11
  43. package/dist/{orchestrator-D4AQNF25.js → orchestrator-N7LLTK5O.js} +7 -6
  44. package/dist/{orchestrator-4IGHVRAF.js → orchestrator-RUQXDYM7.js} +7 -6
  45. package/dist/{thread-store-ESZYZSVC.js → thread-store-55X2JYDT.js} +2 -1
  46. package/dist/{thread-store-FMWDFAO5.js → thread-store-CMZWM5NY.js} +2 -1
  47. package/dist/{workspaces-CLNANACI.js → workspaces-2YNYLSPV.js} +5 -4
  48. package/dist/{workspaces-PZ36M7EQ.js → workspaces-SVDORZEI.js} +5 -4
  49. package/dist/{worktree-JKTM47K5.js → worktree-5CPGB4D2.js} +4 -3
  50. package/dist/{worktree-NC4XQNQI.js → worktree-YQ6XUSR2.js} +4 -3
  51. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  isOrchestratorThread
5
- } from "./chunk-DNTPX6HV.js";
5
+ } from "./chunk-PTOIWKDU.js";
6
6
  import {
7
7
  applyConnectedTeamToCli,
8
8
  brightsyMcpServerName,
@@ -20,7 +20,7 @@ import {
20
20
  mergeAgentGitAuthEnv,
21
21
  resolveAgentGitAuthEnv,
22
22
  resolveCodexGitWritableRoots
23
- } from "./chunk-NJ2CCLV6.js";
23
+ } from "./chunk-42VGWRSE.js";
24
24
  import {
25
25
  enrichPathWithNpmGlobalBin,
26
26
  isConductorBundledCli,
@@ -30,6 +30,7 @@ import {
30
30
  } from "./chunk-FNQNJOHY.js";
31
31
  import {
32
32
  claudeChromeEnabled,
33
+ fromInclusiveInputUsage,
33
34
  isAbleTimeConnected,
34
35
  isElectronLikeCommand,
35
36
  isLinearConnected,
@@ -38,7 +39,7 @@ import {
38
39
  resolveClaudeExecutable,
39
40
  unwrapStrippedElectronLaunch,
40
41
  wrapElectronAsNodeLaunch
41
- } from "./chunk-4EGK47WV.js";
42
+ } from "./chunk-FUC3XFE2.js";
42
43
  import {
43
44
  appDataDir
44
45
  } from "./chunk-EQNRWDLN.js";
@@ -46,85 +47,6 @@ import {
46
47
  // src/agents/brightsy.ts
47
48
  import { existsSync } from "fs";
48
49
 
49
- // src/agents/usage.ts
50
- function sumOptional(a, b) {
51
- if (a == null && b == null) return void 0;
52
- return (a ?? 0) + (b ?? 0);
53
- }
54
- function fromInclusiveInputUsage(opts) {
55
- const totalInput = Number(opts.inputTokens) || 0;
56
- const outputTokens = Number(opts.outputTokens) || 0;
57
- const cached = Number(opts.cachedInputTokens) || 0;
58
- if (!totalInput && !outputTokens) return null;
59
- const cacheReadTokens = cached > 0 ? Math.min(cached, totalInput) : 0;
60
- return {
61
- inputTokens: Math.max(0, totalInput - cacheReadTokens),
62
- outputTokens,
63
- cacheReadTokens: cacheReadTokens || void 0
64
- };
65
- }
66
- function requestOccupancy(u) {
67
- return u.inputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
68
- }
69
- function mergeUsage(a, b) {
70
- return {
71
- inputTokens: (a?.inputTokens ?? 0) + b.inputTokens,
72
- outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
73
- cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
74
- cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
75
- costUsd: sumOptional(a?.costUsd, b.costUsd),
76
- lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
77
- };
78
- }
79
- function sumUsageList(list) {
80
- let acc = null;
81
- for (const u of list) {
82
- if (!u) continue;
83
- acc = mergeUsage(acc, {
84
- inputTokens: u.inputTokens,
85
- outputTokens: u.outputTokens,
86
- cacheReadTokens: u.cacheReadTokens,
87
- cacheWriteTokens: u.cacheWriteTokens,
88
- costUsd: u.costUsd
89
- });
90
- }
91
- if (!acc) return null;
92
- return {
93
- inputTokens: acc.inputTokens,
94
- outputTokens: acc.outputTokens,
95
- ...acc.cacheReadTokens != null ? { cacheReadTokens: acc.cacheReadTokens } : {},
96
- ...acc.cacheWriteTokens != null ? { cacheWriteTokens: acc.cacheWriteTokens } : {},
97
- ...acc.costUsd != null ? { costUsd: acc.costUsd } : {}
98
- };
99
- }
100
- function hasBilledTokens(u) {
101
- return Boolean(
102
- u.inputTokens || u.outputTokens || u.cacheReadTokens || u.cacheWriteTokens
103
- );
104
- }
105
- function applyTurnUsage(current, incoming, scope = "request") {
106
- if (scope === "turn") {
107
- if (!hasBilledTokens(incoming) && current && incoming.costUsd != null) {
108
- return { ...current, costUsd: incoming.costUsd };
109
- }
110
- return {
111
- ...incoming,
112
- costUsd: incoming.costUsd ?? current?.costUsd,
113
- lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
114
- };
115
- }
116
- const merged = mergeUsage(current, incoming);
117
- const occ = incoming.lastRequestTokens != null && incoming.lastRequestTokens > 0 ? incoming.lastRequestTokens : requestOccupancy(incoming);
118
- return {
119
- ...merged,
120
- lastRequestTokens: occ > 0 ? occ : current?.lastRequestTokens ?? occ
121
- };
122
- }
123
- function contextTokens(u) {
124
- if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
125
- return requestOccupancy(u);
126
- }
127
-
128
50
  // src/agents/brightsy-targets.ts
129
51
  function encodeBrightsyTarget(type, id, accountId) {
130
52
  if (accountId) return `team:${accountId}:${type}:${id}`;
@@ -2299,13 +2221,31 @@ function mcpStatusThinkingFromClaudeInit(obj) {
2299
2221
  }
2300
2222
  }
2301
2223
  }
2302
- const notable = servers.filter((s) => !isCleanMcpConnect(s.status));
2224
+ const notable = servers.filter(isNotableMcpInitStatus);
2303
2225
  if (notable.length === 0) return null;
2304
2226
  return `MCP: ${notable.map((s) => `${s.name} ${s.status}`).join(", ")}`;
2305
2227
  }
2306
2228
  function isCleanMcpConnect(status) {
2307
2229
  return /^(connected|ok|ready|success)$/i.test(status.trim());
2308
2230
  }
2231
+ function isMcpAuthStatus(status) {
2232
+ return /needs[_-]?auth|needs authentication|unauthorized|not authenticated|authrequired/i.test(
2233
+ status
2234
+ );
2235
+ }
2236
+ function isSideboardMcpName(name) {
2237
+ return /^sideboard$/i.test(name.trim()) || /^mcp__sideboard$/i.test(name.trim());
2238
+ }
2239
+ function isVendorClaudeAiMcpName(name) {
2240
+ return /^claude\.ai\b/i.test(name.trim()) || /^mcp__claude_ai_/i.test(name.trim());
2241
+ }
2242
+ function isNotableMcpInitStatus(server) {
2243
+ if (isCleanMcpConnect(server.status)) return false;
2244
+ if (isSideboardMcpName(server.name)) return true;
2245
+ if (isVendorClaudeAiMcpName(server.name)) return false;
2246
+ if (isMcpAuthStatus(server.status)) return false;
2247
+ return true;
2248
+ }
2309
2249
  function eventsFromClaudeSystem(obj) {
2310
2250
  const subtype = claudeString(obj, "subtype") ?? "";
2311
2251
  const parentId = claudeParentToolUseId(obj);
@@ -2474,7 +2414,7 @@ var claudeAdapter = {
2474
2414
  );
2475
2415
  }
2476
2416
  const mode = permissionMode(thread);
2477
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-V6G2KH2V.js");
2417
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-H2ANUSGR.js");
2478
2418
  const isOrchestrator = isOrchestratorThread2(thread);
2479
2419
  const injectedServers = await buildInjectedMcpServers({
2480
2420
  includeSideboard: true,
@@ -4809,9 +4749,6 @@ export {
4809
4749
  shouldFeedErrorBackToAgent,
4810
4750
  formatAgentErrorContinuePrompt,
4811
4751
  formatTurnExitError,
4812
- sumUsageList,
4813
- applyTurnUsage,
4814
- contextTokens,
4815
4752
  encodeBrightsyTarget,
4816
4753
  decodeBrightsyTarget,
4817
4754
  parseBrightsyCliLine,
@@ -8,9 +8,7 @@ import {
8
8
  adjustBrightsyTurnExit,
9
9
  allAdapters,
10
10
  applyAgentEvent,
11
- applyTurnUsage,
12
11
  clipAgentEventForPaint,
13
- contextTokens,
14
12
  finalizeParts,
15
13
  getAdapter,
16
14
  isBrightsyNdjsonLine,
@@ -25,9 +23,8 @@ import {
25
23
  partsToAssistantText,
26
24
  resolveQuotaFallbackAgent,
27
25
  stripBrightsyNdjsonNoise,
28
- sumUsageList,
29
26
  toolDescription
30
- } from "./chunk-A6SOSLUV.js";
27
+ } from "./chunk-KJAHVQL6.js";
31
28
  import {
32
29
  SLACK_REPLY_FORMATTING,
33
30
  addWorkspace,
@@ -50,7 +47,7 @@ import {
50
47
  stageAbsolutePathsAsAttachments,
51
48
  stageBuffersAsAttachments,
52
49
  syncWorkspacesFromThreads
53
- } from "./chunk-HA4EZKFY.js";
50
+ } from "./chunk-TZCWNRMC.js";
54
51
  import {
55
52
  addPrStackLayer,
56
53
  allocateTeamName,
@@ -100,7 +97,7 @@ import {
100
97
  worktreeDisplayLabelForGroup,
101
98
  worktreeNameFromPath,
102
99
  worktreeSlugForTicket
103
- } from "./chunk-OP6CFVTB.js";
100
+ } from "./chunk-22A45QOI.js";
104
101
  import {
105
102
  ATTACHMENTS_DIR,
106
103
  DETACHED_JOBS_DIR,
@@ -134,19 +131,28 @@ import {
134
131
  turnFailChatText
135
132
  } from "./chunk-JZHRZ3DR.js";
136
133
  import {
134
+ HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT,
135
+ applyTurnUsage,
137
136
  assertOrchestratorCapableAgent,
137
+ autoCleanupHistoryEnabled,
138
138
  childEnvWithAppSettings,
139
139
  coerceOrchestratorAgent,
140
+ contextTokens,
140
141
  followUpBehavior,
141
142
  formatViewerContextDirective,
142
143
  formatViewerContextReminder,
143
144
  getIssueSource,
145
+ historyMaxCount,
146
+ historyMaxDays,
147
+ historyRetentionStubMessage,
144
148
  isAbleTimeConnected,
145
149
  isLinearConnected,
146
150
  isOrchestratorCapableAgent,
147
151
  isSecureFileEncrypted,
148
152
  loadAppSettings,
149
153
  orchestrationQuotaFallbackAgent,
154
+ planHistoryAgePurge,
155
+ planHistoryRetention,
150
156
  readSecureJson,
151
157
  resolveEffectiveIssueSource,
152
158
  resolveNewThreadOptions,
@@ -154,10 +160,11 @@ import {
154
160
  resolveVaultKey,
155
161
  resolveViewerProfileForRepo,
156
162
  saveAppSettings,
163
+ sumUsageList,
157
164
  updateAdvancedSettings,
158
165
  usageOnLimit,
159
166
  writeSecureJson
160
- } from "./chunk-Y4CF7LHH.js";
167
+ } from "./chunk-VJQDUD24.js";
161
168
  import {
162
169
  stripNestedElectronEnv
163
170
  } from "./chunk-4TR3HZFT.js";
@@ -182,7 +189,7 @@ import {
182
189
  updateThread,
183
190
  withThreadLock,
184
191
  writeThread
185
- } from "./chunk-7DKX5JLT.js";
192
+ } from "./chunk-OY7THBLG.js";
186
193
  import {
187
194
  appDataDir,
188
195
  findConventionSetup,
@@ -476,7 +483,7 @@ async function continueSourceThread(threadId, prompt) {
476
483
  await continueOnReply(threadId, prompt);
477
484
  return;
478
485
  }
479
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-D4AQNF25.js");
486
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-N7LLTK5O.js");
480
487
  await getOrchestrator2().send(threadId, prompt);
481
488
  } catch {
482
489
  }
@@ -810,9 +817,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
810
817
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
811
818
  );
812
819
  }
813
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-5UUUNA4A.js");
820
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-JEKMVE42.js");
814
821
  if (isGlobalThread2(thread)) {
815
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-WOTJQMD5.js");
822
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-EO2X2EYW.js");
816
823
  ensureGlobalCoordinatorCwd2(
817
824
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
818
825
  );
@@ -2592,6 +2599,69 @@ function worktreeCleanupSettings() {
2592
2599
  };
2593
2600
  }
2594
2601
 
2602
+ // src/store/history-cleanup.ts
2603
+ function stripArchivedTranscript(thread) {
2604
+ writeThread(
2605
+ {
2606
+ ...thread,
2607
+ attachments: [],
2608
+ pendingTurnAttachments: [],
2609
+ messages: [historyRetentionStubMessage(thread)]
2610
+ },
2611
+ { touch: false }
2612
+ );
2613
+ }
2614
+ function cleanupArchivedHistory(opts = {}) {
2615
+ const settings = loadAppSettings();
2616
+ if (!opts.force && opts.purgeOlderThanDays == null && !autoCleanupHistoryEnabled(settings)) {
2617
+ return { stripped: [], purged: [] };
2618
+ }
2619
+ const archived = listThreads({ includeArchived: true }).filter((t) => t.status === "archived");
2620
+ const nowMs = opts.nowMs ?? Date.now();
2621
+ const plan = opts.purgeOlderThanDays != null ? { stripIds: [], purgeIds: planHistoryAgePurge(archived, opts.purgeOlderThanDays, nowMs) } : planHistoryRetention(archived, {
2622
+ maxCount: opts.maxCount ?? historyMaxCount(settings),
2623
+ maxDays: opts.maxDays ?? historyMaxDays(settings),
2624
+ nowMs
2625
+ });
2626
+ const stripped = [];
2627
+ const purged = [];
2628
+ if (opts.dryRun) {
2629
+ return { stripped: plan.stripIds, purged: plan.purgeIds };
2630
+ }
2631
+ for (const id of plan.stripIds) {
2632
+ const thread = readThread(id);
2633
+ if (!thread || thread.status !== "archived") continue;
2634
+ try {
2635
+ stripArchivedTranscript(thread);
2636
+ stripped.push(id);
2637
+ } catch {
2638
+ }
2639
+ }
2640
+ for (const id of plan.purgeIds) {
2641
+ const thread = readThread(id);
2642
+ if (!thread || thread.status !== "archived") continue;
2643
+ try {
2644
+ deleteThreadRecord(id);
2645
+ purged.push(id);
2646
+ } catch {
2647
+ }
2648
+ }
2649
+ if (stripped.length > 0 || purged.length > 0) {
2650
+ updateAdvancedSettings({
2651
+ historyLastCleanupAt: new Date(nowMs).toISOString()
2652
+ });
2653
+ }
2654
+ return { stripped, purged };
2655
+ }
2656
+ function shouldRunHistoryCleanup(settings = loadAppSettings()) {
2657
+ if (!autoCleanupHistoryEnabled(settings)) return false;
2658
+ const intervalHours = settings.advanced.historyCleanupIntervalHours ?? HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT;
2659
+ const last = settings.advanced.historyLastCleanupAt;
2660
+ if (!last) return true;
2661
+ const elapsed = Date.now() - Date.parse(last);
2662
+ return Number.isFinite(elapsed) && elapsed >= intervalHours * 36e5;
2663
+ }
2664
+
2595
2665
  // src/git/apply-into-main.ts
2596
2666
  import { execa as execa3 } from "execa";
2597
2667
  async function applyThreadIntoMain(thread, opts) {
@@ -3808,7 +3878,7 @@ async function createThread(input, _onSetupLine) {
3808
3878
  });
3809
3879
  await requireAgent(resolved.agent);
3810
3880
  if (input.cowboy) {
3811
- const { cowboyModeEnabled } = await import("./app-settings-GJ6KDYEF.js");
3881
+ const { cowboyModeEnabled } = await import("./app-settings-VBQHGX5Z.js");
3812
3882
  if (!cowboyModeEnabled()) {
3813
3883
  throw new Error(
3814
3884
  "Cowboy mode is off. Enable it in Settings \u2192 Advanced."
@@ -3866,7 +3936,7 @@ async function createThread(input, _onSetupLine) {
3866
3936
  let sourceIsFork = false;
3867
3937
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
3868
3938
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
3869
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-I4IYZBKU.js");
3939
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-G3MWSZVM.js");
3870
3940
  const task = await ensureAbleTimeTask({
3871
3941
  title: title?.trim() || "Untitled work",
3872
3942
  description: input.prompt?.trim() || void 0
@@ -3968,7 +4038,7 @@ async function createThread(input, _onSetupLine) {
3968
4038
  return readThread(thread.id) ?? thread;
3969
4039
  }
3970
4040
  async function listLinearIssues(agent, repoPath) {
3971
- const { getAdapter: getAdapter2 } = await import("./agents-CCS5IEBV.js");
4041
+ const { getAdapter: getAdapter2 } = await import("./agents-U2NVCYGC.js");
3972
4042
  await requireAgent(agent, { requireLinear: true });
3973
4043
  const adapter = getAdapter2(agent);
3974
4044
  if (!adapter.listLinearIssues) {
@@ -4414,7 +4484,7 @@ async function adoptThread(input) {
4414
4484
  messages: input.messages ?? []
4415
4485
  });
4416
4486
  writeThread(thread);
4417
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-PZ36M7EQ.js");
4487
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-SVDORZEI.js");
4418
4488
  await ensureWorkspace2(repoPath);
4419
4489
  const { ensureWorktreeSideboardIgnored: ensureWorktreeSideboardIgnored2 } = await import("./worktree-exclude-X54WSOXM.js");
4420
4490
  await ensureWorktreeSideboardIgnored2(input.worktreePath);
@@ -7020,7 +7090,7 @@ function formatScheduledPrompt(name, prompt) {
7020
7090
  ${prompt}`;
7021
7091
  }
7022
7092
  async function defaultDeps() {
7023
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-D4AQNF25.js");
7093
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-N7LLTK5O.js");
7024
7094
  const orch = getOrchestrator2();
7025
7095
  return {
7026
7096
  findThread: (id) => findThreadByRef(id),
@@ -7290,12 +7360,18 @@ var Orchestrator = class {
7290
7360
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
7291
7361
  });
7292
7362
  }
7293
- const { autoCleanupOrphansEnabled } = await import("./app-settings-GJ6KDYEF.js");
7363
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-VBQHGX5Z.js");
7294
7364
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
7295
7365
  await cleanupOrphanWorktrees({ repoPaths });
7296
7366
  }
7297
7367
  } catch {
7298
7368
  }
7369
+ try {
7370
+ if (shouldRunHistoryCleanup()) {
7371
+ cleanupArchivedHistory();
7372
+ }
7373
+ } catch {
7374
+ }
7299
7375
  if (drainQueues) {
7300
7376
  this.adoptPersistedQueues();
7301
7377
  }
@@ -7582,7 +7658,7 @@ var Orchestrator = class {
7582
7658
  }
7583
7659
  await setup;
7584
7660
  if (skipSetup) return;
7585
- const { autoRunAfterSetupEnabled } = await import("./app-settings-GJ6KDYEF.js");
7661
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-VBQHGX5Z.js");
7586
7662
  if (autoRunAfterSetupEnabled()) {
7587
7663
  try {
7588
7664
  await this.startDev(threadId);
@@ -7912,7 +7988,7 @@ var Orchestrator = class {
7912
7988
  }
7913
7989
  const isBrightsy = fresh.agent === "brightsy";
7914
7990
  const isOrchestration = isOrchestratorThread(fresh);
7915
- const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-GJ6KDYEF.js");
7991
+ const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-VBQHGX5Z.js");
7916
7992
  const gitAuthMode = getGithubGitAuthMode();
7917
7993
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
7918
7994
  githubSlug: await resolveGithubRepoSlug(fresh.worktreePath).catch(
@@ -8624,6 +8700,20 @@ var Orchestrator = class {
8624
8700
  repoPaths
8625
8701
  });
8626
8702
  }
8703
+ /** Bound Settings → History. After archive always; reconcile is interval-gated. */
8704
+ enforceHistoryRetention() {
8705
+ try {
8706
+ cleanupArchivedHistory();
8707
+ } catch {
8708
+ }
8709
+ }
8710
+ cleanupHistory(opts) {
8711
+ return cleanupArchivedHistory({
8712
+ dryRun: opts?.dryRun,
8713
+ purgeOlderThanDays: opts?.purgeOlderThanDays,
8714
+ force: opts?.force
8715
+ });
8716
+ }
8627
8717
  /**
8628
8718
  * Best-of-n / fanout: create N threads (one per agent) with the same prompt.
8629
8719
  */
@@ -8930,7 +9020,7 @@ var Orchestrator = class {
8930
9020
  if (!titled.userSetTitle && meta.title && titled.title !== meta.title) {
8931
9021
  updateThread(thread.id, { title: meta.title });
8932
9022
  }
8933
- const { autoArchiveOnMergeEnabled } = await import("./app-settings-GJ6KDYEF.js");
9023
+ const { autoArchiveOnMergeEnabled } = await import("./app-settings-VBQHGX5Z.js");
8934
9024
  const latest = this.requireThread(thread.id);
8935
9025
  if (!shouldAutoArchiveOnPrMerge({
8936
9026
  previousPrState: prevState || null,
@@ -9184,6 +9274,7 @@ var Orchestrator = class {
9184
9274
  if (isGlobalThread(thread)) {
9185
9275
  const archived2 = setStatus(thread.id, "archived");
9186
9276
  this.emit({ type: "status_changed", threadId: archived2.id, status: "archived" });
9277
+ this.enforceHistoryRetention();
9187
9278
  return archived2;
9188
9279
  }
9189
9280
  const siblings = threadsSharingWorktree(thread.worktreePath).filter((t) => t.id !== thread.id);
@@ -9205,9 +9296,10 @@ var Orchestrator = class {
9205
9296
  }
9206
9297
  const archived = setStatus(thread.id, "archived");
9207
9298
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
9299
+ this.enforceHistoryRetention();
9208
9300
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
9209
9301
  try {
9210
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-PZ36M7EQ.js");
9302
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-SVDORZEI.js");
9211
9303
  await ensureWorkspace2(thread.repoPath);
9212
9304
  } catch {
9213
9305
  }
@@ -9234,7 +9326,7 @@ var Orchestrator = class {
9234
9326
  await runArchiveScript(thread.repoPath, thread.worktreePath);
9235
9327
  } catch {
9236
9328
  }
9237
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-GJ6KDYEF.js");
9329
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-VBQHGX5Z.js");
9238
9330
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
9239
9331
  await removeWorktree(thread.repoPath, thread.worktreePath, {
9240
9332
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -9261,7 +9353,7 @@ var Orchestrator = class {
9261
9353
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
9262
9354
  );
9263
9355
  }
9264
- const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-NC4XQNQI.js");
9356
+ const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-YQ6XUSR2.js");
9265
9357
  const slug = thread.worktreePath.split("/").pop();
9266
9358
  const dest = thread.worktreePath;
9267
9359
  await withRepoGitLock(thread.repoPath, async () => {
@@ -9371,7 +9463,7 @@ async function startOrchestration(opts) {
9371
9463
  sourceRef: "default",
9372
9464
  ...createOpts
9373
9465
  }).catch(async () => {
9374
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-NC4XQNQI.js");
9466
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-YQ6XUSR2.js");
9375
9467
  const repo = await resolveRepoRoot2(repoPath);
9376
9468
  const def = await resolveDefaultBranch2(repo);
9377
9469
  return orch.createThread({
@@ -9381,7 +9473,7 @@ async function startOrchestration(opts) {
9381
9473
  repoPath: repo
9382
9474
  });
9383
9475
  });
9384
- const { updateThread: upd } = await import("./thread-store-ESZYZSVC.js");
9476
+ const { updateThread: upd } = await import("./thread-store-55X2JYDT.js");
9385
9477
  const updated = upd(thread.id, {
9386
9478
  sourceType: "orchestration",
9387
9479
  sourceRef: goal
@@ -9540,6 +9632,8 @@ export {
9540
9632
  cleanupOrphanWorktrees,
9541
9633
  shouldRunWorktreeCleanup,
9542
9634
  worktreeCleanupSettings,
9635
+ cleanupArchivedHistory,
9636
+ shouldRunHistoryCleanup,
9543
9637
  applyThreadIntoMain,
9544
9638
  cloneRepoIntoSideboard,
9545
9639
  mcpWaitForTurnTimeoutMs,
@@ -1,3 +1,6 @@
1
+ import {
2
+ cursorSdkStoreDir
3
+ } from "./chunk-7J72QJOM.js";
1
4
  import {
2
5
  normalizeThinkingEffort
3
6
  } from "./chunk-77WWLBCI.js";
@@ -13,6 +16,7 @@ import {
13
16
  existsSync,
14
17
  readFileSync,
15
18
  renameSync,
19
+ rmSync,
16
20
  statSync,
17
21
  unlinkSync,
18
22
  writeFileSync,
@@ -159,10 +163,10 @@ function readThread(id) {
159
163
  rememberThread(thread, mtimeMs);
160
164
  return thread;
161
165
  }
162
- function writeThread(thread) {
166
+ function writeThread(thread, opts) {
163
167
  const path = threadFilePath(idPath(thread.id));
164
168
  const tmp = `${path}.${process.pid}.tmp`;
165
- const next = { ...thread, updatedAt: nowIso() };
169
+ const next = opts?.touch === false ? { ...thread } : { ...thread, updatedAt: nowIso() };
166
170
  writeFileSync(tmp, JSON.stringify(next, null, 2), "utf8");
167
171
  renameSync(tmp, path);
168
172
  rememberThread(next, fileMtimeMs(path) ?? Date.now());
@@ -207,6 +211,10 @@ function deleteThreadRecord(id) {
207
211
  } catch {
208
212
  }
209
213
  }
214
+ try {
215
+ rmSync(cursorSdkStoreDir(id), { recursive: true, force: true });
216
+ } catch {
217
+ }
210
218
  }
211
219
  function updateThread(id, patch) {
212
220
  const current = readThread(id);
@@ -7,7 +7,7 @@ import {
7
7
  resolveRepoRoot,
8
8
  takenSlugsFromThread,
9
9
  teamSlugFromName
10
- } from "./chunk-NJ2CCLV6.js";
10
+ } from "./chunk-42VGWRSE.js";
11
11
  import {
12
12
  ATTACHMENTS_DIR,
13
13
  attachmentsGitignoreBody
@@ -17,7 +17,7 @@ import {
17
17
  listThreads,
18
18
  updateThread,
19
19
  writeThread
20
- } from "./chunk-ZHCB4CKR.js";
20
+ } from "./chunk-RPZFNKND.js";
21
21
  import {
22
22
  assertOrchestratorCapableAgent,
23
23
  formatAccountProfilePlaybookLine,
@@ -30,7 +30,7 @@ import {
30
30
  resolveThreadDefaults,
31
31
  resolveViewerProfile,
32
32
  resolveViewerProfileForRepo
33
- } from "./chunk-4EGK47WV.js";
33
+ } from "./chunk-FUC3XFE2.js";
34
34
  import {
35
35
  appDataDir,
36
36
  globalAgentCwd,
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  textFromAbleTimeDoc
3
- } from "./chunk-F4LZUEIO.js";
3
+ } from "./chunk-B2RPIHNJ.js";
4
4
  import {
5
5
  assertAbleTimeCredential,
6
6
  callAbleTimeTool,
7
7
  normalizeAbleTimeHost,
8
8
  rewriteAbleTimeError
9
- } from "./chunk-X45BV4VX.js";
9
+ } from "./chunk-5LFD3KCJ.js";
10
10
  import {
11
11
  isAbleTimeConnected,
12
12
  saveAbleTimeConnection
13
- } from "./chunk-Y4CF7LHH.js";
13
+ } from "./chunk-VJQDUD24.js";
14
14
 
15
15
  // src/integrations/abletime.ts
16
16
  var CLOSED_STATES = /* @__PURE__ */ new Set([
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import {
4
+ cursorSdkStoreDir
5
+ } from "./chunk-X5B3OS5I.js";
3
6
  import {
4
7
  normalizeThinkingEffort
5
8
  } from "./chunk-KGZBYWZ3.js";
@@ -15,6 +18,7 @@ import {
15
18
  existsSync,
16
19
  readFileSync,
17
20
  renameSync,
21
+ rmSync,
18
22
  statSync,
19
23
  unlinkSync,
20
24
  writeFileSync,
@@ -161,10 +165,10 @@ function readThread(id) {
161
165
  rememberThread(thread, mtimeMs);
162
166
  return thread;
163
167
  }
164
- function writeThread(thread) {
168
+ function writeThread(thread, opts) {
165
169
  const path = threadFilePath(idPath(thread.id));
166
170
  const tmp = `${path}.${process.pid}.tmp`;
167
- const next = { ...thread, updatedAt: nowIso() };
171
+ const next = opts?.touch === false ? { ...thread } : { ...thread, updatedAt: nowIso() };
168
172
  writeFileSync(tmp, JSON.stringify(next, null, 2), "utf8");
169
173
  renameSync(tmp, path);
170
174
  rememberThread(next, fileMtimeMs(path) ?? Date.now());
@@ -209,6 +213,10 @@ function deleteThreadRecord(id) {
209
213
  } catch {
210
214
  }
211
215
  }
216
+ try {
217
+ rmSync(cursorSdkStoreDir(id), { recursive: true, force: true });
218
+ } catch {
219
+ }
212
220
  }
213
221
  function updateThread(id, patch) {
214
222
  const current = readThread(id);
@@ -5,7 +5,7 @@ import {
5
5
  resolveRepoRoot,
6
6
  takenSlugsFromThread,
7
7
  teamSlugFromName
8
- } from "./chunk-OP6CFVTB.js";
8
+ } from "./chunk-22A45QOI.js";
9
9
  import {
10
10
  ATTACHMENTS_DIR,
11
11
  attachmentsGitignoreBody
@@ -22,13 +22,13 @@ import {
22
22
  resolveThreadDefaults,
23
23
  resolveViewerProfile,
24
24
  resolveViewerProfileForRepo
25
- } from "./chunk-Y4CF7LHH.js";
25
+ } from "./chunk-VJQDUD24.js";
26
26
  import {
27
27
  createEmptyThread,
28
28
  listThreads,
29
29
  updateThread,
30
30
  writeThread
31
- } from "./chunk-7DKX5JLT.js";
31
+ } from "./chunk-OY7THBLG.js";
32
32
  import {
33
33
  appDataDir,
34
34
  globalAgentCwd,