@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
package/dist/index.cjs CHANGED
@@ -991,6 +991,180 @@ var init_branch_prefix = __esm({
991
991
  }
992
992
  });
993
993
 
994
+ // src/agents/usage.ts
995
+ function sumOptional(a, b) {
996
+ if (a == null && b == null) return void 0;
997
+ return (a ?? 0) + (b ?? 0);
998
+ }
999
+ function fromInclusiveInputUsage(opts) {
1000
+ const totalInput = Number(opts.inputTokens) || 0;
1001
+ const outputTokens = Number(opts.outputTokens) || 0;
1002
+ const cached = Number(opts.cachedInputTokens) || 0;
1003
+ if (!totalInput && !outputTokens) return null;
1004
+ const cacheReadTokens = cached > 0 ? Math.min(cached, totalInput) : 0;
1005
+ return {
1006
+ inputTokens: Math.max(0, totalInput - cacheReadTokens),
1007
+ outputTokens,
1008
+ cacheReadTokens: cacheReadTokens || void 0
1009
+ };
1010
+ }
1011
+ function requestOccupancy(u) {
1012
+ return u.inputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
1013
+ }
1014
+ function mergeUsage(a, b) {
1015
+ return {
1016
+ inputTokens: (a?.inputTokens ?? 0) + b.inputTokens,
1017
+ outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
1018
+ cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
1019
+ cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
1020
+ costUsd: sumOptional(a?.costUsd, b.costUsd),
1021
+ lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
1022
+ };
1023
+ }
1024
+ function sumUsageList(list) {
1025
+ let acc = null;
1026
+ for (const u of list) {
1027
+ if (!u) continue;
1028
+ acc = mergeUsage(acc, {
1029
+ inputTokens: u.inputTokens,
1030
+ outputTokens: u.outputTokens,
1031
+ cacheReadTokens: u.cacheReadTokens,
1032
+ cacheWriteTokens: u.cacheWriteTokens,
1033
+ costUsd: u.costUsd
1034
+ });
1035
+ }
1036
+ if (!acc) return null;
1037
+ return {
1038
+ inputTokens: acc.inputTokens,
1039
+ outputTokens: acc.outputTokens,
1040
+ ...acc.cacheReadTokens != null ? { cacheReadTokens: acc.cacheReadTokens } : {},
1041
+ ...acc.cacheWriteTokens != null ? { cacheWriteTokens: acc.cacheWriteTokens } : {},
1042
+ ...acc.costUsd != null ? { costUsd: acc.costUsd } : {}
1043
+ };
1044
+ }
1045
+ function hasBilledTokens(u) {
1046
+ return Boolean(
1047
+ u.inputTokens || u.outputTokens || u.cacheReadTokens || u.cacheWriteTokens
1048
+ );
1049
+ }
1050
+ function applyTurnUsage(current, incoming, scope = "request") {
1051
+ if (scope === "turn") {
1052
+ if (!hasBilledTokens(incoming) && current && incoming.costUsd != null) {
1053
+ return { ...current, costUsd: incoming.costUsd };
1054
+ }
1055
+ return {
1056
+ ...incoming,
1057
+ costUsd: incoming.costUsd ?? current?.costUsd,
1058
+ lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
1059
+ };
1060
+ }
1061
+ const merged = mergeUsage(current, incoming);
1062
+ const occ = incoming.lastRequestTokens != null && incoming.lastRequestTokens > 0 ? incoming.lastRequestTokens : requestOccupancy(incoming);
1063
+ return {
1064
+ ...merged,
1065
+ lastRequestTokens: occ > 0 ? occ : current?.lastRequestTokens ?? occ
1066
+ };
1067
+ }
1068
+ function totalTokens(u) {
1069
+ return u.inputTokens + u.outputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
1070
+ }
1071
+ function contextTokens(u) {
1072
+ if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
1073
+ return requestOccupancy(u);
1074
+ }
1075
+ var init_usage = __esm({
1076
+ "src/agents/usage.ts"() {
1077
+ "use strict";
1078
+ }
1079
+ });
1080
+
1081
+ // src/store/history-retention.ts
1082
+ function clampHistoryMaxCount(value) {
1083
+ return Math.max(HISTORY_MAX_COUNT_MIN, Math.min(HISTORY_MAX_COUNT_MAX, Math.floor(value)));
1084
+ }
1085
+ function clampHistoryMaxDays(value) {
1086
+ if (!Number.isFinite(value) || value <= 0) return 0;
1087
+ return Math.min(HISTORY_MAX_DAYS_MAX, Math.floor(value));
1088
+ }
1089
+ function archivedUpdatedMs(thread) {
1090
+ const updated = Date.parse(thread.updatedAt);
1091
+ if (Number.isFinite(updated)) return updated;
1092
+ const created = Date.parse(thread.createdAt);
1093
+ return Number.isFinite(created) ? created : 0;
1094
+ }
1095
+ function isHistoryRetentionStub(thread) {
1096
+ if ((thread.attachments?.length ?? 0) > 0) return false;
1097
+ const messages = thread.messages ?? [];
1098
+ if (messages.length === 0) return true;
1099
+ if (messages.length > 1) return false;
1100
+ const only = messages[0];
1101
+ if (only.parts?.length) return false;
1102
+ if ((only.attachments?.length ?? 0) > 0) return false;
1103
+ const text7 = (only.text ?? "").trim();
1104
+ return text7 === "" || text7 === HISTORY_DISCARDED_TEXT;
1105
+ }
1106
+ function historyRetentionStubMessage(thread) {
1107
+ const usage = sumUsageList((thread.messages ?? []).map((m) => m.usage));
1108
+ return {
1109
+ role: "summary",
1110
+ text: HISTORY_DISCARDED_TEXT,
1111
+ ts: thread.updatedAt,
1112
+ ...usage ? { usage } : {}
1113
+ };
1114
+ }
1115
+ function sortArchivedOldestFirst(threads) {
1116
+ return [...threads].sort((a, b) => archivedUpdatedMs(a) - archivedUpdatedMs(b));
1117
+ }
1118
+ function planHistoryRetention(archived, thresholds = {}) {
1119
+ const maxCount = clampHistoryMaxCount(thresholds.maxCount ?? HISTORY_MAX_COUNT_DEFAULT);
1120
+ const maxDays = clampHistoryMaxDays(thresholds.maxDays ?? HISTORY_MAX_DAYS_DEFAULT);
1121
+ const nowMs = thresholds.nowMs ?? Date.now();
1122
+ const oldestFirst = sortArchivedOldestFirst(archived);
1123
+ const expiredIds = /* @__PURE__ */ new Set();
1124
+ if (maxDays > 0) {
1125
+ const cutoff = nowMs - maxDays * 864e5;
1126
+ for (const thread of oldestFirst) {
1127
+ if (archivedUpdatedMs(thread) < cutoff) expiredIds.add(thread.id);
1128
+ }
1129
+ }
1130
+ const remaining = oldestFirst.filter((t) => !expiredIds.has(t.id));
1131
+ const overflow = remaining.length > maxCount ? remaining.slice(0, remaining.length - maxCount) : [];
1132
+ const stripIds = [];
1133
+ const purgeIds = [...expiredIds];
1134
+ const seenPurge = new Set(purgeIds);
1135
+ for (const thread of overflow) {
1136
+ if (isHistoryRetentionStub(thread)) {
1137
+ if (!seenPurge.has(thread.id)) {
1138
+ seenPurge.add(thread.id);
1139
+ purgeIds.push(thread.id);
1140
+ }
1141
+ } else {
1142
+ stripIds.push(thread.id);
1143
+ }
1144
+ }
1145
+ return { stripIds, purgeIds };
1146
+ }
1147
+ function planHistoryAgePurge(archived, olderThanDays, nowMs = Date.now()) {
1148
+ const days = clampHistoryMaxDays(olderThanDays);
1149
+ if (days <= 0) return [];
1150
+ const cutoff = nowMs - days * 864e5;
1151
+ return sortArchivedOldestFirst(archived).filter((t) => archivedUpdatedMs(t) < cutoff).map((t) => t.id);
1152
+ }
1153
+ var HISTORY_MAX_COUNT_DEFAULT, HISTORY_MAX_COUNT_MIN, HISTORY_MAX_COUNT_MAX, HISTORY_MAX_DAYS_DEFAULT, HISTORY_MAX_DAYS_MAX, HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT, HISTORY_DISCARDED_TEXT;
1154
+ var init_history_retention = __esm({
1155
+ "src/store/history-retention.ts"() {
1156
+ "use strict";
1157
+ init_usage();
1158
+ HISTORY_MAX_COUNT_DEFAULT = 200;
1159
+ HISTORY_MAX_COUNT_MIN = 1;
1160
+ HISTORY_MAX_COUNT_MAX = 2e3;
1161
+ HISTORY_MAX_DAYS_DEFAULT = 0;
1162
+ HISTORY_MAX_DAYS_MAX = 3650;
1163
+ HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT = 6;
1164
+ HISTORY_DISCARDED_TEXT = "Transcript discarded by History retention.";
1165
+ }
1166
+ });
1167
+
994
1168
  // src/store/usage-on-limit.ts
995
1169
  function isUsageOnLimit(value) {
996
1170
  return value === "keep_going" || value === "confirm" || value === "switch_agent" || value === "wait_reset";
@@ -1047,6 +1221,7 @@ __export(app_settings_exports, {
1047
1221
  appSettingsPath: () => appSettingsPath,
1048
1222
  applyAppEnvironment: () => applyAppEnvironment,
1049
1223
  autoArchiveOnMergeEnabled: () => autoArchiveOnMergeEnabled,
1224
+ autoCleanupHistoryEnabled: () => autoCleanupHistoryEnabled,
1050
1225
  autoCleanupOrphansEnabled: () => autoCleanupOrphansEnabled,
1051
1226
  autoRenameBranchEnabled: () => autoRenameBranchEnabled,
1052
1227
  autoRunAfterSetupEnabled: () => autoRunAfterSetupEnabled,
@@ -1087,6 +1262,8 @@ __export(app_settings_exports, {
1087
1262
  getLinearApiKey: () => getLinearApiKey,
1088
1263
  gitBranchPrefixSetting: () => gitBranchPrefixSetting,
1089
1264
  harnessEnvKey: () => harnessEnvKey,
1265
+ historyMaxCount: () => historyMaxCount,
1266
+ historyMaxDays: () => historyMaxDays,
1090
1267
  isAbleTimeConnected: () => isAbleTimeConnected,
1091
1268
  isIssueSourceConnected: () => isIssueSourceConnected,
1092
1269
  isLinearConnected: () => isLinearConnected,
@@ -1532,6 +1709,24 @@ function normalizeAdvanced(raw) {
1532
1709
  if (typeof source.autoCleanupOrphans === "boolean") {
1533
1710
  out.autoCleanupOrphans = source.autoCleanupOrphans;
1534
1711
  }
1712
+ if (typeof source.autoCleanupHistory === "boolean") {
1713
+ out.autoCleanupHistory = source.autoCleanupHistory;
1714
+ }
1715
+ if (typeof source.historyMaxCount === "number" && Number.isFinite(source.historyMaxCount)) {
1716
+ out.historyMaxCount = clampHistoryMaxCount(source.historyMaxCount);
1717
+ }
1718
+ if (typeof source.historyMaxDays === "number" && Number.isFinite(source.historyMaxDays)) {
1719
+ out.historyMaxDays = clampHistoryMaxDays(source.historyMaxDays);
1720
+ }
1721
+ if (typeof source.historyCleanupIntervalHours === "number" && Number.isFinite(source.historyCleanupIntervalHours)) {
1722
+ out.historyCleanupIntervalHours = Math.max(
1723
+ 1,
1724
+ Math.min(168, Math.floor(source.historyCleanupIntervalHours))
1725
+ );
1726
+ }
1727
+ if (typeof source.historyLastCleanupAt === "string" && source.historyLastCleanupAt.trim()) {
1728
+ out.historyLastCleanupAt = source.historyLastCleanupAt.trim();
1729
+ }
1535
1730
  if (source.orchestrationQuotaOnLimit === "switch_agent" || source.orchestrationQuotaOnLimit === "wait_reset") {
1536
1731
  out.orchestrationQuotaOnLimit = source.orchestrationQuotaOnLimit;
1537
1732
  }
@@ -2424,6 +2619,24 @@ function updateAdvancedSettings(patch) {
2424
2619
  if (typeof patch.autoCleanupOrphans === "boolean") {
2425
2620
  advanced.autoCleanupOrphans = patch.autoCleanupOrphans;
2426
2621
  }
2622
+ if (typeof patch.autoCleanupHistory === "boolean") {
2623
+ advanced.autoCleanupHistory = patch.autoCleanupHistory;
2624
+ }
2625
+ if (typeof patch.historyMaxCount === "number" && Number.isFinite(patch.historyMaxCount)) {
2626
+ advanced.historyMaxCount = clampHistoryMaxCount(patch.historyMaxCount);
2627
+ }
2628
+ if (typeof patch.historyMaxDays === "number" && Number.isFinite(patch.historyMaxDays)) {
2629
+ advanced.historyMaxDays = clampHistoryMaxDays(patch.historyMaxDays);
2630
+ }
2631
+ if (typeof patch.historyCleanupIntervalHours === "number" && Number.isFinite(patch.historyCleanupIntervalHours)) {
2632
+ advanced.historyCleanupIntervalHours = Math.max(
2633
+ 1,
2634
+ Math.min(168, Math.floor(patch.historyCleanupIntervalHours))
2635
+ );
2636
+ }
2637
+ if (typeof patch.historyLastCleanupAt === "string") {
2638
+ advanced.historyLastCleanupAt = patch.historyLastCleanupAt;
2639
+ }
2427
2640
  if (patch.orchestrationQuotaOnLimit === "switch_agent" || patch.orchestrationQuotaOnLimit === "wait_reset") {
2428
2641
  advanced.orchestrationQuotaOnLimit = patch.orchestrationQuotaOnLimit;
2429
2642
  }
@@ -2474,6 +2687,15 @@ function autoArchiveOnMergeEnabled(settings = loadAppSettings()) {
2474
2687
  function autoCleanupOrphansEnabled(settings = loadAppSettings()) {
2475
2688
  return Boolean(settings.advanced.autoCleanupOrphans);
2476
2689
  }
2690
+ function autoCleanupHistoryEnabled(settings = loadAppSettings()) {
2691
+ return settings.advanced.autoCleanupHistory !== false;
2692
+ }
2693
+ function historyMaxCount(settings = loadAppSettings()) {
2694
+ return clampHistoryMaxCount(settings.advanced.historyMaxCount ?? HISTORY_MAX_COUNT_DEFAULT);
2695
+ }
2696
+ function historyMaxDays(settings = loadAppSettings()) {
2697
+ return clampHistoryMaxDays(settings.advanced.historyMaxDays ?? HISTORY_MAX_DAYS_DEFAULT);
2698
+ }
2477
2699
  function usageOnLimit(settings = loadAppSettings()) {
2478
2700
  return resolveUsageOnLimit(settings.advanced);
2479
2701
  }
@@ -2594,6 +2816,7 @@ var init_app_settings = __esm({
2594
2816
  init_private_file();
2595
2817
  init_secret_vault();
2596
2818
  init_branch_prefix();
2819
+ init_history_retention();
2597
2820
  init_usage_on_limit();
2598
2821
  init_usage_on_limit();
2599
2822
  init_issue_source_labels();
@@ -2814,6 +3037,37 @@ var init_caffeinate_hold = __esm({
2814
3037
  }
2815
3038
  });
2816
3039
 
3040
+ // src/agents/cursor-store.ts
3041
+ function cursorSdkStoreDir(threadId) {
3042
+ const root = (0, import_node_path10.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
3043
+ const id = sanitizeCursorStoreSegment(threadId);
3044
+ if (!id) return root;
3045
+ return (0, import_node_path10.join)(root, "threads", id);
3046
+ }
3047
+ function cursorSdkRunsNdjsonPath(threadId) {
3048
+ return (0, import_node_path10.join)(cursorSdkStoreDir(threadId), "runs.ndjson");
3049
+ }
3050
+ function cursorSdkRunsNdjsonSearchPaths(threadId) {
3051
+ const scoped = cursorSdkRunsNdjsonPath(threadId);
3052
+ const shared = cursorSdkRunsNdjsonPath(null);
3053
+ if (!threadId || !sanitizeCursorStoreSegment(threadId) || scoped === shared) {
3054
+ return [shared];
3055
+ }
3056
+ return [scoped, shared];
3057
+ }
3058
+ function sanitizeCursorStoreSegment(threadId) {
3059
+ return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
3060
+ }
3061
+ var import_node_path10, CURSOR_SDK_STORE_DIR;
3062
+ var init_cursor_store = __esm({
3063
+ "src/agents/cursor-store.ts"() {
3064
+ "use strict";
3065
+ import_node_path10 = require("path");
3066
+ init_paths();
3067
+ CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
3068
+ }
3069
+ });
3070
+
2817
3071
  // src/store/thread-store.ts
2818
3072
  var thread_store_exports = {};
2819
3073
  __export(thread_store_exports, {
@@ -2971,10 +3225,10 @@ function readThread(id) {
2971
3225
  rememberThread(thread, mtimeMs);
2972
3226
  return thread;
2973
3227
  }
2974
- function writeThread(thread) {
3228
+ function writeThread(thread, opts) {
2975
3229
  const path2 = threadFilePath(idPath(thread.id));
2976
3230
  const tmp = `${path2}.${process.pid}.tmp`;
2977
- const next = { ...thread, updatedAt: nowIso() };
3231
+ const next = opts?.touch === false ? { ...thread } : { ...thread, updatedAt: nowIso() };
2978
3232
  (0, import_node_fs9.writeFileSync)(tmp, JSON.stringify(next, null, 2), "utf8");
2979
3233
  (0, import_node_fs9.renameSync)(tmp, path2);
2980
3234
  rememberThread(next, fileMtimeMs(path2) ?? Date.now());
@@ -2983,7 +3237,7 @@ function idPath(id) {
2983
3237
  return id;
2984
3238
  }
2985
3239
  function isThreadRecordFile(nameOrPath) {
2986
- const name = (0, import_node_path10.basename)(nameOrPath);
3240
+ const name = (0, import_node_path11.basename)(nameOrPath);
2987
3241
  return name.endsWith(".json") && !name.endsWith(".live.json");
2988
3242
  }
2989
3243
  function listThreads(opts) {
@@ -3019,6 +3273,10 @@ function deleteThreadRecord(id) {
3019
3273
  } catch {
3020
3274
  }
3021
3275
  }
3276
+ try {
3277
+ (0, import_node_fs9.rmSync)(cursorSdkStoreDir(id), { recursive: true, force: true });
3278
+ } catch {
3279
+ }
3022
3280
  }
3023
3281
  function updateThread(id, patch) {
3024
3282
  const current = readThread(id);
@@ -3041,15 +3299,16 @@ function findThreadByRef(ref) {
3041
3299
  (t) => t.id === ref || t.id.startsWith(ref) || t.branchName === ref || t.title === ref
3042
3300
  ) ?? null;
3043
3301
  }
3044
- var import_node_crypto3, import_node_fs9, import_node_path10, import_proper_lockfile, listCache;
3302
+ var import_node_crypto3, import_node_fs9, import_node_path11, import_proper_lockfile, listCache;
3045
3303
  var init_thread_store = __esm({
3046
3304
  "src/store/thread-store.ts"() {
3047
3305
  "use strict";
3048
3306
  import_node_crypto3 = require("crypto");
3049
3307
  import_node_fs9 = require("fs");
3050
- import_node_path10 = require("path");
3308
+ import_node_path11 = require("path");
3051
3309
  import_proper_lockfile = __toESM(require("proper-lockfile"), 1);
3052
3310
  init_thinking_effort();
3311
+ init_cursor_store();
3053
3312
  init_paths();
3054
3313
  listCache = null;
3055
3314
  }
@@ -4048,93 +4307,6 @@ var init_message_parts = __esm({
4048
4307
  }
4049
4308
  });
4050
4309
 
4051
- // src/agents/usage.ts
4052
- function sumOptional(a, b) {
4053
- if (a == null && b == null) return void 0;
4054
- return (a ?? 0) + (b ?? 0);
4055
- }
4056
- function fromInclusiveInputUsage(opts) {
4057
- const totalInput = Number(opts.inputTokens) || 0;
4058
- const outputTokens = Number(opts.outputTokens) || 0;
4059
- const cached = Number(opts.cachedInputTokens) || 0;
4060
- if (!totalInput && !outputTokens) return null;
4061
- const cacheReadTokens = cached > 0 ? Math.min(cached, totalInput) : 0;
4062
- return {
4063
- inputTokens: Math.max(0, totalInput - cacheReadTokens),
4064
- outputTokens,
4065
- cacheReadTokens: cacheReadTokens || void 0
4066
- };
4067
- }
4068
- function requestOccupancy(u) {
4069
- return u.inputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
4070
- }
4071
- function mergeUsage(a, b) {
4072
- return {
4073
- inputTokens: (a?.inputTokens ?? 0) + b.inputTokens,
4074
- outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
4075
- cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
4076
- cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
4077
- costUsd: sumOptional(a?.costUsd, b.costUsd),
4078
- lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
4079
- };
4080
- }
4081
- function sumUsageList(list) {
4082
- let acc = null;
4083
- for (const u of list) {
4084
- if (!u) continue;
4085
- acc = mergeUsage(acc, {
4086
- inputTokens: u.inputTokens,
4087
- outputTokens: u.outputTokens,
4088
- cacheReadTokens: u.cacheReadTokens,
4089
- cacheWriteTokens: u.cacheWriteTokens,
4090
- costUsd: u.costUsd
4091
- });
4092
- }
4093
- if (!acc) return null;
4094
- return {
4095
- inputTokens: acc.inputTokens,
4096
- outputTokens: acc.outputTokens,
4097
- ...acc.cacheReadTokens != null ? { cacheReadTokens: acc.cacheReadTokens } : {},
4098
- ...acc.cacheWriteTokens != null ? { cacheWriteTokens: acc.cacheWriteTokens } : {},
4099
- ...acc.costUsd != null ? { costUsd: acc.costUsd } : {}
4100
- };
4101
- }
4102
- function hasBilledTokens(u) {
4103
- return Boolean(
4104
- u.inputTokens || u.outputTokens || u.cacheReadTokens || u.cacheWriteTokens
4105
- );
4106
- }
4107
- function applyTurnUsage(current, incoming, scope = "request") {
4108
- if (scope === "turn") {
4109
- if (!hasBilledTokens(incoming) && current && incoming.costUsd != null) {
4110
- return { ...current, costUsd: incoming.costUsd };
4111
- }
4112
- return {
4113
- ...incoming,
4114
- costUsd: incoming.costUsd ?? current?.costUsd,
4115
- lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
4116
- };
4117
- }
4118
- const merged = mergeUsage(current, incoming);
4119
- const occ = incoming.lastRequestTokens != null && incoming.lastRequestTokens > 0 ? incoming.lastRequestTokens : requestOccupancy(incoming);
4120
- return {
4121
- ...merged,
4122
- lastRequestTokens: occ > 0 ? occ : current?.lastRequestTokens ?? occ
4123
- };
4124
- }
4125
- function totalTokens(u) {
4126
- return u.inputTokens + u.outputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
4127
- }
4128
- function contextTokens(u) {
4129
- if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
4130
- return requestOccupancy(u);
4131
- }
4132
- var init_usage = __esm({
4133
- "src/agents/usage.ts"() {
4134
- "use strict";
4135
- }
4136
- });
4137
-
4138
4310
  // src/git/team-meta.ts
4139
4311
  var SOCCER_TEAM_META;
4140
4312
  var init_team_meta = __esm({
@@ -5574,7 +5746,7 @@ ${line}` : line;
5574
5746
  return nl >= 0 && nl < cut.length - 1 ? cut.slice(nl + 1) : cut;
5575
5747
  }
5576
5748
  function setupLogPath(threadId) {
5577
- return (0, import_node_path11.join)(threadsDir(), `${threadId}.setup.log.json`);
5749
+ return (0, import_node_path12.join)(threadsDir(), `${threadId}.setup.log.json`);
5578
5750
  }
5579
5751
  function setupLogKeyForWorktree(worktreePath) {
5580
5752
  const norm = normalizeWorktreePath(worktreePath);
@@ -5677,13 +5849,13 @@ function finishSetupLog(threadId, exitCode, source) {
5677
5849
  persistNow(threadId);
5678
5850
  return clone(snap);
5679
5851
  }
5680
- var import_node_crypto4, import_node_fs10, import_node_path11, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers;
5852
+ var import_node_crypto4, import_node_fs10, import_node_path12, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers;
5681
5853
  var init_setup_log = __esm({
5682
5854
  "src/store/setup-log.ts"() {
5683
5855
  "use strict";
5684
5856
  import_node_crypto4 = require("crypto");
5685
5857
  import_node_fs10 = require("fs");
5686
- import_node_path11 = require("path");
5858
+ import_node_path12 = require("path");
5687
5859
  init_worktree_labels();
5688
5860
  init_paths();
5689
5861
  EMPTY = {
@@ -5700,7 +5872,7 @@ var init_setup_log = __esm({
5700
5872
 
5701
5873
  // src/store/schedules.ts
5702
5874
  function schedulesPath() {
5703
- return (0, import_node_path12.join)(appDataDir(), "schedules.json");
5875
+ return (0, import_node_path13.join)(appDataDir(), "schedules.json");
5704
5876
  }
5705
5877
  function parseDurationMs(every) {
5706
5878
  const m = every.trim().match(DURATION_RE);
@@ -5923,13 +6095,13 @@ function recordScheduleRun(id, result) {
5923
6095
  writeAll(rows);
5924
6096
  return next;
5925
6097
  }
5926
- var import_node_crypto5, import_node_fs11, import_node_path12, import_croner, DURATION_RE, UNIT_MS;
6098
+ var import_node_crypto5, import_node_fs11, import_node_path13, import_croner, DURATION_RE, UNIT_MS;
5927
6099
  var init_schedules = __esm({
5928
6100
  "src/store/schedules.ts"() {
5929
6101
  "use strict";
5930
6102
  import_node_crypto5 = require("crypto");
5931
6103
  import_node_fs11 = require("fs");
5932
- import_node_path12 = require("path");
6104
+ import_node_path13 = require("path");
5933
6105
  import_croner = require("croner");
5934
6106
  init_orchestrator_capable();
5935
6107
  init_paths();
@@ -5946,7 +6118,7 @@ var init_schedules = __esm({
5946
6118
 
5947
6119
  // src/store/desktop-host.ts
5948
6120
  function desktopHostPidPath() {
5949
- return (0, import_node_path13.join)(appDataDir(), "desktop-host.pid");
6121
+ return (0, import_node_path14.join)(appDataDir(), "desktop-host.pid");
5950
6122
  }
5951
6123
  function claimDesktopHost(pid = process.pid) {
5952
6124
  (0, import_node_fs12.writeFileSync)(desktopHostPidPath(), `${pid}
@@ -5987,12 +6159,12 @@ function thisProcessShouldDrainAgentQueues() {
5987
6159
  if (isThisProcessDesktopHost()) return true;
5988
6160
  return !isDesktopHostAlive();
5989
6161
  }
5990
- var import_node_fs12, import_node_path13;
6162
+ var import_node_fs12, import_node_path14;
5991
6163
  var init_desktop_host = __esm({
5992
6164
  "src/store/desktop-host.ts"() {
5993
6165
  "use strict";
5994
6166
  import_node_fs12 = require("fs");
5995
- import_node_path13 = require("path");
6167
+ import_node_path14 = require("path");
5996
6168
  init_paths();
5997
6169
  }
5998
6170
  });
@@ -6059,7 +6231,7 @@ var init_workspace_scratch = __esm({
6059
6231
 
6060
6232
  // src/composer/stage-files.ts
6061
6233
  function fileExtension(filePath) {
6062
- const base = (0, import_node_path14.basename)(filePath).toLowerCase();
6234
+ const base = (0, import_node_path15.basename)(filePath).toLowerCase();
6063
6235
  return base.includes(".") ? base.split(".").pop() || "" : "";
6064
6236
  }
6065
6237
  function isImageFilePath(filePath) {
@@ -6069,9 +6241,9 @@ function imageMimeType(filePath) {
6069
6241
  return IMAGE_MIME_BY_EXT[fileExtension(filePath)] || "image/png";
6070
6242
  }
6071
6243
  function ensureAttachmentsDir(worktreePath) {
6072
- const dir = (0, import_node_path14.join)(worktreePath, ATTACHMENTS_DIR);
6244
+ const dir = (0, import_node_path15.join)(worktreePath, ATTACHMENTS_DIR);
6073
6245
  (0, import_node_fs13.mkdirSync)(dir, { recursive: true });
6074
- const gi = (0, import_node_path14.join)(dir, ".gitignore");
6246
+ const gi = (0, import_node_path15.join)(dir, ".gitignore");
6075
6247
  if (!(0, import_node_fs13.existsSync)(gi)) {
6076
6248
  (0, import_node_fs13.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
6077
6249
  }
@@ -6079,12 +6251,12 @@ function ensureAttachmentsDir(worktreePath) {
6079
6251
  }
6080
6252
  function uniqueAttachmentName(dir, originalName) {
6081
6253
  const safe = originalName.replace(/[/\\]/g, "_") || "file";
6082
- if (!(0, import_node_fs13.existsSync)((0, import_node_path14.join)(dir, safe))) return safe;
6083
- const ext = (0, import_node_path14.extname)(safe);
6254
+ if (!(0, import_node_fs13.existsSync)((0, import_node_path15.join)(dir, safe))) return safe;
6255
+ const ext = (0, import_node_path15.extname)(safe);
6084
6256
  const stem = ext ? safe.slice(0, -ext.length) : safe;
6085
6257
  for (let i = 1; i < 1e4; i++) {
6086
6258
  const candidate = `${stem}-${i}${ext}`;
6087
- if (!(0, import_node_fs13.existsSync)((0, import_node_path14.join)(dir, candidate))) return candidate;
6259
+ if (!(0, import_node_fs13.existsSync)((0, import_node_path15.join)(dir, candidate))) return candidate;
6088
6260
  }
6089
6261
  return `${stem}-${(0, import_node_crypto6.randomUUID)()}${ext}`;
6090
6262
  }
@@ -6136,7 +6308,7 @@ function attachmentFromBuffer(name, buf, opts) {
6136
6308
  };
6137
6309
  }
6138
6310
  function attachmentFromAbsolutePath(absolutePath) {
6139
- const name = (0, import_node_path14.basename)(absolutePath);
6311
+ const name = (0, import_node_path15.basename)(absolutePath);
6140
6312
  try {
6141
6313
  const st = (0, import_node_fs13.statSync)(absolutePath);
6142
6314
  if (!st.isFile()) {
@@ -6163,12 +6335,12 @@ function stageAbsolutePathsAsAttachments(worktreePath, absolutePaths) {
6163
6335
  const dir = ensureAttachmentsDir(worktreePath);
6164
6336
  const out = [];
6165
6337
  for (const abs of absolutePaths) {
6166
- const originalName = (0, import_node_path14.basename)(abs);
6338
+ const originalName = (0, import_node_path15.basename)(abs);
6167
6339
  try {
6168
6340
  const st = (0, import_node_fs13.statSync)(abs);
6169
6341
  if (!st.isFile()) continue;
6170
6342
  const name = uniqueAttachmentName(dir, originalName);
6171
- const destAbs = (0, import_node_path14.join)(dir, name);
6343
+ const destAbs = (0, import_node_path15.join)(dir, name);
6172
6344
  (0, import_node_fs13.copyFileSync)(abs, destAbs);
6173
6345
  const rel = `${ATTACHMENTS_DIR}/${name}`;
6174
6346
  const buf = (0, import_node_fs13.readFileSync)(destAbs);
@@ -6193,7 +6365,7 @@ function stageBuffersAsAttachments(worktreePath, buffers2) {
6193
6365
  try {
6194
6366
  const buf = Buffer.from(item.dataBase64, "base64");
6195
6367
  const name = uniqueAttachmentName(dir, originalName);
6196
- const destAbs = (0, import_node_path14.join)(dir, name);
6368
+ const destAbs = (0, import_node_path15.join)(dir, name);
6197
6369
  (0, import_node_fs13.writeFileSync)(destAbs, buf);
6198
6370
  const rel = `${ATTACHMENTS_DIR}/${name}`;
6199
6371
  out.push(attachmentFromBuffer(name, buf, { path: rel }));
@@ -6271,15 +6443,15 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
6271
6443
  if (!rel || rel.includes("..") || rel.startsWith("/")) {
6272
6444
  out.push({
6273
6445
  id: (0, import_node_crypto6.randomUUID)(),
6274
- name: (0, import_node_path14.basename)(rel) || "file",
6446
+ name: (0, import_node_path15.basename)(rel) || "file",
6275
6447
  kind: "file",
6276
6448
  content: `(invalid path: ${rel})`
6277
6449
  });
6278
6450
  continue;
6279
6451
  }
6280
- const name = (0, import_node_path14.basename)(rel);
6452
+ const name = (0, import_node_path15.basename)(rel);
6281
6453
  try {
6282
- const abs = (0, import_node_path14.join)(worktreePath, rel);
6454
+ const abs = (0, import_node_path15.join)(worktreePath, rel);
6283
6455
  const st = (0, import_node_fs13.statSync)(abs);
6284
6456
  if (!st.isFile()) continue;
6285
6457
  const buf = (0, import_node_fs13.readFileSync)(abs);
@@ -6295,12 +6467,12 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
6295
6467
  }
6296
6468
  return out;
6297
6469
  }
6298
- var import_node_fs13, import_node_path14, import_node_crypto6, IMAGE_EXTENSIONS, IMAGE_MIME_BY_EXT, MAX_INLINE_BYTES, MAX_PREVIEW_BYTES, IMAGE_HINT_RE, PLACEHOLDER_CONTENT_RE;
6470
+ var import_node_fs13, import_node_path15, import_node_crypto6, IMAGE_EXTENSIONS, IMAGE_MIME_BY_EXT, MAX_INLINE_BYTES, MAX_PREVIEW_BYTES, IMAGE_HINT_RE, PLACEHOLDER_CONTENT_RE;
6299
6471
  var init_stage_files = __esm({
6300
6472
  "src/composer/stage-files.ts"() {
6301
6473
  "use strict";
6302
6474
  import_node_fs13 = require("fs");
6303
- import_node_path14 = require("path");
6475
+ import_node_path15 = require("path");
6304
6476
  import_node_crypto6 = require("crypto");
6305
6477
  init_workspace_scratch();
6306
6478
  IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
@@ -6444,15 +6616,15 @@ var init_gh_errors = __esm({
6444
6616
  function prependPathDir(env, dir) {
6445
6617
  if (!dir || !(0, import_node_fs14.existsSync)(dir)) return;
6446
6618
  const current = env.PATH ?? "";
6447
- const parts = current.split(import_node_path15.delimiter).filter(Boolean);
6619
+ const parts = current.split(import_node_path16.delimiter).filter(Boolean);
6448
6620
  if (parts.includes(dir)) {
6449
6621
  env.PATH = current;
6450
6622
  return;
6451
6623
  }
6452
- env.PATH = [dir, ...parts].join(import_node_path15.delimiter);
6624
+ env.PATH = [dir, ...parts].join(import_node_path16.delimiter);
6453
6625
  }
6454
6626
  function conductorBundledBinDir(home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os4.homedir)()) {
6455
- return (0, import_node_path15.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
6627
+ return (0, import_node_path16.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
6456
6628
  }
6457
6629
  function isConductorBundledCli(filePath) {
6458
6630
  const p = (filePath ?? "").replace(/\\/g, "/");
@@ -6461,10 +6633,10 @@ function isConductorBundledCli(filePath) {
6461
6633
  function ensureAgentPath(env = process.env) {
6462
6634
  const home = env.HOME || env.USERPROFILE || (0, import_node_os4.homedir)();
6463
6635
  const current = env.PATH ?? "";
6464
- const parts = current.split(import_node_path15.delimiter).filter(Boolean);
6636
+ const parts = current.split(import_node_path16.delimiter).filter(Boolean);
6465
6637
  const seen = new Set(parts);
6466
6638
  const extras = [
6467
- ...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path15.join)(home, rel)),
6639
+ ...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path16.join)(home, rel)),
6468
6640
  "/opt/homebrew/bin",
6469
6641
  "/usr/local/bin",
6470
6642
  // Keep after Homebrew/npm so a user-installed CLI still wins.
@@ -6475,7 +6647,7 @@ function ensureAgentPath(env = process.env) {
6475
6647
  parts.unshift(dir);
6476
6648
  seen.add(dir);
6477
6649
  }
6478
- const next = parts.join(import_node_path15.delimiter);
6650
+ const next = parts.join(import_node_path16.delimiter);
6479
6651
  env.PATH = next;
6480
6652
  return next;
6481
6653
  }
@@ -6489,7 +6661,7 @@ function enrichPathWithNpmGlobalBin(env = process.env) {
6489
6661
  stdio: ["ignore", "pipe", "ignore"]
6490
6662
  }).trim().split(/\r?\n/).find(Boolean);
6491
6663
  if (prefix) {
6492
- const binDir = process.platform === "win32" ? prefix : (0, import_node_path15.join)(prefix, "bin");
6664
+ const binDir = process.platform === "win32" ? prefix : (0, import_node_path16.join)(prefix, "bin");
6493
6665
  prependPathDir(env, binDir);
6494
6666
  }
6495
6667
  } catch {
@@ -6517,14 +6689,14 @@ function withExportedPath(command, pathValue) {
6517
6689
  if (/^(export\s+PATH=|PATH=)/.test(trimmed)) return trimmed;
6518
6690
  return `export PATH=${posixShellSingleQuote(pathValue)} && ${trimmed}`;
6519
6691
  }
6520
- var import_node_fs14, import_node_child_process3, import_node_os4, import_node_path15, EXTRA_BIN_DIRS;
6692
+ var import_node_fs14, import_node_child_process3, import_node_os4, import_node_path16, EXTRA_BIN_DIRS;
6521
6693
  var init_path = __esm({
6522
6694
  "src/agents/path.ts"() {
6523
6695
  "use strict";
6524
6696
  import_node_fs14 = require("fs");
6525
6697
  import_node_child_process3 = require("child_process");
6526
6698
  import_node_os4 = require("os");
6527
- import_node_path15 = require("path");
6699
+ import_node_path16 = require("path");
6528
6700
  EXTRA_BIN_DIRS = [
6529
6701
  ".local/bin",
6530
6702
  ".cargo/bin",
@@ -6545,18 +6717,18 @@ var init_path = __esm({
6545
6717
  function githubAgentAuthDir() {
6546
6718
  const override = process.env.SIDEBOARD_GIT_AUTH_DIR?.trim();
6547
6719
  if (override) return override;
6548
- return (0, import_node_path16.join)((0, import_node_os5.homedir)(), ".sideboard-git-auth");
6720
+ return (0, import_node_path17.join)((0, import_node_os5.homedir)(), ".sideboard-git-auth");
6549
6721
  }
6550
6722
  function githubCredentialStorePath() {
6551
- return (0, import_node_path16.join)(githubAgentAuthDir(), "git-credentials");
6723
+ return (0, import_node_path17.join)(githubAgentAuthDir(), "git-credentials");
6552
6724
  }
6553
6725
  function githubGhConfigDir() {
6554
- return (0, import_node_path16.join)(githubAgentAuthDir(), "gh");
6726
+ return (0, import_node_path17.join)(githubAgentAuthDir(), "gh");
6555
6727
  }
6556
6728
  function writePrivateFile2(file, body) {
6557
- (0, import_node_fs15.mkdirSync)((0, import_node_path16.dirname)(file), { recursive: true, mode: 448 });
6729
+ (0, import_node_fs15.mkdirSync)((0, import_node_path17.dirname)(file), { recursive: true, mode: 448 });
6558
6730
  try {
6559
- (0, import_node_fs15.chmodSync)((0, import_node_path16.dirname)(file), 448);
6731
+ (0, import_node_fs15.chmodSync)((0, import_node_path17.dirname)(file), 448);
6560
6732
  } catch {
6561
6733
  }
6562
6734
  (0, import_node_fs15.writeFileSync)(file, body, { encoding: "utf8", mode: 384 });
@@ -6594,11 +6766,11 @@ function materializeGithubAgentAuth(token, user) {
6594
6766
  writePrivateFile2(githubCredentialStorePath(), gitCredentialStoreContents(trimmed));
6595
6767
  const ghDir = githubGhConfigDir();
6596
6768
  (0, import_node_fs15.mkdirSync)(ghDir, { recursive: true, mode: 448 });
6597
- writePrivateFile2((0, import_node_path16.join)(ghDir, "hosts.yml"), ghHostsYml(trimmed, user));
6598
- writePrivateFile2((0, import_node_path16.join)(ghDir, "config.yml"), "git_protocol: https\nprompt: disabled\n");
6769
+ writePrivateFile2((0, import_node_path17.join)(ghDir, "hosts.yml"), ghHostsYml(trimmed, user));
6770
+ writePrivateFile2((0, import_node_path17.join)(ghDir, "config.yml"), "git_protocol: https\nprompt: disabled\n");
6599
6771
  }
6600
6772
  function githubAgentAuthReady() {
6601
- return (0, import_node_fs15.existsSync)(githubCredentialStorePath()) && (0, import_node_fs15.existsSync)((0, import_node_path16.join)(githubGhConfigDir(), "hosts.yml"));
6773
+ return (0, import_node_fs15.existsSync)(githubCredentialStorePath()) && (0, import_node_fs15.existsSync)((0, import_node_path17.join)(githubGhConfigDir(), "hosts.yml"));
6602
6774
  }
6603
6775
  function githubCredentialHelperGitConfig() {
6604
6776
  const file = githubCredentialStorePath();
@@ -6613,13 +6785,13 @@ function githubGhConfigEnv() {
6613
6785
  GH_PROMPT_DISABLED: "1"
6614
6786
  };
6615
6787
  }
6616
- var import_node_fs15, import_node_os5, import_node_path16;
6788
+ var import_node_fs15, import_node_os5, import_node_path17;
6617
6789
  var init_github_agent_auth = __esm({
6618
6790
  "src/git/github-agent-auth.ts"() {
6619
6791
  "use strict";
6620
6792
  import_node_fs15 = require("fs");
6621
6793
  import_node_os5 = require("os");
6622
- import_node_path16 = require("path");
6794
+ import_node_path17 = require("path");
6623
6795
  }
6624
6796
  });
6625
6797
 
@@ -6628,7 +6800,7 @@ function isIndexLockError(text7) {
6628
6800
  return /Unable to create ['"][^'"]*index\.lock['"]: File exists/i.test(text7);
6629
6801
  }
6630
6802
  function clearStaleIndexLock(gitDir, maxAgeMs = STALE_INDEX_LOCK_MS, now = Date.now()) {
6631
- const lockPath = (0, import_node_path17.join)(gitDir, "index.lock");
6803
+ const lockPath = (0, import_node_path18.join)(gitDir, "index.lock");
6632
6804
  try {
6633
6805
  if (!(0, import_node_fs16.existsSync)(lockPath)) return null;
6634
6806
  if (now - (0, import_node_fs16.statSync)(lockPath).mtimeMs < maxAgeMs) return null;
@@ -6647,12 +6819,12 @@ function clearStaleIndexLocks(gitDirs, maxAgeMs = STALE_INDEX_LOCK_MS) {
6647
6819
  }
6648
6820
  return removed;
6649
6821
  }
6650
- var import_node_fs16, import_node_path17, STALE_INDEX_LOCK_MS;
6822
+ var import_node_fs16, import_node_path18, STALE_INDEX_LOCK_MS;
6651
6823
  var init_stale_lock = __esm({
6652
6824
  "src/git/stale-lock.ts"() {
6653
6825
  "use strict";
6654
6826
  import_node_fs16 = require("fs");
6655
- import_node_path17 = require("path");
6827
+ import_node_path18 = require("path");
6656
6828
  STALE_INDEX_LOCK_MS = 2e4;
6657
6829
  }
6658
6830
  });
@@ -6792,8 +6964,8 @@ async function ensureWorktreeSideboardIgnored(worktreePath) {
6792
6964
  if (gitDir.exitCode !== 0) return;
6793
6965
  const dir = gitDir.stdout.trim();
6794
6966
  if (!dir) return;
6795
- const excludePath = (0, import_node_path18.join)(dir, "info", "exclude");
6796
- (0, import_node_fs17.mkdirSync)((0, import_node_path18.dirname)(excludePath), { recursive: true });
6967
+ const excludePath = (0, import_node_path19.join)(dir, "info", "exclude");
6968
+ (0, import_node_fs17.mkdirSync)((0, import_node_path19.dirname)(excludePath), { recursive: true });
6797
6969
  let body = "";
6798
6970
  try {
6799
6971
  body = (0, import_node_fs17.readFileSync)(excludePath, "utf8");
@@ -6827,12 +6999,12 @@ async function ensureWorktreeSideboardIgnored(worktreePath) {
6827
6999
  timeoutMs: 8e3
6828
7000
  });
6829
7001
  }
6830
- var import_node_fs17, import_node_path18, WORKTREE_SIDEBOARD_EXCLUDE, WORKTREE_CONTEXT_EXCLUDE, EXCLUDE_COMMENT;
7002
+ var import_node_fs17, import_node_path19, WORKTREE_SIDEBOARD_EXCLUDE, WORKTREE_CONTEXT_EXCLUDE, EXCLUDE_COMMENT;
6831
7003
  var init_worktree_exclude = __esm({
6832
7004
  "src/git/worktree-exclude.ts"() {
6833
7005
  "use strict";
6834
7006
  import_node_fs17 = require("fs");
6835
- import_node_path18 = require("path");
7007
+ import_node_path19 = require("path");
6836
7008
  init_run();
6837
7009
  WORKTREE_SIDEBOARD_EXCLUDE = ".sideboard/";
6838
7010
  WORKTREE_CONTEXT_EXCLUDE = ".context/";
@@ -6953,7 +7125,7 @@ async function warmGithubAgentAuth(opts) {
6953
7125
  }
6954
7126
  function normalizeWritableRoot(raw) {
6955
7127
  const trimmed = raw.trim().replace(/\/+$/, "");
6956
- return trimmed && (0, import_node_path19.isAbsolute)(trimmed) ? trimmed : null;
7128
+ return trimmed && (0, import_node_path20.isAbsolute)(trimmed) ? trimmed : null;
6957
7129
  }
6958
7130
  async function resolveCodexGitWritableRoots(cwd) {
6959
7131
  const roots = /* @__PURE__ */ new Set();
@@ -7031,11 +7203,11 @@ function formatGitAuthModeDirective(mode) {
7031
7203
  ].join("\n");
7032
7204
  }
7033
7205
  }
7034
- var import_node_path19, HTTPS_REWRITE, TOKEN_TTL_MS, tokenMemo, GITHUB_CHILD_TOKEN_KEYS;
7206
+ var import_node_path20, HTTPS_REWRITE, TOKEN_TTL_MS, tokenMemo, GITHUB_CHILD_TOKEN_KEYS;
7035
7207
  var init_git_auth_mode = __esm({
7036
7208
  "src/git/git-auth-mode.ts"() {
7037
7209
  "use strict";
7038
- import_node_path19 = require("path");
7210
+ import_node_path20 = require("path");
7039
7211
  init_app_settings();
7040
7212
  init_github_agent_auth();
7041
7213
  init_run();
@@ -8724,7 +8896,7 @@ async function refreshOriginAndMaybeFastForwardMain(repoPath, sourceRef) {
8724
8896
  }
8725
8897
  async function createThreadWorktree(opts) {
8726
8898
  let branchName = `thread/${opts.slug}`;
8727
- const worktreePath = (0, import_node_path20.join)(worktreesRoot(opts.repoPath), opts.slug);
8899
+ const worktreePath = (0, import_node_path21.join)(worktreesRoot(opts.repoPath), opts.slug);
8728
8900
  if ((0, import_node_fs18.existsSync)(worktreePath)) {
8729
8901
  throw new Error(`Worktree already exists at ${worktreePath}`);
8730
8902
  }
@@ -8766,7 +8938,7 @@ ${add.stdout}`;
8766
8938
  async function createExistingBranchWorktree(opts) {
8767
8939
  const branchName = opts.branchName.trim();
8768
8940
  if (!branchName) throw new Error("branch name required");
8769
- const worktreePath = (0, import_node_path20.join)(worktreesRoot(opts.repoPath), opts.slug);
8941
+ const worktreePath = (0, import_node_path21.join)(worktreesRoot(opts.repoPath), opts.slug);
8770
8942
  if ((0, import_node_fs18.existsSync)(worktreePath)) {
8771
8943
  throw new Error(`Worktree already exists at ${worktreePath}`);
8772
8944
  }
@@ -9048,7 +9220,7 @@ async function createOrUpdatePr(worktreePath, opts) {
9048
9220
  const headRef = ghHeadRef(slug, opts.head);
9049
9221
  const branchOnly = opts.head.trim().replace(/^refs\/heads\//, "");
9050
9222
  const bodyText = clampGithubPrBody(opts.body ?? opts.title);
9051
- const bodyFile = (0, import_node_path20.join)(
9223
+ const bodyFile = (0, import_node_path21.join)(
9052
9224
  (0, import_node_os6.tmpdir)(),
9053
9225
  `sideboard-pr-body-${process.pid}-${(0, import_node_crypto7.randomBytes)(6).toString("hex")}.md`
9054
9226
  );
@@ -9148,7 +9320,7 @@ function sameRepoPath2(a, b) {
9148
9320
  return normalizeWorktreePath(a) === normalizeWorktreePath(b);
9149
9321
  }
9150
9322
  function listLocalThreadBranchSlugs(repoPath) {
9151
- const refsDir = (0, import_node_path20.join)(repoPath, ".git", "refs", "heads", "thread");
9323
+ const refsDir = (0, import_node_path21.join)(repoPath, ".git", "refs", "heads", "thread");
9152
9324
  if (!(0, import_node_fs18.existsSync)(refsDir)) return [];
9153
9325
  try {
9154
9326
  return (0, import_node_fs18.readdirSync)(refsDir).filter((name) => !name.startsWith(".")).map((name) => normalizeTakenSlug(name));
@@ -9185,20 +9357,20 @@ function allocateTeamSlug(repoPath) {
9185
9357
  const taken = collectTakenTeamSlugs(repoPath);
9186
9358
  for (let attempt = 0; attempt < 32; attempt++) {
9187
9359
  const team = allocateTeamName(taken);
9188
- const path2 = (0, import_node_path20.join)(worktreesRoot(repoPath), team.slug);
9360
+ const path2 = (0, import_node_path21.join)(worktreesRoot(repoPath), team.slug);
9189
9361
  if (!(0, import_node_fs18.existsSync)(path2)) return team;
9190
9362
  taken.add(team.slug);
9191
9363
  }
9192
9364
  throw new Error("No available soccer team worktree directories left");
9193
9365
  }
9194
- var import_node_crypto7, import_node_fs18, import_node_os6, import_node_path20, PR_DETAILS_JSON_FIELDS;
9366
+ var import_node_crypto7, import_node_fs18, import_node_os6, import_node_path21, PR_DETAILS_JSON_FIELDS;
9195
9367
  var init_worktree = __esm({
9196
9368
  "src/git/worktree.ts"() {
9197
9369
  "use strict";
9198
9370
  import_node_crypto7 = require("crypto");
9199
9371
  import_node_fs18 = require("fs");
9200
9372
  import_node_os6 = require("os");
9201
- import_node_path20 = require("path");
9373
+ import_node_path21 = require("path");
9202
9374
  init_paths();
9203
9375
  init_thread_store();
9204
9376
  init_teams();
@@ -9250,10 +9422,10 @@ __export(workspaces_exports, {
9250
9422
  syncWorkspacesFromThreads: () => syncWorkspacesFromThreads
9251
9423
  });
9252
9424
  function workspacesFile() {
9253
- return (0, import_node_path21.join)(appDataDir(), "workspaces.json");
9425
+ return (0, import_node_path22.join)(appDataDir(), "workspaces.json");
9254
9426
  }
9255
9427
  function removedWorkspacesFile() {
9256
- return (0, import_node_path21.join)(appDataDir(), "removed-workspaces.json");
9428
+ return (0, import_node_path22.join)(appDataDir(), "removed-workspaces.json");
9257
9429
  }
9258
9430
  function readAll2() {
9259
9431
  const path2 = workspacesFile();
@@ -9312,7 +9484,7 @@ async function addWorkspace(repoPath) {
9312
9484
  if (existing) return existing;
9313
9485
  const next = {
9314
9486
  path: root,
9315
- name: (0, import_node_path21.basename)(root),
9487
+ name: (0, import_node_path22.basename)(root),
9316
9488
  addedAt: (/* @__PURE__ */ new Date()).toISOString()
9317
9489
  };
9318
9490
  writeAll2([...current, next]);
@@ -9337,7 +9509,7 @@ function syncWorkspacesFromThreads(repoPaths) {
9337
9509
  if (!(0, import_node_fs19.existsSync)(path2)) continue;
9338
9510
  const ws = {
9339
9511
  path: path2,
9340
- name: (0, import_node_path21.basename)(path2),
9512
+ name: (0, import_node_path22.basename)(path2),
9341
9513
  addedAt: (/* @__PURE__ */ new Date()).toISOString()
9342
9514
  };
9343
9515
  byPath.set(path2, ws);
@@ -9347,12 +9519,12 @@ function syncWorkspacesFromThreads(repoPaths) {
9347
9519
  if (dirty) writeAll2(next);
9348
9520
  return next.sort((a, b) => a.name.localeCompare(b.name));
9349
9521
  }
9350
- var import_node_fs19, import_node_path21;
9522
+ var import_node_fs19, import_node_path22;
9351
9523
  var init_workspaces = __esm({
9352
9524
  "src/store/workspaces.ts"() {
9353
9525
  "use strict";
9354
9526
  import_node_fs19 = require("fs");
9355
- import_node_path21 = require("path");
9527
+ import_node_path22 = require("path");
9356
9528
  init_paths();
9357
9529
  init_global_workspace();
9358
9530
  init_worktree();
@@ -9471,7 +9643,7 @@ function ensureGlobalCoordinatorCwd(opts) {
9471
9643
  let orchId = opts?.orchestratorThreadId?.trim() || "";
9472
9644
  if (!orchId) {
9473
9645
  try {
9474
- const existing = (0, import_node_fs20.readFileSync)((0, import_node_path22.join)(dir, "AGENTS.md"), "utf8");
9646
+ const existing = (0, import_node_fs20.readFileSync)((0, import_node_path23.join)(dir, "AGENTS.md"), "utf8");
9475
9647
  const m = existing.match(
9476
9648
  /YOUR orchestration thread id is `([0-9a-f-]{36})`/i
9477
9649
  );
@@ -9516,9 +9688,9 @@ function ensureGlobalCoordinatorCwd(opts) {
9516
9688
  "Always ask worktree agents to commit, push, and open draft PRs (`ask_git` / `send_to_thread`). If the user gave a goal (Greptile 5/5, CI green), pass that goal through so they watch-fix-push until it lands \u2014 do not start that loop on a plain push, and do not tell the human to poll. Tell them to merge only when the user explicitly asked. The worktree agent runs git/gh; never merge from this orchestration cwd."
9517
9689
  ].join("\n");
9518
9690
  try {
9519
- (0, import_node_fs20.writeFileSync)((0, import_node_path22.join)(dir, "CLAUDE.md"), `${body}
9691
+ (0, import_node_fs20.writeFileSync)((0, import_node_path23.join)(dir, "CLAUDE.md"), `${body}
9520
9692
  `, "utf8");
9521
- (0, import_node_fs20.writeFileSync)((0, import_node_path22.join)(dir, "AGENTS.md"), `${body}
9693
+ (0, import_node_fs20.writeFileSync)((0, import_node_path23.join)(dir, "AGENTS.md"), `${body}
9522
9694
  `, "utf8");
9523
9695
  } catch {
9524
9696
  }
@@ -9550,12 +9722,12 @@ function coordinatorSystemPrompt(opts) {
9550
9722
  formatWorkspaceInventory(opts.workspaces)
9551
9723
  ].join("\n");
9552
9724
  }
9553
- var import_node_fs20, import_node_path22, COORDINATOR_TOOL_PLAYBOOK, SLACK_REPLY_FORMATTING;
9725
+ var import_node_fs20, import_node_path23, COORDINATOR_TOOL_PLAYBOOK, SLACK_REPLY_FORMATTING;
9554
9726
  var init_coordinator_prompt = __esm({
9555
9727
  "src/orchestrator/coordinator-prompt.ts"() {
9556
9728
  "use strict";
9557
9729
  import_node_fs20 = require("fs");
9558
- import_node_path22 = require("path");
9730
+ import_node_path23 = require("path");
9559
9731
  init_worktree();
9560
9732
  init_app_settings();
9561
9733
  init_paths();
@@ -9914,7 +10086,7 @@ var init_api = __esm({
9914
10086
 
9915
10087
  // src/slack/reply-target.ts
9916
10088
  function storePath() {
9917
- return (0, import_node_path23.join)(appDataDir(), "slack-reply-to.json");
10089
+ return (0, import_node_path24.join)(appDataDir(), "slack-reply-to.json");
9918
10090
  }
9919
10091
  function readStore() {
9920
10092
  const path2 = storePath();
@@ -9935,12 +10107,12 @@ function setSlackReplyTarget(target) {
9935
10107
  function getSlackReplyTarget(threadId) {
9936
10108
  return readStore()[threadId] ?? null;
9937
10109
  }
9938
- var import_node_fs21, import_node_path23;
10110
+ var import_node_fs21, import_node_path24;
9939
10111
  var init_reply_target = __esm({
9940
10112
  "src/slack/reply-target.ts"() {
9941
10113
  "use strict";
9942
10114
  import_node_fs21 = require("fs");
9943
- import_node_path23 = require("path");
10115
+ import_node_path24 = require("path");
9944
10116
  init_paths();
9945
10117
  init_private_file();
9946
10118
  init_secure_file();
@@ -9949,7 +10121,7 @@ var init_reply_target = __esm({
9949
10121
 
9950
10122
  // src/slack/workspaces.ts
9951
10123
  function storePath2() {
9952
- return (0, import_node_path24.join)(appDataDir(), "slack-workspaces.json");
10124
+ return (0, import_node_path25.join)(appDataDir(), "slack-workspaces.json");
9953
10125
  }
9954
10126
  function readStore2() {
9955
10127
  try {
@@ -10056,11 +10228,11 @@ function requireSlackWorkspace(teamId) {
10056
10228
  }
10057
10229
  return ws;
10058
10230
  }
10059
- var import_node_path24;
10231
+ var import_node_path25;
10060
10232
  var init_workspaces2 = __esm({
10061
10233
  "src/slack/workspaces.ts"() {
10062
10234
  "use strict";
10063
- import_node_path24 = require("path");
10235
+ import_node_path25 = require("path");
10064
10236
  init_paths();
10065
10237
  init_secure_file();
10066
10238
  init_api();
@@ -10069,7 +10241,7 @@ var init_workspaces2 = __esm({
10069
10241
 
10070
10242
  // src/slack/outbound-watch.ts
10071
10243
  function storePath3() {
10072
- return (0, import_node_path25.join)(appDataDir(), "slack-outbound-watch.json");
10244
+ return (0, import_node_path26.join)(appDataDir(), "slack-outbound-watch.json");
10073
10245
  }
10074
10246
  function watchId(teamId, channelId, ts) {
10075
10247
  return `${teamId}:${channelId}:${ts}`;
@@ -10406,12 +10578,12 @@ async function pollSlackOutboundWatches(opts) {
10406
10578
  }
10407
10579
  if (changed) writeStore2(watches);
10408
10580
  }
10409
- var import_node_fs22, import_node_path25, MAX_WATCHES, MAX_REPLIES_PER_WATCH, WATCH_TTL_MS, POLL_INTERVAL_MS, lastPollMs, nameCache, continueOnReply;
10581
+ var import_node_fs22, import_node_path26, MAX_WATCHES, MAX_REPLIES_PER_WATCH, WATCH_TTL_MS, POLL_INTERVAL_MS, lastPollMs, nameCache, continueOnReply;
10410
10582
  var init_outbound_watch = __esm({
10411
10583
  "src/slack/outbound-watch.ts"() {
10412
10584
  "use strict";
10413
10585
  import_node_fs22 = require("fs");
10414
- import_node_path25 = require("path");
10586
+ import_node_path26 = require("path");
10415
10587
  init_paths();
10416
10588
  init_private_file();
10417
10589
  init_secure_file();
@@ -10432,7 +10604,7 @@ var init_outbound_watch = __esm({
10432
10604
  function brightsyConfigPath() {
10433
10605
  const override = process.env.BRIGHTSY_CONFIG?.trim();
10434
10606
  if (override) return override;
10435
- return (0, import_node_path26.join)((0, import_node_os7.homedir)(), ".brightsy", "config.json");
10607
+ return (0, import_node_path27.join)((0, import_node_os7.homedir)(), ".brightsy", "config.json");
10436
10608
  }
10437
10609
  function loadBrightsyConfig() {
10438
10610
  const path2 = brightsyConfigPath();
@@ -10451,13 +10623,13 @@ function saveBrightsyConfig(cfg) {
10451
10623
  mode: 384
10452
10624
  });
10453
10625
  }
10454
- var import_node_fs23, import_node_os7, import_node_path26;
10626
+ var import_node_fs23, import_node_os7, import_node_path27;
10455
10627
  var init_config = __esm({
10456
10628
  "src/brightsy/config.ts"() {
10457
10629
  "use strict";
10458
10630
  import_node_fs23 = require("fs");
10459
10631
  import_node_os7 = require("os");
10460
- import_node_path26 = require("path");
10632
+ import_node_path27 = require("path");
10461
10633
  }
10462
10634
  });
10463
10635
 
@@ -10684,7 +10856,7 @@ __export(connected_teams_exports, {
10684
10856
  listConnectedBrightsyTeams: () => listConnectedBrightsyTeams
10685
10857
  });
10686
10858
  function storePath4() {
10687
- return (0, import_node_path27.join)(appDataDir(), "brightsy-teams.json");
10859
+ return (0, import_node_path28.join)(appDataDir(), "brightsy-teams.json");
10688
10860
  }
10689
10861
  function readStore4() {
10690
10862
  const path2 = storePath4();
@@ -10855,12 +11027,12 @@ function brightsyMcpServerName(slug) {
10855
11027
  const cleaned = slug.replace(/[^A-Za-z0-9_-]/g, "_").replace(/^_+|_+$/g, "");
10856
11028
  return `brightsy_${cleaned || "team"}`;
10857
11029
  }
10858
- var import_node_fs24, import_node_path27;
11030
+ var import_node_fs24, import_node_path28;
10859
11031
  var init_connected_teams = __esm({
10860
11032
  "src/brightsy/connected-teams.ts"() {
10861
11033
  "use strict";
10862
11034
  import_node_fs24 = require("fs");
10863
- import_node_path27 = require("path");
11035
+ import_node_path28 = require("path");
10864
11036
  init_paths();
10865
11037
  init_accounts();
10866
11038
  init_config();
@@ -11452,7 +11624,7 @@ function collectSystemCaPem(io = {}) {
11452
11624
  return "";
11453
11625
  }
11454
11626
  function systemCaBundlePath(io = {}) {
11455
- return (0, import_node_path28.join)((io.appData ?? appDataDir)(), BUNDLE_NAME);
11627
+ return (0, import_node_path29.join)((io.appData ?? appDataDir)(), BUNDLE_NAME);
11456
11628
  }
11457
11629
  function bundleIsFresh(path2, now) {
11458
11630
  try {
@@ -11482,7 +11654,7 @@ function materializeSystemCaBundle(io = {}) {
11482
11654
  return (0, import_node_fs26.existsSync)(dest) && splitPemCertificates(readExistingFile(dest)).length > 0 ? dest : void 0;
11483
11655
  }
11484
11656
  try {
11485
- (0, import_node_fs26.mkdirSync)((0, import_node_path28.dirname)(dest), { recursive: true });
11657
+ (0, import_node_fs26.mkdirSync)((0, import_node_path29.dirname)(dest), { recursive: true });
11486
11658
  (0, import_node_fs26.writeFileSync)(dest, pem.endsWith("\n") ? pem : `${pem}
11487
11659
  `, { mode: 384 });
11488
11660
  return dest;
@@ -11523,13 +11695,13 @@ function trustSystemCertificates(io = {}) {
11523
11695
  return false;
11524
11696
  }
11525
11697
  }
11526
- var import_node_child_process4, import_node_fs26, import_node_path28, import_node_tls, NODE_USE_SYSTEM_CA, NODE_EXTRA_CA_CERTS, BUNDLE_NAME, BUNDLE_MAX_AGE_MS, LINUX_CA_FILES, PEM_CERT_RE;
11698
+ var import_node_child_process4, import_node_fs26, import_node_path29, import_node_tls, NODE_USE_SYSTEM_CA, NODE_EXTRA_CA_CERTS, BUNDLE_NAME, BUNDLE_MAX_AGE_MS, LINUX_CA_FILES, PEM_CERT_RE;
11527
11699
  var init_system_ca = __esm({
11528
11700
  "src/http/system-ca.ts"() {
11529
11701
  "use strict";
11530
11702
  import_node_child_process4 = require("child_process");
11531
11703
  import_node_fs26 = require("fs");
11532
- import_node_path28 = require("path");
11704
+ import_node_path29 = require("path");
11533
11705
  import_node_tls = __toESM(require("tls"), 1);
11534
11706
  init_paths();
11535
11707
  NODE_USE_SYSTEM_CA = "NODE_USE_SYSTEM_CA";
@@ -11555,43 +11727,43 @@ function electronResourcesPath() {
11555
11727
  function packagedCursorRuntimeDir() {
11556
11728
  const resources = electronResourcesPath();
11557
11729
  if (!resources) return null;
11558
- const dir = (0, import_node_path29.join)(resources, "cursor-runtime");
11559
- if (!(0, import_node_fs27.existsSync)((0, import_node_path29.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
11730
+ const dir = (0, import_node_path30.join)(resources, "cursor-runtime");
11731
+ if (!(0, import_node_fs27.existsSync)((0, import_node_path30.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
11560
11732
  return dir;
11561
11733
  }
11562
11734
  function packagedCursorRunnerPath() {
11563
11735
  const dir = packagedCursorRuntimeDir();
11564
- return dir ? (0, import_node_path29.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
11736
+ return dir ? (0, import_node_path30.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
11565
11737
  }
11566
11738
  function packagedMcpDir() {
11567
11739
  const resources = electronResourcesPath();
11568
11740
  if (!resources) return null;
11569
- const dir = (0, import_node_path29.join)(resources, "sideboard-mcp");
11570
- if (!(0, import_node_fs27.existsSync)((0, import_node_path29.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
11741
+ const dir = (0, import_node_path30.join)(resources, "sideboard-mcp");
11742
+ if (!(0, import_node_fs27.existsSync)((0, import_node_path30.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
11571
11743
  return dir;
11572
11744
  }
11573
11745
  function packagedMcpStdioPath() {
11574
11746
  const dir = packagedMcpDir();
11575
- return dir ? (0, import_node_path29.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
11747
+ return dir ? (0, import_node_path30.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
11576
11748
  }
11577
11749
  function packagedBundledNodePath() {
11578
11750
  const resources = electronResourcesPath();
11579
11751
  if (!resources) return null;
11580
- const bin = (0, import_node_path29.join)(resources, "node", "bin", "node");
11752
+ const bin = (0, import_node_path30.join)(resources, "node", "bin", "node");
11581
11753
  if (!(0, import_node_fs27.existsSync)(bin)) return null;
11582
11754
  return bin;
11583
11755
  }
11584
11756
  function packagedCursorRipgrepCandidate(platformPkg, binName) {
11585
11757
  const dir = packagedCursorRuntimeDir();
11586
11758
  if (!dir) return null;
11587
- return (0, import_node_path29.join)(dir, "node_modules", platformPkg, "bin", binName);
11759
+ return (0, import_node_path30.join)(dir, "node_modules", platformPkg, "bin", binName);
11588
11760
  }
11589
- var import_node_fs27, import_node_path29;
11761
+ var import_node_fs27, import_node_path30;
11590
11762
  var init_packaged_runtime = __esm({
11591
11763
  "src/agents/packaged-runtime.ts"() {
11592
11764
  "use strict";
11593
11765
  import_node_fs27 = require("fs");
11594
- import_node_path29 = require("path");
11766
+ import_node_path30 = require("path");
11595
11767
  }
11596
11768
  });
11597
11769
 
@@ -11675,28 +11847,28 @@ function versionDirNodeBins(root, toBin) {
11675
11847
  }
11676
11848
  function defaultNodeBinCandidates(home = (0, import_node_os8.homedir)()) {
11677
11849
  const kegs = ["/opt/homebrew", "/usr/local"].flatMap(
11678
- (prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path30.join)(prefix, "opt", `node@${major}`, "bin", "node"))
11850
+ (prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path31.join)(prefix, "opt", `node@${major}`, "bin", "node"))
11679
11851
  );
11680
11852
  return [
11681
11853
  ...kegs,
11682
11854
  "/opt/homebrew/bin/node",
11683
11855
  "/usr/local/bin/node",
11684
- (0, import_node_path30.join)(home, ".local/share/fnm/aliases/default/bin/node"),
11685
- (0, import_node_path30.join)(home, ".nvm/current/bin/node"),
11686
- (0, import_node_path30.join)(home, ".volta/bin/node"),
11687
- (0, import_node_path30.join)(home, ".asdf/shims/node"),
11688
- (0, import_node_path30.join)(home, ".local/share/mise/shims/node"),
11856
+ (0, import_node_path31.join)(home, ".local/share/fnm/aliases/default/bin/node"),
11857
+ (0, import_node_path31.join)(home, ".nvm/current/bin/node"),
11858
+ (0, import_node_path31.join)(home, ".volta/bin/node"),
11859
+ (0, import_node_path31.join)(home, ".asdf/shims/node"),
11860
+ (0, import_node_path31.join)(home, ".local/share/mise/shims/node"),
11689
11861
  ...versionDirNodeBins(
11690
- (0, import_node_path30.join)(home, ".nvm", "versions", "node"),
11691
- (name) => (0, import_node_path30.join)(home, ".nvm", "versions", "node", name, "bin", "node")
11862
+ (0, import_node_path31.join)(home, ".nvm", "versions", "node"),
11863
+ (name) => (0, import_node_path31.join)(home, ".nvm", "versions", "node", name, "bin", "node")
11692
11864
  ),
11693
11865
  ...versionDirNodeBins(
11694
- (0, import_node_path30.join)(home, ".local/share/fnm", "node-versions"),
11695
- (name) => (0, import_node_path30.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
11866
+ (0, import_node_path31.join)(home, ".local/share/fnm", "node-versions"),
11867
+ (name) => (0, import_node_path31.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
11696
11868
  ),
11697
11869
  ...versionDirNodeBins(
11698
- (0, import_node_path30.join)(home, ".volta", "tools", "image", "node"),
11699
- (name) => (0, import_node_path30.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
11870
+ (0, import_node_path31.join)(home, ".volta", "tools", "image", "node"),
11871
+ (name) => (0, import_node_path31.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
11700
11872
  )
11701
11873
  ];
11702
11874
  }
@@ -11788,13 +11960,13 @@ async function resolveNodeLaunch(scriptPath) {
11788
11960
  env: { ELECTRON_RUN_AS_NODE: "1" }
11789
11961
  };
11790
11962
  }
11791
- var import_node_fs28, import_node_os8, import_node_path30, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
11963
+ var import_node_fs28, import_node_os8, import_node_path31, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
11792
11964
  var init_node_launch = __esm({
11793
11965
  "src/agents/node-launch.ts"() {
11794
11966
  "use strict";
11795
11967
  import_node_fs28 = require("fs");
11796
11968
  import_node_os8 = require("os");
11797
- import_node_path30 = require("path");
11969
+ import_node_path31 = require("path");
11798
11970
  init_nested_electron_env();
11799
11971
  init_system_ca();
11800
11972
  init_run();
@@ -11896,13 +12068,13 @@ function corePackageDir() {
11896
12068
  try {
11897
12069
  const url = import_meta.url;
11898
12070
  if (typeof url === "string" && url.length > 0) {
11899
- return (0, import_node_path31.dirname)((0, import_node_url.fileURLToPath)(url));
12071
+ return (0, import_node_path32.dirname)((0, import_node_url.fileURLToPath)(url));
11900
12072
  }
11901
12073
  } catch {
11902
12074
  }
11903
12075
  try {
11904
- const req = (0, import_node_module.createRequire)((0, import_node_path31.join)(process.cwd(), "package.json"));
11905
- return (0, import_node_path31.dirname)(req.resolve("@sideboard-ai/core"));
12076
+ const req = (0, import_node_module.createRequire)((0, import_node_path32.join)(process.cwd(), "package.json"));
12077
+ return (0, import_node_path32.dirname)(req.resolve("@sideboard-ai/core"));
11906
12078
  } catch {
11907
12079
  return process.cwd();
11908
12080
  }
@@ -11915,18 +12087,18 @@ function findSideboardMcpJsEntry() {
11915
12087
  let dir = corePackageDir();
11916
12088
  for (let i = 0; i < 10; i++) {
11917
12089
  const candidates = [
11918
- (0, import_node_path31.join)(dir, "mcp/run-stdio.js"),
11919
- (0, import_node_path31.join)(dir, "mcp/run-stdio.cjs"),
11920
- (0, import_node_path31.join)(dir, "dist/mcp/run-stdio.js"),
11921
- (0, import_node_path31.join)(dir, "dist/mcp/run-stdio.cjs"),
11922
- (0, import_node_path31.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
11923
- (0, import_node_path31.join)(dir, "packages/cli/dist/index.js"),
11924
- (0, import_node_path31.join)(dir, "cli/dist/index.js")
12090
+ (0, import_node_path32.join)(dir, "mcp/run-stdio.js"),
12091
+ (0, import_node_path32.join)(dir, "mcp/run-stdio.cjs"),
12092
+ (0, import_node_path32.join)(dir, "dist/mcp/run-stdio.js"),
12093
+ (0, import_node_path32.join)(dir, "dist/mcp/run-stdio.cjs"),
12094
+ (0, import_node_path32.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
12095
+ (0, import_node_path32.join)(dir, "packages/cli/dist/index.js"),
12096
+ (0, import_node_path32.join)(dir, "cli/dist/index.js")
11925
12097
  ];
11926
12098
  for (const p of candidates) {
11927
12099
  if ((0, import_node_fs29.existsSync)(p) && !isAsarPath(p)) return p;
11928
12100
  }
11929
- const parent = (0, import_node_path31.dirname)(dir);
12101
+ const parent = (0, import_node_path32.dirname)(dir);
11930
12102
  if (parent === dir) break;
11931
12103
  dir = parent;
11932
12104
  }
@@ -12073,22 +12245,22 @@ function writeMcpServersConfig(servers) {
12073
12245
  ...env ? { env } : {}
12074
12246
  };
12075
12247
  }
12076
- const dir = (0, import_node_fs29.mkdtempSync)((0, import_node_path31.join)((0, import_node_os9.tmpdir)(), "sideboard-mcp-"));
12077
- const cfgPath = (0, import_node_path31.join)(dir, "mcp.json");
12248
+ const dir = (0, import_node_fs29.mkdtempSync)((0, import_node_path32.join)((0, import_node_os9.tmpdir)(), "sideboard-mcp-"));
12249
+ const cfgPath = (0, import_node_path32.join)(dir, "mcp.json");
12078
12250
  (0, import_node_fs29.writeFileSync)(cfgPath, JSON.stringify({ mcpServers }, null, 2));
12079
12251
  return cfgPath;
12080
12252
  }
12081
12253
  async function writeInjectedMcpConfig(opts) {
12082
12254
  return writeMcpServersConfig(await buildInjectedMcpServers(opts));
12083
12255
  }
12084
- var import_node_fs29, import_node_module, import_node_os9, import_node_path31, import_node_url, import_meta, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS, SIDEBOARD_GITHUB_MCP_ALLOWED_TOOLS, SIDEBOARD_LINEAR_MCP_ALLOWED_TOOLS, SIDEBOARD_ABLETIME_MCP_ALLOWED_TOOLS, BRIGHTSY_MCP_ALLOWED_TOOLS, brightsyMcpCommandCache, BRIGHTSY_WORD;
12256
+ var import_node_fs29, import_node_module, import_node_os9, import_node_path32, import_node_url, import_meta, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS, SIDEBOARD_GITHUB_MCP_ALLOWED_TOOLS, SIDEBOARD_LINEAR_MCP_ALLOWED_TOOLS, SIDEBOARD_ABLETIME_MCP_ALLOWED_TOOLS, BRIGHTSY_MCP_ALLOWED_TOOLS, brightsyMcpCommandCache, BRIGHTSY_WORD;
12085
12257
  var init_injected_mcp = __esm({
12086
12258
  "src/agents/injected-mcp.ts"() {
12087
12259
  "use strict";
12088
12260
  import_node_fs29 = require("fs");
12089
12261
  import_node_module = require("module");
12090
12262
  import_node_os9 = require("os");
12091
- import_node_path31 = require("path");
12263
+ import_node_path32 = require("path");
12092
12264
  import_node_url = require("url");
12093
12265
  init_run();
12094
12266
  init_config();
@@ -12329,13 +12501,31 @@ function mcpStatusThinkingFromClaudeInit(obj) {
12329
12501
  }
12330
12502
  }
12331
12503
  }
12332
- const notable = servers.filter((s) => !isCleanMcpConnect(s.status));
12504
+ const notable = servers.filter(isNotableMcpInitStatus);
12333
12505
  if (notable.length === 0) return null;
12334
12506
  return `MCP: ${notable.map((s) => `${s.name} ${s.status}`).join(", ")}`;
12335
12507
  }
12336
12508
  function isCleanMcpConnect(status) {
12337
12509
  return /^(connected|ok|ready|success)$/i.test(status.trim());
12338
12510
  }
12511
+ function isMcpAuthStatus(status) {
12512
+ return /needs[_-]?auth|needs authentication|unauthorized|not authenticated|authrequired/i.test(
12513
+ status
12514
+ );
12515
+ }
12516
+ function isSideboardMcpName(name) {
12517
+ return /^sideboard$/i.test(name.trim()) || /^mcp__sideboard$/i.test(name.trim());
12518
+ }
12519
+ function isVendorClaudeAiMcpName(name) {
12520
+ return /^claude\.ai\b/i.test(name.trim()) || /^mcp__claude_ai_/i.test(name.trim());
12521
+ }
12522
+ function isNotableMcpInitStatus(server) {
12523
+ if (isCleanMcpConnect(server.status)) return false;
12524
+ if (isSideboardMcpName(server.name)) return true;
12525
+ if (isVendorClaudeAiMcpName(server.name)) return false;
12526
+ if (isMcpAuthStatus(server.status)) return false;
12527
+ return true;
12528
+ }
12339
12529
  function eventsFromClaudeSystem(obj) {
12340
12530
  const subtype = claudeString(obj, "subtype") ?? "";
12341
12531
  const parentId = claudeParentToolUseId(obj);
@@ -12779,10 +12969,10 @@ var init_claude = __esm({
12779
12969
 
12780
12970
  // src/agents/user-mcp-config.ts
12781
12971
  function userCursorMcpConfigPath() {
12782
- return (0, import_node_path32.join)((0, import_node_os10.homedir)(), ".cursor", "mcp.json");
12972
+ return (0, import_node_path33.join)((0, import_node_os10.homedir)(), ".cursor", "mcp.json");
12783
12973
  }
12784
12974
  function userClaudeMcpConfigPath() {
12785
- return (0, import_node_path32.join)((0, import_node_os10.homedir)(), ".claude.json");
12975
+ return (0, import_node_path33.join)((0, import_node_os10.homedir)(), ".claude.json");
12786
12976
  }
12787
12977
  function asObject(value) {
12788
12978
  if (!value || typeof value !== "object" || Array.isArray(value)) return {};
@@ -12817,7 +13007,7 @@ function writeMergedMcpServersJson(configPath, sideboard) {
12817
13007
  }
12818
13008
  }
12819
13009
  const next = mergeSideboardIntoMcpServersJson(existing, sideboard);
12820
- (0, import_node_fs31.mkdirSync)((0, import_node_path32.dirname)(configPath), { recursive: true });
13010
+ (0, import_node_fs31.mkdirSync)((0, import_node_path33.dirname)(configPath), { recursive: true });
12821
13011
  (0, import_node_fs31.writeFileSync)(configPath, `${JSON.stringify(next, null, 2)}
12822
13012
  `);
12823
13013
  }
@@ -12842,13 +13032,13 @@ async function registerPackagedUserMcpClients() {
12842
13032
  }
12843
13033
  return { cursor };
12844
13034
  }
12845
- var import_node_fs31, import_node_os10, import_node_path32;
13035
+ var import_node_fs31, import_node_os10, import_node_path33;
12846
13036
  var init_user_mcp_config = __esm({
12847
13037
  "src/agents/user-mcp-config.ts"() {
12848
13038
  "use strict";
12849
13039
  import_node_fs31 = require("fs");
12850
13040
  import_node_os10 = require("os");
12851
- import_node_path32 = require("path");
13041
+ import_node_path33 = require("path");
12852
13042
  init_paths();
12853
13043
  init_injected_mcp();
12854
13044
  }
@@ -12889,12 +13079,12 @@ function readText(path2) {
12889
13079
  }
12890
13080
  }
12891
13081
  function userCodexConfigPaths(home = (0, import_node_os11.homedir)()) {
12892
- return [(0, import_node_path33.join)(home, ".codex", "config.toml"), (0, import_node_path33.join)(home, ".config", "codex", "config.toml")];
13082
+ return [(0, import_node_path34.join)(home, ".codex", "config.toml"), (0, import_node_path34.join)(home, ".config", "codex", "config.toml")];
12893
13083
  }
12894
13084
  function userOpencodeConfigPaths(home = (0, import_node_os11.homedir)()) {
12895
13085
  return [
12896
- (0, import_node_path33.join)(home, ".config", "opencode", "opencode.json"),
12897
- (0, import_node_path33.join)(home, ".config", "opencode", "opencode.jsonc")
13086
+ (0, import_node_path34.join)(home, ".config", "opencode", "opencode.json"),
13087
+ (0, import_node_path34.join)(home, ".config", "opencode", "opencode.jsonc")
12898
13088
  ];
12899
13089
  }
12900
13090
  function userMcpNamesToDisable(opts) {
@@ -12949,13 +13139,13 @@ function toCodexUnattendedAppsArgs() {
12949
13139
  "features.plugins=false"
12950
13140
  ];
12951
13141
  }
12952
- var import_node_fs32, import_node_os11, import_node_path33, import_smol_toml2;
13142
+ var import_node_fs32, import_node_os11, import_node_path34, import_smol_toml2;
12953
13143
  var init_orch_mcp_isolation = __esm({
12954
13144
  "src/agents/orch-mcp-isolation.ts"() {
12955
13145
  "use strict";
12956
13146
  import_node_fs32 = require("fs");
12957
13147
  import_node_os11 = require("os");
12958
- import_node_path33 = require("path");
13148
+ import_node_path34 = require("path");
12959
13149
  import_smol_toml2 = require("smol-toml");
12960
13150
  init_user_mcp_config();
12961
13151
  }
@@ -13006,8 +13196,8 @@ function usageFromCodex(usage) {
13006
13196
  }
13007
13197
  function codexConfigHasNetworkAccess() {
13008
13198
  const candidates = [
13009
- (0, import_node_path34.join)((0, import_node_os12.homedir)(), ".codex", "config.toml"),
13010
- (0, import_node_path34.join)((0, import_node_os12.homedir)(), ".config", "codex", "config.toml")
13199
+ (0, import_node_path35.join)((0, import_node_os12.homedir)(), ".codex", "config.toml"),
13200
+ (0, import_node_path35.join)((0, import_node_os12.homedir)(), ".config", "codex", "config.toml")
13011
13201
  ];
13012
13202
  for (const path2 of candidates) {
13013
13203
  if (!(0, import_node_fs33.existsSync)(path2)) continue;
@@ -13043,7 +13233,7 @@ function asRecord2(value) {
13043
13233
  return void 0;
13044
13234
  }
13045
13235
  function codexLooksAuthenticated() {
13046
- const authPath = (0, import_node_path34.join)((0, import_node_os12.homedir)(), ".codex", "auth.json");
13236
+ const authPath = (0, import_node_path35.join)((0, import_node_os12.homedir)(), ".codex", "auth.json");
13047
13237
  if (!(0, import_node_fs33.existsSync)(authPath)) return false;
13048
13238
  try {
13049
13239
  return (0, import_node_fs33.statSync)(authPath).size > 2;
@@ -13051,13 +13241,13 @@ function codexLooksAuthenticated() {
13051
13241
  return false;
13052
13242
  }
13053
13243
  }
13054
- var import_node_fs33, import_node_os12, import_node_path34, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
13244
+ var import_node_fs33, import_node_os12, import_node_path35, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
13055
13245
  var init_codex = __esm({
13056
13246
  "src/agents/codex.ts"() {
13057
13247
  "use strict";
13058
13248
  import_node_fs33 = require("fs");
13059
13249
  import_node_os12 = require("os");
13060
- import_node_path34 = require("path");
13250
+ import_node_path35 = require("path");
13061
13251
  init_run();
13062
13252
  init_app_settings();
13063
13253
  init_global_workspace();
@@ -13583,7 +13773,7 @@ function platformRipgrepPackage() {
13583
13773
  }
13584
13774
  function usableRipgrepPath(candidate) {
13585
13775
  const raw = candidate?.trim();
13586
- if (!raw || !(0, import_node_path35.isAbsolute)(raw)) return null;
13776
+ if (!raw || !(0, import_node_path36.isAbsolute)(raw)) return null;
13587
13777
  const readable = nodeReadableScriptPath(raw);
13588
13778
  if (!(0, import_node_fs34.existsSync)(readable) || isAsarPath(readable)) return null;
13589
13779
  return readable;
@@ -13592,12 +13782,12 @@ function walkForBundledRipgrep(startFile) {
13592
13782
  if (!startFile) return null;
13593
13783
  const pkg = platformRipgrepPackage();
13594
13784
  const name = rgBinaryName();
13595
- let dir = (0, import_node_path35.dirname)((0, import_node_path35.resolve)(startFile));
13596
- const root = (0, import_node_path35.parse)(dir).root;
13785
+ let dir = (0, import_node_path36.dirname)((0, import_node_path36.resolve)(startFile));
13786
+ const root = (0, import_node_path36.parse)(dir).root;
13597
13787
  while (dir !== root) {
13598
- const hit = usableRipgrepPath((0, import_node_path35.join)(dir, "node_modules", pkg, "bin", name));
13788
+ const hit = usableRipgrepPath((0, import_node_path36.join)(dir, "node_modules", pkg, "bin", name));
13599
13789
  if (hit) return hit;
13600
- const next = (0, import_node_path35.dirname)(dir);
13790
+ const next = (0, import_node_path36.dirname)(dir);
13601
13791
  if (next === dir) break;
13602
13792
  dir = next;
13603
13793
  }
@@ -13607,7 +13797,7 @@ function requireResolveBundledRipgrep(fromFile) {
13607
13797
  try {
13608
13798
  const req = (0, import_node_module2.createRequire)(fromFile);
13609
13799
  const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
13610
- return usableRipgrepPath((0, import_node_path35.join)((0, import_node_path35.dirname)(pkgJson), "bin", rgBinaryName()));
13800
+ return usableRipgrepPath((0, import_node_path36.join)((0, import_node_path36.dirname)(pkgJson), "bin", rgBinaryName()));
13611
13801
  } catch {
13612
13802
  return null;
13613
13803
  }
@@ -13629,13 +13819,13 @@ function cursorRipgrepEnv(opts) {
13629
13819
  const path2 = resolveCursorRipgrepPath(opts);
13630
13820
  return path2 ? { [RIPGREP_ENV]: path2 } : {};
13631
13821
  }
13632
- var import_node_fs34, import_node_module2, import_node_path35, RIPGREP_ENV;
13822
+ var import_node_fs34, import_node_module2, import_node_path36, RIPGREP_ENV;
13633
13823
  var init_cursor_ripgrep = __esm({
13634
13824
  "src/agents/cursor-ripgrep.ts"() {
13635
13825
  "use strict";
13636
13826
  import_node_fs34 = require("fs");
13637
13827
  import_node_module2 = require("module");
13638
- import_node_path35 = require("path");
13828
+ import_node_path36 = require("path");
13639
13829
  init_node_launch();
13640
13830
  init_packaged_runtime();
13641
13831
  RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
@@ -13684,11 +13874,11 @@ function entryDir() {
13684
13874
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
13685
13875
  if (cjsDir) return cjsDir;
13686
13876
  try {
13687
- return (0, import_node_path36.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
13877
+ return (0, import_node_path37.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
13688
13878
  } catch {
13689
13879
  try {
13690
13880
  const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
13691
- return (0, import_node_path36.dirname)(req.resolve("@sideboard-ai/core"));
13881
+ return (0, import_node_path37.dirname)(req.resolve("@sideboard-ai/core"));
13692
13882
  } catch {
13693
13883
  return process.cwd();
13694
13884
  }
@@ -13699,27 +13889,27 @@ function cursorRunnerPath() {
13699
13889
  if (packaged) return packaged;
13700
13890
  const root = entryDir();
13701
13891
  const candidates = [
13702
- (0, import_node_path36.join)(root, "agents", "cursor-runner.js"),
13703
- (0, import_node_path36.join)(root, "agents", "cursor-runner.cjs"),
13892
+ (0, import_node_path37.join)(root, "agents", "cursor-runner.js"),
13893
+ (0, import_node_path37.join)(root, "agents", "cursor-runner.cjs"),
13704
13894
  // If somehow resolved from package root instead of dist/
13705
- (0, import_node_path36.join)(root, "dist", "agents", "cursor-runner.js"),
13706
- (0, import_node_path36.join)(root, "dist", "agents", "cursor-runner.cjs"),
13895
+ (0, import_node_path37.join)(root, "dist", "agents", "cursor-runner.js"),
13896
+ (0, import_node_path37.join)(root, "dist", "agents", "cursor-runner.cjs"),
13707
13897
  // Source tree (dev): packages/core/src/agents/cursor-runner.ts
13708
- (0, import_node_path36.join)(root, "cursor-runner.ts"),
13709
- (0, import_node_path36.join)(root, "src", "agents", "cursor-runner.ts")
13898
+ (0, import_node_path37.join)(root, "cursor-runner.ts"),
13899
+ (0, import_node_path37.join)(root, "src", "agents", "cursor-runner.ts")
13710
13900
  ];
13711
13901
  for (const candidate of candidates) {
13712
13902
  if ((0, import_node_fs35.existsSync)(candidate)) return candidate;
13713
13903
  }
13714
13904
  return candidates[0];
13715
13905
  }
13716
- var import_node_fs35, import_node_module3, import_node_path36, import_node_url2, import_sdk, import_meta2, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
13906
+ var import_node_fs35, import_node_module3, import_node_path37, import_node_url2, import_sdk, import_meta2, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
13717
13907
  var init_cursor = __esm({
13718
13908
  "src/agents/cursor.ts"() {
13719
13909
  "use strict";
13720
13910
  import_node_fs35 = require("fs");
13721
13911
  import_node_module3 = require("module");
13722
- import_node_path36 = require("path");
13912
+ import_node_path37 = require("path");
13723
13913
  import_node_url2 = require("url");
13724
13914
  import_sdk = require("@cursor/sdk");
13725
13915
  init_run();
@@ -14652,8 +14842,8 @@ function accessTokenFromCredentialsJson(raw) {
14652
14842
  }
14653
14843
  }
14654
14844
  function claudeCredentialsPath() {
14655
- const root = process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path37.join)((0, import_node_os13.homedir)(), ".claude");
14656
- return (0, import_node_path37.join)(root, ".credentials.json");
14845
+ const root = process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path38.join)((0, import_node_os13.homedir)(), ".claude");
14846
+ return (0, import_node_path38.join)(root, ".credentials.json");
14657
14847
  }
14658
14848
  async function readFileAccessToken() {
14659
14849
  const path2 = claudeCredentialsPath();
@@ -14763,13 +14953,13 @@ async function getClaudePlanUsage(opts = {}) {
14763
14953
  })();
14764
14954
  return inflight;
14765
14955
  }
14766
- var import_node_fs37, import_node_os13, import_node_path37, CLAUDE_OAUTH_USAGE_URL, CLAUDE_USAGE_TTL_MS, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS, KEYCHAIN_SERVICES, cache, errorUntil, inflight, lastGood, claudeVersion;
14956
+ var import_node_fs37, import_node_os13, import_node_path38, CLAUDE_OAUTH_USAGE_URL, CLAUDE_USAGE_TTL_MS, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS, KEYCHAIN_SERVICES, cache, errorUntil, inflight, lastGood, claudeVersion;
14767
14957
  var init_claude_usage_client = __esm({
14768
14958
  "src/agents/claude-usage-client.ts"() {
14769
14959
  "use strict";
14770
14960
  import_node_fs37 = require("fs");
14771
14961
  import_node_os13 = require("os");
14772
- import_node_path37 = require("path");
14962
+ import_node_path38 = require("path");
14773
14963
  init_run();
14774
14964
  init_fetch();
14775
14965
  init_app_settings();
@@ -15132,15 +15322,15 @@ var init_agents = __esm({
15132
15322
 
15133
15323
  // src/hook/worktree-pkg-cache.ts
15134
15324
  function worktreePkgCacheRoot(worktreePath) {
15135
- return (0, import_node_path38.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
15325
+ return (0, import_node_path39.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
15136
15326
  }
15137
15327
  function worktreePkgCacheEnv(worktreePath) {
15138
15328
  const root = worktreePkgCacheRoot(worktreePath);
15139
- const store = (0, import_node_path38.join)(root, "pnpm-store");
15140
- const pnpmCache = (0, import_node_path38.join)(root, "pnpm");
15141
- const npmCache = (0, import_node_path38.join)(root, "npm");
15142
- const nodeGyp = (0, import_node_path38.join)(root, "node-gyp");
15143
- const electron = (0, import_node_path38.join)(root, "electron");
15329
+ const store = (0, import_node_path39.join)(root, "pnpm-store");
15330
+ const pnpmCache = (0, import_node_path39.join)(root, "pnpm");
15331
+ const npmCache = (0, import_node_path39.join)(root, "npm");
15332
+ const nodeGyp = (0, import_node_path39.join)(root, "node-gyp");
15333
+ const electron = (0, import_node_path39.join)(root, "electron");
15144
15334
  return {
15145
15335
  npm_config_store_dir: store,
15146
15336
  PNPM_STORE_DIR: store,
@@ -15176,12 +15366,12 @@ function applyWorktreePkgCacheEnv(env, worktreePath) {
15176
15366
  fillGroup(env, ["electron_config_cache"], next);
15177
15367
  ensureWorktreePkgCacheDirs(cwd);
15178
15368
  }
15179
- var import_node_fs38, import_node_path38, WORKTREE_PKG_CACHE_REL;
15369
+ var import_node_fs38, import_node_path39, WORKTREE_PKG_CACHE_REL;
15180
15370
  var init_worktree_pkg_cache = __esm({
15181
15371
  "src/hook/worktree-pkg-cache.ts"() {
15182
15372
  "use strict";
15183
15373
  import_node_fs38 = require("fs");
15184
- import_node_path38 = require("path");
15374
+ import_node_path39 = require("path");
15185
15375
  WORKTREE_PKG_CACHE_REL = ".context/.sideboard/pkg-cache";
15186
15376
  }
15187
15377
  });
@@ -16394,12 +16584,12 @@ function readTextIfPresent(abs) {
16394
16584
  }
16395
16585
  }
16396
16586
  function readLocalGuidelines(worktreePath) {
16397
- const localAbs = (0, import_node_path39.join)(worktreePath, REVIEW_REQUEST_PATH);
16587
+ const localAbs = (0, import_node_path40.join)(worktreePath, REVIEW_REQUEST_PATH);
16398
16588
  const localContent = readTextIfPresent(localAbs);
16399
16589
  if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
16400
16590
  return { path: REVIEW_REQUEST_PATH, content: localContent };
16401
16591
  }
16402
- const legacyAbs = (0, import_node_path39.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
16592
+ const legacyAbs = (0, import_node_path40.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
16403
16593
  const legacyContent = readTextIfPresent(legacyAbs);
16404
16594
  if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
16405
16595
  return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
@@ -16423,27 +16613,27 @@ function contextGuidelines(content, source) {
16423
16613
  };
16424
16614
  }
16425
16615
  function writeContextGuidelines(worktreePath, content) {
16426
- const abs = (0, import_node_path39.join)(worktreePath, CONTEXT_REVIEW_PATH);
16427
- (0, import_node_fs39.mkdirSync)((0, import_node_path39.dirname)(abs), { recursive: true });
16616
+ const abs = (0, import_node_path40.join)(worktreePath, CONTEXT_REVIEW_PATH);
16617
+ (0, import_node_fs39.mkdirSync)((0, import_node_path40.dirname)(abs), { recursive: true });
16428
16618
  const body = content.endsWith("\n") ? content : `${content}
16429
16619
  `;
16430
16620
  (0, import_node_fs39.writeFileSync)(abs, body, "utf8");
16431
16621
  return body;
16432
16622
  }
16433
16623
  function readSideboardReview(worktreePath, repoPath) {
16434
- const fromWorktree = readTextIfPresent((0, import_node_path39.join)(worktreePath, REPO_REVIEW_PATH));
16624
+ const fromWorktree = readTextIfPresent((0, import_node_path40.join)(worktreePath, REPO_REVIEW_PATH));
16435
16625
  if (fromWorktree) return fromWorktree;
16436
16626
  const repo = repoPath?.replace(/\/+$/, "");
16437
16627
  const wt = worktreePath.replace(/\/+$/, "");
16438
16628
  if (!repo || repo === wt) return null;
16439
- return readTextIfPresent((0, import_node_path39.join)(repo, REPO_REVIEW_PATH));
16629
+ return readTextIfPresent((0, import_node_path40.join)(repo, REPO_REVIEW_PATH));
16440
16630
  }
16441
16631
  function ensureReviewGuidelinesFile(worktreePath, repoPath) {
16442
- const skillContent = readTextIfPresent((0, import_node_path39.join)(worktreePath, REVIEW_SKILL_PATH));
16632
+ const skillContent = readTextIfPresent((0, import_node_path40.join)(worktreePath, REVIEW_SKILL_PATH));
16443
16633
  if (skillContent) {
16444
16634
  return { ...skillGuidelines(skillContent, "skill"), wrote: false };
16445
16635
  }
16446
- const contextContent = readTextIfPresent((0, import_node_path39.join)(worktreePath, CONTEXT_REVIEW_PATH));
16636
+ const contextContent = readTextIfPresent((0, import_node_path40.join)(worktreePath, CONTEXT_REVIEW_PATH));
16447
16637
  if (contextContent && !shouldRefreshReviewRequestTemplate(contextContent)) {
16448
16638
  return { ...contextGuidelines(contextContent, "local"), wrote: false };
16449
16639
  }
@@ -16481,7 +16671,7 @@ function buildReviewRequestAttachment(content, opts) {
16481
16671
  };
16482
16672
  }
16483
16673
  function readExistingReviewRequestFile(worktreePath) {
16484
- return readTextIfPresent((0, import_node_path39.join)(worktreePath, REVIEW_SKILL_PATH)) ?? readTextIfPresent((0, import_node_path39.join)(worktreePath, CONTEXT_REVIEW_PATH)) ?? readTextIfPresent((0, import_node_path39.join)(worktreePath, REPO_REVIEW_PATH)) ?? readTextIfPresent((0, import_node_path39.join)(worktreePath, REVIEW_REQUEST_PATH)) ?? readTextIfPresent((0, import_node_path39.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH));
16674
+ return readTextIfPresent((0, import_node_path40.join)(worktreePath, REVIEW_SKILL_PATH)) ?? readTextIfPresent((0, import_node_path40.join)(worktreePath, CONTEXT_REVIEW_PATH)) ?? readTextIfPresent((0, import_node_path40.join)(worktreePath, REPO_REVIEW_PATH)) ?? readTextIfPresent((0, import_node_path40.join)(worktreePath, REVIEW_REQUEST_PATH)) ?? readTextIfPresent((0, import_node_path40.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH));
16485
16675
  }
16486
16676
  async function requestReview(threadRef, send2) {
16487
16677
  const from = findThreadByRef(threadRef);
@@ -16508,13 +16698,13 @@ async function requestReview(threadRef, send2) {
16508
16698
  const started = await send2(tab.id, REVIEW_REQUEST_PREFILL);
16509
16699
  return { tab: started, from };
16510
16700
  }
16511
- var import_node_crypto9, import_node_fs39, import_node_path39, REPO_REVIEW_PATH, REPO_REVIEW_NAME, CONTEXT_REVIEW_PATH, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
16701
+ var import_node_crypto9, import_node_fs39, import_node_path40, REPO_REVIEW_PATH, REPO_REVIEW_NAME, CONTEXT_REVIEW_PATH, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
16512
16702
  var init_request_review = __esm({
16513
16703
  "src/review/request-review.ts"() {
16514
16704
  "use strict";
16515
16705
  import_node_crypto9 = require("crypto");
16516
16706
  import_node_fs39 = require("fs");
16517
- import_node_path39 = require("path");
16707
+ import_node_path40 = require("path");
16518
16708
  init_global_workspace();
16519
16709
  init_chat_tabs();
16520
16710
  init_thread_store();
@@ -16540,7 +16730,7 @@ function matchSimpleGlob(pattern, name) {
16540
16730
  return new RegExp(`^${escaped}$`).test(name);
16541
16731
  }
16542
16732
  function readWorktreeInclude(repoPath) {
16543
- const path2 = (0, import_node_path40.join)(repoPath, ".worktreeinclude");
16733
+ const path2 = (0, import_node_path41.join)(repoPath, ".worktreeinclude");
16544
16734
  if (!(0, import_node_fs40.existsSync)(path2)) return [];
16545
16735
  return (0, import_node_fs40.readFileSync)(path2, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
16546
16736
  }
@@ -16555,7 +16745,7 @@ function resolveFilesToCopy(repoPath) {
16555
16745
  for (const entry of (0, import_node_fs40.readdirSync)(repoPath, { withFileTypes: true })) {
16556
16746
  if (!entry.isFile()) continue;
16557
16747
  for (const glob of settings.fileIncludeGlobs) {
16558
- if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path40.basename)(glob), entry.name)) {
16748
+ if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path41.basename)(glob), entry.name)) {
16559
16749
  matched.push(entry.name);
16560
16750
  break;
16561
16751
  }
@@ -16581,10 +16771,10 @@ function copyConfiguredFiles(repoPath, worktreePath) {
16581
16771
  const patterns = resolveFilesToCopy(repoPath);
16582
16772
  const copied = [];
16583
16773
  for (const rel of patterns) {
16584
- const src = (0, import_node_path40.join)(repoPath, rel);
16774
+ const src = (0, import_node_path41.join)(repoPath, rel);
16585
16775
  if (!(0, import_node_fs40.existsSync)(src)) continue;
16586
- const dest = (0, import_node_path40.join)(worktreePath, rel);
16587
- (0, import_node_fs40.mkdirSync)((0, import_node_path40.dirname)(dest), { recursive: true });
16776
+ const dest = (0, import_node_path41.join)(worktreePath, rel);
16777
+ (0, import_node_fs40.mkdirSync)((0, import_node_path41.dirname)(dest), { recursive: true });
16588
16778
  (0, import_node_fs40.copyFileSync)(src, dest);
16589
16779
  copied.push(rel);
16590
16780
  }
@@ -16620,7 +16810,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
16620
16810
  const env = stripNestedElectronEnv({
16621
16811
  ...baseEnv ?? process.env
16622
16812
  });
16623
- const name = opts.workspaceName ?? (0, import_node_path40.basename)(opts.worktreePath);
16813
+ const name = opts.workspaceName ?? (0, import_node_path41.basename)(opts.worktreePath);
16624
16814
  const ports = opts.ports ?? [];
16625
16815
  const primary = ports[0];
16626
16816
  env.SIDEBOARD_WORKSPACE_NAME = name;
@@ -16883,13 +17073,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
16883
17073
  done: handle.done
16884
17074
  };
16885
17075
  }
16886
- var import_node_fs40, import_node_net, import_node_path40, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
17076
+ var import_node_fs40, import_node_net, import_node_path41, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
16887
17077
  var init_conductor = __esm({
16888
17078
  "src/hook/conductor.ts"() {
16889
17079
  "use strict";
16890
17080
  import_node_fs40 = require("fs");
16891
17081
  import_node_net = require("net");
16892
- import_node_path40 = require("path");
17082
+ import_node_path41 = require("path");
16893
17083
  import_execa4 = require("execa");
16894
17084
  import_node_readline3 = require("readline");
16895
17085
  init_settings();
@@ -16953,9 +17143,9 @@ async function findOrphanWorktrees(repoPaths) {
16953
17143
  if ((0, import_node_fs41.existsSync)(root)) {
16954
17144
  for (const entry of (0, import_node_fs41.readdirSync)(root, { withFileTypes: true })) {
16955
17145
  if (!entry.isDirectory()) continue;
16956
- const path2 = (0, import_node_path41.join)(root, entry.name).replace(/\/$/, "");
17146
+ const path2 = (0, import_node_path42.join)(root, entry.name).replace(/\/$/, "");
16957
17147
  if (known.has(path2) || seen.has(path2)) continue;
16958
- if (!(0, import_node_fs41.existsSync)((0, import_node_path41.join)(path2, ".git"))) continue;
17148
+ if (!(0, import_node_fs41.existsSync)((0, import_node_path42.join)(path2, ".git"))) continue;
16959
17149
  seen.add(path2);
16960
17150
  let mtimeMs = 0;
16961
17151
  try {
@@ -17020,12 +17210,12 @@ function worktreeCleanupSettings() {
17020
17210
  autoCleanupOrphans: a.autoCleanupOrphans
17021
17211
  };
17022
17212
  }
17023
- var import_node_fs41, import_node_path41;
17213
+ var import_node_fs41, import_node_path42;
17024
17214
  var init_orphan_cleanup = __esm({
17025
17215
  "src/git/orphan-cleanup.ts"() {
17026
17216
  "use strict";
17027
17217
  import_node_fs41 = require("fs");
17028
- import_node_path41 = require("path");
17218
+ import_node_path42 = require("path");
17029
17219
  init_worktree();
17030
17220
  init_thread_store();
17031
17221
  init_paths();
@@ -17033,6 +17223,77 @@ var init_orphan_cleanup = __esm({
17033
17223
  }
17034
17224
  });
17035
17225
 
17226
+ // src/store/history-cleanup.ts
17227
+ function stripArchivedTranscript(thread) {
17228
+ writeThread(
17229
+ {
17230
+ ...thread,
17231
+ attachments: [],
17232
+ pendingTurnAttachments: [],
17233
+ messages: [historyRetentionStubMessage(thread)]
17234
+ },
17235
+ { touch: false }
17236
+ );
17237
+ }
17238
+ function cleanupArchivedHistory(opts = {}) {
17239
+ const settings = loadAppSettings();
17240
+ if (!opts.force && opts.purgeOlderThanDays == null && !autoCleanupHistoryEnabled(settings)) {
17241
+ return { stripped: [], purged: [] };
17242
+ }
17243
+ const archived = listThreads({ includeArchived: true }).filter((t) => t.status === "archived");
17244
+ const nowMs = opts.nowMs ?? Date.now();
17245
+ const plan = opts.purgeOlderThanDays != null ? { stripIds: [], purgeIds: planHistoryAgePurge(archived, opts.purgeOlderThanDays, nowMs) } : planHistoryRetention(archived, {
17246
+ maxCount: opts.maxCount ?? historyMaxCount(settings),
17247
+ maxDays: opts.maxDays ?? historyMaxDays(settings),
17248
+ nowMs
17249
+ });
17250
+ const stripped = [];
17251
+ const purged = [];
17252
+ if (opts.dryRun) {
17253
+ return { stripped: plan.stripIds, purged: plan.purgeIds };
17254
+ }
17255
+ for (const id of plan.stripIds) {
17256
+ const thread = readThread(id);
17257
+ if (!thread || thread.status !== "archived") continue;
17258
+ try {
17259
+ stripArchivedTranscript(thread);
17260
+ stripped.push(id);
17261
+ } catch {
17262
+ }
17263
+ }
17264
+ for (const id of plan.purgeIds) {
17265
+ const thread = readThread(id);
17266
+ if (!thread || thread.status !== "archived") continue;
17267
+ try {
17268
+ deleteThreadRecord(id);
17269
+ purged.push(id);
17270
+ } catch {
17271
+ }
17272
+ }
17273
+ if (stripped.length > 0 || purged.length > 0) {
17274
+ updateAdvancedSettings({
17275
+ historyLastCleanupAt: new Date(nowMs).toISOString()
17276
+ });
17277
+ }
17278
+ return { stripped, purged };
17279
+ }
17280
+ function shouldRunHistoryCleanup(settings = loadAppSettings()) {
17281
+ if (!autoCleanupHistoryEnabled(settings)) return false;
17282
+ const intervalHours = settings.advanced.historyCleanupIntervalHours ?? HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT;
17283
+ const last = settings.advanced.historyLastCleanupAt;
17284
+ if (!last) return true;
17285
+ const elapsed = Date.now() - Date.parse(last);
17286
+ return Number.isFinite(elapsed) && elapsed >= intervalHours * 36e5;
17287
+ }
17288
+ var init_history_cleanup = __esm({
17289
+ "src/store/history-cleanup.ts"() {
17290
+ "use strict";
17291
+ init_app_settings();
17292
+ init_history_retention();
17293
+ init_thread_store();
17294
+ }
17295
+ });
17296
+
17036
17297
  // src/git/apply-into-main.ts
17037
17298
  async function applyThreadIntoMain(thread, opts) {
17038
17299
  const method = opts?.method ?? "merge";
@@ -17128,11 +17389,11 @@ async function cloneRepoIntoSideboard(opts) {
17128
17389
  if (!url) throw new Error("Clone URL is required");
17129
17390
  let name = opts.name?.trim();
17130
17391
  if (!name) {
17131
- const leaf = (0, import_node_path42.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
17392
+ const leaf = (0, import_node_path43.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
17132
17393
  name = leaf || "repo";
17133
17394
  }
17134
17395
  name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
17135
- const dest = (0, import_node_path42.join)(sideboardReposDir(), name);
17396
+ const dest = (0, import_node_path43.join)(sideboardReposDir(), name);
17136
17397
  if ((0, import_node_fs42.existsSync)(dest)) {
17137
17398
  const repoPath2 = await resolveRepoRoot(dest);
17138
17399
  const workspace2 = await ensureWorkspace(repoPath2);
@@ -17148,12 +17409,12 @@ async function cloneRepoIntoSideboard(opts) {
17148
17409
  const workspace = await ensureWorkspace(repoPath);
17149
17410
  return { repoPath, workspace };
17150
17411
  }
17151
- var import_node_fs42, import_node_path42, import_execa6;
17412
+ var import_node_fs42, import_node_path43, import_execa6;
17152
17413
  var init_clone_repo = __esm({
17153
17414
  "src/git/clone-repo.ts"() {
17154
17415
  "use strict";
17155
17416
  import_node_fs42 = require("fs");
17156
- import_node_path42 = require("path");
17417
+ import_node_path43 = require("path");
17157
17418
  import_execa6 = require("execa");
17158
17419
  init_paths();
17159
17420
  init_workspaces();
@@ -17279,7 +17540,7 @@ function readIntFile(file) {
17279
17540
  return Number.isInteger(n) ? n : null;
17280
17541
  }
17281
17542
  function jobDir(root, id, legacy = false) {
17282
- return (0, import_node_path43.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
17543
+ return (0, import_node_path44.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
17283
17544
  }
17284
17545
  function resolveJobDir(root, id) {
17285
17546
  const modern = jobDir(root, id, false);
@@ -17289,7 +17550,7 @@ function resolveJobDir(root, id) {
17289
17550
  return modern;
17290
17551
  }
17291
17552
  function listJobIdsIn(root, rel) {
17292
- const dir = (0, import_node_path43.join)(root, rel);
17553
+ const dir = (0, import_node_path44.join)(root, rel);
17293
17554
  if (!(0, import_node_fs43.existsSync)(dir)) return [];
17294
17555
  return (0, import_node_fs43.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
17295
17556
  }
@@ -17303,7 +17564,7 @@ function listRunningDetachedJobs(worktreePath) {
17303
17564
  const running = [];
17304
17565
  for (const id of ids) {
17305
17566
  const dir = resolveJobDir(root, id);
17306
- const pid = readIntFile((0, import_node_path43.join)(dir, "pid"));
17567
+ const pid = readIntFile((0, import_node_path44.join)(dir, "pid"));
17307
17568
  if (jobTreeAlive(pid)) running.push(id);
17308
17569
  }
17309
17570
  return running.sort();
@@ -17406,15 +17667,15 @@ function takeDelta(logFile, cursorFile) {
17406
17667
  return { delta: capJobLogDelta(lines.slice(start).join("\n")), nextCursor: lines.length };
17407
17668
  }
17408
17669
  function snapshotJob(dir) {
17409
- const pid = readIntFile((0, import_node_path43.join)(dir, "pid"));
17670
+ const pid = readIntFile((0, import_node_path44.join)(dir, "pid"));
17410
17671
  const running = jobTreeAlive(pid);
17411
17672
  return {
17412
17673
  pid,
17413
17674
  running,
17414
- exitCode: readIntFile((0, import_node_path43.join)(dir, "exit")),
17415
- log: (0, import_node_path43.join)(dir, "log"),
17416
- cursor: (0, import_node_path43.join)(dir, "present.cursor"),
17417
- progress: tailProgress((0, import_node_path43.join)(dir, "log"))
17675
+ exitCode: readIntFile((0, import_node_path44.join)(dir, "exit")),
17676
+ log: (0, import_node_path44.join)(dir, "log"),
17677
+ cursor: (0, import_node_path44.join)(dir, "present.cursor"),
17678
+ progress: tailProgress((0, import_node_path44.join)(dir, "log"))
17418
17679
  };
17419
17680
  }
17420
17681
  function toResult(id, snap, extra) {
@@ -17423,7 +17684,7 @@ function toResult(id, snap, extra) {
17423
17684
  const stillRunning = snap.running && !ok;
17424
17685
  const { delta, nextCursor } = takeDelta(snap.log, snap.cursor);
17425
17686
  try {
17426
- (0, import_node_fs43.mkdirSync)((0, import_node_path43.dirname)(snap.cursor), { recursive: true });
17687
+ (0, import_node_fs43.mkdirSync)((0, import_node_path44.dirname)(snap.cursor), { recursive: true });
17427
17688
  (0, import_node_fs43.writeFileSync)(snap.cursor, `${nextCursor}
17428
17689
  `);
17429
17690
  } catch {
@@ -17499,7 +17760,7 @@ function killProcessTree(pid, signal) {
17499
17760
  }
17500
17761
  function appendJobLog(logFile, line) {
17501
17762
  try {
17502
- (0, import_node_fs43.mkdirSync)((0, import_node_path43.dirname)(logFile), { recursive: true });
17763
+ (0, import_node_fs43.mkdirSync)((0, import_node_path44.dirname)(logFile), { recursive: true });
17503
17764
  const body = line.endsWith("\n") ? line : `${line}
17504
17765
  `;
17505
17766
  (0, import_node_fs43.appendFileSync)(logFile, body);
@@ -17548,7 +17809,7 @@ async function stopDetachedJob(cwd, id, opts) {
17548
17809
  killProcessTree(targetPid, "SIGKILL");
17549
17810
  await sleep2(100);
17550
17811
  }
17551
- const exitFile = (0, import_node_path43.join)(dir, "exit");
17812
+ const exitFile = (0, import_node_path44.join)(dir, "exit");
17552
17813
  if (!(0, import_node_fs43.existsSync)(exitFile)) {
17553
17814
  try {
17554
17815
  (0, import_node_fs43.writeFileSync)(exitFile, "1\n");
@@ -17571,12 +17832,12 @@ async function stopDetachedJob(cwd, id, opts) {
17571
17832
  hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
17572
17833
  };
17573
17834
  }
17574
- var import_node_fs43, import_node_path43, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, DEFERRED_DONE_MAX_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
17835
+ var import_node_fs43, import_node_path44, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, DEFERRED_DONE_MAX_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
17575
17836
  var init_wait_for_job = __esm({
17576
17837
  "src/mcp/wait-for-job.ts"() {
17577
17838
  "use strict";
17578
17839
  import_node_fs43 = require("fs");
17579
- import_node_path43 = require("path");
17840
+ import_node_path44 = require("path");
17580
17841
  init_workspace_scratch();
17581
17842
  init_wait_for_turn();
17582
17843
  MAX_JOB_CONTINUES = 8;
@@ -19709,7 +19970,7 @@ var init_quota_failover = __esm({
19709
19970
  // src/threads/adopt.ts
19710
19971
  function thisModuleFile() {
19711
19972
  const cjsFile = typeof __filename !== "undefined" ? __filename : "";
19712
- return cjsFile || process.argv[1] || (0, import_node_path44.join)(process.cwd(), "package.json");
19973
+ return cjsFile || process.argv[1] || (0, import_node_path45.join)(process.cwd(), "package.json");
19713
19974
  }
19714
19975
  function openReadonlySqlite(file) {
19715
19976
  const req = (0, import_node_module4.createRequire)(thisModuleFile());
@@ -19737,7 +19998,7 @@ function resolveConductorCursorAgentId(workspacePath) {
19737
19998
  return null;
19738
19999
  }
19739
20000
  for (const hash of hashes) {
19740
- const agentsFile = (0, import_node_path44.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
20001
+ const agentsFile = (0, import_node_path45.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
19741
20002
  if (!(0, import_node_fs46.existsSync)(agentsFile)) continue;
19742
20003
  let text7;
19743
20004
  try {
@@ -19797,8 +20058,8 @@ function listConductorWorkspaces() {
19797
20058
  if (!(0, import_node_fs46.existsSync)(CONDUCTOR_DB)) {
19798
20059
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
19799
20060
  }
19800
- const tmp = (0, import_node_fs46.mkdtempSync)((0, import_node_path44.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
19801
- const snapshot = (0, import_node_path44.join)(tmp, "conductor.db");
20061
+ const tmp = (0, import_node_fs46.mkdtempSync)((0, import_node_path45.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
20062
+ const snapshot = (0, import_node_path45.join)(tmp, "conductor.db");
19802
20063
  try {
19803
20064
  (0, import_node_fs46.copyFileSync)(CONDUCTOR_DB, snapshot);
19804
20065
  for (const suffix of ["-wal", "-shm"]) {
@@ -19888,8 +20149,8 @@ function importConductorWorkspace(workspaceId) {
19888
20149
  if (!(0, import_node_fs46.existsSync)(CONDUCTOR_DB)) {
19889
20150
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
19890
20151
  }
19891
- const tmp = (0, import_node_fs46.mkdtempSync)((0, import_node_path44.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
19892
- const snapshot = (0, import_node_path44.join)(tmp, "conductor.db");
20152
+ const tmp = (0, import_node_fs46.mkdtempSync)((0, import_node_path45.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
20153
+ const snapshot = (0, import_node_path45.join)(tmp, "conductor.db");
19893
20154
  try {
19894
20155
  (0, import_node_fs46.copyFileSync)(CONDUCTOR_DB, snapshot);
19895
20156
  for (const suffix of ["-wal", "-shm"]) {
@@ -19983,25 +20244,25 @@ function importConductorWorkspace(workspaceId) {
19983
20244
  async function importConductorWorkspaceAsync(workspaceId) {
19984
20245
  return importConductorWorkspace(workspaceId);
19985
20246
  }
19986
- var import_node_child_process5, import_node_fs46, import_node_os14, import_node_path44, import_node_module4, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
20247
+ var import_node_child_process5, import_node_fs46, import_node_os14, import_node_path45, import_node_module4, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
19987
20248
  var init_adopt = __esm({
19988
20249
  "src/threads/adopt.ts"() {
19989
20250
  "use strict";
19990
20251
  import_node_child_process5 = require("child_process");
19991
20252
  import_node_fs46 = require("fs");
19992
20253
  import_node_os14 = require("os");
19993
- import_node_path44 = require("path");
20254
+ import_node_path45 = require("path");
19994
20255
  import_node_module4 = require("module");
19995
20256
  init_worktree();
19996
20257
  init_thread_store();
19997
- CONDUCTOR_APP_SUPPORT = (0, import_node_path44.join)(
20258
+ CONDUCTOR_APP_SUPPORT = (0, import_node_path45.join)(
19998
20259
  process.env.HOME ?? "",
19999
20260
  "Library",
20000
20261
  "Application Support",
20001
20262
  "com.conductor.app"
20002
20263
  );
20003
- CONDUCTOR_DB = (0, import_node_path44.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
20004
- CURSOR_SDK_STORE = (0, import_node_path44.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
20264
+ CONDUCTOR_DB = (0, import_node_path45.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
20265
+ CURSOR_SDK_STORE = (0, import_node_path45.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
20005
20266
  }
20006
20267
  });
20007
20268
 
@@ -20456,7 +20717,7 @@ new file mode 100644
20456
20717
  };
20457
20718
  }
20458
20719
  async function untrackedPatch(worktreePath, path2, maxHunk) {
20459
- const abs = (0, import_node_path45.join)(worktreePath, path2);
20720
+ const abs = (0, import_node_path46.join)(worktreePath, path2);
20460
20721
  try {
20461
20722
  const st = (0, import_node_fs48.statSync)(abs);
20462
20723
  if (st.isFile() && st.size > maxHunk) {
@@ -20949,7 +21210,7 @@ function isImageRelativePath(relativePath) {
20949
21210
  function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
20950
21211
  assertSafeRelativePath(relativePath);
20951
21212
  const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
20952
- const abs = (0, import_node_path45.join)(worktreePath, relativePath);
21213
+ const abs = (0, import_node_path46.join)(worktreePath, relativePath);
20953
21214
  const st = (0, import_node_fs48.statSync)(abs);
20954
21215
  if (!st.isFile()) {
20955
21216
  throw new Error(`Not a file: ${relativePath}`);
@@ -20969,7 +21230,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
20969
21230
  function readWorktreeFile(worktreePath, relativePath, opts) {
20970
21231
  assertSafeRelativePath(relativePath);
20971
21232
  const maxBytes = opts?.maxBytes ?? 2e5;
20972
- const abs = (0, import_node_path45.join)(worktreePath, relativePath);
21233
+ const abs = (0, import_node_path46.join)(worktreePath, relativePath);
20973
21234
  const st = (0, import_node_fs48.statSync)(abs);
20974
21235
  if (!st.isFile()) {
20975
21236
  throw new Error(`Not a file: ${relativePath}`);
@@ -21017,8 +21278,8 @@ function assertSafeRelativePath(relativePath) {
21017
21278
  }
21018
21279
  function writeWorktreeFile(worktreePath, relativePath, content) {
21019
21280
  assertSafeRelativePath(relativePath);
21020
- const abs = (0, import_node_path45.join)(worktreePath, relativePath);
21021
- (0, import_node_fs48.mkdirSync)((0, import_node_path45.dirname)(abs), { recursive: true });
21281
+ const abs = (0, import_node_path46.join)(worktreePath, relativePath);
21282
+ (0, import_node_fs48.mkdirSync)((0, import_node_path46.dirname)(abs), { recursive: true });
21022
21283
  (0, import_node_fs48.writeFileSync)(abs, content, "utf8");
21023
21284
  return { path: relativePath };
21024
21285
  }
@@ -21036,12 +21297,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
21036
21297
  truncated: full.files.length > maxFiles
21037
21298
  };
21038
21299
  }
21039
- var import_node_fs48, import_node_path45, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
21300
+ var import_node_fs48, import_node_path46, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
21040
21301
  var init_diff = __esm({
21041
21302
  "src/diff/diff.ts"() {
21042
21303
  "use strict";
21043
21304
  import_node_fs48 = require("fs");
21044
- import_node_path45 = require("path");
21305
+ import_node_path46 = require("path");
21045
21306
  init_run();
21046
21307
  init_worktree();
21047
21308
  mergeBaseCache = /* @__PURE__ */ new Map();
@@ -21426,7 +21687,7 @@ function scanSkillsDir(dir, source, out) {
21426
21687
  }
21427
21688
  for (const entry of entries) {
21428
21689
  if (entry.startsWith(".")) continue;
21429
- const skillMd = (0, import_node_path46.join)(dir, entry, "SKILL.md");
21690
+ const skillMd = (0, import_node_path47.join)(dir, entry, "SKILL.md");
21430
21691
  if (!(0, import_node_fs49.existsSync)(skillMd)) continue;
21431
21692
  try {
21432
21693
  if (!(0, import_node_fs49.statSync)(skillMd).isFile()) continue;
@@ -21448,12 +21709,12 @@ function scanClaudePluginSkills(pluginsRoot, out) {
21448
21709
  return;
21449
21710
  }
21450
21711
  if (lookingForSkillsDir && entries.includes("SKILL.md")) {
21451
- const skill = readSkill((0, import_node_path46.join)(dir, "SKILL.md"), "cli");
21712
+ const skill = readSkill((0, import_node_path47.join)(dir, "SKILL.md"), "cli");
21452
21713
  if (skill) out.push(skill);
21453
21714
  }
21454
21715
  for (const entry of entries) {
21455
21716
  if (entry === "node_modules" || entry === ".git") continue;
21456
- const full = (0, import_node_path46.join)(dir, entry);
21717
+ const full = (0, import_node_path47.join)(dir, entry);
21457
21718
  try {
21458
21719
  if (!(0, import_node_fs49.statSync)(full).isDirectory()) continue;
21459
21720
  } catch {
@@ -21473,17 +21734,17 @@ function discoverSkills(worktreePath) {
21473
21734
  const home = (0, import_node_os15.homedir)();
21474
21735
  const collected = [];
21475
21736
  for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
21476
- scanSkillsDir((0, import_node_path46.join)(worktreePath, rel), "workspace", collected);
21737
+ scanSkillsDir((0, import_node_path47.join)(worktreePath, rel), "workspace", collected);
21477
21738
  }
21478
21739
  for (const abs of [
21479
- (0, import_node_path46.join)(home, ".claude/skills"),
21480
- (0, import_node_path46.join)(home, ".cursor/skills"),
21481
- (0, import_node_path46.join)(home, ".sideboard/skills"),
21482
- (0, import_node_path46.join)(home, ".brightsy/skills")
21740
+ (0, import_node_path47.join)(home, ".claude/skills"),
21741
+ (0, import_node_path47.join)(home, ".cursor/skills"),
21742
+ (0, import_node_path47.join)(home, ".sideboard/skills"),
21743
+ (0, import_node_path47.join)(home, ".brightsy/skills")
21483
21744
  ]) {
21484
21745
  scanSkillsDir(abs, "user", collected);
21485
21746
  }
21486
- scanClaudePluginSkills((0, import_node_path46.join)(home, ".claude/plugins"), collected);
21747
+ scanClaudePluginSkills((0, import_node_path47.join)(home, ".claude/plugins"), collected);
21487
21748
  collected.push(...bundledSkills());
21488
21749
  const rank = {
21489
21750
  workspace: 0,
@@ -21523,13 +21784,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
21523
21784
 
21524
21785
  \u2026(truncated)` : raw;
21525
21786
  }
21526
- var import_node_fs49, import_node_os15, import_node_path46, BUNDLED_SKILL_PREFIX;
21787
+ var import_node_fs49, import_node_os15, import_node_path47, BUNDLED_SKILL_PREFIX;
21527
21788
  var init_discover = __esm({
21528
21789
  "src/skills/discover.ts"() {
21529
21790
  "use strict";
21530
21791
  import_node_fs49 = require("fs");
21531
21792
  import_node_os15 = require("os");
21532
- import_node_path46 = require("path");
21793
+ import_node_path47 = require("path");
21533
21794
  init_long_running();
21534
21795
  BUNDLED_SKILL_PREFIX = "bundled:";
21535
21796
  }
@@ -21650,7 +21911,7 @@ var init_consume_attachments = __esm({
21650
21911
  // src/skills/detached-job-path.ts
21651
21912
  function detachedJobScriptIn(dir) {
21652
21913
  for (const name of DETACHED_JOB_FILENAMES) {
21653
- const script = (0, import_node_path47.join)(dir, "scripts", name);
21914
+ const script = (0, import_node_path48.join)(dir, "scripts", name);
21654
21915
  if ((0, import_node_fs50.existsSync)(script)) return script;
21655
21916
  }
21656
21917
  return null;
@@ -21663,11 +21924,11 @@ function packagedDetachedJobPath() {
21663
21924
  function resolveDetachedJobScript() {
21664
21925
  const packaged = packagedDetachedJobPath();
21665
21926
  if (packaged) return packaged;
21666
- let dir = (0, import_node_path47.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
21927
+ let dir = (0, import_node_path48.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
21667
21928
  for (let i = 0; i < 8; i++) {
21668
21929
  const candidate = detachedJobScriptIn(dir);
21669
21930
  if (candidate) return candidate;
21670
- const parent = (0, import_node_path47.dirname)(dir);
21931
+ const parent = (0, import_node_path48.dirname)(dir);
21671
21932
  if (parent === dir) break;
21672
21933
  dir = parent;
21673
21934
  }
@@ -21678,12 +21939,12 @@ function formatDetachedJobInvoke(scriptPath) {
21678
21939
  if (resolved) return `node ${JSON.stringify(resolved)}`;
21679
21940
  return "node scripts/detached-job.cjs";
21680
21941
  }
21681
- var import_node_fs50, import_node_path47, import_node_url3, import_meta3, DETACHED_JOB_FILENAMES;
21942
+ var import_node_fs50, import_node_path48, import_node_url3, import_meta3, DETACHED_JOB_FILENAMES;
21682
21943
  var init_detached_job_path = __esm({
21683
21944
  "src/skills/detached-job-path.ts"() {
21684
21945
  "use strict";
21685
21946
  import_node_fs50 = require("fs");
21686
- import_node_path47 = require("path");
21947
+ import_node_path48 = require("path");
21687
21948
  import_node_url3 = require("url");
21688
21949
  init_packaged_runtime();
21689
21950
  import_meta3 = {};
@@ -21865,9 +22126,9 @@ function formatPrGateDirective() {
21865
22126
  }
21866
22127
  function formatProcessGuideDirective(opts) {
21867
22128
  const worktree = opts?.worktreePath?.trim();
21868
- const hasGraphSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path48.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
21869
- const hasReviewSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path48.join)(worktree, ".claude/skills/review/SKILL.md"));
21870
- const hasInstallSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path48.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
22129
+ const hasGraphSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path49.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
22130
+ const hasReviewSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path49.join)(worktree, ".claude/skills/review/SKILL.md"));
22131
+ const hasInstallSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path49.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
21871
22132
  return [
21872
22133
  "Process guides (recurring work only):",
21873
22134
  hasGraphSkill ? "- Migrations, ports, batch fixes, and other fan-out: follow `.claude/skills/graph-engineering/SKILL.md` (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch around it." : null,
@@ -21905,12 +22166,12 @@ function formatArtifactDirective() {
21905
22166
  function formatUiReminder() {
21906
22167
  return "Sideboard UI: markdown table is enough to read data; present_schema if they ask to edit/filter (even after markdown); present_files for the file manager. html fence or present_artifact, not both for the same document. type=log appends (same artifact_id, new lines only). ask_user only for a real multiple-choice (not hellos, \u201Cwhat next?\u201D, or after a review) \u2014 reply in chat. Do not say artifacts/CMS UI are unavailable.";
21907
22168
  }
21908
- var import_node_fs51, import_node_path48, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
22169
+ var import_node_fs51, import_node_path49, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
21909
22170
  var init_instructions = __esm({
21910
22171
  "src/agents/instructions.ts"() {
21911
22172
  "use strict";
21912
22173
  import_node_fs51 = require("fs");
21913
- import_node_path48 = require("path");
22174
+ import_node_path49 = require("path");
21914
22175
  init_git_auth_mode();
21915
22176
  init_branch_prefix();
21916
22177
  init_worktree_labels();
@@ -22296,13 +22557,13 @@ __export(plan_file_exports, {
22296
22557
  writePlanFile: () => writePlanFile
22297
22558
  });
22298
22559
  function ensureAttachmentsGitignore(worktreePath) {
22299
- const gitignoreAbs = (0, import_node_path49.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
22560
+ const gitignoreAbs = (0, import_node_path50.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
22300
22561
  if ((0, import_node_fs52.existsSync)(gitignoreAbs)) return;
22301
- (0, import_node_fs52.mkdirSync)((0, import_node_path49.dirname)(gitignoreAbs), { recursive: true });
22562
+ (0, import_node_fs52.mkdirSync)((0, import_node_path50.dirname)(gitignoreAbs), { recursive: true });
22302
22563
  (0, import_node_fs52.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
22303
22564
  }
22304
22565
  function planFileAbs(worktreePath) {
22305
- return (0, import_node_path49.join)(worktreePath, PLAN_FILE_REL);
22566
+ return (0, import_node_path50.join)(worktreePath, PLAN_FILE_REL);
22306
22567
  }
22307
22568
  function readTextIfPresent2(abs) {
22308
22569
  if (!(0, import_node_fs52.existsSync)(abs)) return null;
@@ -22314,22 +22575,22 @@ function readTextIfPresent2(abs) {
22314
22575
  }
22315
22576
  }
22316
22577
  function readPlanFile(worktreePath) {
22317
- return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path49.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path49.join)(worktreePath, LEGACY_PLAN_FILE_REL));
22578
+ return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path50.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path50.join)(worktreePath, LEGACY_PLAN_FILE_REL));
22318
22579
  }
22319
22580
  function writePlanFile(worktreePath, content) {
22320
22581
  ensureAttachmentsGitignore(worktreePath);
22321
22582
  const abs = planFileAbs(worktreePath);
22322
- (0, import_node_fs52.mkdirSync)((0, import_node_path49.dirname)(abs), { recursive: true });
22583
+ (0, import_node_fs52.mkdirSync)((0, import_node_path50.dirname)(abs), { recursive: true });
22323
22584
  const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
22324
22585
  (0, import_node_fs52.writeFileSync)(abs, body, "utf8");
22325
22586
  return PLAN_FILE_REL;
22326
22587
  }
22327
- var import_node_fs52, import_node_path49;
22588
+ var import_node_fs52, import_node_path50;
22328
22589
  var init_plan_file = __esm({
22329
22590
  "src/plan/plan-file.ts"() {
22330
22591
  "use strict";
22331
22592
  import_node_fs52 = require("fs");
22332
- import_node_path49 = require("path");
22593
+ import_node_path50 = require("path");
22333
22594
  init_workspace_scratch();
22334
22595
  init_plan_present();
22335
22596
  init_plan_present();
@@ -22375,37 +22636,6 @@ var init_sync_branch = __esm({
22375
22636
  }
22376
22637
  });
22377
22638
 
22378
- // src/agents/cursor-store.ts
22379
- function cursorSdkStoreDir(threadId) {
22380
- const root = (0, import_node_path50.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
22381
- const id = sanitizeCursorStoreSegment(threadId);
22382
- if (!id) return root;
22383
- return (0, import_node_path50.join)(root, "threads", id);
22384
- }
22385
- function cursorSdkRunsNdjsonPath(threadId) {
22386
- return (0, import_node_path50.join)(cursorSdkStoreDir(threadId), "runs.ndjson");
22387
- }
22388
- function cursorSdkRunsNdjsonSearchPaths(threadId) {
22389
- const scoped = cursorSdkRunsNdjsonPath(threadId);
22390
- const shared = cursorSdkRunsNdjsonPath(null);
22391
- if (!threadId || !sanitizeCursorStoreSegment(threadId) || scoped === shared) {
22392
- return [shared];
22393
- }
22394
- return [scoped, shared];
22395
- }
22396
- function sanitizeCursorStoreSegment(threadId) {
22397
- return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
22398
- }
22399
- var import_node_path50, CURSOR_SDK_STORE_DIR;
22400
- var init_cursor_store = __esm({
22401
- "src/agents/cursor-store.ts"() {
22402
- "use strict";
22403
- import_node_path50 = require("path");
22404
- init_paths();
22405
- CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
22406
- }
22407
- });
22408
-
22409
22639
  // src/agents/cursor-recover.ts
22410
22640
  var cursor_recover_exports = {};
22411
22641
  __export(cursor_recover_exports, {
@@ -22615,6 +22845,7 @@ var init_orchestrator = __esm({
22615
22845
  init_conductor();
22616
22846
  init_setup_log();
22617
22847
  init_orphan_cleanup();
22848
+ init_history_cleanup();
22618
22849
  init_apply_into_main();
22619
22850
  init_clone_repo();
22620
22851
  init_message_parts();
@@ -22802,6 +23033,12 @@ var init_orchestrator = __esm({
22802
23033
  }
22803
23034
  } catch {
22804
23035
  }
23036
+ try {
23037
+ if (shouldRunHistoryCleanup()) {
23038
+ cleanupArchivedHistory();
23039
+ }
23040
+ } catch {
23041
+ }
22805
23042
  if (drainQueues) {
22806
23043
  this.adoptPersistedQueues();
22807
23044
  }
@@ -24130,6 +24367,20 @@ var init_orchestrator = __esm({
24130
24367
  repoPaths
24131
24368
  });
24132
24369
  }
24370
+ /** Bound Settings → History. After archive always; reconcile is interval-gated. */
24371
+ enforceHistoryRetention() {
24372
+ try {
24373
+ cleanupArchivedHistory();
24374
+ } catch {
24375
+ }
24376
+ }
24377
+ cleanupHistory(opts) {
24378
+ return cleanupArchivedHistory({
24379
+ dryRun: opts?.dryRun,
24380
+ purgeOlderThanDays: opts?.purgeOlderThanDays,
24381
+ force: opts?.force
24382
+ });
24383
+ }
24133
24384
  /**
24134
24385
  * Best-of-n / fanout: create N threads (one per agent) with the same prompt.
24135
24386
  */
@@ -24690,6 +24941,7 @@ var init_orchestrator = __esm({
24690
24941
  if (isGlobalThread(thread)) {
24691
24942
  const archived2 = setStatus(thread.id, "archived");
24692
24943
  this.emit({ type: "status_changed", threadId: archived2.id, status: "archived" });
24944
+ this.enforceHistoryRetention();
24693
24945
  return archived2;
24694
24946
  }
24695
24947
  const siblings = threadsSharingWorktree(thread.worktreePath).filter((t) => t.id !== thread.id);
@@ -24711,6 +24963,7 @@ var init_orchestrator = __esm({
24711
24963
  }
24712
24964
  const archived = setStatus(thread.id, "archived");
24713
24965
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
24966
+ this.enforceHistoryRetention();
24714
24967
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
24715
24968
  try {
24716
24969
  const { ensureWorkspace: ensureWorkspace2 } = await Promise.resolve().then(() => (init_workspaces(), workspaces_exports));
@@ -25011,6 +25264,12 @@ __export(index_exports, {
25011
25264
  GITHUB_PR_BODY_SAFE_CHARS: () => GITHUB_PR_BODY_SAFE_CHARS,
25012
25265
  GLOBAL_WORKSPACE_ID: () => GLOBAL_WORKSPACE_ID2,
25013
25266
  HARNESS_ENV_KEYS: () => HARNESS_ENV_KEYS,
25267
+ HISTORY_DISCARDED_TEXT: () => HISTORY_DISCARDED_TEXT,
25268
+ HISTORY_MAX_COUNT_DEFAULT: () => HISTORY_MAX_COUNT_DEFAULT,
25269
+ HISTORY_MAX_COUNT_MAX: () => HISTORY_MAX_COUNT_MAX,
25270
+ HISTORY_MAX_COUNT_MIN: () => HISTORY_MAX_COUNT_MIN,
25271
+ HISTORY_MAX_DAYS_DEFAULT: () => HISTORY_MAX_DAYS_DEFAULT,
25272
+ HISTORY_MAX_DAYS_MAX: () => HISTORY_MAX_DAYS_MAX,
25014
25273
  HOME_BOARD_CACHE_TTL_MS: () => HOME_BOARD_CACHE_TTL_MS,
25015
25274
  IMPLIED_TICKET_RESOLVE_PROMPT: () => IMPLIED_TICKET_RESOLVE_PROMPT,
25016
25275
  ISSUE_SOURCE_LABELS: () => ISSUE_SOURCE_LABELS,
@@ -25118,6 +25377,7 @@ __export(index_exports, {
25118
25377
  attachmentsFromWorktreePaths: () => attachmentsFromWorktreePaths,
25119
25378
  attachmentsGitignoreBody: () => attachmentsGitignoreBody,
25120
25379
  autoArchiveOnMergeEnabled: () => autoArchiveOnMergeEnabled,
25380
+ autoCleanupHistoryEnabled: () => autoCleanupHistoryEnabled,
25121
25381
  autoCleanupOrphansEnabled: () => autoCleanupOrphansEnabled,
25122
25382
  autoRenameBranchEnabled: () => autoRenameBranchEnabled,
25123
25383
  autoRunAfterSetupEnabled: () => autoRunAfterSetupEnabled,
@@ -25155,11 +25415,14 @@ __export(index_exports, {
25155
25415
  childEnvWithAppSettings: () => childEnvWithAppSettings,
25156
25416
  claimDesktopHost: () => claimDesktopHost,
25157
25417
  clampGithubPrBody: () => clampGithubPrBody,
25418
+ clampHistoryMaxCount: () => clampHistoryMaxCount,
25419
+ clampHistoryMaxDays: () => clampHistoryMaxDays,
25158
25420
  classifyWorktreeColumn: () => classifyWorktreeColumn,
25159
25421
  claudeAdapter: () => claudeAdapter,
25160
25422
  claudeChromeEnabled: () => claudeChromeEnabled,
25161
25423
  claudeUsageOverLimitWindows: () => claudeUsageOverLimitWindows,
25162
25424
  claudeUserSettingsPath: () => claudeUserSettingsPath,
25425
+ cleanupArchivedHistory: () => cleanupArchivedHistory,
25163
25426
  cleanupOrphanWorktrees: () => cleanupOrphanWorktrees,
25164
25427
  clearBoardPins: () => clearBoardPins,
25165
25428
  clearHomeBoardCache: () => clearHomeBoardCache,
@@ -25391,6 +25654,8 @@ __export(index_exports, {
25391
25654
  hasRepoHook: () => hasRepoHook,
25392
25655
  hasWorkspaceHook: () => hasWorkspaceHook,
25393
25656
  healOrchestrationSoccerTitles: () => healOrchestrationSoccerTitles,
25657
+ historyMaxCount: () => historyMaxCount,
25658
+ historyMaxDays: () => historyMaxDays,
25394
25659
  hottestClaudeWindow: () => hottestClaudeWindow,
25395
25660
  httpFetch: () => httpFetch,
25396
25661
  importConductorWorkspace: () => importConductorWorkspace,
@@ -25423,6 +25688,7 @@ __export(index_exports, {
25423
25688
  isGhRateLimitError: () => isGhRateLimitError,
25424
25689
  isGlobalRepoPath: () => isGlobalRepoPath,
25425
25690
  isGlobalThread: () => isGlobalThread,
25691
+ isHistoryRetentionStub: () => isHistoryRetentionStub,
25426
25692
  isHomeBoardThread: () => isHomeBoardThread,
25427
25693
  isImageFilePath: () => isImageFilePath,
25428
25694
  isInPrStack: () => isInPrStack,
@@ -25581,6 +25847,8 @@ __export(index_exports, {
25581
25847
  persistPendingFileAttachments: () => persistPendingFileAttachments,
25582
25848
  persistVaultKeyInKeychain: () => persistVaultKeyInKeychain,
25583
25849
  planFileAbs: () => planFileAbs,
25850
+ planHistoryAgePurge: () => planHistoryAgePurge,
25851
+ planHistoryRetention: () => planHistoryRetention,
25584
25852
  planQuestionsSignature: () => planQuestionsSignature,
25585
25853
  pollSlackOutboundWatches: () => pollSlackOutboundWatches,
25586
25854
  posixShellSingleQuote: () => posixShellSingleQuote,
@@ -25696,6 +25964,7 @@ __export(index_exports, {
25696
25964
  shouldRefreshReviewRequestTemplate: () => shouldRefreshReviewRequestTemplate,
25697
25965
  shouldRemoveWorktreeOnTeardown: () => shouldRemoveWorktreeOnTeardown,
25698
25966
  shouldResetSessionForOccupancy: () => shouldResetSessionForOccupancy,
25967
+ shouldRunHistoryCleanup: () => shouldRunHistoryCleanup,
25699
25968
  shouldRunWorktreeCleanup: () => shouldRunWorktreeCleanup,
25700
25969
  shouldStampSetupLastError: () => shouldStampSetupLastError,
25701
25970
  showCostEnabled: () => showCostEnabled,
@@ -28221,6 +28490,8 @@ init_coordinator_prompt();
28221
28490
  init_apply_into_main();
28222
28491
  init_clone_repo();
28223
28492
  init_orphan_cleanup();
28493
+ init_history_retention();
28494
+ init_history_cleanup();
28224
28495
 
28225
28496
  // src/mcp/server.ts
28226
28497
  var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
@@ -33772,6 +34043,12 @@ init_outbound_watch();
33772
34043
  GITHUB_PR_BODY_SAFE_CHARS,
33773
34044
  GLOBAL_WORKSPACE_ID,
33774
34045
  HARNESS_ENV_KEYS,
34046
+ HISTORY_DISCARDED_TEXT,
34047
+ HISTORY_MAX_COUNT_DEFAULT,
34048
+ HISTORY_MAX_COUNT_MAX,
34049
+ HISTORY_MAX_COUNT_MIN,
34050
+ HISTORY_MAX_DAYS_DEFAULT,
34051
+ HISTORY_MAX_DAYS_MAX,
33775
34052
  HOME_BOARD_CACHE_TTL_MS,
33776
34053
  IMPLIED_TICKET_RESOLVE_PROMPT,
33777
34054
  ISSUE_SOURCE_LABELS,
@@ -33879,6 +34156,7 @@ init_outbound_watch();
33879
34156
  attachmentsFromWorktreePaths,
33880
34157
  attachmentsGitignoreBody,
33881
34158
  autoArchiveOnMergeEnabled,
34159
+ autoCleanupHistoryEnabled,
33882
34160
  autoCleanupOrphansEnabled,
33883
34161
  autoRenameBranchEnabled,
33884
34162
  autoRunAfterSetupEnabled,
@@ -33916,11 +34194,14 @@ init_outbound_watch();
33916
34194
  childEnvWithAppSettings,
33917
34195
  claimDesktopHost,
33918
34196
  clampGithubPrBody,
34197
+ clampHistoryMaxCount,
34198
+ clampHistoryMaxDays,
33919
34199
  classifyWorktreeColumn,
33920
34200
  claudeAdapter,
33921
34201
  claudeChromeEnabled,
33922
34202
  claudeUsageOverLimitWindows,
33923
34203
  claudeUserSettingsPath,
34204
+ cleanupArchivedHistory,
33924
34205
  cleanupOrphanWorktrees,
33925
34206
  clearBoardPins,
33926
34207
  clearHomeBoardCache,
@@ -34152,6 +34433,8 @@ init_outbound_watch();
34152
34433
  hasRepoHook,
34153
34434
  hasWorkspaceHook,
34154
34435
  healOrchestrationSoccerTitles,
34436
+ historyMaxCount,
34437
+ historyMaxDays,
34155
34438
  hottestClaudeWindow,
34156
34439
  httpFetch,
34157
34440
  importConductorWorkspace,
@@ -34184,6 +34467,7 @@ init_outbound_watch();
34184
34467
  isGhRateLimitError,
34185
34468
  isGlobalRepoPath,
34186
34469
  isGlobalThread,
34470
+ isHistoryRetentionStub,
34187
34471
  isHomeBoardThread,
34188
34472
  isImageFilePath,
34189
34473
  isInPrStack,
@@ -34342,6 +34626,8 @@ init_outbound_watch();
34342
34626
  persistPendingFileAttachments,
34343
34627
  persistVaultKeyInKeychain,
34344
34628
  planFileAbs,
34629
+ planHistoryAgePurge,
34630
+ planHistoryRetention,
34345
34631
  planQuestionsSignature,
34346
34632
  pollSlackOutboundWatches,
34347
34633
  posixShellSingleQuote,
@@ -34457,6 +34743,7 @@ init_outbound_watch();
34457
34743
  shouldRefreshReviewRequestTemplate,
34458
34744
  shouldRemoveWorktreeOnTeardown,
34459
34745
  shouldResetSessionForOccupancy,
34746
+ shouldRunHistoryCleanup,
34460
34747
  shouldRunWorktreeCleanup,
34461
34748
  shouldStampSetupLastError,
34462
34749
  showCostEnabled,