@get-bb/plugin-sdk 0.6.79 → 0.6.89

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.
@@ -509,7 +509,7 @@ var require_parse = __commonJS({
509
509
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js"(exports, module) {
510
510
  "use strict";
511
511
  var SemVer = require_semver();
512
- var parse = (version, options, throwErrors = false) => {
512
+ var parse2 = (version, options, throwErrors = false) => {
513
513
  if (version instanceof SemVer) {
514
514
  return version;
515
515
  }
@@ -522,7 +522,7 @@ var require_parse = __commonJS({
522
522
  throw er;
523
523
  }
524
524
  };
525
- module.exports = parse;
525
+ module.exports = parse2;
526
526
  }
527
527
  });
528
528
 
@@ -530,9 +530,9 @@ var require_parse = __commonJS({
530
530
  var require_valid = __commonJS({
531
531
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js"(exports, module) {
532
532
  "use strict";
533
- var parse = require_parse();
533
+ var parse2 = require_parse();
534
534
  var valid = (version, options) => {
535
- const v = parse(version, options);
535
+ const v = parse2(version, options);
536
536
  return v ? v.version : null;
537
537
  };
538
538
  module.exports = valid;
@@ -3826,11 +3826,11 @@ function describeResultContentBlock(block) {
3826
3826
  if (!type) {
3827
3827
  return null;
3828
3828
  }
3829
- const path13 = getStringProperty(block, "path");
3829
+ const path12 = getStringProperty(block, "path");
3830
3830
  const toolName = getStringProperty(block, "tool_name");
3831
3831
  const url2 = getStringProperty(block, "url") ?? getStringProperty(block, "imageUrl");
3832
- if (path13) {
3833
- return `[${type}: ${path13}]`;
3832
+ if (path12) {
3833
+ return `[${type}: ${path12}]`;
3834
3834
  }
3835
3835
  if (toolName) {
3836
3836
  return `[${type}: ${toolName}]`;
@@ -4322,9 +4322,9 @@ function presentationTitle(text) {
4322
4322
  function withTitle(presentation, title) {
4323
4323
  return title === void 0 ? presentation : { ...presentation, title };
4324
4324
  }
4325
- function presentationFileName(path13) {
4326
- const segments = path13.split("/").filter((segment) => segment.length > 0);
4327
- return segments[segments.length - 1] ?? path13;
4325
+ function presentationFileName(path12) {
4326
+ const segments = path12.split("/").filter((segment) => segment.length > 0);
4327
+ return segments[segments.length - 1] ?? path12;
4328
4328
  }
4329
4329
  var COMPACTION_PRESENTATION = {
4330
4330
  label: { pending: "Compacting context", completed: "Compacted context" },
@@ -4334,13 +4334,13 @@ var REASONING_PRESENTATION = {
4334
4334
  label: { pending: "Thinking", completed: "Thought" },
4335
4335
  icon: { glyph: "Brain" }
4336
4336
  };
4337
- function fileReadPresentation(path13) {
4337
+ function fileReadPresentation(path12) {
4338
4338
  return withTitle(
4339
4339
  {
4340
4340
  label: { pending: "Reading file", completed: "Read file" },
4341
4341
  icon: { glyph: "FileText" }
4342
4342
  },
4343
- presentationTitle(presentationFileName(path13))
4343
+ presentationTitle(presentationFileName(path12))
4344
4344
  );
4345
4345
  }
4346
4346
  function searchPresentation(args) {
@@ -4387,10 +4387,556 @@ function experimental_defineProviderBridge(definition) {
4387
4387
  return { experimental_apiVersion: 1, ...definition };
4388
4388
  }
4389
4389
 
4390
- // ../process-utils/src/spawn.ts
4390
+ // ../process-utils/src/host-process.ts
4391
+ import parse from "cross-spawn/lib/parse.js";
4392
+ import {
4393
+ spawn as nodeSpawn,
4394
+ fork as nodeFork,
4395
+ execFile as nodeExecFile
4396
+ } from "node:child_process";
4391
4397
  import crossSpawn from "cross-spawn";
4398
+
4399
+ // ../process-utils/src/host-toolchain.ts
4400
+ import { spawn, spawnSync } from "node:child_process";
4401
+ import {
4402
+ accessSync,
4403
+ constants,
4404
+ existsSync,
4405
+ readdirSync,
4406
+ realpathSync,
4407
+ statSync
4408
+ } from "node:fs";
4409
+ import { createRequire } from "node:module";
4410
+ import { homedir } from "node:os";
4411
+ import {
4412
+ basename,
4413
+ delimiter,
4414
+ dirname,
4415
+ extname as extname2,
4416
+ isAbsolute,
4417
+ join as join2
4418
+ } from "node:path";
4419
+ import { fileURLToPath } from "node:url";
4420
+
4421
+ // ../../node_modules/.pnpm/which-command@0.1.0/node_modules/which-command/index.js
4422
+ import fs from "node:fs";
4423
+ import path from "node:path";
4424
+ import process2 from "node:process";
4425
+ var isWindows = process2.platform === "win32";
4426
+ var separatorPattern = isWindows ? new RegExp("[\\/\\\\]", "v") : new RegExp("\\/", "v");
4427
+ var defaultPathExt = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC";
4428
+ function resolveOptions(command, options) {
4429
+ if (typeof command !== "string" || command.length === 0) {
4430
+ throw new TypeError("Expected a non-empty string.");
4431
+ }
4432
+ const {
4433
+ cwd = process2.cwd(),
4434
+ // On Windows, `process.env.PATH` can be undefined in some contexts (for example, worker threads), where it's only exposed as `Path`.
4435
+ path: searchPath = process2.env.PATH ?? (isWindows ? process2.env.Path : void 0) ?? "",
4436
+ // `||` (not `??`) so an empty `PATHEXT` falls back to the default instead of disabling all lookup on Windows.
4437
+ pathExt = process2.env.PATHEXT || defaultPathExt
4438
+ } = options;
4439
+ return { cwd, searchPath, pathExt };
4440
+ }
4441
+ function windowsExtensions(command, pathExt) {
4442
+ const extensions = pathExt.split(path.delimiter).filter(Boolean);
4443
+ const commandExtension = path.extname(command).toLowerCase();
4444
+ if (commandExtension !== "" && extensions.some((extension) => extension.toLowerCase() === commandExtension)) {
4445
+ return ["", ...extensions];
4446
+ }
4447
+ return extensions;
4448
+ }
4449
+ function* candidatePaths(command, { cwd, searchPath, pathExt }) {
4450
+ const extensions = isWindows ? windowsExtensions(command, pathExt) : [""];
4451
+ if (separatorPattern.test(command)) {
4452
+ const base = path.resolve(cwd, command);
4453
+ for (const extension of extensions) {
4454
+ yield base + extension;
4455
+ }
4456
+ return;
4457
+ }
4458
+ const directories = [
4459
+ // Windows searches the current directory before `PATH`.
4460
+ ...isWindows ? [cwd] : [],
4461
+ ...searchPath.split(path.delimiter)
4462
+ ];
4463
+ for (const directory of directories) {
4464
+ const unquoted = isWindows && directory.length > 1 && directory.startsWith('"') && directory.endsWith('"') ? directory.slice(1, -1) : directory;
4465
+ if (unquoted === "") {
4466
+ continue;
4467
+ }
4468
+ const base = path.resolve(cwd, unquoted, command);
4469
+ for (const extension of extensions) {
4470
+ yield base + extension;
4471
+ }
4472
+ }
4473
+ }
4474
+ function isExecutableSync(filePath) {
4475
+ let stats;
4476
+ try {
4477
+ stats = fs.statSync(filePath);
4478
+ } catch (error) {
4479
+ return isWindows && error.code === "EACCES";
4480
+ }
4481
+ if (!stats.isFile()) {
4482
+ return false;
4483
+ }
4484
+ if (isWindows) {
4485
+ return true;
4486
+ }
4487
+ try {
4488
+ fs.accessSync(filePath, fs.constants.X_OK);
4489
+ return true;
4490
+ } catch {
4491
+ return false;
4492
+ }
4493
+ }
4494
+ function whichCommandSync(command, options = {}) {
4495
+ const resolved = resolveOptions(command, options);
4496
+ for (const candidate of candidatePaths(command, resolved)) {
4497
+ if (isExecutableSync(candidate)) {
4498
+ return candidate;
4499
+ }
4500
+ }
4501
+ return void 0;
4502
+ }
4503
+
4504
+ // ../process-utils/src/host-toolchain.ts
4505
+ var NETWORK_KEYS = [
4506
+ "HTTP_PROXY",
4507
+ "HTTPS_PROXY",
4508
+ "NO_PROXY",
4509
+ "http_proxy",
4510
+ "https_proxy",
4511
+ "no_proxy",
4512
+ "NODE_EXTRA_CA_CERTS",
4513
+ "SSL_CERT_FILE",
4514
+ "SSL_CERT_DIR"
4515
+ ];
4516
+ var SHELL_START = "__BB_SHELL_ENV_START__";
4517
+ var SHELL_END = "__BB_SHELL_ENV_END__";
4518
+ var PROBE_TIMEOUT_MS = 3e3;
4519
+ var PROBE_OUTPUT_MAX_CHARS = 1024 * 1024;
4520
+ function executable(file) {
4521
+ try {
4522
+ accessSync(
4523
+ file,
4524
+ process.platform === "win32" ? constants.F_OK : constants.X_OK
4525
+ );
4526
+ return statSync(file).isFile();
4527
+ } catch {
4528
+ return false;
4529
+ }
4530
+ }
4531
+ function envValue(env, key) {
4532
+ if (process.platform !== "win32") return env[key];
4533
+ return env[Object.keys(env).find(
4534
+ (entry) => entry.toUpperCase() === key.toUpperCase()
4535
+ ) ?? key];
4536
+ }
4537
+ function mergePath(...paths) {
4538
+ const seen = /* @__PURE__ */ new Set();
4539
+ return paths.flatMap((value) => (value ?? "").split(delimiter)).filter((entry) => {
4540
+ if (!entry) return false;
4541
+ const key = process.platform === "win32" ? entry.replace(/[\\/]+$/u, "").toLowerCase() : entry;
4542
+ if (seen.has(key)) return false;
4543
+ seen.add(key);
4544
+ return true;
4545
+ }).join(delimiter);
4546
+ }
4547
+ function onDiskName(file) {
4548
+ if (process.platform !== "win32") return file;
4549
+ try {
4550
+ const name = basename(file).toLowerCase();
4551
+ const entry = readdirSync(dirname(file)).find(
4552
+ (candidate) => candidate.toLowerCase() === name
4553
+ );
4554
+ return entry === void 0 ? file : join2(dirname(file), entry);
4555
+ } catch {
4556
+ return file;
4557
+ }
4558
+ }
4559
+ function runProbe(command, args, env) {
4560
+ return new Promise((resolve5) => {
4561
+ let stdout = "";
4562
+ let settled = false;
4563
+ let timer;
4564
+ const finish = (status) => {
4565
+ if (settled) return;
4566
+ settled = true;
4567
+ clearTimeout(timer);
4568
+ resolve5({ status, stdout });
4569
+ };
4570
+ let child;
4571
+ try {
4572
+ child = spawn(command, args, {
4573
+ cwd: homedir(),
4574
+ env,
4575
+ stdio: ["ignore", "pipe", "ignore"],
4576
+ windowsHide: true
4577
+ });
4578
+ } catch {
4579
+ finish(null);
4580
+ return;
4581
+ }
4582
+ timer = setTimeout(() => {
4583
+ child.kill("SIGKILL");
4584
+ finish(null);
4585
+ }, PROBE_TIMEOUT_MS);
4586
+ child.stdout?.setEncoding("utf8");
4587
+ child.stdout?.on("data", (chunk) => {
4588
+ if (stdout.length < PROBE_OUTPUT_MAX_CHARS) stdout += chunk;
4589
+ });
4590
+ child.once("error", () => finish(null));
4591
+ child.once("close", (code) => finish(code));
4592
+ });
4593
+ }
4594
+ async function readShellEnvironment(env, retainPrevious) {
4595
+ if (process.platform === "win32") {
4596
+ const registry2 = join2(
4597
+ envValue(env, "SystemRoot") ?? "C:\\Windows",
4598
+ "System32",
4599
+ "reg.exe"
4600
+ );
4601
+ const values = { ...env };
4602
+ const paths = [];
4603
+ for (const key of [
4604
+ "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
4605
+ "HKCU\\Environment"
4606
+ ]) {
4607
+ const result = await runProbe(registry2, ["query", key], env);
4608
+ if (result.status !== 0) continue;
4609
+ for (const match of result.stdout.matchAll(
4610
+ /^ {4}(.+?) {4}REG_[A-Z_]+ {4}(.*)$/gmu
4611
+ )) {
4612
+ const name = match[1]?.trim();
4613
+ if (!name) continue;
4614
+ const value = (match[2] ?? "").trim();
4615
+ if (name.toUpperCase() === "PATH") paths.push(value);
4616
+ else {
4617
+ const existing = Object.keys(values).find(
4618
+ (key2) => key2.toUpperCase() === name.toUpperCase()
4619
+ );
4620
+ values[existing ?? name] = value;
4621
+ }
4622
+ }
4623
+ }
4624
+ const expand = (value) => {
4625
+ for (let depth = 0; depth < 10; depth += 1) {
4626
+ const expanded = value.replace(
4627
+ /%([^%;\\/]+)%/gu,
4628
+ (reference, variable) => envValue(values, variable) ?? reference
4629
+ );
4630
+ if (expanded === value) break;
4631
+ value = expanded;
4632
+ }
4633
+ return value;
4634
+ };
4635
+ return paths.length === 0 ? null : { PATH: mergePath(...paths.map(expand), envValue(env, "PATH")) };
4636
+ }
4637
+ const shell = env.SHELL?.trim() || (process.platform === "darwin" ? "/bin/zsh" : "/bin/sh");
4638
+ const command = `printf '%s\\n' ${SHELL_START}; /usr/bin/env; printf '%s\\n' ${SHELL_END}`;
4639
+ const shellArgs = ["sh", "dash"].includes(basename(shell)) ? ["-lc"] : ["-ilc", "-lc"];
4640
+ for (const arg of shellArgs) {
4641
+ const result = await runProbe(shell, [arg, command], env);
4642
+ if (result.status !== 0) {
4643
+ if (retainPrevious) return null;
4644
+ continue;
4645
+ }
4646
+ const start = result.stdout.indexOf(`${SHELL_START}
4647
+ `);
4648
+ const end = result.stdout.indexOf(`
4649
+ ${SHELL_END}`, start);
4650
+ if (start < 0 || end < 0) {
4651
+ if (retainPrevious) return null;
4652
+ continue;
4653
+ }
4654
+ const values = {};
4655
+ for (const line of result.stdout.slice(start + SHELL_START.length + 1, end).split("\n")) {
4656
+ const separator = line.indexOf("=");
4657
+ const key = line.slice(0, separator);
4658
+ if (key === "PATH" || NETWORK_KEYS.includes(key))
4659
+ values[key] = line.slice(separator + 1);
4660
+ }
4661
+ if (values.PATH) return values;
4662
+ }
4663
+ return null;
4664
+ }
4665
+ var HostToolchain = class {
4666
+ constructor(baseEnv = process.env, runtimePath = process.execPath) {
4667
+ this.baseEnv = baseEnv;
4668
+ this.runtimePath = runtimePath;
4669
+ this.inheritedPath = envValue(baseEnv, "PATH");
4670
+ this.nodePath = runtimePath;
4671
+ }
4672
+ baseEnv;
4673
+ runtimePath;
4674
+ shellEnv = {};
4675
+ inheritedPath;
4676
+ misses = /* @__PURE__ */ new Set();
4677
+ nodePath;
4678
+ refreshing = null;
4679
+ refreshedAt = 0;
4680
+ refresh() {
4681
+ if (this.refreshing !== null) return this.refreshing;
4682
+ this.misses.clear();
4683
+ this.refreshedAt = Date.now();
4684
+ const retainPrevious = this.shellEnv.PATH !== void 0;
4685
+ this.refreshing = readShellEnvironment(this.baseEnv, retainPrevious).then((env) => {
4686
+ if (env !== null) this.shellEnv = env;
4687
+ }).finally(() => {
4688
+ this.refreshing = null;
4689
+ });
4690
+ return this.refreshing;
4691
+ }
4692
+ invalidateFailure(errorOrCode) {
4693
+ const code = typeof errorOrCode === "object" && errorOrCode !== null && "code" in errorOrCode ? errorOrCode.code : errorOrCode;
4694
+ if (code === "ENOENT" || code === 127) void this.refresh();
4695
+ }
4696
+ searchPath(env) {
4697
+ const inherited = envValue(env, "PATH");
4698
+ const home = envValue(env, process.platform === "win32" ? "USERPROFILE" : "HOME") ?? homedir();
4699
+ const fallbacks = [
4700
+ join2(home, ".local", "bin"),
4701
+ join2(home, ".local", "share", "mise", "shims"),
4702
+ join2(home, ".asdf", "shims"),
4703
+ join2(home, ".asdf", "bin"),
4704
+ join2(home, ".volta", "bin")
4705
+ ];
4706
+ if (process.platform === "darwin") fallbacks.push("/opt/homebrew/bin");
4707
+ if (process.platform !== "win32")
4708
+ fallbacks.push("/usr/local/bin", "/usr/bin", "/bin");
4709
+ const [first, second] = inherited === void 0 || inherited === this.inheritedPath ? [this.shellEnv.PATH, inherited] : [inherited, this.shellEnv.PATH];
4710
+ return mergePath(
4711
+ first,
4712
+ second,
4713
+ executable(this.nodePath) && /^node(?:\.exe)?$/iu.test(basename(this.nodePath)) ? dirname(this.nodePath) : void 0,
4714
+ ...fallbacks
4715
+ );
4716
+ }
4717
+ environment(env = this.baseEnv) {
4718
+ const path12 = this.searchPath(env);
4719
+ const result = { ...env };
4720
+ if (process.platform === "win32") {
4721
+ for (const key of Object.keys(result))
4722
+ if (key !== "PATH" && key.toUpperCase() === "PATH") delete result[key];
4723
+ }
4724
+ if (path12 !== "") result.PATH = path12;
4725
+ const callerKeys = new Set(
4726
+ Object.keys(env).filter((key) => env[key] !== void 0).map((key) => key.toUpperCase())
4727
+ );
4728
+ for (const key of NETWORK_KEYS)
4729
+ if (!callerKeys.has(key.toUpperCase()) && this.shellEnv[key] !== void 0)
4730
+ result[key] = this.shellEnv[key];
4731
+ return result;
4732
+ }
4733
+ lookup(command, options) {
4734
+ const env = this.environment(options.env);
4735
+ const cwd = options.cwd instanceof URL ? fileURLToPath(options.cwd) : options.cwd ?? process.cwd();
4736
+ if (command === "bb") {
4737
+ for (const candidate of [
4738
+ env.BB_CLI_LAUNCHER,
4739
+ env.BB_CLI,
4740
+ env.BB_CLI_DIR ? join2(env.BB_CLI_DIR, "bb") : void 0
4741
+ ]) {
4742
+ if (candidate?.trim() && isAbsolute(candidate.trim()) && executable(candidate.trim()))
4743
+ return candidate.trim();
4744
+ }
4745
+ }
4746
+ const extension = extname2(command);
4747
+ const pathExt = envValue(env, "PATHEXT");
4748
+ const path12 = envValue(env, "PATH") ?? "";
4749
+ const lookupOptions = {
4750
+ cwd,
4751
+ path: path12,
4752
+ pathExt: extension ? `${extension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
4753
+ };
4754
+ const found = command === "bb" ? path12.split(delimiter).filter(isAbsolute).map(
4755
+ (directory) => whichCommandSync(join2(directory, command), lookupOptions)
4756
+ ).find(Boolean) : whichCommandSync(command, lookupOptions);
4757
+ return found ? onDiskName(found) : null;
4758
+ }
4759
+ resolve(command, options = {}) {
4760
+ const found = this.lookup(command, options);
4761
+ if (found !== null) return found;
4762
+ const key = `${command}\0${String(options.cwd ?? "")}\0${envValue(options.env ?? this.baseEnv, "PATH") ?? ""}`;
4763
+ const sinceRefresh = Date.now() - this.refreshedAt;
4764
+ if (!(this.misses.has(key) && sinceRefresh < 3e4) && (this.misses.size === 0 || sinceRefresh >= 1e3))
4765
+ void this.refresh();
4766
+ this.misses.add(key);
4767
+ return null;
4768
+ }
4769
+ node(options = {}) {
4770
+ if (executable(this.nodePath)) return this.nodePath;
4771
+ const stableHomebrew = this.runtimePath.replace(
4772
+ /\/Cellar\/([^/]+)\/[^/]+\//u,
4773
+ "/opt/$1/"
4774
+ );
4775
+ const candidates = [
4776
+ stableHomebrew,
4777
+ process.argv0,
4778
+ this.lookup(process.platform === "win32" ? "node.exe" : "node", options)
4779
+ ];
4780
+ for (const candidate of candidates) {
4781
+ if (!candidate || !isAbsolute(candidate) || !executable(candidate))
4782
+ continue;
4783
+ const probe = spawnSync(
4784
+ candidate,
4785
+ [
4786
+ "-p",
4787
+ "JSON.stringify({path:process.execPath,abi:process.versions.modules,electron:!!process.versions.electron})"
4788
+ ],
4789
+ {
4790
+ env: this.environment(options.env),
4791
+ cwd: options.cwd,
4792
+ encoding: "utf8",
4793
+ timeout: PROBE_TIMEOUT_MS,
4794
+ killSignal: "SIGKILL",
4795
+ windowsHide: true
4796
+ }
4797
+ );
4798
+ if (probe.status !== 0) continue;
4799
+ try {
4800
+ const runtime = JSON.parse(probe.stdout.trim());
4801
+ if (typeof runtime !== "object" || runtime === null || !("path" in runtime) || typeof runtime.path !== "string" || !("abi" in runtime) || runtime.abi !== process.versions.modules || !("electron" in runtime) || runtime.electron !== Boolean(process.versions.electron))
4802
+ continue;
4803
+ if (isAbsolute(runtime.path) && executable(runtime.path)) {
4804
+ this.nodePath = runtime.path;
4805
+ return runtime.path;
4806
+ }
4807
+ } catch {
4808
+ }
4809
+ }
4810
+ throw Object.assign(
4811
+ new Error(
4812
+ "The Node runtime was removed and no replacement was found. Reinstall Node or restart bb with an available runtime."
4813
+ ),
4814
+ { code: "ENOENT" }
4815
+ );
4816
+ }
4817
+ bundledNpmCli(command = "npm") {
4818
+ const require2 = createRequire(import.meta.url);
4819
+ return join2(
4820
+ dirname(require2.resolve("npm/package.json")),
4821
+ "bin",
4822
+ `${command}-cli.js`
4823
+ );
4824
+ }
4825
+ npmCli(command = "npm", options = {}) {
4826
+ const bin = `${command}-cli.js`;
4827
+ const runtime = process.versions.electron ? null : this.node(options);
4828
+ const candidates = [];
4829
+ if (runtime !== null)
4830
+ for (const cli of [
4831
+ join2(dirname(runtime), "..", "lib", "node_modules", "npm", "bin", bin),
4832
+ join2(dirname(runtime), "node_modules", "npm", "bin", bin)
4833
+ ])
4834
+ candidates.push({ node: runtime, cli });
4835
+ const installed = this.resolve(command, options);
4836
+ if (installed) {
4837
+ try {
4838
+ const cli = realpathSync(installed);
4839
+ const npmRoot = dirname(dirname(cli));
4840
+ const node = [
4841
+ join2(npmRoot, "..", "..", "..", "bin", "node"),
4842
+ join2(npmRoot, "..", "..", "node.exe"),
4843
+ join2(dirname(installed), "node")
4844
+ ].find(executable);
4845
+ if (basename(cli) === bin && node !== void 0)
4846
+ candidates.push({ node: realpathSync(node), cli });
4847
+ } catch {
4848
+ }
4849
+ }
4850
+ if (runtime !== null) {
4851
+ try {
4852
+ candidates.push({ node: runtime, cli: this.bundledNpmCli(command) });
4853
+ } catch {
4854
+ }
4855
+ }
4856
+ return candidates.find((candidate) => existsSync(candidate.cli)) ?? null;
4857
+ }
4858
+ command(command, args = [], options = {}) {
4859
+ const file = command === this.runtimePath ? this.node(options) : this.resolve(command, options) ?? command;
4860
+ const env = this.environment(options.env);
4861
+ if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
4862
+ env.PATH = mergePath(dirname(file), env.PATH);
4863
+ }
4864
+ return { command: file, args: [...args], env };
4865
+ }
4866
+ };
4867
+ var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
4868
+ var shared = globalThis;
4869
+ var hostToolchain = shared[toolchainKey] ??= new HostToolchain();
4870
+
4871
+ // ../process-utils/src/host-process.ts
4872
+ function observe(child) {
4873
+ child.once("error", (error) => hostToolchain.invalidateFailure(error));
4874
+ child.once("exit", (code) => hostToolchain.invalidateFailure(code));
4875
+ return child;
4876
+ }
4877
+ function spawnHostProcess(command, args = [], options = {}) {
4878
+ const launch = options.shell ? { command, args: [...args], env: hostToolchain.environment(options.env) } : hostToolchain.command(command, args, options);
4879
+ const spawn3 = options.shell ? nodeSpawn : crossSpawn;
4880
+ return observe(
4881
+ spawn3(launch.command, launch.args, {
4882
+ ...options,
4883
+ env: launch.env,
4884
+ windowsHide: options.windowsHide ?? true
4885
+ })
4886
+ );
4887
+ }
4888
+ function prepareExecFile(command, args, options) {
4889
+ const launch = hostToolchain.command(command, args, options);
4890
+ const parsed = process.platform === "win32" && hostToolchain.resolve(launch.command, {
4891
+ env: launch.env,
4892
+ cwd: options.cwd
4893
+ }) === null ? { command: launch.command, args: launch.args, options } : parse(launch.command, launch.args, { ...options, env: launch.env });
4894
+ return {
4895
+ command: parsed.command,
4896
+ args: parsed.args,
4897
+ options: {
4898
+ ...options,
4899
+ ...parsed.options,
4900
+ env: launch.env,
4901
+ windowsHide: options.windowsHide ?? true
4902
+ }
4903
+ };
4904
+ }
4905
+ function execHostFileCallback(command, args, options, callback) {
4906
+ const launch = prepareExecFile(command, args, options);
4907
+ return observe(
4908
+ nodeExecFile(
4909
+ launch.command,
4910
+ launch.args,
4911
+ { ...launch.options, encoding: options.encoding ?? "utf8" },
4912
+ callback
4913
+ )
4914
+ );
4915
+ }
4916
+ function settleExecFile(start) {
4917
+ let resolve5;
4918
+ let reject;
4919
+ const promise = new Promise(
4920
+ (resolvePromise, rejectPromise) => {
4921
+ resolve5 = resolvePromise;
4922
+ reject = rejectPromise;
4923
+ }
4924
+ );
4925
+ const child = start((error, stdout, stderr) => {
4926
+ if (error) reject(Object.assign(error, { stdout, stderr }));
4927
+ else resolve5({ stdout, stderr });
4928
+ });
4929
+ return Object.assign(promise, { child });
4930
+ }
4931
+ function execHostFile(command, args = [], options = {}) {
4932
+ return settleExecFile(
4933
+ (callback) => execHostFileCallback(command, args, options, callback)
4934
+ );
4935
+ }
4936
+
4937
+ // ../process-utils/src/spawn.ts
4392
4938
  function spawnPortableProcess(request) {
4393
- return crossSpawn(request.command, request.args, {
4939
+ return spawnHostProcess(request.command, request.args, {
4394
4940
  cwd: request.cwd,
4395
4941
  detached: request.detached,
4396
4942
  env: request.env,
@@ -4413,8 +4959,7 @@ function spawnPortablePipedProcess(request) {
4413
4959
  }
4414
4960
 
4415
4961
  // ../process-utils/src/windows-process-tree.ts
4416
- import { execFile } from "node:child_process";
4417
- import path from "node:path";
4962
+ import path2 from "node:path";
4418
4963
  function hasExited(child) {
4419
4964
  return child.exitCode !== null || child.signalCode !== null;
4420
4965
  }
@@ -4431,8 +4976,8 @@ function terminateWindowsProcessTrees(pids) {
4431
4976
  resolve5(terminated);
4432
4977
  };
4433
4978
  try {
4434
- killer = execFile(
4435
- path.join(
4979
+ killer = execHostFileCallback(
4980
+ path2.join(
4436
4981
  process.env.SystemRoot ?? "C:\\Windows",
4437
4982
  "System32",
4438
4983
  "taskkill.exe"
@@ -4609,7 +5154,7 @@ function isPlainObject(value) {
4609
5154
  }
4610
5155
 
4611
5156
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/arguments/file-url.js
4612
- import { fileURLToPath } from "node:url";
5157
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
4613
5158
  var safeNormalizeFileUrl = (file, name) => {
4614
5159
  const fileString = normalizeFileUrl(normalizeDenoExecPath(file));
4615
5160
  if (typeof fileString !== "string") {
@@ -4619,7 +5164,7 @@ var safeNormalizeFileUrl = (file, name) => {
4619
5164
  };
4620
5165
  var normalizeDenoExecPath = (file) => isDenoExecPath(file) ? file.toString() : file;
4621
5166
  var isDenoExecPath = (file) => typeof file !== "string" && file && Object.getPrototypeOf(file) === String.prototype;
4622
- var normalizeFileUrl = (file) => file instanceof URL ? fileURLToPath(file) : file;
5167
+ var normalizeFileUrl = (file) => file instanceof URL ? fileURLToPath2(file) : file;
4623
5168
 
4624
5169
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/methods/parameters.js
4625
5170
  var normalizeParameters = (rawFile, rawArguments = [], rawOptions = {}) => {
@@ -4793,15 +5338,15 @@ var getSubprocessResult = ({ stdout }) => {
4793
5338
  };
4794
5339
 
4795
5340
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/methods/main-sync.js
4796
- import { spawnSync } from "node:child_process";
5341
+ import { spawnSync as spawnSync2 } from "node:child_process";
4797
5342
 
4798
5343
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/arguments/specific.js
4799
5344
  import { debuglog } from "node:util";
4800
5345
 
4801
5346
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/utils/standard-stream.js
4802
- import process2 from "node:process";
5347
+ import process3 from "node:process";
4803
5348
  var isStandardStream = (stream) => STANDARD_STREAMS.includes(stream);
4804
- var STANDARD_STREAMS = [process2.stdin, process2.stdout, process2.stderr];
5349
+ var STANDARD_STREAMS = [process3.stdin, process3.stdout, process3.stderr];
4805
5350
  var STANDARD_STREAMS_ALIASES = ["stdin", "stdout", "stderr"];
4806
5351
  var getStreamName = (fdNumber) => STANDARD_STREAMS_ALIASES[fdNumber] ?? `stdio[${fdNumber}]`;
4807
5352
 
@@ -4936,11 +5481,11 @@ var quoteString = (escapedArgument) => {
4936
5481
  var NO_ESCAPE_REGEXP = /^[\w./-]+$/;
4937
5482
 
4938
5483
  // ../../node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
4939
- import process3 from "node:process";
5484
+ import process4 from "node:process";
4940
5485
  function isUnicodeSupported() {
4941
- const { env } = process3;
5486
+ const { env } = process4;
4942
5487
  const { TERM, TERM_PROGRAM } = env;
4943
- if (process3.platform !== "win32") {
5488
+ if (process4.platform !== "win32") {
4944
5489
  return TERM !== "linux";
4945
5490
  }
4946
5491
  return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
@@ -5463,13 +6008,13 @@ var handleCommand = (filePath, rawArguments, rawOptions) => {
5463
6008
  };
5464
6009
 
5465
6010
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/arguments/options.js
5466
- import path6 from "node:path";
5467
- import process6 from "node:process";
6011
+ import path7 from "node:path";
6012
+ import process7 from "node:process";
5468
6013
  import crossSpawn2 from "cross-spawn";
5469
6014
 
5470
6015
  // ../../node_modules/.pnpm/npm-run-path@6.0.0/node_modules/npm-run-path/index.js
5471
- import process4 from "node:process";
5472
- import path3 from "node:path";
6016
+ import process5 from "node:process";
6017
+ import path4 from "node:path";
5473
6018
 
5474
6019
  // ../../node_modules/.pnpm/path-key@4.0.0/node_modules/path-key/index.js
5475
6020
  function pathKey(options = {}) {
@@ -5486,21 +6031,21 @@ function pathKey(options = {}) {
5486
6031
  // ../../node_modules/.pnpm/unicorn-magic@0.3.0/node_modules/unicorn-magic/node.js
5487
6032
  import { promisify } from "node:util";
5488
6033
  import { execFile as execFileCallback, execFileSync as execFileSyncOriginal } from "node:child_process";
5489
- import path2 from "node:path";
5490
- import { fileURLToPath as fileURLToPath2 } from "node:url";
6034
+ import path3 from "node:path";
6035
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
5491
6036
  var execFileOriginal = promisify(execFileCallback);
5492
6037
  function toPath(urlOrPath) {
5493
- return urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
6038
+ return urlOrPath instanceof URL ? fileURLToPath3(urlOrPath) : urlOrPath;
5494
6039
  }
5495
6040
  function traversePathUp(startPath) {
5496
6041
  return {
5497
6042
  *[Symbol.iterator]() {
5498
- let currentPath = path2.resolve(toPath(startPath));
6043
+ let currentPath = path3.resolve(toPath(startPath));
5499
6044
  let previousPath;
5500
6045
  while (previousPath !== currentPath) {
5501
6046
  yield currentPath;
5502
6047
  previousPath = currentPath;
5503
- currentPath = path2.resolve(currentPath, "..");
6048
+ currentPath = path3.resolve(currentPath, "..");
5504
6049
  }
5505
6050
  }
5506
6051
  };
@@ -5509,38 +6054,38 @@ var TEN_MEGABYTES_IN_BYTES = 10 * 1024 * 1024;
5509
6054
 
5510
6055
  // ../../node_modules/.pnpm/npm-run-path@6.0.0/node_modules/npm-run-path/index.js
5511
6056
  var npmRunPath = ({
5512
- cwd = process4.cwd(),
5513
- path: pathOption = process4.env[pathKey()],
6057
+ cwd = process5.cwd(),
6058
+ path: pathOption = process5.env[pathKey()],
5514
6059
  preferLocal = true,
5515
- execPath: execPath2 = process4.execPath,
6060
+ execPath: execPath2 = process5.execPath,
5516
6061
  addExecPath = true
5517
6062
  } = {}) => {
5518
- const cwdPath = path3.resolve(toPath(cwd));
6063
+ const cwdPath = path4.resolve(toPath(cwd));
5519
6064
  const result = [];
5520
- const pathParts = pathOption.split(path3.delimiter);
6065
+ const pathParts = pathOption.split(path4.delimiter);
5521
6066
  if (preferLocal) {
5522
6067
  applyPreferLocal(result, pathParts, cwdPath);
5523
6068
  }
5524
6069
  if (addExecPath) {
5525
6070
  applyExecPath(result, pathParts, execPath2, cwdPath);
5526
6071
  }
5527
- return pathOption === "" || pathOption === path3.delimiter ? `${result.join(path3.delimiter)}${pathOption}` : [...result, pathOption].join(path3.delimiter);
6072
+ return pathOption === "" || pathOption === path4.delimiter ? `${result.join(path4.delimiter)}${pathOption}` : [...result, pathOption].join(path4.delimiter);
5528
6073
  };
5529
6074
  var applyPreferLocal = (result, pathParts, cwdPath) => {
5530
6075
  for (const directory of traversePathUp(cwdPath)) {
5531
- const pathPart = path3.join(directory, "node_modules/.bin");
6076
+ const pathPart = path4.join(directory, "node_modules/.bin");
5532
6077
  if (!pathParts.includes(pathPart)) {
5533
6078
  result.push(pathPart);
5534
6079
  }
5535
6080
  }
5536
6081
  };
5537
6082
  var applyExecPath = (result, pathParts, execPath2, cwdPath) => {
5538
- const pathPart = path3.resolve(cwdPath, toPath(execPath2), "..");
6083
+ const pathPart = path4.resolve(cwdPath, toPath(execPath2), "..");
5539
6084
  if (!pathParts.includes(pathPart)) {
5540
6085
  result.push(pathPart);
5541
6086
  }
5542
6087
  };
5543
- var npmRunPathEnv = ({ env = process4.env, ...options } = {}) => {
6088
+ var npmRunPathEnv = ({ env = process5.env, ...options } = {}) => {
5544
6089
  env = { ...env };
5545
6090
  const pathName = pathKey({ env });
5546
6091
  options.path = env[pathName];
@@ -5584,10 +6129,10 @@ var ExecaSyncError = class extends Error {
5584
6129
  setErrorName(ExecaSyncError, ExecaSyncError.name);
5585
6130
 
5586
6131
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/terminate/signal.js
5587
- import { constants as constants3 } from "node:os";
6132
+ import { constants as constants4 } from "node:os";
5588
6133
 
5589
6134
  // ../../node_modules/.pnpm/human-signals@8.0.1/node_modules/human-signals/build/src/main.js
5590
- import { constants as constants2 } from "node:os";
6135
+ import { constants as constants3 } from "node:os";
5591
6136
 
5592
6137
  // ../../node_modules/.pnpm/human-signals@8.0.1/node_modules/human-signals/build/src/realtime.js
5593
6138
  var getRealtimeSignals = () => {
@@ -5605,7 +6150,7 @@ var SIGRTMIN = 34;
5605
6150
  var SIGRTMAX = 64;
5606
6151
 
5607
6152
  // ../../node_modules/.pnpm/human-signals@8.0.1/node_modules/human-signals/build/src/signals.js
5608
- import { constants } from "node:os";
6153
+ import { constants as constants2 } from "node:os";
5609
6154
 
5610
6155
  // ../../node_modules/.pnpm/human-signals@8.0.1/node_modules/human-signals/build/src/core.js
5611
6156
  var SIGNALS = [
@@ -5896,7 +6441,7 @@ var normalizeSignal = ({
5896
6441
  }) => {
5897
6442
  const {
5898
6443
  signals: { [name]: constantSignal }
5899
- } = constants;
6444
+ } = constants2;
5900
6445
  const supported = constantSignal !== void 0;
5901
6446
  const number2 = supported ? constantSignal : defaultNumber;
5902
6447
  return { name, number: number2, description, supported, action, forced, standard };
@@ -5945,7 +6490,7 @@ var getSignalByNumber = (number2, signals2) => {
5945
6490
  };
5946
6491
  };
5947
6492
  var findSignalByNumber = (number2, signals2) => {
5948
- const signal = signals2.find(({ name }) => constants2.signals[name] === number2);
6493
+ const signal = signals2.find(({ name }) => constants3.signals[name] === number2);
5949
6494
  if (signal !== void 0) {
5950
6495
  return signal;
5951
6496
  }
@@ -5979,13 +6524,13 @@ var normalizeSignalInteger = (signalInteger, optionName) => {
5979
6524
  throw new TypeError(`Invalid ${optionName} ${signalInteger}: this signal integer does not exist.
5980
6525
  ${getAvailableSignals()}`);
5981
6526
  };
5982
- var getSignalsIntegerToName = () => new Map(Object.entries(constants3.signals).reverse().map(([signalName, signalInteger]) => [signalInteger, signalName]));
6527
+ var getSignalsIntegerToName = () => new Map(Object.entries(constants4.signals).reverse().map(([signalName, signalInteger]) => [signalInteger, signalName]));
5983
6528
  var signalsIntegerToName = getSignalsIntegerToName();
5984
6529
  var normalizeSignalName = (signalName, optionName) => {
5985
- if (signalName in constants3.signals) {
6530
+ if (signalName in constants4.signals) {
5986
6531
  return signalName;
5987
6532
  }
5988
- if (signalName.toUpperCase() in constants3.signals) {
6533
+ if (signalName.toUpperCase() in constants4.signals) {
5989
6534
  throw new TypeError(`Invalid ${optionName} '${signalName}': please rename it to '${signalName.toUpperCase()}'.`);
5990
6535
  }
5991
6536
  throw new TypeError(`Invalid ${optionName} '${signalName}': this signal name does not exist.
@@ -5993,8 +6538,8 @@ ${getAvailableSignals()}`);
5993
6538
  };
5994
6539
  var getAvailableSignals = () => `Available signal names: ${getAvailableSignalNames()}.
5995
6540
  Available signal numbers: ${getAvailableSignalIntegers()}.`;
5996
- var getAvailableSignalNames = () => Object.keys(constants3.signals).sort().map((signalName) => `'${signalName}'`).join(", ");
5997
- var getAvailableSignalIntegers = () => [...new Set(Object.values(constants3.signals).sort((signalInteger, signalIntegerTwo) => signalInteger - signalIntegerTwo))].join(", ");
6541
+ var getAvailableSignalNames = () => Object.keys(constants4.signals).sort().map((signalName) => `'${signalName}'`).join(", ");
6542
+ var getAvailableSignalIntegers = () => [...new Set(Object.values(constants4.signals).sort((signalInteger, signalIntegerTwo) => signalInteger - signalIntegerTwo))].join(", ");
5998
6543
  var getSignalDescription = (signal) => signalsByName[signal].description;
5999
6544
 
6000
6545
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/terminate/kill.js
@@ -6690,7 +7235,7 @@ var killAfterTimeout = async (subprocess, timeout, context, { signal }) => {
6690
7235
 
6691
7236
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/methods/node.js
6692
7237
  import { execPath, execArgv } from "node:process";
6693
- import path4 from "node:path";
7238
+ import path5 from "node:path";
6694
7239
  var mapNode = ({ options }) => {
6695
7240
  if (options.node === false) {
6696
7241
  throw new TypeError('The "node" option cannot be false with `execaNode()`.');
@@ -6709,7 +7254,7 @@ var handleNodeOption = (file, commandArguments, {
6709
7254
  throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');
6710
7255
  }
6711
7256
  const normalizedNodePath = safeNormalizeFileUrl(nodePath, 'The "nodePath" option');
6712
- const resolvedNodePath = path4.resolve(cwd, normalizedNodePath);
7257
+ const resolvedNodePath = path5.resolve(cwd, normalizedNodePath);
6713
7258
  const newOptions = {
6714
7259
  ...options,
6715
7260
  nodePath: resolvedNodePath,
@@ -6719,7 +7264,7 @@ var handleNodeOption = (file, commandArguments, {
6719
7264
  if (!shouldHandleNode) {
6720
7265
  return [file, commandArguments, newOptions];
6721
7266
  }
6722
- if (path4.basename(file, ".exe") === "node") {
7267
+ if (path5.basename(file, ".exe") === "node") {
6723
7268
  throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');
6724
7269
  }
6725
7270
  return [
@@ -6808,16 +7353,16 @@ var ENCODING_ALIASES = {
6808
7353
  var serializeEncoding = (encoding) => typeof encoding === "string" ? `"${encoding}"` : String(encoding);
6809
7354
 
6810
7355
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/arguments/cwd.js
6811
- import { statSync } from "node:fs";
6812
- import path5 from "node:path";
6813
- import process5 from "node:process";
7356
+ import { statSync as statSync2 } from "node:fs";
7357
+ import path6 from "node:path";
7358
+ import process6 from "node:process";
6814
7359
  var normalizeCwd = (cwd = getDefaultCwd()) => {
6815
7360
  const cwdString = safeNormalizeFileUrl(cwd, 'The "cwd" option');
6816
- return path5.resolve(cwdString);
7361
+ return path6.resolve(cwdString);
6817
7362
  };
6818
7363
  var getDefaultCwd = () => {
6819
7364
  try {
6820
- return process5.cwd();
7365
+ return process6.cwd();
6821
7366
  } catch (error) {
6822
7367
  error.message = `The current directory does not exist.
6823
7368
  ${error.message}`;
@@ -6830,7 +7375,7 @@ var fixCwdError = (originalMessage, cwd) => {
6830
7375
  }
6831
7376
  let cwdStat;
6832
7377
  try {
6833
- cwdStat = statSync(cwd);
7378
+ cwdStat = statSync2(cwd);
6834
7379
  } catch (error) {
6835
7380
  return `The "cwd" option is invalid: ${cwd}.
6836
7381
  ${error.message}
@@ -6860,7 +7405,7 @@ var normalizeOptions = (filePath, rawArguments, rawOptions) => {
6860
7405
  options.killSignal = normalizeKillSignal(options.killSignal);
6861
7406
  options.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);
6862
7407
  options.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);
6863
- if (process6.platform === "win32" && path6.basename(file, ".exe") === "cmd") {
7408
+ if (process7.platform === "win32" && path7.basename(file, ".exe") === "cmd") {
6864
7409
  commandArguments.unshift("/q");
6865
7410
  }
6866
7411
  return { file, commandArguments, options };
@@ -6901,7 +7446,7 @@ var addDefaultOptions = ({
6901
7446
  serialization
6902
7447
  });
6903
7448
  var getEnv = ({ env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath }) => {
6904
- const env = extendEnv ? { ...process6.env, ...envOption } : envOption;
7449
+ const env = extendEnv ? { ...process7.env, ...envOption } : envOption;
6905
7450
  if (preferLocal || node) {
6906
7451
  return npmRunPathEnv({
6907
7452
  env,
@@ -8079,7 +8624,7 @@ var normalizeGenerator = ({ stdioItem, stdioItem: { value }, index, newTransform
8079
8624
  var sortTransforms = (newTransforms, direction) => direction === "input" ? newTransforms.reverse() : newTransforms;
8080
8625
 
8081
8626
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/stdio/direction.js
8082
- import process7 from "node:process";
8627
+ import process8 from "node:process";
8083
8628
  var getStreamDirection = (stdioItems, fdNumber, optionName) => {
8084
8629
  const directions = stdioItems.map((stdioItem) => getStdioItemDirection(stdioItem, fdNumber));
8085
8630
  if (directions.includes("input") && directions.includes("output")) {
@@ -8119,10 +8664,10 @@ var guessStreamDirection = {
8119
8664
  }
8120
8665
  };
8121
8666
  var getStandardStreamDirection = (value) => {
8122
- if ([0, process7.stdin].includes(value)) {
8667
+ if ([0, process8.stdin].includes(value)) {
8123
8668
  return "input";
8124
8669
  }
8125
- if ([1, 2, process7.stdout, process7.stderr].includes(value)) {
8670
+ if ([1, 2, process8.stdout, process8.stderr].includes(value)) {
8126
8671
  return "output";
8127
8672
  }
8128
8673
  };
@@ -9001,13 +9546,13 @@ var logOutputSync = ({ serializedResult, fdNumber, state, verboseInfo, encoding,
9001
9546
  }
9002
9547
  };
9003
9548
  var writeToFiles = (serializedResult, stdioItems, outputFiles) => {
9004
- for (const { path: path13, append } of stdioItems.filter(({ type }) => FILE_TYPES.has(type))) {
9005
- const pathString = typeof path13 === "string" ? path13 : path13.toString();
9549
+ for (const { path: path12, append } of stdioItems.filter(({ type }) => FILE_TYPES.has(type))) {
9550
+ const pathString = typeof path12 === "string" ? path12 : path12.toString();
9006
9551
  if (append || outputFiles.has(pathString)) {
9007
- appendFileSync(path13, serializedResult);
9552
+ appendFileSync(path12, serializedResult);
9008
9553
  } else {
9009
9554
  outputFiles.add(pathString);
9010
- writeFileSync(path13, serializedResult);
9555
+ writeFileSync(path12, serializedResult);
9011
9556
  }
9012
9557
  }
9013
9558
  };
@@ -9180,7 +9725,7 @@ var runSubprocessSync = ({ file, commandArguments, options, command, escapedComm
9180
9725
  try {
9181
9726
  addInputOptionsSync(fileDescriptors, options);
9182
9727
  const normalizedOptions = normalizeSpawnSyncOptions(options);
9183
- return spawnSync(...concatenateShell(file, commandArguments, normalizedOptions));
9728
+ return spawnSync2(...concatenateShell(file, commandArguments, normalizedOptions));
9184
9729
  } catch (error) {
9185
9730
  return makeEarlyError({
9186
9731
  error,
@@ -9223,10 +9768,10 @@ var getSyncResult = ({ error, exitCode, signal, timedOut, isMaxBuffer, stdio, al
9223
9768
 
9224
9769
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/methods/main-async.js
9225
9770
  import { setMaxListeners } from "node:events";
9226
- import { spawn } from "node:child_process";
9771
+ import { spawn as spawn2 } from "node:child_process";
9227
9772
 
9228
9773
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/ipc/methods.js
9229
- import process8 from "node:process";
9774
+ import process9 from "node:process";
9230
9775
 
9231
9776
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/ipc/get-one.js
9232
9777
  import { once as once5, on as on2 } from "node:events";
@@ -9367,9 +9912,9 @@ var addIpcMethods = (subprocess, { ipc }) => {
9367
9912
  Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));
9368
9913
  };
9369
9914
  var getIpcExport = () => {
9370
- const anyProcess = process8;
9915
+ const anyProcess = process9;
9371
9916
  const isSubprocess = true;
9372
- const ipc = process8.channel !== void 0;
9917
+ const ipc = process9.channel !== void 0;
9373
9918
  return {
9374
9919
  ...getIpcMethods(anyProcess, isSubprocess, ipc),
9375
9920
  getCancelSignal: getCancelSignal.bind(void 0, {
@@ -9920,7 +10465,7 @@ var SignalExit = class extends SignalExitBase {
9920
10465
  // "SIGHUP" throws an `ENOSYS` error on Windows,
9921
10466
  // so use a supported signal instead
9922
10467
  /* c8 ignore start */
9923
- #hupSig = process9.platform === "win32" ? "SIGINT" : "SIGHUP";
10468
+ #hupSig = process10.platform === "win32" ? "SIGINT" : "SIGHUP";
9924
10469
  /* c8 ignore stop */
9925
10470
  #emitter = new Emitter();
9926
10471
  #process;
@@ -10031,7 +10576,7 @@ var SignalExit = class extends SignalExitBase {
10031
10576
  }
10032
10577
  }
10033
10578
  };
10034
- var process9 = globalThis.process;
10579
+ var process10 = globalThis.process;
10035
10580
  var {
10036
10581
  /**
10037
10582
  * Called when the process is exiting, whether via signal, explicit
@@ -10059,7 +10604,7 @@ var {
10059
10604
  * @internal
10060
10605
  */
10061
10606
  unload
10062
- } = signalExitWrap(processOk(process9) ? new SignalExit(process9) : new SignalExitFallback());
10607
+ } = signalExitWrap(processOk(process10) ? new SignalExit(process10) : new SignalExitFallback());
10063
10608
 
10064
10609
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/terminate/cleanup.js
10065
10610
  var cleanupOnExit = (subprocess, { cleanup, detached }, { signal }) => {
@@ -11173,7 +11718,7 @@ var handleAsyncOptions = ({ timeout, signal, ...options }) => {
11173
11718
  var spawnSubprocessAsync = ({ file, commandArguments, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors }) => {
11174
11719
  let subprocess;
11175
11720
  try {
11176
- subprocess = spawn(...concatenateShell(file, commandArguments, options));
11721
+ subprocess = spawn2(...concatenateShell(file, commandArguments, options));
11177
11722
  } catch (error) {
11178
11723
  return handleEarlyError({
11179
11724
  error,
@@ -11550,109 +12095,15 @@ async function runVcsProcess(command, args, operation, options = {}) {
11550
12095
  }
11551
12096
 
11552
12097
  // ../process-utils/src/exec-portable-file.ts
11553
- import { basename, extname as extname2 } from "node:path";
11554
-
11555
- // ../../node_modules/.pnpm/which-command@0.1.0/node_modules/which-command/index.js
11556
- import fs from "node:fs";
11557
- import path7 from "node:path";
11558
- import process10 from "node:process";
11559
- var isWindows = process10.platform === "win32";
11560
- var separatorPattern = isWindows ? new RegExp("[\\/\\\\]", "v") : new RegExp("\\/", "v");
11561
- var defaultPathExt = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC";
11562
- function resolveOptions(command, options) {
11563
- if (typeof command !== "string" || command.length === 0) {
11564
- throw new TypeError("Expected a non-empty string.");
11565
- }
11566
- const {
11567
- cwd = process10.cwd(),
11568
- // On Windows, `process.env.PATH` can be undefined in some contexts (for example, worker threads), where it's only exposed as `Path`.
11569
- path: searchPath = process10.env.PATH ?? (isWindows ? process10.env.Path : void 0) ?? "",
11570
- // `||` (not `??`) so an empty `PATHEXT` falls back to the default instead of disabling all lookup on Windows.
11571
- pathExt = process10.env.PATHEXT || defaultPathExt
11572
- } = options;
11573
- return { cwd, searchPath, pathExt };
11574
- }
11575
- function windowsExtensions(command, pathExt) {
11576
- const extensions = pathExt.split(path7.delimiter).filter(Boolean);
11577
- const commandExtension = path7.extname(command).toLowerCase();
11578
- if (commandExtension !== "" && extensions.some((extension) => extension.toLowerCase() === commandExtension)) {
11579
- return ["", ...extensions];
11580
- }
11581
- return extensions;
11582
- }
11583
- function* candidatePaths(command, { cwd, searchPath, pathExt }) {
11584
- const extensions = isWindows ? windowsExtensions(command, pathExt) : [""];
11585
- if (separatorPattern.test(command)) {
11586
- const base = path7.resolve(cwd, command);
11587
- for (const extension of extensions) {
11588
- yield base + extension;
11589
- }
11590
- return;
11591
- }
11592
- const directories = [
11593
- // Windows searches the current directory before `PATH`.
11594
- ...isWindows ? [cwd] : [],
11595
- ...searchPath.split(path7.delimiter)
11596
- ];
11597
- for (const directory of directories) {
11598
- const unquoted = isWindows && directory.length > 1 && directory.startsWith('"') && directory.endsWith('"') ? directory.slice(1, -1) : directory;
11599
- if (unquoted === "") {
11600
- continue;
11601
- }
11602
- const base = path7.resolve(cwd, unquoted, command);
11603
- for (const extension of extensions) {
11604
- yield base + extension;
11605
- }
11606
- }
11607
- }
11608
- function isExecutableSync(filePath) {
11609
- let stats;
11610
- try {
11611
- stats = fs.statSync(filePath);
11612
- } catch (error) {
11613
- return isWindows && error.code === "EACCES";
11614
- }
11615
- if (!stats.isFile()) {
11616
- return false;
11617
- }
11618
- if (isWindows) {
11619
- return true;
11620
- }
11621
- try {
11622
- fs.accessSync(filePath, fs.constants.X_OK);
11623
- return true;
11624
- } catch {
11625
- return false;
11626
- }
11627
- }
11628
- function whichCommandSync(command, options = {}) {
11629
- const resolved = resolveOptions(command, options);
11630
- for (const candidate of candidatePaths(command, resolved)) {
11631
- if (isExecutableSync(candidate)) {
11632
- return candidate;
11633
- }
11634
- }
11635
- return void 0;
11636
- }
11637
-
11638
- // ../process-utils/src/exec-portable-file.ts
12098
+ import { basename as basename2 } from "node:path";
11639
12099
  function resolvePortableCommand(command, options) {
11640
- const envKeys = Object.keys(options.env).sort();
11641
- const pathKey2 = envKeys.find((key) => key.toUpperCase() === "PATH");
11642
- const pathExtKey = envKeys.find((key) => key.toUpperCase() === "PATHEXT");
11643
- const commandExtension = extname2(command);
11644
- const pathExt = options.env[pathExtKey ?? "PATHEXT"];
11645
- return whichCommandSync(command, {
11646
- cwd: options.cwd,
11647
- path: options.env[pathKey2 ?? "PATH"],
11648
- pathExt: commandExtension ? `${commandExtension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
11649
- });
12100
+ return hostToolchain.resolve(command, options) ?? void 0;
11650
12101
  }
11651
12102
  async function execPortableFile(command, args, options) {
11652
- const executable = basename(command).toLowerCase().replace(/\.(exe|cmd|bat)$/u, "");
11653
- if (executable === "git" || executable === "gh") {
12103
+ const executable2 = basename2(command).toLowerCase().replace(/\.(exe|cmd|bat)$/u, "");
12104
+ if (executable2 === "git" || executable2 === "gh") {
11654
12105
  return runVcsProcess(
11655
- executable,
12106
+ executable2,
11656
12107
  args,
11657
12108
  () => execPortableFileUnbounded(command, args, options),
11658
12109
  {
@@ -11675,9 +12126,10 @@ async function execPortableFileUnbounded(command, args, options) {
11675
12126
  killed: false
11676
12127
  });
11677
12128
  }
11678
- const subprocess = execa(command, args, {
12129
+ const launch = hostToolchain.command(command, args, options);
12130
+ const subprocess = execa(launch.command, launch.args, {
11679
12131
  cwd: options.cwd,
11680
- env: options.env,
12132
+ env: launch.env,
11681
12133
  extendEnv: false,
11682
12134
  encoding: "buffer",
11683
12135
  stripFinalNewline: false,
@@ -11733,6 +12185,7 @@ async function execPortableFileUnbounded(command, args, options) {
11733
12185
  stderr: Buffer.from(result.stderr).toString("utf8")
11734
12186
  };
11735
12187
  if (!result.failed && !canceled && !timedOut) return output;
12188
+ hostToolchain.invalidateFailure(result.code ?? result.exitCode);
11736
12189
  const stopped = canceled || result.isMaxBuffer || timedOut;
11737
12190
  const syscall = result.cause instanceof Error && "syscall" in result.cause && typeof result.cause.syscall === "string" ? result.cause.syscall : void 0;
11738
12191
  const overflowStream = result.shortMessage?.startsWith(
@@ -11755,61 +12208,18 @@ async function execPortableFileUnbounded(command, args, options) {
11755
12208
  }
11756
12209
 
11757
12210
  // ../process-utils/src/paths.ts
11758
- import { isAbsolute, relative, resolve as resolve2, sep } from "node:path";
12211
+ import { isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
11759
12212
  function isPathWithinDirectory(directoryPath, candidatePath) {
11760
12213
  const relativePath = relative(directoryPath, candidatePath);
11761
- return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath);
12214
+ return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !isAbsolute2(relativePath);
11762
12215
  }
11763
12216
 
11764
- // ../process-utils/src/process-info.ts
11765
- import { execFile as execFile2 } from "node:child_process";
11766
- import { promisify as promisify3 } from "node:util";
11767
- var execFileAsync = promisify3(execFile2);
11768
-
11769
12217
  // ../provider-bridge-protocol/src/bridge-kit/provider-maintenance-kit.ts
11770
12218
  var import_compare = __toESM(require_compare(), 1);
11771
12219
  var import_valid = __toESM(require_valid(), 1);
11772
- import { execFile as execFile3 } from "node:child_process";
11773
- import { constants as fsConstants } from "node:fs";
11774
- import { access } from "node:fs/promises";
11775
- import path8 from "node:path";
11776
- import { promisify as promisify4 } from "node:util";
11777
12220
  import { z as z34 } from "zod";
11778
- var execFileAsync2 = promisify4(execFile3);
11779
- var CLI_PROBE_TIMEOUT_MS = 5e3;
11780
- var DEFAULT_WINDOWS_PATHEXT = ".COM;.EXE;.BAT;.CMD";
11781
- function selectResolvedExecutable(args) {
11782
- const candidates = args.candidates.map((candidate) => candidate.trim()).filter((candidate) => candidate.length > 0);
11783
- if (args.platform !== "win32") {
11784
- return candidates[0] ?? null;
11785
- }
11786
- const extensions = (args.pathExt ?? DEFAULT_WINDOWS_PATHEXT).split(";").map((extension) => extension.trim().toLowerCase()).filter((extension) => extension.length > 0);
11787
- return candidates.find(
11788
- (candidate) => extensions.includes(path8.win32.extname(candidate).toLowerCase())
11789
- ) ?? null;
11790
- }
11791
12221
  async function resolveExecutablePath(command) {
11792
- if (path8.isAbsolute(command)) {
11793
- try {
11794
- await access(command, fsConstants.X_OK);
11795
- return command;
11796
- } catch {
11797
- return null;
11798
- }
11799
- }
11800
- try {
11801
- const lookup = process.platform === "win32" ? "where" : "which";
11802
- const { stdout } = await execFileAsync2(lookup, [command], {
11803
- timeout: CLI_PROBE_TIMEOUT_MS
11804
- });
11805
- return selectResolvedExecutable({
11806
- candidates: stdout.split(/\r?\n/u),
11807
- platform: process.platform,
11808
- pathExt: process.env.PATHEXT
11809
- });
11810
- } catch {
11811
- return null;
11812
- }
12222
+ return hostToolchain.resolve(command);
11813
12223
  }
11814
12224
  function versionFrom(value) {
11815
12225
  const candidate = value?.match(/\bv?(\d+\.\d+\.\d+[0-9A-Za-z.+-]*)/u)?.[1];
@@ -11869,10 +12279,10 @@ var ignoredJsonRpcResultSchema = z36.unknown();
11869
12279
 
11870
12280
  // ../provider-bridge-acp/src/bridge/bridge.ts
11871
12281
  import { randomBytes as randomBytes2 } from "node:crypto";
11872
- import { promises as fs4, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
12282
+ import { promises as fs4, readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
11873
12283
  import { createServer } from "node:net";
11874
- import { dirname as dirname2, isAbsolute as isAbsolute2, basename as basename4, relative as relative2, resolve as resolve4 } from "node:path";
11875
- import { fileURLToPath as fileURLToPath3 } from "node:url";
12284
+ import { dirname as dirname3, isAbsolute as isAbsolute3, basename as basename5, relative as relative2, resolve as resolve4 } from "node:path";
12285
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
11876
12286
  import { isDeepStrictEqual } from "node:util";
11877
12287
  import { z as z49 } from "zod";
11878
12288
 
@@ -12294,23 +12704,21 @@ var acpWarningNotificationParamsSchema = z38.object({
12294
12704
  }).passthrough();
12295
12705
 
12296
12706
  // ../provider-bridge-acp/src/dialect.ts
12297
- import { basename as basename2 } from "node:path";
12707
+ import { basename as basename3 } from "node:path";
12298
12708
  import { z as z43 } from "zod";
12299
12709
 
12300
12710
  // ../provider-bridge-acp/src/bridge/provider-maintenance.ts
12301
- import { execFile as execFile4 } from "node:child_process";
12302
- import { existsSync } from "node:fs";
12711
+ import { existsSync as existsSync2 } from "node:fs";
12303
12712
  import fs3 from "node:fs/promises";
12304
12713
  import os2 from "node:os";
12305
- import path10 from "node:path";
12714
+ import path9 from "node:path";
12306
12715
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
12307
- import { promisify as promisify5 } from "node:util";
12308
12716
  import { z as z40 } from "zod";
12309
12717
 
12310
12718
  // ../provider-bridge-acp/src/bridge/opencode-usage.ts
12311
12719
  import fs2 from "node:fs/promises";
12312
12720
  import os from "node:os";
12313
- import path9 from "node:path";
12721
+ import path8 from "node:path";
12314
12722
  import { DatabaseSync } from "node:sqlite";
12315
12723
  import { z as z39 } from "zod";
12316
12724
  var apiCredentialSchema = z39.object({
@@ -12358,13 +12766,13 @@ var usageSchema = z39.object({
12358
12766
  });
12359
12767
  function dataDirectory(env) {
12360
12768
  const dataHome = env.XDG_DATA_HOME;
12361
- return path9.join(
12362
- dataHome && path9.isAbsolute(dataHome) ? dataHome : path9.join(env.HOME || os.homedir(), ".local", "share"),
12769
+ return path8.join(
12770
+ dataHome && path8.isAbsolute(dataHome) ? dataHome : path8.join(env.HOME || os.homedir(), ".local", "share"),
12363
12771
  "opencode"
12364
12772
  );
12365
12773
  }
12366
12774
  async function openDatabase(env) {
12367
- const databasePath = path9.join(dataDirectory(env), "opencode.db");
12775
+ const databasePath = path8.join(dataDirectory(env), "opencode.db");
12368
12776
  try {
12369
12777
  await fs2.access(databasePath);
12370
12778
  } catch (error) {
@@ -12407,14 +12815,14 @@ function readStoredCredential(database) {
12407
12815
  const oauth = storedOAuthSchema.safeParse(parsed);
12408
12816
  if (!oauth.success || !isOfficialConsole(oauth.data.metadata.server))
12409
12817
  continue;
12410
- const { access: access2, expires, metadata } = oauth.data;
12818
+ const { access, expires, metadata } = oauth.data;
12411
12819
  return {
12412
- apiKey: access2,
12820
+ apiKey: access,
12413
12821
  account: {
12414
12822
  id: metadata.accountID,
12415
12823
  email: metadata.email,
12416
12824
  url: metadata.server,
12417
- access_token: access2,
12825
+ access_token: access,
12418
12826
  token_expiry: expires,
12419
12827
  active_org_id: metadata.orgID
12420
12828
  }
@@ -12441,7 +12849,7 @@ async function readLegacyApiKey(env) {
12441
12849
  if (!content) {
12442
12850
  try {
12443
12851
  content = await fs2.readFile(
12444
- path9.join(dataDirectory(env), "auth.json"),
12852
+ path8.join(dataDirectory(env), "auth.json"),
12445
12853
  "utf8"
12446
12854
  );
12447
12855
  } catch (error) {
@@ -12552,7 +12960,7 @@ async function readOpenCodeGoUsage(env) {
12552
12960
  }
12553
12961
 
12554
12962
  // ../provider-bridge-acp/src/bridge/provider-maintenance.ts
12555
- var execFileAsync3 = promisify5(execFile4);
12963
+ var execFileAsync = execHostFile;
12556
12964
  var USAGE_FETCH_TIMEOUT_MS = 15e3;
12557
12965
  var CURSOR_DASHBOARD_URL = "https://api2.cursor.sh/aiserver.v1.DashboardService";
12558
12966
  var CURSOR_KEYCHAIN_ACCOUNT = "cursor-user";
@@ -12560,19 +12968,19 @@ var CURSOR_ACCESS_TOKEN_SERVICE = "cursor-access-token";
12560
12968
  var CURSOR_INSTALL_SCRIPT_URL = "https://cursor.com/install";
12561
12969
  function cursorAuthFilePath() {
12562
12970
  if (process.platform === "win32") {
12563
- const appData = process.env.APPDATA ?? path10.join(os2.homedir(), "AppData", "Roaming");
12564
- return path10.join(appData, "Cursor", "auth.json");
12971
+ const appData = process.env.APPDATA ?? path9.join(os2.homedir(), "AppData", "Roaming");
12972
+ return path9.join(appData, "Cursor", "auth.json");
12565
12973
  }
12566
12974
  if (process.platform === "darwin") {
12567
- return path10.join(os2.homedir(), ".cursor", "auth.json");
12975
+ return path9.join(os2.homedir(), ".cursor", "auth.json");
12568
12976
  }
12569
- const configHome = process.env.XDG_CONFIG_HOME ?? path10.join(os2.homedir(), ".config");
12570
- return path10.join(configHome, "cursor", "auth.json");
12977
+ const configHome = process.env.XDG_CONFIG_HOME ?? path9.join(os2.homedir(), ".config");
12978
+ return path9.join(configHome, "cursor", "auth.json");
12571
12979
  }
12572
12980
  async function readKeychainAccessToken() {
12573
12981
  if (process.platform !== "darwin") return null;
12574
12982
  try {
12575
- const { stdout } = await execFileAsync3(
12983
+ const { stdout } = await execFileAsync(
12576
12984
  "security",
12577
12985
  [
12578
12986
  "find-generic-password",
@@ -12606,11 +13014,11 @@ async function readAccessToken() {
12606
13014
  }
12607
13015
  function cursorStateDatabasePath() {
12608
13016
  if (process.platform === "win32") {
12609
- const appData = process.env.APPDATA ?? path10.join(os2.homedir(), "AppData", "Roaming");
12610
- return path10.join(appData, "Cursor", "User", "globalStorage", "state.vscdb");
13017
+ const appData = process.env.APPDATA ?? path9.join(os2.homedir(), "AppData", "Roaming");
13018
+ return path9.join(appData, "Cursor", "User", "globalStorage", "state.vscdb");
12611
13019
  }
12612
13020
  if (process.platform === "darwin") {
12613
- return path10.join(
13021
+ return path9.join(
12614
13022
  os2.homedir(),
12615
13023
  "Library",
12616
13024
  "Application Support",
@@ -12620,8 +13028,8 @@ function cursorStateDatabasePath() {
12620
13028
  "state.vscdb"
12621
13029
  );
12622
13030
  }
12623
- const configHome = process.env.XDG_CONFIG_HOME ?? path10.join(os2.homedir(), ".config");
12624
- return path10.join(
13031
+ const configHome = process.env.XDG_CONFIG_HOME ?? path9.join(os2.homedir(), ".config");
13032
+ return path9.join(
12625
13033
  configHome,
12626
13034
  "Cursor",
12627
13035
  "User",
@@ -12631,7 +13039,7 @@ function cursorStateDatabasePath() {
12631
13039
  }
12632
13040
  function readAccountEmail() {
12633
13041
  const databasePath = cursorStateDatabasePath();
12634
- if (!existsSync(databasePath)) return null;
13042
+ if (!existsSync2(databasePath)) return null;
12635
13043
  let database = null;
12636
13044
  try {
12637
13045
  database = new DatabaseSync2(databasePath);
@@ -12991,7 +13399,7 @@ function toolKindPresentation(args) {
12991
13399
  import { z as z42 } from "zod";
12992
13400
 
12993
13401
  // ../provider-bridge-acp/src/tool-call-operation.ts
12994
- import path11 from "node:path";
13402
+ import path10 from "node:path";
12995
13403
  import { z as z41 } from "zod";
12996
13404
  var acpRawInputCommandSchema = z41.object({ command: z41.string() }).passthrough();
12997
13405
  var acpRawInputPathSchema = z41.object({
@@ -13002,10 +13410,10 @@ var acpRawInputPathSchema = z41.object({
13002
13410
  }).passthrough();
13003
13411
  function resolveAcpToolCallPath(value, options) {
13004
13412
  const cwd = options?.cwd;
13005
- if (cwd === void 0 || path11.isAbsolute(value) || value.startsWith("~")) {
13413
+ if (cwd === void 0 || path10.isAbsolute(value) || value.startsWith("~")) {
13006
13414
  return value;
13007
13415
  }
13008
- return path11.resolve(cwd, value);
13416
+ return path10.resolve(cwd, value);
13009
13417
  }
13010
13418
  function extractAcpCommand(event) {
13011
13419
  const parsed = acpRawInputCommandSchema.safeParse(event.rawInput);
@@ -13063,8 +13471,8 @@ function classifyAcpToolCall(event, options) {
13063
13471
  }
13064
13472
  function resolveAcpFileChangeWriteScope(paths) {
13065
13473
  const normalized = paths.filter(isNonBlank).map((entry) => {
13066
- const value = path11.normalize(entry);
13067
- return value !== path11.parse(value).root && value.endsWith(path11.sep) ? value.slice(0, -1) : value;
13474
+ const value = path10.normalize(entry);
13475
+ return value !== path10.parse(value).root && value.endsWith(path10.sep) ? value.slice(0, -1) : value;
13068
13476
  });
13069
13477
  const [first, ...rest] = normalized;
13070
13478
  if (first === void 0) {
@@ -13315,14 +13723,14 @@ function buildAcpFileChanges(event, operation, options) {
13315
13723
  if (changes.length > 0) {
13316
13724
  return changes;
13317
13725
  }
13318
- const [path13] = operation.paths;
13319
- if (path13 === void 0) {
13726
+ const [path12] = operation.paths;
13727
+ if (path12 === void 0) {
13320
13728
  return [];
13321
13729
  }
13322
13730
  return [
13323
13731
  {
13324
- path: path13,
13325
- kind: operation.changeKind === "update" && options?.existedBefore?.get(path13) === false ? "add" : operation.changeKind
13732
+ path: path12,
13733
+ kind: operation.changeKind === "update" && options?.existedBefore?.get(path12) === false ? "add" : operation.changeKind
13326
13734
  }
13327
13735
  ];
13328
13736
  }
@@ -13337,13 +13745,13 @@ function fileChangeItem(changes, fallbackVerb) {
13337
13745
  }
13338
13746
  function fileReadItem(event, title, options) {
13339
13747
  const ticked = tickedTokenFromTitle(title);
13340
- const path13 = extractAcpToolCallPaths(event, options)[0] ?? (ticked !== void 0 && looksLikePath(ticked) ? ticked : void 0);
13341
- if (path13 === void 0) {
13748
+ const path12 = extractAcpToolCallPaths(event, options)[0] ?? (ticked !== void 0 && looksLikePath(ticked) ? ticked : void 0);
13749
+ if (path12 === void 0) {
13342
13750
  return null;
13343
13751
  }
13344
13752
  return {
13345
- item: { type: "fileRead", path: path13 },
13346
- presentation: fileReadPresentation(path13)
13753
+ item: { type: "fileRead", path: path12 },
13754
+ presentation: fileReadPresentation(path12)
13347
13755
  };
13348
13756
  }
13349
13757
  function searchItem(event) {
@@ -13780,7 +14188,7 @@ function resolveAcpDialect(launch) {
13780
14188
  if (launch.dialectId !== void 0) {
13781
14189
  return DIALECTS_BY_ID.get(launch.dialectId) ?? GENERIC_ACP_DIALECT;
13782
14190
  }
13783
- const byCommand = DIALECT_IDS_BY_COMMAND[basename2(launch.command)];
14191
+ const byCommand = DIALECT_IDS_BY_COMMAND[basename3(launch.command)];
13784
14192
  return byCommand === void 0 ? GENERIC_ACP_DIALECT : DIALECTS_BY_ID.get(byCommand) ?? GENERIC_ACP_DIALECT;
13785
14193
  }
13786
14194
 
@@ -13857,12 +14265,12 @@ function decodeToolCallLocations(value) {
13857
14265
  if (!isJsonObject(entry)) {
13858
14266
  continue;
13859
14267
  }
13860
- const path13 = readString(entry, "path");
13861
- if (path13 === void 0) {
14268
+ const path12 = readString(entry, "path");
14269
+ if (path12 === void 0) {
13862
14270
  continue;
13863
14271
  }
13864
14272
  const line = readFiniteNumber(entry, "line");
13865
- locations.push(line === void 0 ? { path: path13 } : { path: path13, line });
14273
+ locations.push(line === void 0 ? { path: path12 } : { path: path12, line });
13866
14274
  }
13867
14275
  return locations;
13868
14276
  }
@@ -15474,7 +15882,7 @@ function resolveAcpPermissionDecision(args) {
15474
15882
  }
15475
15883
 
15476
15884
  // ../provider-bridge-acp/src/session-params.ts
15477
- import path12 from "node:path";
15885
+ import path11 from "node:path";
15478
15886
 
15479
15887
  // ../provider-bridge-acp/src/bridge/model-catalog.ts
15480
15888
  var ACP_NATIVE_REASONING_EFFORTS = [
@@ -15924,7 +16332,7 @@ function buildAcpSkillsInstructions(skillRoots) {
15924
16332
  }
15925
16333
  const skillLines = skillRoots.flatMap((skillRoot) => {
15926
16334
  return skillRoot.skills.map((skill) => {
15927
- const skillFilePath = path12.join(
16335
+ const skillFilePath = path11.join(
15928
16336
  skillRoot.skillDirectoryRootPath,
15929
16337
  skill.name,
15930
16338
  "SKILL.md"
@@ -18676,13 +19084,13 @@ var ConnectionBuilder = class {
18676
19084
  /**
18677
19085
  * Adds a typed request handler for one method.
18678
19086
  */
18679
- onReceiveRequest(method, parse, handler) {
19087
+ onReceiveRequest(method, parse2, handler) {
18680
19088
  return this.withHandler({
18681
19089
  handleMessage: async (message, cx) => {
18682
19090
  if (message.kind !== "request" || message.method !== method) {
18683
19091
  return Handled.no(message);
18684
19092
  }
18685
- const request = parse(message.params);
19093
+ const request = parse2(message.params);
18686
19094
  return await handler(request, message.responder, cx) ?? Handled.yes();
18687
19095
  },
18688
19096
  describe: () => `${this.connectionName ?? "request"}:${method}`
@@ -18691,13 +19099,13 @@ var ConnectionBuilder = class {
18691
19099
  /**
18692
19100
  * Adds a typed notification handler for one method.
18693
19101
  */
18694
- onReceiveNotification(method, parse, handler) {
19102
+ onReceiveNotification(method, parse2, handler) {
18695
19103
  return this.withHandler({
18696
19104
  handleMessage: async (message, cx) => {
18697
19105
  if (message.kind !== "notification" || message.method !== method) {
18698
19106
  return Handled.no(message);
18699
19107
  }
18700
- const notification = parse(message.params);
19108
+ const notification = parse2(message.params);
18701
19109
  return await handler(notification, cx) ?? Handled.yes();
18702
19110
  },
18703
19111
  describe: () => `${this.connectionName ?? "notification"}:${method}`
@@ -19995,9 +20403,9 @@ function decodeAuthMethods(value) {
19995
20403
  const rawEnv = entry["env"];
19996
20404
  const env = {};
19997
20405
  if (isJsonObject(rawEnv)) {
19998
- for (const [name, envValue] of Object.entries(rawEnv)) {
19999
- if (typeof envValue === "string") {
20000
- env[name] = envValue;
20406
+ for (const [name, envValue2] of Object.entries(rawEnv)) {
20407
+ if (typeof envValue2 === "string") {
20408
+ env[name] = envValue2;
20001
20409
  }
20002
20410
  }
20003
20411
  }
@@ -20995,11 +21403,10 @@ function toThreadSessionOptionsState(options) {
20995
21403
  }
20996
21404
 
20997
21405
  // ../provider-bridge-acp/src/bridge/cursor-mcp-approval.ts
20998
- import { execFile as execFile5 } from "node:child_process";
20999
21406
  import { createHash, randomBytes } from "node:crypto";
21000
21407
  import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
21001
- import { homedir } from "node:os";
21002
- import { basename as basename3, dirname, join as join2, resolve as resolve3 } from "node:path";
21408
+ import { homedir as homedir2 } from "node:os";
21409
+ import { basename as basename4, dirname as dirname2, join as join3, resolve as resolve3 } from "node:path";
21003
21410
 
21004
21411
  // ../provider-bridge-acp/src/bridge/tool-proxy-mcp.ts
21005
21412
  import { createConnection } from "node:net";
@@ -21308,7 +21715,7 @@ function errorCode(error) {
21308
21715
  return error instanceof Error && "code" in error ? error.code : void 0;
21309
21716
  }
21310
21717
  function cursorAgentCommand(command) {
21311
- return basename3(command).toLowerCase().replace(/\.(?:bat|cmd|exe)$/u, "") === "cursor-agent";
21718
+ return basename4(command).toLowerCase().replace(/\.(?:bat|cmd|exe)$/u, "") === "cursor-agent";
21312
21719
  }
21313
21720
  function cursorProjectSlug(projectRoot) {
21314
21721
  return projectRoot.replace(/[^a-zA-Z0-9]/gu, "-").replace(/-+/gu, "-").replace(/^-+|-+$/gu, "");
@@ -21318,8 +21725,8 @@ function cursorDataDirectory(env) {
21318
21725
  if (configured) {
21319
21726
  return configured;
21320
21727
  }
21321
- const home = env.HOME?.trim() || env.USERPROFILE?.trim() || homedir();
21322
- return join2(home, ".cursor");
21728
+ const home = env.HOME?.trim() || env.USERPROFILE?.trim() || homedir2();
21729
+ return join3(home, ".cursor");
21323
21730
  }
21324
21731
  function cursorMcpServerConfig(config) {
21325
21732
  return {
@@ -21339,7 +21746,7 @@ function buildCursorMcpApprovalIdentifier(args) {
21339
21746
  }
21340
21747
  async function resolveCursorProjectRoot(args) {
21341
21748
  return new Promise((resolveRoot) => {
21342
- execFile5(
21749
+ execHostFileCallback(
21343
21750
  "git",
21344
21751
  ["rev-parse", "--show-toplevel"],
21345
21752
  { cwd: args.cwd, env: args.env, windowsHide: true },
@@ -21350,10 +21757,10 @@ async function resolveCursorProjectRoot(args) {
21350
21757
  );
21351
21758
  });
21352
21759
  }
21353
- async function readApprovals(path13) {
21760
+ async function readApprovals(path12) {
21354
21761
  let text;
21355
21762
  try {
21356
- text = await readFile(path13, "utf8");
21763
+ text = await readFile(path12, "utf8");
21357
21764
  } catch (error) {
21358
21765
  if (errorCode(error) === "ENOENT") {
21359
21766
  return [];
@@ -21362,32 +21769,32 @@ async function readApprovals(path13) {
21362
21769
  }
21363
21770
  const value = JSON.parse(text);
21364
21771
  if (!Array.isArray(value) || !value.every((item) => typeof item === "string")) {
21365
- throw new Error(`Cursor MCP approval file is not a string array: ${path13}`);
21772
+ throw new Error(`Cursor MCP approval file is not a string array: ${path12}`);
21366
21773
  }
21367
21774
  return value;
21368
21775
  }
21369
- async function writeApprovals(path13, approvals) {
21370
- await mkdir(dirname(path13), { recursive: true });
21371
- const tempPath = `${path13}.bb-${process.pid}-${randomBytes(6).toString("hex")}.tmp`;
21776
+ async function writeApprovals(path12, approvals) {
21777
+ await mkdir(dirname2(path12), { recursive: true });
21778
+ const tempPath = `${path12}.bb-${process.pid}-${randomBytes(6).toString("hex")}.tmp`;
21372
21779
  try {
21373
21780
  await writeFile(tempPath, `${JSON.stringify(approvals, null, 2)}
21374
21781
  `, {
21375
21782
  encoding: "utf8",
21376
21783
  mode: 384
21377
21784
  });
21378
- await rename(tempPath, path13);
21785
+ await rename(tempPath, path12);
21379
21786
  } catch (error) {
21380
21787
  await rm(tempPath, { force: true });
21381
21788
  throw error;
21382
21789
  }
21383
21790
  }
21384
- async function acquireApprovalLock(path13) {
21385
- const lockPath = `${path13}.bb-lock`;
21791
+ async function acquireApprovalLock(path12) {
21792
+ const lockPath = `${path12}.bb-lock`;
21386
21793
  const deadline = Date.now() + CURSOR_APPROVAL_LOCK_TIMEOUT_MS;
21387
- await mkdir(dirname(path13), { recursive: true });
21794
+ await mkdir(dirname2(path12), { recursive: true });
21388
21795
  for (; ; ) {
21389
21796
  if (Date.now() >= deadline) {
21390
- throw new Error(`Timed out updating Cursor MCP approvals: ${path13}`);
21797
+ throw new Error(`Timed out updating Cursor MCP approvals: ${path12}`);
21391
21798
  }
21392
21799
  try {
21393
21800
  await mkdir(lockPath, { mode: 448 });
@@ -21413,13 +21820,13 @@ async function acquireApprovalLock(path13) {
21413
21820
  await new Promise((resolveDelay) => setTimeout(resolveDelay, 25));
21414
21821
  }
21415
21822
  }
21416
- async function mutateApprovals(path13, mutate) {
21417
- const releaseLock = await acquireApprovalLock(path13);
21823
+ async function mutateApprovals(path12, mutate) {
21824
+ const releaseLock = await acquireApprovalLock(path12);
21418
21825
  try {
21419
- const approvals = await readApprovals(path13);
21826
+ const approvals = await readApprovals(path12);
21420
21827
  const nextApprovals = mutate(approvals);
21421
21828
  if (approvals.length !== nextApprovals.length || approvals.some((approval, index) => approval !== nextApprovals[index])) {
21422
- await writeApprovals(path13, nextApprovals);
21829
+ await writeApprovals(path12, nextApprovals);
21423
21830
  }
21424
21831
  } finally {
21425
21832
  await releaseLock();
@@ -21433,7 +21840,7 @@ async function approveCursorSessionMcpServer(args) {
21433
21840
  cwd: args.cwd,
21434
21841
  env: args.env
21435
21842
  });
21436
- const path13 = join2(
21843
+ const path12 = join3(
21437
21844
  cursorDataDirectory(args.env),
21438
21845
  "projects",
21439
21846
  cursorProjectSlug(projectRoot),
@@ -21444,14 +21851,14 @@ async function approveCursorSessionMcpServer(args) {
21444
21851
  projectRoot
21445
21852
  });
21446
21853
  let installedByBb = false;
21447
- await mutateApprovals(path13, (approvals) => {
21854
+ await mutateApprovals(path12, (approvals) => {
21448
21855
  if (approvals.includes(approval)) {
21449
21856
  return approvals;
21450
21857
  }
21451
21858
  installedByBb = true;
21452
21859
  return [...approvals, approval];
21453
21860
  });
21454
- return { approval, installedByBb, path: path13 };
21861
+ return { approval, installedByBb, path: path12 };
21455
21862
  }
21456
21863
  async function revokeCursorSessionMcpServer(approval) {
21457
21864
  if (!approval.installedByBb) {
@@ -21592,7 +21999,7 @@ function emitSessionError(session, message) {
21592
21999
  });
21593
22000
  }
21594
22001
  function resolveBridgeProcessArgsForMcpServer() {
21595
- return [...process.execArgv, fileURLToPath3(import.meta.url), "--mcp-stdio"];
22002
+ return [...process.execArgv, fileURLToPath4(import.meta.url), "--mcp-stdio"];
21596
22003
  }
21597
22004
  function resolveBridgeProcessEnvForMcpServer() {
21598
22005
  const electronRunAsNode = process.env.ELECTRON_RUN_AS_NODE;
@@ -22624,7 +23031,7 @@ ${instructions}
22624
23031
  blocks.push({
22625
23032
  type: "resource_link",
22626
23033
  uri: `file://${item.path}`,
22627
- name: item.name ?? basename4(item.path)
23034
+ name: item.name ?? basename5(item.path)
22628
23035
  });
22629
23036
  break;
22630
23037
  }
@@ -22789,7 +23196,7 @@ function isPathInsideRoots(targetPath, roots) {
22789
23196
  const resolvedTarget = resolve4(targetPath);
22790
23197
  return roots.some((root) => {
22791
23198
  const relativePath = relative2(resolve4(root), resolvedTarget);
22792
- return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute2(relativePath);
23199
+ return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute3(relativePath);
22793
23200
  });
22794
23201
  }
22795
23202
  function sliceFileContent(content, line, limit) {
@@ -22839,7 +23246,7 @@ async function handleFsWriteTextFile(session, params, responder) {
22839
23246
  } catch {
22840
23247
  oldText = void 0;
22841
23248
  }
22842
- await fs4.mkdir(dirname2(parsed.data.path), { recursive: true });
23249
+ await fs4.mkdir(dirname3(parsed.data.path), { recursive: true });
22843
23250
  await fs4.writeFile(parsed.data.path, parsed.data.content, "utf8");
22844
23251
  emitForSession(session, ACP_FS_WRITE_METHOD, {
22845
23252
  threadId: session.bbThreadId,
@@ -22891,12 +23298,12 @@ function getSessionByProviderThreadId(providerThreadId) {
22891
23298
  const bbThreadId = bbThreadIdByProviderThreadId.get(providerThreadId);
22892
23299
  return bbThreadId ? sessionsByBbThreadId.get(bbThreadId) : void 0;
22893
23300
  }
22894
- function fileCreatedSince(path13, sinceMs) {
23301
+ function fileCreatedSince(path12, sinceMs) {
22895
23302
  if (sinceMs === void 0) {
22896
23303
  return void 0;
22897
23304
  }
22898
23305
  try {
22899
- const { birthtimeMs } = statSync2(path13);
23306
+ const { birthtimeMs } = statSync3(path12);
22900
23307
  return birthtimeMs > 0 ? birthtimeMs >= sinceMs : void 0;
22901
23308
  } catch {
22902
23309
  return void 0;
@@ -22932,7 +23339,7 @@ async function startAgentSession(request) {
22932
23339
  const translator = createAcpDeltaTranslator({
22933
23340
  cwd: params.cwd,
22934
23341
  dialect,
22935
- fileCreatedThisTurn: (path13) => fileCreatedSince(path13, session.turnStartedAtMs)
23342
+ fileCreatedThisTurn: (path12) => fileCreatedSince(path12, session.turnStartedAtMs)
22936
23343
  });
22937
23344
  translator.configureInjectedTools(
22938
23345
  (params.dynamicTools ?? []).map((tool) => ({
@@ -24410,7 +24817,7 @@ var experimental_providerBridge = experimental_defineProviderBridge({
24410
24817
 
24411
24818
  // ../provider-bridge-acp/src/probe.ts
24412
24819
  import { z as z50 } from "zod";
24413
- var PROBE_TIMEOUT_MS = 1e4;
24820
+ var PROBE_TIMEOUT_MS2 = 1e4;
24414
24821
  function describe(error) {
24415
24822
  if (error instanceof AcpAgentExitedError) {
24416
24823
  return `the agent exited before it answered initialize: ${error.message}`;
@@ -24418,7 +24825,7 @@ function describe(error) {
24418
24825
  return error instanceof Error ? error.message : String(error);
24419
24826
  }
24420
24827
  async function probeAcpAgent(request) {
24421
- const timeoutMs = request.timeoutMs ?? PROBE_TIMEOUT_MS;
24828
+ const timeoutMs = request.timeoutMs ?? PROBE_TIMEOUT_MS2;
24422
24829
  let connection;
24423
24830
  try {
24424
24831
  connection = createAcpAgentConnection({