@sideboard-ai/core 0.1.116 → 0.1.120

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 (42) hide show
  1. package/dist/agents/cursor-runner.cjs +74 -59
  2. package/dist/agents/cursor-runner.js +10 -9
  3. package/dist/{agents-7NIX44RB.js → agents-HOIXQEP5.js} +6 -6
  4. package/dist/{agents-DU7DHY7A.js → agents-XTABRYO5.js} +5 -5
  5. package/dist/{chunk-4HOFVKPC.js → chunk-4LRPW6QM.js} +43 -19
  6. package/dist/{chunk-XOYQ7LNQ.js → chunk-4NAW5BAQ.js} +3 -3
  7. package/dist/{chunk-4OJMZ6P2.js → chunk-4WV7C7WP.js} +3 -3
  8. package/dist/{chunk-DWP25N32.js → chunk-AFM6442E.js} +44 -20
  9. package/dist/{chunk-ZRCX43LS.js → chunk-BKVDZV7X.js} +2 -2
  10. package/dist/{chunk-A4VZXJEJ.js → chunk-HPAWHIZ3.js} +4 -1
  11. package/dist/{chunk-GBY7OOMB.js → chunk-NZBDVBCP.js} +1 -1
  12. package/dist/{chunk-5KSLD4MU.js → chunk-QI7VC4EG.js} +92 -62
  13. package/dist/{chunk-KYOTBZ6S.js → chunk-RG737OWT.js} +4 -1
  14. package/dist/{chunk-OFF5AFCR.js → chunk-TDNM7QZJ.js} +92 -62
  15. package/dist/{chunk-K3TIQXOH.js → chunk-U3IVCVLH.js} +2 -2
  16. package/dist/{chunk-FZCIQYNQ.js → chunk-VGPLXQIH.js} +1 -1
  17. package/dist/chunk-VHX673DI.js +32 -0
  18. package/dist/{chunk-ZMROW673.js → chunk-WCU3FHEI.js} +1 -1
  19. package/dist/{chunk-7WC5UWEB.js → chunk-X3NIPGQT.js} +1 -1
  20. package/dist/{chunk-ZYEFCSZJ.js → chunk-XTZQL7OU.js} +1 -1
  21. package/dist/{coordinator-prompt-4KCALEKD.js → coordinator-prompt-QMV6YEP5.js} +3 -3
  22. package/dist/{coordinator-prompt-FML4I5AR.js → coordinator-prompt-XCBHAOGE.js} +3 -3
  23. package/dist/cursor-recover-NOQYOFRF.js +76 -0
  24. package/dist/{cursor-recover-JBTIDARH.js → cursor-recover-QSLWEZNA.js} +12 -7
  25. package/dist/{global-workspace-CSWABOG5.js → global-workspace-SBKXKQFS.js} +4 -4
  26. package/dist/{global-workspace-H4YNASM6.js → global-workspace-Z37MNYU6.js} +4 -4
  27. package/dist/index.cjs +388 -285
  28. package/dist/index.d.cts +13 -2
  29. package/dist/index.d.ts +13 -2
  30. package/dist/index.js +10 -8
  31. package/dist/mcp/run-stdio.cjs +383 -282
  32. package/dist/mcp/run-stdio.js +7 -7
  33. package/dist/{orchestrator-NXPANCZA.js → orchestrator-3LJIG6XG.js} +7 -7
  34. package/dist/{orchestrator-ZY4RUJKT.js → orchestrator-NWNKWZLB.js} +8 -8
  35. package/dist/{thread-store-OEALWU7Y.js → thread-store-JR235AWK.js} +3 -1
  36. package/dist/{thread-store-LPTBVW5C.js → thread-store-PMH3BMB6.js} +3 -1
  37. package/dist/{workspaces-HJ3EVATC.js → workspaces-C3TJJFY3.js} +5 -5
  38. package/dist/{workspaces-QG6PGFQR.js → workspaces-M4OICPWF.js} +5 -5
  39. package/dist/{worktree-IW3BX26B.js → worktree-7AEKZSEX.js} +2 -2
  40. package/dist/{worktree-OTFQO2W7.js → worktree-MRSTQ32S.js} +2 -2
  41. package/package.json +1 -1
  42. package/dist/cursor-recover-ZUJG6XRQ.js +0 -42
@@ -670,6 +670,7 @@ __export(thread_store_exports, {
670
670
  createEmptyThread: () => createEmptyThread,
671
671
  deleteThreadRecord: () => deleteThreadRecord,
672
672
  findThreadByRef: () => findThreadByRef,
673
+ isThreadRecordFile: () => isThreadRecordFile,
673
674
  listThreads: () => listThreads,
674
675
  normalizeThread: () => normalizeThread,
675
676
  readThread: () => readThread,
@@ -780,7 +781,8 @@ function writeThread(thread) {
780
781
  function idPath(id) {
781
782
  return id;
782
783
  }
783
- function isThreadRecordFile(name) {
784
+ function isThreadRecordFile(nameOrPath) {
785
+ const name = (0, import_node_path7.basename)(nameOrPath);
784
786
  return name.endsWith(".json") && !name.endsWith(".live.json");
785
787
  }
786
788
  function listThreads(opts) {
@@ -831,12 +833,13 @@ function findThreadByRef(ref) {
831
833
  (t) => t.id === ref || t.id.startsWith(ref) || t.branchName === ref || t.title === ref
832
834
  ) ?? null;
833
835
  }
834
- var import_node_crypto2, import_node_fs7, import_proper_lockfile;
836
+ var import_node_crypto2, import_node_fs7, import_node_path7, import_proper_lockfile;
835
837
  var init_thread_store = __esm({
836
838
  "src/store/thread-store.ts"() {
837
839
  "use strict";
838
840
  import_node_crypto2 = require("crypto");
839
841
  import_node_fs7 = require("fs");
842
+ import_node_path7 = require("path");
840
843
  import_proper_lockfile = __toESM(require("proper-lockfile"), 1);
841
844
  init_thinking_effort();
842
845
  init_paths();
@@ -887,7 +890,7 @@ var init_api = __esm({
887
890
 
888
891
  // src/slack/reply-target.ts
889
892
  function storePath() {
890
- return (0, import_node_path7.join)(appDataDir(), "slack-reply-to.json");
893
+ return (0, import_node_path8.join)(appDataDir(), "slack-reply-to.json");
891
894
  }
892
895
  function readStore() {
893
896
  const path = storePath();
@@ -902,12 +905,12 @@ function readStore() {
902
905
  function getSlackReplyTarget(threadId) {
903
906
  return readStore()[threadId] ?? null;
904
907
  }
905
- var import_node_fs8, import_node_path7;
908
+ var import_node_fs8, import_node_path8;
906
909
  var init_reply_target = __esm({
907
910
  "src/slack/reply-target.ts"() {
908
911
  "use strict";
909
912
  import_node_fs8 = require("fs");
910
- import_node_path7 = require("path");
913
+ import_node_path8 = require("path");
911
914
  init_paths();
912
915
  init_private_file();
913
916
  init_secure_file();
@@ -916,7 +919,7 @@ var init_reply_target = __esm({
916
919
 
917
920
  // src/slack/workspaces.ts
918
921
  function storePath2() {
919
- return (0, import_node_path8.join)(appDataDir(), "slack-workspaces.json");
922
+ return (0, import_node_path9.join)(appDataDir(), "slack-workspaces.json");
920
923
  }
921
924
  function readStore2() {
922
925
  try {
@@ -977,11 +980,11 @@ function requireSlackWorkspace(teamId) {
977
980
  }
978
981
  return ws;
979
982
  }
980
- var import_node_path8;
983
+ var import_node_path9;
981
984
  var init_workspaces = __esm({
982
985
  "src/slack/workspaces.ts"() {
983
986
  "use strict";
984
- import_node_path8 = require("path");
987
+ import_node_path9 = require("path");
985
988
  init_paths();
986
989
  init_secure_file();
987
990
  init_api();
@@ -990,7 +993,7 @@ var init_workspaces = __esm({
990
993
 
991
994
  // src/slack/outbound-watch.ts
992
995
  function storePath3() {
993
- return (0, import_node_path9.join)(appDataDir(), "slack-outbound-watch.json");
996
+ return (0, import_node_path10.join)(appDataDir(), "slack-outbound-watch.json");
994
997
  }
995
998
  function watchId(teamId, channelId, ts) {
996
999
  return `${teamId}:${channelId}:${ts}`;
@@ -1352,12 +1355,12 @@ async function refreshSlackReplyBadges(opts) {
1352
1355
  if (changed) writeStore(watches);
1353
1356
  return listSlackReplyBadges();
1354
1357
  }
1355
- var import_node_fs9, import_node_path9, MAX_WATCHES, MAX_REPLIES_PER_WATCH, WATCH_TTL_MS, POLL_INTERVAL_MS, lastPollMs, nameCache;
1358
+ var import_node_fs9, import_node_path10, MAX_WATCHES, MAX_REPLIES_PER_WATCH, WATCH_TTL_MS, POLL_INTERVAL_MS, lastPollMs, nameCache;
1356
1359
  var init_outbound_watch = __esm({
1357
1360
  "src/slack/outbound-watch.ts"() {
1358
1361
  "use strict";
1359
1362
  import_node_fs9 = require("fs");
1360
- import_node_path9 = require("path");
1363
+ import_node_path10 = require("path");
1361
1364
  init_paths();
1362
1365
  init_private_file();
1363
1366
  init_secure_file();
@@ -1492,7 +1495,7 @@ function summarizeTurnStderr(tail, maxChars = 500) {
1492
1495
  function looksLikeInvalidAgentSession(text4) {
1493
1496
  const lower = text4.trim().toLowerCase();
1494
1497
  if (!lower) return false;
1495
- return /session not found/.test(lower) || /no conversation found/.test(lower) || /conversation .+ not found/.test(lower) || /thread .+ not found/.test(lower) || /unknown session/.test(lower) || /invalid session/.test(lower) || /session .+ (missing|expired|deleted|gone)/.test(lower) || /cannot resume/.test(lower) || /failed to (load|resume|open) session/.test(lower) || /corrupt local agent checkpoint/.test(lower) || /missing root blob/.test(lower) || /\bagent\b.{0,120}\bnot found\b/.test(lower);
1498
+ return /session not found/.test(lower) || /no conversation found/.test(lower) || /conversation .+ not found/.test(lower) || /thread .+ not found/.test(lower) || /unknown session/.test(lower) || /invalid session/.test(lower) || /session .+ (missing|expired|deleted|gone)/.test(lower) || /cannot resume/.test(lower) || /failed to (load|resume|open) session/.test(lower) || /corrupt local agent checkpoint/.test(lower) || /missing root blob/.test(lower) || /\bagent\b.{0,120}\bnot found\b/.test(lower) || /\brun\b.{0,80}\bnot found for agent\b/.test(lower);
1496
1499
  }
1497
1500
  function looksLikeRetryableRunnerCrash(text4) {
1498
1501
  if (looksLikeAgentFailureMessage(text4)) return false;
@@ -1609,15 +1612,15 @@ var init_error_detail = __esm({
1609
1612
  function prependPathDir(env, dir) {
1610
1613
  if (!dir || !(0, import_node_fs10.existsSync)(dir)) return;
1611
1614
  const current = env.PATH ?? "";
1612
- const parts = current.split(import_node_path10.delimiter).filter(Boolean);
1615
+ const parts = current.split(import_node_path11.delimiter).filter(Boolean);
1613
1616
  if (parts.includes(dir)) {
1614
1617
  env.PATH = current;
1615
1618
  return;
1616
1619
  }
1617
- env.PATH = [dir, ...parts].join(import_node_path10.delimiter);
1620
+ env.PATH = [dir, ...parts].join(import_node_path11.delimiter);
1618
1621
  }
1619
1622
  function conductorBundledBinDir(home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os3.homedir)()) {
1620
- return (0, import_node_path10.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
1623
+ return (0, import_node_path11.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
1621
1624
  }
1622
1625
  function isConductorBundledCli(filePath) {
1623
1626
  const p = (filePath ?? "").replace(/\\/g, "/");
@@ -1626,10 +1629,10 @@ function isConductorBundledCli(filePath) {
1626
1629
  function ensureAgentPath(env = process.env) {
1627
1630
  const home = env.HOME || env.USERPROFILE || (0, import_node_os3.homedir)();
1628
1631
  const current = env.PATH ?? "";
1629
- const parts = current.split(import_node_path10.delimiter).filter(Boolean);
1632
+ const parts = current.split(import_node_path11.delimiter).filter(Boolean);
1630
1633
  const seen = new Set(parts);
1631
1634
  const extras = [
1632
- ...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path10.join)(home, rel)),
1635
+ ...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path11.join)(home, rel)),
1633
1636
  "/opt/homebrew/bin",
1634
1637
  "/usr/local/bin",
1635
1638
  // Keep after Homebrew/npm so a user-installed CLI still wins.
@@ -1640,7 +1643,7 @@ function ensureAgentPath(env = process.env) {
1640
1643
  parts.unshift(dir);
1641
1644
  seen.add(dir);
1642
1645
  }
1643
- const next = parts.join(import_node_path10.delimiter);
1646
+ const next = parts.join(import_node_path11.delimiter);
1644
1647
  env.PATH = next;
1645
1648
  return next;
1646
1649
  }
@@ -1654,7 +1657,7 @@ function enrichPathWithNpmGlobalBin(env = process.env) {
1654
1657
  stdio: ["ignore", "pipe", "ignore"]
1655
1658
  }).trim().split(/\r?\n/).find(Boolean);
1656
1659
  if (prefix) {
1657
- const binDir = process.platform === "win32" ? prefix : (0, import_node_path10.join)(prefix, "bin");
1660
+ const binDir = process.platform === "win32" ? prefix : (0, import_node_path11.join)(prefix, "bin");
1658
1661
  prependPathDir(env, binDir);
1659
1662
  }
1660
1663
  } catch {
@@ -1682,14 +1685,14 @@ function withExportedPath(command, pathValue) {
1682
1685
  if (/^(export\s+PATH=|PATH=)/.test(trimmed)) return trimmed;
1683
1686
  return `export PATH=${posixShellSingleQuote(pathValue)} && ${trimmed}`;
1684
1687
  }
1685
- var import_node_fs10, import_node_child_process2, import_node_os3, import_node_path10, EXTRA_BIN_DIRS;
1688
+ var import_node_fs10, import_node_child_process2, import_node_os3, import_node_path11, EXTRA_BIN_DIRS;
1686
1689
  var init_path = __esm({
1687
1690
  "src/agents/path.ts"() {
1688
1691
  "use strict";
1689
1692
  import_node_fs10 = require("fs");
1690
1693
  import_node_child_process2 = require("child_process");
1691
1694
  import_node_os3 = require("os");
1692
- import_node_path10 = require("path");
1695
+ import_node_path11 = require("path");
1693
1696
  EXTRA_BIN_DIRS = [
1694
1697
  ".local/bin",
1695
1698
  ".cargo/bin",
@@ -1711,7 +1714,7 @@ function isIndexLockError(text4) {
1711
1714
  return /Unable to create ['"][^'"]*index\.lock['"]: File exists/i.test(text4);
1712
1715
  }
1713
1716
  function clearStaleIndexLock(gitDir, maxAgeMs = STALE_INDEX_LOCK_MS, now = Date.now()) {
1714
- const lockPath = (0, import_node_path11.join)(gitDir, "index.lock");
1717
+ const lockPath = (0, import_node_path12.join)(gitDir, "index.lock");
1715
1718
  try {
1716
1719
  if (!(0, import_node_fs11.existsSync)(lockPath)) return null;
1717
1720
  if (now - (0, import_node_fs11.statSync)(lockPath).mtimeMs < maxAgeMs) return null;
@@ -1730,12 +1733,12 @@ function clearStaleIndexLocks(gitDirs, maxAgeMs = STALE_INDEX_LOCK_MS) {
1730
1733
  }
1731
1734
  return removed;
1732
1735
  }
1733
- var import_node_fs11, import_node_path11, STALE_INDEX_LOCK_MS;
1736
+ var import_node_fs11, import_node_path12, STALE_INDEX_LOCK_MS;
1734
1737
  var init_stale_lock = __esm({
1735
1738
  "src/git/stale-lock.ts"() {
1736
1739
  "use strict";
1737
1740
  import_node_fs11 = require("fs");
1738
- import_node_path11 = require("path");
1741
+ import_node_path12 = require("path");
1739
1742
  STALE_INDEX_LOCK_MS = 2e4;
1740
1743
  }
1741
1744
  });
@@ -2753,7 +2756,7 @@ var init_gh_errors = __esm({
2753
2756
 
2754
2757
  // src/store/secret-vault.ts
2755
2758
  function secretVaultPath() {
2756
- return (0, import_node_path12.join)(appDataDir(), "secrets.json");
2759
+ return (0, import_node_path13.join)(appDataDir(), "secrets.json");
2757
2760
  }
2758
2761
  function loadSecretVault() {
2759
2762
  const parsed = readSecureJson(secretVaultPath());
@@ -2797,11 +2800,11 @@ function normalizeVault(raw) {
2797
2800
  }
2798
2801
  return out;
2799
2802
  }
2800
- var import_node_path12;
2803
+ var import_node_path13;
2801
2804
  var init_secret_vault = __esm({
2802
2805
  "src/store/secret-vault.ts"() {
2803
2806
  "use strict";
2804
- import_node_path12 = require("path");
2807
+ import_node_path13 = require("path");
2805
2808
  init_paths();
2806
2809
  init_secure_file();
2807
2810
  }
@@ -2904,10 +2907,10 @@ function toPublicAppSettings(settings) {
2904
2907
  };
2905
2908
  }
2906
2909
  function appSettingsPath() {
2907
- return (0, import_node_path13.join)(appDataDir(), "settings.json");
2910
+ return (0, import_node_path14.join)(appDataDir(), "settings.json");
2908
2911
  }
2909
2912
  function claudeUserSettingsPath() {
2910
- return (0, import_node_path13.join)((0, import_node_os4.homedir)(), ".claude", "settings.json");
2913
+ return (0, import_node_path14.join)((0, import_node_os4.homedir)(), ".claude", "settings.json");
2911
2914
  }
2912
2915
  function normalizeClaude(raw) {
2913
2916
  if (!raw || typeof raw !== "object") return {};
@@ -3731,14 +3734,14 @@ function childEnvWithAppSettings(extra) {
3731
3734
  function harnessEnvKey(harness) {
3732
3735
  return HARNESS_ENV_KEYS[harness];
3733
3736
  }
3734
- var import_node_crypto3, import_node_fs12, import_node_os4, import_node_path13, HARNESS_ENV_KEYS, DEFAULT_AGENTS, GITHUB_GIT_AUTH_MODES, CLOUD_CONNECT_AGENTS, ISSUE_SOURCES, GIT_AUTH_MODES, EMPTY_SETTINGS, DEFAULT_CLI_BIN;
3737
+ var import_node_crypto3, import_node_fs12, import_node_os4, import_node_path14, HARNESS_ENV_KEYS, DEFAULT_AGENTS, GITHUB_GIT_AUTH_MODES, CLOUD_CONNECT_AGENTS, ISSUE_SOURCES, GIT_AUTH_MODES, EMPTY_SETTINGS, DEFAULT_CLI_BIN;
3735
3738
  var init_app_settings = __esm({
3736
3739
  "src/store/app-settings.ts"() {
3737
3740
  "use strict";
3738
3741
  import_node_crypto3 = require("crypto");
3739
3742
  import_node_fs12 = require("fs");
3740
3743
  import_node_os4 = require("os");
3741
- import_node_path13 = require("path");
3744
+ import_node_path14 = require("path");
3742
3745
  init_thinking_effort();
3743
3746
  init_nested_electron_env();
3744
3747
  init_paths();
@@ -3790,18 +3793,18 @@ var init_app_settings = __esm({
3790
3793
  function githubAgentAuthDir() {
3791
3794
  const override = process.env.SIDEBOARD_GIT_AUTH_DIR?.trim();
3792
3795
  if (override) return override;
3793
- return (0, import_node_path14.join)((0, import_node_os5.homedir)(), ".sideboard-git-auth");
3796
+ return (0, import_node_path15.join)((0, import_node_os5.homedir)(), ".sideboard-git-auth");
3794
3797
  }
3795
3798
  function githubCredentialStorePath() {
3796
- return (0, import_node_path14.join)(githubAgentAuthDir(), "git-credentials");
3799
+ return (0, import_node_path15.join)(githubAgentAuthDir(), "git-credentials");
3797
3800
  }
3798
3801
  function githubGhConfigDir() {
3799
- return (0, import_node_path14.join)(githubAgentAuthDir(), "gh");
3802
+ return (0, import_node_path15.join)(githubAgentAuthDir(), "gh");
3800
3803
  }
3801
3804
  function writePrivateFile2(file, body) {
3802
- (0, import_node_fs13.mkdirSync)((0, import_node_path14.dirname)(file), { recursive: true, mode: 448 });
3805
+ (0, import_node_fs13.mkdirSync)((0, import_node_path15.dirname)(file), { recursive: true, mode: 448 });
3803
3806
  try {
3804
- (0, import_node_fs13.chmodSync)((0, import_node_path14.dirname)(file), 448);
3807
+ (0, import_node_fs13.chmodSync)((0, import_node_path15.dirname)(file), 448);
3805
3808
  } catch {
3806
3809
  }
3807
3810
  (0, import_node_fs13.writeFileSync)(file, body, { encoding: "utf8", mode: 384 });
@@ -3839,11 +3842,11 @@ function materializeGithubAgentAuth(token, user) {
3839
3842
  writePrivateFile2(githubCredentialStorePath(), gitCredentialStoreContents(trimmed));
3840
3843
  const ghDir = githubGhConfigDir();
3841
3844
  (0, import_node_fs13.mkdirSync)(ghDir, { recursive: true, mode: 448 });
3842
- writePrivateFile2((0, import_node_path14.join)(ghDir, "hosts.yml"), ghHostsYml(trimmed, user));
3843
- writePrivateFile2((0, import_node_path14.join)(ghDir, "config.yml"), "git_protocol: https\nprompt: disabled\n");
3845
+ writePrivateFile2((0, import_node_path15.join)(ghDir, "hosts.yml"), ghHostsYml(trimmed, user));
3846
+ writePrivateFile2((0, import_node_path15.join)(ghDir, "config.yml"), "git_protocol: https\nprompt: disabled\n");
3844
3847
  }
3845
3848
  function githubAgentAuthReady() {
3846
- return (0, import_node_fs13.existsSync)(githubCredentialStorePath()) && (0, import_node_fs13.existsSync)((0, import_node_path14.join)(githubGhConfigDir(), "hosts.yml"));
3849
+ return (0, import_node_fs13.existsSync)(githubCredentialStorePath()) && (0, import_node_fs13.existsSync)((0, import_node_path15.join)(githubGhConfigDir(), "hosts.yml"));
3847
3850
  }
3848
3851
  function githubCredentialHelperGitConfig() {
3849
3852
  const file = githubCredentialStorePath();
@@ -3858,13 +3861,13 @@ function githubGhConfigEnv() {
3858
3861
  GH_PROMPT_DISABLED: "1"
3859
3862
  };
3860
3863
  }
3861
- var import_node_fs13, import_node_os5, import_node_path14;
3864
+ var import_node_fs13, import_node_os5, import_node_path15;
3862
3865
  var init_github_agent_auth = __esm({
3863
3866
  "src/git/github-agent-auth.ts"() {
3864
3867
  "use strict";
3865
3868
  import_node_fs13 = require("fs");
3866
3869
  import_node_os5 = require("os");
3867
- import_node_path14 = require("path");
3870
+ import_node_path15 = require("path");
3868
3871
  }
3869
3872
  });
3870
3873
 
@@ -3956,7 +3959,7 @@ async function warmGithubAgentAuth(opts) {
3956
3959
  }
3957
3960
  function normalizeWritableRoot(raw) {
3958
3961
  const trimmed = raw.trim().replace(/\/+$/, "");
3959
- return trimmed && (0, import_node_path15.isAbsolute)(trimmed) ? trimmed : null;
3962
+ return trimmed && (0, import_node_path16.isAbsolute)(trimmed) ? trimmed : null;
3960
3963
  }
3961
3964
  async function resolveCodexGitWritableRoots(cwd) {
3962
3965
  const roots = /* @__PURE__ */ new Set();
@@ -4033,11 +4036,11 @@ function formatGitAuthModeDirective(mode) {
4033
4036
  ].join("\n");
4034
4037
  }
4035
4038
  }
4036
- var import_node_path15, HTTPS_REWRITE, TOKEN_TTL_MS, tokenMemo, GITHUB_CHILD_TOKEN_KEYS;
4039
+ var import_node_path16, HTTPS_REWRITE, TOKEN_TTL_MS, tokenMemo, GITHUB_CHILD_TOKEN_KEYS;
4037
4040
  var init_git_auth_mode = __esm({
4038
4041
  "src/git/git-auth-mode.ts"() {
4039
4042
  "use strict";
4040
- import_node_path15 = require("path");
4043
+ import_node_path16 = require("path");
4041
4044
  init_app_settings();
4042
4045
  init_github_agent_auth();
4043
4046
  init_run();
@@ -5207,7 +5210,7 @@ function isLocalPrFetchBranch(ref) {
5207
5210
  }
5208
5211
  async function createThreadWorktree(opts) {
5209
5212
  let branchName = `thread/${opts.slug}`;
5210
- const worktreePath = (0, import_node_path16.join)(worktreesRoot(opts.repoPath), opts.slug);
5213
+ const worktreePath = (0, import_node_path17.join)(worktreesRoot(opts.repoPath), opts.slug);
5211
5214
  if ((0, import_node_fs14.existsSync)(worktreePath)) {
5212
5215
  throw new Error(`Worktree already exists at ${worktreePath}`);
5213
5216
  }
@@ -5275,7 +5278,7 @@ ${add.stdout}`;
5275
5278
  async function createExistingBranchWorktree(opts) {
5276
5279
  const branchName = opts.branchName.trim();
5277
5280
  if (!branchName) throw new Error("branch name required");
5278
- const worktreePath = (0, import_node_path16.join)(worktreesRoot(opts.repoPath), opts.slug);
5281
+ const worktreePath = (0, import_node_path17.join)(worktreesRoot(opts.repoPath), opts.slug);
5279
5282
  if ((0, import_node_fs14.existsSync)(worktreePath)) {
5280
5283
  throw new Error(`Worktree already exists at ${worktreePath}`);
5281
5284
  }
@@ -5567,7 +5570,7 @@ function sameRepoPath(a, b) {
5567
5570
  return normalizeWorktreePath(a) === normalizeWorktreePath(b);
5568
5571
  }
5569
5572
  function listLocalThreadBranchSlugs(repoPath) {
5570
- const refsDir = (0, import_node_path16.join)(repoPath, ".git", "refs", "heads", "thread");
5573
+ const refsDir = (0, import_node_path17.join)(repoPath, ".git", "refs", "heads", "thread");
5571
5574
  if (!(0, import_node_fs14.existsSync)(refsDir)) return [];
5572
5575
  try {
5573
5576
  return (0, import_node_fs14.readdirSync)(refsDir).filter((name) => !name.startsWith(".")).map((name) => normalizeTakenSlug(name));
@@ -5600,18 +5603,18 @@ function allocateTeamSlug(repoPath) {
5600
5603
  const taken = collectTakenTeamSlugs(repoPath);
5601
5604
  for (let attempt = 0; attempt < 32; attempt++) {
5602
5605
  const team = allocateTeamName(taken);
5603
- const path = (0, import_node_path16.join)(worktreesRoot(repoPath), team.slug);
5606
+ const path = (0, import_node_path17.join)(worktreesRoot(repoPath), team.slug);
5604
5607
  if (!(0, import_node_fs14.existsSync)(path)) return team;
5605
5608
  taken.add(team.slug);
5606
5609
  }
5607
5610
  throw new Error("No available soccer team worktree directories left");
5608
5611
  }
5609
- var import_node_fs14, import_node_path16;
5612
+ var import_node_fs14, import_node_path17;
5610
5613
  var init_worktree = __esm({
5611
5614
  "src/git/worktree.ts"() {
5612
5615
  "use strict";
5613
5616
  import_node_fs14 = require("fs");
5614
- import_node_path16 = require("path");
5617
+ import_node_path17 = require("path");
5615
5618
  init_paths();
5616
5619
  init_thread_store();
5617
5620
  init_teams();
@@ -5754,7 +5757,7 @@ function ensureGlobalCoordinatorCwd(opts) {
5754
5757
  let orchId = opts?.orchestratorThreadId?.trim() || "";
5755
5758
  if (!orchId) {
5756
5759
  try {
5757
- const existing = (0, import_node_fs15.readFileSync)((0, import_node_path17.join)(dir, "AGENTS.md"), "utf8");
5760
+ const existing = (0, import_node_fs15.readFileSync)((0, import_node_path18.join)(dir, "AGENTS.md"), "utf8");
5758
5761
  const m = existing.match(
5759
5762
  /YOUR orchestration thread id is `([0-9a-f-]{36})`/i
5760
5763
  );
@@ -5796,9 +5799,9 @@ function ensureGlobalCoordinatorCwd(opts) {
5796
5799
  "Always ask worktree agents to commit, push, and open draft PRs (`ask_git` / `send_to_thread`). Tell them to merge only when the user explicitly asked. The worktree agent runs git/gh; never merge from this orchestration cwd."
5797
5800
  ].join("\n");
5798
5801
  try {
5799
- (0, import_node_fs15.writeFileSync)((0, import_node_path17.join)(dir, "CLAUDE.md"), `${body}
5802
+ (0, import_node_fs15.writeFileSync)((0, import_node_path18.join)(dir, "CLAUDE.md"), `${body}
5800
5803
  `, "utf8");
5801
- (0, import_node_fs15.writeFileSync)((0, import_node_path17.join)(dir, "AGENTS.md"), `${body}
5804
+ (0, import_node_fs15.writeFileSync)((0, import_node_path18.join)(dir, "AGENTS.md"), `${body}
5802
5805
  `, "utf8");
5803
5806
  } catch {
5804
5807
  }
@@ -5830,12 +5833,12 @@ function coordinatorSystemPrompt(opts) {
5830
5833
  formatWorkspaceInventory(opts.workspaces)
5831
5834
  ].join("\n");
5832
5835
  }
5833
- var import_node_fs15, import_node_path17, COORDINATOR_TOOL_PLAYBOOK, SLACK_REPLY_FORMATTING;
5836
+ var import_node_fs15, import_node_path18, COORDINATOR_TOOL_PLAYBOOK, SLACK_REPLY_FORMATTING;
5834
5837
  var init_coordinator_prompt = __esm({
5835
5838
  "src/orchestrator/coordinator-prompt.ts"() {
5836
5839
  "use strict";
5837
5840
  import_node_fs15 = require("fs");
5838
- import_node_path17 = require("path");
5841
+ import_node_path18 = require("path");
5839
5842
  init_worktree();
5840
5843
  init_app_settings();
5841
5844
  init_paths();
@@ -6133,7 +6136,7 @@ var init_global_workspace = __esm({
6133
6136
 
6134
6137
  // src/brightsy/config.ts
6135
6138
  function brightsyConfigPath() {
6136
- return (0, import_node_path18.join)((0, import_node_os6.homedir)(), ".brightsy", "config.json");
6139
+ return (0, import_node_path19.join)((0, import_node_os6.homedir)(), ".brightsy", "config.json");
6137
6140
  }
6138
6141
  function loadBrightsyConfig() {
6139
6142
  const path = brightsyConfigPath();
@@ -6152,13 +6155,13 @@ function saveBrightsyConfig(cfg) {
6152
6155
  mode: 384
6153
6156
  });
6154
6157
  }
6155
- var import_node_fs16, import_node_os6, import_node_path18;
6158
+ var import_node_fs16, import_node_os6, import_node_path19;
6156
6159
  var init_config = __esm({
6157
6160
  "src/brightsy/config.ts"() {
6158
6161
  "use strict";
6159
6162
  import_node_fs16 = require("fs");
6160
6163
  import_node_os6 = require("os");
6161
- import_node_path18 = require("path");
6164
+ import_node_path19 = require("path");
6162
6165
  }
6163
6166
  });
6164
6167
 
@@ -6173,7 +6176,7 @@ var init_accounts = __esm({
6173
6176
 
6174
6177
  // src/brightsy/connected-teams.ts
6175
6178
  function storePath4() {
6176
- return (0, import_node_path19.join)(appDataDir(), "brightsy-teams.json");
6179
+ return (0, import_node_path20.join)(appDataDir(), "brightsy-teams.json");
6177
6180
  }
6178
6181
  function readStore4() {
6179
6182
  const path = storePath4();
@@ -6300,12 +6303,12 @@ function brightsyMcpServerName(slug) {
6300
6303
  const cleaned = slug.replace(/[^A-Za-z0-9_-]/g, "_").replace(/^_+|_+$/g, "");
6301
6304
  return `brightsy_${cleaned || "team"}`;
6302
6305
  }
6303
- var import_node_fs17, import_node_path19;
6306
+ var import_node_fs17, import_node_path20;
6304
6307
  var init_connected_teams = __esm({
6305
6308
  "src/brightsy/connected-teams.ts"() {
6306
6309
  "use strict";
6307
6310
  import_node_fs17 = require("fs");
6308
- import_node_path19 = require("path");
6311
+ import_node_path20 = require("path");
6309
6312
  init_paths();
6310
6313
  init_accounts();
6311
6314
  init_config();
@@ -6984,6 +6987,11 @@ function parseDiffStat(result) {
6984
6987
  }
6985
6988
  return {};
6986
6989
  }
6990
+ function withPartTimes(next, prev) {
6991
+ const now = Date.now();
6992
+ const startedAt = prev && typeof prev.startedAt === "number" ? prev.startedAt : now;
6993
+ return { ...next, startedAt, updatedAt: now };
6994
+ }
6987
6995
  function applyAgentEvent(parts, event) {
6988
6996
  if (event.type === "stdout") {
6989
6997
  const data = event.data;
@@ -6991,17 +6999,22 @@ function applyAgentEvent(parts, event) {
6991
6999
  const next = [...parts];
6992
7000
  const last = next[next.length - 1];
6993
7001
  if (last?.type === "text" && sameParentId(last.parentId, event.parentId)) {
6994
- next[next.length - 1] = {
6995
- type: "text",
6996
- text: last.text + data,
6997
- ...event.parentId ? { parentId: event.parentId } : {}
6998
- };
7002
+ next[next.length - 1] = withPartTimes(
7003
+ {
7004
+ type: "text",
7005
+ text: last.text + data,
7006
+ ...event.parentId ? { parentId: event.parentId } : {}
7007
+ },
7008
+ last
7009
+ );
6999
7010
  } else {
7000
- next.push({
7001
- type: "text",
7002
- text: data,
7003
- ...event.parentId ? { parentId: event.parentId } : {}
7004
- });
7011
+ next.push(
7012
+ withPartTimes({
7013
+ type: "text",
7014
+ text: data,
7015
+ ...event.parentId ? { parentId: event.parentId } : {}
7016
+ })
7017
+ );
7005
7018
  }
7006
7019
  return next;
7007
7020
  }
@@ -7013,34 +7026,44 @@ function applyAgentEvent(parts, event) {
7013
7026
  for (let i = next.length - 1; i >= 0; i--) {
7014
7027
  const prev = next[i];
7015
7028
  if (prev?.type === "thinking" && sameParentId(prev.parentId, event.parentId)) {
7016
- next[i] = {
7017
- type: "thinking",
7018
- text: data,
7019
- ...event.parentId ? { parentId: event.parentId } : {}
7020
- };
7029
+ next[i] = withPartTimes(
7030
+ {
7031
+ type: "thinking",
7032
+ text: data,
7033
+ ...event.parentId ? { parentId: event.parentId } : {}
7034
+ },
7035
+ prev
7036
+ );
7021
7037
  return next;
7022
7038
  }
7023
7039
  }
7024
- next.push({
7025
- type: "thinking",
7026
- text: data,
7027
- ...event.parentId ? { parentId: event.parentId } : {}
7028
- });
7040
+ next.push(
7041
+ withPartTimes({
7042
+ type: "thinking",
7043
+ text: data,
7044
+ ...event.parentId ? { parentId: event.parentId } : {}
7045
+ })
7046
+ );
7029
7047
  return next;
7030
7048
  }
7031
7049
  const last = next[next.length - 1];
7032
7050
  if (last?.type === "thinking" && sameParentId(last.parentId, event.parentId)) {
7033
- next[next.length - 1] = {
7034
- type: "thinking",
7035
- text: last.text + data,
7036
- ...event.parentId ? { parentId: event.parentId } : {}
7037
- };
7051
+ next[next.length - 1] = withPartTimes(
7052
+ {
7053
+ type: "thinking",
7054
+ text: last.text + data,
7055
+ ...event.parentId ? { parentId: event.parentId } : {}
7056
+ },
7057
+ last
7058
+ );
7038
7059
  } else {
7039
- next.push({
7040
- type: "thinking",
7041
- text: data,
7042
- ...event.parentId ? { parentId: event.parentId } : {}
7043
- });
7060
+ next.push(
7061
+ withPartTimes({
7062
+ type: "thinking",
7063
+ text: data,
7064
+ ...event.parentId ? { parentId: event.parentId } : {}
7065
+ })
7066
+ );
7044
7067
  }
7045
7068
  return next;
7046
7069
  }
@@ -7056,22 +7079,25 @@ function applyAgentEvent(parts, event) {
7056
7079
  ...input ?? {}
7057
7080
  };
7058
7081
  const mergedRecord = Object.keys(mergedInput).length > 0 ? mergedInput : void 0;
7059
- next[existing] = {
7060
- ...prev,
7061
- name: event.name || prev.name,
7062
- input: mergedRecord,
7063
- description: toolDescription(event.name || prev.name, mergedRecord),
7064
- detail: toolDetail(event.name || prev.name, mergedRecord) ?? prev.detail,
7065
- filePath: toolFilePath(mergedRecord) ?? prev.filePath,
7066
- additions: diff.additions ?? prev.additions,
7067
- deletions: diff.deletions ?? prev.deletions,
7068
- parentId: event.parentId ?? prev.parentId
7069
- };
7082
+ next[existing] = withPartTimes(
7083
+ {
7084
+ ...prev,
7085
+ name: event.name || prev.name,
7086
+ input: mergedRecord,
7087
+ description: toolDescription(event.name || prev.name, mergedRecord),
7088
+ detail: toolDetail(event.name || prev.name, mergedRecord) ?? prev.detail,
7089
+ filePath: toolFilePath(mergedRecord) ?? prev.filePath,
7090
+ additions: diff.additions ?? prev.additions,
7091
+ deletions: diff.deletions ?? prev.deletions,
7092
+ parentId: event.parentId ?? prev.parentId
7093
+ },
7094
+ prev
7095
+ );
7070
7096
  return next;
7071
7097
  }
7072
7098
  return [
7073
7099
  ...parts,
7074
- {
7100
+ withPartTimes({
7075
7101
  type: "tool",
7076
7102
  id: event.id,
7077
7103
  name: event.name,
@@ -7082,7 +7108,7 @@ function applyAgentEvent(parts, event) {
7082
7108
  filePath: toolFilePath(input),
7083
7109
  ...event.parentId ? { parentId: event.parentId } : {},
7084
7110
  ...diff
7085
- }
7111
+ })
7086
7112
  ];
7087
7113
  }
7088
7114
  if (event.type === "tool_result") {
@@ -7092,7 +7118,7 @@ function applyAgentEvent(parts, event) {
7092
7118
  if (existing < 0) {
7093
7119
  return [
7094
7120
  ...parts,
7095
- {
7121
+ withPartTimes({
7096
7122
  type: "tool",
7097
7123
  id: event.id,
7098
7124
  name: "tool",
@@ -7100,22 +7126,25 @@ function applyAgentEvent(parts, event) {
7100
7126
  status: event.isError ? "error" : "running",
7101
7127
  result: event.content,
7102
7128
  ...event.parentId ? { parentId: event.parentId } : {}
7103
- }
7129
+ })
7104
7130
  ];
7105
7131
  }
7106
7132
  return parts.map((p, i) => {
7107
7133
  if (i !== existing || p.type !== "tool") return p;
7108
7134
  if (p.status === "done" || p.status === "error") return p;
7109
- return {
7110
- ...p,
7111
- result: event.content ?? p.result
7112
- };
7135
+ return withPartTimes(
7136
+ {
7137
+ ...p,
7138
+ result: event.content ?? p.result
7139
+ },
7140
+ p
7141
+ );
7113
7142
  });
7114
7143
  }
7115
7144
  if (existing < 0) {
7116
7145
  return [
7117
7146
  ...parts,
7118
- {
7147
+ withPartTimes({
7119
7148
  type: "tool",
7120
7149
  id: event.id,
7121
7150
  name: "tool",
@@ -7125,18 +7154,21 @@ function applyAgentEvent(parts, event) {
7125
7154
  ...event.parentId ? { parentId: event.parentId } : {},
7126
7155
  ...fromResult.additions != null ? { additions: fromResult.additions } : {},
7127
7156
  ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
7128
- }
7157
+ })
7129
7158
  ];
7130
7159
  }
7131
7160
  return parts.map((p, i) => {
7132
7161
  if (i !== existing || p.type !== "tool") return p;
7133
- return {
7134
- ...p,
7135
- status: event.isError ? "error" : "done",
7136
- result: event.content,
7137
- ...fromResult.additions != null ? { additions: fromResult.additions } : {},
7138
- ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
7139
- };
7162
+ return withPartTimes(
7163
+ {
7164
+ ...p,
7165
+ status: event.isError ? "error" : "done",
7166
+ result: event.content,
7167
+ ...fromResult.additions != null ? { additions: fromResult.additions } : {},
7168
+ ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
7169
+ },
7170
+ p
7171
+ );
7140
7172
  });
7141
7173
  }
7142
7174
  return parts;
@@ -7197,43 +7229,43 @@ function electronResourcesPath() {
7197
7229
  function packagedCursorRuntimeDir() {
7198
7230
  const resources = electronResourcesPath();
7199
7231
  if (!resources) return null;
7200
- const dir = (0, import_node_path20.join)(resources, "cursor-runtime");
7201
- if (!(0, import_node_fs19.existsSync)((0, import_node_path20.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
7232
+ const dir = (0, import_node_path21.join)(resources, "cursor-runtime");
7233
+ if (!(0, import_node_fs19.existsSync)((0, import_node_path21.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
7202
7234
  return dir;
7203
7235
  }
7204
7236
  function packagedCursorRunnerPath() {
7205
7237
  const dir = packagedCursorRuntimeDir();
7206
- return dir ? (0, import_node_path20.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
7238
+ return dir ? (0, import_node_path21.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
7207
7239
  }
7208
7240
  function packagedMcpDir() {
7209
7241
  const resources = electronResourcesPath();
7210
7242
  if (!resources) return null;
7211
- const dir = (0, import_node_path20.join)(resources, "sideboard-mcp");
7212
- if (!(0, import_node_fs19.existsSync)((0, import_node_path20.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
7243
+ const dir = (0, import_node_path21.join)(resources, "sideboard-mcp");
7244
+ if (!(0, import_node_fs19.existsSync)((0, import_node_path21.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
7213
7245
  return dir;
7214
7246
  }
7215
7247
  function packagedMcpStdioPath() {
7216
7248
  const dir = packagedMcpDir();
7217
- return dir ? (0, import_node_path20.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
7249
+ return dir ? (0, import_node_path21.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
7218
7250
  }
7219
7251
  function packagedBundledNodePath() {
7220
7252
  const resources = electronResourcesPath();
7221
7253
  if (!resources) return null;
7222
- const bin = (0, import_node_path20.join)(resources, "node", "bin", "node");
7254
+ const bin = (0, import_node_path21.join)(resources, "node", "bin", "node");
7223
7255
  if (!(0, import_node_fs19.existsSync)(bin)) return null;
7224
7256
  return bin;
7225
7257
  }
7226
7258
  function packagedCursorRipgrepCandidate(platformPkg, binName) {
7227
7259
  const dir = packagedCursorRuntimeDir();
7228
7260
  if (!dir) return null;
7229
- return (0, import_node_path20.join)(dir, "node_modules", platformPkg, "bin", binName);
7261
+ return (0, import_node_path21.join)(dir, "node_modules", platformPkg, "bin", binName);
7230
7262
  }
7231
- var import_node_fs19, import_node_path20;
7263
+ var import_node_fs19, import_node_path21;
7232
7264
  var init_packaged_runtime = __esm({
7233
7265
  "src/agents/packaged-runtime.ts"() {
7234
7266
  "use strict";
7235
7267
  import_node_fs19 = require("fs");
7236
- import_node_path20 = require("path");
7268
+ import_node_path21 = require("path");
7237
7269
  }
7238
7270
  });
7239
7271
 
@@ -7316,28 +7348,28 @@ function versionDirNodeBins(root, toBin) {
7316
7348
  }
7317
7349
  function defaultNodeBinCandidates(home = (0, import_node_os7.homedir)()) {
7318
7350
  const kegs = ["/opt/homebrew", "/usr/local"].flatMap(
7319
- (prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path21.join)(prefix, "opt", `node@${major}`, "bin", "node"))
7351
+ (prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path22.join)(prefix, "opt", `node@${major}`, "bin", "node"))
7320
7352
  );
7321
7353
  return [
7322
7354
  ...kegs,
7323
7355
  "/opt/homebrew/bin/node",
7324
7356
  "/usr/local/bin/node",
7325
- (0, import_node_path21.join)(home, ".local/share/fnm/aliases/default/bin/node"),
7326
- (0, import_node_path21.join)(home, ".nvm/current/bin/node"),
7327
- (0, import_node_path21.join)(home, ".volta/bin/node"),
7328
- (0, import_node_path21.join)(home, ".asdf/shims/node"),
7329
- (0, import_node_path21.join)(home, ".local/share/mise/shims/node"),
7357
+ (0, import_node_path22.join)(home, ".local/share/fnm/aliases/default/bin/node"),
7358
+ (0, import_node_path22.join)(home, ".nvm/current/bin/node"),
7359
+ (0, import_node_path22.join)(home, ".volta/bin/node"),
7360
+ (0, import_node_path22.join)(home, ".asdf/shims/node"),
7361
+ (0, import_node_path22.join)(home, ".local/share/mise/shims/node"),
7330
7362
  ...versionDirNodeBins(
7331
- (0, import_node_path21.join)(home, ".nvm", "versions", "node"),
7332
- (name) => (0, import_node_path21.join)(home, ".nvm", "versions", "node", name, "bin", "node")
7363
+ (0, import_node_path22.join)(home, ".nvm", "versions", "node"),
7364
+ (name) => (0, import_node_path22.join)(home, ".nvm", "versions", "node", name, "bin", "node")
7333
7365
  ),
7334
7366
  ...versionDirNodeBins(
7335
- (0, import_node_path21.join)(home, ".local/share/fnm", "node-versions"),
7336
- (name) => (0, import_node_path21.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
7367
+ (0, import_node_path22.join)(home, ".local/share/fnm", "node-versions"),
7368
+ (name) => (0, import_node_path22.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
7337
7369
  ),
7338
7370
  ...versionDirNodeBins(
7339
- (0, import_node_path21.join)(home, ".volta", "tools", "image", "node"),
7340
- (name) => (0, import_node_path21.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
7371
+ (0, import_node_path22.join)(home, ".volta", "tools", "image", "node"),
7372
+ (name) => (0, import_node_path22.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
7341
7373
  )
7342
7374
  ];
7343
7375
  }
@@ -7429,13 +7461,13 @@ async function resolveNodeLaunch(scriptPath) {
7429
7461
  env: { ELECTRON_RUN_AS_NODE: "1" }
7430
7462
  };
7431
7463
  }
7432
- var import_node_fs20, import_node_os7, import_node_path21, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
7464
+ var import_node_fs20, import_node_os7, import_node_path22, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
7433
7465
  var init_node_launch = __esm({
7434
7466
  "src/agents/node-launch.ts"() {
7435
7467
  "use strict";
7436
7468
  import_node_fs20 = require("fs");
7437
7469
  import_node_os7 = require("os");
7438
- import_node_path21 = require("path");
7470
+ import_node_path22 = require("path");
7439
7471
  init_nested_electron_env();
7440
7472
  init_run();
7441
7473
  init_packaged_runtime();
@@ -7528,13 +7560,13 @@ function corePackageDir() {
7528
7560
  try {
7529
7561
  const url = import_meta.url;
7530
7562
  if (typeof url === "string" && url.length > 0) {
7531
- return (0, import_node_path22.dirname)((0, import_node_url.fileURLToPath)(url));
7563
+ return (0, import_node_path23.dirname)((0, import_node_url.fileURLToPath)(url));
7532
7564
  }
7533
7565
  } catch {
7534
7566
  }
7535
7567
  try {
7536
- const req = (0, import_node_module.createRequire)((0, import_node_path22.join)(process.cwd(), "package.json"));
7537
- return (0, import_node_path22.dirname)(req.resolve("@sideboard-ai/core"));
7568
+ const req = (0, import_node_module.createRequire)((0, import_node_path23.join)(process.cwd(), "package.json"));
7569
+ return (0, import_node_path23.dirname)(req.resolve("@sideboard-ai/core"));
7538
7570
  } catch {
7539
7571
  return process.cwd();
7540
7572
  }
@@ -7547,18 +7579,18 @@ function findSideboardMcpJsEntry() {
7547
7579
  let dir = corePackageDir();
7548
7580
  for (let i = 0; i < 10; i++) {
7549
7581
  const candidates = [
7550
- (0, import_node_path22.join)(dir, "mcp/run-stdio.js"),
7551
- (0, import_node_path22.join)(dir, "mcp/run-stdio.cjs"),
7552
- (0, import_node_path22.join)(dir, "dist/mcp/run-stdio.js"),
7553
- (0, import_node_path22.join)(dir, "dist/mcp/run-stdio.cjs"),
7554
- (0, import_node_path22.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
7555
- (0, import_node_path22.join)(dir, "packages/cli/dist/index.js"),
7556
- (0, import_node_path22.join)(dir, "cli/dist/index.js")
7582
+ (0, import_node_path23.join)(dir, "mcp/run-stdio.js"),
7583
+ (0, import_node_path23.join)(dir, "mcp/run-stdio.cjs"),
7584
+ (0, import_node_path23.join)(dir, "dist/mcp/run-stdio.js"),
7585
+ (0, import_node_path23.join)(dir, "dist/mcp/run-stdio.cjs"),
7586
+ (0, import_node_path23.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
7587
+ (0, import_node_path23.join)(dir, "packages/cli/dist/index.js"),
7588
+ (0, import_node_path23.join)(dir, "cli/dist/index.js")
7557
7589
  ];
7558
7590
  for (const p of candidates) {
7559
7591
  if ((0, import_node_fs21.existsSync)(p) && !isAsarPath(p)) return p;
7560
7592
  }
7561
- const parent = (0, import_node_path22.dirname)(dir);
7593
+ const parent = (0, import_node_path23.dirname)(dir);
7562
7594
  if (parent === dir) break;
7563
7595
  dir = parent;
7564
7596
  }
@@ -7700,19 +7732,19 @@ function writeMcpServersConfig(servers) {
7700
7732
  ...env ? { env } : {}
7701
7733
  };
7702
7734
  }
7703
- const dir = (0, import_node_fs21.mkdtempSync)((0, import_node_path22.join)((0, import_node_os8.tmpdir)(), "sideboard-mcp-"));
7704
- const cfgPath = (0, import_node_path22.join)(dir, "mcp.json");
7735
+ const dir = (0, import_node_fs21.mkdtempSync)((0, import_node_path23.join)((0, import_node_os8.tmpdir)(), "sideboard-mcp-"));
7736
+ const cfgPath = (0, import_node_path23.join)(dir, "mcp.json");
7705
7737
  (0, import_node_fs21.writeFileSync)(cfgPath, JSON.stringify({ mcpServers }, null, 2));
7706
7738
  return cfgPath;
7707
7739
  }
7708
- var import_node_fs21, import_node_module, import_node_os8, import_node_path22, import_node_url, import_meta, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS, brightsyMcpCommandCache, BRIGHTSY_WORD;
7740
+ var import_node_fs21, import_node_module, import_node_os8, import_node_path23, import_node_url, import_meta, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS, brightsyMcpCommandCache, BRIGHTSY_WORD;
7709
7741
  var init_injected_mcp = __esm({
7710
7742
  "src/agents/injected-mcp.ts"() {
7711
7743
  "use strict";
7712
7744
  import_node_fs21 = require("fs");
7713
7745
  import_node_module = require("module");
7714
7746
  import_node_os8 = require("os");
7715
- import_node_path22 = require("path");
7747
+ import_node_path23 = require("path");
7716
7748
  import_node_url = require("url");
7717
7749
  init_run();
7718
7750
  init_config();
@@ -8314,8 +8346,8 @@ function usageFromCodex(usage) {
8314
8346
  }
8315
8347
  function codexConfigHasNetworkAccess() {
8316
8348
  const candidates = [
8317
- (0, import_node_path23.join)((0, import_node_os9.homedir)(), ".codex", "config.toml"),
8318
- (0, import_node_path23.join)((0, import_node_os9.homedir)(), ".config", "codex", "config.toml")
8349
+ (0, import_node_path24.join)((0, import_node_os9.homedir)(), ".codex", "config.toml"),
8350
+ (0, import_node_path24.join)((0, import_node_os9.homedir)(), ".config", "codex", "config.toml")
8319
8351
  ];
8320
8352
  for (const path of candidates) {
8321
8353
  if (!(0, import_node_fs23.existsSync)(path)) continue;
@@ -8351,7 +8383,7 @@ function asRecord2(value) {
8351
8383
  return void 0;
8352
8384
  }
8353
8385
  function codexLooksAuthenticated() {
8354
- const authPath = (0, import_node_path23.join)((0, import_node_os9.homedir)(), ".codex", "auth.json");
8386
+ const authPath = (0, import_node_path24.join)((0, import_node_os9.homedir)(), ".codex", "auth.json");
8355
8387
  if (!(0, import_node_fs23.existsSync)(authPath)) return false;
8356
8388
  try {
8357
8389
  return (0, import_node_fs23.statSync)(authPath).size > 2;
@@ -8359,13 +8391,13 @@ function codexLooksAuthenticated() {
8359
8391
  return false;
8360
8392
  }
8361
8393
  }
8362
- var import_node_fs23, import_node_os9, import_node_path23, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
8394
+ var import_node_fs23, import_node_os9, import_node_path24, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
8363
8395
  var init_codex = __esm({
8364
8396
  "src/agents/codex.ts"() {
8365
8397
  "use strict";
8366
8398
  import_node_fs23 = require("fs");
8367
8399
  import_node_os9 = require("os");
8368
- import_node_path23 = require("path");
8400
+ import_node_path24 = require("path");
8369
8401
  init_run();
8370
8402
  init_app_settings();
8371
8403
  init_global_workspace();
@@ -8845,7 +8877,7 @@ function platformRipgrepPackage() {
8845
8877
  }
8846
8878
  function usableRipgrepPath(candidate) {
8847
8879
  const raw = candidate?.trim();
8848
- if (!raw || !(0, import_node_path24.isAbsolute)(raw)) return null;
8880
+ if (!raw || !(0, import_node_path25.isAbsolute)(raw)) return null;
8849
8881
  const readable = nodeReadableScriptPath(raw);
8850
8882
  if (!(0, import_node_fs24.existsSync)(readable) || isAsarPath(readable)) return null;
8851
8883
  return readable;
@@ -8854,12 +8886,12 @@ function walkForBundledRipgrep(startFile) {
8854
8886
  if (!startFile) return null;
8855
8887
  const pkg = platformRipgrepPackage();
8856
8888
  const name = rgBinaryName();
8857
- let dir = (0, import_node_path24.dirname)((0, import_node_path24.resolve)(startFile));
8858
- const root = (0, import_node_path24.parse)(dir).root;
8889
+ let dir = (0, import_node_path25.dirname)((0, import_node_path25.resolve)(startFile));
8890
+ const root = (0, import_node_path25.parse)(dir).root;
8859
8891
  while (dir !== root) {
8860
- const hit = usableRipgrepPath((0, import_node_path24.join)(dir, "node_modules", pkg, "bin", name));
8892
+ const hit = usableRipgrepPath((0, import_node_path25.join)(dir, "node_modules", pkg, "bin", name));
8861
8893
  if (hit) return hit;
8862
- const next = (0, import_node_path24.dirname)(dir);
8894
+ const next = (0, import_node_path25.dirname)(dir);
8863
8895
  if (next === dir) break;
8864
8896
  dir = next;
8865
8897
  }
@@ -8869,7 +8901,7 @@ function requireResolveBundledRipgrep(fromFile) {
8869
8901
  try {
8870
8902
  const req = (0, import_node_module2.createRequire)(fromFile);
8871
8903
  const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
8872
- return usableRipgrepPath((0, import_node_path24.join)((0, import_node_path24.dirname)(pkgJson), "bin", rgBinaryName()));
8904
+ return usableRipgrepPath((0, import_node_path25.join)((0, import_node_path25.dirname)(pkgJson), "bin", rgBinaryName()));
8873
8905
  } catch {
8874
8906
  return null;
8875
8907
  }
@@ -8891,13 +8923,13 @@ function cursorRipgrepEnv(opts) {
8891
8923
  const path = resolveCursorRipgrepPath(opts);
8892
8924
  return path ? { [RIPGREP_ENV]: path } : {};
8893
8925
  }
8894
- var import_node_fs24, import_node_module2, import_node_path24, RIPGREP_ENV;
8926
+ var import_node_fs24, import_node_module2, import_node_path25, RIPGREP_ENV;
8895
8927
  var init_cursor_ripgrep = __esm({
8896
8928
  "src/agents/cursor-ripgrep.ts"() {
8897
8929
  "use strict";
8898
8930
  import_node_fs24 = require("fs");
8899
8931
  import_node_module2 = require("module");
8900
- import_node_path24 = require("path");
8932
+ import_node_path25 = require("path");
8901
8933
  init_node_launch();
8902
8934
  init_packaged_runtime();
8903
8935
  RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
@@ -8943,11 +8975,11 @@ function entryDir() {
8943
8975
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
8944
8976
  if (cjsDir) return cjsDir;
8945
8977
  try {
8946
- return (0, import_node_path25.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
8978
+ return (0, import_node_path26.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
8947
8979
  } catch {
8948
8980
  try {
8949
8981
  const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
8950
- return (0, import_node_path25.dirname)(req.resolve("@sideboard-ai/core"));
8982
+ return (0, import_node_path26.dirname)(req.resolve("@sideboard-ai/core"));
8951
8983
  } catch {
8952
8984
  return process.cwd();
8953
8985
  }
@@ -8958,27 +8990,27 @@ function cursorRunnerPath() {
8958
8990
  if (packaged) return packaged;
8959
8991
  const root = entryDir();
8960
8992
  const candidates = [
8961
- (0, import_node_path25.join)(root, "agents", "cursor-runner.js"),
8962
- (0, import_node_path25.join)(root, "agents", "cursor-runner.cjs"),
8993
+ (0, import_node_path26.join)(root, "agents", "cursor-runner.js"),
8994
+ (0, import_node_path26.join)(root, "agents", "cursor-runner.cjs"),
8963
8995
  // If somehow resolved from package root instead of dist/
8964
- (0, import_node_path25.join)(root, "dist", "agents", "cursor-runner.js"),
8965
- (0, import_node_path25.join)(root, "dist", "agents", "cursor-runner.cjs"),
8996
+ (0, import_node_path26.join)(root, "dist", "agents", "cursor-runner.js"),
8997
+ (0, import_node_path26.join)(root, "dist", "agents", "cursor-runner.cjs"),
8966
8998
  // Source tree (dev): packages/core/src/agents/cursor-runner.ts
8967
- (0, import_node_path25.join)(root, "cursor-runner.ts"),
8968
- (0, import_node_path25.join)(root, "src", "agents", "cursor-runner.ts")
8999
+ (0, import_node_path26.join)(root, "cursor-runner.ts"),
9000
+ (0, import_node_path26.join)(root, "src", "agents", "cursor-runner.ts")
8969
9001
  ];
8970
9002
  for (const candidate of candidates) {
8971
9003
  if ((0, import_node_fs25.existsSync)(candidate)) return candidate;
8972
9004
  }
8973
9005
  return candidates[0];
8974
9006
  }
8975
- var import_node_fs25, import_node_module3, import_node_path25, import_node_url2, import_sdk, import_meta2, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
9007
+ var import_node_fs25, import_node_module3, import_node_path26, import_node_url2, import_sdk, import_meta2, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
8976
9008
  var init_cursor = __esm({
8977
9009
  "src/agents/cursor.ts"() {
8978
9010
  "use strict";
8979
9011
  import_node_fs25 = require("fs");
8980
9012
  import_node_module3 = require("module");
8981
- import_node_path25 = require("path");
9013
+ import_node_path26 = require("path");
8982
9014
  import_node_url2 = require("url");
8983
9015
  import_sdk = require("@cursor/sdk");
8984
9016
  init_run();
@@ -9037,6 +9069,7 @@ var init_cursor = __esm({
9037
9069
  const req = {
9038
9070
  prompt,
9039
9071
  cwd: thread.worktreePath,
9072
+ threadId: thread.id,
9040
9073
  agentId,
9041
9074
  model: thread.model,
9042
9075
  effort: thread.effort,
@@ -10921,12 +10954,12 @@ function readTextIfPresent(abs) {
10921
10954
  }
10922
10955
  }
10923
10956
  function readLocalGuidelines(worktreePath) {
10924
- const localAbs = (0, import_node_path26.join)(worktreePath, REVIEW_REQUEST_PATH);
10957
+ const localAbs = (0, import_node_path27.join)(worktreePath, REVIEW_REQUEST_PATH);
10925
10958
  const localContent = readTextIfPresent(localAbs);
10926
10959
  if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
10927
10960
  return { path: REVIEW_REQUEST_PATH, content: localContent };
10928
10961
  }
10929
- const legacyAbs = (0, import_node_path26.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
10962
+ const legacyAbs = (0, import_node_path27.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
10930
10963
  const legacyContent = readTextIfPresent(legacyAbs);
10931
10964
  if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
10932
10965
  return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
@@ -10942,20 +10975,20 @@ function skillGuidelines(content, source) {
10942
10975
  };
10943
10976
  }
10944
10977
  function ensureReviewSkillFile(worktreePath) {
10945
- const abs = (0, import_node_path26.join)(worktreePath, REVIEW_SKILL_PATH);
10978
+ const abs = (0, import_node_path27.join)(worktreePath, REVIEW_SKILL_PATH);
10946
10979
  const existing = readTextIfPresent(abs);
10947
10980
  if (existing) {
10948
10981
  return { path: REVIEW_SKILL_PATH, content: existing, wrote: false };
10949
10982
  }
10950
- const fromRepo = readTextIfPresent((0, import_node_path26.join)(worktreePath, REPO_REVIEW_PATH));
10983
+ const fromRepo = readTextIfPresent((0, import_node_path27.join)(worktreePath, REPO_REVIEW_PATH));
10951
10984
  const fromLocal = readLocalGuidelines(worktreePath)?.content ?? null;
10952
10985
  const content = wrapReviewSkillMarkdown(fromRepo ?? fromLocal ?? REVIEW_REQUEST_TEMPLATE);
10953
- (0, import_node_fs27.mkdirSync)((0, import_node_path26.dirname)(abs), { recursive: true });
10986
+ (0, import_node_fs27.mkdirSync)((0, import_node_path27.dirname)(abs), { recursive: true });
10954
10987
  (0, import_node_fs27.writeFileSync)(abs, content, "utf8");
10955
10988
  return { path: REVIEW_SKILL_PATH, content, wrote: true };
10956
10989
  }
10957
10990
  function resolveReviewGuidelines(worktreePath) {
10958
- const skillContent = readTextIfPresent((0, import_node_path26.join)(worktreePath, REVIEW_SKILL_PATH));
10991
+ const skillContent = readTextIfPresent((0, import_node_path27.join)(worktreePath, REVIEW_SKILL_PATH));
10959
10992
  if (skillContent) return skillGuidelines(skillContent, "skill");
10960
10993
  const local = readLocalGuidelines(worktreePath);
10961
10994
  if (local) {
@@ -11005,13 +11038,13 @@ async function requestReview(threadRef, send) {
11005
11038
  const started = await send(tab.id, REVIEW_REQUEST_PREFILL);
11006
11039
  return { tab: started, from };
11007
11040
  }
11008
- var import_node_crypto5, import_node_fs27, import_node_path26, REPO_REVIEW_PATH, REPO_REVIEW_NAME, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
11041
+ var import_node_crypto5, import_node_fs27, import_node_path27, REPO_REVIEW_PATH, REPO_REVIEW_NAME, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
11009
11042
  var init_request_review = __esm({
11010
11043
  "src/review/request-review.ts"() {
11011
11044
  "use strict";
11012
11045
  import_node_crypto5 = require("crypto");
11013
11046
  import_node_fs27 = require("fs");
11014
- import_node_path26 = require("path");
11047
+ import_node_path27 = require("path");
11015
11048
  init_global_workspace();
11016
11049
  init_chat_tabs();
11017
11050
  init_thread_store();
@@ -11036,7 +11069,7 @@ function matchSimpleGlob(pattern, name) {
11036
11069
  return new RegExp(`^${escaped}$`).test(name);
11037
11070
  }
11038
11071
  function readWorktreeInclude(repoPath) {
11039
- const path = (0, import_node_path27.join)(repoPath, ".worktreeinclude");
11072
+ const path = (0, import_node_path28.join)(repoPath, ".worktreeinclude");
11040
11073
  if (!(0, import_node_fs28.existsSync)(path)) return [];
11041
11074
  return (0, import_node_fs28.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
11042
11075
  }
@@ -11051,7 +11084,7 @@ function resolveFilesToCopy(repoPath) {
11051
11084
  for (const entry of (0, import_node_fs28.readdirSync)(repoPath, { withFileTypes: true })) {
11052
11085
  if (!entry.isFile()) continue;
11053
11086
  for (const glob of settings.fileIncludeGlobs) {
11054
- if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path27.basename)(glob), entry.name)) {
11087
+ if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path28.basename)(glob), entry.name)) {
11055
11088
  matched.push(entry.name);
11056
11089
  break;
11057
11090
  }
@@ -11077,10 +11110,10 @@ function copyConfiguredFiles(repoPath, worktreePath) {
11077
11110
  const patterns = resolveFilesToCopy(repoPath);
11078
11111
  const copied = [];
11079
11112
  for (const rel of patterns) {
11080
- const src = (0, import_node_path27.join)(repoPath, rel);
11113
+ const src = (0, import_node_path28.join)(repoPath, rel);
11081
11114
  if (!(0, import_node_fs28.existsSync)(src)) continue;
11082
- const dest = (0, import_node_path27.join)(worktreePath, rel);
11083
- (0, import_node_fs28.mkdirSync)((0, import_node_path27.dirname)(dest), { recursive: true });
11115
+ const dest = (0, import_node_path28.join)(worktreePath, rel);
11116
+ (0, import_node_fs28.mkdirSync)((0, import_node_path28.dirname)(dest), { recursive: true });
11084
11117
  (0, import_node_fs28.copyFileSync)(src, dest);
11085
11118
  copied.push(rel);
11086
11119
  }
@@ -11116,7 +11149,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
11116
11149
  const env = stripNestedElectronEnv({
11117
11150
  ...baseEnv ?? process.env
11118
11151
  });
11119
- const name = opts.workspaceName ?? (0, import_node_path27.basename)(opts.worktreePath);
11152
+ const name = opts.workspaceName ?? (0, import_node_path28.basename)(opts.worktreePath);
11120
11153
  const ports = opts.ports ?? [];
11121
11154
  const primary = ports[0];
11122
11155
  env.SIDEBOARD_WORKSPACE_NAME = name;
@@ -11377,13 +11410,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
11377
11410
  done: handle.done
11378
11411
  };
11379
11412
  }
11380
- var import_node_fs28, import_node_net, import_node_path27, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
11413
+ var import_node_fs28, import_node_net, import_node_path28, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
11381
11414
  var init_conductor = __esm({
11382
11415
  "src/hook/conductor.ts"() {
11383
11416
  "use strict";
11384
11417
  import_node_fs28 = require("fs");
11385
11418
  import_node_net = require("net");
11386
- import_node_path27 = require("path");
11419
+ import_node_path28 = require("path");
11387
11420
  import_execa4 = require("execa");
11388
11421
  import_node_readline3 = require("readline");
11389
11422
  init_settings();
@@ -11445,9 +11478,9 @@ async function findOrphanWorktrees(repoPaths) {
11445
11478
  if ((0, import_node_fs29.existsSync)(root)) {
11446
11479
  for (const entry of (0, import_node_fs29.readdirSync)(root, { withFileTypes: true })) {
11447
11480
  if (!entry.isDirectory()) continue;
11448
- const path = (0, import_node_path28.join)(root, entry.name).replace(/\/$/, "");
11481
+ const path = (0, import_node_path29.join)(root, entry.name).replace(/\/$/, "");
11449
11482
  if (known.has(path) || seen.has(path)) continue;
11450
- if (!(0, import_node_fs29.existsSync)((0, import_node_path28.join)(path, ".git"))) continue;
11483
+ if (!(0, import_node_fs29.existsSync)((0, import_node_path29.join)(path, ".git"))) continue;
11451
11484
  seen.add(path);
11452
11485
  let mtimeMs = 0;
11453
11486
  try {
@@ -11503,12 +11536,12 @@ function shouldRunWorktreeCleanup(settings = loadAppSettings()) {
11503
11536
  const elapsed = Date.now() - Date.parse(last);
11504
11537
  return elapsed >= intervalHours * 36e5;
11505
11538
  }
11506
- var import_node_fs29, import_node_path28;
11539
+ var import_node_fs29, import_node_path29;
11507
11540
  var init_orphan_cleanup = __esm({
11508
11541
  "src/git/orphan-cleanup.ts"() {
11509
11542
  "use strict";
11510
11543
  import_node_fs29 = require("fs");
11511
- import_node_path28 = require("path");
11544
+ import_node_path29 = require("path");
11512
11545
  init_worktree();
11513
11546
  init_thread_store();
11514
11547
  init_paths();
@@ -11615,10 +11648,10 @@ __export(workspaces_exports, {
11615
11648
  syncWorkspacesFromThreads: () => syncWorkspacesFromThreads
11616
11649
  });
11617
11650
  function workspacesFile() {
11618
- return (0, import_node_path29.join)(appDataDir(), "workspaces.json");
11651
+ return (0, import_node_path30.join)(appDataDir(), "workspaces.json");
11619
11652
  }
11620
11653
  function removedWorkspacesFile() {
11621
- return (0, import_node_path29.join)(appDataDir(), "removed-workspaces.json");
11654
+ return (0, import_node_path30.join)(appDataDir(), "removed-workspaces.json");
11622
11655
  }
11623
11656
  function readAll() {
11624
11657
  const path = workspacesFile();
@@ -11677,7 +11710,7 @@ async function addWorkspace(repoPath) {
11677
11710
  if (existing) return existing;
11678
11711
  const next = {
11679
11712
  path: root,
11680
- name: (0, import_node_path29.basename)(root),
11713
+ name: (0, import_node_path30.basename)(root),
11681
11714
  addedAt: (/* @__PURE__ */ new Date()).toISOString()
11682
11715
  };
11683
11716
  writeAll([...current, next]);
@@ -11702,7 +11735,7 @@ function syncWorkspacesFromThreads(repoPaths) {
11702
11735
  if (!(0, import_node_fs30.existsSync)(path)) continue;
11703
11736
  const ws = {
11704
11737
  path,
11705
- name: (0, import_node_path29.basename)(path),
11738
+ name: (0, import_node_path30.basename)(path),
11706
11739
  addedAt: (/* @__PURE__ */ new Date()).toISOString()
11707
11740
  };
11708
11741
  byPath.set(path, ws);
@@ -11712,12 +11745,12 @@ function syncWorkspacesFromThreads(repoPaths) {
11712
11745
  if (dirty) writeAll(next);
11713
11746
  return next.sort((a, b) => a.name.localeCompare(b.name));
11714
11747
  }
11715
- var import_node_fs30, import_node_path29;
11748
+ var import_node_fs30, import_node_path30;
11716
11749
  var init_workspaces2 = __esm({
11717
11750
  "src/store/workspaces.ts"() {
11718
11751
  "use strict";
11719
11752
  import_node_fs30 = require("fs");
11720
- import_node_path29 = require("path");
11753
+ import_node_path30 = require("path");
11721
11754
  init_paths();
11722
11755
  init_global_workspace();
11723
11756
  init_worktree();
@@ -11730,11 +11763,11 @@ async function cloneRepoIntoSideboard(opts) {
11730
11763
  if (!url) throw new Error("Clone URL is required");
11731
11764
  let name = opts.name?.trim();
11732
11765
  if (!name) {
11733
- const leaf = (0, import_node_path30.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
11766
+ const leaf = (0, import_node_path31.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
11734
11767
  name = leaf || "repo";
11735
11768
  }
11736
11769
  name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
11737
- const dest = (0, import_node_path30.join)(sideboardReposDir(), name);
11770
+ const dest = (0, import_node_path31.join)(sideboardReposDir(), name);
11738
11771
  if ((0, import_node_fs31.existsSync)(dest)) {
11739
11772
  const repoPath2 = await resolveRepoRoot(dest);
11740
11773
  const workspace2 = await ensureWorkspace(repoPath2);
@@ -11750,12 +11783,12 @@ async function cloneRepoIntoSideboard(opts) {
11750
11783
  const workspace = await ensureWorkspace(repoPath);
11751
11784
  return { repoPath, workspace };
11752
11785
  }
11753
- var import_node_fs31, import_node_path30, import_execa6;
11786
+ var import_node_fs31, import_node_path31, import_execa6;
11754
11787
  var init_clone_repo = __esm({
11755
11788
  "src/git/clone-repo.ts"() {
11756
11789
  "use strict";
11757
11790
  import_node_fs31 = require("fs");
11758
- import_node_path30 = require("path");
11791
+ import_node_path31 = require("path");
11759
11792
  import_execa6 = require("execa");
11760
11793
  init_paths();
11761
11794
  init_workspaces2();
@@ -11765,7 +11798,7 @@ var init_clone_repo = __esm({
11765
11798
 
11766
11799
  // src/store/desktop-host.ts
11767
11800
  function desktopHostPidPath() {
11768
- return (0, import_node_path31.join)(appDataDir(), "desktop-host.pid");
11801
+ return (0, import_node_path32.join)(appDataDir(), "desktop-host.pid");
11769
11802
  }
11770
11803
  function readDesktopHostPid() {
11771
11804
  try {
@@ -11795,12 +11828,12 @@ function thisProcessShouldDrainAgentQueues() {
11795
11828
  if (isThisProcessDesktopHost()) return true;
11796
11829
  return !isDesktopHostAlive();
11797
11830
  }
11798
- var import_node_fs32, import_node_path31;
11831
+ var import_node_fs32, import_node_path32;
11799
11832
  var init_desktop_host = __esm({
11800
11833
  "src/store/desktop-host.ts"() {
11801
11834
  "use strict";
11802
11835
  import_node_fs32 = require("fs");
11803
- import_node_path31 = require("path");
11836
+ import_node_path32 = require("path");
11804
11837
  init_paths();
11805
11838
  }
11806
11839
  });
@@ -12070,7 +12103,7 @@ function noteTurnLiveEvent(threadId, event) {
12070
12103
  buffers.delete(threadId);
12071
12104
  return;
12072
12105
  }
12073
- const immediate = event.type === "tool_use" || event.type === "tool_result";
12106
+ const immediate = event.type === "tool_use" || event.type === "tool_result" && !event.partial;
12074
12107
  if (immediate) flush(threadId);
12075
12108
  else scheduleFlush(threadId);
12076
12109
  }
@@ -12122,6 +12155,27 @@ var init_turn_live = __esm({
12122
12155
  }
12123
12156
  });
12124
12157
 
12158
+ // src/orchestrator/reconcile-heal.ts
12159
+ function shouldReadThreadToHealReconcile(eventType, lastCheckAt, now) {
12160
+ if (SKIP.has(eventType)) return false;
12161
+ if (lastCheckAt != null && now - lastCheckAt < RECONCILE_HEAL_MIN_MS) return false;
12162
+ return true;
12163
+ }
12164
+ var RECONCILE_HEAL_MIN_MS, SKIP;
12165
+ var init_reconcile_heal = __esm({
12166
+ "src/orchestrator/reconcile-heal.ts"() {
12167
+ "use strict";
12168
+ RECONCILE_HEAL_MIN_MS = 2e3;
12169
+ SKIP = /* @__PURE__ */ new Set([
12170
+ "stdout",
12171
+ "thinking",
12172
+ "usage",
12173
+ "stderr",
12174
+ "tool_result"
12175
+ ]);
12176
+ }
12177
+ });
12178
+
12125
12179
  // src/threads/fork-worktree.ts
12126
12180
  function requireThread2(idOrRef) {
12127
12181
  const thread = findThreadByRef(idOrRef) ?? null;
@@ -12292,7 +12346,7 @@ var init_quota_failover = __esm({
12292
12346
  // src/threads/adopt.ts
12293
12347
  function thisModuleFile() {
12294
12348
  const cjsFile = typeof __filename !== "undefined" ? __filename : "";
12295
- return cjsFile || process.argv[1] || (0, import_node_path32.join)(process.cwd(), "package.json");
12349
+ return cjsFile || process.argv[1] || (0, import_node_path33.join)(process.cwd(), "package.json");
12296
12350
  }
12297
12351
  function openReadonlySqlite(file) {
12298
12352
  const req = (0, import_node_module4.createRequire)(thisModuleFile());
@@ -12320,7 +12374,7 @@ function resolveConductorCursorAgentId(workspacePath) {
12320
12374
  return null;
12321
12375
  }
12322
12376
  for (const hash of hashes) {
12323
- const agentsFile = (0, import_node_path32.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
12377
+ const agentsFile = (0, import_node_path33.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
12324
12378
  if (!(0, import_node_fs35.existsSync)(agentsFile)) continue;
12325
12379
  let text4;
12326
12380
  try {
@@ -12375,8 +12429,8 @@ function listConductorWorkspaces() {
12375
12429
  if (!(0, import_node_fs35.existsSync)(CONDUCTOR_DB)) {
12376
12430
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
12377
12431
  }
12378
- const tmp = (0, import_node_fs35.mkdtempSync)((0, import_node_path32.join)((0, import_node_os10.tmpdir)(), "sideboard-conductor-"));
12379
- const snapshot = (0, import_node_path32.join)(tmp, "conductor.db");
12432
+ const tmp = (0, import_node_fs35.mkdtempSync)((0, import_node_path33.join)((0, import_node_os10.tmpdir)(), "sideboard-conductor-"));
12433
+ const snapshot = (0, import_node_path33.join)(tmp, "conductor.db");
12380
12434
  try {
12381
12435
  (0, import_node_fs35.copyFileSync)(CONDUCTOR_DB, snapshot);
12382
12436
  for (const suffix of ["-wal", "-shm"]) {
@@ -12466,8 +12520,8 @@ function importConductorWorkspace(workspaceId) {
12466
12520
  if (!(0, import_node_fs35.existsSync)(CONDUCTOR_DB)) {
12467
12521
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
12468
12522
  }
12469
- const tmp = (0, import_node_fs35.mkdtempSync)((0, import_node_path32.join)((0, import_node_os10.tmpdir)(), "sideboard-conductor-"));
12470
- const snapshot = (0, import_node_path32.join)(tmp, "conductor.db");
12523
+ const tmp = (0, import_node_fs35.mkdtempSync)((0, import_node_path33.join)((0, import_node_os10.tmpdir)(), "sideboard-conductor-"));
12524
+ const snapshot = (0, import_node_path33.join)(tmp, "conductor.db");
12471
12525
  try {
12472
12526
  (0, import_node_fs35.copyFileSync)(CONDUCTOR_DB, snapshot);
12473
12527
  for (const suffix of ["-wal", "-shm"]) {
@@ -12561,25 +12615,25 @@ function importConductorWorkspace(workspaceId) {
12561
12615
  async function importConductorWorkspaceAsync(workspaceId) {
12562
12616
  return importConductorWorkspace(workspaceId);
12563
12617
  }
12564
- var import_node_child_process3, import_node_fs35, import_node_os10, import_node_path32, import_node_module4, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
12618
+ var import_node_child_process3, import_node_fs35, import_node_os10, import_node_path33, import_node_module4, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
12565
12619
  var init_adopt = __esm({
12566
12620
  "src/threads/adopt.ts"() {
12567
12621
  "use strict";
12568
12622
  import_node_child_process3 = require("child_process");
12569
12623
  import_node_fs35 = require("fs");
12570
12624
  import_node_os10 = require("os");
12571
- import_node_path32 = require("path");
12625
+ import_node_path33 = require("path");
12572
12626
  import_node_module4 = require("module");
12573
12627
  init_worktree();
12574
12628
  init_thread_store();
12575
- CONDUCTOR_APP_SUPPORT = (0, import_node_path32.join)(
12629
+ CONDUCTOR_APP_SUPPORT = (0, import_node_path33.join)(
12576
12630
  process.env.HOME ?? "",
12577
12631
  "Library",
12578
12632
  "Application Support",
12579
12633
  "com.conductor.app"
12580
12634
  );
12581
- CONDUCTOR_DB = (0, import_node_path32.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
12582
- CURSOR_SDK_STORE = (0, import_node_path32.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
12635
+ CONDUCTOR_DB = (0, import_node_path33.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
12636
+ CURSOR_SDK_STORE = (0, import_node_path33.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
12583
12637
  }
12584
12638
  });
12585
12639
 
@@ -13024,7 +13078,7 @@ new file mode 100644
13024
13078
  };
13025
13079
  }
13026
13080
  async function untrackedPatch(worktreePath, path, maxHunk) {
13027
- const abs = (0, import_node_path33.join)(worktreePath, path);
13081
+ const abs = (0, import_node_path34.join)(worktreePath, path);
13028
13082
  try {
13029
13083
  const st = (0, import_node_fs37.statSync)(abs);
13030
13084
  if (st.isFile() && st.size > maxHunk) {
@@ -13517,7 +13571,7 @@ function isImageRelativePath(relativePath) {
13517
13571
  function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
13518
13572
  assertSafeRelativePath(relativePath);
13519
13573
  const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
13520
- const abs = (0, import_node_path33.join)(worktreePath, relativePath);
13574
+ const abs = (0, import_node_path34.join)(worktreePath, relativePath);
13521
13575
  const st = (0, import_node_fs37.statSync)(abs);
13522
13576
  if (!st.isFile()) {
13523
13577
  throw new Error(`Not a file: ${relativePath}`);
@@ -13537,7 +13591,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
13537
13591
  function readWorktreeFile(worktreePath, relativePath, opts) {
13538
13592
  assertSafeRelativePath(relativePath);
13539
13593
  const maxBytes = opts?.maxBytes ?? 2e5;
13540
- const abs = (0, import_node_path33.join)(worktreePath, relativePath);
13594
+ const abs = (0, import_node_path34.join)(worktreePath, relativePath);
13541
13595
  const st = (0, import_node_fs37.statSync)(abs);
13542
13596
  if (!st.isFile()) {
13543
13597
  throw new Error(`Not a file: ${relativePath}`);
@@ -13585,8 +13639,8 @@ function assertSafeRelativePath(relativePath) {
13585
13639
  }
13586
13640
  function writeWorktreeFile(worktreePath, relativePath, content) {
13587
13641
  assertSafeRelativePath(relativePath);
13588
- const abs = (0, import_node_path33.join)(worktreePath, relativePath);
13589
- (0, import_node_fs37.mkdirSync)((0, import_node_path33.dirname)(abs), { recursive: true });
13642
+ const abs = (0, import_node_path34.join)(worktreePath, relativePath);
13643
+ (0, import_node_fs37.mkdirSync)((0, import_node_path34.dirname)(abs), { recursive: true });
13590
13644
  (0, import_node_fs37.writeFileSync)(abs, content, "utf8");
13591
13645
  return { path: relativePath };
13592
13646
  }
@@ -13604,12 +13658,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
13604
13658
  truncated: full.files.length > maxFiles
13605
13659
  };
13606
13660
  }
13607
- var import_node_fs37, import_node_path33, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS, DEFAULT_UPLOAD_MAX_BYTES;
13661
+ var import_node_fs37, import_node_path34, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS, DEFAULT_UPLOAD_MAX_BYTES;
13608
13662
  var init_diff = __esm({
13609
13663
  "src/diff/diff.ts"() {
13610
13664
  "use strict";
13611
13665
  import_node_fs37 = require("fs");
13612
- import_node_path33 = require("path");
13666
+ import_node_path34 = require("path");
13613
13667
  init_run();
13614
13668
  init_worktree();
13615
13669
  mergeBaseCache = /* @__PURE__ */ new Map();
@@ -13805,7 +13859,7 @@ function scanSkillsDir(dir, source, out) {
13805
13859
  }
13806
13860
  for (const entry of entries) {
13807
13861
  if (entry.startsWith(".")) continue;
13808
- const skillMd = (0, import_node_path34.join)(dir, entry, "SKILL.md");
13862
+ const skillMd = (0, import_node_path35.join)(dir, entry, "SKILL.md");
13809
13863
  if (!(0, import_node_fs38.existsSync)(skillMd)) continue;
13810
13864
  try {
13811
13865
  if (!(0, import_node_fs38.statSync)(skillMd).isFile()) continue;
@@ -13827,12 +13881,12 @@ function scanClaudePluginSkills(pluginsRoot, out) {
13827
13881
  return;
13828
13882
  }
13829
13883
  if (lookingForSkillsDir && entries.includes("SKILL.md")) {
13830
- const skill = readSkill((0, import_node_path34.join)(dir, "SKILL.md"), "cli");
13884
+ const skill = readSkill((0, import_node_path35.join)(dir, "SKILL.md"), "cli");
13831
13885
  if (skill) out.push(skill);
13832
13886
  }
13833
13887
  for (const entry of entries) {
13834
13888
  if (entry === "node_modules" || entry === ".git") continue;
13835
- const full = (0, import_node_path34.join)(dir, entry);
13889
+ const full = (0, import_node_path35.join)(dir, entry);
13836
13890
  try {
13837
13891
  if (!(0, import_node_fs38.statSync)(full).isDirectory()) continue;
13838
13892
  } catch {
@@ -13852,17 +13906,17 @@ function discoverSkills(worktreePath) {
13852
13906
  const home = (0, import_node_os11.homedir)();
13853
13907
  const collected = [];
13854
13908
  for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
13855
- scanSkillsDir((0, import_node_path34.join)(worktreePath, rel), "workspace", collected);
13909
+ scanSkillsDir((0, import_node_path35.join)(worktreePath, rel), "workspace", collected);
13856
13910
  }
13857
13911
  for (const abs of [
13858
- (0, import_node_path34.join)(home, ".claude/skills"),
13859
- (0, import_node_path34.join)(home, ".cursor/skills"),
13860
- (0, import_node_path34.join)(home, ".sideboard/skills"),
13861
- (0, import_node_path34.join)(home, ".brightsy/skills")
13912
+ (0, import_node_path35.join)(home, ".claude/skills"),
13913
+ (0, import_node_path35.join)(home, ".cursor/skills"),
13914
+ (0, import_node_path35.join)(home, ".sideboard/skills"),
13915
+ (0, import_node_path35.join)(home, ".brightsy/skills")
13862
13916
  ]) {
13863
13917
  scanSkillsDir(abs, "user", collected);
13864
13918
  }
13865
- scanClaudePluginSkills((0, import_node_path34.join)(home, ".claude/plugins"), collected);
13919
+ scanClaudePluginSkills((0, import_node_path35.join)(home, ".claude/plugins"), collected);
13866
13920
  const rank = { workspace: 0, user: 1, cli: 2 };
13867
13921
  const byCommand = /* @__PURE__ */ new Map();
13868
13922
  for (const skill of collected) {
@@ -13888,13 +13942,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
13888
13942
 
13889
13943
  \u2026(truncated)` : raw;
13890
13944
  }
13891
- var import_node_fs38, import_node_os11, import_node_path34;
13945
+ var import_node_fs38, import_node_os11, import_node_path35;
13892
13946
  var init_discover = __esm({
13893
13947
  "src/skills/discover.ts"() {
13894
13948
  "use strict";
13895
13949
  import_node_fs38 = require("fs");
13896
13950
  import_node_os11 = require("os");
13897
- import_node_path34 = require("path");
13951
+ import_node_path35 = require("path");
13898
13952
  }
13899
13953
  });
13900
13954
 
@@ -13985,7 +14039,7 @@ var init_expand = __esm({
13985
14039
 
13986
14040
  // src/composer/stage-files.ts
13987
14041
  function fileExtension(filePath) {
13988
- const base = (0, import_node_path35.basename)(filePath).toLowerCase();
14042
+ const base = (0, import_node_path36.basename)(filePath).toLowerCase();
13989
14043
  return base.includes(".") ? base.split(".").pop() || "" : "";
13990
14044
  }
13991
14045
  function isImageFilePath(filePath) {
@@ -13995,9 +14049,9 @@ function imageMimeType(filePath) {
13995
14049
  return IMAGE_MIME_BY_EXT[fileExtension(filePath)] || "image/png";
13996
14050
  }
13997
14051
  function ensureAttachmentsDir(worktreePath) {
13998
- const dir = (0, import_node_path35.join)(worktreePath, ATTACHMENTS_DIR);
14052
+ const dir = (0, import_node_path36.join)(worktreePath, ATTACHMENTS_DIR);
13999
14053
  (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
14000
- const gi = (0, import_node_path35.join)(dir, ".gitignore");
14054
+ const gi = (0, import_node_path36.join)(dir, ".gitignore");
14001
14055
  if (!(0, import_node_fs39.existsSync)(gi)) {
14002
14056
  (0, import_node_fs39.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
14003
14057
  }
@@ -14005,12 +14059,12 @@ function ensureAttachmentsDir(worktreePath) {
14005
14059
  }
14006
14060
  function uniqueAttachmentName(dir, originalName) {
14007
14061
  const safe = originalName.replace(/[/\\]/g, "_") || "file";
14008
- if (!(0, import_node_fs39.existsSync)((0, import_node_path35.join)(dir, safe))) return safe;
14009
- const ext = (0, import_node_path35.extname)(safe);
14062
+ if (!(0, import_node_fs39.existsSync)((0, import_node_path36.join)(dir, safe))) return safe;
14063
+ const ext = (0, import_node_path36.extname)(safe);
14010
14064
  const stem = ext ? safe.slice(0, -ext.length) : safe;
14011
14065
  for (let i = 1; i < 1e4; i++) {
14012
14066
  const candidate = `${stem}-${i}${ext}`;
14013
- if (!(0, import_node_fs39.existsSync)((0, import_node_path35.join)(dir, candidate))) return candidate;
14067
+ if (!(0, import_node_fs39.existsSync)((0, import_node_path36.join)(dir, candidate))) return candidate;
14014
14068
  }
14015
14069
  return `${stem}-${(0, import_node_crypto7.randomUUID)()}${ext}`;
14016
14070
  }
@@ -14066,12 +14120,12 @@ function stageAbsolutePathsAsAttachments(worktreePath, absolutePaths) {
14066
14120
  const dir = ensureAttachmentsDir(worktreePath);
14067
14121
  const out = [];
14068
14122
  for (const abs of absolutePaths) {
14069
- const originalName = (0, import_node_path35.basename)(abs);
14123
+ const originalName = (0, import_node_path36.basename)(abs);
14070
14124
  try {
14071
14125
  const st = (0, import_node_fs39.statSync)(abs);
14072
14126
  if (!st.isFile()) continue;
14073
14127
  const name = uniqueAttachmentName(dir, originalName);
14074
- const destAbs = (0, import_node_path35.join)(dir, name);
14128
+ const destAbs = (0, import_node_path36.join)(dir, name);
14075
14129
  (0, import_node_fs39.copyFileSync)(abs, destAbs);
14076
14130
  const rel = `${ATTACHMENTS_DIR}/${name}`;
14077
14131
  const buf = (0, import_node_fs39.readFileSync)(destAbs);
@@ -14096,7 +14150,7 @@ function stageBuffersAsAttachments(worktreePath, buffers2) {
14096
14150
  try {
14097
14151
  const buf = Buffer.from(item.dataBase64, "base64");
14098
14152
  const name = uniqueAttachmentName(dir, originalName);
14099
- const destAbs = (0, import_node_path35.join)(dir, name);
14153
+ const destAbs = (0, import_node_path36.join)(dir, name);
14100
14154
  (0, import_node_fs39.writeFileSync)(destAbs, buf);
14101
14155
  const rel = `${ATTACHMENTS_DIR}/${name}`;
14102
14156
  out.push(attachmentFromBuffer(name, buf, { path: rel }));
@@ -14117,15 +14171,15 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
14117
14171
  if (!rel || rel.includes("..") || rel.startsWith("/")) {
14118
14172
  out.push({
14119
14173
  id: (0, import_node_crypto7.randomUUID)(),
14120
- name: (0, import_node_path35.basename)(rel) || "file",
14174
+ name: (0, import_node_path36.basename)(rel) || "file",
14121
14175
  kind: "file",
14122
14176
  content: `(invalid path: ${rel})`
14123
14177
  });
14124
14178
  continue;
14125
14179
  }
14126
- const name = (0, import_node_path35.basename)(rel);
14180
+ const name = (0, import_node_path36.basename)(rel);
14127
14181
  try {
14128
- const abs = (0, import_node_path35.join)(worktreePath, rel);
14182
+ const abs = (0, import_node_path36.join)(worktreePath, rel);
14129
14183
  const st = (0, import_node_fs39.statSync)(abs);
14130
14184
  if (!st.isFile()) continue;
14131
14185
  const buf = (0, import_node_fs39.readFileSync)(abs);
@@ -14141,12 +14195,12 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
14141
14195
  }
14142
14196
  return out;
14143
14197
  }
14144
- var import_node_fs39, import_node_path35, import_node_crypto7, IMAGE_EXTENSIONS2, IMAGE_MIME_BY_EXT, MAX_INLINE_BYTES, MAX_PREVIEW_BYTES;
14198
+ var import_node_fs39, import_node_path36, import_node_crypto7, IMAGE_EXTENSIONS2, IMAGE_MIME_BY_EXT, MAX_INLINE_BYTES, MAX_PREVIEW_BYTES;
14145
14199
  var init_stage_files = __esm({
14146
14200
  "src/composer/stage-files.ts"() {
14147
14201
  "use strict";
14148
14202
  import_node_fs39 = require("fs");
14149
- import_node_path35 = require("path");
14203
+ import_node_path36 = require("path");
14150
14204
  import_node_crypto7 = require("crypto");
14151
14205
  init_workspace_scratch();
14152
14206
  IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set([
@@ -14316,12 +14370,12 @@ function formatArtifactDirective() {
14316
14370
  function formatUiReminder() {
14317
14371
  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. ask_user only for a real multiple-choice (not hellos or \u201Cwhat next?\u201D) \u2014 reply in chat. Do not say artifacts/CMS UI are unavailable.";
14318
14372
  }
14319
- var import_node_fs40, import_node_path36;
14373
+ var import_node_fs40, import_node_path37;
14320
14374
  var init_instructions = __esm({
14321
14375
  "src/agents/instructions.ts"() {
14322
14376
  "use strict";
14323
14377
  import_node_fs40 = require("fs");
14324
- import_node_path36 = require("path");
14378
+ import_node_path37 = require("path");
14325
14379
  init_git_auth_mode();
14326
14380
  init_worktree_labels();
14327
14381
  }
@@ -14397,13 +14451,13 @@ __export(plan_file_exports, {
14397
14451
  writePlanFile: () => writePlanFile
14398
14452
  });
14399
14453
  function ensureAttachmentsGitignore(worktreePath) {
14400
- const gitignoreAbs = (0, import_node_path37.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
14454
+ const gitignoreAbs = (0, import_node_path38.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
14401
14455
  if ((0, import_node_fs41.existsSync)(gitignoreAbs)) return;
14402
- (0, import_node_fs41.mkdirSync)((0, import_node_path37.dirname)(gitignoreAbs), { recursive: true });
14456
+ (0, import_node_fs41.mkdirSync)((0, import_node_path38.dirname)(gitignoreAbs), { recursive: true });
14403
14457
  (0, import_node_fs41.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
14404
14458
  }
14405
14459
  function planFileAbs(worktreePath) {
14406
- return (0, import_node_path37.join)(worktreePath, PLAN_FILE_REL);
14460
+ return (0, import_node_path38.join)(worktreePath, PLAN_FILE_REL);
14407
14461
  }
14408
14462
  function readTextIfPresent2(abs) {
14409
14463
  if (!(0, import_node_fs41.existsSync)(abs)) return null;
@@ -14415,22 +14469,22 @@ function readTextIfPresent2(abs) {
14415
14469
  }
14416
14470
  }
14417
14471
  function readPlanFile(worktreePath) {
14418
- return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path37.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path37.join)(worktreePath, LEGACY_PLAN_FILE_REL));
14472
+ return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path38.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path38.join)(worktreePath, LEGACY_PLAN_FILE_REL));
14419
14473
  }
14420
14474
  function writePlanFile(worktreePath, content) {
14421
14475
  ensureAttachmentsGitignore(worktreePath);
14422
14476
  const abs = planFileAbs(worktreePath);
14423
- (0, import_node_fs41.mkdirSync)((0, import_node_path37.dirname)(abs), { recursive: true });
14477
+ (0, import_node_fs41.mkdirSync)((0, import_node_path38.dirname)(abs), { recursive: true });
14424
14478
  const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
14425
14479
  (0, import_node_fs41.writeFileSync)(abs, body, "utf8");
14426
14480
  return PLAN_FILE_REL;
14427
14481
  }
14428
- var import_node_fs41, import_node_path37;
14482
+ var import_node_fs41, import_node_path38;
14429
14483
  var init_plan_file = __esm({
14430
14484
  "src/plan/plan-file.ts"() {
14431
14485
  "use strict";
14432
14486
  import_node_fs41 = require("fs");
14433
- import_node_path37 = require("path");
14487
+ import_node_path38 = require("path");
14434
14488
  init_workspace_scratch();
14435
14489
  init_plan_present();
14436
14490
  init_plan_present();
@@ -14490,7 +14544,7 @@ function setCaffeinateHoldHooks(next) {
14490
14544
  hooks = next;
14491
14545
  }
14492
14546
  function caffeinateHoldPath() {
14493
- return (0, import_node_path38.join)(appDataDir(), "caffeinate-hold.json");
14547
+ return (0, import_node_path39.join)(appDataDir(), "caffeinate-hold.json");
14494
14548
  }
14495
14549
  function processAlive(pid) {
14496
14550
  if (hooks.processAlive) return hooks.processAlive(pid);
@@ -14633,13 +14687,13 @@ function releaseCaffeinateHoldForThread(threadId) {
14633
14687
  }
14634
14688
  return setCaffeinateHold(false, { threadId: id });
14635
14689
  }
14636
- var import_node_child_process4, import_node_fs42, import_node_path38, hooks;
14690
+ var import_node_child_process4, import_node_fs42, import_node_path39, hooks;
14637
14691
  var init_caffeinate_hold = __esm({
14638
14692
  "src/store/caffeinate-hold.ts"() {
14639
14693
  "use strict";
14640
14694
  import_node_child_process4 = require("child_process");
14641
14695
  import_node_fs42 = require("fs");
14642
- import_node_path38 = require("path");
14696
+ import_node_path39 = require("path");
14643
14697
  init_paths();
14644
14698
  init_private_file();
14645
14699
  hooks = {};
@@ -14648,7 +14702,7 @@ var init_caffeinate_hold = __esm({
14648
14702
 
14649
14703
  // src/store/schedules.ts
14650
14704
  function schedulesPath() {
14651
- return (0, import_node_path39.join)(appDataDir(), "schedules.json");
14705
+ return (0, import_node_path40.join)(appDataDir(), "schedules.json");
14652
14706
  }
14653
14707
  function parseDurationMs(every) {
14654
14708
  const m = every.trim().match(DURATION_RE);
@@ -14862,13 +14916,13 @@ function recordScheduleRun(id, result) {
14862
14916
  writeAll2(rows);
14863
14917
  return next;
14864
14918
  }
14865
- var import_node_crypto8, import_node_fs43, import_node_path39, import_croner, DURATION_RE, UNIT_MS;
14919
+ var import_node_crypto8, import_node_fs43, import_node_path40, import_croner, DURATION_RE, UNIT_MS;
14866
14920
  var init_schedules = __esm({
14867
14921
  "src/store/schedules.ts"() {
14868
14922
  "use strict";
14869
14923
  import_node_crypto8 = require("crypto");
14870
14924
  import_node_fs43 = require("fs");
14871
- import_node_path39 = require("path");
14925
+ import_node_path40 = require("path");
14872
14926
  import_croner = require("croner");
14873
14927
  init_orchestrator_capable();
14874
14928
  init_paths();
@@ -15008,6 +15062,37 @@ var init_schedule_runner = __esm({
15008
15062
  }
15009
15063
  });
15010
15064
 
15065
+ // src/agents/cursor-store.ts
15066
+ function cursorSdkStoreDir(threadId) {
15067
+ const root = (0, import_node_path41.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
15068
+ const id = sanitizeCursorStoreSegment(threadId);
15069
+ if (!id) return root;
15070
+ return (0, import_node_path41.join)(root, "threads", id);
15071
+ }
15072
+ function cursorSdkRunsNdjsonPath(threadId) {
15073
+ return (0, import_node_path41.join)(cursorSdkStoreDir(threadId), "runs.ndjson");
15074
+ }
15075
+ function cursorSdkRunsNdjsonSearchPaths(threadId) {
15076
+ const scoped = cursorSdkRunsNdjsonPath(threadId);
15077
+ const shared = cursorSdkRunsNdjsonPath(null);
15078
+ if (!threadId || !sanitizeCursorStoreSegment(threadId) || scoped === shared) {
15079
+ return [shared];
15080
+ }
15081
+ return [scoped, shared];
15082
+ }
15083
+ function sanitizeCursorStoreSegment(threadId) {
15084
+ return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
15085
+ }
15086
+ var import_node_path41, CURSOR_SDK_STORE_DIR;
15087
+ var init_cursor_store = __esm({
15088
+ "src/agents/cursor-store.ts"() {
15089
+ "use strict";
15090
+ import_node_path41 = require("path");
15091
+ init_paths();
15092
+ CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
15093
+ }
15094
+ });
15095
+
15011
15096
  // src/agents/cursor-recover.ts
15012
15097
  var cursor_recover_exports = {};
15013
15098
  __export(cursor_recover_exports, {
@@ -15016,7 +15101,14 @@ __export(cursor_recover_exports, {
15016
15101
  function recoverFinishedCursorRun(opts) {
15017
15102
  const agentId = opts.agentId.trim();
15018
15103
  if (!agentId) return null;
15019
- const runsPath = (0, import_node_path40.join)(appDataDir(), "cursor-sdk-store", "runs.ndjson");
15104
+ let best = null;
15105
+ for (const runsPath of cursorSdkRunsNdjsonSearchPaths(opts.threadId)) {
15106
+ const hit = scanFinishedCursorRuns(runsPath, agentId, opts.startedAfterMs);
15107
+ if (hit && (!best || hit.endedAt >= best.endedAt)) best = hit;
15108
+ }
15109
+ return best;
15110
+ }
15111
+ function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
15020
15112
  if (!(0, import_node_fs44.existsSync)(runsPath)) return null;
15021
15113
  try {
15022
15114
  const lines = (0, import_node_fs44.readFileSync)(runsPath, "utf8").split("\n");
@@ -15035,7 +15127,7 @@ function recoverFinishedCursorRun(opts) {
15035
15127
  if (typeof row.result !== "string" || !row.result.trim()) continue;
15036
15128
  const endedAt = typeof row.endedAt === "number" ? row.endedAt : 0;
15037
15129
  const createdAt = typeof row.createdAt === "number" ? row.createdAt : 0;
15038
- if (createdAt < opts.startedAfterMs && endedAt < opts.startedAfterMs) continue;
15130
+ if (createdAt < startedAfterMs && endedAt < startedAfterMs) continue;
15039
15131
  if (!best || endedAt >= best.endedAt) {
15040
15132
  best = { runId: row.runId || "", result: row.result.trim(), endedAt };
15041
15133
  }
@@ -15045,13 +15137,12 @@ function recoverFinishedCursorRun(opts) {
15045
15137
  return null;
15046
15138
  }
15047
15139
  }
15048
- var import_node_fs44, import_node_path40;
15140
+ var import_node_fs44;
15049
15141
  var init_cursor_recover = __esm({
15050
15142
  "src/agents/cursor-recover.ts"() {
15051
15143
  "use strict";
15052
15144
  import_node_fs44 = require("fs");
15053
- import_node_path40 = require("path");
15054
- init_paths();
15145
+ init_cursor_store();
15055
15146
  }
15056
15147
  });
15057
15148
 
@@ -15212,6 +15303,7 @@ var init_orchestrator = __esm({
15212
15303
  init_run();
15213
15304
  init_repo_git_lock();
15214
15305
  init_turn_live();
15306
+ init_reconcile_heal();
15215
15307
  init_request_review();
15216
15308
  init_fork_worktree();
15217
15309
  init_quota_failover();
@@ -15241,6 +15333,8 @@ var init_orchestrator = __esm({
15241
15333
  draining = /* @__PURE__ */ new Set();
15242
15334
  /** Threads past setStatus(running) but not yet in activeTurns (spawn in flight). */
15243
15335
  startingTurns = /* @__PURE__ */ new Set();
15336
+ /** Last sync thread-file read for false-stop heal (throttled per thread). */
15337
+ lastReconcileHealAt = /* @__PURE__ */ new Map();
15244
15338
  /**
15245
15339
  * Threads intentionally force-stopped. Prevents runTurn from re-asserting
15246
15340
  * `running` after spawn, and from overwriting `stopped` with idle/error when
@@ -15838,7 +15932,13 @@ var init_orchestrator = __esm({
15838
15932
  if (event.type === "stderr" && typeof event.data === "string") {
15839
15933
  pushTurnStderr(stderrTail, event.data);
15840
15934
  }
15841
- if (event.type !== "stdout" && event.type !== "thinking") {
15935
+ const now = Date.now();
15936
+ if (shouldReadThreadToHealReconcile(
15937
+ event.type,
15938
+ this.lastReconcileHealAt.get(threadId),
15939
+ now
15940
+ )) {
15941
+ this.lastReconcileHealAt.set(threadId, now);
15842
15942
  const live = readThread(threadId);
15843
15943
  if (live?.lastError?.includes("reconciled on startup") && (this.activeTurns.has(threadId) || this.startingTurns.has(threadId))) {
15844
15944
  setStatus(threadId, "running");
@@ -15882,7 +15982,8 @@ var init_orchestrator = __esm({
15882
15982
  for (let i = 0; i < 8; i++) {
15883
15983
  const recovered = recoverFinishedCursorRun2({
15884
15984
  agentId: sessionId,
15885
- startedAfterMs: turnStartedAt - 5e3
15985
+ startedAfterMs: turnStartedAt - 5e3,
15986
+ threadId
15886
15987
  });
15887
15988
  if (recovered?.result) {
15888
15989
  assistantText = recovered.result;
@@ -16983,7 +17084,7 @@ init_nested_electron_env();
16983
17084
  var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
16984
17085
  var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
16985
17086
  var import_zod4 = require("zod");
16986
- var import_node_path41 = require("path");
17087
+ var import_node_path42 = require("path");
16987
17088
  init_orchestrator();
16988
17089
  init_worktree();
16989
17090
 
@@ -18340,7 +18441,7 @@ async function startMcpServer() {
18340
18441
  async () => {
18341
18442
  const threads = orch.getThreads(true);
18342
18443
  const lines = threads.map((t) => {
18343
- const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path41.basename)(t.repoPath) || t.repoPath;
18444
+ const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path42.basename)(t.repoPath) || t.repoPath;
18344
18445
  const live = t.status === "running" || t.status === "queued" ? readTurnLive(t.id) : null;
18345
18446
  const progress = live?.summary ? ` ${live.summary}` : "";
18346
18447
  return `${t.id.slice(0, 8)} ${t.status.padEnd(9)} ${t.agent.padEnd(8)} ${repo} ${t.sourceType}:${t.sourceRef} ${t.title} sideboard://thread/${t.id}${t.devPort ? ` http://localhost:${t.devPort}` : ""}${progress}`;