@codexhost/cli-darwin-x64 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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, {
@@ -27294,6 +27661,7 @@ var CONSOLE_HOST_METHODS = Object.freeze([
27294
27661
  "codexhost/harness/display-settings/get",
27295
27662
  "codexhost/harness/display-settings/set",
27296
27663
  "codexhost/harness/inspect",
27664
+ "codexhost/harness/installation",
27297
27665
  "codexhost/harness/launch-settings/get",
27298
27666
  "codexhost/harness/launch-settings/set",
27299
27667
  "codexhost/harness/web-ui/open",
@@ -27940,14 +28308,17 @@ var harnessLaunchSettingsSchema = external_exports.object({
27940
28308
  // ../../shared-contracts/dist/harness-installation.js
27941
28309
  var harnessInstallationParamsSchema = external_exports.object({
27942
28310
  harnessId: harnessIdSchema,
27943
- action: external_exports.enum(["check", "update"])
28311
+ action: external_exports.enum(["check", "update", "install"])
27944
28312
  }).strict();
27945
28313
  var harnessInstallationStateSchema = external_exports.object({
27946
28314
  currentVersion: external_exports.string().min(1).max(128),
27947
28315
  latestVersion: external_exports.string().min(1).max(128),
27948
28316
  updateAvailable: external_exports.boolean(),
27949
28317
  canUpdate: external_exports.boolean(),
27950
- message: external_exports.string().max(2048).optional()
28318
+ // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
28319
+ message: external_exports.string().max(2048).optional(),
28320
+ messageCode: external_exports.string().min(1).max(128).optional(),
28321
+ latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
27951
28322
  }).strict();
27952
28323
 
27953
28324
  // ../../shared-contracts/dist/codex-accounts.js
@@ -28249,6 +28620,38 @@ var updateStatusResultSchema = external_exports.strictObject({
28249
28620
  status: updateStatusSchema.nullable()
28250
28621
  });
28251
28622
 
28623
+ // ../../shared-contracts/dist/remote-runtime.js
28624
+ var remoteUpdatePhaseSchema = external_exports.enum([
28625
+ "idle",
28626
+ "installing",
28627
+ "restarting",
28628
+ "succeeded",
28629
+ "failed"
28630
+ ]);
28631
+ var runtimeStatusSchema = external_exports.object({
28632
+ runningVersion: external_exports.string().nullable(),
28633
+ installedVersion: external_exports.string().nullable(),
28634
+ restartRequired: external_exports.boolean(),
28635
+ remote: external_exports.boolean(),
28636
+ updateSupported: external_exports.boolean(),
28637
+ update: external_exports.object({
28638
+ phase: remoteUpdatePhaseSchema,
28639
+ targetVersion: external_exports.string().nullable(),
28640
+ error: external_exports.string().nullable()
28641
+ })
28642
+ });
28643
+ var remoteUpdateParamsSchema = external_exports.object({
28644
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
28645
+ }).strict();
28646
+ var remoteSshSetupParamsSchema = external_exports.object({
28647
+ hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
28648
+ port: external_exports.number().int().min(1).max(65535).nullable(),
28649
+ identity: external_exports.string().max(4096).nullable(),
28650
+ action: external_exports.enum(["inspect", "install", "update", "repair"]),
28651
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
28652
+ }).strict();
28653
+ var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
28654
+
28252
28655
  // ../../shared-contracts/dist/index.js
28253
28656
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
28254
28657
 
@@ -28587,304 +28990,6 @@ function cursorCommandPrompt(command, catalog) {
28587
28990
  return { ok: true, value: `${descriptor.invocation}${text2 ? ` ${text2}` : ""}` };
28588
28991
  }
28589
28992
 
28590
- // ../../harness-discovery/dist/environment.js
28591
- import fs from "node:fs";
28592
- import path from "node:path";
28593
- function targetPath(platform) {
28594
- return platform === "win32" ? path.win32 : path.posix;
28595
- }
28596
- function environmentValue(environment, name) {
28597
- const lowered = name.toLowerCase();
28598
- for (const [key, value] of Object.entries(environment)) {
28599
- if (key.toLowerCase() === lowered)
28600
- return value;
28601
- }
28602
- return void 0;
28603
- }
28604
- function pathDelimiter(platform) {
28605
- return platform === "win32" ? ";" : ":";
28606
- }
28607
- function pathDirectories(environment, platform) {
28608
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
28609
- }
28610
- function executableExtensions(command, platform, environment) {
28611
- if (platform !== "win32")
28612
- return [""];
28613
- if (targetPath(platform).extname(command) !== "")
28614
- return [""];
28615
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
28616
- }
28617
- function isExecutableFile(filePath, platform) {
28618
- try {
28619
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
28620
- return fs.statSync(filePath).isFile();
28621
- } catch {
28622
- return false;
28623
- }
28624
- }
28625
- function subdirectoryNames(directory) {
28626
- try {
28627
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
28628
- } catch {
28629
- return [];
28630
- }
28631
- }
28632
- function newestFirst(names) {
28633
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
28634
- }
28635
-
28636
- // ../../harness-discovery/dist/invocation.js
28637
- import path2 from "node:path";
28638
- function commandInvocation(command, arguments_, environment, platform = process.platform) {
28639
- const extension = path2.win32.extname(command).toLowerCase();
28640
- if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
28641
- return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
28642
- }
28643
- const quote2 = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
28644
- const commandLine = [command, ...arguments_].map(quote2).join(" ");
28645
- return {
28646
- command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
28647
- arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
28648
- windowsVerbatimArguments: true
28649
- };
28650
- }
28651
-
28652
- // ../../harness-discovery/dist/node-runtime.js
28653
- import path3 from "node:path";
28654
- function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
28655
- const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
28656
- const delimiter = platform === "win32" ? ";" : ":";
28657
- const runtimeDirectory = path3.dirname(runtimeExecutable);
28658
- const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
28659
- const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
28660
- if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
28661
- directories.push(runtimeDirectory);
28662
- }
28663
- return { ...environment, [pathKey]: directories.join(delimiter) };
28664
- }
28665
-
28666
- // ../../harness-discovery/dist/resolve.js
28667
- import os from "node:os";
28668
-
28669
- // ../../harness-discovery/dist/version-managers.js
28670
- function versionManagerBinaryDirectories(context) {
28671
- const { platform, environment, home } = context;
28672
- const list = context.subdirectories ?? subdirectoryNames;
28673
- const pathFlavor = targetPath(platform);
28674
- const value = (name) => environmentValue(environment, name);
28675
- const directories = [];
28676
- const versioned = (root, ...tail) => {
28677
- for (const version2 of newestFirst(list(root))) {
28678
- directories.push(pathFlavor.join(root, version2, ...tail));
28679
- }
28680
- };
28681
- if (platform === "win32") {
28682
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
28683
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
28684
- versioned(pathFlavor.join(appData, "nvm"));
28685
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
28686
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
28687
- directories.push(pathFlavor.join(home, ".bun", "bin"));
28688
- const pnpmHome2 = value("PNPM_HOME");
28689
- if (pnpmHome2)
28690
- directories.push(pnpmHome2);
28691
- directories.push(pathFlavor.join(localAppData, "pnpm"));
28692
- return directories;
28693
- }
28694
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
28695
- const fnmRoots = [
28696
- value("FNM_DIR"),
28697
- pathFlavor.join(home, ".local", "share", "fnm"),
28698
- pathFlavor.join(home, "Library", "Application Support", "fnm")
28699
- ].filter((root) => root !== void 0);
28700
- for (const root of fnmRoots) {
28701
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
28702
- }
28703
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
28704
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
28705
- directories.push(pathFlavor.join(voltaHome, "bin"));
28706
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
28707
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
28708
- directories.push(pathFlavor.join(asdfHome, "shims"));
28709
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
28710
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
28711
- directories.push(pathFlavor.join(nodenvHome, "shims"));
28712
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
28713
- directories.push(pathFlavor.join(home, ".bun", "bin"));
28714
- const pnpmHome = value("PNPM_HOME");
28715
- if (pnpmHome)
28716
- directories.push(pnpmHome);
28717
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
28718
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
28719
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
28720
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
28721
- directories.push(pathFlavor.join(prefix, formula, "bin"));
28722
- }
28723
- }
28724
- return directories;
28725
- }
28726
-
28727
- // ../../harness-discovery/dist/resolve.js
28728
- var VERSION_MANAGER_ROOTS = "<version-managers>";
28729
- function installRootExtensions(platform) {
28730
- return platform === "win32" ? [".exe", ".cmd"] : [""];
28731
- }
28732
- function resolveHomeDirectory(input) {
28733
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
28734
- }
28735
- function templateVariables(environment, platform, home) {
28736
- const pathFlavor = targetPath(platform);
28737
- return {
28738
- HOME: home,
28739
- USERPROFILE: home,
28740
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
28741
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
28742
- };
28743
- }
28744
- function joinTemplate(platform, value) {
28745
- const pathFlavor = targetPath(platform);
28746
- const segments = value.split("/");
28747
- const head = segments[0] ?? "";
28748
- const tail = segments.slice(1);
28749
- if (head === "")
28750
- return pathFlavor.join(pathFlavor.sep, ...tail);
28751
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
28752
- }
28753
- function expandInstallRoot(template, environment, platform, home) {
28754
- const variables = templateVariables(environment, platform, home);
28755
- let unresolved = false;
28756
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
28757
- const value = variables[name] ?? environmentValue(environment, name);
28758
- if (value === void 0 || value === "") {
28759
- unresolved = true;
28760
- return "";
28761
- }
28762
- return value;
28763
- });
28764
- return unresolved ? void 0 : joinTemplate(platform, substituted);
28765
- }
28766
- function installRootDirectories(spec, input, dependencies, platform, home) {
28767
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
28768
- const directories = [];
28769
- for (const template of templates) {
28770
- if (template === VERSION_MANAGER_ROOTS) {
28771
- directories.push(...versionManagerBinaryDirectories({
28772
- platform,
28773
- environment: input.environment,
28774
- home,
28775
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
28776
- }));
28777
- continue;
28778
- }
28779
- const directory = expandInstallRoot(template, input.environment, platform, home);
28780
- if (directory !== void 0)
28781
- directories.push(directory);
28782
- }
28783
- return directories;
28784
- }
28785
- function harnessCandidates(spec, input, dependencies = {}) {
28786
- const platform = input.platform ?? process.platform;
28787
- const pathFlavor = targetPath(platform);
28788
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
28789
- const command = configured ?? spec.command;
28790
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
28791
- return [{ candidate: command, source: "configured" }];
28792
- }
28793
- const candidates = [];
28794
- const extensions = executableExtensions(command, platform, input.environment);
28795
- for (const directory of pathDirectories(input.environment, platform)) {
28796
- for (const extension of extensions) {
28797
- candidates.push({
28798
- candidate: pathFlavor.join(directory, command + extension),
28799
- source: "path"
28800
- });
28801
- }
28802
- }
28803
- if (configured !== void 0)
28804
- return candidates;
28805
- const home = resolveHomeDirectory(input);
28806
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
28807
- for (const extension of installRootExtensions(platform)) {
28808
- candidates.push({
28809
- candidate: pathFlavor.join(directory, spec.command + extension),
28810
- source: "install-root"
28811
- });
28812
- }
28813
- }
28814
- return candidates;
28815
- }
28816
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
28817
- const platform = input.platform ?? process.platform;
28818
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
28819
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
28820
- const context = { platform, isExecutable };
28821
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
28822
- const executable = runnable(candidate, context);
28823
- if (executable !== void 0 && isExecutable(executable))
28824
- return { executable, source };
28825
- }
28826
- return void 0;
28827
- }
28828
-
28829
- // ../../harness-discovery/dist/installation.js
28830
- import { execFile } from "node:child_process";
28831
- import { homedir } from "node:os";
28832
- function runInstallationCommand(command, args, environment, timeout = 3e4) {
28833
- const env = withNodeRuntimeOnPath(environment);
28834
- const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
28835
- return new Promise((resolve, reject) => {
28836
- const child = execFile(invocation.command, invocation.arguments, {
28837
- env,
28838
- cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
28839
- encoding: "utf8",
28840
- timeout,
28841
- killSignal: "SIGKILL",
28842
- maxBuffer: 1024 * 1024,
28843
- windowsHide: true,
28844
- windowsVerbatimArguments: invocation.windowsVerbatimArguments
28845
- }, (error51, stdout, stderr) => {
28846
- if (error51)
28847
- reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
28848
- else
28849
- resolve((stdout || stderr).trim());
28850
- });
28851
- child.stdin?.end();
28852
- });
28853
- }
28854
- function installationVersion(value) {
28855
- if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
28856
- throw new Error("Harness returned an invalid version");
28857
- return value.trim().replace(/^v/, "");
28858
- }
28859
- function createInstallationManager(options) {
28860
- let checking;
28861
- let updating;
28862
- const check2 = () => checking ??= options.check().finally(() => {
28863
- checking = void 0;
28864
- });
28865
- return (action) => {
28866
- if (updating)
28867
- return updating;
28868
- if (action === "check")
28869
- return check2();
28870
- updating = (async () => {
28871
- const before = await check2();
28872
- if (!before.updateAvailable)
28873
- return before;
28874
- if (!before.canUpdate)
28875
- throw new Error(before.message ?? "This installation cannot be updated automatically");
28876
- await options.update(before);
28877
- const after = await check2();
28878
- if (after.currentVersion === before.currentVersion)
28879
- throw new Error("The Harness version did not change; check the native updater and retry");
28880
- return after;
28881
- })().finally(() => {
28882
- updating = void 0;
28883
- });
28884
- return updating;
28885
- };
28886
- }
28887
-
28888
28993
  // dist/command.js
28889
28994
  import { existsSync, readdirSync } from "node:fs";
28890
28995
  import path4 from "node:path";
@@ -29051,6 +29156,99 @@ async function fetchCursorAccount(input = {}) {
29051
29156
  import { lstat, opendir, readFile as readFile2, realpath, stat } from "node:fs/promises";
29052
29157
  import path7 from "node:path";
29053
29158
 
29159
+ // ../../harness-adapter/dist/session-import.js
29160
+ var SessionImportChangedError = class extends Error {
29161
+ constructor(message = "Native Session changed during discovery; refresh and retry") {
29162
+ super(message);
29163
+ this.name = "SessionImportChangedError";
29164
+ }
29165
+ };
29166
+ function isMissingFileError(error51) {
29167
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
29168
+ }
29169
+ function sameFileFingerprint(left, right) {
29170
+ return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
29171
+ }
29172
+ function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
29173
+ if (typeof value !== "string")
29174
+ return null;
29175
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
29176
+ if (!normalized)
29177
+ return null;
29178
+ if (normalized.length <= maxLength)
29179
+ return normalized;
29180
+ const characters = [...normalized];
29181
+ if (characters.length <= maxLength)
29182
+ return normalized;
29183
+ return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
29184
+ }
29185
+ function sessionImportCandidate(input) {
29186
+ const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
29187
+ const parsed = harnessSessionImportCandidateSchema.safeParse({
29188
+ nativeSessionId: input.nativeSessionId,
29189
+ cwd: input.cwd,
29190
+ title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
29191
+ updatedAt: Math.floor(time3),
29192
+ // Unknown must stay unknown; only an explicit boolean is a native statement.
29193
+ running: typeof input.running === "boolean" ? input.running : null
29194
+ });
29195
+ return parsed.success ? parsed.data : null;
29196
+ }
29197
+ var SessionImportScope = class {
29198
+ #abort = new AbortController();
29199
+ #options;
29200
+ #pending = /* @__PURE__ */ new Set();
29201
+ constructor(options) {
29202
+ this.#options = options;
29203
+ }
29204
+ #closed() {
29205
+ return {
29206
+ ok: false,
29207
+ error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
29208
+ };
29209
+ }
29210
+ read(operation) {
29211
+ const signal = this.#abort.signal;
29212
+ if (signal.aborted)
29213
+ return Promise.resolve(this.#closed());
29214
+ let started;
29215
+ try {
29216
+ started = operation(signal);
29217
+ } catch (error51) {
29218
+ started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
29219
+ }
29220
+ const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
29221
+ ok: false,
29222
+ error: {
29223
+ code: "unavailable",
29224
+ message: this.#options.unavailableMessage,
29225
+ retryable: true
29226
+ }
29227
+ }).finally(() => this.#pending.delete(request));
29228
+ this.#pending.add(request);
29229
+ return request;
29230
+ }
29231
+ /** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
29232
+ async resolve(operation) {
29233
+ const result = await this.read(operation);
29234
+ if (!result.ok)
29235
+ return result;
29236
+ return result.value ? { ok: true, value: result.value } : {
29237
+ ok: false,
29238
+ error: {
29239
+ code: "sessionNotFound",
29240
+ message: this.#options.notFoundMessage,
29241
+ retryable: false
29242
+ }
29243
+ };
29244
+ }
29245
+ /** Idempotent. Resolves after every started read has settled. */
29246
+ async close() {
29247
+ this.#abort.abort();
29248
+ await Promise.allSettled(this.#pending);
29249
+ }
29250
+ };
29251
+
29054
29252
  // dist/native-history.js
29055
29253
  import { existsSync as existsSync2, readFileSync, realpathSync } from "node:fs";
29056
29254
  import os2 from "node:os";
@@ -29196,8 +29394,6 @@ function cursorExecutionPolicy(ref) {
29196
29394
  // dist/session-import.js
29197
29395
  var SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
29198
29396
  var MAX_METADATA_BYTES = 1024 * 1024;
29199
- var CursorSessionChangedError = class extends Error {
29200
- };
29201
29397
  function errorCode(error51) {
29202
29398
  return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" ? error51.code : void 0;
29203
29399
  }
@@ -29205,23 +29401,23 @@ async function optionalStat(file2) {
29205
29401
  try {
29206
29402
  return await lstat(file2);
29207
29403
  } catch (error51) {
29208
- if (errorCode(error51) === "ENOENT")
29404
+ if (isMissingFileError(error51))
29209
29405
  return null;
29210
29406
  throw error51;
29211
29407
  }
29212
29408
  }
29213
- function sameFile(left, right) {
29214
- 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;
29215
- }
29216
29409
  var CursorSessionImport = class {
29217
29410
  #environment;
29218
- #abort = new AbortController();
29219
- #pending = /* @__PURE__ */ new Set();
29411
+ #scope = new SessionImportScope({
29412
+ closedMessage: "Cursor Session import is closed",
29413
+ unavailableMessage: "Cursor ACP sessions could not be read; close native clients, check storage access and retry",
29414
+ notFoundMessage: "Cursor ACP Session is no longer importable"
29415
+ });
29220
29416
  constructor(environment) {
29221
29417
  this.#environment = { ...environment };
29222
29418
  }
29223
29419
  listCandidates() {
29224
- return this.#read(async (signal) => {
29420
+ return this.#scope.read(async (signal) => {
29225
29421
  const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
29226
29422
  const info = await optionalStat(root);
29227
29423
  if (!info)
@@ -29239,7 +29435,7 @@ var CursorSessionImport = class {
29239
29435
  if (candidate)
29240
29436
  candidates.push(candidate);
29241
29437
  } catch (error51) {
29242
- if (!(error51 instanceof CursorSessionChangedError))
29438
+ if (!(error51 instanceof SessionImportChangedError))
29243
29439
  throw error51;
29244
29440
  }
29245
29441
  }
@@ -29256,27 +29452,15 @@ var CursorSessionImport = class {
29256
29452
  retryable: false
29257
29453
  }
29258
29454
  };
29259
- const result = await this.#read((signal) => this.#candidate(nativeSessionId, signal));
29260
- if (!result.ok)
29261
- return result;
29262
- if (!result.value)
29263
- return {
29264
- ok: false,
29265
- error: {
29266
- code: "sessionNotFound",
29267
- message: "Cursor ACP Session is no longer importable",
29268
- retryable: false
29269
- }
29270
- };
29271
- return {
29272
- ok: true,
29273
- value: {
29274
- candidate: result.value,
29455
+ return this.#scope.resolve(async (signal) => {
29456
+ const candidate = await this.#candidate(nativeSessionId, signal);
29457
+ return candidate ? {
29458
+ candidate,
29275
29459
  // Native ACP stores do not attest to --force. Imported sessions must not
29276
29460
  // acquire unattended privileges from UI defaults or a guessed locator.
29277
29461
  nativeRef: cursorNativeSessionRef(nativeSessionId, "default")
29278
- }
29279
- };
29462
+ } : null;
29463
+ });
29280
29464
  }
29281
29465
  async #candidate(id, signal) {
29282
29466
  signal.throwIfAborted();
@@ -29307,7 +29491,7 @@ var CursorSessionImport = class {
29307
29491
  const turns = readCursorNativeTurns(id, cwd, this.#environment);
29308
29492
  if (!turns.length)
29309
29493
  return null;
29310
- title = turns[0]?.text.replaceAll("\0", "").replace(/\s+/gu, " ").trim().slice(0, HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) || null;
29494
+ title = sessionImportTitle(turns[0]?.text);
29311
29495
  } catch (error51) {
29312
29496
  signal.throwIfAborted();
29313
29497
  if (["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"].includes(errorCode(error51) ?? ""))
@@ -29316,46 +29500,17 @@ var CursorSessionImport = class {
29316
29500
  }
29317
29501
  signal.throwIfAborted();
29318
29502
  const after = await Promise.all(files.map(optionalStat));
29319
- if (before.some((info, index) => !sameFile(info, after[index] ?? null)))
29320
- throw new CursorSessionChangedError("Cursor Session changed during discovery");
29321
- const parsed = harnessSessionImportCandidateSchema.safeParse({
29503
+ if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
29504
+ throw new SessionImportChangedError("Cursor Session changed during discovery");
29505
+ return sessionImportCandidate({
29322
29506
  nativeSessionId: id,
29323
29507
  cwd,
29324
29508
  title,
29325
- updatedAt: Math.floor(Math.max(database.mtimeMs, wal?.mtimeMs ?? 0)),
29326
- // A stable read does not establish that another Cursor process is idle.
29327
- running: null
29509
+ updatedAt: Math.max(database.mtimeMs, wal?.mtimeMs ?? 0)
29328
29510
  });
29329
- return parsed.success ? parsed.data : null;
29330
- }
29331
- #read(operation) {
29332
- const signal = this.#abort.signal;
29333
- if (signal.aborted)
29334
- return Promise.resolve({
29335
- ok: false,
29336
- error: {
29337
- code: "invalidState",
29338
- message: "Cursor Session import is closed",
29339
- retryable: false
29340
- }
29341
- });
29342
- const request = operation(signal).then((value) => {
29343
- signal.throwIfAborted();
29344
- return { ok: true, value };
29345
- }).catch(() => ({
29346
- ok: false,
29347
- error: {
29348
- code: signal.aborted ? "invalidState" : "unavailable",
29349
- message: signal.aborted ? "Cursor Session import is closed" : "Cursor ACP sessions could not be read; close native clients, check storage access and retry",
29350
- retryable: !signal.aborted
29351
- }
29352
- })).finally(() => this.#pending.delete(request));
29353
- this.#pending.add(request);
29354
- return request;
29355
29511
  }
29356
- async close() {
29357
- this.#abort.abort();
29358
- await Promise.allSettled(this.#pending);
29512
+ close() {
29513
+ return this.#scope.close();
29359
29514
  }
29360
29515
  };
29361
29516
 
@@ -46538,7 +46693,7 @@ var CursorInteractions = class {
46538
46693
 
46539
46694
  // dist/fork.js
46540
46695
  import { createHash as createHash2 } from "node:crypto";
46541
- import { copyFile, mkdir, mkdtemp, readdir, readFile as readFile3, realpath as realpath2, rm, writeFile } from "node:fs/promises";
46696
+ import { copyFile, mkdir, mkdtemp as mkdtemp2, readdir, readFile as readFile3, realpath as realpath2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
46542
46697
  import { readdirSync as readdirSync2 } from "node:fs";
46543
46698
  import os3 from "node:os";
46544
46699
  import path9 from "node:path";
@@ -46709,12 +46864,12 @@ async function forkCursorSession(source, checkpoint, options, signal) {
46709
46864
  if (rewindTurn && !rewindTurn.rewindRoot)
46710
46865
  throw new Error("Cursor target has no native rewind checkpoint");
46711
46866
  const original = storeIdentity(sourceDirectory);
46712
- const temporary = await mkdtemp(path9.join(os3.tmpdir(), "codexhost-cursor-fork-"));
46867
+ const temporary = await mkdtemp2(path9.join(os3.tmpdir(), "codexhost-cursor-fork-"));
46713
46868
  let target;
46714
46869
  let committed = false;
46715
46870
  const discard = async () => {
46716
46871
  if (target && !committed)
46717
- await rm(target, { recursive: true, force: true });
46872
+ await rm2(target, { recursive: true, force: true });
46718
46873
  };
46719
46874
  try {
46720
46875
  signal.throwIfAborted();
@@ -46731,7 +46886,7 @@ async function forkCursorSession(source, checkpoint, options, signal) {
46731
46886
  if (!(error51 instanceof Error && "code" in error51 && error51.code === "ENOENT"))
46732
46887
  throw error51;
46733
46888
  }
46734
- await writeFile(path9.join(config2, "cli-config.json"), JSON.stringify({ ...settings, rewind: true }), { mode: 384 });
46889
+ await writeFile2(path9.join(config2, "cli-config.json"), JSON.stringify({ ...settings, rewind: true }), { mode: 384 });
46735
46890
  const chats = path9.join(config2, "chats", createHash2("md5").update(await realpath2(options.cwd)).digest("hex"));
46736
46891
  const copy = path9.join(chats, source.nativeSessionId);
46737
46892
  await mkdir(copy, { recursive: true });
@@ -46785,7 +46940,7 @@ async function forkCursorSession(source, checkpoint, options, signal) {
46785
46940
  throw error51;
46786
46941
  } finally {
46787
46942
  try {
46788
- await rm(temporary, { recursive: true, force: true });
46943
+ await rm2(temporary, { recursive: true, force: true });
46789
46944
  } catch (error51) {
46790
46945
  await discard();
46791
46946
  throw error51;
@@ -48328,7 +48483,11 @@ function createHarnessAdapter(context) {
48328
48483
  });
48329
48484
  const environment = { ...context.environment };
48330
48485
  return Object.assign(new CursorAdapter({ environment }), {
48331
- installation: createCursorInstallation(environment)
48486
+ installation: createCursorInstallation(environment),
48487
+ install: createHarnessInstaller(environment, {
48488
+ posix: "https://cursor.com/install",
48489
+ windows: "https://cursor.com/install?win32=true"
48490
+ })
48332
48491
  });
48333
48492
  }
48334
48493
  export {