@sideboard-ai/core 0.1.232 → 0.1.233

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 (42) hide show
  1. package/dist/agents/cursor-runner.cjs +167 -62
  2. package/dist/agents/cursor-runner.js +16 -9
  3. package/dist/{agents-ENAQHQRZ.js → agents-J2CUJHPC.js} +16 -6
  4. package/dist/{agents-TCTEAK6M.js → agents-LDYMFW6N.js} +17 -7
  5. package/dist/{chunk-TQBUXKIB.js → chunk-26T43LBM.js} +97 -11
  6. package/dist/{chunk-PO4M4JAJ.js → chunk-2P4XKWV2.js} +1 -1
  7. package/dist/{chunk-ABOBTSO6.js → chunk-2UG25RMK.js} +18 -5
  8. package/dist/{chunk-4CZ25DO2.js → chunk-4VFOJZPS.js} +2 -2
  9. package/dist/{chunk-N5TX66CD.js → chunk-7H2CVVLF.js} +2 -2
  10. package/dist/{chunk-LLMG6OVS.js → chunk-BGHDWCAV.js} +19 -19
  11. package/dist/{chunk-SZJZEFTY.js → chunk-DD67JWTN.js} +1 -1
  12. package/dist/{chunk-7BZ7DSBN.js → chunk-NLETJP7Z.js} +17 -17
  13. package/dist/{chunk-FA4CPYCY.js → chunk-PZQNE5X4.js} +81 -41
  14. package/dist/{chunk-HVUVQXZ2.js → chunk-QVN2WOKJ.js} +18 -5
  15. package/dist/{chunk-HZFLKVGC.js → chunk-S2OEFXST.js} +1 -1
  16. package/dist/{chunk-SXFRXNBM.js → chunk-SPAMHHJH.js} +1 -1
  17. package/dist/{chunk-ZXJMAKEP.js → chunk-TNVJPFHM.js} +5 -5
  18. package/dist/{chunk-UNTOZA3C.js → chunk-TWXSZYR2.js} +1 -1
  19. package/dist/{chunk-6L25K7BE.js → chunk-TXMFBL3X.js} +195 -73
  20. package/dist/{connected-teams-PIBQTOJU.js → connected-teams-JUJAQZZE.js} +2 -2
  21. package/dist/{connected-teams-RVD3PFAG.js → connected-teams-KQUDU7LZ.js} +2 -2
  22. package/dist/{coordinator-prompt-YKLXQTWH.js → coordinator-prompt-CE7MN6QY.js} +4 -4
  23. package/dist/{coordinator-prompt-DFXYTM6D.js → coordinator-prompt-IGDMFKCD.js} +4 -4
  24. package/dist/{global-workspace-EYZKYHAO.js → global-workspace-7WH24UFO.js} +4 -4
  25. package/dist/{global-workspace-4SPANNJT.js → global-workspace-NCIC2Y2U.js} +4 -4
  26. package/dist/index.cjs +490 -326
  27. package/dist/index.d.cts +19 -3
  28. package/dist/index.d.ts +19 -3
  29. package/dist/index.js +27 -8
  30. package/dist/mcp/run-stdio.cjs +418 -302
  31. package/dist/mcp/run-stdio.js +7 -7
  32. package/dist/{orchestrator-FTHJKPIX.js → orchestrator-BXALNM4M.js} +8 -8
  33. package/dist/{orchestrator-RJX4OKYC.js → orchestrator-NLZMHTLX.js} +7 -7
  34. package/dist/{run-UEQM4JMZ.js → run-PCX5QWR4.js} +1 -1
  35. package/dist/{run-QDZCTP4Y.js → run-TB7RBII2.js} +1 -1
  36. package/dist/{workspaces-73Y7IJY2.js → workspaces-H2TRFDE2.js} +4 -4
  37. package/dist/{workspaces-FQCSCTNH.js → workspaces-NSQZSDQD.js} +4 -4
  38. package/dist/{worktree-DOPRKG7K.js → worktree-FMIX4BRV.js} +3 -3
  39. package/dist/{worktree-36VEFUJN.js → worktree-W7BSI4GU.js} +3 -3
  40. package/dist/{worktree-exclude-K7QK4RI5.js → worktree-exclude-5N2KTYIT.js} +2 -2
  41. package/dist/{worktree-exclude-L32WEBX6.js → worktree-exclude-RXZPTCNH.js} +2 -2
  42. package/package.json +2 -2
@@ -24,8 +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_sdk = require("@cursor/sdk");
28
- var import_node_fs12 = require("fs");
27
+ var import_node_fs13 = require("fs");
29
28
  var import_node_readline2 = require("readline");
30
29
 
31
30
  // src/hook/nested-electron-env.ts
@@ -46,48 +45,154 @@ var STRIP_NESTED_ELECTRON_THEN_EXEC = [
46
45
  ].join("; ");
47
46
 
48
47
  // src/agents/cursor-ripgrep.ts
49
- var import_node_fs11 = require("fs");
48
+ var import_node_fs12 = require("fs");
49
+ var import_node_module2 = require("module");
50
+ var import_node_path13 = require("path");
51
+
52
+ // src/agents/cursor-sdk-resolve.ts
53
+ var import_node_fs2 = require("fs");
50
54
  var import_node_module = require("module");
51
- var import_node_path12 = require("path");
55
+ var import_node_path2 = require("path");
56
+ var import_node_url = require("url");
57
+
58
+ // src/agents/path.ts
59
+ var import_node_fs = require("fs");
60
+ var import_node_child_process = require("child_process");
61
+ var import_node_os = require("os");
62
+ var import_node_path = require("path");
63
+ function npmGlobalPrefix(env = process.env) {
64
+ try {
65
+ const prefix = (0, import_node_child_process.execFileSync)("npm", ["prefix", "-g"], {
66
+ encoding: "utf8",
67
+ env: { ...process.env, ...env },
68
+ timeout: 8e3,
69
+ stdio: ["ignore", "pipe", "ignore"]
70
+ }).trim().split(/\r?\n/).find(Boolean);
71
+ return prefix || null;
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+ function npmGlobalNodeModules(env = process.env) {
77
+ const prefix = npmGlobalPrefix(env);
78
+ if (!prefix) return null;
79
+ const dir = process.platform === "win32" ? (0, import_node_path.join)(prefix, "node_modules") : (0, import_node_path.join)(prefix, "lib", "node_modules");
80
+ return (0, import_node_fs.existsSync)(dir) ? dir : null;
81
+ }
82
+
83
+ // src/agents/cursor-sdk-resolve.ts
84
+ var import_meta = {};
85
+ var 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.";
86
+ function thisModuleFile() {
87
+ const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
88
+ if (cjsDir) return (0, import_node_path2.join)(cjsDir, "cursor-sdk-resolve.js");
89
+ try {
90
+ return (0, import_node_url.fileURLToPath)(import_meta.url);
91
+ } catch {
92
+ return (0, import_node_path2.join)(process.cwd(), "package.json");
93
+ }
94
+ }
95
+ function packageRootLooksLikeSdk(dir) {
96
+ try {
97
+ const raw = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(dir, "package.json"), "utf8");
98
+ const pkg = JSON.parse(raw);
99
+ return pkg.name === "@cursor/sdk" && (0, import_node_fs2.existsSync)(dir);
100
+ } catch {
101
+ return false;
102
+ }
103
+ }
104
+ function resolvedPackageRoot(fromFile) {
105
+ try {
106
+ const req = (0, import_node_module.createRequire)(fromFile);
107
+ const pkgJson = req.resolve("@cursor/sdk/package.json");
108
+ const root = (0, import_node_path2.dirname)(pkgJson);
109
+ return packageRootLooksLikeSdk(root) ? root : null;
110
+ } catch {
111
+ return null;
112
+ }
113
+ }
114
+ function resolveCursorSdkRoot(opts) {
115
+ const env = opts?.env ?? process.env;
116
+ const override = env.SIDEBOARD_CURSOR_SDK?.trim();
117
+ if (override) {
118
+ return packageRootLooksLikeSdk(override) ? override : null;
119
+ }
120
+ const globalNm = npmGlobalNodeModules(env);
121
+ if (globalNm) {
122
+ const globalRoot = (0, import_node_path2.join)(globalNm, "@cursor/sdk");
123
+ if (packageRootLooksLikeSdk(globalRoot)) return globalRoot;
124
+ }
125
+ const cwdPkg = (0, import_node_path2.join)(process.cwd(), "package.json");
126
+ return resolvedPackageRoot(thisModuleFile()) ?? resolvedPackageRoot(cwdPkg);
127
+ }
128
+ async function importCursorSdk(opts) {
129
+ const root = resolveCursorSdkRoot(opts);
130
+ if (!root) return null;
131
+ try {
132
+ const req = (0, import_node_module.createRequire)((0, import_node_path2.join)(root, "package.json"));
133
+ const entry = req.resolve("@cursor/sdk");
134
+ return await import((0, import_node_url.pathToFileURL)(entry).href);
135
+ } catch {
136
+ return null;
137
+ }
138
+ }
139
+ function cursorSdkPlatformRipgrepPackage() {
140
+ return `@cursor/sdk-${process.platform}-${process.arch}`;
141
+ }
142
+ function nodeModulesDirForPackageRoot(packageRoot) {
143
+ const parent = (0, import_node_path2.dirname)(packageRoot);
144
+ return (0, import_node_path2.basename)(parent).startsWith("@") ? (0, import_node_path2.dirname)(parent) : parent;
145
+ }
146
+ function cursorSdkRipgrepCandidate(opts) {
147
+ const root = resolveCursorSdkRoot(opts);
148
+ if (!root) return null;
149
+ const nm = nodeModulesDirForPackageRoot(root);
150
+ const pkg = cursorSdkPlatformRipgrepPackage();
151
+ const bin = process.platform === "win32" ? "rg.exe" : "rg";
152
+ const sibling = (0, import_node_path2.join)(nm, pkg, "bin", bin);
153
+ if ((0, import_node_fs2.existsSync)(sibling)) return sibling;
154
+ const nested = (0, import_node_path2.join)(root, "node_modules", pkg, "bin", bin);
155
+ return (0, import_node_fs2.existsSync)(nested) ? nested : null;
156
+ }
52
157
 
53
158
  // src/agents/node-launch.ts
54
- var import_node_fs10 = require("fs");
159
+ var import_node_fs11 = require("fs");
55
160
  var import_node_os5 = require("os");
56
- var import_node_path11 = require("path");
161
+ var import_node_path12 = require("path");
57
162
 
58
163
  // src/http/system-ca.ts
59
- var import_node_child_process = require("child_process");
60
- var import_node_fs5 = require("fs");
61
- var import_node_path6 = require("path");
164
+ var import_node_child_process2 = require("child_process");
165
+ var import_node_fs7 = require("fs");
166
+ var import_node_path8 = require("path");
62
167
  var import_node_tls = __toESM(require("tls"), 1);
63
168
 
64
169
  // src/store/paths.ts
65
- var import_node_path4 = require("path");
66
- var import_node_os2 = require("os");
67
- var import_node_path5 = require("path");
68
- var import_node_fs4 = require("fs");
170
+ var import_node_path6 = require("path");
171
+ var import_node_os3 = require("os");
172
+ var import_node_path7 = require("path");
173
+ var import_node_fs6 = require("fs");
69
174
 
70
175
  // src/hook/settings.ts
71
- var import_node_fs3 = require("fs");
72
- var import_node_os = require("os");
73
- var import_node_path3 = require("path");
176
+ var import_node_fs5 = require("fs");
177
+ var import_node_os2 = require("os");
178
+ var import_node_path5 = require("path");
74
179
  var import_smol_toml = require("smol-toml");
75
180
 
76
181
  // src/hook/convention-setup.ts
77
- var import_node_fs = require("fs");
78
- var import_node_path = require("path");
182
+ var import_node_fs3 = require("fs");
183
+ var import_node_path3 = require("path");
79
184
 
80
185
  // src/hook/cursor-worktrees.ts
81
- var import_node_fs2 = require("fs");
82
- var import_node_path2 = require("path");
186
+ var import_node_fs4 = require("fs");
187
+ var import_node_path4 = require("path");
83
188
  var import_execa = require("execa");
84
189
  var import_node_readline = require("readline");
85
190
 
86
191
  // src/store/paths.ts
87
192
  function appDataDir() {
88
193
  const override = process.env.SIDEBOARD_APP_DATA?.trim();
89
- const base = override ? override : process.platform === "darwin" ? (0, import_node_path5.join)((0, import_node_os2.homedir)(), "Library", "Application Support", "sideboard") : process.platform === "win32" ? (0, import_node_path5.join)(process.env.APPDATA ?? (0, import_node_path5.join)((0, import_node_os2.homedir)(), "AppData", "Roaming"), "sideboard") : (0, import_node_path5.join)((0, import_node_os2.homedir)(), ".local", "share", "sideboard");
90
- (0, import_node_fs4.mkdirSync)(base, { recursive: true });
194
+ const base = override ? override : process.platform === "darwin" ? (0, import_node_path7.join)((0, import_node_os3.homedir)(), "Library", "Application Support", "sideboard") : process.platform === "win32" ? (0, import_node_path7.join)(process.env.APPDATA ?? (0, import_node_path7.join)((0, import_node_os3.homedir)(), "AppData", "Roaming"), "sideboard") : (0, import_node_path7.join)((0, import_node_os3.homedir)(), ".local", "share", "sideboard");
195
+ (0, import_node_fs6.mkdirSync)(base, { recursive: true });
91
196
  return base;
92
197
  }
93
198
 
@@ -97,24 +202,18 @@ var BUNDLE_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
97
202
  // src/git/run.ts
98
203
  var import_execa2 = require("execa");
99
204
 
100
- // src/agents/path.ts
101
- var import_node_fs6 = require("fs");
102
- var import_node_child_process2 = require("child_process");
103
- var import_node_os3 = require("os");
104
- var import_node_path7 = require("path");
105
-
106
205
  // src/git/github-agent-auth.ts
107
- var import_node_fs7 = require("fs");
108
- var import_node_os4 = require("os");
109
- var import_node_path8 = require("path");
110
-
111
- // src/git/stale-lock.ts
112
206
  var import_node_fs8 = require("fs");
207
+ var import_node_os4 = require("os");
113
208
  var import_node_path9 = require("path");
114
209
 
115
- // src/agents/packaged-runtime.ts
210
+ // src/git/stale-lock.ts
116
211
  var import_node_fs9 = require("fs");
117
212
  var import_node_path10 = require("path");
213
+
214
+ // src/agents/packaged-runtime.ts
215
+ var import_node_fs10 = require("fs");
216
+ var import_node_path11 = require("path");
118
217
  function electronResourcesPath() {
119
218
  const resources = process.resourcesPath;
120
219
  if (typeof resources !== "string" || !resources) return null;
@@ -123,14 +222,14 @@ function electronResourcesPath() {
123
222
  function packagedCursorRuntimeDir() {
124
223
  const resources = electronResourcesPath();
125
224
  if (!resources) return null;
126
- const dir = (0, import_node_path10.join)(resources, "cursor-runtime");
127
- if (!(0, import_node_fs9.existsSync)((0, import_node_path10.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
225
+ const dir = (0, import_node_path11.join)(resources, "cursor-runtime");
226
+ if (!(0, import_node_fs10.existsSync)((0, import_node_path11.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
128
227
  return dir;
129
228
  }
130
229
  function packagedCursorRipgrepCandidate(platformPkg, binName) {
131
230
  const dir = packagedCursorRuntimeDir();
132
231
  if (!dir) return null;
133
- return (0, import_node_path10.join)(dir, "node_modules", platformPkg, "bin", binName);
232
+ return (0, import_node_path11.join)(dir, "node_modules", platformPkg, "bin", binName);
134
233
  }
135
234
 
136
235
  // src/agents/node-launch.ts
@@ -142,7 +241,7 @@ function unpackedAsarPath(filePath) {
142
241
  if (!isAsarPath(filePath)) return null;
143
242
  const unpacked = filePath.replace(/\.asar(?=[/\\])/, ".asar.unpacked");
144
243
  if (unpacked === filePath) return null;
145
- return (0, import_node_fs10.existsSync)(unpacked) ? unpacked : null;
244
+ return (0, import_node_fs11.existsSync)(unpacked) ? unpacked : null;
146
245
  }
147
246
  function nodeReadableScriptPath(scriptPath) {
148
247
  return unpackedAsarPath(scriptPath) ?? scriptPath;
@@ -158,21 +257,21 @@ function platformRipgrepPackage() {
158
257
  }
159
258
  function usableRipgrepPath(candidate) {
160
259
  const raw = candidate?.trim();
161
- if (!raw || !(0, import_node_path12.isAbsolute)(raw)) return null;
260
+ if (!raw || !(0, import_node_path13.isAbsolute)(raw)) return null;
162
261
  const readable = nodeReadableScriptPath(raw);
163
- if (!(0, import_node_fs11.existsSync)(readable) || isAsarPath(readable)) return null;
262
+ if (!(0, import_node_fs12.existsSync)(readable) || isAsarPath(readable)) return null;
164
263
  return readable;
165
264
  }
166
265
  function walkForBundledRipgrep(startFile) {
167
266
  if (!startFile) return null;
168
267
  const pkg = platformRipgrepPackage();
169
268
  const name = rgBinaryName();
170
- let dir = (0, import_node_path12.dirname)((0, import_node_path12.resolve)(startFile));
171
- const root = (0, import_node_path12.parse)(dir).root;
269
+ let dir = (0, import_node_path13.dirname)((0, import_node_path13.resolve)(startFile));
270
+ const root = (0, import_node_path13.parse)(dir).root;
172
271
  while (dir !== root) {
173
- const hit = usableRipgrepPath((0, import_node_path12.join)(dir, "node_modules", pkg, "bin", name));
272
+ const hit = usableRipgrepPath((0, import_node_path13.join)(dir, "node_modules", pkg, "bin", name));
174
273
  if (hit) return hit;
175
- const next = (0, import_node_path12.dirname)(dir);
274
+ const next = (0, import_node_path13.dirname)(dir);
176
275
  if (next === dir) break;
177
276
  dir = next;
178
277
  }
@@ -180,9 +279,9 @@ function walkForBundledRipgrep(startFile) {
180
279
  }
181
280
  function requireResolveBundledRipgrep(fromFile) {
182
281
  try {
183
- const req = (0, import_node_module.createRequire)(fromFile);
282
+ const req = (0, import_node_module2.createRequire)(fromFile);
184
283
  const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
185
- return usableRipgrepPath((0, import_node_path12.join)((0, import_node_path12.dirname)(pkgJson), "bin", rgBinaryName()));
284
+ return usableRipgrepPath((0, import_node_path13.join)((0, import_node_path13.dirname)(pkgJson), "bin", rgBinaryName()));
186
285
  } catch {
187
286
  return null;
188
287
  }
@@ -198,7 +297,7 @@ function resolveCursorRipgrepPath(opts) {
198
297
  const start = opts?.startFile?.trim() || process.argv[1] || // CJS bundle only — ESM has no __filename; argv[1] is the running script.
199
298
  // eslint-disable-next-line camelcase
200
299
  (typeof __filename !== "undefined" ? __filename : "");
201
- return walkForBundledRipgrep(start) ?? requireResolveBundledRipgrep(start);
300
+ return walkForBundledRipgrep(start) ?? usableRipgrepPath(cursorSdkRipgrepCandidate({ env })) ?? requireResolveBundledRipgrep(start);
202
301
  }
203
302
  function ensureCursorRipgrepPath(opts) {
204
303
  const target = opts?.env ?? process.env;
@@ -208,13 +307,13 @@ function ensureCursorRipgrepPath(opts) {
208
307
  }
209
308
 
210
309
  // src/agents/cursor-store.ts
211
- var import_node_path13 = require("path");
310
+ var import_node_path14 = require("path");
212
311
  var CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
213
312
  function cursorSdkStoreDir(threadId) {
214
- const root = (0, import_node_path13.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
313
+ const root = (0, import_node_path14.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
215
314
  const id = sanitizeCursorStoreSegment(threadId);
216
315
  if (!id) return root;
217
- return (0, import_node_path13.join)(root, "threads", id);
316
+ return (0, import_node_path14.join)(root, "threads", id);
218
317
  }
219
318
  function sanitizeCursorStoreSegment(threadId) {
220
319
  return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
@@ -738,18 +837,17 @@ function createAgentStreamCoalescer(emit2, opts) {
738
837
 
739
838
  // src/agents/cursor-runner.ts
740
839
  dropNestedElectronEnvFromProcess();
741
- ensureCursorRipgrepPath();
742
840
  function emit(event) {
743
841
  process.stdout.write(`${JSON.stringify(event)}
744
842
  `);
745
843
  }
746
- function localAgentStore(threadId) {
844
+ function localAgentStore(Store, threadId) {
747
845
  const root = cursorSdkStoreDir(threadId);
748
- (0, import_node_fs12.mkdirSync)(root, { recursive: true });
749
- return new import_sdk.JsonlLocalAgentStore(root);
846
+ (0, import_node_fs13.mkdirSync)(root, { recursive: true });
847
+ return new Store(root);
750
848
  }
751
- async function cancelStaleLocalRuns(agentId, opts) {
752
- const listed = await import_sdk.Agent.listRuns(agentId, {
849
+ async function cancelStaleLocalRuns(Agent, agentId, opts) {
850
+ const listed = await Agent.listRuns(agentId, {
753
851
  runtime: "local",
754
852
  cwd: opts.cwd,
755
853
  store: opts.store,
@@ -759,7 +857,7 @@ async function cancelStaleLocalRuns(agentId, opts) {
759
857
  for (const run2 of listed.items) {
760
858
  if (run2.status !== "running") continue;
761
859
  try {
762
- await import_sdk.Agent.cancelRun(run2.id, {
860
+ await Agent.cancelRun(run2.id, {
763
861
  runtime: "local",
764
862
  cwd: opts.cwd,
765
863
  store: opts.store
@@ -797,13 +895,20 @@ async function main() {
797
895
  emit({ type: "stderr", data: "cursor-runner: cwd is required" });
798
896
  return 1;
799
897
  }
898
+ const sdk = await importCursorSdk();
899
+ if (!sdk) {
900
+ emit({ type: "stderr", data: CURSOR_SDK_INSTALL_HINT });
901
+ return 1;
902
+ }
903
+ const { Agent, CursorAgentError, JsonlLocalAgentStore } = sdk;
904
+ ensureCursorRipgrepPath();
800
905
  const apiKey = (req.apiKey || process.env.CURSOR_API_KEY || "").trim() || void 0;
801
906
  const model = buildCursorModelSelection(req.model, {
802
907
  effort: req.effort,
803
908
  fast: Boolean(req.fast)
804
909
  });
805
910
  const mode = req.planMode ? "plan" : "agent";
806
- const store = localAgentStore(req.threadId);
911
+ const store = localAgentStore(JsonlLocalAgentStore, req.threadId);
807
912
  const isolateSources = [];
808
913
  const local = withCursorLocalHangGuards({
809
914
  cwd: req.cwd,
@@ -823,12 +928,12 @@ async function main() {
823
928
  emit({ type: "stderr", data: cursorRetryableTransportMessage(err) });
824
929
  });
825
930
  async function createAgent() {
826
- return retryTransport(() => import_sdk.Agent.create(createOpts));
931
+ return retryTransport(() => Agent.create(createOpts));
827
932
  }
828
933
  async function openAgent() {
829
934
  try {
830
935
  return req.agentId ? await retryTransport(
831
- () => import_sdk.Agent.resume(req.agentId, {
936
+ () => Agent.resume(req.agentId, {
832
937
  apiKey,
833
938
  model,
834
939
  mode,
@@ -854,7 +959,7 @@ async function main() {
854
959
  return await retryTransport(() => agent.send(req.prompt, sendOpts));
855
960
  } catch (err) {
856
961
  if (!isAgentBusyError(err)) throw err;
857
- const n = await cancelStaleLocalRuns(agent.agentId, {
962
+ const n = await cancelStaleLocalRuns(Agent, agent.agentId, {
858
963
  cwd: req.cwd,
859
964
  store
860
965
  });
@@ -986,7 +1091,7 @@ async function main() {
986
1091
  await agent[Symbol.asyncDispose]().catch(() => void 0);
987
1092
  }
988
1093
  } catch (err) {
989
- if (err instanceof import_sdk.CursorAgentError) {
1094
+ if (err instanceof CursorAgentError) {
990
1095
  emit({
991
1096
  type: "stderr",
992
1097
  data: `Cursor startup failed: ${err.message}${err.isRetryable ? " (retryable)" : ""}`
@@ -3,25 +3,26 @@ import {
3
3
  createAgentStreamCoalescer
4
4
  } from "../chunk-AXQ4ZWHK.js";
5
5
  import {
6
+ CURSOR_SDK_INSTALL_HINT,
6
7
  cursorCostOnlyUsageEvent,
7
8
  cursorDeltaToEvents,
8
9
  cursorSdkMessageToEvents,
9
10
  ensureCursorRipgrepPath,
10
11
  fetchCursorTurnCostUsd,
11
12
  formatUnknownDetail,
13
+ importCursorSdk,
12
14
  looksLikeCursorHttp2StreamClose
13
- } from "../chunk-TQBUXKIB.js";
15
+ } from "../chunk-26T43LBM.js";
14
16
  import {
15
17
  cursorSdkStoreDir
16
18
  } from "../chunk-7J72QJOM.js";
17
19
  import "../chunk-WFUDY6PC.js";
18
- import "../chunk-HVUVQXZ2.js";
20
+ import "../chunk-QVN2WOKJ.js";
19
21
  import {
20
22
  dropNestedElectronEnvFromProcess
21
23
  } from "../chunk-4TR3HZFT.js";
22
24
 
23
25
  // src/agents/cursor-runner.ts
24
- import { Agent, CursorAgentError, JsonlLocalAgentStore } from "@cursor/sdk";
25
26
  import { mkdirSync } from "fs";
26
27
  import { createInterface } from "readline";
27
28
 
@@ -146,17 +147,16 @@ function buildCursorModelSelection(model, opts) {
146
147
 
147
148
  // src/agents/cursor-runner.ts
148
149
  dropNestedElectronEnvFromProcess();
149
- ensureCursorRipgrepPath();
150
150
  function emit(event) {
151
151
  process.stdout.write(`${JSON.stringify(event)}
152
152
  `);
153
153
  }
154
- function localAgentStore(threadId) {
154
+ function localAgentStore(Store, threadId) {
155
155
  const root = cursorSdkStoreDir(threadId);
156
156
  mkdirSync(root, { recursive: true });
157
- return new JsonlLocalAgentStore(root);
157
+ return new Store(root);
158
158
  }
159
- async function cancelStaleLocalRuns(agentId, opts) {
159
+ async function cancelStaleLocalRuns(Agent, agentId, opts) {
160
160
  const listed = await Agent.listRuns(agentId, {
161
161
  runtime: "local",
162
162
  cwd: opts.cwd,
@@ -205,13 +205,20 @@ async function main() {
205
205
  emit({ type: "stderr", data: "cursor-runner: cwd is required" });
206
206
  return 1;
207
207
  }
208
+ const sdk = await importCursorSdk();
209
+ if (!sdk) {
210
+ emit({ type: "stderr", data: CURSOR_SDK_INSTALL_HINT });
211
+ return 1;
212
+ }
213
+ const { Agent, CursorAgentError, JsonlLocalAgentStore } = sdk;
214
+ ensureCursorRipgrepPath();
208
215
  const apiKey = (req.apiKey || process.env.CURSOR_API_KEY || "").trim() || void 0;
209
216
  const model = buildCursorModelSelection(req.model, {
210
217
  effort: req.effort,
211
218
  fast: Boolean(req.fast)
212
219
  });
213
220
  const mode = req.planMode ? "plan" : "agent";
214
- const store = localAgentStore(req.threadId);
221
+ const store = localAgentStore(JsonlLocalAgentStore, req.threadId);
215
222
  const isolateSources = [];
216
223
  const local = withCursorLocalHangGuards({
217
224
  cwd: req.cwd,
@@ -262,7 +269,7 @@ async function main() {
262
269
  return await retryTransport(() => agent.send(req.prompt, sendOpts));
263
270
  } catch (err) {
264
271
  if (!isAgentBusyError(err)) throw err;
265
- const n = await cancelStaleLocalRuns(agent.agentId, {
272
+ const n = await cancelStaleLocalRuns(Agent, agent.agentId, {
266
273
  cwd: req.cwd,
267
274
  store
268
275
  });
@@ -2,6 +2,7 @@
2
2
 
3
3
  import {
4
4
  CLAUDE_MODEL_CATALOG,
5
+ CURSOR_SDK_INSTALL_HINT,
5
6
  PLAN_MODE_INSTRUCTION,
6
7
  allAdapters,
7
8
  brightsyAdapter,
@@ -28,6 +29,7 @@ import {
28
29
  installNpmGlobalPackage,
29
30
  isCursorApiKeyConfigured,
30
31
  isCursorAutoModel,
32
+ isCursorSdkInstalled,
31
33
  isSessionQuotaLimit,
32
34
  listAgentSetupInfo,
33
35
  listBrightsyChatTargets,
@@ -46,29 +48,32 @@ import {
46
48
  preferredCursorCostCents,
47
49
  prepareTerminalCommand,
48
50
  resolveCursorModelId,
51
+ resolveCursorSdkRoot,
49
52
  resolveLoginCommand,
50
53
  resolveQuotaFallbackAgent,
51
54
  turnCostUsdFromCursorUsage,
52
55
  whichOnPath
53
- } from "./chunk-6L25K7BE.js";
54
- import "./chunk-UNTOZA3C.js";
55
- import "./chunk-SXFRXNBM.js";
56
+ } from "./chunk-TXMFBL3X.js";
57
+ import "./chunk-TWXSZYR2.js";
58
+ import "./chunk-SPAMHHJH.js";
56
59
  import "./chunk-P2BSMNHB.js";
57
60
  import "./chunk-VKQGAWHY.js";
58
- import "./chunk-4CZ25DO2.js";
61
+ import "./chunk-4VFOJZPS.js";
59
62
  import "./chunk-D6JWYJ4P.js";
60
63
  import "./chunk-XJETIO4K.js";
61
64
  import "./chunk-X5B3OS5I.js";
62
- import "./chunk-SZJZEFTY.js";
65
+ import "./chunk-DD67JWTN.js";
63
66
  import {
64
67
  conductorBundledBinDir,
65
68
  enrichPathWithNpmGlobalBin,
66
69
  ensureAgentPath,
67
70
  isConductorBundledCli,
71
+ npmGlobalNodeModules,
72
+ npmGlobalPrefix,
68
73
  posixShellSingleQuote,
69
74
  resolveCommandBinarySync,
70
75
  withExportedPath
71
- } from "./chunk-ABOBTSO6.js";
76
+ } from "./chunk-2UG25RMK.js";
72
77
  import {
73
78
  ORCHESTRATOR_AGENT_KINDS,
74
79
  assertOrchestratorCapableAgent,
@@ -82,6 +87,7 @@ import "./chunk-WWUABK6B.js";
82
87
  import "./chunk-FJZWM2ON.js";
83
88
  export {
84
89
  CLAUDE_MODEL_CATALOG,
90
+ CURSOR_SDK_INSTALL_HINT,
85
91
  ORCHESTRATOR_AGENT_KINDS,
86
92
  PLAN_MODE_INSTRUCTION,
87
93
  allAdapters,
@@ -115,6 +121,7 @@ export {
115
121
  isConductorBundledCli,
116
122
  isCursorApiKeyConfigured,
117
123
  isCursorAutoModel,
124
+ isCursorSdkInstalled,
118
125
  isOrchestratorCapableAgent,
119
126
  isSessionQuotaLimit,
120
127
  listAgentSetupInfo,
@@ -125,6 +132,8 @@ export {
125
132
  listOpencodeModels,
126
133
  loginAgent,
127
134
  mcpStatusThinkingFromClaudeInit,
135
+ npmGlobalNodeModules,
136
+ npmGlobalPrefix,
128
137
  openInSystemTerminal,
129
138
  opencodeAdapter,
130
139
  parseClaudeUsagePayload,
@@ -136,6 +145,7 @@ export {
136
145
  prepareTerminalCommand,
137
146
  resolveCommandBinarySync,
138
147
  resolveCursorModelId,
148
+ resolveCursorSdkRoot,
139
149
  resolveLoginCommand,
140
150
  resolveQuotaFallbackAgent,
141
151
  turnCostUsdFromCursorUsage,
@@ -44,20 +44,23 @@ import {
44
44
  resolveLoginCommand,
45
45
  resolveQuotaFallbackAgent,
46
46
  whichOnPath
47
- } from "./chunk-FA4CPYCY.js";
48
- import "./chunk-HZFLKVGC.js";
49
- import "./chunk-N5TX66CD.js";
47
+ } from "./chunk-PZQNE5X4.js";
48
+ import "./chunk-S2OEFXST.js";
49
+ import "./chunk-7H2CVVLF.js";
50
50
  import "./chunk-6K64FJDD.js";
51
- import "./chunk-PO4M4JAJ.js";
52
- import "./chunk-ZXJMAKEP.js";
51
+ import "./chunk-2P4XKWV2.js";
52
+ import "./chunk-TNVJPFHM.js";
53
53
  import "./chunk-ROPGQRPU.js";
54
54
  import "./chunk-N7WZ6NIN.js";
55
55
  import {
56
+ CURSOR_SDK_INSTALL_HINT,
56
57
  cursorSdkMessageToEvents,
58
+ isCursorSdkInstalled,
57
59
  parseCursorRunnerLine,
58
60
  preferredCursorCostCents,
61
+ resolveCursorSdkRoot,
59
62
  turnCostUsdFromCursorUsage
60
- } from "./chunk-TQBUXKIB.js";
63
+ } from "./chunk-26T43LBM.js";
61
64
  import {
62
65
  ORCHESTRATOR_AGENT_KINDS,
63
66
  assertOrchestratorCapableAgent,
@@ -75,13 +78,16 @@ import {
75
78
  enrichPathWithNpmGlobalBin,
76
79
  ensureAgentPath,
77
80
  isConductorBundledCli,
81
+ npmGlobalNodeModules,
82
+ npmGlobalPrefix,
78
83
  posixShellSingleQuote,
79
84
  resolveCommandBinarySync,
80
85
  withExportedPath
81
- } from "./chunk-HVUVQXZ2.js";
86
+ } from "./chunk-QVN2WOKJ.js";
82
87
  import "./chunk-4TR3HZFT.js";
83
88
  export {
84
89
  CLAUDE_MODEL_CATALOG,
90
+ CURSOR_SDK_INSTALL_HINT,
85
91
  ORCHESTRATOR_AGENT_KINDS,
86
92
  PLAN_MODE_INSTRUCTION,
87
93
  allAdapters,
@@ -115,6 +121,7 @@ export {
115
121
  isConductorBundledCli,
116
122
  isCursorApiKeyConfigured,
117
123
  isCursorAutoModel,
124
+ isCursorSdkInstalled,
118
125
  isOrchestratorCapableAgent,
119
126
  isSessionQuotaLimit,
120
127
  listAgentSetupInfo,
@@ -125,6 +132,8 @@ export {
125
132
  listOpencodeModels,
126
133
  loginAgent,
127
134
  mcpStatusThinkingFromClaudeInit,
135
+ npmGlobalNodeModules,
136
+ npmGlobalPrefix,
128
137
  openInSystemTerminal,
129
138
  opencodeAdapter,
130
139
  parseClaudeUsagePayload,
@@ -136,6 +145,7 @@ export {
136
145
  prepareTerminalCommand,
137
146
  resolveCommandBinarySync,
138
147
  resolveCursorModelId,
148
+ resolveCursorSdkRoot,
139
149
  resolveLoginCommand,
140
150
  resolveQuotaFallbackAgent,
141
151
  turnCostUsdFromCursorUsage,