@sideboard-ai/core 0.1.349 → 0.1.350

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 (78) hide show
  1. package/dist/{abletime-CGFJZB7L.js → abletime-TX7BTTR2.js} +5 -5
  2. package/dist/{abletime-3HRWLQZJ.js → abletime-URSRZW7P.js} +4 -4
  3. package/dist/{abletime-oauth-QNJQLHR4.js → abletime-oauth-QS3WPSCC.js} +3 -3
  4. package/dist/{abletime-oauth-JQDSH5OL.js → abletime-oauth-SL3NMNEC.js} +4 -4
  5. package/dist/{abletime-rest-TANL5TMY.js → abletime-rest-GGQLUO55.js} +3 -3
  6. package/dist/{abletime-rest-UQA2CRZN.js → abletime-rest-JZU6JJCV.js} +4 -4
  7. package/dist/agents/acp-runner.cjs +491 -0
  8. package/dist/agents/acp-runner.d.cts +46 -0
  9. package/dist/agents/acp-runner.d.ts +46 -0
  10. package/dist/agents/acp-runner.js +323 -0
  11. package/dist/{agents-DMPBFF3F.js → agents-P5QIV24I.js} +37 -7
  12. package/dist/{agents-AZ2PV6XP.js → agents-RGAV5OHD.js} +42 -11
  13. package/dist/{app-settings-SNOPJ7P5.js → app-settings-IA7ZZKWQ.js} +2 -2
  14. package/dist/{app-settings-PPIMYJKS.js → app-settings-XILTSD6L.js} +1 -1
  15. package/dist/{chunk-Q4I6KDOL.js → chunk-2MESZ5XR.js} +60 -39
  16. package/dist/{chunk-RUIHNWRV.js → chunk-37ZBEBP6.js} +6 -6
  17. package/dist/{chunk-WHMLMCPU.js → chunk-5AHWUJRT.js} +1925 -1722
  18. package/dist/{chunk-7B2OUQON.js → chunk-5TCMXEYL.js} +48 -3
  19. package/dist/{chunk-FDYMVJFU.js → chunk-5WF54R3B.js} +5 -5
  20. package/dist/{chunk-PVCECFJK.js → chunk-7ZD4OK6G.js} +1 -1
  21. package/dist/{chunk-RYPD7XWV.js → chunk-B4EFQTMP.js} +5 -5
  22. package/dist/chunk-BF6INES4.js +144 -0
  23. package/dist/{chunk-IVRWRYTH.js → chunk-BZK62VPT.js} +2 -2
  24. package/dist/{chunk-AJMERXZP.js → chunk-CCWQ65VD.js} +2 -2
  25. package/dist/{chunk-62ALWH3T.js → chunk-DL4OHDBV.js} +3 -3
  26. package/dist/{chunk-CATTIFSP.js → chunk-EZ2MUWNW.js} +3 -3
  27. package/dist/{chunk-4NXGVJA6.js → chunk-F4RFFE2H.js} +48 -3
  28. package/dist/{chunk-E77SRVVO.js → chunk-FCKTBE26.js} +1 -1
  29. package/dist/{chunk-3DBL2C45.js → chunk-FQ3JYUKI.js} +2 -2
  30. package/dist/{chunk-CEQ4Z32M.js → chunk-J4EA5SHF.js} +3 -3
  31. package/dist/{chunk-MHSBF3SO.js → chunk-LFSTOECH.js} +3 -3
  32. package/dist/{chunk-OHUAAX3O.js → chunk-M45WGODR.js} +2 -2
  33. package/dist/{chunk-MVFFLU5V.js → chunk-MANERA6F.js} +12 -5
  34. package/dist/{chunk-ZXI5DR5S.js → chunk-NDEVAA34.js} +1624 -1487
  35. package/dist/{chunk-UJMCTGV7.js → chunk-PXSWVZIL.js} +2 -2
  36. package/dist/{chunk-6RIPZ73M.js → chunk-SMSD6U3N.js} +3 -1
  37. package/dist/{chunk-RPHH4FNK.js → chunk-TCEUNSLX.js} +3 -1
  38. package/dist/chunk-TRMPDDVL.js +232 -0
  39. package/dist/{chunk-6WMNIX2U.js → chunk-UFUAIVNV.js} +9 -5
  40. package/dist/{chunk-QHXZKHUL.js → chunk-VHQ6OG3U.js} +2 -2
  41. package/dist/{chunk-WWU4SYZR.js → chunk-VL6F2KRE.js} +5 -1
  42. package/dist/{chunk-IRFBD6GU.js → chunk-W5GHFT7E.js} +71 -47
  43. package/dist/{chunk-5FUAOU3G.js → chunk-WB3G2LQO.js} +1 -1
  44. package/dist/{chunk-JCYGQKER.js → chunk-WFX4ZVSZ.js} +1 -1
  45. package/dist/{chunk-F7WP2U5I.js → chunk-WJURGCBR.js} +1 -1
  46. package/dist/chunk-YE7Z5WH3.js +142 -0
  47. package/dist/{chunk-ROXM6QZV.js → chunk-ZBSEJIOV.js} +12 -5
  48. package/dist/{conductor-NHC6X74J.js → conductor-HVOGBK63.js} +6 -5
  49. package/dist/{conductor-65VPUPOW.js → conductor-VGCXUUG6.js} +7 -6
  50. package/dist/connected-teams-2YDE2EZ2.js +1 -1
  51. package/dist/{coordinator-prompt-5GZWIVSY.js → coordinator-prompt-DPO7L2JO.js} +5 -5
  52. package/dist/{coordinator-prompt-R2PURZL3.js → coordinator-prompt-E736TJBS.js} +4 -4
  53. package/dist/{global-workspace-64KC7PST.js → global-workspace-4RDPAOTT.js} +5 -5
  54. package/dist/{global-workspace-UEECLWSX.js → global-workspace-TG2TVLUF.js} +4 -4
  55. package/dist/index.cjs +1600 -929
  56. package/dist/index.d.cts +132 -891
  57. package/dist/index.d.ts +132 -891
  58. package/dist/index.js +433 -207
  59. package/dist/{linear-PKYJH4WK.js → linear-E3BX5PX5.js} +2 -2
  60. package/dist/{linear-MIJO6DCV.js → linear-WG23LBCX.js} +3 -3
  61. package/dist/{linear-list-JPQ27RXG.js → linear-list-OINZWVV5.js} +1 -1
  62. package/dist/{linear-list-N57PR6JM.js → linear-list-VU47BNUV.js} +1 -1
  63. package/dist/mcp/run-stdio.cjs +1097 -720
  64. package/dist/mcp/run-stdio.js +32 -24
  65. package/dist/{optional-cli-4GTEDEYJ.js → optional-cli-K6HX2X5O.js} +4 -3
  66. package/dist/{optional-cli-RPJIQBDX.js → optional-cli-SA3EQYML.js} +6 -5
  67. package/dist/{orchestrator-Y5PYSMR6.js → orchestrator-3I2FLEZL.js} +17 -15
  68. package/dist/{orchestrator-I5G5A5BV.js → orchestrator-QDHZ56LA.js} +11 -10
  69. package/dist/thread-CJRchYLj.d.cts +856 -0
  70. package/dist/thread-CJRchYLj.d.ts +856 -0
  71. package/dist/{thread-store-HZ4U4OXB.js → thread-store-4YTOV2HL.js} +3 -3
  72. package/dist/{thread-store-QKNU5CHM.js → thread-store-LME2ICZP.js} +2 -2
  73. package/dist/{workspaces-6TIM2TM2.js → workspaces-4PA24IX6.js} +4 -4
  74. package/dist/{workspaces-I2EHNTFE.js → workspaces-6TMYV4N2.js} +5 -5
  75. package/dist/{worktree-7JFYDNUX.js → worktree-4ATMCYIE.js} +3 -3
  76. package/dist/{worktree-M2GJGK2P.js → worktree-DA6SKIU5.js} +4 -4
  77. package/package.json +3 -3
  78. /package/dist/{chunk-XOEKCE6L.js → chunk-OHXNGBC4.js} +0 -0
@@ -5340,6 +5340,7 @@ function normalizeDefaults(raw) {
5340
5340
  if (typeof source.agent === "string" && DEFAULT_AGENTS.has(source.agent)) {
5341
5341
  out.agent = source.agent;
5342
5342
  }
5343
+ if (source.acpHarness === "gemini" || source.acpHarness === "copilot") out.acpHarness = source.acpHarness;
5343
5344
  if (typeof source.model === "string") {
5344
5345
  const model = source.model.trim();
5345
5346
  if (model) out.model = model;
@@ -6035,6 +6036,8 @@ function updateDefaultsSettings(patch) {
6035
6036
  defaults.agent = patch.agent;
6036
6037
  }
6037
6038
  }
6039
+ if (patch.acpHarness === "gemini" || patch.acpHarness === "copilot") defaults.acpHarness = patch.acpHarness;
6040
+ else if ("acpHarness" in patch) delete defaults.acpHarness;
6038
6041
  if ("model" in patch) {
6039
6042
  if (patch.model == null || patch.model.trim() === "") {
6040
6043
  delete defaults.model;
@@ -6645,7 +6648,8 @@ var init_app_settings = __esm({
6645
6648
  "codex",
6646
6649
  "opencode",
6647
6650
  "brightsy",
6648
- "cursor"
6651
+ "cursor",
6652
+ "acp"
6649
6653
  ]);
6650
6654
  GITHUB_GIT_AUTH_MODES = ["auto", "gh", "ssh", "token"];
6651
6655
  FOLLOW_UP_BEHAVIORS = ["steer", "queue"];
@@ -8784,6 +8788,7 @@ function normalizeThread(raw) {
8784
8788
  return {
8785
8789
  ...raw,
8786
8790
  model: raw.model ?? null,
8791
+ acpHarness: raw.acpHarness === "gemini" || raw.acpHarness === "copilot" ? raw.acpHarness : void 0,
8787
8792
  effort: resolveThreadEffort(raw),
8788
8793
  fast: Boolean(raw.fast),
8789
8794
  planMode: Boolean(raw.planMode),
@@ -8872,6 +8877,7 @@ function createEmptyThread(partial) {
8872
8877
  worktreePath: partial.worktreePath,
8873
8878
  repoPath: partial.repoPath,
8874
8879
  agent: partial.agent,
8880
+ ...partial.acpHarness === "gemini" || partial.acpHarness === "copilot" ? { acpHarness: partial.acpHarness } : {},
8875
8881
  lastError: null,
8876
8882
  agentPid: null,
8877
8883
  agentPidStartedAt: null,
@@ -12713,124 +12719,201 @@ var init_brightsy = __esm({
12713
12719
  }
12714
12720
  });
12715
12721
 
12716
- // src/agents/claude-mcp-status.ts
12717
- function mcpStatusThinkingFromClaudeInit(obj) {
12718
- const raw = obj.mcp_servers ?? obj.mcpServers;
12719
- const servers = [];
12720
- if (Array.isArray(raw)) {
12721
- for (const item of raw) {
12722
- if (!item || typeof item !== "object" || Array.isArray(item)) continue;
12723
- const rec = item;
12724
- const name = typeof rec.name === "string" && rec.name.trim() || typeof rec.server === "string" && rec.server.trim() || "";
12725
- const status = typeof rec.status === "string" && rec.status.trim() || typeof rec.state === "string" && rec.state.trim() || "";
12726
- if (name) servers.push({ name, status: status || "unknown" });
12727
- }
12728
- } else if (raw && typeof raw === "object") {
12729
- for (const [name, value] of Object.entries(raw)) {
12730
- if (!name.trim()) continue;
12731
- if (typeof value === "string" && value.trim()) {
12732
- servers.push({ name, status: value.trim() });
12733
- continue;
12734
- }
12735
- if (value && typeof value === "object" && !Array.isArray(value)) {
12736
- const rec = value;
12737
- const status = typeof rec.status === "string" && rec.status.trim() || typeof rec.state === "string" && rec.state.trim() || "unknown";
12738
- servers.push({ name, status });
12739
- }
12740
- }
12722
+ // src/agents/acp-harness.ts
12723
+ function isAcpHarnessId(value) {
12724
+ return value === "gemini" || value === "copilot";
12725
+ }
12726
+ function defaultAcpHarness() {
12727
+ const stored = loadAppSettings().defaults?.acpHarness;
12728
+ return isAcpHarnessId(stored) ? stored : "gemini";
12729
+ }
12730
+ function envSet(env, ...keys) {
12731
+ return keys.some((key) => Boolean(env[key]?.trim()));
12732
+ }
12733
+ function fileMentionsCredential(path) {
12734
+ try {
12735
+ if (!(0, import_node_fs27.existsSync)(path)) return false;
12736
+ const text8 = (0, import_node_fs27.readFileSync)(path, "utf8").slice(0, AUTH_READ_MAX);
12737
+ return /"(access_token|refresh_token|oauth_token|api_key|apiKey)"\s*:/i.test(text8) || /oauth_token\s*:/i.test(text8);
12738
+ } catch {
12739
+ return false;
12741
12740
  }
12742
- const coverage = claudeConnectorCoverage();
12743
- const sideboardOk = sideboardMcpOk(servers);
12744
- const notable = servers.filter(
12745
- (server) => isNotableMcpInitStatus(server, sideboardOk, coverage)
12746
- );
12747
- if (notable.length === 0) return null;
12748
- return `MCP: ${notable.map((s) => `${s.name} ${s.status}`).join(", ")}`;
12749
12741
  }
12750
- function isCleanMcpConnect(status) {
12751
- return /^(connected|ok|ready|success)$/i.test(status.trim());
12742
+ function acpHarnessLooksAuthenticated(id, env = process.env, home = (0, import_node_os9.homedir)(), opts) {
12743
+ if (id === "gemini") {
12744
+ if (envSet(env, "GEMINI_API_KEY", "GOOGLE_API_KEY", "GOOGLE_GENAI_API_KEY")) return true;
12745
+ return fileMentionsCredential((0, import_node_path29.join)(home, ".gemini", "oauth_creds.json")) || fileMentionsCredential((0, import_node_path29.join)(home, ".gemini", "google_accounts.json"));
12746
+ }
12747
+ if (envSet(env, "COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN")) return true;
12748
+ if (fileMentionsCredential((0, import_node_path29.join)(home, ".copilot", "config.json")) || fileMentionsCredential((0, import_node_path29.join)(home, ".config", "gh", "hosts.yml"))) {
12749
+ return true;
12750
+ }
12751
+ return opts?.ghLoggedIn === true;
12752
12752
  }
12753
- function isMcpAuthStatus(status) {
12754
- return /needs[_-]?auth|needs authentication|unauthorized|not authenticated|authrequired/i.test(
12755
- status
12753
+ async function copilotGhLoggedIn() {
12754
+ const status = await run("gh", ["auth", "status"], { reject: false, timeoutMs: 5e3 });
12755
+ return status.exitCode === 0;
12756
+ }
12757
+ function acpHarnessStatus(input) {
12758
+ const spec = ACP_HARNESSES[input.id];
12759
+ if (!input.binPath) {
12760
+ return {
12761
+ agent: "acp",
12762
+ acpHarness: input.id,
12763
+ label: spec.label,
12764
+ installed: false,
12765
+ authenticated: false,
12766
+ linearMcp: false,
12767
+ warnings: [],
12768
+ reason: `${spec.label} is not on PATH (\`${spec.bin}\`). ${spec.installCommand}`
12769
+ };
12770
+ }
12771
+ const authenticated = acpHarnessLooksAuthenticated(
12772
+ input.id,
12773
+ input.env ?? process.env,
12774
+ input.home ?? (0, import_node_os9.homedir)(),
12775
+ { ghLoggedIn: input.ghLoggedIn }
12756
12776
  );
12777
+ return {
12778
+ agent: "acp",
12779
+ acpHarness: input.id,
12780
+ label: spec.label,
12781
+ installed: true,
12782
+ authenticated,
12783
+ linearMcp: false,
12784
+ warnings: [],
12785
+ ...authenticated ? {} : { reason: spec.authHint }
12786
+ };
12757
12787
  }
12758
- function isSideboardMcpName(name) {
12759
- return /^sideboard$/i.test(name.trim()) || /^mcp__sideboard$/i.test(name.trim());
12788
+ async function resolveAcpHarnessCommand(id) {
12789
+ const spec = ACP_HARNESSES[id];
12790
+ const which = await run("which", [spec.bin], { reject: false, timeoutMs: 3e3 });
12791
+ const file = which.exitCode === 0 ? which.stdout.trim().split("\n")[0]?.trim() ?? "" : "";
12792
+ if (!file) {
12793
+ throw new Error(`${spec.label} is not on PATH. ${spec.installCommand}`);
12794
+ }
12795
+ return { file, args: [...spec.args] };
12796
+ }
12797
+ async function detectAcpHarness(id) {
12798
+ const spec = ACP_HARNESSES[id];
12799
+ const which = await run("which", [spec.bin], { reject: false, timeoutMs: 3e3 });
12800
+ const file = which.exitCode === 0 ? which.stdout.trim().split("\n")[0]?.trim() ?? "" : "";
12801
+ const ghLoggedIn = id === "copilot" && file && !acpHarnessLooksAuthenticated(id) ? await copilotGhLoggedIn() : false;
12802
+ return acpHarnessStatus({ id, binPath: file || null, ghLoggedIn });
12803
+ }
12804
+ var import_node_fs27, import_node_os9, import_node_path29, ACP_HARNESSES, ACP_HARNESS_IDS, AUTH_READ_MAX;
12805
+ var init_acp_harness = __esm({
12806
+ "src/agents/acp-harness.ts"() {
12807
+ "use strict";
12808
+ import_node_fs27 = require("fs");
12809
+ import_node_os9 = require("os");
12810
+ import_node_path29 = require("path");
12811
+ init_run();
12812
+ init_app_settings();
12813
+ ACP_HARNESSES = {
12814
+ gemini: {
12815
+ id: "gemini",
12816
+ label: "Gemini CLI",
12817
+ bin: "gemini",
12818
+ args: ["--acp"],
12819
+ npmPackage: "@google/gemini-cli",
12820
+ installCommand: "npm install -g @google/gemini-cli",
12821
+ loginCommand: "gemini",
12822
+ docsUrl: "https://geminicli.com/docs/cli/acp-mode/",
12823
+ authHint: "Gemini CLI is on PATH but no API key or ~/.gemini login was found. Set GEMINI_API_KEY or run `gemini` once to sign in."
12824
+ },
12825
+ copilot: {
12826
+ id: "copilot",
12827
+ label: "Copilot CLI",
12828
+ bin: "copilot",
12829
+ args: ["--acp", "--stdio"],
12830
+ npmPackage: "@github/copilot",
12831
+ installCommand: "npm install -g @github/copilot",
12832
+ loginCommand: "copilot",
12833
+ docsUrl: "https://docs.github.com/en/copilot/reference/copilot-cli-reference/acp-server",
12834
+ authHint: "Copilot CLI is on PATH but no GitHub login was found. Run `gh auth login` or `copilot`, or set GH_TOKEN."
12835
+ }
12836
+ };
12837
+ ACP_HARNESS_IDS = Object.keys(ACP_HARNESSES);
12838
+ AUTH_READ_MAX = 64e3;
12839
+ }
12840
+ });
12841
+
12842
+ // src/agents/acp-protocol.ts
12843
+ function acpStdioServerFromEntry(name, entry) {
12844
+ const trimmed = name.trim();
12845
+ if (!trimmed) return null;
12846
+ const type = typeof entry.type === "string" ? entry.type : "";
12847
+ if (type === "http" || type === "sse" || typeof entry.url === "string") return null;
12848
+ const command = typeof entry.command === "string" ? entry.command.trim() : "";
12849
+ if (!command) return null;
12850
+ const args = Array.isArray(entry.args) ? entry.args.filter((item) => typeof item === "string") : [];
12851
+ const env = [];
12852
+ const rawEnv = entry.env;
12853
+ if (rawEnv && typeof rawEnv === "object" && !Array.isArray(rawEnv)) {
12854
+ for (const [key, value] of Object.entries(rawEnv)) {
12855
+ if (key === "ELECTRON_RUN_AS_NODE" || typeof value !== "string") continue;
12856
+ env.push({ name: key, value });
12857
+ }
12858
+ }
12859
+ return { name: trimmed, command, args, env };
12760
12860
  }
12761
- function isVendorClaudeAiMcpName(name) {
12762
- return /^claude\.ai\b/i.test(name.trim()) || /^mcp__claude_ai_/i.test(name.trim());
12861
+ function acpUserStdioServers(entries, taken) {
12862
+ const out = [];
12863
+ for (const [name, entry] of Object.entries(entries)) {
12864
+ if (taken.has(name.trim())) continue;
12865
+ const server = acpStdioServerFromEntry(name, entry);
12866
+ if (server) out.push(server);
12867
+ }
12868
+ return out;
12763
12869
  }
12764
- function sideboardMcpOk(servers) {
12765
- const row = servers.find((server) => isSideboardMcpName(server.name));
12766
- return Boolean(row && isCleanMcpConnect(row.status));
12870
+ function toAcpMcpServers(servers) {
12871
+ return servers.map((server) => ({
12872
+ name: server.name,
12873
+ command: server.command,
12874
+ args: server.args ?? [],
12875
+ env: Object.entries(server.env ?? {}).map(([name, value]) => ({ name, value }))
12876
+ }));
12767
12877
  }
12768
- function sideboardServiceForClaudeConnector(name) {
12769
- const raw = name.trim();
12770
- if (!raw || isSideboardMcpName(raw)) return null;
12771
- const pluginLike = /^(?:plugin[:_]|mcp__plugin_|claude\.ai\s|(?:mcp__)?claude_ai_)/i.test(raw);
12772
- const doubled = raw.match(/^mcp_([a-z0-9]+)_([a-z0-9]+)$/i);
12773
- if (!pluginLike && !(doubled && doubled[1].toLowerCase() === doubled[2].toLowerCase())) {
12774
- return null;
12878
+ function acpPriorTranscript(messages) {
12879
+ const rows = [];
12880
+ for (const message of messages) {
12881
+ if (message.role !== "user" && message.role !== "agent" && message.role !== "summary") {
12882
+ continue;
12883
+ }
12884
+ const text8 = message.text?.trim() ?? "";
12885
+ if (!text8) continue;
12886
+ rows.push({ role: message.role, text: text8 });
12775
12887
  }
12776
- let body = raw;
12777
- if (/^claude\.ai\s+/i.test(body)) body = body.replace(/^claude\.ai\s+/i, "");
12778
- else if (/^(?:mcp__)?claude_ai_/i.test(body)) body = body.replace(/^(?:mcp__)?claude_ai_/i, "");
12779
- else if (/^mcp__plugin_/i.test(body)) body = body.slice("mcp__plugin_".length);
12780
- else if (/^plugin_/i.test(body)) body = body.slice("plugin_".length);
12781
- else if (/^plugin:/i.test(body)) body = body.slice("plugin:".length);
12782
- else if (/^mcp_/i.test(body)) body = body.slice("mcp_".length);
12783
- const head = body.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)[0];
12784
- if (!head || !SIDEBOARD_CONNECTOR_SERVICES.includes(head)) return null;
12785
- return head;
12888
+ const last = rows[rows.length - 1];
12889
+ if (last?.role === "user") rows.pop();
12890
+ return rows;
12786
12891
  }
12787
- function claudeConnectorCoverage() {
12788
- let github = false;
12789
- try {
12790
- github = githubAgentAuthReady();
12791
- } catch {
12792
- github = false;
12793
- }
12794
- let linear = false;
12795
- let posthog = false;
12796
- let vercel = false;
12797
- let supabase = false;
12798
- let sentry = false;
12892
+ function parseAcpRunnerLine(line) {
12893
+ const trimmed = line.trim();
12894
+ if (!trimmed.startsWith("{")) return null;
12799
12895
  try {
12800
- linear = isLinearConnected();
12801
- posthog = isPosthogConnected();
12802
- const integrations = loadAppSettings().integrations ?? {};
12803
- if (integrations.githubPat?.trim()) github = true;
12804
- vercel = Boolean(integrations.vercelToken?.trim());
12805
- supabase = Boolean(integrations.supabaseAccessToken?.trim());
12806
- sentry = Boolean(integrations.sentryAuthToken?.trim());
12896
+ const parsed = JSON.parse(trimmed);
12897
+ if (typeof parsed.type !== "string" || !AGENT_EVENT_TYPES.has(parsed.type)) return null;
12898
+ return parsed;
12807
12899
  } catch {
12900
+ return null;
12808
12901
  }
12809
- return { github, linear, posthog, vercel, supabase, sentry };
12810
12902
  }
12811
- function isNotableMcpInitStatus(server, sideboardOk, coverage) {
12812
- if (isCleanMcpConnect(server.status)) return false;
12813
- if (isSideboardMcpName(server.name)) return true;
12814
- if (isMcpAuthStatus(server.status)) return false;
12815
- const service = sideboardServiceForClaudeConnector(server.name);
12816
- if (service) return !(sideboardOk && coverage[service]);
12817
- if (isVendorClaudeAiMcpName(server.name)) return false;
12818
- return true;
12819
- }
12820
- var SIDEBOARD_CONNECTOR_SERVICES;
12821
- var init_claude_mcp_status = __esm({
12822
- "src/agents/claude-mcp-status.ts"() {
12903
+ var AGENT_EVENT_TYPES;
12904
+ var init_acp_protocol = __esm({
12905
+ "src/agents/acp-protocol.ts"() {
12823
12906
  "use strict";
12824
- init_github_agent_auth();
12825
- init_app_settings();
12826
- SIDEBOARD_CONNECTOR_SERVICES = [
12827
- "github",
12828
- "linear",
12829
- "posthog",
12830
- "vercel",
12831
- "supabase",
12832
- "sentry"
12833
- ];
12907
+ AGENT_EVENT_TYPES = /* @__PURE__ */ new Set([
12908
+ "stdout",
12909
+ "stderr",
12910
+ "session_id",
12911
+ "thinking",
12912
+ "tool_use",
12913
+ "tool_result",
12914
+ "usage",
12915
+ "exit"
12916
+ ]);
12834
12917
  }
12835
12918
  });
12836
12919
 
@@ -13003,18 +13086,18 @@ function claudePluginServerId(pluginName, serverName) {
13003
13086
  return `plugin_${pluginName}_${serverName}`.replace(/[^A-Za-z0-9_-]/g, "_");
13004
13087
  }
13005
13088
  function listEnabledClaudePluginMcpServers(opts) {
13006
- const home = opts?.home ?? (0, import_node_os9.homedir)();
13089
+ const home = opts?.home ?? (0, import_node_os10.homedir)();
13007
13090
  const pluginsRoot = claudePluginsRoot(home);
13008
13091
  const enabled = enabledPluginIds(home, opts?.projectDirs ?? []);
13009
- const installed = readInstalledPlugins((0, import_node_path29.join)(pluginsRoot, "installed_plugins.json"));
13092
+ const installed = readInstalledPlugins((0, import_node_path30.join)(pluginsRoot, "installed_plugins.json"));
13010
13093
  const out = {};
13011
13094
  for (const [id, on] of enabled) {
13012
13095
  if (!on) continue;
13013
13096
  const root = installPathFor(id, installed);
13014
- if (!root || !(0, import_node_fs27.existsSync)(root)) continue;
13097
+ if (!root || !(0, import_node_fs28.existsSync)(root)) continue;
13015
13098
  const pluginName = manifestName(root) || id.split("@")[0]?.trim() || "";
13016
13099
  if (!pluginName) continue;
13017
- const dataDir = (0, import_node_path29.join)(pluginsRoot, "data", pluginDataId(id));
13100
+ const dataDir = (0, import_node_path30.join)(pluginsRoot, "data", pluginDataId(id));
13018
13101
  for (const [serverName, entry] of Object.entries(loadPluginMcpServers(root))) {
13019
13102
  const expanded = expandPluginEntry(entry, root, dataDir);
13020
13103
  if (!parseMcpServerLaunch(expanded)) continue;
@@ -13027,21 +13110,21 @@ function listEnabledClaudePluginMcpServers(opts) {
13027
13110
  }
13028
13111
  function claudePluginsRoot(home) {
13029
13112
  const override = process.env.CLAUDE_CODE_PLUGIN_CACHE_DIR?.trim();
13030
- if (override && (0, import_node_path29.isAbsolute)(override)) return override;
13031
- return (0, import_node_path29.join)(home, ".claude", "plugins");
13113
+ if (override && (0, import_node_path30.isAbsolute)(override)) return override;
13114
+ return (0, import_node_path30.join)(home, ".claude", "plugins");
13032
13115
  }
13033
13116
  function pluginDataId(pluginId) {
13034
13117
  return pluginId.replace(/[^A-Za-z0-9_-]/g, "-");
13035
13118
  }
13036
13119
  function enabledPluginIds(home, projectDirs) {
13037
13120
  const enabled = /* @__PURE__ */ new Map();
13038
- applyEnabled(enabled, readEnabledPlugins((0, import_node_path29.join)(home, ".claude", "settings.json")));
13121
+ applyEnabled(enabled, readEnabledPlugins((0, import_node_path30.join)(home, ".claude", "settings.json")));
13039
13122
  const dirs = [...new Set(projectDirs.map((dir) => dir.trim()).filter(Boolean))];
13040
13123
  for (const dir of dirs) {
13041
- applyEnabled(enabled, readEnabledPlugins((0, import_node_path29.join)(dir, ".claude", "settings.json")));
13124
+ applyEnabled(enabled, readEnabledPlugins((0, import_node_path30.join)(dir, ".claude", "settings.json")));
13042
13125
  }
13043
13126
  for (const dir of dirs) {
13044
- applyEnabled(enabled, readEnabledPlugins((0, import_node_path29.join)(dir, ".claude", "settings.local.json")));
13127
+ applyEnabled(enabled, readEnabledPlugins((0, import_node_path30.join)(dir, ".claude", "settings.local.json")));
13045
13128
  }
13046
13129
  return enabled;
13047
13130
  }
@@ -13085,18 +13168,18 @@ function installPathFor(id, installed) {
13085
13168
  const rows = installed[id] ?? [];
13086
13169
  for (let i = rows.length - 1; i >= 0; i--) {
13087
13170
  const path = rows[i]?.installPath;
13088
- if (path && (0, import_node_fs27.existsSync)(path)) return path;
13171
+ if (path && (0, import_node_fs28.existsSync)(path)) return path;
13089
13172
  }
13090
13173
  return null;
13091
13174
  }
13092
13175
  function manifestName(root) {
13093
- const manifest = readJson((0, import_node_path29.join)(root, ".claude-plugin", "plugin.json"));
13176
+ const manifest = readJson((0, import_node_path30.join)(root, ".claude-plugin", "plugin.json"));
13094
13177
  return typeof manifest.name === "string" ? manifest.name.trim() : "";
13095
13178
  }
13096
13179
  function loadPluginMcpServers(root) {
13097
13180
  const servers = {};
13098
- mergeServerMap(servers, serversFromFile((0, import_node_path29.join)(root, ".mcp.json"), root));
13099
- const manifest = readJson((0, import_node_path29.join)(root, ".claude-plugin", "plugin.json"));
13181
+ mergeServerMap(servers, serversFromFile((0, import_node_path30.join)(root, ".mcp.json"), root));
13182
+ const manifest = readJson((0, import_node_path30.join)(root, ".claude-plugin", "plugin.json"));
13100
13183
  mergeServerMap(servers, serversFromManifest(manifest.mcpServers, root));
13101
13184
  return servers;
13102
13185
  }
@@ -13114,7 +13197,7 @@ function serversFromManifest(value, root) {
13114
13197
  return serverMap(value, root);
13115
13198
  }
13116
13199
  function serversFromFile(path, root) {
13117
- if (!path || !(0, import_node_fs27.existsSync)(path)) return {};
13200
+ if (!path || !(0, import_node_fs28.existsSync)(path)) return {};
13118
13201
  return serverMap(readJson(path), root);
13119
13202
  }
13120
13203
  function serverMap(value, root) {
@@ -13170,28 +13253,28 @@ function resolveInside(root, spec) {
13170
13253
  const trimmed = spec.trim();
13171
13254
  if (!trimmed || trimmed.endsWith(".mcpb") || trimmed.endsWith(".dxt")) return null;
13172
13255
  if (/^https?:\/\//i.test(trimmed)) return null;
13173
- const abs = (0, import_node_path29.resolve)(root, trimmed);
13174
- const rel = (0, import_node_path29.relative)(root, abs);
13175
- if (!rel || rel.startsWith("..") || (0, import_node_path29.isAbsolute)(rel)) return null;
13256
+ const abs = (0, import_node_path30.resolve)(root, trimmed);
13257
+ const rel = (0, import_node_path30.relative)(root, abs);
13258
+ if (!rel || rel.startsWith("..") || (0, import_node_path30.isAbsolute)(rel)) return null;
13176
13259
  return abs;
13177
13260
  }
13178
13261
  function readJson(path) {
13179
- if (!(0, import_node_fs27.existsSync)(path)) return {};
13262
+ if (!(0, import_node_fs28.existsSync)(path)) return {};
13180
13263
  try {
13181
- const parsed = JSON.parse((0, import_node_fs27.readFileSync)(path, "utf8"));
13264
+ const parsed = JSON.parse((0, import_node_fs28.readFileSync)(path, "utf8"));
13182
13265
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
13183
13266
  return parsed;
13184
13267
  } catch {
13185
13268
  return {};
13186
13269
  }
13187
13270
  }
13188
- var import_node_fs27, import_node_os9, import_node_path29;
13271
+ var import_node_fs28, import_node_os10, import_node_path30;
13189
13272
  var init_claude_plugins = __esm({
13190
13273
  "src/agents/claude-plugins.ts"() {
13191
13274
  "use strict";
13192
- import_node_fs27 = require("fs");
13193
- import_node_os9 = require("os");
13194
- import_node_path29 = require("path");
13275
+ import_node_fs28 = require("fs");
13276
+ import_node_os10 = require("os");
13277
+ import_node_path30 = require("path");
13195
13278
  init_meta();
13196
13279
  }
13197
13280
  });
@@ -13298,43 +13381,43 @@ function electronResourcesPath() {
13298
13381
  function packagedCursorRuntimeDir() {
13299
13382
  const resources = electronResourcesPath();
13300
13383
  if (!resources) return null;
13301
- const dir = (0, import_node_path30.join)(resources, "cursor-runtime");
13302
- if (!(0, import_node_fs28.existsSync)((0, import_node_path30.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
13384
+ const dir = (0, import_node_path31.join)(resources, "cursor-runtime");
13385
+ if (!(0, import_node_fs29.existsSync)((0, import_node_path31.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
13303
13386
  return dir;
13304
13387
  }
13305
13388
  function packagedCursorRunnerPath() {
13306
13389
  const dir = packagedCursorRuntimeDir();
13307
- return dir ? (0, import_node_path30.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
13390
+ return dir ? (0, import_node_path31.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
13308
13391
  }
13309
13392
  function packagedMcpDir() {
13310
13393
  const resources = electronResourcesPath();
13311
13394
  if (!resources) return null;
13312
- const dir = (0, import_node_path30.join)(resources, "sideboard-mcp");
13313
- if (!(0, import_node_fs28.existsSync)((0, import_node_path30.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
13395
+ const dir = (0, import_node_path31.join)(resources, "sideboard-mcp");
13396
+ if (!(0, import_node_fs29.existsSync)((0, import_node_path31.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
13314
13397
  return dir;
13315
13398
  }
13316
13399
  function packagedMcpStdioPath() {
13317
13400
  const dir = packagedMcpDir();
13318
- return dir ? (0, import_node_path30.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
13401
+ return dir ? (0, import_node_path31.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
13319
13402
  }
13320
13403
  function packagedBundledNodePath() {
13321
13404
  const resources = electronResourcesPath();
13322
13405
  if (!resources) return null;
13323
- const bin = (0, import_node_path30.join)(resources, "node", "bin", "node");
13324
- if (!(0, import_node_fs28.existsSync)(bin)) return null;
13406
+ const bin = (0, import_node_path31.join)(resources, "node", "bin", "node");
13407
+ if (!(0, import_node_fs29.existsSync)(bin)) return null;
13325
13408
  return bin;
13326
13409
  }
13327
13410
  function packagedCursorRipgrepCandidate(platformPkg, binName) {
13328
13411
  const dir = packagedCursorRuntimeDir();
13329
13412
  if (!dir) return null;
13330
- return (0, import_node_path30.join)(dir, "node_modules", platformPkg, "bin", binName);
13413
+ return (0, import_node_path31.join)(dir, "node_modules", platformPkg, "bin", binName);
13331
13414
  }
13332
- var import_node_fs28, import_node_path30;
13415
+ var import_node_fs29, import_node_path31;
13333
13416
  var init_packaged_runtime = __esm({
13334
13417
  "src/agents/packaged-runtime.ts"() {
13335
13418
  "use strict";
13336
- import_node_fs28 = require("fs");
13337
- import_node_path30 = require("path");
13419
+ import_node_fs29 = require("fs");
13420
+ import_node_path31 = require("path");
13338
13421
  }
13339
13422
  });
13340
13423
 
@@ -13369,7 +13452,7 @@ function unpackedAsarPath(filePath) {
13369
13452
  if (!isAsarPath(filePath)) return null;
13370
13453
  const unpacked = filePath.replace(/\.asar(?=[/\\])/, ".asar.unpacked");
13371
13454
  if (unpacked === filePath) return null;
13372
- return (0, import_node_fs29.existsSync)(unpacked) ? unpacked : null;
13455
+ return (0, import_node_fs30.existsSync)(unpacked) ? unpacked : null;
13373
13456
  }
13374
13457
  function nodeReadableScriptPath(scriptPath) {
13375
13458
  return unpackedAsarPath(scriptPath) ?? scriptPath;
@@ -13409,37 +13492,37 @@ function pickPreferredNode(candidates) {
13409
13492
  return best;
13410
13493
  }
13411
13494
  function versionDirNodeBins(root, toBin) {
13412
- if (!(0, import_node_fs29.existsSync)(root)) return [];
13495
+ if (!(0, import_node_fs30.existsSync)(root)) return [];
13413
13496
  try {
13414
- return (0, import_node_fs29.readdirSync)(root).map(toBin);
13497
+ return (0, import_node_fs30.readdirSync)(root).map(toBin);
13415
13498
  } catch {
13416
13499
  return [];
13417
13500
  }
13418
13501
  }
13419
- function defaultNodeBinCandidates(home = (0, import_node_os10.homedir)()) {
13502
+ function defaultNodeBinCandidates(home = (0, import_node_os11.homedir)()) {
13420
13503
  const kegs = ["/opt/homebrew", "/usr/local"].flatMap(
13421
- (prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path31.join)(prefix, "opt", `node@${major}`, "bin", "node"))
13504
+ (prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path32.join)(prefix, "opt", `node@${major}`, "bin", "node"))
13422
13505
  );
13423
13506
  return [
13424
13507
  ...kegs,
13425
13508
  "/opt/homebrew/bin/node",
13426
13509
  "/usr/local/bin/node",
13427
- (0, import_node_path31.join)(home, ".local/share/fnm/aliases/default/bin/node"),
13428
- (0, import_node_path31.join)(home, ".nvm/current/bin/node"),
13429
- (0, import_node_path31.join)(home, ".volta/bin/node"),
13430
- (0, import_node_path31.join)(home, ".asdf/shims/node"),
13431
- (0, import_node_path31.join)(home, ".local/share/mise/shims/node"),
13510
+ (0, import_node_path32.join)(home, ".local/share/fnm/aliases/default/bin/node"),
13511
+ (0, import_node_path32.join)(home, ".nvm/current/bin/node"),
13512
+ (0, import_node_path32.join)(home, ".volta/bin/node"),
13513
+ (0, import_node_path32.join)(home, ".asdf/shims/node"),
13514
+ (0, import_node_path32.join)(home, ".local/share/mise/shims/node"),
13432
13515
  ...versionDirNodeBins(
13433
- (0, import_node_path31.join)(home, ".nvm", "versions", "node"),
13434
- (name) => (0, import_node_path31.join)(home, ".nvm", "versions", "node", name, "bin", "node")
13516
+ (0, import_node_path32.join)(home, ".nvm", "versions", "node"),
13517
+ (name) => (0, import_node_path32.join)(home, ".nvm", "versions", "node", name, "bin", "node")
13435
13518
  ),
13436
13519
  ...versionDirNodeBins(
13437
- (0, import_node_path31.join)(home, ".local/share/fnm", "node-versions"),
13438
- (name) => (0, import_node_path31.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
13520
+ (0, import_node_path32.join)(home, ".local/share/fnm", "node-versions"),
13521
+ (name) => (0, import_node_path32.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
13439
13522
  ),
13440
13523
  ...versionDirNodeBins(
13441
- (0, import_node_path31.join)(home, ".volta", "tools", "image", "node"),
13442
- (name) => (0, import_node_path31.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
13524
+ (0, import_node_path32.join)(home, ".volta", "tools", "image", "node"),
13525
+ (name) => (0, import_node_path32.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
13443
13526
  )
13444
13527
  ];
13445
13528
  }
@@ -13448,10 +13531,10 @@ function uniqueExistingNodeBins(paths) {
13448
13531
  const out = [];
13449
13532
  for (const raw of paths) {
13450
13533
  const p = raw.trim();
13451
- if (!p || !(0, import_node_fs29.existsSync)(p) || isElectronLikeCommand(p)) continue;
13534
+ if (!p || !(0, import_node_fs30.existsSync)(p) || isElectronLikeCommand(p)) continue;
13452
13535
  let key = p;
13453
13536
  try {
13454
- key = (0, import_node_fs29.realpathSync)(p);
13537
+ key = (0, import_node_fs30.realpathSync)(p);
13455
13538
  } catch {
13456
13539
  continue;
13457
13540
  }
@@ -13531,13 +13614,13 @@ async function resolveNodeLaunch(scriptPath) {
13531
13614
  env: { ELECTRON_RUN_AS_NODE: "1" }
13532
13615
  };
13533
13616
  }
13534
- var import_node_fs29, import_node_os10, import_node_path31, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
13617
+ var import_node_fs30, import_node_os11, import_node_path32, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
13535
13618
  var init_node_launch = __esm({
13536
13619
  "src/agents/node-launch.ts"() {
13537
13620
  "use strict";
13538
- import_node_fs29 = require("fs");
13539
- import_node_os10 = require("os");
13540
- import_node_path31 = require("path");
13621
+ import_node_fs30 = require("fs");
13622
+ import_node_os11 = require("os");
13623
+ import_node_path32 = require("path");
13541
13624
  init_nested_electron_env();
13542
13625
  init_system_ca();
13543
13626
  init_run();
@@ -13573,22 +13656,22 @@ function writeCodexMcpSecretProfile(servers) {
13573
13656
  blocks.push(lines.join("\n"));
13574
13657
  }
13575
13658
  if (blocks.length === 0) return null;
13576
- const home = process.env.CODEX_HOME?.trim() || (0, import_node_path32.join)((0, import_node_os11.homedir)(), ".codex");
13577
- (0, import_node_fs30.mkdirSync)(home, { recursive: true, mode: 448 });
13659
+ const home = process.env.CODEX_HOME?.trim() || (0, import_node_path33.join)((0, import_node_os12.homedir)(), ".codex");
13660
+ (0, import_node_fs31.mkdirSync)(home, { recursive: true, mode: 448 });
13578
13661
  const profile = `sideboard-${(0, import_node_crypto7.randomBytes)(8).toString("hex")}`;
13579
- const file = (0, import_node_path32.join)(home, `${profile}.config.toml`);
13580
- (0, import_node_fs30.writeFileSync)(file, `${blocks.join("\n\n")}
13662
+ const file = (0, import_node_path33.join)(home, `${profile}.config.toml`);
13663
+ (0, import_node_fs31.writeFileSync)(file, `${blocks.join("\n\n")}
13581
13664
  `, { mode: 384 });
13582
13665
  return { profile, file };
13583
13666
  }
13584
- var import_node_crypto7, import_node_fs30, import_node_os11, import_node_path32;
13667
+ var import_node_crypto7, import_node_fs31, import_node_os12, import_node_path33;
13585
13668
  var init_codex_mcp_profile = __esm({
13586
13669
  "src/agents/codex-mcp-profile.ts"() {
13587
13670
  "use strict";
13588
13671
  import_node_crypto7 = require("crypto");
13589
- import_node_fs30 = require("fs");
13590
- import_node_os11 = require("os");
13591
- import_node_path32 = require("path");
13672
+ import_node_fs31 = require("fs");
13673
+ import_node_os12 = require("os");
13674
+ import_node_path33 = require("path");
13592
13675
  }
13593
13676
  });
13594
13677
 
@@ -13686,37 +13769,37 @@ function corePackageDir() {
13686
13769
  try {
13687
13770
  const url = import_meta2.url;
13688
13771
  if (typeof url === "string" && url.length > 0) {
13689
- return (0, import_node_path33.dirname)((0, import_node_url.fileURLToPath)(url));
13772
+ return (0, import_node_path34.dirname)((0, import_node_url.fileURLToPath)(url));
13690
13773
  }
13691
13774
  } catch {
13692
13775
  }
13693
13776
  try {
13694
- const req = (0, import_node_module.createRequire)((0, import_node_path33.join)(process.cwd(), "package.json"));
13695
- return (0, import_node_path33.dirname)(req.resolve("@sideboard-ai/core"));
13777
+ const req = (0, import_node_module.createRequire)((0, import_node_path34.join)(process.cwd(), "package.json"));
13778
+ return (0, import_node_path34.dirname)(req.resolve("@sideboard-ai/core"));
13696
13779
  } catch {
13697
13780
  return process.cwd();
13698
13781
  }
13699
13782
  }
13700
13783
  function findSideboardMcpJsEntry() {
13701
13784
  const override = process.env.SIDEBOARD_MCP_ENTRY?.trim() || process.env.SIDEBOARD_CLI?.trim();
13702
- if (override && (0, import_node_fs31.existsSync)(override)) return override;
13785
+ if (override && (0, import_node_fs32.existsSync)(override)) return override;
13703
13786
  const packaged = packagedMcpStdioPath();
13704
13787
  if (packaged) return packaged;
13705
13788
  let dir = corePackageDir();
13706
13789
  for (let i = 0; i < 10; i++) {
13707
13790
  const candidates = [
13708
- (0, import_node_path33.join)(dir, "mcp/run-stdio.js"),
13709
- (0, import_node_path33.join)(dir, "mcp/run-stdio.cjs"),
13710
- (0, import_node_path33.join)(dir, "dist/mcp/run-stdio.js"),
13711
- (0, import_node_path33.join)(dir, "dist/mcp/run-stdio.cjs"),
13712
- (0, import_node_path33.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
13713
- (0, import_node_path33.join)(dir, "packages/cli/dist/index.js"),
13714
- (0, import_node_path33.join)(dir, "cli/dist/index.js")
13791
+ (0, import_node_path34.join)(dir, "mcp/run-stdio.js"),
13792
+ (0, import_node_path34.join)(dir, "mcp/run-stdio.cjs"),
13793
+ (0, import_node_path34.join)(dir, "dist/mcp/run-stdio.js"),
13794
+ (0, import_node_path34.join)(dir, "dist/mcp/run-stdio.cjs"),
13795
+ (0, import_node_path34.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
13796
+ (0, import_node_path34.join)(dir, "packages/cli/dist/index.js"),
13797
+ (0, import_node_path34.join)(dir, "cli/dist/index.js")
13715
13798
  ];
13716
13799
  for (const p of candidates) {
13717
- if ((0, import_node_fs31.existsSync)(p) && !isAsarPath(p)) return p;
13800
+ if ((0, import_node_fs32.existsSync)(p) && !isAsarPath(p)) return p;
13718
13801
  }
13719
- const parent = (0, import_node_path33.dirname)(dir);
13802
+ const parent = (0, import_node_path34.dirname)(dir);
13720
13803
  if (parent === dir) break;
13721
13804
  dir = parent;
13722
13805
  }
@@ -13878,19 +13961,19 @@ function mcpServersRecord(servers, extraServers) {
13878
13961
  function writeMcpServersConfig(servers, extraServers) {
13879
13962
  const mcpServers = mcpServersRecord(servers, extraServers);
13880
13963
  if (Object.keys(mcpServers).length === 0) return null;
13881
- const dir = (0, import_node_fs31.mkdtempSync)((0, import_node_path33.join)((0, import_node_os12.tmpdir)(), "sideboard-mcp-"));
13882
- const cfgPath = (0, import_node_path33.join)(dir, "mcp.json");
13883
- (0, import_node_fs31.writeFileSync)(cfgPath, JSON.stringify({ mcpServers }, null, 2), { mode: 384 });
13964
+ const dir = (0, import_node_fs32.mkdtempSync)((0, import_node_path34.join)((0, import_node_os13.tmpdir)(), "sideboard-mcp-"));
13965
+ const cfgPath = (0, import_node_path34.join)(dir, "mcp.json");
13966
+ (0, import_node_fs32.writeFileSync)(cfgPath, JSON.stringify({ mcpServers }, null, 2), { mode: 384 });
13884
13967
  return cfgPath;
13885
13968
  }
13886
- var import_node_fs31, import_node_module, import_node_os12, import_node_path33, import_node_url, import_meta2, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS, SIDEBOARD_GITHUB_MCP_ALLOWED_TOOLS, SIDEBOARD_LINEAR_MCP_ALLOWED_TOOLS, SIDEBOARD_ABLETIME_MCP_ALLOWED_TOOLS, brightsyMcpCommandCache, BRIGHTSY_WORD;
13969
+ var import_node_fs32, import_node_module, import_node_os13, import_node_path34, import_node_url, import_meta2, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS, SIDEBOARD_GITHUB_MCP_ALLOWED_TOOLS, SIDEBOARD_LINEAR_MCP_ALLOWED_TOOLS, SIDEBOARD_ABLETIME_MCP_ALLOWED_TOOLS, brightsyMcpCommandCache, BRIGHTSY_WORD;
13887
13970
  var init_injected_mcp = __esm({
13888
13971
  "src/agents/injected-mcp.ts"() {
13889
13972
  "use strict";
13890
- import_node_fs31 = require("fs");
13973
+ import_node_fs32 = require("fs");
13891
13974
  import_node_module = require("module");
13892
- import_node_os12 = require("os");
13893
- import_node_path33 = require("path");
13975
+ import_node_os13 = require("os");
13976
+ import_node_path34 = require("path");
13894
13977
  import_node_url = require("url");
13895
13978
  init_run();
13896
13979
  init_config();
@@ -13954,15 +14037,15 @@ var init_injected_mcp = __esm({
13954
14037
 
13955
14038
  // src/agents/user-mcp-config.ts
13956
14039
  function userClaudeMcpConfigPath() {
13957
- return (0, import_node_path34.join)((0, import_node_os13.homedir)(), ".claude.json");
14040
+ return (0, import_node_path35.join)((0, import_node_os14.homedir)(), ".claude.json");
13958
14041
  }
13959
- var import_node_fs32, import_node_os13, import_node_path34;
14042
+ var import_node_fs33, import_node_os14, import_node_path35;
13960
14043
  var init_user_mcp_config = __esm({
13961
14044
  "src/agents/user-mcp-config.ts"() {
13962
14045
  "use strict";
13963
- import_node_fs32 = require("fs");
13964
- import_node_os13 = require("os");
13965
- import_node_path34 = require("path");
14046
+ import_node_fs33 = require("fs");
14047
+ import_node_os14 = require("os");
14048
+ import_node_path35 = require("path");
13966
14049
  init_paths();
13967
14050
  init_injected_mcp();
13968
14051
  }
@@ -13990,31 +14073,31 @@ function listMcpNamesFromCodexToml(text8) {
13990
14073
  }
13991
14074
  function readJsonObject2(path) {
13992
14075
  try {
13993
- return JSON.parse((0, import_node_fs33.readFileSync)(path, "utf8"));
14076
+ return JSON.parse((0, import_node_fs34.readFileSync)(path, "utf8"));
13994
14077
  } catch {
13995
14078
  return {};
13996
14079
  }
13997
14080
  }
13998
14081
  function readText(path) {
13999
14082
  try {
14000
- return (0, import_node_fs33.readFileSync)(path, "utf8");
14083
+ return (0, import_node_fs34.readFileSync)(path, "utf8");
14001
14084
  } catch {
14002
14085
  return "";
14003
14086
  }
14004
14087
  }
14005
- function userCodexConfigPaths(home = (0, import_node_os14.homedir)()) {
14088
+ function userCodexConfigPaths(home = (0, import_node_os15.homedir)()) {
14006
14089
  const paths = [
14007
- (0, import_node_path35.join)(home, ".codex", "config.toml"),
14008
- (0, import_node_path35.join)(home, ".config", "codex", "config.toml")
14090
+ (0, import_node_path36.join)(home, ".codex", "config.toml"),
14091
+ (0, import_node_path36.join)(home, ".config", "codex", "config.toml")
14009
14092
  ];
14010
14093
  const codexHome = process.env.CODEX_HOME?.trim();
14011
- if (codexHome) paths.unshift((0, import_node_path35.join)(codexHome, "config.toml"));
14094
+ if (codexHome) paths.unshift((0, import_node_path36.join)(codexHome, "config.toml"));
14012
14095
  return paths;
14013
14096
  }
14014
- function userOpencodeConfigPaths(home = (0, import_node_os14.homedir)()) {
14097
+ function userOpencodeConfigPaths(home = (0, import_node_os15.homedir)()) {
14015
14098
  return [
14016
- (0, import_node_path35.join)(home, ".config", "opencode", "opencode.json"),
14017
- (0, import_node_path35.join)(home, ".config", "opencode", "opencode.jsonc")
14099
+ (0, import_node_path36.join)(home, ".config", "opencode", "opencode.json"),
14100
+ (0, import_node_path36.join)(home, ".config", "opencode", "opencode.jsonc")
14018
14101
  ];
14019
14102
  }
14020
14103
  function userMcpNamesToDisable(opts) {
@@ -14033,28 +14116,28 @@ function userMcpNamesToDisable(opts) {
14033
14116
  }
14034
14117
  return out;
14035
14118
  }
14036
- function listUserCodexMcpNames(home = (0, import_node_os14.homedir)()) {
14119
+ function listUserCodexMcpNames(home = (0, import_node_os15.homedir)()) {
14037
14120
  const names = [];
14038
14121
  for (const path of userCodexConfigPaths(home)) {
14039
- if (!(0, import_node_fs33.existsSync)(path)) continue;
14122
+ if (!(0, import_node_fs34.existsSync)(path)) continue;
14040
14123
  names.push(...listMcpNamesFromCodexToml(readText(path)));
14041
14124
  }
14042
14125
  return names;
14043
14126
  }
14044
- function listUserOpencodeMcpNames(home = (0, import_node_os14.homedir)()) {
14127
+ function listUserOpencodeMcpNames(home = (0, import_node_os15.homedir)()) {
14045
14128
  const names = [];
14046
14129
  for (const path of userOpencodeConfigPaths(home)) {
14047
- if (!(0, import_node_fs33.existsSync)(path)) continue;
14130
+ if (!(0, import_node_fs34.existsSync)(path)) continue;
14048
14131
  names.push(...listMcpNamesFromJsonMap(readJsonObject2(path), "mcp"));
14049
14132
  }
14050
14133
  return names;
14051
14134
  }
14052
- function userClaudeMcpConfigObject(home = (0, import_node_os14.homedir)()) {
14053
- const claudePath = home === (0, import_node_os14.homedir)() ? userClaudeMcpConfigPath() : (0, import_node_path35.join)(home, ".claude.json");
14054
- if (!(0, import_node_fs33.existsSync)(claudePath)) return {};
14135
+ function userClaudeMcpConfigObject(home = (0, import_node_os15.homedir)()) {
14136
+ const claudePath = home === (0, import_node_os15.homedir)() ? userClaudeMcpConfigPath() : (0, import_node_path36.join)(home, ".claude.json");
14137
+ if (!(0, import_node_fs34.existsSync)(claudePath)) return {};
14055
14138
  return asObject(asObject(readJsonObject2(claudePath)).mcpServers);
14056
14139
  }
14057
- function listUserClaudeMcpServerEntries(home = (0, import_node_os14.homedir)(), projectDirs) {
14140
+ function listUserClaudeMcpServerEntries(home = (0, import_node_os15.homedir)(), projectDirs) {
14058
14141
  const out = {};
14059
14142
  for (const [name, entry] of Object.entries(
14060
14143
  listEnabledClaudePluginMcpServers({ home, projectDirs })
@@ -14090,19 +14173,260 @@ function toCodexUnattendedAppsArgs() {
14090
14173
  "features.plugins=false"
14091
14174
  ];
14092
14175
  }
14093
- var import_node_fs33, import_node_os14, import_node_path35, import_smol_toml2;
14176
+ var import_node_fs34, import_node_os15, import_node_path36, import_smol_toml2;
14094
14177
  var init_orch_mcp_isolation = __esm({
14095
14178
  "src/agents/orch-mcp-isolation.ts"() {
14096
14179
  "use strict";
14097
- import_node_fs33 = require("fs");
14180
+ import_node_fs34 = require("fs");
14098
14181
  init_claude_plugins();
14099
- import_node_os14 = require("os");
14100
- import_node_path35 = require("path");
14182
+ import_node_os15 = require("os");
14183
+ import_node_path36 = require("path");
14101
14184
  import_smol_toml2 = require("smol-toml");
14102
14185
  init_user_mcp_config();
14103
14186
  }
14104
14187
  });
14105
14188
 
14189
+ // src/agents/acp.ts
14190
+ function entryDir() {
14191
+ const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
14192
+ if (cjsDir) return cjsDir;
14193
+ try {
14194
+ return (0, import_node_path37.dirname)((0, import_node_url2.fileURLToPath)(import_meta3.url));
14195
+ } catch {
14196
+ try {
14197
+ const req = (0, import_node_module2.createRequire)(process.cwd() + "/");
14198
+ return (0, import_node_path37.dirname)(req.resolve("@sideboard-ai/core"));
14199
+ } catch {
14200
+ return process.cwd();
14201
+ }
14202
+ }
14203
+ }
14204
+ function acpRunnerPath() {
14205
+ const packagedRoot = packagedCursorRuntimeDir();
14206
+ if (packagedRoot) {
14207
+ const packaged = (0, import_node_path37.join)(packagedRoot, "core-dist", "agents", "acp-runner.js");
14208
+ if ((0, import_node_fs35.existsSync)(packaged)) return packaged;
14209
+ }
14210
+ const root = entryDir();
14211
+ const candidates = [
14212
+ (0, import_node_path37.join)(root, "agents", "acp-runner.js"),
14213
+ (0, import_node_path37.join)(root, "agents", "acp-runner.cjs"),
14214
+ (0, import_node_path37.join)(root, "dist", "agents", "acp-runner.js"),
14215
+ (0, import_node_path37.join)(root, "dist", "agents", "acp-runner.cjs"),
14216
+ (0, import_node_path37.join)(root, "acp-runner.ts"),
14217
+ (0, import_node_path37.join)(root, "src", "agents", "acp-runner.ts")
14218
+ ];
14219
+ for (const candidate of candidates) {
14220
+ if ((0, import_node_fs35.existsSync)(candidate)) return candidate;
14221
+ }
14222
+ return candidates[0];
14223
+ }
14224
+ function harnessFor(thread) {
14225
+ return isAcpHarnessId(thread.acpHarness) ? thread.acpHarness : defaultAcpHarness();
14226
+ }
14227
+ var import_node_fs35, import_node_module2, import_node_os16, import_node_path37, import_node_url2, import_meta3, ACP_ATTACH_ERROR, acpAdapter;
14228
+ var init_acp = __esm({
14229
+ "src/agents/acp.ts"() {
14230
+ "use strict";
14231
+ import_node_fs35 = require("fs");
14232
+ import_node_module2 = require("module");
14233
+ import_node_os16 = require("os");
14234
+ import_node_path37 = require("path");
14235
+ import_node_url2 = require("url");
14236
+ init_global_workspace();
14237
+ init_acp_harness();
14238
+ init_acp_protocol();
14239
+ init_orch_mcp_isolation();
14240
+ init_injected_mcp();
14241
+ init_node_launch();
14242
+ init_packaged_runtime();
14243
+ init_turn_input();
14244
+ import_meta3 = {};
14245
+ ACP_ATTACH_ERROR = "ACP harnesses have no interactive attach. Continue the chat in Sideboard.";
14246
+ acpAdapter = {
14247
+ kind: "acp",
14248
+ async detect() {
14249
+ return detectAcpHarness(defaultAcpHarness());
14250
+ },
14251
+ async buildTurn(thread, input) {
14252
+ const harness = harnessFor(thread);
14253
+ const command = await resolveAcpHarnessCommand(harness);
14254
+ const sessionId = await this.resolveSessionId(thread.worktreePath, thread.sessionId);
14255
+ const prompt = flattenTurnInput(input);
14256
+ const resumePrompt = flattenTurnInput(dropCachedPrefixOnResume(input, sessionId));
14257
+ const isOrchestrator = isOrchestratorThread(thread);
14258
+ const injected2 = await buildInjectedMcpServers({
14259
+ includeSideboard: true,
14260
+ includeBrightsy: shouldInjectBrightsyMcp(thread, { orchestrator: isOrchestrator }),
14261
+ orchestratorThreadId: isOrchestrator ? thread.id : null,
14262
+ threadId: thread.id
14263
+ });
14264
+ const injectedAcp = toAcpMcpServers(injected2);
14265
+ const userMcp = isOrchestrator ? [] : acpUserStdioServers(
14266
+ listUserClaudeMcpServerEntries((0, import_node_os16.homedir)(), [thread.repoPath, thread.worktreePath]),
14267
+ new Set(injectedAcp.map((server) => server.name))
14268
+ );
14269
+ const req = {
14270
+ prompt,
14271
+ resumePrompt,
14272
+ transcript: acpPriorTranscript(thread.messages ?? []),
14273
+ cwd: thread.worktreePath,
14274
+ sessionId,
14275
+ harness,
14276
+ command: command.file,
14277
+ args: command.args,
14278
+ mcpServers: [...injectedAcp, ...userMcp],
14279
+ planMode: thread.planMode,
14280
+ autonomy: thread.autonomy
14281
+ };
14282
+ const runner = acpRunnerPath();
14283
+ const isTs = runner.endsWith(".ts");
14284
+ const launch = applyNodeLaunch(
14285
+ await resolveNodeLaunch(runner),
14286
+ isTs ? ["--import", "tsx", runner] : [runner]
14287
+ );
14288
+ return {
14289
+ file: launch.file,
14290
+ args: launch.args,
14291
+ cwd: thread.worktreePath,
14292
+ stdin: JSON.stringify(req),
14293
+ env: launch.env
14294
+ };
14295
+ },
14296
+ parseEvent(line) {
14297
+ return parseAcpRunnerLine(line);
14298
+ },
14299
+ async resolveSessionId(_worktreePath, cached) {
14300
+ return cached?.trim() || null;
14301
+ },
14302
+ async buildAttach(_thread) {
14303
+ throw new Error(ACP_ATTACH_ERROR);
14304
+ }
14305
+ };
14306
+ }
14307
+ });
14308
+
14309
+ // src/agents/claude-mcp-status.ts
14310
+ function mcpStatusThinkingFromClaudeInit(obj) {
14311
+ const raw = obj.mcp_servers ?? obj.mcpServers;
14312
+ const servers = [];
14313
+ if (Array.isArray(raw)) {
14314
+ for (const item of raw) {
14315
+ if (!item || typeof item !== "object" || Array.isArray(item)) continue;
14316
+ const rec = item;
14317
+ const name = typeof rec.name === "string" && rec.name.trim() || typeof rec.server === "string" && rec.server.trim() || "";
14318
+ const status = typeof rec.status === "string" && rec.status.trim() || typeof rec.state === "string" && rec.state.trim() || "";
14319
+ if (name) servers.push({ name, status: status || "unknown" });
14320
+ }
14321
+ } else if (raw && typeof raw === "object") {
14322
+ for (const [name, value] of Object.entries(raw)) {
14323
+ if (!name.trim()) continue;
14324
+ if (typeof value === "string" && value.trim()) {
14325
+ servers.push({ name, status: value.trim() });
14326
+ continue;
14327
+ }
14328
+ if (value && typeof value === "object" && !Array.isArray(value)) {
14329
+ const rec = value;
14330
+ const status = typeof rec.status === "string" && rec.status.trim() || typeof rec.state === "string" && rec.state.trim() || "unknown";
14331
+ servers.push({ name, status });
14332
+ }
14333
+ }
14334
+ }
14335
+ const coverage = claudeConnectorCoverage();
14336
+ const sideboardOk = sideboardMcpOk(servers);
14337
+ const notable = servers.filter(
14338
+ (server) => isNotableMcpInitStatus(server, sideboardOk, coverage)
14339
+ );
14340
+ if (notable.length === 0) return null;
14341
+ return `MCP: ${notable.map((s) => `${s.name} ${s.status}`).join(", ")}`;
14342
+ }
14343
+ function isCleanMcpConnect(status) {
14344
+ return /^(connected|ok|ready|success)$/i.test(status.trim());
14345
+ }
14346
+ function isMcpAuthStatus(status) {
14347
+ return /needs[_-]?auth|needs authentication|unauthorized|not authenticated|authrequired/i.test(
14348
+ status
14349
+ );
14350
+ }
14351
+ function isSideboardMcpName(name) {
14352
+ return /^sideboard$/i.test(name.trim()) || /^mcp__sideboard$/i.test(name.trim());
14353
+ }
14354
+ function isVendorClaudeAiMcpName(name) {
14355
+ return /^claude\.ai\b/i.test(name.trim()) || /^mcp__claude_ai_/i.test(name.trim());
14356
+ }
14357
+ function sideboardMcpOk(servers) {
14358
+ const row = servers.find((server) => isSideboardMcpName(server.name));
14359
+ return Boolean(row && isCleanMcpConnect(row.status));
14360
+ }
14361
+ function sideboardServiceForClaudeConnector(name) {
14362
+ const raw = name.trim();
14363
+ if (!raw || isSideboardMcpName(raw)) return null;
14364
+ const pluginLike = /^(?:plugin[:_]|mcp__plugin_|claude\.ai\s|(?:mcp__)?claude_ai_)/i.test(raw);
14365
+ const doubled = raw.match(/^mcp_([a-z0-9]+)_([a-z0-9]+)$/i);
14366
+ if (!pluginLike && !(doubled && doubled[1].toLowerCase() === doubled[2].toLowerCase())) {
14367
+ return null;
14368
+ }
14369
+ let body = raw;
14370
+ if (/^claude\.ai\s+/i.test(body)) body = body.replace(/^claude\.ai\s+/i, "");
14371
+ else if (/^(?:mcp__)?claude_ai_/i.test(body)) body = body.replace(/^(?:mcp__)?claude_ai_/i, "");
14372
+ else if (/^mcp__plugin_/i.test(body)) body = body.slice("mcp__plugin_".length);
14373
+ else if (/^plugin_/i.test(body)) body = body.slice("plugin_".length);
14374
+ else if (/^plugin:/i.test(body)) body = body.slice("plugin:".length);
14375
+ else if (/^mcp_/i.test(body)) body = body.slice("mcp_".length);
14376
+ const head = body.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)[0];
14377
+ if (!head || !SIDEBOARD_CONNECTOR_SERVICES.includes(head)) return null;
14378
+ return head;
14379
+ }
14380
+ function claudeConnectorCoverage() {
14381
+ let github = false;
14382
+ try {
14383
+ github = githubAgentAuthReady();
14384
+ } catch {
14385
+ github = false;
14386
+ }
14387
+ let linear = false;
14388
+ let posthog = false;
14389
+ let vercel = false;
14390
+ let supabase = false;
14391
+ let sentry = false;
14392
+ try {
14393
+ linear = isLinearConnected();
14394
+ posthog = isPosthogConnected();
14395
+ const integrations = loadAppSettings().integrations ?? {};
14396
+ if (integrations.githubPat?.trim()) github = true;
14397
+ vercel = Boolean(integrations.vercelToken?.trim());
14398
+ supabase = Boolean(integrations.supabaseAccessToken?.trim());
14399
+ sentry = Boolean(integrations.sentryAuthToken?.trim());
14400
+ } catch {
14401
+ }
14402
+ return { github, linear, posthog, vercel, supabase, sentry };
14403
+ }
14404
+ function isNotableMcpInitStatus(server, sideboardOk, coverage) {
14405
+ if (isCleanMcpConnect(server.status)) return false;
14406
+ if (isSideboardMcpName(server.name)) return true;
14407
+ if (isMcpAuthStatus(server.status)) return false;
14408
+ const service = sideboardServiceForClaudeConnector(server.name);
14409
+ if (service) return !(sideboardOk && coverage[service]);
14410
+ if (isVendorClaudeAiMcpName(server.name)) return false;
14411
+ return true;
14412
+ }
14413
+ var SIDEBOARD_CONNECTOR_SERVICES;
14414
+ var init_claude_mcp_status = __esm({
14415
+ "src/agents/claude-mcp-status.ts"() {
14416
+ "use strict";
14417
+ init_github_agent_auth();
14418
+ init_app_settings();
14419
+ SIDEBOARD_CONNECTOR_SERVICES = [
14420
+ "github",
14421
+ "linear",
14422
+ "posthog",
14423
+ "vercel",
14424
+ "supabase",
14425
+ "sentry"
14426
+ ];
14427
+ }
14428
+ });
14429
+
14106
14430
  // src/mcp-ui/visibility.ts
14107
14431
  function visibilityFromMeta(meta) {
14108
14432
  const rec = asRecord4(meta);
@@ -14429,7 +14753,7 @@ var init_session = __esm({
14429
14753
  function getMcpUiHost() {
14430
14754
  if (!singleton) {
14431
14755
  singleton = new McpUiHost({
14432
- entries: (projectDirs) => listUserClaudeMcpServerEntries((0, import_node_os15.homedir)(), projectDirs)
14756
+ entries: (projectDirs) => listUserClaudeMcpServerEntries((0, import_node_os17.homedir)(), projectDirs)
14433
14757
  });
14434
14758
  }
14435
14759
  return singleton;
@@ -14437,18 +14761,18 @@ function getMcpUiHost() {
14437
14761
  async function proxyClaudeUserMcp(orchestrator, projectDirs) {
14438
14762
  if (orchestrator) return {};
14439
14763
  const dirs = projectDirs.filter((d) => typeof d === "string" && d.length > 0);
14440
- return getMcpUiHost().proxyEntries(listUserClaudeMcpServerEntries((0, import_node_os15.homedir)(), dirs), dirs);
14764
+ return getMcpUiHost().proxyEntries(listUserClaudeMcpServerEntries((0, import_node_os17.homedir)(), dirs), dirs);
14441
14765
  }
14442
14766
  function dirsKeyFor(projectDirs) {
14443
14767
  if (!projectDirs?.length) return "";
14444
14768
  return (0, import_node_crypto9.createHash)("sha256").update(projectDirs.join("\0")).digest("hex").slice(0, 16);
14445
14769
  }
14446
- var import_node_crypto9, import_node_os15, TOOL_TTL_MS, McpUiHost, singleton;
14770
+ var import_node_crypto9, import_node_os17, TOOL_TTL_MS, McpUiHost, singleton;
14447
14771
  var init_host = __esm({
14448
14772
  "src/mcp-ui/host.ts"() {
14449
14773
  "use strict";
14450
14774
  import_node_crypto9 = require("crypto");
14451
- import_node_os15 = require("os");
14775
+ import_node_os17 = require("os");
14452
14776
  init_orch_mcp_isolation();
14453
14777
  init_meta();
14454
14778
  init_proxy_http();
@@ -14641,14 +14965,14 @@ function accessTokenFromCredentialsJson(raw) {
14641
14965
  }
14642
14966
  }
14643
14967
  function claudeCredentialsPath(configDir) {
14644
- const root = configDir?.trim() || process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path36.join)((0, import_node_os16.homedir)(), ".claude");
14645
- return (0, import_node_path36.join)(root, ".credentials.json");
14968
+ const root = configDir?.trim() || process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path38.join)((0, import_node_os18.homedir)(), ".claude");
14969
+ return (0, import_node_path38.join)(root, ".credentials.json");
14646
14970
  }
14647
14971
  async function readFileAccessToken(configDir) {
14648
14972
  const path = claudeCredentialsPath(configDir);
14649
- if (!(0, import_node_fs34.existsSync)(path)) return null;
14973
+ if (!(0, import_node_fs36.existsSync)(path)) return null;
14650
14974
  try {
14651
- return accessTokenFromCredentialsJson((0, import_node_fs34.readFileSync)(path, "utf8"));
14975
+ return accessTokenFromCredentialsJson((0, import_node_fs36.readFileSync)(path, "utf8"));
14652
14976
  } catch {
14653
14977
  return null;
14654
14978
  }
@@ -14679,13 +15003,13 @@ async function readClaudeAccessToken(configDir) {
14679
15003
  if (fromFile) return fromFile;
14680
15004
  return readKeychainAccessToken(configDir);
14681
15005
  }
14682
- var import_node_fs34, import_node_os16, import_node_path36, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS, KEYCHAIN_SERVICES;
15006
+ var import_node_fs36, import_node_os18, import_node_path38, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS, KEYCHAIN_SERVICES;
14683
15007
  var init_claude_usage_client = __esm({
14684
15008
  "src/agents/claude-usage-client.ts"() {
14685
15009
  "use strict";
14686
- import_node_fs34 = require("fs");
14687
- import_node_os16 = require("os");
14688
- import_node_path36 = require("path");
15010
+ import_node_fs36 = require("fs");
15011
+ import_node_os18 = require("os");
15012
+ import_node_path38 = require("path");
14689
15013
  init_run();
14690
15014
  init_fetch();
14691
15015
  init_app_settings();
@@ -14835,11 +15159,11 @@ var init_types = __esm({
14835
15159
 
14836
15160
  // src/agent-rpc/metadata.ts
14837
15161
  function agentRuntimeMetadataPath() {
14838
- return (0, import_node_path37.join)(appDataDir(), "agent-runtime.json");
15162
+ return (0, import_node_path39.join)(appDataDir(), "agent-runtime.json");
14839
15163
  }
14840
15164
  function readAgentRuntimeMetadata() {
14841
15165
  try {
14842
- const raw = JSON.parse((0, import_node_fs35.readFileSync)(agentRuntimeMetadataPath(), "utf8"));
15166
+ const raw = JSON.parse((0, import_node_fs37.readFileSync)(agentRuntimeMetadataPath(), "utf8"));
14843
15167
  if (!raw || typeof raw !== "object") return null;
14844
15168
  const rec = raw;
14845
15169
  if (typeof rec.runtimeId !== "string" || !rec.runtimeId.trim()) return null;
@@ -14887,12 +15211,12 @@ function agentRuntimeLooksLive(meta = readAgentRuntimeMetadata()) {
14887
15211
  if (!meta) return false;
14888
15212
  return pidAlive(meta.pid);
14889
15213
  }
14890
- var import_node_fs35, import_node_path37;
15214
+ var import_node_fs37, import_node_path39;
14891
15215
  var init_metadata = __esm({
14892
15216
  "src/agent-rpc/metadata.ts"() {
14893
15217
  "use strict";
14894
- import_node_fs35 = require("fs");
14895
- import_node_path37 = require("path");
15218
+ import_node_fs37 = require("fs");
15219
+ import_node_path39 = require("path");
14896
15220
  init_paths();
14897
15221
  init_protocol2();
14898
15222
  }
@@ -14958,15 +15282,15 @@ function withClaudePilotRpcTools(allowed) {
14958
15282
  const omit = new Set(PILOT_TOOL_NAMES.map((name) => `mcp__sideboard__${name}`));
14959
15283
  return [...allowed.filter((name) => !omit.has(name)), ...claudePilotSdkAllowedTools()];
14960
15284
  }
14961
- function entryDir() {
15285
+ function entryDir2() {
14962
15286
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
14963
15287
  if (cjsDir) return cjsDir;
14964
15288
  try {
14965
- return (0, import_node_path38.dirname)((0, import_node_url2.fileURLToPath)(import_meta5.url));
15289
+ return (0, import_node_path40.dirname)((0, import_node_url3.fileURLToPath)(import_meta6.url));
14966
15290
  } catch {
14967
15291
  try {
14968
- const req = (0, import_node_module2.createRequire)(process.cwd() + "/");
14969
- return (0, import_node_path38.dirname)(req.resolve("@sideboard-ai/core"));
15292
+ const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
15293
+ return (0, import_node_path40.dirname)(req.resolve("@sideboard-ai/core"));
14970
15294
  } catch {
14971
15295
  return process.cwd();
14972
15296
  }
@@ -14975,20 +15299,20 @@ function entryDir() {
14975
15299
  function claudeRunnerPath() {
14976
15300
  const packagedDir = packagedCursorRuntimeDir();
14977
15301
  if (packagedDir) {
14978
- const packaged = (0, import_node_path38.join)(packagedDir, "core-dist", "agents", "claude-runner.js");
14979
- if ((0, import_node_fs36.existsSync)(packaged)) return packaged;
15302
+ const packaged = (0, import_node_path40.join)(packagedDir, "core-dist", "agents", "claude-runner.js");
15303
+ if ((0, import_node_fs38.existsSync)(packaged)) return packaged;
14980
15304
  }
14981
- const root = entryDir();
15305
+ const root = entryDir2();
14982
15306
  const candidates = [
14983
- (0, import_node_path38.join)(root, "agents", "claude-runner.js"),
14984
- (0, import_node_path38.join)(root, "agents", "claude-runner.cjs"),
14985
- (0, import_node_path38.join)(root, "dist", "agents", "claude-runner.js"),
14986
- (0, import_node_path38.join)(root, "dist", "agents", "claude-runner.cjs"),
14987
- (0, import_node_path38.join)(root, "claude-runner.ts"),
14988
- (0, import_node_path38.join)(root, "src", "agents", "claude-runner.ts")
15307
+ (0, import_node_path40.join)(root, "agents", "claude-runner.js"),
15308
+ (0, import_node_path40.join)(root, "agents", "claude-runner.cjs"),
15309
+ (0, import_node_path40.join)(root, "dist", "agents", "claude-runner.js"),
15310
+ (0, import_node_path40.join)(root, "dist", "agents", "claude-runner.cjs"),
15311
+ (0, import_node_path40.join)(root, "claude-runner.ts"),
15312
+ (0, import_node_path40.join)(root, "src", "agents", "claude-runner.ts")
14989
15313
  ];
14990
15314
  for (const candidate of candidates) {
14991
- if ((0, import_node_fs36.existsSync)(candidate)) return candidate;
15315
+ if ((0, import_node_fs38.existsSync)(candidate)) return candidate;
14992
15316
  }
14993
15317
  return candidates[0];
14994
15318
  }
@@ -15012,19 +15336,19 @@ async function buildClaudeRpcTurnCommand(req) {
15012
15336
  }
15013
15337
  };
15014
15338
  }
15015
- var import_node_fs36, import_node_module2, import_node_path38, import_node_url2, import_meta5;
15339
+ var import_node_fs38, import_node_module3, import_node_path40, import_node_url3, import_meta6;
15016
15340
  var init_claude_host = __esm({
15017
15341
  "src/agents/claude-host.ts"() {
15018
15342
  "use strict";
15019
- import_node_fs36 = require("fs");
15020
- import_node_module2 = require("module");
15021
- import_node_path38 = require("path");
15022
- import_node_url2 = require("url");
15343
+ import_node_fs38 = require("fs");
15344
+ import_node_module3 = require("module");
15345
+ import_node_path40 = require("path");
15346
+ import_node_url3 = require("url");
15023
15347
  init_protocol2();
15024
15348
  init_pilot_tools();
15025
15349
  init_node_launch();
15026
15350
  init_packaged_runtime();
15027
- import_meta5 = {};
15351
+ import_meta6 = {};
15028
15352
  }
15029
15353
  });
15030
15354
 
@@ -15110,11 +15434,11 @@ function issueAttachmentWorktreePath(repoPath) {
15110
15434
  return raw || process.cwd();
15111
15435
  }
15112
15436
  function ensureIssueAttachmentsDir(worktreePath) {
15113
- const dir = (0, import_node_path39.join)(worktreePath, ATTACHMENTS_DIR);
15114
- (0, import_node_fs37.mkdirSync)(dir, { recursive: true });
15115
- const gi = (0, import_node_path39.join)(dir, ".gitignore");
15116
- if (!(0, import_node_fs37.existsSync)(gi)) {
15117
- (0, import_node_fs37.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
15437
+ const dir = (0, import_node_path41.join)(worktreePath, ATTACHMENTS_DIR);
15438
+ (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
15439
+ const gi = (0, import_node_path41.join)(dir, ".gitignore");
15440
+ if (!(0, import_node_fs39.existsSync)(gi)) {
15441
+ (0, import_node_fs39.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
15118
15442
  }
15119
15443
  return dir;
15120
15444
  }
@@ -15144,7 +15468,7 @@ function looksLikeFileUrl(url) {
15144
15468
  function filenameFromUrl(url, fallback = "attachment") {
15145
15469
  try {
15146
15470
  const parsed = new URL(url);
15147
- const last = decodeURIComponent((0, import_node_path39.basename)(parsed.pathname)).replace(/[/\\]/g, "_");
15471
+ const last = decodeURIComponent((0, import_node_path41.basename)(parsed.pathname)).replace(/[/\\]/g, "_");
15148
15472
  if (last && last !== "/" && last !== ".") return last;
15149
15473
  } catch {
15150
15474
  }
@@ -15166,12 +15490,12 @@ function filenameFromContentDisposition(header) {
15166
15490
  }
15167
15491
  function uniqueAttachmentFileName(dir, originalName) {
15168
15492
  const safe = originalName.replace(/[/\\]/g, "_").replace(/^\.+/, "") || "file";
15169
- if (!(0, import_node_fs37.existsSync)((0, import_node_path39.join)(dir, safe))) return safe;
15170
- const ext = (0, import_node_path39.extname)(safe);
15493
+ if (!(0, import_node_fs39.existsSync)((0, import_node_path41.join)(dir, safe))) return safe;
15494
+ const ext = (0, import_node_path41.extname)(safe);
15171
15495
  const stem = ext ? safe.slice(0, -ext.length) : safe;
15172
15496
  for (let i = 1; i < 1e4; i++) {
15173
15497
  const candidate = `${stem}-${i}${ext}`;
15174
- if (!(0, import_node_fs37.existsSync)((0, import_node_path39.join)(dir, candidate))) return candidate;
15498
+ if (!(0, import_node_fs39.existsSync)((0, import_node_path41.join)(dir, candidate))) return candidate;
15175
15499
  }
15176
15500
  return `${stem}-${(0, import_node_crypto10.randomUUID)()}${ext}`;
15177
15501
  }
@@ -15219,7 +15543,7 @@ function mergeIssueAttachments(items) {
15219
15543
  return out;
15220
15544
  }
15221
15545
  function extensionForContentType(contentType, name) {
15222
- if ((0, import_node_path39.extname)(name)) return name;
15546
+ if ((0, import_node_path41.extname)(name)) return name;
15223
15547
  const mime = (contentType ?? "").split(";")[0]?.trim().toLowerCase() ?? "";
15224
15548
  const ext = EXT_BY_MIME[mime];
15225
15549
  return ext ? `${name}${ext}` : name;
@@ -15271,7 +15595,7 @@ async function downloadAuthenticatedFile(opts) {
15271
15595
  const dir = ensureIssueAttachmentsDir(opts.worktreePath);
15272
15596
  const hinted = opts.name?.trim() || filenameFromContentDisposition(res.headers.get("content-disposition")) || filenameFromUrl(url);
15273
15597
  const name = uniqueAttachmentFileName(dir, extensionForContentType(contentType, hinted));
15274
- (0, import_node_fs37.writeFileSync)((0, import_node_path39.join)(dir, name), buf);
15598
+ (0, import_node_fs39.writeFileSync)((0, import_node_path41.join)(dir, name), buf);
15275
15599
  return {
15276
15600
  name,
15277
15601
  path: `${ATTACHMENTS_DIR}/${name}`,
@@ -15279,12 +15603,12 @@ async function downloadAuthenticatedFile(opts) {
15279
15603
  ...contentType ? { contentType } : {}
15280
15604
  };
15281
15605
  }
15282
- var import_node_fs37, import_node_path39, import_node_crypto10, ISSUE_ATTACHMENT_MAX_BYTES, MARKDOWN_IMAGE_RE, MARKDOWN_LINK_RE, HTML_SRC_RE, BARE_URL_RE, EXT_BY_MIME;
15606
+ var import_node_fs39, import_node_path41, import_node_crypto10, ISSUE_ATTACHMENT_MAX_BYTES, MARKDOWN_IMAGE_RE, MARKDOWN_LINK_RE, HTML_SRC_RE, BARE_URL_RE, EXT_BY_MIME;
15283
15607
  var init_issue_attachments = __esm({
15284
15608
  "src/integrations/issue-attachments.ts"() {
15285
15609
  "use strict";
15286
- import_node_fs37 = require("fs");
15287
- import_node_path39 = require("path");
15610
+ import_node_fs39 = require("fs");
15611
+ import_node_path41 = require("path");
15288
15612
  import_node_crypto10 = require("crypto");
15289
15613
  init_fetch();
15290
15614
  init_workspace_scratch();
@@ -16937,12 +17261,12 @@ function compactMetadataFromClaude(obj) {
16937
17261
  const postTokens = typeof post === "number" && Number.isFinite(post) && post > 0 ? Math.round(post) : void 0;
16938
17262
  return { trigger, postTokens };
16939
17263
  }
16940
- var import_node_fs38, import_node_path40, CLAUDE_PROMPT_ARG_MAX, claudeAdapter;
17264
+ var import_node_fs40, import_node_path42, CLAUDE_PROMPT_ARG_MAX, claudeAdapter;
16941
17265
  var init_claude = __esm({
16942
17266
  "src/agents/claude.ts"() {
16943
17267
  "use strict";
16944
- import_node_fs38 = require("fs");
16945
- import_node_path40 = require("path");
17268
+ import_node_fs40 = require("fs");
17269
+ import_node_path42 = require("path");
16946
17270
  init_run();
16947
17271
  init_app_settings();
16948
17272
  init_claude_mcp_status();
@@ -16962,7 +17286,7 @@ var init_claude = __esm({
16962
17286
  async detect() {
16963
17287
  const claude = resolveClaudeExecutable();
16964
17288
  if (claude !== "claude") {
16965
- if (!(0, import_node_fs38.existsSync)(claude)) {
17289
+ if (!(0, import_node_fs40.existsSync)(claude)) {
16966
17290
  return {
16967
17291
  agent: "claude",
16968
17292
  installed: false,
@@ -17120,7 +17444,7 @@ ${hint}` : hint;
17120
17444
  cwd: thread.worktreePath,
17121
17445
  stdin: useStdin ? `${promptText}
17122
17446
  ` : void 0,
17123
- ...mcpConfigPath ? { cleanupDirs: [(0, import_node_path40.dirname)(mcpConfigPath)] } : {},
17447
+ ...mcpConfigPath ? { cleanupDirs: [(0, import_node_path42.dirname)(mcpConfigPath)] } : {},
17124
17448
  // Nested Task/Agent thinking+text in stream-json (Claude Code 2.1.211+).
17125
17449
  // Raise the -p background-agent wait so long TaskOutput polls are not
17126
17450
  // abandoned at Claude Code’s 10-minute default.
@@ -17300,7 +17624,7 @@ async function listCodexModels() {
17300
17624
  if (codex === "codex") {
17301
17625
  const which = await run("which", ["codex"], { reject: false });
17302
17626
  if (which.exitCode !== 0) return FALLBACK_CODEX_MODELS;
17303
- } else if (!(0, import_node_fs39.existsSync)(codex)) {
17627
+ } else if (!(0, import_node_fs41.existsSync)(codex)) {
17304
17628
  return FALLBACK_CODEX_MODELS;
17305
17629
  }
17306
17630
  const listed = await run(codex, ["debug", "models"], { reject: false });
@@ -17337,7 +17661,7 @@ function usageFromCodex(usage, asContext = false) {
17337
17661
  return occ > 0 ? { ...mapped, lastRequestTokens: occ } : mapped;
17338
17662
  }
17339
17663
  function codexHomeDir() {
17340
- return process.env.CODEX_HOME?.trim() || (0, import_node_path41.join)((0, import_node_os17.homedir)(), ".codex");
17664
+ return process.env.CODEX_HOME?.trim() || (0, import_node_path43.join)((0, import_node_os19.homedir)(), ".codex");
17341
17665
  }
17342
17666
  function unwrapCodexMcpResult(result) {
17343
17667
  if (result == null) return void 0;
@@ -17366,21 +17690,21 @@ function asRecord6(value) {
17366
17690
  return void 0;
17367
17691
  }
17368
17692
  function codexLooksAuthenticated() {
17369
- const authPath = (0, import_node_path41.join)(codexHomeDir(), "auth.json");
17370
- if (!(0, import_node_fs39.existsSync)(authPath)) return false;
17693
+ const authPath = (0, import_node_path43.join)(codexHomeDir(), "auth.json");
17694
+ if (!(0, import_node_fs41.existsSync)(authPath)) return false;
17371
17695
  try {
17372
- return (0, import_node_fs39.statSync)(authPath).size > 2;
17696
+ return (0, import_node_fs41.statSync)(authPath).size > 2;
17373
17697
  } catch {
17374
17698
  return false;
17375
17699
  }
17376
17700
  }
17377
- var import_node_fs39, import_node_os17, import_node_path41, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
17701
+ var import_node_fs41, import_node_os19, import_node_path43, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
17378
17702
  var init_codex = __esm({
17379
17703
  "src/agents/codex.ts"() {
17380
17704
  "use strict";
17381
- import_node_fs39 = require("fs");
17382
- import_node_os17 = require("os");
17383
- import_node_path41 = require("path");
17705
+ import_node_fs41 = require("fs");
17706
+ import_node_os19 = require("os");
17707
+ import_node_path43 = require("path");
17384
17708
  init_run();
17385
17709
  init_app_settings();
17386
17710
  init_global_workspace();
@@ -17409,7 +17733,7 @@ var init_codex = __esm({
17409
17733
  async detect() {
17410
17734
  const codex = resolveAgentExecutable("codex");
17411
17735
  if (codex !== "codex") {
17412
- if (!(0, import_node_fs39.existsSync)(codex)) {
17736
+ if (!(0, import_node_fs41.existsSync)(codex)) {
17413
17737
  return {
17414
17738
  agent: "codex",
17415
17739
  installed: false,
@@ -17441,7 +17765,7 @@ var init_codex = __esm({
17441
17765
  authenticated,
17442
17766
  linearMcp,
17443
17767
  warnings,
17444
- reason: authenticated ? void 0 : `Codex auth not found \u2014 run \`codex login\` (expected ${(0, import_node_path41.join)(codexHomeDir(), "auth.json")})`
17768
+ reason: authenticated ? void 0 : `Codex auth not found \u2014 run \`codex login\` (expected ${(0, import_node_path43.join)(codexHomeDir(), "auth.json")})`
17445
17769
  };
17446
17770
  },
17447
17771
  async buildTurn(thread, input) {
@@ -17673,27 +17997,27 @@ var init_codex = __esm({
17673
17997
  // src/agents/cursor-sdk-resolve.ts
17674
17998
  function thisModuleFile() {
17675
17999
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
17676
- if (cjsDir) return (0, import_node_path42.join)(cjsDir, "cursor-sdk-resolve.js");
18000
+ if (cjsDir) return (0, import_node_path44.join)(cjsDir, "cursor-sdk-resolve.js");
17677
18001
  try {
17678
- return (0, import_node_url3.fileURLToPath)(import_meta6.url);
18002
+ return (0, import_node_url4.fileURLToPath)(import_meta7.url);
17679
18003
  } catch {
17680
- return (0, import_node_path42.join)(process.cwd(), "package.json");
18004
+ return (0, import_node_path44.join)(process.cwd(), "package.json");
17681
18005
  }
17682
18006
  }
17683
18007
  function packageRootLooksLikeSdk(dir) {
17684
18008
  try {
17685
- const raw = (0, import_node_fs40.readFileSync)((0, import_node_path42.join)(dir, "package.json"), "utf8");
18009
+ const raw = (0, import_node_fs42.readFileSync)((0, import_node_path44.join)(dir, "package.json"), "utf8");
17686
18010
  const pkg = JSON.parse(raw);
17687
- return pkg.name === "@cursor/sdk" && (0, import_node_fs40.existsSync)(dir);
18011
+ return pkg.name === "@cursor/sdk" && (0, import_node_fs42.existsSync)(dir);
17688
18012
  } catch {
17689
18013
  return false;
17690
18014
  }
17691
18015
  }
17692
18016
  function resolvedPackageRoot(fromFile) {
17693
18017
  try {
17694
- const req = (0, import_node_module3.createRequire)(fromFile);
18018
+ const req = (0, import_node_module4.createRequire)(fromFile);
17695
18019
  const pkgJson = req.resolve("@cursor/sdk/package.json");
17696
- const root = (0, import_node_path42.dirname)(pkgJson);
18020
+ const root = (0, import_node_path44.dirname)(pkgJson);
17697
18021
  return packageRootLooksLikeSdk(root) ? root : null;
17698
18022
  } catch {
17699
18023
  return null;
@@ -17707,10 +18031,10 @@ function resolveCursorSdkRoot(opts) {
17707
18031
  }
17708
18032
  const globalNm = npmGlobalNodeModules(env);
17709
18033
  if (globalNm) {
17710
- const globalRoot = (0, import_node_path42.join)(globalNm, "@cursor/sdk");
18034
+ const globalRoot = (0, import_node_path44.join)(globalNm, "@cursor/sdk");
17711
18035
  if (packageRootLooksLikeSdk(globalRoot)) return globalRoot;
17712
18036
  }
17713
- const cwdPkg = (0, import_node_path42.join)(process.cwd(), "package.json");
18037
+ const cwdPkg = (0, import_node_path44.join)(process.cwd(), "package.json");
17714
18038
  return resolvedPackageRoot(thisModuleFile()) ?? resolvedPackageRoot(cwdPkg);
17715
18039
  }
17716
18040
  function isCursorSdkInstalled(opts) {
@@ -17726,13 +18050,13 @@ function exportTarget(value) {
17726
18050
  }
17727
18051
  function cursorSdkEsmEntry(root) {
17728
18052
  try {
17729
- const pkg = JSON.parse((0, import_node_fs40.readFileSync)((0, import_node_path42.join)(root, "package.json"), "utf8"));
18053
+ const pkg = JSON.parse((0, import_node_fs42.readFileSync)((0, import_node_path44.join)(root, "package.json"), "utf8"));
17730
18054
  const exp = pkg.exports;
17731
18055
  const dot = exp && typeof exp === "object" && !Array.isArray(exp) && "." in exp ? exp["."] : exp;
17732
18056
  const rel = exportTarget(dot) ?? (typeof pkg.module === "string" ? pkg.module : null);
17733
18057
  if (!rel) return null;
17734
- const entry = (0, import_node_path42.join)(root, rel);
17735
- return (0, import_node_fs40.existsSync)(entry) ? entry : null;
18058
+ const entry = (0, import_node_path44.join)(root, rel);
18059
+ return (0, import_node_fs42.existsSync)(entry) ? entry : null;
17736
18060
  } catch {
17737
18061
  return null;
17738
18062
  }
@@ -17748,10 +18072,10 @@ async function importCursorSdk(opts) {
17748
18072
  try {
17749
18073
  let entry = cursorSdkEsmEntry(root);
17750
18074
  if (!entry) {
17751
- const req = (0, import_node_module3.createRequire)((0, import_node_path42.join)(root, "package.json"));
18075
+ const req = (0, import_node_module4.createRequire)((0, import_node_path44.join)(root, "package.json"));
17752
18076
  entry = req.resolve("@cursor/sdk");
17753
18077
  }
17754
- return unwrapCursorSdkModule(await import((0, import_node_url3.pathToFileURL)(entry).href));
18078
+ return unwrapCursorSdkModule(await import((0, import_node_url4.pathToFileURL)(entry).href));
17755
18079
  } catch {
17756
18080
  return null;
17757
18081
  }
@@ -17760,8 +18084,8 @@ function cursorSdkPlatformRipgrepPackage() {
17760
18084
  return `@cursor/sdk-${process.platform}-${process.arch}`;
17761
18085
  }
17762
18086
  function nodeModulesDirForPackageRoot(packageRoot) {
17763
- const parent = (0, import_node_path42.dirname)(packageRoot);
17764
- return (0, import_node_path42.basename)(parent).startsWith("@") ? (0, import_node_path42.dirname)(parent) : parent;
18087
+ const parent = (0, import_node_path44.dirname)(packageRoot);
18088
+ return (0, import_node_path44.basename)(parent).startsWith("@") ? (0, import_node_path44.dirname)(parent) : parent;
17765
18089
  }
17766
18090
  function cursorSdkRipgrepCandidate(opts) {
17767
18091
  const root = resolveCursorSdkRoot(opts);
@@ -17769,21 +18093,21 @@ function cursorSdkRipgrepCandidate(opts) {
17769
18093
  const nm = nodeModulesDirForPackageRoot(root);
17770
18094
  const pkg = cursorSdkPlatformRipgrepPackage();
17771
18095
  const bin = process.platform === "win32" ? "rg.exe" : "rg";
17772
- const sibling = (0, import_node_path42.join)(nm, pkg, "bin", bin);
17773
- if ((0, import_node_fs40.existsSync)(sibling)) return sibling;
17774
- const nested = (0, import_node_path42.join)(root, "node_modules", pkg, "bin", bin);
17775
- return (0, import_node_fs40.existsSync)(nested) ? nested : null;
18096
+ const sibling = (0, import_node_path44.join)(nm, pkg, "bin", bin);
18097
+ if ((0, import_node_fs42.existsSync)(sibling)) return sibling;
18098
+ const nested = (0, import_node_path44.join)(root, "node_modules", pkg, "bin", bin);
18099
+ return (0, import_node_fs42.existsSync)(nested) ? nested : null;
17776
18100
  }
17777
- var import_node_fs40, import_node_module3, import_node_path42, import_node_url3, import_meta6, CURSOR_SDK_INSTALL_HINT;
18101
+ var import_node_fs42, import_node_module4, import_node_path44, import_node_url4, import_meta7, CURSOR_SDK_INSTALL_HINT;
17778
18102
  var init_cursor_sdk_resolve = __esm({
17779
18103
  "src/agents/cursor-sdk-resolve.ts"() {
17780
18104
  "use strict";
17781
- import_node_fs40 = require("fs");
17782
- import_node_module3 = require("module");
17783
- import_node_path42 = require("path");
17784
- import_node_url3 = require("url");
18105
+ import_node_fs42 = require("fs");
18106
+ import_node_module4 = require("module");
18107
+ import_node_path44 = require("path");
18108
+ import_node_url4 = require("url");
17785
18109
  init_path();
17786
- import_meta6 = {};
18110
+ import_meta7 = {};
17787
18111
  CURSOR_SDK_INSTALL_HINT = "Cursor SDK is not installed. Settings \u2192 Agents \u2192 Cursor \u2192 Install (`npm i -g @cursor/sdk`). Sideboard does not ship the SDK \u2014 update it anytime without a new Sideboard build.";
17788
18112
  }
17789
18113
  });
@@ -17822,21 +18146,21 @@ function platformRipgrepPackage() {
17822
18146
  }
17823
18147
  function usableRipgrepPath(candidate) {
17824
18148
  const raw = candidate?.trim();
17825
- if (!raw || !(0, import_node_path43.isAbsolute)(raw)) return null;
18149
+ if (!raw || !(0, import_node_path45.isAbsolute)(raw)) return null;
17826
18150
  const readable = nodeReadableScriptPath(raw);
17827
- if (!(0, import_node_fs41.existsSync)(readable) || isAsarPath(readable)) return null;
18151
+ if (!(0, import_node_fs43.existsSync)(readable) || isAsarPath(readable)) return null;
17828
18152
  return readable;
17829
18153
  }
17830
18154
  function walkForBundledRipgrep(startFile) {
17831
18155
  if (!startFile) return null;
17832
18156
  const pkg = platformRipgrepPackage();
17833
18157
  const name = rgBinaryName();
17834
- let dir = (0, import_node_path43.dirname)((0, import_node_path43.resolve)(startFile));
17835
- const root = (0, import_node_path43.parse)(dir).root;
18158
+ let dir = (0, import_node_path45.dirname)((0, import_node_path45.resolve)(startFile));
18159
+ const root = (0, import_node_path45.parse)(dir).root;
17836
18160
  while (dir !== root) {
17837
- const hit = usableRipgrepPath((0, import_node_path43.join)(dir, "node_modules", pkg, "bin", name));
18161
+ const hit = usableRipgrepPath((0, import_node_path45.join)(dir, "node_modules", pkg, "bin", name));
17838
18162
  if (hit) return hit;
17839
- const next = (0, import_node_path43.dirname)(dir);
18163
+ const next = (0, import_node_path45.dirname)(dir);
17840
18164
  if (next === dir) break;
17841
18165
  dir = next;
17842
18166
  }
@@ -17844,9 +18168,9 @@ function walkForBundledRipgrep(startFile) {
17844
18168
  }
17845
18169
  function requireResolveBundledRipgrep(fromFile) {
17846
18170
  try {
17847
- const req = (0, import_node_module4.createRequire)(fromFile);
18171
+ const req = (0, import_node_module5.createRequire)(fromFile);
17848
18172
  const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
17849
- return usableRipgrepPath((0, import_node_path43.join)((0, import_node_path43.dirname)(pkgJson), "bin", rgBinaryName()));
18173
+ return usableRipgrepPath((0, import_node_path45.join)((0, import_node_path45.dirname)(pkgJson), "bin", rgBinaryName()));
17850
18174
  } catch {
17851
18175
  return null;
17852
18176
  }
@@ -17868,13 +18192,13 @@ function cursorRipgrepEnv(opts) {
17868
18192
  const path = resolveCursorRipgrepPath(opts);
17869
18193
  return path ? { [RIPGREP_ENV]: path } : {};
17870
18194
  }
17871
- var import_node_fs41, import_node_module4, import_node_path43, RIPGREP_ENV;
18195
+ var import_node_fs43, import_node_module5, import_node_path45, RIPGREP_ENV;
17872
18196
  var init_cursor_ripgrep = __esm({
17873
18197
  "src/agents/cursor-ripgrep.ts"() {
17874
18198
  "use strict";
17875
- import_node_fs41 = require("fs");
17876
- import_node_module4 = require("module");
17877
- import_node_path43 = require("path");
18199
+ import_node_fs43 = require("fs");
18200
+ import_node_module5 = require("module");
18201
+ import_node_path45 = require("path");
17878
18202
  init_cursor_sdk_resolve();
17879
18203
  init_node_launch();
17880
18204
  init_packaged_runtime();
@@ -17914,15 +18238,15 @@ async function listCursorModels() {
17914
18238
  return cachedModels?.models ?? FALLBACK_CURSOR_MODELS;
17915
18239
  }
17916
18240
  }
17917
- function entryDir2() {
18241
+ function entryDir3() {
17918
18242
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
17919
18243
  if (cjsDir) return cjsDir;
17920
18244
  try {
17921
- return (0, import_node_path44.dirname)((0, import_node_url4.fileURLToPath)(import_meta7.url));
18245
+ return (0, import_node_path46.dirname)((0, import_node_url5.fileURLToPath)(import_meta8.url));
17922
18246
  } catch {
17923
18247
  try {
17924
- const req = (0, import_node_module5.createRequire)(process.cwd() + "/");
17925
- return (0, import_node_path44.dirname)(req.resolve("@sideboard-ai/core"));
18248
+ const req = (0, import_node_module6.createRequire)(process.cwd() + "/");
18249
+ return (0, import_node_path46.dirname)(req.resolve("@sideboard-ai/core"));
17926
18250
  } catch {
17927
18251
  return process.cwd();
17928
18252
  }
@@ -17931,30 +18255,30 @@ function entryDir2() {
17931
18255
  function cursorRunnerPath() {
17932
18256
  const packaged = packagedCursorRunnerPath();
17933
18257
  if (packaged) return packaged;
17934
- const root = entryDir2();
18258
+ const root = entryDir3();
17935
18259
  const candidates = [
17936
- (0, import_node_path44.join)(root, "agents", "cursor-runner.js"),
17937
- (0, import_node_path44.join)(root, "agents", "cursor-runner.cjs"),
18260
+ (0, import_node_path46.join)(root, "agents", "cursor-runner.js"),
18261
+ (0, import_node_path46.join)(root, "agents", "cursor-runner.cjs"),
17938
18262
  // If somehow resolved from package root instead of dist/
17939
- (0, import_node_path44.join)(root, "dist", "agents", "cursor-runner.js"),
17940
- (0, import_node_path44.join)(root, "dist", "agents", "cursor-runner.cjs"),
18263
+ (0, import_node_path46.join)(root, "dist", "agents", "cursor-runner.js"),
18264
+ (0, import_node_path46.join)(root, "dist", "agents", "cursor-runner.cjs"),
17941
18265
  // Source tree (dev): packages/core/src/agents/cursor-runner.ts
17942
- (0, import_node_path44.join)(root, "cursor-runner.ts"),
17943
- (0, import_node_path44.join)(root, "src", "agents", "cursor-runner.ts")
18266
+ (0, import_node_path46.join)(root, "cursor-runner.ts"),
18267
+ (0, import_node_path46.join)(root, "src", "agents", "cursor-runner.ts")
17944
18268
  ];
17945
18269
  for (const candidate of candidates) {
17946
- if ((0, import_node_fs42.existsSync)(candidate)) return candidate;
18270
+ if ((0, import_node_fs44.existsSync)(candidate)) return candidate;
17947
18271
  }
17948
18272
  return candidates[0];
17949
18273
  }
17950
- var import_node_fs42, import_node_module5, import_node_path44, import_node_url4, import_meta7, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
18274
+ var import_node_fs44, import_node_module6, import_node_path46, import_node_url5, import_meta8, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
17951
18275
  var init_cursor = __esm({
17952
18276
  "src/agents/cursor.ts"() {
17953
18277
  "use strict";
17954
- import_node_fs42 = require("fs");
17955
- import_node_module5 = require("module");
17956
- import_node_path44 = require("path");
17957
- import_node_url4 = require("url");
18278
+ import_node_fs44 = require("fs");
18279
+ import_node_module6 = require("module");
18280
+ import_node_path46 = require("path");
18281
+ import_node_url5 = require("url");
17958
18282
  init_run();
17959
18283
  init_app_settings();
17960
18284
  init_global_workspace();
@@ -17967,7 +18291,7 @@ var init_cursor = __esm({
17967
18291
  init_packaged_runtime();
17968
18292
  init_turn_input();
17969
18293
  init_cursor_events();
17970
- import_meta7 = {};
18294
+ import_meta8 = {};
17971
18295
  FALLBACK_CURSOR_MODELS = [
17972
18296
  { id: "default", displayName: "Auto" },
17973
18297
  { id: "composer-2.5", displayName: "Composer 2.5" },
@@ -18080,26 +18404,26 @@ var init_cursor = __esm({
18080
18404
 
18081
18405
  // src/agent-rpc/opencode-hook.ts
18082
18406
  function writeOpencodeRpcPlugin() {
18083
- const pluginDir = (0, import_node_path45.join)(appDataDir(), "agent-rpc", "opencode");
18084
- (0, import_node_fs43.mkdirSync)(pluginDir, { recursive: true });
18085
- const pluginFile = (0, import_node_path45.join)(pluginDir, "sideboard-rpc.js");
18086
- if ((0, import_node_fs43.existsSync)(pluginFile)) {
18407
+ const pluginDir = (0, import_node_path47.join)(appDataDir(), "agent-rpc", "opencode");
18408
+ (0, import_node_fs45.mkdirSync)(pluginDir, { recursive: true });
18409
+ const pluginFile = (0, import_node_path47.join)(pluginDir, "sideboard-rpc.js");
18410
+ if ((0, import_node_fs45.existsSync)(pluginFile)) {
18087
18411
  try {
18088
- if ((0, import_node_fs43.readFileSync)(pluginFile, "utf8") === OPENCODE_PLUGIN_SOURCE) return pluginFile;
18412
+ if ((0, import_node_fs45.readFileSync)(pluginFile, "utf8") === OPENCODE_PLUGIN_SOURCE) return pluginFile;
18089
18413
  } catch {
18090
18414
  }
18091
18415
  }
18092
18416
  const tmp = `${pluginFile}.${process.pid}.tmp`;
18093
- (0, import_node_fs43.writeFileSync)(tmp, OPENCODE_PLUGIN_SOURCE);
18094
- (0, import_node_fs43.renameSync)(tmp, pluginFile);
18417
+ (0, import_node_fs45.writeFileSync)(tmp, OPENCODE_PLUGIN_SOURCE);
18418
+ (0, import_node_fs45.renameSync)(tmp, pluginFile);
18095
18419
  return pluginFile;
18096
18420
  }
18097
- var import_node_fs43, import_node_path45, OPENCODE_PLUGIN_SOURCE;
18421
+ var import_node_fs45, import_node_path47, OPENCODE_PLUGIN_SOURCE;
18098
18422
  var init_opencode_hook = __esm({
18099
18423
  "src/agent-rpc/opencode-hook.ts"() {
18100
18424
  "use strict";
18101
- import_node_fs43 = require("fs");
18102
- import_node_path45 = require("path");
18425
+ import_node_fs45 = require("fs");
18426
+ import_node_path47 = require("path");
18103
18427
  init_paths();
18104
18428
  init_pilot_tools();
18105
18429
  init_protocol2();
@@ -18236,18 +18560,18 @@ async function buildOpencodeHostEnv(thread) {
18236
18560
  if (rpc) {
18237
18561
  const pluginFile = writeOpencodeRpcPlugin();
18238
18562
  Object.assign(env, agentRpcChildEnv(rpc, thread.worktreePath));
18239
- config.plugin = [(0, import_node_url5.pathToFileURL)(pluginFile).href];
18563
+ config.plugin = [(0, import_node_url6.pathToFileURL)(pluginFile).href];
18240
18564
  }
18241
18565
  if (Object.keys(config).length > 0) {
18242
18566
  env.OPENCODE_CONFIG_CONTENT = JSON.stringify(config);
18243
18567
  }
18244
18568
  return env;
18245
18569
  }
18246
- var import_node_url5;
18570
+ var import_node_url6;
18247
18571
  var init_opencode_host = __esm({
18248
18572
  "src/agent-rpc/opencode-host.ts"() {
18249
18573
  "use strict";
18250
- import_node_url5 = require("url");
18574
+ import_node_url6 = require("url");
18251
18575
  init_injected_mcp();
18252
18576
  init_orch_mcp_isolation();
18253
18577
  init_global_workspace();
@@ -18302,7 +18626,7 @@ async function listOpencodeModels() {
18302
18626
  if (opencode === "opencode") {
18303
18627
  const which = await run("which", ["opencode"], { reject: false });
18304
18628
  if (which.exitCode !== 0) return FALLBACK_OPENCODE_MODELS;
18305
- } else if (!(0, import_node_fs44.existsSync)(opencode)) {
18629
+ } else if (!(0, import_node_fs46.existsSync)(opencode)) {
18306
18630
  return FALLBACK_OPENCODE_MODELS;
18307
18631
  }
18308
18632
  const listed = await run(opencode, ["models"], { reject: false });
@@ -18332,11 +18656,11 @@ function usageFromOpencode(tokens) {
18332
18656
  cacheWriteTokens: tokens.cache?.write ? Number(tokens.cache.write) : void 0
18333
18657
  };
18334
18658
  }
18335
- var import_node_fs44, FALLBACK_OPENCODE_MODELS, cachedOpencodeModels, OPENCODE_MODEL_CACHE_MS, opencodeAdapter;
18659
+ var import_node_fs46, FALLBACK_OPENCODE_MODELS, cachedOpencodeModels, OPENCODE_MODEL_CACHE_MS, opencodeAdapter;
18336
18660
  var init_opencode = __esm({
18337
18661
  "src/agents/opencode.ts"() {
18338
18662
  "use strict";
18339
- import_node_fs44 = require("fs");
18663
+ import_node_fs46 = require("fs");
18340
18664
  init_run();
18341
18665
  init_app_settings();
18342
18666
  init_error_detail();
@@ -18362,7 +18686,7 @@ var init_opencode = __esm({
18362
18686
  async detect() {
18363
18687
  const opencode = resolveAgentExecutable("opencode");
18364
18688
  if (opencode !== "opencode") {
18365
- if (!(0, import_node_fs44.existsSync)(opencode)) {
18689
+ if (!(0, import_node_fs46.existsSync)(opencode)) {
18366
18690
  return {
18367
18691
  agent: "opencode",
18368
18692
  installed: false,
@@ -18641,7 +18965,7 @@ async function listBrightsyModels() {
18641
18965
  }
18642
18966
  }
18643
18967
  async function listModelsForAgent(agent) {
18644
- const kinds = agent ? [agent] : ["claude", "codex", "opencode", "cursor", "brightsy"];
18968
+ const kinds = agent ? [agent] : ["claude", "codex", "opencode", "cursor", "brightsy", "acp"];
18645
18969
  const out = [];
18646
18970
  for (const kind of kinds) {
18647
18971
  if (kind === "claude") {
@@ -18680,6 +19004,15 @@ async function listModelsForAgent(agent) {
18680
19004
  });
18681
19005
  continue;
18682
19006
  }
19007
+ if (kind === "acp") {
19008
+ out.push({
19009
+ agent: kind,
19010
+ auto: true,
19011
+ models: [],
19012
+ note: "Gemini CLI and Copilot CLI choose the model. Leave model unset."
19013
+ });
19014
+ continue;
19015
+ }
18683
19016
  if (kind === "brightsy") {
18684
19017
  const models = await listBrightsyModels();
18685
19018
  out.push({
@@ -18943,23 +19276,24 @@ async function resolveCliAfterNpmInstall(cliBin) {
18943
19276
  if (prefix.exitCode !== 0) return null;
18944
19277
  const root = prefix.stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.startsWith("/")).pop();
18945
19278
  if (!root) return null;
18946
- const candidate = (0, import_node_path46.join)(root, "bin", cliBin);
18947
- if (!(0, import_node_fs45.existsSync)(candidate)) return null;
19279
+ const candidate = (0, import_node_path48.join)(root, "bin", cliBin);
19280
+ if (!(0, import_node_fs47.existsSync)(candidate)) return null;
18948
19281
  try {
18949
- (0, import_node_fs45.chmodSync)(candidate, 493);
19282
+ (0, import_node_fs47.chmodSync)(candidate, 493);
18950
19283
  } catch {
18951
19284
  }
18952
19285
  enrichPathWithNpmGlobalBin();
18953
19286
  return whichOnPath(cliBin);
18954
19287
  }
18955
- var import_node_fs45, import_node_path46;
19288
+ var import_node_fs47, import_node_path48;
18956
19289
  var init_install = __esm({
18957
19290
  "src/agents/install.ts"() {
18958
19291
  "use strict";
18959
- import_node_fs45 = require("fs");
18960
- import_node_path46 = require("path");
19292
+ import_node_fs47 = require("fs");
19293
+ import_node_path48 = require("path");
18961
19294
  init_run();
18962
19295
  init_app_settings();
19296
+ init_acp_harness();
18963
19297
  init_install_native();
18964
19298
  init_path();
18965
19299
  }
@@ -18973,6 +19307,7 @@ var adapters;
18973
19307
  var init_agents = __esm({
18974
19308
  "src/agents/index.ts"() {
18975
19309
  "use strict";
19310
+ init_acp();
18976
19311
  init_brightsy();
18977
19312
  init_claude();
18978
19313
  init_codex();
@@ -18984,6 +19319,8 @@ var init_agents = __esm({
18984
19319
  init_claude();
18985
19320
  init_codex();
18986
19321
  init_cursor();
19322
+ init_acp();
19323
+ init_acp_harness();
18987
19324
  init_cursor_events();
18988
19325
  init_cursor();
18989
19326
  init_opencode();
@@ -19000,7 +19337,8 @@ var init_agents = __esm({
19000
19337
  codex: codexAdapter,
19001
19338
  opencode: opencodeAdapter,
19002
19339
  brightsy: brightsyAdapter,
19003
- cursor: cursorAdapter
19340
+ cursor: cursorAdapter,
19341
+ acp: acpAdapter
19004
19342
  };
19005
19343
  }
19006
19344
  });
@@ -19062,7 +19400,7 @@ function isAgentHostEnvKey(key) {
19062
19400
  }
19063
19401
  function stripHostToolingPath(pathValue) {
19064
19402
  if (!pathValue?.trim()) return "";
19065
- return pathValue.split(import_node_path47.delimiter).filter((part) => part && !HOST_PATH_NOISE.test(part.replace(/\\/g, "/"))).join(import_node_path47.delimiter);
19403
+ return pathValue.split(import_node_path49.delimiter).filter((part) => part && !HOST_PATH_NOISE.test(part.replace(/\\/g, "/"))).join(import_node_path49.delimiter);
19066
19404
  }
19067
19405
  function sanitizeAgentHostEnv(env, cwd) {
19068
19406
  for (const key of Object.keys(env)) {
@@ -19076,11 +19414,11 @@ function sanitizeAgentHostEnv(env, cwd) {
19076
19414
  }
19077
19415
  return env;
19078
19416
  }
19079
- var import_node_path47, DROP_EXACT, DROP_PREFIXES, HOST_PATH_NOISE;
19417
+ var import_node_path49, DROP_EXACT, DROP_PREFIXES, HOST_PATH_NOISE;
19080
19418
  var init_agent_host_env = __esm({
19081
19419
  "src/hook/agent-host-env.ts"() {
19082
19420
  "use strict";
19083
- import_node_path47 = require("path");
19421
+ import_node_path49 = require("path");
19084
19422
  DROP_EXACT = /* @__PURE__ */ new Set([
19085
19423
  "NODE_PATH",
19086
19424
  "NODE_ENV_ELECTRON_VITE",
@@ -19119,15 +19457,15 @@ var init_agent_host_env = __esm({
19119
19457
 
19120
19458
  // src/hook/worktree-pkg-cache.ts
19121
19459
  function worktreePkgCacheRoot(worktreePath) {
19122
- return (0, import_node_path48.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
19460
+ return (0, import_node_path50.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
19123
19461
  }
19124
19462
  function worktreePkgCacheEnv(worktreePath) {
19125
19463
  const root = worktreePkgCacheRoot(worktreePath);
19126
- const store = (0, import_node_path48.join)(root, "pnpm-store");
19127
- const pnpmCache = (0, import_node_path48.join)(root, "pnpm");
19128
- const npmCache = (0, import_node_path48.join)(root, "npm");
19129
- const nodeGyp = (0, import_node_path48.join)(root, "node-gyp");
19130
- const electron = (0, import_node_path48.join)(root, "electron");
19464
+ const store = (0, import_node_path50.join)(root, "pnpm-store");
19465
+ const pnpmCache = (0, import_node_path50.join)(root, "pnpm");
19466
+ const npmCache = (0, import_node_path50.join)(root, "npm");
19467
+ const nodeGyp = (0, import_node_path50.join)(root, "node-gyp");
19468
+ const electron = (0, import_node_path50.join)(root, "electron");
19131
19469
  return {
19132
19470
  npm_config_store_dir: store,
19133
19471
  PNPM_STORE_DIR: store,
@@ -19149,8 +19487,8 @@ function fillGroup(env, keys, values) {
19149
19487
  }
19150
19488
  }
19151
19489
  function ensureWorktreePkgCacheDirs(worktreePath) {
19152
- if (!(0, import_node_fs46.existsSync)(worktreePath)) return;
19153
- (0, import_node_fs46.mkdirSync)(worktreePkgCacheRoot(worktreePath), { recursive: true });
19490
+ if (!(0, import_node_fs48.existsSync)(worktreePath)) return;
19491
+ (0, import_node_fs48.mkdirSync)(worktreePkgCacheRoot(worktreePath), { recursive: true });
19154
19492
  }
19155
19493
  function applyWorktreePkgCacheEnv(env, worktreePath) {
19156
19494
  const cwd = worktreePath.trim();
@@ -19163,12 +19501,12 @@ function applyWorktreePkgCacheEnv(env, worktreePath) {
19163
19501
  fillGroup(env, ["electron_config_cache"], next);
19164
19502
  ensureWorktreePkgCacheDirs(cwd);
19165
19503
  }
19166
- var import_node_fs46, import_node_path48, WORKTREE_PKG_CACHE_REL;
19504
+ var import_node_fs48, import_node_path50, WORKTREE_PKG_CACHE_REL;
19167
19505
  var init_worktree_pkg_cache = __esm({
19168
19506
  "src/hook/worktree-pkg-cache.ts"() {
19169
19507
  "use strict";
19170
- import_node_fs46 = require("fs");
19171
- import_node_path48 = require("path");
19508
+ import_node_fs48 = require("fs");
19509
+ import_node_path50 = require("path");
19172
19510
  WORKTREE_PKG_CACHE_REL = ".context/.sideboard/pkg-cache";
19173
19511
  }
19174
19512
  });
@@ -19428,7 +19766,7 @@ async function spawnAgentTurn(thread, input, onEvent) {
19428
19766
  }).finally(() => {
19429
19767
  for (const dir of cmd.cleanupDirs ?? []) {
19430
19768
  try {
19431
- (0, import_node_fs47.rmSync)(dir, { recursive: true, force: true });
19769
+ (0, import_node_fs49.rmSync)(dir, { recursive: true, force: true });
19432
19770
  } catch {
19433
19771
  }
19434
19772
  }
@@ -19462,11 +19800,11 @@ async function spawnAgentTurn(thread, input, onEvent) {
19462
19800
  done
19463
19801
  };
19464
19802
  }
19465
- var import_node_fs47, import_node_readline2, import_execa3;
19803
+ var import_node_fs49, import_node_readline2, import_execa3;
19466
19804
  var init_spawn = __esm({
19467
19805
  "src/agents/spawn.ts"() {
19468
19806
  "use strict";
19469
- import_node_fs47 = require("fs");
19807
+ import_node_fs49 = require("fs");
19470
19808
  import_node_readline2 = require("readline");
19471
19809
  import_execa3 = require("execa");
19472
19810
  init_worktree();
@@ -20470,6 +20808,7 @@ function workspaceAgentChatSummaries(worktreePath) {
20470
20808
  id: t.id,
20471
20809
  title: t.title,
20472
20810
  agent: t.agent,
20811
+ ...t.acpHarness ? { acpHarness: t.acpHarness } : {},
20473
20812
  status: t.status,
20474
20813
  link: `sideboard://chat/${t.id}`,
20475
20814
  ...t.agentBlock?.reason ? { blockedReason: t.agentBlock.reason, blockedSource: t.agentBlock.source } : {}
@@ -20498,6 +20837,7 @@ function createChatTab(input) {
20498
20837
  const explicitTitle = input.title?.trim();
20499
20838
  const title = explicitTitle || allocateTeamName(takenTeamSlugsForChatTab(binding.worktreePath)).name;
20500
20839
  const nextAgent = input.agent ?? from.agent;
20840
+ const nextHarness = nextAgent === "acp" ? input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : from.agent === "acp" && (from.acpHarness === "gemini" || from.acpHarness === "copilot") ? from.acpHarness : defaultAcpHarness() : void 0;
20501
20841
  if (isOrchestratorThread(from) || binding.sourceType === "orchestration") {
20502
20842
  assertOrchestratorCapableAgent(nextAgent);
20503
20843
  }
@@ -20514,6 +20854,7 @@ function createChatTab(input) {
20514
20854
  // the connected chat.
20515
20855
  sourceRef: singletonInbox ? title : binding.sourceRef,
20516
20856
  agent: nextAgent,
20857
+ ...nextHarness ? { acpHarness: nextHarness } : {},
20517
20858
  model: input.model !== void 0 ? input.model : input.agent && input.agent !== from.agent ? null : from.model,
20518
20859
  effort: input.effort !== void 0 ? input.effort : from.effort,
20519
20860
  fast: input.fast !== void 0 ? Boolean(input.fast) : from.fast,
@@ -20534,6 +20875,7 @@ function forkChatTab(input) {
20534
20875
  const tab = createChatTab({
20535
20876
  fromThreadId: input.threadId,
20536
20877
  agent: input.agent ?? from.agent,
20878
+ acpHarness: input.acpHarness,
20537
20879
  model: input.model,
20538
20880
  title: input.title?.trim() || void 0,
20539
20881
  attachments: [attachment]
@@ -20554,6 +20896,7 @@ var init_chat_tabs = __esm({
20554
20896
  init_teams();
20555
20897
  init_worktree_labels();
20556
20898
  init_global_workspace();
20899
+ init_acp_harness();
20557
20900
  init_orchestrator_capable();
20558
20901
  init_thread_store();
20559
20902
  init_worktree_runtime();
@@ -20710,21 +21053,21 @@ function shouldRefreshReviewRequestTemplate(content) {
20710
21053
  return LEGACY_REVIEW_TEMPLATE_MARKERS.every((m) => trimmed.includes(m));
20711
21054
  }
20712
21055
  function readTextIfPresent(abs) {
20713
- if (!(0, import_node_fs48.existsSync)(abs)) return null;
21056
+ if (!(0, import_node_fs50.existsSync)(abs)) return null;
20714
21057
  try {
20715
- const content = (0, import_node_fs48.readFileSync)(abs, "utf8");
21058
+ const content = (0, import_node_fs50.readFileSync)(abs, "utf8");
20716
21059
  return content.trim() ? content : null;
20717
21060
  } catch {
20718
21061
  return null;
20719
21062
  }
20720
21063
  }
20721
21064
  function readLocalGuidelines(worktreePath) {
20722
- const localAbs = (0, import_node_path49.join)(worktreePath, REVIEW_REQUEST_PATH);
21065
+ const localAbs = (0, import_node_path51.join)(worktreePath, REVIEW_REQUEST_PATH);
20723
21066
  const localContent = readTextIfPresent(localAbs);
20724
21067
  if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
20725
21068
  return { path: REVIEW_REQUEST_PATH, content: localContent };
20726
21069
  }
20727
- const legacyAbs = (0, import_node_path49.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
21070
+ const legacyAbs = (0, import_node_path51.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
20728
21071
  const legacyContent = readTextIfPresent(legacyAbs);
20729
21072
  if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
20730
21073
  return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
@@ -20748,27 +21091,27 @@ function contextGuidelines(content, source) {
20748
21091
  };
20749
21092
  }
20750
21093
  function writeContextGuidelines(worktreePath, content) {
20751
- const abs = (0, import_node_path49.join)(worktreePath, CONTEXT_REVIEW_PATH);
20752
- (0, import_node_fs48.mkdirSync)((0, import_node_path49.dirname)(abs), { recursive: true });
21094
+ const abs = (0, import_node_path51.join)(worktreePath, CONTEXT_REVIEW_PATH);
21095
+ (0, import_node_fs50.mkdirSync)((0, import_node_path51.dirname)(abs), { recursive: true });
20753
21096
  const body = content.endsWith("\n") ? content : `${content}
20754
21097
  `;
20755
- (0, import_node_fs48.writeFileSync)(abs, body, "utf8");
21098
+ (0, import_node_fs50.writeFileSync)(abs, body, "utf8");
20756
21099
  return body;
20757
21100
  }
20758
21101
  function readSideboardReview(worktreePath, repoPath) {
20759
- const fromWorktree = readTextIfPresent((0, import_node_path49.join)(worktreePath, REPO_REVIEW_PATH));
21102
+ const fromWorktree = readTextIfPresent((0, import_node_path51.join)(worktreePath, REPO_REVIEW_PATH));
20760
21103
  if (fromWorktree) return fromWorktree;
20761
21104
  const repo = repoPath?.replace(/\/+$/, "");
20762
21105
  const wt = worktreePath.replace(/\/+$/, "");
20763
21106
  if (!repo || repo === wt) return null;
20764
- return readTextIfPresent((0, import_node_path49.join)(repo, REPO_REVIEW_PATH));
21107
+ return readTextIfPresent((0, import_node_path51.join)(repo, REPO_REVIEW_PATH));
20765
21108
  }
20766
21109
  function ensureReviewGuidelinesFile(worktreePath, repoPath) {
20767
- const skillContent = readTextIfPresent((0, import_node_path49.join)(worktreePath, REVIEW_SKILL_PATH));
21110
+ const skillContent = readTextIfPresent((0, import_node_path51.join)(worktreePath, REVIEW_SKILL_PATH));
20768
21111
  if (skillContent) {
20769
21112
  return { ...skillGuidelines(skillContent, "skill"), wrote: false };
20770
21113
  }
20771
- const contextContent = readTextIfPresent((0, import_node_path49.join)(worktreePath, CONTEXT_REVIEW_PATH));
21114
+ const contextContent = readTextIfPresent((0, import_node_path51.join)(worktreePath, CONTEXT_REVIEW_PATH));
20772
21115
  if (contextContent && !shouldRefreshReviewRequestTemplate(contextContent)) {
20773
21116
  return { ...contextGuidelines(contextContent, "local"), wrote: false };
20774
21117
  }
@@ -20844,13 +21187,13 @@ async function requestReview(threadRef, send) {
20844
21187
  const started = await send(tab.id, REVIEW_REQUEST_PREFILL);
20845
21188
  return { tab: started, from };
20846
21189
  }
20847
- var import_node_crypto13, import_node_fs48, import_node_path49, REPO_REVIEW_PATH, REPO_REVIEW_NAME, CONTEXT_REVIEW_PATH, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
21190
+ var import_node_crypto13, import_node_fs50, import_node_path51, REPO_REVIEW_PATH, REPO_REVIEW_NAME, CONTEXT_REVIEW_PATH, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
20848
21191
  var init_request_review = __esm({
20849
21192
  "src/review/request-review.ts"() {
20850
21193
  "use strict";
20851
21194
  import_node_crypto13 = require("crypto");
20852
- import_node_fs48 = require("fs");
20853
- import_node_path49 = require("path");
21195
+ import_node_fs50 = require("fs");
21196
+ import_node_path51 = require("path");
20854
21197
  init_global_workspace();
20855
21198
  init_chat_tabs();
20856
21199
  init_thread_store();
@@ -20873,7 +21216,7 @@ var init_request_review = __esm({
20873
21216
 
20874
21217
  // src/hook/worktree-run-ports.ts
20875
21218
  function worktreeRunPortsPath(worktreePath) {
20876
- return (0, import_node_path50.join)(worktreePath, RUN_PORTS_REL);
21219
+ return (0, import_node_path52.join)(worktreePath, RUN_PORTS_REL);
20877
21220
  }
20878
21221
  function isPort(value) {
20879
21222
  return typeof value === "number" && Number.isInteger(value) && value > 0 && value <= 65535;
@@ -20898,7 +21241,7 @@ function parseFile(raw) {
20898
21241
  function readScripts(worktreePath) {
20899
21242
  if (!worktreePath.trim()) return {};
20900
21243
  try {
20901
- const raw = (0, import_node_fs49.readFileSync)(worktreeRunPortsPath(worktreePath), "utf8");
21244
+ const raw = (0, import_node_fs51.readFileSync)(worktreeRunPortsPath(worktreePath), "utf8");
20902
21245
  return parseFile(raw).scripts ?? {};
20903
21246
  } catch {
20904
21247
  return {};
@@ -20925,22 +21268,22 @@ function saveWorktreeRunPorts(worktreePath, scriptName, ports) {
20925
21268
  const path = worktreeRunPortsPath(worktreePath);
20926
21269
  let current = {};
20927
21270
  try {
20928
- current = parseFile((0, import_node_fs49.readFileSync)(path, "utf8"));
21271
+ current = parseFile((0, import_node_fs51.readFileSync)(path, "utf8"));
20929
21272
  } catch {
20930
21273
  current = {};
20931
21274
  }
20932
21275
  const scripts = { ...current.scripts ?? {} };
20933
21276
  scripts[scriptName] = cleaned;
20934
- (0, import_node_fs49.mkdirSync)((0, import_node_path50.dirname)(path), { recursive: true });
20935
- (0, import_node_fs49.writeFileSync)(path, `${JSON.stringify({ scripts }, null, 2)}
21277
+ (0, import_node_fs51.mkdirSync)((0, import_node_path52.dirname)(path), { recursive: true });
21278
+ (0, import_node_fs51.writeFileSync)(path, `${JSON.stringify({ scripts }, null, 2)}
20936
21279
  `, "utf8");
20937
21280
  }
20938
- var import_node_fs49, import_node_path50, RUN_PORTS_REL;
21281
+ var import_node_fs51, import_node_path52, RUN_PORTS_REL;
20939
21282
  var init_worktree_run_ports = __esm({
20940
21283
  "src/hook/worktree-run-ports.ts"() {
20941
21284
  "use strict";
20942
- import_node_fs49 = require("fs");
20943
- import_node_path50 = require("path");
21285
+ import_node_fs51 = require("fs");
21286
+ import_node_path52 = require("path");
20944
21287
  RUN_PORTS_REL = ".context/.sideboard/run-ports.json";
20945
21288
  }
20946
21289
  });
@@ -21038,24 +21381,24 @@ function sanitizeDetachedJobId(id) {
21038
21381
  return s;
21039
21382
  }
21040
21383
  function readIntFile(file) {
21041
- if (!(0, import_node_fs50.existsSync)(file)) return null;
21042
- const n = Number.parseInt((0, import_node_fs50.readFileSync)(file, "utf8").trim(), 10);
21384
+ if (!(0, import_node_fs52.existsSync)(file)) return null;
21385
+ const n = Number.parseInt((0, import_node_fs52.readFileSync)(file, "utf8").trim(), 10);
21043
21386
  return Number.isInteger(n) ? n : null;
21044
21387
  }
21045
21388
  function jobDir(root, id, legacy = false) {
21046
- return (0, import_node_path51.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
21389
+ return (0, import_node_path53.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
21047
21390
  }
21048
21391
  function resolveJobDir(root, id) {
21049
21392
  const modern = jobDir(root, id, false);
21050
- if ((0, import_node_fs50.existsSync)(modern)) return modern;
21393
+ if ((0, import_node_fs52.existsSync)(modern)) return modern;
21051
21394
  const legacy = jobDir(root, id, true);
21052
- if ((0, import_node_fs50.existsSync)(legacy)) return legacy;
21395
+ if ((0, import_node_fs52.existsSync)(legacy)) return legacy;
21053
21396
  return modern;
21054
21397
  }
21055
21398
  function listJobIdsIn(root, rel) {
21056
- const dir = (0, import_node_path51.join)(root, rel);
21057
- if (!(0, import_node_fs50.existsSync)(dir)) return [];
21058
- return (0, import_node_fs50.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
21399
+ const dir = (0, import_node_path53.join)(root, rel);
21400
+ if (!(0, import_node_fs52.existsSync)(dir)) return [];
21401
+ return (0, import_node_fs52.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
21059
21402
  }
21060
21403
  function listRunningDetachedJobs(worktreePath) {
21061
21404
  const root = worktreePath.trim();
@@ -21067,7 +21410,7 @@ function listRunningDetachedJobs(worktreePath) {
21067
21410
  const running = [];
21068
21411
  for (const id of ids) {
21069
21412
  const dir = resolveJobDir(root, id);
21070
- const pid = readIntFile((0, import_node_path51.join)(dir, "pid"));
21413
+ const pid = readIntFile((0, import_node_path53.join)(dir, "pid"));
21071
21414
  if (jobTreeAlive(pid)) running.push(id);
21072
21415
  }
21073
21416
  return running.sort();
@@ -21149,8 +21492,8 @@ function planJobContinue(opts) {
21149
21492
  return { action: "none" };
21150
21493
  }
21151
21494
  function tailProgress(logFile, maxLines = 12) {
21152
- if (!(0, import_node_fs50.existsSync)(logFile)) return "(no log yet)";
21153
- const lines = (0, import_node_fs50.readFileSync)(logFile, "utf8").split("\n");
21495
+ if (!(0, import_node_fs52.existsSync)(logFile)) return "(no log yet)";
21496
+ const lines = (0, import_node_fs52.readFileSync)(logFile, "utf8").split("\n");
21154
21497
  return lines.slice(-maxLines).join("\n");
21155
21498
  }
21156
21499
  function lastProgressLine(progress) {
@@ -21158,8 +21501,8 @@ function lastProgressLine(progress) {
21158
21501
  return last ? last.slice(0, 72) : void 0;
21159
21502
  }
21160
21503
  function readLogLines(file) {
21161
- if (!(0, import_node_fs50.existsSync)(file)) return [];
21162
- const lines = (0, import_node_fs50.readFileSync)(file, "utf8").split("\n");
21504
+ if (!(0, import_node_fs52.existsSync)(file)) return [];
21505
+ const lines = (0, import_node_fs52.readFileSync)(file, "utf8").split("\n");
21163
21506
  if (lines.length && lines[lines.length - 1] === "") lines.pop();
21164
21507
  return lines;
21165
21508
  }
@@ -21170,15 +21513,15 @@ function takeDelta(logFile, cursorFile) {
21170
21513
  return { delta: capJobLogDelta(lines.slice(start).join("\n")), nextCursor: lines.length };
21171
21514
  }
21172
21515
  function snapshotJob(dir) {
21173
- const pid = readIntFile((0, import_node_path51.join)(dir, "pid"));
21516
+ const pid = readIntFile((0, import_node_path53.join)(dir, "pid"));
21174
21517
  const running = jobTreeAlive(pid);
21175
21518
  return {
21176
21519
  pid,
21177
21520
  running,
21178
- exitCode: readIntFile((0, import_node_path51.join)(dir, "exit")),
21179
- log: (0, import_node_path51.join)(dir, "log"),
21180
- cursor: (0, import_node_path51.join)(dir, "present.cursor"),
21181
- progress: tailProgress((0, import_node_path51.join)(dir, "log"))
21521
+ exitCode: readIntFile((0, import_node_path53.join)(dir, "exit")),
21522
+ log: (0, import_node_path53.join)(dir, "log"),
21523
+ cursor: (0, import_node_path53.join)(dir, "present.cursor"),
21524
+ progress: tailProgress((0, import_node_path53.join)(dir, "log"))
21182
21525
  };
21183
21526
  }
21184
21527
  function toResult(id, snap, extra) {
@@ -21187,8 +21530,8 @@ function toResult(id, snap, extra) {
21187
21530
  const stillRunning = snap.running && !ok;
21188
21531
  const { delta, nextCursor } = takeDelta(snap.log, snap.cursor);
21189
21532
  try {
21190
- (0, import_node_fs50.mkdirSync)((0, import_node_path51.dirname)(snap.cursor), { recursive: true });
21191
- (0, import_node_fs50.writeFileSync)(snap.cursor, `${nextCursor}
21533
+ (0, import_node_fs52.mkdirSync)((0, import_node_path53.dirname)(snap.cursor), { recursive: true });
21534
+ (0, import_node_fs52.writeFileSync)(snap.cursor, `${nextCursor}
21192
21535
  `);
21193
21536
  } catch {
21194
21537
  }
@@ -21217,7 +21560,7 @@ async function waitForDetachedJob(cwd, id, opts) {
21217
21560
  const dir = resolveJobDir(root, jobId);
21218
21561
  const timeoutMs = mcpWaitForJobTimeoutMs(opts?.timeoutMs);
21219
21562
  const sleep = opts?.sleep ?? sleepMs;
21220
- if (!(0, import_node_fs50.existsSync)(dir)) {
21563
+ if (!(0, import_node_fs52.existsSync)(dir)) {
21221
21564
  return {
21222
21565
  stillRunning: false,
21223
21566
  ok: false,
@@ -21263,10 +21606,10 @@ function killProcessTree(pid, signal) {
21263
21606
  }
21264
21607
  function appendJobLog(logFile, line) {
21265
21608
  try {
21266
- (0, import_node_fs50.mkdirSync)((0, import_node_path51.dirname)(logFile), { recursive: true });
21609
+ (0, import_node_fs52.mkdirSync)((0, import_node_path53.dirname)(logFile), { recursive: true });
21267
21610
  const body = line.endsWith("\n") ? line : `${line}
21268
21611
  `;
21269
- (0, import_node_fs50.appendFileSync)(logFile, body);
21612
+ (0, import_node_fs52.appendFileSync)(logFile, body);
21270
21613
  } catch {
21271
21614
  }
21272
21615
  }
@@ -21276,7 +21619,7 @@ async function stopDetachedJob(cwd, id, opts) {
21276
21619
  const dir = resolveJobDir(root, jobId);
21277
21620
  const sleep = opts?.sleep ?? sleepMs;
21278
21621
  const why = opts?.reason?.trim() ?? "";
21279
- if (!(0, import_node_fs50.existsSync)(dir)) {
21622
+ if (!(0, import_node_fs52.existsSync)(dir)) {
21280
21623
  return {
21281
21624
  stillRunning: false,
21282
21625
  ok: false,
@@ -21312,10 +21655,10 @@ async function stopDetachedJob(cwd, id, opts) {
21312
21655
  killProcessTree(targetPid, "SIGKILL");
21313
21656
  await sleep(100);
21314
21657
  }
21315
- const exitFile = (0, import_node_path51.join)(dir, "exit");
21316
- if (!(0, import_node_fs50.existsSync)(exitFile)) {
21658
+ const exitFile = (0, import_node_path53.join)(dir, "exit");
21659
+ if (!(0, import_node_fs52.existsSync)(exitFile)) {
21317
21660
  try {
21318
- (0, import_node_fs50.writeFileSync)(exitFile, "1\n");
21661
+ (0, import_node_fs52.writeFileSync)(exitFile, "1\n");
21319
21662
  } catch {
21320
21663
  }
21321
21664
  }
@@ -21335,12 +21678,12 @@ async function stopDetachedJob(cwd, id, opts) {
21335
21678
  hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
21336
21679
  };
21337
21680
  }
21338
- var import_node_fs50, import_node_path51, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
21681
+ var import_node_fs52, import_node_path53, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
21339
21682
  var init_wait_for_job = __esm({
21340
21683
  "src/mcp/wait-for-job.ts"() {
21341
21684
  "use strict";
21342
- import_node_fs50 = require("fs");
21343
- import_node_path51 = require("path");
21685
+ import_node_fs52 = require("fs");
21686
+ import_node_path53 = require("path");
21344
21687
  init_workspace_scratch();
21345
21688
  init_job_process();
21346
21689
  init_wait_for_turn();
@@ -21617,9 +21960,9 @@ function matchSimpleGlob(pattern, name) {
21617
21960
  return new RegExp(`^${escaped}$`).test(name);
21618
21961
  }
21619
21962
  function readWorktreeInclude(repoPath) {
21620
- const path = (0, import_node_path52.join)(repoPath, ".worktreeinclude");
21621
- if (!(0, import_node_fs51.existsSync)(path)) return [];
21622
- return (0, import_node_fs51.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
21963
+ const path = (0, import_node_path54.join)(repoPath, ".worktreeinclude");
21964
+ if (!(0, import_node_fs53.existsSync)(path)) return [];
21965
+ return (0, import_node_fs53.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
21623
21966
  }
21624
21967
  function resolveFilesToCopy(repoPath) {
21625
21968
  const fromInclude = readWorktreeInclude(repoPath);
@@ -21629,10 +21972,10 @@ function resolveFilesToCopy(repoPath) {
21629
21972
  if (settings?.fileIncludeGlobs?.length) {
21630
21973
  const matched = [];
21631
21974
  try {
21632
- for (const entry of (0, import_node_fs51.readdirSync)(repoPath, { withFileTypes: true })) {
21975
+ for (const entry of (0, import_node_fs53.readdirSync)(repoPath, { withFileTypes: true })) {
21633
21976
  if (!entry.isFile()) continue;
21634
21977
  for (const glob of settings.fileIncludeGlobs) {
21635
- if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path52.basename)(glob), entry.name)) {
21978
+ if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path54.basename)(glob), entry.name)) {
21636
21979
  matched.push(entry.name);
21637
21980
  break;
21638
21981
  }
@@ -21644,7 +21987,7 @@ function resolveFilesToCopy(repoPath) {
21644
21987
  }
21645
21988
  const defaults = [];
21646
21989
  try {
21647
- for (const entry of (0, import_node_fs51.readdirSync)(repoPath, { withFileTypes: true })) {
21990
+ for (const entry of (0, import_node_fs53.readdirSync)(repoPath, { withFileTypes: true })) {
21648
21991
  if (entry.isFile() && entry.name.startsWith(".env")) {
21649
21992
  defaults.push(entry.name);
21650
21993
  }
@@ -21658,11 +22001,11 @@ function copyConfiguredFiles(repoPath, worktreePath) {
21658
22001
  const patterns = resolveFilesToCopy(repoPath);
21659
22002
  const copied = [];
21660
22003
  for (const rel of patterns) {
21661
- const src = (0, import_node_path52.join)(repoPath, rel);
21662
- if (!(0, import_node_fs51.existsSync)(src)) continue;
21663
- const dest = (0, import_node_path52.join)(worktreePath, rel);
21664
- (0, import_node_fs51.mkdirSync)((0, import_node_path52.dirname)(dest), { recursive: true });
21665
- (0, import_node_fs51.copyFileSync)(src, dest);
22004
+ const src = (0, import_node_path54.join)(repoPath, rel);
22005
+ if (!(0, import_node_fs53.existsSync)(src)) continue;
22006
+ const dest = (0, import_node_path54.join)(worktreePath, rel);
22007
+ (0, import_node_fs53.mkdirSync)((0, import_node_path54.dirname)(dest), { recursive: true });
22008
+ (0, import_node_fs53.copyFileSync)(src, dest);
21666
22009
  copied.push(rel);
21667
22010
  }
21668
22011
  linkSharedDirectories(repoPath, worktreePath);
@@ -21675,19 +22018,19 @@ function linkSharedDirectories(repoPath, worktreePath) {
21675
22018
  for (const rel of dirs) {
21676
22019
  if (!isSafeRelativeDir(rel)) continue;
21677
22020
  if (!isGitignored(repoPath, rel)) continue;
21678
- const src = (0, import_node_path52.join)(repoPath, rel);
22021
+ const src = (0, import_node_path54.join)(repoPath, rel);
21679
22022
  let srcStat;
21680
22023
  try {
21681
- srcStat = (0, import_node_fs51.lstatSync)(src);
22024
+ srcStat = (0, import_node_fs53.lstatSync)(src);
21682
22025
  } catch {
21683
22026
  continue;
21684
22027
  }
21685
22028
  if (!srcStat.isDirectory()) continue;
21686
- const dest = (0, import_node_path52.join)(worktreePath, rel);
21687
- if ((0, import_node_fs51.existsSync)(dest)) continue;
21688
- (0, import_node_fs51.mkdirSync)((0, import_node_path52.dirname)(dest), { recursive: true });
22029
+ const dest = (0, import_node_path54.join)(worktreePath, rel);
22030
+ if ((0, import_node_fs53.existsSync)(dest)) continue;
22031
+ (0, import_node_fs53.mkdirSync)((0, import_node_path54.dirname)(dest), { recursive: true });
21689
22032
  try {
21690
- (0, import_node_fs51.symlinkSync)(src, dest);
22033
+ (0, import_node_fs53.symlinkSync)(src, dest);
21691
22034
  } catch {
21692
22035
  continue;
21693
22036
  }
@@ -21697,13 +22040,13 @@ function linkSharedDirectories(repoPath, worktreePath) {
21697
22040
  }
21698
22041
  function samePath(a, b) {
21699
22042
  try {
21700
- return (0, import_node_fs51.realpathSync)(a) === (0, import_node_fs51.realpathSync)(b);
22043
+ return (0, import_node_fs53.realpathSync)(a) === (0, import_node_fs53.realpathSync)(b);
21701
22044
  } catch {
21702
- return (0, import_node_path52.resolve)(a) === (0, import_node_path52.resolve)(b);
22045
+ return (0, import_node_path54.resolve)(a) === (0, import_node_path54.resolve)(b);
21703
22046
  }
21704
22047
  }
21705
22048
  function isSafeRelativeDir(rel) {
21706
- if (!rel || (0, import_node_path52.isAbsolute)(rel)) return false;
22049
+ if (!rel || (0, import_node_path54.isAbsolute)(rel)) return false;
21707
22050
  const parts = rel.split(/[\\/]/).filter(Boolean);
21708
22051
  return parts.length > 0 && parts.every((part) => part !== "." && part !== "..");
21709
22052
  }
@@ -21745,7 +22088,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
21745
22088
  const env = stripNestedElectronEnv({
21746
22089
  ...baseEnv ?? process.env
21747
22090
  });
21748
- const name = opts.workspaceName ?? (0, import_node_path52.basename)(opts.worktreePath);
22091
+ const name = opts.workspaceName ?? (0, import_node_path54.basename)(opts.worktreePath);
21749
22092
  const ports = opts.ports ?? [];
21750
22093
  const primary = ports[0];
21751
22094
  env.SIDEBOARD_WORKSPACE_NAME = name;
@@ -21814,20 +22157,20 @@ function listenerCwd(pid) {
21814
22157
  }
21815
22158
  function realpathOrResolve(path) {
21816
22159
  try {
21817
- return (0, import_node_fs51.realpathSync)(path);
22160
+ return (0, import_node_fs53.realpathSync)(path);
21818
22161
  } catch {
21819
- return (0, import_node_path52.resolve)(path);
22162
+ return (0, import_node_path54.resolve)(path);
21820
22163
  }
21821
22164
  }
21822
22165
  function isOtherWorktreeListenerCwd(cwd, worktreePath) {
21823
22166
  const wt = realpathOrResolve(worktreePath);
21824
22167
  const c = realpathOrResolve(cwd);
21825
- if (c === wt || c.startsWith(wt + import_node_path52.sep)) return false;
21826
- const parent = (0, import_node_path52.dirname)(wt);
21827
- const thisName = (0, import_node_path52.basename)(wt);
22168
+ if (c === wt || c.startsWith(wt + import_node_path54.sep)) return false;
22169
+ const parent = (0, import_node_path54.dirname)(wt);
22170
+ const thisName = (0, import_node_path54.basename)(wt);
21828
22171
  if (!thisName || c === parent) return false;
21829
- if (!c.startsWith(parent + import_node_path52.sep)) return false;
21830
- const first = c.slice(parent.length + 1).split(import_node_path52.sep)[0];
22172
+ if (!c.startsWith(parent + import_node_path54.sep)) return false;
22173
+ const first = c.slice(parent.length + 1).split(import_node_path54.sep)[0];
21831
22174
  return Boolean(first) && first !== thisName;
21832
22175
  }
21833
22176
  function signalPid(pid, signal) {
@@ -21839,7 +22182,7 @@ function signalPid(pid, signal) {
21839
22182
  function isThisWorktreeListenerCwd(cwd, worktreePath) {
21840
22183
  const wt = realpathOrResolve(worktreePath);
21841
22184
  const c = realpathOrResolve(cwd);
21842
- return c === wt || c.startsWith(wt + import_node_path52.sep);
22185
+ return c === wt || c.startsWith(wt + import_node_path54.sep);
21843
22186
  }
21844
22187
  function killDetachedRunTree(pid, worktreePath) {
21845
22188
  if (!Number.isFinite(pid) || pid <= 1 || pid === process.pid) return;
@@ -22091,13 +22434,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
22091
22434
  throw err;
22092
22435
  }
22093
22436
  }
22094
- var import_node_fs51, import_node_child_process5, import_node_path52, import_execa4, import_node_readline3, cachedLoginEnv;
22437
+ var import_node_fs53, import_node_child_process5, import_node_path54, import_execa4, import_node_readline3, cachedLoginEnv;
22095
22438
  var init_conductor = __esm({
22096
22439
  "src/hook/conductor.ts"() {
22097
22440
  "use strict";
22098
- import_node_fs51 = require("fs");
22441
+ import_node_fs53 = require("fs");
22099
22442
  import_node_child_process5 = require("child_process");
22100
- import_node_path52 = require("path");
22443
+ import_node_path54 = require("path");
22101
22444
  import_execa4 = require("execa");
22102
22445
  import_node_readline3 = require("readline");
22103
22446
  init_settings();
@@ -22150,7 +22493,7 @@ function materialize(mem) {
22150
22493
  };
22151
22494
  }
22152
22495
  function setupLogPath(threadId) {
22153
- return (0, import_node_path53.join)(threadsDir(), `${threadId}.setup.log.json`);
22496
+ return (0, import_node_path55.join)(threadsDir(), `${threadId}.setup.log.json`);
22154
22497
  }
22155
22498
  function setupLogKeyForWorktree(worktreePath) {
22156
22499
  const norm = normalizeWorktreePath(worktreePath);
@@ -22168,7 +22511,7 @@ function persistNow(threadId) {
22168
22511
  const mem = memory.get(threadId);
22169
22512
  if (!mem) return;
22170
22513
  try {
22171
- (0, import_node_fs52.writeFileSync)(
22514
+ (0, import_node_fs54.writeFileSync)(
22172
22515
  setupLogPath(threadId),
22173
22516
  `${JSON.stringify(materialize(mem))}
22174
22517
  `,
@@ -22189,9 +22532,9 @@ function schedulePersist(threadId) {
22189
22532
  }
22190
22533
  function loadFromDisk(threadId) {
22191
22534
  const path = setupLogPath(threadId);
22192
- if (!(0, import_node_fs52.existsSync)(path)) return null;
22535
+ if (!(0, import_node_fs54.existsSync)(path)) return null;
22193
22536
  try {
22194
- const raw = JSON.parse((0, import_node_fs52.readFileSync)(path, "utf8"));
22537
+ const raw = JSON.parse((0, import_node_fs54.readFileSync)(path, "utf8"));
22195
22538
  return {
22196
22539
  output: typeof raw.output === "string" ? raw.output : "",
22197
22540
  running: Boolean(raw.running),
@@ -22247,13 +22590,13 @@ function finishSetupLog(threadId, exitCode, source) {
22247
22590
  persistNow(threadId);
22248
22591
  return materialize(mem);
22249
22592
  }
22250
- var import_node_crypto14, import_node_fs52, import_node_path53, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers, PERSIST_DEBOUNCE_MS;
22593
+ var import_node_crypto14, import_node_fs54, import_node_path55, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers, PERSIST_DEBOUNCE_MS;
22251
22594
  var init_setup_log = __esm({
22252
22595
  "src/store/setup-log.ts"() {
22253
22596
  "use strict";
22254
22597
  import_node_crypto14 = require("crypto");
22255
- import_node_fs52 = require("fs");
22256
- import_node_path53 = require("path");
22598
+ import_node_fs54 = require("fs");
22599
+ import_node_path55 = require("path");
22257
22600
  init_worktree_labels();
22258
22601
  init_paths();
22259
22602
  EMPTY = {
@@ -22298,7 +22641,7 @@ function safeScriptToken(scriptName) {
22298
22641
  return token || "dev";
22299
22642
  }
22300
22643
  function runLogPath(key) {
22301
- return (0, import_node_path54.join)(threadsDir(), `${key}.run.log.json`);
22644
+ return (0, import_node_path56.join)(threadsDir(), `${key}.run.log.json`);
22302
22645
  }
22303
22646
  function runLogKeyForWorktree(worktreePath, scriptName) {
22304
22647
  const norm = normalizeWorktreePath(worktreePath);
@@ -22326,7 +22669,7 @@ function persistNow2(key) {
22326
22669
  const mem = memory2.get(key);
22327
22670
  if (!mem) return;
22328
22671
  try {
22329
- (0, import_node_fs53.writeFileSync)(runLogPath(key), `${JSON.stringify(materialize2(mem))}
22672
+ (0, import_node_fs55.writeFileSync)(runLogPath(key), `${JSON.stringify(materialize2(mem))}
22330
22673
  `, "utf8");
22331
22674
  } catch {
22332
22675
  }
@@ -22343,9 +22686,9 @@ function schedulePersist2(key) {
22343
22686
  }
22344
22687
  function loadFromDisk2(key) {
22345
22688
  const path = runLogPath(key);
22346
- if (!(0, import_node_fs53.existsSync)(path)) return null;
22689
+ if (!(0, import_node_fs55.existsSync)(path)) return null;
22347
22690
  try {
22348
- const raw = JSON.parse((0, import_node_fs53.readFileSync)(path, "utf8"));
22691
+ const raw = JSON.parse((0, import_node_fs55.readFileSync)(path, "utf8"));
22349
22692
  return {
22350
22693
  output: typeof raw.output === "string" ? raw.output : "",
22351
22694
  running: Boolean(raw.running),
@@ -22403,13 +22746,13 @@ function finishRunLog(key, exitCode) {
22403
22746
  function flushRunLog(key) {
22404
22747
  persistNow2(key);
22405
22748
  }
22406
- var import_node_crypto15, import_node_fs53, import_node_path54, EMPTY2, MAX_RUN_LOG_CHARS, DEFAULT_RUN_LOG_TAIL_CHARS, memory2, persistTimers2, PERSIST_DEBOUNCE_MS2;
22749
+ var import_node_crypto15, import_node_fs55, import_node_path56, EMPTY2, MAX_RUN_LOG_CHARS, DEFAULT_RUN_LOG_TAIL_CHARS, memory2, persistTimers2, PERSIST_DEBOUNCE_MS2;
22407
22750
  var init_run_log = __esm({
22408
22751
  "src/store/run-log.ts"() {
22409
22752
  "use strict";
22410
22753
  import_node_crypto15 = require("crypto");
22411
- import_node_fs53 = require("fs");
22412
- import_node_path54 = require("path");
22754
+ import_node_fs55 = require("fs");
22755
+ import_node_path56 = require("path");
22413
22756
  init_worktree_labels();
22414
22757
  init_setup_log();
22415
22758
  init_paths();
@@ -22438,9 +22781,9 @@ async function findOrphanWorktrees(repoPaths) {
22438
22781
  repoPaths?.length ? repoPaths : threads.map((t) => t.repoPath).filter(Boolean)
22439
22782
  );
22440
22783
  const homeRoot = sideboardWorkspacesDir();
22441
- if ((0, import_node_fs54.existsSync)(homeRoot)) {
22784
+ if ((0, import_node_fs56.existsSync)(homeRoot)) {
22442
22785
  try {
22443
- for (const entry of (0, import_node_fs54.readdirSync)(homeRoot, { withFileTypes: true })) {
22786
+ for (const entry of (0, import_node_fs56.readdirSync)(homeRoot, { withFileTypes: true })) {
22444
22787
  if (!entry.isDirectory()) continue;
22445
22788
  void entry;
22446
22789
  }
@@ -22450,7 +22793,7 @@ async function findOrphanWorktrees(repoPaths) {
22450
22793
  const orphans = [];
22451
22794
  const seen = /* @__PURE__ */ new Set();
22452
22795
  for (const repoPath of repos) {
22453
- if (!repoPath || !(0, import_node_fs54.existsSync)(repoPath)) continue;
22796
+ if (!repoPath || !(0, import_node_fs56.existsSync)(repoPath)) continue;
22454
22797
  try {
22455
22798
  const wts = await listWorktrees(repoPath);
22456
22799
  for (const wt of wts) {
@@ -22461,7 +22804,7 @@ async function findOrphanWorktrees(repoPaths) {
22461
22804
  seen.add(path);
22462
22805
  let mtimeMs = 0;
22463
22806
  try {
22464
- mtimeMs = (0, import_node_fs54.statSync)(path).mtimeMs;
22807
+ mtimeMs = (0, import_node_fs56.statSync)(path).mtimeMs;
22465
22808
  } catch {
22466
22809
  mtimeMs = 0;
22467
22810
  }
@@ -22471,16 +22814,16 @@ async function findOrphanWorktrees(repoPaths) {
22471
22814
  }
22472
22815
  try {
22473
22816
  const root = worktreesRoot(repoPath);
22474
- if ((0, import_node_fs54.existsSync)(root)) {
22475
- for (const entry of (0, import_node_fs54.readdirSync)(root, { withFileTypes: true })) {
22817
+ if ((0, import_node_fs56.existsSync)(root)) {
22818
+ for (const entry of (0, import_node_fs56.readdirSync)(root, { withFileTypes: true })) {
22476
22819
  if (!entry.isDirectory()) continue;
22477
- const path = (0, import_node_path55.join)(root, entry.name).replace(/\/$/, "");
22820
+ const path = (0, import_node_path57.join)(root, entry.name).replace(/\/$/, "");
22478
22821
  if (known.has(path) || seen.has(path)) continue;
22479
- if (!(0, import_node_fs54.existsSync)((0, import_node_path55.join)(path, ".git"))) continue;
22822
+ if (!(0, import_node_fs56.existsSync)((0, import_node_path57.join)(path, ".git"))) continue;
22480
22823
  seen.add(path);
22481
22824
  let mtimeMs = 0;
22482
22825
  try {
22483
- mtimeMs = (0, import_node_fs54.statSync)(path).mtimeMs;
22826
+ mtimeMs = (0, import_node_fs56.statSync)(path).mtimeMs;
22484
22827
  } catch {
22485
22828
  mtimeMs = Date.now();
22486
22829
  }
@@ -22532,12 +22875,12 @@ function shouldRunWorktreeCleanup(settings = loadAppSettings()) {
22532
22875
  const elapsed = Date.now() - Date.parse(last);
22533
22876
  return elapsed >= intervalHours * 36e5;
22534
22877
  }
22535
- var import_node_fs54, import_node_path55;
22878
+ var import_node_fs56, import_node_path57;
22536
22879
  var init_orphan_cleanup = __esm({
22537
22880
  "src/git/orphan-cleanup.ts"() {
22538
22881
  "use strict";
22539
- import_node_fs54 = require("fs");
22540
- import_node_path55 = require("path");
22882
+ import_node_fs56 = require("fs");
22883
+ import_node_path57 = require("path");
22541
22884
  init_worktree();
22542
22885
  init_thread_store();
22543
22886
  init_paths();
@@ -22713,12 +23056,12 @@ async function cloneRepoIntoSideboard(opts) {
22713
23056
  if (!url) throw new Error("Clone URL is required");
22714
23057
  let name = opts.name?.trim();
22715
23058
  if (!name) {
22716
- const leaf = (0, import_node_path56.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
23059
+ const leaf = (0, import_node_path58.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
22717
23060
  name = leaf || "repo";
22718
23061
  }
22719
23062
  name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
22720
- const dest = (0, import_node_path56.join)(sideboardReposDir(), name);
22721
- if ((0, import_node_fs55.existsSync)(dest)) {
23063
+ const dest = (0, import_node_path58.join)(sideboardReposDir(), name);
23064
+ if ((0, import_node_fs57.existsSync)(dest)) {
22722
23065
  const repoPath2 = await resolveRepoRoot(dest);
22723
23066
  const workspace2 = await addWorkspace(repoPath2);
22724
23067
  return { repoPath: repoPath2, workspace: workspace2 };
@@ -22733,12 +23076,12 @@ async function cloneRepoIntoSideboard(opts) {
22733
23076
  const workspace = await addWorkspace(repoPath);
22734
23077
  return { repoPath, workspace };
22735
23078
  }
22736
- var import_node_fs55, import_node_path56, import_execa6;
23079
+ var import_node_fs57, import_node_path58, import_execa6;
22737
23080
  var init_clone_repo = __esm({
22738
23081
  "src/git/clone-repo.ts"() {
22739
23082
  "use strict";
22740
- import_node_fs55 = require("fs");
22741
- import_node_path56 = require("path");
23083
+ import_node_fs57 = require("fs");
23084
+ import_node_path58 = require("path");
22742
23085
  import_execa6 = require("execa");
22743
23086
  init_paths();
22744
23087
  init_workspaces();
@@ -22758,11 +23101,11 @@ var init_thread = __esm({
22758
23101
 
22759
23102
  // src/store/desktop-host.ts
22760
23103
  function desktopHostPidPath() {
22761
- return (0, import_node_path57.join)(appDataDir(), "desktop-host.pid");
23104
+ return (0, import_node_path59.join)(appDataDir(), "desktop-host.pid");
22762
23105
  }
22763
23106
  function readDesktopHostPid() {
22764
23107
  try {
22765
- const pid = Number.parseInt((0, import_node_fs56.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
23108
+ const pid = Number.parseInt((0, import_node_fs58.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
22766
23109
  if (!Number.isFinite(pid) || pid <= 0) return null;
22767
23110
  return pid;
22768
23111
  } catch {
@@ -22788,12 +23131,12 @@ function thisProcessShouldDrainAgentQueues() {
22788
23131
  if (isThisProcessDesktopHost()) return true;
22789
23132
  return !isDesktopHostAlive();
22790
23133
  }
22791
- var import_node_fs56, import_node_path57;
23134
+ var import_node_fs58, import_node_path59;
22792
23135
  var init_desktop_host = __esm({
22793
23136
  "src/store/desktop-host.ts"() {
22794
23137
  "use strict";
22795
- import_node_fs56 = require("fs");
22796
- import_node_path57 = require("path");
23138
+ import_node_fs58 = require("fs");
23139
+ import_node_path59 = require("path");
22797
23140
  init_paths();
22798
23141
  }
22799
23142
  });
@@ -22833,12 +23176,12 @@ function denyPendingToolPermissions(threadId) {
22833
23176
  const last = pending[pending.length - 1];
22834
23177
  if (last) clearPrompt(threadId, last.id);
22835
23178
  }
22836
- var import_node_crypto16, import_node_path58, queues, publisher;
23179
+ var import_node_crypto16, import_node_path60, queues, publisher;
22837
23180
  var init_tool_permission = __esm({
22838
23181
  "src/agents/tool-permission.ts"() {
22839
23182
  "use strict";
22840
23183
  import_node_crypto16 = require("crypto");
22841
- import_node_path58 = require("path");
23184
+ import_node_path60 = require("path");
22842
23185
  init_claude_mcp();
22843
23186
  queues = /* @__PURE__ */ new Map();
22844
23187
  publisher = null;
@@ -23677,7 +24020,7 @@ async function requireAgent(agent, opts) {
23677
24020
  ensureAgentPath();
23678
24021
  enrichPathWithNpmGlobalBin();
23679
24022
  const status = await Promise.race([
23680
- getAdapter(agent).detect(),
24023
+ agent === "acp" ? detectAcpHarness(opts?.acpHarness ?? defaultAcpHarness()) : getAdapter(agent).detect(),
23681
24024
  new Promise((_, reject) => {
23682
24025
  setTimeout(() => {
23683
24026
  reject(
@@ -23703,6 +24046,7 @@ var init_detect = __esm({
23703
24046
  "src/detect/detect.ts"() {
23704
24047
  "use strict";
23705
24048
  init_agents();
24049
+ init_acp_harness();
23706
24050
  REQUIRE_AGENT_TIMEOUT_MS = 8e3;
23707
24051
  }
23708
24052
  });
@@ -26009,7 +26353,7 @@ function reuseLiveThread(input, repoPath, match) {
26009
26353
  }
26010
26354
  async function createThread(input, _onSetupLine) {
26011
26355
  const repoPath = await resolveRepoRoot(input.repoPath);
26012
- if (!(0, import_node_fs57.existsSync)(repoPath)) {
26356
+ if (!(0, import_node_fs59.existsSync)(repoPath)) {
26013
26357
  throw new Error(`Repo not found: ${repoPath}`);
26014
26358
  }
26015
26359
  if (isRemovedWorkspace(repoPath)) throw new Error(`Project was removed: ${repoPath}`);
@@ -26026,7 +26370,8 @@ async function createThread(input, _onSetupLine) {
26026
26370
  fast: input.fast,
26027
26371
  autonomy: input.autonomy
26028
26372
  });
26029
- await requireAgent(resolved.agent);
26373
+ const acpHarness = resolved.agent === "acp" ? input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : defaultAcpHarness() : void 0;
26374
+ await requireAgent(resolved.agent, { acpHarness });
26030
26375
  if (input.cowboy) {
26031
26376
  const { cowboyModeEnabled: cowboyModeEnabled2 } = await Promise.resolve().then(() => (init_app_settings(), app_settings_exports));
26032
26377
  if (!cowboyModeEnabled2()) {
@@ -26063,6 +26408,7 @@ async function createThread(input, _onSetupLine) {
26063
26408
  worktreePath: repoPath,
26064
26409
  repoPath,
26065
26410
  agent: resolved.agent,
26411
+ ...acpHarness ? { acpHarness } : {},
26066
26412
  autonomy: resolved.autonomy,
26067
26413
  model: resolved.model,
26068
26414
  effort: resolved.effort,
@@ -26177,6 +26523,7 @@ async function createThread(input, _onSetupLine) {
26177
26523
  worktreePath,
26178
26524
  repoPath,
26179
26525
  agent: resolved.agent,
26526
+ ...acpHarness ? { acpHarness } : {},
26180
26527
  autonomy: resolved.autonomy,
26181
26528
  model: resolved.model,
26182
26529
  effort: resolved.effort,
@@ -26197,11 +26544,12 @@ async function createThread(input, _onSetupLine) {
26197
26544
  await ensureWorkspace(repoPath);
26198
26545
  return readThread(thread.id) ?? thread;
26199
26546
  }
26200
- var import_node_fs57;
26547
+ var import_node_fs59;
26201
26548
  var init_create = __esm({
26202
26549
  "src/threads/create.ts"() {
26203
26550
  "use strict";
26204
- import_node_fs57 = require("fs");
26551
+ import_node_fs59 = require("fs");
26552
+ init_acp_harness();
26205
26553
  init_detect();
26206
26554
  init_worktree();
26207
26555
  init_worktree_labels();
@@ -26250,6 +26598,36 @@ var init_cowboy = __esm({
26250
26598
  }
26251
26599
  });
26252
26600
 
26601
+ // src/orchestrator/thread-agent-patch.ts
26602
+ function applyThreadAgentPatch(thread, patch, next) {
26603
+ const agent = patch.agent ?? thread.agent;
26604
+ const harness = agent === "acp" ? patch.acpHarness === "gemini" || patch.acpHarness === "copilot" ? patch.acpHarness : thread.acpHarness === "gemini" || thread.acpHarness === "copilot" ? thread.acpHarness : defaultAcpHarness() : null;
26605
+ const providerChanged = agent !== thread.agent || agent === "acp" && harness !== (thread.acpHarness ?? null);
26606
+ if (providerChanged) {
26607
+ if (thread.messages.length > 0) {
26608
+ const from = thread.agent === "acp" ? thread.acpHarness === "copilot" ? "copilot" : "gemini" : thread.agent;
26609
+ const to = agent === "acp" ? harness === "copilot" ? "copilot" : "gemini" : agent;
26610
+ throw new Error(
26611
+ `Cannot switch agent provider mid-chat (${from} \u2192 ${to}). Start a new chat tab instead.`
26612
+ );
26613
+ }
26614
+ if (isOrchestratorThread(thread)) assertOrchestratorCapableAgent(agent);
26615
+ next.agent = agent;
26616
+ if (agent !== "claude" && patch.model === void 0) next.model = null;
26617
+ next.sessionId = null;
26618
+ }
26619
+ if (agent === "acp") next.acpHarness = harness;
26620
+ else if (thread.acpHarness) next.acpHarness = null;
26621
+ }
26622
+ var init_thread_agent_patch = __esm({
26623
+ "src/orchestrator/thread-agent-patch.ts"() {
26624
+ "use strict";
26625
+ init_acp_harness();
26626
+ init_orchestrator_capable();
26627
+ init_global_workspace();
26628
+ }
26629
+ });
26630
+
26253
26631
  // src/archive/fleet-archive.ts
26254
26632
  function oneLine(value) {
26255
26633
  return value.replace(/\s+/g, " ").trim();
@@ -26260,7 +26638,7 @@ function stampOf(thread) {
26260
26638
  function repoLabel(thread) {
26261
26639
  if (isOrchestratorThread(thread)) return "Orchestration";
26262
26640
  const path = thread.repoPath?.trim() ?? "";
26263
- return path && (0, import_node_path59.basename)(path) || path || "project";
26641
+ return path && (0, import_node_path61.basename)(path) || path || "project";
26264
26642
  }
26265
26643
  function toAgent(thread, flags) {
26266
26644
  const prUrl = thread.prUrl?.trim();
@@ -26459,11 +26837,11 @@ function formatFleetArchive(view) {
26459
26837
  }
26460
26838
  return lines.join("\n");
26461
26839
  }
26462
- var import_node_path59, DEFAULT_LIMIT, MAX_LIMIT;
26840
+ var import_node_path61, DEFAULT_LIMIT, MAX_LIMIT;
26463
26841
  var init_fleet_archive = __esm({
26464
26842
  "src/archive/fleet-archive.ts"() {
26465
26843
  "use strict";
26466
- import_node_path59 = require("path");
26844
+ import_node_path61 = require("path");
26467
26845
  init_global_workspace();
26468
26846
  init_worktree_labels();
26469
26847
  DEFAULT_LIMIT = 40;
@@ -26638,11 +27016,11 @@ function writeTurnLive(threadId, progress) {
26638
27016
  const path = threadLivePath(threadId);
26639
27017
  const tmp = `${path}.${process.pid}.tmp`;
26640
27018
  try {
26641
- (0, import_node_fs58.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
26642
- (0, import_node_fs58.renameSync)(tmp, path);
27019
+ (0, import_node_fs60.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
27020
+ (0, import_node_fs60.renameSync)(tmp, path);
26643
27021
  } catch {
26644
27022
  try {
26645
- (0, import_node_fs58.unlinkSync)(tmp);
27023
+ (0, import_node_fs60.unlinkSync)(tmp);
26646
27024
  } catch {
26647
27025
  }
26648
27026
  }
@@ -26652,9 +27030,9 @@ function readTurnLiveParts(threadId) {
26652
27030
  }
26653
27031
  function readTurnLive(threadId) {
26654
27032
  const path = threadLivePath(threadId);
26655
- if (!(0, import_node_fs58.existsSync)(path)) return null;
27033
+ if (!(0, import_node_fs60.existsSync)(path)) return null;
26656
27034
  try {
26657
- const raw = JSON.parse((0, import_node_fs58.readFileSync)(path, "utf8"));
27035
+ const raw = JSON.parse((0, import_node_fs60.readFileSync)(path, "utf8"));
26658
27036
  if (!raw || typeof raw.summary !== "string") return null;
26659
27037
  return raw;
26660
27038
  } catch {
@@ -26666,17 +27044,17 @@ function clearTurnLive(threadId) {
26666
27044
  if (buf?.timer) clearTimeout(buf.timer);
26667
27045
  buffers.delete(threadId);
26668
27046
  const path = threadLivePath(threadId);
26669
- if (!(0, import_node_fs58.existsSync)(path)) return;
27047
+ if (!(0, import_node_fs60.existsSync)(path)) return;
26670
27048
  try {
26671
- (0, import_node_fs58.unlinkSync)(path);
27049
+ (0, import_node_fs60.unlinkSync)(path);
26672
27050
  } catch {
26673
27051
  }
26674
27052
  }
26675
- var import_node_fs58, buffers, FLUSH_MS, MAX_PARTS;
27053
+ var import_node_fs60, buffers, FLUSH_MS, MAX_PARTS;
26676
27054
  var init_turn_live = __esm({
26677
27055
  "src/store/turn-live.ts"() {
26678
27056
  "use strict";
26679
- import_node_fs58 = require("fs");
27057
+ import_node_fs60 = require("fs");
26680
27058
  init_message_parts();
26681
27059
  init_paths();
26682
27060
  init_agent_block();
@@ -26751,6 +27129,7 @@ async function forkThreadWorktree(input, onSetupLine) {
26751
27129
  sourceRef: from.branchName,
26752
27130
  repoPath: from.repoPath,
26753
27131
  agent: nextAgent,
27132
+ acpHarness: nextAgent === "acp" ? input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : from.acpHarness : void 0,
26754
27133
  autonomy: from.autonomy,
26755
27134
  model: nextModel,
26756
27135
  effort: from.effort,
@@ -26960,10 +27339,10 @@ var init_quota_failover = __esm({
26960
27339
  // src/threads/adopt.ts
26961
27340
  function thisModuleFile2() {
26962
27341
  const cjsFile = typeof __filename !== "undefined" ? __filename : "";
26963
- return cjsFile || process.argv[1] || (0, import_node_path60.join)(process.cwd(), "package.json");
27342
+ return cjsFile || process.argv[1] || (0, import_node_path62.join)(process.cwd(), "package.json");
26964
27343
  }
26965
27344
  function openReadonlySqlite(file) {
26966
- const req = (0, import_node_module6.createRequire)(thisModuleFile2());
27345
+ const req = (0, import_node_module7.createRequire)(thisModuleFile2());
26967
27346
  const Database = req("better-sqlite3");
26968
27347
  return new Database(file, { readonly: true, fileMustExist: true });
26969
27348
  }
@@ -26978,21 +27357,21 @@ function mapAgentType(raw) {
26978
27357
  return null;
26979
27358
  }
26980
27359
  function resolveConductorCursorAgentId(workspacePath) {
26981
- if (!workspacePath || !(0, import_node_fs59.existsSync)(CURSOR_SDK_STORE)) return null;
27360
+ if (!workspacePath || !(0, import_node_fs61.existsSync)(CURSOR_SDK_STORE)) return null;
26982
27361
  const normalized = workspacePath.replace(/\/$/, "");
26983
27362
  let best = null;
26984
27363
  let hashes;
26985
27364
  try {
26986
- hashes = (0, import_node_fs59.readdirSync)(CURSOR_SDK_STORE);
27365
+ hashes = (0, import_node_fs61.readdirSync)(CURSOR_SDK_STORE);
26987
27366
  } catch {
26988
27367
  return null;
26989
27368
  }
26990
27369
  for (const hash of hashes) {
26991
- const agentsFile = (0, import_node_path60.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
26992
- if (!(0, import_node_fs59.existsSync)(agentsFile)) continue;
27370
+ const agentsFile = (0, import_node_path62.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
27371
+ if (!(0, import_node_fs61.existsSync)(agentsFile)) continue;
26993
27372
  let text8;
26994
27373
  try {
26995
- text8 = (0, import_node_fs59.readFileSync)(agentsFile, "utf8");
27374
+ text8 = (0, import_node_fs61.readFileSync)(agentsFile, "utf8");
26996
27375
  } catch {
26997
27376
  continue;
26998
27377
  }
@@ -27016,7 +27395,7 @@ function resolveConductorCursorAgentId(workspacePath) {
27016
27395
  return best?.agentId ?? null;
27017
27396
  }
27018
27397
  async function adoptThread(input) {
27019
- if (!(0, import_node_fs59.existsSync)(input.worktreePath)) {
27398
+ if (!(0, import_node_fs61.existsSync)(input.worktreePath)) {
27020
27399
  throw new Error(`Worktree not found: ${input.worktreePath}`);
27021
27400
  }
27022
27401
  const repoPath = await resolveRepoRoot(input.worktreePath);
@@ -27031,6 +27410,9 @@ async function adoptThread(input) {
27031
27410
  worktreePath: input.worktreePath,
27032
27411
  repoPath,
27033
27412
  agent: input.agent,
27413
+ ...input.agent === "acp" ? {
27414
+ acpHarness: input.acpHarness === "gemini" || input.acpHarness === "copilot" ? input.acpHarness : void 0
27415
+ } : {},
27034
27416
  sessionId: input.sessionId ?? null,
27035
27417
  messages: input.messages ?? []
27036
27418
  });
@@ -27042,18 +27424,18 @@ async function adoptThread(input) {
27042
27424
  return thread;
27043
27425
  }
27044
27426
  function listConductorWorkspaces() {
27045
- if (!(0, import_node_fs59.existsSync)(CONDUCTOR_DB)) {
27427
+ if (!(0, import_node_fs61.existsSync)(CONDUCTOR_DB)) {
27046
27428
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
27047
27429
  }
27048
- const tmp = (0, import_node_fs59.mkdtempSync)((0, import_node_path60.join)((0, import_node_os18.tmpdir)(), "sideboard-conductor-"));
27049
- const snapshot = (0, import_node_path60.join)(tmp, "conductor.db");
27430
+ const tmp = (0, import_node_fs61.mkdtempSync)((0, import_node_path62.join)((0, import_node_os20.tmpdir)(), "sideboard-conductor-"));
27431
+ const snapshot = (0, import_node_path62.join)(tmp, "conductor.db");
27050
27432
  try {
27051
- (0, import_node_fs59.copyFileSync)(CONDUCTOR_DB, snapshot);
27433
+ (0, import_node_fs61.copyFileSync)(CONDUCTOR_DB, snapshot);
27052
27434
  for (const suffix of ["-wal", "-shm"]) {
27053
27435
  const src = `${CONDUCTOR_DB}${suffix}`;
27054
- if ((0, import_node_fs59.existsSync)(src)) {
27436
+ if ((0, import_node_fs61.existsSync)(src)) {
27055
27437
  try {
27056
- (0, import_node_fs59.copyFileSync)(src, `${snapshot}${suffix}`);
27438
+ (0, import_node_fs61.copyFileSync)(src, `${snapshot}${suffix}`);
27057
27439
  } catch {
27058
27440
  }
27059
27441
  }
@@ -27129,22 +27511,22 @@ function listConductorWorkspaces() {
27129
27511
  db.close();
27130
27512
  }
27131
27513
  } finally {
27132
- (0, import_node_fs59.rmSync)(tmp, { recursive: true, force: true });
27514
+ (0, import_node_fs61.rmSync)(tmp, { recursive: true, force: true });
27133
27515
  }
27134
27516
  }
27135
27517
  function importConductorWorkspace(workspaceId) {
27136
- if (!(0, import_node_fs59.existsSync)(CONDUCTOR_DB)) {
27518
+ if (!(0, import_node_fs61.existsSync)(CONDUCTOR_DB)) {
27137
27519
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
27138
27520
  }
27139
- const tmp = (0, import_node_fs59.mkdtempSync)((0, import_node_path60.join)((0, import_node_os18.tmpdir)(), "sideboard-conductor-"));
27140
- const snapshot = (0, import_node_path60.join)(tmp, "conductor.db");
27521
+ const tmp = (0, import_node_fs61.mkdtempSync)((0, import_node_path62.join)((0, import_node_os20.tmpdir)(), "sideboard-conductor-"));
27522
+ const snapshot = (0, import_node_path62.join)(tmp, "conductor.db");
27141
27523
  try {
27142
- (0, import_node_fs59.copyFileSync)(CONDUCTOR_DB, snapshot);
27524
+ (0, import_node_fs61.copyFileSync)(CONDUCTOR_DB, snapshot);
27143
27525
  for (const suffix of ["-wal", "-shm"]) {
27144
27526
  const src = `${CONDUCTOR_DB}${suffix}`;
27145
- if ((0, import_node_fs59.existsSync)(src)) {
27527
+ if ((0, import_node_fs61.existsSync)(src)) {
27146
27528
  try {
27147
- (0, import_node_fs59.copyFileSync)(src, `${snapshot}${suffix}`);
27529
+ (0, import_node_fs61.copyFileSync)(src, `${snapshot}${suffix}`);
27148
27530
  } catch {
27149
27531
  }
27150
27532
  }
@@ -27162,7 +27544,7 @@ function importConductorWorkspace(workspaceId) {
27162
27544
  ).get(workspaceId);
27163
27545
  if (!row) throw new Error(`Conductor workspace not found: ${workspaceId}`);
27164
27546
  const worktreePath = String(row.workspacePath);
27165
- if (!(0, import_node_fs59.existsSync)(worktreePath)) {
27547
+ if (!(0, import_node_fs61.existsSync)(worktreePath)) {
27166
27548
  throw new Error(`Conductor worktree missing on disk: ${worktreePath}`);
27167
27549
  }
27168
27550
  let sessionId = null;
@@ -27225,31 +27607,31 @@ function importConductorWorkspace(workspaceId) {
27225
27607
  db.close();
27226
27608
  }
27227
27609
  } finally {
27228
- (0, import_node_fs59.rmSync)(tmp, { recursive: true, force: true });
27610
+ (0, import_node_fs61.rmSync)(tmp, { recursive: true, force: true });
27229
27611
  }
27230
27612
  }
27231
27613
  async function importConductorWorkspaceAsync(workspaceId) {
27232
27614
  return importConductorWorkspace(workspaceId);
27233
27615
  }
27234
- var import_node_child_process6, import_node_fs59, import_node_os18, import_node_path60, import_node_module6, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
27616
+ var import_node_child_process6, import_node_fs61, import_node_os20, import_node_path62, import_node_module7, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
27235
27617
  var init_adopt = __esm({
27236
27618
  "src/threads/adopt.ts"() {
27237
27619
  "use strict";
27238
27620
  import_node_child_process6 = require("child_process");
27239
- import_node_fs59 = require("fs");
27240
- import_node_os18 = require("os");
27241
- import_node_path60 = require("path");
27242
- import_node_module6 = require("module");
27621
+ import_node_fs61 = require("fs");
27622
+ import_node_os20 = require("os");
27623
+ import_node_path62 = require("path");
27624
+ import_node_module7 = require("module");
27243
27625
  init_worktree();
27244
27626
  init_thread_store();
27245
- CONDUCTOR_APP_SUPPORT = (0, import_node_path60.join)(
27627
+ CONDUCTOR_APP_SUPPORT = (0, import_node_path62.join)(
27246
27628
  process.env.HOME ?? "",
27247
27629
  "Library",
27248
27630
  "Application Support",
27249
27631
  "com.conductor.app"
27250
27632
  );
27251
- CONDUCTOR_DB = (0, import_node_path60.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
27252
- CURSOR_SDK_STORE = (0, import_node_path60.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
27633
+ CONDUCTOR_DB = (0, import_node_path62.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
27634
+ CURSOR_SDK_STORE = (0, import_node_path62.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
27253
27635
  }
27254
27636
  });
27255
27637
 
@@ -27316,7 +27698,7 @@ async function openStackLayer(input, _onSetupLine) {
27316
27698
  let createdWorktree = false;
27317
27699
  const trees = await listWorktrees(repoPath);
27318
27700
  const checkedOut = trees.find((w) => w.branch === branchName);
27319
- if (checkedOut?.path && (0, import_node_fs60.existsSync)(checkedOut.path)) {
27701
+ if (checkedOut?.path && (0, import_node_fs62.existsSync)(checkedOut.path)) {
27320
27702
  if (input.reuseExistingWorktree !== false) {
27321
27703
  worktreePath = checkedOut.path;
27322
27704
  } else {
@@ -27458,7 +27840,7 @@ async function initStackFromThread(input, onSetupLine) {
27458
27840
  async function createPrStack(input, onSetupLine) {
27459
27841
  await requireAgent(input.agent);
27460
27842
  const repoPath = await resolveRepoRoot(input.repoPath);
27461
- if (!(0, import_node_fs60.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
27843
+ if (!(0, import_node_fs62.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
27462
27844
  if (!input.branches.length) throw new Error("At least one branch name required");
27463
27845
  const status = await detectGhStack(repoPath);
27464
27846
  if (!status.available) throw new Error(status.reason);
@@ -27525,7 +27907,7 @@ async function createPrStack(input, onSetupLine) {
27525
27907
  }
27526
27908
  }
27527
27909
  const claimed = new Set(threads.map((t) => t.worktreePath));
27528
- if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs60.existsSync)(bootstrap.worktreePath)) {
27910
+ if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs62.existsSync)(bootstrap.worktreePath)) {
27529
27911
  try {
27530
27912
  await removeWorktree(repoPath, bootstrap.worktreePath, {
27531
27913
  deleteBranch: bootstrap.branchName
@@ -27535,11 +27917,11 @@ async function createPrStack(input, onSetupLine) {
27535
27917
  }
27536
27918
  return { stack, threads, createdThreadIds };
27537
27919
  }
27538
- var import_node_fs60;
27920
+ var import_node_fs62;
27539
27921
  var init_stack_layers = __esm({
27540
27922
  "src/threads/stack-layers.ts"() {
27541
27923
  "use strict";
27542
- import_node_fs60 = require("fs");
27924
+ import_node_fs62 = require("fs");
27543
27925
  init_detect();
27544
27926
  init_run();
27545
27927
  init_stack();
@@ -27579,11 +27961,11 @@ async function formatPrCreateFailure(raw, cwd, ctx) {
27579
27961
  }
27580
27962
  async function createCursorPullRequest(worktreePath, slug, opts) {
27581
27963
  const bodyText = (opts.body ?? opts.title).trim() || opts.title;
27582
- const bodyFile = (0, import_node_path61.join)(
27583
- (0, import_node_os19.tmpdir)(),
27964
+ const bodyFile = (0, import_node_path63.join)(
27965
+ (0, import_node_os21.tmpdir)(),
27584
27966
  `sideboard-pr-body-${process.pid}-${(0, import_node_crypto20.randomBytes)(6).toString("hex")}.md`
27585
27967
  );
27586
- (0, import_node_fs61.writeFileSync)(bodyFile, bodyText.endsWith("\n") ? bodyText : `${bodyText}
27968
+ (0, import_node_fs63.writeFileSync)(bodyFile, bodyText.endsWith("\n") ? bodyText : `${bodyText}
27587
27969
  `, "utf8");
27588
27970
  try {
27589
27971
  return await createOrUpdateCursorPr(worktreePath, slug, {
@@ -27595,7 +27977,7 @@ async function createCursorPullRequest(worktreePath, slug, opts) {
27595
27977
  });
27596
27978
  } finally {
27597
27979
  try {
27598
- (0, import_node_fs61.unlinkSync)(bodyFile);
27980
+ (0, import_node_fs63.unlinkSync)(bodyFile);
27599
27981
  } catch {
27600
27982
  }
27601
27983
  }
@@ -27621,11 +28003,11 @@ async function createOrUpdatePr(worktreePath, opts) {
27621
28003
  const headRef = ghHeadRef(slug, opts.head);
27622
28004
  const branchOnly = opts.head.trim().replace(/^refs\/heads\//, "");
27623
28005
  const bodyText = clampGithubPrBody(opts.body ?? opts.title);
27624
- const bodyFile = (0, import_node_path61.join)(
27625
- (0, import_node_os19.tmpdir)(),
28006
+ const bodyFile = (0, import_node_path63.join)(
28007
+ (0, import_node_os21.tmpdir)(),
27626
28008
  `sideboard-pr-body-${process.pid}-${(0, import_node_crypto20.randomBytes)(6).toString("hex")}.md`
27627
28009
  );
27628
- (0, import_node_fs61.writeFileSync)(bodyFile, bodyText.endsWith("\n") ? bodyText : `${bodyText}
28010
+ (0, import_node_fs63.writeFileSync)(bodyFile, bodyText.endsWith("\n") ? bodyText : `${bodyText}
27629
28011
  `, "utf8");
27630
28012
  const bodyArgs = ["--body-file", bodyFile];
27631
28013
  try {
@@ -27639,7 +28021,7 @@ async function createOrUpdatePr(worktreePath, opts) {
27639
28021
  });
27640
28022
  } finally {
27641
28023
  try {
27642
- (0, import_node_fs61.unlinkSync)(bodyFile);
28024
+ (0, import_node_fs63.unlinkSync)(bodyFile);
27643
28025
  } catch {
27644
28026
  }
27645
28027
  }
@@ -27714,14 +28096,14 @@ async function createOrUpdatePrWithBodyFile(worktreePath, opts) {
27714
28096
  const url = created.stdout.trim().split("\n").find((l) => l.startsWith("http")) ?? created.stdout.trim();
27715
28097
  return url;
27716
28098
  }
27717
- var import_node_crypto20, import_node_fs61, import_node_os19, import_node_path61;
28099
+ var import_node_crypto20, import_node_fs63, import_node_os21, import_node_path63;
27718
28100
  var init_pr_write = __esm({
27719
28101
  "src/git/pr-write.ts"() {
27720
28102
  "use strict";
27721
28103
  import_node_crypto20 = require("crypto");
27722
- import_node_fs61 = require("fs");
27723
- import_node_os19 = require("os");
27724
- import_node_path61 = require("path");
28104
+ import_node_fs63 = require("fs");
28105
+ import_node_os21 = require("os");
28106
+ import_node_path63 = require("path");
27725
28107
  init_gh_errors();
27726
28108
  init_run();
27727
28109
  init_cursor_pr();
@@ -27731,7 +28113,7 @@ var init_pr_write = __esm({
27731
28113
 
27732
28114
  // src/diff/diff.ts
27733
28115
  async function inspectGitWorktree(worktreePath) {
27734
- if (!worktreePath || !(0, import_node_fs62.existsSync)(worktreePath)) return "missing_worktree";
28116
+ if (!worktreePath || !(0, import_node_fs64.existsSync)(worktreePath)) return "missing_worktree";
27735
28117
  const check = await git(["rev-parse", "--is-inside-work-tree"], worktreePath, {
27736
28118
  reject: false
27737
28119
  });
@@ -27739,7 +28121,7 @@ async function inspectGitWorktree(worktreePath) {
27739
28121
  return "ok";
27740
28122
  }
27741
28123
  async function initializeGitRepository(worktreePath) {
27742
- if (!worktreePath || !(0, import_node_fs62.existsSync)(worktreePath)) {
28124
+ if (!worktreePath || !(0, import_node_fs64.existsSync)(worktreePath)) {
27743
28125
  throw new Error("Worktree not found");
27744
28126
  }
27745
28127
  const status = await inspectGitWorktree(worktreePath);
@@ -27873,11 +28255,11 @@ new file mode 100644
27873
28255
  };
27874
28256
  }
27875
28257
  async function untrackedPatch(worktreePath, path, maxHunk) {
27876
- const abs = (0, import_node_path62.join)(worktreePath, path);
28258
+ const abs = (0, import_node_path64.join)(worktreePath, path);
27877
28259
  try {
27878
- const st = (0, import_node_fs62.statSync)(abs);
28260
+ const st = (0, import_node_fs64.statSync)(abs);
27879
28261
  if (st.isFile() && st.size > maxHunk) {
27880
- const buf = (0, import_node_fs62.readFileSync)(abs).subarray(0, maxHunk);
28262
+ const buf = (0, import_node_fs64.readFileSync)(abs).subarray(0, maxHunk);
27881
28263
  return syntheticAddPatch(path, buf.toString("utf8"), maxHunk);
27882
28264
  }
27883
28265
  } catch {
@@ -28344,9 +28726,9 @@ async function getDiff(worktreePath, repoPath, opts) {
28344
28726
  }
28345
28727
  function statWorktreePath(worktreePath, relativePath) {
28346
28728
  assertSafeRelativePath(relativePath);
28347
- const abs = (0, import_node_path62.join)(worktreePath, relativePath);
28348
- if (!(0, import_node_fs62.existsSync)(abs)) return "missing";
28349
- const st = (0, import_node_fs62.statSync)(abs);
28729
+ const abs = (0, import_node_path64.join)(worktreePath, relativePath);
28730
+ if (!(0, import_node_fs64.existsSync)(abs)) return "missing";
28731
+ const st = (0, import_node_fs64.statSync)(abs);
28350
28732
  if (st.isDirectory()) return "dir";
28351
28733
  if (st.isFile()) return "file";
28352
28734
  return "missing";
@@ -28375,8 +28757,8 @@ function isImageRelativePath(relativePath) {
28375
28757
  function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
28376
28758
  assertSafeRelativePath(relativePath);
28377
28759
  const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
28378
- const abs = (0, import_node_path62.join)(worktreePath, relativePath);
28379
- const st = (0, import_node_fs62.statSync)(abs);
28760
+ const abs = (0, import_node_path64.join)(worktreePath, relativePath);
28761
+ const st = (0, import_node_fs64.statSync)(abs);
28380
28762
  if (!st.isFile()) {
28381
28763
  throw new Error(`Not a file: ${relativePath}`);
28382
28764
  }
@@ -28385,7 +28767,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
28385
28767
  `File too large to upload (${st.size} bytes; max ${maxBytes})`
28386
28768
  );
28387
28769
  }
28388
- const buf = (0, import_node_fs62.readFileSync)(abs);
28770
+ const buf = (0, import_node_fs64.readFileSync)(abs);
28389
28771
  return {
28390
28772
  path: relativePath,
28391
28773
  contentBase64: buf.toString("base64"),
@@ -28395,12 +28777,12 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
28395
28777
  function readWorktreeFile(worktreePath, relativePath, opts) {
28396
28778
  assertSafeRelativePath(relativePath);
28397
28779
  const maxBytes = opts?.maxBytes ?? 2e5;
28398
- const abs = (0, import_node_path62.join)(worktreePath, relativePath);
28399
- const st = (0, import_node_fs62.statSync)(abs);
28780
+ const abs = (0, import_node_path64.join)(worktreePath, relativePath);
28781
+ const st = (0, import_node_fs64.statSync)(abs);
28400
28782
  if (!st.isFile()) {
28401
28783
  throw new Error(`Not a file: ${relativePath}`);
28402
28784
  }
28403
- const buf = (0, import_node_fs62.readFileSync)(abs);
28785
+ const buf = (0, import_node_fs64.readFileSync)(abs);
28404
28786
  if (isImageRelativePath(relativePath)) {
28405
28787
  const maxImageBytes = Math.max(maxBytes, 15e6);
28406
28788
  const truncated2 = buf.length > maxImageBytes;
@@ -28443,9 +28825,9 @@ function assertSafeRelativePath(relativePath) {
28443
28825
  }
28444
28826
  function writeWorktreeFile(worktreePath, relativePath, content) {
28445
28827
  assertSafeRelativePath(relativePath);
28446
- const abs = (0, import_node_path62.join)(worktreePath, relativePath);
28447
- (0, import_node_fs62.mkdirSync)((0, import_node_path62.dirname)(abs), { recursive: true });
28448
- (0, import_node_fs62.writeFileSync)(abs, content, "utf8");
28828
+ const abs = (0, import_node_path64.join)(worktreePath, relativePath);
28829
+ (0, import_node_fs64.mkdirSync)((0, import_node_path64.dirname)(abs), { recursive: true });
28830
+ (0, import_node_fs64.writeFileSync)(abs, content, "utf8");
28449
28831
  return { path: relativePath };
28450
28832
  }
28451
28833
  async function getWorktreeDirtyStat(worktreePath) {
@@ -28485,12 +28867,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
28485
28867
  truncated: full.files.length > maxFiles
28486
28868
  };
28487
28869
  }
28488
- var import_node_fs62, import_node_path62, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
28870
+ var import_node_fs64, import_node_path64, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
28489
28871
  var init_diff = __esm({
28490
28872
  "src/diff/diff.ts"() {
28491
28873
  "use strict";
28492
- import_node_fs62 = require("fs");
28493
- import_node_path62 = require("path");
28874
+ import_node_fs64 = require("fs");
28875
+ import_node_path64 = require("path");
28494
28876
  init_run();
28495
28877
  init_worktree();
28496
28878
  mergeBaseCache = /* @__PURE__ */ new Map();
@@ -28713,16 +29095,16 @@ function readWorktreeFileTail(worktreePath, relativePath, maxBytes = WORKTREE_TA
28713
29095
  if (!relativePath || relativePath.includes("..") || relativePath.startsWith("/")) {
28714
29096
  throw new Error("Invalid path");
28715
29097
  }
28716
- const abs = (0, import_node_path63.join)(worktreePath, relativePath);
28717
- const fd = (0, import_node_fs63.openSync)(abs, "r");
29098
+ const abs = (0, import_node_path65.join)(worktreePath, relativePath);
29099
+ const fd = (0, import_node_fs65.openSync)(abs, "r");
28718
29100
  try {
28719
- const st = (0, import_node_fs63.fstatSync)(fd);
29101
+ const st = (0, import_node_fs65.fstatSync)(fd);
28720
29102
  if (!st.isFile()) throw new Error(`Not a file: ${relativePath}`);
28721
29103
  const size = st.size;
28722
29104
  const start = Math.max(0, size - maxBytes);
28723
29105
  const length = size - start;
28724
29106
  const buf = Buffer.alloc(length);
28725
- if (length > 0) (0, import_node_fs63.readSync)(fd, buf, 0, length, start);
29107
+ if (length > 0) (0, import_node_fs65.readSync)(fd, buf, 0, length, start);
28726
29108
  if (buf.subarray(0, Math.min(buf.length, 8e3)).includes(0)) {
28727
29109
  return {
28728
29110
  path: relativePath,
@@ -28740,15 +29122,15 @@ function readWorktreeFileTail(worktreePath, relativePath, maxBytes = WORKTREE_TA
28740
29122
  }
28741
29123
  return { path: relativePath, content, truncated, binary: false, encoding: "utf8" };
28742
29124
  } finally {
28743
- (0, import_node_fs63.closeSync)(fd);
29125
+ (0, import_node_fs65.closeSync)(fd);
28744
29126
  }
28745
29127
  }
28746
- var import_node_fs63, import_node_path63, WORKTREE_TAIL_BYTES;
29128
+ var import_node_fs65, import_node_path65, WORKTREE_TAIL_BYTES;
28747
29129
  var init_read_worktree_tail = __esm({
28748
29130
  "src/diff/read-worktree-tail.ts"() {
28749
29131
  "use strict";
28750
- import_node_fs63 = require("fs");
28751
- import_node_path63 = require("path");
29132
+ import_node_fs65 = require("fs");
29133
+ import_node_path65 = require("path");
28752
29134
  WORKTREE_TAIL_BYTES = 2e5;
28753
29135
  }
28754
29136
  });
@@ -28897,7 +29279,7 @@ function parseFrontmatter(content) {
28897
29279
  }
28898
29280
  function readSkill(skillMd, source) {
28899
29281
  try {
28900
- const content = (0, import_node_fs64.readFileSync)(skillMd, "utf8");
29282
+ const content = (0, import_node_fs66.readFileSync)(skillMd, "utf8");
28901
29283
  const { name: fmName, description } = parseFrontmatter(content);
28902
29284
  const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
28903
29285
  const name = fmName || dirName;
@@ -28916,19 +29298,19 @@ function readSkill(skillMd, source) {
28916
29298
  }
28917
29299
  }
28918
29300
  function scanSkillsDir(dir, source, out) {
28919
- if (!(0, import_node_fs64.existsSync)(dir)) return;
29301
+ if (!(0, import_node_fs66.existsSync)(dir)) return;
28920
29302
  let entries;
28921
29303
  try {
28922
- entries = (0, import_node_fs64.readdirSync)(dir);
29304
+ entries = (0, import_node_fs66.readdirSync)(dir);
28923
29305
  } catch {
28924
29306
  return;
28925
29307
  }
28926
29308
  for (const entry of entries) {
28927
29309
  if (entry.startsWith(".")) continue;
28928
- const skillMd = (0, import_node_path64.join)(dir, entry, "SKILL.md");
28929
- if (!(0, import_node_fs64.existsSync)(skillMd)) continue;
29310
+ const skillMd = (0, import_node_path66.join)(dir, entry, "SKILL.md");
29311
+ if (!(0, import_node_fs66.existsSync)(skillMd)) continue;
28930
29312
  try {
28931
- if (!(0, import_node_fs64.statSync)(skillMd).isFile()) continue;
29313
+ if (!(0, import_node_fs66.statSync)(skillMd).isFile()) continue;
28932
29314
  } catch {
28933
29315
  continue;
28934
29316
  }
@@ -28937,24 +29319,24 @@ function scanSkillsDir(dir, source, out) {
28937
29319
  }
28938
29320
  }
28939
29321
  function scanClaudePluginSkills(pluginsRoot, out) {
28940
- if (!(0, import_node_fs64.existsSync)(pluginsRoot)) return;
29322
+ if (!(0, import_node_fs66.existsSync)(pluginsRoot)) return;
28941
29323
  const walk = (dir, depth, lookingForSkillsDir) => {
28942
29324
  if (depth > 7) return;
28943
29325
  let entries;
28944
29326
  try {
28945
- entries = (0, import_node_fs64.readdirSync)(dir);
29327
+ entries = (0, import_node_fs66.readdirSync)(dir);
28946
29328
  } catch {
28947
29329
  return;
28948
29330
  }
28949
29331
  if (lookingForSkillsDir && entries.includes("SKILL.md")) {
28950
- const skill = readSkill((0, import_node_path64.join)(dir, "SKILL.md"), "cli");
29332
+ const skill = readSkill((0, import_node_path66.join)(dir, "SKILL.md"), "cli");
28951
29333
  if (skill) out.push(skill);
28952
29334
  }
28953
29335
  for (const entry of entries) {
28954
29336
  if (entry === "node_modules" || entry === ".git") continue;
28955
- const full = (0, import_node_path64.join)(dir, entry);
29337
+ const full = (0, import_node_path66.join)(dir, entry);
28956
29338
  try {
28957
- if (!(0, import_node_fs64.statSync)(full).isDirectory()) continue;
29339
+ if (!(0, import_node_fs66.statSync)(full).isDirectory()) continue;
28958
29340
  } catch {
28959
29341
  continue;
28960
29342
  }
@@ -28969,20 +29351,20 @@ function scanClaudePluginSkills(pluginsRoot, out) {
28969
29351
  walk(pluginsRoot, 0, false);
28970
29352
  }
28971
29353
  function discoverSkills(worktreePath) {
28972
- const home = (0, import_node_os20.homedir)();
29354
+ const home = (0, import_node_os22.homedir)();
28973
29355
  const collected = [];
28974
29356
  for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
28975
- scanSkillsDir((0, import_node_path64.join)(worktreePath, rel), "workspace", collected);
29357
+ scanSkillsDir((0, import_node_path66.join)(worktreePath, rel), "workspace", collected);
28976
29358
  }
28977
29359
  for (const abs of [
28978
- (0, import_node_path64.join)(home, ".claude/skills"),
28979
- (0, import_node_path64.join)(home, ".cursor/skills"),
28980
- (0, import_node_path64.join)(home, ".sideboard/skills"),
28981
- (0, import_node_path64.join)(home, ".brightsy/skills")
29360
+ (0, import_node_path66.join)(home, ".claude/skills"),
29361
+ (0, import_node_path66.join)(home, ".cursor/skills"),
29362
+ (0, import_node_path66.join)(home, ".sideboard/skills"),
29363
+ (0, import_node_path66.join)(home, ".brightsy/skills")
28982
29364
  ]) {
28983
29365
  scanSkillsDir(abs, "user", collected);
28984
29366
  }
28985
- scanClaudePluginSkills((0, import_node_path64.join)(home, ".claude/plugins"), collected);
29367
+ scanClaudePluginSkills((0, import_node_path66.join)(home, ".claude/plugins"), collected);
28986
29368
  collected.push(...bundledSkills());
28987
29369
  const rank = {
28988
29370
  workspace: 0,
@@ -29008,7 +29390,7 @@ function readSkillBody(skillPath, maxChars = 12e3) {
29008
29390
  \u2026(truncated)` : body;
29009
29391
  }
29010
29392
  }
29011
- const raw = (0, import_node_fs64.readFileSync)(skillPath, "utf8");
29393
+ const raw = (0, import_node_fs66.readFileSync)(skillPath, "utf8");
29012
29394
  if (raw.startsWith("---")) {
29013
29395
  const end = raw.indexOf("\n---", 3);
29014
29396
  if (end >= 0) {
@@ -29022,13 +29404,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
29022
29404
 
29023
29405
  \u2026(truncated)` : raw;
29024
29406
  }
29025
- var import_node_fs64, import_node_os20, import_node_path64, BUNDLED_SKILL_PREFIX;
29407
+ var import_node_fs66, import_node_os22, import_node_path66, BUNDLED_SKILL_PREFIX;
29026
29408
  var init_discover = __esm({
29027
29409
  "src/skills/discover.ts"() {
29028
29410
  "use strict";
29029
- import_node_fs64 = require("fs");
29030
- import_node_os20 = require("os");
29031
- import_node_path64 = require("path");
29411
+ import_node_fs66 = require("fs");
29412
+ import_node_os22 = require("os");
29413
+ import_node_path66 = require("path");
29032
29414
  init_long_running();
29033
29415
  BUNDLED_SKILL_PREFIX = "bundled:";
29034
29416
  }
@@ -29339,10 +29721,10 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
29339
29721
  throw new Error(`Thread is archived: ${thread.id}`);
29340
29722
  }
29341
29723
  const requested = opts?.followUp;
29342
- const join65 = requested === "join";
29724
+ const join67 = requested === "join";
29343
29725
  const followUp = resolveSendFollowUp(
29344
29726
  current,
29345
- join65 ? "steer" : requested
29727
+ join67 ? "steer" : requested
29346
29728
  );
29347
29729
  const explicit = opts?.attachments;
29348
29730
  const consumed = explicit !== void 0 ? { attachments: current.attachments, consumed: explicit } : consumeComposerAttachments(current);
@@ -29351,7 +29733,7 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
29351
29733
  const draft = host.openSteerPrompt.get(current.id);
29352
29734
  const queuedHead = !inFlightEarly && current.status === "queued" && current.queue.length > 0 ? current.queue[0] : null;
29353
29735
  const joinCanMerge = draft != null && !draft.spawned || !inFlightEarly && queuedHead != null;
29354
- const unanswered = followUp === "steer" && !agentHasRepliedEarly && (!join65 || joinCanMerge) ? draft?.text ?? (inFlightEarly ? trailingUnansweredUserText(current.messages) : queuedHead) : null;
29736
+ const unanswered = followUp === "steer" && !agentHasRepliedEarly && (!join67 || joinCanMerge) ? draft?.text ?? (inFlightEarly ? trailingUnansweredUserText(current.messages) : queuedHead) : null;
29355
29737
  if (unanswered != null && (draft ? !draft.spawned : queuedHead != null)) {
29356
29738
  clearSendBookkeeping(host, thread.id);
29357
29739
  const combined = joinSteerPrompt(unanswered, prompt);
@@ -29403,7 +29785,7 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
29403
29785
  clearSendBookkeeping(host, thread.id);
29404
29786
  const inFlight = host.activeTurns.has(thread.id) || host.startingTurns.has(thread.id) || current.status === "running";
29405
29787
  shouldSteer = sendFollowUpInterrupts(
29406
- join65 ? "join" : followUp,
29788
+ join67 ? "join" : followUp,
29407
29789
  inFlight || current.queue.length > 0
29408
29790
  );
29409
29791
  const patch = queued;
@@ -29474,9 +29856,9 @@ function compiledModuleDir() {
29474
29856
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
29475
29857
  if (cjsDir) return cjsDir;
29476
29858
  try {
29477
- const url = import_meta8.url;
29859
+ const url = import_meta9.url;
29478
29860
  if (typeof url === "string" && url.length > 0) {
29479
- return (0, import_node_path65.dirname)((0, import_node_url6.fileURLToPath)(url));
29861
+ return (0, import_node_path67.dirname)((0, import_node_url7.fileURLToPath)(url));
29480
29862
  }
29481
29863
  } catch {
29482
29864
  }
@@ -29484,8 +29866,8 @@ function compiledModuleDir() {
29484
29866
  }
29485
29867
  function detachedJobScriptIn(dir) {
29486
29868
  for (const name of DETACHED_JOB_FILENAMES) {
29487
- const script = (0, import_node_path65.join)(dir, "scripts", name);
29488
- if ((0, import_node_fs65.existsSync)(script)) return script;
29869
+ const script = (0, import_node_path67.join)(dir, "scripts", name);
29870
+ if ((0, import_node_fs67.existsSync)(script)) return script;
29489
29871
  }
29490
29872
  return null;
29491
29873
  }
@@ -29502,7 +29884,7 @@ function resolveDetachedJobScript() {
29502
29884
  for (let i = 0; i < 8; i++) {
29503
29885
  const candidate = detachedJobScriptIn(dir);
29504
29886
  if (candidate) return candidate;
29505
- const parent = (0, import_node_path65.dirname)(dir);
29887
+ const parent = (0, import_node_path67.dirname)(dir);
29506
29888
  if (parent === dir) break;
29507
29889
  dir = parent;
29508
29890
  }
@@ -29513,15 +29895,15 @@ function formatDetachedJobInvoke(scriptPath) {
29513
29895
  if (resolved) return `node ${JSON.stringify(resolved)}`;
29514
29896
  return "node scripts/detached-job.cjs";
29515
29897
  }
29516
- var import_node_fs65, import_node_path65, import_node_url6, import_meta8, DETACHED_JOB_FILENAMES;
29898
+ var import_node_fs67, import_node_path67, import_node_url7, import_meta9, DETACHED_JOB_FILENAMES;
29517
29899
  var init_detached_job_path = __esm({
29518
29900
  "src/skills/detached-job-path.ts"() {
29519
29901
  "use strict";
29520
- import_node_fs65 = require("fs");
29521
- import_node_path65 = require("path");
29522
- import_node_url6 = require("url");
29902
+ import_node_fs67 = require("fs");
29903
+ import_node_path67 = require("path");
29904
+ import_node_url7 = require("url");
29523
29905
  init_packaged_runtime();
29524
- import_meta8 = {};
29906
+ import_meta9 = {};
29525
29907
  DETACHED_JOB_FILENAMES = ["detached-job.cjs", "detached-job.js"];
29526
29908
  }
29527
29909
  });
@@ -29755,16 +30137,16 @@ function formatPrGateDirective() {
29755
30137
  }
29756
30138
  function formatProcessGuideDirective(opts) {
29757
30139
  const worktree = opts?.worktreePath?.trim();
29758
- const hasGraphSkill = !!worktree && (0, import_node_fs66.existsSync)((0, import_node_path66.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
29759
- const hasReviewSkill = !!worktree && (0, import_node_fs66.existsSync)((0, import_node_path66.join)(worktree, ".claude/skills/review/SKILL.md"));
29760
- const hasInstallSkill = !!worktree && (0, import_node_fs66.existsSync)((0, import_node_path66.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
30140
+ const hasGraphSkill = !!worktree && (0, import_node_fs68.existsSync)((0, import_node_path68.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
30141
+ const hasReviewSkill = !!worktree && (0, import_node_fs68.existsSync)((0, import_node_path68.join)(worktree, ".claude/skills/review/SKILL.md"));
30142
+ const hasInstallSkill = !!worktree && (0, import_node_fs68.existsSync)((0, import_node_path68.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
29761
30143
  return [
29762
30144
  "Process guides (recurring work only):",
29763
30145
  hasGraphSkill ? "- Migrations, ports, batch fixes, and other fan-out: follow `.claude/skills/graph-engineering/SKILL.md` (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch around it." : null,
29764
30146
  hasInstallSkill ? "- After merge-from-main / lockfile change, or a hung `pnpm install`: follow `.claude/skills/worktree-install/SKILL.md` (`/worktree-install`). Use the worktree-local store Sideboard already set; do not share `~/.pnpm-store` across concurrent worktrees." : null,
29765
30147
  "- If this same shape of work will happen again, write `.claude/skills/<kebab-name>/SKILL.md` in this worktree (Claude Code project skill; Sideboard `/name`, Claude Code, and `attach` all load it). Not under `.sideboard/skills/`. Point Codex/OpenCode at it from `AGENTS.md`.",
29766
30148
  hasReviewSkill ? "- Merge-readiness notes go in `.claude/skills/review/SKILL.md` (edit it; do not create another review skill)." : "- Merge-readiness notes go in `.context/review.md` (copied from `.sideboard/review.md` when that file exists). Do not create a review skill.",
29767
- !!worktree && (0, import_node_fs66.existsSync)((0, import_node_path66.join)(worktree, ".claude/skills/skill-improver/SKILL.md")) ? "- Skip a guide for a one-off. If a matching skill exists, follow it. A miss that will recur (you made it twice, or a person told you the rule) \u2192 follow `.claude/skills/skill-improver/SKILL.md` (`/skill-improver`): one sentence in the skill that owns it, in this change. Do not patch around it." : "- Skip a guide for a one-off. If a matching skill exists, follow it. Same miss twice \u2192 edit the skill, do not patch around it."
30149
+ !!worktree && (0, import_node_fs68.existsSync)((0, import_node_path68.join)(worktree, ".claude/skills/skill-improver/SKILL.md")) ? "- Skip a guide for a one-off. If a matching skill exists, follow it. A miss that will recur (you made it twice, or a person told you the rule) \u2192 follow `.claude/skills/skill-improver/SKILL.md` (`/skill-improver`): one sentence in the skill that owns it, in this change. Do not patch around it." : "- Skip a guide for a one-off. If a matching skill exists, follow it. Same miss twice \u2192 edit the skill, do not patch around it."
29768
30150
  ].filter(Boolean).join("\n");
29769
30151
  }
29770
30152
  function formatLongRunningDirective(opts) {
@@ -29797,12 +30179,12 @@ function formatArtifactDirective() {
29797
30179
  function formatUiReminder() {
29798
30180
  return "Sideboard UI: markdown table is enough to read data; present_schema if they ask to edit/filter (even after markdown); present_files for the file manager. html fence or present_artifact, not both for the same document. type=log appends (same artifact_id, new lines only). Chat links: `[name](sideboard://artifact/<id-or-title>)` opens that pane; `[name](sideboard://file/path#L12-L40)` opens a file. ask_user only for a real multiple-choice (not hellos, \u201Cwhat next?\u201D, or after a review) \u2014 reply in chat. ask_user wakes the parent orchestrator; notify_orchestrator if blocked without a picker. Do not say artifacts/CMS UI are unavailable. Dev / preview: run_dev_script (same as the Dev button; pass name \u2014 several scripts can run at once) returns {url, port, preview} (SIDEBOARD_PORT \u2014 never guess :3000). preview=url \u2192 open url; preview=window \u2192 Electron window is the app, url is renderer/HMR only. list_run_scripts active[].url if already running; get_run_log for that script\u2019s Run-tab terminal; stop_dev_script to stop one.";
29799
30181
  }
29800
- var import_node_fs66, import_node_path66, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
30182
+ var import_node_fs68, import_node_path68, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
29801
30183
  var init_instructions = __esm({
29802
30184
  "src/agents/instructions.ts"() {
29803
30185
  "use strict";
29804
- import_node_fs66 = require("fs");
29805
- import_node_path66 = require("path");
30186
+ import_node_fs68 = require("fs");
30187
+ import_node_path68 = require("path");
29806
30188
  init_git_auth_mode();
29807
30189
  init_forge_git_directives();
29808
30190
  init_branch_prefix();
@@ -30472,40 +30854,40 @@ __export(plan_file_exports, {
30472
30854
  writePlanFile: () => writePlanFile
30473
30855
  });
30474
30856
  function ensureAttachmentsGitignore(worktreePath) {
30475
- const gitignoreAbs = (0, import_node_path67.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
30476
- if ((0, import_node_fs67.existsSync)(gitignoreAbs)) return;
30477
- (0, import_node_fs67.mkdirSync)((0, import_node_path67.dirname)(gitignoreAbs), { recursive: true });
30478
- (0, import_node_fs67.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
30857
+ const gitignoreAbs = (0, import_node_path69.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
30858
+ if ((0, import_node_fs69.existsSync)(gitignoreAbs)) return;
30859
+ (0, import_node_fs69.mkdirSync)((0, import_node_path69.dirname)(gitignoreAbs), { recursive: true });
30860
+ (0, import_node_fs69.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
30479
30861
  }
30480
30862
  function planFileAbs(worktreePath) {
30481
- return (0, import_node_path67.join)(worktreePath, PLAN_FILE_REL);
30863
+ return (0, import_node_path69.join)(worktreePath, PLAN_FILE_REL);
30482
30864
  }
30483
30865
  function readTextIfPresent2(abs) {
30484
- if (!(0, import_node_fs67.existsSync)(abs)) return null;
30866
+ if (!(0, import_node_fs69.existsSync)(abs)) return null;
30485
30867
  try {
30486
- const content = (0, import_node_fs67.readFileSync)(abs, "utf8");
30868
+ const content = (0, import_node_fs69.readFileSync)(abs, "utf8");
30487
30869
  return content.trim() ? content : null;
30488
30870
  } catch {
30489
30871
  return null;
30490
30872
  }
30491
30873
  }
30492
30874
  function readPlanFile(worktreePath) {
30493
- return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path67.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path67.join)(worktreePath, LEGACY_PLAN_FILE_REL));
30875
+ return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path69.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path69.join)(worktreePath, LEGACY_PLAN_FILE_REL));
30494
30876
  }
30495
30877
  function writePlanFile(worktreePath, content) {
30496
30878
  ensureAttachmentsGitignore(worktreePath);
30497
30879
  const abs = planFileAbs(worktreePath);
30498
- (0, import_node_fs67.mkdirSync)((0, import_node_path67.dirname)(abs), { recursive: true });
30880
+ (0, import_node_fs69.mkdirSync)((0, import_node_path69.dirname)(abs), { recursive: true });
30499
30881
  const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
30500
- (0, import_node_fs67.writeFileSync)(abs, body, "utf8");
30882
+ (0, import_node_fs69.writeFileSync)(abs, body, "utf8");
30501
30883
  return PLAN_FILE_REL;
30502
30884
  }
30503
- var import_node_fs67, import_node_path67;
30885
+ var import_node_fs69, import_node_path69;
30504
30886
  var init_plan_file = __esm({
30505
30887
  "src/plan/plan-file.ts"() {
30506
30888
  "use strict";
30507
- import_node_fs67 = require("fs");
30508
- import_node_path67 = require("path");
30889
+ import_node_fs69 = require("fs");
30890
+ import_node_path69 = require("path");
30509
30891
  init_workspace_scratch();
30510
30892
  init_plan_present();
30511
30893
  init_plan_present();
@@ -30554,7 +30936,7 @@ function setCaffeinateHoldHooks(next) {
30554
30936
  hooks = next;
30555
30937
  }
30556
30938
  function caffeinateHoldPath() {
30557
- return (0, import_node_path68.join)(appDataDir(), "caffeinate-hold.json");
30939
+ return (0, import_node_path70.join)(appDataDir(), "caffeinate-hold.json");
30558
30940
  }
30559
30941
  function processAlive(pid) {
30560
30942
  if (hooks.processAlive) return hooks.processAlive(pid);
@@ -30588,9 +30970,9 @@ function uniqueIds(ids) {
30588
30970
  }
30589
30971
  function readHold() {
30590
30972
  const path = caffeinateHoldPath();
30591
- if (!(0, import_node_fs68.existsSync)(path)) return null;
30973
+ if (!(0, import_node_fs70.existsSync)(path)) return null;
30592
30974
  try {
30593
- const parsed = JSON.parse((0, import_node_fs68.readFileSync)(path, "utf8"));
30975
+ const parsed = JSON.parse((0, import_node_fs70.readFileSync)(path, "utf8"));
30594
30976
  if (typeof parsed?.pid === "number" && parsed.pid > 0) {
30595
30977
  return {
30596
30978
  pid: parsed.pid,
@@ -30612,7 +30994,7 @@ function writeHold(pid, threadIds) {
30612
30994
  }
30613
30995
  function clearHold() {
30614
30996
  try {
30615
- (0, import_node_fs68.unlinkSync)(caffeinateHoldPath());
30997
+ (0, import_node_fs70.unlinkSync)(caffeinateHoldPath());
30616
30998
  } catch {
30617
30999
  }
30618
31000
  }
@@ -30697,13 +31079,13 @@ function releaseCaffeinateHoldForThread(threadId) {
30697
31079
  }
30698
31080
  return setCaffeinateHold(false, { threadId: id });
30699
31081
  }
30700
- var import_node_child_process7, import_node_fs68, import_node_path68, hooks;
31082
+ var import_node_child_process7, import_node_fs70, import_node_path70, hooks;
30701
31083
  var init_caffeinate_hold = __esm({
30702
31084
  "src/store/caffeinate-hold.ts"() {
30703
31085
  "use strict";
30704
31086
  import_node_child_process7 = require("child_process");
30705
- import_node_fs68 = require("fs");
30706
- import_node_path68 = require("path");
31087
+ import_node_fs70 = require("fs");
31088
+ import_node_path70 = require("path");
30707
31089
  init_paths();
30708
31090
  init_private_file();
30709
31091
  hooks = {};
@@ -30981,13 +31363,13 @@ var init_github_edge = __esm({
30981
31363
 
30982
31364
  // src/orchestrator/github-edge-watch.ts
30983
31365
  function githubEdgeSnapshotPath() {
30984
- return (0, import_node_path69.join)(appDataDir(), "github-edge-watch.json");
31366
+ return (0, import_node_path71.join)(appDataDir(), "github-edge-watch.json");
30985
31367
  }
30986
31368
  function loadGithubEdgeSnapshot() {
30987
31369
  try {
30988
31370
  const path = githubEdgeSnapshotPath();
30989
- if (!(0, import_node_fs69.existsSync)(path)) return emptyGithubEdgeSnapshot();
30990
- return coerceGithubEdgeSnapshot(JSON.parse((0, import_node_fs69.readFileSync)(path, "utf8")));
31371
+ if (!(0, import_node_fs71.existsSync)(path)) return emptyGithubEdgeSnapshot();
31372
+ return coerceGithubEdgeSnapshot(JSON.parse((0, import_node_fs71.readFileSync)(path, "utf8")));
30991
31373
  } catch {
30992
31374
  return emptyGithubEdgeSnapshot();
30993
31375
  }
@@ -31302,12 +31684,12 @@ function realDeps() {
31302
31684
  now: () => Date.now()
31303
31685
  };
31304
31686
  }
31305
- var import_node_fs69, import_node_path69, timer, polling, needsBaseline;
31687
+ var import_node_fs71, import_node_path71, timer, polling, needsBaseline;
31306
31688
  var init_github_edge_watch = __esm({
31307
31689
  "src/orchestrator/github-edge-watch.ts"() {
31308
31690
  "use strict";
31309
- import_node_fs69 = require("fs");
31310
- import_node_path69 = require("path");
31691
+ import_node_fs71 = require("fs");
31692
+ import_node_path71 = require("path");
31311
31693
  init_pr_gates();
31312
31694
  init_pr_merge_archive();
31313
31695
  init_worktree();
@@ -31590,9 +31972,9 @@ function recoverFinishedCursorRun(opts) {
31590
31972
  return best;
31591
31973
  }
31592
31974
  function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
31593
- if (!(0, import_node_fs70.existsSync)(runsPath)) return null;
31975
+ if (!(0, import_node_fs72.existsSync)(runsPath)) return null;
31594
31976
  try {
31595
- const lines = (0, import_node_fs70.readFileSync)(runsPath, "utf8").split("\n");
31977
+ const lines = (0, import_node_fs72.readFileSync)(runsPath, "utf8").split("\n");
31596
31978
  let best = null;
31597
31979
  for (const line of lines) {
31598
31980
  const trimmed = line.trim();
@@ -31618,11 +32000,11 @@ function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
31618
32000
  return null;
31619
32001
  }
31620
32002
  }
31621
- var import_node_fs70;
32003
+ var import_node_fs72;
31622
32004
  var init_cursor_recover = __esm({
31623
32005
  "src/agents/cursor-recover.ts"() {
31624
32006
  "use strict";
31625
- import_node_fs70 = require("fs");
32007
+ import_node_fs72 = require("fs");
31626
32008
  init_cursor_store();
31627
32009
  }
31628
32010
  });
@@ -31726,7 +32108,7 @@ async function startOrchestration(opts) {
31726
32108
  }
31727
32109
  return ready;
31728
32110
  }
31729
- var import_node_events, import_node_crypto21, import_node_fs71, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton2;
32111
+ var import_node_events, import_node_crypto21, import_node_fs73, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton2;
31730
32112
  var init_orchestrator = __esm({
31731
32113
  "src/orchestrator/orchestrator.ts"() {
31732
32114
  "use strict";
@@ -31735,7 +32117,7 @@ var init_orchestrator = __esm({
31735
32117
  init_task_state();
31736
32118
  init_wait_for_turn();
31737
32119
  import_node_crypto21 = require("crypto");
31738
- import_node_fs71 = require("fs");
32120
+ import_node_fs73 = require("fs");
31739
32121
  init_error_detail();
31740
32122
  init_run();
31741
32123
  init_stale_lock();
@@ -31775,7 +32157,7 @@ var init_orchestrator = __esm({
31775
32157
  init_workspace_tags();
31776
32158
  init_implied_first_prompt();
31777
32159
  init_cowboy();
31778
- init_orchestrator_capable();
32160
+ init_thread_agent_patch();
31779
32161
  init_chat_tabs();
31780
32162
  init_enqueue_by_key();
31781
32163
  init_workspace_archive();
@@ -31939,7 +32321,7 @@ var init_orchestrator = __esm({
31939
32321
  this.lightReconcileAt.set(repoPath, Date.now());
31940
32322
  for (const thread of listThreads()) {
31941
32323
  if (isGlobalThread(thread) || thread.repoPath !== repoPath) continue;
31942
- if (!(0, import_node_fs71.existsSync)(thread.worktreePath)) {
32324
+ if (!(0, import_node_fs73.existsSync)(thread.worktreePath)) {
31943
32325
  setStatus(thread.id, "broken", "Worktree missing on disk");
31944
32326
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
31945
32327
  }
@@ -31968,7 +32350,7 @@ var init_orchestrator = __esm({
31968
32350
  }
31969
32351
  continue;
31970
32352
  }
31971
- if (!(0, import_node_fs71.existsSync)(thread.worktreePath)) {
32353
+ if (!(0, import_node_fs73.existsSync)(thread.worktreePath)) {
31972
32354
  setStatus(thread.id, "broken", "Worktree missing on disk");
31973
32355
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
31974
32356
  continue;
@@ -34296,20 +34678,8 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
34296
34678
  if (patch.fast !== void 0) next.fast = patch.fast;
34297
34679
  if (patch.planMode !== void 0) next.planMode = patch.planMode;
34298
34680
  if (patch.model !== void 0) next.model = patch.model;
34299
- if (patch.agent !== void 0) {
34300
- if (patch.agent !== thread.agent) {
34301
- if (thread.messages.length > 0) {
34302
- throw new Error(
34303
- `Cannot switch agent provider mid-chat (${thread.agent} \u2192 ${patch.agent}). Start a new chat tab instead.`
34304
- );
34305
- }
34306
- if (isOrchestratorThread(thread)) {
34307
- assertOrchestratorCapableAgent(patch.agent);
34308
- }
34309
- next.agent = patch.agent;
34310
- if (patch.agent !== "claude" && patch.model === void 0) next.model = null;
34311
- next.sessionId = null;
34312
- }
34681
+ if (patch.agent !== void 0 || patch.acpHarness !== void 0) {
34682
+ applyThreadAgentPatch(thread, patch, next);
34313
34683
  }
34314
34684
  return updateThread(thread.id, next);
34315
34685
  }
@@ -34466,7 +34836,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
34466
34836
  this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
34467
34837
  return restored2;
34468
34838
  }
34469
- if (!(0, import_node_fs71.existsSync)(thread.worktreePath)) {
34839
+ if (!(0, import_node_fs73.existsSync)(thread.worktreePath)) {
34470
34840
  if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
34471
34841
  throw new Error(
34472
34842
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
@@ -34658,7 +35028,7 @@ function createClippedMcpServer() {
34658
35028
  // src/mcp/server.ts
34659
35029
  var import_zod13 = require("zod");
34660
35030
  var import_node_crypto26 = require("crypto");
34661
- var import_node_path74 = require("path");
35031
+ var import_node_path76 = require("path");
34662
35032
  init_orchestrator();
34663
35033
  init_task_state();
34664
35034
  init_worktree();
@@ -35587,6 +35957,7 @@ async function createOrchChildThread(orch, args, resolveNewThreadOptions2) {
35587
35957
  sourceType: args.sourceType,
35588
35958
  sourceRef: args.sourceRef,
35589
35959
  agent: opts.agent,
35960
+ ...opts.agent === "acp" ? { acpHarness: args.acpHarness } : {},
35590
35961
  model: opts.model,
35591
35962
  effort: opts.effort,
35592
35963
  fast: opts.fast,
@@ -35611,6 +35982,7 @@ async function createOrchChildThread(orch, args, resolveNewThreadOptions2) {
35611
35982
  branchName: thread.branchName,
35612
35983
  worktreePath: thread.worktreePath,
35613
35984
  agent: thread.agent,
35985
+ ...thread.acpHarness ? { acpHarness: thread.acpHarness } : {},
35614
35986
  model: thread.model,
35615
35987
  status: thread.status,
35616
35988
  cowboy: Boolean(thread.cowboy),
@@ -37297,8 +37669,8 @@ var import_zod12 = require("zod");
37297
37669
 
37298
37670
  // src/order/order.ts
37299
37671
  var import_node_crypto23 = require("crypto");
37300
- var import_node_fs72 = require("fs");
37301
- var import_node_path70 = require("path");
37672
+ var import_node_fs74 = require("fs");
37673
+ var import_node_path72 = require("path");
37302
37674
  init_paths();
37303
37675
  init_private_file();
37304
37676
  init_thread_store();
@@ -37877,7 +38249,7 @@ function showPlanMessage(docs, worktree) {
37877
38249
 
37878
38250
  // src/order/order.ts
37879
38251
  function orderPath() {
37880
- return (0, import_node_path70.join)(appDataDir(), "order.json");
38252
+ return (0, import_node_path72.join)(appDataDir(), "order.json");
37881
38253
  }
37882
38254
  function emptyFile() {
37883
38255
  return { plans: [], edges: [], marks: [] };
@@ -37940,9 +38312,9 @@ function asMark(value) {
37940
38312
  }
37941
38313
  function readFile() {
37942
38314
  const path = orderPath();
37943
- if (!(0, import_node_fs72.existsSync)(path)) return emptyFile();
38315
+ if (!(0, import_node_fs74.existsSync)(path)) return emptyFile();
37944
38316
  try {
37945
- const parsed = JSON.parse((0, import_node_fs72.readFileSync)(path, "utf8"));
38317
+ const parsed = JSON.parse((0, import_node_fs74.readFileSync)(path, "utf8"));
37946
38318
  if (!parsed || typeof parsed !== "object") return emptyFile();
37947
38319
  const raw = parsed;
37948
38320
  const edges = Array.isArray(raw.edges) ? raw.edges.map(asEdge).filter((row) => Boolean(row)) : [];
@@ -38439,7 +38811,7 @@ function registerOrderTools(server) {
38439
38811
 
38440
38812
  // src/agent-rpc/handlers.ts
38441
38813
  var import_node_crypto24 = require("crypto");
38442
- var import_node_path71 = require("path");
38814
+ var import_node_path73 = require("path");
38443
38815
  init_wait_for_job();
38444
38816
  init_wait_for_turn();
38445
38817
 
@@ -38504,27 +38876,27 @@ init_gh_errors();
38504
38876
  init_git_auth_mode();
38505
38877
 
38506
38878
  // src/board/load-home-board.ts
38507
- var import_node_fs74 = require("fs");
38508
- var import_node_path73 = require("path");
38879
+ var import_node_fs76 = require("fs");
38880
+ var import_node_path75 = require("path");
38509
38881
  init_worktree();
38510
38882
  init_paths();
38511
38883
 
38512
38884
  // src/board/board-pins.ts
38513
38885
  var import_node_crypto25 = require("crypto");
38514
- var import_node_fs73 = require("fs");
38515
- var import_node_path72 = require("path");
38886
+ var import_node_fs75 = require("fs");
38887
+ var import_node_path74 = require("path");
38516
38888
  init_paths();
38517
38889
  init_home_board();
38518
38890
  var FILE = "home-board-pins.json";
38519
38891
  var VERSION = 1;
38520
38892
  function pinsFile() {
38521
- return (0, import_node_path72.join)(appDataDir(), FILE);
38893
+ return (0, import_node_path74.join)(appDataDir(), FILE);
38522
38894
  }
38523
38895
  function readDisk() {
38524
38896
  const path = pinsFile();
38525
- if (!(0, import_node_fs73.existsSync)(path)) return [];
38897
+ if (!(0, import_node_fs75.existsSync)(path)) return [];
38526
38898
  try {
38527
- const raw = JSON.parse((0, import_node_fs73.readFileSync)(path, "utf8"));
38899
+ const raw = JSON.parse((0, import_node_fs75.readFileSync)(path, "utf8"));
38528
38900
  if (raw?.version !== VERSION || !Array.isArray(raw.items)) return [];
38529
38901
  return raw.items.filter((item) => item?.id && item.kind && item.ref);
38530
38902
  } catch {
@@ -38532,8 +38904,8 @@ function readDisk() {
38532
38904
  }
38533
38905
  }
38534
38906
  function writeDisk(items) {
38535
- (0, import_node_fs73.mkdirSync)(appDataDir(), { recursive: true });
38536
- (0, import_node_fs73.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
38907
+ (0, import_node_fs75.mkdirSync)(appDataDir(), { recursive: true });
38908
+ (0, import_node_fs75.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
38537
38909
  }
38538
38910
  function listBoardPins() {
38539
38911
  return readDisk();
@@ -38554,7 +38926,7 @@ function homeBoardWorkspaceKey(workspaces) {
38554
38926
  return workspaces.map((w) => w.path).filter(Boolean).sort().join("\n");
38555
38927
  }
38556
38928
  function cacheFile() {
38557
- return (0, import_node_path73.join)(appDataDir(), "home-board-cache.json");
38929
+ return (0, import_node_path75.join)(appDataDir(), "home-board-cache.json");
38558
38930
  }
38559
38931
  function emptyInputs() {
38560
38932
  return {
@@ -38580,9 +38952,9 @@ function shouldCacheHomeBoardInputs(inputs) {
38580
38952
  }
38581
38953
  function readDiskCache() {
38582
38954
  const path = cacheFile();
38583
- if (!(0, import_node_fs74.existsSync)(path)) return null;
38955
+ if (!(0, import_node_fs76.existsSync)(path)) return null;
38584
38956
  try {
38585
- const raw = JSON.parse((0, import_node_fs74.readFileSync)(path, "utf8"));
38957
+ const raw = JSON.parse((0, import_node_fs76.readFileSync)(path, "utf8"));
38586
38958
  if (raw?.version !== CACHE_VERSION || typeof raw.fetchedAt !== "number") {
38587
38959
  return null;
38588
38960
  }
@@ -38596,8 +38968,8 @@ function readDiskCache() {
38596
38968
  }
38597
38969
  function writeDiskCache(entry) {
38598
38970
  try {
38599
- (0, import_node_fs74.mkdirSync)(appDataDir(), { recursive: true });
38600
- (0, import_node_fs74.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
38971
+ (0, import_node_fs76.mkdirSync)(appDataDir(), { recursive: true });
38972
+ (0, import_node_fs76.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
38601
38973
  } catch {
38602
38974
  }
38603
38975
  }
@@ -38852,7 +39224,7 @@ async function startMcpServer() {
38852
39224
  async () => {
38853
39225
  const threads = orch.getThreads();
38854
39226
  const lines = threads.map((t) => {
38855
- const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path74.basename)(t.repoPath) || t.repoPath;
39227
+ const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path76.basename)(t.repoPath) || t.repoPath;
38856
39228
  const live = orch.threadLooksLive(t) ? readTurnLive(t.id) : null;
38857
39229
  const parent = t.parentThreadId ? ` parent:${t.parentThreadId.slice(0, 8)}` : "";
38858
39230
  const preview = lastMessagePreview(t.messages, 80);
@@ -39401,9 +39773,10 @@ async function startMcpServer() {
39401
39773
  {
39402
39774
  sourceType: import_zod13.z.enum(["branch", "pr", "ticket"]),
39403
39775
  sourceRef: import_zod13.z.string(),
39404
- agent: import_zod13.z.enum(["claude", "codex", "opencode", "brightsy", "cursor"]).optional().describe(
39405
- `Usually omit. Sideboard uses Account default agent (${accountDefaults.agent}). Passing your own agent or cursor is ignored.`
39776
+ agent: import_zod13.z.enum(["claude", "codex", "opencode", "brightsy", "cursor", "acp"]).optional().describe(
39777
+ `Usually omit. Sideboard uses Account default agent (${accountDefaults.agent}). Passing your own agent or cursor is ignored. Pass agent=acp and acpHarness=gemini or copilot for Gemini CLI or Copilot CLI.`
39406
39778
  ),
39779
+ acpHarness: import_zod13.z.enum(["gemini", "copilot"]).optional().describe("When agent is acp: gemini (Gemini CLI) or copilot (GitHub Copilot CLI)."),
39407
39780
  model: import_zod13.z.string().nullable().optional().describe(
39408
39781
  `Usually omit to use Account default model (${accountDefaults.model?.trim() || "Auto"}). Pass null only to force Auto / agent-default.`
39409
39782
  ),
@@ -39723,7 +40096,7 @@ async function startMcpServer() {
39723
40096
  }
39724
40097
  }
39725
40098
  );
39726
- const agentEnum = import_zod13.z.enum(["claude", "codex", "opencode", "brightsy", "cursor"]);
40099
+ const agentEnum = import_zod13.z.enum(["claude", "codex", "opencode", "brightsy", "cursor", "acp"]);
39727
40100
  server.tool(
39728
40101
  "list_models",
39729
40102
  "List models for an agent. Prefer Auto: do not call this unless you have a reason to pin a specific model (user request, cost/latency, capability). Omit agent to list all.",
@@ -39747,10 +40120,11 @@ async function startMcpServer() {
39747
40120
  ref: import_zod13.z.string().describe("Worktree thread id/ref to fork"),
39748
40121
  through_index: import_zod13.z.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
39749
40122
  agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source)"),
40123
+ acpHarness: import_zod13.z.enum(["gemini", "copilot"]).optional().describe("When agent is acp: gemini or copilot."),
39750
40124
  model: import_zod13.z.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
39751
40125
  title: import_zod13.z.string().optional()
39752
40126
  },
39753
- async ({ ref, through_index, agent, model, title }) => {
40127
+ async ({ ref, through_index, agent, model, title, acpHarness }) => {
39754
40128
  try {
39755
40129
  const source = orch.getThread(ref);
39756
40130
  if (source) await orch.reconcile(source.repoPath, { drainQueues: false });
@@ -39758,6 +40132,7 @@ async function startMcpServer() {
39758
40132
  threadId: ref,
39759
40133
  throughIndex: through_index,
39760
40134
  agent,
40135
+ acpHarness,
39761
40136
  model,
39762
40137
  title
39763
40138
  });
@@ -39784,11 +40159,12 @@ async function startMcpServer() {
39784
40159
  {
39785
40160
  ref: import_zod13.z.string().describe("Thread id/ref to fork (worktree agent or orchestration chat)"),
39786
40161
  through_index: import_zod13.z.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
39787
- agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source)"),
40162
+ agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source). agent=acp with acpHarness=gemini or copilot opens Gemini CLI or Copilot CLI. An orchestration fork cannot use acp."),
40163
+ acpHarness: import_zod13.z.enum(["gemini", "copilot"]).optional().describe("When agent is acp: gemini or copilot."),
39788
40164
  model: import_zod13.z.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
39789
40165
  title: import_zod13.z.string().optional()
39790
40166
  },
39791
- async ({ ref, through_index, agent, model, title }) => {
40167
+ async ({ ref, through_index, agent, model, title, acpHarness }) => {
39792
40168
  try {
39793
40169
  const source = orch.getThread(ref);
39794
40170
  if (!source) {
@@ -39801,6 +40177,7 @@ async function startMcpServer() {
39801
40177
  threadId: source.id,
39802
40178
  throughIndex: through_index,
39803
40179
  agent,
40180
+ acpHarness,
39804
40181
  model,
39805
40182
  title
39806
40183
  });
@@ -39853,7 +40230,7 @@ async function startMcpServer() {
39853
40230
  "Best-of-n: create one thread per agent with the same prompt (parallel attempts)",
39854
40231
  {
39855
40232
  prompt: import_zod13.z.string(),
39856
- agents: import_zod13.z.array(import_zod13.z.enum(["claude", "codex", "opencode", "brightsy", "cursor"])),
40233
+ agents: import_zod13.z.array(import_zod13.z.enum(["claude", "codex", "opencode", "brightsy", "cursor", "acp"])),
39857
40234
  repoPath: import_zod13.z.string(),
39858
40235
  sourceType: import_zod13.z.enum(["branch", "pr", "ticket"]).optional(),
39859
40236
  sourceRef: import_zod13.z.string().optional(),
@@ -39998,7 +40375,7 @@ async function startMcpServer() {
39998
40375
  {
39999
40376
  repoPath: import_zod13.z.string(),
40000
40377
  branches: import_zod13.z.array(import_zod13.z.string()).min(1),
40001
- agent: import_zod13.z.enum(["claude", "codex", "opencode", "brightsy", "cursor"]),
40378
+ agent: import_zod13.z.enum(["claude", "codex", "opencode", "brightsy", "cursor", "acp"]),
40002
40379
  base: import_zod13.z.string().optional(),
40003
40380
  title: import_zod13.z.string().optional()
40004
40381
  },