@sideboard-ai/core 0.1.87 → 0.1.89

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 (33) hide show
  1. package/dist/agents/cursor-runner.cjs +47 -1
  2. package/dist/agents/cursor-runner.js +8 -2
  3. package/dist/{agents-W5446HSV.js → agents-LMUFTGKF.js} +5 -5
  4. package/dist/{agents-V6PVSQYH.js → agents-ODBP7J6E.js} +6 -6
  5. package/dist/{app-settings-HFINR3XG.js → app-settings-BRF7VKTQ.js} +2 -2
  6. package/dist/{app-settings-F36ISTCF.js → app-settings-ZXPAB3QN.js} +1 -1
  7. package/dist/{chunk-HBXQQ5TO.js → chunk-6EZRSCIT.js} +2 -2
  8. package/dist/{chunk-TC2KY5G7.js → chunk-6LFV4VFI.js} +14 -1
  9. package/dist/{chunk-L63LLCTX.js → chunk-7D27DD2X.js} +1 -1
  10. package/dist/{chunk-4PTN2LED.js → chunk-B2KIO2SD.js} +3 -3
  11. package/dist/{chunk-XY6XXMAK.js → chunk-FT2SQOL4.js} +1 -1
  12. package/dist/{chunk-QWNROSRB.js → chunk-JE75QW2I.js} +56 -22
  13. package/dist/chunk-MMI4RJ5I.js +46 -0
  14. package/dist/{chunk-3MA6JH6G.js → chunk-OB6IRIFV.js} +2 -2
  15. package/dist/{chunk-U4GZKLIV.js → chunk-RJLBSYUO.js} +57 -23
  16. package/dist/{chunk-5KLC2MWZ.js → chunk-TLPJHLLM.js} +14 -1
  17. package/dist/{chunk-UVNXLTFB.js → chunk-UHTNJKZX.js} +3 -3
  18. package/dist/{chunk-A7LONVNO.js → chunk-VZ2L4AEJ.js} +2 -2
  19. package/dist/{chunk-R2EOZNQI.js → chunk-WANQFU3S.js} +2 -2
  20. package/dist/{chunk-CY45C3GA.js → chunk-ZXYWWSHZ.js} +1 -1
  21. package/dist/{coordinator-prompt-PYRAXZN3.js → coordinator-prompt-CI5SHONJ.js} +3 -3
  22. package/dist/{coordinator-prompt-EC3KQLN3.js → coordinator-prompt-UK5LYFN5.js} +4 -4
  23. package/dist/{global-workspace-T5IAJF4R.js → global-workspace-2YZ2V4I5.js} +4 -4
  24. package/dist/{global-workspace-ICWOWUW6.js → global-workspace-JQQLPJM5.js} +5 -5
  25. package/dist/index.cjs +118 -24
  26. package/dist/index.js +36 -29
  27. package/dist/mcp/run-stdio.cjs +118 -24
  28. package/dist/mcp/run-stdio.js +74 -27
  29. package/dist/{workspaces-J4ULXOUH.js → workspaces-FDO5L4NI.js} +5 -5
  30. package/dist/{workspaces-AJCAFW64.js → workspaces-YWCC3WV4.js} +6 -6
  31. package/dist/{worktree-4Z2VSHAQ.js → worktree-4555QBQ7.js} +2 -2
  32. package/dist/{worktree-H57CCHWO.js → worktree-7YNSJ224.js} +3 -3
  33. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  resolveGithubRepoSlug
3
- } from "./chunk-L63LLCTX.js";
3
+ } from "./chunk-7D27DD2X.js";
4
4
  import {
5
5
  resolveThreadDefaults
6
- } from "./chunk-XY6XXMAK.js";
6
+ } from "./chunk-FT2SQOL4.js";
7
7
  import {
8
8
  globalAgentCwd,
9
9
  sideboardReposDir
@@ -2,11 +2,11 @@
2
2
 
3
3
  import {
4
4
  isGlobalRepoPath
5
- } from "./chunk-UVNXLTFB.js";
5
+ } from "./chunk-UHTNJKZX.js";
6
6
  import {
7
7
  ensureGhPreferOrigin,
8
8
  resolveRepoRoot
9
- } from "./chunk-CY45C3GA.js";
9
+ } from "./chunk-ZXYWWSHZ.js";
10
10
  import {
11
11
  appDataDir
12
12
  } from "./chunk-JL4SJ6V7.js";
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  getGithubGitAuthMode,
11
11
  getGithubPat
12
- } from "./chunk-TC2KY5G7.js";
12
+ } from "./chunk-6LFV4VFI.js";
13
13
  import {
14
14
  worktreesRoot
15
15
  } from "./chunk-JL4SJ6V7.js";
@@ -9,11 +9,11 @@ import {
9
9
  enrichWorkspacesWithGithub,
10
10
  ensureGlobalCoordinatorCwd,
11
11
  formatWorkspaceInventory
12
- } from "./chunk-3MA6JH6G.js";
13
- import "./chunk-CY45C3GA.js";
12
+ } from "./chunk-OB6IRIFV.js";
13
+ import "./chunk-ZXYWWSHZ.js";
14
14
  import "./chunk-B3SJXYIJ.js";
15
15
  import "./chunk-JOF3XIEM.js";
16
- import "./chunk-TC2KY5G7.js";
16
+ import "./chunk-6LFV4VFI.js";
17
17
  import "./chunk-NSTQ6QKD.js";
18
18
  import "./chunk-KGZBYWZ3.js";
19
19
  import "./chunk-JL4SJ6V7.js";
@@ -7,11 +7,11 @@ import {
7
7
  enrichWorkspacesWithGithub,
8
8
  ensureGlobalCoordinatorCwd,
9
9
  formatWorkspaceInventory
10
- } from "./chunk-A7LONVNO.js";
11
- import "./chunk-L63LLCTX.js";
10
+ } from "./chunk-VZ2L4AEJ.js";
11
+ import "./chunk-7D27DD2X.js";
12
12
  import "./chunk-FKOIHGKV.js";
13
- import "./chunk-XY6XXMAK.js";
14
- import "./chunk-5KLC2MWZ.js";
13
+ import "./chunk-FT2SQOL4.js";
14
+ import "./chunk-TLPJHLLM.js";
15
15
  import "./chunk-JT7R45JB.js";
16
16
  import "./chunk-3WA37BRI.js";
17
17
  import "./chunk-77WWLBCI.js";
@@ -16,12 +16,12 @@ import {
16
16
  orchestratorSessionPoisonedByBuiltins,
17
17
  slackCoordinatorSourceRef,
18
18
  takenTeamSlugsForOrchestration
19
- } from "./chunk-UVNXLTFB.js";
20
- import "./chunk-3MA6JH6G.js";
21
- import "./chunk-CY45C3GA.js";
19
+ } from "./chunk-UHTNJKZX.js";
20
+ import "./chunk-OB6IRIFV.js";
21
+ import "./chunk-ZXYWWSHZ.js";
22
22
  import "./chunk-B3SJXYIJ.js";
23
23
  import "./chunk-JOF3XIEM.js";
24
- import "./chunk-TC2KY5G7.js";
24
+ import "./chunk-6LFV4VFI.js";
25
25
  import "./chunk-NSTQ6QKD.js";
26
26
  import "./chunk-KGZBYWZ3.js";
27
27
  import {
@@ -14,12 +14,12 @@ import {
14
14
  orchestratorSessionPoisonedByBuiltins,
15
15
  slackCoordinatorSourceRef,
16
16
  takenTeamSlugsForOrchestration
17
- } from "./chunk-4PTN2LED.js";
18
- import "./chunk-A7LONVNO.js";
19
- import "./chunk-L63LLCTX.js";
17
+ } from "./chunk-B2KIO2SD.js";
18
+ import "./chunk-VZ2L4AEJ.js";
19
+ import "./chunk-7D27DD2X.js";
20
20
  import "./chunk-FKOIHGKV.js";
21
- import "./chunk-XY6XXMAK.js";
22
- import "./chunk-5KLC2MWZ.js";
21
+ import "./chunk-FT2SQOL4.js";
22
+ import "./chunk-TLPJHLLM.js";
23
23
  import "./chunk-JT7R45JB.js";
24
24
  import "./chunk-3WA37BRI.js";
25
25
  import "./chunk-77WWLBCI.js";
package/dist/index.cjs CHANGED
@@ -547,6 +547,18 @@ function wrapElectronAsNodeLaunch(file, args) {
547
547
  function isStrippedElectronLaunch(command, args) {
548
548
  return command === "/bin/sh" && Boolean(args?.[1]?.includes("ELECTRON_RUN_AS_NODE") && args[1].includes("unset"));
549
549
  }
550
+ function isElectronLikeCommand(command) {
551
+ const name = command.trim();
552
+ if (!name) return false;
553
+ if (process.versions.electron && name === process.execPath) return true;
554
+ return /(?:^|[/\\])Electron(?:\.exe)?$/i.test(name) || /Sideboard\.app[/\\]/i.test(name) || /Electron\.app[/\\]/i.test(name);
555
+ }
556
+ function unwrapStrippedElectronLaunch(command, args) {
557
+ if (!isStrippedElectronLaunch(command, args) || !args || args.length < 4) {
558
+ return null;
559
+ }
560
+ return { file: args[3], args: args.slice(4) };
561
+ }
550
562
  var NESTED_ELECTRON_ENV_PREFIXES, STRIP_NESTED_ELECTRON_THEN_EXEC;
551
563
  var init_nested_electron_env = __esm({
552
564
  "src/hook/nested-electron-env.ts"() {
@@ -6657,22 +6669,52 @@ async function buildInjectedMcpServers(opts) {
6657
6669
  }
6658
6670
  return servers;
6659
6671
  }
6672
+ function shSingleQuote(value) {
6673
+ return `'${value.replace(/'/g, `'\\''`)}'`;
6674
+ }
6675
+ function cursorSafeMcpLaunch(command, args) {
6676
+ if (process.platform === "win32") {
6677
+ return args && args.length > 0 ? { command, args } : { command };
6678
+ }
6679
+ const unwrapped = unwrapStrippedElectronLaunch(command, args);
6680
+ const file = unwrapped?.file ?? command;
6681
+ const fileArgs = unwrapped?.args ?? args ?? [];
6682
+ if (!isElectronLikeCommand(file)) {
6683
+ return fileArgs.length > 0 ? { command: file, args: fileArgs } : { command: file };
6684
+ }
6685
+ const dir = (0, import_node_path16.join)(appDataDir(), "mcp-launch");
6686
+ (0, import_node_fs17.mkdirSync)(dir, { recursive: true });
6687
+ const wrap = (0, import_node_path16.join)(dir, "cursor-electron-as-node.sh");
6688
+ const execLine = [file, ...fileArgs].map(shSingleQuote).join(" ");
6689
+ (0, import_node_fs17.writeFileSync)(
6690
+ wrap,
6691
+ [
6692
+ "#!/bin/sh",
6693
+ "vars=`printenv | awk -F= '/^(ELECTRON_|CHROME_)/{print $1}'`",
6694
+ '[ -n "$vars" ] && unset $vars',
6695
+ "export ELECTRON_RUN_AS_NODE=1",
6696
+ `exec ${execLine} "$@"`,
6697
+ ""
6698
+ ].join("\n"),
6699
+ { mode: 493 }
6700
+ );
6701
+ return { command: wrap };
6702
+ }
6703
+ function mcpSpawnEnv(env) {
6704
+ if (!env) return void 0;
6705
+ const out = { ...env };
6706
+ delete out.ELECTRON_RUN_AS_NODE;
6707
+ return Object.keys(out).length > 0 ? out : void 0;
6708
+ }
6660
6709
  function toCursorMcpServers(servers) {
6661
6710
  const out = {};
6662
6711
  for (const s of servers) {
6663
- const env = s.env ? { ...s.env } : void 0;
6664
- if (env) delete env.ELECTRON_RUN_AS_NODE;
6665
- let command = s.command;
6666
- let args = s.args;
6667
- if (process.platform !== "win32" && !isStrippedElectronLaunch(command, args)) {
6668
- const wrapped = wrapElectronAsNodeLaunch(command, args ?? []);
6669
- command = wrapped.file;
6670
- args = wrapped.args;
6671
- }
6712
+ const env = mcpSpawnEnv(s.env);
6713
+ const launch = cursorSafeMcpLaunch(s.command, s.args);
6672
6714
  out[s.name] = {
6673
- command,
6674
- ...args && args.length > 0 ? { args } : {},
6675
- ...env && Object.keys(env).length > 0 ? { env } : {}
6715
+ command: launch.command,
6716
+ ...launch.args && launch.args.length > 0 ? { args: launch.args } : {},
6717
+ ...env ? { env } : {}
6676
6718
  };
6677
6719
  }
6678
6720
  return out;
@@ -6685,8 +6727,9 @@ function toCodexMcpConfigArgs(servers) {
6685
6727
  if (s.args?.length) {
6686
6728
  args.push("-c", `${prefix}.args=${JSON.stringify(s.args)}`);
6687
6729
  }
6688
- if (s.env) {
6689
- for (const [key, value] of Object.entries(s.env)) {
6730
+ const env = mcpSpawnEnv(s.env);
6731
+ if (env) {
6732
+ for (const [key, value] of Object.entries(env)) {
6690
6733
  args.push("-c", `${prefix}.env.${key}=${JSON.stringify(value)}`);
6691
6734
  }
6692
6735
  }
@@ -6699,11 +6742,12 @@ function toCodexMcpConfigArgs(servers) {
6699
6742
  function toOpencodeMcpConfigContent(servers) {
6700
6743
  const mcp = {};
6701
6744
  for (const s of servers) {
6745
+ const env = mcpSpawnEnv(s.env);
6702
6746
  mcp[s.name] = {
6703
6747
  type: "local",
6704
6748
  command: [s.command, ...s.args ?? []],
6705
6749
  enabled: true,
6706
- ...s.env && Object.keys(s.env).length > 0 ? { environment: s.env } : {}
6750
+ ...env ? { environment: env } : {}
6707
6751
  };
6708
6752
  }
6709
6753
  return JSON.stringify({ mcp });
@@ -6712,10 +6756,11 @@ function writeMcpServersConfig(servers) {
6712
6756
  if (servers.length === 0) return null;
6713
6757
  const mcpServers = {};
6714
6758
  for (const s of servers) {
6759
+ const env = mcpSpawnEnv(s.env);
6715
6760
  mcpServers[s.name] = {
6716
6761
  command: s.command,
6717
6762
  ...s.args ? { args: s.args } : {},
6718
- ...s.env ? { env: s.env } : {}
6763
+ ...env ? { env } : {}
6719
6764
  };
6720
6765
  }
6721
6766
  const dir = (0, import_node_fs17.mkdtempSync)((0, import_node_path16.join)((0, import_node_os6.tmpdir)(), "sideboard-mcp-"));
@@ -10396,6 +10441,51 @@ function normalizeParseResult(parsed) {
10396
10441
  // src/agents/spawn.ts
10397
10442
  init_path();
10398
10443
  init_usage();
10444
+
10445
+ // src/agents/cursor-stream-coalesce.ts
10446
+ function isTextEvent(event) {
10447
+ return event.type === "stdout" || event.type === "thinking";
10448
+ }
10449
+ function createAgentStreamCoalescer(emit, opts) {
10450
+ const intervalMs = opts?.intervalMs ?? 32;
10451
+ let pending = null;
10452
+ let timer = null;
10453
+ const flush = () => {
10454
+ if (timer) {
10455
+ clearTimeout(timer);
10456
+ timer = null;
10457
+ }
10458
+ if (!pending) return;
10459
+ const event = pending;
10460
+ pending = null;
10461
+ emit({ type: event.type, data: event.data });
10462
+ };
10463
+ const schedule = () => {
10464
+ if (timer) return;
10465
+ timer = setTimeout(flush, intervalMs);
10466
+ timer.unref?.();
10467
+ };
10468
+ return {
10469
+ push(event) {
10470
+ if (!isTextEvent(event)) {
10471
+ flush();
10472
+ emit(event);
10473
+ return;
10474
+ }
10475
+ if (!event.data) return;
10476
+ if (pending && pending.type === event.type) {
10477
+ pending.data += event.data;
10478
+ } else {
10479
+ flush();
10480
+ pending = { type: event.type, data: event.data };
10481
+ }
10482
+ schedule();
10483
+ },
10484
+ flush
10485
+ };
10486
+ }
10487
+
10488
+ // src/agents/spawn.ts
10399
10489
  async function spawnAgentTurn(thread, input, onEvent) {
10400
10490
  ensureAgentPath();
10401
10491
  if (!thread.worktreePath?.trim()) {
@@ -10450,12 +10540,13 @@ async function spawnAgentTurn(thread, input, onEvent) {
10450
10540
  let assistantText = "";
10451
10541
  let parts = [];
10452
10542
  let usage = null;
10543
+ const outbound = createAgentStreamCoalescer(onEvent);
10453
10544
  const consume = (stream, kind) => {
10454
10545
  if (!stream) return;
10455
10546
  const rl = (0, import_node_readline2.createInterface)({ input: stream, crlfDelay: Infinity });
10456
10547
  rl.on("line", (line) => {
10457
10548
  if (kind === "stderr") {
10458
- onEvent({ type: "stderr", data: line });
10549
+ outbound.push({ type: "stderr", data: line });
10459
10550
  return;
10460
10551
  }
10461
10552
  let events = normalizeParseResult(adapter.parseEvent(line));
@@ -10470,12 +10561,12 @@ async function spawnAgentTurn(thread, input, onEvent) {
10470
10561
  for (const parsed of events) {
10471
10562
  if (parsed.type === "session_id") {
10472
10563
  sessionId = parsed.data;
10473
- onEvent(parsed);
10564
+ outbound.push(parsed);
10474
10565
  continue;
10475
10566
  }
10476
10567
  if (parsed.type === "usage") {
10477
10568
  usage = applyTurnUsage(usage, parsed.data, parsed.scope ?? "request");
10478
- onEvent(parsed);
10569
+ outbound.push(parsed);
10479
10570
  continue;
10480
10571
  }
10481
10572
  if (parsed.type === "stdout") {
@@ -10488,13 +10579,14 @@ async function spawnAgentTurn(thread, input, onEvent) {
10488
10579
  assistantText += parsed.data;
10489
10580
  }
10490
10581
  parts = applyAgentEvent(parts, parsed);
10491
- onEvent(parsed);
10582
+ outbound.push(parsed);
10492
10583
  }
10493
10584
  });
10494
10585
  };
10495
10586
  consume(child.stdout, "stdout");
10496
10587
  consume(child.stderr, "stderr");
10497
10588
  const done = child.then((result) => {
10589
+ outbound.flush();
10498
10590
  const exitCode = result.exitCode ?? null;
10499
10591
  onEvent({ type: "exit", data: exitCode });
10500
10592
  const finalized = finalizeParts(parts);
@@ -15515,10 +15607,12 @@ var Orchestrator = class {
15515
15607
  if (event.type === "stderr" && typeof event.data === "string") {
15516
15608
  pushTurnStderr(stderrTail, event.data);
15517
15609
  }
15518
- const live = readThread(threadId);
15519
- if (live?.lastError?.includes("reconciled on startup") && (this.activeTurns.has(threadId) || this.startingTurns.has(threadId))) {
15520
- setStatus(threadId, "running");
15521
- this.emit({ type: "status_changed", threadId, status: "running" });
15610
+ if (event.type !== "stdout" && event.type !== "thinking") {
15611
+ const live = readThread(threadId);
15612
+ if (live?.lastError?.includes("reconciled on startup") && (this.activeTurns.has(threadId) || this.startingTurns.has(threadId))) {
15613
+ setStatus(threadId, "running");
15614
+ this.emit({ type: "status_changed", threadId, status: "running" });
15615
+ }
15522
15616
  }
15523
15617
  }
15524
15618
  );
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  listWorkspaces,
5
5
  removeWorkspace,
6
6
  syncWorkspacesFromThreads
7
- } from "./chunk-HBXQQ5TO.js";
7
+ } from "./chunk-6EZRSCIT.js";
8
8
  import {
9
9
  BRIGHTSY_MCP_ALLOWED_TOOLS,
10
10
  CLAUDE_MODEL_CATALOG,
@@ -64,7 +64,7 @@ import {
64
64
  threadRequestsBrightsyMcp,
65
65
  totalTokens,
66
66
  writeInjectedMcpConfig
67
- } from "./chunk-U4GZKLIV.js";
67
+ } from "./chunk-RJLBSYUO.js";
68
68
  import {
69
69
  CLOUD_COORDINATOR_BUSY_REPLY,
70
70
  CLOUD_COORDINATOR_STOPPED_REPLY,
@@ -91,7 +91,7 @@ import {
91
91
  parseForceStopMessage,
92
92
  slackCoordinatorSourceRef,
93
93
  takenTeamSlugsForOrchestration
94
- } from "./chunk-4PTN2LED.js";
94
+ } from "./chunk-B2KIO2SD.js";
95
95
  import {
96
96
  COORDINATOR_TOOL_PLAYBOOK,
97
97
  SLACK_REPLY_FORMATTING,
@@ -100,7 +100,7 @@ import {
100
100
  enrichWorkspacesWithGithub,
101
101
  ensureGlobalCoordinatorCwd,
102
102
  formatWorkspaceInventory
103
- } from "./chunk-A7LONVNO.js";
103
+ } from "./chunk-VZ2L4AEJ.js";
104
104
  import {
105
105
  brightsyConfigPath,
106
106
  brightsyMcpServerName,
@@ -124,6 +124,9 @@ import {
124
124
  resolvePlanMarkdown,
125
125
  writePlanFile
126
126
  } from "./chunk-QTUESPAW.js";
127
+ import {
128
+ createAgentStreamCoalescer
129
+ } from "./chunk-MMI4RJ5I.js";
127
130
  import {
128
131
  cursorSdkMessageToEvents,
129
132
  fallbackTurnFailDetail,
@@ -214,7 +217,7 @@ import {
214
217
  worktreeDisplayLabel,
215
218
  worktreeDisplayLabelForGroup,
216
219
  worktreeNameFromPath
217
- } from "./chunk-L63LLCTX.js";
220
+ } from "./chunk-7D27DD2X.js";
218
221
  import {
219
222
  ATTACHMENTS_DIR,
220
223
  LEGACY_ATTACHMENTS_DIR,
@@ -283,10 +286,10 @@ import {
283
286
  updateIntegrationsSettings,
284
287
  updateOpencodeSettings,
285
288
  writeSecureJson
286
- } from "./chunk-XY6XXMAK.js";
289
+ } from "./chunk-FT2SQOL4.js";
287
290
  import {
288
291
  stripNestedElectronEnv
289
- } from "./chunk-5KLC2MWZ.js";
292
+ } from "./chunk-TLPJHLLM.js";
290
293
  import {
291
294
  writePrivateFile
292
295
  } from "./chunk-JT7R45JB.js";
@@ -1325,9 +1328,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
1325
1328
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
1326
1329
  );
1327
1330
  }
1328
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-ICWOWUW6.js");
1331
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-JQQLPJM5.js");
1329
1332
  if (isGlobalThread2(thread)) {
1330
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-EC3KQLN3.js");
1333
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-UK5LYFN5.js");
1331
1334
  ensureGlobalCoordinatorCwd2(
1332
1335
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
1333
1336
  );
@@ -1372,12 +1375,13 @@ async function spawnAgentTurn(thread, input, onEvent) {
1372
1375
  let assistantText = "";
1373
1376
  let parts = [];
1374
1377
  let usage = null;
1378
+ const outbound = createAgentStreamCoalescer(onEvent);
1375
1379
  const consume = (stream, kind) => {
1376
1380
  if (!stream) return;
1377
1381
  const rl = createInterface({ input: stream, crlfDelay: Infinity });
1378
1382
  rl.on("line", (line) => {
1379
1383
  if (kind === "stderr") {
1380
- onEvent({ type: "stderr", data: line });
1384
+ outbound.push({ type: "stderr", data: line });
1381
1385
  return;
1382
1386
  }
1383
1387
  let events = normalizeParseResult(adapter.parseEvent(line));
@@ -1392,12 +1396,12 @@ async function spawnAgentTurn(thread, input, onEvent) {
1392
1396
  for (const parsed of events) {
1393
1397
  if (parsed.type === "session_id") {
1394
1398
  sessionId = parsed.data;
1395
- onEvent(parsed);
1399
+ outbound.push(parsed);
1396
1400
  continue;
1397
1401
  }
1398
1402
  if (parsed.type === "usage") {
1399
1403
  usage = applyTurnUsage(usage, parsed.data, parsed.scope ?? "request");
1400
- onEvent(parsed);
1404
+ outbound.push(parsed);
1401
1405
  continue;
1402
1406
  }
1403
1407
  if (parsed.type === "stdout") {
@@ -1410,13 +1414,14 @@ async function spawnAgentTurn(thread, input, onEvent) {
1410
1414
  assistantText += parsed.data;
1411
1415
  }
1412
1416
  parts = applyAgentEvent(parts, parsed);
1413
- onEvent(parsed);
1417
+ outbound.push(parsed);
1414
1418
  }
1415
1419
  });
1416
1420
  };
1417
1421
  consume(child.stdout, "stdout");
1418
1422
  consume(child.stderr, "stderr");
1419
1423
  const done = child.then((result) => {
1424
+ outbound.flush();
1420
1425
  const exitCode = result.exitCode ?? null;
1421
1426
  onEvent({ type: "exit", data: exitCode });
1422
1427
  const finalized = finalizeParts(parts);
@@ -3806,7 +3811,7 @@ async function createThread(input, _onSetupLine) {
3806
3811
  return readThread(thread.id) ?? thread;
3807
3812
  }
3808
3813
  async function listLinearIssues(agent, repoPath) {
3809
- const { getAdapter: getAdapter2 } = await import("./agents-V6PVSQYH.js");
3814
+ const { getAdapter: getAdapter2 } = await import("./agents-ODBP7J6E.js");
3810
3815
  await requireAgent(agent, { requireLinear: true });
3811
3816
  const adapter = getAdapter2(agent);
3812
3817
  if (!adapter.listLinearIssues) {
@@ -4349,7 +4354,7 @@ async function adoptThread(input) {
4349
4354
  messages: input.messages ?? []
4350
4355
  });
4351
4356
  writeThread(thread);
4352
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-AJCAFW64.js");
4357
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-YWCC3WV4.js");
4353
4358
  await ensureWorkspace2(repoPath);
4354
4359
  return thread;
4355
4360
  }
@@ -5870,7 +5875,7 @@ var Orchestrator = class {
5870
5875
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
5871
5876
  });
5872
5877
  }
5873
- const { autoCleanupOrphansEnabled: autoCleanupOrphansEnabled2 } = await import("./app-settings-HFINR3XG.js");
5878
+ const { autoCleanupOrphansEnabled: autoCleanupOrphansEnabled2 } = await import("./app-settings-BRF7VKTQ.js");
5874
5879
  if (autoCleanupOrphansEnabled2() && shouldRunWorktreeCleanup() && orphans.length > 0) {
5875
5880
  await cleanupOrphanWorktrees({ repoPaths });
5876
5881
  }
@@ -6038,7 +6043,7 @@ var Orchestrator = class {
6038
6043
  }
6039
6044
  }
6040
6045
  await setup;
6041
- const { autoRunAfterSetupEnabled: autoRunAfterSetupEnabled2 } = await import("./app-settings-HFINR3XG.js");
6046
+ const { autoRunAfterSetupEnabled: autoRunAfterSetupEnabled2 } = await import("./app-settings-BRF7VKTQ.js");
6042
6047
  if (autoRunAfterSetupEnabled2()) {
6043
6048
  try {
6044
6049
  await this.startDev(threadId);
@@ -6299,7 +6304,7 @@ var Orchestrator = class {
6299
6304
  }
6300
6305
  const isBrightsy = fresh.agent === "brightsy";
6301
6306
  const isOrchestration = isOrchestratorThread(fresh);
6302
- const { autoRenameBranchEnabled: autoRenameBranchEnabled2, getGithubGitAuthMode: getGithubGitAuthMode2 } = await import("./app-settings-HFINR3XG.js");
6307
+ const { autoRenameBranchEnabled: autoRenameBranchEnabled2, getGithubGitAuthMode: getGithubGitAuthMode2 } = await import("./app-settings-BRF7VKTQ.js");
6303
6308
  const gitAuthMode = getGithubGitAuthMode2();
6304
6309
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
6305
6310
  githubSlug: await resolveGithubRepoSlug(fresh.worktreePath).catch(
@@ -6354,10 +6359,12 @@ var Orchestrator = class {
6354
6359
  if (event.type === "stderr" && typeof event.data === "string") {
6355
6360
  pushTurnStderr(stderrTail, event.data);
6356
6361
  }
6357
- const live = readThread(threadId);
6358
- if (live?.lastError?.includes("reconciled on startup") && (this.activeTurns.has(threadId) || this.startingTurns.has(threadId))) {
6359
- setStatus(threadId, "running");
6360
- this.emit({ type: "status_changed", threadId, status: "running" });
6362
+ if (event.type !== "stdout" && event.type !== "thinking") {
6363
+ const live = readThread(threadId);
6364
+ if (live?.lastError?.includes("reconciled on startup") && (this.activeTurns.has(threadId) || this.startingTurns.has(threadId))) {
6365
+ setStatus(threadId, "running");
6366
+ this.emit({ type: "status_changed", threadId, status: "running" });
6367
+ }
6361
6368
  }
6362
6369
  }
6363
6370
  );
@@ -7007,7 +7014,7 @@ var Orchestrator = class {
7007
7014
  updateThread(thread.id, { title: meta.title });
7008
7015
  }
7009
7016
  }
7010
- const { autoArchiveOnMergeEnabled: autoArchiveOnMergeEnabled2 } = await import("./app-settings-HFINR3XG.js");
7017
+ const { autoArchiveOnMergeEnabled: autoArchiveOnMergeEnabled2 } = await import("./app-settings-BRF7VKTQ.js");
7011
7018
  const latest = this.requireThread(thread.id);
7012
7019
  if (!shouldAutoArchiveOnPrMerge({
7013
7020
  previousPrState: prevState || null,
@@ -7295,7 +7302,7 @@ var Orchestrator = class {
7295
7302
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
7296
7303
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
7297
7304
  try {
7298
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-AJCAFW64.js");
7305
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-YWCC3WV4.js");
7299
7306
  await ensureWorkspace2(thread.repoPath);
7300
7307
  } catch {
7301
7308
  }
@@ -7317,7 +7324,7 @@ var Orchestrator = class {
7317
7324
  await runArchiveScript(thread.repoPath, thread.worktreePath);
7318
7325
  } catch {
7319
7326
  }
7320
- const { deleteBranchOnPurgeEnabled: deleteBranchOnPurgeEnabled2 } = await import("./app-settings-HFINR3XG.js");
7327
+ const { deleteBranchOnPurgeEnabled: deleteBranchOnPurgeEnabled2 } = await import("./app-settings-BRF7VKTQ.js");
7321
7328
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled2();
7322
7329
  await removeWorktree(thread.repoPath, thread.worktreePath, {
7323
7330
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -7338,7 +7345,7 @@ var Orchestrator = class {
7338
7345
  return restored2;
7339
7346
  }
7340
7347
  if (!existsSync14(thread.worktreePath)) {
7341
- const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-H57CCHWO.js");
7348
+ const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-7YNSJ224.js");
7342
7349
  const { execa: execa5 } = await import("execa");
7343
7350
  const slug = thread.worktreePath.split("/").pop();
7344
7351
  const dest = thread.worktreePath;
@@ -7447,7 +7454,7 @@ async function startOrchestration(opts) {
7447
7454
  sourceRef: "default",
7448
7455
  ...createOpts
7449
7456
  }).catch(async () => {
7450
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-H57CCHWO.js");
7457
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-7YNSJ224.js");
7451
7458
  const repo = await resolveRepoRoot2(repoPath);
7452
7459
  const def = await resolveDefaultBranch2(repo);
7453
7460
  return orch.createThread({
@@ -8199,7 +8206,7 @@ function withTimeout(promise, ms, label) {
8199
8206
  async function startMcpServer() {
8200
8207
  const orch = getOrchestrator();
8201
8208
  try {
8202
- const { maxConcurrentAgents: maxConcurrentAgents2 } = await import("./app-settings-HFINR3XG.js");
8209
+ const { maxConcurrentAgents: maxConcurrentAgents2 } = await import("./app-settings-BRF7VKTQ.js");
8203
8210
  orch.setMaxConcurrent(maxConcurrentAgents2());
8204
8211
  } catch {
8205
8212
  }
@@ -8409,7 +8416,7 @@ async function startMcpServer() {
8409
8416
  registerLinearTools(server);
8410
8417
  if (sideboardMcpProfile() !== "worktree") {
8411
8418
  const { getCaffeinateHold: getCaffeinateHold2, setCaffeinateHold: setCaffeinateHold2 } = await import("./caffeinate-hold-I7SG6UQR.js");
8412
- const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await import("./app-settings-HFINR3XG.js");
8419
+ const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await import("./app-settings-BRF7VKTQ.js");
8413
8420
  const accountDefaults = resolveThreadDefaults2();
8414
8421
  const accountDefaultsHint = `Account defaults: agent=${accountDefaults.agent}, model=${accountDefaults.model?.trim() || "Auto"}, effort=${accountDefaults.effort}`;
8415
8422
  server.tool(