@sideboard-ai/core 0.1.293 → 0.1.295
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/{abletime-VFKYNSJT.js → abletime-APP3DZ4P.js} +4 -4
- package/dist/{abletime-4WJUVE64.js → abletime-RYDAQ3FE.js} +4 -4
- package/dist/{abletime-oauth-ICMB2XV2.js → abletime-oauth-KTERKARA.js} +3 -3
- package/dist/{abletime-oauth-FW24YHYX.js → abletime-oauth-ZURGXSY6.js} +3 -3
- package/dist/{abletime-rest-OGWC7BC6.js → abletime-rest-4TVIWLZK.js} +3 -3
- package/dist/{abletime-rest-HFMRTUDT.js → abletime-rest-EUB6RW7K.js} +3 -3
- package/dist/agents/cursor-runner.cjs +128 -50
- package/dist/agents/cursor-runner.js +62 -43
- package/dist/{agents-SITR5V6F.js → agents-EFHYZUZT.js} +8 -8
- package/dist/{agents-WT72O5A3.js → agents-S55DBAVO.js} +6 -6
- package/dist/{app-settings-EHMXHNG5.js → app-settings-2IH42VA5.js} +3 -1
- package/dist/{app-settings-MR2U6AXN.js → app-settings-3OQWRKOK.js} +3 -1
- package/dist/{chunk-3E4NOIXN.js → chunk-3D3GGL6X.js} +3 -3
- package/dist/{chunk-UO5C2L2G.js → chunk-6SGYGYH7.js} +1 -1
- package/dist/{chunk-RPCKGO3J.js → chunk-ABLHTRRG.js} +17 -12
- package/dist/{chunk-NXXQFLNQ.js → chunk-B42H6GJR.js} +2 -2
- package/dist/{chunk-MVZO7QZ2.js → chunk-BU6HH5VA.js} +4 -0
- package/dist/{chunk-PO3PDNMV.js → chunk-E7G7RY6T.js} +3 -3
- package/dist/{chunk-AFLNFGGB.js → chunk-ED4ZXQVO.js} +1 -0
- package/dist/{chunk-K6IOJI3L.js → chunk-ER6BGGME.js} +70 -1
- package/dist/{chunk-NFPWLDCH.js → chunk-FAXOEKQR.js} +5 -5
- package/dist/{chunk-MIVX7QKI.js → chunk-HO5R3ZRH.js} +1 -0
- package/dist/{chunk-GU6DT6NO.js → chunk-HSF2RQSQ.js} +5 -5
- package/dist/{chunk-WRDKJRWF.js → chunk-HWIIRVYE.js} +5 -5
- package/dist/{chunk-7UUILVMV.js → chunk-IOY2LF3Y.js} +1 -1
- package/dist/{chunk-OH4EN323.js → chunk-ISEYRGMP.js} +2 -2
- package/dist/{chunk-4YXXLWDI.js → chunk-KCP6IVRI.js} +6 -6
- package/dist/{chunk-MYJYINTS.js → chunk-LZVWKJXY.js} +3 -3
- package/dist/{chunk-Y67TBJD5.js → chunk-MOP5L5QZ.js} +3 -3
- package/dist/{chunk-YSLCWCMJ.js → chunk-Q3DPZ4DE.js} +1 -1
- package/dist/{chunk-AF2DMY3K.js → chunk-QDDTVIWE.js} +13 -4
- package/dist/{chunk-B3BPLPKQ.js → chunk-R3R3ZDFC.js} +2 -2
- package/dist/{chunk-36J3IZBS.js → chunk-RSATPXU4.js} +4 -0
- package/dist/{chunk-XZW3BXZW.js → chunk-RWIYYFID.js} +20 -14
- package/dist/{chunk-AHH5USEA.js → chunk-SSETL5EX.js} +2 -2
- package/dist/{chunk-W2KZTDET.js → chunk-WZCPZVUC.js} +2 -2
- package/dist/{chunk-4BXRRHDC.js → chunk-XCXUVX7I.js} +12 -3
- package/dist/{chunk-LSHGJI4S.js → chunk-XXT3C2EF.js} +22 -22
- package/dist/{chunk-ZRQWV3MS.js → chunk-YEIPPZ5W.js} +3 -3
- package/dist/{chunk-IP5WSADC.js → chunk-YFKAC4LB.js} +19 -19
- package/dist/{chunk-2VGLZIU6.js → chunk-ZEP6JIRF.js} +1 -1
- package/dist/{conductor-P7XPGYF4.js → conductor-GURU5XD7.js} +5 -5
- package/dist/{conductor-MAYZSFL6.js → conductor-HT2UANDY.js} +6 -6
- package/dist/{coordinator-prompt-NAM5JHLT.js → coordinator-prompt-AROMFCP2.js} +3 -3
- package/dist/{coordinator-prompt-OZFKNCM3.js → coordinator-prompt-K6XHUG3N.js} +3 -3
- package/dist/{global-workspace-UGR6FQXI.js → global-workspace-4WAU4PAL.js} +3 -3
- package/dist/{global-workspace-CTFQDG7G.js → global-workspace-PX4GUVLW.js} +3 -3
- package/dist/index.cjs +58 -13
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +40 -24
- package/dist/mcp/run-stdio.cjs +78 -37
- package/dist/mcp/run-stdio.js +39 -16
- package/dist/{optional-cli-FRUZSZ3U.js → optional-cli-JQVNSMSU.js} +3 -3
- package/dist/{optional-cli-6SW4OOX3.js → optional-cli-PZXDOVJJ.js} +4 -4
- package/dist/{orchestrator-BOGVTCWI.js → orchestrator-VDYZSZWY.js} +11 -11
- package/dist/{orchestrator-4QVF6CE2.js → orchestrator-VNSEXL62.js} +9 -9
- package/dist/{workspaces-QNKFBA63.js → workspaces-MFU3IGAP.js} +3 -3
- package/dist/{workspaces-YNZXVBSF.js → workspaces-U7SSD27C.js} +3 -3
- package/dist/{worktree-EMCWDPZJ.js → worktree-2VSHRI72.js} +2 -2
- package/dist/{worktree-ERRH4TAG.js → worktree-TQKASYPZ.js} +2 -2
- package/package.json +1 -1
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
toAbleTimeIssueInfo,
|
|
19
19
|
updateAbleTimeTask,
|
|
20
20
|
verifyAbleTimeConnection
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-MOP5L5QZ.js";
|
|
22
|
+
import "./chunk-SSETL5EX.js";
|
|
23
|
+
import "./chunk-HSF2RQSQ.js";
|
|
24
24
|
import "./chunk-2GPQZZLY.js";
|
|
25
25
|
import "./chunk-N2WW62LF.js";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-BU6HH5VA.js";
|
|
27
27
|
import "./chunk-NSTQ6QKD.js";
|
|
28
28
|
import "./chunk-WWUABK6B.js";
|
|
29
29
|
import "./chunk-FJZWM2ON.js";
|
|
@@ -16,12 +16,12 @@ import {
|
|
|
16
16
|
toAbleTimeIssueInfo,
|
|
17
17
|
updateAbleTimeTask,
|
|
18
18
|
verifyAbleTimeConnection
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-LZVWKJXY.js";
|
|
20
|
+
import "./chunk-R3R3ZDFC.js";
|
|
21
|
+
import "./chunk-FAXOEKQR.js";
|
|
22
22
|
import "./chunk-JAT3JFOS.js";
|
|
23
23
|
import "./chunk-6K64FJDD.js";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-RSATPXU4.js";
|
|
25
25
|
import "./chunk-77WWLBCI.js";
|
|
26
26
|
import "./chunk-4TR3HZFT.js";
|
|
27
27
|
import "./chunk-WDRMZKVB.js";
|
|
@@ -20,10 +20,10 @@ import {
|
|
|
20
20
|
parseAbleTimeOAuthCallbackUrl,
|
|
21
21
|
resolveAbleTimeOAuthHost,
|
|
22
22
|
startAbleTimeOAuth
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-3D3GGL6X.js";
|
|
24
|
+
import "./chunk-FAXOEKQR.js";
|
|
25
25
|
import "./chunk-JAT3JFOS.js";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-RSATPXU4.js";
|
|
27
27
|
import "./chunk-77WWLBCI.js";
|
|
28
28
|
import "./chunk-4TR3HZFT.js";
|
|
29
29
|
import "./chunk-WDRMZKVB.js";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
DEFAULT_ABLETIME_HOST,
|
|
5
5
|
normalizeAbleTimeHost
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HSF2RQSQ.js";
|
|
7
7
|
import {
|
|
8
8
|
httpFetch
|
|
9
9
|
} from "./chunk-2GPQZZLY.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getAbleTimeHost,
|
|
13
13
|
loadAppSettings,
|
|
14
14
|
saveAbleTimeConnection
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BU6HH5VA.js";
|
|
16
16
|
import "./chunk-NSTQ6QKD.js";
|
|
17
17
|
import "./chunk-WWUABK6B.js";
|
|
18
18
|
import "./chunk-FJZWM2ON.js";
|
|
@@ -288,7 +288,7 @@ async function startAbleTimeOAuth(opts) {
|
|
|
288
288
|
persistAbleTimeTokens(data, { host });
|
|
289
289
|
const token = data.access_token.trim();
|
|
290
290
|
try {
|
|
291
|
-
const { getAbleTimeOrientation } = await import("./abletime-
|
|
291
|
+
const { getAbleTimeOrientation } = await import("./abletime-APP3DZ4P.js");
|
|
292
292
|
const orientation = await getAbleTimeOrientation({ token, host });
|
|
293
293
|
return saveAbleTimeConnection({
|
|
294
294
|
accessToken: token,
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
callAbleTimeRestTool,
|
|
8
8
|
looksLikeAbleTimeUlid,
|
|
9
9
|
textFromAbleTimeDoc
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-SSETL5EX.js";
|
|
11
|
+
import "./chunk-HSF2RQSQ.js";
|
|
12
12
|
import "./chunk-2GPQZZLY.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-BU6HH5VA.js";
|
|
14
14
|
import "./chunk-NSTQ6QKD.js";
|
|
15
15
|
import "./chunk-WWUABK6B.js";
|
|
16
16
|
import "./chunk-FJZWM2ON.js";
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
callAbleTimeRestTool,
|
|
6
6
|
looksLikeAbleTimeUlid,
|
|
7
7
|
textFromAbleTimeDoc
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-R3R3ZDFC.js";
|
|
9
|
+
import "./chunk-FAXOEKQR.js";
|
|
10
10
|
import "./chunk-JAT3JFOS.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-RSATPXU4.js";
|
|
12
12
|
import "./chunk-77WWLBCI.js";
|
|
13
13
|
import "./chunk-4TR3HZFT.js";
|
|
14
14
|
import "./chunk-WDRMZKVB.js";
|
|
@@ -1402,6 +1402,113 @@ function clipAgentEventForEmit(event, cwd) {
|
|
|
1402
1402
|
return event;
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
|
+
// src/agents/cursor-tool-guard.ts
|
|
1406
|
+
var CURSOR_TOOL_RECOVERY_HINT = "Continue with a smaller request. If you were reading a large file or API payload, pass offset and limit or write the output to .context/cli/ and read a slice. Do not retry the same call.";
|
|
1407
|
+
function cursorToolErrorText(err) {
|
|
1408
|
+
const raw = formatUnknownDetail(err).replace(/\s+/g, " ").trim();
|
|
1409
|
+
const message = looksLikeHugeToolResultDump(raw) ? HUGE_TOOL_RESULT_SUMMARY : (raw || "unknown tool error").slice(0, 500);
|
|
1410
|
+
return `Error: ${message}
|
|
1411
|
+
${CURSOR_TOOL_RECOVERY_HINT}`;
|
|
1412
|
+
}
|
|
1413
|
+
function cursorToolErrorResult(err) {
|
|
1414
|
+
return {
|
|
1415
|
+
isError: true,
|
|
1416
|
+
content: [{ type: "text", text: cursorToolErrorText(err) }]
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
function boundedCursorToolResult(result, opts) {
|
|
1420
|
+
const prefix = opts?.name ?? "cursor-tool";
|
|
1421
|
+
if (typeof result === "string") {
|
|
1422
|
+
return spillAndClipToolResult(result, { cwd: opts?.cwd, prefix });
|
|
1423
|
+
}
|
|
1424
|
+
if (result == null) {
|
|
1425
|
+
return cursorToolErrorText(new Error("tool returned no result"));
|
|
1426
|
+
}
|
|
1427
|
+
let json;
|
|
1428
|
+
try {
|
|
1429
|
+
json = JSON.stringify(result);
|
|
1430
|
+
} catch (err) {
|
|
1431
|
+
return cursorToolErrorText(err);
|
|
1432
|
+
}
|
|
1433
|
+
return spillAndClipToolResult(json, { cwd: opts?.cwd, prefix });
|
|
1434
|
+
}
|
|
1435
|
+
function guardCursorCustomTool(tool, opts) {
|
|
1436
|
+
const execute = tool.execute.bind(tool);
|
|
1437
|
+
return {
|
|
1438
|
+
...tool,
|
|
1439
|
+
execute: async (args, context) => {
|
|
1440
|
+
try {
|
|
1441
|
+
const result = await execute(args, context);
|
|
1442
|
+
return boundedCursorToolResult(result, opts);
|
|
1443
|
+
} catch (err) {
|
|
1444
|
+
return cursorToolErrorResult(err);
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
var NON_RECOVERABLE_RUN_ERROR = /invalid (?:user )?api key|not logged in|not authenticated|unauthorized|credit balance|out of credits|insufficient.?quota|usage limit|you've hit your|too many requests|rate.?limit/;
|
|
1450
|
+
function shouldReturnRunErrorToAgent(detail) {
|
|
1451
|
+
const text = detail.trim();
|
|
1452
|
+
if (!text) return false;
|
|
1453
|
+
if (looksLikeHugeToolResultDump(text) || looksLikeCursorStreamCutOff(text)) return true;
|
|
1454
|
+
const head = text.slice(0, 2e3).toLowerCase();
|
|
1455
|
+
if (NON_RECOVERABLE_RUN_ERROR.test(head)) return false;
|
|
1456
|
+
return true;
|
|
1457
|
+
}
|
|
1458
|
+
function cursorRunErrorRecoveryPrompt(detail) {
|
|
1459
|
+
const summary = looksLikeHugeToolResultDump(detail) ? HUGE_TOOL_RESULT_SUMMARY : detail.replace(/\s+/g, " ").trim().slice(0, 400);
|
|
1460
|
+
return [
|
|
1461
|
+
"A tool call failed before its result reached you. The session is still open.",
|
|
1462
|
+
`Error: ${summary || "unknown"}`,
|
|
1463
|
+
CURSOR_TOOL_RECOVERY_HINT
|
|
1464
|
+
].join("\n");
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
// src/agents/cursor-stale-runs.ts
|
|
1468
|
+
async function cancelStaleCursorRuns(Agent, agentId, opts) {
|
|
1469
|
+
let cancelled = 0;
|
|
1470
|
+
const listed = await Agent.listRuns(agentId, {
|
|
1471
|
+
runtime: "local",
|
|
1472
|
+
cwd: opts.cwd,
|
|
1473
|
+
store: opts.store,
|
|
1474
|
+
limit: 20
|
|
1475
|
+
});
|
|
1476
|
+
for (const run2 of listed.items) {
|
|
1477
|
+
if (run2.status !== "running") continue;
|
|
1478
|
+
try {
|
|
1479
|
+
await Agent.cancelRun(run2.id, {
|
|
1480
|
+
runtime: "local",
|
|
1481
|
+
cwd: opts.cwd,
|
|
1482
|
+
store: opts.store
|
|
1483
|
+
});
|
|
1484
|
+
cancelled += 1;
|
|
1485
|
+
} catch {
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
if (cancelled > 0 || !opts.apiKey) return cancelled;
|
|
1489
|
+
try {
|
|
1490
|
+
const cloud = await Agent.listRuns(agentId, {
|
|
1491
|
+
runtime: "cloud",
|
|
1492
|
+
apiKey: opts.apiKey,
|
|
1493
|
+
limit: 20
|
|
1494
|
+
});
|
|
1495
|
+
for (const run2 of cloud.items) {
|
|
1496
|
+
if (run2.status !== "running") continue;
|
|
1497
|
+
try {
|
|
1498
|
+
await Agent.cancelRun(run2.id, {
|
|
1499
|
+
runtime: "cloud",
|
|
1500
|
+
agentId,
|
|
1501
|
+
apiKey: opts.apiKey
|
|
1502
|
+
});
|
|
1503
|
+
cancelled += 1;
|
|
1504
|
+
} catch {
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
} catch {
|
|
1508
|
+
}
|
|
1509
|
+
return cancelled;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1405
1512
|
// src/agents/cursor-events.ts
|
|
1406
1513
|
function usageFromCursor(usage) {
|
|
1407
1514
|
if (!usage) return null;
|
|
@@ -1784,49 +1891,6 @@ function localAgentStore(Store, threadId) {
|
|
|
1784
1891
|
(0, import_node_fs18.mkdirSync)(root, { recursive: true });
|
|
1785
1892
|
return new Store(root);
|
|
1786
1893
|
}
|
|
1787
|
-
async function cancelStaleRuns(Agent, agentId, opts) {
|
|
1788
|
-
let cancelled = 0;
|
|
1789
|
-
const listed = await Agent.listRuns(agentId, {
|
|
1790
|
-
runtime: "local",
|
|
1791
|
-
cwd: opts.cwd,
|
|
1792
|
-
store: opts.store,
|
|
1793
|
-
limit: 20
|
|
1794
|
-
});
|
|
1795
|
-
for (const run2 of listed.items) {
|
|
1796
|
-
if (run2.status !== "running") continue;
|
|
1797
|
-
try {
|
|
1798
|
-
await Agent.cancelRun(run2.id, {
|
|
1799
|
-
runtime: "local",
|
|
1800
|
-
cwd: opts.cwd,
|
|
1801
|
-
store: opts.store
|
|
1802
|
-
});
|
|
1803
|
-
cancelled += 1;
|
|
1804
|
-
} catch {
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
if (cancelled > 0 || !opts.apiKey) return cancelled;
|
|
1808
|
-
try {
|
|
1809
|
-
const cloud = await Agent.listRuns(agentId, {
|
|
1810
|
-
runtime: "cloud",
|
|
1811
|
-
apiKey: opts.apiKey,
|
|
1812
|
-
limit: 20
|
|
1813
|
-
});
|
|
1814
|
-
for (const run2 of cloud.items) {
|
|
1815
|
-
if (run2.status !== "running") continue;
|
|
1816
|
-
try {
|
|
1817
|
-
await Agent.cancelRun(run2.id, {
|
|
1818
|
-
runtime: "cloud",
|
|
1819
|
-
agentId,
|
|
1820
|
-
apiKey: opts.apiKey
|
|
1821
|
-
});
|
|
1822
|
-
cancelled += 1;
|
|
1823
|
-
} catch {
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
} catch {
|
|
1827
|
-
}
|
|
1828
|
-
return cancelled;
|
|
1829
|
-
}
|
|
1830
1894
|
async function readStdinJson() {
|
|
1831
1895
|
const rl = (0, import_node_readline2.createInterface)({ input: process.stdin, crlfDelay: Infinity });
|
|
1832
1896
|
const chunks = [];
|
|
@@ -1896,10 +1960,16 @@ async function main() {
|
|
|
1896
1960
|
}
|
|
1897
1961
|
}
|
|
1898
1962
|
}) : {};
|
|
1899
|
-
const
|
|
1963
|
+
const rawCustomTools = {
|
|
1900
1964
|
read: slicedReadCustomToolConfig(req.cwd),
|
|
1901
1965
|
...rpcTools
|
|
1902
1966
|
};
|
|
1967
|
+
const customTools = Object.fromEntries(
|
|
1968
|
+
Object.entries(rawCustomTools).map(([name, tool]) => [
|
|
1969
|
+
name,
|
|
1970
|
+
guardCursorCustomTool(tool, { cwd: req.cwd, name })
|
|
1971
|
+
])
|
|
1972
|
+
);
|
|
1903
1973
|
const local = withCursorLocalHangGuards({
|
|
1904
1974
|
cwd: req.cwd,
|
|
1905
1975
|
store,
|
|
@@ -1946,7 +2016,7 @@ async function main() {
|
|
|
1946
2016
|
}
|
|
1947
2017
|
}
|
|
1948
2018
|
async function retryAfterBusy(agent) {
|
|
1949
|
-
const n = await
|
|
2019
|
+
const n = await cancelStaleCursorRuns(Agent, agent.agentId, {
|
|
1950
2020
|
cwd: req.cwd,
|
|
1951
2021
|
store,
|
|
1952
2022
|
...apiKey ? { apiKey } : {}
|
|
@@ -1959,17 +2029,17 @@ async function main() {
|
|
|
1959
2029
|
await new Promise((resolve2) => setTimeout(resolve2, CURSOR_BUSY_RETRY_DELAY_MS));
|
|
1960
2030
|
}
|
|
1961
2031
|
}
|
|
1962
|
-
async function sendPrompt(agent, extra) {
|
|
2032
|
+
async function sendPrompt(agent, prompt, extra) {
|
|
1963
2033
|
const sendOpts = {
|
|
1964
2034
|
...cursorSendOptions(mcpServers),
|
|
1965
2035
|
...extra
|
|
1966
2036
|
};
|
|
1967
2037
|
try {
|
|
1968
|
-
return await retryTransport(() => agent.send(
|
|
2038
|
+
return await retryTransport(() => agent.send(prompt, sendOpts));
|
|
1969
2039
|
} catch (err) {
|
|
1970
2040
|
if (!isAgentBusyError(err)) throw err;
|
|
1971
2041
|
await retryAfterBusy(agent);
|
|
1972
|
-
return retryTransport(() => agent.send(
|
|
2042
|
+
return retryTransport(() => agent.send(prompt, sendOpts));
|
|
1973
2043
|
}
|
|
1974
2044
|
}
|
|
1975
2045
|
let liveRun = null;
|
|
@@ -1997,7 +2067,7 @@ async function main() {
|
|
|
1997
2067
|
};
|
|
1998
2068
|
process.once("SIGTERM", onSignal);
|
|
1999
2069
|
process.once("SIGINT", onSignal);
|
|
2000
|
-
async function runTurn(agent) {
|
|
2070
|
+
async function runTurn(agent, prompt = req.prompt, recoveryLeft = 1) {
|
|
2001
2071
|
emit({ type: "session_id", data: agent.agentId });
|
|
2002
2072
|
const stream = createAgentStreamCoalescer(emit);
|
|
2003
2073
|
const activity = { at: Date.now() };
|
|
@@ -2011,7 +2081,7 @@ async function main() {
|
|
|
2011
2081
|
} catch {
|
|
2012
2082
|
}
|
|
2013
2083
|
let lastUsageRunId;
|
|
2014
|
-
const run2 = await sendPrompt(agent, {
|
|
2084
|
+
const run2 = await sendPrompt(agent, prompt, {
|
|
2015
2085
|
onDelta: ({ update }) => {
|
|
2016
2086
|
bump();
|
|
2017
2087
|
for (const event of cursorDeltaToEvents(update)) {
|
|
@@ -2056,6 +2126,14 @@ async function main() {
|
|
|
2056
2126
|
if (isAgentBusyError(detail)) {
|
|
2057
2127
|
throw Object.assign(new Error(detail || "agent still running"), { name: "AgentBusyError" });
|
|
2058
2128
|
}
|
|
2129
|
+
if (recoveryLeft > 0 && shouldReturnRunErrorToAgent(detail)) {
|
|
2130
|
+
const brief = detail.replace(/\s+/g, " ").trim().slice(0, 240);
|
|
2131
|
+
emit({
|
|
2132
|
+
type: "stderr",
|
|
2133
|
+
data: `Cursor tool error \u2014 handing it back to the agent (${brief})`
|
|
2134
|
+
});
|
|
2135
|
+
return runTurn(agent, cursorRunErrorRecoveryPrompt(detail), 0);
|
|
2136
|
+
}
|
|
2059
2137
|
emit({
|
|
2060
2138
|
type: "stderr",
|
|
2061
2139
|
data: detail ? `Cursor run failed (${result.id}): ${detail}` : `Cursor run failed (${result.id})`
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
clipAgentEventForEmit,
|
|
4
|
+
cursorRunErrorRecoveryPrompt,
|
|
5
|
+
guardCursorCustomTool,
|
|
6
|
+
shouldReturnRunErrorToAgent,
|
|
4
7
|
sideboardCursorRpcTools
|
|
5
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-ER6BGGME.js";
|
|
6
9
|
import {
|
|
7
10
|
createAgentStreamCoalescer
|
|
8
11
|
} from "../chunk-AXQ4ZWHK.js";
|
|
@@ -17,12 +20,12 @@ import {
|
|
|
17
20
|
fetchCursorTurnCostUsd,
|
|
18
21
|
importCursorSdk,
|
|
19
22
|
resolveCursorSdkRoot
|
|
20
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-IOY2LF3Y.js";
|
|
21
24
|
import {
|
|
22
25
|
TOOL_RESULT_STORE_MAX_CHARS,
|
|
23
26
|
formatUnknownDetail,
|
|
24
27
|
looksLikeCursorStreamCutOff
|
|
25
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-HO5R3ZRH.js";
|
|
26
29
|
import "../chunk-6K64FJDD.js";
|
|
27
30
|
import {
|
|
28
31
|
cursorSdkStoreDir
|
|
@@ -559,39 +562,8 @@ function slicedReadCustomToolConfig(cwd) {
|
|
|
559
562
|
};
|
|
560
563
|
}
|
|
561
564
|
|
|
562
|
-
// src/agents/cursor-
|
|
563
|
-
function
|
|
564
|
-
const raw = model && model.trim() || "";
|
|
565
|
-
const id = !raw || raw.toLowerCase() === "auto" || raw.toLowerCase() === "default" ? "default" : raw;
|
|
566
|
-
const isGrok47 = /^grok-4\.7(?:$|-)/i.test(id);
|
|
567
|
-
const params = [];
|
|
568
|
-
if (isGrok47) {
|
|
569
|
-
params.push({ id: "context", value: "256k" });
|
|
570
|
-
}
|
|
571
|
-
const effort = (opts.effort ?? "").trim().toLowerCase();
|
|
572
|
-
const normalized = effort === "normal" ? "medium" : effort === "low" || effort === "medium" || effort === "high" || effort === "xhigh" || effort === "max" ? effort : "";
|
|
573
|
-
if (normalized) {
|
|
574
|
-
params.push({
|
|
575
|
-
id: isGrok47 ? "reasoning_effort" : "effort",
|
|
576
|
-
value: isGrok47 && normalized === "max" ? "xhigh" : normalized
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
params.push({ id: "fast", value: opts.fast ? "true" : "false" });
|
|
580
|
-
return { id, params };
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// src/agents/cursor-runner.ts
|
|
584
|
-
dropNestedElectronEnvFromProcess();
|
|
585
|
-
function emit(event) {
|
|
586
|
-
process.stdout.write(`${JSON.stringify(clipAgentEventForEmit(event, process.cwd()))}
|
|
587
|
-
`);
|
|
588
|
-
}
|
|
589
|
-
function localAgentStore(Store, threadId) {
|
|
590
|
-
const root = cursorSdkStoreDir(threadId);
|
|
591
|
-
mkdirSync2(root, { recursive: true });
|
|
592
|
-
return new Store(root);
|
|
593
|
-
}
|
|
594
|
-
async function cancelStaleRuns(Agent, agentId, opts) {
|
|
565
|
+
// src/agents/cursor-stale-runs.ts
|
|
566
|
+
async function cancelStaleCursorRuns(Agent, agentId, opts) {
|
|
595
567
|
let cancelled = 0;
|
|
596
568
|
const listed = await Agent.listRuns(agentId, {
|
|
597
569
|
runtime: "local",
|
|
@@ -634,6 +606,39 @@ async function cancelStaleRuns(Agent, agentId, opts) {
|
|
|
634
606
|
}
|
|
635
607
|
return cancelled;
|
|
636
608
|
}
|
|
609
|
+
|
|
610
|
+
// src/agents/cursor-model-selection.ts
|
|
611
|
+
function buildCursorModelSelection(model, opts) {
|
|
612
|
+
const raw = model && model.trim() || "";
|
|
613
|
+
const id = !raw || raw.toLowerCase() === "auto" || raw.toLowerCase() === "default" ? "default" : raw;
|
|
614
|
+
const isGrok47 = /^grok-4\.7(?:$|-)/i.test(id);
|
|
615
|
+
const params = [];
|
|
616
|
+
if (isGrok47) {
|
|
617
|
+
params.push({ id: "context", value: "256k" });
|
|
618
|
+
}
|
|
619
|
+
const effort = (opts.effort ?? "").trim().toLowerCase();
|
|
620
|
+
const normalized = effort === "normal" ? "medium" : effort === "low" || effort === "medium" || effort === "high" || effort === "xhigh" || effort === "max" ? effort : "";
|
|
621
|
+
if (normalized) {
|
|
622
|
+
params.push({
|
|
623
|
+
id: isGrok47 ? "reasoning_effort" : "effort",
|
|
624
|
+
value: isGrok47 && normalized === "max" ? "xhigh" : normalized
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
params.push({ id: "fast", value: opts.fast ? "true" : "false" });
|
|
628
|
+
return { id, params };
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// src/agents/cursor-runner.ts
|
|
632
|
+
dropNestedElectronEnvFromProcess();
|
|
633
|
+
function emit(event) {
|
|
634
|
+
process.stdout.write(`${JSON.stringify(clipAgentEventForEmit(event, process.cwd()))}
|
|
635
|
+
`);
|
|
636
|
+
}
|
|
637
|
+
function localAgentStore(Store, threadId) {
|
|
638
|
+
const root = cursorSdkStoreDir(threadId);
|
|
639
|
+
mkdirSync2(root, { recursive: true });
|
|
640
|
+
return new Store(root);
|
|
641
|
+
}
|
|
637
642
|
async function readStdinJson() {
|
|
638
643
|
const rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
639
644
|
const chunks = [];
|
|
@@ -703,10 +708,16 @@ async function main() {
|
|
|
703
708
|
}
|
|
704
709
|
}
|
|
705
710
|
}) : {};
|
|
706
|
-
const
|
|
711
|
+
const rawCustomTools = {
|
|
707
712
|
read: slicedReadCustomToolConfig(req.cwd),
|
|
708
713
|
...rpcTools
|
|
709
714
|
};
|
|
715
|
+
const customTools = Object.fromEntries(
|
|
716
|
+
Object.entries(rawCustomTools).map(([name, tool]) => [
|
|
717
|
+
name,
|
|
718
|
+
guardCursorCustomTool(tool, { cwd: req.cwd, name })
|
|
719
|
+
])
|
|
720
|
+
);
|
|
710
721
|
const local = withCursorLocalHangGuards({
|
|
711
722
|
cwd: req.cwd,
|
|
712
723
|
store,
|
|
@@ -753,7 +764,7 @@ async function main() {
|
|
|
753
764
|
}
|
|
754
765
|
}
|
|
755
766
|
async function retryAfterBusy(agent) {
|
|
756
|
-
const n = await
|
|
767
|
+
const n = await cancelStaleCursorRuns(Agent, agent.agentId, {
|
|
757
768
|
cwd: req.cwd,
|
|
758
769
|
store,
|
|
759
770
|
...apiKey ? { apiKey } : {}
|
|
@@ -766,17 +777,17 @@ async function main() {
|
|
|
766
777
|
await new Promise((resolve2) => setTimeout(resolve2, CURSOR_BUSY_RETRY_DELAY_MS));
|
|
767
778
|
}
|
|
768
779
|
}
|
|
769
|
-
async function sendPrompt(agent, extra) {
|
|
780
|
+
async function sendPrompt(agent, prompt, extra) {
|
|
770
781
|
const sendOpts = {
|
|
771
782
|
...cursorSendOptions(mcpServers),
|
|
772
783
|
...extra
|
|
773
784
|
};
|
|
774
785
|
try {
|
|
775
|
-
return await retryTransport(() => agent.send(
|
|
786
|
+
return await retryTransport(() => agent.send(prompt, sendOpts));
|
|
776
787
|
} catch (err) {
|
|
777
788
|
if (!isAgentBusyError(err)) throw err;
|
|
778
789
|
await retryAfterBusy(agent);
|
|
779
|
-
return retryTransport(() => agent.send(
|
|
790
|
+
return retryTransport(() => agent.send(prompt, sendOpts));
|
|
780
791
|
}
|
|
781
792
|
}
|
|
782
793
|
let liveRun = null;
|
|
@@ -804,7 +815,7 @@ async function main() {
|
|
|
804
815
|
};
|
|
805
816
|
process.once("SIGTERM", onSignal);
|
|
806
817
|
process.once("SIGINT", onSignal);
|
|
807
|
-
async function runTurn(agent) {
|
|
818
|
+
async function runTurn(agent, prompt = req.prompt, recoveryLeft = 1) {
|
|
808
819
|
emit({ type: "session_id", data: agent.agentId });
|
|
809
820
|
const stream = createAgentStreamCoalescer(emit);
|
|
810
821
|
const activity = { at: Date.now() };
|
|
@@ -818,7 +829,7 @@ async function main() {
|
|
|
818
829
|
} catch {
|
|
819
830
|
}
|
|
820
831
|
let lastUsageRunId;
|
|
821
|
-
const run = await sendPrompt(agent, {
|
|
832
|
+
const run = await sendPrompt(agent, prompt, {
|
|
822
833
|
onDelta: ({ update }) => {
|
|
823
834
|
bump();
|
|
824
835
|
for (const event of cursorDeltaToEvents(update)) {
|
|
@@ -863,6 +874,14 @@ async function main() {
|
|
|
863
874
|
if (isAgentBusyError(detail)) {
|
|
864
875
|
throw Object.assign(new Error(detail || "agent still running"), { name: "AgentBusyError" });
|
|
865
876
|
}
|
|
877
|
+
if (recoveryLeft > 0 && shouldReturnRunErrorToAgent(detail)) {
|
|
878
|
+
const brief = detail.replace(/\s+/g, " ").trim().slice(0, 240);
|
|
879
|
+
emit({
|
|
880
|
+
type: "stderr",
|
|
881
|
+
data: `Cursor tool error \u2014 handing it back to the agent (${brief})`
|
|
882
|
+
});
|
|
883
|
+
return runTurn(agent, cursorRunErrorRecoveryPrompt(detail), 0);
|
|
884
|
+
}
|
|
866
885
|
emit({
|
|
867
886
|
type: "stderr",
|
|
868
887
|
data: detail ? `Cursor run failed (${result.id}): ${detail}` : `Cursor run failed (${result.id})`
|
|
@@ -37,9 +37,9 @@ import {
|
|
|
37
37
|
planModeTurnInstruction,
|
|
38
38
|
resolveCursorModelId,
|
|
39
39
|
resolveQuotaFallbackAgent
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-RWIYYFID.js";
|
|
41
41
|
import "./chunk-VGNLMGBK.js";
|
|
42
|
-
import "./chunk-
|
|
42
|
+
import "./chunk-Q3DPZ4DE.js";
|
|
43
43
|
import {
|
|
44
44
|
getAgentSetupInfo,
|
|
45
45
|
installAgent,
|
|
@@ -51,9 +51,9 @@ import {
|
|
|
51
51
|
prepareTerminalCommand,
|
|
52
52
|
resolveLoginCommand,
|
|
53
53
|
whichOnPath
|
|
54
|
-
} from "./chunk-
|
|
55
|
-
import "./chunk-
|
|
56
|
-
import "./chunk-
|
|
54
|
+
} from "./chunk-B42H6GJR.js";
|
|
55
|
+
import "./chunk-YEIPPZ5W.js";
|
|
56
|
+
import "./chunk-ZEP6JIRF.js";
|
|
57
57
|
import "./chunk-QB5MDOHL.js";
|
|
58
58
|
import "./chunk-2P4XKWV2.js";
|
|
59
59
|
import "./chunk-33KDPEK4.js";
|
|
@@ -66,8 +66,8 @@ import {
|
|
|
66
66
|
preferredCursorCostCents,
|
|
67
67
|
resolveCursorSdkRoot,
|
|
68
68
|
turnCostUsdFromCursorUsage
|
|
69
|
-
} from "./chunk-
|
|
70
|
-
import "./chunk-
|
|
69
|
+
} from "./chunk-IOY2LF3Y.js";
|
|
70
|
+
import "./chunk-HO5R3ZRH.js";
|
|
71
71
|
import "./chunk-6K64FJDD.js";
|
|
72
72
|
import "./chunk-UWQ6UCIB.js";
|
|
73
73
|
import {
|
|
@@ -87,7 +87,7 @@ import {
|
|
|
87
87
|
assertOrchestratorCapableAgent,
|
|
88
88
|
coerceOrchestratorAgent,
|
|
89
89
|
isOrchestratorCapableAgent
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-RSATPXU4.js";
|
|
91
91
|
import "./chunk-77WWLBCI.js";
|
|
92
92
|
import "./chunk-4TR3HZFT.js";
|
|
93
93
|
import "./chunk-WDRMZKVB.js";
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
resolveCursorSdkRoot,
|
|
47
47
|
resolveQuotaFallbackAgent,
|
|
48
48
|
turnCostUsdFromCursorUsage
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-ABLHTRRG.js";
|
|
50
50
|
import {
|
|
51
51
|
getAgentSetupInfo,
|
|
52
52
|
installAgent,
|
|
@@ -58,13 +58,13 @@ import {
|
|
|
58
58
|
prepareTerminalCommand,
|
|
59
59
|
resolveLoginCommand,
|
|
60
60
|
whichOnPath
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-WZCPZVUC.js";
|
|
62
62
|
import "./chunk-7IAMHN2N.js";
|
|
63
63
|
import "./chunk-PXMLMBMI.js";
|
|
64
64
|
import "./chunk-2GPQZZLY.js";
|
|
65
|
-
import "./chunk-
|
|
66
|
-
import "./chunk-
|
|
67
|
-
import "./chunk-
|
|
65
|
+
import "./chunk-ED4ZXQVO.js";
|
|
66
|
+
import "./chunk-E7G7RY6T.js";
|
|
67
|
+
import "./chunk-6SGYGYH7.js";
|
|
68
68
|
import "./chunk-N2WW62LF.js";
|
|
69
69
|
import "./chunk-DD67JWTN.js";
|
|
70
70
|
import {
|
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
assertOrchestratorCapableAgent,
|
|
84
84
|
coerceOrchestratorAgent,
|
|
85
85
|
isOrchestratorCapableAgent
|
|
86
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-BU6HH5VA.js";
|
|
87
87
|
import "./chunk-NSTQ6QKD.js";
|
|
88
88
|
import "./chunk-WWUABK6B.js";
|
|
89
89
|
import "./chunk-FJZWM2ON.js";
|
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
isChatTextScale,
|
|
65
65
|
isIssueSourceConnected,
|
|
66
66
|
isLinearConnected,
|
|
67
|
+
isPosthogConnected,
|
|
67
68
|
isUsageOnLimit,
|
|
68
69
|
issueSourceLabel,
|
|
69
70
|
loadAppSettings,
|
|
@@ -107,7 +108,7 @@ import {
|
|
|
107
108
|
updateProjectProfileSettings,
|
|
108
109
|
usageOnLimit,
|
|
109
110
|
writeViewerContext
|
|
110
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-BU6HH5VA.js";
|
|
111
112
|
import "./chunk-NSTQ6QKD.js";
|
|
112
113
|
import "./chunk-WWUABK6B.js";
|
|
113
114
|
import "./chunk-FJZWM2ON.js";
|
|
@@ -178,6 +179,7 @@ export {
|
|
|
178
179
|
isChatTextScale,
|
|
179
180
|
isIssueSourceConnected,
|
|
180
181
|
isLinearConnected,
|
|
182
|
+
isPosthogConnected,
|
|
181
183
|
isUsageOnLimit,
|
|
182
184
|
issueSourceLabel,
|
|
183
185
|
loadAppSettings,
|
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
isChatTextScale,
|
|
63
63
|
isIssueSourceConnected,
|
|
64
64
|
isLinearConnected,
|
|
65
|
+
isPosthogConnected,
|
|
65
66
|
isUsageOnLimit,
|
|
66
67
|
issueSourceLabel,
|
|
67
68
|
loadAppSettings,
|
|
@@ -105,7 +106,7 @@ import {
|
|
|
105
106
|
updateProjectProfileSettings,
|
|
106
107
|
usageOnLimit,
|
|
107
108
|
writeViewerContext
|
|
108
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-RSATPXU4.js";
|
|
109
110
|
import "./chunk-77WWLBCI.js";
|
|
110
111
|
import "./chunk-4TR3HZFT.js";
|
|
111
112
|
import "./chunk-WDRMZKVB.js";
|
|
@@ -176,6 +177,7 @@ export {
|
|
|
176
177
|
isChatTextScale,
|
|
177
178
|
isIssueSourceConnected,
|
|
178
179
|
isLinearConnected,
|
|
180
|
+
isPosthogConnected,
|
|
179
181
|
isUsageOnLimit,
|
|
180
182
|
issueSourceLabel,
|
|
181
183
|
loadAppSettings,
|