@geminilight/mindos 0.5.24 → 0.5.25

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.
@@ -15,16 +15,17 @@ function isPortInUse(port: number): Promise<boolean> {
15
15
  }
16
16
 
17
17
  async function isSelfPort(port: number): Promise<boolean> {
18
- try {
19
- const res = await fetch(`http://127.0.0.1:${port}/api/health`, {
20
- signal: AbortSignal.timeout(800),
21
- });
22
- if (!res.ok) return false;
23
- const data = await res.json() as Record<string, unknown>;
24
- return data.service === 'mindos';
25
- } catch {
26
- return false;
18
+ for (const host of ['127.0.0.1', 'localhost']) {
19
+ try {
20
+ const res = await fetch(`http://${host}:${port}/api/health`, {
21
+ signal: AbortSignal.timeout(2000),
22
+ });
23
+ if (!res.ok) continue;
24
+ const data = await res.json() as Record<string, unknown>;
25
+ if (data.service === 'mindos') return true;
26
+ } catch { /* try next host */ }
27
27
  }
28
+ return false;
28
29
  }
29
30
 
30
31
  async function findFreePort(start: number, selfPorts: Set<number>): Promise<number | null> {
package/bin/cli.js CHANGED
@@ -245,7 +245,7 @@ const commands = {
245
245
  // Do NOT call start() here — kickstart -k would kill the just-started process,
246
246
  // causing a port-conflict race condition with KeepAlive restart loops.
247
247
  console.log(dim(' (First run may take a few minutes to install dependencies and build the app.)'));
248
- const ready = await waitForHttp(Number(webPort), { retries: 120, intervalMs: 2000, label: 'Web UI', logFile: LOG_PATH });
248
+ const ready = await waitForHttp(Number(webPort), { retries: 180, intervalMs: 2000, label: 'Web UI', logFile: LOG_PATH });
249
249
  if (!ready) {
250
250
  console.error(red('\n✘ Service started but Web UI did not become ready in time.'));
251
251
  console.error(dim(' Check logs with: mindos logs\n'));
@@ -124,13 +124,15 @@ export async function waitForHttp(port, { retries = 60, intervalMs = 2000, label
124
124
  for (let i = 0; i < retries; i++) {
125
125
  try {
126
126
  const { request } = await import('node:http');
127
- const ok = await new Promise((resolve) => {
128
- const req = request({ hostname: '127.0.0.1', port, path: '/api/health', method: 'GET', timeout: 1500 },
127
+ // Try both 127.0.0.1 and localhost Next.js may bind differently
128
+ const tryHost = async (hostname) => new Promise((resolve) => {
129
+ const req = request({ hostname, port, path: '/api/health', method: 'GET', timeout: 5000 },
129
130
  (res) => { res.resume(); resolve(res.statusCode < 500); });
130
131
  req.on('error', () => resolve(false));
131
132
  req.on('timeout', () => { req.destroy(); resolve(false); });
132
133
  req.end();
133
134
  });
135
+ const ok = await tryHost('127.0.0.1') || await tryHost('localhost');
134
136
  if (ok) {
135
137
  process.stdout.write(`\r\x1b[K`);
136
138
  process.stdout.write(` ${green('\u2714')} ${label} ready ${dim(`(${elapsed()})`)}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geminilight/mindos",
3
- "version": "0.5.24",
3
+ "version": "0.5.25",
4
4
  "description": "MindOS — Human-Agent Collaborative Mind System. Local-first knowledge base that syncs your mind to all AI Agents via MCP.",
5
5
  "keywords": [
6
6
  "mindos",
package/scripts/setup.js CHANGED
@@ -902,7 +902,7 @@ async function startGuiSetup() {
902
902
 
903
903
  // Wait for the server to be ready (120s timeout)
904
904
  const { waitForHttp } = await import('../bin/lib/gateway.js');
905
- const ready = await waitForHttp(usePort, { retries: 120, intervalMs: 1000, label: 'MindOS', logFile: LOG_PATH });
905
+ const ready = await waitForHttp(usePort, { retries: 180, intervalMs: 1000, label: 'MindOS', logFile: LOG_PATH });
906
906
 
907
907
  if (!ready) {
908
908
  write(c.red('\n✘ Server failed to start.\n'));