@sideboard-ai/core 0.1.351 → 0.1.353
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-TX7BTTR2.js → abletime-5LEOMLQE.js} +4 -4
- package/dist/{abletime-URSRZW7P.js → abletime-VUPUERE4.js} +4 -4
- package/dist/{abletime-oauth-QS3WPSCC.js → abletime-oauth-65LHLQ7P.js} +3 -3
- package/dist/{abletime-oauth-SL3NMNEC.js → abletime-oauth-JAINJBNY.js} +3 -3
- package/dist/{abletime-rest-JZU6JJCV.js → abletime-rest-4TCWPN7E.js} +3 -3
- package/dist/{abletime-rest-GGQLUO55.js → abletime-rest-HBIK234Y.js} +3 -3
- package/dist/agents/claude-runner.cjs +37 -6
- package/dist/agents/claude-runner.js +16 -1
- package/dist/agents/cursor-runner.cjs +56 -12
- package/dist/agents/cursor-runner.js +2 -2
- package/dist/{agents-INTH7J3F.js → agents-5LFUHPSA.js} +9 -9
- package/dist/{agents-D5CL4CR4.js → agents-6B2HHICJ.js} +8 -8
- package/dist/{app-settings-IA7ZZKWQ.js → app-settings-GM4MJD2E.js} +3 -1
- package/dist/{app-settings-XILTSD6L.js → app-settings-X3UFWRAF.js} +3 -1
- package/dist/{chunk-BZK62VPT.js → chunk-2S7EAUDI.js} +2 -2
- package/dist/{chunk-CCWQ65VD.js → chunk-2SFKLWU5.js} +2 -2
- package/dist/{chunk-YVN7L4KG.js → chunk-AF5K6GQU.js} +6 -1
- package/dist/{chunk-WB3G2LQO.js → chunk-BCNPZ7H2.js} +1 -1
- package/dist/chunk-EAV2ZF5S.js +858 -0
- package/dist/{chunk-SMSD6U3N.js → chunk-GA5MLYVG.js} +1 -1
- package/dist/{chunk-HISSQICH.js → chunk-HBRP2SHA.js} +3 -3
- package/dist/{chunk-7WPQAVS5.js → chunk-HMSXKV53.js} +150 -126
- package/dist/{chunk-DL4OHDBV.js → chunk-I6BKWSCT.js} +3 -3
- package/dist/{chunk-WJURGCBR.js → chunk-KSBJOWVO.js} +1 -1
- package/dist/{chunk-J4EA5SHF.js → chunk-LZ3TAKNJ.js} +3 -3
- package/dist/{chunk-F4RFFE2H.js → chunk-M426EW7O.js} +3 -3
- package/dist/{chunk-C3E2DGDF.js → chunk-MBQU6RE2.js} +6 -6
- package/dist/{chunk-UXAKH4AW.js → chunk-MX2XU4BS.js} +418 -71
- package/dist/{chunk-TCEUNSLX.js → chunk-NRGT7RMO.js} +1 -1
- package/dist/{chunk-M45WGODR.js → chunk-OCCUD5CK.js} +2 -2
- package/dist/{chunk-BDWVBEKN.js → chunk-PKH3DRA6.js} +153 -127
- package/dist/{chunk-YE7Z5WH3.js → chunk-QKNOKO2P.js} +1 -1
- package/dist/{chunk-VL6F2KRE.js → chunk-RMJXFABA.js} +8 -6
- package/dist/{chunk-FQ3JYUKI.js → chunk-SBUR2WCP.js} +2 -2
- package/dist/{chunk-AEEOYLVK.js → chunk-SWU5C3HQ.js} +6 -6
- package/dist/{chunk-UFUAIVNV.js → chunk-TB7SYXXS.js} +8 -6
- package/dist/{chunk-7ZD4OK6G.js → chunk-TDWE7INS.js} +1 -1
- package/dist/{chunk-WFX4ZVSZ.js → chunk-TRUNDXCE.js} +1 -1
- package/dist/{chunk-PXSWVZIL.js → chunk-UPJB6TFI.js} +2 -2
- package/dist/{chunk-37ZBEBP6.js → chunk-VZAICZHU.js} +3 -3
- package/dist/{chunk-FCKTBE26.js → chunk-WJQFWDGH.js} +1 -1
- package/dist/{chunk-SZY23KGS.js → chunk-WTT525MC.js} +3 -3
- package/dist/{chunk-BF6INES4.js → chunk-X52SO3DM.js} +1 -1
- package/dist/{chunk-B4EFQTMP.js → chunk-XB6NCBZK.js} +5 -5
- package/dist/{chunk-5TCMXEYL.js → chunk-YGXUIBIT.js} +3 -3
- package/dist/{chunk-AAKQU4UZ.js → chunk-Z3CGD5HC.js} +28 -10
- package/dist/{chunk-VHQ6OG3U.js → chunk-ZHYFRRPN.js} +2 -2
- package/dist/{chunk-5WF54R3B.js → chunk-ZLPP66IP.js} +5 -5
- package/dist/{conductor-FWYWIHEW.js → conductor-2UOW2XBE.js} +6 -6
- package/dist/{conductor-W2X7QUKZ.js → conductor-6NYG2SZA.js} +6 -6
- package/dist/{coordinator-prompt-J57Q4Z4W.js → coordinator-prompt-K3WT5UVS.js} +4 -4
- package/dist/{coordinator-prompt-KIHNLENN.js → coordinator-prompt-ZP6AEETR.js} +4 -4
- package/dist/{global-workspace-WXDWFZAN.js → global-workspace-EFPSYP4N.js} +4 -4
- package/dist/{global-workspace-CGB5CY4U.js → global-workspace-EPVNFQVC.js} +4 -4
- package/dist/index.cjs +1414 -869
- package/dist/index.d.cts +116 -10
- package/dist/index.d.ts +116 -10
- package/dist/index.js +398 -315
- package/dist/{linear-WG23LBCX.js → linear-4ACCQCWM.js} +2 -2
- package/dist/{linear-E3BX5PX5.js → linear-Q2E6LKJW.js} +2 -2
- package/dist/{linear-list-VU47BNUV.js → linear-list-5A3BAWRZ.js} +1 -1
- package/dist/{linear-list-OINZWVV5.js → linear-list-V3A57XBR.js} +1 -1
- package/dist/mcp/run-stdio.cjs +1227 -802
- package/dist/mcp/run-stdio.js +342 -308
- package/dist/{optional-cli-K6HX2X5O.js → optional-cli-CKQPLY4Q.js} +4 -4
- package/dist/{optional-cli-SA3EQYML.js → optional-cli-WE3ULLFV.js} +5 -5
- package/dist/{orchestrator-MUD4FY7Q.js → orchestrator-UFHS2FOC.js} +12 -12
- package/dist/{orchestrator-DMEE7CEW.js → orchestrator-YCGWSIHF.js} +11 -11
- package/dist/{thread-store-4YTOV2HL.js → thread-store-CDFHHRXB.js} +2 -2
- package/dist/{thread-store-LME2ICZP.js → thread-store-TDGZEGS6.js} +2 -2
- package/dist/{workspaces-ZCTF4ECL.js → workspaces-KL4SZMJE.js} +4 -4
- package/dist/{workspaces-7DPHDXNY.js → workspaces-SQRR67HD.js} +4 -4
- package/dist/{worktree-4ATMCYIE.js → worktree-7KG5N2XL.js} +3 -3
- package/dist/{worktree-DA6SKIU5.js → worktree-IDX7LMBC.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-SUZOPJZC.js +0 -430
|
@@ -16,16 +16,16 @@ import {
|
|
|
16
16
|
detectAcpHarness,
|
|
17
17
|
isAcpHarnessId,
|
|
18
18
|
resolveAcpHarnessCommand
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-X52SO3DM.js";
|
|
20
20
|
import {
|
|
21
21
|
isOrchestratorThread
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-WTT525MC.js";
|
|
23
23
|
import {
|
|
24
24
|
codexUnattendedGitConfigArgs,
|
|
25
25
|
mergeAgentGitAuthEnv,
|
|
26
26
|
resolveAgentGitAuthEnv,
|
|
27
27
|
resolveCodexGitWritableRoots
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-ZHYFRRPN.js";
|
|
29
29
|
import {
|
|
30
30
|
applyConnectedTeamToCli,
|
|
31
31
|
brightsyMcpServerName,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
} from "./chunk-2GPQZZLY.js";
|
|
41
41
|
import {
|
|
42
42
|
listAssignedLinearIssues
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-TRUNDXCE.js";
|
|
44
44
|
import {
|
|
45
45
|
githubAgentAuthReady,
|
|
46
46
|
npmGlobalNodeModules,
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
CLAUDE_POSTHOG_CONNECTOR_ALLOWED_TOOLS,
|
|
53
53
|
CLAUDE_PRINT_BG_WAIT_CEILING_MS,
|
|
54
54
|
mcpAllowToolsFromNames
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-GA5MLYVG.js";
|
|
56
56
|
import {
|
|
57
57
|
claudeChromeEnabled,
|
|
58
58
|
fromInclusiveInputUsage,
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
requestOccupancy,
|
|
64
64
|
resolveAgentExecutable,
|
|
65
65
|
resolveClaudeExecutable
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-RMJXFABA.js";
|
|
67
67
|
import {
|
|
68
68
|
isElectronLikeCommand,
|
|
69
69
|
unwrapStrippedElectronLaunch,
|
|
@@ -553,7 +553,8 @@ function injectedSideboardMcpEnv(opts) {
|
|
|
553
553
|
var AGENT_RPC_PILOT_MCP_TOOLS = [
|
|
554
554
|
"present_artifact",
|
|
555
555
|
"wait_for_job",
|
|
556
|
-
"stop_job"
|
|
556
|
+
"stop_job",
|
|
557
|
+
"computer_use"
|
|
557
558
|
];
|
|
558
559
|
function shouldRegisterMcpWaitForTurn(env = process.env) {
|
|
559
560
|
return !agentRpcOwnsPilotTools(env);
|
|
@@ -575,6 +576,7 @@ var WORKTREE_MCP_TOOLS = [
|
|
|
575
576
|
"run_dev_script",
|
|
576
577
|
"stop_dev_script",
|
|
577
578
|
"get_run_log",
|
|
579
|
+
"computer_use",
|
|
578
580
|
"get_orchestrator",
|
|
579
581
|
"notify_orchestrator",
|
|
580
582
|
"set_workspace_tags",
|
|
@@ -3171,9 +3173,332 @@ function agentRpcChildEnv(rpc, cwd) {
|
|
|
3171
3173
|
// src/agents/claude-host.ts
|
|
3172
3174
|
import { existsSync as existsSync12 } from "fs";
|
|
3173
3175
|
import { createRequire as createRequire3 } from "module";
|
|
3174
|
-
import { dirname as dirname5, join as
|
|
3176
|
+
import { dirname as dirname5, join as join14 } from "path";
|
|
3175
3177
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
3176
3178
|
|
|
3179
|
+
// src/computer-use/computer-use.ts
|
|
3180
|
+
import { execFile } from "child_process";
|
|
3181
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
3182
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
3183
|
+
import { isAbsolute as isAbsolute2, join as join13 } from "path";
|
|
3184
|
+
import { promisify } from "util";
|
|
3185
|
+
|
|
3186
|
+
// src/computer-use/bridge.ts
|
|
3187
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
3188
|
+
import { join as join12 } from "path";
|
|
3189
|
+
function computerUseBridgePath() {
|
|
3190
|
+
return join12(appDataDir(), "computer-use-bridge.json");
|
|
3191
|
+
}
|
|
3192
|
+
function readComputerUseBridge(file = computerUseBridgePath()) {
|
|
3193
|
+
try {
|
|
3194
|
+
const raw = JSON.parse(readFileSync7(file, "utf8"));
|
|
3195
|
+
if (typeof raw.port !== "number" || !Number.isInteger(raw.port)) return null;
|
|
3196
|
+
if (raw.port < 1 || raw.port > 65535) return null;
|
|
3197
|
+
if (typeof raw.token !== "string" || raw.token.length < 16) return null;
|
|
3198
|
+
return { port: raw.port, token: raw.token };
|
|
3199
|
+
} catch {
|
|
3200
|
+
return null;
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
function cgScrollWheels(dx, dy) {
|
|
3204
|
+
return { wheel1: -dy, wheel2: -dx };
|
|
3205
|
+
}
|
|
3206
|
+
async function bridgeError(res) {
|
|
3207
|
+
try {
|
|
3208
|
+
const body = await res.json();
|
|
3209
|
+
if (typeof body.error === "string" && body.error) return body.error;
|
|
3210
|
+
} catch {
|
|
3211
|
+
}
|
|
3212
|
+
return `computer use bridge returned ${res.status}`;
|
|
3213
|
+
}
|
|
3214
|
+
async function bridgeFetch(info, path, init) {
|
|
3215
|
+
try {
|
|
3216
|
+
return await fetch(`http://127.0.0.1:${info.port}${path}`, {
|
|
3217
|
+
...init,
|
|
3218
|
+
headers: {
|
|
3219
|
+
authorization: `Bearer ${info.token}`,
|
|
3220
|
+
...init.headers
|
|
3221
|
+
},
|
|
3222
|
+
signal: AbortSignal.timeout(15e3)
|
|
3223
|
+
});
|
|
3224
|
+
} catch {
|
|
3225
|
+
return null;
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
async function postComputerUseBridge(event, file = computerUseBridgePath()) {
|
|
3229
|
+
const info = readComputerUseBridge(file);
|
|
3230
|
+
if (!info) return false;
|
|
3231
|
+
const res = await bridgeFetch(info, "/v1/event", {
|
|
3232
|
+
method: "POST",
|
|
3233
|
+
headers: { "content-type": "application/json" },
|
|
3234
|
+
body: JSON.stringify(event)
|
|
3235
|
+
});
|
|
3236
|
+
if (!res) return false;
|
|
3237
|
+
if (!res.ok) throw new Error(await bridgeError(res));
|
|
3238
|
+
return true;
|
|
3239
|
+
}
|
|
3240
|
+
async function fetchComputerUseScreenshot(file = computerUseBridgePath()) {
|
|
3241
|
+
const info = readComputerUseBridge(file);
|
|
3242
|
+
if (!info) return null;
|
|
3243
|
+
const res = await bridgeFetch(info, "/v1/screenshot", { method: "POST" });
|
|
3244
|
+
if (!res) return null;
|
|
3245
|
+
if (!res.ok) throw new Error(await bridgeError(res));
|
|
3246
|
+
const png = Buffer.from(await res.arrayBuffer());
|
|
3247
|
+
if (png.length < 24) throw new Error("screen capture was empty");
|
|
3248
|
+
const header = Number(res.headers.get("x-sideboard-scale"));
|
|
3249
|
+
return { png, scale: Number.isFinite(header) && header > 0 ? header : 1 };
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
// src/computer-use/computer-use.ts
|
|
3253
|
+
var execFileAsync = promisify(execFile);
|
|
3254
|
+
var COMPUTER_USE_OFF = "Computer use is off. Turn it on in Settings \u2192 Advanced.";
|
|
3255
|
+
var COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Clicks, typing, scrolling, and screenshots are posted by Sideboard after macOS allows Sideboard to control this Mac and record the screen. Do not drive an app you did not start for this test.";
|
|
3256
|
+
var KEY_CODES = {
|
|
3257
|
+
return: 36,
|
|
3258
|
+
enter: 36,
|
|
3259
|
+
tab: 48,
|
|
3260
|
+
escape: 53,
|
|
3261
|
+
esc: 53,
|
|
3262
|
+
delete: 51,
|
|
3263
|
+
backspace: 51,
|
|
3264
|
+
forwarddelete: 117,
|
|
3265
|
+
left: 123,
|
|
3266
|
+
right: 124,
|
|
3267
|
+
down: 125,
|
|
3268
|
+
up: 126
|
|
3269
|
+
};
|
|
3270
|
+
var MODIFIERS = /* @__PURE__ */ new Set(["command", "cmd", "shift", "option", "alt", "control", "ctrl"]);
|
|
3271
|
+
function macKeyCode(key) {
|
|
3272
|
+
const code = KEY_CODES[key];
|
|
3273
|
+
return code === void 0 ? null : code;
|
|
3274
|
+
}
|
|
3275
|
+
var PNG_SIG = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
3276
|
+
function appleScriptString(text) {
|
|
3277
|
+
return `"${text.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
3278
|
+
}
|
|
3279
|
+
function typeScripts(text) {
|
|
3280
|
+
const parts = text.split(/\r\n|\n|\r/);
|
|
3281
|
+
const scripts = [];
|
|
3282
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
3283
|
+
if (parts[i]) {
|
|
3284
|
+
scripts.push(`tell application "System Events" to keystroke ${appleScriptString(parts[i])}`);
|
|
3285
|
+
}
|
|
3286
|
+
if (i < parts.length - 1) {
|
|
3287
|
+
scripts.push('tell application "System Events" to key code 36');
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
return scripts;
|
|
3291
|
+
}
|
|
3292
|
+
function modifierClause(modifiers) {
|
|
3293
|
+
const downs = modifiers.map((name) => {
|
|
3294
|
+
if (name === "cmd" || name === "command") return "command down";
|
|
3295
|
+
if (name === "alt" || name === "option") return "option down";
|
|
3296
|
+
if (name === "ctrl" || name === "control") return "control down";
|
|
3297
|
+
return "shift down";
|
|
3298
|
+
});
|
|
3299
|
+
if (!downs.length) return "";
|
|
3300
|
+
return ` using {${downs.join(", ")}}`;
|
|
3301
|
+
}
|
|
3302
|
+
function pngPointSize(bytes) {
|
|
3303
|
+
if (bytes.length < 24 || !bytes.subarray(0, 8).equals(PNG_SIG)) {
|
|
3304
|
+
throw new Error("screenshot is not a PNG");
|
|
3305
|
+
}
|
|
3306
|
+
let pixelWidth = 0;
|
|
3307
|
+
let pixelHeight = 0;
|
|
3308
|
+
let scale = 1;
|
|
3309
|
+
let offset = 8;
|
|
3310
|
+
while (offset + 8 <= bytes.length) {
|
|
3311
|
+
const length = bytes.readUInt32BE(offset);
|
|
3312
|
+
const type = bytes.toString("ascii", offset + 4, offset + 8);
|
|
3313
|
+
const data = offset + 8;
|
|
3314
|
+
if (data + length > bytes.length) break;
|
|
3315
|
+
if (type === "IHDR" && length >= 8) {
|
|
3316
|
+
pixelWidth = bytes.readUInt32BE(data);
|
|
3317
|
+
pixelHeight = bytes.readUInt32BE(data + 4);
|
|
3318
|
+
} else if (type === "pHYs" && length >= 9 && bytes[data + 8] === 1) {
|
|
3319
|
+
const ppm = bytes.readUInt32BE(data);
|
|
3320
|
+
if (ppm > 0) scale = ppm * 0.0254 / 72;
|
|
3321
|
+
} else if (type === "IEND") {
|
|
3322
|
+
break;
|
|
3323
|
+
}
|
|
3324
|
+
offset = data + length + 4;
|
|
3325
|
+
}
|
|
3326
|
+
if (pixelWidth <= 0 || pixelHeight <= 0) throw new Error("screenshot PNG has no size");
|
|
3327
|
+
return { pixelWidth, pixelHeight, scale };
|
|
3328
|
+
}
|
|
3329
|
+
function pointGeometry(info) {
|
|
3330
|
+
const raw = info.scale > 0 && Number.isFinite(info.scale) ? info.scale : 1;
|
|
3331
|
+
const scale = Math.round(raw * 100) / 100;
|
|
3332
|
+
return {
|
|
3333
|
+
width: Math.round(info.pixelWidth / scale),
|
|
3334
|
+
height: Math.round(info.pixelHeight / scale),
|
|
3335
|
+
scale
|
|
3336
|
+
};
|
|
3337
|
+
}
|
|
3338
|
+
function scrollWheelSwift(x, y, dx, dy) {
|
|
3339
|
+
for (const n of [x, y, dx, dy]) {
|
|
3340
|
+
if (!Number.isInteger(n)) throw new Error("scroll coordinates must be integers");
|
|
3341
|
+
}
|
|
3342
|
+
const { wheel1, wheel2 } = cgScrollWheels(dx, dy);
|
|
3343
|
+
return `import CoreGraphics
|
|
3344
|
+
let src = CGEventSource(stateID: .hidSystemState)
|
|
3345
|
+
let p = CGPoint(x: ${x}, y: ${y})
|
|
3346
|
+
if let move = CGEvent(mouseEventSource: src, mouseType: .mouseMoved, mouseCursorPosition: p, mouseButton: .left) {
|
|
3347
|
+
move.post(tap: .cghidEventTap)
|
|
3348
|
+
}
|
|
3349
|
+
if let ev = CGEvent(scrollWheelEvent2Source: src, units: .pixel, wheelCount: 2, wheel1: ${wheel1}, wheel2: ${wheel2}, wheel3: 0) {
|
|
3350
|
+
ev.location = p
|
|
3351
|
+
ev.post(tap: .cghidEventTap)
|
|
3352
|
+
}
|
|
3353
|
+
`;
|
|
3354
|
+
}
|
|
3355
|
+
function asRecord4(value) {
|
|
3356
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
3357
|
+
return value;
|
|
3358
|
+
}
|
|
3359
|
+
function finite(value) {
|
|
3360
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
3361
|
+
}
|
|
3362
|
+
function point(value) {
|
|
3363
|
+
const n = Math.round(value);
|
|
3364
|
+
if (n < -8e3 || n > 2e4) return null;
|
|
3365
|
+
return n;
|
|
3366
|
+
}
|
|
3367
|
+
function scrollDelta(value) {
|
|
3368
|
+
const n = Math.round(value);
|
|
3369
|
+
if (n < -4e3 || n > 4e3) return null;
|
|
3370
|
+
return n;
|
|
3371
|
+
}
|
|
3372
|
+
function screenshotFile(cwd, now) {
|
|
3373
|
+
const root = isAbsolute2(cwd) ? cwd : tmpdir2();
|
|
3374
|
+
const dir = join13(root, ".context", "cli");
|
|
3375
|
+
mkdirSync4(dir, { recursive: true });
|
|
3376
|
+
return join13(dir, `computer-use-${now}.png`);
|
|
3377
|
+
}
|
|
3378
|
+
async function posted(runner, event) {
|
|
3379
|
+
if (!runner.postInput) return false;
|
|
3380
|
+
return runner.postInput(event);
|
|
3381
|
+
}
|
|
3382
|
+
function screenshotMessage(width, height, scale) {
|
|
3383
|
+
return `Screenshot saved (main display). Read that PNG. x and y are screen points from the top-left of this image, not PNG pixels. Divide a pixel by scale ${scale}. Point size is ${width}\xD7${height}. Judge behavior and visual design: hierarchy, alignment, spacing, type, contrast, and fit with the surrounding surface.`;
|
|
3384
|
+
}
|
|
3385
|
+
async function performComputerUse(opts) {
|
|
3386
|
+
if (!opts.enabled) return { ok: false, error: COMPUTER_USE_OFF };
|
|
3387
|
+
const rec = asRecord4(opts.input);
|
|
3388
|
+
const action = typeof rec.action === "string" ? rec.action : "";
|
|
3389
|
+
try {
|
|
3390
|
+
if (action === "screenshot") {
|
|
3391
|
+
const file = screenshotFile(opts.cwd, opts.now ?? Date.now());
|
|
3392
|
+
const captured = await opts.runner.screenshot(file);
|
|
3393
|
+
const geo = pointGeometry(captured);
|
|
3394
|
+
return {
|
|
3395
|
+
ok: true,
|
|
3396
|
+
action,
|
|
3397
|
+
path: file,
|
|
3398
|
+
width: geo.width,
|
|
3399
|
+
height: geo.height,
|
|
3400
|
+
scale: geo.scale,
|
|
3401
|
+
message: screenshotMessage(geo.width, geo.height, geo.scale)
|
|
3402
|
+
};
|
|
3403
|
+
}
|
|
3404
|
+
if (action === "click") {
|
|
3405
|
+
const x = finite(rec.x);
|
|
3406
|
+
const y = finite(rec.y);
|
|
3407
|
+
if (x === null || y === null) return { ok: false, error: "click requires finite x and y" };
|
|
3408
|
+
const px = point(x);
|
|
3409
|
+
const py = point(y);
|
|
3410
|
+
if (px === null || py === null) return { ok: false, error: "click point is out of range" };
|
|
3411
|
+
if (!await posted(opts.runner, { type: "click", x: px, y: py })) {
|
|
3412
|
+
await opts.runner.runAppleScript(
|
|
3413
|
+
`tell application "System Events" to click at {${px}, ${py}}`
|
|
3414
|
+
);
|
|
3415
|
+
}
|
|
3416
|
+
return { ok: true, action, message: `Clicked ${px}, ${py}.` };
|
|
3417
|
+
}
|
|
3418
|
+
if (action === "type") {
|
|
3419
|
+
const text = typeof rec.text === "string" ? rec.text : "";
|
|
3420
|
+
if (!text) return { ok: false, error: "type requires text" };
|
|
3421
|
+
if (text.length > 2e3) return { ok: false, error: "type text is longer than 2000 characters" };
|
|
3422
|
+
if (!await posted(opts.runner, { type: "type", text })) {
|
|
3423
|
+
for (const script of typeScripts(text)) {
|
|
3424
|
+
await opts.runner.runAppleScript(script);
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
return { ok: true, action, message: `Typed ${text.length} characters.` };
|
|
3428
|
+
}
|
|
3429
|
+
if (action === "key") {
|
|
3430
|
+
const key = typeof rec.key === "string" ? rec.key.trim().toLowerCase() : "";
|
|
3431
|
+
const modifiers = Array.isArray(rec.modifiers) ? rec.modifiers.filter((item) => typeof item === "string") : [];
|
|
3432
|
+
if (!key) return { ok: false, error: "key requires key" };
|
|
3433
|
+
if (modifiers.some((name) => !MODIFIERS.has(name.toLowerCase()))) {
|
|
3434
|
+
return { ok: false, error: "key modifiers are command, shift, option, and control" };
|
|
3435
|
+
}
|
|
3436
|
+
const mods = modifiers.map((name) => name.toLowerCase());
|
|
3437
|
+
const using = modifierClause(mods);
|
|
3438
|
+
const code = macKeyCode(key);
|
|
3439
|
+
const script = code !== null ? `tell application "System Events" to key code ${code}${using}` : key.length === 1 ? `tell application "System Events" to keystroke ${appleScriptString(key)}${using}` : "";
|
|
3440
|
+
if (!script) return { ok: false, error: `unsupported key ${key}` };
|
|
3441
|
+
if (!await posted(opts.runner, { type: "key", key, modifiers: mods })) {
|
|
3442
|
+
await opts.runner.runAppleScript(script);
|
|
3443
|
+
}
|
|
3444
|
+
return { ok: true, action, message: `Pressed ${key}.` };
|
|
3445
|
+
}
|
|
3446
|
+
if (action === "scroll") {
|
|
3447
|
+
const x = finite(rec.x);
|
|
3448
|
+
const y = finite(rec.y);
|
|
3449
|
+
if (x === null || y === null) return { ok: false, error: "scroll requires finite x and y" };
|
|
3450
|
+
const px = point(x);
|
|
3451
|
+
const py = point(y);
|
|
3452
|
+
if (px === null || py === null) return { ok: false, error: "scroll point is out of range" };
|
|
3453
|
+
const dx = finite(rec.dx) ?? 0;
|
|
3454
|
+
const dy = finite(rec.dy) ?? 0;
|
|
3455
|
+
const sdx = scrollDelta(dx);
|
|
3456
|
+
const sdy = scrollDelta(dy);
|
|
3457
|
+
if (sdx === null || sdy === null) return { ok: false, error: "scroll delta is out of range" };
|
|
3458
|
+
if (sdx === 0 && sdy === 0) return { ok: false, error: "scroll requires dx or dy" };
|
|
3459
|
+
if (!await posted(opts.runner, { type: "scroll", x: px, y: py, dx: sdx, dy: sdy })) {
|
|
3460
|
+
await opts.runner.scroll(px, py, sdx, sdy);
|
|
3461
|
+
}
|
|
3462
|
+
return {
|
|
3463
|
+
ok: true,
|
|
3464
|
+
action,
|
|
3465
|
+
message: `Scrolled at ${px}, ${py} by ${sdx}, ${sdy}. Positive dx is right, positive dy is down.`
|
|
3466
|
+
};
|
|
3467
|
+
}
|
|
3468
|
+
return { ok: false, error: "action must be screenshot, click, type, key, or scroll" };
|
|
3469
|
+
} catch (err) {
|
|
3470
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3471
|
+
return { ok: false, error: message };
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
function formatComputerUseHint(enabled) {
|
|
3475
|
+
if (!enabled) {
|
|
3476
|
+
return "Computer use is off (Settings \u2192 Advanced). Say the visual pass was not seen.";
|
|
3477
|
+
}
|
|
3478
|
+
return "Computer use is on. Screenshot returns scale; x and y are screen points (divide a PNG pixel by scale). Scroll is a wheel event at that point.";
|
|
3479
|
+
}
|
|
3480
|
+
var macosComputerUseRunner = {
|
|
3481
|
+
async screenshot(file) {
|
|
3482
|
+
const via = await fetchComputerUseScreenshot();
|
|
3483
|
+
if (via) {
|
|
3484
|
+
writeFileSync6(file, via.png);
|
|
3485
|
+
const info = pngPointSize(via.png);
|
|
3486
|
+
return { ...info, scale: via.scale > 0 ? via.scale : info.scale };
|
|
3487
|
+
}
|
|
3488
|
+
await execFileAsync("screencapture", ["-x", "-m", file]);
|
|
3489
|
+
return pngPointSize(readFileSync8(file));
|
|
3490
|
+
},
|
|
3491
|
+
async runAppleScript(script) {
|
|
3492
|
+
await execFileAsync("osascript", ["-e", script]);
|
|
3493
|
+
},
|
|
3494
|
+
async scroll(x, y, dx, dy) {
|
|
3495
|
+
await execFileAsync("swift", ["-e", scrollWheelSwift(x, y, dx, dy)]);
|
|
3496
|
+
},
|
|
3497
|
+
postInput(event) {
|
|
3498
|
+
return postComputerUseBridge(event);
|
|
3499
|
+
}
|
|
3500
|
+
};
|
|
3501
|
+
|
|
3177
3502
|
// src/agent-rpc/client.ts
|
|
3178
3503
|
import { WebSocket } from "ws";
|
|
3179
3504
|
|
|
@@ -3181,12 +3506,14 @@ import { WebSocket } from "ws";
|
|
|
3181
3506
|
var PILOT_TOOL_NAMES = [
|
|
3182
3507
|
"present_artifact",
|
|
3183
3508
|
"wait_for_job",
|
|
3184
|
-
"stop_job"
|
|
3509
|
+
"stop_job",
|
|
3510
|
+
"computer_use"
|
|
3185
3511
|
];
|
|
3186
3512
|
var PILOT_TOOL_DESCRIPTIONS = {
|
|
3187
3513
|
present_artifact: "Show a document or live log in Sideboard\u2019s side column. For html/svg/markdown/react, pass the FULL document and do not also fence that same body in chat. For type=log, pass only NEW lines (same artifact_id appends). Prefer type=log for long-running job output \u2014 do not resend HTML. type=react is a single default-export component (JSX/TSX); only react/react-dom imports.",
|
|
3188
3514
|
wait_for_job: "Wait until a detached long job (tests, pack, deploy, connector CLI) finishes. This call stays open for up to ~2 minutes. stillRunning true means the runtime hit the max hold; call wait_for_job again immediately. If the job is hanging, producing no useful output, or doing the wrong thing, call stop_job instead. Do not end the turn or tell the user you will let them know later.",
|
|
3189
|
-
stop_job: "Stop a detached job you started with detached-job.cjs when it is hanging, producing no useful output, buffering forever, or doing the wrong thing (wrong project, infinite watch, huge dump). Do not stop a pack/test/deploy that is clearly making progress."
|
|
3515
|
+
stop_job: "Stop a detached job you started with detached-job.cjs when it is hanging, producing no useful output, buffering forever, or doing the wrong thing (wrong project, infinite watch, huge dump). Do not stop a pack/test/deploy that is clearly making progress.",
|
|
3516
|
+
computer_use: COMPUTER_USE_DESCRIPTION
|
|
3190
3517
|
};
|
|
3191
3518
|
|
|
3192
3519
|
// src/agents/claude-host.ts
|
|
@@ -3216,17 +3543,17 @@ function entryDir2() {
|
|
|
3216
3543
|
function claudeRunnerPath() {
|
|
3217
3544
|
const packagedDir = packagedCursorRuntimeDir();
|
|
3218
3545
|
if (packagedDir) {
|
|
3219
|
-
const packaged =
|
|
3546
|
+
const packaged = join14(packagedDir, "core-dist", "agents", "claude-runner.js");
|
|
3220
3547
|
if (existsSync12(packaged)) return packaged;
|
|
3221
3548
|
}
|
|
3222
3549
|
const root = entryDir2();
|
|
3223
3550
|
const candidates = [
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3551
|
+
join14(root, "agents", "claude-runner.js"),
|
|
3552
|
+
join14(root, "agents", "claude-runner.cjs"),
|
|
3553
|
+
join14(root, "dist", "agents", "claude-runner.js"),
|
|
3554
|
+
join14(root, "dist", "agents", "claude-runner.cjs"),
|
|
3555
|
+
join14(root, "claude-runner.ts"),
|
|
3556
|
+
join14(root, "src", "agents", "claude-runner.ts")
|
|
3230
3557
|
];
|
|
3231
3558
|
for (const candidate of candidates) {
|
|
3232
3559
|
if (existsSync12(candidate)) return candidate;
|
|
@@ -3634,7 +3961,7 @@ var claudeAdapter = {
|
|
|
3634
3961
|
);
|
|
3635
3962
|
}
|
|
3636
3963
|
const mode = permissionMode(thread);
|
|
3637
|
-
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-
|
|
3964
|
+
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-EPVNFQVC.js");
|
|
3638
3965
|
const isOrchestrator = isOrchestratorThread2(thread);
|
|
3639
3966
|
const rpc = worktreeAgentRpc(isOrchestrator);
|
|
3640
3967
|
const injectedServers = await buildInjectedMcpServers({
|
|
@@ -3871,7 +4198,7 @@ ${hint}` : hint;
|
|
|
3871
4198
|
return { file: claude, args, cwd: thread.worktreePath };
|
|
3872
4199
|
},
|
|
3873
4200
|
async listLinearIssues(_repoPath) {
|
|
3874
|
-
const { listAssignedLinearIssues: listAssignedLinearIssues2 } = await import("./linear-list-
|
|
4201
|
+
const { listAssignedLinearIssues: listAssignedLinearIssues2 } = await import("./linear-list-V3A57XBR.js");
|
|
3875
4202
|
return listAssignedLinearIssues2();
|
|
3876
4203
|
}
|
|
3877
4204
|
};
|
|
@@ -3879,7 +4206,7 @@ ${hint}` : hint;
|
|
|
3879
4206
|
// src/agents/codex.ts
|
|
3880
4207
|
import { existsSync as existsSync14, statSync as statSync2 } from "fs";
|
|
3881
4208
|
import { homedir as homedir9 } from "os";
|
|
3882
|
-
import { join as
|
|
4209
|
+
import { join as join15 } from "path";
|
|
3883
4210
|
|
|
3884
4211
|
// src/agents/codex-items.ts
|
|
3885
4212
|
function eventsFromCodexItem(eventType, item) {
|
|
@@ -3968,7 +4295,7 @@ function usageFromCodex(usage, asContext = false) {
|
|
|
3968
4295
|
return occ > 0 ? { ...mapped, lastRequestTokens: occ } : mapped;
|
|
3969
4296
|
}
|
|
3970
4297
|
function codexHomeDir() {
|
|
3971
|
-
return process.env.CODEX_HOME?.trim() ||
|
|
4298
|
+
return process.env.CODEX_HOME?.trim() || join15(homedir9(), ".codex");
|
|
3972
4299
|
}
|
|
3973
4300
|
function unwrapCodexMcpResult(result) {
|
|
3974
4301
|
if (result == null) return void 0;
|
|
@@ -3990,14 +4317,14 @@ function unwrapCodexMcpResult(result) {
|
|
|
3990
4317
|
return String(result);
|
|
3991
4318
|
}
|
|
3992
4319
|
}
|
|
3993
|
-
function
|
|
4320
|
+
function asRecord5(value) {
|
|
3994
4321
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
3995
4322
|
return value;
|
|
3996
4323
|
}
|
|
3997
4324
|
return void 0;
|
|
3998
4325
|
}
|
|
3999
4326
|
function codexLooksAuthenticated() {
|
|
4000
|
-
const authPath =
|
|
4327
|
+
const authPath = join15(codexHomeDir(), "auth.json");
|
|
4001
4328
|
if (!existsSync14(authPath)) return false;
|
|
4002
4329
|
try {
|
|
4003
4330
|
return statSync2(authPath).size > 2;
|
|
@@ -4042,7 +4369,7 @@ var codexAdapter = {
|
|
|
4042
4369
|
authenticated,
|
|
4043
4370
|
linearMcp,
|
|
4044
4371
|
warnings,
|
|
4045
|
-
reason: authenticated ? void 0 : `Codex auth not found \u2014 run \`codex login\` (expected ${
|
|
4372
|
+
reason: authenticated ? void 0 : `Codex auth not found \u2014 run \`codex login\` (expected ${join15(codexHomeDir(), "auth.json")})`
|
|
4046
4373
|
};
|
|
4047
4374
|
},
|
|
4048
4375
|
async buildTurn(thread, input) {
|
|
@@ -4150,7 +4477,7 @@ var codexAdapter = {
|
|
|
4150
4477
|
}
|
|
4151
4478
|
if (itemType === "mcp_tool_call" && item.id && item.server && item.tool) {
|
|
4152
4479
|
const name = `mcp__${item.server}__${item.tool}`;
|
|
4153
|
-
const input =
|
|
4480
|
+
const input = asRecord5(item.arguments);
|
|
4154
4481
|
const events = [
|
|
4155
4482
|
{ type: "tool_use", id: item.id, name, input }
|
|
4156
4483
|
];
|
|
@@ -4272,27 +4599,27 @@ var codexAdapter = {
|
|
|
4272
4599
|
// src/agents/cursor.ts
|
|
4273
4600
|
import { existsSync as existsSync17 } from "fs";
|
|
4274
4601
|
import { createRequire as createRequire6 } from "module";
|
|
4275
|
-
import { dirname as dirname9, join as
|
|
4602
|
+
import { dirname as dirname9, join as join18 } from "path";
|
|
4276
4603
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
4277
4604
|
|
|
4278
4605
|
// src/agents/cursor-sdk-resolve.ts
|
|
4279
|
-
import { existsSync as existsSync15, readFileSync as
|
|
4606
|
+
import { existsSync as existsSync15, readFileSync as readFileSync9 } from "fs";
|
|
4280
4607
|
import { createRequire as createRequire4 } from "module";
|
|
4281
|
-
import { basename, dirname as dirname7, join as
|
|
4608
|
+
import { basename, dirname as dirname7, join as join16 } from "path";
|
|
4282
4609
|
import { fileURLToPath as fileURLToPath4, pathToFileURL } from "url";
|
|
4283
4610
|
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.";
|
|
4284
4611
|
function thisModuleFile() {
|
|
4285
4612
|
const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
|
|
4286
|
-
if (cjsDir) return
|
|
4613
|
+
if (cjsDir) return join16(cjsDir, "cursor-sdk-resolve.js");
|
|
4287
4614
|
try {
|
|
4288
4615
|
return fileURLToPath4(import.meta.url);
|
|
4289
4616
|
} catch {
|
|
4290
|
-
return
|
|
4617
|
+
return join16(process.cwd(), "package.json");
|
|
4291
4618
|
}
|
|
4292
4619
|
}
|
|
4293
4620
|
function packageRootLooksLikeSdk(dir) {
|
|
4294
4621
|
try {
|
|
4295
|
-
const raw =
|
|
4622
|
+
const raw = readFileSync9(join16(dir, "package.json"), "utf8");
|
|
4296
4623
|
const pkg = JSON.parse(raw);
|
|
4297
4624
|
return pkg.name === "@cursor/sdk" && existsSync15(dir);
|
|
4298
4625
|
} catch {
|
|
@@ -4317,10 +4644,10 @@ function resolveCursorSdkRoot(opts) {
|
|
|
4317
4644
|
}
|
|
4318
4645
|
const globalNm = npmGlobalNodeModules(env);
|
|
4319
4646
|
if (globalNm) {
|
|
4320
|
-
const globalRoot =
|
|
4647
|
+
const globalRoot = join16(globalNm, "@cursor/sdk");
|
|
4321
4648
|
if (packageRootLooksLikeSdk(globalRoot)) return globalRoot;
|
|
4322
4649
|
}
|
|
4323
|
-
const cwdPkg =
|
|
4650
|
+
const cwdPkg = join16(process.cwd(), "package.json");
|
|
4324
4651
|
return resolvedPackageRoot(thisModuleFile()) ?? resolvedPackageRoot(cwdPkg);
|
|
4325
4652
|
}
|
|
4326
4653
|
function isCursorSdkInstalled(opts) {
|
|
@@ -4336,12 +4663,12 @@ function exportTarget(value) {
|
|
|
4336
4663
|
}
|
|
4337
4664
|
function cursorSdkEsmEntry(root) {
|
|
4338
4665
|
try {
|
|
4339
|
-
const pkg = JSON.parse(
|
|
4666
|
+
const pkg = JSON.parse(readFileSync9(join16(root, "package.json"), "utf8"));
|
|
4340
4667
|
const exp = pkg.exports;
|
|
4341
4668
|
const dot = exp && typeof exp === "object" && !Array.isArray(exp) && "." in exp ? exp["."] : exp;
|
|
4342
4669
|
const rel = exportTarget(dot) ?? (typeof pkg.module === "string" ? pkg.module : null);
|
|
4343
4670
|
if (!rel) return null;
|
|
4344
|
-
const entry =
|
|
4671
|
+
const entry = join16(root, rel);
|
|
4345
4672
|
return existsSync15(entry) ? entry : null;
|
|
4346
4673
|
} catch {
|
|
4347
4674
|
return null;
|
|
@@ -4358,7 +4685,7 @@ async function importCursorSdk(opts) {
|
|
|
4358
4685
|
try {
|
|
4359
4686
|
let entry = cursorSdkEsmEntry(root);
|
|
4360
4687
|
if (!entry) {
|
|
4361
|
-
const req = createRequire4(
|
|
4688
|
+
const req = createRequire4(join16(root, "package.json"));
|
|
4362
4689
|
entry = req.resolve("@cursor/sdk");
|
|
4363
4690
|
}
|
|
4364
4691
|
return unwrapCursorSdkModule(await import(pathToFileURL(entry).href));
|
|
@@ -4379,9 +4706,9 @@ function cursorSdkRipgrepCandidate(opts) {
|
|
|
4379
4706
|
const nm = nodeModulesDirForPackageRoot(root);
|
|
4380
4707
|
const pkg = cursorSdkPlatformRipgrepPackage();
|
|
4381
4708
|
const bin = process.platform === "win32" ? "rg.exe" : "rg";
|
|
4382
|
-
const sibling =
|
|
4709
|
+
const sibling = join16(nm, pkg, "bin", bin);
|
|
4383
4710
|
if (existsSync15(sibling)) return sibling;
|
|
4384
|
-
const nested =
|
|
4711
|
+
const nested = join16(root, "node_modules", pkg, "bin", bin);
|
|
4385
4712
|
return existsSync15(nested) ? nested : null;
|
|
4386
4713
|
}
|
|
4387
4714
|
|
|
@@ -4430,20 +4757,20 @@ function turnCostUsdFromCursorUsage(before, after) {
|
|
|
4430
4757
|
if (!(delta >= 0) || !Number.isFinite(delta)) return void 0;
|
|
4431
4758
|
return delta / 100;
|
|
4432
4759
|
}
|
|
4433
|
-
function
|
|
4760
|
+
function asRecord6(value) {
|
|
4434
4761
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
4435
4762
|
return value;
|
|
4436
4763
|
}
|
|
4437
4764
|
return void 0;
|
|
4438
4765
|
}
|
|
4439
4766
|
function normalizeCursorToolCall(name, args) {
|
|
4440
|
-
const raw =
|
|
4767
|
+
const raw = asRecord6(args);
|
|
4441
4768
|
const toolName = typeof raw?.toolName === "string" && raw.toolName.trim() ? raw.toolName.trim() : null;
|
|
4442
|
-
const looksLikeMcp = name === "mcp" || toolName != null && (typeof raw?.providerIdentifier === "string" ||
|
|
4769
|
+
const looksLikeMcp = name === "mcp" || toolName != null && (typeof raw?.providerIdentifier === "string" || asRecord6(raw?.args) != null);
|
|
4443
4770
|
if (looksLikeMcp && toolName) {
|
|
4444
4771
|
const providerRaw = typeof raw.providerIdentifier === "string" && raw.providerIdentifier.trim() ? raw.providerIdentifier.trim() : "sideboard";
|
|
4445
4772
|
const provider = providerRaw.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
4446
|
-
const nested =
|
|
4773
|
+
const nested = asRecord6(raw.args);
|
|
4447
4774
|
return {
|
|
4448
4775
|
name: `mcp__${provider}__${toolName}`,
|
|
4449
4776
|
input: nested ?? { toolName }
|
|
@@ -4454,7 +4781,7 @@ function normalizeCursorToolCall(name, args) {
|
|
|
4454
4781
|
function unwrapCursorToolResult(result) {
|
|
4455
4782
|
if (result == null) return void 0;
|
|
4456
4783
|
if (typeof result === "string") return result;
|
|
4457
|
-
const rec =
|
|
4784
|
+
const rec = asRecord6(result);
|
|
4458
4785
|
if (!rec) {
|
|
4459
4786
|
try {
|
|
4460
4787
|
return JSON.stringify(result);
|
|
@@ -4465,18 +4792,18 @@ function unwrapCursorToolResult(result) {
|
|
|
4465
4792
|
const collectTexts = (items) => {
|
|
4466
4793
|
const texts = [];
|
|
4467
4794
|
for (const item of items) {
|
|
4468
|
-
const row =
|
|
4795
|
+
const row = asRecord6(item);
|
|
4469
4796
|
if (!row) continue;
|
|
4470
4797
|
if (typeof row.text === "string") {
|
|
4471
4798
|
texts.push(row.text);
|
|
4472
4799
|
continue;
|
|
4473
4800
|
}
|
|
4474
|
-
const nested =
|
|
4801
|
+
const nested = asRecord6(row.text);
|
|
4475
4802
|
if (typeof nested?.text === "string") texts.push(nested.text);
|
|
4476
4803
|
}
|
|
4477
4804
|
return texts;
|
|
4478
4805
|
};
|
|
4479
|
-
const value =
|
|
4806
|
+
const value = asRecord6(rec.value);
|
|
4480
4807
|
if (value && Array.isArray(value.content)) {
|
|
4481
4808
|
const texts = collectTexts(value.content);
|
|
4482
4809
|
if (texts.length) return texts.join("\n");
|
|
@@ -4493,10 +4820,10 @@ function unwrapCursorToolResult(result) {
|
|
|
4493
4820
|
}
|
|
4494
4821
|
function cursorToolResultIsError(status, result) {
|
|
4495
4822
|
if (status === "error") return true;
|
|
4496
|
-
const rec =
|
|
4823
|
+
const rec = asRecord6(result);
|
|
4497
4824
|
if (!rec) return false;
|
|
4498
4825
|
if (rec.status === "error") return true;
|
|
4499
|
-
const value =
|
|
4826
|
+
const value = asRecord6(rec.value);
|
|
4500
4827
|
return value?.isError === true;
|
|
4501
4828
|
}
|
|
4502
4829
|
function cursorSdkMessageToEvents(msg) {
|
|
@@ -4599,7 +4926,7 @@ function parseCursorRunnerLine(line) {
|
|
|
4599
4926
|
// src/agents/cursor-ripgrep.ts
|
|
4600
4927
|
import { existsSync as existsSync16 } from "fs";
|
|
4601
4928
|
import { createRequire as createRequire5 } from "module";
|
|
4602
|
-
import { dirname as dirname8, isAbsolute as
|
|
4929
|
+
import { dirname as dirname8, isAbsolute as isAbsolute3, join as join17, parse, resolve as resolvePath } from "path";
|
|
4603
4930
|
var RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
|
|
4604
4931
|
function rgBinaryName() {
|
|
4605
4932
|
return process.platform === "win32" ? "rg.exe" : "rg";
|
|
@@ -4609,7 +4936,7 @@ function platformRipgrepPackage() {
|
|
|
4609
4936
|
}
|
|
4610
4937
|
function usableRipgrepPath(candidate) {
|
|
4611
4938
|
const raw = candidate?.trim();
|
|
4612
|
-
if (!raw || !
|
|
4939
|
+
if (!raw || !isAbsolute3(raw)) return null;
|
|
4613
4940
|
const readable = nodeReadableScriptPath(raw);
|
|
4614
4941
|
if (!existsSync16(readable) || isAsarPath(readable)) return null;
|
|
4615
4942
|
return readable;
|
|
@@ -4621,7 +4948,7 @@ function walkForBundledRipgrep(startFile) {
|
|
|
4621
4948
|
let dir = dirname8(resolvePath(startFile));
|
|
4622
4949
|
const root = parse(dir).root;
|
|
4623
4950
|
while (dir !== root) {
|
|
4624
|
-
const hit = usableRipgrepPath(
|
|
4951
|
+
const hit = usableRipgrepPath(join17(dir, "node_modules", pkg, "bin", name));
|
|
4625
4952
|
if (hit) return hit;
|
|
4626
4953
|
const next = dirname8(dir);
|
|
4627
4954
|
if (next === dir) break;
|
|
@@ -4633,7 +4960,7 @@ function requireResolveBundledRipgrep(fromFile) {
|
|
|
4633
4960
|
try {
|
|
4634
4961
|
const req = createRequire5(fromFile);
|
|
4635
4962
|
const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
|
|
4636
|
-
return usableRipgrepPath(
|
|
4963
|
+
return usableRipgrepPath(join17(dirname8(pkgJson), "bin", rgBinaryName()));
|
|
4637
4964
|
} catch {
|
|
4638
4965
|
return null;
|
|
4639
4966
|
}
|
|
@@ -4722,14 +5049,14 @@ function cursorRunnerPath() {
|
|
|
4722
5049
|
if (packaged) return packaged;
|
|
4723
5050
|
const root = entryDir3();
|
|
4724
5051
|
const candidates = [
|
|
4725
|
-
|
|
4726
|
-
|
|
5052
|
+
join18(root, "agents", "cursor-runner.js"),
|
|
5053
|
+
join18(root, "agents", "cursor-runner.cjs"),
|
|
4727
5054
|
// If somehow resolved from package root instead of dist/
|
|
4728
|
-
|
|
4729
|
-
|
|
5055
|
+
join18(root, "dist", "agents", "cursor-runner.js"),
|
|
5056
|
+
join18(root, "dist", "agents", "cursor-runner.cjs"),
|
|
4730
5057
|
// Source tree (dev): packages/core/src/agents/cursor-runner.ts
|
|
4731
|
-
|
|
4732
|
-
|
|
5058
|
+
join18(root, "cursor-runner.ts"),
|
|
5059
|
+
join18(root, "src", "agents", "cursor-runner.ts")
|
|
4733
5060
|
];
|
|
4734
5061
|
for (const candidate of candidates) {
|
|
4735
5062
|
if (existsSync17(candidate)) return candidate;
|
|
@@ -4844,8 +5171,8 @@ import { existsSync as existsSync19 } from "fs";
|
|
|
4844
5171
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
4845
5172
|
|
|
4846
5173
|
// src/agent-rpc/opencode-hook.ts
|
|
4847
|
-
import { existsSync as existsSync18, mkdirSync as
|
|
4848
|
-
import { join as
|
|
5174
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync5, readFileSync as readFileSync10, renameSync, writeFileSync as writeFileSync7 } from "fs";
|
|
5175
|
+
import { join as join19 } from "path";
|
|
4849
5176
|
var OPENCODE_PLUGIN_SOURCE = `import { tool } from "@opencode-ai/plugin"
|
|
4850
5177
|
|
|
4851
5178
|
const RPC_URL = process.env[${JSON.stringify(AGENT_RPC_URL_ENV)}] || ""
|
|
@@ -4950,22 +5277,38 @@ export const SideboardRpc = async (ctx) => {
|
|
|
4950
5277
|
return job("job.stop", args)
|
|
4951
5278
|
},
|
|
4952
5279
|
}),
|
|
5280
|
+
computer_use: tool({
|
|
5281
|
+
description: ${JSON.stringify(PILOT_TOOL_DESCRIPTIONS.computer_use)},
|
|
5282
|
+
args: {
|
|
5283
|
+
action: tool.schema.enum(["screenshot", "click", "type", "key", "scroll"]),
|
|
5284
|
+
x: tool.schema.number().optional().describe("Screen x in points, not PNG pixels"),
|
|
5285
|
+
y: tool.schema.number().optional().describe("Screen y in points, not PNG pixels"),
|
|
5286
|
+
text: opt("Text to type"),
|
|
5287
|
+
key: opt("One key: return, tab, escape, arrows, delete, or one character"),
|
|
5288
|
+
modifiers: tool.schema.array(tool.schema.string()).optional().describe("command, shift, option, control"),
|
|
5289
|
+
dx: tool.schema.number().optional().describe("Horizontal scroll in points. Positive is right"),
|
|
5290
|
+
dy: tool.schema.number().optional().describe("Vertical scroll in points. Positive is down"),
|
|
5291
|
+
},
|
|
5292
|
+
async execute(args) {
|
|
5293
|
+
return job("computer.act", args)
|
|
5294
|
+
},
|
|
5295
|
+
}),
|
|
4953
5296
|
},
|
|
4954
5297
|
}
|
|
4955
5298
|
}
|
|
4956
5299
|
`;
|
|
4957
5300
|
function writeOpencodeRpcPlugin() {
|
|
4958
|
-
const pluginDir =
|
|
4959
|
-
|
|
4960
|
-
const pluginFile =
|
|
5301
|
+
const pluginDir = join19(appDataDir(), "agent-rpc", "opencode");
|
|
5302
|
+
mkdirSync5(pluginDir, { recursive: true });
|
|
5303
|
+
const pluginFile = join19(pluginDir, "sideboard-rpc.js");
|
|
4961
5304
|
if (existsSync18(pluginFile)) {
|
|
4962
5305
|
try {
|
|
4963
|
-
if (
|
|
5306
|
+
if (readFileSync10(pluginFile, "utf8") === OPENCODE_PLUGIN_SOURCE) return pluginFile;
|
|
4964
5307
|
} catch {
|
|
4965
5308
|
}
|
|
4966
5309
|
}
|
|
4967
5310
|
const tmp = `${pluginFile}.${process.pid}.tmp`;
|
|
4968
|
-
|
|
5311
|
+
writeFileSync7(tmp, OPENCODE_PLUGIN_SOURCE);
|
|
4969
5312
|
renameSync(tmp, pluginFile);
|
|
4970
5313
|
return pluginFile;
|
|
4971
5314
|
}
|
|
@@ -5014,7 +5357,7 @@ var FALLBACK_OPENCODE_MODELS = [
|
|
|
5014
5357
|
];
|
|
5015
5358
|
var cachedOpencodeModels = null;
|
|
5016
5359
|
var OPENCODE_MODEL_CACHE_MS = 5 * 60 * 1e3;
|
|
5017
|
-
function
|
|
5360
|
+
function asRecord7(value) {
|
|
5018
5361
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
5019
5362
|
return value;
|
|
5020
5363
|
}
|
|
@@ -5194,7 +5537,7 @@ var opencodeAdapter = {
|
|
|
5194
5537
|
const name = part?.tool ?? part?.name ?? obj.tool ?? obj.name ?? "tool";
|
|
5195
5538
|
const state = part?.state;
|
|
5196
5539
|
const input = (state?.input && typeof state.input === "object" ? state.input : void 0) ?? part?.input ?? obj.input;
|
|
5197
|
-
const metadata =
|
|
5540
|
+
const metadata = asRecord7(state?.metadata);
|
|
5198
5541
|
const id = opencodeToolId(
|
|
5199
5542
|
name,
|
|
5200
5543
|
part?.callID ?? part?.id ?? obj.id,
|
|
@@ -5229,7 +5572,7 @@ var opencodeAdapter = {
|
|
|
5229
5572
|
}
|
|
5230
5573
|
if (obj.type === "subtask_event") {
|
|
5231
5574
|
const parentId = str(obj.childSessionID) ?? str(obj.childSessionId);
|
|
5232
|
-
const part =
|
|
5575
|
+
const part = asRecord7(obj.part);
|
|
5233
5576
|
if (!parentId || !part) return null;
|
|
5234
5577
|
if (part.type === "text" && str(part.text)) {
|
|
5235
5578
|
return withTaskParent(
|
|
@@ -5240,8 +5583,8 @@ var opencodeAdapter = {
|
|
|
5240
5583
|
if (part.type === "tool" || str(part.tool)) {
|
|
5241
5584
|
const name = str(part.tool) ?? str(part.name) ?? "tool";
|
|
5242
5585
|
const id = str(part.callID) ?? str(part.id) ?? `${parentId}-${name}`;
|
|
5243
|
-
const state =
|
|
5244
|
-
const input =
|
|
5586
|
+
const state = asRecord7(part.state);
|
|
5587
|
+
const input = asRecord7(state?.input) ?? asRecord7(part.input);
|
|
5245
5588
|
const nested = [
|
|
5246
5589
|
withEventParentId({ type: "tool_use", id, name, input }, parentId)
|
|
5247
5590
|
];
|
|
@@ -5345,7 +5688,7 @@ var opencodeAdapter = {
|
|
|
5345
5688
|
};
|
|
5346
5689
|
},
|
|
5347
5690
|
async listLinearIssues(_repoPath) {
|
|
5348
|
-
const { listAssignedLinearIssues: listAssignedLinearIssues2 } = await import("./linear-list-
|
|
5691
|
+
const { listAssignedLinearIssues: listAssignedLinearIssues2 } = await import("./linear-list-V3A57XBR.js");
|
|
5349
5692
|
return listAssignedLinearIssues2();
|
|
5350
5693
|
}
|
|
5351
5694
|
};
|
|
@@ -5587,6 +5930,10 @@ export {
|
|
|
5587
5930
|
PLAN_MODE_OFF_INSTRUCTION,
|
|
5588
5931
|
planModeTurnInstruction,
|
|
5589
5932
|
permissionMode,
|
|
5933
|
+
COMPUTER_USE_DESCRIPTION,
|
|
5934
|
+
performComputerUse,
|
|
5935
|
+
formatComputerUseHint,
|
|
5936
|
+
macosComputerUseRunner,
|
|
5590
5937
|
claudeAdapter,
|
|
5591
5938
|
listCodexModels,
|
|
5592
5939
|
codexAdapter,
|