@sideboard-ai/core 0.1.258 → 0.1.261

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 (66) hide show
  1. package/dist/{abletime-IDQJI2KW.js → abletime-CDGINDXG.js} +6 -5
  2. package/dist/{abletime-OGQR4LIL.js → abletime-OQ4PC52L.js} +7 -6
  3. package/dist/{abletime-oauth-ZQUIY4EM.js → abletime-oauth-5A5EOH2A.js} +5 -4
  4. package/dist/{abletime-oauth-MBAG5MYU.js → abletime-oauth-KX2TDFTE.js} +6 -5
  5. package/dist/{abletime-rest-WEJERY4O.js → abletime-rest-PUGKYTRR.js} +6 -5
  6. package/dist/{abletime-rest-JZIIT5W3.js → abletime-rest-UEHOBLXD.js} +5 -4
  7. package/dist/agents/cursor-runner.cjs +274 -12
  8. package/dist/agents/cursor-runner.js +156 -13
  9. package/dist/{agents-HZP7YEKC.js → agents-IKVUGW5H.js} +12 -9
  10. package/dist/{agents-FSUI5MET.js → agents-J2P4KNEY.js} +21 -18
  11. package/dist/{app-settings-CLARFJUX.js → app-settings-OM7H64YM.js} +12 -3
  12. package/dist/{app-settings-ONYJ36XH.js → app-settings-VQEUCONM.js} +11 -2
  13. package/dist/chunk-3HO2OY5T.js +159 -0
  14. package/dist/{chunk-F7ANS66U.js → chunk-4F7J6UWD.js} +75 -33
  15. package/dist/{chunk-WDDUIGFK.js → chunk-4GK32AYX.js} +1 -1
  16. package/dist/{chunk-ZC3TVLY6.js → chunk-5OKJDCBK.js} +5 -5
  17. package/dist/{chunk-KJM3E3NF.js → chunk-6PFZ6XO7.js} +65 -6
  18. package/dist/{title-4A2ATYNY.js → chunk-7H655NEW.js} +1 -0
  19. package/dist/{chunk-R4DWUBOL.js → chunk-ABPNIYRS.js} +78 -37
  20. package/dist/{chunk-XIEDFRBP.js → chunk-B6XFBNYM.js} +2 -2
  21. package/dist/chunk-CEMNIGQH.js +161 -0
  22. package/dist/{chunk-66LAOKLK.js → chunk-D554YCHG.js} +2 -2
  23. package/dist/{chunk-HCNCZPDL.js → chunk-FSZ7YYFQ.js} +119 -63
  24. package/dist/{chunk-4723RAO3.js → chunk-FWNL62VA.js} +3 -1
  25. package/dist/{chunk-Y7CS2WGJ.js → chunk-GIZQAOHZ.js} +247 -109
  26. package/dist/chunk-HHEKVR6C.js +72 -0
  27. package/dist/{chunk-IFHHPPSL.js → chunk-J6ONZP74.js} +5 -5
  28. package/dist/{chunk-PJK24CN3.js → chunk-JTNY5CK4.js} +10 -10
  29. package/dist/{chunk-CPEIHTG7.js → chunk-KVQX62XI.js} +3 -3
  30. package/dist/{chunk-5F4YFGHL.js → chunk-LDXSAVWO.js} +7 -7
  31. package/dist/{title-4WAKWZRF.js → chunk-LX5R5JOR.js} +1 -0
  32. package/dist/{chunk-D6JWYJ4P.js → chunk-N2WW62LF.js} +1 -0
  33. package/dist/{chunk-RTQOCFIV.js → chunk-S7VDDJ34.js} +3 -3
  34. package/dist/{chunk-RJC2MKXN.js → chunk-TJ673EZT.js} +3 -1
  35. package/dist/{chunk-63YSFXLT.js → chunk-U3AOJLH3.js} +126 -70
  36. package/dist/{chunk-452Y24PW.js → chunk-VIC6TDYT.js} +68 -9
  37. package/dist/{chunk-553IEH7O.js → chunk-W5PWGEKS.js} +241 -104
  38. package/dist/{chunk-VVHHBOIA.js → chunk-WV7KJH2E.js} +5 -3
  39. package/dist/{chunk-BYRZS2S2.js → chunk-X2OTZ36G.js} +4 -4
  40. package/dist/{chunk-FGWUZOZN.js → chunk-YFTO7U2A.js} +3 -3
  41. package/dist/connected-teams-7CENZDWU.js +1 -1
  42. package/dist/{connected-teams-Z5GOIC5I.js → connected-teams-RU6VATCM.js} +2 -2
  43. package/dist/{coordinator-prompt-HZUWK3NP.js → coordinator-prompt-TU6656OK.js} +9 -8
  44. package/dist/{coordinator-prompt-Y6S6USNS.js → coordinator-prompt-VQHQ3RIX.js} +8 -7
  45. package/dist/{global-workspace-4JCITHB6.js → global-workspace-47NZVA44.js} +8 -7
  46. package/dist/{global-workspace-YA7U4M2N.js → global-workspace-PHF2MOGW.js} +9 -8
  47. package/dist/index.cjs +1443 -856
  48. package/dist/index.d.cts +118 -37
  49. package/dist/index.d.ts +118 -37
  50. package/dist/index.js +148 -64
  51. package/dist/managed-accounts-2AK5RIAF.js +39 -0
  52. package/dist/managed-accounts-4BLTJKAN.js +41 -0
  53. package/dist/mcp/run-stdio.cjs +2722 -2248
  54. package/dist/mcp/run-stdio.js +136 -50
  55. package/dist/{orchestrator-LWADJQTN.js → orchestrator-OCG4QVA5.js} +13 -11
  56. package/dist/{orchestrator-VHJZEVGA.js → orchestrator-VLTO5JBR.js} +13 -11
  57. package/dist/{plan-file-CKXUFTQ2.js → plan-file-VAHV5WBB.js} +2 -2
  58. package/dist/{thread-store-HDQ4CH54.js → thread-store-FJ5CDX2M.js} +1 -1
  59. package/dist/{thread-store-ZDR3Z5UG.js → thread-store-SHCUBWB3.js} +1 -1
  60. package/dist/title-ERD6D3C3.js +8 -0
  61. package/dist/title-Z7WAJN57.js +6 -0
  62. package/dist/{workspaces-IXZD7EC4.js → workspaces-2XTDS7N2.js} +9 -8
  63. package/dist/{workspaces-4KHEUPEX.js → workspaces-I7TWFTJM.js} +8 -7
  64. package/dist/{worktree-DAAF64UU.js → worktree-DDDF3WHV.js} +8 -7
  65. package/dist/{worktree-S3FOMEQ2.js → worktree-YASFE65H.js} +7 -6
  66. package/package.json +1 -1
@@ -15,16 +15,17 @@ import {
15
15
  toAbleTimeIssueInfo,
16
16
  updateAbleTimeTask,
17
17
  verifyAbleTimeConnection
18
- } from "./chunk-CPEIHTG7.js";
19
- import "./chunk-66LAOKLK.js";
20
- import "./chunk-IFHHPPSL.js";
18
+ } from "./chunk-KVQX62XI.js";
19
+ import "./chunk-D554YCHG.js";
20
+ import "./chunk-J6ONZP74.js";
21
21
  import "./chunk-N7WZ6NIN.js";
22
- import "./chunk-KJM3E3NF.js";
22
+ import "./chunk-6PFZ6XO7.js";
23
+ import "./chunk-4TR3HZFT.js";
23
24
  import "./chunk-WDRMZKVB.js";
25
+ import "./chunk-3HO2OY5T.js";
24
26
  import "./chunk-JT7R45JB.js";
25
27
  import "./chunk-77WWLBCI.js";
26
28
  import "./chunk-EHT2DRT4.js";
27
- import "./chunk-4TR3HZFT.js";
28
29
  export {
29
30
  ableTimeDependencyTarget,
30
31
  commentAbleTimeTask,
@@ -17,16 +17,17 @@ import {
17
17
  toAbleTimeIssueInfo,
18
18
  updateAbleTimeTask,
19
19
  verifyAbleTimeConnection
20
- } from "./chunk-RTQOCFIV.js";
21
- import "./chunk-XIEDFRBP.js";
22
- import "./chunk-ZC3TVLY6.js";
20
+ } from "./chunk-S7VDDJ34.js";
21
+ import "./chunk-B6XFBNYM.js";
22
+ import "./chunk-5OKJDCBK.js";
23
23
  import "./chunk-VKQGAWHY.js";
24
- import "./chunk-452Y24PW.js";
24
+ import "./chunk-VIC6TDYT.js";
25
25
  import "./chunk-NSTQ6QKD.js";
26
- import "./chunk-KGZBYWZ3.js";
27
- import "./chunk-Z2LGMV6C.js";
28
26
  import "./chunk-WWUABK6B.js";
29
27
  import "./chunk-FJZWM2ON.js";
28
+ import "./chunk-CEMNIGQH.js";
29
+ import "./chunk-KGZBYWZ3.js";
30
+ import "./chunk-Z2LGMV6C.js";
30
31
  export {
31
32
  ableTimeDependencyTarget,
32
33
  commentAbleTimeTask,
@@ -20,15 +20,16 @@ import {
20
20
  parseAbleTimeOAuthCallbackUrl,
21
21
  resolveAbleTimeOAuthHost,
22
22
  startAbleTimeOAuth
23
- } from "./chunk-FGWUZOZN.js";
24
- import "./chunk-IFHHPPSL.js";
23
+ } from "./chunk-YFTO7U2A.js";
24
+ import "./chunk-J6ONZP74.js";
25
25
  import "./chunk-N7WZ6NIN.js";
26
- import "./chunk-KJM3E3NF.js";
26
+ import "./chunk-6PFZ6XO7.js";
27
+ import "./chunk-4TR3HZFT.js";
27
28
  import "./chunk-WDRMZKVB.js";
29
+ import "./chunk-3HO2OY5T.js";
28
30
  import "./chunk-JT7R45JB.js";
29
31
  import "./chunk-77WWLBCI.js";
30
32
  import "./chunk-EHT2DRT4.js";
31
- import "./chunk-4TR3HZFT.js";
32
33
  export {
33
34
  ABLETIME_OAUTH_CALLBACK_PATH,
34
35
  ABLETIME_OAUTH_CANCELLED,
@@ -3,7 +3,7 @@
3
3
  import {
4
4
  DEFAULT_ABLETIME_HOST,
5
5
  normalizeAbleTimeHost
6
- } from "./chunk-ZC3TVLY6.js";
6
+ } from "./chunk-5OKJDCBK.js";
7
7
  import {
8
8
  httpFetch
9
9
  } from "./chunk-VKQGAWHY.js";
@@ -12,12 +12,13 @@ import {
12
12
  getAbleTimeHost,
13
13
  loadAppSettings,
14
14
  saveAbleTimeConnection
15
- } from "./chunk-452Y24PW.js";
15
+ } from "./chunk-VIC6TDYT.js";
16
16
  import "./chunk-NSTQ6QKD.js";
17
- import "./chunk-KGZBYWZ3.js";
18
- import "./chunk-Z2LGMV6C.js";
19
17
  import "./chunk-WWUABK6B.js";
20
18
  import "./chunk-FJZWM2ON.js";
19
+ import "./chunk-CEMNIGQH.js";
20
+ import "./chunk-KGZBYWZ3.js";
21
+ import "./chunk-Z2LGMV6C.js";
21
22
 
22
23
  // src/integrations/abletime-oauth.ts
23
24
  import { createHash, randomBytes } from "crypto";
@@ -287,7 +288,7 @@ async function startAbleTimeOAuth(opts) {
287
288
  persistAbleTimeTokens(data, { host });
288
289
  const token = data.access_token.trim();
289
290
  try {
290
- const { getAbleTimeOrientation } = await import("./abletime-OGQR4LIL.js");
291
+ const { getAbleTimeOrientation } = await import("./abletime-OQ4PC52L.js");
291
292
  const orientation = await getAbleTimeOrientation({ token, host });
292
293
  return saveAbleTimeConnection({
293
294
  accessToken: token,
@@ -7,15 +7,16 @@ import {
7
7
  callAbleTimeRestTool,
8
8
  looksLikeAbleTimeUlid,
9
9
  textFromAbleTimeDoc
10
- } from "./chunk-XIEDFRBP.js";
11
- import "./chunk-ZC3TVLY6.js";
10
+ } from "./chunk-B6XFBNYM.js";
11
+ import "./chunk-5OKJDCBK.js";
12
12
  import "./chunk-VKQGAWHY.js";
13
- import "./chunk-452Y24PW.js";
13
+ import "./chunk-VIC6TDYT.js";
14
14
  import "./chunk-NSTQ6QKD.js";
15
- import "./chunk-KGZBYWZ3.js";
16
- import "./chunk-Z2LGMV6C.js";
17
15
  import "./chunk-WWUABK6B.js";
18
16
  import "./chunk-FJZWM2ON.js";
17
+ import "./chunk-CEMNIGQH.js";
18
+ import "./chunk-KGZBYWZ3.js";
19
+ import "./chunk-Z2LGMV6C.js";
19
20
  export {
20
21
  ABLETIME_REST_PREFIX,
21
22
  ableTimeDocFromText,
@@ -5,15 +5,16 @@ import {
5
5
  callAbleTimeRestTool,
6
6
  looksLikeAbleTimeUlid,
7
7
  textFromAbleTimeDoc
8
- } from "./chunk-66LAOKLK.js";
9
- import "./chunk-IFHHPPSL.js";
8
+ } from "./chunk-D554YCHG.js";
9
+ import "./chunk-J6ONZP74.js";
10
10
  import "./chunk-N7WZ6NIN.js";
11
- import "./chunk-KJM3E3NF.js";
11
+ import "./chunk-6PFZ6XO7.js";
12
+ import "./chunk-4TR3HZFT.js";
12
13
  import "./chunk-WDRMZKVB.js";
14
+ import "./chunk-3HO2OY5T.js";
13
15
  import "./chunk-JT7R45JB.js";
14
16
  import "./chunk-77WWLBCI.js";
15
17
  import "./chunk-EHT2DRT4.js";
16
- import "./chunk-4TR3HZFT.js";
17
18
  export {
18
19
  ABLETIME_REST_PREFIX,
19
20
  ableTimeDocFromText,
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/agents/cursor-runner.ts
27
- var import_node_fs14 = require("fs");
27
+ var import_node_fs16 = require("fs");
28
28
  var import_node_readline2 = require("readline");
29
29
 
30
30
  // src/hook/nested-electron-env.ts
@@ -402,6 +402,79 @@ function extractJsonErrorMessage(obj) {
402
402
  }
403
403
  return null;
404
404
  }
405
+ function looksLikeMinifiedJsDump(line) {
406
+ if (line.length < 200) return false;
407
+ return /yield Promise\.all/.test(line) || /\(0,[A-Za-z$]\.\w+\)/.test(line) || /CURSOR_RIPGREP_PATH/.test(line) || /findFilesWithRipgrep/.test(line) || /@cursor\/sdk\/dist\//.test(line) || looksLikeCursorSdkSourceDump(line);
408
+ }
409
+ function looksLikeCursorSdkSourceDump(text) {
410
+ const t = text.trim();
411
+ if (t.length < 120) return false;
412
+ return /cursor-runtime\/node_modules\/@cursor\/sdk/.test(t) || /importas [a-z] from"@bufbuild\/protobuf"/.test(t) || /file:\/\/[^\s]*@cursor\/sdk\/dist\/esm\/index\.js/.test(t);
413
+ }
414
+ function looksLikeHugeToolResultDump(text) {
415
+ if (looksLikeCursorSdkSourceDump(text)) return true;
416
+ const t = text.trim();
417
+ if (t.length < 4e3) return false;
418
+ return looksLikeMinifiedJsDump(t);
419
+ }
420
+ function looksLikeJobWaitResult(rec) {
421
+ if (typeof rec.delta === "string") {
422
+ return typeof rec.status === "string" || typeof rec.id === "string" || typeof rec.stillRunning === "boolean";
423
+ }
424
+ if (typeof rec.stopped === "boolean") {
425
+ return typeof rec.id === "string" || typeof rec.status === "string";
426
+ }
427
+ return rec.started === true || rec.reason === "already-running";
428
+ }
429
+ function clipJobWaitResultJson(content) {
430
+ const trimmed = content.trim();
431
+ if (!trimmed.startsWith("{")) return void 0;
432
+ try {
433
+ const rec = JSON.parse(trimmed);
434
+ if (!looksLikeJobWaitResult(rec)) return void 0;
435
+ if (typeof rec.delta === "string" && rec.delta.length > 3500) {
436
+ rec.delta = `\u2026(truncated ${rec.delta.length} chars)
437
+ ${rec.delta.slice(-3500)}`;
438
+ }
439
+ if (typeof rec.progress === "string" && rec.progress.length > 800) {
440
+ rec.progress = rec.progress.slice(-800);
441
+ }
442
+ if (typeof rec.hint === "string" && rec.hint.length > 240) {
443
+ rec.hint = rec.hint.slice(0, 240);
444
+ }
445
+ let out = JSON.stringify(rec);
446
+ if (out.length <= TOOL_RESULT_STORE_MAX_CHARS) return out;
447
+ return JSON.stringify({
448
+ stillRunning: rec.stillRunning,
449
+ ok: rec.ok,
450
+ failed: rec.failed,
451
+ status: rec.status,
452
+ id: rec.id,
453
+ phase: rec.phase,
454
+ delta: typeof rec.delta === "string" ? rec.delta.slice(-2500) : ""
455
+ });
456
+ } catch {
457
+ return void 0;
458
+ }
459
+ }
460
+ function clipToolResultForStore(content) {
461
+ if (content == null) return void 0;
462
+ if (looksLikeCursorSdkSourceDump(content) || looksLikeMinifiedJsDump(content)) {
463
+ return `${HUGE_TOOL_RESULT_SUMMARY} (${content.length} chars omitted)`;
464
+ }
465
+ const jobClipped = clipJobWaitResultJson(content);
466
+ if (jobClipped) return jobClipped;
467
+ if (content.length <= TOOL_RESULT_STORE_MAX_CHARS) return content;
468
+ const head = 5e3;
469
+ const tail = 2e3;
470
+ return `${content.slice(0, head)}
471
+
472
+ \u2026(truncated ${content.length} chars \u2014 write output to .context/cli/ and read a slice)
473
+
474
+ ${content.slice(-tail)}`;
475
+ }
476
+ var HUGE_TOOL_RESULT_SUMMARY = "Agent crashed mid-turn after a huge tool result. Write CLI/HTTP output to .context/cli/ and read a slice \u2014 never dump raw --json/--expand into the tool result.";
477
+ var TOOL_RESULT_STORE_MAX_CHARS = 8e3;
405
478
  function looksLikeCursorHttp2StreamClose(text) {
406
479
  return /nghttp2/i.test(text.trim());
407
480
  }
@@ -458,7 +531,7 @@ async function retryOnceOnRetryableCursorError(fn, onRetry, delayMs = CURSOR_RET
458
531
  if (!isRetryableCursorTransportError(err)) throw err;
459
532
  onRetry?.(err);
460
533
  if (delayMs > 0) {
461
- await new Promise((resolve) => setTimeout(resolve, delayMs));
534
+ await new Promise((resolve2) => setTimeout(resolve2, delayMs));
462
535
  }
463
536
  return fn();
464
537
  }
@@ -486,8 +559,8 @@ async function* iterateUntilIdle(iterable, idleMs, onIdle, activity) {
486
559
  let idleTimer;
487
560
  const raced = await Promise.race([
488
561
  pending.then((result) => ({ kind: "item", result })),
489
- new Promise((resolve) => {
490
- idleTimer = setTimeout(() => resolve({ kind: "idle" }), waitMs);
562
+ new Promise((resolve2) => {
563
+ idleTimer = setTimeout(() => resolve2({ kind: "idle" }), waitMs);
491
564
  idleTimer.unref?.();
492
565
  })
493
566
  ]);
@@ -511,6 +584,189 @@ async function* iterateUntilIdle(iterable, idleMs, onIdle, activity) {
511
584
  }
512
585
  }
513
586
 
587
+ // src/agents/sliced-file-read.ts
588
+ var import_node_fs14 = require("fs");
589
+ var import_node_path16 = require("path");
590
+ var SLICED_READ_DEFAULT_LIMIT = 200;
591
+ var SLICED_READ_MAX_LINE_CHARS = 2e3;
592
+ var SLICED_READ_DESCRIPTION = "Read a text file. Defaults to 200 lines (and a small char budget). Pass offset (1-based) + limit to continue \u2014 never request the whole file when it is large.";
593
+ var SLICED_READ_INPUT_SCHEMA = {
594
+ type: "object",
595
+ properties: {
596
+ path: {
597
+ type: "string",
598
+ description: "Absolute or cwd-relative path inside the worktree."
599
+ },
600
+ offset: {
601
+ type: "number",
602
+ description: "1-based start line (default 1)."
603
+ },
604
+ limit: {
605
+ type: "number",
606
+ description: `Max lines to return (default ${SLICED_READ_DEFAULT_LIMIT}).`
607
+ }
608
+ },
609
+ required: ["path"]
610
+ };
611
+ function realpathOrSelf(path) {
612
+ try {
613
+ return (0, import_node_fs14.realpathSync)(path);
614
+ } catch {
615
+ return (0, import_node_path16.resolve)(path);
616
+ }
617
+ }
618
+ function isOutsideWorktree(root, abs) {
619
+ const rel = (0, import_node_path16.relative)(root, abs);
620
+ return rel === ".." || rel.startsWith(`..${import_node_path16.sep}`) || (0, import_node_path16.isAbsolute)(rel);
621
+ }
622
+ function resolveWithinCwd(cwd, input) {
623
+ const root = realpathOrSelf(cwd);
624
+ const abs = (0, import_node_path16.isAbsolute)(input) ? (0, import_node_path16.resolve)(input) : (0, import_node_path16.resolve)(root, input);
625
+ if (isOutsideWorktree(root, abs)) {
626
+ throw new Error(`Path is outside the worktree: ${input}`);
627
+ }
628
+ const real = realpathOrSelf(abs);
629
+ if (isOutsideWorktree(root, real)) {
630
+ throw new Error(`Path is outside the worktree: ${input}`);
631
+ }
632
+ return real;
633
+ }
634
+ function capLine(line) {
635
+ if (line.length <= SLICED_READ_MAX_LINE_CHARS) return line;
636
+ return `${line.slice(0, SLICED_READ_MAX_LINE_CHARS)}\u2026(${line.length - SLICED_READ_MAX_LINE_CHARS} more chars on this line)`;
637
+ }
638
+ function looksBinary(buf) {
639
+ const n = Math.min(buf.length, 8192);
640
+ for (let i = 0; i < n; i += 1) {
641
+ if (buf[i] === 0) return true;
642
+ }
643
+ return false;
644
+ }
645
+ function asPositiveInt(value, fallback) {
646
+ const n = typeof value === "number" ? value : Number(value);
647
+ if (!Number.isFinite(n)) return fallback;
648
+ return Math.max(1, Math.floor(n));
649
+ }
650
+ function executeSlicedFileRead(cwd, args) {
651
+ const rawPath = typeof args.path === "string" ? args.path.trim() : "";
652
+ if (!rawPath) return "Error: path is required.";
653
+ let abs;
654
+ try {
655
+ abs = resolveWithinCwd(cwd, rawPath);
656
+ } catch (err) {
657
+ return `Error: ${err instanceof Error ? err.message : String(err)}`;
658
+ }
659
+ let buf;
660
+ try {
661
+ const st = (0, import_node_fs14.statSync)(abs);
662
+ if (!st.isFile()) return `Error: not a file: ${rawPath}`;
663
+ buf = (0, import_node_fs14.readFileSync)(abs);
664
+ } catch (err) {
665
+ return `Error: ${err instanceof Error ? err.message : String(err)}`;
666
+ }
667
+ if (looksBinary(buf)) {
668
+ return `Error: ${rawPath} looks binary (${buf.length} bytes). Do not dump it into the turn.`;
669
+ }
670
+ const text = buf.toString("utf8");
671
+ const lines = text.split("\n");
672
+ if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
673
+ const totalLines = lines.length;
674
+ const offset = asPositiveInt(args.offset, 1);
675
+ const limit = asPositiveInt(args.limit, SLICED_READ_DEFAULT_LIMIT);
676
+ const start = Math.min(offset, totalLines + 1);
677
+ const end = Math.min(start + limit - 1, totalLines);
678
+ const numbered = [];
679
+ let used = 0;
680
+ let stoppedEarly = false;
681
+ for (let i = start; i <= end; i += 1) {
682
+ const row = `${String(i).padStart(6, " ")}|${capLine(lines[i - 1] ?? "")}`;
683
+ if (used + row.length + 1 > TOOL_RESULT_STORE_MAX_CHARS && numbered.length > 0) {
684
+ stoppedEarly = true;
685
+ break;
686
+ }
687
+ numbered.push(row);
688
+ used += row.length + 1;
689
+ }
690
+ const header = `${rawPath} (${totalLines} lines, ${buf.length} bytes)`;
691
+ if (totalLines === 0) return `${header}
692
+ (empty file)`;
693
+ if (start > totalLines) {
694
+ return `${header}
695
+ offset ${offset} is past EOF. Last line is ${totalLines}.`;
696
+ }
697
+ const shownEnd = start + numbered.length - 1;
698
+ const truncated = stoppedEarly || shownEnd < totalLines;
699
+ const body = numbered.join("\n");
700
+ if (!truncated && start === 1) return `${header}
701
+ ${body}`;
702
+ const next = shownEnd + 1;
703
+ const hint = truncated ? `
704
+
705
+ \u2026truncated; ${totalLines - shownEnd} lines remain. Re-call with offset=${next} (and limit) \u2014 do not read the whole file.` : start > 1 ? `
706
+
707
+ (lines ${start}\u2013${shownEnd} of ${totalLines})` : "";
708
+ return `${header}
709
+ ${body}${hint}`;
710
+ }
711
+ function slicedReadCustomToolConfig(cwd) {
712
+ return {
713
+ description: SLICED_READ_DESCRIPTION,
714
+ inputSchema: SLICED_READ_INPUT_SCHEMA,
715
+ execute: (args) => executeSlicedFileRead(cwd, args)
716
+ };
717
+ }
718
+
719
+ // src/agents/tool-result-clip.ts
720
+ var import_node_fs15 = require("fs");
721
+ var import_node_path17 = require("path");
722
+
723
+ // src/paths/workspace-scratch.ts
724
+ var CLI_DIR = ".context/cli";
725
+
726
+ // src/agents/tool-result-clip.ts
727
+ function spillPath(cwd, prefix) {
728
+ const stamp = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
729
+ const safe = prefix.replace(/[^a-zA-Z0-9_-]+/g, "-").slice(0, 40) || "tool";
730
+ return (0, import_node_path17.join)(cwd, CLI_DIR, `${safe}-${stamp}.txt`);
731
+ }
732
+ function spillToolResultToCli(content, opts) {
733
+ const cwd = opts?.cwd?.trim();
734
+ if (!cwd || !content) return null;
735
+ const file = spillPath(cwd, opts?.prefix ?? "tool-result");
736
+ try {
737
+ (0, import_node_fs15.mkdirSync)((0, import_node_path17.join)(cwd, CLI_DIR), { recursive: true });
738
+ (0, import_node_fs15.writeFileSync)(file, content, "utf8");
739
+ return file;
740
+ } catch {
741
+ return null;
742
+ }
743
+ }
744
+ function spillAndClipToolResult(content, opts) {
745
+ const clipped = clipToolResultForStore(content);
746
+ if (clipped == null) return content;
747
+ if (clipped === content) return content;
748
+ if (looksLikeHugeToolResultDump(content)) return clipped;
749
+ const spilled = spillToolResultToCli(content, opts);
750
+ if (!spilled) return clipped;
751
+ return `${clipped}
752
+
753
+ Full output: ${spilled} (${content.length} chars). Read that file with offset/limit \u2014 do not dump it whole.`;
754
+ }
755
+ function clipAgentEventForEmit(event, cwd) {
756
+ if (!event || typeof event !== "object") return event;
757
+ const rec = event;
758
+ if (rec.type === "tool_result" && typeof rec.content === "string") {
759
+ return {
760
+ ...rec,
761
+ content: spillAndClipToolResult(rec.content, { cwd, prefix: "cursor-tool" })
762
+ };
763
+ }
764
+ if ((rec.type === "stderr" || rec.type === "stdout") && typeof rec.data === "string" && looksLikeHugeToolResultDump(rec.data)) {
765
+ return { ...rec, data: clipToolResultForStore(rec.data) };
766
+ }
767
+ return event;
768
+ }
769
+
514
770
  // src/agents/cursor-events.ts
515
771
  function usageFromCursor(usage) {
516
772
  if (!usage) return null;
@@ -569,8 +825,8 @@ function cursorGetUsageRunId(runId) {
569
825
  }
570
826
  var CURSOR_COST_POLL_MS = [0, 400, 800, 1600, 3200];
571
827
  function sleep(ms) {
572
- return new Promise((resolve) => {
573
- setTimeout(resolve, ms);
828
+ return new Promise((resolve2) => {
829
+ setTimeout(resolve2, ms);
574
830
  });
575
831
  }
576
832
  async function fetchCursorTurnCostUsd(getUsage, usageBefore, opts) {
@@ -878,12 +1134,12 @@ function createAgentStreamCoalescer(emit2, opts) {
878
1134
  // src/agents/cursor-runner.ts
879
1135
  dropNestedElectronEnvFromProcess();
880
1136
  function emit(event) {
881
- process.stdout.write(`${JSON.stringify(event)}
1137
+ process.stdout.write(`${JSON.stringify(clipAgentEventForEmit(event, process.cwd()))}
882
1138
  `);
883
1139
  }
884
1140
  function localAgentStore(Store, threadId) {
885
1141
  const root = cursorSdkStoreDir(threadId);
886
- (0, import_node_fs14.mkdirSync)(root, { recursive: true });
1142
+ (0, import_node_fs16.mkdirSync)(root, { recursive: true });
887
1143
  return new Store(root);
888
1144
  }
889
1145
  async function cancelStaleLocalRuns(Agent, agentId, opts) {
@@ -954,9 +1210,13 @@ async function main() {
954
1210
  const mode = req.planMode ? "plan" : "agent";
955
1211
  const store = localAgentStore(JsonlLocalAgentStore, req.threadId);
956
1212
  const isolateSources = [];
1213
+ const customTools = {
1214
+ read: slicedReadCustomToolConfig(req.cwd)
1215
+ };
957
1216
  const local = withCursorLocalHangGuards({
958
1217
  cwd: req.cwd,
959
1218
  store,
1219
+ customTools,
960
1220
  ...req.isolateAmbientMcp ? { settingSources: isolateSources } : {}
961
1221
  });
962
1222
  const mcpServers = req.mcpServers && Object.keys(req.mcpServers).length > 0 ? req.mcpServers : void 0;
@@ -966,6 +1226,7 @@ async function main() {
966
1226
  mode,
967
1227
  local,
968
1228
  name: "Sideboard",
1229
+ disallowedTools: ["read"],
969
1230
  ...mcpServers ? { mcpServers } : {}
970
1231
  };
971
1232
  const retryTransport = (fn) => retryOnceOnRetryableCursorError(fn, (err) => {
@@ -982,6 +1243,7 @@ async function main() {
982
1243
  model,
983
1244
  mode,
984
1245
  local,
1246
+ disallowedTools: ["read"],
985
1247
  ...mcpServers ? { mcpServers } : {}
986
1248
  })
987
1249
  ) : await createAgent();
@@ -1030,8 +1292,8 @@ async function main() {
1030
1292
  shuttingDown = true;
1031
1293
  void Promise.race([
1032
1294
  cancelLiveRun(),
1033
- new Promise((resolve) => {
1034
- setTimeout(resolve, 2e3);
1295
+ new Promise((resolve2) => {
1296
+ setTimeout(resolve2, 2e3);
1035
1297
  })
1036
1298
  ]).finally(() => process.exit(1));
1037
1299
  };
@@ -1086,8 +1348,8 @@ async function main() {
1086
1348
  stream.flush();
1087
1349
  const result = streamIdle ? await Promise.race([
1088
1350
  run2.wait(),
1089
- new Promise((resolve) => {
1090
- setTimeout(() => resolve({ status: "cancelled" }), 5e3);
1351
+ new Promise((resolve2) => {
1352
+ setTimeout(() => resolve2({ status: "cancelled" }), 5e3);
1091
1353
  })
1092
1354
  ]) : await run2.wait();
1093
1355
  if (result.status === "error") {