@sideboard-ai/core 0.1.83 → 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.
Files changed (33) hide show
  1. package/dist/agents/cursor-runner.cjs +88 -53
  2. package/dist/agents/cursor-runner.js +93 -56
  3. package/dist/{agents-3YPUZME7.js → agents-JFXM66QA.js} +7 -7
  4. package/dist/{agents-4KRD46KG.js → agents-OPTHS4IX.js} +5 -5
  5. package/dist/{app-settings-MQXL7OUF.js → app-settings-K6RFCRF6.js} +2 -2
  6. package/dist/{app-settings-GVSOIJLZ.js → app-settings-PEXK5VEX.js} +1 -1
  7. package/dist/{chunk-IZ7RPF54.js → chunk-5KLC2MWZ.js} +5 -1
  8. package/dist/{chunk-UHGN4KCL.js → chunk-AY53MPDE.js} +4 -0
  9. package/dist/{chunk-JMRJ4F5B.js → chunk-BBQ6HXKS.js} +52 -13
  10. package/dist/{chunk-SEOICVGB.js → chunk-CBJSPTBG.js} +30 -6
  11. package/dist/{chunk-HBBXS2FR.js → chunk-CKBIQ54F.js} +1 -1
  12. package/dist/{chunk-YO3CYL6B.js → chunk-I3FRXL7J.js} +1 -1
  13. package/dist/{chunk-E2MIA7DO.js → chunk-JPHG2KCC.js} +2 -2
  14. package/dist/{chunk-ERJS3ZDP.js → chunk-NW7MEJHO.js} +2 -2
  15. package/dist/{chunk-LVTNWH7B.js → chunk-ODZ2ZOA4.js} +2 -2
  16. package/dist/{chunk-NXXT5SE3.js → chunk-OIEFHOP7.js} +3 -3
  17. package/dist/{chunk-JW6YFPQE.js → chunk-R753UFSX.js} +24 -9
  18. package/dist/{chunk-RS54WYYH.js → chunk-UN3LVQB2.js} +2 -2
  19. package/dist/{chunk-DJFGX4RT.js → chunk-WJ5TINR6.js} +3 -3
  20. package/dist/{chunk-GD2FM6FN.js → chunk-XW47PL6A.js} +1 -1
  21. package/dist/{coordinator-prompt-6ICA54JR.js → coordinator-prompt-DOIOSLUN.js} +3 -3
  22. package/dist/{coordinator-prompt-46JE4NQR.js → coordinator-prompt-RCTIIZ6C.js} +4 -4
  23. package/dist/{global-workspace-OBRWUPZG.js → global-workspace-33BIG7KK.js} +4 -4
  24. package/dist/{global-workspace-GSLCEB5E.js → global-workspace-73OAKD3C.js} +5 -5
  25. package/dist/index.cjs +54 -12
  26. package/dist/index.js +23 -23
  27. package/dist/mcp/run-stdio.cjs +54 -12
  28. package/dist/mcp/run-stdio.js +20 -20
  29. package/dist/{workspaces-7B3PTEF4.js → workspaces-SRITISKA.js} +6 -6
  30. package/dist/{workspaces-RJIWQB6J.js → workspaces-WDLY34MX.js} +5 -5
  31. package/dist/{worktree-HSN5LWY6.js → worktree-SGZVAWOQ.js} +3 -3
  32. package/dist/{worktree-U3UIID2K.js → worktree-TUAO74SI.js} +2 -2
  33. package/package.json +1 -1
@@ -44,6 +44,32 @@ function appDataDir() {
44
44
  return base;
45
45
  }
46
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
+
47
73
  // src/agents/error-detail.ts
48
74
  function formatUnknownDetail(err) {
49
75
  if (err == null) return "";
@@ -265,11 +291,6 @@ function localAgentStore() {
265
291
  (0, import_node_fs3.mkdirSync)(root, { recursive: true });
266
292
  return new import_sdk.JsonlLocalAgentStore(root);
267
293
  }
268
- function isAgentBusyError(err) {
269
- if (err instanceof import_sdk.AgentBusyError) return true;
270
- const message = err instanceof Error ? err.message : String(err);
271
- return /already has active run/i.test(message);
272
- }
273
294
  async function cancelStaleLocalRuns(agentId, opts) {
274
295
  const listed = await import_sdk.Agent.listRuns(agentId, {
275
296
  runtime: "local",
@@ -328,75 +349,89 @@ async function main() {
328
349
  const store = localAgentStore();
329
350
  const local = { cwd: req.cwd, store };
330
351
  const mcpServers = req.mcpServers && Object.keys(req.mcpServers).length > 0 ? req.mcpServers : void 0;
331
- try {
332
- let agent;
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() {
333
364
  try {
334
- agent = req.agentId ? await import_sdk.Agent.resume(req.agentId, {
335
- apiKey,
336
- model,
337
- mode,
338
- local,
339
- ...mcpServers ? { mcpServers } : {}
340
- }) : await import_sdk.Agent.create({
365
+ return req.agentId ? await import_sdk.Agent.resume(req.agentId, {
341
366
  apiKey,
342
367
  model,
343
368
  mode,
344
369
  local,
345
- name: "Sideboard",
346
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)
347
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);
348
385
  } catch (err) {
349
- const message = err instanceof Error ? err.message : String(err);
350
- if (!req.agentId || !/not found/i.test(message)) throw err;
386
+ if (!isAgentBusyError(err)) throw err;
387
+ const n = await cancelStaleLocalRuns(agent.agentId, {
388
+ cwd: req.cwd,
389
+ store
390
+ });
351
391
  emit({
352
392
  type: "stderr",
353
- data: `Cursor agent ${req.agentId} not found \u2014 starting a new session`
393
+ data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
354
394
  });
355
- agent = await import_sdk.Agent.create({
356
- apiKey,
357
- model,
358
- mode,
359
- local,
360
- name: "Sideboard",
361
- ...mcpServers ? { mcpServers } : {}
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})`
362
412
  });
413
+ return 2;
363
414
  }
415
+ if (result.status === "cancelled") return 0;
416
+ return 0;
417
+ }
418
+ try {
419
+ let agent = await openAgent();
364
420
  try {
365
- emit({ type: "session_id", data: agent.agentId });
366
- const sendOpts = mcpServers ? { mcpServers } : void 0;
367
- let run;
368
421
  try {
369
- run = await agent.send(req.prompt, sendOpts);
422
+ return await runTurn(agent);
370
423
  } catch (err) {
371
- if (!isAgentBusyError(err)) throw err;
372
- const n = await cancelStaleLocalRuns(agent.agentId, {
373
- cwd: req.cwd,
374
- store
375
- });
376
- emit({
377
- type: "stderr",
378
- data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
379
- });
380
- run = await agent.send(req.prompt, sendOpts);
381
- }
382
- for await (const msg of run.stream()) {
383
- for (const event of cursorSdkMessageToEvents(msg)) {
384
- emit(event);
385
- }
386
- }
387
- const result = await run.wait();
388
- if (result.status === "error") {
389
- const detail = formatUnknownDetail(result.error);
424
+ if (!isUnresumableCursorSession(err)) throw err;
390
425
  emit({
391
426
  type: "stderr",
392
- data: detail ? `Cursor run failed (${result.id}): ${detail}` : `Cursor run failed (${result.id})`
427
+ data: cursorSessionRecoveryMessage(err, agent.agentId)
393
428
  });
394
- return 2;
429
+ await agent[Symbol.asyncDispose]().catch(() => void 0);
430
+ agent = await createAgent();
431
+ return await runTurn(agent);
395
432
  }
396
- if (result.status === "cancelled") return 0;
397
- return 0;
398
433
  } finally {
399
- await agent[Symbol.asyncDispose]();
434
+ await agent[Symbol.asyncDispose]().catch(() => void 0);
400
435
  }
401
436
  } catch (err) {
402
437
  if (err instanceof import_sdk.CursorAgentError) {
@@ -2,19 +2,47 @@
2
2
  import {
3
3
  cursorSdkMessageToEvents,
4
4
  formatUnknownDetail
5
- } from "../chunk-SEOICVGB.js";
5
+ } from "../chunk-CBJSPTBG.js";
6
6
  import {
7
7
  dropNestedElectronEnvFromProcess
8
- } from "../chunk-IZ7RPF54.js";
8
+ } from "../chunk-5KLC2MWZ.js";
9
9
  import {
10
10
  appDataDir
11
11
  } from "../chunk-M37RITA6.js";
12
12
 
13
13
  // src/agents/cursor-runner.ts
14
- import { Agent, AgentBusyError, CursorAgentError, JsonlLocalAgentStore } from "@cursor/sdk";
14
+ import { Agent, CursorAgentError, JsonlLocalAgentStore } from "@cursor/sdk";
15
15
  import { mkdirSync } from "fs";
16
16
  import { join } from "path";
17
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
18
46
  dropNestedElectronEnvFromProcess();
19
47
  function emit(event) {
20
48
  process.stdout.write(`${JSON.stringify(event)}
@@ -39,11 +67,6 @@ function localAgentStore() {
39
67
  mkdirSync(root, { recursive: true });
40
68
  return new JsonlLocalAgentStore(root);
41
69
  }
42
- function isAgentBusyError(err) {
43
- if (err instanceof AgentBusyError) return true;
44
- const message = err instanceof Error ? err.message : String(err);
45
- return /already has active run/i.test(message);
46
- }
47
70
  async function cancelStaleLocalRuns(agentId, opts) {
48
71
  const listed = await Agent.listRuns(agentId, {
49
72
  runtime: "local",
@@ -102,75 +125,89 @@ async function main() {
102
125
  const store = localAgentStore();
103
126
  const local = { cwd: req.cwd, store };
104
127
  const mcpServers = req.mcpServers && Object.keys(req.mcpServers).length > 0 ? req.mcpServers : void 0;
105
- try {
106
- let agent;
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() {
107
140
  try {
108
- agent = req.agentId ? await Agent.resume(req.agentId, {
141
+ return req.agentId ? await Agent.resume(req.agentId, {
109
142
  apiKey,
110
143
  model,
111
144
  mode,
112
145
  local,
113
146
  ...mcpServers ? { mcpServers } : {}
114
- }) : await Agent.create({
115
- apiKey,
116
- model,
117
- mode,
118
- local,
119
- name: "Sideboard",
120
- ...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)
121
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);
122
161
  } catch (err) {
123
- const message = err instanceof Error ? err.message : String(err);
124
- if (!req.agentId || !/not found/i.test(message)) throw err;
162
+ if (!isAgentBusyError(err)) throw err;
163
+ const n = await cancelStaleLocalRuns(agent.agentId, {
164
+ cwd: req.cwd,
165
+ store
166
+ });
125
167
  emit({
126
168
  type: "stderr",
127
- data: `Cursor agent ${req.agentId} not found \u2014 starting a new session`
169
+ data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
128
170
  });
129
- agent = await Agent.create({
130
- apiKey,
131
- model,
132
- mode,
133
- local,
134
- name: "Sideboard",
135
- ...mcpServers ? { mcpServers } : {}
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})`
136
188
  });
189
+ return 2;
137
190
  }
191
+ if (result.status === "cancelled") return 0;
192
+ return 0;
193
+ }
194
+ try {
195
+ let agent = await openAgent();
138
196
  try {
139
- emit({ type: "session_id", data: agent.agentId });
140
- const sendOpts = mcpServers ? { mcpServers } : void 0;
141
- let run;
142
197
  try {
143
- run = await agent.send(req.prompt, sendOpts);
198
+ return await runTurn(agent);
144
199
  } catch (err) {
145
- if (!isAgentBusyError(err)) throw err;
146
- const n = await cancelStaleLocalRuns(agent.agentId, {
147
- cwd: req.cwd,
148
- store
149
- });
150
- emit({
151
- type: "stderr",
152
- data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
153
- });
154
- run = await agent.send(req.prompt, sendOpts);
155
- }
156
- for await (const msg of run.stream()) {
157
- for (const event of cursorSdkMessageToEvents(msg)) {
158
- emit(event);
159
- }
160
- }
161
- const result = await run.wait();
162
- if (result.status === "error") {
163
- const detail = formatUnknownDetail(result.error);
200
+ if (!isUnresumableCursorSession(err)) throw err;
164
201
  emit({
165
202
  type: "stderr",
166
- data: detail ? `Cursor run failed (${result.id}): ${detail}` : `Cursor run failed (${result.id})`
203
+ data: cursorSessionRecoveryMessage(err, agent.agentId)
167
204
  });
168
- return 2;
205
+ await agent[Symbol.asyncDispose]().catch(() => void 0);
206
+ agent = await createAgent();
207
+ return await runTurn(agent);
169
208
  }
170
- if (result.status === "cancelled") return 0;
171
- return 0;
172
209
  } finally {
173
- await agent[Symbol.asyncDispose]();
210
+ await agent[Symbol.asyncDispose]().catch(() => void 0);
174
211
  }
175
212
  } catch (err) {
176
213
  if (err instanceof CursorAgentError) {
@@ -28,23 +28,23 @@ import {
28
28
  resolveCursorModelId,
29
29
  resolveLoginCommand,
30
30
  resolveQuotaFallbackAgent
31
- } from "./chunk-JW6YFPQE.js";
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-NXXT5SE3.js";
38
- import "./chunk-E2MIA7DO.js";
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-SEOICVGB.js";
44
- import "./chunk-GD2FM6FN.js";
43
+ } from "./chunk-CBJSPTBG.js";
44
+ import "./chunk-XW47PL6A.js";
45
45
  import "./chunk-FKOIHGKV.js";
46
- import "./chunk-YO3CYL6B.js";
47
- import "./chunk-IZ7RPF54.js";
46
+ import "./chunk-I3FRXL7J.js";
47
+ import "./chunk-5KLC2MWZ.js";
48
48
  import "./chunk-JT7R45JB.js";
49
49
  import "./chunk-FWJYLBO6.js";
50
50
  import "./chunk-77WWLBCI.js";
@@ -32,16 +32,16 @@ import {
32
32
  resolveCursorModelId,
33
33
  resolveLoginCommand,
34
34
  resolveQuotaFallbackAgent
35
- } from "./chunk-JMRJ4F5B.js";
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-DJFGX4RT.js";
43
- import "./chunk-ERJS3ZDP.js";
44
- import "./chunk-HBBXS2FR.js";
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-UHGN4KCL.js";
56
+ import "./chunk-AY53MPDE.js";
57
57
  import "./chunk-NSTQ6QKD.js";
58
58
  import "./chunk-KGZBYWZ3.js";
59
59
  import "./chunk-7MV3RXSC.js";
@@ -52,8 +52,8 @@ import {
52
52
  updateDefaultsSettings,
53
53
  updateIntegrationsSettings,
54
54
  updateOpencodeSettings
55
- } from "./chunk-YO3CYL6B.js";
56
- import "./chunk-IZ7RPF54.js";
55
+ } from "./chunk-I3FRXL7J.js";
56
+ import "./chunk-5KLC2MWZ.js";
57
57
  import "./chunk-JT7R45JB.js";
58
58
  import "./chunk-77WWLBCI.js";
59
59
  import "./chunk-M37RITA6.js";
@@ -54,7 +54,7 @@ import {
54
54
  updateDefaultsSettings,
55
55
  updateIntegrationsSettings,
56
56
  updateOpencodeSettings
57
- } from "./chunk-UHGN4KCL.js";
57
+ } from "./chunk-AY53MPDE.js";
58
58
  import "./chunk-NSTQ6QKD.js";
59
59
  import "./chunk-KGZBYWZ3.js";
60
60
  import "./chunk-7MV3RXSC.js";
@@ -28,9 +28,13 @@ function wrapElectronAsNodeLaunch(file, args) {
28
28
  args: ["-c", STRIP_NESTED_ELECTRON_THEN_EXEC, "sh", file, ...args]
29
29
  };
30
30
  }
31
+ function isStrippedElectronLaunch(command, args) {
32
+ return command === "/bin/sh" && Boolean(args?.[1]?.includes("ELECTRON_RUN_AS_NODE") && args[1].includes("unset"));
33
+ }
31
34
 
32
35
  export {
33
36
  stripNestedElectronEnv,
34
37
  dropNestedElectronEnvFromProcess,
35
- wrapElectronAsNodeLaunch
38
+ wrapElectronAsNodeLaunch,
39
+ isStrippedElectronLaunch
36
40
  };
@@ -47,6 +47,9 @@ function wrapElectronAsNodeLaunch(file, args) {
47
47
  args: ["-c", STRIP_NESTED_ELECTRON_THEN_EXEC, "sh", file, ...args]
48
48
  };
49
49
  }
50
+ function isStrippedElectronLaunch(command, args) {
51
+ return command === "/bin/sh" && Boolean(args?.[1]?.includes("ELECTRON_RUN_AS_NODE") && args[1].includes("unset"));
52
+ }
50
53
 
51
54
  // src/store/secret-vault.ts
52
55
  import { join } from "path";
@@ -1110,6 +1113,7 @@ export {
1110
1113
  stripNestedElectronEnv,
1111
1114
  dropNestedElectronEnvFromProcess,
1112
1115
  wrapElectronAsNodeLaunch,
1116
+ isStrippedElectronLaunch,
1113
1117
  resolveVaultKey,
1114
1118
  readSecureJson,
1115
1119
  writeSecureJson,
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-VROPG6QF.js";
10
10
  import {
11
11
  isOrchestratorThread
12
- } from "./chunk-DJFGX4RT.js";
12
+ } from "./chunk-WJ5TINR6.js";
13
13
  import {
14
14
  enrichPathWithNpmGlobalBin,
15
15
  isConductorBundledCli,
@@ -19,11 +19,12 @@ import {
19
19
  } from "./chunk-AE5VBOFE.js";
20
20
  import {
21
21
  claudeChromeEnabled,
22
+ isStrippedElectronLaunch,
22
23
  loadAppSettings,
23
24
  resolveAgentExecutable,
24
25
  resolveClaudeExecutable,
25
26
  wrapElectronAsNodeLaunch
26
- } from "./chunk-UHGN4KCL.js";
27
+ } from "./chunk-AY53MPDE.js";
27
28
  import {
28
29
  appDataDir
29
30
  } from "./chunk-7MV3RXSC.js";
@@ -153,20 +154,38 @@ function pushTurnStderr(tail, line, maxLines = 12) {
153
154
  tail.push(trimmed);
154
155
  while (tail.length > maxLines) tail.shift();
155
156
  }
157
+ function looksLikeMinifiedJsDump(line) {
158
+ if (line.length < 200) return false;
159
+ return /yield Promise\.all/.test(line) || /\(0,[A-Za-z$]\.\w+\)/.test(line) || /CURSOR_RIPGREP_PATH/.test(line);
160
+ }
161
+ function looksLikeNestedElectronCrash(line) {
162
+ return /HasCustomHostObject|ElectronInitializeICUandStartNode/i.test(line);
163
+ }
164
+ var NESTED_ELECTRON_SUMMARY = "Cursor local agent crashed at Electron startup (nested Chromium / HasCustomHostObject)";
165
+ var MINIFIED_DUMP_SUMMARY = "Cursor local agent crashed during startup (truncated crash dump)";
166
+ function clipStderr(text, maxChars) {
167
+ const trimmed = text.trim();
168
+ if (trimmed.length <= maxChars) return trimmed;
169
+ return trimmed.slice(0, maxChars);
170
+ }
156
171
  function summarizeTurnStderr(tail, maxChars = 500) {
157
172
  if (tail.length === 0) return "";
173
+ const cursorStartup = [...tail].reverse().find((line) => /cursor startup failed:/i.test(line));
174
+ if (cursorStartup) return clipStderr(cursorStartup, maxChars);
175
+ if (tail.some(looksLikeNestedElectronCrash)) return NESTED_ELECTRON_SUMMARY;
158
176
  const moduleMissing = [...tail].reverse().find((line) => /cannot find module/i.test(line));
159
- if (moduleMissing) {
160
- return moduleMissing.length <= maxChars ? moduleMissing : moduleMissing.slice(0, maxChars);
177
+ if (moduleMissing) return clipStderr(moduleMissing, maxChars);
178
+ const useful = tail.filter((line) => !looksLikeMinifiedJsDump(line));
179
+ if (useful.length === 0 && tail.some(looksLikeMinifiedJsDump)) {
180
+ return MINIFIED_DUMP_SUMMARY;
161
181
  }
162
- const joined = tail.slice(-6).join("\n").trim();
163
- if (joined.length <= maxChars) return joined;
164
- return joined.slice(joined.length - maxChars);
182
+ const joined = (useful.length ? useful : tail).slice(-6).join("\n").trim();
183
+ return clipStderr(joined, maxChars);
165
184
  }
166
185
  function looksLikeInvalidAgentSession(text) {
167
186
  const lower = text.trim().toLowerCase();
168
187
  if (!lower) return false;
169
- return /session not found/.test(lower) || /no conversation found/.test(lower) || /conversation .+ not found/.test(lower) || /thread .+ not found/.test(lower) || /unknown session/.test(lower) || /invalid session/.test(lower) || /session .+ (missing|expired|deleted|gone)/.test(lower) || /cannot resume/.test(lower) || /failed to (load|resume|open) session/.test(lower);
188
+ return /session not found/.test(lower) || /no conversation found/.test(lower) || /conversation .+ not found/.test(lower) || /thread .+ not found/.test(lower) || /unknown session/.test(lower) || /invalid session/.test(lower) || /session .+ (missing|expired|deleted|gone)/.test(lower) || /cannot resume/.test(lower) || /failed to (load|resume|open) session/.test(lower) || /corrupt local agent checkpoint/.test(lower) || /missing root blob/.test(lower) || /\bagent\b.{0,120}\bnot found\b/.test(lower);
170
189
  }
171
190
  function looksLikeAgentFailureMessage(text) {
172
191
  const lower = text.trim().toLowerCase();
@@ -206,6 +225,12 @@ function humanizeAgentFailDetail(detail) {
206
225
  if (/context.*(too long|exceed)|prompt is too long|conversation too long/.test(lower)) {
207
226
  return `${raw} \u2014 start a new chat or compact context, then retry.`;
208
227
  }
228
+ if (/hascustomhostobject|electroninitializeicuandstartnode|nested chromium/i.test(lower)) {
229
+ return `${raw} \u2014 retry the turn; if it keeps failing, pick another agent.`;
230
+ }
231
+ if (/corrupt local agent checkpoint|missing root blob|truncated crash dump/.test(lower)) {
232
+ return `${raw} \u2014 retry the turn (Sideboard will start a fresh Cursor session).`;
233
+ }
209
234
  return raw;
210
235
  }
211
236
  function formatTurnExitError(exitCode, stderrSummary) {
@@ -594,7 +619,12 @@ function applyNodeLaunch(launch, args) {
594
619
  return { file: launch.file, args, env: launch.env };
595
620
  }
596
621
  const wrapped = wrapElectronAsNodeLaunch(launch.file, args);
597
- return { file: wrapped.file, args: wrapped.args, env: launch.env };
622
+ if (process.platform === "win32") {
623
+ return { file: wrapped.file, args: wrapped.args, env: launch.env };
624
+ }
625
+ const env = { ...launch.env };
626
+ delete env.ELECTRON_RUN_AS_NODE;
627
+ return { file: wrapped.file, args: wrapped.args, env };
598
628
  }
599
629
  async function resolveNodeLaunch(scriptPath) {
600
630
  if (isAsarPath(scriptPath)) {
@@ -806,10 +836,19 @@ async function buildInjectedMcpServers(opts) {
806
836
  function toCursorMcpServers(servers) {
807
837
  const out = {};
808
838
  for (const s of servers) {
839
+ const env = s.env ? { ...s.env } : void 0;
840
+ if (env) delete env.ELECTRON_RUN_AS_NODE;
841
+ let command = s.command;
842
+ let args = s.args;
843
+ if (process.platform !== "win32" && !isStrippedElectronLaunch(command, args)) {
844
+ const wrapped = wrapElectronAsNodeLaunch(command, args ?? []);
845
+ command = wrapped.file;
846
+ args = wrapped.args;
847
+ }
809
848
  out[s.name] = {
810
- command: s.command,
811
- ...s.args ? { args: s.args } : {},
812
- ...s.env ? { env: s.env } : {}
849
+ command,
850
+ ...args && args.length > 0 ? { args } : {},
851
+ ...env && Object.keys(env).length > 0 ? { env } : {}
813
852
  };
814
853
  }
815
854
  return out;
@@ -1053,7 +1092,7 @@ var claudeAdapter = {
1053
1092
  );
1054
1093
  }
1055
1094
  const mode = permissionMode(thread);
1056
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-OBRWUPZG.js");
1095
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-33BIG7KK.js");
1057
1096
  const isOrchestrator = isOrchestratorThread2(thread);
1058
1097
  const injectedServers = await buildInjectedMcpServers({
1059
1098
  includeSideboard: true,