@lichao0223/lobehub-cli 0.0.105 → 0.0.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +343 -80
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Buffer as Buffer$1 } from "node:buffer";
|
|
|
15
15
|
import * as net$1 from "node:net";
|
|
16
16
|
import net, { BlockList, connect, createServer, isIP } from "node:net";
|
|
17
17
|
import { scheduler, setImmediate as setImmediate$1, setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
18
|
-
import
|
|
18
|
+
import process$1, { cwd, execArgv, execPath, hrtime, platform as platform$1 } from "node:process";
|
|
19
19
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
20
20
|
import { finished, pipeline } from "node:stream/promises";
|
|
21
21
|
import { Duplex, PassThrough, Readable, Transform, Writable, getDefaultHighWaterMark, pipeline as pipeline$1 } from "node:stream";
|
|
@@ -22225,7 +22225,7 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
22225
22225
|
const childProcess$2 = __require("node:child_process");
|
|
22226
22226
|
const path$16 = __require("node:path");
|
|
22227
22227
|
const fs$17 = __require("node:fs");
|
|
22228
|
-
const process$
|
|
22228
|
+
const process$3 = __require("node:process");
|
|
22229
22229
|
const { Argument, humanReadableArgName } = require_argument();
|
|
22230
22230
|
const { CommanderError } = require_error$1();
|
|
22231
22231
|
const { Help, stripColor } = require_help();
|
|
@@ -22277,13 +22277,13 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
22277
22277
|
this._showSuggestionAfterError = true;
|
|
22278
22278
|
this._savedState = null;
|
|
22279
22279
|
this._outputConfiguration = {
|
|
22280
|
-
writeOut: (str) => process$
|
|
22281
|
-
writeErr: (str) => process$
|
|
22280
|
+
writeOut: (str) => process$3.stdout.write(str),
|
|
22281
|
+
writeErr: (str) => process$3.stderr.write(str),
|
|
22282
22282
|
outputError: (str, write) => write(str),
|
|
22283
|
-
getOutHelpWidth: () => process$
|
|
22284
|
-
getErrHelpWidth: () => process$
|
|
22285
|
-
getOutHasColors: () => useColor() ?? (process$
|
|
22286
|
-
getErrHasColors: () => useColor() ?? (process$
|
|
22283
|
+
getOutHelpWidth: () => process$3.stdout.isTTY ? process$3.stdout.columns : void 0,
|
|
22284
|
+
getErrHelpWidth: () => process$3.stderr.isTTY ? process$3.stderr.columns : void 0,
|
|
22285
|
+
getOutHasColors: () => useColor() ?? (process$3.stdout.isTTY && process$3.stdout.hasColors?.()),
|
|
22286
|
+
getErrHasColors: () => useColor() ?? (process$3.stderr.isTTY && process$3.stderr.hasColors?.()),
|
|
22287
22287
|
stripColor: (str) => stripColor(str)
|
|
22288
22288
|
};
|
|
22289
22289
|
this._hidden = false;
|
|
@@ -22641,7 +22641,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22641
22641
|
*/
|
|
22642
22642
|
_exit(exitCode, code, message) {
|
|
22643
22643
|
if (this._exitCallback) this._exitCallback(new CommanderError(exitCode, code, message));
|
|
22644
|
-
process$
|
|
22644
|
+
process$3.exit(exitCode);
|
|
22645
22645
|
}
|
|
22646
22646
|
/**
|
|
22647
22647
|
* Register callback `fn` for the command.
|
|
@@ -22980,11 +22980,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22980
22980
|
if (argv !== void 0 && !Array.isArray(argv)) throw new Error("first parameter to parse must be array or undefined");
|
|
22981
22981
|
parseOptions = parseOptions || {};
|
|
22982
22982
|
if (argv === void 0 && parseOptions.from === void 0) {
|
|
22983
|
-
if (process$
|
|
22984
|
-
const execArgv = process$
|
|
22983
|
+
if (process$3.versions?.electron) parseOptions.from = "electron";
|
|
22984
|
+
const execArgv = process$3.execArgv ?? [];
|
|
22985
22985
|
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) parseOptions.from = "eval";
|
|
22986
22986
|
}
|
|
22987
|
-
if (argv === void 0) argv = process$
|
|
22987
|
+
if (argv === void 0) argv = process$3.argv;
|
|
22988
22988
|
this.rawArgs = argv.slice();
|
|
22989
22989
|
let userArgs;
|
|
22990
22990
|
switch (parseOptions.from) {
|
|
@@ -22994,7 +22994,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22994
22994
|
userArgs = argv.slice(2);
|
|
22995
22995
|
break;
|
|
22996
22996
|
case "electron":
|
|
22997
|
-
if (process$
|
|
22997
|
+
if (process$3.defaultApp) {
|
|
22998
22998
|
this._scriptPath = argv[1];
|
|
22999
22999
|
userArgs = argv.slice(2);
|
|
23000
23000
|
} else userArgs = argv.slice(1);
|
|
@@ -23159,16 +23159,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23159
23159
|
}
|
|
23160
23160
|
launchWithNode = sourceExt.includes(path$16.extname(executableFile));
|
|
23161
23161
|
let proc;
|
|
23162
|
-
if (process$
|
|
23162
|
+
if (process$3.platform !== "win32") if (launchWithNode) {
|
|
23163
23163
|
args.unshift(executableFile);
|
|
23164
|
-
args = incrementNodeInspectorPort(process$
|
|
23165
|
-
proc = childProcess$2.spawn(process$
|
|
23164
|
+
args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
|
|
23165
|
+
proc = childProcess$2.spawn(process$3.argv[0], args, { stdio: "inherit" });
|
|
23166
23166
|
} else proc = childProcess$2.spawn(executableFile, args, { stdio: "inherit" });
|
|
23167
23167
|
else {
|
|
23168
23168
|
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
23169
23169
|
args.unshift(executableFile);
|
|
23170
|
-
args = incrementNodeInspectorPort(process$
|
|
23171
|
-
proc = childProcess$2.spawn(process$
|
|
23170
|
+
args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
|
|
23171
|
+
proc = childProcess$2.spawn(process$3.execPath, args, { stdio: "inherit" });
|
|
23172
23172
|
}
|
|
23173
23173
|
if (!proc.killed) [
|
|
23174
23174
|
"SIGUSR1",
|
|
@@ -23177,20 +23177,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23177
23177
|
"SIGINT",
|
|
23178
23178
|
"SIGHUP"
|
|
23179
23179
|
].forEach((signal) => {
|
|
23180
|
-
process$
|
|
23180
|
+
process$3.on(signal, () => {
|
|
23181
23181
|
if (proc.killed === false && proc.exitCode === null) proc.kill(signal);
|
|
23182
23182
|
});
|
|
23183
23183
|
});
|
|
23184
23184
|
const exitCallback = this._exitCallback;
|
|
23185
23185
|
proc.on("close", (code) => {
|
|
23186
23186
|
code = code ?? 1;
|
|
23187
|
-
if (!exitCallback) process$
|
|
23187
|
+
if (!exitCallback) process$3.exit(code);
|
|
23188
23188
|
else exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
|
|
23189
23189
|
});
|
|
23190
23190
|
proc.on("error", (err) => {
|
|
23191
23191
|
if (err.code === "ENOENT") this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
23192
23192
|
else if (err.code === "EACCES") throw new Error(`'${executableFile}' not executable`);
|
|
23193
|
-
if (!exitCallback) process$
|
|
23193
|
+
if (!exitCallback) process$3.exit(1);
|
|
23194
23194
|
else {
|
|
23195
23195
|
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
23196
23196
|
wrappedError.nestedError = err;
|
|
@@ -23599,13 +23599,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23599
23599
|
*/
|
|
23600
23600
|
_parseOptionsEnv() {
|
|
23601
23601
|
this.options.forEach((option) => {
|
|
23602
|
-
if (option.envVar && option.envVar in process$
|
|
23602
|
+
if (option.envVar && option.envVar in process$3.env) {
|
|
23603
23603
|
const optionKey = option.attributeName();
|
|
23604
23604
|
if (this.getOptionValue(optionKey) === void 0 || [
|
|
23605
23605
|
"default",
|
|
23606
23606
|
"config",
|
|
23607
23607
|
"env"
|
|
23608
|
-
].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$
|
|
23608
|
+
].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$3.env[option.envVar]);
|
|
23609
23609
|
else this.emit(`optionEnv:${option.name()}`);
|
|
23610
23610
|
}
|
|
23611
23611
|
});
|
|
@@ -24022,7 +24022,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
24022
24022
|
*/
|
|
24023
24023
|
help(contextOptions) {
|
|
24024
24024
|
this.outputHelp(contextOptions);
|
|
24025
|
-
let exitCode = Number(process$
|
|
24025
|
+
let exitCode = Number(process$3.exitCode ?? 0);
|
|
24026
24026
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) exitCode = 1;
|
|
24027
24027
|
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
24028
24028
|
}
|
|
@@ -24112,8 +24112,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
24112
24112
|
* @package
|
|
24113
24113
|
*/
|
|
24114
24114
|
function useColor() {
|
|
24115
|
-
if (process$
|
|
24116
|
-
if (process$
|
|
24115
|
+
if (process$3.env.NO_COLOR || process$3.env.FORCE_COLOR === "0" || process$3.env.FORCE_COLOR === "false") return false;
|
|
24116
|
+
if (process$3.env.FORCE_COLOR || process$3.env.CLICOLOR_FORCE !== void 0) return true;
|
|
24117
24117
|
}
|
|
24118
24118
|
exports.Command = Command;
|
|
24119
24119
|
exports.useColor = useColor;
|
|
@@ -60397,7 +60397,7 @@ const buildAntigravityArgs = ({ extraArgs = [], resumeSessionId }) => {
|
|
|
60397
60397
|
|
|
60398
60398
|
//#endregion
|
|
60399
60399
|
//#region ../../packages/heterogeneous-agents/src/spawn/wsl.ts
|
|
60400
|
-
var WSL_COMMAND_PREFIX, isWslCommand, parseWslCommand, formatWslCommand, getWslExecutable, toWslPath, toWslArg, NEVER_FORWARDED, FORWARDED_PREFIXES, FORWARDED_PROXY, ENV_NAME, collectForwardedEnvNames, mergeWslEnv, buildWslSpawnPlan, WSL_PROBE_TIMEOUT_MS, WSL_LIST_TIMEOUT_MS, PATH_MARKER, COMMAND_MARKER, WSL_PROBED_COMMANDS,
|
|
60400
|
+
var WSL_COMMAND_PREFIX, isWslCommand, parseWslCommand, formatWslCommand, getWslExecutable, toWslPath, toWslArg, NEVER_FORWARDED, FORWARDED_PREFIXES, FORWARDED_PROXY, ENV_NAME, collectForwardedEnvNames, mergeWslEnv, WSL_DEFAULT_PATH, withWslBinaryFolder, buildWslSpawnPlan, WSL_PROBE_TIMEOUT_MS, WSL_INTERACTIVE_SHELL_TIMEOUT_S, WSL_LOGIN_SHELL_TIMEOUT_S, WSL_LIST_TIMEOUT_MS, PATH_MARKER, COMMAND_MARKER, SHELL_PATH_MARKER, WSL_PROBED_COMMANDS, WSL_PROBE_SCRIPT, runWsl, decodeWslOutput, parseWslDistroList, isOnWindowsDrive, parseWslProbeOutput, distrosPromise, distroProbes, settledPathEnv, listWslDistros, probeWslDistro, invalidateWslCache, findWslCommandCandidates, getWslPathEnv;
|
|
60401
60401
|
var init_wsl = __esmMin((() => {
|
|
60402
60402
|
init_config();
|
|
60403
60403
|
WSL_COMMAND_PREFIX = "wsl://";
|
|
@@ -60479,6 +60479,13 @@ var init_wsl = __esmMin((() => {
|
|
|
60479
60479
|
for (const name of names) if (!present.has(name.toLowerCase())) entries.push(`${name}/u`);
|
|
60480
60480
|
return entries.join(":");
|
|
60481
60481
|
};
|
|
60482
|
+
WSL_DEFAULT_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
60483
|
+
withWslBinaryFolder = (linuxPath, pathEnv) => {
|
|
60484
|
+
const dir = linuxPath.slice(0, linuxPath.lastIndexOf("/"));
|
|
60485
|
+
const current = pathEnv || WSL_DEFAULT_PATH;
|
|
60486
|
+
if (!dir || current.split(":").includes(dir)) return current;
|
|
60487
|
+
return `${dir}:${current}`;
|
|
60488
|
+
};
|
|
60482
60489
|
buildWslSpawnPlan = ({ distro, linuxPath }, args, env, pathEnv) => {
|
|
60483
60490
|
const forwarded = env ? collectForwardedEnvNames(env) : [];
|
|
60484
60491
|
return {
|
|
@@ -60486,7 +60493,8 @@ var init_wsl = __esmMin((() => {
|
|
|
60486
60493
|
"--distribution",
|
|
60487
60494
|
distro,
|
|
60488
60495
|
"--exec",
|
|
60489
|
-
|
|
60496
|
+
"env",
|
|
60497
|
+
`PATH=${withWslBinaryFolder(linuxPath, pathEnv)}`,
|
|
60490
60498
|
linuxPath,
|
|
60491
60499
|
...args.map(toWslArg)
|
|
60492
60500
|
],
|
|
@@ -60497,18 +60505,62 @@ var init_wsl = __esmMin((() => {
|
|
|
60497
60505
|
} : env
|
|
60498
60506
|
};
|
|
60499
60507
|
};
|
|
60500
|
-
WSL_PROBE_TIMEOUT_MS =
|
|
60501
|
-
|
|
60508
|
+
WSL_PROBE_TIMEOUT_MS = 3e4;
|
|
60509
|
+
WSL_INTERACTIVE_SHELL_TIMEOUT_S = 10;
|
|
60510
|
+
WSL_LOGIN_SHELL_TIMEOUT_S = 5;
|
|
60511
|
+
WSL_LIST_TIMEOUT_MS = 15e3;
|
|
60502
60512
|
PATH_MARKER = "__LOBEHUB_WSL_PATH__=";
|
|
60503
60513
|
COMMAND_MARKER = "__LOBEHUB_WSL_CMD__=";
|
|
60514
|
+
SHELL_PATH_MARKER = "__LOBEHUB_WSL_SHELL_PATH__=";
|
|
60504
60515
|
WSL_PROBED_COMMANDS = [...new Set([
|
|
60505
60516
|
...HETEROGENEOUS_AGENT_CONFIGS.map((config) => config.defaultCommand),
|
|
60506
60517
|
"cursor-agent",
|
|
60507
60518
|
"dsh"
|
|
60508
60519
|
])].filter((name) => /^[\w.-]+$/.test(name));
|
|
60509
|
-
|
|
60510
|
-
|
|
60511
|
-
|
|
60520
|
+
WSL_PROBE_SCRIPT = `lh_c='${COMMAND_MARKER}'
|
|
60521
|
+
lh_to=; command -v timeout >/dev/null 2>&1 && lh_to=timeout
|
|
60522
|
+
lh_run() { lh_s=$1; shift; if [ -n "$lh_to" ]; then timeout "$lh_s" "$@"; else "$@"; fi; }
|
|
60523
|
+
lh_shell="\${SHELL:-/bin/sh}"
|
|
60524
|
+
case "\${lh_shell##*/}" in
|
|
60525
|
+
bash|zsh|ksh|sh|dash) lh_ip=$(lh_run ${WSL_INTERACTIVE_SHELL_TIMEOUT_S} "$lh_shell" -ilc 'printf "\\n${SHELL_PATH_MARKER}%s\\n" "$PATH"' </dev/null 2>/dev/null) ;;
|
|
60526
|
+
fish) lh_ip=$(lh_run ${WSL_INTERACTIVE_SHELL_TIMEOUT_S} "$lh_shell" -ilc 'printf "\\n${SHELL_PATH_MARKER}%s\\n" (string join : $PATH)' </dev/null 2>/dev/null) ;;
|
|
60527
|
+
*) lh_ip= ;;
|
|
60528
|
+
esac
|
|
60529
|
+
lh_ip=$(printf '%s\\n' "$lh_ip" | sed -n 's/^${SHELL_PATH_MARKER}//p' | tail -n 1)
|
|
60530
|
+
lh_lp=$(lh_run ${WSL_LOGIN_SHELL_TIMEOUT_S} sh -lc 'printf "\\n${SHELL_PATH_MARKER}%s\\n" "$PATH"' </dev/null 2>/dev/null | sed -n 's/^${SHELL_PATH_MARKER}//p' | tail -n 1)
|
|
60531
|
+
printf '\\n${PATH_MARKER}%s\\n' "\${lh_ip:-$lh_lp}"
|
|
60532
|
+
lh_wm=$(awk '$1 ~ /^[A-Za-z]:/ {print $2}' /proc/mounts 2>/dev/null)
|
|
60533
|
+
lh_win() { case "$1" in /mnt/[A-Za-z]/*) return 0 ;; esac; for lh_m in $lh_wm; do case "$1" in "$lh_m"/*) return 0 ;; esac; done; return 1; }
|
|
60534
|
+
lh_emit() { case "$2" in /*) ;; *) return 0 ;; esac; lh_win "$2" && return 0; [ -f "$2" ] && [ -x "$2" ] && printf '%s%s=%s\\n' "$lh_c" "$1" "$2"; return 0; }
|
|
60535
|
+
lh_vs() { ls "$1" 2>/dev/null | sed 's/^v*\\([0-9][0-9.]*\\).*$/\\1 &/;t;d' | sort -t. -k1,1nr -k2,2nr -k3,3nr | cut -d' ' -f2; }
|
|
60536
|
+
lh_dirs() {
|
|
60537
|
+
echo "$HOME/.local/bin"
|
|
60538
|
+
lh_np=$(sed -n 's/^[[:space:]]*prefix[[:space:]]*=[[:space:]]*//p' "$HOME/.npmrc" 2>/dev/null | head -n 1 | tr -d "\\"'\\r")
|
|
60539
|
+
case "$lh_np" in "~/"*) echo "$HOME/\${lh_np#??}/bin" ;; /*) echo "$lh_np/bin" ;; esac
|
|
60540
|
+
echo "$HOME/.npm-global/bin"; echo "$HOME/.bun/bin"; echo "$HOME/.local/share/pnpm"; echo "$HOME/.volta/bin"
|
|
60541
|
+
lh_nv="\${NVM_DIR:-$HOME/.nvm}"
|
|
60542
|
+
lh_nd=$(head -n 1 "$lh_nv/alias/default" 2>/dev/null); lh_nd=\${lh_nd#v}
|
|
60543
|
+
case "$lh_nd" in [0-9]*) for lh_v in $(lh_vs "$lh_nv/versions/node"); do case "\${lh_v#v}" in "$lh_nd"|"$lh_nd".*) echo "$lh_nv/versions/node/$lh_v/bin" ;; esac; done ;; esac
|
|
60544
|
+
for lh_v in $(lh_vs "$lh_nv/versions/node"); do echo "$lh_nv/versions/node/$lh_v/bin"; done
|
|
60545
|
+
for lh_r in "$HOME/.local/share/fnm" "$HOME/.fnm"; do [ -d "$lh_r/node-versions" ] || continue; echo "$lh_r/aliases/default/bin"; for lh_v in $(lh_vs "$lh_r/node-versions"); do echo "$lh_r/node-versions/$lh_v/installation/bin"; done; done
|
|
60546
|
+
echo "$HOME/.local/share/mise/shims"
|
|
60547
|
+
for lh_v in $(lh_vs "$HOME/.local/share/mise/installs/node"); do echo "$HOME/.local/share/mise/installs/node/$lh_v/bin"; done
|
|
60548
|
+
echo "$HOME/.asdf/shims"; echo "$HOME/.cargo/bin"; echo "$HOME/.deno/bin"
|
|
60549
|
+
echo /home/linuxbrew/.linuxbrew/bin; echo "$HOME/.linuxbrew/bin"; echo /usr/local/bin; echo /snap/bin
|
|
60550
|
+
for lh_a in .opencode .amp .kimi-code .grok; do echo "$HOME/$lh_a/bin"; done
|
|
60551
|
+
}
|
|
60552
|
+
lh_ds=$(lh_dirs)
|
|
60553
|
+
for lh_name in "$@"; do
|
|
60554
|
+
for lh_p in "$lh_ip" "$lh_lp" "$PATH"; do
|
|
60555
|
+
lh_o=$IFS; IFS=:
|
|
60556
|
+
for lh_d in $lh_p; do IFS=$lh_o; lh_emit "$lh_name" "$lh_d/$lh_name"; done
|
|
60557
|
+
IFS=$lh_o
|
|
60558
|
+
done
|
|
60559
|
+
lh_o=$IFS; IFS='
|
|
60560
|
+
'
|
|
60561
|
+
for lh_d in $lh_ds; do IFS=$lh_o; lh_emit "$lh_name" "$lh_d/$lh_name"; done
|
|
60562
|
+
IFS=$lh_o
|
|
60563
|
+
done
|
|
60512
60564
|
`;
|
|
60513
60565
|
runWsl = (args, { env, input, timeout }) => new Promise((resolve, reject) => {
|
|
60514
60566
|
let settled = false;
|
|
@@ -60547,6 +60599,7 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60547
60599
|
});
|
|
60548
60600
|
decodeWslOutput = (output) => (output.includes(0) ? output.toString("utf16le") : output.toString("utf8")).replace(/^\uFEFF/, "");
|
|
60549
60601
|
parseWslDistroList = (output) => output.split(/\r?\n/).map((line) => line.replaceAll("\0", "").trim()).filter((name) => name && !/^docker-desktop/i.test(name));
|
|
60602
|
+
isOnWindowsDrive = (linuxPath) => /^\/mnt\/[a-z]\//i.test(linuxPath);
|
|
60550
60603
|
parseWslProbeOutput = (output) => {
|
|
60551
60604
|
const commands = /* @__PURE__ */ new Map();
|
|
60552
60605
|
let pathEnv;
|
|
@@ -60558,7 +60611,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60558
60611
|
const separator = entry.indexOf("=");
|
|
60559
60612
|
const name = entry.slice(0, separator);
|
|
60560
60613
|
const linuxPath = entry.slice(separator + 1);
|
|
60561
|
-
if (separator
|
|
60614
|
+
if (separator <= 0 || !linuxPath.startsWith("/") || isOnWindowsDrive(linuxPath)) continue;
|
|
60615
|
+
const found = commands.get(name) ?? [];
|
|
60616
|
+
if (!found.includes(linuxPath)) found.push(linuxPath);
|
|
60617
|
+
commands.set(name, found);
|
|
60562
60618
|
}
|
|
60563
60619
|
}
|
|
60564
60620
|
return {
|
|
@@ -60570,7 +60626,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60570
60626
|
distroProbes = /* @__PURE__ */ new Map();
|
|
60571
60627
|
settledPathEnv = /* @__PURE__ */ new Map();
|
|
60572
60628
|
listWslDistros = () => {
|
|
60573
|
-
distrosPromise ??= runWsl(["--list", "--quiet"], { timeout: WSL_LIST_TIMEOUT_MS }).then((output) => parseWslDistroList(decodeWslOutput(output))).catch(() =>
|
|
60629
|
+
distrosPromise ??= runWsl(["--list", "--quiet"], { timeout: WSL_LIST_TIMEOUT_MS }).then((output) => parseWslDistroList(decodeWslOutput(output))).catch(() => {
|
|
60630
|
+
distrosPromise = void 0;
|
|
60631
|
+
return [];
|
|
60632
|
+
});
|
|
60574
60633
|
return distrosPromise;
|
|
60575
60634
|
};
|
|
60576
60635
|
probeWslDistro = (distro) => {
|
|
@@ -60585,7 +60644,7 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60585
60644
|
"--",
|
|
60586
60645
|
...WSL_PROBED_COMMANDS
|
|
60587
60646
|
], {
|
|
60588
|
-
input:
|
|
60647
|
+
input: WSL_PROBE_SCRIPT,
|
|
60589
60648
|
timeout: WSL_PROBE_TIMEOUT_MS
|
|
60590
60649
|
}).then((output) => {
|
|
60591
60650
|
const result = parseWslProbeOutput(decodeWslOutput(output));
|
|
@@ -60607,13 +60666,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60607
60666
|
if (platform() !== "win32") return [];
|
|
60608
60667
|
const distros = await listWslDistros();
|
|
60609
60668
|
const probes = await Promise.all(distros.map((distro) => probeWslDistro(distro)));
|
|
60610
|
-
return distros.flatMap((distro, index) => {
|
|
60611
|
-
|
|
60612
|
-
|
|
60613
|
-
|
|
60614
|
-
linuxPath
|
|
60615
|
-
})] : [];
|
|
60616
|
-
});
|
|
60669
|
+
return distros.flatMap((distro, index) => (probes[index]?.commands.get(command) ?? []).map((linuxPath) => formatWslCommand({
|
|
60670
|
+
distro,
|
|
60671
|
+
linuxPath
|
|
60672
|
+
})));
|
|
60617
60673
|
};
|
|
60618
60674
|
getWslPathEnv = async (distro) => (await probeWslDistro(distro))?.pathEnv;
|
|
60619
60675
|
}));
|
|
@@ -60807,6 +60863,192 @@ var init_cliSpawn = __esmMin((() => {
|
|
|
60807
60863
|
};
|
|
60808
60864
|
}));
|
|
60809
60865
|
|
|
60866
|
+
//#endregion
|
|
60867
|
+
//#region ../../packages/heterogeneous-agents/src/spawn/userBinDirs.ts
|
|
60868
|
+
var getEnv$1, pathFor, readDirNames, VERSION_DIR, sortVersionDirsDesc, defaultFirst, readFirstLine, readNpmrcPrefix, nodeVersionBins, getWindowsUserBinDirs, getPosixUserBinDirs, getUserBinDirs, WINDOWS_EXTS, isRunnableFile, findCommandInUserBinDirs;
|
|
60869
|
+
var init_userBinDirs = __esmMin((() => {
|
|
60870
|
+
getEnv$1 = (env, name, os) => {
|
|
60871
|
+
const exact = env[name]?.trim();
|
|
60872
|
+
if (exact || os !== "win32") return exact || void 0;
|
|
60873
|
+
const lower = name.toLowerCase();
|
|
60874
|
+
const key = Object.keys(env).find((candidate) => candidate.toLowerCase() === lower && !!env[candidate]?.trim());
|
|
60875
|
+
return key ? env[key].trim() : void 0;
|
|
60876
|
+
};
|
|
60877
|
+
pathFor = (os) => os === "win32" ? path.win32 : path.posix;
|
|
60878
|
+
readDirNames = async (dir) => {
|
|
60879
|
+
try {
|
|
60880
|
+
const entries = await readdir(dir);
|
|
60881
|
+
return Array.isArray(entries) ? entries.map(String) : [];
|
|
60882
|
+
} catch {
|
|
60883
|
+
return [];
|
|
60884
|
+
}
|
|
60885
|
+
};
|
|
60886
|
+
VERSION_DIR = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
|
|
60887
|
+
sortVersionDirsDesc = (names) => names.map((name) => ({
|
|
60888
|
+
match: name.match(VERSION_DIR),
|
|
60889
|
+
name
|
|
60890
|
+
})).filter((entry) => !!entry.match).sort((a, b) => {
|
|
60891
|
+
for (let index = 1; index <= 3; index += 1) {
|
|
60892
|
+
const diff = Number(b.match[index] ?? 0) - Number(a.match[index] ?? 0);
|
|
60893
|
+
if (diff !== 0) return diff;
|
|
60894
|
+
}
|
|
60895
|
+
return 0;
|
|
60896
|
+
}).map(({ name }) => name);
|
|
60897
|
+
defaultFirst = (versions, alias) => {
|
|
60898
|
+
const wanted = alias?.trim().replace(/^v/, "");
|
|
60899
|
+
if (!wanted || !/^\d/.test(wanted)) return versions;
|
|
60900
|
+
const matches = (version) => {
|
|
60901
|
+
const bare = version.replace(/^v/, "");
|
|
60902
|
+
return bare === wanted || bare.startsWith(`${wanted}.`);
|
|
60903
|
+
};
|
|
60904
|
+
return [...versions.filter(matches), ...versions.filter((version) => !matches(version))];
|
|
60905
|
+
};
|
|
60906
|
+
readFirstLine = async (file) => {
|
|
60907
|
+
try {
|
|
60908
|
+
const content = await readFile(file, "utf8");
|
|
60909
|
+
return typeof content === "string" ? content.split(/\r?\n/)[0]?.trim() || void 0 : void 0;
|
|
60910
|
+
} catch {
|
|
60911
|
+
return;
|
|
60912
|
+
}
|
|
60913
|
+
};
|
|
60914
|
+
readNpmrcPrefix = async (home, os, env) => {
|
|
60915
|
+
const fromEnv = getEnv$1(env, "NPM_CONFIG_PREFIX", os) ?? getEnv$1(env, "npm_config_prefix", os);
|
|
60916
|
+
if (fromEnv) return fromEnv;
|
|
60917
|
+
let content;
|
|
60918
|
+
try {
|
|
60919
|
+
content = await readFile(pathFor(os).join(home, ".npmrc"), "utf8");
|
|
60920
|
+
} catch {
|
|
60921
|
+
return;
|
|
60922
|
+
}
|
|
60923
|
+
if (typeof content !== "string") return void 0;
|
|
60924
|
+
const value = content.match(/^\s*prefix\s*=\s*(.+?)\s*$/m)?.[1]?.replaceAll(/^["']|["']$/g, "").trim();
|
|
60925
|
+
if (!value) return void 0;
|
|
60926
|
+
if (value.startsWith("~/") || value.startsWith("~\\")) return pathFor(os).join(home, value.slice(2));
|
|
60927
|
+
return pathFor(os).isAbsolute(value) ? value : void 0;
|
|
60928
|
+
};
|
|
60929
|
+
nodeVersionBins = async (versionsDir, alias, toBin, os) => defaultFirst(sortVersionDirsDesc(await readDirNames(versionsDir)), alias).map((version) => toBin(pathFor(os).join(versionsDir, version)));
|
|
60930
|
+
getWindowsUserBinDirs = async (env, home) => {
|
|
60931
|
+
const os = "win32";
|
|
60932
|
+
const { join } = path.win32;
|
|
60933
|
+
const get = (name) => getEnv$1(env, name, os);
|
|
60934
|
+
const appData = get("APPDATA") ?? join(home, "AppData", "Roaming");
|
|
60935
|
+
const localAppData = get("LOCALAPPDATA") ?? join(home, "AppData", "Local");
|
|
60936
|
+
const programData = get("ProgramData") ?? "C:\\ProgramData";
|
|
60937
|
+
const programFiles = get("ProgramFiles") ?? "C:\\Program Files";
|
|
60938
|
+
const npmPrefix = await readNpmrcPrefix(home, os, env);
|
|
60939
|
+
const nvmHome = get("NVM_HOME");
|
|
60940
|
+
const nvmVersions = nvmHome ? await nodeVersionBins(nvmHome, void 0, (dir) => dir, os) : [];
|
|
60941
|
+
const fnmRoots = [
|
|
60942
|
+
get("FNM_DIR"),
|
|
60943
|
+
join(appData, "fnm"),
|
|
60944
|
+
join(localAppData, "fnm")
|
|
60945
|
+
].filter((dir) => !!dir);
|
|
60946
|
+
const fnmDirs = [];
|
|
60947
|
+
for (const root of new Set(fnmRoots)) fnmDirs.push(join(root, "aliases", "default"), ...await nodeVersionBins(join(root, "node-versions"), void 0, (dir) => join(dir, "installation"), os));
|
|
60948
|
+
const miseData = get("MISE_DATA_DIR") ?? (get("XDG_DATA_HOME") ? join(get("XDG_DATA_HOME"), "mise") : join(localAppData, "mise"));
|
|
60949
|
+
const scoop = get("SCOOP") ?? join(home, "scoop");
|
|
60950
|
+
const scoopGlobal = get("SCOOP_GLOBAL") ?? join(programData, "scoop");
|
|
60951
|
+
return [
|
|
60952
|
+
join(home, ".local", "bin"),
|
|
60953
|
+
...npmPrefix ? [npmPrefix] : [],
|
|
60954
|
+
join(appData, "npm"),
|
|
60955
|
+
...get("PNPM_HOME") ? [get("PNPM_HOME")] : [],
|
|
60956
|
+
join(localAppData, "pnpm"),
|
|
60957
|
+
...get("BUN_INSTALL") ? [join(get("BUN_INSTALL"), "bin")] : [],
|
|
60958
|
+
join(home, ".bun", "bin"),
|
|
60959
|
+
...get("VOLTA_HOME") ? [join(get("VOLTA_HOME"), "bin")] : [],
|
|
60960
|
+
join(localAppData, "Volta", "bin"),
|
|
60961
|
+
...get("NVM_SYMLINK") ? [get("NVM_SYMLINK")] : [],
|
|
60962
|
+
"C:\\nvm4w\\nodejs",
|
|
60963
|
+
...nvmVersions,
|
|
60964
|
+
...fnmDirs,
|
|
60965
|
+
join(miseData, "shims"),
|
|
60966
|
+
join(scoop, "shims"),
|
|
60967
|
+
join(scoopGlobal, "shims"),
|
|
60968
|
+
join(localAppData, "Microsoft", "WinGet", "Links"),
|
|
60969
|
+
join(programFiles, "WinGet", "Links"),
|
|
60970
|
+
join(get("ChocolateyInstall") ?? join(programData, "chocolatey"), "bin"),
|
|
60971
|
+
join(programFiles, "nodejs"),
|
|
60972
|
+
join(home, ".cargo", "bin"),
|
|
60973
|
+
join(home, ".deno", "bin")
|
|
60974
|
+
];
|
|
60975
|
+
};
|
|
60976
|
+
getPosixUserBinDirs = async (env, home) => {
|
|
60977
|
+
const os = "linux";
|
|
60978
|
+
const { join } = path.posix;
|
|
60979
|
+
const get = (name) => getEnv$1(env, name, os);
|
|
60980
|
+
const xdgData = get("XDG_DATA_HOME") ?? join(home, ".local", "share");
|
|
60981
|
+
const npmPrefix = await readNpmrcPrefix(home, os, env);
|
|
60982
|
+
const nvmDir = get("NVM_DIR") ?? join(home, ".nvm");
|
|
60983
|
+
const nvmBins = await nodeVersionBins(join(nvmDir, "versions", "node"), await readFirstLine(join(nvmDir, "alias", "default")), (dir) => join(dir, "bin"), os);
|
|
60984
|
+
const fnmRoots = [
|
|
60985
|
+
get("FNM_DIR"),
|
|
60986
|
+
join(xdgData, "fnm"),
|
|
60987
|
+
join(home, "Library", "Application Support", "fnm"),
|
|
60988
|
+
join(home, ".fnm")
|
|
60989
|
+
].filter((dir) => !!dir);
|
|
60990
|
+
const fnmDirs = [];
|
|
60991
|
+
for (const root of new Set(fnmRoots)) fnmDirs.push(join(root, "aliases", "default", "bin"), ...await nodeVersionBins(join(root, "node-versions"), void 0, (dir) => join(dir, "installation", "bin"), os));
|
|
60992
|
+
const miseData = get("MISE_DATA_DIR") ?? join(xdgData, "mise");
|
|
60993
|
+
const miseNodes = await nodeVersionBins(join(miseData, "installs", "node"), void 0, (dir) => join(dir, "bin"), os);
|
|
60994
|
+
return [
|
|
60995
|
+
join(home, ".local", "bin"),
|
|
60996
|
+
...npmPrefix ? [join(npmPrefix, "bin")] : [],
|
|
60997
|
+
join(home, ".npm-global", "bin"),
|
|
60998
|
+
join(home, ".npm", "bin"),
|
|
60999
|
+
...get("BUN_INSTALL") ? [join(get("BUN_INSTALL"), "bin")] : [],
|
|
61000
|
+
join(home, ".bun", "bin"),
|
|
61001
|
+
...get("PNPM_HOME") ? [get("PNPM_HOME")] : [],
|
|
61002
|
+
join(home, "Library", "pnpm"),
|
|
61003
|
+
join(xdgData, "pnpm"),
|
|
61004
|
+
join(get("VOLTA_HOME") ?? join(home, ".volta"), "bin"),
|
|
61005
|
+
...nvmBins,
|
|
61006
|
+
...fnmDirs,
|
|
61007
|
+
join(miseData, "shims"),
|
|
61008
|
+
...miseNodes,
|
|
61009
|
+
join(get("ASDF_DATA_DIR") ?? join(home, ".asdf"), "shims"),
|
|
61010
|
+
join(home, ".cargo", "bin"),
|
|
61011
|
+
join(home, ".deno", "bin"),
|
|
61012
|
+
"/opt/homebrew/bin",
|
|
61013
|
+
"/usr/local/bin",
|
|
61014
|
+
"/home/linuxbrew/.linuxbrew/bin",
|
|
61015
|
+
join(home, ".linuxbrew", "bin")
|
|
61016
|
+
];
|
|
61017
|
+
};
|
|
61018
|
+
getUserBinDirs = async ({ env = process.env, home = homedir(), os = platform() } = {}) => {
|
|
61019
|
+
const dirs = os === "win32" ? await getWindowsUserBinDirs(env, home) : await getPosixUserBinDirs(env, home);
|
|
61020
|
+
const seen = /* @__PURE__ */ new Set();
|
|
61021
|
+
return dirs.filter((dir) => {
|
|
61022
|
+
const key = os === "win32" ? dir.toLowerCase() : dir;
|
|
61023
|
+
if (!dir || seen.has(key)) return false;
|
|
61024
|
+
seen.add(key);
|
|
61025
|
+
return true;
|
|
61026
|
+
});
|
|
61027
|
+
};
|
|
61028
|
+
WINDOWS_EXTS = [
|
|
61029
|
+
".exe",
|
|
61030
|
+
".cmd",
|
|
61031
|
+
".bat"
|
|
61032
|
+
];
|
|
61033
|
+
isRunnableFile = async (file, os) => {
|
|
61034
|
+
try {
|
|
61035
|
+
await access(file, os === "win32" ? constants.F_OK : constants.X_OK);
|
|
61036
|
+
return true;
|
|
61037
|
+
} catch {
|
|
61038
|
+
return false;
|
|
61039
|
+
}
|
|
61040
|
+
};
|
|
61041
|
+
findCommandInUserBinDirs = async (names, options = {}) => {
|
|
61042
|
+
const os = options.os ?? platform();
|
|
61043
|
+
const files = (await getUserBinDirs({
|
|
61044
|
+
...options,
|
|
61045
|
+
os
|
|
61046
|
+
})).flatMap((dir) => names.flatMap((name) => os === "win32" ? WINDOWS_EXTS.map((ext) => path.win32.join(dir, `${name}${ext}`)) : [path.posix.join(dir, name)]));
|
|
61047
|
+
const runnable = await Promise.all(files.map((file) => isRunnableFile(file, os)));
|
|
61048
|
+
return files.filter((_, index) => runnable[index]);
|
|
61049
|
+
};
|
|
61050
|
+
}));
|
|
61051
|
+
|
|
60810
61052
|
//#endregion
|
|
60811
61053
|
//#region ../../packages/heterogeneous-agents/src/spawn/resolveCliCommand.ts
|
|
60812
61054
|
var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
|
|
@@ -60814,6 +61056,7 @@ var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
60814
61056
|
LOGIN_SHELL_TIMEOUT_STATUS_ERROR: () => LOGIN_SHELL_TIMEOUT_STATUS_ERROR,
|
|
60815
61057
|
LoginShellPathTimeoutError: () => LoginShellPathTimeoutError,
|
|
60816
61058
|
detectHeterogeneousCliCommand: () => detectHeterogeneousCliCommand,
|
|
61059
|
+
detectInUserBinDirs: () => detectInUserBinDirs,
|
|
60817
61060
|
detectInWslWhenMissing: () => detectInWslWhenMissing,
|
|
60818
61061
|
detectValidatedCommand: () => detectValidatedCommand,
|
|
60819
61062
|
detectValidatedCommandCandidates: () => detectValidatedCommandCandidates,
|
|
@@ -60822,10 +61065,11 @@ var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
60822
61065
|
resolveHeteroSpawnCommand: () => resolveHeteroSpawnCommand,
|
|
60823
61066
|
resolveUserSpawnPath: () => resolveUserSpawnPath
|
|
60824
61067
|
});
|
|
60825
|
-
var execFilePromise$2, VERSION_PATTERN, extractVersion, isWindows, shellPathPromise, registryPathPromise, WINDOWS_SHELL_METAS, WINDOWS_RUNNABLE_EXTS, WINDOWS_SHIM_EXTS, WINDOWS_SHELL_MAX_COMMAND_LINE_LENGTH, isWindowsRunnablePath, isWindowsShimPath, pickWindowsRunnables, isPathLikeCommand, LOGIN_SHELL_PATH_TIMEOUT_MS, LOGIN_SHELL_TIMEOUT_STATUS_ERROR, isLoginShellTimeoutStatus, LoginShellPathTimeoutError, getLoginShellPath, cachedShellPath, shellPathGeneration, getCurrentLoginShellPath, invalidateLoginShellPathCache, WINDOWS_REGISTRY_PATH_KEYS, WINDOWS_REGISTRY_PATH_VALUE, expandWindowsEnvRefs$1, readWindowsRegistryPathValue, readMergedWindowsRegistryPath, getWindowsRegistryPath, mergePathValues, resolveUserSpawnPath, recoverProbeEnvironment, getCommandPathLines, resolveCommandCandidates, quoteWindowsShellToken, buildWindowsShellProbe, UNRESOLVED_SHIM, execProbe, detectValidatedCommandInEnvironment, isProbeableCommand, detectValidatedCommandCandidates, detectValidatedCommand, HETEROGENEOUS_CLI_AGENT_OPTIONS, DEFAULT_HETERO_COMMAND, getWellKnownCommandPaths, detectHeterogeneousCliCommand,
|
|
61068
|
+
var execFilePromise$2, VERSION_PATTERN, extractVersion, isWindows, shellPathPromise, registryPathPromise, WINDOWS_SHELL_METAS, WINDOWS_RUNNABLE_EXTS, WINDOWS_SHIM_EXTS, WINDOWS_SHELL_MAX_COMMAND_LINE_LENGTH, isWindowsRunnablePath, isWindowsShimPath, pickWindowsRunnables, isPathLikeCommand, LOGIN_SHELL_PATH_TIMEOUT_MS, LOGIN_SHELL_TIMEOUT_STATUS_ERROR, isLoginShellTimeoutStatus, LoginShellPathTimeoutError, getLoginShellPath, cachedShellPath, shellPathGeneration, getCurrentLoginShellPath, invalidateLoginShellPathCache, WINDOWS_REGISTRY_PATH_KEYS, WINDOWS_REGISTRY_PATH_VALUE, expandWindowsEnvRefs$1, readWindowsRegistryPathValue, readMergedWindowsRegistryPath, getWindowsRegistryPath, mergePathValues, resolveUserSpawnPath, recoverProbeEnvironment, getCommandPathLines, resolveCommandCandidates, quoteWindowsShellToken, buildWindowsShellProbe, UNRESOLVED_SHIM, execProbe, detectValidatedCommandInEnvironment, isProbeableCommand, detectValidatedCommandCandidates, detectValidatedCommand, HETEROGENEOUS_CLI_AGENT_OPTIONS, DEFAULT_HETERO_COMMAND, getWellKnownCommandPaths, detectHeterogeneousCliCommand, DEFAULT_COMMAND_ALIASES, withFolderOnPath, detectInUserBinDirs, detectInWslWhenMissing, resolveHeteroSpawnCommand;
|
|
60826
61069
|
var init_resolveCliCommand = __esmMin((() => {
|
|
60827
61070
|
init_config();
|
|
60828
61071
|
init_cliSpawn();
|
|
61072
|
+
init_userBinDirs();
|
|
60829
61073
|
init_wsl();
|
|
60830
61074
|
execFilePromise$2 = promisify(execFile);
|
|
60831
61075
|
VERSION_PATTERN = /v?(\d+\.\d+\.\d+(?:-[\dA-Za-z.-]+)?(?:\+[\dA-Za-z.-]+)?)/;
|
|
@@ -61155,7 +61399,7 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
61155
61399
|
},
|
|
61156
61400
|
"cursor": {
|
|
61157
61401
|
validateFlag: "--help",
|
|
61158
|
-
validatePattern: /^Usage: agent[\s\S]*Cursor Agent/im
|
|
61402
|
+
validatePattern: /^Usage: (?:cursor-)?agent[\s\S]*Cursor Agent/im
|
|
61159
61403
|
},
|
|
61160
61404
|
"droid": {
|
|
61161
61405
|
validateHelpArgs: ["exec", "--help"],
|
|
@@ -61248,7 +61492,7 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
61248
61492
|
if (platform() === "win32") {
|
|
61249
61493
|
const localAppData = process.env.LOCALAPPDATA;
|
|
61250
61494
|
if (!localAppData) return [];
|
|
61251
|
-
return [path.win32.join(localAppData, "cursor-agent", "agent.cmd")];
|
|
61495
|
+
return [path.win32.join(localAppData, "cursor-agent", "agent.cmd"), path.win32.join(localAppData, "cursor-agent", "cursor-agent.cmd")];
|
|
61252
61496
|
}
|
|
61253
61497
|
if (platform() !== "darwin" && platform() !== "linux") return [];
|
|
61254
61498
|
return [path.join(homedir(), ".local", "bin", "agent"), path.join(homedir(), ".local", "bin", "cursor-agent")];
|
|
@@ -61321,12 +61565,32 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
61321
61565
|
detectHeterogeneousCliCommand = async (agentType, command, probeEnv) => {
|
|
61322
61566
|
const validator = HETEROGENEOUS_CLI_AGENT_OPTIONS[agentType];
|
|
61323
61567
|
if (!validator) return { available: false };
|
|
61324
|
-
|
|
61325
|
-
const
|
|
61326
|
-
|
|
61327
|
-
|
|
61568
|
+
if (!(command.trim() === DEFAULT_HETERO_COMMAND[agentType])) return detectValidatedCommandCandidates([command], validator, probeEnv);
|
|
61569
|
+
const names = [command, ...DEFAULT_COMMAND_ALIASES[agentType] ?? []];
|
|
61570
|
+
return detectInWslWhenMissing(await detectInUserBinDirs(await detectValidatedCommandCandidates([...names, ...getWellKnownCommandPaths(agentType)], validator, probeEnv), names, validator, probeEnv), names, validator);
|
|
61571
|
+
};
|
|
61572
|
+
DEFAULT_COMMAND_ALIASES = { cursor: ["cursor-agent"] };
|
|
61573
|
+
withFolderOnPath = (file, env) => {
|
|
61574
|
+
const base = env ?? process.env;
|
|
61575
|
+
const windows = isWindows();
|
|
61576
|
+
const dir = windows ? path.win32.dirname(file) : path.posix.dirname(file);
|
|
61577
|
+
const delimiter = windows ? ";" : ":";
|
|
61578
|
+
const key = base.PATH === void 0 && windows ? Object.keys(base).find((name) => name.toLowerCase() === "path") : "PATH";
|
|
61579
|
+
const current = key && base[key] || "";
|
|
61580
|
+
return current.split(delimiter).some((entry) => windows ? entry.toLowerCase() === dir.toLowerCase() : entry === dir) ? base : {
|
|
61581
|
+
...base,
|
|
61582
|
+
PATH: current ? `${dir}${delimiter}${current}` : dir
|
|
61583
|
+
};
|
|
61584
|
+
};
|
|
61585
|
+
detectInUserBinDirs = async (status, commandNames, options, probeEnv) => {
|
|
61586
|
+
if (status.available) return status;
|
|
61587
|
+
const candidates = await findCommandInUserBinDirs(commandNames, { env: probeEnv ?? process.env }).catch(() => []);
|
|
61588
|
+
for (const candidate of candidates) {
|
|
61589
|
+
const found = await detectValidatedCommandInEnvironment(candidate, options, withFolderOnPath(candidate, probeEnv));
|
|
61590
|
+
if (found.available) return found;
|
|
61591
|
+
}
|
|
61592
|
+
return status;
|
|
61328
61593
|
};
|
|
61329
|
-
WSL_COMMAND_NAMES = { cursor: ["agent", "cursor-agent"] };
|
|
61330
61594
|
detectInWslWhenMissing = async (status, commandNames, options) => {
|
|
61331
61595
|
if (status.available || !isWindows()) return status;
|
|
61332
61596
|
const candidates = [];
|
|
@@ -75341,18 +75605,17 @@ const isSupportedDshVersion = (version) => {
|
|
|
75341
75605
|
* Find a `dsh` that can run LobeHub turns. An older CLI still answers
|
|
75342
75606
|
* `--version` but has no `acp` profile, so it is reported unavailable here
|
|
75343
75607
|
* rather than failing every turn after the agent was created.
|
|
75608
|
+
*
|
|
75609
|
+
* `dsh` is installed with `npm i -g`, which puts it in whichever global folder
|
|
75610
|
+
* the user's Node setup has: `%APPDATA%\npm`, an nvm-windows or fnm Node's own
|
|
75611
|
+
* folder, a pnpm / bun / Volta global, often off the PATH this app started
|
|
75612
|
+
* with. Those folders are swept before WSL is asked.
|
|
75344
75613
|
*/
|
|
75345
|
-
/**
|
|
75346
|
-
* `dsh` is installed with `npm i -g`. On Windows that drops `dsh.cmd` in npm's
|
|
75347
|
-
* global prefix (`%APPDATA%\npm`), a directory npm's installer only adds to the
|
|
75348
|
-
* registry User PATH, so an app started before it never sees it.
|
|
75349
|
-
*/
|
|
75350
|
-
const getDshWellKnownPaths = () => platform() === "win32" ? [path.win32.join(process.env.APPDATA || path.win32.join(homedir(), "AppData", "Roaming"), "npm", "dsh.cmd")] : [];
|
|
75351
75614
|
const detectDshCommand = async (command = "dsh", env) => {
|
|
75352
75615
|
const isDefaultCommand = command.trim() === "dsh";
|
|
75353
75616
|
const validation = { validatePattern: DSH_VERSION_PATTERN };
|
|
75354
|
-
const nativeStatus = await detectValidatedCommandCandidates(
|
|
75355
|
-
const status = isDefaultCommand ? await detectInWslWhenMissing(nativeStatus, ["dsh"], validation) : nativeStatus;
|
|
75617
|
+
const nativeStatus = await detectValidatedCommandCandidates([command], validation, env);
|
|
75618
|
+
const status = isDefaultCommand ? await detectInWslWhenMissing(await detectInUserBinDirs(nativeStatus, ["dsh"], validation, env), ["dsh"], validation) : nativeStatus;
|
|
75356
75619
|
if (!status.available || isSupportedDshVersion(status.version)) return status;
|
|
75357
75620
|
return {
|
|
75358
75621
|
...status,
|
|
@@ -335060,7 +335323,7 @@ var stdio_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
335060
335323
|
function getDefaultEnvironment() {
|
|
335061
335324
|
const env = {};
|
|
335062
335325
|
for (const key of DEFAULT_INHERITED_ENV_VARS) {
|
|
335063
|
-
const value =
|
|
335326
|
+
const value = process$1.env[key];
|
|
335064
335327
|
if (value === void 0) continue;
|
|
335065
335328
|
if (value.startsWith("()")) continue;
|
|
335066
335329
|
env[key] = value;
|
|
@@ -335071,7 +335334,7 @@ var import_cross_spawn$1, DEFAULT_INHERITED_ENV_VARS, StdioClientTransport;
|
|
|
335071
335334
|
var init_stdio = __esmMin((() => {
|
|
335072
335335
|
init_src_CeKsbNLO();
|
|
335073
335336
|
import_cross_spawn$1 = /* @__PURE__ */ __toESM$2(require_cross_spawn(), 1);
|
|
335074
|
-
DEFAULT_INHERITED_ENV_VARS =
|
|
335337
|
+
DEFAULT_INHERITED_ENV_VARS = process$1.platform === "win32" ? [
|
|
335075
335338
|
"APPDATA",
|
|
335076
335339
|
"COMSPEC",
|
|
335077
335340
|
"HOMEDRIVE",
|
|
@@ -335128,7 +335391,7 @@ var init_stdio = __esmMin((() => {
|
|
|
335128
335391
|
this._serverParams.stderr ?? "inherit"
|
|
335129
335392
|
],
|
|
335130
335393
|
shell: false,
|
|
335131
|
-
windowsHide:
|
|
335394
|
+
windowsHide: process$1.platform === "win32",
|
|
335132
335395
|
cwd: this._serverParams.cwd
|
|
335133
335396
|
});
|
|
335134
335397
|
this._process.on("error", (error) => {
|
|
@@ -338162,9 +338425,9 @@ const getSubprocessResult = ({ stdout }) => {
|
|
|
338162
338425
|
//#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/utils/standard-stream.js
|
|
338163
338426
|
const isStandardStream = (stream) => STANDARD_STREAMS.includes(stream);
|
|
338164
338427
|
const STANDARD_STREAMS = [
|
|
338165
|
-
|
|
338166
|
-
|
|
338167
|
-
|
|
338428
|
+
process$1.stdin,
|
|
338429
|
+
process$1.stdout,
|
|
338430
|
+
process$1.stderr
|
|
338168
338431
|
];
|
|
338169
338432
|
const STANDARD_STREAMS_ALIASES = [
|
|
338170
338433
|
"stdin",
|
|
@@ -338289,9 +338552,9 @@ const NO_ESCAPE_REGEXP = /^[\w./-]+$/;
|
|
|
338289
338552
|
//#endregion
|
|
338290
338553
|
//#region node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
|
|
338291
338554
|
function isUnicodeSupported() {
|
|
338292
|
-
const { env } =
|
|
338555
|
+
const { env } = process$1;
|
|
338293
338556
|
const { TERM, TERM_PROGRAM } = env;
|
|
338294
|
-
if (
|
|
338557
|
+
if (process$1.platform !== "win32") return TERM !== "linux";
|
|
338295
338558
|
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";
|
|
338296
338559
|
}
|
|
338297
338560
|
|
|
@@ -338826,7 +339089,7 @@ function traversePathUp(startPath) {
|
|
|
338826
339089
|
|
|
338827
339090
|
//#endregion
|
|
338828
339091
|
//#region node_modules/.pnpm/npm-run-path@6.0.0/node_modules/npm-run-path/index.js
|
|
338829
|
-
const npmRunPath = ({ cwd =
|
|
339092
|
+
const npmRunPath = ({ cwd = process$1.cwd(), path: pathOption = process$1.env[pathKey()], preferLocal = true, execPath = process$1.execPath, addExecPath = true } = {}) => {
|
|
338830
339093
|
const cwdPath = path.resolve(toPath(cwd));
|
|
338831
339094
|
const result = [];
|
|
338832
339095
|
const pathParts = pathOption.split(path.delimiter);
|
|
@@ -338844,7 +339107,7 @@ const applyExecPath = (result, pathParts, execPath, cwdPath) => {
|
|
|
338844
339107
|
const pathPart = path.resolve(cwdPath, toPath(execPath), "..");
|
|
338845
339108
|
if (!pathParts.includes(pathPart)) result.push(pathPart);
|
|
338846
339109
|
};
|
|
338847
|
-
const npmRunPathEnv = ({ env =
|
|
339110
|
+
const npmRunPathEnv = ({ env = process$1.env, ...options } = {}) => {
|
|
338848
339111
|
env = { ...env };
|
|
338849
339112
|
const pathName = pathKey({ env });
|
|
338850
339113
|
options.path = env[pathName];
|
|
@@ -339979,7 +340242,7 @@ const normalizeCwd = (cwd = getDefaultCwd()) => {
|
|
|
339979
340242
|
};
|
|
339980
340243
|
const getDefaultCwd = () => {
|
|
339981
340244
|
try {
|
|
339982
|
-
return
|
|
340245
|
+
return process$1.cwd();
|
|
339983
340246
|
} catch (error) {
|
|
339984
340247
|
error.message = `The current directory does not exist.\n${error.message}`;
|
|
339985
340248
|
throw error;
|
|
@@ -340015,7 +340278,7 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
|
|
|
340015
340278
|
options.killSignal = normalizeKillSignal(options.killSignal);
|
|
340016
340279
|
options.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);
|
|
340017
340280
|
options.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);
|
|
340018
|
-
if (
|
|
340281
|
+
if (process$1.platform === "win32" && path.basename(file, ".exe") === "cmd") commandArguments.unshift("/q");
|
|
340019
340282
|
return {
|
|
340020
340283
|
file,
|
|
340021
340284
|
commandArguments,
|
|
@@ -340042,7 +340305,7 @@ const addDefaultOptions = ({ extendEnv = true, preferLocal = false, cwd, localDi
|
|
|
340042
340305
|
});
|
|
340043
340306
|
const getEnv = ({ env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath }) => {
|
|
340044
340307
|
const env = extendEnv ? {
|
|
340045
|
-
...
|
|
340308
|
+
...process$1.env,
|
|
340046
340309
|
...envOption
|
|
340047
340310
|
} : envOption;
|
|
340048
340311
|
if (preferLocal || node) return npmRunPathEnv({
|
|
@@ -341044,12 +341307,12 @@ const guessStreamDirection = {
|
|
|
341044
341307
|
}
|
|
341045
341308
|
};
|
|
341046
341309
|
const getStandardStreamDirection = (value) => {
|
|
341047
|
-
if ([0,
|
|
341310
|
+
if ([0, process$1.stdin].includes(value)) return "input";
|
|
341048
341311
|
if ([
|
|
341049
341312
|
1,
|
|
341050
341313
|
2,
|
|
341051
|
-
|
|
341052
|
-
|
|
341314
|
+
process$1.stdout,
|
|
341315
|
+
process$1.stderr
|
|
341053
341316
|
].includes(value)) return "output";
|
|
341054
341317
|
};
|
|
341055
341318
|
const DEFAULT_DIRECTION = "output";
|
|
@@ -342113,9 +342376,9 @@ const addIpcMethods = (subprocess, { ipc }) => {
|
|
|
342113
342376
|
Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));
|
|
342114
342377
|
};
|
|
342115
342378
|
const getIpcExport = () => {
|
|
342116
|
-
const anyProcess =
|
|
342379
|
+
const anyProcess = process$1;
|
|
342117
342380
|
const isSubprocess = true;
|
|
342118
|
-
const ipc =
|
|
342381
|
+
const ipc = process$1.channel !== void 0;
|
|
342119
342382
|
return {
|
|
342120
342383
|
...getIpcMethods(anyProcess, isSubprocess, ipc),
|
|
342121
342384
|
getCancelSignal: getCancelSignal$1.bind(void 0, {
|
|
@@ -342592,7 +342855,7 @@ var SignalExitFallback = class extends SignalExitBase {
|
|
|
342592
342855
|
};
|
|
342593
342856
|
var SignalExit = class extends SignalExitBase {
|
|
342594
342857
|
/* c8 ignore start */
|
|
342595
|
-
#hupSig = process$
|
|
342858
|
+
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
342596
342859
|
/* c8 ignore stop */
|
|
342597
342860
|
#emitter = new Emitter();
|
|
342598
342861
|
#process;
|
|
@@ -342687,8 +342950,8 @@ var SignalExit = class extends SignalExitBase {
|
|
|
342687
342950
|
} else return og.call(this.#process, ev, ...args);
|
|
342688
342951
|
}
|
|
342689
342952
|
};
|
|
342690
|
-
const process$
|
|
342691
|
-
const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$
|
|
342953
|
+
const process$2 = globalThis.process;
|
|
342954
|
+
const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
342692
342955
|
|
|
342693
342956
|
//#endregion
|
|
342694
342957
|
//#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/terminate/cleanup.js
|
package/man/man1/lh.1
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
|
|
2
2
|
.\" Manual command details come from the Commander command tree.
|
|
3
|
-
.TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.
|
|
3
|
+
.TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.106" "User Commands"
|
|
4
4
|
.SH NAME
|
|
5
5
|
lh \- LobeHub CLI \- manage and connect to LobeHub services
|
|
6
6
|
.SH SYNOPSIS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lichao0223/lobehub-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.106",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/lichao0223/lobehub",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"access": "public",
|
|
84
84
|
"registry": "https://registry.npmjs.org"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "4357e5f1f596e9ceefc8625578e6b7a36ca3fa6d"
|
|
87
87
|
}
|