@sideboard-ai/core 0.1.84 → 0.1.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{agents-OPTHS4IX.js → agents-FD77JUOP.js} +10 -10
  2. package/dist/{agents-JFXM66QA.js → agents-YAYNNJWC.js} +6 -6
  3. package/dist/{chunk-ODZ2ZOA4.js → chunk-2N5DVTGH.js} +2 -2
  4. package/dist/{chunk-BBQ6HXKS.js → chunk-3CCRD6WS.js} +19 -9
  5. package/dist/{chunk-AE5VBOFE.js → chunk-3KETJKYA.js} +9 -2
  6. package/dist/{chunk-WJ5TINR6.js → chunk-6GKDYUTJ.js} +2 -2
  7. package/dist/{chunk-VROPG6QF.js → chunk-6K5VAPVR.js} +3 -3
  8. package/dist/{chunk-CKBIQ54F.js → chunk-6WQAYBVE.js} +88 -20
  9. package/dist/{chunk-BTL7EMGT.js → chunk-HHTHF5BQ.js} +4 -4
  10. package/dist/{chunk-UN3LVQB2.js → chunk-JFQ2M6NQ.js} +2 -2
  11. package/dist/{chunk-OIEFHOP7.js → chunk-JTHWVYSD.js} +2 -2
  12. package/dist/{chunk-XW47PL6A.js → chunk-KRAUS3RF.js} +86 -16
  13. package/dist/{chunk-D4DPQ552.js → chunk-LGXBYZZA.js} +9 -2
  14. package/dist/{chunk-JPHG2KCC.js → chunk-SH75CXJR.js} +1 -1
  15. package/dist/{chunk-R753UFSX.js → chunk-WGI6KXKJ.js} +14 -4
  16. package/dist/{chunk-NW7MEJHO.js → chunk-XVFV56JG.js} +1 -1
  17. package/dist/{connected-teams-ZRS53OAT.js → connected-teams-BNBM7OIC.js} +2 -2
  18. package/dist/{connected-teams-35EIRJCP.js → connected-teams-LSQ5TAZP.js} +2 -2
  19. package/dist/{coordinator-prompt-RCTIIZ6C.js → coordinator-prompt-VN7FF76K.js} +3 -3
  20. package/dist/{coordinator-prompt-DOIOSLUN.js → coordinator-prompt-YYQSPLIP.js} +3 -3
  21. package/dist/{global-workspace-73OAKD3C.js → global-workspace-BRIDCBMY.js} +4 -4
  22. package/dist/{global-workspace-33BIG7KK.js → global-workspace-U3XVTQLL.js} +4 -4
  23. package/dist/index.cjs +181 -82
  24. package/dist/index.d.cts +32 -6
  25. package/dist/index.d.ts +32 -6
  26. package/dist/index.js +36 -22
  27. package/dist/mcp/run-stdio.cjs +361 -270
  28. package/dist/mcp/run-stdio.js +34 -27
  29. package/dist/{run-V2WZUMJA.js → run-CFKZPY7F.js} +1 -1
  30. package/dist/{run-A4RHY7HH.js → run-XKTAJRWF.js} +1 -1
  31. package/dist/{workspaces-WDLY34MX.js → workspaces-AIZDG6PS.js} +5 -5
  32. package/dist/{workspaces-SRITISKA.js → workspaces-IWQIWAMQ.js} +5 -5
  33. package/dist/{worktree-TUAO74SI.js → worktree-6ZALJUWG.js} +2 -2
  34. package/dist/{worktree-SGZVAWOQ.js → worktree-7Y22WHR7.js} +2 -2
  35. package/package.json +1 -1
@@ -1732,261 +1732,9 @@ var init_gh_errors = __esm({
1732
1732
  }
1733
1733
  });
1734
1734
 
1735
- // src/git/git-auth-mode.ts
1736
- function appendIndexedGitConfig(existing, entries) {
1737
- const start = Number.parseInt(String(existing?.GIT_CONFIG_COUNT ?? "0"), 10);
1738
- const count = Number.isFinite(start) && start > 0 ? start : 0;
1739
- const out = {};
1740
- entries.forEach((entry, i) => {
1741
- const n = count + i;
1742
- out[`GIT_CONFIG_KEY_${n}`] = entry.key;
1743
- out[`GIT_CONFIG_VALUE_${n}`] = entry.value;
1744
- });
1745
- out.GIT_CONFIG_COUNT = String(count + entries.length);
1746
- return out;
1747
- }
1748
- function githubAgentGitEnv(existing) {
1749
- return appendIndexedGitConfig(existing, HTTPS_REWRITE);
1750
- }
1751
- function applyGithubGitAuthEnv(existing, opts) {
1752
- const out = {};
1753
- if (opts.mode === "gh" || opts.mode === "token") {
1754
- Object.assign(out, githubAgentGitEnv(existing));
1755
- }
1756
- if (opts.mode === "token") {
1757
- const token = opts.token?.trim();
1758
- if (token && !existing?.GH_TOKEN?.trim()) {
1759
- out.GH_TOKEN = token;
1760
- }
1761
- }
1762
- return out;
1763
- }
1764
- function formatGitAuthModeDirective(mode) {
1765
- switch (mode) {
1766
- case "gh":
1767
- return [
1768
- "Git authentication (Account \u2192 GitHub mode: gh CLI):",
1769
- "- This process rewrites `git@github.com:` and `ssh://git@github.com/` to HTTPS.",
1770
- "- `gh` supplies credentials (`gh auth git-credential`). Do not switch remotes to SSH.",
1771
- "- Push with `git push -u origin HEAD`. Create/update PRs with `gh` as below."
1772
- ].join("\n");
1773
- case "ssh":
1774
- return [
1775
- "Git authentication (Account \u2192 GitHub mode: SSH):",
1776
- "- Keep SSH remotes (`git@github.com:\u2026`). Do not rewrite them to HTTPS.",
1777
- "- Use this Mac\u2019s SSH agent / keys. If push fails with `Permission denied (publickey)`, tell the user to start ssh-agent or switch Account \u2192 GitHub to Auto / gh CLI \u2014 do not rewrite remotes yourself.",
1778
- "- Push with `git push -u origin HEAD`. Create/update PRs with `gh` as below (API still uses `gh`)."
1779
- ].join("\n");
1780
- case "token":
1781
- return [
1782
- "Git authentication (Account \u2192 GitHub mode: personal access token):",
1783
- "- This process rewrites GitHub SSH remotes to HTTPS.",
1784
- "- `GH_TOKEN` is set in the environment. Use HTTPS git and `gh`; do not paste the token into commands or chat.",
1785
- "- Push with `git push -u origin HEAD`. Create/update PRs with `gh` as below."
1786
- ].join("\n");
1787
- case "auto":
1788
- default:
1789
- return [
1790
- "Git authentication (Account \u2192 GitHub mode: auto):",
1791
- "- Prefer the existing remote URL (SSH or HTTPS). Do not rewrite remotes unless a push/fetch fails.",
1792
- '- If `git push` fails with `Permission denied (publickey)`, this shell has no ssh-agent. Retry over HTTPS (do not stop): `git -c url.https://github.com/.insteadOf=git@github.com: -c http.extraHeader="AUTHORIZATION: bearer $(gh auth token)" push -u origin HEAD`.',
1793
- "- Then create/update the PR with `gh` as below."
1794
- ].join("\n");
1795
- }
1796
- }
1797
- var HTTPS_REWRITE;
1798
- var init_git_auth_mode = __esm({
1799
- "src/git/git-auth-mode.ts"() {
1800
- "use strict";
1801
- HTTPS_REWRITE = [
1802
- { key: "url.https://github.com/.insteadOf", value: "git@github.com:" },
1803
- { key: "url.https://github.com/.insteadOf", value: "ssh://git@github.com/" },
1804
- { key: "credential.https://github.com.helper", value: "!gh auth git-credential" }
1805
- ];
1806
- }
1807
- });
1808
-
1809
- // src/agents/path.ts
1810
- function prependPathDir(env, dir) {
1811
- if (!dir || !(0, import_node_fs8.existsSync)(dir)) return;
1812
- const current = env.PATH ?? "";
1813
- const parts = current.split(import_node_path8.delimiter).filter(Boolean);
1814
- if (parts.includes(dir)) {
1815
- env.PATH = current;
1816
- return;
1817
- }
1818
- env.PATH = [dir, ...parts].join(import_node_path8.delimiter);
1819
- }
1820
- function conductorBundledBinDir(home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os3.homedir)()) {
1821
- return (0, import_node_path8.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
1822
- }
1823
- function isConductorBundledCli(filePath) {
1824
- const p = (filePath ?? "").replace(/\\/g, "/");
1825
- return p.includes("/com.conductor.app/bin/") || p.endsWith("/com.conductor.app/bin");
1826
- }
1827
- function ensureAgentPath(env = process.env) {
1828
- const home = env.HOME || env.USERPROFILE || (0, import_node_os3.homedir)();
1829
- const current = env.PATH ?? "";
1830
- const parts = current.split(import_node_path8.delimiter).filter(Boolean);
1831
- const seen = new Set(parts);
1832
- const extras = [
1833
- ...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path8.join)(home, rel)),
1834
- "/opt/homebrew/bin",
1835
- "/usr/local/bin",
1836
- // Keep after Homebrew/npm so a user-installed CLI still wins.
1837
- conductorBundledBinDir(home)
1838
- ];
1839
- for (const dir of extras.reverse()) {
1840
- if (!dir || seen.has(dir) || !(0, import_node_fs8.existsSync)(dir)) continue;
1841
- parts.unshift(dir);
1842
- seen.add(dir);
1843
- }
1844
- const next = parts.join(import_node_path8.delimiter);
1845
- env.PATH = next;
1846
- return next;
1847
- }
1848
- function enrichPathWithNpmGlobalBin(env = process.env) {
1849
- ensureAgentPath(env);
1850
- try {
1851
- const prefix = (0, import_node_child_process2.execFileSync)("npm", ["prefix", "-g"], {
1852
- encoding: "utf8",
1853
- env: { ...process.env, ...env },
1854
- timeout: 8e3,
1855
- stdio: ["ignore", "pipe", "ignore"]
1856
- }).trim().split(/\r?\n/).find(Boolean);
1857
- if (prefix) {
1858
- const binDir = process.platform === "win32" ? prefix : (0, import_node_path8.join)(prefix, "bin");
1859
- prependPathDir(env, binDir);
1860
- }
1861
- } catch {
1862
- }
1863
- return env.PATH ?? "";
1864
- }
1865
- function posixShellSingleQuote(value) {
1866
- return `'${value.replace(/'/g, `'\\''`)}'`;
1867
- }
1868
- function resolveCommandBinarySync(command, whichPath) {
1869
- const trimmed = command.trim();
1870
- if (!trimmed) return trimmed;
1871
- const match = /^(\S+)(\s[\s\S]*)?$/.exec(trimmed);
1872
- if (!match) return trimmed;
1873
- const bin = match[1];
1874
- const rest = match[2] ?? "";
1875
- if (bin.includes("/") || bin.includes("\\")) return trimmed;
1876
- const abs = whichPath?.trim().split(/\r?\n/).find(Boolean);
1877
- if (!abs) return trimmed;
1878
- return `${abs}${rest}`;
1879
- }
1880
- function withExportedPath(command, pathValue) {
1881
- const trimmed = command.trim();
1882
- if (!trimmed) return trimmed;
1883
- if (/^(export\s+PATH=|PATH=)/.test(trimmed)) return trimmed;
1884
- return `export PATH=${posixShellSingleQuote(pathValue)} && ${trimmed}`;
1885
- }
1886
- var import_node_fs8, import_node_child_process2, import_node_os3, import_node_path8, EXTRA_BIN_DIRS;
1887
- var init_path = __esm({
1888
- "src/agents/path.ts"() {
1889
- "use strict";
1890
- import_node_fs8 = require("fs");
1891
- import_node_child_process2 = require("child_process");
1892
- import_node_os3 = require("os");
1893
- import_node_path8 = require("path");
1894
- EXTRA_BIN_DIRS = [
1895
- ".local/bin",
1896
- ".cargo/bin",
1897
- ".nvm/current/bin",
1898
- ".asdf/shims",
1899
- ".volta/bin",
1900
- ".npm-global/bin",
1901
- // fnm default alias (common when shell init is skipped)
1902
- ".local/share/fnm/aliases/default/bin",
1903
- // pnpm / npm global bins (where `@brightsy/cli` typically lands)
1904
- "Library/pnpm",
1905
- ".pnpm"
1906
- ];
1907
- }
1908
- });
1909
-
1910
- // src/git/run.ts
1911
- var run_exports = {};
1912
- __export(run_exports, {
1913
- gh: () => gh,
1914
- git: () => git,
1915
- resolveGhAuthToken: () => resolveGhAuthToken,
1916
- run: () => run
1917
- });
1918
- async function run(file, args, opts) {
1919
- ensureAgentPath();
1920
- try {
1921
- const result = await (0, import_execa.execa)(file, args, {
1922
- cwd: opts?.cwd,
1923
- env: { ...process.env, ...opts?.env },
1924
- reject: opts?.reject ?? true,
1925
- ...opts?.timeoutMs != null ? { timeout: opts.timeoutMs } : {}
1926
- });
1927
- return {
1928
- stdout: result.stdout ?? "",
1929
- stderr: result.stderr ?? "",
1930
- exitCode: result.exitCode ?? 0
1931
- };
1932
- } catch (err) {
1933
- const e = err;
1934
- if (opts?.reject === false) {
1935
- return {
1936
- stdout: String(e.stdout ?? ""),
1937
- stderr: String(e.stderr ?? ""),
1938
- exitCode: e.exitCode ?? 1
1939
- };
1940
- }
1941
- throw err;
1942
- }
1943
- }
1944
- async function git(args, cwd, opts) {
1945
- const prefix = [];
1946
- if (opts?.config) {
1947
- for (const [key, value] of Object.entries(opts.config)) {
1948
- if (!key) continue;
1949
- prefix.push("-c", `${key}=${value}`);
1950
- }
1951
- }
1952
- return run("git", ["--no-pager", ...prefix, ...args], {
1953
- cwd,
1954
- reject: opts?.reject,
1955
- timeoutMs: opts?.timeoutMs,
1956
- // Never block forever on a credential/SSH prompt inside MCP / Electron.
1957
- env: {
1958
- GIT_TERMINAL_PROMPT: "0",
1959
- GIT_ASKPASS: process.env.GIT_ASKPASS || "echo",
1960
- GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND || "ssh -o BatchMode=yes -o ConnectTimeout=15",
1961
- ...opts?.env
1962
- }
1963
- });
1964
- }
1965
- async function gh(args, cwd, opts) {
1966
- return run("gh", args, {
1967
- cwd,
1968
- reject: opts?.reject,
1969
- timeoutMs: opts?.timeoutMs
1970
- });
1971
- }
1972
- async function resolveGhAuthToken(cwd) {
1973
- const result = await gh(["auth", "token"], cwd, { reject: false });
1974
- if (result.exitCode !== 0) return null;
1975
- const token = result.stdout.trim();
1976
- return token || null;
1977
- }
1978
- var import_execa;
1979
- var init_run = __esm({
1980
- "src/git/run.ts"() {
1981
- "use strict";
1982
- import_execa = require("execa");
1983
- init_path();
1984
- }
1985
- });
1986
-
1987
1735
  // src/store/secret-vault.ts
1988
1736
  function secretVaultPath() {
1989
- return (0, import_node_path9.join)(appDataDir(), "secrets.json");
1737
+ return (0, import_node_path8.join)(appDataDir(), "secrets.json");
1990
1738
  }
1991
1739
  function loadSecretVault() {
1992
1740
  const parsed = readSecureJson(secretVaultPath());
@@ -2030,11 +1778,11 @@ function normalizeVault(raw) {
2030
1778
  }
2031
1779
  return out;
2032
1780
  }
2033
- var import_node_path9;
1781
+ var import_node_path8;
2034
1782
  var init_secret_vault = __esm({
2035
1783
  "src/store/secret-vault.ts"() {
2036
1784
  "use strict";
2037
- import_node_path9 = require("path");
1785
+ import_node_path8 = require("path");
2038
1786
  init_paths();
2039
1787
  init_secure_file();
2040
1788
  }
@@ -2135,10 +1883,10 @@ function toPublicAppSettings(settings) {
2135
1883
  };
2136
1884
  }
2137
1885
  function appSettingsPath() {
2138
- return (0, import_node_path10.join)(appDataDir(), "settings.json");
1886
+ return (0, import_node_path9.join)(appDataDir(), "settings.json");
2139
1887
  }
2140
1888
  function claudeUserSettingsPath() {
2141
- return (0, import_node_path10.join)((0, import_node_os4.homedir)(), ".claude", "settings.json");
1889
+ return (0, import_node_path9.join)((0, import_node_os3.homedir)(), ".claude", "settings.json");
2142
1890
  }
2143
1891
  function normalizeClaude(raw) {
2144
1892
  if (!raw || typeof raw !== "object") return {};
@@ -2381,10 +2129,10 @@ function normalizeSettings(raw) {
2381
2129
  }
2382
2130
  function readSettingsFile() {
2383
2131
  const path = appSettingsPath();
2384
- if (!(0, import_node_fs9.existsSync)(path)) return { ...EMPTY_SETTINGS };
2132
+ if (!(0, import_node_fs8.existsSync)(path)) return { ...EMPTY_SETTINGS };
2385
2133
  try {
2386
2134
  chmodOwnerOnly(path);
2387
- const parsed = JSON.parse((0, import_node_fs9.readFileSync)(path, "utf8"));
2135
+ const parsed = JSON.parse((0, import_node_fs8.readFileSync)(path, "utf8"));
2388
2136
  return normalizeSettings(parsed);
2389
2137
  } catch {
2390
2138
  return { ...EMPTY_SETTINGS };
@@ -2769,7 +2517,7 @@ function ensureSlackDeviceIdentity(settings = loadAppSettings()) {
2769
2517
  }
2770
2518
  if (!deviceLabel) {
2771
2519
  try {
2772
- deviceLabel = (0, import_node_os4.hostname)().split(".")[0]?.trim() || "This Mac";
2520
+ deviceLabel = (0, import_node_os3.hostname)().split(".")[0]?.trim() || "This Mac";
2773
2521
  } catch {
2774
2522
  deviceLabel = "This Mac";
2775
2523
  }
@@ -2944,14 +2692,14 @@ function childEnvWithAppSettings(extra) {
2944
2692
  function harnessEnvKey(harness) {
2945
2693
  return HARNESS_ENV_KEYS[harness];
2946
2694
  }
2947
- var import_node_crypto3, import_node_fs9, import_node_os4, import_node_path10, HARNESS_ENV_KEYS, DEFAULT_AGENTS, GITHUB_GIT_AUTH_MODES, CLOUD_CONNECT_AGENTS, ISSUE_SOURCES, GIT_AUTH_MODES, EMPTY_SETTINGS, DEFAULT_CLI_BIN;
2695
+ var import_node_crypto3, import_node_fs8, import_node_os3, import_node_path9, HARNESS_ENV_KEYS, DEFAULT_AGENTS, GITHUB_GIT_AUTH_MODES, CLOUD_CONNECT_AGENTS, ISSUE_SOURCES, GIT_AUTH_MODES, EMPTY_SETTINGS, DEFAULT_CLI_BIN;
2948
2696
  var init_app_settings = __esm({
2949
2697
  "src/store/app-settings.ts"() {
2950
2698
  "use strict";
2951
2699
  import_node_crypto3 = require("crypto");
2952
- import_node_fs9 = require("fs");
2953
- import_node_os4 = require("os");
2954
- import_node_path10 = require("path");
2700
+ import_node_fs8 = require("fs");
2701
+ import_node_os3 = require("os");
2702
+ import_node_path9 = require("path");
2955
2703
  init_thinking_effort();
2956
2704
  init_nested_electron_env();
2957
2705
  init_paths();
@@ -2999,6 +2747,333 @@ var init_app_settings = __esm({
2999
2747
  }
3000
2748
  });
3001
2749
 
2750
+ // src/agents/path.ts
2751
+ function prependPathDir(env, dir) {
2752
+ if (!dir || !(0, import_node_fs9.existsSync)(dir)) return;
2753
+ const current = env.PATH ?? "";
2754
+ const parts = current.split(import_node_path10.delimiter).filter(Boolean);
2755
+ if (parts.includes(dir)) {
2756
+ env.PATH = current;
2757
+ return;
2758
+ }
2759
+ env.PATH = [dir, ...parts].join(import_node_path10.delimiter);
2760
+ }
2761
+ function conductorBundledBinDir(home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os4.homedir)()) {
2762
+ return (0, import_node_path10.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
2763
+ }
2764
+ function isConductorBundledCli(filePath) {
2765
+ const p = (filePath ?? "").replace(/\\/g, "/");
2766
+ return p.includes("/com.conductor.app/bin/") || p.endsWith("/com.conductor.app/bin");
2767
+ }
2768
+ function ensureAgentPath(env = process.env) {
2769
+ const home = env.HOME || env.USERPROFILE || (0, import_node_os4.homedir)();
2770
+ const current = env.PATH ?? "";
2771
+ const parts = current.split(import_node_path10.delimiter).filter(Boolean);
2772
+ const seen = new Set(parts);
2773
+ const extras = [
2774
+ ...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path10.join)(home, rel)),
2775
+ "/opt/homebrew/bin",
2776
+ "/usr/local/bin",
2777
+ // Keep after Homebrew/npm so a user-installed CLI still wins.
2778
+ conductorBundledBinDir(home)
2779
+ ];
2780
+ for (const dir of extras.reverse()) {
2781
+ if (!dir || seen.has(dir) || !(0, import_node_fs9.existsSync)(dir)) continue;
2782
+ parts.unshift(dir);
2783
+ seen.add(dir);
2784
+ }
2785
+ const next = parts.join(import_node_path10.delimiter);
2786
+ env.PATH = next;
2787
+ return next;
2788
+ }
2789
+ function enrichPathWithNpmGlobalBin(env = process.env) {
2790
+ ensureAgentPath(env);
2791
+ try {
2792
+ const prefix = (0, import_node_child_process2.execFileSync)("npm", ["prefix", "-g"], {
2793
+ encoding: "utf8",
2794
+ env: { ...process.env, ...env },
2795
+ timeout: 8e3,
2796
+ stdio: ["ignore", "pipe", "ignore"]
2797
+ }).trim().split(/\r?\n/).find(Boolean);
2798
+ if (prefix) {
2799
+ const binDir = process.platform === "win32" ? prefix : (0, import_node_path10.join)(prefix, "bin");
2800
+ prependPathDir(env, binDir);
2801
+ }
2802
+ } catch {
2803
+ }
2804
+ return env.PATH ?? "";
2805
+ }
2806
+ function posixShellSingleQuote(value) {
2807
+ return `'${value.replace(/'/g, `'\\''`)}'`;
2808
+ }
2809
+ function resolveCommandBinarySync(command, whichPath) {
2810
+ const trimmed = command.trim();
2811
+ if (!trimmed) return trimmed;
2812
+ const match = /^(\S+)(\s[\s\S]*)?$/.exec(trimmed);
2813
+ if (!match) return trimmed;
2814
+ const bin = match[1];
2815
+ const rest = match[2] ?? "";
2816
+ if (bin.includes("/") || bin.includes("\\")) return trimmed;
2817
+ const abs = whichPath?.trim().split(/\r?\n/).find(Boolean);
2818
+ if (!abs) return trimmed;
2819
+ return `${abs}${rest}`;
2820
+ }
2821
+ function withExportedPath(command, pathValue) {
2822
+ const trimmed = command.trim();
2823
+ if (!trimmed) return trimmed;
2824
+ if (/^(export\s+PATH=|PATH=)/.test(trimmed)) return trimmed;
2825
+ return `export PATH=${posixShellSingleQuote(pathValue)} && ${trimmed}`;
2826
+ }
2827
+ var import_node_fs9, import_node_child_process2, import_node_os4, import_node_path10, EXTRA_BIN_DIRS;
2828
+ var init_path = __esm({
2829
+ "src/agents/path.ts"() {
2830
+ "use strict";
2831
+ import_node_fs9 = require("fs");
2832
+ import_node_child_process2 = require("child_process");
2833
+ import_node_os4 = require("os");
2834
+ import_node_path10 = require("path");
2835
+ EXTRA_BIN_DIRS = [
2836
+ ".local/bin",
2837
+ ".cargo/bin",
2838
+ ".nvm/current/bin",
2839
+ ".asdf/shims",
2840
+ ".volta/bin",
2841
+ ".npm-global/bin",
2842
+ // fnm default alias (common when shell init is skipped)
2843
+ ".local/share/fnm/aliases/default/bin",
2844
+ // pnpm / npm global bins (where `@brightsy/cli` typically lands)
2845
+ "Library/pnpm",
2846
+ ".pnpm"
2847
+ ];
2848
+ }
2849
+ });
2850
+
2851
+ // src/git/run.ts
2852
+ var run_exports = {};
2853
+ __export(run_exports, {
2854
+ gh: () => gh,
2855
+ git: () => git,
2856
+ resolveGhAuthToken: () => resolveGhAuthToken,
2857
+ run: () => run
2858
+ });
2859
+ async function run(file, args, opts) {
2860
+ ensureAgentPath();
2861
+ try {
2862
+ const result = await (0, import_execa.execa)(file, args, {
2863
+ cwd: opts?.cwd,
2864
+ env: { ...process.env, ...opts?.env },
2865
+ reject: opts?.reject ?? true,
2866
+ ...opts?.timeoutMs != null ? { timeout: opts.timeoutMs } : {}
2867
+ });
2868
+ return {
2869
+ stdout: result.stdout ?? "",
2870
+ stderr: result.stderr ?? "",
2871
+ exitCode: result.exitCode ?? 0
2872
+ };
2873
+ } catch (err) {
2874
+ const e = err;
2875
+ if (opts?.reject === false) {
2876
+ return {
2877
+ stdout: String(e.stdout ?? ""),
2878
+ stderr: String(e.stderr ?? ""),
2879
+ exitCode: e.exitCode ?? 1
2880
+ };
2881
+ }
2882
+ throw err;
2883
+ }
2884
+ }
2885
+ async function git(args, cwd, opts) {
2886
+ const prefix = [];
2887
+ if (opts?.config) {
2888
+ for (const [key, value] of Object.entries(opts.config)) {
2889
+ if (!key) continue;
2890
+ prefix.push("-c", `${key}=${value}`);
2891
+ }
2892
+ }
2893
+ return run("git", ["--no-pager", ...prefix, ...args], {
2894
+ cwd,
2895
+ reject: opts?.reject,
2896
+ timeoutMs: opts?.timeoutMs,
2897
+ // Never block forever on a credential/SSH prompt inside MCP / Electron.
2898
+ env: {
2899
+ GIT_TERMINAL_PROMPT: "0",
2900
+ GIT_ASKPASS: process.env.GIT_ASKPASS || "echo",
2901
+ SSH_ASKPASS: process.env.SSH_ASKPASS || "echo",
2902
+ GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND || "ssh -o BatchMode=yes -o ConnectTimeout=15",
2903
+ GCM_INTERACTIVE: "never",
2904
+ GH_PROMPT_DISABLED: "1",
2905
+ ...opts?.env
2906
+ }
2907
+ });
2908
+ }
2909
+ async function gh(args, cwd, opts) {
2910
+ return run("gh", args, {
2911
+ cwd,
2912
+ reject: opts?.reject,
2913
+ timeoutMs: opts?.timeoutMs,
2914
+ env: {
2915
+ GH_PROMPT_DISABLED: "1",
2916
+ GIT_TERMINAL_PROMPT: "0"
2917
+ }
2918
+ });
2919
+ }
2920
+ async function resolveGhAuthToken(cwd) {
2921
+ const result = await gh(["auth", "token"], cwd, { reject: false, timeoutMs: 8e3 });
2922
+ if (result.exitCode !== 0) return null;
2923
+ const token = result.stdout.trim();
2924
+ return token || null;
2925
+ }
2926
+ var import_execa;
2927
+ var init_run = __esm({
2928
+ "src/git/run.ts"() {
2929
+ "use strict";
2930
+ import_execa = require("execa");
2931
+ init_path();
2932
+ }
2933
+ });
2934
+
2935
+ // src/git/git-auth-mode.ts
2936
+ function nonInteractiveGitProcessEnv() {
2937
+ return {
2938
+ GIT_TERMINAL_PROMPT: "0",
2939
+ GIT_ASKPASS: process.env.GIT_ASKPASS?.trim() || "echo",
2940
+ SSH_ASKPASS: process.env.SSH_ASKPASS?.trim() || "echo",
2941
+ GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND?.trim() || "ssh -o BatchMode=yes -o ConnectTimeout=15",
2942
+ GCM_INTERACTIVE: "never",
2943
+ GH_PROMPT_DISABLED: "1"
2944
+ };
2945
+ }
2946
+ function appendIndexedGitConfig(existing, entries) {
2947
+ const start = Number.parseInt(String(existing?.GIT_CONFIG_COUNT ?? "0"), 10);
2948
+ const count = Number.isFinite(start) && start > 0 ? start : 0;
2949
+ const out = {};
2950
+ entries.forEach((entry, i) => {
2951
+ const n = count + i;
2952
+ out[`GIT_CONFIG_KEY_${n}`] = entry.key;
2953
+ out[`GIT_CONFIG_VALUE_${n}`] = entry.value;
2954
+ });
2955
+ out.GIT_CONFIG_COUNT = String(count + entries.length);
2956
+ return out;
2957
+ }
2958
+ function githubAgentGitEnv(existing) {
2959
+ return appendIndexedGitConfig(existing, HTTPS_REWRITE);
2960
+ }
2961
+ function githubHttpsBearerEnv(existing, token) {
2962
+ const rewrite = githubAgentGitEnv(existing);
2963
+ const header = appendIndexedGitConfig(
2964
+ { ...existing, ...rewrite },
2965
+ [
2966
+ {
2967
+ key: "http.https://github.com/.extraHeader",
2968
+ value: `AUTHORIZATION: bearer ${token}`
2969
+ }
2970
+ ]
2971
+ );
2972
+ return { ...rewrite, ...header };
2973
+ }
2974
+ function applyGithubGitAuthEnv(existing, opts) {
2975
+ const out = { ...nonInteractiveGitProcessEnv() };
2976
+ if (opts.mode === "ssh") return out;
2977
+ const existingToken = existing?.GH_TOKEN?.trim() || "";
2978
+ const provided = existingToken ? "" : opts.token?.trim() || "";
2979
+ const token = existingToken || provided;
2980
+ Object.assign(
2981
+ out,
2982
+ token ? githubHttpsBearerEnv(existing, token) : githubAgentGitEnv(existing)
2983
+ );
2984
+ if (provided) out.GH_TOKEN = provided;
2985
+ return out;
2986
+ }
2987
+ async function resolveGithubAgentToken(mode, cwd) {
2988
+ if (mode === "ssh") return null;
2989
+ if (mode === "token") return getGithubPat();
2990
+ try {
2991
+ return await resolveGhAuthToken(cwd);
2992
+ } catch {
2993
+ return null;
2994
+ }
2995
+ }
2996
+ async function resolveAgentGitAuthEnv(existing, opts) {
2997
+ let mode = "auto";
2998
+ if (opts?.mode) {
2999
+ mode = opts.mode;
3000
+ } else {
3001
+ try {
3002
+ mode = getGithubGitAuthMode();
3003
+ } catch {
3004
+ mode = "auto";
3005
+ }
3006
+ }
3007
+ const cwd = opts?.cwd?.trim() || process.cwd();
3008
+ let token = null;
3009
+ try {
3010
+ token = await resolveGithubAgentToken(mode, cwd);
3011
+ } catch {
3012
+ token = null;
3013
+ }
3014
+ return applyGithubGitAuthEnv(existing, { mode, token });
3015
+ }
3016
+ function codexUnattendedGitConfigArgs(sandbox) {
3017
+ const args = [
3018
+ "-c",
3019
+ 'shell_environment_policy.inherit="all"',
3020
+ "-c",
3021
+ "shell_environment_policy.ignore_default_excludes=true"
3022
+ ];
3023
+ if (sandbox === "workspace-write") {
3024
+ args.push("-c", "sandbox_workspace_write.network_access=true");
3025
+ }
3026
+ return args;
3027
+ }
3028
+ function formatGitAuthModeDirective(mode) {
3029
+ switch (mode) {
3030
+ case "gh":
3031
+ return [
3032
+ "Git authentication (Account \u2192 GitHub mode: gh CLI):",
3033
+ "- This process rewrites `git@github.com:` and `ssh://git@github.com/` to HTTPS.",
3034
+ "- `GH_TOKEN` is injected from `gh auth token` (no macOS Keychain prompts). Do not switch remotes to SSH.",
3035
+ "- Push with `git push -u origin HEAD`. Create/update PRs with `gh` as below."
3036
+ ].join("\n");
3037
+ case "ssh":
3038
+ return [
3039
+ "Git authentication (Account \u2192 GitHub mode: SSH):",
3040
+ "- Keep SSH remotes (`git@github.com:\u2026`). Do not rewrite them to HTTPS.",
3041
+ "- SSH is batch-mode: it will not prompt for a Keychain password. If push fails with `Permission denied (publickey)`, tell the user to unlock ssh-agent or switch Account \u2192 GitHub to Auto / gh CLI \u2014 do not rewrite remotes yourself.",
3042
+ "- Push with `git push -u origin HEAD`. Create/update PRs with `gh` as below (API still uses `gh`)."
3043
+ ].join("\n");
3044
+ case "token":
3045
+ return [
3046
+ "Git authentication (Account \u2192 GitHub mode: personal access token):",
3047
+ "- This process rewrites GitHub SSH remotes to HTTPS.",
3048
+ "- `GH_TOKEN` is set in the environment. Use HTTPS git and `gh`; do not paste the token into commands or chat.",
3049
+ "- Push with `git push -u origin HEAD`. Create/update PRs with `gh` as below."
3050
+ ].join("\n");
3051
+ case "auto":
3052
+ default:
3053
+ return [
3054
+ "Git authentication (Account \u2192 GitHub mode: auto):",
3055
+ "- This process rewrites GitHub SSH remotes to HTTPS and authenticates with `GH_TOKEN` from `gh` so git/ssh never prompt the macOS Keychain (required for Slack / unattended Cursor).",
3056
+ "- Do not switch remotes to SSH. Push with `git push -u origin HEAD`.",
3057
+ "- If HTTPS auth fails, tell the user to run `gh auth login` on this Mac or set Account \u2192 GitHub to a PAT \u2014 do not wait for a Keychain dialog."
3058
+ ].join("\n");
3059
+ }
3060
+ }
3061
+ var HTTPS_REWRITE;
3062
+ var init_git_auth_mode = __esm({
3063
+ "src/git/git-auth-mode.ts"() {
3064
+ "use strict";
3065
+ init_app_settings();
3066
+ init_run();
3067
+ HTTPS_REWRITE = [
3068
+ { key: "url.https://github.com/.insteadOf", value: "git@github.com:" },
3069
+ { key: "url.https://github.com/.insteadOf", value: "ssh://git@github.com/" },
3070
+ // Empty helper disables ~/.gitconfig osxkeychain so GUI agents cannot pop
3071
+ // "git-credential-osxkeychain wants to use the keychain".
3072
+ { key: "credential.helper", value: "" }
3073
+ ];
3074
+ }
3075
+ });
3076
+
3002
3077
  // src/git/pr-gates.ts
3003
3078
  function prIsInMergeQueue(gate) {
3004
3079
  if (gate.isInMergeQueue) return true;
@@ -3456,7 +3531,7 @@ async function originGhRepoEnv(cwd, opts) {
3456
3531
  await ensureGhPreferOrigin(cwd);
3457
3532
  const slug = await resolveGithubRepoSlug(cwd);
3458
3533
  const mode = opts?.mode ?? getGithubGitAuthMode();
3459
- const token = mode === "token" ? getGithubPat() : null;
3534
+ const token = mode === "token" ? getGithubPat() : mode === "ssh" ? null : await resolveGhAuthToken(cwd);
3460
3535
  return {
3461
3536
  ...applyGithubGitAuthEnv(opts?.env, { mode, token }),
3462
3537
  ...slug ? { GH_REPO: slug } : {}
@@ -5814,6 +5889,10 @@ async function buildInjectedMcpServers(opts) {
5814
5889
  if (orchId) {
5815
5890
  sideboard.env.SIDEBOARD_ORCHESTRATOR_THREAD_ID = orchId;
5816
5891
  }
5892
+ try {
5893
+ Object.assign(sideboard.env, await resolveAgentGitAuthEnv(sideboard.env));
5894
+ } catch {
5895
+ }
5817
5896
  servers.push(sideboard);
5818
5897
  }
5819
5898
  if (opts.includeBrightsy && isBrightsyConnected()) {
@@ -5916,6 +5995,7 @@ var init_injected_mcp = __esm({
5916
5995
  init_paths();
5917
5996
  init_node_launch();
5918
5997
  init_nested_electron_env();
5998
+ init_git_auth_mode();
5919
5999
  import_meta = {};
5920
6000
  SIDEBOARD_MCP_ALLOWED_TOOLS = [
5921
6001
  "mcp__sideboard",
@@ -6455,6 +6535,7 @@ var init_codex = __esm({
6455
6535
  init_global_workspace();
6456
6536
  init_error_detail();
6457
6537
  init_usage();
6538
+ init_git_auth_mode();
6458
6539
  init_injected_mcp();
6459
6540
  init_turn_input();
6460
6541
  init_types();
@@ -6546,6 +6627,8 @@ var init_codex = __esm({
6546
6627
  // `codex exec` rejects `--ask-for-approval` (global-only on newer CLIs).
6547
6628
  "-c",
6548
6629
  'approval_policy="never"',
6630
+ // Seatbelt cannot use the login Keychain; default policy also strips GH_TOKEN.
6631
+ ...codexUnattendedGitConfigArgs(mode.codexSandbox),
6549
6632
  ...model ? ["--model", model] : [],
6550
6633
  ...mcpOverrides
6551
6634
  ];
@@ -8825,6 +8908,7 @@ init_error_detail();
8825
8908
  var import_node_readline = require("readline");
8826
8909
  var import_execa2 = require("execa");
8827
8910
  init_worktree();
8911
+ init_git_auth_mode();
8828
8912
  init_app_settings();
8829
8913
  init_global_workspace();
8830
8914
  init_brightsy();
@@ -9087,14 +9171,16 @@ async function spawnAgentTurn(thread, input, onEvent) {
9087
9171
  );
9088
9172
  }
9089
9173
  const env = childEnvWithAppSettings(cmd.env);
9090
- if (!isOrchestratorThread(thread)) {
9091
- try {
9174
+ try {
9175
+ if (isOrchestratorThread(thread)) {
9176
+ Object.assign(env, await resolveAgentGitAuthEnv(env));
9177
+ } else {
9092
9178
  const originEnv = await originGhRepoEnv(thread.worktreePath, { env });
9093
9179
  Object.assign(env, originEnv);
9094
- } catch (err) {
9095
- const detail = err instanceof Error ? err.message : String(err);
9096
- console.warn(`[sideboard] originGhRepoEnv failed (${thread.worktreePath}): ${detail}`);
9097
9180
  }
9181
+ } catch (err) {
9182
+ const detail = err instanceof Error ? err.message : String(err);
9183
+ console.warn(`[sideboard] git auth env failed (${thread.worktreePath}): ${detail}`);
9098
9184
  }
9099
9185
  const child = (0, import_execa2.execa)(cmd.file, cmd.args, {
9100
9186
  cwd: cmd.cwd,
@@ -9308,6 +9394,7 @@ var import_execa3 = require("execa");
9308
9394
  var import_node_readline2 = require("readline");
9309
9395
  init_settings();
9310
9396
  init_nested_electron_env();
9397
+ init_git_auth_mode();
9311
9398
  init_nested_electron_env();
9312
9399
  var PORT_RANGE_SIZE = 10;
9313
9400
  function matchSimpleGlob(pattern, name) {
@@ -9481,6 +9568,10 @@ async function spawnWorkspaceScript(command, opts) {
9481
9568
  },
9482
9569
  loginEnv
9483
9570
  );
9571
+ try {
9572
+ Object.assign(env, await resolveAgentGitAuthEnv(env, { cwd: opts.worktreePath }));
9573
+ } catch {
9574
+ }
9484
9575
  const shell = process.platform === "darwin" ? "zsh" : "bash";
9485
9576
  const child = (0, import_execa3.execa)(shell, ["-lc", command], {
9486
9577
  cwd: opts.worktreePath,