@codexhost/cli-darwin-x64 0.10.2 → 0.12.0
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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +4 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +18001 -0
- package/app/console-web.js +27674 -0
- package/app/desktop-controller.mjs +452 -110
- package/app/host-runtime.mjs +6670 -1272
- package/app/plugins/antigravity/plugin.mjs +686 -305
- package/app/plugins/claude-code/plugin.mjs +2283 -1450
- package/app/plugins/codebuddy/plugin.mjs +1272 -506
- package/app/plugins/cursor-cli/manifest.json +1 -1
- package/app/plugins/cursor-cli/plugin.mjs +1295 -497
- package/app/plugins/deepseek-harness/plugin.mjs +4718 -4925
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/plugin.mjs +1012 -369
- package/app/plugins/hermes/plugin.mjs +18587 -22714
- package/app/plugins/kimi-code/plugin.mjs +1283 -355
- package/app/plugins/kiro-cli/plugin.mjs +840 -299
- package/app/plugins/omp/plugin.mjs +1045 -328
- package/app/plugins/opencode/plugin.mjs +5341 -1686
- package/app/plugins/pi/plugin.mjs +1343 -534
- package/app/plugins/qoder/plugin.mjs +913 -258
- package/app/plugins/qoder-cn/plugin.mjs +712 -49
- package/app/plugins/workbuddy/plugin.mjs +531 -44
- package/app/plugins/zcode/assets/icon.svg +8 -0
- package/app/plugins/zcode/manifest.json +14 -0
- package/app/plugins/zcode/plugin.mjs +19202 -0
- package/app/renderer-extension.js +5011 -1899
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/licenses/OpenCode-v2-Client-LICENSE.txt +21 -0
- package/package.json +1 -1
|
@@ -3229,8 +3229,8 @@ var require_utils = __commonJS({
|
|
|
3229
3229
|
}
|
|
3230
3230
|
return ind;
|
|
3231
3231
|
}
|
|
3232
|
-
function removeDotSegments(
|
|
3233
|
-
let input =
|
|
3232
|
+
function removeDotSegments(path12) {
|
|
3233
|
+
let input = path12;
|
|
3234
3234
|
const output = [];
|
|
3235
3235
|
let nextSlash = -1;
|
|
3236
3236
|
let len = 0;
|
|
@@ -3482,8 +3482,8 @@ var require_schemes = __commonJS({
|
|
|
3482
3482
|
wsComponent.secure = void 0;
|
|
3483
3483
|
}
|
|
3484
3484
|
if (wsComponent.resourceName) {
|
|
3485
|
-
const [
|
|
3486
|
-
wsComponent.path =
|
|
3485
|
+
const [path12, query] = wsComponent.resourceName.split("?");
|
|
3486
|
+
wsComponent.path = path12 && path12 !== "/" ? path12 : void 0;
|
|
3487
3487
|
wsComponent.query = query;
|
|
3488
3488
|
wsComponent.resourceName = void 0;
|
|
3489
3489
|
}
|
|
@@ -12694,6 +12694,373 @@ var require_content_type = __commonJS({
|
|
|
12694
12694
|
}
|
|
12695
12695
|
});
|
|
12696
12696
|
|
|
12697
|
+
// ../../harness-discovery/dist/environment.js
|
|
12698
|
+
import fs from "node:fs";
|
|
12699
|
+
import path from "node:path";
|
|
12700
|
+
function targetPath(platform) {
|
|
12701
|
+
return platform === "win32" ? path.win32 : path.posix;
|
|
12702
|
+
}
|
|
12703
|
+
function environmentValue(environment, name) {
|
|
12704
|
+
const lowered = name.toLowerCase();
|
|
12705
|
+
for (const [key, value] of Object.entries(environment)) {
|
|
12706
|
+
if (key.toLowerCase() === lowered)
|
|
12707
|
+
return value;
|
|
12708
|
+
}
|
|
12709
|
+
return void 0;
|
|
12710
|
+
}
|
|
12711
|
+
function pathDelimiter(platform) {
|
|
12712
|
+
return platform === "win32" ? ";" : ":";
|
|
12713
|
+
}
|
|
12714
|
+
function pathDirectories(environment, platform) {
|
|
12715
|
+
return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
12716
|
+
}
|
|
12717
|
+
function executableExtensions(command, platform, environment) {
|
|
12718
|
+
if (platform !== "win32")
|
|
12719
|
+
return [""];
|
|
12720
|
+
if (targetPath(platform).extname(command) !== "")
|
|
12721
|
+
return [""];
|
|
12722
|
+
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
12723
|
+
}
|
|
12724
|
+
function isExecutableFile(filePath, platform) {
|
|
12725
|
+
try {
|
|
12726
|
+
fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
12727
|
+
return fs.statSync(filePath).isFile();
|
|
12728
|
+
} catch {
|
|
12729
|
+
return false;
|
|
12730
|
+
}
|
|
12731
|
+
}
|
|
12732
|
+
function subdirectoryNames(directory) {
|
|
12733
|
+
try {
|
|
12734
|
+
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
12735
|
+
} catch {
|
|
12736
|
+
return [];
|
|
12737
|
+
}
|
|
12738
|
+
}
|
|
12739
|
+
function newestFirst(names) {
|
|
12740
|
+
return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
|
|
12741
|
+
}
|
|
12742
|
+
|
|
12743
|
+
// ../../harness-discovery/dist/invocation.js
|
|
12744
|
+
import path2 from "node:path";
|
|
12745
|
+
function commandInvocation(command, arguments_, environment, platform = process.platform) {
|
|
12746
|
+
const extension = path2.win32.extname(command).toLowerCase();
|
|
12747
|
+
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
12748
|
+
return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
|
|
12749
|
+
}
|
|
12750
|
+
const quote2 = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
12751
|
+
const commandLine = [command, ...arguments_].map(quote2).join(" ");
|
|
12752
|
+
return {
|
|
12753
|
+
command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
|
|
12754
|
+
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
12755
|
+
windowsVerbatimArguments: true
|
|
12756
|
+
};
|
|
12757
|
+
}
|
|
12758
|
+
|
|
12759
|
+
// ../../harness-discovery/dist/node-runtime.js
|
|
12760
|
+
import path3 from "node:path";
|
|
12761
|
+
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
12762
|
+
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
12763
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
12764
|
+
const runtimeDirectory = path3.dirname(runtimeExecutable);
|
|
12765
|
+
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
12766
|
+
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
12767
|
+
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
12768
|
+
directories.push(runtimeDirectory);
|
|
12769
|
+
}
|
|
12770
|
+
return { ...environment, [pathKey]: directories.join(delimiter) };
|
|
12771
|
+
}
|
|
12772
|
+
|
|
12773
|
+
// ../../harness-discovery/dist/resolve.js
|
|
12774
|
+
import os from "node:os";
|
|
12775
|
+
|
|
12776
|
+
// ../../harness-discovery/dist/version-managers.js
|
|
12777
|
+
function versionManagerBinaryDirectories(context) {
|
|
12778
|
+
const { platform, environment, home } = context;
|
|
12779
|
+
const list = context.subdirectories ?? subdirectoryNames;
|
|
12780
|
+
const pathFlavor = targetPath(platform);
|
|
12781
|
+
const value = (name) => environmentValue(environment, name);
|
|
12782
|
+
const directories = [];
|
|
12783
|
+
const versioned = (root, ...tail) => {
|
|
12784
|
+
for (const version2 of newestFirst(list(root))) {
|
|
12785
|
+
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
12786
|
+
}
|
|
12787
|
+
};
|
|
12788
|
+
if (platform === "win32") {
|
|
12789
|
+
const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
|
|
12790
|
+
const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
|
|
12791
|
+
versioned(pathFlavor.join(appData, "nvm"));
|
|
12792
|
+
versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
|
|
12793
|
+
directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
|
|
12794
|
+
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
12795
|
+
const pnpmHome2 = value("PNPM_HOME");
|
|
12796
|
+
if (pnpmHome2)
|
|
12797
|
+
directories.push(pnpmHome2);
|
|
12798
|
+
directories.push(pathFlavor.join(localAppData, "pnpm"));
|
|
12799
|
+
return directories;
|
|
12800
|
+
}
|
|
12801
|
+
versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
|
|
12802
|
+
const fnmRoots = [
|
|
12803
|
+
value("FNM_DIR"),
|
|
12804
|
+
pathFlavor.join(home, ".local", "share", "fnm"),
|
|
12805
|
+
pathFlavor.join(home, "Library", "Application Support", "fnm")
|
|
12806
|
+
].filter((root) => root !== void 0);
|
|
12807
|
+
for (const root of fnmRoots) {
|
|
12808
|
+
versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
|
|
12809
|
+
}
|
|
12810
|
+
const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
|
|
12811
|
+
versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
|
|
12812
|
+
directories.push(pathFlavor.join(voltaHome, "bin"));
|
|
12813
|
+
const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
|
|
12814
|
+
versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
|
|
12815
|
+
directories.push(pathFlavor.join(asdfHome, "shims"));
|
|
12816
|
+
const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
|
|
12817
|
+
versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
|
|
12818
|
+
directories.push(pathFlavor.join(nodenvHome, "shims"));
|
|
12819
|
+
versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
|
|
12820
|
+
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
12821
|
+
const pnpmHome = value("PNPM_HOME");
|
|
12822
|
+
if (pnpmHome)
|
|
12823
|
+
directories.push(pnpmHome);
|
|
12824
|
+
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
12825
|
+
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
12826
|
+
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
12827
|
+
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
12828
|
+
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
12829
|
+
}
|
|
12830
|
+
}
|
|
12831
|
+
return directories;
|
|
12832
|
+
}
|
|
12833
|
+
|
|
12834
|
+
// ../../harness-discovery/dist/resolve.js
|
|
12835
|
+
var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
12836
|
+
function installRootExtensions(platform) {
|
|
12837
|
+
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
12838
|
+
}
|
|
12839
|
+
function resolveHomeDirectory(input) {
|
|
12840
|
+
return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
|
|
12841
|
+
}
|
|
12842
|
+
function templateVariables(environment, platform, home) {
|
|
12843
|
+
const pathFlavor = targetPath(platform);
|
|
12844
|
+
return {
|
|
12845
|
+
HOME: home,
|
|
12846
|
+
USERPROFILE: home,
|
|
12847
|
+
APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
|
|
12848
|
+
LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
|
|
12849
|
+
};
|
|
12850
|
+
}
|
|
12851
|
+
function joinTemplate(platform, value) {
|
|
12852
|
+
const pathFlavor = targetPath(platform);
|
|
12853
|
+
const segments = value.split("/");
|
|
12854
|
+
const head = segments[0] ?? "";
|
|
12855
|
+
const tail = segments.slice(1);
|
|
12856
|
+
if (head === "")
|
|
12857
|
+
return pathFlavor.join(pathFlavor.sep, ...tail);
|
|
12858
|
+
return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
|
|
12859
|
+
}
|
|
12860
|
+
function expandInstallRoot(template, environment, platform, home) {
|
|
12861
|
+
const variables = templateVariables(environment, platform, home);
|
|
12862
|
+
let unresolved = false;
|
|
12863
|
+
const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
|
|
12864
|
+
const value = variables[name] ?? environmentValue(environment, name);
|
|
12865
|
+
if (value === void 0 || value === "") {
|
|
12866
|
+
unresolved = true;
|
|
12867
|
+
return "";
|
|
12868
|
+
}
|
|
12869
|
+
return value;
|
|
12870
|
+
});
|
|
12871
|
+
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
12872
|
+
}
|
|
12873
|
+
function installRootDirectories(spec, input, dependencies, platform, home) {
|
|
12874
|
+
const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
|
|
12875
|
+
const directories = [];
|
|
12876
|
+
for (const template of templates) {
|
|
12877
|
+
if (template === VERSION_MANAGER_ROOTS) {
|
|
12878
|
+
directories.push(...versionManagerBinaryDirectories({
|
|
12879
|
+
platform,
|
|
12880
|
+
environment: input.environment,
|
|
12881
|
+
home,
|
|
12882
|
+
...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
|
|
12883
|
+
}));
|
|
12884
|
+
continue;
|
|
12885
|
+
}
|
|
12886
|
+
const directory = expandInstallRoot(template, input.environment, platform, home);
|
|
12887
|
+
if (directory !== void 0)
|
|
12888
|
+
directories.push(directory);
|
|
12889
|
+
}
|
|
12890
|
+
return directories;
|
|
12891
|
+
}
|
|
12892
|
+
function harnessCandidates(spec, input, dependencies = {}) {
|
|
12893
|
+
const platform = input.platform ?? process.platform;
|
|
12894
|
+
const pathFlavor = targetPath(platform);
|
|
12895
|
+
const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
|
|
12896
|
+
const command = configured ?? spec.command;
|
|
12897
|
+
if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
12898
|
+
return [{ candidate: command, source: "configured" }];
|
|
12899
|
+
}
|
|
12900
|
+
const candidates = [];
|
|
12901
|
+
const extensions = executableExtensions(command, platform, input.environment);
|
|
12902
|
+
for (const directory of pathDirectories(input.environment, platform)) {
|
|
12903
|
+
for (const extension of extensions) {
|
|
12904
|
+
candidates.push({
|
|
12905
|
+
candidate: pathFlavor.join(directory, command + extension),
|
|
12906
|
+
source: "path"
|
|
12907
|
+
});
|
|
12908
|
+
}
|
|
12909
|
+
}
|
|
12910
|
+
if (configured !== void 0)
|
|
12911
|
+
return candidates;
|
|
12912
|
+
const home = resolveHomeDirectory(input);
|
|
12913
|
+
for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
|
|
12914
|
+
for (const extension of installRootExtensions(platform)) {
|
|
12915
|
+
candidates.push({
|
|
12916
|
+
candidate: pathFlavor.join(directory, spec.command + extension),
|
|
12917
|
+
source: "install-root"
|
|
12918
|
+
});
|
|
12919
|
+
}
|
|
12920
|
+
}
|
|
12921
|
+
return candidates;
|
|
12922
|
+
}
|
|
12923
|
+
function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
12924
|
+
const platform = input.platform ?? process.platform;
|
|
12925
|
+
const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
|
|
12926
|
+
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
12927
|
+
const context = { platform, isExecutable };
|
|
12928
|
+
for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
|
|
12929
|
+
const executable = runnable(candidate, context);
|
|
12930
|
+
if (executable !== void 0 && isExecutable(executable))
|
|
12931
|
+
return { executable, source };
|
|
12932
|
+
}
|
|
12933
|
+
return void 0;
|
|
12934
|
+
}
|
|
12935
|
+
|
|
12936
|
+
// ../../harness-discovery/dist/installation.js
|
|
12937
|
+
import { execFile } from "node:child_process";
|
|
12938
|
+
import { homedir } from "node:os";
|
|
12939
|
+
function runInstallationCommand(command, args, environment, timeout = 3e4) {
|
|
12940
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
12941
|
+
const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
|
|
12942
|
+
return new Promise((resolve, reject) => {
|
|
12943
|
+
const child = execFile(invocation.command, invocation.arguments, {
|
|
12944
|
+
env,
|
|
12945
|
+
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
12946
|
+
encoding: "utf8",
|
|
12947
|
+
timeout,
|
|
12948
|
+
killSignal: "SIGKILL",
|
|
12949
|
+
maxBuffer: 1024 * 1024,
|
|
12950
|
+
windowsHide: true,
|
|
12951
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
12952
|
+
}, (error51, stdout, stderr) => {
|
|
12953
|
+
if (error51)
|
|
12954
|
+
reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
|
|
12955
|
+
else
|
|
12956
|
+
resolve((stdout || stderr).trim());
|
|
12957
|
+
});
|
|
12958
|
+
child.stdin?.end();
|
|
12959
|
+
});
|
|
12960
|
+
}
|
|
12961
|
+
function installationVersion(value) {
|
|
12962
|
+
if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
|
|
12963
|
+
throw new Error("Harness returned an invalid version");
|
|
12964
|
+
return value.trim().replace(/^v/, "");
|
|
12965
|
+
}
|
|
12966
|
+
function createInstallationManager(options) {
|
|
12967
|
+
let checking;
|
|
12968
|
+
let updating;
|
|
12969
|
+
const check2 = () => checking ??= options.check().finally(() => {
|
|
12970
|
+
checking = void 0;
|
|
12971
|
+
});
|
|
12972
|
+
return (action) => {
|
|
12973
|
+
if (updating)
|
|
12974
|
+
return updating;
|
|
12975
|
+
if (action === "check")
|
|
12976
|
+
return check2();
|
|
12977
|
+
updating = (async () => {
|
|
12978
|
+
const before = await check2();
|
|
12979
|
+
if (!before.updateAvailable)
|
|
12980
|
+
return before;
|
|
12981
|
+
if (!before.canUpdate)
|
|
12982
|
+
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
12983
|
+
await options.update(before);
|
|
12984
|
+
const after = await check2();
|
|
12985
|
+
if (after.currentVersion === before.currentVersion)
|
|
12986
|
+
throw new Error("The Harness version did not change; check the native updater and retry");
|
|
12987
|
+
return after;
|
|
12988
|
+
})().finally(() => {
|
|
12989
|
+
updating = void 0;
|
|
12990
|
+
});
|
|
12991
|
+
return updating;
|
|
12992
|
+
};
|
|
12993
|
+
}
|
|
12994
|
+
async function fetchInstallationText(url2) {
|
|
12995
|
+
const request = async () => {
|
|
12996
|
+
const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
|
|
12997
|
+
if (!response.ok)
|
|
12998
|
+
throw new Error("Could not check the latest Harness version");
|
|
12999
|
+
return response.text();
|
|
13000
|
+
};
|
|
13001
|
+
try {
|
|
13002
|
+
return await request();
|
|
13003
|
+
} catch (error51) {
|
|
13004
|
+
if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
|
|
13005
|
+
throw error51;
|
|
13006
|
+
return request();
|
|
13007
|
+
}
|
|
13008
|
+
}
|
|
13009
|
+
|
|
13010
|
+
// ../../harness-discovery/dist/installer.js
|
|
13011
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
13012
|
+
import { tmpdir } from "node:os";
|
|
13013
|
+
import { join } from "node:path";
|
|
13014
|
+
function createHarnessInstaller(environment, source) {
|
|
13015
|
+
return async () => {
|
|
13016
|
+
if (!["darwin", "linux", "win32"].includes(process.platform))
|
|
13017
|
+
throw new Error("Unsupported installation platform");
|
|
13018
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
13019
|
+
if ("npm" in source) {
|
|
13020
|
+
const npm = resolveHarnessExecutable({
|
|
13021
|
+
id: "npm",
|
|
13022
|
+
command: "npm",
|
|
13023
|
+
installRoots: {
|
|
13024
|
+
posix: [
|
|
13025
|
+
"~/.npm-global/bin",
|
|
13026
|
+
"~/.local/bin",
|
|
13027
|
+
VERSION_MANAGER_ROOTS,
|
|
13028
|
+
"/opt/homebrew/bin",
|
|
13029
|
+
"/usr/local/bin",
|
|
13030
|
+
"/usr/bin"
|
|
13031
|
+
],
|
|
13032
|
+
windows: [
|
|
13033
|
+
"${APPDATA}/npm",
|
|
13034
|
+
VERSION_MANAGER_ROOTS,
|
|
13035
|
+
"${ProgramFiles}/nodejs",
|
|
13036
|
+
"${LOCALAPPDATA}/Programs/nodejs"
|
|
13037
|
+
]
|
|
13038
|
+
}
|
|
13039
|
+
}, { environment: env });
|
|
13040
|
+
if (!npm)
|
|
13041
|
+
throw new Error("Install Node.js and npm first");
|
|
13042
|
+
await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
|
|
13043
|
+
...env,
|
|
13044
|
+
...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
|
|
13045
|
+
}, 6e5);
|
|
13046
|
+
return;
|
|
13047
|
+
}
|
|
13048
|
+
const windows = process.platform === "win32";
|
|
13049
|
+
const url2 = windows ? source.windows : source.posix;
|
|
13050
|
+
if (new URL(url2).protocol !== "https:")
|
|
13051
|
+
throw new Error("Installer requires HTTPS");
|
|
13052
|
+
const script = await fetchInstallationText(url2);
|
|
13053
|
+
const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
|
|
13054
|
+
try {
|
|
13055
|
+
const file2 = join(directory, windows ? "install.ps1" : "install.sh");
|
|
13056
|
+
await writeFile(file2, script, { mode: 384 });
|
|
13057
|
+
await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
|
|
13058
|
+
} finally {
|
|
13059
|
+
await rm(directory, { recursive: true, force: true });
|
|
13060
|
+
}
|
|
13061
|
+
};
|
|
13062
|
+
}
|
|
13063
|
+
|
|
12697
13064
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
12698
13065
|
var external_exports = {};
|
|
12699
13066
|
__export(external_exports, {
|
|
@@ -13460,10 +13827,10 @@ function mergeDefs(...defs) {
|
|
|
13460
13827
|
function cloneDef(schema) {
|
|
13461
13828
|
return mergeDefs(schema._zod.def);
|
|
13462
13829
|
}
|
|
13463
|
-
function getElementAtPath(obj2,
|
|
13464
|
-
if (!
|
|
13830
|
+
function getElementAtPath(obj2, path12) {
|
|
13831
|
+
if (!path12)
|
|
13465
13832
|
return obj2;
|
|
13466
|
-
return
|
|
13833
|
+
return path12.reduce((acc, key) => acc?.[key], obj2);
|
|
13467
13834
|
}
|
|
13468
13835
|
function promiseAllObject(promisesObj) {
|
|
13469
13836
|
const keys = Object.keys(promisesObj);
|
|
@@ -13872,11 +14239,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
13872
14239
|
}
|
|
13873
14240
|
return false;
|
|
13874
14241
|
}
|
|
13875
|
-
function prefixIssues(
|
|
14242
|
+
function prefixIssues(path12, issues) {
|
|
13876
14243
|
return issues.map((iss) => {
|
|
13877
14244
|
var _a3;
|
|
13878
14245
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
13879
|
-
iss.path.unshift(
|
|
14246
|
+
iss.path.unshift(path12);
|
|
13880
14247
|
return iss;
|
|
13881
14248
|
});
|
|
13882
14249
|
}
|
|
@@ -14023,16 +14390,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
14023
14390
|
}
|
|
14024
14391
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
14025
14392
|
const fieldErrors = { _errors: [] };
|
|
14026
|
-
const processError = (error52,
|
|
14393
|
+
const processError = (error52, path12 = []) => {
|
|
14027
14394
|
for (const issue2 of error52.issues) {
|
|
14028
14395
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
14029
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
14396
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
14030
14397
|
} else if (issue2.code === "invalid_key") {
|
|
14031
|
-
processError({ issues: issue2.issues }, [...
|
|
14398
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
14032
14399
|
} else if (issue2.code === "invalid_element") {
|
|
14033
|
-
processError({ issues: issue2.issues }, [...
|
|
14400
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
14034
14401
|
} else {
|
|
14035
|
-
const fullpath = [...
|
|
14402
|
+
const fullpath = [...path12, ...issue2.path];
|
|
14036
14403
|
if (fullpath.length === 0) {
|
|
14037
14404
|
fieldErrors._errors.push(mapper(issue2));
|
|
14038
14405
|
} else {
|
|
@@ -14059,17 +14426,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
14059
14426
|
}
|
|
14060
14427
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
14061
14428
|
const result = { errors: [] };
|
|
14062
|
-
const processError = (error52,
|
|
14429
|
+
const processError = (error52, path12 = []) => {
|
|
14063
14430
|
var _a3, _b;
|
|
14064
14431
|
for (const issue2 of error52.issues) {
|
|
14065
14432
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
14066
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
14433
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
14067
14434
|
} else if (issue2.code === "invalid_key") {
|
|
14068
|
-
processError({ issues: issue2.issues }, [...
|
|
14435
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
14069
14436
|
} else if (issue2.code === "invalid_element") {
|
|
14070
|
-
processError({ issues: issue2.issues }, [...
|
|
14437
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
14071
14438
|
} else {
|
|
14072
|
-
const fullpath = [...
|
|
14439
|
+
const fullpath = [...path12, ...issue2.path];
|
|
14073
14440
|
if (fullpath.length === 0) {
|
|
14074
14441
|
result.errors.push(mapper(issue2));
|
|
14075
14442
|
continue;
|
|
@@ -14101,8 +14468,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
14101
14468
|
}
|
|
14102
14469
|
function toDotPath(_path) {
|
|
14103
14470
|
const segs = [];
|
|
14104
|
-
const
|
|
14105
|
-
for (const seg of
|
|
14471
|
+
const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
14472
|
+
for (const seg of path12) {
|
|
14106
14473
|
if (typeof seg === "number")
|
|
14107
14474
|
segs.push(`[${seg}]`);
|
|
14108
14475
|
else if (typeof seg === "symbol")
|
|
@@ -26794,13 +27161,13 @@ function resolveRef(ref, ctx) {
|
|
|
26794
27161
|
if (!ref.startsWith("#")) {
|
|
26795
27162
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
26796
27163
|
}
|
|
26797
|
-
const
|
|
26798
|
-
if (
|
|
27164
|
+
const path12 = ref.slice(1).split("/").filter(Boolean);
|
|
27165
|
+
if (path12.length === 0) {
|
|
26799
27166
|
return ctx.rootSchema;
|
|
26800
27167
|
}
|
|
26801
27168
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
26802
|
-
if (
|
|
26803
|
-
const key =
|
|
27169
|
+
if (path12[0] === defsKey) {
|
|
27170
|
+
const key = path12[1];
|
|
26804
27171
|
if (!key || !ctx.defs[key]) {
|
|
26805
27172
|
throw new Error(`Reference not found: ${ref}`);
|
|
26806
27173
|
}
|
|
@@ -27263,6 +27630,56 @@ var credentialImportsParamsSchema = external_exports.object({
|
|
|
27263
27630
|
request: credentialImportsRequestSchema
|
|
27264
27631
|
}).strict();
|
|
27265
27632
|
|
|
27633
|
+
// ../../shared-contracts/dist/harness-display-settings.js
|
|
27634
|
+
var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
|
|
27635
|
+
agent: external_exports.string().min(1).max(128),
|
|
27636
|
+
section: external_exports.enum(["main", "more", "auto"])
|
|
27637
|
+
})).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
|
|
27638
|
+
var harnessDisplaySettingsSchema = external_exports.strictObject({
|
|
27639
|
+
entries: harnessDisplayEntriesSchema.nullable()
|
|
27640
|
+
});
|
|
27641
|
+
var harnessDisplayGetSchema = external_exports.strictObject({});
|
|
27642
|
+
var harnessDisplaySetSchema = external_exports.strictObject({
|
|
27643
|
+
entries: harnessDisplayEntriesSchema,
|
|
27644
|
+
/** Import legacy Desktop preferences only if no shared settings exist yet. */
|
|
27645
|
+
initializeOnly: external_exports.boolean().optional()
|
|
27646
|
+
});
|
|
27647
|
+
|
|
27648
|
+
// ../../shared-contracts/dist/console.js
|
|
27649
|
+
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
27650
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
27651
|
+
type: external_exports.enum(["info", "warning", "danger"]),
|
|
27652
|
+
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
27653
|
+
});
|
|
27654
|
+
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
27655
|
+
var consoleOpenResultSchema = external_exports.strictObject({
|
|
27656
|
+
/** The console address. */
|
|
27657
|
+
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
27658
|
+
});
|
|
27659
|
+
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
27660
|
+
"codexhost/harness/plugins/list",
|
|
27661
|
+
"codexhost/harness/display-settings/get",
|
|
27662
|
+
"codexhost/harness/display-settings/set",
|
|
27663
|
+
"codexhost/harness/inspect",
|
|
27664
|
+
"codexhost/harness/installation",
|
|
27665
|
+
"codexhost/harness/launch-settings/get",
|
|
27666
|
+
"codexhost/harness/launch-settings/set",
|
|
27667
|
+
"codexhost/harness/web-ui/open",
|
|
27668
|
+
"codexhost/harness/accounts/sources",
|
|
27669
|
+
"codexhost/harness/accounts/list",
|
|
27670
|
+
"codexhost/harness/accounts/inspect",
|
|
27671
|
+
"codexhost/harness/credential-imports",
|
|
27672
|
+
"codexhost/harness/session-import/sources",
|
|
27673
|
+
"codexhost/harness/session-import/list",
|
|
27674
|
+
"codexhost/harness/session-import/import",
|
|
27675
|
+
"codexhost/account/list",
|
|
27676
|
+
"codexhost/account/refresh",
|
|
27677
|
+
"codexhost/account/usage/inspect",
|
|
27678
|
+
"codexhost/update/check",
|
|
27679
|
+
"codexhost/update/start",
|
|
27680
|
+
"codexhost/update/status"
|
|
27681
|
+
]);
|
|
27682
|
+
|
|
27266
27683
|
// ../../shared-contracts/dist/version.js
|
|
27267
27684
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
27268
27685
|
|
|
@@ -27316,6 +27733,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
27316
27733
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
27317
27734
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
27318
27735
|
|
|
27736
|
+
// ../../shared-contracts/dist/manual-compaction.js
|
|
27737
|
+
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
27738
|
+
threadId: hostThreadIdSchema,
|
|
27739
|
+
turnId: hostTurnIdSchema
|
|
27740
|
+
});
|
|
27741
|
+
|
|
27319
27742
|
// ../../shared-contracts/dist/thread-usage.js
|
|
27320
27743
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
27321
27744
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -27376,6 +27799,10 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
27376
27799
|
var usagePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
27377
27800
|
var accountCreditsProductUsageSchema = external_exports.object({
|
|
27378
27801
|
product: external_exports.string().min(1),
|
|
27802
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
27803
|
+
// Zero is a real empty cap, not an absent field.
|
|
27804
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
27805
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
27379
27806
|
usagePercent: usagePercentSchema,
|
|
27380
27807
|
resetsAt: external_exports.string().min(1).optional()
|
|
27381
27808
|
}).strict();
|
|
@@ -27385,6 +27812,10 @@ var accountResetCreditsSchema = external_exports.object({
|
|
|
27385
27812
|
expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
|
|
27386
27813
|
}).strict();
|
|
27387
27814
|
var accountCreditsSnapshotSchema = external_exports.object({
|
|
27815
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
27816
|
+
// Zero is a real empty cap, not an absent field.
|
|
27817
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
27818
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
27388
27819
|
/** Native label when the primary limit is scoped to a model or product group. */
|
|
27389
27820
|
label: external_exports.string().min(1).optional(),
|
|
27390
27821
|
usedPercent: usagePercentSchema,
|
|
@@ -27404,12 +27835,27 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
27404
27835
|
}).strict();
|
|
27405
27836
|
|
|
27406
27837
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
27407
|
-
var
|
|
27838
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
27839
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
27840
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
27841
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
27842
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
27843
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
27844
|
+
}).strict();
|
|
27845
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
27408
27846
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
27409
27847
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
27410
27848
|
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
27411
|
-
credits: accountCreditsSnapshotSchema
|
|
27849
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
27850
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
27412
27851
|
}).strict();
|
|
27852
|
+
function requireReportedQuota(schema) {
|
|
27853
|
+
return schema.refine((value) => {
|
|
27854
|
+
const reported = value;
|
|
27855
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
27856
|
+
}, { message: "Account must report either credits or a balance" });
|
|
27857
|
+
}
|
|
27858
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
27413
27859
|
var harnessAccountIdentityShape = {
|
|
27414
27860
|
harnessId: harnessIdSchema,
|
|
27415
27861
|
harnessName: external_exports.string().trim().min(1).max(128)
|
|
@@ -27420,11 +27866,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
|
|
|
27420
27866
|
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
27421
27867
|
var harnessAccountInspectResultSchema = external_exports.object({
|
|
27422
27868
|
...harnessAccountIdentityShape,
|
|
27423
|
-
account: harnessAccountSnapshotSchema.nullable()
|
|
27869
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
27870
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
27871
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
27424
27872
|
}).strict();
|
|
27425
27873
|
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
27426
27874
|
var harnessAccountListResultSchema = external_exports.object({
|
|
27427
|
-
accounts: external_exports.array(
|
|
27875
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
27428
27876
|
}).strict();
|
|
27429
27877
|
|
|
27430
27878
|
// ../../shared-contracts/dist/json-value.js
|
|
@@ -27562,6 +28010,8 @@ var harnessModelSchema = external_exports.object({
|
|
|
27562
28010
|
ref: harnessModelRefSchema,
|
|
27563
28011
|
label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
27564
28012
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
28013
|
+
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
28014
|
+
fastModel: harnessModelRefSchema.optional(),
|
|
27565
28015
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
27566
28016
|
}).strict();
|
|
27567
28017
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
@@ -27594,6 +28044,16 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
27594
28044
|
});
|
|
27595
28045
|
}
|
|
27596
28046
|
refs.add(model.ref.id);
|
|
28047
|
+
if (model.fastModel) {
|
|
28048
|
+
if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
|
|
28049
|
+
context.addIssue({
|
|
28050
|
+
code: "custom",
|
|
28051
|
+
message: "Fast Model refs must be distinct and unique",
|
|
28052
|
+
path: ["models", index, "fastModel"]
|
|
28053
|
+
});
|
|
28054
|
+
}
|
|
28055
|
+
refs.add(model.fastModel.id);
|
|
28056
|
+
}
|
|
27597
28057
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
27598
28058
|
for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
|
|
27599
28059
|
if (supportedThinkingIds.has(optionId)) {
|
|
@@ -27713,11 +28173,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
|
|
|
27713
28173
|
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
27714
28174
|
}).strict();
|
|
27715
28175
|
var threadInspectionParamsSchema = external_exports.object({
|
|
27716
|
-
threadId: hostThreadIdSchema
|
|
28176
|
+
threadId: hostThreadIdSchema,
|
|
28177
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
27717
28178
|
}).strict();
|
|
27718
28179
|
var codexThreadInspectionSchema = external_exports.object({
|
|
27719
28180
|
owner: external_exports.literal("codex"),
|
|
27720
|
-
locked: external_exports.literal(true)
|
|
28181
|
+
locked: external_exports.literal(true),
|
|
28182
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
27721
28183
|
}).strict();
|
|
27722
28184
|
var externalThreadInspectionSchema = external_exports.object({
|
|
27723
28185
|
owner: external_exports.literal("external"),
|
|
@@ -27843,6 +28305,22 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
27843
28305
|
restartRequired: external_exports.boolean()
|
|
27844
28306
|
}).strict();
|
|
27845
28307
|
|
|
28308
|
+
// ../../shared-contracts/dist/harness-installation.js
|
|
28309
|
+
var harnessInstallationParamsSchema = external_exports.object({
|
|
28310
|
+
harnessId: harnessIdSchema,
|
|
28311
|
+
action: external_exports.enum(["check", "update", "install"])
|
|
28312
|
+
}).strict();
|
|
28313
|
+
var harnessInstallationStateSchema = external_exports.object({
|
|
28314
|
+
currentVersion: external_exports.string().min(1).max(128),
|
|
28315
|
+
latestVersion: external_exports.string().min(1).max(128),
|
|
28316
|
+
updateAvailable: external_exports.boolean(),
|
|
28317
|
+
canUpdate: external_exports.boolean(),
|
|
28318
|
+
// Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
|
|
28319
|
+
message: external_exports.string().max(2048).optional(),
|
|
28320
|
+
messageCode: external_exports.string().min(1).max(128).optional(),
|
|
28321
|
+
latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
|
|
28322
|
+
}).strict();
|
|
28323
|
+
|
|
27846
28324
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
27847
28325
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
27848
28326
|
var nonBlankTextSchema3 = external_exports.string().trim().min(1);
|
|
@@ -28142,6 +28620,38 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
28142
28620
|
status: updateStatusSchema.nullable()
|
|
28143
28621
|
});
|
|
28144
28622
|
|
|
28623
|
+
// ../../shared-contracts/dist/remote-runtime.js
|
|
28624
|
+
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
28625
|
+
"idle",
|
|
28626
|
+
"installing",
|
|
28627
|
+
"restarting",
|
|
28628
|
+
"succeeded",
|
|
28629
|
+
"failed"
|
|
28630
|
+
]);
|
|
28631
|
+
var runtimeStatusSchema = external_exports.object({
|
|
28632
|
+
runningVersion: external_exports.string().nullable(),
|
|
28633
|
+
installedVersion: external_exports.string().nullable(),
|
|
28634
|
+
restartRequired: external_exports.boolean(),
|
|
28635
|
+
remote: external_exports.boolean(),
|
|
28636
|
+
updateSupported: external_exports.boolean(),
|
|
28637
|
+
update: external_exports.object({
|
|
28638
|
+
phase: remoteUpdatePhaseSchema,
|
|
28639
|
+
targetVersion: external_exports.string().nullable(),
|
|
28640
|
+
error: external_exports.string().nullable()
|
|
28641
|
+
})
|
|
28642
|
+
});
|
|
28643
|
+
var remoteUpdateParamsSchema = external_exports.object({
|
|
28644
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
|
|
28645
|
+
}).strict();
|
|
28646
|
+
var remoteSshSetupParamsSchema = external_exports.object({
|
|
28647
|
+
hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
|
|
28648
|
+
port: external_exports.number().int().min(1).max(65535).nullable(),
|
|
28649
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
28650
|
+
action: external_exports.enum(["inspect", "install", "update", "repair"]),
|
|
28651
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
|
|
28652
|
+
}).strict();
|
|
28653
|
+
var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
|
|
28654
|
+
|
|
28145
28655
|
// ../../shared-contracts/dist/index.js
|
|
28146
28656
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
28147
28657
|
|
|
@@ -28480,9 +28990,530 @@ function cursorCommandPrompt(command, catalog) {
|
|
|
28480
28990
|
return { ok: true, value: `${descriptor.invocation}${text2 ? ` ${text2}` : ""}` };
|
|
28481
28991
|
}
|
|
28482
28992
|
|
|
28993
|
+
// dist/command.js
|
|
28994
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
28995
|
+
import path4 from "node:path";
|
|
28996
|
+
var PINNED_VERSION_AGENT = /[/\\]cursor-agent[/\\]versions[/\\][^/\\]+[/\\]cursor-agent(?:\.exe)?$/iu;
|
|
28997
|
+
function cursorDiscoverySpec(skipPinnedVersions) {
|
|
28998
|
+
return {
|
|
28999
|
+
id: "cursor-cli",
|
|
29000
|
+
command: "cursor-agent",
|
|
29001
|
+
commandEnvironmentVariable: "CODEXHOST_CURSOR_COMMAND",
|
|
29002
|
+
installRoots: {
|
|
29003
|
+
posix: ["~/.local/bin", "/usr/local/bin", "/opt/homebrew/bin"],
|
|
29004
|
+
windows: ["${LOCALAPPDATA}/cursor-agent"]
|
|
29005
|
+
},
|
|
29006
|
+
...skipPinnedVersions ? {
|
|
29007
|
+
runnableCandidate: (candidate) => PINNED_VERSION_AGENT.test(candidate) ? void 0 : candidate
|
|
29008
|
+
} : {}
|
|
29009
|
+
};
|
|
29010
|
+
}
|
|
29011
|
+
function resolveCursorExecutable(environment, command) {
|
|
29012
|
+
const input = { environment, ...command ? { command } : {} };
|
|
29013
|
+
const pinned = resolveHarnessExecutable(cursorDiscoverySpec(false), input);
|
|
29014
|
+
if (!pinned)
|
|
29015
|
+
throw new Error("Cursor CLI is not installed; install cursor-agent or set CODEXHOST_CURSOR_COMMAND");
|
|
29016
|
+
const explicit = command?.trim() || environment.CODEXHOST_CURSOR_COMMAND?.trim();
|
|
29017
|
+
if (explicit || !PINNED_VERSION_AGENT.test(pinned.executable))
|
|
29018
|
+
return pinned;
|
|
29019
|
+
return resolveHarnessExecutable(cursorDiscoverySpec(true), input) ?? pinned;
|
|
29020
|
+
}
|
|
29021
|
+
function cursorInvocation(environment, command, args) {
|
|
29022
|
+
const resolution = resolveCursorExecutable(environment, command);
|
|
29023
|
+
if (process.platform === "win32" && /\.(cmd|ps1)$/iu.test(resolution.executable)) {
|
|
29024
|
+
const root = path4.dirname(resolution.executable);
|
|
29025
|
+
const versions = path4.join(root, "versions");
|
|
29026
|
+
if (existsSync(versions)) {
|
|
29027
|
+
const version2 = readdirSync(versions).filter((name) => /^\d{4}\.\d{2}\.\d{2}-(?:\d{2}-\d{2}-\d{2}-)?[a-f0-9]+$/u.test(name)).sort().reverse().find((name) => existsSync(path4.join(versions, name, "node.exe")) && existsSync(path4.join(versions, name, "index.js")));
|
|
29028
|
+
if (version2)
|
|
29029
|
+
return {
|
|
29030
|
+
command: path4.join(versions, version2, "node.exe"),
|
|
29031
|
+
arguments: [path4.join(versions, version2, "index.js"), ...args],
|
|
29032
|
+
windowsVerbatimArguments: false
|
|
29033
|
+
};
|
|
29034
|
+
}
|
|
29035
|
+
throw new Error("Cursor Windows launcher has no supported native bundle; configure a native executable");
|
|
29036
|
+
}
|
|
29037
|
+
return commandInvocation(resolution.executable, args, environment);
|
|
29038
|
+
}
|
|
29039
|
+
|
|
29040
|
+
// dist/installation.js
|
|
29041
|
+
function createCursorInstallation(environment) {
|
|
29042
|
+
const run = (args, timeout) => {
|
|
29043
|
+
const invocation = cursorInvocation(environment, void 0, args);
|
|
29044
|
+
return runInstallationCommand(invocation.command, invocation.arguments, environment, timeout);
|
|
29045
|
+
};
|
|
29046
|
+
return createInstallationManager({
|
|
29047
|
+
async check() {
|
|
29048
|
+
const state = JSON.parse(await run(["about", "--format", "json"]));
|
|
29049
|
+
if (state.latestStatus !== "up_to_date" && state.latestStatus !== "update_available")
|
|
29050
|
+
throw new Error("Cursor update checks are disabled or unavailable");
|
|
29051
|
+
return {
|
|
29052
|
+
currentVersion: installationVersion(state.cliVersion),
|
|
29053
|
+
latestVersion: installationVersion(state.latestVersion),
|
|
29054
|
+
updateAvailable: state.latestStatus === "update_available",
|
|
29055
|
+
canUpdate: true
|
|
29056
|
+
};
|
|
29057
|
+
},
|
|
29058
|
+
async update() {
|
|
29059
|
+
await run(["update"], 3e5);
|
|
29060
|
+
}
|
|
29061
|
+
});
|
|
29062
|
+
}
|
|
29063
|
+
|
|
28483
29064
|
// dist/adapter.js
|
|
29065
|
+
import path10 from "node:path";
|
|
29066
|
+
|
|
29067
|
+
// dist/account-usage.js
|
|
29068
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
29069
|
+
import { readFile } from "node:fs/promises";
|
|
29070
|
+
import { homedir as homedir2 } from "node:os";
|
|
29071
|
+
import path5 from "node:path";
|
|
29072
|
+
import { promisify } from "node:util";
|
|
29073
|
+
var execute = promisify(execFile2);
|
|
29074
|
+
var ENDPOINT = "https://api2.cursor.sh/aiserver.v1.DashboardService/";
|
|
29075
|
+
var record2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
29076
|
+
var percent = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.min(100, value) : void 0;
|
|
29077
|
+
function projectCursorAccountUsage(usage, identity, plan) {
|
|
29078
|
+
const data = record2(usage);
|
|
29079
|
+
const buckets = record2(data.planUsage);
|
|
29080
|
+
const usedPercent = percent(buckets.autoPercentUsed);
|
|
29081
|
+
if (usedPercent === void 0)
|
|
29082
|
+
return null;
|
|
29083
|
+
const end = typeof data.billingCycleEnd === "string" || typeof data.billingCycleEnd === "number" ? Number(data.billingCycleEnd) : NaN;
|
|
29084
|
+
const date5 = new Date(end);
|
|
29085
|
+
const resetsAt = Number.isFinite(date5.getTime()) && end > 0 ? date5.toISOString() : void 0;
|
|
29086
|
+
const apiPercent = percent(buckets.apiPercentUsed);
|
|
29087
|
+
const email3 = record2(identity).email;
|
|
29088
|
+
const planName = record2(record2(plan).planInfo).planName;
|
|
29089
|
+
const result = harnessAccountSnapshotSchema.safeParse({
|
|
29090
|
+
...typeof email3 === "string" && email3.trim() ? { email: email3 } : {},
|
|
29091
|
+
...typeof planName === "string" && planName.trim() ? { plan: planName } : {},
|
|
29092
|
+
credits: {
|
|
29093
|
+
usedPercent,
|
|
29094
|
+
label: "Auto · monthly",
|
|
29095
|
+
periodType: "monthly",
|
|
29096
|
+
...resetsAt ? { resetsAt } : {},
|
|
29097
|
+
...apiPercent === void 0 ? {} : {
|
|
29098
|
+
productUsage: [
|
|
29099
|
+
{
|
|
29100
|
+
product: "API · monthly",
|
|
29101
|
+
usagePercent: apiPercent,
|
|
29102
|
+
...resetsAt ? { resetsAt } : {}
|
|
29103
|
+
}
|
|
29104
|
+
]
|
|
29105
|
+
}
|
|
29106
|
+
}
|
|
29107
|
+
});
|
|
29108
|
+
return result.success ? result.data : null;
|
|
29109
|
+
}
|
|
29110
|
+
async function accessToken(environment) {
|
|
29111
|
+
if (environment.CURSOR_API_KEY?.trim() || environment.AGENT_CLI_CREDENTIAL_STORE === "memory")
|
|
29112
|
+
return void 0;
|
|
29113
|
+
if (process.platform === "darwin" && environment.AGENT_CLI_CREDENTIAL_STORE !== "file") {
|
|
29114
|
+
const result = await execute("/usr/bin/security", ["find-generic-password", "-s", "cursor-access-token", "-a", "cursor-user", "-w"], { timeout: 5e3, maxBuffer: 64 * 1024 });
|
|
29115
|
+
return result.stdout.trim() || void 0;
|
|
29116
|
+
}
|
|
29117
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? homedir2();
|
|
29118
|
+
const authPath = process.platform === "darwin" ? path5.join(home, ".cursor", "auth.json") : process.platform === "win32" ? path5.join(environment.APPDATA ?? path5.join(home, "AppData", "Roaming"), "Cursor", "auth.json") : path5.join(environment.XDG_CONFIG_HOME ?? path5.join(home, ".config"), "cursor", "auth.json");
|
|
29119
|
+
const auth = record2(JSON.parse(await readFile(authPath, "utf8")));
|
|
29120
|
+
return typeof auth.accessToken === "string" && auth.accessToken.trim() ? auth.accessToken : void 0;
|
|
29121
|
+
}
|
|
29122
|
+
async function fetchCursorAccount(input = {}) {
|
|
29123
|
+
try {
|
|
29124
|
+
const environment = input.environment ?? process.env;
|
|
29125
|
+
if (environment.CURSOR_API_KEY?.trim() || environment.AGENT_CLI_CREDENTIAL_STORE === "memory")
|
|
29126
|
+
return null;
|
|
29127
|
+
const token = await (input.readAccessToken ? input.readAccessToken() : accessToken(environment));
|
|
29128
|
+
if (!token)
|
|
29129
|
+
return null;
|
|
29130
|
+
const signal = input.signal ? AbortSignal.any([input.signal, AbortSignal.timeout(1e4)]) : AbortSignal.timeout(1e4);
|
|
29131
|
+
const request = async (method) => {
|
|
29132
|
+
const response = await (input.fetch ?? fetch)(ENDPOINT + method, {
|
|
29133
|
+
method: "POST",
|
|
29134
|
+
headers: {
|
|
29135
|
+
Authorization: `Bearer ${token}`,
|
|
29136
|
+
"Content-Type": "application/json",
|
|
29137
|
+
"Connect-Protocol-Version": "1"
|
|
29138
|
+
},
|
|
29139
|
+
body: "{}",
|
|
29140
|
+
signal
|
|
29141
|
+
});
|
|
29142
|
+
return response.ok ? response.json() : null;
|
|
29143
|
+
};
|
|
29144
|
+
const [usage, identity, plan] = await Promise.all([
|
|
29145
|
+
request("GetCurrentPeriodUsage"),
|
|
29146
|
+
request("GetMe").catch(() => null),
|
|
29147
|
+
request("GetPlanInfo").catch(() => null)
|
|
29148
|
+
]);
|
|
29149
|
+
return projectCursorAccountUsage(usage, identity, plan);
|
|
29150
|
+
} catch {
|
|
29151
|
+
return null;
|
|
29152
|
+
}
|
|
29153
|
+
}
|
|
29154
|
+
|
|
29155
|
+
// dist/session-import.js
|
|
29156
|
+
import { lstat, opendir, readFile as readFile2, realpath, stat } from "node:fs/promises";
|
|
28484
29157
|
import path7 from "node:path";
|
|
28485
29158
|
|
|
29159
|
+
// ../../harness-adapter/dist/session-import.js
|
|
29160
|
+
var SessionImportChangedError = class extends Error {
|
|
29161
|
+
constructor(message = "Native Session changed during discovery; refresh and retry") {
|
|
29162
|
+
super(message);
|
|
29163
|
+
this.name = "SessionImportChangedError";
|
|
29164
|
+
}
|
|
29165
|
+
};
|
|
29166
|
+
function isMissingFileError(error51) {
|
|
29167
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
29168
|
+
}
|
|
29169
|
+
function sameFileFingerprint(left, right) {
|
|
29170
|
+
return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
29171
|
+
}
|
|
29172
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
29173
|
+
if (typeof value !== "string")
|
|
29174
|
+
return null;
|
|
29175
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
29176
|
+
if (!normalized)
|
|
29177
|
+
return null;
|
|
29178
|
+
if (normalized.length <= maxLength)
|
|
29179
|
+
return normalized;
|
|
29180
|
+
const characters = [...normalized];
|
|
29181
|
+
if (characters.length <= maxLength)
|
|
29182
|
+
return normalized;
|
|
29183
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
29184
|
+
}
|
|
29185
|
+
function sessionImportCandidate(input) {
|
|
29186
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
29187
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
29188
|
+
nativeSessionId: input.nativeSessionId,
|
|
29189
|
+
cwd: input.cwd,
|
|
29190
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
29191
|
+
updatedAt: Math.floor(time3),
|
|
29192
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
29193
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
29194
|
+
});
|
|
29195
|
+
return parsed.success ? parsed.data : null;
|
|
29196
|
+
}
|
|
29197
|
+
var SessionImportScope = class {
|
|
29198
|
+
#abort = new AbortController();
|
|
29199
|
+
#options;
|
|
29200
|
+
#pending = /* @__PURE__ */ new Set();
|
|
29201
|
+
constructor(options) {
|
|
29202
|
+
this.#options = options;
|
|
29203
|
+
}
|
|
29204
|
+
#closed() {
|
|
29205
|
+
return {
|
|
29206
|
+
ok: false,
|
|
29207
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
29208
|
+
};
|
|
29209
|
+
}
|
|
29210
|
+
read(operation) {
|
|
29211
|
+
const signal = this.#abort.signal;
|
|
29212
|
+
if (signal.aborted)
|
|
29213
|
+
return Promise.resolve(this.#closed());
|
|
29214
|
+
let started;
|
|
29215
|
+
try {
|
|
29216
|
+
started = operation(signal);
|
|
29217
|
+
} catch (error51) {
|
|
29218
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
29219
|
+
}
|
|
29220
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
29221
|
+
ok: false,
|
|
29222
|
+
error: {
|
|
29223
|
+
code: "unavailable",
|
|
29224
|
+
message: this.#options.unavailableMessage,
|
|
29225
|
+
retryable: true
|
|
29226
|
+
}
|
|
29227
|
+
}).finally(() => this.#pending.delete(request));
|
|
29228
|
+
this.#pending.add(request);
|
|
29229
|
+
return request;
|
|
29230
|
+
}
|
|
29231
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
29232
|
+
async resolve(operation) {
|
|
29233
|
+
const result = await this.read(operation);
|
|
29234
|
+
if (!result.ok)
|
|
29235
|
+
return result;
|
|
29236
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
29237
|
+
ok: false,
|
|
29238
|
+
error: {
|
|
29239
|
+
code: "sessionNotFound",
|
|
29240
|
+
message: this.#options.notFoundMessage,
|
|
29241
|
+
retryable: false
|
|
29242
|
+
}
|
|
29243
|
+
};
|
|
29244
|
+
}
|
|
29245
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
29246
|
+
async close() {
|
|
29247
|
+
this.#abort.abort();
|
|
29248
|
+
await Promise.allSettled(this.#pending);
|
|
29249
|
+
}
|
|
29250
|
+
};
|
|
29251
|
+
|
|
29252
|
+
// dist/native-history.js
|
|
29253
|
+
import { existsSync as existsSync2, readFileSync, realpathSync } from "node:fs";
|
|
29254
|
+
import os2 from "node:os";
|
|
29255
|
+
import path6 from "node:path";
|
|
29256
|
+
import { DatabaseSync } from "node:sqlite";
|
|
29257
|
+
function cursorConfigDirectory(environment) {
|
|
29258
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? os2.homedir();
|
|
29259
|
+
return environment.CURSOR_CONFIG_DIR?.trim() ? path6.resolve(environment.CURSOR_CONFIG_DIR) : environment.XDG_CONFIG_HOME?.trim() ? path6.resolve(environment.XDG_CONFIG_HOME, "cursor") : path6.join(home, ".cursor");
|
|
29260
|
+
}
|
|
29261
|
+
function cursorSessionDirectory(sessionId, environment) {
|
|
29262
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId))
|
|
29263
|
+
throw new Error("Unsupported Cursor native session ID");
|
|
29264
|
+
return path6.join(cursorConfigDirectory(environment), "acp-sessions", sessionId);
|
|
29265
|
+
}
|
|
29266
|
+
function cursorSameWorkspace(left, right) {
|
|
29267
|
+
return path6.resolve(left) === path6.resolve(right) || existsSync2(left) && existsSync2(right) && realpathSync(left) === realpathSync(right);
|
|
29268
|
+
}
|
|
29269
|
+
function protobufBytes(data) {
|
|
29270
|
+
if (data.length > 32 * 1024 * 1024)
|
|
29271
|
+
throw new Error("Cursor native record is too large");
|
|
29272
|
+
let offset = 0;
|
|
29273
|
+
const varint = () => {
|
|
29274
|
+
let result = 0;
|
|
29275
|
+
for (let shift = 0; shift < 70; shift += 7) {
|
|
29276
|
+
const value = data[offset++];
|
|
29277
|
+
if (value === void 0)
|
|
29278
|
+
throw new Error("Truncated Cursor native record");
|
|
29279
|
+
result += (value & 127) * 2 ** shift;
|
|
29280
|
+
if (!(value & 128))
|
|
29281
|
+
return result;
|
|
29282
|
+
}
|
|
29283
|
+
throw new Error("Invalid Cursor native varint");
|
|
29284
|
+
};
|
|
29285
|
+
const fields = /* @__PURE__ */ new Map();
|
|
29286
|
+
while (offset < data.length) {
|
|
29287
|
+
const tag = varint();
|
|
29288
|
+
const field = Math.floor(tag / 8), wire = tag % 8;
|
|
29289
|
+
if (!Number.isSafeInteger(tag) || field === 0)
|
|
29290
|
+
throw new Error("Invalid Cursor native field");
|
|
29291
|
+
if (wire === 0) {
|
|
29292
|
+
varint();
|
|
29293
|
+
continue;
|
|
29294
|
+
}
|
|
29295
|
+
const length = wire === 2 ? varint() : wire === 1 ? 8 : wire === 5 ? 4 : -1;
|
|
29296
|
+
if (!Number.isSafeInteger(length) || length < 0 || offset + length > data.length)
|
|
29297
|
+
throw new Error("Unsupported Cursor native record");
|
|
29298
|
+
if (wire === 2) {
|
|
29299
|
+
const values = fields.get(field) ?? [];
|
|
29300
|
+
values.push(Buffer.from(data.subarray(offset, offset + length)));
|
|
29301
|
+
fields.set(field, values);
|
|
29302
|
+
}
|
|
29303
|
+
offset += length;
|
|
29304
|
+
}
|
|
29305
|
+
return fields;
|
|
29306
|
+
}
|
|
29307
|
+
function one(fields, field) {
|
|
29308
|
+
const values = fields.get(field);
|
|
29309
|
+
if (values?.length !== 1 || !values[0])
|
|
29310
|
+
throw new Error("Cursor native history identity is missing or ambiguous");
|
|
29311
|
+
return values[0];
|
|
29312
|
+
}
|
|
29313
|
+
function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = false) {
|
|
29314
|
+
const directory = cursorSessionDirectory(sessionId, environment);
|
|
29315
|
+
const filename = path6.join(directory, "store.db");
|
|
29316
|
+
if (allowMissing && !existsSync2(filename))
|
|
29317
|
+
return { revision: void 0, turns: [] };
|
|
29318
|
+
const info = JSON.parse(readFileSync(path6.join(directory, "meta.json"), "utf8"));
|
|
29319
|
+
if (!info || typeof info !== "object" || !("cwd" in info) || typeof info.cwd !== "string" || !cursorSameWorkspace(info.cwd, cwd))
|
|
29320
|
+
throw new Error("Cursor session workspace does not match");
|
|
29321
|
+
const db = new DatabaseSync(filename, { readOnly: true });
|
|
29322
|
+
try {
|
|
29323
|
+
db.exec("BEGIN");
|
|
29324
|
+
const row = db.prepare("SELECT value FROM meta WHERE key = ?").get("0");
|
|
29325
|
+
if (!row && allowMissing)
|
|
29326
|
+
return { revision: void 0, turns: [] };
|
|
29327
|
+
if (typeof row?.value !== "string" || row.value.length > 1e6)
|
|
29328
|
+
throw new Error("Unsupported Cursor native metadata");
|
|
29329
|
+
const metadata = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
|
|
29330
|
+
if (metadata.agentId !== sessionId || typeof metadata.latestRootBlobId !== "string")
|
|
29331
|
+
throw new Error("Cursor native session identity mismatch");
|
|
29332
|
+
const get = (id) => {
|
|
29333
|
+
if (!/^[0-9a-f]{64}$/u.test(id))
|
|
29334
|
+
throw new Error("Invalid Cursor native blob reference");
|
|
29335
|
+
const blob = db.prepare("SELECT data FROM blobs WHERE id = ?").get(id)?.data;
|
|
29336
|
+
if (!(blob instanceof Uint8Array))
|
|
29337
|
+
throw new Error("Cursor native history blob is missing");
|
|
29338
|
+
return protobufBytes(blob);
|
|
29339
|
+
};
|
|
29340
|
+
const root = get(metadata.latestRootBlobId);
|
|
29341
|
+
const result = [];
|
|
29342
|
+
for (const ref of root.get(8) ?? []) {
|
|
29343
|
+
if (ref.length !== 32)
|
|
29344
|
+
throw new Error("Unsupported Cursor turn reference");
|
|
29345
|
+
const container = get(ref.toString("hex"));
|
|
29346
|
+
for (const record3 of container.get(1) ?? []) {
|
|
29347
|
+
const turn = protobufBytes(record3);
|
|
29348
|
+
const user = get(one(turn, 1).toString("hex"));
|
|
29349
|
+
const id = one(user, 2).toString("utf8");
|
|
29350
|
+
if (!/^[0-9a-f-]{36}$/iu.test(id) || result.some((existing) => existing.id === id))
|
|
29351
|
+
throw new Error("Cursor native turn ID is invalid or duplicated");
|
|
29352
|
+
const anchor = user.get(10)?.[0];
|
|
29353
|
+
const rewindRoot = anchor?.length === 32 && db.prepare("SELECT 1 FROM blobs WHERE id = ?").get(anchor.toString("hex")) ? anchor.toString("hex") : void 0;
|
|
29354
|
+
result.push({
|
|
29355
|
+
id,
|
|
29356
|
+
text: one(user, 1).toString("utf8"),
|
|
29357
|
+
...rewindRoot ? { rewindRoot } : {}
|
|
29358
|
+
});
|
|
29359
|
+
}
|
|
29360
|
+
}
|
|
29361
|
+
return { revision: metadata.latestRootBlobId, turns: result };
|
|
29362
|
+
} finally {
|
|
29363
|
+
db.close();
|
|
29364
|
+
}
|
|
29365
|
+
}
|
|
29366
|
+
function readCursorNativeTurns(sessionId, cwd, environment, allowMissing = false) {
|
|
29367
|
+
return readCursorNativeHistory(sessionId, cwd, environment, allowMissing).turns;
|
|
29368
|
+
}
|
|
29369
|
+
|
|
29370
|
+
// dist/session-ref.js
|
|
29371
|
+
var cursorHarnessId = harnessIdSchema.parse("cursor-cli");
|
|
29372
|
+
var cursorSessionLocatorSchema = external_exports.strictObject({
|
|
29373
|
+
executionPolicy: external_exports.enum(["default", "unattended-full-access"])
|
|
29374
|
+
});
|
|
29375
|
+
function cursorNativeSessionRef(nativeSessionId, executionPolicy) {
|
|
29376
|
+
return nativeSessionRefSchema.parse({
|
|
29377
|
+
harnessId: cursorHarnessId,
|
|
29378
|
+
nativeSessionId,
|
|
29379
|
+
locator: { executionPolicy },
|
|
29380
|
+
formatVersion: 1
|
|
29381
|
+
});
|
|
29382
|
+
}
|
|
29383
|
+
function cursorExecutionPolicy(ref) {
|
|
29384
|
+
if (ref.harnessId !== cursorHarnessId || ref.formatVersion !== 1)
|
|
29385
|
+
throw new Error("Invalid Cursor Native Session Ref");
|
|
29386
|
+
if (ref.locator === void 0)
|
|
29387
|
+
return "default";
|
|
29388
|
+
const locator = cursorSessionLocatorSchema.safeParse(ref.locator);
|
|
29389
|
+
if (!locator.success)
|
|
29390
|
+
throw new Error("Invalid Cursor Native Session locator");
|
|
29391
|
+
return locator.data.executionPolicy;
|
|
29392
|
+
}
|
|
29393
|
+
|
|
29394
|
+
// dist/session-import.js
|
|
29395
|
+
var SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
29396
|
+
var MAX_METADATA_BYTES = 1024 * 1024;
|
|
29397
|
+
function errorCode(error51) {
|
|
29398
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" ? error51.code : void 0;
|
|
29399
|
+
}
|
|
29400
|
+
async function optionalStat(file2) {
|
|
29401
|
+
try {
|
|
29402
|
+
return await lstat(file2);
|
|
29403
|
+
} catch (error51) {
|
|
29404
|
+
if (isMissingFileError(error51))
|
|
29405
|
+
return null;
|
|
29406
|
+
throw error51;
|
|
29407
|
+
}
|
|
29408
|
+
}
|
|
29409
|
+
var CursorSessionImport = class {
|
|
29410
|
+
#environment;
|
|
29411
|
+
#scope = new SessionImportScope({
|
|
29412
|
+
closedMessage: "Cursor Session import is closed",
|
|
29413
|
+
unavailableMessage: "Cursor ACP sessions could not be read; close native clients, check storage access and retry",
|
|
29414
|
+
notFoundMessage: "Cursor ACP Session is no longer importable"
|
|
29415
|
+
});
|
|
29416
|
+
constructor(environment) {
|
|
29417
|
+
this.#environment = { ...environment };
|
|
29418
|
+
}
|
|
29419
|
+
listCandidates() {
|
|
29420
|
+
return this.#scope.read(async (signal) => {
|
|
29421
|
+
const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
|
|
29422
|
+
const info = await optionalStat(root);
|
|
29423
|
+
if (!info)
|
|
29424
|
+
return [];
|
|
29425
|
+
if (!info.isDirectory())
|
|
29426
|
+
throw new Error("Cursor ACP store is not a directory");
|
|
29427
|
+
const candidates = [];
|
|
29428
|
+
const entries = await opendir(root);
|
|
29429
|
+
for await (const entry of entries) {
|
|
29430
|
+
signal.throwIfAborted();
|
|
29431
|
+
if (!entry.isDirectory() || !SESSION_ID.test(entry.name))
|
|
29432
|
+
continue;
|
|
29433
|
+
try {
|
|
29434
|
+
const candidate = await this.#candidate(entry.name, signal);
|
|
29435
|
+
if (candidate)
|
|
29436
|
+
candidates.push(candidate);
|
|
29437
|
+
} catch (error51) {
|
|
29438
|
+
if (!(error51 instanceof SessionImportChangedError))
|
|
29439
|
+
throw error51;
|
|
29440
|
+
}
|
|
29441
|
+
}
|
|
29442
|
+
return candidates;
|
|
29443
|
+
});
|
|
29444
|
+
}
|
|
29445
|
+
async resolveCandidate(nativeSessionId) {
|
|
29446
|
+
if (!SESSION_ID.test(nativeSessionId))
|
|
29447
|
+
return {
|
|
29448
|
+
ok: false,
|
|
29449
|
+
error: {
|
|
29450
|
+
code: "invalidRequest",
|
|
29451
|
+
message: "Invalid Cursor ACP Session ID",
|
|
29452
|
+
retryable: false
|
|
29453
|
+
}
|
|
29454
|
+
};
|
|
29455
|
+
return this.#scope.resolve(async (signal) => {
|
|
29456
|
+
const candidate = await this.#candidate(nativeSessionId, signal);
|
|
29457
|
+
return candidate ? {
|
|
29458
|
+
candidate,
|
|
29459
|
+
// Native ACP stores do not attest to --force. Imported sessions must not
|
|
29460
|
+
// acquire unattended privileges from UI defaults or a guessed locator.
|
|
29461
|
+
nativeRef: cursorNativeSessionRef(nativeSessionId, "default")
|
|
29462
|
+
} : null;
|
|
29463
|
+
});
|
|
29464
|
+
}
|
|
29465
|
+
async #candidate(id, signal) {
|
|
29466
|
+
signal.throwIfAborted();
|
|
29467
|
+
const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
|
|
29468
|
+
if (!(await optionalStat(root))?.isDirectory())
|
|
29469
|
+
return null;
|
|
29470
|
+
const directory = cursorSessionDirectory(id, this.#environment);
|
|
29471
|
+
const files = [
|
|
29472
|
+
directory,
|
|
29473
|
+
path7.join(directory, "meta.json"),
|
|
29474
|
+
path7.join(directory, "store.db"),
|
|
29475
|
+
path7.join(directory, "store.db-wal")
|
|
29476
|
+
];
|
|
29477
|
+
const before = await Promise.all(files.map(optionalStat));
|
|
29478
|
+
const [folder, metadata, database, wal] = before;
|
|
29479
|
+
if (!folder?.isDirectory() || !metadata?.isFile() || !database?.isFile() || wal && !wal.isFile() || metadata.size > MAX_METADATA_BYTES)
|
|
29480
|
+
return null;
|
|
29481
|
+
let cwd;
|
|
29482
|
+
let title;
|
|
29483
|
+
try {
|
|
29484
|
+
const raw = JSON.parse(await readFile2(files[1], { encoding: "utf8", signal }));
|
|
29485
|
+
if (!raw || typeof raw !== "object" || !("cwd" in raw) || typeof raw.cwd !== "string" || !path7.isAbsolute(raw.cwd) || raw.cwd.includes("\0"))
|
|
29486
|
+
return null;
|
|
29487
|
+
cwd = await realpath(raw.cwd);
|
|
29488
|
+
if (!(await stat(cwd)).isDirectory())
|
|
29489
|
+
return null;
|
|
29490
|
+
signal.throwIfAborted();
|
|
29491
|
+
const turns = readCursorNativeTurns(id, cwd, this.#environment);
|
|
29492
|
+
if (!turns.length)
|
|
29493
|
+
return null;
|
|
29494
|
+
title = sessionImportTitle(turns[0]?.text);
|
|
29495
|
+
} catch (error51) {
|
|
29496
|
+
signal.throwIfAborted();
|
|
29497
|
+
if (["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"].includes(errorCode(error51) ?? ""))
|
|
29498
|
+
throw error51;
|
|
29499
|
+
return null;
|
|
29500
|
+
}
|
|
29501
|
+
signal.throwIfAborted();
|
|
29502
|
+
const after = await Promise.all(files.map(optionalStat));
|
|
29503
|
+
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
29504
|
+
throw new SessionImportChangedError("Cursor Session changed during discovery");
|
|
29505
|
+
return sessionImportCandidate({
|
|
29506
|
+
nativeSessionId: id,
|
|
29507
|
+
cwd,
|
|
29508
|
+
title,
|
|
29509
|
+
updatedAt: Math.max(database.mtimeMs, wal?.mtimeMs ?? 0)
|
|
29510
|
+
});
|
|
29511
|
+
}
|
|
29512
|
+
close() {
|
|
29513
|
+
return this.#scope.close();
|
|
29514
|
+
}
|
|
29515
|
+
};
|
|
29516
|
+
|
|
28486
29517
|
// dist/thinking.js
|
|
28487
29518
|
var choices = (option) => option.type === "select" ? option.options.flatMap((entry) => "value" in entry ? [entry] : entry.options) : [];
|
|
28488
29519
|
function cursorThinking(options) {
|
|
@@ -28523,9 +29554,9 @@ function cursorThinkingState(info) {
|
|
|
28523
29554
|
}
|
|
28524
29555
|
|
|
28525
29556
|
// dist/fork-support.js
|
|
28526
|
-
import { existsSync } from "node:fs";
|
|
29557
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
28527
29558
|
function cursorForkAvailable() {
|
|
28528
|
-
return (process.platform === "darwin" || process.platform === "linux") &&
|
|
29559
|
+
return (process.platform === "darwin" || process.platform === "linux") && existsSync3("/usr/bin/script");
|
|
28529
29560
|
}
|
|
28530
29561
|
function cursorCheckpoint(sessionId, turnId) {
|
|
28531
29562
|
return nativeCheckpointRefSchema.parse({
|
|
@@ -32826,10 +33857,10 @@ var ClientSideConnection = class {
|
|
|
32826
33857
|
};
|
|
32827
33858
|
|
|
32828
33859
|
// dist/delegation-bridge.js
|
|
32829
|
-
import { execFile } from "node:child_process";
|
|
33860
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
32830
33861
|
import { randomBytes } from "node:crypto";
|
|
32831
33862
|
import { createServer } from "node:http";
|
|
32832
|
-
import
|
|
33863
|
+
import path8 from "node:path";
|
|
32833
33864
|
|
|
32834
33865
|
// ../../../node_modules/zod/v3/helpers/util.js
|
|
32835
33866
|
var util;
|
|
@@ -33190,8 +34221,8 @@ function getErrorMap2() {
|
|
|
33190
34221
|
|
|
33191
34222
|
// ../../../node_modules/zod/v3/helpers/parseUtil.js
|
|
33192
34223
|
var makeIssue = (params) => {
|
|
33193
|
-
const { data, path:
|
|
33194
|
-
const fullPath = [...
|
|
34224
|
+
const { data, path: path12, errorMaps, issueData } = params;
|
|
34225
|
+
const fullPath = [...path12, ...issueData.path || []];
|
|
33195
34226
|
const fullIssue = {
|
|
33196
34227
|
...issueData,
|
|
33197
34228
|
path: fullPath
|
|
@@ -33306,11 +34337,11 @@ var errorUtil;
|
|
|
33306
34337
|
|
|
33307
34338
|
// ../../../node_modules/zod/v3/types.js
|
|
33308
34339
|
var ParseInputLazyPath = class {
|
|
33309
|
-
constructor(parent, value,
|
|
34340
|
+
constructor(parent, value, path12, key) {
|
|
33310
34341
|
this._cachedPath = [];
|
|
33311
34342
|
this.parent = parent;
|
|
33312
34343
|
this.data = value;
|
|
33313
|
-
this._path =
|
|
34344
|
+
this._path = path12;
|
|
33314
34345
|
this._key = key;
|
|
33315
34346
|
}
|
|
33316
34347
|
get path() {
|
|
@@ -36837,11 +37868,11 @@ function normalizeObjectSchema(schema) {
|
|
|
36837
37868
|
}
|
|
36838
37869
|
return void 0;
|
|
36839
37870
|
}
|
|
36840
|
-
function getDotPath(
|
|
36841
|
-
if (
|
|
37871
|
+
function getDotPath(path12) {
|
|
37872
|
+
if (path12.length === 0) {
|
|
36842
37873
|
return "object root";
|
|
36843
37874
|
}
|
|
36844
|
-
return
|
|
37875
|
+
return path12.reduce((acc, seg, index) => {
|
|
36845
37876
|
if (index === 0) {
|
|
36846
37877
|
return String(seg);
|
|
36847
37878
|
}
|
|
@@ -44210,7 +45241,7 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44210
45241
|
const runtimeToken = environment.CODEXHOST_RUNTIME_TOKEN;
|
|
44211
45242
|
if (!cli || !environment.CODEXHOST_RUNTIME_ENDPOINT || !runtimeToken || !environment.CODEXHOST_THREAD_ID)
|
|
44212
45243
|
return void 0;
|
|
44213
|
-
if (!
|
|
45244
|
+
if (!path8.isAbsolute(cli))
|
|
44214
45245
|
throw new Error("Cursor delegation requires an absolute Host CLI path");
|
|
44215
45246
|
const token = randomBytes(32).toString("base64url");
|
|
44216
45247
|
const children = /* @__PURE__ */ new Set();
|
|
@@ -44225,7 +45256,7 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44225
45256
|
});
|
|
44226
45257
|
return;
|
|
44227
45258
|
}
|
|
44228
|
-
const child =
|
|
45259
|
+
const child = execFile3(cli, [...args, "--format", "compact"], {
|
|
44229
45260
|
cwd,
|
|
44230
45261
|
env: environment,
|
|
44231
45262
|
windowsHide: true,
|
|
@@ -44365,265 +45396,6 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44365
45396
|
};
|
|
44366
45397
|
}
|
|
44367
45398
|
|
|
44368
|
-
// dist/command.js
|
|
44369
|
-
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
44370
|
-
import path4 from "node:path";
|
|
44371
|
-
|
|
44372
|
-
// ../../harness-discovery/dist/environment.js
|
|
44373
|
-
import fs from "node:fs";
|
|
44374
|
-
import path2 from "node:path";
|
|
44375
|
-
function targetPath(platform) {
|
|
44376
|
-
return platform === "win32" ? path2.win32 : path2.posix;
|
|
44377
|
-
}
|
|
44378
|
-
function environmentValue(environment, name) {
|
|
44379
|
-
const lowered = name.toLowerCase();
|
|
44380
|
-
for (const [key, value] of Object.entries(environment)) {
|
|
44381
|
-
if (key.toLowerCase() === lowered)
|
|
44382
|
-
return value;
|
|
44383
|
-
}
|
|
44384
|
-
return void 0;
|
|
44385
|
-
}
|
|
44386
|
-
function pathDelimiter(platform) {
|
|
44387
|
-
return platform === "win32" ? ";" : ":";
|
|
44388
|
-
}
|
|
44389
|
-
function pathDirectories(environment, platform) {
|
|
44390
|
-
return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
44391
|
-
}
|
|
44392
|
-
function executableExtensions(command, platform, environment) {
|
|
44393
|
-
if (platform !== "win32")
|
|
44394
|
-
return [""];
|
|
44395
|
-
if (targetPath(platform).extname(command) !== "")
|
|
44396
|
-
return [""];
|
|
44397
|
-
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
44398
|
-
}
|
|
44399
|
-
function isExecutableFile(filePath, platform) {
|
|
44400
|
-
try {
|
|
44401
|
-
fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
44402
|
-
return fs.statSync(filePath).isFile();
|
|
44403
|
-
} catch {
|
|
44404
|
-
return false;
|
|
44405
|
-
}
|
|
44406
|
-
}
|
|
44407
|
-
function subdirectoryNames(directory) {
|
|
44408
|
-
try {
|
|
44409
|
-
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
44410
|
-
} catch {
|
|
44411
|
-
return [];
|
|
44412
|
-
}
|
|
44413
|
-
}
|
|
44414
|
-
function newestFirst(names) {
|
|
44415
|
-
return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
|
|
44416
|
-
}
|
|
44417
|
-
|
|
44418
|
-
// ../../harness-discovery/dist/invocation.js
|
|
44419
|
-
import path3 from "node:path";
|
|
44420
|
-
function commandInvocation(command, arguments_, environment, platform = process.platform) {
|
|
44421
|
-
const extension = path3.win32.extname(command).toLowerCase();
|
|
44422
|
-
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
44423
|
-
return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
|
|
44424
|
-
}
|
|
44425
|
-
const quote2 = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
44426
|
-
const commandLine = [command, ...arguments_].map(quote2).join(" ");
|
|
44427
|
-
return {
|
|
44428
|
-
command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
|
|
44429
|
-
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
44430
|
-
windowsVerbatimArguments: true
|
|
44431
|
-
};
|
|
44432
|
-
}
|
|
44433
|
-
|
|
44434
|
-
// ../../harness-discovery/dist/resolve.js
|
|
44435
|
-
import os from "node:os";
|
|
44436
|
-
|
|
44437
|
-
// ../../harness-discovery/dist/version-managers.js
|
|
44438
|
-
function versionManagerBinaryDirectories(context) {
|
|
44439
|
-
const { platform, environment, home } = context;
|
|
44440
|
-
const list = context.subdirectories ?? subdirectoryNames;
|
|
44441
|
-
const pathFlavor = targetPath(platform);
|
|
44442
|
-
const value = (name) => environmentValue(environment, name);
|
|
44443
|
-
const directories = [];
|
|
44444
|
-
const versioned = (root, ...tail) => {
|
|
44445
|
-
for (const version2 of newestFirst(list(root))) {
|
|
44446
|
-
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
44447
|
-
}
|
|
44448
|
-
};
|
|
44449
|
-
if (platform === "win32") {
|
|
44450
|
-
const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
|
|
44451
|
-
const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
|
|
44452
|
-
versioned(pathFlavor.join(appData, "nvm"));
|
|
44453
|
-
versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
|
|
44454
|
-
directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
|
|
44455
|
-
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
44456
|
-
const pnpmHome2 = value("PNPM_HOME");
|
|
44457
|
-
if (pnpmHome2)
|
|
44458
|
-
directories.push(pnpmHome2);
|
|
44459
|
-
directories.push(pathFlavor.join(localAppData, "pnpm"));
|
|
44460
|
-
return directories;
|
|
44461
|
-
}
|
|
44462
|
-
versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
|
|
44463
|
-
const fnmRoots = [
|
|
44464
|
-
value("FNM_DIR"),
|
|
44465
|
-
pathFlavor.join(home, ".local", "share", "fnm"),
|
|
44466
|
-
pathFlavor.join(home, "Library", "Application Support", "fnm")
|
|
44467
|
-
].filter((root) => root !== void 0);
|
|
44468
|
-
for (const root of fnmRoots) {
|
|
44469
|
-
versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
|
|
44470
|
-
}
|
|
44471
|
-
const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
|
|
44472
|
-
versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
|
|
44473
|
-
directories.push(pathFlavor.join(voltaHome, "bin"));
|
|
44474
|
-
const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
|
|
44475
|
-
versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
|
|
44476
|
-
directories.push(pathFlavor.join(asdfHome, "shims"));
|
|
44477
|
-
const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
|
|
44478
|
-
versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
|
|
44479
|
-
directories.push(pathFlavor.join(nodenvHome, "shims"));
|
|
44480
|
-
versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
|
|
44481
|
-
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
44482
|
-
const pnpmHome = value("PNPM_HOME");
|
|
44483
|
-
if (pnpmHome)
|
|
44484
|
-
directories.push(pnpmHome);
|
|
44485
|
-
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
44486
|
-
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
44487
|
-
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
44488
|
-
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
44489
|
-
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
44490
|
-
}
|
|
44491
|
-
}
|
|
44492
|
-
return directories;
|
|
44493
|
-
}
|
|
44494
|
-
|
|
44495
|
-
// ../../harness-discovery/dist/resolve.js
|
|
44496
|
-
var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
44497
|
-
function installRootExtensions(platform) {
|
|
44498
|
-
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
44499
|
-
}
|
|
44500
|
-
function resolveHomeDirectory(input) {
|
|
44501
|
-
return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
|
|
44502
|
-
}
|
|
44503
|
-
function templateVariables(environment, platform, home) {
|
|
44504
|
-
const pathFlavor = targetPath(platform);
|
|
44505
|
-
return {
|
|
44506
|
-
HOME: home,
|
|
44507
|
-
USERPROFILE: home,
|
|
44508
|
-
APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
|
|
44509
|
-
LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
|
|
44510
|
-
};
|
|
44511
|
-
}
|
|
44512
|
-
function joinTemplate(platform, value) {
|
|
44513
|
-
const pathFlavor = targetPath(platform);
|
|
44514
|
-
const segments = value.split("/");
|
|
44515
|
-
const head = segments[0] ?? "";
|
|
44516
|
-
const tail = segments.slice(1);
|
|
44517
|
-
if (head === "")
|
|
44518
|
-
return pathFlavor.join(pathFlavor.sep, ...tail);
|
|
44519
|
-
return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
|
|
44520
|
-
}
|
|
44521
|
-
function expandInstallRoot(template, environment, platform, home) {
|
|
44522
|
-
const variables = templateVariables(environment, platform, home);
|
|
44523
|
-
let unresolved = false;
|
|
44524
|
-
const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
|
|
44525
|
-
const value = variables[name] ?? environmentValue(environment, name);
|
|
44526
|
-
if (value === void 0 || value === "") {
|
|
44527
|
-
unresolved = true;
|
|
44528
|
-
return "";
|
|
44529
|
-
}
|
|
44530
|
-
return value;
|
|
44531
|
-
});
|
|
44532
|
-
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
44533
|
-
}
|
|
44534
|
-
function installRootDirectories(spec, input, dependencies, platform, home) {
|
|
44535
|
-
const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
|
|
44536
|
-
const directories = [];
|
|
44537
|
-
for (const template of templates) {
|
|
44538
|
-
if (template === VERSION_MANAGER_ROOTS) {
|
|
44539
|
-
directories.push(...versionManagerBinaryDirectories({
|
|
44540
|
-
platform,
|
|
44541
|
-
environment: input.environment,
|
|
44542
|
-
home,
|
|
44543
|
-
...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
|
|
44544
|
-
}));
|
|
44545
|
-
continue;
|
|
44546
|
-
}
|
|
44547
|
-
const directory = expandInstallRoot(template, input.environment, platform, home);
|
|
44548
|
-
if (directory !== void 0)
|
|
44549
|
-
directories.push(directory);
|
|
44550
|
-
}
|
|
44551
|
-
return directories;
|
|
44552
|
-
}
|
|
44553
|
-
function harnessCandidates(spec, input, dependencies = {}) {
|
|
44554
|
-
const platform = input.platform ?? process.platform;
|
|
44555
|
-
const pathFlavor = targetPath(platform);
|
|
44556
|
-
const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
|
|
44557
|
-
const command = configured ?? spec.command;
|
|
44558
|
-
if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
44559
|
-
return [{ candidate: command, source: "configured" }];
|
|
44560
|
-
}
|
|
44561
|
-
const candidates = [];
|
|
44562
|
-
const extensions = executableExtensions(command, platform, input.environment);
|
|
44563
|
-
for (const directory of pathDirectories(input.environment, platform)) {
|
|
44564
|
-
for (const extension of extensions) {
|
|
44565
|
-
candidates.push({
|
|
44566
|
-
candidate: pathFlavor.join(directory, command + extension),
|
|
44567
|
-
source: "path"
|
|
44568
|
-
});
|
|
44569
|
-
}
|
|
44570
|
-
}
|
|
44571
|
-
if (configured !== void 0)
|
|
44572
|
-
return candidates;
|
|
44573
|
-
const home = resolveHomeDirectory(input);
|
|
44574
|
-
for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
|
|
44575
|
-
for (const extension of installRootExtensions(platform)) {
|
|
44576
|
-
candidates.push({
|
|
44577
|
-
candidate: pathFlavor.join(directory, spec.command + extension),
|
|
44578
|
-
source: "install-root"
|
|
44579
|
-
});
|
|
44580
|
-
}
|
|
44581
|
-
}
|
|
44582
|
-
return candidates;
|
|
44583
|
-
}
|
|
44584
|
-
function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
44585
|
-
const platform = input.platform ?? process.platform;
|
|
44586
|
-
const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
|
|
44587
|
-
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
44588
|
-
const context = { platform, isExecutable };
|
|
44589
|
-
for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
|
|
44590
|
-
const executable = runnable(candidate, context);
|
|
44591
|
-
if (executable !== void 0 && isExecutable(executable))
|
|
44592
|
-
return { executable, source };
|
|
44593
|
-
}
|
|
44594
|
-
return void 0;
|
|
44595
|
-
}
|
|
44596
|
-
|
|
44597
|
-
// dist/command.js
|
|
44598
|
-
function cursorInvocation(environment, command, args = ["acp"]) {
|
|
44599
|
-
const resolution = resolveHarnessExecutable({
|
|
44600
|
-
id: "cursor-cli",
|
|
44601
|
-
command: "cursor-agent",
|
|
44602
|
-
commandEnvironmentVariable: "CODEXHOST_CURSOR_COMMAND",
|
|
44603
|
-
installRoots: {
|
|
44604
|
-
posix: ["~/.local/bin", "/usr/local/bin", "/opt/homebrew/bin"],
|
|
44605
|
-
windows: ["${LOCALAPPDATA}/cursor-agent"]
|
|
44606
|
-
}
|
|
44607
|
-
}, { environment, ...command ? { command } : {} });
|
|
44608
|
-
if (!resolution)
|
|
44609
|
-
throw new Error("Cursor CLI is not installed; install cursor-agent or set CODEXHOST_CURSOR_COMMAND");
|
|
44610
|
-
if (process.platform === "win32" && /\.(cmd|ps1)$/iu.test(resolution.executable)) {
|
|
44611
|
-
const root = path4.dirname(resolution.executable);
|
|
44612
|
-
const versions = path4.join(root, "versions");
|
|
44613
|
-
if (existsSync2(versions)) {
|
|
44614
|
-
const version2 = readdirSync(versions).filter((name) => /^\d{4}\.\d{2}\.\d{2}-(?:\d{2}-\d{2}-\d{2}-)?[a-f0-9]+$/u.test(name)).sort().reverse().find((name) => existsSync2(path4.join(versions, name, "node.exe")) && existsSync2(path4.join(versions, name, "index.js")));
|
|
44615
|
-
if (version2)
|
|
44616
|
-
return {
|
|
44617
|
-
command: path4.join(versions, version2, "node.exe"),
|
|
44618
|
-
arguments: [path4.join(versions, version2, "index.js"), ...args],
|
|
44619
|
-
windowsVerbatimArguments: false
|
|
44620
|
-
};
|
|
44621
|
-
}
|
|
44622
|
-
throw new Error("Cursor Windows launcher has no supported native bundle; configure a native executable");
|
|
44623
|
-
}
|
|
44624
|
-
return commandInvocation(resolution.executable, args, environment);
|
|
44625
|
-
}
|
|
44626
|
-
|
|
44627
45399
|
// dist/transport.js
|
|
44628
45400
|
var CursorTransport = class {
|
|
44629
45401
|
options;
|
|
@@ -44676,7 +45448,7 @@ var CursorTransport = class {
|
|
|
44676
45448
|
return this.#preparation ??= this.#prepare();
|
|
44677
45449
|
}
|
|
44678
45450
|
async #prepare() {
|
|
44679
|
-
const invocation = cursorInvocation(this.options.environment, this.options.command);
|
|
45451
|
+
const invocation = cursorInvocation(this.options.environment, this.options.command, this.options.executionPolicy === "unattended-full-access" ? ["--force", "acp"] : ["acp"]);
|
|
44680
45452
|
const child = spawn(invocation.command, invocation.arguments, {
|
|
44681
45453
|
cwd: this.options.cwd,
|
|
44682
45454
|
env: this.options.environment,
|
|
@@ -44857,124 +45629,6 @@ var CursorTransport = class {
|
|
|
44857
45629
|
}
|
|
44858
45630
|
};
|
|
44859
45631
|
|
|
44860
|
-
// dist/native-history.js
|
|
44861
|
-
import { existsSync as existsSync3, readFileSync, realpathSync } from "node:fs";
|
|
44862
|
-
import os2 from "node:os";
|
|
44863
|
-
import path5 from "node:path";
|
|
44864
|
-
import { DatabaseSync } from "node:sqlite";
|
|
44865
|
-
function cursorConfigDirectory(environment) {
|
|
44866
|
-
const home = environment.HOME ?? environment.USERPROFILE ?? os2.homedir();
|
|
44867
|
-
return environment.CURSOR_CONFIG_DIR?.trim() ? path5.resolve(environment.CURSOR_CONFIG_DIR) : environment.XDG_CONFIG_HOME?.trim() ? path5.resolve(environment.XDG_CONFIG_HOME, "cursor") : path5.join(home, ".cursor");
|
|
44868
|
-
}
|
|
44869
|
-
function cursorSessionDirectory(sessionId, environment) {
|
|
44870
|
-
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId))
|
|
44871
|
-
throw new Error("Unsupported Cursor native session ID");
|
|
44872
|
-
return path5.join(cursorConfigDirectory(environment), "acp-sessions", sessionId);
|
|
44873
|
-
}
|
|
44874
|
-
function cursorSameWorkspace(left, right) {
|
|
44875
|
-
return path5.resolve(left) === path5.resolve(right) || existsSync3(left) && existsSync3(right) && realpathSync(left) === realpathSync(right);
|
|
44876
|
-
}
|
|
44877
|
-
function protobufBytes(data) {
|
|
44878
|
-
if (data.length > 32 * 1024 * 1024)
|
|
44879
|
-
throw new Error("Cursor native record is too large");
|
|
44880
|
-
let offset = 0;
|
|
44881
|
-
const varint = () => {
|
|
44882
|
-
let result = 0;
|
|
44883
|
-
for (let shift = 0; shift < 70; shift += 7) {
|
|
44884
|
-
const value = data[offset++];
|
|
44885
|
-
if (value === void 0)
|
|
44886
|
-
throw new Error("Truncated Cursor native record");
|
|
44887
|
-
result += (value & 127) * 2 ** shift;
|
|
44888
|
-
if (!(value & 128))
|
|
44889
|
-
return result;
|
|
44890
|
-
}
|
|
44891
|
-
throw new Error("Invalid Cursor native varint");
|
|
44892
|
-
};
|
|
44893
|
-
const fields = /* @__PURE__ */ new Map();
|
|
44894
|
-
while (offset < data.length) {
|
|
44895
|
-
const tag = varint();
|
|
44896
|
-
const field = Math.floor(tag / 8), wire = tag % 8;
|
|
44897
|
-
if (!Number.isSafeInteger(tag) || field === 0)
|
|
44898
|
-
throw new Error("Invalid Cursor native field");
|
|
44899
|
-
if (wire === 0) {
|
|
44900
|
-
varint();
|
|
44901
|
-
continue;
|
|
44902
|
-
}
|
|
44903
|
-
const length = wire === 2 ? varint() : wire === 1 ? 8 : wire === 5 ? 4 : -1;
|
|
44904
|
-
if (!Number.isSafeInteger(length) || length < 0 || offset + length > data.length)
|
|
44905
|
-
throw new Error("Unsupported Cursor native record");
|
|
44906
|
-
if (wire === 2) {
|
|
44907
|
-
const values = fields.get(field) ?? [];
|
|
44908
|
-
values.push(Buffer.from(data.subarray(offset, offset + length)));
|
|
44909
|
-
fields.set(field, values);
|
|
44910
|
-
}
|
|
44911
|
-
offset += length;
|
|
44912
|
-
}
|
|
44913
|
-
return fields;
|
|
44914
|
-
}
|
|
44915
|
-
function one(fields, field) {
|
|
44916
|
-
const values = fields.get(field);
|
|
44917
|
-
if (values?.length !== 1 || !values[0])
|
|
44918
|
-
throw new Error("Cursor native history identity is missing or ambiguous");
|
|
44919
|
-
return values[0];
|
|
44920
|
-
}
|
|
44921
|
-
function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = false) {
|
|
44922
|
-
const directory = cursorSessionDirectory(sessionId, environment);
|
|
44923
|
-
const filename = path5.join(directory, "store.db");
|
|
44924
|
-
if (allowMissing && !existsSync3(filename))
|
|
44925
|
-
return { revision: void 0, turns: [] };
|
|
44926
|
-
const info = JSON.parse(readFileSync(path5.join(directory, "meta.json"), "utf8"));
|
|
44927
|
-
if (!info || typeof info !== "object" || !("cwd" in info) || typeof info.cwd !== "string" || !cursorSameWorkspace(info.cwd, cwd))
|
|
44928
|
-
throw new Error("Cursor session workspace does not match");
|
|
44929
|
-
const db = new DatabaseSync(filename, { readOnly: true });
|
|
44930
|
-
try {
|
|
44931
|
-
db.exec("BEGIN");
|
|
44932
|
-
const row = db.prepare("SELECT value FROM meta WHERE key = ?").get("0");
|
|
44933
|
-
if (!row && allowMissing)
|
|
44934
|
-
return { revision: void 0, turns: [] };
|
|
44935
|
-
if (typeof row?.value !== "string" || row.value.length > 1e6)
|
|
44936
|
-
throw new Error("Unsupported Cursor native metadata");
|
|
44937
|
-
const metadata = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
|
|
44938
|
-
if (metadata.agentId !== sessionId || typeof metadata.latestRootBlobId !== "string")
|
|
44939
|
-
throw new Error("Cursor native session identity mismatch");
|
|
44940
|
-
const get = (id) => {
|
|
44941
|
-
if (!/^[0-9a-f]{64}$/u.test(id))
|
|
44942
|
-
throw new Error("Invalid Cursor native blob reference");
|
|
44943
|
-
const blob = db.prepare("SELECT data FROM blobs WHERE id = ?").get(id)?.data;
|
|
44944
|
-
if (!(blob instanceof Uint8Array))
|
|
44945
|
-
throw new Error("Cursor native history blob is missing");
|
|
44946
|
-
return protobufBytes(blob);
|
|
44947
|
-
};
|
|
44948
|
-
const root = get(metadata.latestRootBlobId);
|
|
44949
|
-
const result = [];
|
|
44950
|
-
for (const ref of root.get(8) ?? []) {
|
|
44951
|
-
if (ref.length !== 32)
|
|
44952
|
-
throw new Error("Unsupported Cursor turn reference");
|
|
44953
|
-
const container = get(ref.toString("hex"));
|
|
44954
|
-
for (const record2 of container.get(1) ?? []) {
|
|
44955
|
-
const turn = protobufBytes(record2);
|
|
44956
|
-
const user = get(one(turn, 1).toString("hex"));
|
|
44957
|
-
const id = one(user, 2).toString("utf8");
|
|
44958
|
-
if (!/^[0-9a-f-]{36}$/iu.test(id) || result.some((existing) => existing.id === id))
|
|
44959
|
-
throw new Error("Cursor native turn ID is invalid or duplicated");
|
|
44960
|
-
const anchor = user.get(10)?.[0];
|
|
44961
|
-
const rewindRoot = anchor?.length === 32 && db.prepare("SELECT 1 FROM blobs WHERE id = ?").get(anchor.toString("hex")) ? anchor.toString("hex") : void 0;
|
|
44962
|
-
result.push({
|
|
44963
|
-
id,
|
|
44964
|
-
text: one(user, 1).toString("utf8"),
|
|
44965
|
-
...rewindRoot ? { rewindRoot } : {}
|
|
44966
|
-
});
|
|
44967
|
-
}
|
|
44968
|
-
}
|
|
44969
|
-
return { revision: metadata.latestRootBlobId, turns: result };
|
|
44970
|
-
} finally {
|
|
44971
|
-
db.close();
|
|
44972
|
-
}
|
|
44973
|
-
}
|
|
44974
|
-
function readCursorNativeTurns(sessionId, cwd, environment, allowMissing = false) {
|
|
44975
|
-
return readCursorNativeHistory(sessionId, cwd, environment, allowMissing).turns;
|
|
44976
|
-
}
|
|
44977
|
-
|
|
44978
45632
|
// ../../../node_modules/diff/libesm/diff/base.js
|
|
44979
45633
|
var Diff = class {
|
|
44980
45634
|
diff(oldStr, newStr, options = {}) {
|
|
@@ -45075,16 +45729,16 @@ var Diff = class {
|
|
|
45075
45729
|
}
|
|
45076
45730
|
}
|
|
45077
45731
|
}
|
|
45078
|
-
addToPath(
|
|
45079
|
-
const last =
|
|
45732
|
+
addToPath(path12, added, removed, oldPosInc, options) {
|
|
45733
|
+
const last = path12.lastComponent;
|
|
45080
45734
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
45081
45735
|
return {
|
|
45082
|
-
oldPos:
|
|
45736
|
+
oldPos: path12.oldPos + oldPosInc,
|
|
45083
45737
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
45084
45738
|
};
|
|
45085
45739
|
} else {
|
|
45086
45740
|
return {
|
|
45087
|
-
oldPos:
|
|
45741
|
+
oldPos: path12.oldPos + oldPosInc,
|
|
45088
45742
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
45089
45743
|
};
|
|
45090
45744
|
}
|
|
@@ -45602,6 +46256,42 @@ function cursorChildSnapshot(parentId, item, terminal, output) {
|
|
|
45602
46256
|
};
|
|
45603
46257
|
}
|
|
45604
46258
|
|
|
46259
|
+
// dist/stream-error.js
|
|
46260
|
+
var CLOSED_ERROR = /(?:^|\n\n)Error:\s*(?:(?:RetriableError|T):)?\s*WritableIterable is closed\s*$/u;
|
|
46261
|
+
var CLOSED_PREFIXES = [
|
|
46262
|
+
"\n\nError: RetriableError: WritableIterable is closed",
|
|
46263
|
+
"\n\nError: T: WritableIterable is closed",
|
|
46264
|
+
"\n\nError: WritableIterable is closed",
|
|
46265
|
+
"Error: RetriableError: WritableIterable is closed",
|
|
46266
|
+
"Error: T: WritableIterable is closed",
|
|
46267
|
+
"Error: WritableIterable is closed"
|
|
46268
|
+
];
|
|
46269
|
+
var LONGEST_PREFIX = Math.max(...CLOSED_PREFIXES.map((prefix) => prefix.length));
|
|
46270
|
+
function isCursorWritableIterableClosed(message) {
|
|
46271
|
+
return /WritableIterable is closed/iu.test(message);
|
|
46272
|
+
}
|
|
46273
|
+
function takeCursorWritableIterableClosed(text2, atMessageStart = true) {
|
|
46274
|
+
const match = text2.match(CLOSED_ERROR);
|
|
46275
|
+
if (!match || match.index === void 0 || match.index === 0 && !text2.startsWith("\n\n") && !atMessageStart)
|
|
46276
|
+
return { visible: text2, closed: false };
|
|
46277
|
+
return { visible: text2.slice(0, match.index), closed: true };
|
|
46278
|
+
}
|
|
46279
|
+
function holdCursorWritableIterablePrefix(text2, atMessageStart = true) {
|
|
46280
|
+
const taken = takeCursorWritableIterableClosed(text2, atMessageStart);
|
|
46281
|
+
if (taken.closed)
|
|
46282
|
+
return { emit: taken.visible, hold: text2.slice(taken.visible.length) };
|
|
46283
|
+
for (let size = Math.min(text2.length, LONGEST_PREFIX); size > 0; size -= 1) {
|
|
46284
|
+
const suffix = text2.slice(-size);
|
|
46285
|
+
const start = text2.length - size;
|
|
46286
|
+
if (!suffix.startsWith("\n") && !(start === 0 && atMessageStart) && text2.slice(Math.max(0, start - 2), start) !== "\n\n")
|
|
46287
|
+
continue;
|
|
46288
|
+
if (CLOSED_PREFIXES.some((candidate) => candidate.startsWith(suffix))) {
|
|
46289
|
+
return { emit: text2.slice(0, -size), hold: suffix };
|
|
46290
|
+
}
|
|
46291
|
+
}
|
|
46292
|
+
return { emit: text2, hold: "" };
|
|
46293
|
+
}
|
|
46294
|
+
|
|
45605
46295
|
// dist/projection.js
|
|
45606
46296
|
var TOOL_OUTPUT_LIMIT = 1e5;
|
|
45607
46297
|
function cursorFileChanges(content) {
|
|
@@ -45631,11 +46321,52 @@ var CursorTurnOutput = class {
|
|
|
45631
46321
|
#text;
|
|
45632
46322
|
#tools = /* @__PURE__ */ new Map();
|
|
45633
46323
|
#finishedTools = /* @__PURE__ */ new Set();
|
|
46324
|
+
#hold = "";
|
|
46325
|
+
#writableIterableClosed = false;
|
|
46326
|
+
#visibleAssistantText = false;
|
|
45634
46327
|
constructor(turnId, emit, nativeTurnIndex = 0) {
|
|
45635
46328
|
this.turnId = turnId;
|
|
45636
46329
|
this.emit = emit;
|
|
45637
46330
|
this.subagents = new CursorSubagents(turnId, emit, nativeTurnIndex);
|
|
45638
46331
|
}
|
|
46332
|
+
sawWritableIterableClosed() {
|
|
46333
|
+
return this.#writableIterableClosed || takeCursorWritableIterableClosed(this.#hold).closed;
|
|
46334
|
+
}
|
|
46335
|
+
hasVisibleAssistantText() {
|
|
46336
|
+
return this.#visibleAssistantText || takeCursorWritableIterableClosed(this.#hold).visible.trim().length > 0;
|
|
46337
|
+
}
|
|
46338
|
+
#flushHold() {
|
|
46339
|
+
if (!this.#hold)
|
|
46340
|
+
return;
|
|
46341
|
+
const held = this.#hold;
|
|
46342
|
+
this.#hold = "";
|
|
46343
|
+
this.#appendText("agentMessage", held);
|
|
46344
|
+
}
|
|
46345
|
+
#appendText(type, text2) {
|
|
46346
|
+
if (!text2)
|
|
46347
|
+
return;
|
|
46348
|
+
if (type === "agentMessage" && text2.trim())
|
|
46349
|
+
this.#visibleAssistantText = true;
|
|
46350
|
+
if (this.#text?.type !== type) {
|
|
46351
|
+
this.#finishText();
|
|
46352
|
+
const item = {
|
|
46353
|
+
type,
|
|
46354
|
+
itemId: hostItemIdSchema.parse(`cursor-${this.turnId}-${++this.#index}`),
|
|
46355
|
+
text: ""
|
|
46356
|
+
};
|
|
46357
|
+
this.#text = item;
|
|
46358
|
+
this.emit({ type: "item.started", turnId: this.turnId, item: { ...item } });
|
|
46359
|
+
}
|
|
46360
|
+
if (!this.#text)
|
|
46361
|
+
return;
|
|
46362
|
+
this.#text.text += text2;
|
|
46363
|
+
this.emit({
|
|
46364
|
+
type: "item.updated",
|
|
46365
|
+
turnId: this.turnId,
|
|
46366
|
+
itemId: this.#text.itemId,
|
|
46367
|
+
update: { type: "text.append", text: text2 }
|
|
46368
|
+
});
|
|
46369
|
+
}
|
|
45639
46370
|
#finishText(outcome = { status: "succeeded" }) {
|
|
45640
46371
|
if (this.#text)
|
|
45641
46372
|
this.emit({
|
|
@@ -45647,6 +46378,7 @@ var CursorTurnOutput = class {
|
|
|
45647
46378
|
}
|
|
45648
46379
|
update(notification) {
|
|
45649
46380
|
if (this.subagents.update(notification)) {
|
|
46381
|
+
this.#flushHold();
|
|
45650
46382
|
this.#finishText();
|
|
45651
46383
|
return;
|
|
45652
46384
|
}
|
|
@@ -45655,26 +46387,17 @@ var CursorTurnOutput = class {
|
|
|
45655
46387
|
if (update.content.type !== "text")
|
|
45656
46388
|
return;
|
|
45657
46389
|
const type = update.sessionUpdate === "agent_message_chunk" ? "agentMessage" : "reasoning";
|
|
45658
|
-
if (
|
|
45659
|
-
this.#
|
|
45660
|
-
|
|
45661
|
-
type,
|
|
45662
|
-
itemId: hostItemIdSchema.parse(`cursor-${this.turnId}-${++this.#index}`),
|
|
45663
|
-
text: ""
|
|
45664
|
-
};
|
|
45665
|
-
this.#text = item;
|
|
45666
|
-
this.emit({ type: "item.started", turnId: this.turnId, item: { ...item } });
|
|
45667
|
-
}
|
|
45668
|
-
if (!this.#text)
|
|
46390
|
+
if (type === "reasoning") {
|
|
46391
|
+
this.#flushHold();
|
|
46392
|
+
this.#appendText(type, update.content.text);
|
|
45669
46393
|
return;
|
|
45670
|
-
|
|
45671
|
-
this.
|
|
45672
|
-
|
|
45673
|
-
|
|
45674
|
-
|
|
45675
|
-
update: { type: "text.append", text: update.content.text }
|
|
45676
|
-
});
|
|
46394
|
+
}
|
|
46395
|
+
const combined = `${this.#hold}${update.content.text}`;
|
|
46396
|
+
const { emit, hold } = holdCursorWritableIterablePrefix(combined, this.#text?.type !== "agentMessage" || this.#text.text.length === 0);
|
|
46397
|
+
this.#hold = hold;
|
|
46398
|
+
this.#appendText(type, emit);
|
|
45677
46399
|
} else if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
|
|
46400
|
+
this.#flushHold();
|
|
45678
46401
|
this.#finishText();
|
|
45679
46402
|
if (this.#finishedTools.has(update.toolCallId))
|
|
45680
46403
|
return;
|
|
@@ -45743,6 +46466,11 @@ ${content.newText}`] : []).join("\n");
|
|
|
45743
46466
|
}
|
|
45744
46467
|
finish(outcome) {
|
|
45745
46468
|
this.subagents.finish(outcome);
|
|
46469
|
+
if (takeCursorWritableIterableClosed(this.#hold).closed) {
|
|
46470
|
+
this.#writableIterableClosed = true;
|
|
46471
|
+
this.#hold = "";
|
|
46472
|
+
}
|
|
46473
|
+
this.#flushHold();
|
|
45746
46474
|
this.#finishText(outcome);
|
|
45747
46475
|
for (const { item } of this.#tools.values())
|
|
45748
46476
|
this.emit({
|
|
@@ -45822,9 +46550,11 @@ function cursorSnapshot(sessionId, native, replay, nativeSubagentId) {
|
|
|
45822
46550
|
import { randomUUID } from "node:crypto";
|
|
45823
46551
|
var CursorInteractions = class {
|
|
45824
46552
|
emit;
|
|
46553
|
+
refuseUnattendedApproval;
|
|
45825
46554
|
#pending = /* @__PURE__ */ new Map();
|
|
45826
|
-
constructor(emit) {
|
|
46555
|
+
constructor(emit, refuseUnattendedApproval) {
|
|
45827
46556
|
this.emit = emit;
|
|
46557
|
+
this.refuseUnattendedApproval = refuseUnattendedApproval;
|
|
45828
46558
|
}
|
|
45829
46559
|
#ask(interaction) {
|
|
45830
46560
|
return new Promise((resolve) => {
|
|
@@ -45833,6 +46563,10 @@ var CursorInteractions = class {
|
|
|
45833
46563
|
});
|
|
45834
46564
|
}
|
|
45835
46565
|
async permission(turnId, request) {
|
|
46566
|
+
if (this.refuseUnattendedApproval) {
|
|
46567
|
+
await this.refuseUnattendedApproval();
|
|
46568
|
+
return { outcome: { outcome: "cancelled" } };
|
|
46569
|
+
}
|
|
45836
46570
|
const response = await this.#ask({
|
|
45837
46571
|
type: "approval",
|
|
45838
46572
|
interactionId: hostInteractionIdSchema.parse(randomUUID()),
|
|
@@ -45850,6 +46584,10 @@ var CursorInteractions = class {
|
|
|
45850
46584
|
async extension(turnId, method, params) {
|
|
45851
46585
|
const interactionId = hostInteractionIdSchema.parse(randomUUID());
|
|
45852
46586
|
if (method === "cursor/create_plan" && typeof params.plan === "string") {
|
|
46587
|
+
if (this.refuseUnattendedApproval) {
|
|
46588
|
+
await this.refuseUnattendedApproval();
|
|
46589
|
+
return { outcome: { outcome: "cancelled" } };
|
|
46590
|
+
}
|
|
45853
46591
|
const response = await this.#ask({
|
|
45854
46592
|
type: "approval",
|
|
45855
46593
|
interactionId,
|
|
@@ -45955,10 +46693,10 @@ var CursorInteractions = class {
|
|
|
45955
46693
|
|
|
45956
46694
|
// dist/fork.js
|
|
45957
46695
|
import { createHash as createHash2 } from "node:crypto";
|
|
45958
|
-
import { copyFile, mkdir, mkdtemp, readdir, readFile, realpath, rm, writeFile } from "node:fs/promises";
|
|
46696
|
+
import { copyFile, mkdir, mkdtemp as mkdtemp2, readdir, readFile as readFile3, realpath as realpath2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
45959
46697
|
import { readdirSync as readdirSync2 } from "node:fs";
|
|
45960
46698
|
import os3 from "node:os";
|
|
45961
|
-
import
|
|
46699
|
+
import path9 from "node:path";
|
|
45962
46700
|
import { backup, DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
45963
46701
|
|
|
45964
46702
|
// dist/fork-terminal.js
|
|
@@ -46076,16 +46814,16 @@ async function runCursorForkTerminal(options, sessionId, signal, rewind) {
|
|
|
46076
46814
|
|
|
46077
46815
|
// dist/fork.js
|
|
46078
46816
|
async function copySnapshot(source, target) {
|
|
46079
|
-
const db = new DatabaseSync2(
|
|
46817
|
+
const db = new DatabaseSync2(path9.join(source, "store.db"), { readOnly: true });
|
|
46080
46818
|
try {
|
|
46081
|
-
await backup(db,
|
|
46819
|
+
await backup(db, path9.join(target, "store.db"));
|
|
46082
46820
|
} finally {
|
|
46083
46821
|
db.close();
|
|
46084
46822
|
}
|
|
46085
|
-
await copyFile(
|
|
46823
|
+
await copyFile(path9.join(source, "meta.json"), path9.join(target, "meta.json"));
|
|
46086
46824
|
}
|
|
46087
46825
|
function storeIdentity(directory, hashBlobs = true) {
|
|
46088
|
-
const db = new DatabaseSync2(
|
|
46826
|
+
const db = new DatabaseSync2(path9.join(directory, "store.db"), { readOnly: true });
|
|
46089
46827
|
try {
|
|
46090
46828
|
db.exec("BEGIN");
|
|
46091
46829
|
const value = db.prepare("SELECT value FROM meta WHERE key = '0'").get()?.value;
|
|
@@ -46126,21 +46864,21 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46126
46864
|
if (rewindTurn && !rewindTurn.rewindRoot)
|
|
46127
46865
|
throw new Error("Cursor target has no native rewind checkpoint");
|
|
46128
46866
|
const original = storeIdentity(sourceDirectory);
|
|
46129
|
-
const temporary = await
|
|
46867
|
+
const temporary = await mkdtemp2(path9.join(os3.tmpdir(), "codexhost-cursor-fork-"));
|
|
46130
46868
|
let target;
|
|
46131
46869
|
let committed = false;
|
|
46132
46870
|
const discard = async () => {
|
|
46133
46871
|
if (target && !committed)
|
|
46134
|
-
await
|
|
46872
|
+
await rm2(target, { recursive: true, force: true });
|
|
46135
46873
|
};
|
|
46136
46874
|
try {
|
|
46137
46875
|
signal.throwIfAborted();
|
|
46138
|
-
const config2 =
|
|
46876
|
+
const config2 = path9.join(temporary, "config");
|
|
46139
46877
|
await mkdir(config2, { mode: 448 });
|
|
46140
|
-
const nativeConfig =
|
|
46878
|
+
const nativeConfig = path9.join(cursorConfigDirectory(options.environment), "cli-config.json");
|
|
46141
46879
|
let settings = {};
|
|
46142
46880
|
try {
|
|
46143
|
-
const data = JSON.parse(await
|
|
46881
|
+
const data = JSON.parse(await readFile3(nativeConfig, "utf8"));
|
|
46144
46882
|
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
46145
46883
|
throw new Error("Invalid Cursor CLI configuration");
|
|
46146
46884
|
settings = data;
|
|
@@ -46148,9 +46886,9 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46148
46886
|
if (!(error51 instanceof Error && "code" in error51 && error51.code === "ENOENT"))
|
|
46149
46887
|
throw error51;
|
|
46150
46888
|
}
|
|
46151
|
-
await
|
|
46152
|
-
const chats =
|
|
46153
|
-
const copy =
|
|
46889
|
+
await writeFile2(path9.join(config2, "cli-config.json"), JSON.stringify({ ...settings, rewind: true }), { mode: 384 });
|
|
46890
|
+
const chats = path9.join(config2, "chats", createHash2("md5").update(await realpath2(options.cwd)).digest("hex"));
|
|
46891
|
+
const copy = path9.join(chats, source.nativeSessionId);
|
|
46154
46892
|
await mkdir(copy, { recursive: true });
|
|
46155
46893
|
await copySnapshot(sourceDirectory, copy);
|
|
46156
46894
|
if (JSON.stringify(storeIdentity(copy)) !== JSON.stringify(original))
|
|
@@ -46160,14 +46898,14 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46160
46898
|
environment: {
|
|
46161
46899
|
...options.environment,
|
|
46162
46900
|
CURSOR_CONFIG_DIR: config2,
|
|
46163
|
-
CURSOR_DATA_DIR:
|
|
46901
|
+
CURSOR_DATA_DIR: path9.join(temporary, "data")
|
|
46164
46902
|
}
|
|
46165
46903
|
}, source.nativeSessionId, signal, rewindTurn ? {
|
|
46166
46904
|
steps: sourceTurns.slice(retained).filter((turn) => turn.rewindRoot).length,
|
|
46167
46905
|
complete: () => {
|
|
46168
46906
|
const targets = readdirSync2(chats).filter((id) => id !== source.nativeSessionId);
|
|
46169
46907
|
const targetId = targets[0];
|
|
46170
|
-
return targets.length === 1 && !!targetId && storeIdentity(
|
|
46908
|
+
return targets.length === 1 && !!targetId && storeIdentity(path9.join(chats, targetId), false).root === rewindTurn.rewindRoot;
|
|
46171
46909
|
}
|
|
46172
46910
|
} : void 0);
|
|
46173
46911
|
signal.throwIfAborted();
|
|
@@ -46176,7 +46914,7 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46176
46914
|
throw new Error("Cursor fork did not create one independent session");
|
|
46177
46915
|
const sessionId = children[0].name;
|
|
46178
46916
|
const destination = cursorSessionDirectory(sessionId, options.environment);
|
|
46179
|
-
const nativeFork =
|
|
46917
|
+
const nativeFork = path9.join(chats, sessionId);
|
|
46180
46918
|
const forked = storeIdentity(nativeFork);
|
|
46181
46919
|
if (forked.agentId !== sessionId || forked.root !== (rewindTurn?.rewindRoot ?? original.root) || forked.blobs !== original.blobs)
|
|
46182
46920
|
throw new Error("Cursor native fork changed conversation contents or identity");
|
|
@@ -46202,7 +46940,7 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46202
46940
|
throw error51;
|
|
46203
46941
|
} finally {
|
|
46204
46942
|
try {
|
|
46205
|
-
await
|
|
46943
|
+
await rm2(temporary, { recursive: true, force: true });
|
|
46206
46944
|
} catch (error51) {
|
|
46207
46945
|
await discard();
|
|
46208
46946
|
throw error51;
|
|
@@ -46213,6 +46951,13 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46213
46951
|
// dist/adapter.js
|
|
46214
46952
|
function cursorError(error51) {
|
|
46215
46953
|
const message = sanitizeDiagnosticTail(error51 instanceof Error ? error51.message : "Cursor operation failed");
|
|
46954
|
+
if (isCursorWritableIterableClosed(message)) {
|
|
46955
|
+
return {
|
|
46956
|
+
code: "nativeFailure",
|
|
46957
|
+
message: "Cursor stream closed (WritableIterable)",
|
|
46958
|
+
retryable: true
|
|
46959
|
+
};
|
|
46960
|
+
}
|
|
46216
46961
|
const code = /not installed/iu.test(message) ? "notInstalled" : /auth|not logged in|login/iu.test(message) ? "authenticationRequired" : /exited|closed/iu.test(message) ? "processExited" : "protocolError";
|
|
46217
46962
|
return { code, message, retryable: false };
|
|
46218
46963
|
}
|
|
@@ -46231,14 +46976,19 @@ var CursorAdapter = class {
|
|
|
46231
46976
|
try {
|
|
46232
46977
|
cursorTaskAddress(nativeSubagentId);
|
|
46233
46978
|
const session = [...this.#sessions].find((s) => s.transport.sessionId === parent.nativeSessionId);
|
|
46234
|
-
if (session &&
|
|
46979
|
+
if (session && path10.resolve(session.transport.options.cwd) !== path10.resolve(cwd))
|
|
46235
46980
|
return rejected("invalidRequest", "Cursor parent workspace does not match");
|
|
46236
46981
|
const active = session?.subagentSnapshot(nativeSubagentId);
|
|
46237
46982
|
if (active)
|
|
46238
46983
|
return { ok: true, value: active };
|
|
46239
46984
|
const options = session?.transport.options ?? this.transportOptions(cwd);
|
|
46240
46985
|
const before = readCursorNativeTurns(parent.nativeSessionId, cwd, options.environment);
|
|
46241
|
-
replay = new CursorTransport({
|
|
46986
|
+
replay = new CursorTransport({
|
|
46987
|
+
...options,
|
|
46988
|
+
delegation: false,
|
|
46989
|
+
executionPolicy: "default",
|
|
46990
|
+
loadModelCatalog: false
|
|
46991
|
+
});
|
|
46242
46992
|
await replay.open(parent.nativeSessionId);
|
|
46243
46993
|
const after = readCursorNativeTurns(parent.nativeSessionId, cwd, options.environment);
|
|
46244
46994
|
if (JSON.stringify(before) !== JSON.stringify(after))
|
|
@@ -46259,12 +47009,19 @@ var CursorAdapter = class {
|
|
|
46259
47009
|
#forks = /* @__PURE__ */ new Map();
|
|
46260
47010
|
#inspections = /* @__PURE__ */ new Map();
|
|
46261
47011
|
#closed = false;
|
|
47012
|
+
sessionImport;
|
|
46262
47013
|
constructor(options = {}) {
|
|
46263
47014
|
this.options = options;
|
|
47015
|
+
this.sessionImport = new CursorSessionImport(options.environment ?? process.env);
|
|
47016
|
+
}
|
|
47017
|
+
async inspectAccount() {
|
|
47018
|
+
if (this.#closed)
|
|
47019
|
+
return null;
|
|
47020
|
+
return fetchCursorAccount({ environment: this.options.environment ?? process.env });
|
|
46264
47021
|
}
|
|
46265
47022
|
transportOptions(cwd, environment) {
|
|
46266
47023
|
return {
|
|
46267
|
-
cwd:
|
|
47024
|
+
cwd: path10.resolve(cwd),
|
|
46268
47025
|
environment: { ...this.options.environment ?? process.env, ...environment },
|
|
46269
47026
|
...this.options.command ? { command: this.options.command } : {},
|
|
46270
47027
|
...this.options.timeoutMs ? { timeoutMs: this.options.timeoutMs } : {}
|
|
@@ -46276,7 +47033,7 @@ var CursorAdapter = class {
|
|
|
46276
47033
|
status: "unavailable",
|
|
46277
47034
|
error: { code: "unavailable", message: "Cursor adapter is closed", retryable: false }
|
|
46278
47035
|
};
|
|
46279
|
-
const cwd =
|
|
47036
|
+
const cwd = path10.resolve(input.cwd ?? process.cwd());
|
|
46280
47037
|
const cached2 = this.#inspections.get(cwd);
|
|
46281
47038
|
if (cached2 && (cached2.pending || !input.refresh))
|
|
46282
47039
|
return cached2.result;
|
|
@@ -46323,11 +47080,19 @@ var CursorAdapter = class {
|
|
|
46323
47080
|
return this.#openSession(input);
|
|
46324
47081
|
}
|
|
46325
47082
|
async #openSession(input, prepared) {
|
|
46326
|
-
if (input.kind === "create" && input.executionPolicy === "unattended-full-access")
|
|
46327
|
-
return rejected("unsupported", "Cursor ACP cannot confirm unattended full access under native team policy");
|
|
46328
47083
|
if (input.kind === "resume" && input.nativeRef.harnessId !== this.harnessId)
|
|
46329
47084
|
return rejected("invalidRequest", "Session belongs to another Harness");
|
|
46330
|
-
|
|
47085
|
+
let executionPolicy;
|
|
47086
|
+
try {
|
|
47087
|
+
executionPolicy = input.kind === "create" ? input.executionPolicy ?? "default" : cursorExecutionPolicy(input.nativeRef);
|
|
47088
|
+
} catch {
|
|
47089
|
+
return rejected("invalidRequest", "Invalid Cursor Native Session locator");
|
|
47090
|
+
}
|
|
47091
|
+
const options = {
|
|
47092
|
+
...this.transportOptions(input.cwd, input.environment),
|
|
47093
|
+
delegation: true,
|
|
47094
|
+
executionPolicy
|
|
47095
|
+
};
|
|
46331
47096
|
const transport = prepared ?? new CursorTransport(options);
|
|
46332
47097
|
try {
|
|
46333
47098
|
const before = input.kind === "resume" ? readCursorNativeHistory(input.nativeRef.nativeSessionId, options.cwd, options.environment) : void 0;
|
|
@@ -46380,11 +47145,13 @@ var CursorAdapter = class {
|
|
|
46380
47145
|
const signal = controller.signal;
|
|
46381
47146
|
if (!cursorForkAvailable())
|
|
46382
47147
|
return rejected("unsupported", "Cursor Fork requires macOS/Linux with /usr/bin/script");
|
|
47148
|
+
let executionPolicy;
|
|
46383
47149
|
try {
|
|
46384
47150
|
if (input.kind === "fork")
|
|
46385
47151
|
validateCursorFork(input.sourceRef, input.checkpoint);
|
|
46386
47152
|
else if (input.sourceRef.harnessId !== this.harnessId || input.sourceRef.formatVersion !== 1)
|
|
46387
47153
|
return rejected("invalidRequest", "Invalid Cursor rollback source");
|
|
47154
|
+
executionPolicy = cursorExecutionPolicy(input.sourceRef);
|
|
46388
47155
|
} catch {
|
|
46389
47156
|
return rejected("invalidRequest", "Invalid Cursor fork checkpoint");
|
|
46390
47157
|
}
|
|
@@ -46417,7 +47184,7 @@ var CursorAdapter = class {
|
|
|
46417
47184
|
const sameEnvironment = sourceEnvironment && [
|
|
46418
47185
|
.../* @__PURE__ */ new Set([...Object.keys(sourceEnvironment), ...Object.keys(options.environment)])
|
|
46419
47186
|
].every((key) => sourceEnvironment[key] === options.environment[key]);
|
|
46420
|
-
transport = new CursorTransport({ ...options, delegation: true }, sameEnvironment ? source?.info.nativeModels : void 0);
|
|
47187
|
+
transport = new CursorTransport({ ...options, delegation: true, executionPolicy }, sameEnvironment ? source?.info.nativeModels : void 0);
|
|
46421
47188
|
const abort = (error51) => {
|
|
46422
47189
|
controller.abort(error51);
|
|
46423
47190
|
throw error51;
|
|
@@ -46442,11 +47209,7 @@ var CursorAdapter = class {
|
|
|
46442
47209
|
kind: "resume",
|
|
46443
47210
|
cwd: input.cwd,
|
|
46444
47211
|
environment: options.environment,
|
|
46445
|
-
nativeRef:
|
|
46446
|
-
harnessId: this.harnessId,
|
|
46447
|
-
nativeSessionId: derived.sessionId,
|
|
46448
|
-
formatVersion: 1
|
|
46449
|
-
}),
|
|
47212
|
+
nativeRef: cursorNativeSessionRef(derived.sessionId, executionPolicy),
|
|
46450
47213
|
...model ? { model } : {},
|
|
46451
47214
|
...thinking ? { thinkingOptionId: thinking } : {},
|
|
46452
47215
|
...mode ? { permissionModeId: mode } : {}
|
|
@@ -46472,9 +47235,10 @@ var CursorAdapter = class {
|
|
|
46472
47235
|
}
|
|
46473
47236
|
async close() {
|
|
46474
47237
|
this.#closed = true;
|
|
47238
|
+
const importing = this.sessionImport.close();
|
|
46475
47239
|
for (const controller of this.#forks.keys())
|
|
46476
47240
|
controller.abort();
|
|
46477
|
-
await Promise.allSettled(this.#forks.values());
|
|
47241
|
+
await Promise.allSettled([importing, ...this.#forks.values()]);
|
|
46478
47242
|
await Promise.allSettled([...this.#sessions].map((session) => session.close()));
|
|
46479
47243
|
await Promise.allSettled([...this.#inspections.values()].map((inspection) => inspection.result));
|
|
46480
47244
|
}
|
|
@@ -46506,9 +47270,11 @@ var CursorSession = class {
|
|
|
46506
47270
|
initialState;
|
|
46507
47271
|
#channel = new HarnessOutputChannel();
|
|
46508
47272
|
outputs = this.#channel.outputs;
|
|
46509
|
-
#interactions
|
|
47273
|
+
#interactions;
|
|
47274
|
+
#executionPolicy;
|
|
46510
47275
|
#submitted = /* @__PURE__ */ new Set();
|
|
46511
47276
|
#active;
|
|
47277
|
+
#unattendedApproval = false;
|
|
46512
47278
|
#configuring = false;
|
|
46513
47279
|
#closed = false;
|
|
46514
47280
|
#fresh;
|
|
@@ -46536,12 +47302,10 @@ var CursorSession = class {
|
|
|
46536
47302
|
this.info = structuredClone(info);
|
|
46537
47303
|
this.#fresh = created;
|
|
46538
47304
|
this.#snapshot = loadedSnapshot;
|
|
47305
|
+
this.#executionPolicy = transport.options.executionPolicy ?? "default";
|
|
47306
|
+
this.#interactions = new CursorInteractions((output) => this.#channel.emit(output), this.#executionPolicy === "unattended-full-access" ? () => this.#refuseUnattendedApproval() : void 0);
|
|
46539
47307
|
this.initialState = {
|
|
46540
|
-
nativeRef:
|
|
46541
|
-
harnessId: "cursor-cli",
|
|
46542
|
-
nativeSessionId: transport.sessionId,
|
|
46543
|
-
formatVersion: 1
|
|
46544
|
-
}),
|
|
47308
|
+
nativeRef: cursorNativeSessionRef(transport.sessionId, this.#executionPolicy),
|
|
46545
47309
|
effectiveModel: cursorConfiguredModelRef(cursorModels(info).current, info.configOptions),
|
|
46546
47310
|
...cursorThinkingState(info),
|
|
46547
47311
|
effectivePermissionModeId: harnessPermissionModeIdSchema.parse(info.configOptions?.find((option) => option.id === "mode")?.currentValue ?? info.modes?.currentModeId ?? "agent")
|
|
@@ -46550,6 +47314,11 @@ var CursorSession = class {
|
|
|
46550
47314
|
#native(allowMissing = false) {
|
|
46551
47315
|
return readCursorNativeTurns(this.transport.sessionId, this.transport.options.cwd, this.transport.options.environment, allowMissing);
|
|
46552
47316
|
}
|
|
47317
|
+
/** Bound to unattended full access only; Cursor itself keeps enforcing its team policy. */
|
|
47318
|
+
#refuseUnattendedApproval() {
|
|
47319
|
+
this.#unattendedApproval = true;
|
|
47320
|
+
return this.transport.cancel();
|
|
47321
|
+
}
|
|
46553
47322
|
async readSnapshot() {
|
|
46554
47323
|
if (this.#closed)
|
|
46555
47324
|
return rejected("invalidState", "Cursor session is closed");
|
|
@@ -46566,6 +47335,7 @@ var CursorSession = class {
|
|
|
46566
47335
|
replay = new CursorTransport({
|
|
46567
47336
|
...this.transport.options,
|
|
46568
47337
|
delegation: false,
|
|
47338
|
+
executionPolicy: "default",
|
|
46569
47339
|
loadModelCatalog: false
|
|
46570
47340
|
});
|
|
46571
47341
|
await replay.open(this.transport.sessionId);
|
|
@@ -46680,6 +47450,7 @@ var CursorSession = class {
|
|
|
46680
47450
|
let fault;
|
|
46681
47451
|
const output = new CursorTurnOutput(command.turnId, (event) => this.#channel.emit({ kind: "event", event }), before.length);
|
|
46682
47452
|
this.#subagentOutput = output.subagents;
|
|
47453
|
+
this.#unattendedApproval = false;
|
|
46683
47454
|
this.#channel.emit({ kind: "event", event: { type: "turn.started", turnId: command.turnId } });
|
|
46684
47455
|
let outcome = {
|
|
46685
47456
|
status: "failed",
|
|
@@ -46695,7 +47466,15 @@ var CursorSession = class {
|
|
|
46695
47466
|
output.subagents.extension(method, params);
|
|
46696
47467
|
}
|
|
46697
47468
|
});
|
|
46698
|
-
|
|
47469
|
+
const streamClosed = output.sawWritableIterableClosed() && !output.hasVisibleAssistantText();
|
|
47470
|
+
outcome = this.#active?.cancelled || result.stopReason === "cancelled" ? { status: "cancelled" } : streamClosed ? {
|
|
47471
|
+
status: "failed",
|
|
47472
|
+
error: {
|
|
47473
|
+
code: "nativeFailure",
|
|
47474
|
+
message: "Cursor stream closed (WritableIterable)",
|
|
47475
|
+
retryable: true
|
|
47476
|
+
}
|
|
47477
|
+
} : result.stopReason === "end_turn" ? { status: "succeeded" } : {
|
|
46699
47478
|
status: "failed",
|
|
46700
47479
|
error: {
|
|
46701
47480
|
code: "nativeFailure",
|
|
@@ -46707,6 +47486,15 @@ var CursorSession = class {
|
|
|
46707
47486
|
fault = cursorError(error51);
|
|
46708
47487
|
outcome = this.#active?.cancelled ? { status: "cancelled" } : { status: "failed", error: cursorError(error51) };
|
|
46709
47488
|
}
|
|
47489
|
+
if (!this.#active?.cancelled && this.#unattendedApproval)
|
|
47490
|
+
outcome = {
|
|
47491
|
+
status: "failed",
|
|
47492
|
+
error: {
|
|
47493
|
+
code: "nativeFailure",
|
|
47494
|
+
message: "Cursor requested approval during unattended full access",
|
|
47495
|
+
retryable: false
|
|
47496
|
+
}
|
|
47497
|
+
};
|
|
46710
47498
|
try {
|
|
46711
47499
|
const after = this.#native(this.#fresh);
|
|
46712
47500
|
const added = after.filter((turn) => !before.some((old) => old.id === turn.id));
|
|
@@ -46770,7 +47558,7 @@ var CursorSession = class {
|
|
|
46770
47558
|
|
|
46771
47559
|
// ../../harness-broker/dist/client.js
|
|
46772
47560
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
46773
|
-
import { lstat, readFile as
|
|
47561
|
+
import { lstat as lstat2, readFile as readFile4 } from "node:fs/promises";
|
|
46774
47562
|
import net, {} from "node:net";
|
|
46775
47563
|
|
|
46776
47564
|
// ../../harness-broker/dist/protocol.js
|
|
@@ -46885,24 +47673,25 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
46885
47673
|
|
|
46886
47674
|
// ../../harness-broker/dist/paths.js
|
|
46887
47675
|
import os4 from "node:os";
|
|
46888
|
-
import
|
|
47676
|
+
import path11 from "node:path";
|
|
46889
47677
|
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
46890
47678
|
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
46891
47679
|
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
46892
47680
|
const home = environment.HOME || os4.homedir();
|
|
46893
|
-
return
|
|
47681
|
+
return path11.join(home, ".codexhost", "harness-broker");
|
|
46894
47682
|
}
|
|
46895
47683
|
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
46896
47684
|
harnessPluginIdSchema.parse(harnessId);
|
|
46897
47685
|
if (harnessId !== "claude-code")
|
|
46898
|
-
return
|
|
46899
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ??
|
|
47686
|
+
return path11.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
47687
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path11.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
46900
47688
|
}
|
|
46901
47689
|
|
|
46902
47690
|
// ../../harness-broker/dist/validation.js
|
|
46903
47691
|
var cwdSchema = external_exports.string().min(1).max(16384);
|
|
46904
47692
|
var brokerEnvironmentSchema = external_exports.object({
|
|
46905
47693
|
CODEXHOST_CLI_PATH: external_exports.string().max(16384).optional(),
|
|
47694
|
+
CODEXHOST_CLI_NODE_PATH: external_exports.string().max(16384).optional(),
|
|
46906
47695
|
CODEXHOST_RUNTIME_ENDPOINT: external_exports.string().max(16384).optional(),
|
|
46907
47696
|
CODEXHOST_RUNTIME_TOKEN: external_exports.string().max(16384).optional(),
|
|
46908
47697
|
CODEXHOST_THREAD_ID: external_exports.string().max(256).optional()
|
|
@@ -47029,7 +47818,7 @@ var harnessErrorSchema = external_exports.object({
|
|
|
47029
47818
|
var harnessSessionStateSchema = external_exports.custom((value) => {
|
|
47030
47819
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
47031
47820
|
return false;
|
|
47032
|
-
const
|
|
47821
|
+
const record3 = value;
|
|
47033
47822
|
const allowed = /* @__PURE__ */ new Set([
|
|
47034
47823
|
"nativeRef",
|
|
47035
47824
|
"effectiveModel",
|
|
@@ -47038,12 +47827,12 @@ var harnessSessionStateSchema = external_exports.custom((value) => {
|
|
|
47038
47827
|
"availableThinkingOptions",
|
|
47039
47828
|
"effectivePermissionModeId"
|
|
47040
47829
|
]);
|
|
47041
|
-
if (Object.keys(
|
|
47830
|
+
if (Object.keys(record3).some((key) => !allowed.has(key)))
|
|
47042
47831
|
return false;
|
|
47043
|
-
if (
|
|
47832
|
+
if (record3.nativeRef !== void 0 && !nativeSessionRefSchema.safeParse(record3.nativeRef).success) {
|
|
47044
47833
|
return false;
|
|
47045
47834
|
}
|
|
47046
|
-
const { nativeRef: _nativeRef, ...configuration } =
|
|
47835
|
+
const { nativeRef: _nativeRef, ...configuration } = record3;
|
|
47047
47836
|
void _nativeRef;
|
|
47048
47837
|
return harnessConfigurationStateSchema.safeParse(configuration).success;
|
|
47049
47838
|
});
|
|
@@ -47057,6 +47846,7 @@ var eventKeys = /* @__PURE__ */ new Map([
|
|
|
47057
47846
|
["item.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
|
|
47058
47847
|
["item.updated", /* @__PURE__ */ new Set(["type", "turnId", "itemId", "update"])],
|
|
47059
47848
|
["item.completed", /* @__PURE__ */ new Set(["type", "turnId", "snapshot"])],
|
|
47849
|
+
["item.detached", /* @__PURE__ */ new Set(["type", "turnId", "itemId"])],
|
|
47060
47850
|
["interaction.closed", /* @__PURE__ */ new Set(["type", "interactionId", "turnId", "reason"])],
|
|
47061
47851
|
["turn.completed", /* @__PURE__ */ new Set(["type", "turnId", "nativeTurnRef", "outcome"])],
|
|
47062
47852
|
["session.faulted", /* @__PURE__ */ new Set(["type", "error"])]
|
|
@@ -47173,7 +47963,7 @@ function parseSessionMetadata(value) {
|
|
|
47173
47963
|
};
|
|
47174
47964
|
}
|
|
47175
47965
|
async function readDescriptor(descriptorPath) {
|
|
47176
|
-
const metadata = await
|
|
47966
|
+
const metadata = await lstat2(descriptorPath);
|
|
47177
47967
|
if (metadata.isSymbolicLink())
|
|
47178
47968
|
throw new Error("Aqua Harness broker descriptor must not be a symlink");
|
|
47179
47969
|
if (!metadata.isFile())
|
|
@@ -47185,12 +47975,12 @@ async function readDescriptor(descriptorPath) {
|
|
|
47185
47975
|
throw new Error("Aqua Harness broker descriptor belongs to another user");
|
|
47186
47976
|
}
|
|
47187
47977
|
}
|
|
47188
|
-
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await
|
|
47978
|
+
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile4(descriptorPath, "utf8")));
|
|
47189
47979
|
if (process.platform === "darwin" && Buffer.byteLength(descriptor.socketPath) > 103) {
|
|
47190
47980
|
throw new Error("Aqua Harness broker socket path is too long for macOS");
|
|
47191
47981
|
}
|
|
47192
47982
|
if (process.platform !== "win32") {
|
|
47193
|
-
const socket = await
|
|
47983
|
+
const socket = await lstat2(descriptor.socketPath);
|
|
47194
47984
|
if (socket.isSymbolicLink() || !socket.isSocket()) {
|
|
47195
47985
|
throw new Error("Aqua Harness broker endpoint is not a Unix socket");
|
|
47196
47986
|
}
|
|
@@ -47625,6 +48415,7 @@ var BrokeredHarnessAdapter = class {
|
|
|
47625
48415
|
if (this.#forwardEnvironment && input.environment) {
|
|
47626
48416
|
const allowed = [
|
|
47627
48417
|
"CODEXHOST_CLI_PATH",
|
|
48418
|
+
"CODEXHOST_CLI_NODE_PATH",
|
|
47628
48419
|
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
47629
48420
|
"CODEXHOST_RUNTIME_TOKEN",
|
|
47630
48421
|
"CODEXHOST_THREAD_ID"
|
|
@@ -47690,7 +48481,14 @@ function createHarnessAdapter(context) {
|
|
|
47690
48481
|
liveCommandCatalog: true,
|
|
47691
48482
|
environment: { ...context.environment }
|
|
47692
48483
|
});
|
|
47693
|
-
|
|
48484
|
+
const environment = { ...context.environment };
|
|
48485
|
+
return Object.assign(new CursorAdapter({ environment }), {
|
|
48486
|
+
installation: createCursorInstallation(environment),
|
|
48487
|
+
install: createHarnessInstaller(environment, {
|
|
48488
|
+
posix: "https://cursor.com/install",
|
|
48489
|
+
windows: "https://cursor.com/install?win32=true"
|
|
48490
|
+
})
|
|
48491
|
+
});
|
|
47694
48492
|
}
|
|
47695
48493
|
export {
|
|
47696
48494
|
createHarnessAdapter
|