pi-cursor-bridge 0.2.2 → 0.2.3
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/.codex-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/dist/cursor-bridge.mjs +189 -116
- package/dist/cursor-lifecycle-supervisor.mjs +3990 -68
- package/extensions/index.ts +1 -1
- package/package.json +2 -2
package/dist/cursor-bridge.mjs
CHANGED
|
@@ -2990,7 +2990,7 @@ var require_compile = __commonJS({
|
|
|
2990
2990
|
const schOrFunc = root.refs[ref];
|
|
2991
2991
|
if (schOrFunc)
|
|
2992
2992
|
return schOrFunc;
|
|
2993
|
-
let _sch =
|
|
2993
|
+
let _sch = resolve9.call(this, root, ref);
|
|
2994
2994
|
if (_sch === void 0) {
|
|
2995
2995
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
2996
2996
|
const { schemaId } = this.opts;
|
|
@@ -3017,7 +3017,7 @@ var require_compile = __commonJS({
|
|
|
3017
3017
|
function sameSchemaEnv(s1, s2) {
|
|
3018
3018
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3019
3019
|
}
|
|
3020
|
-
function
|
|
3020
|
+
function resolve9(root, ref) {
|
|
3021
3021
|
let sch;
|
|
3022
3022
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3023
3023
|
ref = sch;
|
|
@@ -3842,7 +3842,7 @@ var require_fast_uri = __commonJS({
|
|
|
3842
3842
|
}
|
|
3843
3843
|
return uri;
|
|
3844
3844
|
}
|
|
3845
|
-
function
|
|
3845
|
+
function resolve9(baseURI, relativeURI, options) {
|
|
3846
3846
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3847
3847
|
const {
|
|
3848
3848
|
parsed: baseParsed,
|
|
@@ -4204,7 +4204,7 @@ var require_fast_uri = __commonJS({
|
|
|
4204
4204
|
var fastUri = {
|
|
4205
4205
|
SCHEMES,
|
|
4206
4206
|
normalize,
|
|
4207
|
-
resolve:
|
|
4207
|
+
resolve: resolve9,
|
|
4208
4208
|
resolveComponent,
|
|
4209
4209
|
equal,
|
|
4210
4210
|
serialize,
|
|
@@ -9432,7 +9432,7 @@ var require_websocket = __commonJS({
|
|
|
9432
9432
|
var http3 = __require("http");
|
|
9433
9433
|
var net2 = __require("net");
|
|
9434
9434
|
var tls = __require("tls");
|
|
9435
|
-
var { randomBytes, createHash:
|
|
9435
|
+
var { randomBytes, createHash: createHash4 } = __require("crypto");
|
|
9436
9436
|
var { Duplex, Readable } = __require("stream");
|
|
9437
9437
|
var { URL: URL2 } = __require("url");
|
|
9438
9438
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -10100,7 +10100,7 @@ var require_websocket = __commonJS({
|
|
|
10100
10100
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
10101
10101
|
return;
|
|
10102
10102
|
}
|
|
10103
|
-
const digest =
|
|
10103
|
+
const digest = createHash4("sha1").update(key + GUID).digest("base64");
|
|
10104
10104
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
10105
10105
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
10106
10106
|
return;
|
|
@@ -10469,7 +10469,7 @@ var require_websocket_server = __commonJS({
|
|
|
10469
10469
|
var EventEmitter = __require("events");
|
|
10470
10470
|
var http3 = __require("http");
|
|
10471
10471
|
var { Duplex } = __require("stream");
|
|
10472
|
-
var { createHash:
|
|
10472
|
+
var { createHash: createHash4 } = __require("crypto");
|
|
10473
10473
|
var extension2 = require_extension();
|
|
10474
10474
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
10475
10475
|
var subprotocol2 = require_subprotocol();
|
|
@@ -10776,7 +10776,7 @@ var require_websocket_server = __commonJS({
|
|
|
10776
10776
|
);
|
|
10777
10777
|
}
|
|
10778
10778
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
10779
|
-
const digest =
|
|
10779
|
+
const digest = createHash4("sha1").update(key + GUID).digest("base64");
|
|
10780
10780
|
const headers = [
|
|
10781
10781
|
"HTTP/1.1 101 Switching Protocols",
|
|
10782
10782
|
"Upgrade: websocket",
|
|
@@ -11385,12 +11385,69 @@ var init_workspace_binding = __esm({
|
|
|
11385
11385
|
}
|
|
11386
11386
|
});
|
|
11387
11387
|
|
|
11388
|
+
// cursor-startup-window.mjs
|
|
11389
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync5, renameSync as renameSync5, writeFileSync as writeFileSync5, rmSync as rmSync5 } from "node:fs";
|
|
11390
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
11391
|
+
import { homedir as homedir6 } from "node:os";
|
|
11392
|
+
import { dirname as dirname5, join as join6, resolve as resolve5 } from "node:path";
|
|
11393
|
+
function cursorWindowStatePath(options = {}) {
|
|
11394
|
+
const env = options.env || process.env;
|
|
11395
|
+
const home = options.home || homedir6();
|
|
11396
|
+
const platform = options.platform || process.platform;
|
|
11397
|
+
let dataDir;
|
|
11398
|
+
if (env.VSCODE_PORTABLE) dataDir = join6(env.VSCODE_PORTABLE, "user-data");
|
|
11399
|
+
else if (env.VSCODE_APPDATA) dataDir = join6(env.VSCODE_APPDATA, "Cursor");
|
|
11400
|
+
else if (platform === "win32") dataDir = join6(env.APPDATA || join6(home, "AppData", "Roaming"), "Cursor");
|
|
11401
|
+
else if (platform === "darwin") dataDir = join6(home, "Library", "Application Support", "Cursor");
|
|
11402
|
+
else dataDir = join6(env.XDG_CONFIG_HOME || join6(home, ".config"), "Cursor");
|
|
11403
|
+
return join6(dataDir, "User", "globalStorage", "storage.json");
|
|
11404
|
+
}
|
|
11405
|
+
function bridgeWindowStatePath(options = {}) {
|
|
11406
|
+
const env = options.env || process.env;
|
|
11407
|
+
if (env.CURSOR_BRIDGE_WINDOW_STATE_FILE) return resolve5(env.CURSOR_BRIDGE_WINDOW_STATE_FILE);
|
|
11408
|
+
const root = (options.platform || process.platform) === "win32" && env.APPDATA ? env.APPDATA : env.XDG_CONFIG_HOME || join6(options.home || homedir6(), ".config");
|
|
11409
|
+
return join6(root, "cursor-bridge", "last-window.json");
|
|
11410
|
+
}
|
|
11411
|
+
function nativeWindowState(options) {
|
|
11412
|
+
try {
|
|
11413
|
+
return JSON.parse((options.readFileSyncImpl || readFileSync5)(options.file || cursorWindowStatePath(options), "utf8"))?.windowsState?.lastActiveWindow || null;
|
|
11414
|
+
} catch {
|
|
11415
|
+
return null;
|
|
11416
|
+
}
|
|
11417
|
+
}
|
|
11418
|
+
function stateSignature(last) {
|
|
11419
|
+
return createHash2("sha256").update(JSON.stringify(last)).digest("hex");
|
|
11420
|
+
}
|
|
11421
|
+
function readCursorStartupWindow(options = {}) {
|
|
11422
|
+
const file = options.file || cursorWindowStatePath(options);
|
|
11423
|
+
const last = nativeWindowState(options);
|
|
11424
|
+
try {
|
|
11425
|
+
const observed = JSON.parse((options.readFileSyncImpl || readFileSync5)(options.bridgeFile || bridgeWindowStatePath(options), "utf8"));
|
|
11426
|
+
if (observed.version === 1 && observed.cursorStatePath === resolve5(file) && observed.nativeSignature === stateSignature(last) && ["agents_v2", "legacy"].includes(observed.uiFlavor)) {
|
|
11427
|
+
return { uiFlavor: observed.uiFlavor, source: "bridge-last-closed-window" };
|
|
11428
|
+
}
|
|
11429
|
+
} catch {
|
|
11430
|
+
}
|
|
11431
|
+
if (last?.uiState && typeof last.uiState === "object" && !Array.isArray(last.uiState)) {
|
|
11432
|
+
return { uiFlavor: last.uiState.glassMode === true ? "agents_v2" : "legacy", source: "cursor-last-active-window" };
|
|
11433
|
+
}
|
|
11434
|
+
return { uiFlavor: "agents_v2", source: "default-agents-window" };
|
|
11435
|
+
}
|
|
11436
|
+
function cursorStartupWindowArgs(startupWindow, projectPath) {
|
|
11437
|
+
if (startupWindow.uiFlavor !== "legacy") return ["--glass"];
|
|
11438
|
+
return ["--classic", ...projectPath ? [projectPath] : ["--new-window"]];
|
|
11439
|
+
}
|
|
11440
|
+
var init_cursor_startup_window = __esm({
|
|
11441
|
+
"cursor-startup-window.mjs"() {
|
|
11442
|
+
}
|
|
11443
|
+
});
|
|
11444
|
+
|
|
11388
11445
|
// cursor-ensure-core.mjs
|
|
11389
11446
|
import { spawn as spawn2, execFileSync as execFileSync2 } from "child_process";
|
|
11390
11447
|
import { existsSync as existsSync2 } from "fs";
|
|
11391
11448
|
import { createRequire as createNodeRequire } from "node:module";
|
|
11392
|
-
import { homedir as
|
|
11393
|
-
import { basename as basename4, extname as extname2, join as
|
|
11449
|
+
import { homedir as homedir7 } from "node:os";
|
|
11450
|
+
import { basename as basename4, extname as extname2, join as join7, resolve as resolve6, win32 as winPath, posix as posixPath } from "node:path";
|
|
11394
11451
|
import http from "http";
|
|
11395
11452
|
function resolveCursorLaunchCdpPort(port = process.env.CURSOR_BRIDGE_CDP_PORT) {
|
|
11396
11453
|
const parsed = Number(port == null || String(port).trim() === "" ? 9223 : port);
|
|
@@ -11417,13 +11474,13 @@ function resolveCodexThreadProjectPath(options = {}) {
|
|
|
11417
11474
|
try {
|
|
11418
11475
|
const lookupThreadCwd = options.lookupThreadCwd || ((id) => {
|
|
11419
11476
|
const { DatabaseSync } = (options.requireImpl || loadModule)("node:sqlite");
|
|
11420
|
-
const databasePath = options.databasePath ||
|
|
11477
|
+
const databasePath = options.databasePath || join7(homedir7(), ".codex", "state_5.sqlite");
|
|
11421
11478
|
database = new DatabaseSync(databasePath, { readOnly: true });
|
|
11422
11479
|
return database.prepare("SELECT cwd FROM threads WHERE id = ?").get(id)?.cwd || null;
|
|
11423
11480
|
});
|
|
11424
11481
|
const candidate = normalizeCodexThreadCwd(lookupThreadCwd(threadId));
|
|
11425
11482
|
const existsImpl = options.existsImpl || existsSync2;
|
|
11426
|
-
const resolved = candidate && !looksLikePluginRuntimePath(candidate) && existsImpl(candidate) ?
|
|
11483
|
+
const resolved = candidate && !looksLikePluginRuntimePath(candidate) && existsImpl(candidate) ? resolve6(candidate) : null;
|
|
11427
11484
|
if (options.useCache !== false) CODEX_THREAD_PROJECTS.set(threadId, resolved);
|
|
11428
11485
|
return resolved;
|
|
11429
11486
|
} catch {
|
|
@@ -11438,14 +11495,14 @@ function resolveCodexThreadProjectPath(options = {}) {
|
|
|
11438
11495
|
}
|
|
11439
11496
|
function resolveProjectPath(value = process.env.CURSOR_PROJECT_PATH, options = {}) {
|
|
11440
11497
|
const explicit = String(value || "").trim();
|
|
11441
|
-
if (explicit) return
|
|
11498
|
+
if (explicit) return resolve6(explicit);
|
|
11442
11499
|
const persisted = String(options.persistedProjectPath || "").trim();
|
|
11443
|
-
if (persisted) return
|
|
11500
|
+
if (persisted) return resolve6(normalizeCodexThreadCwd(persisted));
|
|
11444
11501
|
const threadProjectPath = options.threadProjectPath === void 0 ? resolveCodexThreadProjectPath(options) : options.threadProjectPath;
|
|
11445
|
-
if (threadProjectPath) return
|
|
11502
|
+
if (threadProjectPath) return resolve6(normalizeCodexThreadCwd(threadProjectPath));
|
|
11446
11503
|
const cwd = options.cwd ?? process.cwd();
|
|
11447
11504
|
if (!cwd || looksLikePluginRuntimePath(cwd)) return null;
|
|
11448
|
-
return
|
|
11505
|
+
return resolve6(cwd);
|
|
11449
11506
|
}
|
|
11450
11507
|
function cursorFromRegistry(options = {}) {
|
|
11451
11508
|
const execFileSyncImpl = options.execFileSyncImpl || execFileSync2;
|
|
@@ -11510,7 +11567,7 @@ function findCursorExeDetails(options = {}) {
|
|
|
11510
11567
|
existsImpl
|
|
11511
11568
|
});
|
|
11512
11569
|
if (fromReg) return { path: fromReg, source: "windows_registry", platform };
|
|
11513
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
11570
|
+
const localAppData = env.LOCALAPPDATA || join7(homedir7(), "AppData", "Local");
|
|
11514
11571
|
const programFiles = env.ProgramFiles || env.PROGRAMFILES || "C:\\Program Files";
|
|
11515
11572
|
const programFilesX86 = env["ProgramFiles(x86)"] || env.PROGRAMFILES_X86 || "";
|
|
11516
11573
|
const candidates = [
|
|
@@ -11527,7 +11584,7 @@ function findCursorExeDetails(options = {}) {
|
|
|
11527
11584
|
return null;
|
|
11528
11585
|
}
|
|
11529
11586
|
if (platform === "darwin") {
|
|
11530
|
-
const userHome = env.HOME ||
|
|
11587
|
+
const userHome = env.HOME || homedir7();
|
|
11531
11588
|
const candidates = [
|
|
11532
11589
|
"/Applications/Cursor.app/Contents/MacOS/Cursor",
|
|
11533
11590
|
userHome && posixPath.join(userHome, "Applications", "Cursor.app", "Contents", "MacOS", "Cursor")
|
|
@@ -11546,42 +11603,42 @@ function findCursorExe(options = {}) {
|
|
|
11546
11603
|
return findCursorExeDetails(options)?.path || null;
|
|
11547
11604
|
}
|
|
11548
11605
|
function cdpUp(timeoutMs = 1500) {
|
|
11549
|
-
return new Promise((
|
|
11606
|
+
return new Promise((resolve9) => {
|
|
11550
11607
|
const req = http.get({ host: CDP_HOST, port: CDP_PORT, path: "/json/version" }, (res) => {
|
|
11551
11608
|
res.resume();
|
|
11552
|
-
|
|
11609
|
+
resolve9(res.statusCode === 200);
|
|
11553
11610
|
});
|
|
11554
|
-
req.on("error", () =>
|
|
11611
|
+
req.on("error", () => resolve9(false));
|
|
11555
11612
|
req.setTimeout(timeoutMs, () => {
|
|
11556
11613
|
try {
|
|
11557
11614
|
req.destroy();
|
|
11558
11615
|
} catch {
|
|
11559
11616
|
}
|
|
11560
|
-
|
|
11617
|
+
resolve9(false);
|
|
11561
11618
|
});
|
|
11562
11619
|
});
|
|
11563
11620
|
}
|
|
11564
11621
|
function cdpIsCursor(timeoutMs = 1500) {
|
|
11565
|
-
return new Promise((
|
|
11622
|
+
return new Promise((resolve9) => {
|
|
11566
11623
|
const req = http.get({ host: CDP_HOST, port: CDP_PORT, path: "/json/list" }, (res) => {
|
|
11567
11624
|
let d = "";
|
|
11568
11625
|
res.on("data", (c) => d += c);
|
|
11569
11626
|
res.on("end", () => {
|
|
11570
11627
|
try {
|
|
11571
|
-
if (/[\/\\](windsurf)[\/\\]/i.test(d)) return
|
|
11572
|
-
|
|
11628
|
+
if (/[\/\\](windsurf)[\/\\]/i.test(d)) return resolve9(false);
|
|
11629
|
+
resolve9(/[\/\\]cursor[\/\\](resources|app)|cursor\.exe|vscode-app[^"]*[\/\\]cursor[\/\\]/i.test(d));
|
|
11573
11630
|
} catch {
|
|
11574
|
-
|
|
11631
|
+
resolve9(false);
|
|
11575
11632
|
}
|
|
11576
11633
|
});
|
|
11577
11634
|
});
|
|
11578
|
-
req.on("error", () =>
|
|
11635
|
+
req.on("error", () => resolve9(false));
|
|
11579
11636
|
req.setTimeout(timeoutMs, () => {
|
|
11580
11637
|
try {
|
|
11581
11638
|
req.destroy();
|
|
11582
11639
|
} catch {
|
|
11583
11640
|
}
|
|
11584
|
-
|
|
11641
|
+
resolve9(false);
|
|
11585
11642
|
});
|
|
11586
11643
|
});
|
|
11587
11644
|
}
|
|
@@ -11673,7 +11730,7 @@ async function ensureCursorRunningLocal(options = {}) {
|
|
|
11673
11730
|
const cdpIsCursorImpl = options.cdpIsCursorImpl || cdpIsCursor;
|
|
11674
11731
|
const cursorRunningImpl = options.cursorRunningImpl || cursorRunning;
|
|
11675
11732
|
const findCursorExeDetailsImpl = options.findCursorExeDetailsImpl || findCursorExeDetails;
|
|
11676
|
-
const projectPath = Object.hasOwn(options, "projectPath") ? options.projectPath ?
|
|
11733
|
+
const projectPath = Object.hasOwn(options, "projectPath") ? options.projectPath ? resolve6(String(options.projectPath)) : null : resolveProjectPath();
|
|
11677
11734
|
const listCdpPageTargetsImpl = options.listCdpPageTargetsImpl || listCdpPageTargets;
|
|
11678
11735
|
const spawnImpl = options.spawnImpl || spawn2;
|
|
11679
11736
|
const sleepImpl = options.sleepImpl || ((ms) => new Promise((resolveWait) => setTimeout(resolveWait, ms)));
|
|
@@ -11881,14 +11938,17 @@ async function ensureCursorRunningLocal(options = {}) {
|
|
|
11881
11938
|
};
|
|
11882
11939
|
}
|
|
11883
11940
|
const launchPort = resolveCursorLaunchCdpPort(CDP_PORT);
|
|
11884
|
-
const
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11941
|
+
const startupWindow = (options.readCursorStartupWindowImpl || readCursorStartupWindow)();
|
|
11942
|
+
const args = [
|
|
11943
|
+
`--remote-debugging-port=${launchPort}`,
|
|
11944
|
+
`--remote-allow-origins=http://localhost:${launchPort}`,
|
|
11945
|
+
...cursorStartupWindowArgs(startupWindow, projectPath)
|
|
11946
|
+
];
|
|
11947
|
+
args.push(
|
|
11948
|
+
"--disable-background-timer-throttling",
|
|
11949
|
+
"--disable-renderer-backgrounding",
|
|
11950
|
+
"--disable-backgrounding-occluded-windows"
|
|
11951
|
+
);
|
|
11892
11952
|
const launched = await spawnDetachedSafely(spawnImpl, exe, args, {
|
|
11893
11953
|
detached: true,
|
|
11894
11954
|
stdio: "ignore",
|
|
@@ -11899,6 +11959,7 @@ async function ensureCursorRunningLocal(options = {}) {
|
|
|
11899
11959
|
ok: false,
|
|
11900
11960
|
status: "spawn-blocked",
|
|
11901
11961
|
exe,
|
|
11962
|
+
startupWindow,
|
|
11902
11963
|
port: CDP_PORT,
|
|
11903
11964
|
cursorPid: null,
|
|
11904
11965
|
runtimeMode: effectiveRuntimeMode,
|
|
@@ -11918,6 +11979,7 @@ async function ensureCursorRunningLocal(options = {}) {
|
|
|
11918
11979
|
ok: false,
|
|
11919
11980
|
status: "timeout",
|
|
11920
11981
|
exe,
|
|
11982
|
+
startupWindow,
|
|
11921
11983
|
port: CDP_PORT,
|
|
11922
11984
|
cursorPid: child.pid || null,
|
|
11923
11985
|
runtimeMode: effectiveRuntimeMode,
|
|
@@ -11939,6 +12001,7 @@ async function ensureCursorRunningLocal(options = {}) {
|
|
|
11939
12001
|
ok: false,
|
|
11940
12002
|
status: "workspace-not-ready",
|
|
11941
12003
|
exe,
|
|
12004
|
+
startupWindow,
|
|
11942
12005
|
port: CDP_PORT,
|
|
11943
12006
|
cursorPid,
|
|
11944
12007
|
runtimeMode: effectiveRuntimeMode,
|
|
@@ -11961,6 +12024,7 @@ async function ensureCursorRunningLocal(options = {}) {
|
|
|
11961
12024
|
ok: true,
|
|
11962
12025
|
status: "launched",
|
|
11963
12026
|
exe,
|
|
12027
|
+
startupWindow,
|
|
11964
12028
|
port: CDP_PORT,
|
|
11965
12029
|
cursorPid,
|
|
11966
12030
|
runtimeMode: effectiveRuntimeMode,
|
|
@@ -11976,7 +12040,7 @@ async function ensureCursorRunningLocal(options = {}) {
|
|
|
11976
12040
|
};
|
|
11977
12041
|
}
|
|
11978
12042
|
function normalizeProjectKey(projectPath) {
|
|
11979
|
-
return projectPath ?
|
|
12043
|
+
return projectPath ? resolve6(String(projectPath)).replace(/\\/g, "/").toLowerCase() : "";
|
|
11980
12044
|
}
|
|
11981
12045
|
function targetTitleMatchesProject(title, projectPath) {
|
|
11982
12046
|
const name = basename4(String(projectPath || "")).trim().toLowerCase();
|
|
@@ -12054,6 +12118,7 @@ async function waitForProjectCdpTarget(maxMs, projectPath, listImpl = listCdpPag
|
|
|
12054
12118
|
var CDP_PORT, CDP_ORIGIN, CDP_HOST, PROJECT_TARGETS, CODEX_THREAD_PROJECTS, loadModule;
|
|
12055
12119
|
var init_cursor_ensure_core = __esm({
|
|
12056
12120
|
"cursor-ensure-core.mjs"() {
|
|
12121
|
+
init_cursor_startup_window();
|
|
12057
12122
|
init_cursor_runtime();
|
|
12058
12123
|
CDP_PORT = Number(process.env.CURSOR_BRIDGE_CDP_PORT || 9223);
|
|
12059
12124
|
CDP_ORIGIN = `http://localhost:${CDP_PORT}`;
|
|
@@ -12282,20 +12347,20 @@ var init_win_job_breakaway = __esm({
|
|
|
12282
12347
|
|
|
12283
12348
|
// cursor-lifecycle-client.mjs
|
|
12284
12349
|
import net from "node:net";
|
|
12285
|
-
import { createHash as
|
|
12350
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
12286
12351
|
import {
|
|
12287
12352
|
existsSync as existsSync4,
|
|
12288
|
-
mkdirSync as
|
|
12289
|
-
readFileSync as
|
|
12353
|
+
mkdirSync as mkdirSync7,
|
|
12354
|
+
readFileSync as readFileSync6,
|
|
12290
12355
|
realpathSync,
|
|
12291
12356
|
readdirSync,
|
|
12292
|
-
renameSync as
|
|
12293
|
-
rmSync as
|
|
12357
|
+
renameSync as renameSync6,
|
|
12358
|
+
rmSync as rmSync6,
|
|
12294
12359
|
unlinkSync,
|
|
12295
|
-
writeFileSync as
|
|
12360
|
+
writeFileSync as writeFileSync6
|
|
12296
12361
|
} from "node:fs";
|
|
12297
12362
|
import { fileURLToPath } from "node:url";
|
|
12298
|
-
import { basename as basename5, dirname as
|
|
12363
|
+
import { basename as basename5, dirname as dirname6, join as join8, resolve as resolve7, win32 as win32Path } from "node:path";
|
|
12299
12364
|
function resolveSupervisorSpawnCwd({
|
|
12300
12365
|
requestedCwd = null,
|
|
12301
12366
|
runtimeRoot = null,
|
|
@@ -12310,9 +12375,9 @@ function resolveSupervisorSpawnCwd({
|
|
|
12310
12375
|
return runtimeRoot;
|
|
12311
12376
|
}
|
|
12312
12377
|
function resolvePluginLocalLifecycleDir(sourceScript) {
|
|
12313
|
-
const scriptDir =
|
|
12314
|
-
const pluginRoot = basename5(scriptDir).toLowerCase() === "dist" ?
|
|
12315
|
-
return
|
|
12378
|
+
const scriptDir = dirname6(resolve7(sourceScript));
|
|
12379
|
+
const pluginRoot = basename5(scriptDir).toLowerCase() === "dist" ? dirname6(scriptDir) : scriptDir;
|
|
12380
|
+
return join8(pluginRoot, ".cursor-bridge-lifecycle");
|
|
12316
12381
|
}
|
|
12317
12382
|
function inspectWindowsAppContainerPath(target, options = {}) {
|
|
12318
12383
|
const platform = options.platform || process.platform;
|
|
@@ -12355,59 +12420,59 @@ function sleep(ms) {
|
|
|
12355
12420
|
}
|
|
12356
12421
|
function resolveSupervisorScript() {
|
|
12357
12422
|
if (process.env.CURSOR_BRIDGE_SUPERVISOR_SCRIPT && existsSync4(process.env.CURSOR_BRIDGE_SUPERVISOR_SCRIPT)) {
|
|
12358
|
-
return
|
|
12423
|
+
return resolve7(process.env.CURSOR_BRIDGE_SUPERVISOR_SCRIPT);
|
|
12359
12424
|
}
|
|
12360
|
-
const here =
|
|
12425
|
+
const here = dirname6(fileURLToPath(import.meta.url));
|
|
12361
12426
|
const candidates = [];
|
|
12362
12427
|
if (typeof process.argv[1] === "string") {
|
|
12363
|
-
const entryDir =
|
|
12364
|
-
candidates.push(
|
|
12365
|
-
candidates.push(
|
|
12428
|
+
const entryDir = dirname6(resolve7(process.argv[1]));
|
|
12429
|
+
candidates.push(join8(entryDir, "dist", "cursor-lifecycle-supervisor.mjs"));
|
|
12430
|
+
candidates.push(join8(entryDir, "cursor-lifecycle-supervisor.mjs"));
|
|
12366
12431
|
}
|
|
12367
12432
|
candidates.push(
|
|
12368
|
-
|
|
12369
|
-
|
|
12433
|
+
join8(here, "dist", "cursor-lifecycle-supervisor.mjs"),
|
|
12434
|
+
join8(here, "cursor-lifecycle-supervisor.mjs")
|
|
12370
12435
|
);
|
|
12371
12436
|
for (const c of candidates) {
|
|
12372
12437
|
if (existsSync4(c)) return c;
|
|
12373
12438
|
}
|
|
12374
|
-
return
|
|
12439
|
+
return join8(here, "cursor-lifecycle-supervisor.mjs");
|
|
12375
12440
|
}
|
|
12376
12441
|
function writeRuntimeFile(target, content) {
|
|
12377
|
-
if (existsSync4(target) &&
|
|
12442
|
+
if (existsSync4(target) && readFileSync6(target).equals(content)) return;
|
|
12378
12443
|
const temporary = `${target}.${process.pid}.${Date.now()}.tmp`;
|
|
12379
|
-
|
|
12444
|
+
writeFileSync6(temporary, content);
|
|
12380
12445
|
try {
|
|
12381
|
-
|
|
12446
|
+
renameSync6(temporary, target);
|
|
12382
12447
|
} catch (error2) {
|
|
12383
12448
|
if (!existsSync4(target)) {
|
|
12384
|
-
|
|
12449
|
+
rmSync6(temporary, { force: true });
|
|
12385
12450
|
throw error2;
|
|
12386
12451
|
}
|
|
12387
|
-
if (
|
|
12388
|
-
|
|
12452
|
+
if (readFileSync6(target).equals(content)) {
|
|
12453
|
+
rmSync6(temporary, { force: true });
|
|
12389
12454
|
return;
|
|
12390
12455
|
}
|
|
12391
|
-
|
|
12392
|
-
|
|
12456
|
+
rmSync6(target, { force: true });
|
|
12457
|
+
renameSync6(temporary, target);
|
|
12393
12458
|
}
|
|
12394
12459
|
}
|
|
12395
12460
|
function materializeLifecycleSupervisorRuntime({ sourceScript, dir = defaultLifecycleDir() } = {}) {
|
|
12396
12461
|
const described = describeLifecycleSupervisorRuntime({ sourceScript, dir });
|
|
12397
12462
|
const { sourceScript: source, content, fingerprint } = described;
|
|
12398
|
-
const runtimeRoot =
|
|
12399
|
-
|
|
12400
|
-
const script =
|
|
12463
|
+
const runtimeRoot = join8(ensureLifecycleDir(dir), "runtime", `supervisor-${fingerprint.slice(0, 20)}`);
|
|
12464
|
+
mkdirSync7(runtimeRoot, { recursive: true });
|
|
12465
|
+
const script = join8(runtimeRoot, "cursor-lifecycle-supervisor.mjs");
|
|
12401
12466
|
writeRuntimeFile(script, content);
|
|
12402
12467
|
return { sourceScript: source, script, runtimeRoot, fingerprint };
|
|
12403
12468
|
}
|
|
12404
12469
|
function describeLifecycleSupervisorRuntime({ sourceScript, dir = defaultLifecycleDir() } = {}) {
|
|
12405
|
-
const source =
|
|
12470
|
+
const source = resolve7(sourceScript || resolveSupervisorScript());
|
|
12406
12471
|
if (!existsSync4(source)) throw new Error(`lifecycle supervisor script missing: ${source}`);
|
|
12407
|
-
const content =
|
|
12408
|
-
const fingerprint =
|
|
12409
|
-
const runtimeRoot =
|
|
12410
|
-
const script =
|
|
12472
|
+
const content = readFileSync6(source);
|
|
12473
|
+
const fingerprint = createHash3("sha256").update(content).digest("hex");
|
|
12474
|
+
const runtimeRoot = join8(dir, "runtime", `supervisor-${fingerprint.slice(0, 20)}`);
|
|
12475
|
+
const script = join8(runtimeRoot, "cursor-lifecycle-supervisor.mjs");
|
|
12411
12476
|
return { sourceScript: source, script, runtimeRoot, fingerprint, content };
|
|
12412
12477
|
}
|
|
12413
12478
|
function isProcessAlive(pid) {
|
|
@@ -12421,7 +12486,7 @@ function isProcessAlive(pid) {
|
|
|
12421
12486
|
}
|
|
12422
12487
|
function readPidFile(pidPath) {
|
|
12423
12488
|
try {
|
|
12424
|
-
const n = Number(String(
|
|
12489
|
+
const n = Number(String(readFileSync6(pidPath, "utf8")).trim());
|
|
12425
12490
|
return Number.isFinite(n) ? n : null;
|
|
12426
12491
|
} catch {
|
|
12427
12492
|
return null;
|
|
@@ -12536,7 +12601,7 @@ function tryUnlink(path) {
|
|
|
12536
12601
|
}
|
|
12537
12602
|
}
|
|
12538
12603
|
function writeBootEnv(dir, extra = {}) {
|
|
12539
|
-
const bootPath =
|
|
12604
|
+
const bootPath = join8(dir, `boot-env-${process.pid}-${Date.now()}.json`);
|
|
12540
12605
|
const payload = { ...extra };
|
|
12541
12606
|
for (const [key, value] of Object.entries(process.env)) {
|
|
12542
12607
|
if (key.startsWith("CURSOR_BRIDGE_") || key === "CURSOR_PROJECT_PATH" || key === "CURSOR_EXE") {
|
|
@@ -12547,7 +12612,7 @@ function writeBootEnv(dir, extra = {}) {
|
|
|
12547
12612
|
for (const [k, v] of Object.entries(payload)) {
|
|
12548
12613
|
if (v != null && v !== "") cleaned[k] = String(v);
|
|
12549
12614
|
}
|
|
12550
|
-
|
|
12615
|
+
writeFileSync6(bootPath, `${JSON.stringify(cleaned, null, 2)}
|
|
12551
12616
|
`, { encoding: "utf8" });
|
|
12552
12617
|
return bootPath;
|
|
12553
12618
|
}
|
|
@@ -12582,9 +12647,9 @@ async function ensureSupervisorConnected(options = {}) {
|
|
|
12582
12647
|
let targetRuntime = null;
|
|
12583
12648
|
try {
|
|
12584
12649
|
targetRuntime = options.persistSupervisorRuntime === false ? {
|
|
12585
|
-
sourceScript:
|
|
12586
|
-
script:
|
|
12587
|
-
runtimeRoot:
|
|
12650
|
+
sourceScript: resolve7(sourceScript),
|
|
12651
|
+
script: resolve7(sourceScript),
|
|
12652
|
+
runtimeRoot: dirname6(resolve7(sourceScript)),
|
|
12588
12653
|
fingerprint: null
|
|
12589
12654
|
} : describeLifecycleSupervisorRuntime({ sourceScript, dir });
|
|
12590
12655
|
} catch {
|
|
@@ -12668,9 +12733,9 @@ async function ensureSupervisorConnected(options = {}) {
|
|
|
12668
12733
|
try {
|
|
12669
12734
|
ensureLifecycleDir(dir);
|
|
12670
12735
|
runtime = options.persistSupervisorRuntime === false ? {
|
|
12671
|
-
sourceScript:
|
|
12672
|
-
script:
|
|
12673
|
-
runtimeRoot:
|
|
12736
|
+
sourceScript: resolve7(sourceScript),
|
|
12737
|
+
script: resolve7(sourceScript),
|
|
12738
|
+
runtimeRoot: dirname6(resolve7(sourceScript)),
|
|
12674
12739
|
fingerprint: null
|
|
12675
12740
|
} : (options.materializeRuntimeImpl || materializeLifecycleSupervisorRuntime)({ sourceScript, dir });
|
|
12676
12741
|
} catch (error2) {
|
|
@@ -12834,6 +12899,7 @@ async function ensureCursorViaSupervisor(options = {}) {
|
|
|
12834
12899
|
presentation: response.presentation || null,
|
|
12835
12900
|
windowGuard: response.windowGuard || null,
|
|
12836
12901
|
startupWindowGuard: response.startupWindowGuard || null,
|
|
12902
|
+
startupWindow: response.startupWindow || null,
|
|
12837
12903
|
adapterPid,
|
|
12838
12904
|
supervisorPid: response.supervisorPid || conn.supervisorPid,
|
|
12839
12905
|
reusedSupervisor: conn.reusedSupervisor,
|
|
@@ -21124,7 +21190,7 @@ var Protocol = class {
|
|
|
21124
21190
|
return;
|
|
21125
21191
|
}
|
|
21126
21192
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
21127
|
-
await new Promise((
|
|
21193
|
+
await new Promise((resolve9) => setTimeout(resolve9, pollInterval));
|
|
21128
21194
|
options?.signal?.throwIfAborted();
|
|
21129
21195
|
}
|
|
21130
21196
|
} catch (error2) {
|
|
@@ -21141,7 +21207,7 @@ var Protocol = class {
|
|
|
21141
21207
|
*/
|
|
21142
21208
|
request(request2, resultSchema, options) {
|
|
21143
21209
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
21144
|
-
return new Promise((
|
|
21210
|
+
return new Promise((resolve9, reject) => {
|
|
21145
21211
|
const earlyReject = (error2) => {
|
|
21146
21212
|
reject(error2);
|
|
21147
21213
|
};
|
|
@@ -21219,7 +21285,7 @@ var Protocol = class {
|
|
|
21219
21285
|
if (!parseResult.success) {
|
|
21220
21286
|
reject(parseResult.error);
|
|
21221
21287
|
} else {
|
|
21222
|
-
|
|
21288
|
+
resolve9(parseResult.data);
|
|
21223
21289
|
}
|
|
21224
21290
|
} catch (error2) {
|
|
21225
21291
|
reject(error2);
|
|
@@ -21480,12 +21546,12 @@ var Protocol = class {
|
|
|
21480
21546
|
}
|
|
21481
21547
|
} catch {
|
|
21482
21548
|
}
|
|
21483
|
-
return new Promise((
|
|
21549
|
+
return new Promise((resolve9, reject) => {
|
|
21484
21550
|
if (signal.aborted) {
|
|
21485
21551
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
21486
21552
|
return;
|
|
21487
21553
|
}
|
|
21488
|
-
const timeoutId = setTimeout(
|
|
21554
|
+
const timeoutId = setTimeout(resolve9, interval);
|
|
21489
21555
|
signal.addEventListener("abort", () => {
|
|
21490
21556
|
clearTimeout(timeoutId);
|
|
21491
21557
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -22361,19 +22427,19 @@ var StdioServerTransport = class {
|
|
|
22361
22427
|
this.onclose?.();
|
|
22362
22428
|
}
|
|
22363
22429
|
send(message) {
|
|
22364
|
-
return new Promise((
|
|
22430
|
+
return new Promise((resolve9) => {
|
|
22365
22431
|
const json = serializeMessage(message);
|
|
22366
22432
|
if (this._stdout.write(json)) {
|
|
22367
|
-
|
|
22433
|
+
resolve9();
|
|
22368
22434
|
} else {
|
|
22369
|
-
this._stdout.once("drain",
|
|
22435
|
+
this._stdout.once("drain", resolve9);
|
|
22370
22436
|
}
|
|
22371
22437
|
});
|
|
22372
22438
|
}
|
|
22373
22439
|
};
|
|
22374
22440
|
|
|
22375
22441
|
// server.mjs
|
|
22376
|
-
import { basename as basename6, dirname as
|
|
22442
|
+
import { basename as basename6, dirname as dirname7, join as join9, resolve as resolve8 } from "node:path";
|
|
22377
22443
|
import { statSync as statSync3 } from "node:fs";
|
|
22378
22444
|
|
|
22379
22445
|
// node_modules/ws/wrapper.mjs
|
|
@@ -22436,8 +22502,8 @@ function makeClient(wsUrl, options = {}) {
|
|
|
22436
22502
|
let readyResolve;
|
|
22437
22503
|
let readyReject;
|
|
22438
22504
|
const pending = /* @__PURE__ */ new Map();
|
|
22439
|
-
const ready = new Promise((
|
|
22440
|
-
readyResolve =
|
|
22505
|
+
const ready = new Promise((resolve9, reject) => {
|
|
22506
|
+
readyResolve = resolve9;
|
|
22441
22507
|
readyReject = reject;
|
|
22442
22508
|
});
|
|
22443
22509
|
void ready.catch(() => {
|
|
@@ -22588,7 +22654,7 @@ function makeClient(wsUrl, options = {}) {
|
|
|
22588
22654
|
elapsedMs: 0
|
|
22589
22655
|
}));
|
|
22590
22656
|
}
|
|
22591
|
-
return new Promise((
|
|
22657
|
+
return new Promise((resolve9, reject) => {
|
|
22592
22658
|
const startedAt = Date.now();
|
|
22593
22659
|
const timer = setTimeout(() => {
|
|
22594
22660
|
if (!pending.delete(id)) return;
|
|
@@ -22599,7 +22665,7 @@ function makeClient(wsUrl, options = {}) {
|
|
|
22599
22665
|
elapsedMs: Date.now() - startedAt
|
|
22600
22666
|
}));
|
|
22601
22667
|
}, timeoutMs);
|
|
22602
|
-
pending.set(id, { method, resolve:
|
|
22668
|
+
pending.set(id, { method, resolve: resolve9, reject, timer, startedAt });
|
|
22603
22669
|
try {
|
|
22604
22670
|
ws.send(payload, (cause) => {
|
|
22605
22671
|
if (!cause || !pending.has(id)) return;
|
|
@@ -22901,7 +22967,7 @@ function updateCursorSessionRegistry(filePath, mutator, options = {}) {
|
|
|
22901
22967
|
// server.mjs
|
|
22902
22968
|
init_cursor_ensure_core();
|
|
22903
22969
|
init_lifecycle_paths();
|
|
22904
|
-
var PLUGIN_VERSION = "6.0.
|
|
22970
|
+
var PLUGIN_VERSION = "6.0.3";
|
|
22905
22971
|
var CDP_PORT2 = Number(process.env.CURSOR_BRIDGE_CDP_PORT || 9223);
|
|
22906
22972
|
var ORIGIN = `http://localhost:${CDP_PORT2}`;
|
|
22907
22973
|
var QUERY_TIMEOUT = Number(process.env.CURSOR_BRIDGE_TIMEOUT || 3e5);
|
|
@@ -22925,8 +22991,8 @@ function sessionPathContains(parent, child) {
|
|
|
22925
22991
|
return candidate === base || candidate.startsWith(`${base}/`);
|
|
22926
22992
|
}
|
|
22927
22993
|
function sameSessionProject(left, right) {
|
|
22928
|
-
const a =
|
|
22929
|
-
const b =
|
|
22994
|
+
const a = resolve8(String(left || ""));
|
|
22995
|
+
const b = resolve8(String(right || ""));
|
|
22930
22996
|
return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
22931
22997
|
}
|
|
22932
22998
|
function searchResultContract() {
|
|
@@ -23007,13 +23073,13 @@ var DO_DEFAULT_CONTRACT = "\n\nCompletion requirements: Work directly in the wor
|
|
|
23007
23073
|
var DO_LANGUAGE_CONTRACT = "\n\nResponse language: Reply in the language of the user task unless it explicitly requests another language. Never translate paths, commands, identifiers, keys, enum values, exact options, or error/status codes.";
|
|
23008
23074
|
var CDP_HOST2 = "127.0.0.1";
|
|
23009
23075
|
function httpJson(path) {
|
|
23010
|
-
return new Promise((
|
|
23076
|
+
return new Promise((resolve9, reject) => {
|
|
23011
23077
|
const req = http2.get({ host: CDP_HOST2, port: CDP_PORT2, path }, (res) => {
|
|
23012
23078
|
let d = "";
|
|
23013
23079
|
res.on("data", (c) => d += c);
|
|
23014
23080
|
res.on("end", () => {
|
|
23015
23081
|
try {
|
|
23016
|
-
|
|
23082
|
+
resolve9(JSON.parse(d));
|
|
23017
23083
|
} catch {
|
|
23018
23084
|
reject(new Error("CDP returned a non-JSON response"));
|
|
23019
23085
|
}
|
|
@@ -23232,6 +23298,15 @@ function createChatPanelUnavailableError(snapshot) {
|
|
|
23232
23298
|
return error2;
|
|
23233
23299
|
}
|
|
23234
23300
|
var EXPR_PREPARE_INPUT = `(function(){${INPUT_PICKER_BODY}const inp=pickInput();if(!inp)return 'NO_INPUT';inp.focus();try{const s=getSelection();const r=document.createRange();r.selectNodeContents(inp);s.removeAllRanges();s.addRange(r);}catch(e){}return 'READY';})()`;
|
|
23301
|
+
var SEND_PICKER_BODY = `
|
|
23302
|
+
const composerSelector='.composer-bar,.ui-prompt-input,.agent-prompt-input-root';
|
|
23303
|
+
const composer=input&&(input.closest(composerSelector)||input.parentElement);
|
|
23304
|
+
const sendButtons=composer?[...composer.querySelectorAll('button.ui-prompt-input-submit-button[data-state="send"],button.ui-prompt-input-submit-button[aria-label="Send message"],button[aria-label="Send"],.send-with-mode .anysphere-icon-button')]
|
|
23305
|
+
.filter(button=>button.offsetParent!==null&&!button.disabled
|
|
23306
|
+
&&button.getAttribute('aria-disabled')!=='true'&&button.getAttribute('data-disabled')!=='true'
|
|
23307
|
+
&&!button.classList.contains('disabled')&&getComputedStyle(button).pointerEvents!=='none'
|
|
23308
|
+
&&button.closest(composerSelector)===composer
|
|
23309
|
+
&&(!button.matches('.send-with-mode .anysphere-icon-button')||!!button.querySelector('.codicon-arrow-up-two'))):[];`;
|
|
23235
23310
|
var EXPR_SNAP = `(function(){
|
|
23236
23311
|
const md=[...document.querySelectorAll('.markdown-root,.aichat-container [class*=markdown]')]
|
|
23237
23312
|
.filter(e=>e.offsetParent!==null&&!e.closest('.ui-model-picker__trigger,[class*=model-picker]'));
|
|
@@ -23242,19 +23317,15 @@ var EXPR_SNAP = `(function(){
|
|
|
23242
23317
|
${INPUT_PICKER_BODY}
|
|
23243
23318
|
const input=pickInput();
|
|
23244
23319
|
const inputText=String(input&&(input.innerText||input.textContent)||'').trim();
|
|
23245
|
-
|
|
23246
|
-
const sendButtons=composer?[...composer.querySelectorAll('button.ui-prompt-input-submit-button[data-state="send"],button.ui-prompt-input-submit-button[aria-label="Send message"],button[aria-label="Send"]')]
|
|
23247
|
-
.filter(button=>button.offsetParent!==null&&!button.disabled&&button.closest('.composer-bar,.ui-prompt-input,.agent-prompt-input-root')===composer):[];
|
|
23320
|
+
${SEND_PICKER_BODY}
|
|
23248
23321
|
return JSON.stringify({messageCount:texts.length,replyLength:last.length,replyHash:hash,stop,inputTextLength:inputText.length,sendReady:sendButtons.length===1});
|
|
23249
23322
|
})()`;
|
|
23250
23323
|
var EXPR_CLICK_SEND = `(function(){${INPUT_PICKER_BODY}
|
|
23251
23324
|
const input=pickInput();if(!input)return 'NO_INPUT';
|
|
23252
|
-
|
|
23325
|
+
${SEND_PICKER_BODY}
|
|
23253
23326
|
if(!composer)return 'NO_COMPOSER';
|
|
23254
|
-
|
|
23255
|
-
|
|
23256
|
-
if(buttons.length!==1)return buttons.length?'AMBIGUOUS_SEND':'NO_SEND';
|
|
23257
|
-
buttons[0].click();return 'CLICKED';
|
|
23327
|
+
if(sendButtons.length!==1)return sendButtons.length?'AMBIGUOUS_SEND':'NO_SEND';
|
|
23328
|
+
sendButtons[0].click();return 'CLICKED';
|
|
23258
23329
|
})()`;
|
|
23259
23330
|
var EXPR_EXTRACT = `(function(){
|
|
23260
23331
|
const md=[...document.querySelectorAll('.markdown-root,.aichat-container [class*=markdown]')]
|
|
@@ -24076,6 +24147,7 @@ function lifecycleFromEnsureResult(result, fallbackRuntimeMode) {
|
|
|
24076
24147
|
presentation: result.presentation || null,
|
|
24077
24148
|
windowGuard: result.windowGuard || null,
|
|
24078
24149
|
startupWindowGuard: result.startupWindowGuard || null,
|
|
24150
|
+
startupWindow: result.startupWindow || null,
|
|
24079
24151
|
message: result.message || null,
|
|
24080
24152
|
needsAction: result.needsAction || null,
|
|
24081
24153
|
nextStep: result.nextStep || null,
|
|
@@ -24101,16 +24173,16 @@ function lifecycleFailureSummary(lifecycle, fallback) {
|
|
|
24101
24173
|
return [lifecycle.message || fallback, `[${diagnostic}]`, original].filter(Boolean).join(" ");
|
|
24102
24174
|
}
|
|
24103
24175
|
function releaseAdapterWorkingDirectory({ targetDir = null, chdir = process.chdir } = {}) {
|
|
24104
|
-
const target = targetDir ? ensureLifecycleDir(targetDir) :
|
|
24176
|
+
const target = targetDir ? ensureLifecycleDir(targetDir) : dirname7(process.execPath);
|
|
24105
24177
|
chdir(target);
|
|
24106
24178
|
return target;
|
|
24107
24179
|
}
|
|
24108
24180
|
var CursorBridge = class {
|
|
24109
24181
|
constructor(options = {}) {
|
|
24110
|
-
this.adapterStartCwd =
|
|
24182
|
+
this.adapterStartCwd = resolve8(options.adapterStartCwd || process.cwd());
|
|
24111
24183
|
this.environmentDelegationMode = normalizeDelegationMode(options.delegationMode || DELEGATION_MODE);
|
|
24112
24184
|
this._syncDelegationState();
|
|
24113
|
-
this.runtimeFile = options.runtimeFile === null ? null :
|
|
24185
|
+
this.runtimeFile = options.runtimeFile === null ? null : resolve8(options.runtimeFile || resolveCursorRuntimeFile());
|
|
24114
24186
|
this.runtimeModeDefault = normalizeCursorRuntimeMode(
|
|
24115
24187
|
options.runtimeModeDefault || process.env.CURSOR_BRIDGE_RUNTIME_MODE,
|
|
24116
24188
|
"normal"
|
|
@@ -24121,16 +24193,16 @@ var CursorBridge = class {
|
|
|
24121
24193
|
this.runtimeMode = normalizeCursorRuntimeMode(requestedRuntimeMode);
|
|
24122
24194
|
this.runtimeModeSource = options.runtimeMode !== void 0 ? "constructor" : persistedRuntimeMode ? "persistent" : process.env.CURSOR_BRIDGE_RUNTIME_MODE ? "environment" : "default";
|
|
24123
24195
|
this.runtimeModeScope = persistedRuntimeMode ? "persistent" : options.runtimeMode !== void 0 ? "constructor" : process.env.CURSOR_BRIDGE_RUNTIME_MODE ? "environment" : "default";
|
|
24124
|
-
this.workspaceFile = options.workspaceFile === null ? null :
|
|
24196
|
+
this.workspaceFile = options.workspaceFile === null ? null : resolve8(options.workspaceFile || resolveWorkspaceBindingFile());
|
|
24125
24197
|
this.workspaceKey = options.workspaceKey || resolveWorkspaceBindingKey();
|
|
24126
24198
|
const persistedWorkspace = options.projectPath === void 0 ? readWorkspaceBinding(this.workspaceFile, this.workspaceKey) : null;
|
|
24127
|
-
this.projectPath = options.projectPath !== void 0 ?
|
|
24199
|
+
this.projectPath = options.projectPath !== void 0 ? resolve8(String(options.projectPath)) : persistedWorkspace && persistedWorkspace.projectPath || null;
|
|
24128
24200
|
this.workspaceSource = options.projectPath !== void 0 ? "constructor" : persistedWorkspace ? "persistent_init" : "auto_detect";
|
|
24129
24201
|
this.workspaceUpdatedAt = persistedWorkspace && persistedWorkspace.updatedAt || null;
|
|
24130
24202
|
this.workspaceConfirmationRequired = this.workspaceKey === "default" && !!persistedWorkspace;
|
|
24131
|
-
this.modelPreferencesFile = options.modelPreferencesFile === null ? null :
|
|
24203
|
+
this.modelPreferencesFile = options.modelPreferencesFile === null ? null : resolve8(options.modelPreferencesFile || resolveCursorModelPreferencesFile());
|
|
24132
24204
|
this.modelPreferences = readCursorModelPreferences(this.modelPreferencesFile);
|
|
24133
|
-
this.sessionFile = options.sessionFile === null ? null :
|
|
24205
|
+
this.sessionFile = options.sessionFile === null ? null : resolve8(options.sessionFile || resolveCursorSessionRegistryFile());
|
|
24134
24206
|
this.sessionInstanceId = String(
|
|
24135
24207
|
options.sessionInstanceId || `cursor-adapter-${createCursorSessionId().slice("cursor-session-".length)}`
|
|
24136
24208
|
);
|
|
@@ -24988,8 +25060,8 @@ var CursorBridge = class {
|
|
|
24988
25060
|
const id = options.taskId || this._nextTaskId();
|
|
24989
25061
|
let resolvePromise;
|
|
24990
25062
|
let rejectPromise;
|
|
24991
|
-
const promise = new Promise((
|
|
24992
|
-
resolvePromise =
|
|
25063
|
+
const promise = new Promise((resolve9, reject) => {
|
|
25064
|
+
resolvePromise = resolve9;
|
|
24993
25065
|
rejectPromise = reject;
|
|
24994
25066
|
});
|
|
24995
25067
|
promise.catch(() => {
|
|
@@ -27784,6 +27856,7 @@ export {
|
|
|
27784
27856
|
EXPR_PAGE_CAPABILITIES,
|
|
27785
27857
|
EXPR_PREPARE_INPUT,
|
|
27786
27858
|
EXPR_PROVIDER_ERROR,
|
|
27859
|
+
EXPR_SNAP,
|
|
27787
27860
|
EXPR_VISIBLE,
|
|
27788
27861
|
EXPR_VISIBLE_COMPOSER,
|
|
27789
27862
|
PLUGIN_VERSION,
|