@sideboard-ai/core 0.1.232 → 0.1.234
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.
- package/dist/agents/cursor-runner.cjs +207 -62
- package/dist/agents/cursor-runner.js +24 -10
- package/dist/{agents-TCTEAK6M.js → agents-BTXL6R5I.js} +17 -7
- package/dist/{agents-ENAQHQRZ.js → agents-WMN7C322.js} +16 -6
- package/dist/{chunk-PO4M4JAJ.js → chunk-2P4XKWV2.js} +1 -1
- package/dist/{chunk-FA4CPYCY.js → chunk-2UBVFL2X.js} +81 -41
- package/dist/{chunk-ABOBTSO6.js → chunk-2UG25RMK.js} +18 -5
- package/dist/{chunk-4CZ25DO2.js → chunk-4VFOJZPS.js} +2 -2
- package/dist/{chunk-N5TX66CD.js → chunk-7H2CVVLF.js} +2 -2
- package/dist/{chunk-SZJZEFTY.js → chunk-DD67JWTN.js} +1 -1
- package/dist/{chunk-LLMG6OVS.js → chunk-LEYY54BN.js} +19 -19
- package/dist/{chunk-6L25K7BE.js → chunk-NOIWXANG.js} +224 -73
- package/dist/{chunk-HVUVQXZ2.js → chunk-QVN2WOKJ.js} +18 -5
- package/dist/{chunk-7BZ7DSBN.js → chunk-RKKTCKVX.js} +17 -17
- package/dist/{chunk-HZFLKVGC.js → chunk-S2OEFXST.js} +1 -1
- package/dist/{chunk-SXFRXNBM.js → chunk-SPAMHHJH.js} +1 -1
- package/dist/{chunk-ZXJMAKEP.js → chunk-TNVJPFHM.js} +5 -5
- package/dist/{chunk-UNTOZA3C.js → chunk-TWXSZYR2.js} +1 -1
- package/dist/{chunk-TQBUXKIB.js → chunk-WPD7BR6C.js} +135 -11
- package/dist/{connected-teams-PIBQTOJU.js → connected-teams-JUJAQZZE.js} +2 -2
- package/dist/{connected-teams-RVD3PFAG.js → connected-teams-KQUDU7LZ.js} +2 -2
- package/dist/{coordinator-prompt-YKLXQTWH.js → coordinator-prompt-CE7MN6QY.js} +4 -4
- package/dist/{coordinator-prompt-DFXYTM6D.js → coordinator-prompt-IGDMFKCD.js} +4 -4
- package/dist/{global-workspace-EYZKYHAO.js → global-workspace-7WH24UFO.js} +4 -4
- package/dist/{global-workspace-4SPANNJT.js → global-workspace-NCIC2Y2U.js} +4 -4
- package/dist/index.cjs +519 -326
- package/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +27 -8
- package/dist/mcp/run-stdio.cjs +447 -302
- package/dist/mcp/run-stdio.js +7 -7
- package/dist/{orchestrator-RJX4OKYC.js → orchestrator-7ZEGFPK4.js} +7 -7
- package/dist/{orchestrator-FTHJKPIX.js → orchestrator-R2WCTNJI.js} +8 -8
- package/dist/{run-UEQM4JMZ.js → run-PCX5QWR4.js} +1 -1
- package/dist/{run-QDZCTP4Y.js → run-TB7RBII2.js} +1 -1
- package/dist/{workspaces-73Y7IJY2.js → workspaces-H2TRFDE2.js} +4 -4
- package/dist/{workspaces-FQCSCTNH.js → workspaces-NSQZSDQD.js} +4 -4
- package/dist/{worktree-DOPRKG7K.js → worktree-FMIX4BRV.js} +3 -3
- package/dist/{worktree-36VEFUJN.js → worktree-W7BSI4GU.js} +3 -3
- package/dist/{worktree-exclude-K7QK4RI5.js → worktree-exclude-5N2KTYIT.js} +2 -2
- package/dist/{worktree-exclude-L32WEBX6.js → worktree-exclude-RXZPTCNH.js} +2 -2
- 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
|
|
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,190 @@ var STRIP_NESTED_ELECTRON_THEN_EXEC = [
|
|
|
46
45
|
].join("; ");
|
|
47
46
|
|
|
48
47
|
// src/agents/cursor-ripgrep.ts
|
|
49
|
-
var
|
|
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
|
|
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
|
+
function exportTarget(value) {
|
|
129
|
+
if (typeof value === "string") return value;
|
|
130
|
+
if (value && typeof value === "object") {
|
|
131
|
+
const v = value;
|
|
132
|
+
return exportTarget(v.import) ?? exportTarget(v.default);
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
function cursorSdkEsmEntry(root) {
|
|
137
|
+
try {
|
|
138
|
+
const pkg = JSON.parse((0, import_node_fs2.readFileSync)((0, import_node_path2.join)(root, "package.json"), "utf8"));
|
|
139
|
+
const exp = pkg.exports;
|
|
140
|
+
const dot = exp && typeof exp === "object" && !Array.isArray(exp) && "." in exp ? exp["."] : exp;
|
|
141
|
+
const rel = exportTarget(dot) ?? (typeof pkg.module === "string" ? pkg.module : null);
|
|
142
|
+
if (!rel) return null;
|
|
143
|
+
const entry = (0, import_node_path2.join)(root, rel);
|
|
144
|
+
return (0, import_node_fs2.existsSync)(entry) ? entry : null;
|
|
145
|
+
} catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function unwrapCursorSdkModule(mod) {
|
|
150
|
+
const m = mod;
|
|
151
|
+
if (m && !m.Agent && m.default?.Agent) return m.default;
|
|
152
|
+
return m;
|
|
153
|
+
}
|
|
154
|
+
function cursorSdkHasExpectedExports(mod) {
|
|
155
|
+
const m = mod;
|
|
156
|
+
return typeof m?.Agent === "function" && typeof m?.JsonlLocalAgentStore === "function";
|
|
157
|
+
}
|
|
158
|
+
function cursorSdkMissingExportsMessage(root) {
|
|
159
|
+
return `Cursor SDK at ${root ?? "(unknown)"} is missing expected exports (Agent, JsonlLocalAgentStore) \u2014 reinstall with \`npm i -g @cursor/sdk\`.`;
|
|
160
|
+
}
|
|
161
|
+
async function importCursorSdk(opts) {
|
|
162
|
+
const root = resolveCursorSdkRoot(opts);
|
|
163
|
+
if (!root) return null;
|
|
164
|
+
try {
|
|
165
|
+
let entry = cursorSdkEsmEntry(root);
|
|
166
|
+
if (!entry) {
|
|
167
|
+
const req = (0, import_node_module.createRequire)((0, import_node_path2.join)(root, "package.json"));
|
|
168
|
+
entry = req.resolve("@cursor/sdk");
|
|
169
|
+
}
|
|
170
|
+
return unwrapCursorSdkModule(await import((0, import_node_url.pathToFileURL)(entry).href));
|
|
171
|
+
} catch {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function cursorSdkPlatformRipgrepPackage() {
|
|
176
|
+
return `@cursor/sdk-${process.platform}-${process.arch}`;
|
|
177
|
+
}
|
|
178
|
+
function nodeModulesDirForPackageRoot(packageRoot) {
|
|
179
|
+
const parent = (0, import_node_path2.dirname)(packageRoot);
|
|
180
|
+
return (0, import_node_path2.basename)(parent).startsWith("@") ? (0, import_node_path2.dirname)(parent) : parent;
|
|
181
|
+
}
|
|
182
|
+
function cursorSdkRipgrepCandidate(opts) {
|
|
183
|
+
const root = resolveCursorSdkRoot(opts);
|
|
184
|
+
if (!root) return null;
|
|
185
|
+
const nm = nodeModulesDirForPackageRoot(root);
|
|
186
|
+
const pkg = cursorSdkPlatformRipgrepPackage();
|
|
187
|
+
const bin = process.platform === "win32" ? "rg.exe" : "rg";
|
|
188
|
+
const sibling = (0, import_node_path2.join)(nm, pkg, "bin", bin);
|
|
189
|
+
if ((0, import_node_fs2.existsSync)(sibling)) return sibling;
|
|
190
|
+
const nested = (0, import_node_path2.join)(root, "node_modules", pkg, "bin", bin);
|
|
191
|
+
return (0, import_node_fs2.existsSync)(nested) ? nested : null;
|
|
192
|
+
}
|
|
52
193
|
|
|
53
194
|
// src/agents/node-launch.ts
|
|
54
|
-
var
|
|
195
|
+
var import_node_fs11 = require("fs");
|
|
55
196
|
var import_node_os5 = require("os");
|
|
56
|
-
var
|
|
197
|
+
var import_node_path12 = require("path");
|
|
57
198
|
|
|
58
199
|
// src/http/system-ca.ts
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var
|
|
200
|
+
var import_node_child_process2 = require("child_process");
|
|
201
|
+
var import_node_fs7 = require("fs");
|
|
202
|
+
var import_node_path8 = require("path");
|
|
62
203
|
var import_node_tls = __toESM(require("tls"), 1);
|
|
63
204
|
|
|
64
205
|
// src/store/paths.ts
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
206
|
+
var import_node_path6 = require("path");
|
|
207
|
+
var import_node_os3 = require("os");
|
|
208
|
+
var import_node_path7 = require("path");
|
|
209
|
+
var import_node_fs6 = require("fs");
|
|
69
210
|
|
|
70
211
|
// src/hook/settings.ts
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
212
|
+
var import_node_fs5 = require("fs");
|
|
213
|
+
var import_node_os2 = require("os");
|
|
214
|
+
var import_node_path5 = require("path");
|
|
74
215
|
var import_smol_toml = require("smol-toml");
|
|
75
216
|
|
|
76
217
|
// src/hook/convention-setup.ts
|
|
77
|
-
var
|
|
78
|
-
var
|
|
218
|
+
var import_node_fs3 = require("fs");
|
|
219
|
+
var import_node_path3 = require("path");
|
|
79
220
|
|
|
80
221
|
// src/hook/cursor-worktrees.ts
|
|
81
|
-
var
|
|
82
|
-
var
|
|
222
|
+
var import_node_fs4 = require("fs");
|
|
223
|
+
var import_node_path4 = require("path");
|
|
83
224
|
var import_execa = require("execa");
|
|
84
225
|
var import_node_readline = require("readline");
|
|
85
226
|
|
|
86
227
|
// src/store/paths.ts
|
|
87
228
|
function appDataDir() {
|
|
88
229
|
const override = process.env.SIDEBOARD_APP_DATA?.trim();
|
|
89
|
-
const base = override ? override : process.platform === "darwin" ? (0,
|
|
90
|
-
(0,
|
|
230
|
+
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");
|
|
231
|
+
(0, import_node_fs6.mkdirSync)(base, { recursive: true });
|
|
91
232
|
return base;
|
|
92
233
|
}
|
|
93
234
|
|
|
@@ -97,24 +238,18 @@ var BUNDLE_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
|
97
238
|
// src/git/run.ts
|
|
98
239
|
var import_execa2 = require("execa");
|
|
99
240
|
|
|
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
241
|
// 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
242
|
var import_node_fs8 = require("fs");
|
|
243
|
+
var import_node_os4 = require("os");
|
|
113
244
|
var import_node_path9 = require("path");
|
|
114
245
|
|
|
115
|
-
// src/
|
|
246
|
+
// src/git/stale-lock.ts
|
|
116
247
|
var import_node_fs9 = require("fs");
|
|
117
248
|
var import_node_path10 = require("path");
|
|
249
|
+
|
|
250
|
+
// src/agents/packaged-runtime.ts
|
|
251
|
+
var import_node_fs10 = require("fs");
|
|
252
|
+
var import_node_path11 = require("path");
|
|
118
253
|
function electronResourcesPath() {
|
|
119
254
|
const resources = process.resourcesPath;
|
|
120
255
|
if (typeof resources !== "string" || !resources) return null;
|
|
@@ -123,14 +258,14 @@ function electronResourcesPath() {
|
|
|
123
258
|
function packagedCursorRuntimeDir() {
|
|
124
259
|
const resources = electronResourcesPath();
|
|
125
260
|
if (!resources) return null;
|
|
126
|
-
const dir = (0,
|
|
127
|
-
if (!(0,
|
|
261
|
+
const dir = (0, import_node_path11.join)(resources, "cursor-runtime");
|
|
262
|
+
if (!(0, import_node_fs10.existsSync)((0, import_node_path11.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
|
|
128
263
|
return dir;
|
|
129
264
|
}
|
|
130
265
|
function packagedCursorRipgrepCandidate(platformPkg, binName) {
|
|
131
266
|
const dir = packagedCursorRuntimeDir();
|
|
132
267
|
if (!dir) return null;
|
|
133
|
-
return (0,
|
|
268
|
+
return (0, import_node_path11.join)(dir, "node_modules", platformPkg, "bin", binName);
|
|
134
269
|
}
|
|
135
270
|
|
|
136
271
|
// src/agents/node-launch.ts
|
|
@@ -142,7 +277,7 @@ function unpackedAsarPath(filePath) {
|
|
|
142
277
|
if (!isAsarPath(filePath)) return null;
|
|
143
278
|
const unpacked = filePath.replace(/\.asar(?=[/\\])/, ".asar.unpacked");
|
|
144
279
|
if (unpacked === filePath) return null;
|
|
145
|
-
return (0,
|
|
280
|
+
return (0, import_node_fs11.existsSync)(unpacked) ? unpacked : null;
|
|
146
281
|
}
|
|
147
282
|
function nodeReadableScriptPath(scriptPath) {
|
|
148
283
|
return unpackedAsarPath(scriptPath) ?? scriptPath;
|
|
@@ -158,21 +293,21 @@ function platformRipgrepPackage() {
|
|
|
158
293
|
}
|
|
159
294
|
function usableRipgrepPath(candidate) {
|
|
160
295
|
const raw = candidate?.trim();
|
|
161
|
-
if (!raw || !(0,
|
|
296
|
+
if (!raw || !(0, import_node_path13.isAbsolute)(raw)) return null;
|
|
162
297
|
const readable = nodeReadableScriptPath(raw);
|
|
163
|
-
if (!(0,
|
|
298
|
+
if (!(0, import_node_fs12.existsSync)(readable) || isAsarPath(readable)) return null;
|
|
164
299
|
return readable;
|
|
165
300
|
}
|
|
166
301
|
function walkForBundledRipgrep(startFile) {
|
|
167
302
|
if (!startFile) return null;
|
|
168
303
|
const pkg = platformRipgrepPackage();
|
|
169
304
|
const name = rgBinaryName();
|
|
170
|
-
let dir = (0,
|
|
171
|
-
const root = (0,
|
|
305
|
+
let dir = (0, import_node_path13.dirname)((0, import_node_path13.resolve)(startFile));
|
|
306
|
+
const root = (0, import_node_path13.parse)(dir).root;
|
|
172
307
|
while (dir !== root) {
|
|
173
|
-
const hit = usableRipgrepPath((0,
|
|
308
|
+
const hit = usableRipgrepPath((0, import_node_path13.join)(dir, "node_modules", pkg, "bin", name));
|
|
174
309
|
if (hit) return hit;
|
|
175
|
-
const next = (0,
|
|
310
|
+
const next = (0, import_node_path13.dirname)(dir);
|
|
176
311
|
if (next === dir) break;
|
|
177
312
|
dir = next;
|
|
178
313
|
}
|
|
@@ -180,9 +315,9 @@ function walkForBundledRipgrep(startFile) {
|
|
|
180
315
|
}
|
|
181
316
|
function requireResolveBundledRipgrep(fromFile) {
|
|
182
317
|
try {
|
|
183
|
-
const req = (0,
|
|
318
|
+
const req = (0, import_node_module2.createRequire)(fromFile);
|
|
184
319
|
const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
|
|
185
|
-
return usableRipgrepPath((0,
|
|
320
|
+
return usableRipgrepPath((0, import_node_path13.join)((0, import_node_path13.dirname)(pkgJson), "bin", rgBinaryName()));
|
|
186
321
|
} catch {
|
|
187
322
|
return null;
|
|
188
323
|
}
|
|
@@ -198,7 +333,7 @@ function resolveCursorRipgrepPath(opts) {
|
|
|
198
333
|
const start = opts?.startFile?.trim() || process.argv[1] || // CJS bundle only — ESM has no __filename; argv[1] is the running script.
|
|
199
334
|
// eslint-disable-next-line camelcase
|
|
200
335
|
(typeof __filename !== "undefined" ? __filename : "");
|
|
201
|
-
return walkForBundledRipgrep(start) ?? requireResolveBundledRipgrep(start);
|
|
336
|
+
return walkForBundledRipgrep(start) ?? usableRipgrepPath(cursorSdkRipgrepCandidate({ env })) ?? requireResolveBundledRipgrep(start);
|
|
202
337
|
}
|
|
203
338
|
function ensureCursorRipgrepPath(opts) {
|
|
204
339
|
const target = opts?.env ?? process.env;
|
|
@@ -208,13 +343,13 @@ function ensureCursorRipgrepPath(opts) {
|
|
|
208
343
|
}
|
|
209
344
|
|
|
210
345
|
// src/agents/cursor-store.ts
|
|
211
|
-
var
|
|
346
|
+
var import_node_path14 = require("path");
|
|
212
347
|
var CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
|
|
213
348
|
function cursorSdkStoreDir(threadId) {
|
|
214
|
-
const root = (0,
|
|
349
|
+
const root = (0, import_node_path14.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
|
|
215
350
|
const id = sanitizeCursorStoreSegment(threadId);
|
|
216
351
|
if (!id) return root;
|
|
217
|
-
return (0,
|
|
352
|
+
return (0, import_node_path14.join)(root, "threads", id);
|
|
218
353
|
}
|
|
219
354
|
function sanitizeCursorStoreSegment(threadId) {
|
|
220
355
|
return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
@@ -738,18 +873,17 @@ function createAgentStreamCoalescer(emit2, opts) {
|
|
|
738
873
|
|
|
739
874
|
// src/agents/cursor-runner.ts
|
|
740
875
|
dropNestedElectronEnvFromProcess();
|
|
741
|
-
ensureCursorRipgrepPath();
|
|
742
876
|
function emit(event) {
|
|
743
877
|
process.stdout.write(`${JSON.stringify(event)}
|
|
744
878
|
`);
|
|
745
879
|
}
|
|
746
|
-
function localAgentStore(threadId) {
|
|
880
|
+
function localAgentStore(Store, threadId) {
|
|
747
881
|
const root = cursorSdkStoreDir(threadId);
|
|
748
|
-
(0,
|
|
749
|
-
return new
|
|
882
|
+
(0, import_node_fs13.mkdirSync)(root, { recursive: true });
|
|
883
|
+
return new Store(root);
|
|
750
884
|
}
|
|
751
|
-
async function cancelStaleLocalRuns(agentId, opts) {
|
|
752
|
-
const listed = await
|
|
885
|
+
async function cancelStaleLocalRuns(Agent, agentId, opts) {
|
|
886
|
+
const listed = await Agent.listRuns(agentId, {
|
|
753
887
|
runtime: "local",
|
|
754
888
|
cwd: opts.cwd,
|
|
755
889
|
store: opts.store,
|
|
@@ -759,7 +893,7 @@ async function cancelStaleLocalRuns(agentId, opts) {
|
|
|
759
893
|
for (const run2 of listed.items) {
|
|
760
894
|
if (run2.status !== "running") continue;
|
|
761
895
|
try {
|
|
762
|
-
await
|
|
896
|
+
await Agent.cancelRun(run2.id, {
|
|
763
897
|
runtime: "local",
|
|
764
898
|
cwd: opts.cwd,
|
|
765
899
|
store: opts.store
|
|
@@ -797,13 +931,24 @@ async function main() {
|
|
|
797
931
|
emit({ type: "stderr", data: "cursor-runner: cwd is required" });
|
|
798
932
|
return 1;
|
|
799
933
|
}
|
|
934
|
+
const sdk = await importCursorSdk();
|
|
935
|
+
if (!sdk) {
|
|
936
|
+
emit({ type: "stderr", data: CURSOR_SDK_INSTALL_HINT });
|
|
937
|
+
return 1;
|
|
938
|
+
}
|
|
939
|
+
if (!cursorSdkHasExpectedExports(sdk)) {
|
|
940
|
+
emit({ type: "stderr", data: cursorSdkMissingExportsMessage(resolveCursorSdkRoot()) });
|
|
941
|
+
return 1;
|
|
942
|
+
}
|
|
943
|
+
const { Agent, CursorAgentError, JsonlLocalAgentStore } = sdk;
|
|
944
|
+
ensureCursorRipgrepPath();
|
|
800
945
|
const apiKey = (req.apiKey || process.env.CURSOR_API_KEY || "").trim() || void 0;
|
|
801
946
|
const model = buildCursorModelSelection(req.model, {
|
|
802
947
|
effort: req.effort,
|
|
803
948
|
fast: Boolean(req.fast)
|
|
804
949
|
});
|
|
805
950
|
const mode = req.planMode ? "plan" : "agent";
|
|
806
|
-
const store = localAgentStore(req.threadId);
|
|
951
|
+
const store = localAgentStore(JsonlLocalAgentStore, req.threadId);
|
|
807
952
|
const isolateSources = [];
|
|
808
953
|
const local = withCursorLocalHangGuards({
|
|
809
954
|
cwd: req.cwd,
|
|
@@ -823,12 +968,12 @@ async function main() {
|
|
|
823
968
|
emit({ type: "stderr", data: cursorRetryableTransportMessage(err) });
|
|
824
969
|
});
|
|
825
970
|
async function createAgent() {
|
|
826
|
-
return retryTransport(() =>
|
|
971
|
+
return retryTransport(() => Agent.create(createOpts));
|
|
827
972
|
}
|
|
828
973
|
async function openAgent() {
|
|
829
974
|
try {
|
|
830
975
|
return req.agentId ? await retryTransport(
|
|
831
|
-
() =>
|
|
976
|
+
() => Agent.resume(req.agentId, {
|
|
832
977
|
apiKey,
|
|
833
978
|
model,
|
|
834
979
|
mode,
|
|
@@ -854,7 +999,7 @@ async function main() {
|
|
|
854
999
|
return await retryTransport(() => agent.send(req.prompt, sendOpts));
|
|
855
1000
|
} catch (err) {
|
|
856
1001
|
if (!isAgentBusyError(err)) throw err;
|
|
857
|
-
const n = await cancelStaleLocalRuns(agent.agentId, {
|
|
1002
|
+
const n = await cancelStaleLocalRuns(Agent, agent.agentId, {
|
|
858
1003
|
cwd: req.cwd,
|
|
859
1004
|
store
|
|
860
1005
|
});
|
|
@@ -986,7 +1131,7 @@ async function main() {
|
|
|
986
1131
|
await agent[Symbol.asyncDispose]().catch(() => void 0);
|
|
987
1132
|
}
|
|
988
1133
|
} catch (err) {
|
|
989
|
-
if (err instanceof
|
|
1134
|
+
if (err instanceof CursorAgentError) {
|
|
990
1135
|
emit({
|
|
991
1136
|
type: "stderr",
|
|
992
1137
|
data: `Cursor startup failed: ${err.message}${err.isRetryable ? " (retryable)" : ""}`
|
|
@@ -3,25 +3,29 @@ import {
|
|
|
3
3
|
createAgentStreamCoalescer
|
|
4
4
|
} from "../chunk-AXQ4ZWHK.js";
|
|
5
5
|
import {
|
|
6
|
+
CURSOR_SDK_INSTALL_HINT,
|
|
6
7
|
cursorCostOnlyUsageEvent,
|
|
7
8
|
cursorDeltaToEvents,
|
|
9
|
+
cursorSdkHasExpectedExports,
|
|
8
10
|
cursorSdkMessageToEvents,
|
|
11
|
+
cursorSdkMissingExportsMessage,
|
|
9
12
|
ensureCursorRipgrepPath,
|
|
10
13
|
fetchCursorTurnCostUsd,
|
|
11
14
|
formatUnknownDetail,
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
importCursorSdk,
|
|
16
|
+
looksLikeCursorHttp2StreamClose,
|
|
17
|
+
resolveCursorSdkRoot
|
|
18
|
+
} from "../chunk-WPD7BR6C.js";
|
|
14
19
|
import {
|
|
15
20
|
cursorSdkStoreDir
|
|
16
21
|
} from "../chunk-7J72QJOM.js";
|
|
17
22
|
import "../chunk-WFUDY6PC.js";
|
|
18
|
-
import "../chunk-
|
|
23
|
+
import "../chunk-QVN2WOKJ.js";
|
|
19
24
|
import {
|
|
20
25
|
dropNestedElectronEnvFromProcess
|
|
21
26
|
} from "../chunk-4TR3HZFT.js";
|
|
22
27
|
|
|
23
28
|
// src/agents/cursor-runner.ts
|
|
24
|
-
import { Agent, CursorAgentError, JsonlLocalAgentStore } from "@cursor/sdk";
|
|
25
29
|
import { mkdirSync } from "fs";
|
|
26
30
|
import { createInterface } from "readline";
|
|
27
31
|
|
|
@@ -146,17 +150,16 @@ function buildCursorModelSelection(model, opts) {
|
|
|
146
150
|
|
|
147
151
|
// src/agents/cursor-runner.ts
|
|
148
152
|
dropNestedElectronEnvFromProcess();
|
|
149
|
-
ensureCursorRipgrepPath();
|
|
150
153
|
function emit(event) {
|
|
151
154
|
process.stdout.write(`${JSON.stringify(event)}
|
|
152
155
|
`);
|
|
153
156
|
}
|
|
154
|
-
function localAgentStore(threadId) {
|
|
157
|
+
function localAgentStore(Store, threadId) {
|
|
155
158
|
const root = cursorSdkStoreDir(threadId);
|
|
156
159
|
mkdirSync(root, { recursive: true });
|
|
157
|
-
return new
|
|
160
|
+
return new Store(root);
|
|
158
161
|
}
|
|
159
|
-
async function cancelStaleLocalRuns(agentId, opts) {
|
|
162
|
+
async function cancelStaleLocalRuns(Agent, agentId, opts) {
|
|
160
163
|
const listed = await Agent.listRuns(agentId, {
|
|
161
164
|
runtime: "local",
|
|
162
165
|
cwd: opts.cwd,
|
|
@@ -205,13 +208,24 @@ async function main() {
|
|
|
205
208
|
emit({ type: "stderr", data: "cursor-runner: cwd is required" });
|
|
206
209
|
return 1;
|
|
207
210
|
}
|
|
211
|
+
const sdk = await importCursorSdk();
|
|
212
|
+
if (!sdk) {
|
|
213
|
+
emit({ type: "stderr", data: CURSOR_SDK_INSTALL_HINT });
|
|
214
|
+
return 1;
|
|
215
|
+
}
|
|
216
|
+
if (!cursorSdkHasExpectedExports(sdk)) {
|
|
217
|
+
emit({ type: "stderr", data: cursorSdkMissingExportsMessage(resolveCursorSdkRoot()) });
|
|
218
|
+
return 1;
|
|
219
|
+
}
|
|
220
|
+
const { Agent, CursorAgentError, JsonlLocalAgentStore } = sdk;
|
|
221
|
+
ensureCursorRipgrepPath();
|
|
208
222
|
const apiKey = (req.apiKey || process.env.CURSOR_API_KEY || "").trim() || void 0;
|
|
209
223
|
const model = buildCursorModelSelection(req.model, {
|
|
210
224
|
effort: req.effort,
|
|
211
225
|
fast: Boolean(req.fast)
|
|
212
226
|
});
|
|
213
227
|
const mode = req.planMode ? "plan" : "agent";
|
|
214
|
-
const store = localAgentStore(req.threadId);
|
|
228
|
+
const store = localAgentStore(JsonlLocalAgentStore, req.threadId);
|
|
215
229
|
const isolateSources = [];
|
|
216
230
|
const local = withCursorLocalHangGuards({
|
|
217
231
|
cwd: req.cwd,
|
|
@@ -262,7 +276,7 @@ async function main() {
|
|
|
262
276
|
return await retryTransport(() => agent.send(req.prompt, sendOpts));
|
|
263
277
|
} catch (err) {
|
|
264
278
|
if (!isAgentBusyError(err)) throw err;
|
|
265
|
-
const n = await cancelStaleLocalRuns(agent.agentId, {
|
|
279
|
+
const n = await cancelStaleLocalRuns(Agent, agent.agentId, {
|
|
266
280
|
cwd: req.cwd,
|
|
267
281
|
store
|
|
268
282
|
});
|
|
@@ -44,20 +44,23 @@ import {
|
|
|
44
44
|
resolveLoginCommand,
|
|
45
45
|
resolveQuotaFallbackAgent,
|
|
46
46
|
whichOnPath
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import "./chunk-
|
|
49
|
-
import "./chunk-
|
|
47
|
+
} from "./chunk-2UBVFL2X.js";
|
|
48
|
+
import "./chunk-S2OEFXST.js";
|
|
49
|
+
import "./chunk-7H2CVVLF.js";
|
|
50
50
|
import "./chunk-6K64FJDD.js";
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-
|
|
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-
|
|
63
|
+
} from "./chunk-WPD7BR6C.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-
|
|
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,
|
|
@@ -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-
|
|
54
|
-
import "./chunk-
|
|
55
|
-
import "./chunk-
|
|
56
|
+
} from "./chunk-NOIWXANG.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-
|
|
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-
|
|
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-
|
|
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,
|