@devness/useai-cli 0.5.47 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +45 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var SYSTEMD_SERVICE_PATH = join(homedir(), ".config", "systemd", "user", "useai-
|
|
|
30
30
|
var WINDOWS_STARTUP_SCRIPT_PATH = join(process.env["APPDATA"] ?? join(homedir(), "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "useai-daemon.vbs");
|
|
31
31
|
|
|
32
32
|
// ../shared/dist/constants/version.js
|
|
33
|
-
var VERSION = "0.
|
|
33
|
+
var VERSION = "0.6.0";
|
|
34
34
|
|
|
35
35
|
// ../shared/dist/constants/defaults.js
|
|
36
36
|
var DEFAULT_CONFIG = {
|
|
@@ -4635,13 +4635,28 @@ var KNOWN_PATHS = isWindows ? [] : [
|
|
|
4635
4635
|
join2(homedir2(), ".bun", "bin", "npx")
|
|
4636
4636
|
];
|
|
4637
4637
|
function resolveNpxPath() {
|
|
4638
|
-
const whichCmd = isWindows ? "where npx" : "which npx";
|
|
4638
|
+
const whichCmd = isWindows ? "where npx.cmd" : "which npx";
|
|
4639
4639
|
try {
|
|
4640
4640
|
const result = execSync(whichCmd, { stdio: ["pipe", "pipe", "ignore"], encoding: "utf-8" }).trim();
|
|
4641
4641
|
if (result)
|
|
4642
4642
|
return result.split("\n")[0].trim();
|
|
4643
4643
|
} catch {
|
|
4644
4644
|
}
|
|
4645
|
+
if (isWindows) {
|
|
4646
|
+
try {
|
|
4647
|
+
const result = execSync("where npx", { stdio: ["pipe", "pipe", "ignore"], encoding: "utf-8" }).trim();
|
|
4648
|
+
if (result) {
|
|
4649
|
+
const first = result.split("\n")[0].trim();
|
|
4650
|
+
if (!first.toLowerCase().endsWith(".cmd")) {
|
|
4651
|
+
const cmdPath = first + ".cmd";
|
|
4652
|
+
if (existsSync3(cmdPath))
|
|
4653
|
+
return cmdPath;
|
|
4654
|
+
}
|
|
4655
|
+
return first;
|
|
4656
|
+
}
|
|
4657
|
+
} catch {
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4645
4660
|
if (!isWindows && process.env["SHELL"]) {
|
|
4646
4661
|
try {
|
|
4647
4662
|
const result = execSync(`${process.env["SHELL"]} -lc "which npx"`, {
|
|
@@ -4723,6 +4738,21 @@ async function fetchDaemonHealth(port) {
|
|
|
4723
4738
|
}
|
|
4724
4739
|
function findPidsByPort(port) {
|
|
4725
4740
|
try {
|
|
4741
|
+
if (process.platform === "win32") {
|
|
4742
|
+
const output2 = execSync2(`netstat -ano | findstr :${port} | findstr LISTENING`, {
|
|
4743
|
+
encoding: "utf-8",
|
|
4744
|
+
timeout: 5e3,
|
|
4745
|
+
shell: "cmd.exe"
|
|
4746
|
+
});
|
|
4747
|
+
const pids = /* @__PURE__ */ new Set();
|
|
4748
|
+
for (const line of output2.trim().split("\n")) {
|
|
4749
|
+
const parts = line.trim().split(/\s+/);
|
|
4750
|
+
const pid = parseInt(parts[parts.length - 1], 10);
|
|
4751
|
+
if (!isNaN(pid) && pid > 0)
|
|
4752
|
+
pids.add(pid);
|
|
4753
|
+
}
|
|
4754
|
+
return [...pids];
|
|
4755
|
+
}
|
|
4726
4756
|
const output = execSync2(`lsof -ti :${port}`, { encoding: "utf-8", timeout: 3e3 });
|
|
4727
4757
|
return output.trim().split("\n").map((s) => parseInt(s, 10)).filter((n) => !isNaN(n) && n > 0);
|
|
4728
4758
|
} catch {
|
|
@@ -4794,11 +4824,16 @@ async function ensureDaemon(options) {
|
|
|
4794
4824
|
}
|
|
4795
4825
|
}
|
|
4796
4826
|
}
|
|
4827
|
+
const isWindows2 = process.platform === "win32";
|
|
4797
4828
|
let npxPath;
|
|
4798
|
-
|
|
4799
|
-
npxPath = resolveNpxPath();
|
|
4800
|
-
} catch {
|
|
4829
|
+
if (isWindows2) {
|
|
4801
4830
|
npxPath = "npx";
|
|
4831
|
+
} else {
|
|
4832
|
+
try {
|
|
4833
|
+
npxPath = resolveNpxPath();
|
|
4834
|
+
} catch {
|
|
4835
|
+
npxPath = "npx";
|
|
4836
|
+
}
|
|
4802
4837
|
}
|
|
4803
4838
|
const usePreferOnline = options?.preferOnline !== false;
|
|
4804
4839
|
const npxArgs = ["-y"];
|
|
@@ -4807,7 +4842,8 @@ async function ensureDaemon(options) {
|
|
|
4807
4842
|
npxArgs.push("@devness/useai@latest", "daemon", "--port", String(DAEMON_PORT));
|
|
4808
4843
|
const child = spawn(npxPath, npxArgs, {
|
|
4809
4844
|
detached: true,
|
|
4810
|
-
stdio: "ignore"
|
|
4845
|
+
stdio: "ignore",
|
|
4846
|
+
shell: isWindows2
|
|
4811
4847
|
});
|
|
4812
4848
|
child.unref();
|
|
4813
4849
|
const start = Date.now();
|
|
@@ -6522,7 +6558,9 @@ var startCommand = new Command8("start").description("Start the UseAI daemon").o
|
|
|
6522
6558
|
}
|
|
6523
6559
|
if (opts.foreground) {
|
|
6524
6560
|
const child = spawn2("npx", ["-y", "@devness/useai@latest", "daemon", "--port", String(port)], {
|
|
6525
|
-
stdio: "inherit"
|
|
6561
|
+
stdio: "inherit",
|
|
6562
|
+
shell: true
|
|
6563
|
+
// Required on Windows for npx.cmd; harmless on macOS/Linux
|
|
6526
6564
|
});
|
|
6527
6565
|
child.on("exit", (code) => {
|
|
6528
6566
|
process.exit(code ?? 0);
|