anywhere-ai 0.0.29 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +13 -40
  2. 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, openSync } from "fs";
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.29"}`);
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.29"} \u2014 Mobile coding agent
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
- --daemon, -d Run server in background
37
+ --foreground Run in foreground (exit when terminal closes)
38
38
  --no-tunnel Skip Cloudflare tunnel`);
39
39
  process.exit(0);
40
40
  }
@@ -121,6 +121,7 @@ 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("--foreground");
124
125
  var existingPid = getDaemonPid();
125
126
  if (existingPid) {
126
127
  console.log(`Server already running (PID ${existingPid}). Use 'anywhere-ai stop' first.`);
@@ -130,9 +131,9 @@ async function checkForUpdate() {
130
131
  try {
131
132
  const res = await fetch("https://registry.npmjs.org/anywhere-ai/latest", { signal: AbortSignal.timeout(3e3) });
132
133
  const data = await res.json();
133
- if (data.version && data.version !== "0.0.29") {
134
+ if (data.version && data.version !== "0.0.31") {
134
135
  console.log(`
135
- Update available: v${"0.0.29"} \u2192 v${data.version}`);
136
+ Update available: v${"0.0.31"} \u2192 v${data.version}`);
136
137
  console.log(` Run: npx anywhere-ai@latest
137
138
  `);
138
139
  }
@@ -414,10 +415,7 @@ if (!args.includes("--no-tunnel")) {
414
415
  }
415
416
  var localURL = isVPS ? "http://" + publicIP + ":" + port : "http://" + (localIP || "localhost") + ":" + port;
416
417
  var serverURL = tunnelURL || localURL;
417
- var isDaemonized = args.includes("--_daemonized");
418
- if (!isDaemonized) {
419
- await printBanner(serverURL, localURL);
420
- }
418
+ await printBanner(serverURL, localURL);
421
419
  writeFileSync(PID_PATH, String(process.pid));
422
420
  writeFileSync(STATUS_PATH, JSON.stringify({
423
421
  serverURL,
@@ -426,39 +424,14 @@ writeFileSync(STATUS_PATH, JSON.stringify({
426
424
  startedAt: Date.now(),
427
425
  pid: process.pid
428
426
  }, null, 2));
429
- var isDaemon = args.includes("--daemon") || args.includes("-d");
430
427
  if (isDaemon) {
431
- const logFd = openSync(LOG_PATH, "a");
432
- const child = spawn(process.execPath, [new URL(import.meta.url).pathname, ...args.filter((a) => a !== "--daemon" && a !== "-d"), "--_daemonized"], {
433
- detached: true,
434
- stdio: ["ignore", logFd, logFd],
435
- env: { ...process.env }
428
+ process.on("SIGHUP", () => {
436
429
  });
437
- child.unref();
438
- writeFileSync(PID_PATH, String(child.pid));
439
- writeFileSync(STATUS_PATH, JSON.stringify({
440
- serverURL,
441
- localURL,
442
- authToken: config.authToken,
443
- startedAt: Date.now(),
444
- pid: child.pid
445
- }, null, 2));
446
- console.log(`
447
- Running in background (PID ${child.pid})`);
448
- console.log(` Logs: ${LOG_PATH}`);
430
+ console.log(" Server will keep running after terminal closes.");
431
+ console.log(" Use --foreground to disable this behavior.");
449
432
  console.log(` Status: anywhere-ai status`);
450
- console.log(` Stop: anywhere-ai stop
451
- `);
452
- intentionalShutdown = true;
453
- if (serverProcess) {
454
- serverProcess.kill();
455
- serverProcess = null;
456
- }
457
- if (tunnelProcess) {
458
- tunnelProcess.kill();
459
- tunnelProcess = null;
460
- }
461
- process.exit(0);
433
+ console.log(` Stop: anywhere-ai stop`);
434
+ console.log();
462
435
  }
463
436
  function cleanup() {
464
437
  intentionalShutdown = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anywhere-ai",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "type": "module",
5
5
  "description": "Code on any repo from your phone",
6
6
  "bin": {