@devness/useai-cli 0.5.48 → 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 +27 -6
- 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 = {
|
|
@@ -4738,6 +4738,21 @@ async function fetchDaemonHealth(port) {
|
|
|
4738
4738
|
}
|
|
4739
4739
|
function findPidsByPort(port) {
|
|
4740
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
|
+
}
|
|
4741
4756
|
const output = execSync2(`lsof -ti :${port}`, { encoding: "utf-8", timeout: 3e3 });
|
|
4742
4757
|
return output.trim().split("\n").map((s) => parseInt(s, 10)).filter((n) => !isNaN(n) && n > 0);
|
|
4743
4758
|
} catch {
|
|
@@ -4809,11 +4824,16 @@ async function ensureDaemon(options) {
|
|
|
4809
4824
|
}
|
|
4810
4825
|
}
|
|
4811
4826
|
}
|
|
4827
|
+
const isWindows2 = process.platform === "win32";
|
|
4812
4828
|
let npxPath;
|
|
4813
|
-
|
|
4814
|
-
npxPath = resolveNpxPath();
|
|
4815
|
-
} catch {
|
|
4829
|
+
if (isWindows2) {
|
|
4816
4830
|
npxPath = "npx";
|
|
4831
|
+
} else {
|
|
4832
|
+
try {
|
|
4833
|
+
npxPath = resolveNpxPath();
|
|
4834
|
+
} catch {
|
|
4835
|
+
npxPath = "npx";
|
|
4836
|
+
}
|
|
4817
4837
|
}
|
|
4818
4838
|
const usePreferOnline = options?.preferOnline !== false;
|
|
4819
4839
|
const npxArgs = ["-y"];
|
|
@@ -4823,7 +4843,7 @@ async function ensureDaemon(options) {
|
|
|
4823
4843
|
const child = spawn(npxPath, npxArgs, {
|
|
4824
4844
|
detached: true,
|
|
4825
4845
|
stdio: "ignore",
|
|
4826
|
-
shell:
|
|
4846
|
+
shell: isWindows2
|
|
4827
4847
|
});
|
|
4828
4848
|
child.unref();
|
|
4829
4849
|
const start = Date.now();
|
|
@@ -6539,7 +6559,8 @@ var startCommand = new Command8("start").description("Start the UseAI daemon").o
|
|
|
6539
6559
|
if (opts.foreground) {
|
|
6540
6560
|
const child = spawn2("npx", ["-y", "@devness/useai@latest", "daemon", "--port", String(port)], {
|
|
6541
6561
|
stdio: "inherit",
|
|
6542
|
-
shell:
|
|
6562
|
+
shell: true
|
|
6563
|
+
// Required on Windows for npx.cmd; harmless on macOS/Linux
|
|
6543
6564
|
});
|
|
6544
6565
|
child.on("exit", (code) => {
|
|
6545
6566
|
process.exit(code ?? 0);
|