agendex-cli 0.9.0 → 0.9.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/dist/cli.js +20 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2398,7 +2398,7 @@ async function loadOrInitConfig(options = {}) {
|
|
|
2398
2398
|
}
|
|
2399
2399
|
// ../shared/src/daemon-status.ts
|
|
2400
2400
|
var CLI_DAEMON_HEARTBEAT_INTERVAL_MS = 30000;
|
|
2401
|
-
var CLI_DAEMON_STALE_AFTER_MS = CLI_DAEMON_HEARTBEAT_INTERVAL_MS *
|
|
2401
|
+
var CLI_DAEMON_STALE_AFTER_MS = CLI_DAEMON_HEARTBEAT_INTERVAL_MS * 5;
|
|
2402
2402
|
// ../shared/src/services/plan-service.ts
|
|
2403
2403
|
import { existsSync as existsSync4, readdirSync as readdirSync3, statSync } from "node:fs";
|
|
2404
2404
|
import { lstat, mkdir, readdir as readdir2, readFile as readFile6, stat as stat6, writeFile as writeFile3 } from "node:fs/promises";
|
|
@@ -2817,6 +2817,13 @@ async function sendHeartbeat() {
|
|
|
2817
2817
|
}
|
|
2818
2818
|
} catch {}
|
|
2819
2819
|
}
|
|
2820
|
+
async function sendShutdown() {
|
|
2821
|
+
try {
|
|
2822
|
+
const { token, convexUrl } = getCloudConfig();
|
|
2823
|
+
cachedDeviceId ??= loadOrCreateDeviceId();
|
|
2824
|
+
await deleteDaemons([cachedDeviceId]);
|
|
2825
|
+
} catch {}
|
|
2826
|
+
}
|
|
2820
2827
|
async function refreshToken(currentToken, convexUrl) {
|
|
2821
2828
|
const res = await requestText(`${convexUrl}/api/cli/refresh`, {
|
|
2822
2829
|
method: "POST",
|
|
@@ -3201,7 +3208,7 @@ async function runWorker() {
|
|
|
3201
3208
|
const adapters = resolveAdapters(config.enabledAdapters);
|
|
3202
3209
|
setActiveAdapters(adapters);
|
|
3203
3210
|
console.log(`[agendex] daemon starting with ${config.enabledAdapters.length} adapters`);
|
|
3204
|
-
sendHeartbeat();
|
|
3211
|
+
await sendHeartbeat();
|
|
3205
3212
|
const syncCache = loadSyncCache();
|
|
3206
3213
|
const syncQueue = [];
|
|
3207
3214
|
let syncing = false;
|
|
@@ -3289,6 +3296,12 @@ async function runWorker() {
|
|
|
3289
3296
|
processSyncQueue();
|
|
3290
3297
|
});
|
|
3291
3298
|
console.log(`[agendex] daemon running. Watching for file changes...`);
|
|
3299
|
+
async function gracefulShutdown() {
|
|
3300
|
+
await sendShutdown();
|
|
3301
|
+
process.exit(0);
|
|
3302
|
+
}
|
|
3303
|
+
process.on("SIGTERM", () => void gracefulShutdown());
|
|
3304
|
+
process.on("SIGINT", () => void gracefulShutdown());
|
|
3292
3305
|
await new Promise(() => {});
|
|
3293
3306
|
}
|
|
3294
3307
|
async function startSupervisor() {
|
|
@@ -3396,7 +3409,7 @@ import { join as join12 } from "node:path";
|
|
|
3396
3409
|
// package.json
|
|
3397
3410
|
var package_default = {
|
|
3398
3411
|
name: "agendex-cli",
|
|
3399
|
-
version: "0.9.
|
|
3412
|
+
version: "0.9.1",
|
|
3400
3413
|
description: "Agendex CLI for login, sync, and daemon workflows",
|
|
3401
3414
|
homepage: "https://github.com/Tyru5/Agendex#readme",
|
|
3402
3415
|
repository: {
|
|
@@ -3592,6 +3605,7 @@ async function main() {
|
|
|
3592
3605
|
writeStderr("[agendex] daemon did not stop in time");
|
|
3593
3606
|
} else {
|
|
3594
3607
|
removePid();
|
|
3608
|
+
await sendShutdown();
|
|
3595
3609
|
writeStdout(`[agendex] daemon stopped (PID ${pid})`);
|
|
3596
3610
|
}
|
|
3597
3611
|
return isRunning(pid) ? 1 : 0;
|
|
@@ -3713,6 +3727,7 @@ async function main() {
|
|
|
3713
3727
|
const allDevices = await fetchDevices();
|
|
3714
3728
|
if (allDevices.length > 0) {
|
|
3715
3729
|
const now = Date.now();
|
|
3730
|
+
const localDeviceId = config.deviceId;
|
|
3716
3731
|
writeStdout(`[agendex] All daemons:`);
|
|
3717
3732
|
for (const device of allDevices) {
|
|
3718
3733
|
const age = device.lastSeenAt ? now - device.lastSeenAt : Number.POSITIVE_INFINITY;
|
|
@@ -3720,7 +3735,8 @@ async function main() {
|
|
|
3720
3735
|
const uptimeStr = device.startedAtMs != null ? formatDuration(now - device.startedAtMs) : "~";
|
|
3721
3736
|
const pidStr = device.pid != null ? String(device.pid) : "~";
|
|
3722
3737
|
const hostnameStr = device.hostname ?? "~";
|
|
3723
|
-
|
|
3738
|
+
const isLocal = localDeviceId && device.deviceId === localDeviceId;
|
|
3739
|
+
writeStdout(`- hostname: ${hostnameStr}${isLocal ? " (this machine)" : ""}
|
|
3724
3740
|
pid: ${pidStr}
|
|
3725
3741
|
uptime: ${uptimeStr}
|
|
3726
3742
|
status: ${status}`);
|