@vendian/cli 0.0.39 → 0.0.40
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/cli-wrapper.mjs +45 -29
- package/package.json +1 -1
package/cli-wrapper.mjs
CHANGED
|
@@ -491,6 +491,29 @@ function spawnForward(command, args, options = {}) {
|
|
|
491
491
|
});
|
|
492
492
|
});
|
|
493
493
|
}
|
|
494
|
+
function childProcessIsRunning(child) {
|
|
495
|
+
return Boolean(child) && child.exitCode == null && child.signalCode == null;
|
|
496
|
+
}
|
|
497
|
+
function killProcessTree(child, {
|
|
498
|
+
platform = process.platform,
|
|
499
|
+
signal = "SIGTERM",
|
|
500
|
+
spawnSyncFn = spawnSync
|
|
501
|
+
} = {}) {
|
|
502
|
+
if (!childProcessIsRunning(child)) return false;
|
|
503
|
+
if (platform === "win32") {
|
|
504
|
+
try {
|
|
505
|
+
spawnSyncFn("taskkill", ["/F", "/T", "/PID", String(child.pid)], { stdio: "ignore" });
|
|
506
|
+
} catch {
|
|
507
|
+
}
|
|
508
|
+
return true;
|
|
509
|
+
}
|
|
510
|
+
try {
|
|
511
|
+
child.kill(signal);
|
|
512
|
+
return true;
|
|
513
|
+
} catch {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
494
517
|
|
|
495
518
|
// src/python.js
|
|
496
519
|
import fs2 from "node:fs";
|
|
@@ -2381,7 +2404,7 @@ function buildLocalServeEventStreamArgs({ agentsDir: agentsDir2 = "./agents", co
|
|
|
2381
2404
|
}
|
|
2382
2405
|
|
|
2383
2406
|
// src/version.js
|
|
2384
|
-
var CLI_VERSION = true ? "0.0.
|
|
2407
|
+
var CLI_VERSION = true ? "0.0.40" : process.env.npm_package_version || "0.0.0-dev";
|
|
2385
2408
|
|
|
2386
2409
|
// src/dev-server.js
|
|
2387
2410
|
var __dirname = path8.dirname(fileURLToPath(import.meta.url));
|
|
@@ -2440,8 +2463,8 @@ async function startDevServer({
|
|
|
2440
2463
|
}
|
|
2441
2464
|
function shutdown(server) {
|
|
2442
2465
|
console.log("\n \x1B[90mShutting down...\x1B[0m");
|
|
2443
|
-
if (serveChild
|
|
2444
|
-
serveChild
|
|
2466
|
+
if (childProcessIsRunning(serveChild)) {
|
|
2467
|
+
killProcessTree(serveChild, { signal: "SIGTERM" });
|
|
2445
2468
|
}
|
|
2446
2469
|
server.close();
|
|
2447
2470
|
process.exit(0);
|
|
@@ -2530,7 +2553,7 @@ async function handleApi(req, res, pathname, parsed) {
|
|
|
2530
2553
|
}
|
|
2531
2554
|
}
|
|
2532
2555
|
function apiStatus(req, res) {
|
|
2533
|
-
const serving = serveChild
|
|
2556
|
+
const serving = childProcessIsRunning(serveChild);
|
|
2534
2557
|
jsonResponse(res, {
|
|
2535
2558
|
serving,
|
|
2536
2559
|
agentsDir,
|
|
@@ -2544,7 +2567,7 @@ function apiStatus(req, res) {
|
|
|
2544
2567
|
});
|
|
2545
2568
|
}
|
|
2546
2569
|
function apiServeState(req, res) {
|
|
2547
|
-
const serving = serveChild
|
|
2570
|
+
const serving = childProcessIsRunning(serveChild);
|
|
2548
2571
|
const agentStatuses = serveState.agents.map((agent) => {
|
|
2549
2572
|
const relPath = agent.relativePath || ".";
|
|
2550
2573
|
const runtime = agentRuntimeStatus(agent, serveState.agentRunState);
|
|
@@ -2718,7 +2741,7 @@ function devServerStateAfterServeStart(current = {}, target = {}) {
|
|
|
2718
2741
|
};
|
|
2719
2742
|
}
|
|
2720
2743
|
async function apiServeStart(req, res, body) {
|
|
2721
|
-
if (serveChild
|
|
2744
|
+
if (childProcessIsRunning(serveChild)) {
|
|
2722
2745
|
return jsonResponse(res, { ok: false, error: "Already serving" });
|
|
2723
2746
|
}
|
|
2724
2747
|
const target = resolveServeStartTarget(body, { agentsDir, collectionId });
|
|
@@ -2790,14 +2813,15 @@ async function apiServeStart(req, res, body) {
|
|
|
2790
2813
|
}
|
|
2791
2814
|
}
|
|
2792
2815
|
function apiServeStop(req, res) {
|
|
2793
|
-
if (!serveChild
|
|
2816
|
+
if (!childProcessIsRunning(serveChild)) {
|
|
2794
2817
|
activeServeAgentsDir = "";
|
|
2795
2818
|
return jsonResponse(res, { ok: true, wasRunning: false });
|
|
2796
2819
|
}
|
|
2797
|
-
serveChild
|
|
2820
|
+
const stoppingChild = serveChild;
|
|
2821
|
+
killProcessTree(stoppingChild, { signal: "SIGTERM" });
|
|
2798
2822
|
setTimeout(() => {
|
|
2799
|
-
if (
|
|
2800
|
-
|
|
2823
|
+
if (childProcessIsRunning(stoppingChild)) {
|
|
2824
|
+
killProcessTree(stoppingChild, { signal: "SIGKILL" });
|
|
2801
2825
|
}
|
|
2802
2826
|
}, 3e3);
|
|
2803
2827
|
jsonResponse(res, { ok: true, wasRunning: true });
|
|
@@ -2974,7 +2998,6 @@ function openUrl(url) {
|
|
|
2974
2998
|
// src/tui.js
|
|
2975
2999
|
init_constants();
|
|
2976
3000
|
init_auth();
|
|
2977
|
-
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
2978
3001
|
import fs12 from "node:fs";
|
|
2979
3002
|
import path9 from "node:path";
|
|
2980
3003
|
import readline from "node:readline";
|
|
@@ -3685,7 +3708,7 @@ async function runServeDashboard({ env, platform, agentsDir: agentsDir2, collect
|
|
|
3685
3708
|
stopSignalAttempt += 1;
|
|
3686
3709
|
const signal = stopSignalForAttempt(stopSignalAttempt);
|
|
3687
3710
|
if (process.platform === "win32") {
|
|
3688
|
-
|
|
3711
|
+
killProcessTree2(child);
|
|
3689
3712
|
} else {
|
|
3690
3713
|
try {
|
|
3691
3714
|
child.kill(signal);
|
|
@@ -3707,7 +3730,7 @@ async function runServeDashboard({ env, platform, agentsDir: agentsDir2, collect
|
|
|
3707
3730
|
clearTimeout(ctrlCArmTimer);
|
|
3708
3731
|
ctrlCArmed = false;
|
|
3709
3732
|
if (process.platform === "win32") {
|
|
3710
|
-
|
|
3733
|
+
killProcessTree2(child);
|
|
3711
3734
|
} else {
|
|
3712
3735
|
try {
|
|
3713
3736
|
child.kill(stopSignalForAttempt(stopSignalAttempt));
|
|
@@ -3721,9 +3744,13 @@ async function runServeDashboard({ env, platform, agentsDir: agentsDir2, collect
|
|
|
3721
3744
|
if (!key) return;
|
|
3722
3745
|
if (key.ctrl && key.name === "c") {
|
|
3723
3746
|
if (ctrlCArmed) {
|
|
3724
|
-
|
|
3725
|
-
child
|
|
3726
|
-
}
|
|
3747
|
+
if (process.platform === "win32") {
|
|
3748
|
+
killProcessTree2(child);
|
|
3749
|
+
} else {
|
|
3750
|
+
try {
|
|
3751
|
+
child?.kill("SIGINT");
|
|
3752
|
+
} catch (error) {
|
|
3753
|
+
}
|
|
3727
3754
|
}
|
|
3728
3755
|
finish("exit");
|
|
3729
3756
|
return;
|
|
@@ -3962,19 +3989,8 @@ function stopSignalForAttempt(attempt = 0) {
|
|
|
3962
3989
|
if (attempt === 1) return "SIGTERM";
|
|
3963
3990
|
return "SIGKILL";
|
|
3964
3991
|
}
|
|
3965
|
-
function
|
|
3966
|
-
|
|
3967
|
-
if (process.platform === "win32") {
|
|
3968
|
-
try {
|
|
3969
|
-
spawnSync4("taskkill", ["/F", "/T", "/PID", String(child.pid)], { stdio: "ignore" });
|
|
3970
|
-
} catch {
|
|
3971
|
-
}
|
|
3972
|
-
} else {
|
|
3973
|
-
try {
|
|
3974
|
-
child.kill("SIGTERM");
|
|
3975
|
-
} catch {
|
|
3976
|
-
}
|
|
3977
|
-
}
|
|
3992
|
+
function killProcessTree2(child) {
|
|
3993
|
+
killProcessTree(child, { signal: "SIGTERM" });
|
|
3978
3994
|
}
|
|
3979
3995
|
function helpText() {
|
|
3980
3996
|
return [
|