mobygate 0.5.0 → 0.5.2

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/CHANGELOG.md CHANGED
@@ -4,6 +4,33 @@ All notable changes to mobygate are documented here. Format loosely follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); version numbers are
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.5.2] — 2026-04-19
8
+
9
+ ### Added
10
+
11
+ - **`mobygate init` auto-opens the dashboard** in the user's default
12
+ browser after the smoke test passes. Closes the last "copy this
13
+ URL to your browser" step of the install flow. Opt out with
14
+ `--no-browser` or `MOBYGATE_NO_BROWSER=1` for headless / CI /
15
+ nested-script contexts. Also auto-skipped when stdout isn't a TTY.
16
+ - macOS: `open`
17
+ - Linux: `xdg-open`
18
+ - Windows: `cmd /c start`
19
+ - Silent no-op if the OS call fails — init never errors out
20
+ because a browser couldn't launch.
21
+
22
+ ## [0.5.1] — 2026-04-19
23
+
24
+ ### Fixed
25
+
26
+ - **Dashboard 404** on `/` after `npm install -g mobygate@latest` on
27
+ some fnm / npm-global setups. Root cause: Express 5's
28
+ `res.sendFile(absolutePath)` + `send` middleware was throwing a
29
+ spurious `NotFoundError` even when `index.html` was present on
30
+ disk. Replaced with `fs.readFile` + `res.send(html)` — more direct,
31
+ no middleware in between, and surfaces any real file-missing
32
+ problem as a readable HTML error page pointing at the fix.
33
+
7
34
  ## [0.5.0] — 2026-04-19
8
35
 
9
36
  The "upgrade should just work" release. Closes an entire class of
package/bin/mobygate.js CHANGED
@@ -35,7 +35,7 @@ import {
35
35
  installLinuxServices, uninstallLinuxServices,
36
36
  queryLinuxUnit, startLinuxUnit, stopLinuxUnit, LINUX_UNITS,
37
37
  nonMacInstallInstructions,
38
- cleanupLegacyServices, killPort,
38
+ cleanupLegacyServices, killPort, openBrowser,
39
39
  } from '../lib/platform.js';
40
40
  import { getAuthStatus, forceRefresh } from '../scripts/auth-helper.js';
41
41
  import { banner, compactBanner } from '../lib/ascii.js';
@@ -287,6 +287,17 @@ async function cmdInit() {
287
287
  print(`Dashboard: ${c.cyan(`http://localhost:${port}`)}`);
288
288
  print(`Configure: ${c.cyan(CONFIG_PATH)}`);
289
289
  print(`Try: ${c.cyan('mobygate status')} | ${c.cyan('mobygate logs')} | ${c.cyan('mobygate auth')}`);
290
+
291
+ // Auto-open the dashboard unless explicitly suppressed (headless / CI /
292
+ // nested scripts). Silent no-op if the OS call fails — we never want init
293
+ // to error out because a browser couldn't launch.
294
+ const noBrowser = process.argv.includes('--no-browser')
295
+ || process.env.MOBYGATE_NO_BROWSER === '1'
296
+ || !process.stdout.isTTY;
297
+ if (!noBrowser) {
298
+ const opened = openBrowser(`http://localhost:${port}`);
299
+ if (opened) print(c.dim(`\nOpening dashboard in your browser…`));
300
+ }
290
301
  }
291
302
 
292
303
  function cmdStart() {
@@ -605,7 +616,8 @@ function usage() {
605
616
  print(`mobygate — OpenAI → Claude Max local gateway
606
617
 
607
618
  Usage:
608
- mobygate init Interactive setup (add --yes to skip prompts)
619
+ mobygate init Interactive setup (add --yes to skip prompts,
620
+ --no-browser to not auto-open the dashboard)
609
621
  mobygate update Upgrade to the latest version + restart service
610
622
  mobygate doctor Diagnose version mismatches, zombie services, port conflicts
611
623
  mobygate start Start the proxy service
package/lib/platform.js CHANGED
@@ -401,6 +401,24 @@ export function cleanupLegacyServices() {
401
401
  * Kill whatever currently owns the given port. Best-effort across platforms.
402
402
  * Returns the list of PIDs killed (empty if nothing was bound).
403
403
  */
404
+ /**
405
+ * Open a URL in the user's default browser. No-op on failure — we never
406
+ * want an init to error out because a browser couldn't launch.
407
+ * - macOS: `open <url>`
408
+ * - Linux: `xdg-open <url>` (falls back to sensible-browser)
409
+ * - Windows: `cmd /c start "" <url>`
410
+ */
411
+ export function openBrowser(url) {
412
+ try {
413
+ if (IS_MAC) spawnSync('open', [url], { stdio: 'ignore', detached: true });
414
+ else if (IS_LINUX) spawnSync('xdg-open', [url], { stdio: 'ignore', detached: true });
415
+ else if (IS_WIN) spawnSync('cmd', ['/c', 'start', '""', url], { stdio: 'ignore', detached: true, windowsHide: true });
416
+ return true;
417
+ } catch {
418
+ return false;
419
+ }
420
+ }
421
+
404
422
  export function killPort(port) {
405
423
  const killed = [];
406
424
  if (IS_MAC || IS_LINUX) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobygate",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "OpenAI-compatible local proxy for Claude Max. The Möbius-strip gateway: OpenAI shape in, Claude Max out.",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -788,11 +788,33 @@ app.use(express.json({ limit: '10mb' }));
788
788
  // GET / — serve dashboard. No-cache headers so browsers always re-fetch
789
789
  // after a mobygate upgrade; otherwise they keep serving the old index.html
790
790
  // from cache and users see a stale dashboard long after the service updated.
791
- app.get('/', (_req, res) => {
791
+ //
792
+ // We use fs.readFile + res.send instead of res.sendFile because Express 5's
793
+ // sendFile + send middleware has produced spurious 404s in npm-global fnm
794
+ // installs even when the file definitely exists — likely an interaction
795
+ // between ESM __dirname resolution and send's internal path checks.
796
+ // readFile is straightforward and gives us a real error to log if the
797
+ // file genuinely is missing.
798
+ app.get('/', async (_req, res) => {
792
799
  res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
793
800
  res.setHeader('Pragma', 'no-cache');
794
801
  res.setHeader('Expires', '0');
795
- res.sendFile(join(__dirname, 'index.html'));
802
+ try {
803
+ const { readFile } = await import('fs/promises');
804
+ const html = await readFile(join(__dirname, 'index.html'), 'utf8');
805
+ res.type('html').send(html);
806
+ } catch (e) {
807
+ res.status(500).type('html').send(
808
+ `<!doctype html><meta charset=utf-8><title>mobygate — dashboard unavailable</title>
809
+ <body style="background:#0B0B09;color:#F3EFE4;font-family:ui-monospace,monospace;padding:2rem">
810
+ <h1>Dashboard failed to load</h1>
811
+ <p>Server is running fine — the dashboard HTML is just missing from the install.</p>
812
+ <pre>Path tried: ${join(__dirname, 'index.html')}</pre>
813
+ <pre>Error: ${e.code || ''} ${e.message}</pre>
814
+ <p>Fix: <code>npm install -g mobygate@latest --force</code></p>
815
+ </body>`
816
+ );
817
+ }
796
818
  });
797
819
 
798
820
  // POST /v1/chat/completions