@sideboard-ai/core 0.1.110 → 0.1.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/agents/cursor-runner.cjs +32 -23
  2. package/dist/agents/cursor-runner.js +3 -3
  3. package/dist/{agents-WK54VP7J.js → agents-3X3EFCQY.js} +7 -7
  4. package/dist/{agents-MQDW3YXL.js → agents-AHAFC6FR.js} +10 -10
  5. package/dist/{chunk-4EWPKYOU.js → chunk-4OJMZ6P2.js} +2 -2
  6. package/dist/{chunk-VOJSO3RM.js → chunk-66XTXHR3.js} +277 -49
  7. package/dist/{chunk-KQBI5HNT.js → chunk-7WC5UWEB.js} +2 -2
  8. package/dist/{chunk-WIHKHR5R.js → chunk-AXQ4ZWHK.js} +5 -0
  9. package/dist/{chunk-RSIWPLRG.js → chunk-C6OBY6IC.js} +268 -27
  10. package/dist/{chunk-EAAB4EK5.js → chunk-DCNR7NAL.js} +44 -32
  11. package/dist/{chunk-LGXBYZZA.js → chunk-DVM4ID64.js} +69 -13
  12. package/dist/{chunk-2GO3YKBA.js → chunk-EKIDHL2T.js} +4 -4
  13. package/dist/{chunk-C4KHDW3U.js → chunk-FZCIQYNQ.js} +1 -1
  14. package/dist/{chunk-7KWYXGIU.js → chunk-K3TIQXOH.js} +2 -2
  15. package/dist/{chunk-3KETJKYA.js → chunk-KPIYENTF.js} +69 -13
  16. package/dist/{chunk-XOZDAVOP.js → chunk-MZ6HJ7VL.js} +52 -35
  17. package/dist/{chunk-3UOKB6VQ.js → chunk-SLU5JVKD.js} +282 -228
  18. package/dist/{chunk-VOD3HFLP.js → chunk-XOYQ7LNQ.js} +2 -2
  19. package/dist/{chunk-7YKXHBIW.js → chunk-YMRT2DU6.js} +3 -3
  20. package/dist/{chunk-YXDR43ZC.js → chunk-ZMROW673.js} +5 -5
  21. package/dist/{chunk-YFAXVUY2.js → chunk-ZRCX43LS.js} +2 -2
  22. package/dist/{chunk-AROMOP3C.js → chunk-ZYEFCSZJ.js} +2 -2
  23. package/dist/{connected-teams-M5XNXRI5.js → connected-teams-O6D4PM7A.js} +2 -2
  24. package/dist/{connected-teams-J4I5AKMR.js → connected-teams-ZCOU6KCD.js} +2 -2
  25. package/dist/{coordinator-prompt-AR66L3N4.js → coordinator-prompt-4KCALEKD.js} +3 -3
  26. package/dist/{coordinator-prompt-BHMLWL64.js → coordinator-prompt-FML4I5AR.js} +3 -3
  27. package/dist/{global-workspace-XSUFEIAQ.js → global-workspace-CSWABOG5.js} +4 -4
  28. package/dist/{global-workspace-SKFODUQQ.js → global-workspace-H4YNASM6.js} +4 -4
  29. package/dist/index.cjs +825 -443
  30. package/dist/index.d.cts +53 -1
  31. package/dist/index.d.ts +53 -1
  32. package/dist/index.js +33 -15
  33. package/dist/mcp/run-stdio.cjs +947 -644
  34. package/dist/mcp/run-stdio.js +18 -14
  35. package/dist/{orchestrator-SCATSB3O.js → orchestrator-GKLYKLRC.js} +8 -8
  36. package/dist/{orchestrator-FCZVCKBK.js → orchestrator-TXASYNHT.js} +10 -10
  37. package/dist/{run-XKTAJRWF.js → run-USF6FRKV.js} +3 -1
  38. package/dist/{run-CFKZPY7F.js → run-XQKGHQZ2.js} +3 -1
  39. package/dist/{workspaces-XAQVKTLO.js → workspaces-HJ3EVATC.js} +5 -5
  40. package/dist/{workspaces-HV3J4TTW.js → workspaces-QG6PGFQR.js} +5 -5
  41. package/dist/{worktree-XFJED3VU.js → worktree-IW3BX26B.js} +2 -2
  42. package/dist/{worktree-N2EV24EE.js → worktree-OTFQO2W7.js} +2 -2
  43. package/package.json +1 -1
@@ -6,16 +6,23 @@ import {
6
6
  ensureCliTeamTracked,
7
7
  ensureConnectedBrightsyTeamTokens,
8
8
  loadBrightsyConfig
9
- } from "./chunk-7YKXHBIW.js";
9
+ } from "./chunk-YMRT2DU6.js";
10
10
  import {
11
11
  isOrchestratorThread
12
- } from "./chunk-VOD3HFLP.js";
12
+ } from "./chunk-XOYQ7LNQ.js";
13
13
  import {
14
14
  codexUnattendedGitConfigArgs,
15
15
  mergeAgentGitAuthEnv,
16
16
  resolveAgentGitAuthEnv,
17
17
  resolveCodexGitWritableRoots
18
- } from "./chunk-YXDR43ZC.js";
18
+ } from "./chunk-ZMROW673.js";
19
+ import {
20
+ enrichPathWithNpmGlobalBin,
21
+ isConductorBundledCli,
22
+ resolveCommandBinarySync,
23
+ run,
24
+ withExportedPath
25
+ } from "./chunk-KPIYENTF.js";
19
26
  import {
20
27
  claudeChromeEnabled,
21
28
  isElectronLikeCommand,
@@ -28,13 +35,6 @@ import {
28
35
  import {
29
36
  appDataDir
30
37
  } from "./chunk-BD2ICC4D.js";
31
- import {
32
- enrichPathWithNpmGlobalBin,
33
- isConductorBundledCli,
34
- resolveCommandBinarySync,
35
- run,
36
- withExportedPath
37
- } from "./chunk-3KETJKYA.js";
38
38
 
39
39
  // src/agents/brightsy.ts
40
40
  import { existsSync } from "fs";
@@ -159,7 +159,7 @@ function extractJsonErrorMessage(obj) {
159
159
  var NODE_VERSION_FOOTER = /^Node\.js v\d+/i;
160
160
  function isPinnedStderrLine(line) {
161
161
  if (/^\s*at\s/.test(line)) return false;
162
- return /cannot find (?:package|module)|ERR_MODULE_NOT_FOUND|cursor startup failed:/i.test(
162
+ return /cannot find (?:package|module)|ERR_MODULE_NOT_FOUND|cursor startup failed:|FATAL ERROR|heap out of memory|javascript heap|OOMErrorHandler|FatalProcessOutOfMemory/i.test(
163
163
  line
164
164
  );
165
165
  }
@@ -182,15 +182,22 @@ function looksLikeMinifiedJsDump(line) {
182
182
  function looksLikeNestedElectronCrash(line) {
183
183
  return /HasCustomHostObject|ElectronInitializeICUandStartNode/i.test(line);
184
184
  }
185
- function looksLikeHomebrewLibuvCrash(line) {
186
- const uvRun = /uv_run/i.test(line);
187
- const spin = /SpinEventLoopInternal/i.test(line);
188
- const homebrewUv = /Cellar\/libuv|libuv\.\d\.dylib/i.test(line);
189
- const homebrewNode = /Cellar\/node\//i.test(line);
190
- return uvRun && (homebrewUv || spin || homebrewNode) || spin && (homebrewUv || homebrewNode);
185
+ function looksLikeNativeEventLoopCrash(text) {
186
+ return /uv_run|uv__io_poll|SpinEventLoopInternal/i.test(text);
187
+ }
188
+ function looksLikeV8Oom(text) {
189
+ return /javascript heap|reached heap limit|OOMErrorHandler|FatalProcessOutOfMemory|Allocation failed - JavaScript heap/i.test(
190
+ text
191
+ );
192
+ }
193
+ function looksLikeHomebrewLibuvCrash(text) {
194
+ if (!looksLikeNativeEventLoopCrash(text)) return false;
195
+ return /Cellar\/(?:libuv|node)|libuv\.\d+\.dylib/i.test(text);
191
196
  }
192
197
  var NESTED_ELECTRON_SUMMARY = "Cursor local agent crashed at Electron startup (nested Chromium / HasCustomHostObject)";
193
198
  var HOMEBREW_LIBUV_SUMMARY = "Cursor runner crashed in Node (Homebrew Node + shared libuv). Install Node 22 LTS (`brew install node@22`) and retry.";
199
+ var BUNDLED_NODE_CRASH_SUMMARY = "Cursor runner crashed in Node. Retry the turn.";
200
+ var V8_OOM_SUMMARY = "Agent ran out of memory (JavaScript heap). If it keeps happening, exclude large files from the project folder.";
194
201
  var MINIFIED_DUMP_SUMMARY = "Cursor local agent crashed during startup (truncated crash dump)";
195
202
  function clipStderr(text, maxChars) {
196
203
  const trimmed = text.trim();
@@ -204,7 +211,12 @@ function summarizeTurnStderr(tail, maxChars = 500) {
204
211
  const cursorRunFailed = [...tail].reverse().find((line) => /^cursor run failed\b/i.test(line.trim()));
205
212
  if (cursorRunFailed) return clipStderr(cursorRunFailed, maxChars);
206
213
  if (tail.some(looksLikeNestedElectronCrash)) return NESTED_ELECTRON_SUMMARY;
207
- if (tail.some(looksLikeHomebrewLibuvCrash)) return HOMEBREW_LIBUV_SUMMARY;
214
+ const blob = tail.join("\n");
215
+ if (looksLikeV8Oom(blob)) return V8_OOM_SUMMARY;
216
+ if (looksLikeHomebrewLibuvCrash(blob)) return HOMEBREW_LIBUV_SUMMARY;
217
+ if (looksLikeNativeEventLoopCrash(blob)) {
218
+ return BUNDLED_NODE_CRASH_SUMMARY;
219
+ }
208
220
  if (tail.some(
209
221
  (line) => /\[resource_exhausted\]|resource_exhausted/i.test(line) || /findFilesWithRipgrep/.test(line)
210
222
  )) {
@@ -230,15 +242,17 @@ function looksLikeInvalidAgentSession(text) {
230
242
  function looksLikeRetryableRunnerCrash(text) {
231
243
  if (looksLikeAgentFailureMessage(text)) return false;
232
244
  if (looksLikeInvalidAgentSession(text)) return false;
245
+ if (looksLikeV8Oom(text)) return false;
233
246
  const lower = text.trim().toLowerCase();
234
247
  if (/cannot find (?:package|module)|err_module_not_found/.test(lower)) return false;
235
248
  if (!lower) return true;
236
- return /uv_run|spineventloopinternal|libuv|homebrew node \+ shared libuv|hascustomhostobject|electroninitializeicuandstartnode|nested chromium|truncated crash dump|connection stalled|sig(?:segv|abrt|ill)|segmentation fault|illegal instruction|fatal error/.test(
249
+ return /uv_run|spineventloopinternal|libuv|homebrew node \+ shared libuv|cursor runner crashed in node|hascustomhostobject|electroninitializeicuandstartnode|nested chromium|truncated crash dump|connection stalled|sig(?:segv|abrt|ill)|segmentation fault|illegal instruction|fatal error/.test(
237
250
  lower
238
251
  );
239
252
  }
240
253
  function shouldRetryFailedAgentTurn(detail, opts) {
241
254
  if (looksLikeInvalidAgentSession(detail) && opts.hasSession) return true;
255
+ if (looksLikeV8Oom(detail) && opts.hasSession) return true;
242
256
  return looksLikeRetryableRunnerCrash(detail);
243
257
  }
244
258
  function looksLikeAgentFailureMessage(text) {
@@ -285,9 +299,15 @@ function humanizeAgentFailDetail(detail) {
285
299
  if (/hascustomhostobject|electroninitializeicuandstartnode|nested chromium/i.test(lower)) {
286
300
  return `${raw} \u2014 retry the turn; if it keeps failing, pick another agent.`;
287
301
  }
288
- if (/homebrew node \+ shared libuv|uv_run|spineventloopinternal/i.test(lower)) {
302
+ if (looksLikeV8Oom(raw) || /javascript heap out of memory/i.test(lower)) {
303
+ return /ran out of memory/i.test(raw) ? raw : V8_OOM_SUMMARY;
304
+ }
305
+ if (/homebrew node \+ shared libuv|Cellar\/(?:libuv|node)|libuv\.\d+\.dylib/i.test(raw)) {
289
306
  return /brew install node@22/i.test(raw) ? raw : `${raw} \u2014 install Node 22 LTS (\`brew install node@22\`) and retry.`;
290
307
  }
308
+ if (/uv_run|spineventloopinternal|uv__io_poll|cursor runner crashed in node/i.test(lower)) {
309
+ return /retry the turn/i.test(raw) ? raw : BUNDLED_NODE_CRASH_SUMMARY;
310
+ }
291
311
  if (/corrupt local agent checkpoint|missing root blob|truncated crash dump/.test(lower)) {
292
312
  return `${raw} \u2014 retry the turn (Sideboard will start a fresh Cursor session).`;
293
313
  }
@@ -723,9 +743,9 @@ function toolDescription(name, input) {
723
743
  if (/connectedAgentRequest/i.test(name)) {
724
744
  return str(input?.agent_id) ? `Ask connected agent` : "Ask connected agent";
725
745
  }
726
- if (desc && kind) return `${kind}: ${desc}`;
727
- if (desc) return desc;
728
- return "Subagent";
746
+ if (desc && kind) return `${kind}: ${desc}${subagentLiveSuffix(input)}`;
747
+ if (desc) return `${desc}${subagentLiveSuffix(input)}`;
748
+ return `Subagent${subagentLiveSuffix(input)}`;
729
749
  }
730
750
  if (/^(create|update)_artifact$/i.test(name.replace(/^mcp__[^_]+__/, ""))) {
731
751
  return str(input?.title) ? `Artifact ${str(input?.title)}` : "Artifact";
@@ -750,13 +770,83 @@ function toolDescription(name, input) {
750
770
  }
751
771
  if (/grep/i.test(name)) return "Search files";
752
772
  if (/glob/i.test(name)) return "Find files";
773
+ const compact = n.replace(/[_-]/g, "");
774
+ if (/^taskoutput$/i.test(compact)) {
775
+ return str(input.task_id) ? `Wait for ${str(input.task_id)}` : "Wait for background task";
776
+ }
777
+ if (/^taskstop$/i.test(compact)) {
778
+ return str(input.task_id) ? `Stop ${str(input.task_id)}` : "Stop background task";
779
+ }
780
+ if (/^monitor$/i.test(compact)) {
781
+ const command = str(input.command);
782
+ return command ? `Watch ${command.length > 48 ? `${command.slice(0, 45)}\u2026` : command}` : "Watch command";
783
+ }
753
784
  return n;
754
785
  }
786
+ function subagentLiveSuffix(input) {
787
+ if (!input) return "";
788
+ const bits = [];
789
+ const status = str(input.live_status);
790
+ if (status && !/^runn(ing)?$|^working$/i.test(status)) bits.push(status);
791
+ if (typeof input.live_tool_uses === "number") bits.push(`${input.live_tool_uses} tools`);
792
+ if (typeof input.live_duration_ms === "number") {
793
+ bits.push(`${Math.max(0, Math.round(Number(input.live_duration_ms) / 1e3))}s`);
794
+ }
795
+ const last = str(input.live_last_tool);
796
+ if (last) bits.push(last);
797
+ return bits.length ? ` \xB7 ${bits.join(" \xB7 ")}` : "";
798
+ }
755
799
  function isSubagentToolName(name) {
756
800
  const n = (name ?? "").trim();
757
801
  if (/^(task|agent|spawn_agent)$/i.test(n)) return true;
758
802
  return /connectedAgentRequest/i.test(n);
759
803
  }
804
+ function isPollWrapperToolName(name) {
805
+ const n = (name ?? "").replace(/[_-]/g, "");
806
+ return /^(taskoutput|taskstop|sleep)$/i.test(n);
807
+ }
808
+ function lastTextPart(parts, type) {
809
+ for (let i = parts.length - 1; i >= 0; i--) {
810
+ const p = parts[i];
811
+ if (p.type === type && p.text.trim()) return p.text.trim();
812
+ }
813
+ return "";
814
+ }
815
+ function toolLabel(tool) {
816
+ return tool.description || toolDescription(tool.name, tool.input) || tool.name;
817
+ }
818
+ function liveActivitySummary(parts, opts) {
819
+ if (opts?.queued && parts.length === 0) {
820
+ return "Queued \u2014 waiting for a slot";
821
+ }
822
+ const tools = parts.filter((p) => p.type === "tool");
823
+ const runningSubs = tools.filter(
824
+ (t) => t.status === "running" && !t.parentId && isSubagentToolName(t.name)
825
+ );
826
+ const runningNested = [...tools].reverse().find((t) => t.status === "running" && t.parentId && !isPollWrapperToolName(t.name));
827
+ const runningTop = [...tools].reverse().find(
828
+ (t) => t.status === "running" && !t.parentId && !isPollWrapperToolName(t.name) && !isSubagentToolName(t.name)
829
+ );
830
+ const runningPoll = [...tools].reverse().find((t) => t.status === "running" && isPollWrapperToolName(t.name));
831
+ const thinking = lastTextPart(parts, "thinking");
832
+ const text = lastTextPart(parts, "text");
833
+ if (runningSubs.length > 0) {
834
+ const heads = runningSubs.map(toolLabel);
835
+ const head = runningSubs.length === 1 ? heads[0] : `${runningSubs.length} subagents \xB7 ${heads.slice(0, 2).join(" \xB7 ")}`;
836
+ if (runningNested) return `${head} \xB7 ${toolLabel(runningNested)}`;
837
+ return head;
838
+ }
839
+ if (runningTop) return toolLabel(runningTop);
840
+ if (runningPoll) return toolLabel(runningPoll);
841
+ if (thinking) return thinking.length > 96 ? `\u2026${thinking.slice(-96)}` : thinking;
842
+ if (text) return "Writing reply\u2026";
843
+ const last = [...tools].reverse().find((t) => !isPollWrapperToolName(t.name)) ?? tools.at(-1);
844
+ if (last) {
845
+ const label = toolLabel(last);
846
+ return last.status === "running" ? label : `Finished ${label}`;
847
+ }
848
+ return "Working\u2026";
849
+ }
760
850
  function messagePartParentId(part) {
761
851
  if ("parentId" in part && typeof part.parentId === "string" && part.parentId.trim()) {
762
852
  return part.parentId;
@@ -838,6 +928,25 @@ function applyAgentEvent(parts, event) {
838
928
  const data = event.data;
839
929
  if (!data) return parts;
840
930
  const next = [...parts];
931
+ if (event.replace) {
932
+ for (let i = next.length - 1; i >= 0; i--) {
933
+ const prev = next[i];
934
+ if (prev?.type === "thinking" && sameParentId(prev.parentId, event.parentId)) {
935
+ next[i] = {
936
+ type: "thinking",
937
+ text: data,
938
+ ...event.parentId ? { parentId: event.parentId } : {}
939
+ };
940
+ return next;
941
+ }
942
+ }
943
+ next.push({
944
+ type: "thinking",
945
+ text: data,
946
+ ...event.parentId ? { parentId: event.parentId } : {}
947
+ });
948
+ return next;
949
+ }
841
950
  const last = next[next.length - 1];
842
951
  if (last?.type === "thinking" && sameParentId(last.parentId, event.parentId)) {
843
952
  next[next.length - 1] = {
@@ -861,14 +970,18 @@ function applyAgentEvent(parts, event) {
861
970
  if (existing >= 0) {
862
971
  const prev = parts[existing];
863
972
  const next = [...parts];
864
- const mergedInput = input && Object.keys(input).length > 0 ? input : prev.input ?? input;
973
+ const mergedInput = {
974
+ ...prev.input ?? {},
975
+ ...input ?? {}
976
+ };
977
+ const mergedRecord = Object.keys(mergedInput).length > 0 ? mergedInput : void 0;
865
978
  next[existing] = {
866
979
  ...prev,
867
980
  name: event.name || prev.name,
868
- input: mergedInput,
869
- description: toolDescription(event.name || prev.name, mergedInput),
870
- detail: toolDetail(event.name || prev.name, mergedInput) ?? prev.detail,
871
- filePath: toolFilePath(mergedInput) ?? prev.filePath,
981
+ input: mergedRecord,
982
+ description: toolDescription(event.name || prev.name, mergedRecord),
983
+ detail: toolDetail(event.name || prev.name, mergedRecord) ?? prev.detail,
984
+ filePath: toolFilePath(mergedRecord) ?? prev.filePath,
872
985
  additions: diff.additions ?? prev.additions,
873
986
  deletions: diff.deletions ?? prev.deletions,
874
987
  parentId: event.parentId ?? prev.parentId
@@ -1015,6 +1128,29 @@ function packagedCursorRipgrepCandidate(platformPkg, binName) {
1015
1128
  }
1016
1129
 
1017
1130
  // src/agents/node-launch.ts
1131
+ var AGENT_RUNNER_MAX_OLD_SPACE_MB = 8192;
1132
+ var MAX_OLD_SPACE_FLAG = /(?:^|\s)(--max[-_]old[-_]space[-_]size)(?:[= ](\d+))?(?=\s|$)/;
1133
+ function withMaxOldSpaceSize(nodeOptions, heapMb) {
1134
+ const existing = (nodeOptions ?? "").trim();
1135
+ const match = MAX_OLD_SPACE_FLAG.exec(existing);
1136
+ if (match) {
1137
+ const current = match[2] ? Number(match[2]) : 0;
1138
+ if (Number.isFinite(current) && current >= heapMb) return existing;
1139
+ return existing.replace(MAX_OLD_SPACE_FLAG, ` --max-old-space-size=${heapMb}`).trim();
1140
+ }
1141
+ return existing ? `${existing} --max-old-space-size=${heapMb}` : `--max-old-space-size=${heapMb}`;
1142
+ }
1143
+ function applyAgentRunnerHeapEnv(env) {
1144
+ env.NODE_OPTIONS = withMaxOldSpaceSize(
1145
+ env.NODE_OPTIONS,
1146
+ AGENT_RUNNER_MAX_OLD_SPACE_MB
1147
+ );
1148
+ }
1149
+ function envWithAgentHeap(env) {
1150
+ const next = { ...env };
1151
+ applyAgentRunnerHeapEnv(next);
1152
+ return next;
1153
+ }
1018
1154
  function isAsarPath(filePath) {
1019
1155
  if (/\.asar\.unpacked([/\\]|$)/.test(filePath)) return false;
1020
1156
  return /\.asar([/\\]|$)/.test(filePath);
@@ -1151,13 +1287,21 @@ async function findSystemNode() {
1151
1287
  function applyNodeLaunch(launch, args) {
1152
1288
  const readableArgs = args.map(nodeReadableScriptPath);
1153
1289
  if (!launch.env.ELECTRON_RUN_AS_NODE) {
1154
- return { file: launch.file, args: readableArgs, env: launch.env };
1290
+ return {
1291
+ file: launch.file,
1292
+ args: readableArgs,
1293
+ env: envWithAgentHeap(launch.env)
1294
+ };
1155
1295
  }
1156
1296
  const wrapped = wrapElectronAsNodeLaunch(launch.file, readableArgs);
1157
1297
  if (process.platform === "win32") {
1158
- return { file: wrapped.file, args: wrapped.args, env: launch.env };
1298
+ return {
1299
+ file: wrapped.file,
1300
+ args: wrapped.args,
1301
+ env: envWithAgentHeap(launch.env)
1302
+ };
1159
1303
  }
1160
- const env = { ...launch.env };
1304
+ const env = envWithAgentHeap(launch.env);
1161
1305
  delete env.ELECTRON_RUN_AS_NODE;
1162
1306
  return { file: wrapped.file, args: wrapped.args, env };
1163
1307
  }
@@ -1353,6 +1497,7 @@ async function buildInjectedMcpServers(opts) {
1353
1497
  );
1354
1498
  } catch {
1355
1499
  }
1500
+ applyAgentRunnerHeapEnv(sideboard.env);
1356
1501
  servers.push(sideboard);
1357
1502
  }
1358
1503
  if (opts.includeBrightsy && isBrightsyConnected()) {
@@ -1505,8 +1650,14 @@ var BASE_ALLOWED_TOOLS = [
1505
1650
  "WebSearch",
1506
1651
  // Subagents (Claude Code v2.1.63 renamed Task → Agent; allow both).
1507
1652
  "Task",
1508
- "Agent"
1653
+ "Agent",
1654
+ "TaskOutput",
1655
+ "TaskStop",
1656
+ "EnterWorktree",
1657
+ "ExitWorktree",
1658
+ "Skill"
1509
1659
  ];
1660
+ var CLAUDE_PRINT_BG_WAIT_CEILING_MS = 72e5;
1510
1661
  var CLAUDE_CHROME_ALLOWED_TOOLS = [
1511
1662
  "mcp__claude-in-chrome",
1512
1663
  "mcp__claude-in-chrome__*",
@@ -1610,6 +1761,80 @@ function claudeParentToolUseId(obj) {
1610
1761
  }
1611
1762
  return void 0;
1612
1763
  }
1764
+ function claudeString(obj, key) {
1765
+ const v = obj[key];
1766
+ return typeof v === "string" && v.trim() ? v.trim() : void 0;
1767
+ }
1768
+ function eventsFromClaudeSystem(obj) {
1769
+ const subtype = claudeString(obj, "subtype") ?? "";
1770
+ const parentId = claudeParentToolUseId(obj);
1771
+ if (subtype === "init") {
1772
+ if (parentId) return null;
1773
+ const sid = claudeString(obj, "session_id");
1774
+ return sid ? { type: "session_id", data: sid } : null;
1775
+ }
1776
+ if (subtype === "task_started") {
1777
+ const id = claudeString(obj, "tool_use_id") ?? claudeString(obj, "task_id");
1778
+ if (!id) return null;
1779
+ const description = claudeString(obj, "description");
1780
+ const taskType = claudeString(obj, "task_type");
1781
+ const prompt = claudeString(obj, "prompt");
1782
+ return withEventParentId(
1783
+ {
1784
+ type: "tool_use",
1785
+ id,
1786
+ name: taskType || "Agent",
1787
+ input: {
1788
+ ...description ? { description } : {},
1789
+ ...prompt ? { prompt } : {},
1790
+ ...claudeString(obj, "task_id") ? { task_id: claudeString(obj, "task_id") } : {}
1791
+ }
1792
+ },
1793
+ parentId
1794
+ );
1795
+ }
1796
+ if (subtype === "task_notification") {
1797
+ const id = claudeString(obj, "tool_use_id") ?? claudeString(obj, "task_id") ?? parentId;
1798
+ if (!id) return null;
1799
+ const status = claudeString(obj, "status") ?? "working";
1800
+ const tools = typeof obj.tool_uses === "number" ? obj.tool_uses : void 0;
1801
+ const durationMs = typeof obj.duration_ms === "number" ? obj.duration_ms : void 0;
1802
+ const lastTool = claudeString(obj, "last_tool") ?? claudeString(obj, "current_tool") ?? claudeString(obj, "tool");
1803
+ const snapshot = [
1804
+ status,
1805
+ tools != null ? `${tools} tools` : null,
1806
+ durationMs != null ? `${Math.round(durationMs / 1e3)}s` : null,
1807
+ lastTool
1808
+ ].filter((bit) => Boolean(bit)).join(" \xB7 ");
1809
+ return [
1810
+ {
1811
+ type: "tool_use",
1812
+ id,
1813
+ name: claudeString(obj, "task_type") || "Agent",
1814
+ input: {
1815
+ live_status: status,
1816
+ ...tools != null ? { live_tool_uses: tools } : {},
1817
+ ...durationMs != null ? { live_duration_ms: durationMs } : {},
1818
+ ...lastTool ? { live_last_tool: lastTool } : {}
1819
+ }
1820
+ },
1821
+ withEventParentId(
1822
+ { type: "thinking", data: snapshot, replace: true },
1823
+ id
1824
+ )
1825
+ ];
1826
+ }
1827
+ if (subtype === "api_retry") {
1828
+ const attempt = obj.attempt;
1829
+ const max = obj.max_retries;
1830
+ const delay = obj.retry_delay_ms;
1831
+ return {
1832
+ type: "thinking",
1833
+ data: `API retry ${attempt ?? "?"}/${max ?? "?"}${typeof delay === "number" ? ` (wait ${delay}ms)` : ""}`
1834
+ };
1835
+ }
1836
+ return null;
1837
+ }
1613
1838
  var claudeAdapter = {
1614
1839
  kind: "claude",
1615
1840
  async detect() {
@@ -1664,7 +1889,7 @@ var claudeAdapter = {
1664
1889
  );
1665
1890
  }
1666
1891
  const mode = permissionMode(thread);
1667
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-SKFODUQQ.js");
1892
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-H4YNASM6.js");
1668
1893
  const isOrchestrator = isOrchestratorThread2(thread);
1669
1894
  const injectedServers = await buildInjectedMcpServers({
1670
1895
  includeSideboard: true,
@@ -1732,7 +1957,12 @@ var claudeAdapter = {
1732
1957
  stdin: useStdin ? `${promptText}
1733
1958
  ` : void 0,
1734
1959
  // Nested Task/Agent thinking+text in stream-json (Claude Code 2.1.211+).
1735
- env: { CLAUDE_CODE_FORWARD_SUBAGENT_TEXT: "1" }
1960
+ // Raise the -p background-agent wait so long TaskOutput polls are not
1961
+ // abandoned at Claude Code’s 10-minute default.
1962
+ env: {
1963
+ CLAUDE_CODE_FORWARD_SUBAGENT_TEXT: "1",
1964
+ CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS: process.env.CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS ?? String(CLAUDE_PRINT_BG_WAIT_CEILING_MS)
1965
+ }
1736
1966
  };
1737
1967
  },
1738
1968
  parseEvent(line) {
@@ -1740,13 +1970,8 @@ var claudeAdapter = {
1740
1970
  if (!trimmed) return null;
1741
1971
  try {
1742
1972
  const obj = JSON.parse(trimmed);
1743
- if (obj.type === "system" && obj.subtype === "init") {
1744
- const sid = obj.session_id;
1745
- if (typeof sid === "string") return { type: "session_id", data: sid };
1746
- return null;
1747
- }
1748
- if (obj.type === "system" && typeof obj.session_id === "string") {
1749
- return { type: "session_id", data: obj.session_id };
1973
+ if (obj.type === "system") {
1974
+ return eventsFromClaudeSystem(obj);
1750
1975
  }
1751
1976
  if (obj.type === "assistant" || obj.type === "user") {
1752
1977
  const parentId = claudeParentToolUseId(obj);
@@ -2176,9 +2401,6 @@ var codexAdapter = {
2176
2401
  if (sid && (type === "thread.started" || type === "session" || !type)) {
2177
2402
  return { type: "session_id", data: sid };
2178
2403
  }
2179
- if (sid && type.endsWith(".started")) {
2180
- return { type: "session_id", data: sid };
2181
- }
2182
2404
  if (type === "turn.completed" || type === "turn_completed") {
2183
2405
  const usage = usageFromCodex(obj.usage);
2184
2406
  return usage ? { type: "usage", data: usage, scope: "turn" } : null;
@@ -2244,7 +2466,7 @@ var codexAdapter = {
2244
2466
  import { existsSync as existsSync8 } from "fs";
2245
2467
  import { createRequire as createRequire3 } from "module";
2246
2468
  import { dirname as dirname3, join as join6 } from "path";
2247
- import { fileURLToPath as fileURLToPath3 } from "url";
2469
+ import { fileURLToPath as fileURLToPath2 } from "url";
2248
2470
  import { Cursor } from "@cursor/sdk";
2249
2471
 
2250
2472
  // src/agents/cursor-events.ts
@@ -2420,7 +2642,6 @@ function parseCursorRunnerLine(line) {
2420
2642
  import { existsSync as existsSync7 } from "fs";
2421
2643
  import { createRequire as createRequire2 } from "module";
2422
2644
  import { dirname as dirname2, isAbsolute, join as join5, parse, resolve as resolvePath } from "path";
2423
- import { fileURLToPath as fileURLToPath2 } from "url";
2424
2645
  var RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
2425
2646
  function rgBinaryName() {
2426
2647
  return process.platform === "win32" ? "rg.exe" : "rg";
@@ -2467,7 +2688,9 @@ function resolveCursorRipgrepPath(opts) {
2467
2688
  packagedCursorRipgrepCandidate(platformRipgrepPackage(), rgBinaryName())
2468
2689
  );
2469
2690
  if (fromPackaged) return fromPackaged;
2470
- const start = opts?.startFile?.trim() || process.argv[1] || fileURLToPath2(import.meta.url);
2691
+ const start = opts?.startFile?.trim() || process.argv[1] || // CJS bundle only — ESM has no __filename; argv[1] is the running script.
2692
+ // eslint-disable-next-line camelcase
2693
+ (typeof __filename !== "undefined" ? __filename : "");
2471
2694
  return walkForBundledRipgrep(start) ?? requireResolveBundledRipgrep(start);
2472
2695
  }
2473
2696
  function cursorRipgrepEnv(opts) {
@@ -2521,7 +2744,7 @@ function entryDir() {
2521
2744
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
2522
2745
  if (cjsDir) return cjsDir;
2523
2746
  try {
2524
- return dirname3(fileURLToPath3(import.meta.url));
2747
+ return dirname3(fileURLToPath2(import.meta.url));
2525
2748
  } catch {
2526
2749
  try {
2527
2750
  const req = createRequire3(process.cwd() + "/");
@@ -2812,7 +3035,8 @@ var opencodeAdapter = {
2812
3035
  return { type: "stderr", data: detail };
2813
3036
  }
2814
3037
  const sid = typeof obj.sessionID === "string" && obj.sessionID || typeof obj.sessionId === "string" && obj.sessionId || typeof obj.session_id === "string" && obj.session_id;
2815
- if (sid && (!obj.type || obj.type === "step_start" || obj.type === "session")) {
3038
+ const childSid = str2(obj.childSessionID) ?? str2(obj.childSessionId) ?? str2(obj.parentID) ?? str2(obj.parentId);
3039
+ if (sid && !childSid && (!obj.type || obj.type === "step_start" || obj.type === "session")) {
2816
3040
  return { type: "session_id", data: sid };
2817
3041
  }
2818
3042
  if (obj.type === "text") {
@@ -3409,6 +3633,7 @@ function allAdapters() {
3409
3633
 
3410
3634
  export {
3411
3635
  pushTurnStderr,
3636
+ looksLikeV8Oom,
3412
3637
  summarizeTurnStderr,
3413
3638
  looksLikeInvalidAgentSession,
3414
3639
  shouldRetryFailedAgentTurn,
@@ -3424,6 +3649,8 @@ export {
3424
3649
  listBrightsyChatTargets,
3425
3650
  brightsyAdapter,
3426
3651
  toolDescription,
3652
+ isPollWrapperToolName,
3653
+ liveActivitySummary,
3427
3654
  applyAgentEvent,
3428
3655
  partsToAssistantText,
3429
3656
  stripBrightsyNdjsonNoise,
@@ -3431,6 +3658,7 @@ export {
3431
3658
  finalizeParts,
3432
3659
  normalizeParseResult,
3433
3660
  sideboardMcpProfile,
3661
+ applyAgentRunnerHeapEnv,
3434
3662
  PLAN_MODE_INSTRUCTION,
3435
3663
  permissionMode,
3436
3664
  claudeAdapter,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveGithubRepoSlug
3
- } from "./chunk-C4KHDW3U.js";
3
+ } from "./chunk-FZCIQYNQ.js";
4
4
  import {
5
5
  resolveThreadDefaults
6
6
  } from "./chunk-4NR5FL46.js";
@@ -61,7 +61,7 @@ var COORDINATOR_TOOL_PLAYBOOK = [
61
61
  "- fork_worktree \u2014 fork a worktree chat into a NEW git worktree + chat (transcript attached); optional agent; leave model unset (Auto) unless you have a reason. Not for orchestration chats.",
62
62
  "- fork_chat \u2014 fork a worktree chat (same worktree tab) OR a Global orchestration chat (new orchestration tab); optional agent; leave model unset (Auto) unless you have a reason. Remote coordinators: use this to continue another orchestration chat on a different agent after session limits.",
63
63
  "- send_to_thread \u2014 queue a prompt (start/continue a chat turn); pass force_stop: true to interrupt mid-turn / clear stale queued prompts before replacing with a new request",
64
- "- wait_for_turn / get_turn_result \u2014 wait for and read the agent reply. wait_for_turn returns within ~45s even if the child is still working (MCP clients kill longer tool calls). If stillRunning is true, progress is a live snapshot of tools/thinking \u2014 call wait_for_turn again. Do not send \u201Care you stuck?\u201D or assume a hang while lastActivityAt is recent. On status error, lastError (and text) is the failure \u2014 switch agent, tell the user, or retry; do not treat empty text as success.",
64
+ "- wait_for_turn / get_turn_result \u2014 wait for and read the agent reply. wait_for_turn returns within ~45s even if the child is still working (MCP clients kill longer tool calls). If stillRunning is true, progress is a live snapshot of tools/thinking \u2014 call wait_for_turn again. status=queued with no lastActivityAt means the child has not started yet (concurrency cap) \u2014 keep waiting; do not force_stop or send a check-in. Do not send \u201Care you stuck?\u201D or assume a hang while lastActivityAt is recent. On status error, lastError (and text) is the failure \u2014 switch agent, tell the user, or retry; do not treat empty text as success.",
65
65
  "- stop_thread \u2014 force-stop: kill in-flight turn AND clear queued prompts (do not leave stale queue after an interrupt)",
66
66
  "- archive_thread / restore_thread \u2014 archive (tears down worktree when last tab) or restore",
67
67
  "Setup / run:",
@@ -36,6 +36,11 @@ function createAgentStreamCoalescer(emit, opts) {
36
36
  return;
37
37
  }
38
38
  if (!event.data) return;
39
+ if (event.type === "thinking" && event.replace) {
40
+ flush();
41
+ emit(event);
42
+ return;
43
+ }
39
44
  if (pending && pending.type === event.type && parentKey(pending) === parentKey(event)) {
40
45
  pending.data += event.data;
41
46
  } else {