@sideboard-ai/core 0.1.111 → 0.1.115
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.
- package/dist/agents/cursor-runner.cjs +29 -20
- package/dist/agents/cursor-runner.js +3 -3
- package/dist/{agents-NN22A4G5.js → agents-3X3EFCQY.js} +7 -7
- package/dist/{agents-GH3FWDW2.js → agents-AHAFC6FR.js} +10 -10
- package/dist/{chunk-4EWPKYOU.js → chunk-4OJMZ6P2.js} +2 -2
- package/dist/{chunk-KVFNTWFG.js → chunk-66XTXHR3.js} +244 -36
- package/dist/{chunk-KQBI5HNT.js → chunk-7WC5UWEB.js} +2 -2
- package/dist/{chunk-WIHKHR5R.js → chunk-AXQ4ZWHK.js} +5 -0
- package/dist/{chunk-NC3U42ZP.js → chunk-C6OBY6IC.js} +268 -27
- package/dist/{chunk-DMJKOFTO.js → chunk-DCNR7NAL.js} +39 -31
- package/dist/{chunk-LGXBYZZA.js → chunk-DVM4ID64.js} +69 -13
- package/dist/{chunk-2GO3YKBA.js → chunk-EKIDHL2T.js} +4 -4
- package/dist/{chunk-C4KHDW3U.js → chunk-FZCIQYNQ.js} +1 -1
- package/dist/{chunk-7KWYXGIU.js → chunk-K3TIQXOH.js} +2 -2
- package/dist/{chunk-3KETJKYA.js → chunk-KPIYENTF.js} +69 -13
- package/dist/{chunk-JTQQPJAU.js → chunk-MZ6HJ7VL.js} +47 -34
- package/dist/{chunk-363Z34PY.js → chunk-SLU5JVKD.js} +251 -217
- package/dist/{chunk-VOD3HFLP.js → chunk-XOYQ7LNQ.js} +2 -2
- package/dist/{chunk-7YKXHBIW.js → chunk-YMRT2DU6.js} +3 -3
- package/dist/{chunk-YXDR43ZC.js → chunk-ZMROW673.js} +5 -5
- package/dist/{chunk-YFAXVUY2.js → chunk-ZRCX43LS.js} +2 -2
- package/dist/{chunk-AROMOP3C.js → chunk-ZYEFCSZJ.js} +2 -2
- package/dist/{connected-teams-M5XNXRI5.js → connected-teams-O6D4PM7A.js} +2 -2
- package/dist/{connected-teams-J4I5AKMR.js → connected-teams-ZCOU6KCD.js} +2 -2
- package/dist/{coordinator-prompt-AR66L3N4.js → coordinator-prompt-4KCALEKD.js} +3 -3
- package/dist/{coordinator-prompt-BHMLWL64.js → coordinator-prompt-FML4I5AR.js} +3 -3
- package/dist/{global-workspace-XSUFEIAQ.js → global-workspace-CSWABOG5.js} +4 -4
- package/dist/{global-workspace-SKFODUQQ.js → global-workspace-H4YNASM6.js} +4 -4
- package/dist/index.cjs +787 -427
- package/dist/index.d.cts +53 -1
- package/dist/index.d.ts +53 -1
- package/dist/index.js +33 -15
- package/dist/mcp/run-stdio.cjs +906 -625
- package/dist/mcp/run-stdio.js +18 -14
- package/dist/{orchestrator-4T2SXDZ7.js → orchestrator-GKLYKLRC.js} +8 -8
- package/dist/{orchestrator-EP57AB5W.js → orchestrator-TXASYNHT.js} +10 -10
- package/dist/{run-XKTAJRWF.js → run-USF6FRKV.js} +3 -1
- package/dist/{run-CFKZPY7F.js → run-XQKGHQZ2.js} +3 -1
- package/dist/{workspaces-XAQVKTLO.js → workspaces-HJ3EVATC.js} +5 -5
- package/dist/{workspaces-HV3J4TTW.js → workspaces-QG6PGFQR.js} +5 -5
- package/dist/{worktree-XFJED3VU.js → worktree-IW3BX26B.js} +2 -2
- package/dist/{worktree-N2EV24EE.js → worktree-OTFQO2W7.js} +2 -2
- package/package.json +1 -1
package/dist/mcp/run-stdio.cjs
CHANGED
|
@@ -1507,6 +1507,7 @@ function looksLikeRetryableRunnerCrash(text4) {
|
|
|
1507
1507
|
}
|
|
1508
1508
|
function shouldRetryFailedAgentTurn(detail, opts) {
|
|
1509
1509
|
if (looksLikeInvalidAgentSession(detail) && opts.hasSession) return true;
|
|
1510
|
+
if (looksLikeV8Oom(detail) && opts.hasSession) return true;
|
|
1510
1511
|
return looksLikeRetryableRunnerCrash(detail);
|
|
1511
1512
|
}
|
|
1512
1513
|
function looksLikeAgentFailureMessage(text4) {
|
|
@@ -1599,11 +1600,258 @@ var init_error_detail = __esm({
|
|
|
1599
1600
|
NESTED_ELECTRON_SUMMARY = "Cursor local agent crashed at Electron startup (nested Chromium / HasCustomHostObject)";
|
|
1600
1601
|
HOMEBREW_LIBUV_SUMMARY = "Cursor runner crashed in Node (Homebrew Node + shared libuv). Install Node 22 LTS (`brew install node@22`) and retry.";
|
|
1601
1602
|
BUNDLED_NODE_CRASH_SUMMARY = "Cursor runner crashed in Node. Retry the turn.";
|
|
1602
|
-
V8_OOM_SUMMARY = "
|
|
1603
|
+
V8_OOM_SUMMARY = "Agent ran out of memory (JavaScript heap). If it keeps happening, exclude large files from the project folder.";
|
|
1603
1604
|
MINIFIED_DUMP_SUMMARY = "Cursor local agent crashed during startup (truncated crash dump)";
|
|
1604
1605
|
}
|
|
1605
1606
|
});
|
|
1606
1607
|
|
|
1608
|
+
// src/agents/path.ts
|
|
1609
|
+
function prependPathDir(env, dir) {
|
|
1610
|
+
if (!dir || !(0, import_node_fs10.existsSync)(dir)) return;
|
|
1611
|
+
const current = env.PATH ?? "";
|
|
1612
|
+
const parts = current.split(import_node_path10.delimiter).filter(Boolean);
|
|
1613
|
+
if (parts.includes(dir)) {
|
|
1614
|
+
env.PATH = current;
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
env.PATH = [dir, ...parts].join(import_node_path10.delimiter);
|
|
1618
|
+
}
|
|
1619
|
+
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");
|
|
1621
|
+
}
|
|
1622
|
+
function isConductorBundledCli(filePath) {
|
|
1623
|
+
const p = (filePath ?? "").replace(/\\/g, "/");
|
|
1624
|
+
return p.includes("/com.conductor.app/bin/") || p.endsWith("/com.conductor.app/bin");
|
|
1625
|
+
}
|
|
1626
|
+
function ensureAgentPath(env = process.env) {
|
|
1627
|
+
const home = env.HOME || env.USERPROFILE || (0, import_node_os3.homedir)();
|
|
1628
|
+
const current = env.PATH ?? "";
|
|
1629
|
+
const parts = current.split(import_node_path10.delimiter).filter(Boolean);
|
|
1630
|
+
const seen = new Set(parts);
|
|
1631
|
+
const extras = [
|
|
1632
|
+
...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path10.join)(home, rel)),
|
|
1633
|
+
"/opt/homebrew/bin",
|
|
1634
|
+
"/usr/local/bin",
|
|
1635
|
+
// Keep after Homebrew/npm so a user-installed CLI still wins.
|
|
1636
|
+
conductorBundledBinDir(home)
|
|
1637
|
+
];
|
|
1638
|
+
for (const dir of extras.reverse()) {
|
|
1639
|
+
if (!dir || seen.has(dir) || !(0, import_node_fs10.existsSync)(dir)) continue;
|
|
1640
|
+
parts.unshift(dir);
|
|
1641
|
+
seen.add(dir);
|
|
1642
|
+
}
|
|
1643
|
+
const next = parts.join(import_node_path10.delimiter);
|
|
1644
|
+
env.PATH = next;
|
|
1645
|
+
return next;
|
|
1646
|
+
}
|
|
1647
|
+
function enrichPathWithNpmGlobalBin(env = process.env) {
|
|
1648
|
+
ensureAgentPath(env);
|
|
1649
|
+
try {
|
|
1650
|
+
const prefix = (0, import_node_child_process2.execFileSync)("npm", ["prefix", "-g"], {
|
|
1651
|
+
encoding: "utf8",
|
|
1652
|
+
env: { ...process.env, ...env },
|
|
1653
|
+
timeout: 8e3,
|
|
1654
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
1655
|
+
}).trim().split(/\r?\n/).find(Boolean);
|
|
1656
|
+
if (prefix) {
|
|
1657
|
+
const binDir = process.platform === "win32" ? prefix : (0, import_node_path10.join)(prefix, "bin");
|
|
1658
|
+
prependPathDir(env, binDir);
|
|
1659
|
+
}
|
|
1660
|
+
} catch {
|
|
1661
|
+
}
|
|
1662
|
+
return env.PATH ?? "";
|
|
1663
|
+
}
|
|
1664
|
+
function posixShellSingleQuote(value) {
|
|
1665
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
1666
|
+
}
|
|
1667
|
+
function resolveCommandBinarySync(command, whichPath) {
|
|
1668
|
+
const trimmed = command.trim();
|
|
1669
|
+
if (!trimmed) return trimmed;
|
|
1670
|
+
const match = /^(\S+)(\s[\s\S]*)?$/.exec(trimmed);
|
|
1671
|
+
if (!match) return trimmed;
|
|
1672
|
+
const bin = match[1];
|
|
1673
|
+
const rest = match[2] ?? "";
|
|
1674
|
+
if (bin.includes("/") || bin.includes("\\")) return trimmed;
|
|
1675
|
+
const abs = whichPath?.trim().split(/\r?\n/).find(Boolean);
|
|
1676
|
+
if (!abs) return trimmed;
|
|
1677
|
+
return `${abs}${rest}`;
|
|
1678
|
+
}
|
|
1679
|
+
function withExportedPath(command, pathValue) {
|
|
1680
|
+
const trimmed = command.trim();
|
|
1681
|
+
if (!trimmed) return trimmed;
|
|
1682
|
+
if (/^(export\s+PATH=|PATH=)/.test(trimmed)) return trimmed;
|
|
1683
|
+
return `export PATH=${posixShellSingleQuote(pathValue)} && ${trimmed}`;
|
|
1684
|
+
}
|
|
1685
|
+
var import_node_fs10, import_node_child_process2, import_node_os3, import_node_path10, EXTRA_BIN_DIRS;
|
|
1686
|
+
var init_path = __esm({
|
|
1687
|
+
"src/agents/path.ts"() {
|
|
1688
|
+
"use strict";
|
|
1689
|
+
import_node_fs10 = require("fs");
|
|
1690
|
+
import_node_child_process2 = require("child_process");
|
|
1691
|
+
import_node_os3 = require("os");
|
|
1692
|
+
import_node_path10 = require("path");
|
|
1693
|
+
EXTRA_BIN_DIRS = [
|
|
1694
|
+
".local/bin",
|
|
1695
|
+
".cargo/bin",
|
|
1696
|
+
".nvm/current/bin",
|
|
1697
|
+
".asdf/shims",
|
|
1698
|
+
".volta/bin",
|
|
1699
|
+
".npm-global/bin",
|
|
1700
|
+
// fnm default alias (common when shell init is skipped)
|
|
1701
|
+
".local/share/fnm/aliases/default/bin",
|
|
1702
|
+
// pnpm / npm global bins (where `@brightsy/cli` typically lands)
|
|
1703
|
+
"Library/pnpm",
|
|
1704
|
+
".pnpm"
|
|
1705
|
+
];
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1708
|
+
|
|
1709
|
+
// src/git/stale-lock.ts
|
|
1710
|
+
function isIndexLockError(text4) {
|
|
1711
|
+
return /Unable to create ['"][^'"]*index\.lock['"]: File exists/i.test(text4);
|
|
1712
|
+
}
|
|
1713
|
+
function clearStaleIndexLock(gitDir, maxAgeMs = STALE_INDEX_LOCK_MS, now = Date.now()) {
|
|
1714
|
+
const lockPath = (0, import_node_path11.join)(gitDir, "index.lock");
|
|
1715
|
+
try {
|
|
1716
|
+
if (!(0, import_node_fs11.existsSync)(lockPath)) return null;
|
|
1717
|
+
if (now - (0, import_node_fs11.statSync)(lockPath).mtimeMs < maxAgeMs) return null;
|
|
1718
|
+
(0, import_node_fs11.unlinkSync)(lockPath);
|
|
1719
|
+
return lockPath;
|
|
1720
|
+
} catch {
|
|
1721
|
+
return null;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
function clearStaleIndexLocks(gitDirs, maxAgeMs = STALE_INDEX_LOCK_MS) {
|
|
1725
|
+
const now = Date.now();
|
|
1726
|
+
const removed = [];
|
|
1727
|
+
for (const dir of new Set(gitDirs)) {
|
|
1728
|
+
const cleared = clearStaleIndexLock(dir, maxAgeMs, now);
|
|
1729
|
+
if (cleared) removed.push(cleared);
|
|
1730
|
+
}
|
|
1731
|
+
return removed;
|
|
1732
|
+
}
|
|
1733
|
+
var import_node_fs11, import_node_path11, STALE_INDEX_LOCK_MS;
|
|
1734
|
+
var init_stale_lock = __esm({
|
|
1735
|
+
"src/git/stale-lock.ts"() {
|
|
1736
|
+
"use strict";
|
|
1737
|
+
import_node_fs11 = require("fs");
|
|
1738
|
+
import_node_path11 = require("path");
|
|
1739
|
+
STALE_INDEX_LOCK_MS = 2e4;
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
|
|
1743
|
+
// src/git/run.ts
|
|
1744
|
+
var run_exports = {};
|
|
1745
|
+
__export(run_exports, {
|
|
1746
|
+
gh: () => gh,
|
|
1747
|
+
git: () => git,
|
|
1748
|
+
resolveGhAuthToken: () => resolveGhAuthToken,
|
|
1749
|
+
resolveGitDirsForLockRecovery: () => resolveGitDirsForLockRecovery,
|
|
1750
|
+
run: () => run
|
|
1751
|
+
});
|
|
1752
|
+
async function run(file, args, opts) {
|
|
1753
|
+
ensureAgentPath();
|
|
1754
|
+
try {
|
|
1755
|
+
const result = await (0, import_execa2.execa)(file, args, {
|
|
1756
|
+
cwd: opts?.cwd,
|
|
1757
|
+
env: { ...process.env, ...opts?.env },
|
|
1758
|
+
reject: opts?.reject ?? true,
|
|
1759
|
+
...opts?.timeoutMs != null ? { timeout: opts.timeoutMs } : {}
|
|
1760
|
+
});
|
|
1761
|
+
return {
|
|
1762
|
+
stdout: result.stdout ?? "",
|
|
1763
|
+
stderr: result.stderr ?? "",
|
|
1764
|
+
exitCode: result.exitCode ?? 0
|
|
1765
|
+
};
|
|
1766
|
+
} catch (err) {
|
|
1767
|
+
const e = err;
|
|
1768
|
+
if (opts?.reject === false) {
|
|
1769
|
+
return {
|
|
1770
|
+
stdout: String(e.stdout ?? ""),
|
|
1771
|
+
stderr: String(e.stderr ?? ""),
|
|
1772
|
+
exitCode: e.exitCode ?? 1
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
throw err;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
async function resolveGitDirsForLockRecovery(cwd, env = {}) {
|
|
1779
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
1780
|
+
const [gitDir, commonDir] = await Promise.all([
|
|
1781
|
+
run("git", ["rev-parse", "--absolute-git-dir"], { cwd, reject: false, env, timeoutMs: 5e3 }),
|
|
1782
|
+
run("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], {
|
|
1783
|
+
cwd,
|
|
1784
|
+
reject: false,
|
|
1785
|
+
env,
|
|
1786
|
+
timeoutMs: 5e3
|
|
1787
|
+
})
|
|
1788
|
+
]);
|
|
1789
|
+
if (gitDir.exitCode === 0 && gitDir.stdout.trim()) dirs.add(gitDir.stdout.trim());
|
|
1790
|
+
if (commonDir.exitCode === 0 && commonDir.stdout.trim()) dirs.add(commonDir.stdout.trim());
|
|
1791
|
+
return [...dirs];
|
|
1792
|
+
}
|
|
1793
|
+
async function git(args, cwd, opts) {
|
|
1794
|
+
const prefix = [];
|
|
1795
|
+
if (opts?.config) {
|
|
1796
|
+
for (const [key, value] of Object.entries(opts.config)) {
|
|
1797
|
+
if (!key) continue;
|
|
1798
|
+
prefix.push("-c", `${key}=${value}`);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
const gitArgs = ["--no-pager", ...prefix, ...args];
|
|
1802
|
+
const env = {
|
|
1803
|
+
// Never block forever on a credential/SSH prompt inside MCP / Electron.
|
|
1804
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
1805
|
+
GIT_ASKPASS: process.env.GIT_ASKPASS || "echo",
|
|
1806
|
+
SSH_ASKPASS: process.env.SSH_ASKPASS || "echo",
|
|
1807
|
+
GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND || "ssh -o BatchMode=yes -o ConnectTimeout=15",
|
|
1808
|
+
GCM_INTERACTIVE: "never",
|
|
1809
|
+
GH_PROMPT_DISABLED: "1",
|
|
1810
|
+
...opts?.env
|
|
1811
|
+
};
|
|
1812
|
+
let result = await run("git", gitArgs, { cwd, reject: false, timeoutMs: opts?.timeoutMs, env });
|
|
1813
|
+
if (result.exitCode !== 0 && isIndexLockError(result.stderr)) {
|
|
1814
|
+
const gitDirs = await resolveGitDirsForLockRecovery(cwd, env);
|
|
1815
|
+
const cleared = clearStaleIndexLocks(gitDirs);
|
|
1816
|
+
if (cleared.length > 0) {
|
|
1817
|
+
result = await run("git", gitArgs, { cwd, reject: false, timeoutMs: opts?.timeoutMs, env });
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
if ((opts?.reject ?? true) && result.exitCode !== 0) {
|
|
1821
|
+
throw new Error(
|
|
1822
|
+
`Command failed with exit code ${result.exitCode}: git ${gitArgs.join(" ")}
|
|
1823
|
+
${result.stderr}`
|
|
1824
|
+
);
|
|
1825
|
+
}
|
|
1826
|
+
return result;
|
|
1827
|
+
}
|
|
1828
|
+
async function gh(args, cwd, opts) {
|
|
1829
|
+
return run("gh", args, {
|
|
1830
|
+
cwd,
|
|
1831
|
+
reject: opts?.reject,
|
|
1832
|
+
timeoutMs: opts?.timeoutMs,
|
|
1833
|
+
env: {
|
|
1834
|
+
GH_PROMPT_DISABLED: "1",
|
|
1835
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
1836
|
+
}
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
async function resolveGhAuthToken(cwd) {
|
|
1840
|
+
const result = await gh(["auth", "token"], cwd, { reject: false, timeoutMs: 8e3 });
|
|
1841
|
+
if (result.exitCode !== 0) return null;
|
|
1842
|
+
const token = result.stdout.trim();
|
|
1843
|
+
return token || null;
|
|
1844
|
+
}
|
|
1845
|
+
var import_execa2;
|
|
1846
|
+
var init_run = __esm({
|
|
1847
|
+
"src/git/run.ts"() {
|
|
1848
|
+
"use strict";
|
|
1849
|
+
import_execa2 = require("execa");
|
|
1850
|
+
init_path();
|
|
1851
|
+
init_stale_lock();
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
|
|
1607
1855
|
// src/git/team-meta.ts
|
|
1608
1856
|
var SOCCER_TEAM_META;
|
|
1609
1857
|
var init_team_meta = __esm({
|
|
@@ -2505,7 +2753,7 @@ var init_gh_errors = __esm({
|
|
|
2505
2753
|
|
|
2506
2754
|
// src/store/secret-vault.ts
|
|
2507
2755
|
function secretVaultPath() {
|
|
2508
|
-
return (0,
|
|
2756
|
+
return (0, import_node_path12.join)(appDataDir(), "secrets.json");
|
|
2509
2757
|
}
|
|
2510
2758
|
function loadSecretVault() {
|
|
2511
2759
|
const parsed = readSecureJson(secretVaultPath());
|
|
@@ -2549,11 +2797,11 @@ function normalizeVault(raw) {
|
|
|
2549
2797
|
}
|
|
2550
2798
|
return out;
|
|
2551
2799
|
}
|
|
2552
|
-
var
|
|
2800
|
+
var import_node_path12;
|
|
2553
2801
|
var init_secret_vault = __esm({
|
|
2554
2802
|
"src/store/secret-vault.ts"() {
|
|
2555
2803
|
"use strict";
|
|
2556
|
-
|
|
2804
|
+
import_node_path12 = require("path");
|
|
2557
2805
|
init_paths();
|
|
2558
2806
|
init_secure_file();
|
|
2559
2807
|
}
|
|
@@ -2656,10 +2904,10 @@ function toPublicAppSettings(settings) {
|
|
|
2656
2904
|
};
|
|
2657
2905
|
}
|
|
2658
2906
|
function appSettingsPath() {
|
|
2659
|
-
return (0,
|
|
2907
|
+
return (0, import_node_path13.join)(appDataDir(), "settings.json");
|
|
2660
2908
|
}
|
|
2661
2909
|
function claudeUserSettingsPath() {
|
|
2662
|
-
return (0,
|
|
2910
|
+
return (0, import_node_path13.join)((0, import_node_os4.homedir)(), ".claude", "settings.json");
|
|
2663
2911
|
}
|
|
2664
2912
|
function normalizeClaude(raw) {
|
|
2665
2913
|
if (!raw || typeof raw !== "object") return {};
|
|
@@ -2908,10 +3156,10 @@ function normalizeSettings(raw) {
|
|
|
2908
3156
|
}
|
|
2909
3157
|
function readSettingsFile() {
|
|
2910
3158
|
const path = appSettingsPath();
|
|
2911
|
-
if (!(0,
|
|
3159
|
+
if (!(0, import_node_fs12.existsSync)(path)) return { ...EMPTY_SETTINGS };
|
|
2912
3160
|
try {
|
|
2913
3161
|
chmodOwnerOnly(path);
|
|
2914
|
-
const parsed = JSON.parse((0,
|
|
3162
|
+
const parsed = JSON.parse((0, import_node_fs12.readFileSync)(path, "utf8"));
|
|
2915
3163
|
return normalizeSettings(parsed);
|
|
2916
3164
|
} catch {
|
|
2917
3165
|
return { ...EMPTY_SETTINGS };
|
|
@@ -3296,7 +3544,7 @@ function ensureSlackDeviceIdentity(settings = loadAppSettings()) {
|
|
|
3296
3544
|
}
|
|
3297
3545
|
if (!deviceLabel) {
|
|
3298
3546
|
try {
|
|
3299
|
-
deviceLabel = (0,
|
|
3547
|
+
deviceLabel = (0, import_node_os4.hostname)().split(".")[0]?.trim() || "This Mac";
|
|
3300
3548
|
} catch {
|
|
3301
3549
|
deviceLabel = "This Mac";
|
|
3302
3550
|
}
|
|
@@ -3483,14 +3731,14 @@ function childEnvWithAppSettings(extra) {
|
|
|
3483
3731
|
function harnessEnvKey(harness) {
|
|
3484
3732
|
return HARNESS_ENV_KEYS[harness];
|
|
3485
3733
|
}
|
|
3486
|
-
var import_node_crypto3,
|
|
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;
|
|
3487
3735
|
var init_app_settings = __esm({
|
|
3488
3736
|
"src/store/app-settings.ts"() {
|
|
3489
3737
|
"use strict";
|
|
3490
3738
|
import_node_crypto3 = require("crypto");
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3739
|
+
import_node_fs12 = require("fs");
|
|
3740
|
+
import_node_os4 = require("os");
|
|
3741
|
+
import_node_path13 = require("path");
|
|
3494
3742
|
init_thinking_effort();
|
|
3495
3743
|
init_nested_electron_env();
|
|
3496
3744
|
init_paths();
|
|
@@ -3542,23 +3790,23 @@ var init_app_settings = __esm({
|
|
|
3542
3790
|
function githubAgentAuthDir() {
|
|
3543
3791
|
const override = process.env.SIDEBOARD_GIT_AUTH_DIR?.trim();
|
|
3544
3792
|
if (override) return override;
|
|
3545
|
-
return (0,
|
|
3793
|
+
return (0, import_node_path14.join)((0, import_node_os5.homedir)(), ".sideboard-git-auth");
|
|
3546
3794
|
}
|
|
3547
3795
|
function githubCredentialStorePath() {
|
|
3548
|
-
return (0,
|
|
3796
|
+
return (0, import_node_path14.join)(githubAgentAuthDir(), "git-credentials");
|
|
3549
3797
|
}
|
|
3550
3798
|
function githubGhConfigDir() {
|
|
3551
|
-
return (0,
|
|
3799
|
+
return (0, import_node_path14.join)(githubAgentAuthDir(), "gh");
|
|
3552
3800
|
}
|
|
3553
3801
|
function writePrivateFile2(file, body) {
|
|
3554
|
-
(0,
|
|
3802
|
+
(0, import_node_fs13.mkdirSync)((0, import_node_path14.dirname)(file), { recursive: true, mode: 448 });
|
|
3555
3803
|
try {
|
|
3556
|
-
(0,
|
|
3804
|
+
(0, import_node_fs13.chmodSync)((0, import_node_path14.dirname)(file), 448);
|
|
3557
3805
|
} catch {
|
|
3558
3806
|
}
|
|
3559
|
-
(0,
|
|
3807
|
+
(0, import_node_fs13.writeFileSync)(file, body, { encoding: "utf8", mode: 384 });
|
|
3560
3808
|
try {
|
|
3561
|
-
(0,
|
|
3809
|
+
(0, import_node_fs13.chmodSync)(file, 384);
|
|
3562
3810
|
} catch {
|
|
3563
3811
|
}
|
|
3564
3812
|
}
|
|
@@ -3582,226 +3830,41 @@ function ghHostsYml(token, user = "x-access-token") {
|
|
|
3582
3830
|
function materializeGithubAgentAuth(token, user) {
|
|
3583
3831
|
const trimmed = token.trim();
|
|
3584
3832
|
if (!trimmed) return;
|
|
3585
|
-
const root = githubAgentAuthDir();
|
|
3586
|
-
(0,
|
|
3587
|
-
try {
|
|
3588
|
-
(0,
|
|
3589
|
-
} catch {
|
|
3590
|
-
}
|
|
3591
|
-
writePrivateFile2(githubCredentialStorePath(), gitCredentialStoreContents(trimmed));
|
|
3592
|
-
const ghDir = githubGhConfigDir();
|
|
3593
|
-
(0, import_node_fs11.mkdirSync)(ghDir, { recursive: true, mode: 448 });
|
|
3594
|
-
writePrivateFile2((0, import_node_path12.join)(ghDir, "hosts.yml"), ghHostsYml(trimmed, user));
|
|
3595
|
-
writePrivateFile2((0, import_node_path12.join)(ghDir, "config.yml"), "git_protocol: https\nprompt: disabled\n");
|
|
3596
|
-
}
|
|
3597
|
-
function githubAgentAuthReady() {
|
|
3598
|
-
return (0, import_node_fs11.existsSync)(githubCredentialStorePath()) && (0, import_node_fs11.existsSync)((0, import_node_path12.join)(githubGhConfigDir(), "hosts.yml"));
|
|
3599
|
-
}
|
|
3600
|
-
function githubCredentialHelperGitConfig() {
|
|
3601
|
-
const file = githubCredentialStorePath();
|
|
3602
|
-
return [
|
|
3603
|
-
{ key: "credential.helper", value: "" },
|
|
3604
|
-
{ key: "credential.helper", value: `store --file=${file}` }
|
|
3605
|
-
];
|
|
3606
|
-
}
|
|
3607
|
-
function githubGhConfigEnv() {
|
|
3608
|
-
return {
|
|
3609
|
-
GH_CONFIG_DIR: githubGhConfigDir(),
|
|
3610
|
-
GH_PROMPT_DISABLED: "1"
|
|
3611
|
-
};
|
|
3612
|
-
}
|
|
3613
|
-
var import_node_fs11, import_node_os4, import_node_path12;
|
|
3614
|
-
var init_github_agent_auth = __esm({
|
|
3615
|
-
"src/git/github-agent-auth.ts"() {
|
|
3616
|
-
"use strict";
|
|
3617
|
-
import_node_fs11 = require("fs");
|
|
3618
|
-
import_node_os4 = require("os");
|
|
3619
|
-
import_node_path12 = require("path");
|
|
3620
|
-
}
|
|
3621
|
-
});
|
|
3622
|
-
|
|
3623
|
-
// src/agents/path.ts
|
|
3624
|
-
function prependPathDir(env, dir) {
|
|
3625
|
-
if (!dir || !(0, import_node_fs12.existsSync)(dir)) return;
|
|
3626
|
-
const current = env.PATH ?? "";
|
|
3627
|
-
const parts = current.split(import_node_path13.delimiter).filter(Boolean);
|
|
3628
|
-
if (parts.includes(dir)) {
|
|
3629
|
-
env.PATH = current;
|
|
3630
|
-
return;
|
|
3631
|
-
}
|
|
3632
|
-
env.PATH = [dir, ...parts].join(import_node_path13.delimiter);
|
|
3633
|
-
}
|
|
3634
|
-
function conductorBundledBinDir(home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os5.homedir)()) {
|
|
3635
|
-
return (0, import_node_path13.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
|
|
3636
|
-
}
|
|
3637
|
-
function isConductorBundledCli(filePath) {
|
|
3638
|
-
const p = (filePath ?? "").replace(/\\/g, "/");
|
|
3639
|
-
return p.includes("/com.conductor.app/bin/") || p.endsWith("/com.conductor.app/bin");
|
|
3640
|
-
}
|
|
3641
|
-
function ensureAgentPath(env = process.env) {
|
|
3642
|
-
const home = env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)();
|
|
3643
|
-
const current = env.PATH ?? "";
|
|
3644
|
-
const parts = current.split(import_node_path13.delimiter).filter(Boolean);
|
|
3645
|
-
const seen = new Set(parts);
|
|
3646
|
-
const extras = [
|
|
3647
|
-
...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path13.join)(home, rel)),
|
|
3648
|
-
"/opt/homebrew/bin",
|
|
3649
|
-
"/usr/local/bin",
|
|
3650
|
-
// Keep after Homebrew/npm so a user-installed CLI still wins.
|
|
3651
|
-
conductorBundledBinDir(home)
|
|
3652
|
-
];
|
|
3653
|
-
for (const dir of extras.reverse()) {
|
|
3654
|
-
if (!dir || seen.has(dir) || !(0, import_node_fs12.existsSync)(dir)) continue;
|
|
3655
|
-
parts.unshift(dir);
|
|
3656
|
-
seen.add(dir);
|
|
3657
|
-
}
|
|
3658
|
-
const next = parts.join(import_node_path13.delimiter);
|
|
3659
|
-
env.PATH = next;
|
|
3660
|
-
return next;
|
|
3661
|
-
}
|
|
3662
|
-
function enrichPathWithNpmGlobalBin(env = process.env) {
|
|
3663
|
-
ensureAgentPath(env);
|
|
3664
|
-
try {
|
|
3665
|
-
const prefix = (0, import_node_child_process2.execFileSync)("npm", ["prefix", "-g"], {
|
|
3666
|
-
encoding: "utf8",
|
|
3667
|
-
env: { ...process.env, ...env },
|
|
3668
|
-
timeout: 8e3,
|
|
3669
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
3670
|
-
}).trim().split(/\r?\n/).find(Boolean);
|
|
3671
|
-
if (prefix) {
|
|
3672
|
-
const binDir = process.platform === "win32" ? prefix : (0, import_node_path13.join)(prefix, "bin");
|
|
3673
|
-
prependPathDir(env, binDir);
|
|
3674
|
-
}
|
|
3675
|
-
} catch {
|
|
3676
|
-
}
|
|
3677
|
-
return env.PATH ?? "";
|
|
3678
|
-
}
|
|
3679
|
-
function posixShellSingleQuote(value) {
|
|
3680
|
-
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
3681
|
-
}
|
|
3682
|
-
function resolveCommandBinarySync(command, whichPath) {
|
|
3683
|
-
const trimmed = command.trim();
|
|
3684
|
-
if (!trimmed) return trimmed;
|
|
3685
|
-
const match = /^(\S+)(\s[\s\S]*)?$/.exec(trimmed);
|
|
3686
|
-
if (!match) return trimmed;
|
|
3687
|
-
const bin = match[1];
|
|
3688
|
-
const rest = match[2] ?? "";
|
|
3689
|
-
if (bin.includes("/") || bin.includes("\\")) return trimmed;
|
|
3690
|
-
const abs = whichPath?.trim().split(/\r?\n/).find(Boolean);
|
|
3691
|
-
if (!abs) return trimmed;
|
|
3692
|
-
return `${abs}${rest}`;
|
|
3693
|
-
}
|
|
3694
|
-
function withExportedPath(command, pathValue) {
|
|
3695
|
-
const trimmed = command.trim();
|
|
3696
|
-
if (!trimmed) return trimmed;
|
|
3697
|
-
if (/^(export\s+PATH=|PATH=)/.test(trimmed)) return trimmed;
|
|
3698
|
-
return `export PATH=${posixShellSingleQuote(pathValue)} && ${trimmed}`;
|
|
3699
|
-
}
|
|
3700
|
-
var import_node_fs12, import_node_child_process2, import_node_os5, import_node_path13, EXTRA_BIN_DIRS;
|
|
3701
|
-
var init_path = __esm({
|
|
3702
|
-
"src/agents/path.ts"() {
|
|
3703
|
-
"use strict";
|
|
3704
|
-
import_node_fs12 = require("fs");
|
|
3705
|
-
import_node_child_process2 = require("child_process");
|
|
3706
|
-
import_node_os5 = require("os");
|
|
3707
|
-
import_node_path13 = require("path");
|
|
3708
|
-
EXTRA_BIN_DIRS = [
|
|
3709
|
-
".local/bin",
|
|
3710
|
-
".cargo/bin",
|
|
3711
|
-
".nvm/current/bin",
|
|
3712
|
-
".asdf/shims",
|
|
3713
|
-
".volta/bin",
|
|
3714
|
-
".npm-global/bin",
|
|
3715
|
-
// fnm default alias (common when shell init is skipped)
|
|
3716
|
-
".local/share/fnm/aliases/default/bin",
|
|
3717
|
-
// pnpm / npm global bins (where `@brightsy/cli` typically lands)
|
|
3718
|
-
"Library/pnpm",
|
|
3719
|
-
".pnpm"
|
|
3720
|
-
];
|
|
3721
|
-
}
|
|
3722
|
-
});
|
|
3723
|
-
|
|
3724
|
-
// src/git/run.ts
|
|
3725
|
-
var run_exports = {};
|
|
3726
|
-
__export(run_exports, {
|
|
3727
|
-
gh: () => gh,
|
|
3728
|
-
git: () => git,
|
|
3729
|
-
resolveGhAuthToken: () => resolveGhAuthToken,
|
|
3730
|
-
run: () => run
|
|
3731
|
-
});
|
|
3732
|
-
async function run(file, args, opts) {
|
|
3733
|
-
ensureAgentPath();
|
|
3734
|
-
try {
|
|
3735
|
-
const result = await (0, import_execa2.execa)(file, args, {
|
|
3736
|
-
cwd: opts?.cwd,
|
|
3737
|
-
env: { ...process.env, ...opts?.env },
|
|
3738
|
-
reject: opts?.reject ?? true,
|
|
3739
|
-
...opts?.timeoutMs != null ? { timeout: opts.timeoutMs } : {}
|
|
3740
|
-
});
|
|
3741
|
-
return {
|
|
3742
|
-
stdout: result.stdout ?? "",
|
|
3743
|
-
stderr: result.stderr ?? "",
|
|
3744
|
-
exitCode: result.exitCode ?? 0
|
|
3745
|
-
};
|
|
3746
|
-
} catch (err) {
|
|
3747
|
-
const e = err;
|
|
3748
|
-
if (opts?.reject === false) {
|
|
3749
|
-
return {
|
|
3750
|
-
stdout: String(e.stdout ?? ""),
|
|
3751
|
-
stderr: String(e.stderr ?? ""),
|
|
3752
|
-
exitCode: e.exitCode ?? 1
|
|
3753
|
-
};
|
|
3754
|
-
}
|
|
3755
|
-
throw err;
|
|
3833
|
+
const root = githubAgentAuthDir();
|
|
3834
|
+
(0, import_node_fs13.mkdirSync)(root, { recursive: true, mode: 448 });
|
|
3835
|
+
try {
|
|
3836
|
+
(0, import_node_fs13.chmodSync)(root, 448);
|
|
3837
|
+
} catch {
|
|
3756
3838
|
}
|
|
3839
|
+
writePrivateFile2(githubCredentialStorePath(), gitCredentialStoreContents(trimmed));
|
|
3840
|
+
const ghDir = githubGhConfigDir();
|
|
3841
|
+
(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");
|
|
3757
3844
|
}
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
if (opts?.config) {
|
|
3761
|
-
for (const [key, value] of Object.entries(opts.config)) {
|
|
3762
|
-
if (!key) continue;
|
|
3763
|
-
prefix.push("-c", `${key}=${value}`);
|
|
3764
|
-
}
|
|
3765
|
-
}
|
|
3766
|
-
return run("git", ["--no-pager", ...prefix, ...args], {
|
|
3767
|
-
cwd,
|
|
3768
|
-
reject: opts?.reject,
|
|
3769
|
-
timeoutMs: opts?.timeoutMs,
|
|
3770
|
-
// Never block forever on a credential/SSH prompt inside MCP / Electron.
|
|
3771
|
-
env: {
|
|
3772
|
-
GIT_TERMINAL_PROMPT: "0",
|
|
3773
|
-
GIT_ASKPASS: process.env.GIT_ASKPASS || "echo",
|
|
3774
|
-
SSH_ASKPASS: process.env.SSH_ASKPASS || "echo",
|
|
3775
|
-
GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND || "ssh -o BatchMode=yes -o ConnectTimeout=15",
|
|
3776
|
-
GCM_INTERACTIVE: "never",
|
|
3777
|
-
GH_PROMPT_DISABLED: "1",
|
|
3778
|
-
...opts?.env
|
|
3779
|
-
}
|
|
3780
|
-
});
|
|
3845
|
+
function githubAgentAuthReady() {
|
|
3846
|
+
return (0, import_node_fs13.existsSync)(githubCredentialStorePath()) && (0, import_node_fs13.existsSync)((0, import_node_path14.join)(githubGhConfigDir(), "hosts.yml"));
|
|
3781
3847
|
}
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
GH_PROMPT_DISABLED: "1",
|
|
3789
|
-
GIT_TERMINAL_PROMPT: "0"
|
|
3790
|
-
}
|
|
3791
|
-
});
|
|
3848
|
+
function githubCredentialHelperGitConfig() {
|
|
3849
|
+
const file = githubCredentialStorePath();
|
|
3850
|
+
return [
|
|
3851
|
+
{ key: "credential.helper", value: "" },
|
|
3852
|
+
{ key: "credential.helper", value: `store --file=${file}` }
|
|
3853
|
+
];
|
|
3792
3854
|
}
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3855
|
+
function githubGhConfigEnv() {
|
|
3856
|
+
return {
|
|
3857
|
+
GH_CONFIG_DIR: githubGhConfigDir(),
|
|
3858
|
+
GH_PROMPT_DISABLED: "1"
|
|
3859
|
+
};
|
|
3798
3860
|
}
|
|
3799
|
-
var
|
|
3800
|
-
var
|
|
3801
|
-
"src/git/
|
|
3861
|
+
var import_node_fs13, import_node_os5, import_node_path14;
|
|
3862
|
+
var init_github_agent_auth = __esm({
|
|
3863
|
+
"src/git/github-agent-auth.ts"() {
|
|
3802
3864
|
"use strict";
|
|
3803
|
-
|
|
3804
|
-
|
|
3865
|
+
import_node_fs13 = require("fs");
|
|
3866
|
+
import_node_os5 = require("os");
|
|
3867
|
+
import_node_path14 = require("path");
|
|
3805
3868
|
}
|
|
3806
3869
|
});
|
|
3807
3870
|
|
|
@@ -3893,7 +3956,7 @@ async function warmGithubAgentAuth(opts) {
|
|
|
3893
3956
|
}
|
|
3894
3957
|
function normalizeWritableRoot(raw) {
|
|
3895
3958
|
const trimmed = raw.trim().replace(/\/+$/, "");
|
|
3896
|
-
return trimmed && (0,
|
|
3959
|
+
return trimmed && (0, import_node_path15.isAbsolute)(trimmed) ? trimmed : null;
|
|
3897
3960
|
}
|
|
3898
3961
|
async function resolveCodexGitWritableRoots(cwd) {
|
|
3899
3962
|
const roots = /* @__PURE__ */ new Set();
|
|
@@ -3970,11 +4033,11 @@ function formatGitAuthModeDirective(mode) {
|
|
|
3970
4033
|
].join("\n");
|
|
3971
4034
|
}
|
|
3972
4035
|
}
|
|
3973
|
-
var
|
|
4036
|
+
var import_node_path15, HTTPS_REWRITE, TOKEN_TTL_MS, tokenMemo, GITHUB_CHILD_TOKEN_KEYS;
|
|
3974
4037
|
var init_git_auth_mode = __esm({
|
|
3975
4038
|
"src/git/git-auth-mode.ts"() {
|
|
3976
4039
|
"use strict";
|
|
3977
|
-
|
|
4040
|
+
import_node_path15 = require("path");
|
|
3978
4041
|
init_app_settings();
|
|
3979
4042
|
init_github_agent_auth();
|
|
3980
4043
|
init_run();
|
|
@@ -5144,8 +5207,8 @@ function isLocalPrFetchBranch(ref) {
|
|
|
5144
5207
|
}
|
|
5145
5208
|
async function createThreadWorktree(opts) {
|
|
5146
5209
|
let branchName = `thread/${opts.slug}`;
|
|
5147
|
-
const worktreePath = (0,
|
|
5148
|
-
if ((0,
|
|
5210
|
+
const worktreePath = (0, import_node_path16.join)(worktreesRoot(opts.repoPath), opts.slug);
|
|
5211
|
+
if ((0, import_node_fs14.existsSync)(worktreePath)) {
|
|
5149
5212
|
throw new Error(`Worktree already exists at ${worktreePath}`);
|
|
5150
5213
|
}
|
|
5151
5214
|
await ensureGhPreferOrigin(opts.repoPath);
|
|
@@ -5212,8 +5275,8 @@ ${add.stdout}`;
|
|
|
5212
5275
|
async function createExistingBranchWorktree(opts) {
|
|
5213
5276
|
const branchName = opts.branchName.trim();
|
|
5214
5277
|
if (!branchName) throw new Error("branch name required");
|
|
5215
|
-
const worktreePath = (0,
|
|
5216
|
-
if ((0,
|
|
5278
|
+
const worktreePath = (0, import_node_path16.join)(worktreesRoot(opts.repoPath), opts.slug);
|
|
5279
|
+
if ((0, import_node_fs14.existsSync)(worktreePath)) {
|
|
5217
5280
|
throw new Error(`Worktree already exists at ${worktreePath}`);
|
|
5218
5281
|
}
|
|
5219
5282
|
await ensureGhPreferOrigin(opts.repoPath);
|
|
@@ -5504,10 +5567,10 @@ function sameRepoPath(a, b) {
|
|
|
5504
5567
|
return normalizeWorktreePath(a) === normalizeWorktreePath(b);
|
|
5505
5568
|
}
|
|
5506
5569
|
function listLocalThreadBranchSlugs(repoPath) {
|
|
5507
|
-
const refsDir = (0,
|
|
5508
|
-
if (!(0,
|
|
5570
|
+
const refsDir = (0, import_node_path16.join)(repoPath, ".git", "refs", "heads", "thread");
|
|
5571
|
+
if (!(0, import_node_fs14.existsSync)(refsDir)) return [];
|
|
5509
5572
|
try {
|
|
5510
|
-
return (0,
|
|
5573
|
+
return (0, import_node_fs14.readdirSync)(refsDir).filter((name) => !name.startsWith(".")).map((name) => normalizeTakenSlug(name));
|
|
5511
5574
|
} catch {
|
|
5512
5575
|
return [];
|
|
5513
5576
|
}
|
|
@@ -5515,8 +5578,8 @@ function listLocalThreadBranchSlugs(repoPath) {
|
|
|
5515
5578
|
function collectTakenTeamSlugs(repoPath) {
|
|
5516
5579
|
const taken = /* @__PURE__ */ new Set();
|
|
5517
5580
|
const root = worktreesRoot(repoPath);
|
|
5518
|
-
if ((0,
|
|
5519
|
-
for (const entry of (0,
|
|
5581
|
+
if ((0, import_node_fs14.existsSync)(root)) {
|
|
5582
|
+
for (const entry of (0, import_node_fs14.readdirSync)(root, { withFileTypes: true })) {
|
|
5520
5583
|
if (entry.isDirectory() && entry.name !== ".DS_Store") {
|
|
5521
5584
|
taken.add(normalizeTakenSlug(entry.name));
|
|
5522
5585
|
}
|
|
@@ -5537,18 +5600,18 @@ function allocateTeamSlug(repoPath) {
|
|
|
5537
5600
|
const taken = collectTakenTeamSlugs(repoPath);
|
|
5538
5601
|
for (let attempt = 0; attempt < 32; attempt++) {
|
|
5539
5602
|
const team = allocateTeamName(taken);
|
|
5540
|
-
const path = (0,
|
|
5541
|
-
if (!(0,
|
|
5603
|
+
const path = (0, import_node_path16.join)(worktreesRoot(repoPath), team.slug);
|
|
5604
|
+
if (!(0, import_node_fs14.existsSync)(path)) return team;
|
|
5542
5605
|
taken.add(team.slug);
|
|
5543
5606
|
}
|
|
5544
5607
|
throw new Error("No available soccer team worktree directories left");
|
|
5545
5608
|
}
|
|
5546
|
-
var
|
|
5609
|
+
var import_node_fs14, import_node_path16;
|
|
5547
5610
|
var init_worktree = __esm({
|
|
5548
5611
|
"src/git/worktree.ts"() {
|
|
5549
5612
|
"use strict";
|
|
5550
|
-
|
|
5551
|
-
|
|
5613
|
+
import_node_fs14 = require("fs");
|
|
5614
|
+
import_node_path16 = require("path");
|
|
5552
5615
|
init_paths();
|
|
5553
5616
|
init_thread_store();
|
|
5554
5617
|
init_teams();
|
|
@@ -5683,7 +5746,7 @@ function coordinatorTurnReminder(opts) {
|
|
|
5683
5746
|
function ensureGlobalCoordinatorCwd(opts) {
|
|
5684
5747
|
const dir = globalAgentCwd();
|
|
5685
5748
|
try {
|
|
5686
|
-
(0,
|
|
5749
|
+
(0, import_node_fs15.mkdirSync)(dir, { recursive: true });
|
|
5687
5750
|
} catch {
|
|
5688
5751
|
return dir;
|
|
5689
5752
|
}
|
|
@@ -5691,7 +5754,7 @@ function ensureGlobalCoordinatorCwd(opts) {
|
|
|
5691
5754
|
let orchId = opts?.orchestratorThreadId?.trim() || "";
|
|
5692
5755
|
if (!orchId) {
|
|
5693
5756
|
try {
|
|
5694
|
-
const existing = (0,
|
|
5757
|
+
const existing = (0, import_node_fs15.readFileSync)((0, import_node_path17.join)(dir, "AGENTS.md"), "utf8");
|
|
5695
5758
|
const m = existing.match(
|
|
5696
5759
|
/YOUR orchestration thread id is `([0-9a-f-]{36})`/i
|
|
5697
5760
|
);
|
|
@@ -5733,9 +5796,9 @@ function ensureGlobalCoordinatorCwd(opts) {
|
|
|
5733
5796
|
"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."
|
|
5734
5797
|
].join("\n");
|
|
5735
5798
|
try {
|
|
5736
|
-
(0,
|
|
5799
|
+
(0, import_node_fs15.writeFileSync)((0, import_node_path17.join)(dir, "CLAUDE.md"), `${body}
|
|
5737
5800
|
`, "utf8");
|
|
5738
|
-
(0,
|
|
5801
|
+
(0, import_node_fs15.writeFileSync)((0, import_node_path17.join)(dir, "AGENTS.md"), `${body}
|
|
5739
5802
|
`, "utf8");
|
|
5740
5803
|
} catch {
|
|
5741
5804
|
}
|
|
@@ -5767,12 +5830,12 @@ function coordinatorSystemPrompt(opts) {
|
|
|
5767
5830
|
formatWorkspaceInventory(opts.workspaces)
|
|
5768
5831
|
].join("\n");
|
|
5769
5832
|
}
|
|
5770
|
-
var
|
|
5833
|
+
var import_node_fs15, import_node_path17, COORDINATOR_TOOL_PLAYBOOK, SLACK_REPLY_FORMATTING;
|
|
5771
5834
|
var init_coordinator_prompt = __esm({
|
|
5772
5835
|
"src/orchestrator/coordinator-prompt.ts"() {
|
|
5773
5836
|
"use strict";
|
|
5774
|
-
|
|
5775
|
-
|
|
5837
|
+
import_node_fs15 = require("fs");
|
|
5838
|
+
import_node_path17 = require("path");
|
|
5776
5839
|
init_worktree();
|
|
5777
5840
|
init_app_settings();
|
|
5778
5841
|
init_paths();
|
|
@@ -5798,7 +5861,7 @@ var init_coordinator_prompt = __esm({
|
|
|
5798
5861
|
"- fork_worktree \u2014 fork a worktree chat into a NEW git worktree + chat (transcript attached); optional agent; leave model unset (Auto) unless you have a reason. Not for orchestration chats.",
|
|
5799
5862
|
"- fork_chat \u2014 fork a worktree chat (same worktree tab) OR a Global orchestration chat (new orchestration tab); optional agent; leave model unset (Auto) unless you have a reason. Remote coordinators: use this to continue another orchestration chat on a different agent after session limits.",
|
|
5800
5863
|
"- send_to_thread \u2014 queue a prompt (start/continue a chat turn); pass force_stop: true to interrupt mid-turn / clear stale queued prompts before replacing with a new request",
|
|
5801
|
-
"- wait_for_turn / get_turn_result \u2014 wait for and read the agent reply. wait_for_turn returns within ~45s even if the child is still working (MCP clients kill longer tool calls). If stillRunning is true, progress is a live snapshot of tools/thinking \u2014 call wait_for_turn again. Do not send \u201Care you stuck?\u201D or assume a hang while lastActivityAt is recent. On status error, lastError (and text) is the failure \u2014 switch agent, tell the user, or retry; do not treat empty text as success.",
|
|
5864
|
+
"- wait_for_turn / get_turn_result \u2014 wait for and read the agent reply. wait_for_turn returns within ~45s even if the child is still working (MCP clients kill longer tool calls). If stillRunning is true, progress is a live snapshot of tools/thinking \u2014 call wait_for_turn again. status=queued with no lastActivityAt means the child has not started yet (concurrency cap) \u2014 keep waiting; do not force_stop or send a check-in. Do not send \u201Care you stuck?\u201D or assume a hang while lastActivityAt is recent. On status error, lastError (and text) is the failure \u2014 switch agent, tell the user, or retry; do not treat empty text as success.",
|
|
5802
5865
|
"- stop_thread \u2014 force-stop: kill in-flight turn AND clear queued prompts (do not leave stale queue after an interrupt)",
|
|
5803
5866
|
"- archive_thread / restore_thread \u2014 archive (tears down worktree when last tab) or restore",
|
|
5804
5867
|
"Setup / run:",
|
|
@@ -6070,32 +6133,32 @@ var init_global_workspace = __esm({
|
|
|
6070
6133
|
|
|
6071
6134
|
// src/brightsy/config.ts
|
|
6072
6135
|
function brightsyConfigPath() {
|
|
6073
|
-
return (0,
|
|
6136
|
+
return (0, import_node_path18.join)((0, import_node_os6.homedir)(), ".brightsy", "config.json");
|
|
6074
6137
|
}
|
|
6075
6138
|
function loadBrightsyConfig() {
|
|
6076
6139
|
const path = brightsyConfigPath();
|
|
6077
|
-
if (!(0,
|
|
6140
|
+
if (!(0, import_node_fs16.existsSync)(path)) {
|
|
6078
6141
|
throw new Error("Brightsy not logged in \u2014 run `brightsy login` first");
|
|
6079
6142
|
}
|
|
6080
|
-
const raw = JSON.parse((0,
|
|
6143
|
+
const raw = JSON.parse((0, import_node_fs16.readFileSync)(path, "utf8"));
|
|
6081
6144
|
if (!raw.access_token || !raw.account_id) {
|
|
6082
6145
|
throw new Error("Brightsy config incomplete \u2014 run `brightsy login`");
|
|
6083
6146
|
}
|
|
6084
6147
|
return raw;
|
|
6085
6148
|
}
|
|
6086
6149
|
function saveBrightsyConfig(cfg) {
|
|
6087
|
-
(0,
|
|
6150
|
+
(0, import_node_fs16.writeFileSync)(brightsyConfigPath(), `${JSON.stringify(cfg, null, 2)}
|
|
6088
6151
|
`, {
|
|
6089
6152
|
mode: 384
|
|
6090
6153
|
});
|
|
6091
6154
|
}
|
|
6092
|
-
var
|
|
6155
|
+
var import_node_fs16, import_node_os6, import_node_path18;
|
|
6093
6156
|
var init_config = __esm({
|
|
6094
6157
|
"src/brightsy/config.ts"() {
|
|
6095
6158
|
"use strict";
|
|
6096
|
-
|
|
6159
|
+
import_node_fs16 = require("fs");
|
|
6097
6160
|
import_node_os6 = require("os");
|
|
6098
|
-
|
|
6161
|
+
import_node_path18 = require("path");
|
|
6099
6162
|
}
|
|
6100
6163
|
});
|
|
6101
6164
|
|
|
@@ -6110,22 +6173,22 @@ var init_accounts = __esm({
|
|
|
6110
6173
|
|
|
6111
6174
|
// src/brightsy/connected-teams.ts
|
|
6112
6175
|
function storePath4() {
|
|
6113
|
-
return (0,
|
|
6176
|
+
return (0, import_node_path19.join)(appDataDir(), "brightsy-teams.json");
|
|
6114
6177
|
}
|
|
6115
6178
|
function readStore4() {
|
|
6116
6179
|
const path = storePath4();
|
|
6117
|
-
if (!(0,
|
|
6180
|
+
if (!(0, import_node_fs17.existsSync)(path)) return [];
|
|
6118
6181
|
try {
|
|
6119
|
-
const parsed = JSON.parse((0,
|
|
6182
|
+
const parsed = JSON.parse((0, import_node_fs17.readFileSync)(path, "utf8"));
|
|
6120
6183
|
return Array.isArray(parsed.teams) ? parsed.teams : [];
|
|
6121
6184
|
} catch {
|
|
6122
6185
|
return [];
|
|
6123
6186
|
}
|
|
6124
6187
|
}
|
|
6125
6188
|
function writeStore2(teams) {
|
|
6126
|
-
(0,
|
|
6189
|
+
(0, import_node_fs17.mkdirSync)(appDataDir(), { recursive: true });
|
|
6127
6190
|
const path = storePath4();
|
|
6128
|
-
(0,
|
|
6191
|
+
(0, import_node_fs17.writeFileSync)(path, `${JSON.stringify({ teams }, null, 2)}
|
|
6129
6192
|
`, {
|
|
6130
6193
|
mode: 384
|
|
6131
6194
|
});
|
|
@@ -6237,12 +6300,12 @@ function brightsyMcpServerName(slug) {
|
|
|
6237
6300
|
const cleaned = slug.replace(/[^A-Za-z0-9_-]/g, "_").replace(/^_+|_+$/g, "");
|
|
6238
6301
|
return `brightsy_${cleaned || "team"}`;
|
|
6239
6302
|
}
|
|
6240
|
-
var
|
|
6303
|
+
var import_node_fs17, import_node_path19;
|
|
6241
6304
|
var init_connected_teams = __esm({
|
|
6242
6305
|
"src/brightsy/connected-teams.ts"() {
|
|
6243
6306
|
"use strict";
|
|
6244
|
-
|
|
6245
|
-
|
|
6307
|
+
import_node_fs17 = require("fs");
|
|
6308
|
+
import_node_path19 = require("path");
|
|
6246
6309
|
init_paths();
|
|
6247
6310
|
init_accounts();
|
|
6248
6311
|
init_config();
|
|
@@ -6573,11 +6636,11 @@ async function syncCliForTarget(accountId) {
|
|
|
6573
6636
|
}
|
|
6574
6637
|
applyConnectedTeamToCli(team);
|
|
6575
6638
|
}
|
|
6576
|
-
var
|
|
6639
|
+
var import_node_fs18, brightsyAdapter;
|
|
6577
6640
|
var init_brightsy = __esm({
|
|
6578
6641
|
"src/agents/brightsy.ts"() {
|
|
6579
6642
|
"use strict";
|
|
6580
|
-
|
|
6643
|
+
import_node_fs18 = require("fs");
|
|
6581
6644
|
init_run();
|
|
6582
6645
|
init_connected_teams();
|
|
6583
6646
|
init_config();
|
|
@@ -6592,7 +6655,7 @@ var init_brightsy = __esm({
|
|
|
6592
6655
|
async detect() {
|
|
6593
6656
|
const brightsy = resolveAgentExecutable("brightsy");
|
|
6594
6657
|
if (brightsy !== "brightsy") {
|
|
6595
|
-
if (!(0,
|
|
6658
|
+
if (!(0, import_node_fs18.existsSync)(brightsy)) {
|
|
6596
6659
|
return {
|
|
6597
6660
|
agent: "brightsy",
|
|
6598
6661
|
installed: false,
|
|
@@ -6761,9 +6824,9 @@ function toolDescription(name, input) {
|
|
|
6761
6824
|
if (/connectedAgentRequest/i.test(name)) {
|
|
6762
6825
|
return str2(input?.agent_id) ? `Ask connected agent` : "Ask connected agent";
|
|
6763
6826
|
}
|
|
6764
|
-
if (desc && kind) return `${kind}: ${desc}`;
|
|
6765
|
-
if (desc) return desc
|
|
6766
|
-
return
|
|
6827
|
+
if (desc && kind) return `${kind}: ${desc}${subagentLiveSuffix(input)}`;
|
|
6828
|
+
if (desc) return `${desc}${subagentLiveSuffix(input)}`;
|
|
6829
|
+
return `Subagent${subagentLiveSuffix(input)}`;
|
|
6767
6830
|
}
|
|
6768
6831
|
if (/^(create|update)_artifact$/i.test(name.replace(/^mcp__[^_]+__/, ""))) {
|
|
6769
6832
|
return str2(input?.title) ? `Artifact ${str2(input?.title)}` : "Artifact";
|
|
@@ -6788,13 +6851,83 @@ function toolDescription(name, input) {
|
|
|
6788
6851
|
}
|
|
6789
6852
|
if (/grep/i.test(name)) return "Search files";
|
|
6790
6853
|
if (/glob/i.test(name)) return "Find files";
|
|
6854
|
+
const compact = n.replace(/[_-]/g, "");
|
|
6855
|
+
if (/^taskoutput$/i.test(compact)) {
|
|
6856
|
+
return str2(input.task_id) ? `Wait for ${str2(input.task_id)}` : "Wait for background task";
|
|
6857
|
+
}
|
|
6858
|
+
if (/^taskstop$/i.test(compact)) {
|
|
6859
|
+
return str2(input.task_id) ? `Stop ${str2(input.task_id)}` : "Stop background task";
|
|
6860
|
+
}
|
|
6861
|
+
if (/^monitor$/i.test(compact)) {
|
|
6862
|
+
const command = str2(input.command);
|
|
6863
|
+
return command ? `Watch ${command.length > 48 ? `${command.slice(0, 45)}\u2026` : command}` : "Watch command";
|
|
6864
|
+
}
|
|
6791
6865
|
return n;
|
|
6792
6866
|
}
|
|
6867
|
+
function subagentLiveSuffix(input) {
|
|
6868
|
+
if (!input) return "";
|
|
6869
|
+
const bits = [];
|
|
6870
|
+
const status = str2(input.live_status);
|
|
6871
|
+
if (status && !/^runn(ing)?$|^working$/i.test(status)) bits.push(status);
|
|
6872
|
+
if (typeof input.live_tool_uses === "number") bits.push(`${input.live_tool_uses} tools`);
|
|
6873
|
+
if (typeof input.live_duration_ms === "number") {
|
|
6874
|
+
bits.push(`${Math.max(0, Math.round(Number(input.live_duration_ms) / 1e3))}s`);
|
|
6875
|
+
}
|
|
6876
|
+
const last = str2(input.live_last_tool);
|
|
6877
|
+
if (last) bits.push(last);
|
|
6878
|
+
return bits.length ? ` \xB7 ${bits.join(" \xB7 ")}` : "";
|
|
6879
|
+
}
|
|
6793
6880
|
function isSubagentToolName(name) {
|
|
6794
6881
|
const n = (name ?? "").trim();
|
|
6795
6882
|
if (/^(task|agent|spawn_agent)$/i.test(n)) return true;
|
|
6796
6883
|
return /connectedAgentRequest/i.test(n);
|
|
6797
6884
|
}
|
|
6885
|
+
function isPollWrapperToolName(name) {
|
|
6886
|
+
const n = (name ?? "").replace(/[_-]/g, "");
|
|
6887
|
+
return /^(taskoutput|taskstop|sleep)$/i.test(n);
|
|
6888
|
+
}
|
|
6889
|
+
function lastTextPart(parts, type) {
|
|
6890
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
6891
|
+
const p = parts[i];
|
|
6892
|
+
if (p.type === type && p.text.trim()) return p.text.trim();
|
|
6893
|
+
}
|
|
6894
|
+
return "";
|
|
6895
|
+
}
|
|
6896
|
+
function toolLabel(tool) {
|
|
6897
|
+
return tool.description || toolDescription(tool.name, tool.input) || tool.name;
|
|
6898
|
+
}
|
|
6899
|
+
function liveActivitySummary(parts, opts) {
|
|
6900
|
+
if (opts?.queued && parts.length === 0) {
|
|
6901
|
+
return "Queued \u2014 waiting for a slot";
|
|
6902
|
+
}
|
|
6903
|
+
const tools = parts.filter((p) => p.type === "tool");
|
|
6904
|
+
const runningSubs = tools.filter(
|
|
6905
|
+
(t) => t.status === "running" && !t.parentId && isSubagentToolName(t.name)
|
|
6906
|
+
);
|
|
6907
|
+
const runningNested = [...tools].reverse().find((t) => t.status === "running" && t.parentId && !isPollWrapperToolName(t.name));
|
|
6908
|
+
const runningTop = [...tools].reverse().find(
|
|
6909
|
+
(t) => t.status === "running" && !t.parentId && !isPollWrapperToolName(t.name) && !isSubagentToolName(t.name)
|
|
6910
|
+
);
|
|
6911
|
+
const runningPoll = [...tools].reverse().find((t) => t.status === "running" && isPollWrapperToolName(t.name));
|
|
6912
|
+
const thinking = lastTextPart(parts, "thinking");
|
|
6913
|
+
const text4 = lastTextPart(parts, "text");
|
|
6914
|
+
if (runningSubs.length > 0) {
|
|
6915
|
+
const heads = runningSubs.map(toolLabel);
|
|
6916
|
+
const head = runningSubs.length === 1 ? heads[0] : `${runningSubs.length} subagents \xB7 ${heads.slice(0, 2).join(" \xB7 ")}`;
|
|
6917
|
+
if (runningNested) return `${head} \xB7 ${toolLabel(runningNested)}`;
|
|
6918
|
+
return head;
|
|
6919
|
+
}
|
|
6920
|
+
if (runningTop) return toolLabel(runningTop);
|
|
6921
|
+
if (runningPoll) return toolLabel(runningPoll);
|
|
6922
|
+
if (thinking) return thinking.length > 96 ? `\u2026${thinking.slice(-96)}` : thinking;
|
|
6923
|
+
if (text4) return "Writing reply\u2026";
|
|
6924
|
+
const last = [...tools].reverse().find((t) => !isPollWrapperToolName(t.name)) ?? tools.at(-1);
|
|
6925
|
+
if (last) {
|
|
6926
|
+
const label = toolLabel(last);
|
|
6927
|
+
return last.status === "running" ? label : `Finished ${label}`;
|
|
6928
|
+
}
|
|
6929
|
+
return "Working\u2026";
|
|
6930
|
+
}
|
|
6798
6931
|
function messagePartParentId(part) {
|
|
6799
6932
|
if ("parentId" in part && typeof part.parentId === "string" && part.parentId.trim()) {
|
|
6800
6933
|
return part.parentId;
|
|
@@ -6876,6 +7009,25 @@ function applyAgentEvent(parts, event) {
|
|
|
6876
7009
|
const data = event.data;
|
|
6877
7010
|
if (!data) return parts;
|
|
6878
7011
|
const next = [...parts];
|
|
7012
|
+
if (event.replace) {
|
|
7013
|
+
for (let i = next.length - 1; i >= 0; i--) {
|
|
7014
|
+
const prev = next[i];
|
|
7015
|
+
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
|
+
};
|
|
7021
|
+
return next;
|
|
7022
|
+
}
|
|
7023
|
+
}
|
|
7024
|
+
next.push({
|
|
7025
|
+
type: "thinking",
|
|
7026
|
+
text: data,
|
|
7027
|
+
...event.parentId ? { parentId: event.parentId } : {}
|
|
7028
|
+
});
|
|
7029
|
+
return next;
|
|
7030
|
+
}
|
|
6879
7031
|
const last = next[next.length - 1];
|
|
6880
7032
|
if (last?.type === "thinking" && sameParentId(last.parentId, event.parentId)) {
|
|
6881
7033
|
next[next.length - 1] = {
|
|
@@ -6899,14 +7051,18 @@ function applyAgentEvent(parts, event) {
|
|
|
6899
7051
|
if (existing >= 0) {
|
|
6900
7052
|
const prev = parts[existing];
|
|
6901
7053
|
const next = [...parts];
|
|
6902
|
-
const mergedInput =
|
|
7054
|
+
const mergedInput = {
|
|
7055
|
+
...prev.input ?? {},
|
|
7056
|
+
...input ?? {}
|
|
7057
|
+
};
|
|
7058
|
+
const mergedRecord = Object.keys(mergedInput).length > 0 ? mergedInput : void 0;
|
|
6903
7059
|
next[existing] = {
|
|
6904
7060
|
...prev,
|
|
6905
7061
|
name: event.name || prev.name,
|
|
6906
|
-
input:
|
|
6907
|
-
description: toolDescription(event.name || prev.name,
|
|
6908
|
-
detail: toolDetail(event.name || prev.name,
|
|
6909
|
-
filePath: toolFilePath(
|
|
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,
|
|
6910
7066
|
additions: diff.additions ?? prev.additions,
|
|
6911
7067
|
deletions: diff.deletions ?? prev.deletions,
|
|
6912
7068
|
parentId: event.parentId ?? prev.parentId
|
|
@@ -7017,47 +7173,68 @@ function electronResourcesPath() {
|
|
|
7017
7173
|
function packagedCursorRuntimeDir() {
|
|
7018
7174
|
const resources = electronResourcesPath();
|
|
7019
7175
|
if (!resources) return null;
|
|
7020
|
-
const dir = (0,
|
|
7021
|
-
if (!(0,
|
|
7176
|
+
const dir = (0, import_node_path20.join)(resources, "cursor-runtime");
|
|
7177
|
+
if (!(0, import_node_fs19.existsSync)((0, import_node_path20.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
|
|
7022
7178
|
return dir;
|
|
7023
7179
|
}
|
|
7024
7180
|
function packagedCursorRunnerPath() {
|
|
7025
7181
|
const dir = packagedCursorRuntimeDir();
|
|
7026
|
-
return dir ? (0,
|
|
7182
|
+
return dir ? (0, import_node_path20.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
|
|
7027
7183
|
}
|
|
7028
7184
|
function packagedMcpDir() {
|
|
7029
7185
|
const resources = electronResourcesPath();
|
|
7030
7186
|
if (!resources) return null;
|
|
7031
|
-
const dir = (0,
|
|
7032
|
-
if (!(0,
|
|
7187
|
+
const dir = (0, import_node_path20.join)(resources, "sideboard-mcp");
|
|
7188
|
+
if (!(0, import_node_fs19.existsSync)((0, import_node_path20.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
|
|
7033
7189
|
return dir;
|
|
7034
7190
|
}
|
|
7035
7191
|
function packagedMcpStdioPath() {
|
|
7036
7192
|
const dir = packagedMcpDir();
|
|
7037
|
-
return dir ? (0,
|
|
7193
|
+
return dir ? (0, import_node_path20.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
|
|
7038
7194
|
}
|
|
7039
7195
|
function packagedBundledNodePath() {
|
|
7040
7196
|
const resources = electronResourcesPath();
|
|
7041
7197
|
if (!resources) return null;
|
|
7042
|
-
const bin = (0,
|
|
7043
|
-
if (!(0,
|
|
7198
|
+
const bin = (0, import_node_path20.join)(resources, "node", "bin", "node");
|
|
7199
|
+
if (!(0, import_node_fs19.existsSync)(bin)) return null;
|
|
7044
7200
|
return bin;
|
|
7045
7201
|
}
|
|
7046
7202
|
function packagedCursorRipgrepCandidate(platformPkg, binName) {
|
|
7047
7203
|
const dir = packagedCursorRuntimeDir();
|
|
7048
7204
|
if (!dir) return null;
|
|
7049
|
-
return (0,
|
|
7205
|
+
return (0, import_node_path20.join)(dir, "node_modules", platformPkg, "bin", binName);
|
|
7050
7206
|
}
|
|
7051
|
-
var
|
|
7207
|
+
var import_node_fs19, import_node_path20;
|
|
7052
7208
|
var init_packaged_runtime = __esm({
|
|
7053
7209
|
"src/agents/packaged-runtime.ts"() {
|
|
7054
7210
|
"use strict";
|
|
7055
|
-
|
|
7056
|
-
|
|
7211
|
+
import_node_fs19 = require("fs");
|
|
7212
|
+
import_node_path20 = require("path");
|
|
7057
7213
|
}
|
|
7058
7214
|
});
|
|
7059
7215
|
|
|
7060
7216
|
// src/agents/node-launch.ts
|
|
7217
|
+
function withMaxOldSpaceSize(nodeOptions, heapMb) {
|
|
7218
|
+
const existing = (nodeOptions ?? "").trim();
|
|
7219
|
+
const match = MAX_OLD_SPACE_FLAG.exec(existing);
|
|
7220
|
+
if (match) {
|
|
7221
|
+
const current = match[2] ? Number(match[2]) : 0;
|
|
7222
|
+
if (Number.isFinite(current) && current >= heapMb) return existing;
|
|
7223
|
+
return existing.replace(MAX_OLD_SPACE_FLAG, ` --max-old-space-size=${heapMb}`).trim();
|
|
7224
|
+
}
|
|
7225
|
+
return existing ? `${existing} --max-old-space-size=${heapMb}` : `--max-old-space-size=${heapMb}`;
|
|
7226
|
+
}
|
|
7227
|
+
function applyAgentRunnerHeapEnv(env) {
|
|
7228
|
+
env.NODE_OPTIONS = withMaxOldSpaceSize(
|
|
7229
|
+
env.NODE_OPTIONS,
|
|
7230
|
+
AGENT_RUNNER_MAX_OLD_SPACE_MB
|
|
7231
|
+
);
|
|
7232
|
+
}
|
|
7233
|
+
function envWithAgentHeap(env) {
|
|
7234
|
+
const next = { ...env };
|
|
7235
|
+
applyAgentRunnerHeapEnv(next);
|
|
7236
|
+
return next;
|
|
7237
|
+
}
|
|
7061
7238
|
function isAsarPath(filePath) {
|
|
7062
7239
|
if (/\.asar\.unpacked([/\\]|$)/.test(filePath)) return false;
|
|
7063
7240
|
return /\.asar([/\\]|$)/.test(filePath);
|
|
@@ -7066,7 +7243,7 @@ function unpackedAsarPath(filePath) {
|
|
|
7066
7243
|
if (!isAsarPath(filePath)) return null;
|
|
7067
7244
|
const unpacked = filePath.replace(/\.asar(?=[/\\])/, ".asar.unpacked");
|
|
7068
7245
|
if (unpacked === filePath) return null;
|
|
7069
|
-
return (0,
|
|
7246
|
+
return (0, import_node_fs20.existsSync)(unpacked) ? unpacked : null;
|
|
7070
7247
|
}
|
|
7071
7248
|
function nodeReadableScriptPath(scriptPath) {
|
|
7072
7249
|
return unpackedAsarPath(scriptPath) ?? scriptPath;
|
|
@@ -7106,37 +7283,37 @@ function pickPreferredNode(candidates) {
|
|
|
7106
7283
|
return best;
|
|
7107
7284
|
}
|
|
7108
7285
|
function versionDirNodeBins(root, toBin) {
|
|
7109
|
-
if (!(0,
|
|
7286
|
+
if (!(0, import_node_fs20.existsSync)(root)) return [];
|
|
7110
7287
|
try {
|
|
7111
|
-
return (0,
|
|
7288
|
+
return (0, import_node_fs20.readdirSync)(root).map(toBin);
|
|
7112
7289
|
} catch {
|
|
7113
7290
|
return [];
|
|
7114
7291
|
}
|
|
7115
7292
|
}
|
|
7116
7293
|
function defaultNodeBinCandidates(home = (0, import_node_os7.homedir)()) {
|
|
7117
7294
|
const kegs = ["/opt/homebrew", "/usr/local"].flatMap(
|
|
7118
|
-
(prefix) => PREFERRED_LTS_MAJORS.map((major) => (0,
|
|
7295
|
+
(prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path21.join)(prefix, "opt", `node@${major}`, "bin", "node"))
|
|
7119
7296
|
);
|
|
7120
7297
|
return [
|
|
7121
7298
|
...kegs,
|
|
7122
7299
|
"/opt/homebrew/bin/node",
|
|
7123
7300
|
"/usr/local/bin/node",
|
|
7124
|
-
(0,
|
|
7125
|
-
(0,
|
|
7126
|
-
(0,
|
|
7127
|
-
(0,
|
|
7128
|
-
(0,
|
|
7301
|
+
(0, import_node_path21.join)(home, ".local/share/fnm/aliases/default/bin/node"),
|
|
7302
|
+
(0, import_node_path21.join)(home, ".nvm/current/bin/node"),
|
|
7303
|
+
(0, import_node_path21.join)(home, ".volta/bin/node"),
|
|
7304
|
+
(0, import_node_path21.join)(home, ".asdf/shims/node"),
|
|
7305
|
+
(0, import_node_path21.join)(home, ".local/share/mise/shims/node"),
|
|
7129
7306
|
...versionDirNodeBins(
|
|
7130
|
-
(0,
|
|
7131
|
-
(name) => (0,
|
|
7307
|
+
(0, import_node_path21.join)(home, ".nvm", "versions", "node"),
|
|
7308
|
+
(name) => (0, import_node_path21.join)(home, ".nvm", "versions", "node", name, "bin", "node")
|
|
7132
7309
|
),
|
|
7133
7310
|
...versionDirNodeBins(
|
|
7134
|
-
(0,
|
|
7135
|
-
(name) => (0,
|
|
7311
|
+
(0, import_node_path21.join)(home, ".local/share/fnm", "node-versions"),
|
|
7312
|
+
(name) => (0, import_node_path21.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
|
|
7136
7313
|
),
|
|
7137
7314
|
...versionDirNodeBins(
|
|
7138
|
-
(0,
|
|
7139
|
-
(name) => (0,
|
|
7315
|
+
(0, import_node_path21.join)(home, ".volta", "tools", "image", "node"),
|
|
7316
|
+
(name) => (0, import_node_path21.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
|
|
7140
7317
|
)
|
|
7141
7318
|
];
|
|
7142
7319
|
}
|
|
@@ -7145,10 +7322,10 @@ function uniqueExistingNodeBins(paths) {
|
|
|
7145
7322
|
const out = [];
|
|
7146
7323
|
for (const raw of paths) {
|
|
7147
7324
|
const p = raw.trim();
|
|
7148
|
-
if (!p || !(0,
|
|
7325
|
+
if (!p || !(0, import_node_fs20.existsSync)(p) || isElectronLikeCommand(p)) continue;
|
|
7149
7326
|
let key = p;
|
|
7150
7327
|
try {
|
|
7151
|
-
key = (0,
|
|
7328
|
+
key = (0, import_node_fs20.realpathSync)(p);
|
|
7152
7329
|
} catch {
|
|
7153
7330
|
continue;
|
|
7154
7331
|
}
|
|
@@ -7193,13 +7370,21 @@ async function findSystemNode() {
|
|
|
7193
7370
|
function applyNodeLaunch(launch, args) {
|
|
7194
7371
|
const readableArgs = args.map(nodeReadableScriptPath);
|
|
7195
7372
|
if (!launch.env.ELECTRON_RUN_AS_NODE) {
|
|
7196
|
-
return {
|
|
7373
|
+
return {
|
|
7374
|
+
file: launch.file,
|
|
7375
|
+
args: readableArgs,
|
|
7376
|
+
env: envWithAgentHeap(launch.env)
|
|
7377
|
+
};
|
|
7197
7378
|
}
|
|
7198
7379
|
const wrapped = wrapElectronAsNodeLaunch(launch.file, readableArgs);
|
|
7199
7380
|
if (process.platform === "win32") {
|
|
7200
|
-
return {
|
|
7381
|
+
return {
|
|
7382
|
+
file: wrapped.file,
|
|
7383
|
+
args: wrapped.args,
|
|
7384
|
+
env: envWithAgentHeap(launch.env)
|
|
7385
|
+
};
|
|
7201
7386
|
}
|
|
7202
|
-
const env =
|
|
7387
|
+
const env = envWithAgentHeap(launch.env);
|
|
7203
7388
|
delete env.ELECTRON_RUN_AS_NODE;
|
|
7204
7389
|
return { file: wrapped.file, args: wrapped.args, env };
|
|
7205
7390
|
}
|
|
@@ -7220,16 +7405,18 @@ async function resolveNodeLaunch(scriptPath) {
|
|
|
7220
7405
|
env: { ELECTRON_RUN_AS_NODE: "1" }
|
|
7221
7406
|
};
|
|
7222
7407
|
}
|
|
7223
|
-
var
|
|
7408
|
+
var import_node_fs20, import_node_os7, import_node_path21, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
|
|
7224
7409
|
var init_node_launch = __esm({
|
|
7225
7410
|
"src/agents/node-launch.ts"() {
|
|
7226
7411
|
"use strict";
|
|
7227
|
-
|
|
7412
|
+
import_node_fs20 = require("fs");
|
|
7228
7413
|
import_node_os7 = require("os");
|
|
7229
|
-
|
|
7414
|
+
import_node_path21 = require("path");
|
|
7230
7415
|
init_nested_electron_env();
|
|
7231
7416
|
init_run();
|
|
7232
7417
|
init_packaged_runtime();
|
|
7418
|
+
AGENT_RUNNER_MAX_OLD_SPACE_MB = 8192;
|
|
7419
|
+
MAX_OLD_SPACE_FLAG = /(?:^|\s)(--max[-_]old[-_]space[-_]size)(?:[= ](\d+))?(?=\s|$)/;
|
|
7233
7420
|
PREFERRED_LTS_MAJORS = [24, 22, 20];
|
|
7234
7421
|
}
|
|
7235
7422
|
});
|
|
@@ -7317,37 +7504,37 @@ function corePackageDir() {
|
|
|
7317
7504
|
try {
|
|
7318
7505
|
const url = import_meta.url;
|
|
7319
7506
|
if (typeof url === "string" && url.length > 0) {
|
|
7320
|
-
return (0,
|
|
7507
|
+
return (0, import_node_path22.dirname)((0, import_node_url.fileURLToPath)(url));
|
|
7321
7508
|
}
|
|
7322
7509
|
} catch {
|
|
7323
7510
|
}
|
|
7324
7511
|
try {
|
|
7325
|
-
const req = (0, import_node_module.createRequire)((0,
|
|
7326
|
-
return (0,
|
|
7512
|
+
const req = (0, import_node_module.createRequire)((0, import_node_path22.join)(process.cwd(), "package.json"));
|
|
7513
|
+
return (0, import_node_path22.dirname)(req.resolve("@sideboard-ai/core"));
|
|
7327
7514
|
} catch {
|
|
7328
7515
|
return process.cwd();
|
|
7329
7516
|
}
|
|
7330
7517
|
}
|
|
7331
7518
|
function findSideboardMcpJsEntry() {
|
|
7332
7519
|
const override = process.env.SIDEBOARD_MCP_ENTRY?.trim() || process.env.SIDEBOARD_CLI?.trim();
|
|
7333
|
-
if (override && (0,
|
|
7520
|
+
if (override && (0, import_node_fs21.existsSync)(override)) return override;
|
|
7334
7521
|
const packaged = packagedMcpStdioPath();
|
|
7335
7522
|
if (packaged) return packaged;
|
|
7336
7523
|
let dir = corePackageDir();
|
|
7337
7524
|
for (let i = 0; i < 10; i++) {
|
|
7338
7525
|
const candidates = [
|
|
7339
|
-
(0,
|
|
7340
|
-
(0,
|
|
7341
|
-
(0,
|
|
7342
|
-
(0,
|
|
7343
|
-
(0,
|
|
7344
|
-
(0,
|
|
7345
|
-
(0,
|
|
7526
|
+
(0, import_node_path22.join)(dir, "mcp/run-stdio.js"),
|
|
7527
|
+
(0, import_node_path22.join)(dir, "mcp/run-stdio.cjs"),
|
|
7528
|
+
(0, import_node_path22.join)(dir, "dist/mcp/run-stdio.js"),
|
|
7529
|
+
(0, import_node_path22.join)(dir, "dist/mcp/run-stdio.cjs"),
|
|
7530
|
+
(0, import_node_path22.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
|
|
7531
|
+
(0, import_node_path22.join)(dir, "packages/cli/dist/index.js"),
|
|
7532
|
+
(0, import_node_path22.join)(dir, "cli/dist/index.js")
|
|
7346
7533
|
];
|
|
7347
7534
|
for (const p of candidates) {
|
|
7348
|
-
if ((0,
|
|
7535
|
+
if ((0, import_node_fs21.existsSync)(p) && !isAsarPath(p)) return p;
|
|
7349
7536
|
}
|
|
7350
|
-
const parent = (0,
|
|
7537
|
+
const parent = (0, import_node_path22.dirname)(dir);
|
|
7351
7538
|
if (parent === dir) break;
|
|
7352
7539
|
dir = parent;
|
|
7353
7540
|
}
|
|
@@ -7395,6 +7582,7 @@ async function buildInjectedMcpServers(opts) {
|
|
|
7395
7582
|
);
|
|
7396
7583
|
} catch {
|
|
7397
7584
|
}
|
|
7585
|
+
applyAgentRunnerHeapEnv(sideboard.env);
|
|
7398
7586
|
servers.push(sideboard);
|
|
7399
7587
|
}
|
|
7400
7588
|
if (opts.includeBrightsy && isBrightsyConnected()) {
|
|
@@ -7488,19 +7676,19 @@ function writeMcpServersConfig(servers) {
|
|
|
7488
7676
|
...env ? { env } : {}
|
|
7489
7677
|
};
|
|
7490
7678
|
}
|
|
7491
|
-
const dir = (0,
|
|
7492
|
-
const cfgPath = (0,
|
|
7493
|
-
(0,
|
|
7679
|
+
const dir = (0, import_node_fs21.mkdtempSync)((0, import_node_path22.join)((0, import_node_os8.tmpdir)(), "sideboard-mcp-"));
|
|
7680
|
+
const cfgPath = (0, import_node_path22.join)(dir, "mcp.json");
|
|
7681
|
+
(0, import_node_fs21.writeFileSync)(cfgPath, JSON.stringify({ mcpServers }, null, 2));
|
|
7494
7682
|
return cfgPath;
|
|
7495
7683
|
}
|
|
7496
|
-
var
|
|
7684
|
+
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;
|
|
7497
7685
|
var init_injected_mcp = __esm({
|
|
7498
7686
|
"src/agents/injected-mcp.ts"() {
|
|
7499
7687
|
"use strict";
|
|
7500
|
-
|
|
7688
|
+
import_node_fs21 = require("fs");
|
|
7501
7689
|
import_node_module = require("module");
|
|
7502
7690
|
import_node_os8 = require("os");
|
|
7503
|
-
|
|
7691
|
+
import_node_path22 = require("path");
|
|
7504
7692
|
import_node_url = require("url");
|
|
7505
7693
|
init_run();
|
|
7506
7694
|
init_config();
|
|
@@ -7674,6 +7862,80 @@ function claudeParentToolUseId(obj) {
|
|
|
7674
7862
|
}
|
|
7675
7863
|
return void 0;
|
|
7676
7864
|
}
|
|
7865
|
+
function claudeString(obj, key) {
|
|
7866
|
+
const v = obj[key];
|
|
7867
|
+
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
7868
|
+
}
|
|
7869
|
+
function eventsFromClaudeSystem(obj) {
|
|
7870
|
+
const subtype = claudeString(obj, "subtype") ?? "";
|
|
7871
|
+
const parentId = claudeParentToolUseId(obj);
|
|
7872
|
+
if (subtype === "init") {
|
|
7873
|
+
if (parentId) return null;
|
|
7874
|
+
const sid = claudeString(obj, "session_id");
|
|
7875
|
+
return sid ? { type: "session_id", data: sid } : null;
|
|
7876
|
+
}
|
|
7877
|
+
if (subtype === "task_started") {
|
|
7878
|
+
const id = claudeString(obj, "tool_use_id") ?? claudeString(obj, "task_id");
|
|
7879
|
+
if (!id) return null;
|
|
7880
|
+
const description = claudeString(obj, "description");
|
|
7881
|
+
const taskType = claudeString(obj, "task_type");
|
|
7882
|
+
const prompt = claudeString(obj, "prompt");
|
|
7883
|
+
return withEventParentId(
|
|
7884
|
+
{
|
|
7885
|
+
type: "tool_use",
|
|
7886
|
+
id,
|
|
7887
|
+
name: taskType || "Agent",
|
|
7888
|
+
input: {
|
|
7889
|
+
...description ? { description } : {},
|
|
7890
|
+
...prompt ? { prompt } : {},
|
|
7891
|
+
...claudeString(obj, "task_id") ? { task_id: claudeString(obj, "task_id") } : {}
|
|
7892
|
+
}
|
|
7893
|
+
},
|
|
7894
|
+
parentId
|
|
7895
|
+
);
|
|
7896
|
+
}
|
|
7897
|
+
if (subtype === "task_notification") {
|
|
7898
|
+
const id = claudeString(obj, "tool_use_id") ?? claudeString(obj, "task_id") ?? parentId;
|
|
7899
|
+
if (!id) return null;
|
|
7900
|
+
const status = claudeString(obj, "status") ?? "working";
|
|
7901
|
+
const tools = typeof obj.tool_uses === "number" ? obj.tool_uses : void 0;
|
|
7902
|
+
const durationMs = typeof obj.duration_ms === "number" ? obj.duration_ms : void 0;
|
|
7903
|
+
const lastTool = claudeString(obj, "last_tool") ?? claudeString(obj, "current_tool") ?? claudeString(obj, "tool");
|
|
7904
|
+
const snapshot = [
|
|
7905
|
+
status,
|
|
7906
|
+
tools != null ? `${tools} tools` : null,
|
|
7907
|
+
durationMs != null ? `${Math.round(durationMs / 1e3)}s` : null,
|
|
7908
|
+
lastTool
|
|
7909
|
+
].filter((bit) => Boolean(bit)).join(" \xB7 ");
|
|
7910
|
+
return [
|
|
7911
|
+
{
|
|
7912
|
+
type: "tool_use",
|
|
7913
|
+
id,
|
|
7914
|
+
name: claudeString(obj, "task_type") || "Agent",
|
|
7915
|
+
input: {
|
|
7916
|
+
live_status: status,
|
|
7917
|
+
...tools != null ? { live_tool_uses: tools } : {},
|
|
7918
|
+
...durationMs != null ? { live_duration_ms: durationMs } : {},
|
|
7919
|
+
...lastTool ? { live_last_tool: lastTool } : {}
|
|
7920
|
+
}
|
|
7921
|
+
},
|
|
7922
|
+
withEventParentId(
|
|
7923
|
+
{ type: "thinking", data: snapshot, replace: true },
|
|
7924
|
+
id
|
|
7925
|
+
)
|
|
7926
|
+
];
|
|
7927
|
+
}
|
|
7928
|
+
if (subtype === "api_retry") {
|
|
7929
|
+
const attempt = obj.attempt;
|
|
7930
|
+
const max = obj.max_retries;
|
|
7931
|
+
const delay = obj.retry_delay_ms;
|
|
7932
|
+
return {
|
|
7933
|
+
type: "thinking",
|
|
7934
|
+
data: `API retry ${attempt ?? "?"}/${max ?? "?"}${typeof delay === "number" ? ` (wait ${delay}ms)` : ""}`
|
|
7935
|
+
};
|
|
7936
|
+
}
|
|
7937
|
+
return null;
|
|
7938
|
+
}
|
|
7677
7939
|
function parseIssuesJson(raw) {
|
|
7678
7940
|
const text4 = raw.trim();
|
|
7679
7941
|
const candidates = [text4];
|
|
@@ -7699,11 +7961,11 @@ function parseIssuesJson(raw) {
|
|
|
7699
7961
|
}
|
|
7700
7962
|
return [];
|
|
7701
7963
|
}
|
|
7702
|
-
var
|
|
7964
|
+
var import_node_fs22, BASE_ALLOWED_TOOLS, CLAUDE_PRINT_BG_WAIT_CEILING_MS, CLAUDE_CHROME_ALLOWED_TOOLS, CLAUDE_PROMPT_ARG_MAX, claudeAdapter;
|
|
7703
7965
|
var init_claude = __esm({
|
|
7704
7966
|
"src/agents/claude.ts"() {
|
|
7705
7967
|
"use strict";
|
|
7706
|
-
|
|
7968
|
+
import_node_fs22 = require("fs");
|
|
7707
7969
|
init_run();
|
|
7708
7970
|
init_app_settings();
|
|
7709
7971
|
init_claude_mcp();
|
|
@@ -7723,8 +7985,14 @@ var init_claude = __esm({
|
|
|
7723
7985
|
"WebSearch",
|
|
7724
7986
|
// Subagents (Claude Code v2.1.63 renamed Task → Agent; allow both).
|
|
7725
7987
|
"Task",
|
|
7726
|
-
"Agent"
|
|
7988
|
+
"Agent",
|
|
7989
|
+
"TaskOutput",
|
|
7990
|
+
"TaskStop",
|
|
7991
|
+
"EnterWorktree",
|
|
7992
|
+
"ExitWorktree",
|
|
7993
|
+
"Skill"
|
|
7727
7994
|
];
|
|
7995
|
+
CLAUDE_PRINT_BG_WAIT_CEILING_MS = 72e5;
|
|
7728
7996
|
CLAUDE_CHROME_ALLOWED_TOOLS = [
|
|
7729
7997
|
"mcp__claude-in-chrome",
|
|
7730
7998
|
"mcp__claude-in-chrome__*",
|
|
@@ -7736,7 +8004,7 @@ var init_claude = __esm({
|
|
|
7736
8004
|
async detect() {
|
|
7737
8005
|
const claude = resolveClaudeExecutable();
|
|
7738
8006
|
if (claude !== "claude") {
|
|
7739
|
-
if (!(0,
|
|
8007
|
+
if (!(0, import_node_fs22.existsSync)(claude)) {
|
|
7740
8008
|
return {
|
|
7741
8009
|
agent: "claude",
|
|
7742
8010
|
installed: false,
|
|
@@ -7853,7 +8121,12 @@ var init_claude = __esm({
|
|
|
7853
8121
|
stdin: useStdin ? `${promptText}
|
|
7854
8122
|
` : void 0,
|
|
7855
8123
|
// Nested Task/Agent thinking+text in stream-json (Claude Code 2.1.211+).
|
|
7856
|
-
|
|
8124
|
+
// Raise the -p background-agent wait so long TaskOutput polls are not
|
|
8125
|
+
// abandoned at Claude Code’s 10-minute default.
|
|
8126
|
+
env: {
|
|
8127
|
+
CLAUDE_CODE_FORWARD_SUBAGENT_TEXT: "1",
|
|
8128
|
+
CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS: process.env.CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS ?? String(CLAUDE_PRINT_BG_WAIT_CEILING_MS)
|
|
8129
|
+
}
|
|
7857
8130
|
};
|
|
7858
8131
|
},
|
|
7859
8132
|
parseEvent(line) {
|
|
@@ -7861,13 +8134,8 @@ var init_claude = __esm({
|
|
|
7861
8134
|
if (!trimmed) return null;
|
|
7862
8135
|
try {
|
|
7863
8136
|
const obj = JSON.parse(trimmed);
|
|
7864
|
-
if (obj.type === "system"
|
|
7865
|
-
|
|
7866
|
-
if (typeof sid === "string") return { type: "session_id", data: sid };
|
|
7867
|
-
return null;
|
|
7868
|
-
}
|
|
7869
|
-
if (obj.type === "system" && typeof obj.session_id === "string") {
|
|
7870
|
-
return { type: "session_id", data: obj.session_id };
|
|
8137
|
+
if (obj.type === "system") {
|
|
8138
|
+
return eventsFromClaudeSystem(obj);
|
|
7871
8139
|
}
|
|
7872
8140
|
if (obj.type === "assistant" || obj.type === "user") {
|
|
7873
8141
|
const parentId = claudeParentToolUseId(obj);
|
|
@@ -7987,7 +8255,7 @@ async function listCodexModels() {
|
|
|
7987
8255
|
if (codex === "codex") {
|
|
7988
8256
|
const which = await run("which", ["codex"], { reject: false });
|
|
7989
8257
|
if (which.exitCode !== 0) return FALLBACK_CODEX_MODELS;
|
|
7990
|
-
} else if (!(0,
|
|
8258
|
+
} else if (!(0, import_node_fs23.existsSync)(codex)) {
|
|
7991
8259
|
return FALLBACK_CODEX_MODELS;
|
|
7992
8260
|
}
|
|
7993
8261
|
const listed = await run(codex, ["debug", "models"], { reject: false });
|
|
@@ -8022,12 +8290,12 @@ function usageFromCodex(usage) {
|
|
|
8022
8290
|
}
|
|
8023
8291
|
function codexConfigHasNetworkAccess() {
|
|
8024
8292
|
const candidates = [
|
|
8025
|
-
(0,
|
|
8026
|
-
(0,
|
|
8293
|
+
(0, import_node_path23.join)((0, import_node_os9.homedir)(), ".codex", "config.toml"),
|
|
8294
|
+
(0, import_node_path23.join)((0, import_node_os9.homedir)(), ".config", "codex", "config.toml")
|
|
8027
8295
|
];
|
|
8028
8296
|
for (const path of candidates) {
|
|
8029
|
-
if (!(0,
|
|
8030
|
-
const text4 = (0,
|
|
8297
|
+
if (!(0, import_node_fs23.existsSync)(path)) continue;
|
|
8298
|
+
const text4 = (0, import_node_fs23.readFileSync)(path, "utf8");
|
|
8031
8299
|
if (/network_access\s*=\s*true/.test(text4)) return true;
|
|
8032
8300
|
}
|
|
8033
8301
|
return false;
|
|
@@ -8059,21 +8327,21 @@ function asRecord2(value) {
|
|
|
8059
8327
|
return void 0;
|
|
8060
8328
|
}
|
|
8061
8329
|
function codexLooksAuthenticated() {
|
|
8062
|
-
const authPath = (0,
|
|
8063
|
-
if (!(0,
|
|
8330
|
+
const authPath = (0, import_node_path23.join)((0, import_node_os9.homedir)(), ".codex", "auth.json");
|
|
8331
|
+
if (!(0, import_node_fs23.existsSync)(authPath)) return false;
|
|
8064
8332
|
try {
|
|
8065
|
-
return (0,
|
|
8333
|
+
return (0, import_node_fs23.statSync)(authPath).size > 2;
|
|
8066
8334
|
} catch {
|
|
8067
8335
|
return false;
|
|
8068
8336
|
}
|
|
8069
8337
|
}
|
|
8070
|
-
var
|
|
8338
|
+
var import_node_fs23, import_node_os9, import_node_path23, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
|
|
8071
8339
|
var init_codex = __esm({
|
|
8072
8340
|
"src/agents/codex.ts"() {
|
|
8073
8341
|
"use strict";
|
|
8074
|
-
|
|
8342
|
+
import_node_fs23 = require("fs");
|
|
8075
8343
|
import_node_os9 = require("os");
|
|
8076
|
-
|
|
8344
|
+
import_node_path23 = require("path");
|
|
8077
8345
|
init_run();
|
|
8078
8346
|
init_app_settings();
|
|
8079
8347
|
init_global_workspace();
|
|
@@ -8098,7 +8366,7 @@ var init_codex = __esm({
|
|
|
8098
8366
|
async detect() {
|
|
8099
8367
|
const codex = resolveAgentExecutable("codex");
|
|
8100
8368
|
if (codex !== "codex") {
|
|
8101
|
-
if (!(0,
|
|
8369
|
+
if (!(0, import_node_fs23.existsSync)(codex)) {
|
|
8102
8370
|
return {
|
|
8103
8371
|
agent: "codex",
|
|
8104
8372
|
installed: false,
|
|
@@ -8287,9 +8555,6 @@ var init_codex = __esm({
|
|
|
8287
8555
|
if (sid && (type === "thread.started" || type === "session" || !type)) {
|
|
8288
8556
|
return { type: "session_id", data: sid };
|
|
8289
8557
|
}
|
|
8290
|
-
if (sid && type.endsWith(".started")) {
|
|
8291
|
-
return { type: "session_id", data: sid };
|
|
8292
|
-
}
|
|
8293
8558
|
if (type === "turn.completed" || type === "turn_completed") {
|
|
8294
8559
|
const usage = usageFromCodex(obj.usage);
|
|
8295
8560
|
return usage ? { type: "usage", data: usage, scope: "turn" } : null;
|
|
@@ -8537,21 +8802,21 @@ function platformRipgrepPackage() {
|
|
|
8537
8802
|
}
|
|
8538
8803
|
function usableRipgrepPath(candidate) {
|
|
8539
8804
|
const raw = candidate?.trim();
|
|
8540
|
-
if (!raw || !(0,
|
|
8805
|
+
if (!raw || !(0, import_node_path24.isAbsolute)(raw)) return null;
|
|
8541
8806
|
const readable = nodeReadableScriptPath(raw);
|
|
8542
|
-
if (!(0,
|
|
8807
|
+
if (!(0, import_node_fs24.existsSync)(readable) || isAsarPath(readable)) return null;
|
|
8543
8808
|
return readable;
|
|
8544
8809
|
}
|
|
8545
8810
|
function walkForBundledRipgrep(startFile) {
|
|
8546
8811
|
if (!startFile) return null;
|
|
8547
8812
|
const pkg = platformRipgrepPackage();
|
|
8548
8813
|
const name = rgBinaryName();
|
|
8549
|
-
let dir = (0,
|
|
8550
|
-
const root = (0,
|
|
8814
|
+
let dir = (0, import_node_path24.dirname)((0, import_node_path24.resolve)(startFile));
|
|
8815
|
+
const root = (0, import_node_path24.parse)(dir).root;
|
|
8551
8816
|
while (dir !== root) {
|
|
8552
|
-
const hit = usableRipgrepPath((0,
|
|
8817
|
+
const hit = usableRipgrepPath((0, import_node_path24.join)(dir, "node_modules", pkg, "bin", name));
|
|
8553
8818
|
if (hit) return hit;
|
|
8554
|
-
const next = (0,
|
|
8819
|
+
const next = (0, import_node_path24.dirname)(dir);
|
|
8555
8820
|
if (next === dir) break;
|
|
8556
8821
|
dir = next;
|
|
8557
8822
|
}
|
|
@@ -8561,7 +8826,7 @@ function requireResolveBundledRipgrep(fromFile) {
|
|
|
8561
8826
|
try {
|
|
8562
8827
|
const req = (0, import_node_module2.createRequire)(fromFile);
|
|
8563
8828
|
const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
|
|
8564
|
-
return usableRipgrepPath((0,
|
|
8829
|
+
return usableRipgrepPath((0, import_node_path24.join)((0, import_node_path24.dirname)(pkgJson), "bin", rgBinaryName()));
|
|
8565
8830
|
} catch {
|
|
8566
8831
|
return null;
|
|
8567
8832
|
}
|
|
@@ -8583,13 +8848,13 @@ function cursorRipgrepEnv(opts) {
|
|
|
8583
8848
|
const path = resolveCursorRipgrepPath(opts);
|
|
8584
8849
|
return path ? { [RIPGREP_ENV]: path } : {};
|
|
8585
8850
|
}
|
|
8586
|
-
var
|
|
8851
|
+
var import_node_fs24, import_node_module2, import_node_path24, RIPGREP_ENV;
|
|
8587
8852
|
var init_cursor_ripgrep = __esm({
|
|
8588
8853
|
"src/agents/cursor-ripgrep.ts"() {
|
|
8589
8854
|
"use strict";
|
|
8590
|
-
|
|
8855
|
+
import_node_fs24 = require("fs");
|
|
8591
8856
|
import_node_module2 = require("module");
|
|
8592
|
-
|
|
8857
|
+
import_node_path24 = require("path");
|
|
8593
8858
|
init_node_launch();
|
|
8594
8859
|
init_packaged_runtime();
|
|
8595
8860
|
RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
|
|
@@ -8635,11 +8900,11 @@ function entryDir() {
|
|
|
8635
8900
|
const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
|
|
8636
8901
|
if (cjsDir) return cjsDir;
|
|
8637
8902
|
try {
|
|
8638
|
-
return (0,
|
|
8903
|
+
return (0, import_node_path25.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
8639
8904
|
} catch {
|
|
8640
8905
|
try {
|
|
8641
8906
|
const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
|
|
8642
|
-
return (0,
|
|
8907
|
+
return (0, import_node_path25.dirname)(req.resolve("@sideboard-ai/core"));
|
|
8643
8908
|
} catch {
|
|
8644
8909
|
return process.cwd();
|
|
8645
8910
|
}
|
|
@@ -8650,27 +8915,27 @@ function cursorRunnerPath() {
|
|
|
8650
8915
|
if (packaged) return packaged;
|
|
8651
8916
|
const root = entryDir();
|
|
8652
8917
|
const candidates = [
|
|
8653
|
-
(0,
|
|
8654
|
-
(0,
|
|
8918
|
+
(0, import_node_path25.join)(root, "agents", "cursor-runner.js"),
|
|
8919
|
+
(0, import_node_path25.join)(root, "agents", "cursor-runner.cjs"),
|
|
8655
8920
|
// If somehow resolved from package root instead of dist/
|
|
8656
|
-
(0,
|
|
8657
|
-
(0,
|
|
8921
|
+
(0, import_node_path25.join)(root, "dist", "agents", "cursor-runner.js"),
|
|
8922
|
+
(0, import_node_path25.join)(root, "dist", "agents", "cursor-runner.cjs"),
|
|
8658
8923
|
// Source tree (dev): packages/core/src/agents/cursor-runner.ts
|
|
8659
|
-
(0,
|
|
8660
|
-
(0,
|
|
8924
|
+
(0, import_node_path25.join)(root, "cursor-runner.ts"),
|
|
8925
|
+
(0, import_node_path25.join)(root, "src", "agents", "cursor-runner.ts")
|
|
8661
8926
|
];
|
|
8662
8927
|
for (const candidate of candidates) {
|
|
8663
|
-
if ((0,
|
|
8928
|
+
if ((0, import_node_fs25.existsSync)(candidate)) return candidate;
|
|
8664
8929
|
}
|
|
8665
8930
|
return candidates[0];
|
|
8666
8931
|
}
|
|
8667
|
-
var
|
|
8932
|
+
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;
|
|
8668
8933
|
var init_cursor = __esm({
|
|
8669
8934
|
"src/agents/cursor.ts"() {
|
|
8670
8935
|
"use strict";
|
|
8671
|
-
|
|
8936
|
+
import_node_fs25 = require("fs");
|
|
8672
8937
|
import_node_module3 = require("module");
|
|
8673
|
-
|
|
8938
|
+
import_node_path25 = require("path");
|
|
8674
8939
|
import_node_url2 = require("url");
|
|
8675
8940
|
import_sdk = require("@cursor/sdk");
|
|
8676
8941
|
init_run();
|
|
@@ -8820,7 +9085,7 @@ async function listOpencodeModels() {
|
|
|
8820
9085
|
if (opencode === "opencode") {
|
|
8821
9086
|
const which = await run("which", ["opencode"], { reject: false });
|
|
8822
9087
|
if (which.exitCode !== 0) return FALLBACK_OPENCODE_MODELS;
|
|
8823
|
-
} else if (!(0,
|
|
9088
|
+
} else if (!(0, import_node_fs26.existsSync)(opencode)) {
|
|
8824
9089
|
return FALLBACK_OPENCODE_MODELS;
|
|
8825
9090
|
}
|
|
8826
9091
|
const listed = await run(opencode, ["models"], { reject: false });
|
|
@@ -8850,11 +9115,11 @@ function usageFromOpencode(tokens) {
|
|
|
8850
9115
|
cacheWriteTokens: tokens.cache?.write ? Number(tokens.cache.write) : void 0
|
|
8851
9116
|
};
|
|
8852
9117
|
}
|
|
8853
|
-
var
|
|
9118
|
+
var import_node_fs26, FALLBACK_OPENCODE_MODELS, cachedOpencodeModels, OPENCODE_MODEL_CACHE_MS, opencodeAdapter;
|
|
8854
9119
|
var init_opencode = __esm({
|
|
8855
9120
|
"src/agents/opencode.ts"() {
|
|
8856
9121
|
"use strict";
|
|
8857
|
-
|
|
9122
|
+
import_node_fs26 = require("fs");
|
|
8858
9123
|
init_run();
|
|
8859
9124
|
init_app_settings();
|
|
8860
9125
|
init_global_workspace();
|
|
@@ -8881,7 +9146,7 @@ var init_opencode = __esm({
|
|
|
8881
9146
|
async detect() {
|
|
8882
9147
|
const opencode = resolveAgentExecutable("opencode");
|
|
8883
9148
|
if (opencode !== "opencode") {
|
|
8884
|
-
if (!(0,
|
|
9149
|
+
if (!(0, import_node_fs26.existsSync)(opencode)) {
|
|
8885
9150
|
return {
|
|
8886
9151
|
agent: "opencode",
|
|
8887
9152
|
installed: false,
|
|
@@ -8967,7 +9232,8 @@ var init_opencode = __esm({
|
|
|
8967
9232
|
return { type: "stderr", data: detail };
|
|
8968
9233
|
}
|
|
8969
9234
|
const sid = typeof obj.sessionID === "string" && obj.sessionID || typeof obj.sessionId === "string" && obj.sessionId || typeof obj.session_id === "string" && obj.session_id;
|
|
8970
|
-
|
|
9235
|
+
const childSid = str3(obj.childSessionID) ?? str3(obj.childSessionId) ?? str3(obj.parentID) ?? str3(obj.parentId);
|
|
9236
|
+
if (sid && !childSid && (!obj.type || obj.type === "step_start" || obj.type === "session")) {
|
|
8971
9237
|
return { type: "session_id", data: sid };
|
|
8972
9238
|
}
|
|
8973
9239
|
if (obj.type === "text") {
|
|
@@ -9698,6 +9964,11 @@ function createAgentStreamCoalescer(emit, opts) {
|
|
|
9698
9964
|
return;
|
|
9699
9965
|
}
|
|
9700
9966
|
if (!event.data) return;
|
|
9967
|
+
if (event.type === "thinking" && event.replace) {
|
|
9968
|
+
flush2();
|
|
9969
|
+
emit(event);
|
|
9970
|
+
return;
|
|
9971
|
+
}
|
|
9701
9972
|
if (pending && pending.type === event.type && parentKey(pending) === parentKey(event)) {
|
|
9702
9973
|
pending.data += event.data;
|
|
9703
9974
|
} else {
|
|
@@ -9754,6 +10025,7 @@ async function spawnAgentTurn(thread, input, onEvent) {
|
|
|
9754
10025
|
}
|
|
9755
10026
|
const env = childEnvWithAppSettings(cmd.env);
|
|
9756
10027
|
applyPromptCacheTtlEnv(thread.agent, env);
|
|
10028
|
+
applyAgentRunnerHeapEnv(env);
|
|
9757
10029
|
try {
|
|
9758
10030
|
if (isOrchestratorThread(thread)) {
|
|
9759
10031
|
mergeAgentGitAuthEnv(env, await resolveAgentGitAuthEnv(env));
|
|
@@ -9861,9 +10133,11 @@ var init_spawn = __esm({
|
|
|
9861
10133
|
init_agents();
|
|
9862
10134
|
init_orchestrator_capable();
|
|
9863
10135
|
init_message_parts();
|
|
10136
|
+
init_node_launch();
|
|
9864
10137
|
init_path();
|
|
9865
10138
|
init_usage();
|
|
9866
10139
|
init_cursor_stream_coalesce();
|
|
10140
|
+
init_node_launch();
|
|
9867
10141
|
}
|
|
9868
10142
|
});
|
|
9869
10143
|
|
|
@@ -10589,21 +10863,21 @@ function shouldRefreshReviewRequestTemplate(content) {
|
|
|
10589
10863
|
return LEGACY_REVIEW_TEMPLATE_MARKERS.every((m) => trimmed.includes(m));
|
|
10590
10864
|
}
|
|
10591
10865
|
function readTextIfPresent(abs) {
|
|
10592
|
-
if (!(0,
|
|
10866
|
+
if (!(0, import_node_fs27.existsSync)(abs)) return null;
|
|
10593
10867
|
try {
|
|
10594
|
-
const content = (0,
|
|
10868
|
+
const content = (0, import_node_fs27.readFileSync)(abs, "utf8");
|
|
10595
10869
|
return content.trim() ? content : null;
|
|
10596
10870
|
} catch {
|
|
10597
10871
|
return null;
|
|
10598
10872
|
}
|
|
10599
10873
|
}
|
|
10600
10874
|
function readLocalGuidelines(worktreePath) {
|
|
10601
|
-
const localAbs = (0,
|
|
10875
|
+
const localAbs = (0, import_node_path26.join)(worktreePath, REVIEW_REQUEST_PATH);
|
|
10602
10876
|
const localContent = readTextIfPresent(localAbs);
|
|
10603
10877
|
if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
|
|
10604
10878
|
return { path: REVIEW_REQUEST_PATH, content: localContent };
|
|
10605
10879
|
}
|
|
10606
|
-
const legacyAbs = (0,
|
|
10880
|
+
const legacyAbs = (0, import_node_path26.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
|
|
10607
10881
|
const legacyContent = readTextIfPresent(legacyAbs);
|
|
10608
10882
|
if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
|
|
10609
10883
|
return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
|
|
@@ -10619,20 +10893,20 @@ function skillGuidelines(content, source) {
|
|
|
10619
10893
|
};
|
|
10620
10894
|
}
|
|
10621
10895
|
function ensureReviewSkillFile(worktreePath) {
|
|
10622
|
-
const abs = (0,
|
|
10896
|
+
const abs = (0, import_node_path26.join)(worktreePath, REVIEW_SKILL_PATH);
|
|
10623
10897
|
const existing = readTextIfPresent(abs);
|
|
10624
10898
|
if (existing) {
|
|
10625
10899
|
return { path: REVIEW_SKILL_PATH, content: existing, wrote: false };
|
|
10626
10900
|
}
|
|
10627
|
-
const fromRepo = readTextIfPresent((0,
|
|
10901
|
+
const fromRepo = readTextIfPresent((0, import_node_path26.join)(worktreePath, REPO_REVIEW_PATH));
|
|
10628
10902
|
const fromLocal = readLocalGuidelines(worktreePath)?.content ?? null;
|
|
10629
10903
|
const content = wrapReviewSkillMarkdown(fromRepo ?? fromLocal ?? REVIEW_REQUEST_TEMPLATE);
|
|
10630
|
-
(0,
|
|
10631
|
-
(0,
|
|
10904
|
+
(0, import_node_fs27.mkdirSync)((0, import_node_path26.dirname)(abs), { recursive: true });
|
|
10905
|
+
(0, import_node_fs27.writeFileSync)(abs, content, "utf8");
|
|
10632
10906
|
return { path: REVIEW_SKILL_PATH, content, wrote: true };
|
|
10633
10907
|
}
|
|
10634
10908
|
function resolveReviewGuidelines(worktreePath) {
|
|
10635
|
-
const skillContent = readTextIfPresent((0,
|
|
10909
|
+
const skillContent = readTextIfPresent((0, import_node_path26.join)(worktreePath, REVIEW_SKILL_PATH));
|
|
10636
10910
|
if (skillContent) return skillGuidelines(skillContent, "skill");
|
|
10637
10911
|
const local = readLocalGuidelines(worktreePath);
|
|
10638
10912
|
if (local) {
|
|
@@ -10682,13 +10956,13 @@ async function requestReview(threadRef, send) {
|
|
|
10682
10956
|
const started = await send(tab.id, REVIEW_REQUEST_PREFILL);
|
|
10683
10957
|
return { tab: started, from };
|
|
10684
10958
|
}
|
|
10685
|
-
var import_node_crypto5,
|
|
10959
|
+
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;
|
|
10686
10960
|
var init_request_review = __esm({
|
|
10687
10961
|
"src/review/request-review.ts"() {
|
|
10688
10962
|
"use strict";
|
|
10689
10963
|
import_node_crypto5 = require("crypto");
|
|
10690
|
-
|
|
10691
|
-
|
|
10964
|
+
import_node_fs27 = require("fs");
|
|
10965
|
+
import_node_path26 = require("path");
|
|
10692
10966
|
init_global_workspace();
|
|
10693
10967
|
init_chat_tabs();
|
|
10694
10968
|
init_thread_store();
|
|
@@ -10713,9 +10987,9 @@ function matchSimpleGlob(pattern, name) {
|
|
|
10713
10987
|
return new RegExp(`^${escaped}$`).test(name);
|
|
10714
10988
|
}
|
|
10715
10989
|
function readWorktreeInclude(repoPath) {
|
|
10716
|
-
const path = (0,
|
|
10717
|
-
if (!(0,
|
|
10718
|
-
return (0,
|
|
10990
|
+
const path = (0, import_node_path27.join)(repoPath, ".worktreeinclude");
|
|
10991
|
+
if (!(0, import_node_fs28.existsSync)(path)) return [];
|
|
10992
|
+
return (0, import_node_fs28.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
10719
10993
|
}
|
|
10720
10994
|
function resolveFilesToCopy(repoPath) {
|
|
10721
10995
|
const fromInclude = readWorktreeInclude(repoPath);
|
|
@@ -10725,10 +10999,10 @@ function resolveFilesToCopy(repoPath) {
|
|
|
10725
10999
|
if (settings?.fileIncludeGlobs?.length) {
|
|
10726
11000
|
const matched = [];
|
|
10727
11001
|
try {
|
|
10728
|
-
for (const entry of (0,
|
|
11002
|
+
for (const entry of (0, import_node_fs28.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
10729
11003
|
if (!entry.isFile()) continue;
|
|
10730
11004
|
for (const glob of settings.fileIncludeGlobs) {
|
|
10731
|
-
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0,
|
|
11005
|
+
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path27.basename)(glob), entry.name)) {
|
|
10732
11006
|
matched.push(entry.name);
|
|
10733
11007
|
break;
|
|
10734
11008
|
}
|
|
@@ -10740,7 +11014,7 @@ function resolveFilesToCopy(repoPath) {
|
|
|
10740
11014
|
}
|
|
10741
11015
|
const defaults = [];
|
|
10742
11016
|
try {
|
|
10743
|
-
for (const entry of (0,
|
|
11017
|
+
for (const entry of (0, import_node_fs28.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
10744
11018
|
if (entry.isFile() && entry.name.startsWith(".env")) {
|
|
10745
11019
|
defaults.push(entry.name);
|
|
10746
11020
|
}
|
|
@@ -10754,11 +11028,11 @@ function copyConfiguredFiles(repoPath, worktreePath) {
|
|
|
10754
11028
|
const patterns = resolveFilesToCopy(repoPath);
|
|
10755
11029
|
const copied = [];
|
|
10756
11030
|
for (const rel of patterns) {
|
|
10757
|
-
const src = (0,
|
|
10758
|
-
if (!(0,
|
|
10759
|
-
const dest = (0,
|
|
10760
|
-
(0,
|
|
10761
|
-
(0,
|
|
11031
|
+
const src = (0, import_node_path27.join)(repoPath, rel);
|
|
11032
|
+
if (!(0, import_node_fs28.existsSync)(src)) continue;
|
|
11033
|
+
const dest = (0, import_node_path27.join)(worktreePath, rel);
|
|
11034
|
+
(0, import_node_fs28.mkdirSync)((0, import_node_path27.dirname)(dest), { recursive: true });
|
|
11035
|
+
(0, import_node_fs28.copyFileSync)(src, dest);
|
|
10762
11036
|
copied.push(rel);
|
|
10763
11037
|
}
|
|
10764
11038
|
return copied;
|
|
@@ -10793,7 +11067,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
|
|
|
10793
11067
|
const env = stripNestedElectronEnv({
|
|
10794
11068
|
...baseEnv ?? process.env
|
|
10795
11069
|
});
|
|
10796
|
-
const name = opts.workspaceName ?? (0,
|
|
11070
|
+
const name = opts.workspaceName ?? (0, import_node_path27.basename)(opts.worktreePath);
|
|
10797
11071
|
const ports = opts.ports ?? [];
|
|
10798
11072
|
const primary = ports[0];
|
|
10799
11073
|
env.SIDEBOARD_WORKSPACE_NAME = name;
|
|
@@ -11054,13 +11328,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
|
|
|
11054
11328
|
done: handle.done
|
|
11055
11329
|
};
|
|
11056
11330
|
}
|
|
11057
|
-
var
|
|
11331
|
+
var import_node_fs28, import_node_net, import_node_path27, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
|
|
11058
11332
|
var init_conductor = __esm({
|
|
11059
11333
|
"src/hook/conductor.ts"() {
|
|
11060
11334
|
"use strict";
|
|
11061
|
-
|
|
11335
|
+
import_node_fs28 = require("fs");
|
|
11062
11336
|
import_node_net = require("net");
|
|
11063
|
-
|
|
11337
|
+
import_node_path27 = require("path");
|
|
11064
11338
|
import_execa4 = require("execa");
|
|
11065
11339
|
import_node_readline3 = require("readline");
|
|
11066
11340
|
init_settings();
|
|
@@ -11086,9 +11360,9 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
11086
11360
|
repoPaths?.length ? repoPaths : threads.map((t) => t.repoPath).filter(Boolean)
|
|
11087
11361
|
);
|
|
11088
11362
|
const homeRoot = sideboardWorkspacesDir();
|
|
11089
|
-
if ((0,
|
|
11363
|
+
if ((0, import_node_fs29.existsSync)(homeRoot)) {
|
|
11090
11364
|
try {
|
|
11091
|
-
for (const entry of (0,
|
|
11365
|
+
for (const entry of (0, import_node_fs29.readdirSync)(homeRoot, { withFileTypes: true })) {
|
|
11092
11366
|
if (!entry.isDirectory()) continue;
|
|
11093
11367
|
void entry;
|
|
11094
11368
|
}
|
|
@@ -11098,7 +11372,7 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
11098
11372
|
const orphans = [];
|
|
11099
11373
|
const seen = /* @__PURE__ */ new Set();
|
|
11100
11374
|
for (const repoPath of repos) {
|
|
11101
|
-
if (!repoPath || !(0,
|
|
11375
|
+
if (!repoPath || !(0, import_node_fs29.existsSync)(repoPath)) continue;
|
|
11102
11376
|
try {
|
|
11103
11377
|
const wts = await listWorktrees(repoPath);
|
|
11104
11378
|
for (const wt of wts) {
|
|
@@ -11109,7 +11383,7 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
11109
11383
|
seen.add(path);
|
|
11110
11384
|
let mtimeMs = 0;
|
|
11111
11385
|
try {
|
|
11112
|
-
mtimeMs = (0,
|
|
11386
|
+
mtimeMs = (0, import_node_fs29.statSync)(path).mtimeMs;
|
|
11113
11387
|
} catch {
|
|
11114
11388
|
mtimeMs = 0;
|
|
11115
11389
|
}
|
|
@@ -11119,16 +11393,16 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
11119
11393
|
}
|
|
11120
11394
|
try {
|
|
11121
11395
|
const root = worktreesRoot(repoPath);
|
|
11122
|
-
if ((0,
|
|
11123
|
-
for (const entry of (0,
|
|
11396
|
+
if ((0, import_node_fs29.existsSync)(root)) {
|
|
11397
|
+
for (const entry of (0, import_node_fs29.readdirSync)(root, { withFileTypes: true })) {
|
|
11124
11398
|
if (!entry.isDirectory()) continue;
|
|
11125
|
-
const path = (0,
|
|
11399
|
+
const path = (0, import_node_path28.join)(root, entry.name).replace(/\/$/, "");
|
|
11126
11400
|
if (known.has(path) || seen.has(path)) continue;
|
|
11127
|
-
if (!(0,
|
|
11401
|
+
if (!(0, import_node_fs29.existsSync)((0, import_node_path28.join)(path, ".git"))) continue;
|
|
11128
11402
|
seen.add(path);
|
|
11129
11403
|
let mtimeMs = 0;
|
|
11130
11404
|
try {
|
|
11131
|
-
mtimeMs = (0,
|
|
11405
|
+
mtimeMs = (0, import_node_fs29.statSync)(path).mtimeMs;
|
|
11132
11406
|
} catch {
|
|
11133
11407
|
mtimeMs = Date.now();
|
|
11134
11408
|
}
|
|
@@ -11180,12 +11454,12 @@ function shouldRunWorktreeCleanup(settings = loadAppSettings()) {
|
|
|
11180
11454
|
const elapsed = Date.now() - Date.parse(last);
|
|
11181
11455
|
return elapsed >= intervalHours * 36e5;
|
|
11182
11456
|
}
|
|
11183
|
-
var
|
|
11457
|
+
var import_node_fs29, import_node_path28;
|
|
11184
11458
|
var init_orphan_cleanup = __esm({
|
|
11185
11459
|
"src/git/orphan-cleanup.ts"() {
|
|
11186
11460
|
"use strict";
|
|
11187
|
-
|
|
11188
|
-
|
|
11461
|
+
import_node_fs29 = require("fs");
|
|
11462
|
+
import_node_path28 = require("path");
|
|
11189
11463
|
init_worktree();
|
|
11190
11464
|
init_thread_store();
|
|
11191
11465
|
init_paths();
|
|
@@ -11292,38 +11566,38 @@ __export(workspaces_exports, {
|
|
|
11292
11566
|
syncWorkspacesFromThreads: () => syncWorkspacesFromThreads
|
|
11293
11567
|
});
|
|
11294
11568
|
function workspacesFile() {
|
|
11295
|
-
return (0,
|
|
11569
|
+
return (0, import_node_path29.join)(appDataDir(), "workspaces.json");
|
|
11296
11570
|
}
|
|
11297
11571
|
function removedWorkspacesFile() {
|
|
11298
|
-
return (0,
|
|
11572
|
+
return (0, import_node_path29.join)(appDataDir(), "removed-workspaces.json");
|
|
11299
11573
|
}
|
|
11300
11574
|
function readAll() {
|
|
11301
11575
|
const path = workspacesFile();
|
|
11302
|
-
if (!(0,
|
|
11576
|
+
if (!(0, import_node_fs30.existsSync)(path)) return [];
|
|
11303
11577
|
try {
|
|
11304
|
-
const raw = JSON.parse((0,
|
|
11578
|
+
const raw = JSON.parse((0, import_node_fs30.readFileSync)(path, "utf8"));
|
|
11305
11579
|
return Array.isArray(raw) ? raw : [];
|
|
11306
11580
|
} catch {
|
|
11307
11581
|
return [];
|
|
11308
11582
|
}
|
|
11309
11583
|
}
|
|
11310
11584
|
function writeAll(list) {
|
|
11311
|
-
(0,
|
|
11312
|
-
(0,
|
|
11585
|
+
(0, import_node_fs30.mkdirSync)(appDataDir(), { recursive: true });
|
|
11586
|
+
(0, import_node_fs30.writeFileSync)(workspacesFile(), JSON.stringify(list, null, 2), "utf8");
|
|
11313
11587
|
}
|
|
11314
11588
|
function readRemoved() {
|
|
11315
11589
|
const path = removedWorkspacesFile();
|
|
11316
|
-
if (!(0,
|
|
11590
|
+
if (!(0, import_node_fs30.existsSync)(path)) return /* @__PURE__ */ new Set();
|
|
11317
11591
|
try {
|
|
11318
|
-
const raw = JSON.parse((0,
|
|
11592
|
+
const raw = JSON.parse((0, import_node_fs30.readFileSync)(path, "utf8"));
|
|
11319
11593
|
return new Set(Array.isArray(raw) ? raw.filter((p) => typeof p === "string") : []);
|
|
11320
11594
|
} catch {
|
|
11321
11595
|
return /* @__PURE__ */ new Set();
|
|
11322
11596
|
}
|
|
11323
11597
|
}
|
|
11324
11598
|
function writeRemoved(paths) {
|
|
11325
|
-
(0,
|
|
11326
|
-
(0,
|
|
11599
|
+
(0, import_node_fs30.mkdirSync)(appDataDir(), { recursive: true });
|
|
11600
|
+
(0, import_node_fs30.writeFileSync)(removedWorkspacesFile(), JSON.stringify([...paths].sort(), null, 2), "utf8");
|
|
11327
11601
|
}
|
|
11328
11602
|
function rememberRemoved(repoPath) {
|
|
11329
11603
|
const next = readRemoved();
|
|
@@ -11346,7 +11620,7 @@ function listWorkspaces() {
|
|
|
11346
11620
|
async function addWorkspace(repoPath) {
|
|
11347
11621
|
const root = await resolveRepoRoot(repoPath);
|
|
11348
11622
|
if (!root || root === "/") throw new Error(`Invalid repo path: ${repoPath}`);
|
|
11349
|
-
if (!(0,
|
|
11623
|
+
if (!(0, import_node_fs30.existsSync)(root)) throw new Error(`Repo not found: ${root}`);
|
|
11350
11624
|
forgetRemoved(root);
|
|
11351
11625
|
await ensureGhPreferOrigin(root);
|
|
11352
11626
|
const current = readAll();
|
|
@@ -11354,7 +11628,7 @@ async function addWorkspace(repoPath) {
|
|
|
11354
11628
|
if (existing) return existing;
|
|
11355
11629
|
const next = {
|
|
11356
11630
|
path: root,
|
|
11357
|
-
name: (0,
|
|
11631
|
+
name: (0, import_node_path29.basename)(root),
|
|
11358
11632
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
11359
11633
|
};
|
|
11360
11634
|
writeAll([...current, next]);
|
|
@@ -11376,10 +11650,10 @@ function syncWorkspacesFromThreads(repoPaths) {
|
|
|
11376
11650
|
if (!path || path === "/" || isGlobalRepoPath(path) || byPath.has(path) || removed.has(path)) {
|
|
11377
11651
|
continue;
|
|
11378
11652
|
}
|
|
11379
|
-
if (!(0,
|
|
11653
|
+
if (!(0, import_node_fs30.existsSync)(path)) continue;
|
|
11380
11654
|
const ws = {
|
|
11381
11655
|
path,
|
|
11382
|
-
name: (0,
|
|
11656
|
+
name: (0, import_node_path29.basename)(path),
|
|
11383
11657
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
11384
11658
|
};
|
|
11385
11659
|
byPath.set(path, ws);
|
|
@@ -11389,12 +11663,12 @@ function syncWorkspacesFromThreads(repoPaths) {
|
|
|
11389
11663
|
if (dirty) writeAll(next);
|
|
11390
11664
|
return next.sort((a, b) => a.name.localeCompare(b.name));
|
|
11391
11665
|
}
|
|
11392
|
-
var
|
|
11666
|
+
var import_node_fs30, import_node_path29;
|
|
11393
11667
|
var init_workspaces2 = __esm({
|
|
11394
11668
|
"src/store/workspaces.ts"() {
|
|
11395
11669
|
"use strict";
|
|
11396
|
-
|
|
11397
|
-
|
|
11670
|
+
import_node_fs30 = require("fs");
|
|
11671
|
+
import_node_path29 = require("path");
|
|
11398
11672
|
init_paths();
|
|
11399
11673
|
init_global_workspace();
|
|
11400
11674
|
init_worktree();
|
|
@@ -11407,12 +11681,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
11407
11681
|
if (!url) throw new Error("Clone URL is required");
|
|
11408
11682
|
let name = opts.name?.trim();
|
|
11409
11683
|
if (!name) {
|
|
11410
|
-
const leaf = (0,
|
|
11684
|
+
const leaf = (0, import_node_path30.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
|
|
11411
11685
|
name = leaf || "repo";
|
|
11412
11686
|
}
|
|
11413
11687
|
name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
|
|
11414
|
-
const dest = (0,
|
|
11415
|
-
if ((0,
|
|
11688
|
+
const dest = (0, import_node_path30.join)(sideboardReposDir(), name);
|
|
11689
|
+
if ((0, import_node_fs31.existsSync)(dest)) {
|
|
11416
11690
|
const repoPath2 = await resolveRepoRoot(dest);
|
|
11417
11691
|
const workspace2 = await ensureWorkspace(repoPath2);
|
|
11418
11692
|
return { repoPath: repoPath2, workspace: workspace2 };
|
|
@@ -11427,12 +11701,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
11427
11701
|
const workspace = await ensureWorkspace(repoPath);
|
|
11428
11702
|
return { repoPath, workspace };
|
|
11429
11703
|
}
|
|
11430
|
-
var
|
|
11704
|
+
var import_node_fs31, import_node_path30, import_execa6;
|
|
11431
11705
|
var init_clone_repo = __esm({
|
|
11432
11706
|
"src/git/clone-repo.ts"() {
|
|
11433
11707
|
"use strict";
|
|
11434
|
-
|
|
11435
|
-
|
|
11708
|
+
import_node_fs31 = require("fs");
|
|
11709
|
+
import_node_path30 = require("path");
|
|
11436
11710
|
import_execa6 = require("execa");
|
|
11437
11711
|
init_paths();
|
|
11438
11712
|
init_workspaces2();
|
|
@@ -11442,11 +11716,11 @@ var init_clone_repo = __esm({
|
|
|
11442
11716
|
|
|
11443
11717
|
// src/store/desktop-host.ts
|
|
11444
11718
|
function desktopHostPidPath() {
|
|
11445
|
-
return (0,
|
|
11719
|
+
return (0, import_node_path31.join)(appDataDir(), "desktop-host.pid");
|
|
11446
11720
|
}
|
|
11447
11721
|
function readDesktopHostPid() {
|
|
11448
11722
|
try {
|
|
11449
|
-
const pid = Number.parseInt((0,
|
|
11723
|
+
const pid = Number.parseInt((0, import_node_fs32.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
|
|
11450
11724
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
11451
11725
|
return pid;
|
|
11452
11726
|
} catch {
|
|
@@ -11472,12 +11746,12 @@ function thisProcessShouldDrainAgentQueues() {
|
|
|
11472
11746
|
if (isThisProcessDesktopHost()) return true;
|
|
11473
11747
|
return !isDesktopHostAlive();
|
|
11474
11748
|
}
|
|
11475
|
-
var
|
|
11749
|
+
var import_node_fs32, import_node_path31;
|
|
11476
11750
|
var init_desktop_host = __esm({
|
|
11477
11751
|
"src/store/desktop-host.ts"() {
|
|
11478
11752
|
"use strict";
|
|
11479
|
-
|
|
11480
|
-
|
|
11753
|
+
import_node_fs32 = require("fs");
|
|
11754
|
+
import_node_path31 = require("path");
|
|
11481
11755
|
init_paths();
|
|
11482
11756
|
}
|
|
11483
11757
|
});
|
|
@@ -11527,7 +11801,7 @@ async function createThread(input, _onSetupLine) {
|
|
|
11527
11801
|
});
|
|
11528
11802
|
await requireAgent(resolved.agent);
|
|
11529
11803
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
11530
|
-
if (!(0,
|
|
11804
|
+
if (!(0, import_node_fs33.existsSync)(repoPath)) {
|
|
11531
11805
|
throw new Error(`Repo not found: ${repoPath}`);
|
|
11532
11806
|
}
|
|
11533
11807
|
if (input.cowboy) {
|
|
@@ -11650,11 +11924,11 @@ async function listLinearIssues(agent, repoPath) {
|
|
|
11650
11924
|
}
|
|
11651
11925
|
return adapter.listLinearIssues(repoPath);
|
|
11652
11926
|
}
|
|
11653
|
-
var
|
|
11927
|
+
var import_node_fs33;
|
|
11654
11928
|
var init_create = __esm({
|
|
11655
11929
|
"src/threads/create.ts"() {
|
|
11656
11930
|
"use strict";
|
|
11657
|
-
|
|
11931
|
+
import_node_fs33 = require("fs");
|
|
11658
11932
|
init_detect();
|
|
11659
11933
|
init_worktree();
|
|
11660
11934
|
init_conductor();
|
|
@@ -11699,21 +11973,13 @@ function summarizeTurnLive(parts) {
|
|
|
11699
11973
|
(p) => p.type === "tool"
|
|
11700
11974
|
);
|
|
11701
11975
|
const lastTool = tools[tools.length - 1];
|
|
11702
|
-
const
|
|
11703
|
-
const
|
|
11976
|
+
const interesting = [...tools].reverse().find((t) => !isPollWrapperToolName(t.name)) ?? lastTool;
|
|
11977
|
+
const lastToolLabel = interesting ? interesting.description || toolDescription(interesting.name, interesting.input) || interesting.name : void 0;
|
|
11704
11978
|
const thinking = lastText(parts, "thinking");
|
|
11705
11979
|
const text4 = lastText(parts, "text");
|
|
11706
11980
|
const excerptRaw = thinking || text4;
|
|
11707
11981
|
const excerpt = excerptRaw.length > 280 ? `${excerptRaw.slice(-280)}` : excerptRaw || void 0;
|
|
11708
|
-
|
|
11709
|
-
if (lastToolLabel) {
|
|
11710
|
-
const verb = running ? lastToolLabel : `Finished ${lastToolLabel}`;
|
|
11711
|
-
summary = tools.length > 1 ? `${verb} (${tools.length} tools)` : verb;
|
|
11712
|
-
} else if (thinking) {
|
|
11713
|
-
summary = "Thinking\u2026";
|
|
11714
|
-
} else if (text4) {
|
|
11715
|
-
summary = "Writing reply\u2026";
|
|
11716
|
-
}
|
|
11982
|
+
const summary = liveActivitySummary(parts);
|
|
11717
11983
|
return {
|
|
11718
11984
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11719
11985
|
summary,
|
|
@@ -11763,20 +12029,20 @@ function writeTurnLive(threadId, progress) {
|
|
|
11763
12029
|
const path = threadLivePath(threadId);
|
|
11764
12030
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
11765
12031
|
try {
|
|
11766
|
-
(0,
|
|
11767
|
-
(0,
|
|
12032
|
+
(0, import_node_fs34.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
|
|
12033
|
+
(0, import_node_fs34.renameSync)(tmp, path);
|
|
11768
12034
|
} catch {
|
|
11769
12035
|
try {
|
|
11770
|
-
(0,
|
|
12036
|
+
(0, import_node_fs34.unlinkSync)(tmp);
|
|
11771
12037
|
} catch {
|
|
11772
12038
|
}
|
|
11773
12039
|
}
|
|
11774
12040
|
}
|
|
11775
12041
|
function readTurnLive(threadId) {
|
|
11776
12042
|
const path = threadLivePath(threadId);
|
|
11777
|
-
if (!(0,
|
|
12043
|
+
if (!(0, import_node_fs34.existsSync)(path)) return null;
|
|
11778
12044
|
try {
|
|
11779
|
-
const raw = JSON.parse((0,
|
|
12045
|
+
const raw = JSON.parse((0, import_node_fs34.readFileSync)(path, "utf8"));
|
|
11780
12046
|
if (!raw || typeof raw.summary !== "string") return null;
|
|
11781
12047
|
return raw;
|
|
11782
12048
|
} catch {
|
|
@@ -11788,17 +12054,17 @@ function clearTurnLive(threadId) {
|
|
|
11788
12054
|
if (buf?.timer) clearTimeout(buf.timer);
|
|
11789
12055
|
buffers.delete(threadId);
|
|
11790
12056
|
const path = threadLivePath(threadId);
|
|
11791
|
-
if (!(0,
|
|
12057
|
+
if (!(0, import_node_fs34.existsSync)(path)) return;
|
|
11792
12058
|
try {
|
|
11793
|
-
(0,
|
|
12059
|
+
(0, import_node_fs34.unlinkSync)(path);
|
|
11794
12060
|
} catch {
|
|
11795
12061
|
}
|
|
11796
12062
|
}
|
|
11797
|
-
var
|
|
12063
|
+
var import_node_fs34, buffers, FLUSH_MS, MAX_PARTS;
|
|
11798
12064
|
var init_turn_live = __esm({
|
|
11799
12065
|
"src/store/turn-live.ts"() {
|
|
11800
12066
|
"use strict";
|
|
11801
|
-
|
|
12067
|
+
import_node_fs34 = require("fs");
|
|
11802
12068
|
init_message_parts();
|
|
11803
12069
|
init_paths();
|
|
11804
12070
|
buffers = /* @__PURE__ */ new Map();
|
|
@@ -11977,7 +12243,7 @@ var init_quota_failover = __esm({
|
|
|
11977
12243
|
// src/threads/adopt.ts
|
|
11978
12244
|
function thisModuleFile() {
|
|
11979
12245
|
const cjsFile = typeof __filename !== "undefined" ? __filename : "";
|
|
11980
|
-
return cjsFile || process.argv[1] || (0,
|
|
12246
|
+
return cjsFile || process.argv[1] || (0, import_node_path32.join)(process.cwd(), "package.json");
|
|
11981
12247
|
}
|
|
11982
12248
|
function openReadonlySqlite(file) {
|
|
11983
12249
|
const req = (0, import_node_module4.createRequire)(thisModuleFile());
|
|
@@ -11995,21 +12261,21 @@ function mapAgentType(raw) {
|
|
|
11995
12261
|
return null;
|
|
11996
12262
|
}
|
|
11997
12263
|
function resolveConductorCursorAgentId(workspacePath) {
|
|
11998
|
-
if (!workspacePath || !(0,
|
|
12264
|
+
if (!workspacePath || !(0, import_node_fs35.existsSync)(CURSOR_SDK_STORE)) return null;
|
|
11999
12265
|
const normalized = workspacePath.replace(/\/$/, "");
|
|
12000
12266
|
let best = null;
|
|
12001
12267
|
let hashes;
|
|
12002
12268
|
try {
|
|
12003
|
-
hashes = (0,
|
|
12269
|
+
hashes = (0, import_node_fs35.readdirSync)(CURSOR_SDK_STORE);
|
|
12004
12270
|
} catch {
|
|
12005
12271
|
return null;
|
|
12006
12272
|
}
|
|
12007
12273
|
for (const hash of hashes) {
|
|
12008
|
-
const agentsFile = (0,
|
|
12009
|
-
if (!(0,
|
|
12274
|
+
const agentsFile = (0, import_node_path32.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
|
|
12275
|
+
if (!(0, import_node_fs35.existsSync)(agentsFile)) continue;
|
|
12010
12276
|
let text4;
|
|
12011
12277
|
try {
|
|
12012
|
-
text4 = (0,
|
|
12278
|
+
text4 = (0, import_node_fs35.readFileSync)(agentsFile, "utf8");
|
|
12013
12279
|
} catch {
|
|
12014
12280
|
continue;
|
|
12015
12281
|
}
|
|
@@ -12033,7 +12299,7 @@ function resolveConductorCursorAgentId(workspacePath) {
|
|
|
12033
12299
|
return best?.agentId ?? null;
|
|
12034
12300
|
}
|
|
12035
12301
|
async function adoptThread(input) {
|
|
12036
|
-
if (!(0,
|
|
12302
|
+
if (!(0, import_node_fs35.existsSync)(input.worktreePath)) {
|
|
12037
12303
|
throw new Error(`Worktree not found: ${input.worktreePath}`);
|
|
12038
12304
|
}
|
|
12039
12305
|
const repoPath = await resolveRepoRoot(input.worktreePath);
|
|
@@ -12057,18 +12323,18 @@ async function adoptThread(input) {
|
|
|
12057
12323
|
return thread;
|
|
12058
12324
|
}
|
|
12059
12325
|
function listConductorWorkspaces() {
|
|
12060
|
-
if (!(0,
|
|
12326
|
+
if (!(0, import_node_fs35.existsSync)(CONDUCTOR_DB)) {
|
|
12061
12327
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
12062
12328
|
}
|
|
12063
|
-
const tmp = (0,
|
|
12064
|
-
const snapshot = (0,
|
|
12329
|
+
const tmp = (0, import_node_fs35.mkdtempSync)((0, import_node_path32.join)((0, import_node_os10.tmpdir)(), "sideboard-conductor-"));
|
|
12330
|
+
const snapshot = (0, import_node_path32.join)(tmp, "conductor.db");
|
|
12065
12331
|
try {
|
|
12066
|
-
(0,
|
|
12332
|
+
(0, import_node_fs35.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
12067
12333
|
for (const suffix of ["-wal", "-shm"]) {
|
|
12068
12334
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
12069
|
-
if ((0,
|
|
12335
|
+
if ((0, import_node_fs35.existsSync)(src)) {
|
|
12070
12336
|
try {
|
|
12071
|
-
(0,
|
|
12337
|
+
(0, import_node_fs35.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
12072
12338
|
} catch {
|
|
12073
12339
|
}
|
|
12074
12340
|
}
|
|
@@ -12144,22 +12410,22 @@ function listConductorWorkspaces() {
|
|
|
12144
12410
|
db.close();
|
|
12145
12411
|
}
|
|
12146
12412
|
} finally {
|
|
12147
|
-
(0,
|
|
12413
|
+
(0, import_node_fs35.rmSync)(tmp, { recursive: true, force: true });
|
|
12148
12414
|
}
|
|
12149
12415
|
}
|
|
12150
12416
|
function importConductorWorkspace(workspaceId) {
|
|
12151
|
-
if (!(0,
|
|
12417
|
+
if (!(0, import_node_fs35.existsSync)(CONDUCTOR_DB)) {
|
|
12152
12418
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
12153
12419
|
}
|
|
12154
|
-
const tmp = (0,
|
|
12155
|
-
const snapshot = (0,
|
|
12420
|
+
const tmp = (0, import_node_fs35.mkdtempSync)((0, import_node_path32.join)((0, import_node_os10.tmpdir)(), "sideboard-conductor-"));
|
|
12421
|
+
const snapshot = (0, import_node_path32.join)(tmp, "conductor.db");
|
|
12156
12422
|
try {
|
|
12157
|
-
(0,
|
|
12423
|
+
(0, import_node_fs35.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
12158
12424
|
for (const suffix of ["-wal", "-shm"]) {
|
|
12159
12425
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
12160
|
-
if ((0,
|
|
12426
|
+
if ((0, import_node_fs35.existsSync)(src)) {
|
|
12161
12427
|
try {
|
|
12162
|
-
(0,
|
|
12428
|
+
(0, import_node_fs35.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
12163
12429
|
} catch {
|
|
12164
12430
|
}
|
|
12165
12431
|
}
|
|
@@ -12177,7 +12443,7 @@ function importConductorWorkspace(workspaceId) {
|
|
|
12177
12443
|
).get(workspaceId);
|
|
12178
12444
|
if (!row) throw new Error(`Conductor workspace not found: ${workspaceId}`);
|
|
12179
12445
|
const worktreePath = String(row.workspacePath);
|
|
12180
|
-
if (!(0,
|
|
12446
|
+
if (!(0, import_node_fs35.existsSync)(worktreePath)) {
|
|
12181
12447
|
throw new Error(`Conductor worktree missing on disk: ${worktreePath}`);
|
|
12182
12448
|
}
|
|
12183
12449
|
let sessionId = null;
|
|
@@ -12240,31 +12506,31 @@ function importConductorWorkspace(workspaceId) {
|
|
|
12240
12506
|
db.close();
|
|
12241
12507
|
}
|
|
12242
12508
|
} finally {
|
|
12243
|
-
(0,
|
|
12509
|
+
(0, import_node_fs35.rmSync)(tmp, { recursive: true, force: true });
|
|
12244
12510
|
}
|
|
12245
12511
|
}
|
|
12246
12512
|
async function importConductorWorkspaceAsync(workspaceId) {
|
|
12247
12513
|
return importConductorWorkspace(workspaceId);
|
|
12248
12514
|
}
|
|
12249
|
-
var import_node_child_process3,
|
|
12515
|
+
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;
|
|
12250
12516
|
var init_adopt = __esm({
|
|
12251
12517
|
"src/threads/adopt.ts"() {
|
|
12252
12518
|
"use strict";
|
|
12253
12519
|
import_node_child_process3 = require("child_process");
|
|
12254
|
-
|
|
12520
|
+
import_node_fs35 = require("fs");
|
|
12255
12521
|
import_node_os10 = require("os");
|
|
12256
|
-
|
|
12522
|
+
import_node_path32 = require("path");
|
|
12257
12523
|
import_node_module4 = require("module");
|
|
12258
12524
|
init_worktree();
|
|
12259
12525
|
init_thread_store();
|
|
12260
|
-
CONDUCTOR_APP_SUPPORT = (0,
|
|
12526
|
+
CONDUCTOR_APP_SUPPORT = (0, import_node_path32.join)(
|
|
12261
12527
|
process.env.HOME ?? "",
|
|
12262
12528
|
"Library",
|
|
12263
12529
|
"Application Support",
|
|
12264
12530
|
"com.conductor.app"
|
|
12265
12531
|
);
|
|
12266
|
-
CONDUCTOR_DB = (0,
|
|
12267
|
-
CURSOR_SDK_STORE = (0,
|
|
12532
|
+
CONDUCTOR_DB = (0, import_node_path32.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
|
|
12533
|
+
CURSOR_SDK_STORE = (0, import_node_path32.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
|
|
12268
12534
|
}
|
|
12269
12535
|
});
|
|
12270
12536
|
|
|
@@ -12331,7 +12597,7 @@ async function openStackLayer(input, _onSetupLine) {
|
|
|
12331
12597
|
let createdWorktree = false;
|
|
12332
12598
|
const trees = await listWorktrees(repoPath);
|
|
12333
12599
|
const checkedOut = trees.find((w) => w.branch === branchName);
|
|
12334
|
-
if (checkedOut?.path && (0,
|
|
12600
|
+
if (checkedOut?.path && (0, import_node_fs36.existsSync)(checkedOut.path)) {
|
|
12335
12601
|
if (input.reuseExistingWorktree !== false) {
|
|
12336
12602
|
worktreePath = checkedOut.path;
|
|
12337
12603
|
} else {
|
|
@@ -12473,7 +12739,7 @@ async function initStackFromThread(input, onSetupLine) {
|
|
|
12473
12739
|
async function createPrStack(input, onSetupLine) {
|
|
12474
12740
|
await requireAgent(input.agent);
|
|
12475
12741
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
12476
|
-
if (!(0,
|
|
12742
|
+
if (!(0, import_node_fs36.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
|
|
12477
12743
|
if (!input.branches.length) throw new Error("At least one branch name required");
|
|
12478
12744
|
const status = await detectGhStack(repoPath);
|
|
12479
12745
|
if (!status.available) throw new Error(status.reason);
|
|
@@ -12540,7 +12806,7 @@ async function createPrStack(input, onSetupLine) {
|
|
|
12540
12806
|
}
|
|
12541
12807
|
}
|
|
12542
12808
|
const claimed = new Set(threads.map((t) => t.worktreePath));
|
|
12543
|
-
if (!claimed.has(bootstrap.worktreePath) && (0,
|
|
12809
|
+
if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs36.existsSync)(bootstrap.worktreePath)) {
|
|
12544
12810
|
try {
|
|
12545
12811
|
await removeWorktree(repoPath, bootstrap.worktreePath, {
|
|
12546
12812
|
deleteBranch: bootstrap.branchName
|
|
@@ -12550,11 +12816,11 @@ async function createPrStack(input, onSetupLine) {
|
|
|
12550
12816
|
}
|
|
12551
12817
|
return { stack, threads, createdThreadIds };
|
|
12552
12818
|
}
|
|
12553
|
-
var
|
|
12819
|
+
var import_node_fs36;
|
|
12554
12820
|
var init_stack_layers = __esm({
|
|
12555
12821
|
"src/threads/stack-layers.ts"() {
|
|
12556
12822
|
"use strict";
|
|
12557
|
-
|
|
12823
|
+
import_node_fs36 = require("fs");
|
|
12558
12824
|
init_detect();
|
|
12559
12825
|
init_run();
|
|
12560
12826
|
init_stack();
|
|
@@ -12567,7 +12833,7 @@ var init_stack_layers = __esm({
|
|
|
12567
12833
|
|
|
12568
12834
|
// src/diff/diff.ts
|
|
12569
12835
|
async function inspectGitWorktree(worktreePath) {
|
|
12570
|
-
if (!worktreePath || !(0,
|
|
12836
|
+
if (!worktreePath || !(0, import_node_fs37.existsSync)(worktreePath)) return "missing_worktree";
|
|
12571
12837
|
const check = await git(["rev-parse", "--is-inside-work-tree"], worktreePath, {
|
|
12572
12838
|
reject: false
|
|
12573
12839
|
});
|
|
@@ -12575,7 +12841,7 @@ async function inspectGitWorktree(worktreePath) {
|
|
|
12575
12841
|
return "ok";
|
|
12576
12842
|
}
|
|
12577
12843
|
async function initializeGitRepository(worktreePath) {
|
|
12578
|
-
if (!worktreePath || !(0,
|
|
12844
|
+
if (!worktreePath || !(0, import_node_fs37.existsSync)(worktreePath)) {
|
|
12579
12845
|
throw new Error("Worktree not found");
|
|
12580
12846
|
}
|
|
12581
12847
|
const status = await inspectGitWorktree(worktreePath);
|
|
@@ -12709,11 +12975,11 @@ new file mode 100644
|
|
|
12709
12975
|
};
|
|
12710
12976
|
}
|
|
12711
12977
|
async function untrackedPatch(worktreePath, path, maxHunk) {
|
|
12712
|
-
const abs = (0,
|
|
12978
|
+
const abs = (0, import_node_path33.join)(worktreePath, path);
|
|
12713
12979
|
try {
|
|
12714
|
-
const st = (0,
|
|
12980
|
+
const st = (0, import_node_fs37.statSync)(abs);
|
|
12715
12981
|
if (st.isFile() && st.size > maxHunk) {
|
|
12716
|
-
const buf = (0,
|
|
12982
|
+
const buf = (0, import_node_fs37.readFileSync)(abs).subarray(0, maxHunk);
|
|
12717
12983
|
return syntheticAddPatch(path, buf.toString("utf8"), maxHunk);
|
|
12718
12984
|
}
|
|
12719
12985
|
} catch {
|
|
@@ -13202,8 +13468,8 @@ function isImageRelativePath(relativePath) {
|
|
|
13202
13468
|
function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
13203
13469
|
assertSafeRelativePath(relativePath);
|
|
13204
13470
|
const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
13205
|
-
const abs = (0,
|
|
13206
|
-
const st = (0,
|
|
13471
|
+
const abs = (0, import_node_path33.join)(worktreePath, relativePath);
|
|
13472
|
+
const st = (0, import_node_fs37.statSync)(abs);
|
|
13207
13473
|
if (!st.isFile()) {
|
|
13208
13474
|
throw new Error(`Not a file: ${relativePath}`);
|
|
13209
13475
|
}
|
|
@@ -13212,7 +13478,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
13212
13478
|
`File too large to upload (${st.size} bytes; max ${maxBytes})`
|
|
13213
13479
|
);
|
|
13214
13480
|
}
|
|
13215
|
-
const buf = (0,
|
|
13481
|
+
const buf = (0, import_node_fs37.readFileSync)(abs);
|
|
13216
13482
|
return {
|
|
13217
13483
|
path: relativePath,
|
|
13218
13484
|
contentBase64: buf.toString("base64"),
|
|
@@ -13222,12 +13488,12 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
13222
13488
|
function readWorktreeFile(worktreePath, relativePath, opts) {
|
|
13223
13489
|
assertSafeRelativePath(relativePath);
|
|
13224
13490
|
const maxBytes = opts?.maxBytes ?? 2e5;
|
|
13225
|
-
const abs = (0,
|
|
13226
|
-
const st = (0,
|
|
13491
|
+
const abs = (0, import_node_path33.join)(worktreePath, relativePath);
|
|
13492
|
+
const st = (0, import_node_fs37.statSync)(abs);
|
|
13227
13493
|
if (!st.isFile()) {
|
|
13228
13494
|
throw new Error(`Not a file: ${relativePath}`);
|
|
13229
13495
|
}
|
|
13230
|
-
const buf = (0,
|
|
13496
|
+
const buf = (0, import_node_fs37.readFileSync)(abs);
|
|
13231
13497
|
if (isImageRelativePath(relativePath)) {
|
|
13232
13498
|
const maxImageBytes = Math.max(maxBytes, 15e6);
|
|
13233
13499
|
const truncated2 = buf.length > maxImageBytes;
|
|
@@ -13270,9 +13536,9 @@ function assertSafeRelativePath(relativePath) {
|
|
|
13270
13536
|
}
|
|
13271
13537
|
function writeWorktreeFile(worktreePath, relativePath, content) {
|
|
13272
13538
|
assertSafeRelativePath(relativePath);
|
|
13273
|
-
const abs = (0,
|
|
13274
|
-
(0,
|
|
13275
|
-
(0,
|
|
13539
|
+
const abs = (0, import_node_path33.join)(worktreePath, relativePath);
|
|
13540
|
+
(0, import_node_fs37.mkdirSync)((0, import_node_path33.dirname)(abs), { recursive: true });
|
|
13541
|
+
(0, import_node_fs37.writeFileSync)(abs, content, "utf8");
|
|
13276
13542
|
return { path: relativePath };
|
|
13277
13543
|
}
|
|
13278
13544
|
async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
@@ -13289,12 +13555,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
|
13289
13555
|
truncated: full.files.length > maxFiles
|
|
13290
13556
|
};
|
|
13291
13557
|
}
|
|
13292
|
-
var
|
|
13558
|
+
var import_node_fs37, import_node_path33, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS, DEFAULT_UPLOAD_MAX_BYTES;
|
|
13293
13559
|
var init_diff = __esm({
|
|
13294
13560
|
"src/diff/diff.ts"() {
|
|
13295
13561
|
"use strict";
|
|
13296
|
-
|
|
13297
|
-
|
|
13562
|
+
import_node_fs37 = require("fs");
|
|
13563
|
+
import_node_path33 = require("path");
|
|
13298
13564
|
init_run();
|
|
13299
13565
|
init_worktree();
|
|
13300
13566
|
mergeBaseCache = /* @__PURE__ */ new Map();
|
|
@@ -13462,7 +13728,7 @@ function parseFrontmatter(content) {
|
|
|
13462
13728
|
}
|
|
13463
13729
|
function readSkill(skillMd, source) {
|
|
13464
13730
|
try {
|
|
13465
|
-
const content = (0,
|
|
13731
|
+
const content = (0, import_node_fs38.readFileSync)(skillMd, "utf8");
|
|
13466
13732
|
const { name: fmName, description } = parseFrontmatter(content);
|
|
13467
13733
|
const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
|
|
13468
13734
|
const name = fmName || dirName;
|
|
@@ -13481,19 +13747,19 @@ function readSkill(skillMd, source) {
|
|
|
13481
13747
|
}
|
|
13482
13748
|
}
|
|
13483
13749
|
function scanSkillsDir(dir, source, out) {
|
|
13484
|
-
if (!(0,
|
|
13750
|
+
if (!(0, import_node_fs38.existsSync)(dir)) return;
|
|
13485
13751
|
let entries;
|
|
13486
13752
|
try {
|
|
13487
|
-
entries = (0,
|
|
13753
|
+
entries = (0, import_node_fs38.readdirSync)(dir);
|
|
13488
13754
|
} catch {
|
|
13489
13755
|
return;
|
|
13490
13756
|
}
|
|
13491
13757
|
for (const entry of entries) {
|
|
13492
13758
|
if (entry.startsWith(".")) continue;
|
|
13493
|
-
const skillMd = (0,
|
|
13494
|
-
if (!(0,
|
|
13759
|
+
const skillMd = (0, import_node_path34.join)(dir, entry, "SKILL.md");
|
|
13760
|
+
if (!(0, import_node_fs38.existsSync)(skillMd)) continue;
|
|
13495
13761
|
try {
|
|
13496
|
-
if (!(0,
|
|
13762
|
+
if (!(0, import_node_fs38.statSync)(skillMd).isFile()) continue;
|
|
13497
13763
|
} catch {
|
|
13498
13764
|
continue;
|
|
13499
13765
|
}
|
|
@@ -13502,24 +13768,24 @@ function scanSkillsDir(dir, source, out) {
|
|
|
13502
13768
|
}
|
|
13503
13769
|
}
|
|
13504
13770
|
function scanClaudePluginSkills(pluginsRoot, out) {
|
|
13505
|
-
if (!(0,
|
|
13771
|
+
if (!(0, import_node_fs38.existsSync)(pluginsRoot)) return;
|
|
13506
13772
|
const walk = (dir, depth, lookingForSkillsDir) => {
|
|
13507
13773
|
if (depth > 7) return;
|
|
13508
13774
|
let entries;
|
|
13509
13775
|
try {
|
|
13510
|
-
entries = (0,
|
|
13776
|
+
entries = (0, import_node_fs38.readdirSync)(dir);
|
|
13511
13777
|
} catch {
|
|
13512
13778
|
return;
|
|
13513
13779
|
}
|
|
13514
13780
|
if (lookingForSkillsDir && entries.includes("SKILL.md")) {
|
|
13515
|
-
const skill = readSkill((0,
|
|
13781
|
+
const skill = readSkill((0, import_node_path34.join)(dir, "SKILL.md"), "cli");
|
|
13516
13782
|
if (skill) out.push(skill);
|
|
13517
13783
|
}
|
|
13518
13784
|
for (const entry of entries) {
|
|
13519
13785
|
if (entry === "node_modules" || entry === ".git") continue;
|
|
13520
|
-
const full = (0,
|
|
13786
|
+
const full = (0, import_node_path34.join)(dir, entry);
|
|
13521
13787
|
try {
|
|
13522
|
-
if (!(0,
|
|
13788
|
+
if (!(0, import_node_fs38.statSync)(full).isDirectory()) continue;
|
|
13523
13789
|
} catch {
|
|
13524
13790
|
continue;
|
|
13525
13791
|
}
|
|
@@ -13537,17 +13803,17 @@ function discoverSkills(worktreePath) {
|
|
|
13537
13803
|
const home = (0, import_node_os11.homedir)();
|
|
13538
13804
|
const collected = [];
|
|
13539
13805
|
for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
|
|
13540
|
-
scanSkillsDir((0,
|
|
13806
|
+
scanSkillsDir((0, import_node_path34.join)(worktreePath, rel), "workspace", collected);
|
|
13541
13807
|
}
|
|
13542
13808
|
for (const abs of [
|
|
13543
|
-
(0,
|
|
13544
|
-
(0,
|
|
13545
|
-
(0,
|
|
13546
|
-
(0,
|
|
13809
|
+
(0, import_node_path34.join)(home, ".claude/skills"),
|
|
13810
|
+
(0, import_node_path34.join)(home, ".cursor/skills"),
|
|
13811
|
+
(0, import_node_path34.join)(home, ".sideboard/skills"),
|
|
13812
|
+
(0, import_node_path34.join)(home, ".brightsy/skills")
|
|
13547
13813
|
]) {
|
|
13548
13814
|
scanSkillsDir(abs, "user", collected);
|
|
13549
13815
|
}
|
|
13550
|
-
scanClaudePluginSkills((0,
|
|
13816
|
+
scanClaudePluginSkills((0, import_node_path34.join)(home, ".claude/plugins"), collected);
|
|
13551
13817
|
const rank = { workspace: 0, user: 1, cli: 2 };
|
|
13552
13818
|
const byCommand = /* @__PURE__ */ new Map();
|
|
13553
13819
|
for (const skill of collected) {
|
|
@@ -13559,7 +13825,7 @@ function discoverSkills(worktreePath) {
|
|
|
13559
13825
|
return [...byCommand.values()].sort((a, b) => a.command.localeCompare(b.command));
|
|
13560
13826
|
}
|
|
13561
13827
|
function readSkillBody(skillPath, maxChars = 12e3) {
|
|
13562
|
-
const raw = (0,
|
|
13828
|
+
const raw = (0, import_node_fs38.readFileSync)(skillPath, "utf8");
|
|
13563
13829
|
if (raw.startsWith("---")) {
|
|
13564
13830
|
const end = raw.indexOf("\n---", 3);
|
|
13565
13831
|
if (end >= 0) {
|
|
@@ -13573,13 +13839,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
|
|
|
13573
13839
|
|
|
13574
13840
|
\u2026(truncated)` : raw;
|
|
13575
13841
|
}
|
|
13576
|
-
var
|
|
13842
|
+
var import_node_fs38, import_node_os11, import_node_path34;
|
|
13577
13843
|
var init_discover = __esm({
|
|
13578
13844
|
"src/skills/discover.ts"() {
|
|
13579
13845
|
"use strict";
|
|
13580
|
-
|
|
13846
|
+
import_node_fs38 = require("fs");
|
|
13581
13847
|
import_node_os11 = require("os");
|
|
13582
|
-
|
|
13848
|
+
import_node_path34 = require("path");
|
|
13583
13849
|
}
|
|
13584
13850
|
});
|
|
13585
13851
|
|
|
@@ -13670,7 +13936,7 @@ var init_expand = __esm({
|
|
|
13670
13936
|
|
|
13671
13937
|
// src/composer/stage-files.ts
|
|
13672
13938
|
function fileExtension(filePath) {
|
|
13673
|
-
const base = (0,
|
|
13939
|
+
const base = (0, import_node_path35.basename)(filePath).toLowerCase();
|
|
13674
13940
|
return base.includes(".") ? base.split(".").pop() || "" : "";
|
|
13675
13941
|
}
|
|
13676
13942
|
function isImageFilePath(filePath) {
|
|
@@ -13680,22 +13946,22 @@ function imageMimeType(filePath) {
|
|
|
13680
13946
|
return IMAGE_MIME_BY_EXT[fileExtension(filePath)] || "image/png";
|
|
13681
13947
|
}
|
|
13682
13948
|
function ensureAttachmentsDir(worktreePath) {
|
|
13683
|
-
const dir = (0,
|
|
13684
|
-
(0,
|
|
13685
|
-
const gi = (0,
|
|
13686
|
-
if (!(0,
|
|
13687
|
-
(0,
|
|
13949
|
+
const dir = (0, import_node_path35.join)(worktreePath, ATTACHMENTS_DIR);
|
|
13950
|
+
(0, import_node_fs39.mkdirSync)(dir, { recursive: true });
|
|
13951
|
+
const gi = (0, import_node_path35.join)(dir, ".gitignore");
|
|
13952
|
+
if (!(0, import_node_fs39.existsSync)(gi)) {
|
|
13953
|
+
(0, import_node_fs39.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
|
|
13688
13954
|
}
|
|
13689
13955
|
return dir;
|
|
13690
13956
|
}
|
|
13691
13957
|
function uniqueAttachmentName(dir, originalName) {
|
|
13692
13958
|
const safe = originalName.replace(/[/\\]/g, "_") || "file";
|
|
13693
|
-
if (!(0,
|
|
13694
|
-
const ext = (0,
|
|
13959
|
+
if (!(0, import_node_fs39.existsSync)((0, import_node_path35.join)(dir, safe))) return safe;
|
|
13960
|
+
const ext = (0, import_node_path35.extname)(safe);
|
|
13695
13961
|
const stem = ext ? safe.slice(0, -ext.length) : safe;
|
|
13696
13962
|
for (let i = 1; i < 1e4; i++) {
|
|
13697
13963
|
const candidate = `${stem}-${i}${ext}`;
|
|
13698
|
-
if (!(0,
|
|
13964
|
+
if (!(0, import_node_fs39.existsSync)((0, import_node_path35.join)(dir, candidate))) return candidate;
|
|
13699
13965
|
}
|
|
13700
13966
|
return `${stem}-${(0, import_node_crypto7.randomUUID)()}${ext}`;
|
|
13701
13967
|
}
|
|
@@ -13751,15 +14017,15 @@ function stageAbsolutePathsAsAttachments(worktreePath, absolutePaths) {
|
|
|
13751
14017
|
const dir = ensureAttachmentsDir(worktreePath);
|
|
13752
14018
|
const out = [];
|
|
13753
14019
|
for (const abs of absolutePaths) {
|
|
13754
|
-
const originalName = (0,
|
|
14020
|
+
const originalName = (0, import_node_path35.basename)(abs);
|
|
13755
14021
|
try {
|
|
13756
|
-
const st = (0,
|
|
14022
|
+
const st = (0, import_node_fs39.statSync)(abs);
|
|
13757
14023
|
if (!st.isFile()) continue;
|
|
13758
14024
|
const name = uniqueAttachmentName(dir, originalName);
|
|
13759
|
-
const destAbs = (0,
|
|
13760
|
-
(0,
|
|
14025
|
+
const destAbs = (0, import_node_path35.join)(dir, name);
|
|
14026
|
+
(0, import_node_fs39.copyFileSync)(abs, destAbs);
|
|
13761
14027
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
13762
|
-
const buf = (0,
|
|
14028
|
+
const buf = (0, import_node_fs39.readFileSync)(destAbs);
|
|
13763
14029
|
out.push(attachmentFromBuffer(name, buf, { path: rel, sourceLabel: abs }));
|
|
13764
14030
|
} catch (err) {
|
|
13765
14031
|
out.push({
|
|
@@ -13781,8 +14047,8 @@ function stageBuffersAsAttachments(worktreePath, buffers2) {
|
|
|
13781
14047
|
try {
|
|
13782
14048
|
const buf = Buffer.from(item.dataBase64, "base64");
|
|
13783
14049
|
const name = uniqueAttachmentName(dir, originalName);
|
|
13784
|
-
const destAbs = (0,
|
|
13785
|
-
(0,
|
|
14050
|
+
const destAbs = (0, import_node_path35.join)(dir, name);
|
|
14051
|
+
(0, import_node_fs39.writeFileSync)(destAbs, buf);
|
|
13786
14052
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
13787
14053
|
out.push(attachmentFromBuffer(name, buf, { path: rel }));
|
|
13788
14054
|
} catch (err) {
|
|
@@ -13802,18 +14068,18 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
13802
14068
|
if (!rel || rel.includes("..") || rel.startsWith("/")) {
|
|
13803
14069
|
out.push({
|
|
13804
14070
|
id: (0, import_node_crypto7.randomUUID)(),
|
|
13805
|
-
name: (0,
|
|
14071
|
+
name: (0, import_node_path35.basename)(rel) || "file",
|
|
13806
14072
|
kind: "file",
|
|
13807
14073
|
content: `(invalid path: ${rel})`
|
|
13808
14074
|
});
|
|
13809
14075
|
continue;
|
|
13810
14076
|
}
|
|
13811
|
-
const name = (0,
|
|
14077
|
+
const name = (0, import_node_path35.basename)(rel);
|
|
13812
14078
|
try {
|
|
13813
|
-
const abs = (0,
|
|
13814
|
-
const st = (0,
|
|
14079
|
+
const abs = (0, import_node_path35.join)(worktreePath, rel);
|
|
14080
|
+
const st = (0, import_node_fs39.statSync)(abs);
|
|
13815
14081
|
if (!st.isFile()) continue;
|
|
13816
|
-
const buf = (0,
|
|
14082
|
+
const buf = (0, import_node_fs39.readFileSync)(abs);
|
|
13817
14083
|
out.push(attachmentFromBuffer(name, buf, { path: rel, sourceLabel: abs }));
|
|
13818
14084
|
} catch (err) {
|
|
13819
14085
|
out.push({
|
|
@@ -13826,12 +14092,12 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
13826
14092
|
}
|
|
13827
14093
|
return out;
|
|
13828
14094
|
}
|
|
13829
|
-
var
|
|
14095
|
+
var import_node_fs39, import_node_path35, import_node_crypto7, IMAGE_EXTENSIONS2, IMAGE_MIME_BY_EXT, MAX_INLINE_BYTES, MAX_PREVIEW_BYTES;
|
|
13830
14096
|
var init_stage_files = __esm({
|
|
13831
14097
|
"src/composer/stage-files.ts"() {
|
|
13832
14098
|
"use strict";
|
|
13833
|
-
|
|
13834
|
-
|
|
14099
|
+
import_node_fs39 = require("fs");
|
|
14100
|
+
import_node_path35 = require("path");
|
|
13835
14101
|
import_node_crypto7 = require("crypto");
|
|
13836
14102
|
init_workspace_scratch();
|
|
13837
14103
|
IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
@@ -14000,12 +14266,12 @@ function formatArtifactDirective() {
|
|
|
14000
14266
|
function formatUiReminder() {
|
|
14001
14267
|
return "Sideboard UI: html fence or present_artifact / present_schema / present_files; 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.";
|
|
14002
14268
|
}
|
|
14003
|
-
var
|
|
14269
|
+
var import_node_fs40, import_node_path36;
|
|
14004
14270
|
var init_instructions = __esm({
|
|
14005
14271
|
"src/agents/instructions.ts"() {
|
|
14006
14272
|
"use strict";
|
|
14007
|
-
|
|
14008
|
-
|
|
14273
|
+
import_node_fs40 = require("fs");
|
|
14274
|
+
import_node_path36 = require("path");
|
|
14009
14275
|
init_git_auth_mode();
|
|
14010
14276
|
init_worktree_labels();
|
|
14011
14277
|
}
|
|
@@ -14081,40 +14347,40 @@ __export(plan_file_exports, {
|
|
|
14081
14347
|
writePlanFile: () => writePlanFile
|
|
14082
14348
|
});
|
|
14083
14349
|
function ensureAttachmentsGitignore(worktreePath) {
|
|
14084
|
-
const gitignoreAbs = (0,
|
|
14085
|
-
if ((0,
|
|
14086
|
-
(0,
|
|
14087
|
-
(0,
|
|
14350
|
+
const gitignoreAbs = (0, import_node_path37.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
14351
|
+
if ((0, import_node_fs41.existsSync)(gitignoreAbs)) return;
|
|
14352
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path37.dirname)(gitignoreAbs), { recursive: true });
|
|
14353
|
+
(0, import_node_fs41.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
14088
14354
|
}
|
|
14089
14355
|
function planFileAbs(worktreePath) {
|
|
14090
|
-
return (0,
|
|
14356
|
+
return (0, import_node_path37.join)(worktreePath, PLAN_FILE_REL);
|
|
14091
14357
|
}
|
|
14092
14358
|
function readTextIfPresent2(abs) {
|
|
14093
|
-
if (!(0,
|
|
14359
|
+
if (!(0, import_node_fs41.existsSync)(abs)) return null;
|
|
14094
14360
|
try {
|
|
14095
|
-
const content = (0,
|
|
14361
|
+
const content = (0, import_node_fs41.readFileSync)(abs, "utf8");
|
|
14096
14362
|
return content.trim() ? content : null;
|
|
14097
14363
|
} catch {
|
|
14098
14364
|
return null;
|
|
14099
14365
|
}
|
|
14100
14366
|
}
|
|
14101
14367
|
function readPlanFile(worktreePath) {
|
|
14102
|
-
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0,
|
|
14368
|
+
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));
|
|
14103
14369
|
}
|
|
14104
14370
|
function writePlanFile(worktreePath, content) {
|
|
14105
14371
|
ensureAttachmentsGitignore(worktreePath);
|
|
14106
14372
|
const abs = planFileAbs(worktreePath);
|
|
14107
|
-
(0,
|
|
14373
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path37.dirname)(abs), { recursive: true });
|
|
14108
14374
|
const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
|
|
14109
|
-
(0,
|
|
14375
|
+
(0, import_node_fs41.writeFileSync)(abs, body, "utf8");
|
|
14110
14376
|
return PLAN_FILE_REL;
|
|
14111
14377
|
}
|
|
14112
|
-
var
|
|
14378
|
+
var import_node_fs41, import_node_path37;
|
|
14113
14379
|
var init_plan_file = __esm({
|
|
14114
14380
|
"src/plan/plan-file.ts"() {
|
|
14115
14381
|
"use strict";
|
|
14116
|
-
|
|
14117
|
-
|
|
14382
|
+
import_node_fs41 = require("fs");
|
|
14383
|
+
import_node_path37 = require("path");
|
|
14118
14384
|
init_workspace_scratch();
|
|
14119
14385
|
init_plan_present();
|
|
14120
14386
|
init_plan_present();
|
|
@@ -14174,7 +14440,7 @@ function setCaffeinateHoldHooks(next) {
|
|
|
14174
14440
|
hooks = next;
|
|
14175
14441
|
}
|
|
14176
14442
|
function caffeinateHoldPath() {
|
|
14177
|
-
return (0,
|
|
14443
|
+
return (0, import_node_path38.join)(appDataDir(), "caffeinate-hold.json");
|
|
14178
14444
|
}
|
|
14179
14445
|
function processAlive(pid) {
|
|
14180
14446
|
if (hooks.processAlive) return hooks.processAlive(pid);
|
|
@@ -14208,9 +14474,9 @@ function uniqueIds(ids) {
|
|
|
14208
14474
|
}
|
|
14209
14475
|
function readHold() {
|
|
14210
14476
|
const path = caffeinateHoldPath();
|
|
14211
|
-
if (!(0,
|
|
14477
|
+
if (!(0, import_node_fs42.existsSync)(path)) return null;
|
|
14212
14478
|
try {
|
|
14213
|
-
const parsed = JSON.parse((0,
|
|
14479
|
+
const parsed = JSON.parse((0, import_node_fs42.readFileSync)(path, "utf8"));
|
|
14214
14480
|
if (typeof parsed?.pid === "number" && parsed.pid > 0) {
|
|
14215
14481
|
return {
|
|
14216
14482
|
pid: parsed.pid,
|
|
@@ -14232,7 +14498,7 @@ function writeHold(pid, threadIds) {
|
|
|
14232
14498
|
}
|
|
14233
14499
|
function clearHold() {
|
|
14234
14500
|
try {
|
|
14235
|
-
(0,
|
|
14501
|
+
(0, import_node_fs42.unlinkSync)(caffeinateHoldPath());
|
|
14236
14502
|
} catch {
|
|
14237
14503
|
}
|
|
14238
14504
|
}
|
|
@@ -14317,13 +14583,13 @@ function releaseCaffeinateHoldForThread(threadId) {
|
|
|
14317
14583
|
}
|
|
14318
14584
|
return setCaffeinateHold(false, { threadId: id });
|
|
14319
14585
|
}
|
|
14320
|
-
var import_node_child_process4,
|
|
14586
|
+
var import_node_child_process4, import_node_fs42, import_node_path38, hooks;
|
|
14321
14587
|
var init_caffeinate_hold = __esm({
|
|
14322
14588
|
"src/store/caffeinate-hold.ts"() {
|
|
14323
14589
|
"use strict";
|
|
14324
14590
|
import_node_child_process4 = require("child_process");
|
|
14325
|
-
|
|
14326
|
-
|
|
14591
|
+
import_node_fs42 = require("fs");
|
|
14592
|
+
import_node_path38 = require("path");
|
|
14327
14593
|
init_paths();
|
|
14328
14594
|
init_private_file();
|
|
14329
14595
|
hooks = {};
|
|
@@ -14332,7 +14598,7 @@ var init_caffeinate_hold = __esm({
|
|
|
14332
14598
|
|
|
14333
14599
|
// src/store/schedules.ts
|
|
14334
14600
|
function schedulesPath() {
|
|
14335
|
-
return (0,
|
|
14601
|
+
return (0, import_node_path39.join)(appDataDir(), "schedules.json");
|
|
14336
14602
|
}
|
|
14337
14603
|
function parseDurationMs(every) {
|
|
14338
14604
|
const m = every.trim().match(DURATION_RE);
|
|
@@ -14432,9 +14698,9 @@ function normalizeTask(raw) {
|
|
|
14432
14698
|
}
|
|
14433
14699
|
function readAll2() {
|
|
14434
14700
|
const path = schedulesPath();
|
|
14435
|
-
if (!(0,
|
|
14701
|
+
if (!(0, import_node_fs43.existsSync)(path)) return [];
|
|
14436
14702
|
try {
|
|
14437
|
-
const parsed = JSON.parse((0,
|
|
14703
|
+
const parsed = JSON.parse((0, import_node_fs43.readFileSync)(path, "utf8"));
|
|
14438
14704
|
if (!Array.isArray(parsed)) return [];
|
|
14439
14705
|
return parsed.map((row) => {
|
|
14440
14706
|
try {
|
|
@@ -14546,13 +14812,13 @@ function recordScheduleRun(id, result) {
|
|
|
14546
14812
|
writeAll2(rows);
|
|
14547
14813
|
return next;
|
|
14548
14814
|
}
|
|
14549
|
-
var import_node_crypto8,
|
|
14815
|
+
var import_node_crypto8, import_node_fs43, import_node_path39, import_croner, DURATION_RE, UNIT_MS;
|
|
14550
14816
|
var init_schedules = __esm({
|
|
14551
14817
|
"src/store/schedules.ts"() {
|
|
14552
14818
|
"use strict";
|
|
14553
14819
|
import_node_crypto8 = require("crypto");
|
|
14554
|
-
|
|
14555
|
-
|
|
14820
|
+
import_node_fs43 = require("fs");
|
|
14821
|
+
import_node_path39 = require("path");
|
|
14556
14822
|
import_croner = require("croner");
|
|
14557
14823
|
init_orchestrator_capable();
|
|
14558
14824
|
init_paths();
|
|
@@ -14700,10 +14966,10 @@ __export(cursor_recover_exports, {
|
|
|
14700
14966
|
function recoverFinishedCursorRun(opts) {
|
|
14701
14967
|
const agentId = opts.agentId.trim();
|
|
14702
14968
|
if (!agentId) return null;
|
|
14703
|
-
const runsPath = (0,
|
|
14704
|
-
if (!(0,
|
|
14969
|
+
const runsPath = (0, import_node_path40.join)(appDataDir(), "cursor-sdk-store", "runs.ndjson");
|
|
14970
|
+
if (!(0, import_node_fs44.existsSync)(runsPath)) return null;
|
|
14705
14971
|
try {
|
|
14706
|
-
const lines = (0,
|
|
14972
|
+
const lines = (0, import_node_fs44.readFileSync)(runsPath, "utf8").split("\n");
|
|
14707
14973
|
let best = null;
|
|
14708
14974
|
for (const line of lines) {
|
|
14709
14975
|
const trimmed = line.trim();
|
|
@@ -14729,12 +14995,12 @@ function recoverFinishedCursorRun(opts) {
|
|
|
14729
14995
|
return null;
|
|
14730
14996
|
}
|
|
14731
14997
|
}
|
|
14732
|
-
var
|
|
14998
|
+
var import_node_fs44, import_node_path40;
|
|
14733
14999
|
var init_cursor_recover = __esm({
|
|
14734
15000
|
"src/agents/cursor-recover.ts"() {
|
|
14735
15001
|
"use strict";
|
|
14736
|
-
|
|
14737
|
-
|
|
15002
|
+
import_node_fs44 = require("fs");
|
|
15003
|
+
import_node_path40 = require("path");
|
|
14738
15004
|
init_paths();
|
|
14739
15005
|
}
|
|
14740
15006
|
});
|
|
@@ -14865,14 +15131,16 @@ async function startOrchestration(opts) {
|
|
|
14865
15131
|
}
|
|
14866
15132
|
return updated;
|
|
14867
15133
|
}
|
|
14868
|
-
var import_node_events,
|
|
15134
|
+
var import_node_events, import_node_fs45, STALE_AGENT_PID_WAIT_MS, Orchestrator, singleton;
|
|
14869
15135
|
var init_orchestrator = __esm({
|
|
14870
15136
|
"src/orchestrator/orchestrator.ts"() {
|
|
14871
15137
|
"use strict";
|
|
14872
15138
|
import_node_events = require("events");
|
|
14873
15139
|
init_outbound_watch();
|
|
14874
|
-
|
|
15140
|
+
import_node_fs45 = require("fs");
|
|
14875
15141
|
init_error_detail();
|
|
15142
|
+
init_run();
|
|
15143
|
+
init_stale_lock();
|
|
14876
15144
|
init_spawn();
|
|
14877
15145
|
init_agents();
|
|
14878
15146
|
init_worktree();
|
|
@@ -14988,7 +15256,7 @@ var init_orchestrator = __esm({
|
|
|
14988
15256
|
}
|
|
14989
15257
|
continue;
|
|
14990
15258
|
}
|
|
14991
|
-
if (!(0,
|
|
15259
|
+
if (!(0, import_node_fs45.existsSync)(thread.worktreePath)) {
|
|
14992
15260
|
setStatus(thread.id, "broken", "Worktree missing on disk");
|
|
14993
15261
|
this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
|
|
14994
15262
|
continue;
|
|
@@ -15581,7 +15849,15 @@ var init_orchestrator = __esm({
|
|
|
15581
15849
|
hasSession: Boolean(this.requireThread(threadId).sessionId)
|
|
15582
15850
|
})) {
|
|
15583
15851
|
updateThread(threadId, { sessionId: null });
|
|
15584
|
-
|
|
15852
|
+
try {
|
|
15853
|
+
const gitDirs = await resolveGitDirsForLockRecovery(thread.worktreePath);
|
|
15854
|
+
const clearedLocks = clearStaleIndexLocks(gitDirs, 2e3);
|
|
15855
|
+
if (clearedLocks.length > 0) {
|
|
15856
|
+
pushTurnStderr(stderrTail, "Cleared a stale git lock left by the crashed agent process");
|
|
15857
|
+
}
|
|
15858
|
+
} catch {
|
|
15859
|
+
}
|
|
15860
|
+
const retryNote = looksLikeInvalidAgentSession(detail) ? "Agent session missing \u2014 starting a fresh session" : looksLikeV8Oom(detail) ? "Agent ran out of memory \u2014 starting a fresh session" : "Agent runner crashed \u2014 restarting Node once";
|
|
15585
15861
|
pushTurnStderr(stderrTail, retryNote);
|
|
15586
15862
|
this.emit({
|
|
15587
15863
|
type: "turn_output",
|
|
@@ -16053,13 +16329,14 @@ var init_orchestrator = __esm({
|
|
|
16053
16329
|
const text4 = (lastAgent?.text ?? "").trim() || (thread.status === "error" ? lastError ?? "" : "");
|
|
16054
16330
|
const stillRunning = thread.status === "running" || thread.status === "queued";
|
|
16055
16331
|
const live = stillRunning ? readTurnLive(thread.id) : null;
|
|
16332
|
+
const queuedHint = thread.status === "queued" && !live?.summary ? "Queued \u2014 waiting for a concurrency slot" : null;
|
|
16056
16333
|
return {
|
|
16057
16334
|
text: text4,
|
|
16058
16335
|
status: thread.status,
|
|
16059
16336
|
sessionId: thread.sessionId,
|
|
16060
16337
|
lastError,
|
|
16061
16338
|
stillRunning,
|
|
16062
|
-
progress: live?.summary ??
|
|
16339
|
+
progress: live?.summary ?? queuedHint,
|
|
16063
16340
|
lastActivityAt: live?.updatedAt ?? null
|
|
16064
16341
|
};
|
|
16065
16342
|
}
|
|
@@ -16576,7 +16853,7 @@ var init_orchestrator = __esm({
|
|
|
16576
16853
|
this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
|
|
16577
16854
|
return restored2;
|
|
16578
16855
|
}
|
|
16579
|
-
if (!(0,
|
|
16856
|
+
if (!(0, import_node_fs45.existsSync)(thread.worktreePath)) {
|
|
16580
16857
|
if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
|
|
16581
16858
|
throw new Error(
|
|
16582
16859
|
`Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
|
|
@@ -16656,7 +16933,7 @@ init_nested_electron_env();
|
|
|
16656
16933
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
16657
16934
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
16658
16935
|
var import_zod4 = require("zod");
|
|
16659
|
-
var
|
|
16936
|
+
var import_node_path41 = require("path");
|
|
16660
16937
|
init_orchestrator();
|
|
16661
16938
|
init_worktree();
|
|
16662
16939
|
|
|
@@ -17163,6 +17440,10 @@ function mcpWaitForTurnTimeoutMs(requested) {
|
|
|
17163
17440
|
return Math.min(Math.max(1e3, Math.floor(n)), MCP_WAIT_FOR_TURN_MAX_MS);
|
|
17164
17441
|
}
|
|
17165
17442
|
var MCP_WAIT_STILL_RUNNING_HINT = "Child is still working. Call wait_for_turn again. Do not send a check-in prompt or assume a hang while progress is updating.";
|
|
17443
|
+
var MCP_WAIT_QUEUED_HINT = "Child is queued waiting for a concurrency slot \u2014 it has not started yet. Call wait_for_turn again. Do not send a check-in prompt, force_stop, or assume it failed to start.";
|
|
17444
|
+
function mcpWaitStillRunningHint(status) {
|
|
17445
|
+
return status === "queued" ? MCP_WAIT_QUEUED_HINT : MCP_WAIT_STILL_RUNNING_HINT;
|
|
17446
|
+
}
|
|
17166
17447
|
|
|
17167
17448
|
// src/mcp/server.ts
|
|
17168
17449
|
init_turn_live();
|
|
@@ -18009,7 +18290,7 @@ async function startMcpServer() {
|
|
|
18009
18290
|
async () => {
|
|
18010
18291
|
const threads = orch.getThreads(true);
|
|
18011
18292
|
const lines = threads.map((t) => {
|
|
18012
|
-
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0,
|
|
18293
|
+
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path41.basename)(t.repoPath) || t.repoPath;
|
|
18013
18294
|
const live = t.status === "running" || t.status === "queued" ? readTurnLive(t.id) : null;
|
|
18014
18295
|
const progress = live?.summary ? ` ${live.summary}` : "";
|
|
18015
18296
|
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}`;
|
|
@@ -18045,7 +18326,7 @@ async function startMcpServer() {
|
|
|
18045
18326
|
prUrl: t.prUrl,
|
|
18046
18327
|
lastError: t.lastError ?? null,
|
|
18047
18328
|
stillRunning: t.status === "running" || t.status === "queued",
|
|
18048
|
-
progress: live?.summary ?? null,
|
|
18329
|
+
progress: live?.summary ?? (t.status === "queued" ? "Queued \u2014 waiting for a concurrency slot" : null),
|
|
18049
18330
|
lastActivityAt: live?.updatedAt ?? null
|
|
18050
18331
|
};
|
|
18051
18332
|
return { content: [{ type: "text", text: JSON.stringify(summary, null, 2) }] };
|
|
@@ -18379,7 +18660,7 @@ async function startMcpServer() {
|
|
|
18379
18660
|
);
|
|
18380
18661
|
server.tool(
|
|
18381
18662
|
"wait_for_turn",
|
|
18382
|
-
"Wait until the thread finishes its current/queued turn, or return early with a live progress snapshot. MCP clients often kill tools around 60s, so this returns within 45s even while the child is still working. If stillRunning is true, progress is tools/thinking \
|
|
18663
|
+
"Wait until the thread finishes its current/queued turn, or return early with a live progress snapshot. MCP clients often kill tools around 60s, so this returns within 45s even while the child is still working. If stillRunning is true, progress is tools/thinking (or \u201Cqueued, waiting for a concurrency slot\u201D if it has not started). Call wait_for_turn again. Do not send a check-in prompt, force_stop, or assume a hang. On status error, lastError/text is the failure.",
|
|
18383
18664
|
{
|
|
18384
18665
|
ref: import_zod4.z.string(),
|
|
18385
18666
|
timeoutMs: import_zod4.z.number().optional()
|
|
@@ -18401,7 +18682,7 @@ async function startMcpServer() {
|
|
|
18401
18682
|
stillRunning: result.stillRunning,
|
|
18402
18683
|
progress: result.progress,
|
|
18403
18684
|
lastActivityAt: result.lastActivityAt,
|
|
18404
|
-
hint: result.stillRunning ?
|
|
18685
|
+
hint: result.stillRunning ? mcpWaitStillRunningHint(result.status) : void 0
|
|
18405
18686
|
})
|
|
18406
18687
|
}
|
|
18407
18688
|
]
|
|
@@ -18420,7 +18701,7 @@ async function startMcpServer() {
|
|
|
18420
18701
|
type: "text",
|
|
18421
18702
|
text: JSON.stringify({
|
|
18422
18703
|
...result,
|
|
18423
|
-
hint: result.stillRunning ?
|
|
18704
|
+
hint: result.stillRunning ? mcpWaitStillRunningHint(result.status) : void 0
|
|
18424
18705
|
})
|
|
18425
18706
|
}
|
|
18426
18707
|
]
|