@jait/gateway 0.1.211 → 0.1.212
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/jait.mjs +90 -1
- package/package.json +4 -2
package/bin/jait.mjs
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* jait start Start the gateway in the background
|
|
9
9
|
* jait stop Stop the background gateway
|
|
10
10
|
* jait status Check if the gateway is running
|
|
11
|
+
* jait reset Wipe all data
|
|
11
12
|
* jait --port 9000 Use a custom port
|
|
12
13
|
* jait --host 127.0.0.1 Bind to specific host
|
|
13
14
|
* jait --help Show help
|
|
@@ -21,12 +22,13 @@
|
|
|
21
22
|
* jait daemon logs Tail service logs
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
|
-
import { readFileSync, existsSync, writeFileSync, mkdirSync, unlinkSync, openSync } from "node:fs";
|
|
25
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync, unlinkSync, openSync, rmSync, readdirSync, statSync } from "node:fs";
|
|
25
26
|
import { resolve, dirname, join } from "node:path";
|
|
26
27
|
import { homedir, platform } from "node:os";
|
|
27
28
|
import { fileURLToPath } from "node:url";
|
|
28
29
|
import { execSync, spawn } from "node:child_process";
|
|
29
30
|
import { createConnection } from "node:net";
|
|
31
|
+
import { createInterface } from "node:readline";
|
|
30
32
|
|
|
31
33
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
32
34
|
const pkg = JSON.parse(
|
|
@@ -73,6 +75,7 @@ Commands:
|
|
|
73
75
|
start Start the gateway in the background
|
|
74
76
|
stop Stop the background gateway
|
|
75
77
|
status Check if the gateway is running
|
|
78
|
+
reset Wipe all data (~/.jait)
|
|
76
79
|
daemon <cmd> Manage systemd service (Linux only)
|
|
77
80
|
|
|
78
81
|
Options:
|
|
@@ -258,6 +261,87 @@ function cmdStop() {
|
|
|
258
261
|
console.log("");
|
|
259
262
|
}
|
|
260
263
|
|
|
264
|
+
function prompt(question) {
|
|
265
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
266
|
+
return new Promise((res) => rl.question(question, (answer) => { rl.close(); res(answer.trim()); }));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function formatBytes(bytes) {
|
|
270
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
271
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
272
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function dirSize(dir) {
|
|
276
|
+
let total = 0;
|
|
277
|
+
try {
|
|
278
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
279
|
+
const p = join(dir, entry.name);
|
|
280
|
+
if (entry.isDirectory()) total += dirSize(p);
|
|
281
|
+
else try { total += statSync(p).size; } catch {}
|
|
282
|
+
}
|
|
283
|
+
} catch {}
|
|
284
|
+
return total;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function cmdReset() {
|
|
288
|
+
printBanner();
|
|
289
|
+
|
|
290
|
+
if (!existsSync(JAIT_DIR)) {
|
|
291
|
+
console.log(` Nothing to reset — ${JAIT_DIR} does not exist.`);
|
|
292
|
+
console.log("");
|
|
293
|
+
process.exit(0);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Show what will be deleted
|
|
297
|
+
const size = dirSize(JAIT_DIR);
|
|
298
|
+
console.log(` This will permanently delete ALL Jait data:`);
|
|
299
|
+
console.log(``);
|
|
300
|
+
console.log(` ${JAIT_DIR} (${formatBytes(size)})`);
|
|
301
|
+
console.log(``);
|
|
302
|
+
console.log(` This includes:`);
|
|
303
|
+
console.log(` • Database (accounts, sessions, threads, messages)`);
|
|
304
|
+
console.log(` • Configuration (.env, settings)`);
|
|
305
|
+
console.log(` • Logs`);
|
|
306
|
+
console.log(` • PID files`);
|
|
307
|
+
console.log(``);
|
|
308
|
+
|
|
309
|
+
const answer1 = await prompt(" Are you sure? Type 'yes' to continue: ");
|
|
310
|
+
if (answer1.toLowerCase() !== "yes") {
|
|
311
|
+
console.log(" Aborted.");
|
|
312
|
+
console.log("");
|
|
313
|
+
process.exit(0);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const answer2 = await prompt(" This cannot be undone. Type 'delete everything' to confirm: ");
|
|
317
|
+
if (answer2.toLowerCase() !== "delete everything") {
|
|
318
|
+
console.log(" Aborted.");
|
|
319
|
+
console.log("");
|
|
320
|
+
process.exit(0);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Stop running instance first
|
|
324
|
+
if (existsSync(PID_PATH)) {
|
|
325
|
+
const pid = readFileSync(PID_PATH, "utf8").trim();
|
|
326
|
+
if (isProcessRunning(pid)) {
|
|
327
|
+
console.log(` Stopping running instance (PID ${pid})...`);
|
|
328
|
+
try {
|
|
329
|
+
if (platform() === "win32") {
|
|
330
|
+
execSync(`taskkill /PID ${pid} /T /F`, { stdio: "ignore" });
|
|
331
|
+
} else {
|
|
332
|
+
process.kill(Number(pid), "SIGTERM");
|
|
333
|
+
}
|
|
334
|
+
} catch {}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
rmSync(JAIT_DIR, { recursive: true, force: true });
|
|
339
|
+
console.log(``);
|
|
340
|
+
console.log(` Done. All data in ${JAIT_DIR} has been deleted.`);
|
|
341
|
+
console.log(` Run 'jait' to start fresh.`);
|
|
342
|
+
console.log("");
|
|
343
|
+
}
|
|
344
|
+
|
|
261
345
|
// ── Daemon commands ─────────────────────────────────────────────────
|
|
262
346
|
|
|
263
347
|
function ensureLinux() {
|
|
@@ -470,6 +554,11 @@ if (args[0] === "stop") {
|
|
|
470
554
|
process.exit(0);
|
|
471
555
|
}
|
|
472
556
|
|
|
557
|
+
if (args[0] === "reset") {
|
|
558
|
+
await cmdReset();
|
|
559
|
+
process.exit(0);
|
|
560
|
+
}
|
|
561
|
+
|
|
473
562
|
// Check for daemon subcommand first
|
|
474
563
|
if (args[0] === "daemon") {
|
|
475
564
|
const subCmd = args[1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jait/gateway",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.212",
|
|
4
4
|
"description": "Jait AI gateway — local-first AI coding agent with terminal, filesystem, and browser control",
|
|
5
5
|
"author": "JakobWl",
|
|
6
6
|
"type": "module",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"@jait/screen-share": "^0.1.21",
|
|
46
46
|
"@jait/shared": "^0.1.36",
|
|
47
47
|
"@parcel/watcher": "^2.5.6",
|
|
48
|
-
"better-sqlite3": "^12.6.2",
|
|
49
48
|
"dotenv": "^16.4.0",
|
|
50
49
|
"drizzle-orm": "^0.45.1",
|
|
51
50
|
"fastify": "^5.2.0",
|
|
@@ -56,6 +55,9 @@
|
|
|
56
55
|
"playwright": "^1.58.2",
|
|
57
56
|
"ws": "^8.18.0"
|
|
58
57
|
},
|
|
58
|
+
"optionalDependencies": {
|
|
59
|
+
"better-sqlite3": "^12.6.2"
|
|
60
|
+
},
|
|
59
61
|
"devDependencies": {
|
|
60
62
|
"@types/better-sqlite3": "^7.6.0",
|
|
61
63
|
"@types/ws": "^8.5.0",
|