nextclaw 0.5.0 → 0.5.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.
Files changed (2) hide show
  1. package/dist/cli/index.js +45 -5
  2. package/package.json +3 -3
package/dist/cli/index.js CHANGED
@@ -130,7 +130,7 @@ async function resolvePublicIp(timeoutMs = 1500) {
130
130
  }
131
131
  function buildServeArgs(options) {
132
132
  const cliPath = fileURLToPath(new URL("./index.js", import.meta.url));
133
- return [cliPath, "serve", "--ui-host", options.uiHost, "--ui-port", String(options.uiPort)];
133
+ return [cliPath, "serve", "--ui-port", String(options.uiPort)];
134
134
  }
135
135
  function readServiceState() {
136
136
  const path = resolveServiceStatePath();
@@ -2273,13 +2273,19 @@ ${this.logo} ${APP_NAME} is ready! (${source})`);
2273
2273
  };
2274
2274
  }
2275
2275
  })();
2276
- await this.printPublicUiUrls(parsedUi.host, parsedUi.port);
2277
2276
  if (parsedUi.host !== uiConfig.host || parsedUi.port !== uiConfig.port) {
2278
2277
  console.log(
2279
- `Note: requested UI bind (${uiConfig.host}:${uiConfig.port}) differs from running service (${parsedUi.host}:${parsedUi.port}).`
2278
+ `Detected running service UI bind (${parsedUi.host}:${parsedUi.port}); enforcing (${uiConfig.host}:${uiConfig.port})...`
2280
2279
  );
2281
- console.log(`Run: ${APP_NAME} restart`);
2280
+ await this.stopService();
2281
+ const stateAfterStop = readServiceState();
2282
+ if (stateAfterStop && isProcessRunning(stateAfterStop.pid)) {
2283
+ console.error("Error: Failed to stop running service while enforcing public UI exposure.");
2284
+ return;
2285
+ }
2286
+ return this.startService(options);
2282
2287
  }
2288
+ await this.printPublicUiUrls(parsedUi.host, parsedUi.port);
2283
2289
  console.log(`Logs: ${existing.logPath}`);
2284
2290
  console.log(`Stop: ${APP_NAME} stop`);
2285
2291
  return;
@@ -2295,7 +2301,6 @@ ${this.logo} ${APP_NAME} is ready! (${source})`);
2295
2301
  mkdirSync2(logDir, { recursive: true });
2296
2302
  const logFd = openSync(logPath, "a");
2297
2303
  const serveArgs = buildServeArgs({
2298
- uiHost: uiConfig.host,
2299
2304
  uiPort: uiConfig.port
2300
2305
  });
2301
2306
  const child = spawn2(process.execPath, [...process.execArgv, ...serveArgs], {
@@ -2308,6 +2313,24 @@ ${this.logo} ${APP_NAME} is ready! (${source})`);
2308
2313
  console.error("Error: Failed to start background service.");
2309
2314
  return;
2310
2315
  }
2316
+ const healthUrl = `${apiUrl}/health`;
2317
+ const started = await this.waitForBackgroundServiceReady({
2318
+ pid: child.pid,
2319
+ healthUrl,
2320
+ timeoutMs: 8e3
2321
+ });
2322
+ if (!started) {
2323
+ if (isProcessRunning(child.pid)) {
2324
+ try {
2325
+ process.kill(child.pid, "SIGTERM");
2326
+ await waitForExit(child.pid, 2e3);
2327
+ } catch {
2328
+ }
2329
+ }
2330
+ clearServiceState();
2331
+ console.error(`Error: Failed to start background service. Check logs: ${logPath}`);
2332
+ return;
2333
+ }
2311
2334
  child.unref();
2312
2335
  const state = {
2313
2336
  pid: child.pid,
@@ -2329,6 +2352,23 @@ ${this.logo} ${APP_NAME} is ready! (${source})`);
2329
2352
  openBrowser(uiUrl);
2330
2353
  }
2331
2354
  }
2355
+ async waitForBackgroundServiceReady(params) {
2356
+ const startedAt = Date.now();
2357
+ while (Date.now() - startedAt < params.timeoutMs) {
2358
+ if (!isProcessRunning(params.pid)) {
2359
+ return false;
2360
+ }
2361
+ try {
2362
+ const response = await fetch(params.healthUrl, { method: "GET" });
2363
+ if (response.ok) {
2364
+ return true;
2365
+ }
2366
+ } catch {
2367
+ }
2368
+ await new Promise((resolve5) => setTimeout(resolve5, 200));
2369
+ }
2370
+ return false;
2371
+ }
2332
2372
  async stopService() {
2333
2373
  const state = readServiceState();
2334
2374
  if (!state) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextclaw",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -38,8 +38,8 @@
38
38
  "dependencies": {
39
39
  "chokidar": "^3.6.0",
40
40
  "commander": "^12.1.0",
41
- "@nextclaw/core": "^0.5.0",
42
- "@nextclaw/server": "^0.3.6",
41
+ "@nextclaw/core": "^0.5.1",
42
+ "@nextclaw/server": "^0.3.7",
43
43
  "@nextclaw/openclaw-compat": "^0.1.3"
44
44
  },
45
45
  "devDependencies": {