@vibelet/cli 0.0.9 → 0.1.1
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/bin/vibelet-runtime-policy.mjs +9 -0
- package/bin/vibelet.mjs +19 -2
- package/dist/index.cjs +40 -42
- package/package.json +2 -17
package/bin/vibelet.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { homedir } from 'node:os';
|
|
|
6
6
|
import { dirname, join, resolve } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import QRCode from 'qrcode';
|
|
9
|
+
import { shouldReuseHealthyDaemon } from './vibelet-runtime-policy.mjs';
|
|
9
10
|
|
|
10
11
|
// ─── Paths & constants ─────────────────────────────────────────────────────────
|
|
11
12
|
|
|
@@ -473,8 +474,8 @@ async function requestShutdown() {
|
|
|
473
474
|
|
|
474
475
|
// ─── Commands ───────────────────────────────────────────────────────────────────
|
|
475
476
|
|
|
476
|
-
async function printPairingSummary() {
|
|
477
|
-
const health = await waitForHealth();
|
|
477
|
+
async function printPairingSummary(existingHealth = null) {
|
|
478
|
+
const health = existingHealth ?? await waitForHealth();
|
|
478
479
|
const pairingPayload = await postJson('/pair/open');
|
|
479
480
|
|
|
480
481
|
process.stdout.write(`Vibelet daemon is ready.\n\n`);
|
|
@@ -552,6 +553,7 @@ async function main() {
|
|
|
552
553
|
const relayArg = parseRelayArg();
|
|
553
554
|
const hostArg = parseNamedArg('host', '100.x.x.x');
|
|
554
555
|
const fallbackHostsArg = parseNamedArg('fallback-hosts', '100.x.x.x,192.168.1.x');
|
|
556
|
+
const hasExplicitConfigOverrides = relayArg !== null || Boolean(hostArg) || Boolean(fallbackHostsArg);
|
|
555
557
|
// --relay "" clears saved relay; --relay <url> saves it; omitted uses saved value
|
|
556
558
|
if (relayArg !== null) {
|
|
557
559
|
if (relayArg) {
|
|
@@ -677,6 +679,21 @@ async function main() {
|
|
|
677
679
|
fail(`Unknown command: ${command}`);
|
|
678
680
|
}
|
|
679
681
|
|
|
682
|
+
const healthyDaemon = hasExplicitConfigOverrides ? null : await probeHealth(1_500);
|
|
683
|
+
const existingHealth = shouldReuseHealthyDaemon({
|
|
684
|
+
command,
|
|
685
|
+
daemonHealthy: Boolean(healthyDaemon),
|
|
686
|
+
hasExplicitConfigOverrides,
|
|
687
|
+
}) ? healthyDaemon : null;
|
|
688
|
+
|
|
689
|
+
if (existingHealth) {
|
|
690
|
+
process.stdout.write('Vibelet daemon is already running.\n');
|
|
691
|
+
process.stdout.write('Reusing the current runtime so active sessions stay alive.\n');
|
|
692
|
+
process.stdout.write('Run `npx vibelet restart` to apply freshly built daemon code.\n\n');
|
|
693
|
+
await printPairingSummary(existingHealth);
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
|
|
680
697
|
ensureRuntimeInstalled();
|
|
681
698
|
backend.install();
|
|
682
699
|
backend.start();
|