anywhere-ai 0.0.29 → 0.0.30

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 +29 -39
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -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.30"}`);
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.30"} \u2014 Mobile coding agent
25
25
 
26
26
  Usage: anywhere-ai [command] [options]
27
27
 
@@ -121,8 +121,32 @@ 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("--daemon") || args.includes("-d");
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
148
  var existingPid = getDaemonPid();
125
- if (existingPid) {
149
+ if (existingPid && !args.includes("--_daemonized")) {
126
150
  console.log(`Server already running (PID ${existingPid}). Use 'anywhere-ai stop' first.`);
127
151
  process.exit(1);
128
152
  }
@@ -130,9 +154,9 @@ async function checkForUpdate() {
130
154
  try {
131
155
  const res = await fetch("https://registry.npmjs.org/anywhere-ai/latest", { signal: AbortSignal.timeout(3e3) });
132
156
  const data = await res.json();
133
- if (data.version && data.version !== "0.0.29") {
157
+ if (data.version && data.version !== "0.0.30") {
134
158
  console.log(`
135
- Update available: v${"0.0.29"} \u2192 v${data.version}`);
159
+ Update available: v${"0.0.30"} \u2192 v${data.version}`);
136
160
  console.log(` Run: npx anywhere-ai@latest
137
161
  `);
138
162
  }
@@ -426,40 +450,6 @@ writeFileSync(STATUS_PATH, JSON.stringify({
426
450
  startedAt: Date.now(),
427
451
  pid: process.pid
428
452
  }, null, 2));
429
- var isDaemon = args.includes("--daemon") || args.includes("-d");
430
- 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 }
436
- });
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}`);
449
- 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);
462
- }
463
453
  function cleanup() {
464
454
  intentionalShutdown = true;
465
455
  if (serverProcess) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anywhere-ai",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "type": "module",
5
5
  "description": "Code on any repo from your phone",
6
6
  "bin": {