anywhere-ai 0.0.30 → 0.0.31
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 +18 -35
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import fs from "fs/promises";
|
|
5
|
-
import { readFileSync, existsSync, writeFileSync, unlinkSync
|
|
5
|
+
import { readFileSync, existsSync, writeFileSync, unlinkSync } from "fs";
|
|
6
6
|
import os from "os";
|
|
7
7
|
import path from "path";
|
|
8
8
|
import crypto from "crypto";
|
|
@@ -17,11 +17,11 @@ var STATUS_PATH = path.join(ANYWHERE_DIR, "status.json");
|
|
|
17
17
|
var args = process.argv.slice(2);
|
|
18
18
|
var command = args.find((a) => !a.startsWith("-"));
|
|
19
19
|
if (args.includes("--version") || args.includes("-v")) {
|
|
20
|
-
console.log(`anywhere-ai v${"0.0.
|
|
20
|
+
console.log(`anywhere-ai v${"0.0.31"}`);
|
|
21
21
|
process.exit(0);
|
|
22
22
|
}
|
|
23
23
|
if (args.includes("--help") || args.includes("-h") || command === "help") {
|
|
24
|
-
console.log(`anywhere-ai v${"0.0.
|
|
24
|
+
console.log(`anywhere-ai v${"0.0.31"} \u2014 Mobile coding agent
|
|
25
25
|
|
|
26
26
|
Usage: anywhere-ai [command] [options]
|
|
27
27
|
|
|
@@ -34,7 +34,7 @@ Commands:
|
|
|
34
34
|
Options:
|
|
35
35
|
--help, -h Show this help message
|
|
36
36
|
--version, -v Show version
|
|
37
|
-
--
|
|
37
|
+
--foreground Run in foreground (exit when terminal closes)
|
|
38
38
|
--no-tunnel Skip Cloudflare tunnel`);
|
|
39
39
|
process.exit(0);
|
|
40
40
|
}
|
|
@@ -121,32 +121,9 @@ if (command === "regenerate-token") {
|
|
|
121
121
|
console.log("New auth token: " + config2.authToken);
|
|
122
122
|
process.exit(0);
|
|
123
123
|
}
|
|
124
|
-
var isDaemon = args.includes("--
|
|
125
|
-
if (isDaemon && !args.includes("--_daemonized")) {
|
|
126
|
-
await fs.mkdir(ANYWHERE_DIR, { recursive: true });
|
|
127
|
-
const existingPid2 = getDaemonPid();
|
|
128
|
-
if (existingPid2) {
|
|
129
|
-
console.log(`Server already running (PID ${existingPid2}). Use 'anywhere-ai stop' first.`);
|
|
130
|
-
process.exit(1);
|
|
131
|
-
}
|
|
132
|
-
const logFd = openSync(LOG_PATH, "a");
|
|
133
|
-
const daemonArgs = args.filter((a) => a !== "--daemon" && a !== "-d");
|
|
134
|
-
daemonArgs.push("--_daemonized");
|
|
135
|
-
const child = spawn(process.execPath, [new URL(import.meta.url).pathname, ...daemonArgs], {
|
|
136
|
-
detached: true,
|
|
137
|
-
stdio: ["ignore", logFd, logFd],
|
|
138
|
-
env: { ...process.env }
|
|
139
|
-
});
|
|
140
|
-
child.unref();
|
|
141
|
-
writeFileSync(PID_PATH, String(child.pid));
|
|
142
|
-
console.log(`Starting server in background (PID ${child.pid})...`);
|
|
143
|
-
console.log(` Logs: ${LOG_PATH}`);
|
|
144
|
-
console.log(` Status: anywhere-ai status`);
|
|
145
|
-
console.log(` Stop: anywhere-ai stop`);
|
|
146
|
-
process.exit(0);
|
|
147
|
-
}
|
|
124
|
+
var isDaemon = !args.includes("--foreground");
|
|
148
125
|
var existingPid = getDaemonPid();
|
|
149
|
-
if (existingPid
|
|
126
|
+
if (existingPid) {
|
|
150
127
|
console.log(`Server already running (PID ${existingPid}). Use 'anywhere-ai stop' first.`);
|
|
151
128
|
process.exit(1);
|
|
152
129
|
}
|
|
@@ -154,9 +131,9 @@ async function checkForUpdate() {
|
|
|
154
131
|
try {
|
|
155
132
|
const res = await fetch("https://registry.npmjs.org/anywhere-ai/latest", { signal: AbortSignal.timeout(3e3) });
|
|
156
133
|
const data = await res.json();
|
|
157
|
-
if (data.version && data.version !== "0.0.
|
|
134
|
+
if (data.version && data.version !== "0.0.31") {
|
|
158
135
|
console.log(`
|
|
159
|
-
Update available: v${"0.0.
|
|
136
|
+
Update available: v${"0.0.31"} \u2192 v${data.version}`);
|
|
160
137
|
console.log(` Run: npx anywhere-ai@latest
|
|
161
138
|
`);
|
|
162
139
|
}
|
|
@@ -438,10 +415,7 @@ if (!args.includes("--no-tunnel")) {
|
|
|
438
415
|
}
|
|
439
416
|
var localURL = isVPS ? "http://" + publicIP + ":" + port : "http://" + (localIP || "localhost") + ":" + port;
|
|
440
417
|
var serverURL = tunnelURL || localURL;
|
|
441
|
-
|
|
442
|
-
if (!isDaemonized) {
|
|
443
|
-
await printBanner(serverURL, localURL);
|
|
444
|
-
}
|
|
418
|
+
await printBanner(serverURL, localURL);
|
|
445
419
|
writeFileSync(PID_PATH, String(process.pid));
|
|
446
420
|
writeFileSync(STATUS_PATH, JSON.stringify({
|
|
447
421
|
serverURL,
|
|
@@ -450,6 +424,15 @@ writeFileSync(STATUS_PATH, JSON.stringify({
|
|
|
450
424
|
startedAt: Date.now(),
|
|
451
425
|
pid: process.pid
|
|
452
426
|
}, null, 2));
|
|
427
|
+
if (isDaemon) {
|
|
428
|
+
process.on("SIGHUP", () => {
|
|
429
|
+
});
|
|
430
|
+
console.log(" Server will keep running after terminal closes.");
|
|
431
|
+
console.log(" Use --foreground to disable this behavior.");
|
|
432
|
+
console.log(` Status: anywhere-ai status`);
|
|
433
|
+
console.log(` Stop: anywhere-ai stop`);
|
|
434
|
+
console.log();
|
|
435
|
+
}
|
|
453
436
|
function cleanup() {
|
|
454
437
|
intentionalShutdown = true;
|
|
455
438
|
if (serverProcess) {
|