@sideboard-ai/core 0.1.81 → 0.1.84
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 +106 -53
- package/dist/agents/cursor-runner.js +96 -55
- package/dist/{agents-UQ7D6U6L.js → agents-JFXM66QA.js} +7 -6
- package/dist/{agents-EBKJ55PN.js → agents-OPTHS4IX.js} +5 -5
- package/dist/{app-settings-6IOQYGBK.js → app-settings-K6RFCRF6.js} +2 -1
- package/dist/{app-settings-NILNWNNQ.js → app-settings-PEXK5VEX.js} +1 -1
- package/dist/chunk-5KLC2MWZ.js +40 -0
- package/dist/{chunk-XKNBSYA7.js → chunk-AY53MPDE.js} +39 -1
- package/dist/{chunk-4AVU4QXO.js → chunk-BBQ6HXKS.js} +67 -17
- package/dist/{chunk-SEOICVGB.js → chunk-CBJSPTBG.js} +30 -6
- package/dist/{chunk-FUUVPN4A.js → chunk-CKBIQ54F.js} +78 -49
- package/dist/{chunk-IFPN6TER.js → chunk-I3FRXL7J.js} +4 -1
- package/dist/{chunk-CQBQWX73.js → chunk-JPHG2KCC.js} +8 -3
- package/dist/{chunk-4HJK57XU.js → chunk-NW7MEJHO.js} +8 -3
- package/dist/{chunk-K553XK7M.js → chunk-ODZ2ZOA4.js} +2 -2
- package/dist/{chunk-6F2TQFJE.js → chunk-OIEFHOP7.js} +3 -3
- package/dist/{chunk-XNECBC6T.js → chunk-R753UFSX.js} +39 -11
- package/dist/{chunk-TDJ43HUD.js → chunk-UN3LVQB2.js} +2 -2
- package/dist/{chunk-P5VDPGAN.js → chunk-WJ5TINR6.js} +3 -3
- package/dist/{chunk-YVVXWWCC.js → chunk-XW47PL6A.js} +81 -49
- package/dist/{coordinator-prompt-NYNEFKIV.js → coordinator-prompt-DOIOSLUN.js} +3 -3
- package/dist/{coordinator-prompt-JQF72JKX.js → coordinator-prompt-RCTIIZ6C.js} +4 -3
- package/dist/{global-workspace-NUMUJRWG.js → global-workspace-33BIG7KK.js} +4 -4
- package/dist/{global-workspace-DZM4ZFGU.js → global-workspace-73OAKD3C.js} +5 -4
- package/dist/index.cjs +235 -88
- package/dist/index.d.cts +36 -9
- package/dist/index.d.ts +36 -9
- package/dist/index.js +69 -45
- package/dist/mcp/run-stdio.cjs +233 -88
- package/dist/mcp/run-stdio.js +60 -43
- package/dist/{workspaces-QLRCOXAY.js → workspaces-SRITISKA.js} +6 -5
- package/dist/{workspaces-SUU2GO3A.js → workspaces-WDLY34MX.js} +5 -5
- package/dist/{worktree-5VLLFI5W.js → worktree-SGZVAWOQ.js} +3 -2
- package/dist/{worktree-UNSOCYZU.js → worktree-TUAO74SI.js} +2 -2
- package/package.json +1 -1
|
@@ -7,6 +7,23 @@ var import_node_fs3 = require("fs");
|
|
|
7
7
|
var import_node_path4 = require("path");
|
|
8
8
|
var import_node_readline = require("readline");
|
|
9
9
|
|
|
10
|
+
// src/hook/nested-electron-env.ts
|
|
11
|
+
var NESTED_ELECTRON_ENV_PREFIXES = ["ELECTRON_", "CHROME_"];
|
|
12
|
+
function isNestedElectronEnvKey(key) {
|
|
13
|
+
return NESTED_ELECTRON_ENV_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
14
|
+
}
|
|
15
|
+
function dropNestedElectronEnvFromProcess(env = process.env) {
|
|
16
|
+
for (const key of Object.keys(env)) {
|
|
17
|
+
if (isNestedElectronEnvKey(key)) delete env[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
var STRIP_NESTED_ELECTRON_THEN_EXEC = [
|
|
21
|
+
"vars=`printenv | awk -F= '/^(ELECTRON_|CHROME_)/{print $1}'`",
|
|
22
|
+
'[ -n "$vars" ] && unset $vars',
|
|
23
|
+
"export ELECTRON_RUN_AS_NODE=1",
|
|
24
|
+
'exec "$@"'
|
|
25
|
+
].join("; ");
|
|
26
|
+
|
|
10
27
|
// src/store/paths.ts
|
|
11
28
|
var import_node_path2 = require("path");
|
|
12
29
|
var import_node_os2 = require("os");
|
|
@@ -27,6 +44,32 @@ function appDataDir() {
|
|
|
27
44
|
return base;
|
|
28
45
|
}
|
|
29
46
|
|
|
47
|
+
// src/agents/cursor-session.ts
|
|
48
|
+
function cursorErrorMessage(err) {
|
|
49
|
+
if (err instanceof Error) return err.message.trim();
|
|
50
|
+
return String(err).trim();
|
|
51
|
+
}
|
|
52
|
+
function isAgentBusyError(err) {
|
|
53
|
+
const name = err instanceof Error ? err.name : "";
|
|
54
|
+
if (name === "AgentBusyError") return true;
|
|
55
|
+
return /already has active run/i.test(cursorErrorMessage(err));
|
|
56
|
+
}
|
|
57
|
+
function isUnresumableCursorSession(err) {
|
|
58
|
+
const name = err instanceof Error ? err.name : "";
|
|
59
|
+
if (name === "AgentNotFoundError") return true;
|
|
60
|
+
const lower = cursorErrorMessage(err).toLowerCase();
|
|
61
|
+
if (!lower) return false;
|
|
62
|
+
return /corrupt local agent checkpoint/.test(lower) || /missing root blob/.test(lower) || /\bagent\b.{0,120}\bnot found\b/.test(lower) || /cannot resume/.test(lower);
|
|
63
|
+
}
|
|
64
|
+
function cursorSessionRecoveryMessage(err, agentId) {
|
|
65
|
+
const detail = cursorErrorMessage(err) || "unresumable session";
|
|
66
|
+
const id = (agentId ?? "").trim();
|
|
67
|
+
if (id) {
|
|
68
|
+
return `Cursor agent ${id} is unresumable (${detail}) \u2014 starting a new session`;
|
|
69
|
+
}
|
|
70
|
+
return `Cursor session is unresumable (${detail}) \u2014 starting a new session`;
|
|
71
|
+
}
|
|
72
|
+
|
|
30
73
|
// src/agents/error-detail.ts
|
|
31
74
|
function formatUnknownDetail(err) {
|
|
32
75
|
if (err == null) return "";
|
|
@@ -224,6 +267,7 @@ function cursorSdkMessageToEvents(msg) {
|
|
|
224
267
|
}
|
|
225
268
|
|
|
226
269
|
// src/agents/cursor-runner.ts
|
|
270
|
+
dropNestedElectronEnvFromProcess();
|
|
227
271
|
function emit(event) {
|
|
228
272
|
process.stdout.write(`${JSON.stringify(event)}
|
|
229
273
|
`);
|
|
@@ -247,11 +291,6 @@ function localAgentStore() {
|
|
|
247
291
|
(0, import_node_fs3.mkdirSync)(root, { recursive: true });
|
|
248
292
|
return new import_sdk.JsonlLocalAgentStore(root);
|
|
249
293
|
}
|
|
250
|
-
function isAgentBusyError(err) {
|
|
251
|
-
if (err instanceof import_sdk.AgentBusyError) return true;
|
|
252
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
253
|
-
return /already has active run/i.test(message);
|
|
254
|
-
}
|
|
255
294
|
async function cancelStaleLocalRuns(agentId, opts) {
|
|
256
295
|
const listed = await import_sdk.Agent.listRuns(agentId, {
|
|
257
296
|
runtime: "local",
|
|
@@ -310,75 +349,89 @@ async function main() {
|
|
|
310
349
|
const store = localAgentStore();
|
|
311
350
|
const local = { cwd: req.cwd, store };
|
|
312
351
|
const mcpServers = req.mcpServers && Object.keys(req.mcpServers).length > 0 ? req.mcpServers : void 0;
|
|
313
|
-
|
|
314
|
-
|
|
352
|
+
const createOpts = {
|
|
353
|
+
apiKey,
|
|
354
|
+
model,
|
|
355
|
+
mode,
|
|
356
|
+
local,
|
|
357
|
+
name: "Sideboard",
|
|
358
|
+
...mcpServers ? { mcpServers } : {}
|
|
359
|
+
};
|
|
360
|
+
async function createAgent() {
|
|
361
|
+
return import_sdk.Agent.create(createOpts);
|
|
362
|
+
}
|
|
363
|
+
async function openAgent() {
|
|
315
364
|
try {
|
|
316
|
-
|
|
317
|
-
apiKey,
|
|
318
|
-
model,
|
|
319
|
-
mode,
|
|
320
|
-
local,
|
|
321
|
-
...mcpServers ? { mcpServers } : {}
|
|
322
|
-
}) : await import_sdk.Agent.create({
|
|
365
|
+
return req.agentId ? await import_sdk.Agent.resume(req.agentId, {
|
|
323
366
|
apiKey,
|
|
324
367
|
model,
|
|
325
368
|
mode,
|
|
326
369
|
local,
|
|
327
|
-
name: "Sideboard",
|
|
328
370
|
...mcpServers ? { mcpServers } : {}
|
|
371
|
+
}) : await createAgent();
|
|
372
|
+
} catch (err) {
|
|
373
|
+
if (!isUnresumableCursorSession(err)) throw err;
|
|
374
|
+
emit({
|
|
375
|
+
type: "stderr",
|
|
376
|
+
data: cursorSessionRecoveryMessage(err, req.agentId)
|
|
329
377
|
});
|
|
378
|
+
return createAgent();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
async function sendPrompt(agent) {
|
|
382
|
+
const sendOpts = mcpServers ? { mcpServers } : void 0;
|
|
383
|
+
try {
|
|
384
|
+
return await agent.send(req.prompt, sendOpts);
|
|
330
385
|
} catch (err) {
|
|
331
|
-
|
|
332
|
-
|
|
386
|
+
if (!isAgentBusyError(err)) throw err;
|
|
387
|
+
const n = await cancelStaleLocalRuns(agent.agentId, {
|
|
388
|
+
cwd: req.cwd,
|
|
389
|
+
store
|
|
390
|
+
});
|
|
333
391
|
emit({
|
|
334
392
|
type: "stderr",
|
|
335
|
-
data: `Cursor agent ${
|
|
393
|
+
data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
|
|
336
394
|
});
|
|
337
|
-
agent
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
395
|
+
return agent.send(req.prompt, sendOpts);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
async function runTurn(agent) {
|
|
399
|
+
emit({ type: "session_id", data: agent.agentId });
|
|
400
|
+
const run = await sendPrompt(agent);
|
|
401
|
+
for await (const msg of run.stream()) {
|
|
402
|
+
for (const event of cursorSdkMessageToEvents(msg)) {
|
|
403
|
+
emit(event);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const result = await run.wait();
|
|
407
|
+
if (result.status === "error") {
|
|
408
|
+
const detail = formatUnknownDetail(result.error);
|
|
409
|
+
emit({
|
|
410
|
+
type: "stderr",
|
|
411
|
+
data: detail ? `Cursor run failed (${result.id}): ${detail}` : `Cursor run failed (${result.id})`
|
|
344
412
|
});
|
|
413
|
+
return 2;
|
|
345
414
|
}
|
|
415
|
+
if (result.status === "cancelled") return 0;
|
|
416
|
+
return 0;
|
|
417
|
+
}
|
|
418
|
+
try {
|
|
419
|
+
let agent = await openAgent();
|
|
346
420
|
try {
|
|
347
|
-
emit({ type: "session_id", data: agent.agentId });
|
|
348
|
-
const sendOpts = mcpServers ? { mcpServers } : void 0;
|
|
349
|
-
let run;
|
|
350
421
|
try {
|
|
351
|
-
|
|
422
|
+
return await runTurn(agent);
|
|
352
423
|
} catch (err) {
|
|
353
|
-
if (!
|
|
354
|
-
const n = await cancelStaleLocalRuns(agent.agentId, {
|
|
355
|
-
cwd: req.cwd,
|
|
356
|
-
store
|
|
357
|
-
});
|
|
358
|
-
emit({
|
|
359
|
-
type: "stderr",
|
|
360
|
-
data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
|
|
361
|
-
});
|
|
362
|
-
run = await agent.send(req.prompt, sendOpts);
|
|
363
|
-
}
|
|
364
|
-
for await (const msg of run.stream()) {
|
|
365
|
-
for (const event of cursorSdkMessageToEvents(msg)) {
|
|
366
|
-
emit(event);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
const result = await run.wait();
|
|
370
|
-
if (result.status === "error") {
|
|
371
|
-
const detail = formatUnknownDetail(result.error);
|
|
424
|
+
if (!isUnresumableCursorSession(err)) throw err;
|
|
372
425
|
emit({
|
|
373
426
|
type: "stderr",
|
|
374
|
-
data:
|
|
427
|
+
data: cursorSessionRecoveryMessage(err, agent.agentId)
|
|
375
428
|
});
|
|
376
|
-
|
|
429
|
+
await agent[Symbol.asyncDispose]().catch(() => void 0);
|
|
430
|
+
agent = await createAgent();
|
|
431
|
+
return await runTurn(agent);
|
|
377
432
|
}
|
|
378
|
-
if (result.status === "cancelled") return 0;
|
|
379
|
-
return 0;
|
|
380
433
|
} finally {
|
|
381
|
-
await agent[Symbol.asyncDispose]();
|
|
434
|
+
await agent[Symbol.asyncDispose]().catch(() => void 0);
|
|
382
435
|
}
|
|
383
436
|
} catch (err) {
|
|
384
437
|
if (err instanceof import_sdk.CursorAgentError) {
|
|
@@ -2,16 +2,48 @@
|
|
|
2
2
|
import {
|
|
3
3
|
cursorSdkMessageToEvents,
|
|
4
4
|
formatUnknownDetail
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-CBJSPTBG.js";
|
|
6
|
+
import {
|
|
7
|
+
dropNestedElectronEnvFromProcess
|
|
8
|
+
} from "../chunk-5KLC2MWZ.js";
|
|
6
9
|
import {
|
|
7
10
|
appDataDir
|
|
8
11
|
} from "../chunk-M37RITA6.js";
|
|
9
12
|
|
|
10
13
|
// src/agents/cursor-runner.ts
|
|
11
|
-
import { Agent,
|
|
14
|
+
import { Agent, CursorAgentError, JsonlLocalAgentStore } from "@cursor/sdk";
|
|
12
15
|
import { mkdirSync } from "fs";
|
|
13
16
|
import { join } from "path";
|
|
14
17
|
import { createInterface } from "readline";
|
|
18
|
+
|
|
19
|
+
// src/agents/cursor-session.ts
|
|
20
|
+
function cursorErrorMessage(err) {
|
|
21
|
+
if (err instanceof Error) return err.message.trim();
|
|
22
|
+
return String(err).trim();
|
|
23
|
+
}
|
|
24
|
+
function isAgentBusyError(err) {
|
|
25
|
+
const name = err instanceof Error ? err.name : "";
|
|
26
|
+
if (name === "AgentBusyError") return true;
|
|
27
|
+
return /already has active run/i.test(cursorErrorMessage(err));
|
|
28
|
+
}
|
|
29
|
+
function isUnresumableCursorSession(err) {
|
|
30
|
+
const name = err instanceof Error ? err.name : "";
|
|
31
|
+
if (name === "AgentNotFoundError") return true;
|
|
32
|
+
const lower = cursorErrorMessage(err).toLowerCase();
|
|
33
|
+
if (!lower) return false;
|
|
34
|
+
return /corrupt local agent checkpoint/.test(lower) || /missing root blob/.test(lower) || /\bagent\b.{0,120}\bnot found\b/.test(lower) || /cannot resume/.test(lower);
|
|
35
|
+
}
|
|
36
|
+
function cursorSessionRecoveryMessage(err, agentId) {
|
|
37
|
+
const detail = cursorErrorMessage(err) || "unresumable session";
|
|
38
|
+
const id = (agentId ?? "").trim();
|
|
39
|
+
if (id) {
|
|
40
|
+
return `Cursor agent ${id} is unresumable (${detail}) \u2014 starting a new session`;
|
|
41
|
+
}
|
|
42
|
+
return `Cursor session is unresumable (${detail}) \u2014 starting a new session`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/agents/cursor-runner.ts
|
|
46
|
+
dropNestedElectronEnvFromProcess();
|
|
15
47
|
function emit(event) {
|
|
16
48
|
process.stdout.write(`${JSON.stringify(event)}
|
|
17
49
|
`);
|
|
@@ -35,11 +67,6 @@ function localAgentStore() {
|
|
|
35
67
|
mkdirSync(root, { recursive: true });
|
|
36
68
|
return new JsonlLocalAgentStore(root);
|
|
37
69
|
}
|
|
38
|
-
function isAgentBusyError(err) {
|
|
39
|
-
if (err instanceof AgentBusyError) return true;
|
|
40
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
41
|
-
return /already has active run/i.test(message);
|
|
42
|
-
}
|
|
43
70
|
async function cancelStaleLocalRuns(agentId, opts) {
|
|
44
71
|
const listed = await Agent.listRuns(agentId, {
|
|
45
72
|
runtime: "local",
|
|
@@ -98,75 +125,89 @@ async function main() {
|
|
|
98
125
|
const store = localAgentStore();
|
|
99
126
|
const local = { cwd: req.cwd, store };
|
|
100
127
|
const mcpServers = req.mcpServers && Object.keys(req.mcpServers).length > 0 ? req.mcpServers : void 0;
|
|
101
|
-
|
|
102
|
-
|
|
128
|
+
const createOpts = {
|
|
129
|
+
apiKey,
|
|
130
|
+
model,
|
|
131
|
+
mode,
|
|
132
|
+
local,
|
|
133
|
+
name: "Sideboard",
|
|
134
|
+
...mcpServers ? { mcpServers } : {}
|
|
135
|
+
};
|
|
136
|
+
async function createAgent() {
|
|
137
|
+
return Agent.create(createOpts);
|
|
138
|
+
}
|
|
139
|
+
async function openAgent() {
|
|
103
140
|
try {
|
|
104
|
-
|
|
141
|
+
return req.agentId ? await Agent.resume(req.agentId, {
|
|
105
142
|
apiKey,
|
|
106
143
|
model,
|
|
107
144
|
mode,
|
|
108
145
|
local,
|
|
109
146
|
...mcpServers ? { mcpServers } : {}
|
|
110
|
-
}) : await
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
...mcpServers ? { mcpServers } : {}
|
|
147
|
+
}) : await createAgent();
|
|
148
|
+
} catch (err) {
|
|
149
|
+
if (!isUnresumableCursorSession(err)) throw err;
|
|
150
|
+
emit({
|
|
151
|
+
type: "stderr",
|
|
152
|
+
data: cursorSessionRecoveryMessage(err, req.agentId)
|
|
117
153
|
});
|
|
154
|
+
return createAgent();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function sendPrompt(agent) {
|
|
158
|
+
const sendOpts = mcpServers ? { mcpServers } : void 0;
|
|
159
|
+
try {
|
|
160
|
+
return await agent.send(req.prompt, sendOpts);
|
|
118
161
|
} catch (err) {
|
|
119
|
-
|
|
120
|
-
|
|
162
|
+
if (!isAgentBusyError(err)) throw err;
|
|
163
|
+
const n = await cancelStaleLocalRuns(agent.agentId, {
|
|
164
|
+
cwd: req.cwd,
|
|
165
|
+
store
|
|
166
|
+
});
|
|
121
167
|
emit({
|
|
122
168
|
type: "stderr",
|
|
123
|
-
data: `Cursor agent ${
|
|
169
|
+
data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
|
|
124
170
|
});
|
|
125
|
-
agent
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
171
|
+
return agent.send(req.prompt, sendOpts);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async function runTurn(agent) {
|
|
175
|
+
emit({ type: "session_id", data: agent.agentId });
|
|
176
|
+
const run = await sendPrompt(agent);
|
|
177
|
+
for await (const msg of run.stream()) {
|
|
178
|
+
for (const event of cursorSdkMessageToEvents(msg)) {
|
|
179
|
+
emit(event);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const result = await run.wait();
|
|
183
|
+
if (result.status === "error") {
|
|
184
|
+
const detail = formatUnknownDetail(result.error);
|
|
185
|
+
emit({
|
|
186
|
+
type: "stderr",
|
|
187
|
+
data: detail ? `Cursor run failed (${result.id}): ${detail}` : `Cursor run failed (${result.id})`
|
|
132
188
|
});
|
|
189
|
+
return 2;
|
|
133
190
|
}
|
|
191
|
+
if (result.status === "cancelled") return 0;
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
let agent = await openAgent();
|
|
134
196
|
try {
|
|
135
|
-
emit({ type: "session_id", data: agent.agentId });
|
|
136
|
-
const sendOpts = mcpServers ? { mcpServers } : void 0;
|
|
137
|
-
let run;
|
|
138
197
|
try {
|
|
139
|
-
|
|
198
|
+
return await runTurn(agent);
|
|
140
199
|
} catch (err) {
|
|
141
|
-
if (!
|
|
142
|
-
const n = await cancelStaleLocalRuns(agent.agentId, {
|
|
143
|
-
cwd: req.cwd,
|
|
144
|
-
store
|
|
145
|
-
});
|
|
146
|
-
emit({
|
|
147
|
-
type: "stderr",
|
|
148
|
-
data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
|
|
149
|
-
});
|
|
150
|
-
run = await agent.send(req.prompt, sendOpts);
|
|
151
|
-
}
|
|
152
|
-
for await (const msg of run.stream()) {
|
|
153
|
-
for (const event of cursorSdkMessageToEvents(msg)) {
|
|
154
|
-
emit(event);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
const result = await run.wait();
|
|
158
|
-
if (result.status === "error") {
|
|
159
|
-
const detail = formatUnknownDetail(result.error);
|
|
200
|
+
if (!isUnresumableCursorSession(err)) throw err;
|
|
160
201
|
emit({
|
|
161
202
|
type: "stderr",
|
|
162
|
-
data:
|
|
203
|
+
data: cursorSessionRecoveryMessage(err, agent.agentId)
|
|
163
204
|
});
|
|
164
|
-
|
|
205
|
+
await agent[Symbol.asyncDispose]().catch(() => void 0);
|
|
206
|
+
agent = await createAgent();
|
|
207
|
+
return await runTurn(agent);
|
|
165
208
|
}
|
|
166
|
-
if (result.status === "cancelled") return 0;
|
|
167
|
-
return 0;
|
|
168
209
|
} finally {
|
|
169
|
-
await agent[Symbol.asyncDispose]();
|
|
210
|
+
await agent[Symbol.asyncDispose]().catch(() => void 0);
|
|
170
211
|
}
|
|
171
212
|
} catch (err) {
|
|
172
213
|
if (err instanceof CursorAgentError) {
|
|
@@ -28,22 +28,23 @@ import {
|
|
|
28
28
|
resolveCursorModelId,
|
|
29
29
|
resolveLoginCommand,
|
|
30
30
|
resolveQuotaFallbackAgent
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-R753UFSX.js";
|
|
32
32
|
import {
|
|
33
33
|
ORCHESTRATOR_AGENT_KINDS,
|
|
34
34
|
assertOrchestratorCapableAgent,
|
|
35
35
|
coerceOrchestratorAgent,
|
|
36
36
|
isOrchestratorCapableAgent
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
37
|
+
} from "./chunk-OIEFHOP7.js";
|
|
38
|
+
import "./chunk-JPHG2KCC.js";
|
|
39
39
|
import "./chunk-BTL7EMGT.js";
|
|
40
40
|
import {
|
|
41
41
|
cursorSdkMessageToEvents,
|
|
42
42
|
parseCursorRunnerLine
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import "./chunk-
|
|
43
|
+
} from "./chunk-CBJSPTBG.js";
|
|
44
|
+
import "./chunk-XW47PL6A.js";
|
|
45
45
|
import "./chunk-FKOIHGKV.js";
|
|
46
|
-
import "./chunk-
|
|
46
|
+
import "./chunk-I3FRXL7J.js";
|
|
47
|
+
import "./chunk-5KLC2MWZ.js";
|
|
47
48
|
import "./chunk-JT7R45JB.js";
|
|
48
49
|
import "./chunk-FWJYLBO6.js";
|
|
49
50
|
import "./chunk-77WWLBCI.js";
|
|
@@ -32,16 +32,16 @@ import {
|
|
|
32
32
|
resolveCursorModelId,
|
|
33
33
|
resolveLoginCommand,
|
|
34
34
|
resolveQuotaFallbackAgent
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-BBQ6HXKS.js";
|
|
36
36
|
import "./chunk-VROPG6QF.js";
|
|
37
37
|
import {
|
|
38
38
|
ORCHESTRATOR_AGENT_KINDS,
|
|
39
39
|
assertOrchestratorCapableAgent,
|
|
40
40
|
coerceOrchestratorAgent,
|
|
41
41
|
isOrchestratorCapableAgent
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import "./chunk-
|
|
44
|
-
import "./chunk-
|
|
42
|
+
} from "./chunk-WJ5TINR6.js";
|
|
43
|
+
import "./chunk-NW7MEJHO.js";
|
|
44
|
+
import "./chunk-CKBIQ54F.js";
|
|
45
45
|
import "./chunk-B3SJXYIJ.js";
|
|
46
46
|
import "./chunk-7FD7COKE.js";
|
|
47
47
|
import {
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
resolveCommandBinarySync,
|
|
54
54
|
withExportedPath
|
|
55
55
|
} from "./chunk-AE5VBOFE.js";
|
|
56
|
-
import "./chunk-
|
|
56
|
+
import "./chunk-AY53MPDE.js";
|
|
57
57
|
import "./chunk-NSTQ6QKD.js";
|
|
58
58
|
import "./chunk-KGZBYWZ3.js";
|
|
59
59
|
import "./chunk-7MV3RXSC.js";
|
|
@@ -52,7 +52,8 @@ import {
|
|
|
52
52
|
updateDefaultsSettings,
|
|
53
53
|
updateIntegrationsSettings,
|
|
54
54
|
updateOpencodeSettings
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-I3FRXL7J.js";
|
|
56
|
+
import "./chunk-5KLC2MWZ.js";
|
|
56
57
|
import "./chunk-JT7R45JB.js";
|
|
57
58
|
import "./chunk-77WWLBCI.js";
|
|
58
59
|
import "./chunk-M37RITA6.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/hook/nested-electron-env.ts
|
|
2
|
+
var NESTED_ELECTRON_ENV_PREFIXES = ["ELECTRON_", "CHROME_"];
|
|
3
|
+
function isNestedElectronEnvKey(key) {
|
|
4
|
+
return NESTED_ELECTRON_ENV_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
5
|
+
}
|
|
6
|
+
function stripNestedElectronEnv(env) {
|
|
7
|
+
const out = { ...env };
|
|
8
|
+
for (const key of Object.keys(out)) {
|
|
9
|
+
if (isNestedElectronEnvKey(key)) delete out[key];
|
|
10
|
+
}
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
function dropNestedElectronEnvFromProcess(env = process.env) {
|
|
14
|
+
for (const key of Object.keys(env)) {
|
|
15
|
+
if (isNestedElectronEnvKey(key)) delete env[key];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var STRIP_NESTED_ELECTRON_THEN_EXEC = [
|
|
19
|
+
"vars=`printenv | awk -F= '/^(ELECTRON_|CHROME_)/{print $1}'`",
|
|
20
|
+
'[ -n "$vars" ] && unset $vars',
|
|
21
|
+
"export ELECTRON_RUN_AS_NODE=1",
|
|
22
|
+
'exec "$@"'
|
|
23
|
+
].join("; ");
|
|
24
|
+
function wrapElectronAsNodeLaunch(file, args) {
|
|
25
|
+
if (process.platform === "win32") return { file, args };
|
|
26
|
+
return {
|
|
27
|
+
file: "/bin/sh",
|
|
28
|
+
args: ["-c", STRIP_NESTED_ELECTRON_THEN_EXEC, "sh", file, ...args]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function isStrippedElectronLaunch(command, args) {
|
|
32
|
+
return command === "/bin/sh" && Boolean(args?.[1]?.includes("ELECTRON_RUN_AS_NODE") && args[1].includes("unset"));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
stripNestedElectronEnv,
|
|
37
|
+
dropNestedElectronEnvFromProcess,
|
|
38
|
+
wrapElectronAsNodeLaunch,
|
|
39
|
+
isStrippedElectronLaunch
|
|
40
|
+
};
|
|
@@ -17,6 +17,40 @@ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
|
17
17
|
import { homedir, hostname } from "os";
|
|
18
18
|
import { join as join2 } from "path";
|
|
19
19
|
|
|
20
|
+
// src/hook/nested-electron-env.ts
|
|
21
|
+
var NESTED_ELECTRON_ENV_PREFIXES = ["ELECTRON_", "CHROME_"];
|
|
22
|
+
function isNestedElectronEnvKey(key) {
|
|
23
|
+
return NESTED_ELECTRON_ENV_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
24
|
+
}
|
|
25
|
+
function stripNestedElectronEnv(env) {
|
|
26
|
+
const out = { ...env };
|
|
27
|
+
for (const key of Object.keys(out)) {
|
|
28
|
+
if (isNestedElectronEnvKey(key)) delete out[key];
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
function dropNestedElectronEnvFromProcess(env = process.env) {
|
|
33
|
+
for (const key of Object.keys(env)) {
|
|
34
|
+
if (isNestedElectronEnvKey(key)) delete env[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
var STRIP_NESTED_ELECTRON_THEN_EXEC = [
|
|
38
|
+
"vars=`printenv | awk -F= '/^(ELECTRON_|CHROME_)/{print $1}'`",
|
|
39
|
+
'[ -n "$vars" ] && unset $vars',
|
|
40
|
+
"export ELECTRON_RUN_AS_NODE=1",
|
|
41
|
+
'exec "$@"'
|
|
42
|
+
].join("; ");
|
|
43
|
+
function wrapElectronAsNodeLaunch(file, args) {
|
|
44
|
+
if (process.platform === "win32") return { file, args };
|
|
45
|
+
return {
|
|
46
|
+
file: "/bin/sh",
|
|
47
|
+
args: ["-c", STRIP_NESTED_ELECTRON_THEN_EXEC, "sh", file, ...args]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function isStrippedElectronLaunch(command, args) {
|
|
51
|
+
return command === "/bin/sh" && Boolean(args?.[1]?.includes("ELECTRON_RUN_AS_NODE") && args[1].includes("unset"));
|
|
52
|
+
}
|
|
53
|
+
|
|
20
54
|
// src/store/secret-vault.ts
|
|
21
55
|
import { join } from "path";
|
|
22
56
|
|
|
@@ -1062,7 +1096,7 @@ function applyAppEnvironment(target = process.env, settings = loadAppSettings())
|
|
|
1062
1096
|
}
|
|
1063
1097
|
function childEnvWithAppSettings(extra) {
|
|
1064
1098
|
const settings = loadAppSettings();
|
|
1065
|
-
const env = { ...process.env };
|
|
1099
|
+
const env = stripNestedElectronEnv({ ...process.env });
|
|
1066
1100
|
applyAppEnvironment(env, settings);
|
|
1067
1101
|
if (extra) {
|
|
1068
1102
|
for (const [k, v] of Object.entries(extra)) {
|
|
@@ -1076,6 +1110,10 @@ function harnessEnvKey(harness) {
|
|
|
1076
1110
|
}
|
|
1077
1111
|
|
|
1078
1112
|
export {
|
|
1113
|
+
stripNestedElectronEnv,
|
|
1114
|
+
dropNestedElectronEnvFromProcess,
|
|
1115
|
+
wrapElectronAsNodeLaunch,
|
|
1116
|
+
isStrippedElectronLaunch,
|
|
1079
1117
|
resolveVaultKey,
|
|
1080
1118
|
readSecureJson,
|
|
1081
1119
|
writeSecureJson,
|