@liberseek/boft-cli-linux-x64 0.7.5 → 0.7.7
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/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +17950 -0
- package/app/console-web.js +27484 -0
- package/app/desktop-controller.mjs +221 -33
- package/app/host-runtime.mjs +3590 -1251
- package/app/plugins/antigravity/plugin.mjs +726 -357
- package/app/plugins/claude-code/plugin.mjs +3067 -2208
- package/app/plugins/codebuddy/plugin.mjs +798 -386
- package/app/plugins/cursor-cli/manifest.json +1 -1
- package/app/plugins/cursor-cli/plugin.mjs +1230 -555
- package/app/plugins/deepseek-harness/plugin.mjs +4761 -4967
- package/app/plugins/grok/plugin.mjs +670 -361
- package/app/plugins/hermes/plugin.mjs +764 -441
- package/app/plugins/kimi-code/plugin.mjs +1095 -428
- package/app/plugins/kiro-cli/plugin.mjs +603 -332
- package/app/plugins/muse/plugin.mjs +189 -58
- package/app/plugins/omp/plugin.mjs +689 -334
- package/app/plugins/opencode/plugin.mjs +946 -478
- package/app/plugins/pi/plugin.mjs +1325 -587
- package/app/plugins/qoder/plugin.mjs +756 -308
- package/app/plugins/qoder-cn/plugin.mjs +555 -99
- package/app/plugins/workbuddy/plugin.mjs +192 -58
- package/app/renderer-extension.js +3703 -1703
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/package.json +2 -2
|
@@ -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,123 @@ 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/ids.js
|
|
27649
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
27650
|
+
message: "Identifier must not be empty or whitespace"
|
|
27651
|
+
});
|
|
27652
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
27653
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
27654
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
27655
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
27656
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
27657
|
+
|
|
27658
|
+
// ../../shared-contracts/dist/harness-plugins.js
|
|
27659
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
27660
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
27661
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
27662
|
+
var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
|
|
27663
|
+
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
27664
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
27665
|
+
var pluginPresentationShape = {
|
|
27666
|
+
id: harnessPluginIdSchema,
|
|
27667
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
27668
|
+
version: external_exports.string().min(1).max(128),
|
|
27669
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
27670
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
27671
|
+
links: external_exports.object({
|
|
27672
|
+
documentation: documentationUrlSchema.optional(),
|
|
27673
|
+
installation: documentationUrlSchema.optional()
|
|
27674
|
+
}).strict().optional()
|
|
27675
|
+
};
|
|
27676
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
27677
|
+
manifestVersion: external_exports.literal(1),
|
|
27678
|
+
...pluginPresentationShape,
|
|
27679
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
27680
|
+
entry: relativeResourceSchema,
|
|
27681
|
+
icon: relativeResourceSchema.optional()
|
|
27682
|
+
}).strict();
|
|
27683
|
+
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
27684
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
27685
|
+
...pluginPresentationShape,
|
|
27686
|
+
icon: harnessPluginIconSchema.optional()
|
|
27687
|
+
}).strict();
|
|
27688
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
27689
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
27690
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
27691
|
+
}).strict();
|
|
27692
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
27693
|
+
version: external_exports.literal(1),
|
|
27694
|
+
enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
27695
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
27696
|
+
message: "Enabled plugin IDs must be unique",
|
|
27697
|
+
path: ["enabled"]
|
|
27698
|
+
});
|
|
27699
|
+
|
|
27700
|
+
// ../../shared-contracts/dist/harness-long-context.js
|
|
27701
|
+
var HARNESS_LONG_CONTEXT_GET_METHOD = "codexhost/harness/long-context/get";
|
|
27702
|
+
var HARNESS_LONG_CONTEXT_SET_METHOD = "codexhost/harness/long-context/set";
|
|
27703
|
+
var harnessLongContextGetSchema = external_exports.object({
|
|
27704
|
+
harnessId: harnessPluginIdSchema
|
|
27705
|
+
}).strict();
|
|
27706
|
+
var harnessLongContextSetSchema = harnessLongContextGetSchema.extend({
|
|
27707
|
+
enabled: external_exports.boolean()
|
|
27708
|
+
});
|
|
27709
|
+
var harnessLongContextSchema = external_exports.object({
|
|
27710
|
+
enabled: external_exports.boolean()
|
|
27711
|
+
}).strict();
|
|
27712
|
+
|
|
27713
|
+
// ../../shared-contracts/dist/console.js
|
|
27714
|
+
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
27715
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
27716
|
+
type: external_exports.enum(["info", "warning", "danger"]),
|
|
27717
|
+
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
27718
|
+
});
|
|
27719
|
+
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
27720
|
+
var consoleOpenResultSchema = external_exports.strictObject({
|
|
27721
|
+
/** The console address. */
|
|
27722
|
+
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
27723
|
+
});
|
|
27724
|
+
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
27725
|
+
"codexhost/harness/plugins/list",
|
|
27726
|
+
"codexhost/harness/display-settings/get",
|
|
27727
|
+
"codexhost/harness/display-settings/set",
|
|
27728
|
+
"codexhost/harness/inspect",
|
|
27729
|
+
"codexhost/harness/installation",
|
|
27730
|
+
"codexhost/harness/launch-settings/get",
|
|
27731
|
+
"codexhost/harness/launch-settings/set",
|
|
27732
|
+
HARNESS_LONG_CONTEXT_GET_METHOD,
|
|
27733
|
+
HARNESS_LONG_CONTEXT_SET_METHOD,
|
|
27734
|
+
"codexhost/harness/web-ui/open",
|
|
27735
|
+
"codexhost/harness/accounts/sources",
|
|
27736
|
+
"codexhost/harness/accounts/list",
|
|
27737
|
+
"codexhost/harness/accounts/inspect",
|
|
27738
|
+
"codexhost/harness/credential-imports",
|
|
27739
|
+
"codexhost/harness/session-import/sources",
|
|
27740
|
+
"codexhost/harness/session-import/list",
|
|
27741
|
+
"codexhost/harness/session-import/import",
|
|
27742
|
+
"codexhost/account/list",
|
|
27743
|
+
"codexhost/account/refresh",
|
|
27744
|
+
"codexhost/account/usage/inspect",
|
|
27745
|
+
"codexhost/update/check",
|
|
27746
|
+
"codexhost/update/start",
|
|
27747
|
+
"codexhost/update/status"
|
|
27748
|
+
]);
|
|
27749
|
+
|
|
27266
27750
|
// ../../shared-contracts/dist/version.js
|
|
27267
27751
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
27268
27752
|
|
|
@@ -27306,15 +27790,11 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
|
|
|
27306
27790
|
inactiveMs: external_exports.number().nonnegative()
|
|
27307
27791
|
}));
|
|
27308
27792
|
|
|
27309
|
-
// ../../shared-contracts/dist/
|
|
27310
|
-
var
|
|
27311
|
-
|
|
27793
|
+
// ../../shared-contracts/dist/manual-compaction.js
|
|
27794
|
+
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
27795
|
+
threadId: hostThreadIdSchema,
|
|
27796
|
+
turnId: hostTurnIdSchema
|
|
27312
27797
|
});
|
|
27313
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
27314
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
27315
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
27316
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
27317
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
27318
27798
|
|
|
27319
27799
|
// ../../shared-contracts/dist/thread-usage.js
|
|
27320
27800
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
@@ -27376,6 +27856,10 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
27376
27856
|
var usagePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
27377
27857
|
var accountCreditsProductUsageSchema = external_exports.object({
|
|
27378
27858
|
product: external_exports.string().min(1),
|
|
27859
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
27860
|
+
// Zero is a real empty cap, not an absent field.
|
|
27861
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
27862
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
27379
27863
|
usagePercent: usagePercentSchema,
|
|
27380
27864
|
resetsAt: external_exports.string().min(1).optional()
|
|
27381
27865
|
}).strict();
|
|
@@ -27385,11 +27869,14 @@ var accountResetCreditsSchema = external_exports.object({
|
|
|
27385
27869
|
expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
|
|
27386
27870
|
}).strict();
|
|
27387
27871
|
var accountCreditsSnapshotSchema = external_exports.object({
|
|
27872
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
27873
|
+
// Zero is a real empty cap, not an absent field.
|
|
27874
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
27875
|
+
unit: external_exports.string().trim().min(1).max(32).optional(),
|
|
27388
27876
|
/** Native label when the primary limit is scoped to a model or product group. */
|
|
27389
27877
|
label: external_exports.string().min(1).optional(),
|
|
27390
27878
|
usedPercent: usagePercentSchema.optional(),
|
|
27391
27879
|
remaining: external_exports.number().finite().optional(),
|
|
27392
|
-
unit: external_exports.string().trim().min(1).max(32).optional(),
|
|
27393
27880
|
resetsAt: external_exports.string().min(1).optional(),
|
|
27394
27881
|
periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
|
|
27395
27882
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
@@ -27420,12 +27907,27 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
27420
27907
|
}).strict();
|
|
27421
27908
|
|
|
27422
27909
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
27423
|
-
var
|
|
27910
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
27911
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
27912
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
27913
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
27914
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
27915
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
27916
|
+
}).strict();
|
|
27917
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
27424
27918
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
27425
27919
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
27426
27920
|
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
27427
|
-
credits: accountCreditsSnapshotSchema
|
|
27921
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
27922
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
27428
27923
|
}).strict();
|
|
27924
|
+
function requireReportedQuota(schema) {
|
|
27925
|
+
return schema.refine((value) => {
|
|
27926
|
+
const reported = value;
|
|
27927
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
27928
|
+
}, { message: "Account must report either credits or a balance" });
|
|
27929
|
+
}
|
|
27930
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
27429
27931
|
var harnessAccountIdentityShape = {
|
|
27430
27932
|
harnessId: harnessIdSchema,
|
|
27431
27933
|
harnessName: external_exports.string().trim().min(1).max(128)
|
|
@@ -27436,11 +27938,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
|
|
|
27436
27938
|
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
27437
27939
|
var harnessAccountInspectResultSchema = external_exports.object({
|
|
27438
27940
|
...harnessAccountIdentityShape,
|
|
27439
|
-
account: harnessAccountSnapshotSchema.nullable()
|
|
27941
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
27942
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
27943
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
27440
27944
|
}).strict();
|
|
27441
27945
|
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
27442
27946
|
var harnessAccountListResultSchema = external_exports.object({
|
|
27443
|
-
accounts: external_exports.array(
|
|
27947
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
27444
27948
|
}).strict();
|
|
27445
27949
|
|
|
27446
27950
|
// ../../shared-contracts/dist/json-value.js
|
|
@@ -27578,6 +28082,8 @@ var harnessModelSchema = external_exports.object({
|
|
|
27578
28082
|
ref: harnessModelRefSchema,
|
|
27579
28083
|
label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
27580
28084
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
28085
|
+
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
28086
|
+
fastModel: harnessModelRefSchema.optional(),
|
|
27581
28087
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
27582
28088
|
}).strict();
|
|
27583
28089
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
@@ -27610,6 +28116,16 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
27610
28116
|
});
|
|
27611
28117
|
}
|
|
27612
28118
|
refs.add(model.ref.id);
|
|
28119
|
+
if (model.fastModel) {
|
|
28120
|
+
if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
|
|
28121
|
+
context.addIssue({
|
|
28122
|
+
code: "custom",
|
|
28123
|
+
message: "Fast Model refs must be distinct and unique",
|
|
28124
|
+
path: ["models", index, "fastModel"]
|
|
28125
|
+
});
|
|
28126
|
+
}
|
|
28127
|
+
refs.add(model.fastModel.id);
|
|
28128
|
+
}
|
|
27613
28129
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
27614
28130
|
for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
|
|
27615
28131
|
if (supportedThinkingIds.has(optionId)) {
|
|
@@ -27732,11 +28248,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
|
|
|
27732
28248
|
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
27733
28249
|
}).strict();
|
|
27734
28250
|
var threadInspectionParamsSchema = external_exports.object({
|
|
27735
|
-
threadId: hostThreadIdSchema
|
|
28251
|
+
threadId: hostThreadIdSchema,
|
|
28252
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
27736
28253
|
}).strict();
|
|
27737
28254
|
var codexThreadInspectionSchema = external_exports.object({
|
|
27738
28255
|
owner: external_exports.literal("codex"),
|
|
27739
|
-
locked: external_exports.literal(true)
|
|
28256
|
+
locked: external_exports.literal(true),
|
|
28257
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
27740
28258
|
}).strict();
|
|
27741
28259
|
var externalThreadInspectionSchema = external_exports.object({
|
|
27742
28260
|
owner: external_exports.literal("external"),
|
|
@@ -27801,48 +28319,6 @@ var threadOwnershipListResultSchema = external_exports.object({
|
|
|
27801
28319
|
}
|
|
27802
28320
|
});
|
|
27803
28321
|
|
|
27804
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
27805
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
27806
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
27807
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
27808
|
-
var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
|
|
27809
|
-
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
27810
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
27811
|
-
var pluginPresentationShape = {
|
|
27812
|
-
id: harnessPluginIdSchema,
|
|
27813
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
27814
|
-
version: external_exports.string().min(1).max(128),
|
|
27815
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
27816
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
27817
|
-
links: external_exports.object({
|
|
27818
|
-
documentation: documentationUrlSchema.optional(),
|
|
27819
|
-
installation: documentationUrlSchema.optional()
|
|
27820
|
-
}).strict().optional()
|
|
27821
|
-
};
|
|
27822
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
27823
|
-
manifestVersion: external_exports.literal(1),
|
|
27824
|
-
...pluginPresentationShape,
|
|
27825
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
27826
|
-
entry: relativeResourceSchema,
|
|
27827
|
-
icon: relativeResourceSchema.optional()
|
|
27828
|
-
}).strict();
|
|
27829
|
-
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
27830
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
27831
|
-
...pluginPresentationShape,
|
|
27832
|
-
icon: harnessPluginIconSchema.optional()
|
|
27833
|
-
}).strict();
|
|
27834
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
27835
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
27836
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
27837
|
-
}).strict();
|
|
27838
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
27839
|
-
version: external_exports.literal(1),
|
|
27840
|
-
enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
27841
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
27842
|
-
message: "Enabled plugin IDs must be unique",
|
|
27843
|
-
path: ["enabled"]
|
|
27844
|
-
});
|
|
27845
|
-
|
|
27846
28322
|
// ../../shared-contracts/dist/harness-route.js
|
|
27847
28323
|
var harnessPluginRouteSchema = external_exports.object({
|
|
27848
28324
|
harnessId: harnessPluginIdSchema,
|
|
@@ -27864,10 +28340,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
27864
28340
|
restartRequired: external_exports.boolean()
|
|
27865
28341
|
}).strict();
|
|
27866
28342
|
|
|
28343
|
+
// ../../shared-contracts/dist/harness-installation.js
|
|
28344
|
+
var harnessInstallationParamsSchema = external_exports.object({
|
|
28345
|
+
harnessId: harnessIdSchema,
|
|
28346
|
+
action: external_exports.enum(["check", "update", "install"])
|
|
28347
|
+
}).strict();
|
|
28348
|
+
var harnessInstallationStateSchema = external_exports.object({
|
|
28349
|
+
currentVersion: external_exports.string().min(1).max(128),
|
|
28350
|
+
latestVersion: external_exports.string().min(1).max(128),
|
|
28351
|
+
updateAvailable: external_exports.boolean(),
|
|
28352
|
+
canUpdate: external_exports.boolean(),
|
|
28353
|
+
message: external_exports.string().max(2048).optional()
|
|
28354
|
+
}).strict();
|
|
28355
|
+
|
|
27867
28356
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
27868
28357
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
27869
28358
|
var nonBlankTextSchema3 = external_exports.string().trim().min(1);
|
|
27870
28359
|
var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
|
|
28360
|
+
var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
|
|
28361
|
+
function isCodexAccountSiteUrl(value) {
|
|
28362
|
+
return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
|
|
28363
|
+
}
|
|
28364
|
+
var externalUrlOpenParamsSchema = external_exports.object({
|
|
28365
|
+
url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
|
|
28366
|
+
}).strict();
|
|
28367
|
+
var externalUrlOpenResultSchema = external_exports.object({}).strict();
|
|
27871
28368
|
var codexAccountPlanTypeSchema = external_exports.enum([
|
|
27872
28369
|
"free",
|
|
27873
28370
|
"go",
|
|
@@ -27893,7 +28390,8 @@ var codexAccountSchema = external_exports.object({
|
|
|
27893
28390
|
email: external_exports.string().email().max(320).optional(),
|
|
27894
28391
|
planType: codexAccountPlanTypeSchema.optional(),
|
|
27895
28392
|
authKind: codexAccountAuthKindSchema.optional(),
|
|
27896
|
-
authIdentity: nonBlankTextSchema3.max(256).optional()
|
|
28393
|
+
authIdentity: nonBlankTextSchema3.max(256).optional(),
|
|
28394
|
+
siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
|
|
27897
28395
|
}).strict();
|
|
27898
28396
|
var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
|
|
27899
28397
|
var codexAccountListResultSchema = external_exports.object({
|
|
@@ -28510,9 +29008,480 @@ function cursorCommandPrompt(command, catalog) {
|
|
|
28510
29008
|
return { ok: true, value: `${descriptor.invocation}${text2 ? ` ${text2}` : ""}` };
|
|
28511
29009
|
}
|
|
28512
29010
|
|
|
29011
|
+
// dist/command.js
|
|
29012
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
29013
|
+
import path4 from "node:path";
|
|
29014
|
+
var PINNED_VERSION_AGENT = /[/\\]cursor-agent[/\\]versions[/\\][^/\\]+[/\\]cursor-agent(?:\.exe)?$/iu;
|
|
29015
|
+
function cursorDiscoverySpec(skipPinnedVersions) {
|
|
29016
|
+
return {
|
|
29017
|
+
id: "cursor-cli",
|
|
29018
|
+
command: "cursor-agent",
|
|
29019
|
+
commandEnvironmentVariable: "CODEXHOST_CURSOR_COMMAND",
|
|
29020
|
+
installRoots: {
|
|
29021
|
+
posix: ["~/.local/bin", "/usr/local/bin", "/opt/homebrew/bin"],
|
|
29022
|
+
windows: ["${LOCALAPPDATA}/cursor-agent"]
|
|
29023
|
+
},
|
|
29024
|
+
...skipPinnedVersions ? {
|
|
29025
|
+
runnableCandidate: (candidate) => PINNED_VERSION_AGENT.test(candidate) ? void 0 : candidate
|
|
29026
|
+
} : {}
|
|
29027
|
+
};
|
|
29028
|
+
}
|
|
29029
|
+
function resolveCursorExecutable(environment, command) {
|
|
29030
|
+
const input = { environment, ...command ? { command } : {} };
|
|
29031
|
+
const pinned = resolveHarnessExecutable(cursorDiscoverySpec(false), input);
|
|
29032
|
+
if (!pinned)
|
|
29033
|
+
throw new Error("Cursor CLI is not installed; install cursor-agent or set CODEXHOST_CURSOR_COMMAND");
|
|
29034
|
+
const explicit = command?.trim() || environment.CODEXHOST_CURSOR_COMMAND?.trim();
|
|
29035
|
+
if (explicit || !PINNED_VERSION_AGENT.test(pinned.executable))
|
|
29036
|
+
return pinned;
|
|
29037
|
+
return resolveHarnessExecutable(cursorDiscoverySpec(true), input) ?? pinned;
|
|
29038
|
+
}
|
|
29039
|
+
function cursorInvocation(environment, command, args) {
|
|
29040
|
+
const resolution = resolveCursorExecutable(environment, command);
|
|
29041
|
+
if (process.platform === "win32" && /\.(cmd|ps1)$/iu.test(resolution.executable)) {
|
|
29042
|
+
const root = path4.dirname(resolution.executable);
|
|
29043
|
+
const versions = path4.join(root, "versions");
|
|
29044
|
+
if (existsSync(versions)) {
|
|
29045
|
+
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")));
|
|
29046
|
+
if (version2)
|
|
29047
|
+
return {
|
|
29048
|
+
command: path4.join(versions, version2, "node.exe"),
|
|
29049
|
+
arguments: [path4.join(versions, version2, "index.js"), ...args],
|
|
29050
|
+
windowsVerbatimArguments: false
|
|
29051
|
+
};
|
|
29052
|
+
}
|
|
29053
|
+
throw new Error("Cursor Windows launcher has no supported native bundle; configure a native executable");
|
|
29054
|
+
}
|
|
29055
|
+
return commandInvocation(resolution.executable, args, environment);
|
|
29056
|
+
}
|
|
29057
|
+
|
|
29058
|
+
// dist/installation.js
|
|
29059
|
+
function createCursorInstallation(environment) {
|
|
29060
|
+
const run = (args, timeout) => {
|
|
29061
|
+
const invocation = cursorInvocation(environment, void 0, args);
|
|
29062
|
+
return runInstallationCommand(invocation.command, invocation.arguments, environment, timeout);
|
|
29063
|
+
};
|
|
29064
|
+
return createInstallationManager({
|
|
29065
|
+
async check() {
|
|
29066
|
+
const state = JSON.parse(await run(["about", "--format", "json"]));
|
|
29067
|
+
if (state.latestStatus !== "up_to_date" && state.latestStatus !== "update_available")
|
|
29068
|
+
throw new Error("Cursor update checks are disabled or unavailable");
|
|
29069
|
+
return {
|
|
29070
|
+
currentVersion: installationVersion(state.cliVersion),
|
|
29071
|
+
latestVersion: installationVersion(state.latestVersion),
|
|
29072
|
+
updateAvailable: state.latestStatus === "update_available",
|
|
29073
|
+
canUpdate: true
|
|
29074
|
+
};
|
|
29075
|
+
},
|
|
29076
|
+
async update() {
|
|
29077
|
+
await run(["update"], 3e5);
|
|
29078
|
+
}
|
|
29079
|
+
});
|
|
29080
|
+
}
|
|
29081
|
+
|
|
28513
29082
|
// dist/adapter.js
|
|
29083
|
+
import path10 from "node:path";
|
|
29084
|
+
|
|
29085
|
+
// dist/account-usage.js
|
|
29086
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
29087
|
+
import { readFile } from "node:fs/promises";
|
|
29088
|
+
import { homedir as homedir2 } from "node:os";
|
|
29089
|
+
import path5 from "node:path";
|
|
29090
|
+
import { promisify } from "node:util";
|
|
29091
|
+
var execute = promisify(execFile2);
|
|
29092
|
+
var ENDPOINT = "https://api2.cursor.sh/aiserver.v1.DashboardService/";
|
|
29093
|
+
var record2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
29094
|
+
var percent = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.min(100, value) : void 0;
|
|
29095
|
+
function projectCursorAccountUsage(usage, identity, plan) {
|
|
29096
|
+
const data = record2(usage);
|
|
29097
|
+
const buckets = record2(data.planUsage);
|
|
29098
|
+
const usedPercent = percent(buckets.autoPercentUsed);
|
|
29099
|
+
if (usedPercent === void 0)
|
|
29100
|
+
return null;
|
|
29101
|
+
const end = typeof data.billingCycleEnd === "string" || typeof data.billingCycleEnd === "number" ? Number(data.billingCycleEnd) : NaN;
|
|
29102
|
+
const date5 = new Date(end);
|
|
29103
|
+
const resetsAt = Number.isFinite(date5.getTime()) && end > 0 ? date5.toISOString() : void 0;
|
|
29104
|
+
const apiPercent = percent(buckets.apiPercentUsed);
|
|
29105
|
+
const email3 = record2(identity).email;
|
|
29106
|
+
const planName = record2(record2(plan).planInfo).planName;
|
|
29107
|
+
const result = harnessAccountSnapshotSchema.safeParse({
|
|
29108
|
+
...typeof email3 === "string" && email3.trim() ? { email: email3 } : {},
|
|
29109
|
+
...typeof planName === "string" && planName.trim() ? { plan: planName } : {},
|
|
29110
|
+
credits: {
|
|
29111
|
+
usedPercent,
|
|
29112
|
+
label: "Auto · monthly",
|
|
29113
|
+
periodType: "monthly",
|
|
29114
|
+
...resetsAt ? { resetsAt } : {},
|
|
29115
|
+
...apiPercent === void 0 ? {} : {
|
|
29116
|
+
productUsage: [
|
|
29117
|
+
{
|
|
29118
|
+
product: "API · monthly",
|
|
29119
|
+
usagePercent: apiPercent,
|
|
29120
|
+
...resetsAt ? { resetsAt } : {}
|
|
29121
|
+
}
|
|
29122
|
+
]
|
|
29123
|
+
}
|
|
29124
|
+
}
|
|
29125
|
+
});
|
|
29126
|
+
return result.success ? result.data : null;
|
|
29127
|
+
}
|
|
29128
|
+
async function accessToken(environment) {
|
|
29129
|
+
if (environment.CURSOR_API_KEY?.trim() || environment.AGENT_CLI_CREDENTIAL_STORE === "memory")
|
|
29130
|
+
return void 0;
|
|
29131
|
+
if (process.platform === "darwin" && environment.AGENT_CLI_CREDENTIAL_STORE !== "file") {
|
|
29132
|
+
const result = await execute("/usr/bin/security", ["find-generic-password", "-s", "cursor-access-token", "-a", "cursor-user", "-w"], { timeout: 5e3, maxBuffer: 64 * 1024 });
|
|
29133
|
+
return result.stdout.trim() || void 0;
|
|
29134
|
+
}
|
|
29135
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? homedir2();
|
|
29136
|
+
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");
|
|
29137
|
+
const auth = record2(JSON.parse(await readFile(authPath, "utf8")));
|
|
29138
|
+
return typeof auth.accessToken === "string" && auth.accessToken.trim() ? auth.accessToken : void 0;
|
|
29139
|
+
}
|
|
29140
|
+
async function fetchCursorAccount(input = {}) {
|
|
29141
|
+
try {
|
|
29142
|
+
const environment = input.environment ?? process.env;
|
|
29143
|
+
if (environment.CURSOR_API_KEY?.trim() || environment.AGENT_CLI_CREDENTIAL_STORE === "memory")
|
|
29144
|
+
return null;
|
|
29145
|
+
const token = await (input.readAccessToken ? input.readAccessToken() : accessToken(environment));
|
|
29146
|
+
if (!token)
|
|
29147
|
+
return null;
|
|
29148
|
+
const signal = input.signal ? AbortSignal.any([input.signal, AbortSignal.timeout(1e4)]) : AbortSignal.timeout(1e4);
|
|
29149
|
+
const request = async (method) => {
|
|
29150
|
+
const response = await (input.fetch ?? fetch)(ENDPOINT + method, {
|
|
29151
|
+
method: "POST",
|
|
29152
|
+
headers: {
|
|
29153
|
+
Authorization: `Bearer ${token}`,
|
|
29154
|
+
"Content-Type": "application/json",
|
|
29155
|
+
"Connect-Protocol-Version": "1"
|
|
29156
|
+
},
|
|
29157
|
+
body: "{}",
|
|
29158
|
+
signal
|
|
29159
|
+
});
|
|
29160
|
+
return response.ok ? response.json() : null;
|
|
29161
|
+
};
|
|
29162
|
+
const [usage, identity, plan] = await Promise.all([
|
|
29163
|
+
request("GetCurrentPeriodUsage"),
|
|
29164
|
+
request("GetMe").catch(() => null),
|
|
29165
|
+
request("GetPlanInfo").catch(() => null)
|
|
29166
|
+
]);
|
|
29167
|
+
return projectCursorAccountUsage(usage, identity, plan);
|
|
29168
|
+
} catch {
|
|
29169
|
+
return null;
|
|
29170
|
+
}
|
|
29171
|
+
}
|
|
29172
|
+
|
|
29173
|
+
// dist/session-import.js
|
|
29174
|
+
import { lstat, opendir, readFile as readFile2, realpath, stat } from "node:fs/promises";
|
|
28514
29175
|
import path7 from "node:path";
|
|
28515
29176
|
|
|
29177
|
+
// dist/native-history.js
|
|
29178
|
+
import { existsSync as existsSync2, readFileSync, realpathSync } from "node:fs";
|
|
29179
|
+
import os2 from "node:os";
|
|
29180
|
+
import path6 from "node:path";
|
|
29181
|
+
import { DatabaseSync } from "node:sqlite";
|
|
29182
|
+
function cursorConfigDirectory(environment) {
|
|
29183
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? os2.homedir();
|
|
29184
|
+
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");
|
|
29185
|
+
}
|
|
29186
|
+
function cursorSessionDirectory(sessionId, environment) {
|
|
29187
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId))
|
|
29188
|
+
throw new Error("Unsupported Cursor native session ID");
|
|
29189
|
+
return path6.join(cursorConfigDirectory(environment), "acp-sessions", sessionId);
|
|
29190
|
+
}
|
|
29191
|
+
function cursorSameWorkspace(left, right) {
|
|
29192
|
+
return path6.resolve(left) === path6.resolve(right) || existsSync2(left) && existsSync2(right) && realpathSync(left) === realpathSync(right);
|
|
29193
|
+
}
|
|
29194
|
+
function protobufBytes(data) {
|
|
29195
|
+
if (data.length > 32 * 1024 * 1024)
|
|
29196
|
+
throw new Error("Cursor native record is too large");
|
|
29197
|
+
let offset = 0;
|
|
29198
|
+
const varint = () => {
|
|
29199
|
+
let result = 0;
|
|
29200
|
+
for (let shift = 0; shift < 70; shift += 7) {
|
|
29201
|
+
const value = data[offset++];
|
|
29202
|
+
if (value === void 0)
|
|
29203
|
+
throw new Error("Truncated Cursor native record");
|
|
29204
|
+
result += (value & 127) * 2 ** shift;
|
|
29205
|
+
if (!(value & 128))
|
|
29206
|
+
return result;
|
|
29207
|
+
}
|
|
29208
|
+
throw new Error("Invalid Cursor native varint");
|
|
29209
|
+
};
|
|
29210
|
+
const fields = /* @__PURE__ */ new Map();
|
|
29211
|
+
while (offset < data.length) {
|
|
29212
|
+
const tag = varint();
|
|
29213
|
+
const field = Math.floor(tag / 8), wire = tag % 8;
|
|
29214
|
+
if (!Number.isSafeInteger(tag) || field === 0)
|
|
29215
|
+
throw new Error("Invalid Cursor native field");
|
|
29216
|
+
if (wire === 0) {
|
|
29217
|
+
varint();
|
|
29218
|
+
continue;
|
|
29219
|
+
}
|
|
29220
|
+
const length = wire === 2 ? varint() : wire === 1 ? 8 : wire === 5 ? 4 : -1;
|
|
29221
|
+
if (!Number.isSafeInteger(length) || length < 0 || offset + length > data.length)
|
|
29222
|
+
throw new Error("Unsupported Cursor native record");
|
|
29223
|
+
if (wire === 2) {
|
|
29224
|
+
const values = fields.get(field) ?? [];
|
|
29225
|
+
values.push(Buffer.from(data.subarray(offset, offset + length)));
|
|
29226
|
+
fields.set(field, values);
|
|
29227
|
+
}
|
|
29228
|
+
offset += length;
|
|
29229
|
+
}
|
|
29230
|
+
return fields;
|
|
29231
|
+
}
|
|
29232
|
+
function one(fields, field) {
|
|
29233
|
+
const values = fields.get(field);
|
|
29234
|
+
if (values?.length !== 1 || !values[0])
|
|
29235
|
+
throw new Error("Cursor native history identity is missing or ambiguous");
|
|
29236
|
+
return values[0];
|
|
29237
|
+
}
|
|
29238
|
+
function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = false) {
|
|
29239
|
+
const directory = cursorSessionDirectory(sessionId, environment);
|
|
29240
|
+
const filename = path6.join(directory, "store.db");
|
|
29241
|
+
if (allowMissing && !existsSync2(filename))
|
|
29242
|
+
return { revision: void 0, turns: [] };
|
|
29243
|
+
const info = JSON.parse(readFileSync(path6.join(directory, "meta.json"), "utf8"));
|
|
29244
|
+
if (!info || typeof info !== "object" || !("cwd" in info) || typeof info.cwd !== "string" || !cursorSameWorkspace(info.cwd, cwd))
|
|
29245
|
+
throw new Error("Cursor session workspace does not match");
|
|
29246
|
+
const db = new DatabaseSync(filename, { readOnly: true });
|
|
29247
|
+
try {
|
|
29248
|
+
db.exec("BEGIN");
|
|
29249
|
+
const row = db.prepare("SELECT value FROM meta WHERE key = ?").get("0");
|
|
29250
|
+
if (!row && allowMissing)
|
|
29251
|
+
return { revision: void 0, turns: [] };
|
|
29252
|
+
if (typeof row?.value !== "string" || row.value.length > 1e6)
|
|
29253
|
+
throw new Error("Unsupported Cursor native metadata");
|
|
29254
|
+
const metadata = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
|
|
29255
|
+
if (metadata.agentId !== sessionId || typeof metadata.latestRootBlobId !== "string")
|
|
29256
|
+
throw new Error("Cursor native session identity mismatch");
|
|
29257
|
+
const get = (id) => {
|
|
29258
|
+
if (!/^[0-9a-f]{64}$/u.test(id))
|
|
29259
|
+
throw new Error("Invalid Cursor native blob reference");
|
|
29260
|
+
const blob = db.prepare("SELECT data FROM blobs WHERE id = ?").get(id)?.data;
|
|
29261
|
+
if (!(blob instanceof Uint8Array))
|
|
29262
|
+
throw new Error("Cursor native history blob is missing");
|
|
29263
|
+
return protobufBytes(blob);
|
|
29264
|
+
};
|
|
29265
|
+
const root = get(metadata.latestRootBlobId);
|
|
29266
|
+
const result = [];
|
|
29267
|
+
for (const ref of root.get(8) ?? []) {
|
|
29268
|
+
if (ref.length !== 32)
|
|
29269
|
+
throw new Error("Unsupported Cursor turn reference");
|
|
29270
|
+
const container = get(ref.toString("hex"));
|
|
29271
|
+
for (const record3 of container.get(1) ?? []) {
|
|
29272
|
+
const turn = protobufBytes(record3);
|
|
29273
|
+
const user = get(one(turn, 1).toString("hex"));
|
|
29274
|
+
const id = one(user, 2).toString("utf8");
|
|
29275
|
+
if (!/^[0-9a-f-]{36}$/iu.test(id) || result.some((existing) => existing.id === id))
|
|
29276
|
+
throw new Error("Cursor native turn ID is invalid or duplicated");
|
|
29277
|
+
const anchor = user.get(10)?.[0];
|
|
29278
|
+
const rewindRoot = anchor?.length === 32 && db.prepare("SELECT 1 FROM blobs WHERE id = ?").get(anchor.toString("hex")) ? anchor.toString("hex") : void 0;
|
|
29279
|
+
result.push({
|
|
29280
|
+
id,
|
|
29281
|
+
text: one(user, 1).toString("utf8"),
|
|
29282
|
+
...rewindRoot ? { rewindRoot } : {}
|
|
29283
|
+
});
|
|
29284
|
+
}
|
|
29285
|
+
}
|
|
29286
|
+
return { revision: metadata.latestRootBlobId, turns: result };
|
|
29287
|
+
} finally {
|
|
29288
|
+
db.close();
|
|
29289
|
+
}
|
|
29290
|
+
}
|
|
29291
|
+
function readCursorNativeTurns(sessionId, cwd, environment, allowMissing = false) {
|
|
29292
|
+
return readCursorNativeHistory(sessionId, cwd, environment, allowMissing).turns;
|
|
29293
|
+
}
|
|
29294
|
+
|
|
29295
|
+
// dist/session-ref.js
|
|
29296
|
+
var cursorHarnessId = harnessIdSchema.parse("cursor-cli");
|
|
29297
|
+
var cursorSessionLocatorSchema = external_exports.strictObject({
|
|
29298
|
+
executionPolicy: external_exports.enum(["default", "unattended-full-access"])
|
|
29299
|
+
});
|
|
29300
|
+
function cursorNativeSessionRef(nativeSessionId, executionPolicy) {
|
|
29301
|
+
return nativeSessionRefSchema.parse({
|
|
29302
|
+
harnessId: cursorHarnessId,
|
|
29303
|
+
nativeSessionId,
|
|
29304
|
+
locator: { executionPolicy },
|
|
29305
|
+
formatVersion: 1
|
|
29306
|
+
});
|
|
29307
|
+
}
|
|
29308
|
+
function cursorExecutionPolicy(ref) {
|
|
29309
|
+
if (ref.harnessId !== cursorHarnessId || ref.formatVersion !== 1)
|
|
29310
|
+
throw new Error("Invalid Cursor Native Session Ref");
|
|
29311
|
+
if (ref.locator === void 0)
|
|
29312
|
+
return "default";
|
|
29313
|
+
const locator = cursorSessionLocatorSchema.safeParse(ref.locator);
|
|
29314
|
+
if (!locator.success)
|
|
29315
|
+
throw new Error("Invalid Cursor Native Session locator");
|
|
29316
|
+
return locator.data.executionPolicy;
|
|
29317
|
+
}
|
|
29318
|
+
|
|
29319
|
+
// dist/session-import.js
|
|
29320
|
+
var SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
29321
|
+
var MAX_METADATA_BYTES = 1024 * 1024;
|
|
29322
|
+
var CursorSessionChangedError = class extends Error {
|
|
29323
|
+
};
|
|
29324
|
+
function errorCode(error51) {
|
|
29325
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" ? error51.code : void 0;
|
|
29326
|
+
}
|
|
29327
|
+
async function optionalStat(file2) {
|
|
29328
|
+
try {
|
|
29329
|
+
return await lstat(file2);
|
|
29330
|
+
} catch (error51) {
|
|
29331
|
+
if (errorCode(error51) === "ENOENT")
|
|
29332
|
+
return null;
|
|
29333
|
+
throw error51;
|
|
29334
|
+
}
|
|
29335
|
+
}
|
|
29336
|
+
function sameFile(left, right) {
|
|
29337
|
+
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;
|
|
29338
|
+
}
|
|
29339
|
+
var CursorSessionImport = class {
|
|
29340
|
+
#environment;
|
|
29341
|
+
#abort = new AbortController();
|
|
29342
|
+
#pending = /* @__PURE__ */ new Set();
|
|
29343
|
+
constructor(environment) {
|
|
29344
|
+
this.#environment = { ...environment };
|
|
29345
|
+
}
|
|
29346
|
+
listCandidates() {
|
|
29347
|
+
return this.#read(async (signal) => {
|
|
29348
|
+
const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
|
|
29349
|
+
const info = await optionalStat(root);
|
|
29350
|
+
if (!info)
|
|
29351
|
+
return [];
|
|
29352
|
+
if (!info.isDirectory())
|
|
29353
|
+
throw new Error("Cursor ACP store is not a directory");
|
|
29354
|
+
const candidates = [];
|
|
29355
|
+
const entries = await opendir(root);
|
|
29356
|
+
for await (const entry of entries) {
|
|
29357
|
+
signal.throwIfAborted();
|
|
29358
|
+
if (!entry.isDirectory() || !SESSION_ID.test(entry.name))
|
|
29359
|
+
continue;
|
|
29360
|
+
try {
|
|
29361
|
+
const candidate = await this.#candidate(entry.name, signal);
|
|
29362
|
+
if (candidate)
|
|
29363
|
+
candidates.push(candidate);
|
|
29364
|
+
} catch (error51) {
|
|
29365
|
+
if (!(error51 instanceof CursorSessionChangedError))
|
|
29366
|
+
throw error51;
|
|
29367
|
+
}
|
|
29368
|
+
}
|
|
29369
|
+
return candidates;
|
|
29370
|
+
});
|
|
29371
|
+
}
|
|
29372
|
+
async resolveCandidate(nativeSessionId) {
|
|
29373
|
+
if (!SESSION_ID.test(nativeSessionId))
|
|
29374
|
+
return {
|
|
29375
|
+
ok: false,
|
|
29376
|
+
error: {
|
|
29377
|
+
code: "invalidRequest",
|
|
29378
|
+
message: "Invalid Cursor ACP Session ID",
|
|
29379
|
+
retryable: false
|
|
29380
|
+
}
|
|
29381
|
+
};
|
|
29382
|
+
const result = await this.#read((signal) => this.#candidate(nativeSessionId, signal));
|
|
29383
|
+
if (!result.ok)
|
|
29384
|
+
return result;
|
|
29385
|
+
if (!result.value)
|
|
29386
|
+
return {
|
|
29387
|
+
ok: false,
|
|
29388
|
+
error: {
|
|
29389
|
+
code: "sessionNotFound",
|
|
29390
|
+
message: "Cursor ACP Session is no longer importable",
|
|
29391
|
+
retryable: false
|
|
29392
|
+
}
|
|
29393
|
+
};
|
|
29394
|
+
return {
|
|
29395
|
+
ok: true,
|
|
29396
|
+
value: {
|
|
29397
|
+
candidate: result.value,
|
|
29398
|
+
// Native ACP stores do not attest to --force. Imported sessions must not
|
|
29399
|
+
// acquire unattended privileges from UI defaults or a guessed locator.
|
|
29400
|
+
nativeRef: cursorNativeSessionRef(nativeSessionId, "default")
|
|
29401
|
+
}
|
|
29402
|
+
};
|
|
29403
|
+
}
|
|
29404
|
+
async #candidate(id, signal) {
|
|
29405
|
+
signal.throwIfAborted();
|
|
29406
|
+
const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
|
|
29407
|
+
if (!(await optionalStat(root))?.isDirectory())
|
|
29408
|
+
return null;
|
|
29409
|
+
const directory = cursorSessionDirectory(id, this.#environment);
|
|
29410
|
+
const files = [
|
|
29411
|
+
directory,
|
|
29412
|
+
path7.join(directory, "meta.json"),
|
|
29413
|
+
path7.join(directory, "store.db"),
|
|
29414
|
+
path7.join(directory, "store.db-wal")
|
|
29415
|
+
];
|
|
29416
|
+
const before = await Promise.all(files.map(optionalStat));
|
|
29417
|
+
const [folder, metadata, database, wal] = before;
|
|
29418
|
+
if (!folder?.isDirectory() || !metadata?.isFile() || !database?.isFile() || wal && !wal.isFile() || metadata.size > MAX_METADATA_BYTES)
|
|
29419
|
+
return null;
|
|
29420
|
+
let cwd;
|
|
29421
|
+
let title;
|
|
29422
|
+
try {
|
|
29423
|
+
const raw = JSON.parse(await readFile2(files[1], { encoding: "utf8", signal }));
|
|
29424
|
+
if (!raw || typeof raw !== "object" || !("cwd" in raw) || typeof raw.cwd !== "string" || !path7.isAbsolute(raw.cwd) || raw.cwd.includes("\0"))
|
|
29425
|
+
return null;
|
|
29426
|
+
cwd = await realpath(raw.cwd);
|
|
29427
|
+
if (!(await stat(cwd)).isDirectory())
|
|
29428
|
+
return null;
|
|
29429
|
+
signal.throwIfAborted();
|
|
29430
|
+
const turns = readCursorNativeTurns(id, cwd, this.#environment);
|
|
29431
|
+
if (!turns.length)
|
|
29432
|
+
return null;
|
|
29433
|
+
title = turns[0]?.text.replaceAll("\0", "").replace(/\s+/gu, " ").trim().slice(0, HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) || null;
|
|
29434
|
+
} catch (error51) {
|
|
29435
|
+
signal.throwIfAborted();
|
|
29436
|
+
if (["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"].includes(errorCode(error51) ?? ""))
|
|
29437
|
+
throw error51;
|
|
29438
|
+
return null;
|
|
29439
|
+
}
|
|
29440
|
+
signal.throwIfAborted();
|
|
29441
|
+
const after = await Promise.all(files.map(optionalStat));
|
|
29442
|
+
if (before.some((info, index) => !sameFile(info, after[index] ?? null)))
|
|
29443
|
+
throw new CursorSessionChangedError("Cursor Session changed during discovery");
|
|
29444
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
29445
|
+
nativeSessionId: id,
|
|
29446
|
+
cwd,
|
|
29447
|
+
title,
|
|
29448
|
+
updatedAt: Math.floor(Math.max(database.mtimeMs, wal?.mtimeMs ?? 0)),
|
|
29449
|
+
// A stable read does not establish that another Cursor process is idle.
|
|
29450
|
+
running: null
|
|
29451
|
+
});
|
|
29452
|
+
return parsed.success ? parsed.data : null;
|
|
29453
|
+
}
|
|
29454
|
+
#read(operation) {
|
|
29455
|
+
const signal = this.#abort.signal;
|
|
29456
|
+
if (signal.aborted)
|
|
29457
|
+
return Promise.resolve({
|
|
29458
|
+
ok: false,
|
|
29459
|
+
error: {
|
|
29460
|
+
code: "invalidState",
|
|
29461
|
+
message: "Cursor Session import is closed",
|
|
29462
|
+
retryable: false
|
|
29463
|
+
}
|
|
29464
|
+
});
|
|
29465
|
+
const request = operation(signal).then((value) => {
|
|
29466
|
+
signal.throwIfAborted();
|
|
29467
|
+
return { ok: true, value };
|
|
29468
|
+
}).catch(() => ({
|
|
29469
|
+
ok: false,
|
|
29470
|
+
error: {
|
|
29471
|
+
code: signal.aborted ? "invalidState" : "unavailable",
|
|
29472
|
+
message: signal.aborted ? "Cursor Session import is closed" : "Cursor ACP sessions could not be read; close native clients, check storage access and retry",
|
|
29473
|
+
retryable: !signal.aborted
|
|
29474
|
+
}
|
|
29475
|
+
})).finally(() => this.#pending.delete(request));
|
|
29476
|
+
this.#pending.add(request);
|
|
29477
|
+
return request;
|
|
29478
|
+
}
|
|
29479
|
+
async close() {
|
|
29480
|
+
this.#abort.abort();
|
|
29481
|
+
await Promise.allSettled(this.#pending);
|
|
29482
|
+
}
|
|
29483
|
+
};
|
|
29484
|
+
|
|
28516
29485
|
// dist/thinking.js
|
|
28517
29486
|
var choices = (option) => option.type === "select" ? option.options.flatMap((entry) => "value" in entry ? [entry] : entry.options) : [];
|
|
28518
29487
|
function cursorThinking(options) {
|
|
@@ -28553,9 +29522,9 @@ function cursorThinkingState(info) {
|
|
|
28553
29522
|
}
|
|
28554
29523
|
|
|
28555
29524
|
// dist/fork-support.js
|
|
28556
|
-
import { existsSync } from "node:fs";
|
|
29525
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
28557
29526
|
function cursorForkAvailable() {
|
|
28558
|
-
return (process.platform === "darwin" || process.platform === "linux") &&
|
|
29527
|
+
return (process.platform === "darwin" || process.platform === "linux") && existsSync3("/usr/bin/script");
|
|
28559
29528
|
}
|
|
28560
29529
|
function cursorCheckpoint(sessionId, turnId) {
|
|
28561
29530
|
return nativeCheckpointRefSchema.parse({
|
|
@@ -32856,10 +33825,10 @@ var ClientSideConnection = class {
|
|
|
32856
33825
|
};
|
|
32857
33826
|
|
|
32858
33827
|
// dist/delegation-bridge.js
|
|
32859
|
-
import { execFile } from "node:child_process";
|
|
33828
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
32860
33829
|
import { randomBytes } from "node:crypto";
|
|
32861
33830
|
import { createServer } from "node:http";
|
|
32862
|
-
import
|
|
33831
|
+
import path8 from "node:path";
|
|
32863
33832
|
|
|
32864
33833
|
// ../../../node_modules/zod/v3/helpers/util.js
|
|
32865
33834
|
var util;
|
|
@@ -33220,8 +34189,8 @@ function getErrorMap2() {
|
|
|
33220
34189
|
|
|
33221
34190
|
// ../../../node_modules/zod/v3/helpers/parseUtil.js
|
|
33222
34191
|
var makeIssue = (params) => {
|
|
33223
|
-
const { data, path:
|
|
33224
|
-
const fullPath = [...
|
|
34192
|
+
const { data, path: path12, errorMaps, issueData } = params;
|
|
34193
|
+
const fullPath = [...path12, ...issueData.path || []];
|
|
33225
34194
|
const fullIssue = {
|
|
33226
34195
|
...issueData,
|
|
33227
34196
|
path: fullPath
|
|
@@ -33336,11 +34305,11 @@ var errorUtil;
|
|
|
33336
34305
|
|
|
33337
34306
|
// ../../../node_modules/zod/v3/types.js
|
|
33338
34307
|
var ParseInputLazyPath = class {
|
|
33339
|
-
constructor(parent, value,
|
|
34308
|
+
constructor(parent, value, path12, key) {
|
|
33340
34309
|
this._cachedPath = [];
|
|
33341
34310
|
this.parent = parent;
|
|
33342
34311
|
this.data = value;
|
|
33343
|
-
this._path =
|
|
34312
|
+
this._path = path12;
|
|
33344
34313
|
this._key = key;
|
|
33345
34314
|
}
|
|
33346
34315
|
get path() {
|
|
@@ -36867,11 +37836,11 @@ function normalizeObjectSchema(schema) {
|
|
|
36867
37836
|
}
|
|
36868
37837
|
return void 0;
|
|
36869
37838
|
}
|
|
36870
|
-
function getDotPath(
|
|
36871
|
-
if (
|
|
37839
|
+
function getDotPath(path12) {
|
|
37840
|
+
if (path12.length === 0) {
|
|
36872
37841
|
return "object root";
|
|
36873
37842
|
}
|
|
36874
|
-
return
|
|
37843
|
+
return path12.reduce((acc, seg, index) => {
|
|
36875
37844
|
if (index === 0) {
|
|
36876
37845
|
return String(seg);
|
|
36877
37846
|
}
|
|
@@ -44240,7 +45209,7 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44240
45209
|
const runtimeToken = environment.CODEXHOST_RUNTIME_TOKEN;
|
|
44241
45210
|
if (!cli || !environment.CODEXHOST_RUNTIME_ENDPOINT || !runtimeToken || !environment.CODEXHOST_THREAD_ID)
|
|
44242
45211
|
return void 0;
|
|
44243
|
-
if (!
|
|
45212
|
+
if (!path8.isAbsolute(cli))
|
|
44244
45213
|
throw new Error("Cursor delegation requires an absolute Host CLI path");
|
|
44245
45214
|
const token = randomBytes(32).toString("base64url");
|
|
44246
45215
|
const children = /* @__PURE__ */ new Set();
|
|
@@ -44255,7 +45224,7 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44255
45224
|
});
|
|
44256
45225
|
return;
|
|
44257
45226
|
}
|
|
44258
|
-
const child =
|
|
45227
|
+
const child = execFile3(cli, [...args, "--format", "compact"], {
|
|
44259
45228
|
cwd,
|
|
44260
45229
|
env: environment,
|
|
44261
45230
|
windowsHide: true,
|
|
@@ -44395,265 +45364,6 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44395
45364
|
};
|
|
44396
45365
|
}
|
|
44397
45366
|
|
|
44398
|
-
// dist/command.js
|
|
44399
|
-
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
44400
|
-
import path4 from "node:path";
|
|
44401
|
-
|
|
44402
|
-
// ../../harness-discovery/dist/environment.js
|
|
44403
|
-
import fs from "node:fs";
|
|
44404
|
-
import path2 from "node:path";
|
|
44405
|
-
function targetPath(platform) {
|
|
44406
|
-
return platform === "win32" ? path2.win32 : path2.posix;
|
|
44407
|
-
}
|
|
44408
|
-
function environmentValue(environment, name) {
|
|
44409
|
-
const lowered = name.toLowerCase();
|
|
44410
|
-
for (const [key, value] of Object.entries(environment)) {
|
|
44411
|
-
if (key.toLowerCase() === lowered)
|
|
44412
|
-
return value;
|
|
44413
|
-
}
|
|
44414
|
-
return void 0;
|
|
44415
|
-
}
|
|
44416
|
-
function pathDelimiter(platform) {
|
|
44417
|
-
return platform === "win32" ? ";" : ":";
|
|
44418
|
-
}
|
|
44419
|
-
function pathDirectories(environment, platform) {
|
|
44420
|
-
return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
44421
|
-
}
|
|
44422
|
-
function executableExtensions(command, platform, environment) {
|
|
44423
|
-
if (platform !== "win32")
|
|
44424
|
-
return [""];
|
|
44425
|
-
if (targetPath(platform).extname(command) !== "")
|
|
44426
|
-
return [""];
|
|
44427
|
-
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
44428
|
-
}
|
|
44429
|
-
function isExecutableFile(filePath, platform) {
|
|
44430
|
-
try {
|
|
44431
|
-
fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
44432
|
-
return fs.statSync(filePath).isFile();
|
|
44433
|
-
} catch {
|
|
44434
|
-
return false;
|
|
44435
|
-
}
|
|
44436
|
-
}
|
|
44437
|
-
function subdirectoryNames(directory) {
|
|
44438
|
-
try {
|
|
44439
|
-
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
44440
|
-
} catch {
|
|
44441
|
-
return [];
|
|
44442
|
-
}
|
|
44443
|
-
}
|
|
44444
|
-
function newestFirst(names) {
|
|
44445
|
-
return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
|
|
44446
|
-
}
|
|
44447
|
-
|
|
44448
|
-
// ../../harness-discovery/dist/invocation.js
|
|
44449
|
-
import path3 from "node:path";
|
|
44450
|
-
function commandInvocation(command, arguments_, environment, platform = process.platform) {
|
|
44451
|
-
const extension = path3.win32.extname(command).toLowerCase();
|
|
44452
|
-
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
44453
|
-
return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
|
|
44454
|
-
}
|
|
44455
|
-
const quote2 = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
44456
|
-
const commandLine = [command, ...arguments_].map(quote2).join(" ");
|
|
44457
|
-
return {
|
|
44458
|
-
command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
|
|
44459
|
-
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
44460
|
-
windowsVerbatimArguments: true
|
|
44461
|
-
};
|
|
44462
|
-
}
|
|
44463
|
-
|
|
44464
|
-
// ../../harness-discovery/dist/resolve.js
|
|
44465
|
-
import os from "node:os";
|
|
44466
|
-
|
|
44467
|
-
// ../../harness-discovery/dist/version-managers.js
|
|
44468
|
-
function versionManagerBinaryDirectories(context) {
|
|
44469
|
-
const { platform, environment, home } = context;
|
|
44470
|
-
const list = context.subdirectories ?? subdirectoryNames;
|
|
44471
|
-
const pathFlavor = targetPath(platform);
|
|
44472
|
-
const value = (name) => environmentValue(environment, name);
|
|
44473
|
-
const directories = [];
|
|
44474
|
-
const versioned = (root, ...tail) => {
|
|
44475
|
-
for (const version2 of newestFirst(list(root))) {
|
|
44476
|
-
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
44477
|
-
}
|
|
44478
|
-
};
|
|
44479
|
-
if (platform === "win32") {
|
|
44480
|
-
const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
|
|
44481
|
-
const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
|
|
44482
|
-
versioned(pathFlavor.join(appData, "nvm"));
|
|
44483
|
-
versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
|
|
44484
|
-
directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
|
|
44485
|
-
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
44486
|
-
const pnpmHome2 = value("PNPM_HOME");
|
|
44487
|
-
if (pnpmHome2)
|
|
44488
|
-
directories.push(pnpmHome2);
|
|
44489
|
-
directories.push(pathFlavor.join(localAppData, "pnpm"));
|
|
44490
|
-
return directories;
|
|
44491
|
-
}
|
|
44492
|
-
versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
|
|
44493
|
-
const fnmRoots = [
|
|
44494
|
-
value("FNM_DIR"),
|
|
44495
|
-
pathFlavor.join(home, ".local", "share", "fnm"),
|
|
44496
|
-
pathFlavor.join(home, "Library", "Application Support", "fnm")
|
|
44497
|
-
].filter((root) => root !== void 0);
|
|
44498
|
-
for (const root of fnmRoots) {
|
|
44499
|
-
versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
|
|
44500
|
-
}
|
|
44501
|
-
const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
|
|
44502
|
-
versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
|
|
44503
|
-
directories.push(pathFlavor.join(voltaHome, "bin"));
|
|
44504
|
-
const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
|
|
44505
|
-
versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
|
|
44506
|
-
directories.push(pathFlavor.join(asdfHome, "shims"));
|
|
44507
|
-
const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
|
|
44508
|
-
versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
|
|
44509
|
-
directories.push(pathFlavor.join(nodenvHome, "shims"));
|
|
44510
|
-
versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
|
|
44511
|
-
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
44512
|
-
const pnpmHome = value("PNPM_HOME");
|
|
44513
|
-
if (pnpmHome)
|
|
44514
|
-
directories.push(pnpmHome);
|
|
44515
|
-
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
44516
|
-
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
44517
|
-
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
44518
|
-
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
44519
|
-
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
44520
|
-
}
|
|
44521
|
-
}
|
|
44522
|
-
return directories;
|
|
44523
|
-
}
|
|
44524
|
-
|
|
44525
|
-
// ../../harness-discovery/dist/resolve.js
|
|
44526
|
-
var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
44527
|
-
function installRootExtensions(platform) {
|
|
44528
|
-
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
44529
|
-
}
|
|
44530
|
-
function resolveHomeDirectory(input) {
|
|
44531
|
-
return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
|
|
44532
|
-
}
|
|
44533
|
-
function templateVariables(environment, platform, home) {
|
|
44534
|
-
const pathFlavor = targetPath(platform);
|
|
44535
|
-
return {
|
|
44536
|
-
HOME: home,
|
|
44537
|
-
USERPROFILE: home,
|
|
44538
|
-
APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
|
|
44539
|
-
LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
|
|
44540
|
-
};
|
|
44541
|
-
}
|
|
44542
|
-
function joinTemplate(platform, value) {
|
|
44543
|
-
const pathFlavor = targetPath(platform);
|
|
44544
|
-
const segments = value.split("/");
|
|
44545
|
-
const head = segments[0] ?? "";
|
|
44546
|
-
const tail = segments.slice(1);
|
|
44547
|
-
if (head === "")
|
|
44548
|
-
return pathFlavor.join(pathFlavor.sep, ...tail);
|
|
44549
|
-
return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
|
|
44550
|
-
}
|
|
44551
|
-
function expandInstallRoot(template, environment, platform, home) {
|
|
44552
|
-
const variables = templateVariables(environment, platform, home);
|
|
44553
|
-
let unresolved = false;
|
|
44554
|
-
const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
|
|
44555
|
-
const value = variables[name] ?? environmentValue(environment, name);
|
|
44556
|
-
if (value === void 0 || value === "") {
|
|
44557
|
-
unresolved = true;
|
|
44558
|
-
return "";
|
|
44559
|
-
}
|
|
44560
|
-
return value;
|
|
44561
|
-
});
|
|
44562
|
-
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
44563
|
-
}
|
|
44564
|
-
function installRootDirectories(spec, input, dependencies, platform, home) {
|
|
44565
|
-
const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
|
|
44566
|
-
const directories = [];
|
|
44567
|
-
for (const template of templates) {
|
|
44568
|
-
if (template === VERSION_MANAGER_ROOTS) {
|
|
44569
|
-
directories.push(...versionManagerBinaryDirectories({
|
|
44570
|
-
platform,
|
|
44571
|
-
environment: input.environment,
|
|
44572
|
-
home,
|
|
44573
|
-
...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
|
|
44574
|
-
}));
|
|
44575
|
-
continue;
|
|
44576
|
-
}
|
|
44577
|
-
const directory = expandInstallRoot(template, input.environment, platform, home);
|
|
44578
|
-
if (directory !== void 0)
|
|
44579
|
-
directories.push(directory);
|
|
44580
|
-
}
|
|
44581
|
-
return directories;
|
|
44582
|
-
}
|
|
44583
|
-
function harnessCandidates(spec, input, dependencies = {}) {
|
|
44584
|
-
const platform = input.platform ?? process.platform;
|
|
44585
|
-
const pathFlavor = targetPath(platform);
|
|
44586
|
-
const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
|
|
44587
|
-
const command = configured ?? spec.command;
|
|
44588
|
-
if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
44589
|
-
return [{ candidate: command, source: "configured" }];
|
|
44590
|
-
}
|
|
44591
|
-
const candidates = [];
|
|
44592
|
-
const extensions = executableExtensions(command, platform, input.environment);
|
|
44593
|
-
for (const directory of pathDirectories(input.environment, platform)) {
|
|
44594
|
-
for (const extension of extensions) {
|
|
44595
|
-
candidates.push({
|
|
44596
|
-
candidate: pathFlavor.join(directory, command + extension),
|
|
44597
|
-
source: "path"
|
|
44598
|
-
});
|
|
44599
|
-
}
|
|
44600
|
-
}
|
|
44601
|
-
if (configured !== void 0)
|
|
44602
|
-
return candidates;
|
|
44603
|
-
const home = resolveHomeDirectory(input);
|
|
44604
|
-
for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
|
|
44605
|
-
for (const extension of installRootExtensions(platform)) {
|
|
44606
|
-
candidates.push({
|
|
44607
|
-
candidate: pathFlavor.join(directory, spec.command + extension),
|
|
44608
|
-
source: "install-root"
|
|
44609
|
-
});
|
|
44610
|
-
}
|
|
44611
|
-
}
|
|
44612
|
-
return candidates;
|
|
44613
|
-
}
|
|
44614
|
-
function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
44615
|
-
const platform = input.platform ?? process.platform;
|
|
44616
|
-
const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
|
|
44617
|
-
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
44618
|
-
const context = { platform, isExecutable };
|
|
44619
|
-
for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
|
|
44620
|
-
const executable = runnable(candidate, context);
|
|
44621
|
-
if (executable !== void 0 && isExecutable(executable))
|
|
44622
|
-
return { executable, source };
|
|
44623
|
-
}
|
|
44624
|
-
return void 0;
|
|
44625
|
-
}
|
|
44626
|
-
|
|
44627
|
-
// dist/command.js
|
|
44628
|
-
function cursorInvocation(environment, command, args) {
|
|
44629
|
-
const resolution = resolveHarnessExecutable({
|
|
44630
|
-
id: "cursor-cli",
|
|
44631
|
-
command: "cursor-agent",
|
|
44632
|
-
commandEnvironmentVariable: "CODEXHOST_CURSOR_COMMAND",
|
|
44633
|
-
installRoots: {
|
|
44634
|
-
posix: ["~/.local/bin", "/usr/local/bin", "/opt/homebrew/bin"],
|
|
44635
|
-
windows: ["${LOCALAPPDATA}/cursor-agent"]
|
|
44636
|
-
}
|
|
44637
|
-
}, { environment, ...command ? { command } : {} });
|
|
44638
|
-
if (!resolution)
|
|
44639
|
-
throw new Error("Cursor CLI is not installed; install cursor-agent or set CODEXHOST_CURSOR_COMMAND");
|
|
44640
|
-
if (process.platform === "win32" && /\.(cmd|ps1)$/iu.test(resolution.executable)) {
|
|
44641
|
-
const root = path4.dirname(resolution.executable);
|
|
44642
|
-
const versions = path4.join(root, "versions");
|
|
44643
|
-
if (existsSync2(versions)) {
|
|
44644
|
-
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")));
|
|
44645
|
-
if (version2)
|
|
44646
|
-
return {
|
|
44647
|
-
command: path4.join(versions, version2, "node.exe"),
|
|
44648
|
-
arguments: [path4.join(versions, version2, "index.js"), ...args],
|
|
44649
|
-
windowsVerbatimArguments: false
|
|
44650
|
-
};
|
|
44651
|
-
}
|
|
44652
|
-
throw new Error("Cursor Windows launcher has no supported native bundle; configure a native executable");
|
|
44653
|
-
}
|
|
44654
|
-
return commandInvocation(resolution.executable, args, environment);
|
|
44655
|
-
}
|
|
44656
|
-
|
|
44657
45367
|
// dist/transport.js
|
|
44658
45368
|
var CursorTransport = class {
|
|
44659
45369
|
options;
|
|
@@ -44887,124 +45597,6 @@ var CursorTransport = class {
|
|
|
44887
45597
|
}
|
|
44888
45598
|
};
|
|
44889
45599
|
|
|
44890
|
-
// dist/native-history.js
|
|
44891
|
-
import { existsSync as existsSync3, readFileSync, realpathSync } from "node:fs";
|
|
44892
|
-
import os2 from "node:os";
|
|
44893
|
-
import path5 from "node:path";
|
|
44894
|
-
import { DatabaseSync } from "node:sqlite";
|
|
44895
|
-
function cursorConfigDirectory(environment) {
|
|
44896
|
-
const home = environment.HOME ?? environment.USERPROFILE ?? os2.homedir();
|
|
44897
|
-
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");
|
|
44898
|
-
}
|
|
44899
|
-
function cursorSessionDirectory(sessionId, environment) {
|
|
44900
|
-
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId))
|
|
44901
|
-
throw new Error("Unsupported Cursor native session ID");
|
|
44902
|
-
return path5.join(cursorConfigDirectory(environment), "acp-sessions", sessionId);
|
|
44903
|
-
}
|
|
44904
|
-
function cursorSameWorkspace(left, right) {
|
|
44905
|
-
return path5.resolve(left) === path5.resolve(right) || existsSync3(left) && existsSync3(right) && realpathSync(left) === realpathSync(right);
|
|
44906
|
-
}
|
|
44907
|
-
function protobufBytes(data) {
|
|
44908
|
-
if (data.length > 32 * 1024 * 1024)
|
|
44909
|
-
throw new Error("Cursor native record is too large");
|
|
44910
|
-
let offset = 0;
|
|
44911
|
-
const varint = () => {
|
|
44912
|
-
let result = 0;
|
|
44913
|
-
for (let shift = 0; shift < 70; shift += 7) {
|
|
44914
|
-
const value = data[offset++];
|
|
44915
|
-
if (value === void 0)
|
|
44916
|
-
throw new Error("Truncated Cursor native record");
|
|
44917
|
-
result += (value & 127) * 2 ** shift;
|
|
44918
|
-
if (!(value & 128))
|
|
44919
|
-
return result;
|
|
44920
|
-
}
|
|
44921
|
-
throw new Error("Invalid Cursor native varint");
|
|
44922
|
-
};
|
|
44923
|
-
const fields = /* @__PURE__ */ new Map();
|
|
44924
|
-
while (offset < data.length) {
|
|
44925
|
-
const tag = varint();
|
|
44926
|
-
const field = Math.floor(tag / 8), wire = tag % 8;
|
|
44927
|
-
if (!Number.isSafeInteger(tag) || field === 0)
|
|
44928
|
-
throw new Error("Invalid Cursor native field");
|
|
44929
|
-
if (wire === 0) {
|
|
44930
|
-
varint();
|
|
44931
|
-
continue;
|
|
44932
|
-
}
|
|
44933
|
-
const length = wire === 2 ? varint() : wire === 1 ? 8 : wire === 5 ? 4 : -1;
|
|
44934
|
-
if (!Number.isSafeInteger(length) || length < 0 || offset + length > data.length)
|
|
44935
|
-
throw new Error("Unsupported Cursor native record");
|
|
44936
|
-
if (wire === 2) {
|
|
44937
|
-
const values = fields.get(field) ?? [];
|
|
44938
|
-
values.push(Buffer.from(data.subarray(offset, offset + length)));
|
|
44939
|
-
fields.set(field, values);
|
|
44940
|
-
}
|
|
44941
|
-
offset += length;
|
|
44942
|
-
}
|
|
44943
|
-
return fields;
|
|
44944
|
-
}
|
|
44945
|
-
function one(fields, field) {
|
|
44946
|
-
const values = fields.get(field);
|
|
44947
|
-
if (values?.length !== 1 || !values[0])
|
|
44948
|
-
throw new Error("Cursor native history identity is missing or ambiguous");
|
|
44949
|
-
return values[0];
|
|
44950
|
-
}
|
|
44951
|
-
function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = false) {
|
|
44952
|
-
const directory = cursorSessionDirectory(sessionId, environment);
|
|
44953
|
-
const filename = path5.join(directory, "store.db");
|
|
44954
|
-
if (allowMissing && !existsSync3(filename))
|
|
44955
|
-
return { revision: void 0, turns: [] };
|
|
44956
|
-
const info = JSON.parse(readFileSync(path5.join(directory, "meta.json"), "utf8"));
|
|
44957
|
-
if (!info || typeof info !== "object" || !("cwd" in info) || typeof info.cwd !== "string" || !cursorSameWorkspace(info.cwd, cwd))
|
|
44958
|
-
throw new Error("Cursor session workspace does not match");
|
|
44959
|
-
const db = new DatabaseSync(filename, { readOnly: true });
|
|
44960
|
-
try {
|
|
44961
|
-
db.exec("BEGIN");
|
|
44962
|
-
const row = db.prepare("SELECT value FROM meta WHERE key = ?").get("0");
|
|
44963
|
-
if (!row && allowMissing)
|
|
44964
|
-
return { revision: void 0, turns: [] };
|
|
44965
|
-
if (typeof row?.value !== "string" || row.value.length > 1e6)
|
|
44966
|
-
throw new Error("Unsupported Cursor native metadata");
|
|
44967
|
-
const metadata = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
|
|
44968
|
-
if (metadata.agentId !== sessionId || typeof metadata.latestRootBlobId !== "string")
|
|
44969
|
-
throw new Error("Cursor native session identity mismatch");
|
|
44970
|
-
const get = (id) => {
|
|
44971
|
-
if (!/^[0-9a-f]{64}$/u.test(id))
|
|
44972
|
-
throw new Error("Invalid Cursor native blob reference");
|
|
44973
|
-
const blob = db.prepare("SELECT data FROM blobs WHERE id = ?").get(id)?.data;
|
|
44974
|
-
if (!(blob instanceof Uint8Array))
|
|
44975
|
-
throw new Error("Cursor native history blob is missing");
|
|
44976
|
-
return protobufBytes(blob);
|
|
44977
|
-
};
|
|
44978
|
-
const root = get(metadata.latestRootBlobId);
|
|
44979
|
-
const result = [];
|
|
44980
|
-
for (const ref of root.get(8) ?? []) {
|
|
44981
|
-
if (ref.length !== 32)
|
|
44982
|
-
throw new Error("Unsupported Cursor turn reference");
|
|
44983
|
-
const container = get(ref.toString("hex"));
|
|
44984
|
-
for (const record2 of container.get(1) ?? []) {
|
|
44985
|
-
const turn = protobufBytes(record2);
|
|
44986
|
-
const user = get(one(turn, 1).toString("hex"));
|
|
44987
|
-
const id = one(user, 2).toString("utf8");
|
|
44988
|
-
if (!/^[0-9a-f-]{36}$/iu.test(id) || result.some((existing) => existing.id === id))
|
|
44989
|
-
throw new Error("Cursor native turn ID is invalid or duplicated");
|
|
44990
|
-
const anchor = user.get(10)?.[0];
|
|
44991
|
-
const rewindRoot = anchor?.length === 32 && db.prepare("SELECT 1 FROM blobs WHERE id = ?").get(anchor.toString("hex")) ? anchor.toString("hex") : void 0;
|
|
44992
|
-
result.push({
|
|
44993
|
-
id,
|
|
44994
|
-
text: one(user, 1).toString("utf8"),
|
|
44995
|
-
...rewindRoot ? { rewindRoot } : {}
|
|
44996
|
-
});
|
|
44997
|
-
}
|
|
44998
|
-
}
|
|
44999
|
-
return { revision: metadata.latestRootBlobId, turns: result };
|
|
45000
|
-
} finally {
|
|
45001
|
-
db.close();
|
|
45002
|
-
}
|
|
45003
|
-
}
|
|
45004
|
-
function readCursorNativeTurns(sessionId, cwd, environment, allowMissing = false) {
|
|
45005
|
-
return readCursorNativeHistory(sessionId, cwd, environment, allowMissing).turns;
|
|
45006
|
-
}
|
|
45007
|
-
|
|
45008
45600
|
// ../../../node_modules/diff/libesm/diff/base.js
|
|
45009
45601
|
var Diff = class {
|
|
45010
45602
|
diff(oldStr, newStr, options = {}) {
|
|
@@ -45105,16 +45697,16 @@ var Diff = class {
|
|
|
45105
45697
|
}
|
|
45106
45698
|
}
|
|
45107
45699
|
}
|
|
45108
|
-
addToPath(
|
|
45109
|
-
const last =
|
|
45700
|
+
addToPath(path12, added, removed, oldPosInc, options) {
|
|
45701
|
+
const last = path12.lastComponent;
|
|
45110
45702
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
45111
45703
|
return {
|
|
45112
|
-
oldPos:
|
|
45704
|
+
oldPos: path12.oldPos + oldPosInc,
|
|
45113
45705
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
45114
45706
|
};
|
|
45115
45707
|
} else {
|
|
45116
45708
|
return {
|
|
45117
|
-
oldPos:
|
|
45709
|
+
oldPos: path12.oldPos + oldPosInc,
|
|
45118
45710
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
45119
45711
|
};
|
|
45120
45712
|
}
|
|
@@ -45632,6 +46224,42 @@ function cursorChildSnapshot(parentId, item, terminal, output) {
|
|
|
45632
46224
|
};
|
|
45633
46225
|
}
|
|
45634
46226
|
|
|
46227
|
+
// dist/stream-error.js
|
|
46228
|
+
var CLOSED_ERROR = /(?:^|\n\n)Error:\s*(?:(?:RetriableError|T):)?\s*WritableIterable is closed\s*$/u;
|
|
46229
|
+
var CLOSED_PREFIXES = [
|
|
46230
|
+
"\n\nError: RetriableError: WritableIterable is closed",
|
|
46231
|
+
"\n\nError: T: WritableIterable is closed",
|
|
46232
|
+
"\n\nError: WritableIterable is closed",
|
|
46233
|
+
"Error: RetriableError: WritableIterable is closed",
|
|
46234
|
+
"Error: T: WritableIterable is closed",
|
|
46235
|
+
"Error: WritableIterable is closed"
|
|
46236
|
+
];
|
|
46237
|
+
var LONGEST_PREFIX = Math.max(...CLOSED_PREFIXES.map((prefix) => prefix.length));
|
|
46238
|
+
function isCursorWritableIterableClosed(message) {
|
|
46239
|
+
return /WritableIterable is closed/iu.test(message);
|
|
46240
|
+
}
|
|
46241
|
+
function takeCursorWritableIterableClosed(text2, atMessageStart = true) {
|
|
46242
|
+
const match = text2.match(CLOSED_ERROR);
|
|
46243
|
+
if (!match || match.index === void 0 || match.index === 0 && !text2.startsWith("\n\n") && !atMessageStart)
|
|
46244
|
+
return { visible: text2, closed: false };
|
|
46245
|
+
return { visible: text2.slice(0, match.index), closed: true };
|
|
46246
|
+
}
|
|
46247
|
+
function holdCursorWritableIterablePrefix(text2, atMessageStart = true) {
|
|
46248
|
+
const taken = takeCursorWritableIterableClosed(text2, atMessageStart);
|
|
46249
|
+
if (taken.closed)
|
|
46250
|
+
return { emit: taken.visible, hold: text2.slice(taken.visible.length) };
|
|
46251
|
+
for (let size = Math.min(text2.length, LONGEST_PREFIX); size > 0; size -= 1) {
|
|
46252
|
+
const suffix = text2.slice(-size);
|
|
46253
|
+
const start = text2.length - size;
|
|
46254
|
+
if (!suffix.startsWith("\n") && !(start === 0 && atMessageStart) && text2.slice(Math.max(0, start - 2), start) !== "\n\n")
|
|
46255
|
+
continue;
|
|
46256
|
+
if (CLOSED_PREFIXES.some((candidate) => candidate.startsWith(suffix))) {
|
|
46257
|
+
return { emit: text2.slice(0, -size), hold: suffix };
|
|
46258
|
+
}
|
|
46259
|
+
}
|
|
46260
|
+
return { emit: text2, hold: "" };
|
|
46261
|
+
}
|
|
46262
|
+
|
|
45635
46263
|
// dist/projection.js
|
|
45636
46264
|
var TOOL_OUTPUT_LIMIT = 1e5;
|
|
45637
46265
|
function cursorFileChanges(content) {
|
|
@@ -45661,11 +46289,52 @@ var CursorTurnOutput = class {
|
|
|
45661
46289
|
#text;
|
|
45662
46290
|
#tools = /* @__PURE__ */ new Map();
|
|
45663
46291
|
#finishedTools = /* @__PURE__ */ new Set();
|
|
46292
|
+
#hold = "";
|
|
46293
|
+
#writableIterableClosed = false;
|
|
46294
|
+
#visibleAssistantText = false;
|
|
45664
46295
|
constructor(turnId, emit, nativeTurnIndex = 0) {
|
|
45665
46296
|
this.turnId = turnId;
|
|
45666
46297
|
this.emit = emit;
|
|
45667
46298
|
this.subagents = new CursorSubagents(turnId, emit, nativeTurnIndex);
|
|
45668
46299
|
}
|
|
46300
|
+
sawWritableIterableClosed() {
|
|
46301
|
+
return this.#writableIterableClosed || takeCursorWritableIterableClosed(this.#hold).closed;
|
|
46302
|
+
}
|
|
46303
|
+
hasVisibleAssistantText() {
|
|
46304
|
+
return this.#visibleAssistantText || takeCursorWritableIterableClosed(this.#hold).visible.trim().length > 0;
|
|
46305
|
+
}
|
|
46306
|
+
#flushHold() {
|
|
46307
|
+
if (!this.#hold)
|
|
46308
|
+
return;
|
|
46309
|
+
const held = this.#hold;
|
|
46310
|
+
this.#hold = "";
|
|
46311
|
+
this.#appendText("agentMessage", held);
|
|
46312
|
+
}
|
|
46313
|
+
#appendText(type, text2) {
|
|
46314
|
+
if (!text2)
|
|
46315
|
+
return;
|
|
46316
|
+
if (type === "agentMessage" && text2.trim())
|
|
46317
|
+
this.#visibleAssistantText = true;
|
|
46318
|
+
if (this.#text?.type !== type) {
|
|
46319
|
+
this.#finishText();
|
|
46320
|
+
const item = {
|
|
46321
|
+
type,
|
|
46322
|
+
itemId: hostItemIdSchema.parse(`cursor-${this.turnId}-${++this.#index}`),
|
|
46323
|
+
text: ""
|
|
46324
|
+
};
|
|
46325
|
+
this.#text = item;
|
|
46326
|
+
this.emit({ type: "item.started", turnId: this.turnId, item: { ...item } });
|
|
46327
|
+
}
|
|
46328
|
+
if (!this.#text)
|
|
46329
|
+
return;
|
|
46330
|
+
this.#text.text += text2;
|
|
46331
|
+
this.emit({
|
|
46332
|
+
type: "item.updated",
|
|
46333
|
+
turnId: this.turnId,
|
|
46334
|
+
itemId: this.#text.itemId,
|
|
46335
|
+
update: { type: "text.append", text: text2 }
|
|
46336
|
+
});
|
|
46337
|
+
}
|
|
45669
46338
|
#finishText(outcome = { status: "succeeded" }) {
|
|
45670
46339
|
if (this.#text)
|
|
45671
46340
|
this.emit({
|
|
@@ -45677,6 +46346,7 @@ var CursorTurnOutput = class {
|
|
|
45677
46346
|
}
|
|
45678
46347
|
update(notification) {
|
|
45679
46348
|
if (this.subagents.update(notification)) {
|
|
46349
|
+
this.#flushHold();
|
|
45680
46350
|
this.#finishText();
|
|
45681
46351
|
return;
|
|
45682
46352
|
}
|
|
@@ -45685,26 +46355,17 @@ var CursorTurnOutput = class {
|
|
|
45685
46355
|
if (update.content.type !== "text")
|
|
45686
46356
|
return;
|
|
45687
46357
|
const type = update.sessionUpdate === "agent_message_chunk" ? "agentMessage" : "reasoning";
|
|
45688
|
-
if (
|
|
45689
|
-
this.#
|
|
45690
|
-
|
|
45691
|
-
type,
|
|
45692
|
-
itemId: hostItemIdSchema.parse(`cursor-${this.turnId}-${++this.#index}`),
|
|
45693
|
-
text: ""
|
|
45694
|
-
};
|
|
45695
|
-
this.#text = item;
|
|
45696
|
-
this.emit({ type: "item.started", turnId: this.turnId, item: { ...item } });
|
|
45697
|
-
}
|
|
45698
|
-
if (!this.#text)
|
|
46358
|
+
if (type === "reasoning") {
|
|
46359
|
+
this.#flushHold();
|
|
46360
|
+
this.#appendText(type, update.content.text);
|
|
45699
46361
|
return;
|
|
45700
|
-
|
|
45701
|
-
this.
|
|
45702
|
-
|
|
45703
|
-
|
|
45704
|
-
|
|
45705
|
-
update: { type: "text.append", text: update.content.text }
|
|
45706
|
-
});
|
|
46362
|
+
}
|
|
46363
|
+
const combined = `${this.#hold}${update.content.text}`;
|
|
46364
|
+
const { emit, hold } = holdCursorWritableIterablePrefix(combined, this.#text?.type !== "agentMessage" || this.#text.text.length === 0);
|
|
46365
|
+
this.#hold = hold;
|
|
46366
|
+
this.#appendText(type, emit);
|
|
45707
46367
|
} else if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
|
|
46368
|
+
this.#flushHold();
|
|
45708
46369
|
this.#finishText();
|
|
45709
46370
|
if (this.#finishedTools.has(update.toolCallId))
|
|
45710
46371
|
return;
|
|
@@ -45773,6 +46434,11 @@ ${content.newText}`] : []).join("\n");
|
|
|
45773
46434
|
}
|
|
45774
46435
|
finish(outcome) {
|
|
45775
46436
|
this.subagents.finish(outcome);
|
|
46437
|
+
if (takeCursorWritableIterableClosed(this.#hold).closed) {
|
|
46438
|
+
this.#writableIterableClosed = true;
|
|
46439
|
+
this.#hold = "";
|
|
46440
|
+
}
|
|
46441
|
+
this.#flushHold();
|
|
45776
46442
|
this.#finishText(outcome);
|
|
45777
46443
|
for (const { item } of this.#tools.values())
|
|
45778
46444
|
this.emit({
|
|
@@ -45993,36 +46659,12 @@ var CursorInteractions = class {
|
|
|
45993
46659
|
}
|
|
45994
46660
|
};
|
|
45995
46661
|
|
|
45996
|
-
// dist/session-ref.js
|
|
45997
|
-
var cursorHarnessId = harnessIdSchema.parse("cursor-cli");
|
|
45998
|
-
var cursorSessionLocatorSchema = external_exports.strictObject({
|
|
45999
|
-
executionPolicy: external_exports.enum(["default", "unattended-full-access"])
|
|
46000
|
-
});
|
|
46001
|
-
function cursorNativeSessionRef(nativeSessionId, executionPolicy) {
|
|
46002
|
-
return nativeSessionRefSchema.parse({
|
|
46003
|
-
harnessId: cursorHarnessId,
|
|
46004
|
-
nativeSessionId,
|
|
46005
|
-
locator: { executionPolicy },
|
|
46006
|
-
formatVersion: 1
|
|
46007
|
-
});
|
|
46008
|
-
}
|
|
46009
|
-
function cursorExecutionPolicy(ref) {
|
|
46010
|
-
if (ref.harnessId !== cursorHarnessId || ref.formatVersion !== 1)
|
|
46011
|
-
throw new Error("Invalid Cursor Native Session Ref");
|
|
46012
|
-
if (ref.locator === void 0)
|
|
46013
|
-
return "default";
|
|
46014
|
-
const locator = cursorSessionLocatorSchema.safeParse(ref.locator);
|
|
46015
|
-
if (!locator.success)
|
|
46016
|
-
throw new Error("Invalid Cursor Native Session locator");
|
|
46017
|
-
return locator.data.executionPolicy;
|
|
46018
|
-
}
|
|
46019
|
-
|
|
46020
46662
|
// dist/fork.js
|
|
46021
46663
|
import { createHash as createHash2 } from "node:crypto";
|
|
46022
|
-
import { copyFile, mkdir, mkdtemp, readdir, readFile, realpath, rm, writeFile } from "node:fs/promises";
|
|
46664
|
+
import { copyFile, mkdir, mkdtemp as mkdtemp2, readdir, readFile as readFile3, realpath as realpath2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
46023
46665
|
import { readdirSync as readdirSync2 } from "node:fs";
|
|
46024
46666
|
import os3 from "node:os";
|
|
46025
|
-
import
|
|
46667
|
+
import path9 from "node:path";
|
|
46026
46668
|
import { backup, DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
46027
46669
|
|
|
46028
46670
|
// dist/fork-terminal.js
|
|
@@ -46140,16 +46782,16 @@ async function runCursorForkTerminal(options, sessionId, signal, rewind) {
|
|
|
46140
46782
|
|
|
46141
46783
|
// dist/fork.js
|
|
46142
46784
|
async function copySnapshot(source, target) {
|
|
46143
|
-
const db = new DatabaseSync2(
|
|
46785
|
+
const db = new DatabaseSync2(path9.join(source, "store.db"), { readOnly: true });
|
|
46144
46786
|
try {
|
|
46145
|
-
await backup(db,
|
|
46787
|
+
await backup(db, path9.join(target, "store.db"));
|
|
46146
46788
|
} finally {
|
|
46147
46789
|
db.close();
|
|
46148
46790
|
}
|
|
46149
|
-
await copyFile(
|
|
46791
|
+
await copyFile(path9.join(source, "meta.json"), path9.join(target, "meta.json"));
|
|
46150
46792
|
}
|
|
46151
46793
|
function storeIdentity(directory, hashBlobs = true) {
|
|
46152
|
-
const db = new DatabaseSync2(
|
|
46794
|
+
const db = new DatabaseSync2(path9.join(directory, "store.db"), { readOnly: true });
|
|
46153
46795
|
try {
|
|
46154
46796
|
db.exec("BEGIN");
|
|
46155
46797
|
const value = db.prepare("SELECT value FROM meta WHERE key = '0'").get()?.value;
|
|
@@ -46190,21 +46832,21 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46190
46832
|
if (rewindTurn && !rewindTurn.rewindRoot)
|
|
46191
46833
|
throw new Error("Cursor target has no native rewind checkpoint");
|
|
46192
46834
|
const original = storeIdentity(sourceDirectory);
|
|
46193
|
-
const temporary = await
|
|
46835
|
+
const temporary = await mkdtemp2(path9.join(os3.tmpdir(), "codexhost-cursor-fork-"));
|
|
46194
46836
|
let target;
|
|
46195
46837
|
let committed = false;
|
|
46196
46838
|
const discard = async () => {
|
|
46197
46839
|
if (target && !committed)
|
|
46198
|
-
await
|
|
46840
|
+
await rm2(target, { recursive: true, force: true });
|
|
46199
46841
|
};
|
|
46200
46842
|
try {
|
|
46201
46843
|
signal.throwIfAborted();
|
|
46202
|
-
const config2 =
|
|
46844
|
+
const config2 = path9.join(temporary, "config");
|
|
46203
46845
|
await mkdir(config2, { mode: 448 });
|
|
46204
|
-
const nativeConfig =
|
|
46846
|
+
const nativeConfig = path9.join(cursorConfigDirectory(options.environment), "cli-config.json");
|
|
46205
46847
|
let settings = {};
|
|
46206
46848
|
try {
|
|
46207
|
-
const data = JSON.parse(await
|
|
46849
|
+
const data = JSON.parse(await readFile3(nativeConfig, "utf8"));
|
|
46208
46850
|
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
46209
46851
|
throw new Error("Invalid Cursor CLI configuration");
|
|
46210
46852
|
settings = data;
|
|
@@ -46212,9 +46854,9 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46212
46854
|
if (!(error51 instanceof Error && "code" in error51 && error51.code === "ENOENT"))
|
|
46213
46855
|
throw error51;
|
|
46214
46856
|
}
|
|
46215
|
-
await
|
|
46216
|
-
const chats =
|
|
46217
|
-
const copy =
|
|
46857
|
+
await writeFile2(path9.join(config2, "cli-config.json"), JSON.stringify({ ...settings, rewind: true }), { mode: 384 });
|
|
46858
|
+
const chats = path9.join(config2, "chats", createHash2("md5").update(await realpath2(options.cwd)).digest("hex"));
|
|
46859
|
+
const copy = path9.join(chats, source.nativeSessionId);
|
|
46218
46860
|
await mkdir(copy, { recursive: true });
|
|
46219
46861
|
await copySnapshot(sourceDirectory, copy);
|
|
46220
46862
|
if (JSON.stringify(storeIdentity(copy)) !== JSON.stringify(original))
|
|
@@ -46224,14 +46866,14 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46224
46866
|
environment: {
|
|
46225
46867
|
...options.environment,
|
|
46226
46868
|
CURSOR_CONFIG_DIR: config2,
|
|
46227
|
-
CURSOR_DATA_DIR:
|
|
46869
|
+
CURSOR_DATA_DIR: path9.join(temporary, "data")
|
|
46228
46870
|
}
|
|
46229
46871
|
}, source.nativeSessionId, signal, rewindTurn ? {
|
|
46230
46872
|
steps: sourceTurns.slice(retained).filter((turn) => turn.rewindRoot).length,
|
|
46231
46873
|
complete: () => {
|
|
46232
46874
|
const targets = readdirSync2(chats).filter((id) => id !== source.nativeSessionId);
|
|
46233
46875
|
const targetId = targets[0];
|
|
46234
|
-
return targets.length === 1 && !!targetId && storeIdentity(
|
|
46876
|
+
return targets.length === 1 && !!targetId && storeIdentity(path9.join(chats, targetId), false).root === rewindTurn.rewindRoot;
|
|
46235
46877
|
}
|
|
46236
46878
|
} : void 0);
|
|
46237
46879
|
signal.throwIfAborted();
|
|
@@ -46240,7 +46882,7 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46240
46882
|
throw new Error("Cursor fork did not create one independent session");
|
|
46241
46883
|
const sessionId = children[0].name;
|
|
46242
46884
|
const destination = cursorSessionDirectory(sessionId, options.environment);
|
|
46243
|
-
const nativeFork =
|
|
46885
|
+
const nativeFork = path9.join(chats, sessionId);
|
|
46244
46886
|
const forked = storeIdentity(nativeFork);
|
|
46245
46887
|
if (forked.agentId !== sessionId || forked.root !== (rewindTurn?.rewindRoot ?? original.root) || forked.blobs !== original.blobs)
|
|
46246
46888
|
throw new Error("Cursor native fork changed conversation contents or identity");
|
|
@@ -46266,7 +46908,7 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46266
46908
|
throw error51;
|
|
46267
46909
|
} finally {
|
|
46268
46910
|
try {
|
|
46269
|
-
await
|
|
46911
|
+
await rm2(temporary, { recursive: true, force: true });
|
|
46270
46912
|
} catch (error51) {
|
|
46271
46913
|
await discard();
|
|
46272
46914
|
throw error51;
|
|
@@ -46277,6 +46919,13 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46277
46919
|
// dist/adapter.js
|
|
46278
46920
|
function cursorError(error51) {
|
|
46279
46921
|
const message = sanitizeDiagnosticTail(error51 instanceof Error ? error51.message : "Cursor operation failed");
|
|
46922
|
+
if (isCursorWritableIterableClosed(message)) {
|
|
46923
|
+
return {
|
|
46924
|
+
code: "nativeFailure",
|
|
46925
|
+
message: "Cursor stream closed (WritableIterable)",
|
|
46926
|
+
retryable: true
|
|
46927
|
+
};
|
|
46928
|
+
}
|
|
46280
46929
|
const code = /not installed/iu.test(message) ? "notInstalled" : /auth|not logged in|login/iu.test(message) ? "authenticationRequired" : /exited|closed/iu.test(message) ? "processExited" : "protocolError";
|
|
46281
46930
|
return { code, message, retryable: false };
|
|
46282
46931
|
}
|
|
@@ -46295,7 +46944,7 @@ var CursorAdapter = class {
|
|
|
46295
46944
|
try {
|
|
46296
46945
|
cursorTaskAddress(nativeSubagentId);
|
|
46297
46946
|
const session = [...this.#sessions].find((s) => s.transport.sessionId === parent.nativeSessionId);
|
|
46298
|
-
if (session &&
|
|
46947
|
+
if (session && path10.resolve(session.transport.options.cwd) !== path10.resolve(cwd))
|
|
46299
46948
|
return rejected("invalidRequest", "Cursor parent workspace does not match");
|
|
46300
46949
|
const active = session?.subagentSnapshot(nativeSubagentId);
|
|
46301
46950
|
if (active)
|
|
@@ -46328,12 +46977,19 @@ var CursorAdapter = class {
|
|
|
46328
46977
|
#forks = /* @__PURE__ */ new Map();
|
|
46329
46978
|
#inspections = /* @__PURE__ */ new Map();
|
|
46330
46979
|
#closed = false;
|
|
46980
|
+
sessionImport;
|
|
46331
46981
|
constructor(options = {}) {
|
|
46332
46982
|
this.options = options;
|
|
46983
|
+
this.sessionImport = new CursorSessionImport(options.environment ?? process.env);
|
|
46984
|
+
}
|
|
46985
|
+
async inspectAccount() {
|
|
46986
|
+
if (this.#closed)
|
|
46987
|
+
return null;
|
|
46988
|
+
return fetchCursorAccount({ environment: this.options.environment ?? process.env });
|
|
46333
46989
|
}
|
|
46334
46990
|
transportOptions(cwd, environment) {
|
|
46335
46991
|
return {
|
|
46336
|
-
cwd:
|
|
46992
|
+
cwd: path10.resolve(cwd),
|
|
46337
46993
|
environment: { ...this.options.environment ?? process.env, ...environment },
|
|
46338
46994
|
...this.options.command ? { command: this.options.command } : {},
|
|
46339
46995
|
...this.options.timeoutMs ? { timeoutMs: this.options.timeoutMs } : {}
|
|
@@ -46345,7 +47001,7 @@ var CursorAdapter = class {
|
|
|
46345
47001
|
status: "unavailable",
|
|
46346
47002
|
error: { code: "unavailable", message: "Cursor adapter is closed", retryable: false }
|
|
46347
47003
|
};
|
|
46348
|
-
const cwd =
|
|
47004
|
+
const cwd = path10.resolve(input.cwd ?? process.cwd());
|
|
46349
47005
|
const cached2 = this.#inspections.get(cwd);
|
|
46350
47006
|
if (cached2 && (cached2.pending || !input.refresh))
|
|
46351
47007
|
return cached2.result;
|
|
@@ -46547,9 +47203,10 @@ var CursorAdapter = class {
|
|
|
46547
47203
|
}
|
|
46548
47204
|
async close() {
|
|
46549
47205
|
this.#closed = true;
|
|
47206
|
+
const importing = this.sessionImport.close();
|
|
46550
47207
|
for (const controller of this.#forks.keys())
|
|
46551
47208
|
controller.abort();
|
|
46552
|
-
await Promise.allSettled(this.#forks.values());
|
|
47209
|
+
await Promise.allSettled([importing, ...this.#forks.values()]);
|
|
46553
47210
|
await Promise.allSettled([...this.#sessions].map((session) => session.close()));
|
|
46554
47211
|
await Promise.allSettled([...this.#inspections.values()].map((inspection) => inspection.result));
|
|
46555
47212
|
}
|
|
@@ -46778,7 +47435,15 @@ var CursorSession = class {
|
|
|
46778
47435
|
output.subagents.extension(method, params);
|
|
46779
47436
|
}
|
|
46780
47437
|
});
|
|
46781
|
-
|
|
47438
|
+
const streamClosed = output.sawWritableIterableClosed() && !output.hasVisibleAssistantText();
|
|
47439
|
+
outcome = this.#active?.cancelled || result.stopReason === "cancelled" ? { status: "cancelled" } : streamClosed ? {
|
|
47440
|
+
status: "failed",
|
|
47441
|
+
error: {
|
|
47442
|
+
code: "nativeFailure",
|
|
47443
|
+
message: "Cursor stream closed (WritableIterable)",
|
|
47444
|
+
retryable: true
|
|
47445
|
+
}
|
|
47446
|
+
} : result.stopReason === "end_turn" ? { status: "succeeded" } : {
|
|
46782
47447
|
status: "failed",
|
|
46783
47448
|
error: {
|
|
46784
47449
|
code: "nativeFailure",
|
|
@@ -46863,7 +47528,7 @@ var CursorSession = class {
|
|
|
46863
47528
|
|
|
46864
47529
|
// ../../harness-broker/dist/client.js
|
|
46865
47530
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
46866
|
-
import { lstat, readFile as
|
|
47531
|
+
import { lstat as lstat2, readFile as readFile4 } from "node:fs/promises";
|
|
46867
47532
|
import net, {} from "node:net";
|
|
46868
47533
|
|
|
46869
47534
|
// ../../harness-broker/dist/protocol.js
|
|
@@ -46981,24 +47646,25 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
46981
47646
|
|
|
46982
47647
|
// ../../harness-broker/dist/paths.js
|
|
46983
47648
|
import os4 from "node:os";
|
|
46984
|
-
import
|
|
47649
|
+
import path11 from "node:path";
|
|
46985
47650
|
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
46986
47651
|
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
46987
47652
|
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
46988
47653
|
const home = environment.HOME || os4.homedir();
|
|
46989
|
-
return
|
|
47654
|
+
return path11.join(home, ".codexhost", "harness-broker");
|
|
46990
47655
|
}
|
|
46991
47656
|
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
46992
47657
|
harnessPluginIdSchema.parse(harnessId);
|
|
46993
47658
|
if (harnessId !== "claude-code")
|
|
46994
|
-
return
|
|
46995
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ??
|
|
47659
|
+
return path11.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
47660
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path11.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
46996
47661
|
}
|
|
46997
47662
|
|
|
46998
47663
|
// ../../harness-broker/dist/validation.js
|
|
46999
47664
|
var cwdSchema = external_exports.string().min(1).max(16384);
|
|
47000
47665
|
var brokerEnvironmentSchema = external_exports.object({
|
|
47001
47666
|
CODEXHOST_CLI_PATH: external_exports.string().max(16384).optional(),
|
|
47667
|
+
CODEXHOST_CLI_NODE_PATH: external_exports.string().max(16384).optional(),
|
|
47002
47668
|
CODEXHOST_RUNTIME_ENDPOINT: external_exports.string().max(16384).optional(),
|
|
47003
47669
|
CODEXHOST_RUNTIME_TOKEN: external_exports.string().max(16384).optional(),
|
|
47004
47670
|
CODEXHOST_THREAD_ID: external_exports.string().max(256).optional()
|
|
@@ -47146,7 +47812,7 @@ var harnessErrorSchema = external_exports.object({
|
|
|
47146
47812
|
var harnessSessionStateSchema = external_exports.custom((value) => {
|
|
47147
47813
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
47148
47814
|
return false;
|
|
47149
|
-
const
|
|
47815
|
+
const record3 = value;
|
|
47150
47816
|
const allowed = /* @__PURE__ */ new Set([
|
|
47151
47817
|
"nativeRef",
|
|
47152
47818
|
"effectiveModel",
|
|
@@ -47155,12 +47821,12 @@ var harnessSessionStateSchema = external_exports.custom((value) => {
|
|
|
47155
47821
|
"availableThinkingOptions",
|
|
47156
47822
|
"effectivePermissionModeId"
|
|
47157
47823
|
]);
|
|
47158
|
-
if (Object.keys(
|
|
47824
|
+
if (Object.keys(record3).some((key) => !allowed.has(key)))
|
|
47159
47825
|
return false;
|
|
47160
|
-
if (
|
|
47826
|
+
if (record3.nativeRef !== void 0 && !nativeSessionRefSchema.safeParse(record3.nativeRef).success) {
|
|
47161
47827
|
return false;
|
|
47162
47828
|
}
|
|
47163
|
-
const { nativeRef: _nativeRef, ...configuration } =
|
|
47829
|
+
const { nativeRef: _nativeRef, ...configuration } = record3;
|
|
47164
47830
|
void _nativeRef;
|
|
47165
47831
|
return harnessConfigurationStateSchema.safeParse(configuration).success;
|
|
47166
47832
|
});
|
|
@@ -47174,6 +47840,7 @@ var eventKeys = /* @__PURE__ */ new Map([
|
|
|
47174
47840
|
["item.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
|
|
47175
47841
|
["item.updated", /* @__PURE__ */ new Set(["type", "turnId", "itemId", "update"])],
|
|
47176
47842
|
["item.completed", /* @__PURE__ */ new Set(["type", "turnId", "snapshot"])],
|
|
47843
|
+
["item.detached", /* @__PURE__ */ new Set(["type", "turnId", "itemId"])],
|
|
47177
47844
|
["interaction.closed", /* @__PURE__ */ new Set(["type", "interactionId", "turnId", "reason"])],
|
|
47178
47845
|
["turn.completed", /* @__PURE__ */ new Set(["type", "turnId", "nativeTurnRef", "outcome", "completedAtMs"])],
|
|
47179
47846
|
["session.faulted", /* @__PURE__ */ new Set(["type", "error"])]
|
|
@@ -47290,7 +47957,7 @@ function parseSessionMetadata(value) {
|
|
|
47290
47957
|
};
|
|
47291
47958
|
}
|
|
47292
47959
|
async function readDescriptor(descriptorPath) {
|
|
47293
|
-
const metadata = await
|
|
47960
|
+
const metadata = await lstat2(descriptorPath);
|
|
47294
47961
|
if (metadata.isSymbolicLink())
|
|
47295
47962
|
throw new Error("Aqua Harness broker descriptor must not be a symlink");
|
|
47296
47963
|
if (!metadata.isFile())
|
|
@@ -47302,12 +47969,12 @@ async function readDescriptor(descriptorPath) {
|
|
|
47302
47969
|
throw new Error("Aqua Harness broker descriptor belongs to another user");
|
|
47303
47970
|
}
|
|
47304
47971
|
}
|
|
47305
|
-
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await
|
|
47972
|
+
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile4(descriptorPath, "utf8")));
|
|
47306
47973
|
if (process.platform === "darwin" && Buffer.byteLength(descriptor.socketPath) > 103) {
|
|
47307
47974
|
throw new Error("Aqua Harness broker socket path is too long for macOS");
|
|
47308
47975
|
}
|
|
47309
47976
|
if (process.platform !== "win32") {
|
|
47310
|
-
const socket = await
|
|
47977
|
+
const socket = await lstat2(descriptor.socketPath);
|
|
47311
47978
|
if (socket.isSymbolicLink() || !socket.isSocket()) {
|
|
47312
47979
|
throw new Error("Aqua Harness broker endpoint is not a Unix socket");
|
|
47313
47980
|
}
|
|
@@ -47821,6 +48488,7 @@ var BrokeredHarnessAdapter = class {
|
|
|
47821
48488
|
if (this.#forwardEnvironment && input.environment) {
|
|
47822
48489
|
const allowed = [
|
|
47823
48490
|
"CODEXHOST_CLI_PATH",
|
|
48491
|
+
"CODEXHOST_CLI_NODE_PATH",
|
|
47824
48492
|
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
47825
48493
|
"CODEXHOST_RUNTIME_TOKEN",
|
|
47826
48494
|
"CODEXHOST_THREAD_ID"
|
|
@@ -47886,7 +48554,14 @@ function createHarnessAdapter(context) {
|
|
|
47886
48554
|
liveCommandCatalog: true,
|
|
47887
48555
|
environment: { ...context.environment }
|
|
47888
48556
|
});
|
|
47889
|
-
|
|
48557
|
+
const environment = { ...context.environment };
|
|
48558
|
+
return Object.assign(new CursorAdapter({ environment }), {
|
|
48559
|
+
installation: createCursorInstallation(environment),
|
|
48560
|
+
install: createHarnessInstaller(environment, {
|
|
48561
|
+
posix: "https://cursor.com/install",
|
|
48562
|
+
windows: "https://cursor.com/install?win32=true"
|
|
48563
|
+
})
|
|
48564
|
+
});
|
|
47890
48565
|
}
|
|
47891
48566
|
export {
|
|
47892
48567
|
createHarnessAdapter
|