@myrialabs/clopen 0.3.6 → 0.3.7

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/README.md CHANGED
@@ -57,7 +57,7 @@ A complete development environment designed around AI-assisted workflows, built
57
57
  - **Cloudflare Tunnel** — One-click public HTTPS URL for your local dev server. Built-in QR code for instant mobile access. Share your work without deploying
58
58
  - **MCP Support** — Full Model Context Protocol integration. Connect AI tools, external APIs, and custom capabilities to your AI agents with zero friction
59
59
  - **Flexible Authentication** — No Login or With Login mode with admin/member roles, invite links, rate-limited login, and CLI token recovery
60
- - **System Tools Installer** — Install Git, Claude Code, OpenCode, and Chromium straight from the admin Settings UI, with live install output streamed to the browser via xterm.js
60
+ - **System Tools Installer** — Install Git, Claude Code, OpenCode, Chrome, and Cloudflared (for Public Tunnel) straight from the admin Settings UI, with live install output streamed to the browser via xterm.js
61
61
  - **Background Processing** — Chat, terminal, and other processes continue running even when you close the browser — come back later and pick up where you left off
62
62
  - **Database Management** — Browse tables, run queries, and inspect your database directly from the workspace *(coming soon)*
63
63
 
@@ -88,7 +88,7 @@ Or manually via Bun:
88
88
  bun add -g @myrialabs/clopen
89
89
  ```
90
90
 
91
- You can also update from the **Settings > Maintenance > Updates** section in the web UI.
91
+ You can also update from the **Settings → Maintenance > Updates** section in the web UI.
92
92
 
93
93
  ### Usage
94
94
 
@@ -107,9 +107,9 @@ On first launch, a setup wizard guides you through:
107
107
  3. **AI Engines** — Check Claude Code and OpenCode installation status
108
108
  4. **Preferences** — Set theme, font size, and notification preferences
109
109
 
110
- You can change the authentication mode anytime in **Settings > Security > Authentication**.
110
+ You can change the authentication mode anytime in **Settings → Security > Authentication**.
111
111
 
112
- To invite team members (With Login mode), go to **Settings > Team > Invite** and generate an invite link (valid for 15 minutes).
112
+ To invite team members (With Login mode), go to **Settings → Team > Invite** and generate an invite link (valid for 15 minutes).
113
113
 
114
114
  If you lose your admin token:
115
115
 
@@ -2,7 +2,7 @@
2
2
  * System Tool Install Recipes
3
3
  *
4
4
  * Data-driven registry of install commands for system tools that clopen
5
- * depends on (Git, Claude Code, OpenCode, Chromium for puppeteer). Each
5
+ * depends on (Git, Claude Code, OpenCode, Chrome for puppeteer). Each
6
6
  * recipe is platform-aware and privilege-aware: when the runner cannot
7
7
  * reasonably complete the install non-interactively (e.g. `apt` without
8
8
  * root, `choco` without Administrator), the recipe is marked
@@ -13,15 +13,14 @@
13
13
  * surface a copy-able command and a docs link, regardless of platform.
14
14
  */
15
15
 
16
- import { homedir } from 'node:os';
17
- import { existsSync, readdirSync, readFileSync } from 'node:fs';
16
+ import { existsSync, readdirSync } from 'node:fs';
18
17
  import { join } from 'node:path';
19
18
  import { isElevated } from '$backend/utils/privilege';
20
19
  import { getClopenDir } from '$backend/utils/paths';
21
20
  import { resolveBinary, resolveBinaryWithRefresh } from '$backend/utils/cli';
22
21
  import { resolveStaticCurlAsset } from '$backend/utils/static-curl';
23
22
 
24
- export type ToolId = 'git' | 'claude' | 'opencode' | 'chromium';
23
+ export type ToolId = 'git' | 'claude' | 'opencode' | 'chrome' | 'cloudflared';
25
24
 
26
25
  export interface ManualInstruction {
27
26
  label: string;
@@ -99,32 +98,41 @@ function detectMacPkgMgr(): 'brew' | null {
99
98
  }
100
99
 
101
100
  // ─────────────────────────────────────────────────────────────────────────────
102
- // Chromium detection
101
+ // Chrome detection
103
102
  // ─────────────────────────────────────────────────────────────────────────────
104
103
 
105
104
  /**
106
- * Resolve the Chromium executable path under ~/.clopen/bin using the
107
- * @puppeteer/browsers cache layout: <cache>/chromium/<platform>-<buildId>/<archive>/<binary>.
108
- * Only macOS and Windows install via @puppeteer/browsers — on Linux we
109
- * delegate to the distro package manager and skip this scan.
105
+ * Resolve the Chrome for Testing executable path under ~/.clopen/bin using
106
+ * the @puppeteer/browsers cache layout: <cache>/chrome/<platform>-<buildId>/<archive>/<binary>.
107
+ * Only macOS and Windows install Chrome this way — on Linux we install
108
+ * Google Chrome via the distro package manager and skip this scan.
110
109
  */
111
- export function resolveClopenChromiumPath(): string | null {
110
+ export function resolveClopenChromePath(): string | null {
112
111
  if (process.platform !== 'darwin' && process.platform !== 'win32') return null;
113
112
 
114
- const cacheDir = join(getClopenDir(), 'bin', 'chromium');
113
+ const cacheDir = join(getClopenDir(), 'bin', 'chrome');
115
114
  if (!existsSync(cacheDir)) return null;
116
115
 
117
116
  try {
118
117
  const entries = readdirSync(cacheDir);
119
118
  for (const entry of entries) {
120
119
  const buildDir = join(cacheDir, entry);
121
- let candidate: string;
122
120
  if (process.platform === 'darwin') {
123
- candidate = join(buildDir, 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium');
124
- if (existsSync(candidate)) return candidate;
121
+ const macDirs = ['chrome-mac-arm64', 'chrome-mac-x64', 'chrome-mac'];
122
+ for (const dir of macDirs) {
123
+ const candidate = join(
124
+ buildDir, dir,
125
+ 'Google Chrome for Testing.app',
126
+ 'Contents', 'MacOS', 'Google Chrome for Testing'
127
+ );
128
+ if (existsSync(candidate)) return candidate;
129
+ }
125
130
  } else {
126
- candidate = join(buildDir, 'chrome-win', 'chrome.exe');
127
- if (existsSync(candidate)) return candidate;
131
+ const winDirs = ['chrome-win64', 'chrome-win'];
132
+ for (const dir of winDirs) {
133
+ const candidate = join(buildDir, dir, 'chrome.exe');
134
+ if (existsSync(candidate)) return candidate;
135
+ }
128
136
  }
129
137
  }
130
138
  } catch {
@@ -133,29 +141,37 @@ export function resolveClopenChromiumPath(): string | null {
133
141
  return null;
134
142
  }
135
143
 
136
- function detectSystemChromium(): string | null {
144
+ function detectSystemChrome(): string | null {
137
145
  if (process.platform === 'darwin') {
138
- const paths = ['/Applications/Chromium.app/Contents/MacOS/Chromium'];
139
- for (const p of paths) if (existsSync(p)) return p;
140
- return null;
146
+ const p = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
147
+ return existsSync(p) ? p : null;
141
148
  }
142
149
  if (process.platform === 'win32') {
143
- // Chromium has no canonical Windows install location; rely on PATH.
144
- return resolveBinary('chromium');
150
+ const paths = [
151
+ 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
152
+ 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
153
+ ];
154
+ for (const p of paths) if (existsSync(p)) return p;
155
+ return resolveBinary('chrome');
145
156
  }
146
- // Linux: distro package + snap (Ubuntu).
147
- const snapPath = '/snap/bin/chromium';
148
- if (existsSync(snapPath)) return snapPath;
149
- return resolveBinary('chromium') ?? resolveBinary('chromium-browser');
157
+ // Linux: Google Chrome only (installed via apt/dnf/zypper from dl.google.com).
158
+ const chromePaths = [
159
+ '/opt/google/chrome/chrome',
160
+ '/usr/bin/google-chrome-stable',
161
+ '/usr/bin/google-chrome'
162
+ ];
163
+ for (const p of chromePaths) if (existsSync(p)) return p;
164
+ return resolveBinary('google-chrome-stable') ?? resolveBinary('google-chrome');
150
165
  }
151
166
 
152
167
  /**
153
- * Preferred Chromium executable path for puppeteer. Clopen-managed install
154
- * (macOS/Windows via @puppeteer/browsers) wins over system Chromium so the
155
- * bundled version stays consistent; on Linux only the system path is used.
168
+ * Preferred Chrome executable path for puppeteer. Clopen-managed install
169
+ * (macOS/Windows via @puppeteer/browsers → Chrome for Testing) wins over
170
+ * system Google Chrome so the bundled version stays consistent; on Linux
171
+ * only the system Google Chrome path is used.
156
172
  */
157
- export function getChromiumExecutablePath(): string | null {
158
- return resolveClopenChromiumPath() ?? detectSystemChromium();
173
+ export function getChromeExecutablePath(): string | null {
174
+ return resolveClopenChromePath() ?? detectSystemChrome();
159
175
  }
160
176
 
161
177
  // ─────────────────────────────────────────────────────────────────────────────
@@ -176,11 +192,11 @@ async function runVersion(binary: string, versionFlag = '--version'): Promise<st
176
192
  }
177
193
 
178
194
  export async function getToolStatus(tool: ToolId): Promise<ToolStatus> {
179
- if (tool === 'chromium') {
180
- const resolved = getChromiumExecutablePath();
195
+ if (tool === 'chrome') {
196
+ const resolved = getChromeExecutablePath();
181
197
  if (!resolved) return { tool, installed: false, version: null, source: null };
182
198
  const version = await runVersion(resolved);
183
- const source = resolveClopenChromiumPath() ? 'clopen' : 'system';
199
+ const source = resolveClopenChromePath() ? 'clopen' : resolved;
184
200
  return { tool, installed: true, version, source };
185
201
  }
186
202
 
@@ -188,6 +204,16 @@ export async function getToolStatus(tool: ToolId): Promise<ToolStatus> {
188
204
  if (!resolved) return { tool, installed: false, version: null, source: null };
189
205
  const version = await runVersion(resolved);
190
206
  if (!version) return { tool, installed: false, version: null, source: null };
207
+
208
+ // Cloudflared: tag binaries under ~/.clopen/bin as "clopen"-managed so the
209
+ // UI distinguishes System Tools installs from system-wide ones.
210
+ if (tool === 'cloudflared') {
211
+ const clopenBinDir = join(getClopenDir(), 'bin');
212
+ if (resolved.startsWith(clopenBinDir)) {
213
+ return { tool, installed: true, version, source: 'clopen' };
214
+ }
215
+ }
216
+
191
217
  return { tool, installed: true, version, source: resolved };
192
218
  }
193
219
 
@@ -384,132 +410,92 @@ async function resolveOpenCodeRecipe(): Promise<Recipe> {
384
410
  }
385
411
 
386
412
  // ─────────────────────────────────────────────────────────────────────────────
387
- // Linux distro detection (apt sub-flavour: Debian vs Ubuntu)
413
+ // Chrome recipe — Puppeteer download (macOS/Windows) or Google Chrome (Linux)
388
414
  // ─────────────────────────────────────────────────────────────────────────────
389
415
 
390
- interface LinuxDistro {
391
- id: string;
392
- idLike: string[];
393
- }
394
-
395
- function readLinuxDistro(): LinuxDistro | null {
396
- try {
397
- const text = readFileSync('/etc/os-release', 'utf8');
398
- const fields: Record<string, string> = {};
399
- for (const line of text.split('\n')) {
400
- const eq = line.indexOf('=');
401
- if (eq < 0) continue;
402
- const key = line.slice(0, eq).trim();
403
- let value = line.slice(eq + 1).trim();
404
- if (value.startsWith('"') && value.endsWith('"')) value = value.slice(1, -1);
405
- fields[key] = value;
406
- }
407
- return {
408
- id: (fields['ID'] ?? '').toLowerCase(),
409
- idLike: (fields['ID_LIKE'] ?? '').toLowerCase().split(/\s+/).filter(Boolean)
410
- };
411
- } catch {
412
- return null;
413
- }
414
- }
415
-
416
- function isUbuntuLike(distro: LinuxDistro | null): boolean {
417
- if (!distro) return false;
418
- if (distro.id === 'ubuntu') return true;
419
- return distro.idLike.includes('ubuntu');
420
- }
421
-
422
- // ─────────────────────────────────────────────────────────────────────────────
423
- // Chromium recipe — Puppeteer download (macOS/Windows) or distro pkg (Linux)
424
- // ─────────────────────────────────────────────────────────────────────────────
416
+ const PPTR_CHROME_DOCS = 'https://pptr.dev/browsers-api';
417
+ const CHROME_LINUX_DOCS = 'https://www.google.com/chrome/';
425
418
 
426
- const PPTR_CHROMIUM_DOCS = 'https://pptr.dev/browsers-api';
427
- const PPTR_LINUX_DOCS = 'https://pptr.dev/troubleshooting#chrome-doesnt-launch-on-linux';
419
+ // Google Chrome Linux package URLs. Google only publishes Linux x86_64
420
+ // .deb (apt) and .rpm (dnf/zypper) — other distros / arm64 surface manual
421
+ // instructions.
422
+ const GOOGLE_CHROME_DEB_URL = 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb';
423
+ const GOOGLE_CHROME_RPM_URL = 'https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm';
428
424
 
429
- async function resolveChromiumRecipe(): Promise<Recipe> {
425
+ async function resolveChromeRecipe(): Promise<Recipe> {
430
426
  const cacheDir = join(getClopenDir(), 'bin');
431
- const pptrArgs = ['bun', 'x', '@puppeteer/browsers', 'install', 'chromium@latest', '--path', cacheDir];
432
- const pptrDisplay = `bun x @puppeteer/browsers install chromium@latest --path "${cacheDir}"`;
427
+ const pptrArgs = ['bun', 'x', '@puppeteer/browsers', 'install', 'chrome@stable', '--path', cacheDir];
428
+ const pptrDisplay = `bun x @puppeteer/browsers install chrome@stable --path "${cacheDir}"`;
433
429
 
434
- // macOS / Windows: Puppeteer download is self-contained.
430
+ // macOS / Windows: Puppeteer downloads Chrome for Testing, self-contained.
435
431
  if (process.platform === 'darwin' || process.platform === 'win32') {
436
432
  return {
437
- tool: 'chromium',
433
+ tool: 'chrome',
438
434
  autoInstallable: true,
439
435
  missingPrereqs: [],
440
436
  manualInstructions: [{
441
437
  label: 'Puppeteer browsers CLI',
442
438
  command: pptrDisplay,
443
- docs: PPTR_CHROMIUM_DOCS
439
+ docs: PPTR_CHROME_DOCS
444
440
  }],
445
441
  command: pptrArgs,
446
442
  displayCommand: pptrDisplay
447
443
  };
448
444
  }
449
445
 
450
- // Linux: delegate to distro package manager so deps auto-resolve.
451
- return resolveLinuxChromiumRecipe();
446
+ // Linux: Google Chrome deb/rpm for x86_64 (apt/dnf/zypper). Other
447
+ // distros / arm64 are marked non-auto-installable with manual steps.
448
+ return resolveLinuxChromeRecipe();
452
449
  }
453
450
 
454
- interface LinuxChromiumStrategy {
451
+ interface LinuxChromeStrategy {
455
452
  pkgMgrLabel: string;
456
453
  /** Argv-form command to spawn (sh -c <string>). */
457
454
  installCommand: string;
458
455
  /** User-facing display command (with sudo prefix if interactive). */
459
456
  manualCommand: string;
457
+ /** Whether this strategy shells out to curl (for static-curl fallback). */
458
+ requiresCurl?: boolean;
460
459
  /** Extra env to inject into the spawn. */
461
460
  env?: Record<string, string>;
462
461
  }
463
462
 
464
- async function resolveLinuxChromiumRecipe(): Promise<Recipe> {
465
- const distro = readLinuxDistro();
466
- const ubuntuLike = isUbuntuLike(distro);
463
+ async function resolveLinuxChromeRecipe(): Promise<Recipe> {
467
464
  const mgr = detectLinuxPkgMgr();
465
+ const arch = process.arch;
468
466
 
469
467
  const manual: ManualInstruction[] = [];
470
-
471
- // Always surface the recommended manual command(s) for this platform.
472
- const strategy = pickLinuxChromiumStrategy(mgr, ubuntuLike);
468
+ const strategy = pickLinuxChromeStrategy(mgr, arch);
473
469
 
474
470
  if (strategy) {
475
471
  manual.push({
476
472
  label: `${strategy.pkgMgrLabel} (recommended)`,
477
473
  command: strategy.manualCommand,
478
- docs: PPTR_LINUX_DOCS
479
- });
480
- }
481
-
482
- // Ubuntu users may want a non-snap fallback; mention common alternatives.
483
- if (ubuntuLike) {
484
- manual.push({
485
- label: 'Ubuntu — install snapd first if missing',
486
- command: 'sudo apt-get update && sudo apt-get install -y snapd && sudo snap install chromium',
487
- docs: 'https://snapcraft.io/chromium'
474
+ docs: CHROME_LINUX_DOCS
488
475
  });
489
476
  }
490
477
 
491
478
  const base: Recipe = {
492
- tool: 'chromium',
479
+ tool: 'chrome',
493
480
  autoInstallable: false,
494
481
  missingPrereqs: [],
495
482
  manualInstructions: manual
496
483
  };
497
484
 
498
- if (!mgr || !strategy) {
499
- base.unavailableReason = mgr
500
- ? `No Chromium install strategy is mapped for ${mgr} on this distro. Install Chromium manually with your package manager.`
501
- : 'No supported Linux package manager found (apt / dnf / pacman / apk / zypper). Install Chromium manually.';
485
+ if (!strategy) {
486
+ base.unavailableReason = arch !== 'x64'
487
+ ? `Google Chrome is only published for Linux x86_64. No Chrome build exists for ${arch}. Download Chrome manually from google.com/chrome.`
488
+ : `Google Chrome is only available via apt, dnf, or zypper on Linux${mgr ? ` (this system uses ${mgr})` : ' — no supported package manager was detected'}. Download Chrome manually from google.com/chrome.`;
502
489
  return base;
503
490
  }
504
491
 
505
- if (ubuntuLike && !resolveBinary('snap')) {
506
- base.unavailableReason = 'Ubuntu Chromium is distributed as a snap, but snapd is not installed on this system. Install snapd first (`sudo apt-get install -y snapd`), then retry — or use the manual instructions below.';
492
+ if (strategy.requiresCurl && !attachCurlRequirement(base, 'Google Chrome')) {
507
493
  return base;
508
494
  }
509
495
 
510
496
  const elevated = await isElevated();
511
497
  if (!elevated) {
512
- base.unavailableReason = `Installing Chromium via ${strategy.pkgMgrLabel} requires root. Run clopen as root, or install Chromium manually with the command below and retry.`;
498
+ base.unavailableReason = `Installing Google Chrome via ${strategy.pkgMgrLabel} requires root. Run clopen as root, or install Chrome manually with the command below and retry.`;
513
499
  return base;
514
500
  }
515
501
 
@@ -521,57 +507,149 @@ async function resolveLinuxChromiumRecipe(): Promise<Recipe> {
521
507
  return base;
522
508
  }
523
509
 
524
- function pickLinuxChromiumStrategy(
510
+ function pickLinuxChromeStrategy(
525
511
  mgr: LinuxPkgMgr | null,
526
- ubuntuLike: boolean
527
- ): LinuxChromiumStrategy | null {
528
- if (mgr === 'apt' && ubuntuLike) {
529
- // Ubuntu's `chromium` / `chromium-browser` deb is a snap shim. Use snap directly.
530
- return {
531
- pkgMgrLabel: 'snap',
532
- installCommand: 'snap install chromium',
533
- manualCommand: 'sudo snap install chromium'
534
- };
535
- }
512
+ arch: string
513
+ ): LinuxChromeStrategy | null {
514
+ // Google only publishes Linux Chrome for x86_64.
515
+ if (arch !== 'x64') return null;
516
+
536
517
  if (mgr === 'apt') {
518
+ // Download + install the .deb from dl.google.com. apt-get install with
519
+ // a local deb path auto-resolves dependencies (libatk, libnss3, etc.)
520
+ // from the distro repos. The postinst adds Google's apt source for
521
+ // future updates.
522
+ const cmd =
523
+ 'apt-get update && apt-get install -y curl ca-certificates && ' +
524
+ `curl -fsSL -o /tmp/google-chrome-stable.deb ${GOOGLE_CHROME_DEB_URL} && ` +
525
+ 'apt-get install -y /tmp/google-chrome-stable.deb && ' +
526
+ 'rm -f /tmp/google-chrome-stable.deb';
537
527
  return {
538
528
  pkgMgrLabel: 'apt',
539
- installCommand: 'apt-get update && apt-get install -y chromium',
540
- manualCommand: 'sudo apt-get update && sudo apt-get install -y chromium',
529
+ installCommand: cmd,
530
+ manualCommand:
531
+ `sudo apt-get update && sudo apt-get install -y curl ca-certificates && ` +
532
+ `curl -fsSL -o /tmp/google-chrome-stable.deb ${GOOGLE_CHROME_DEB_URL} && ` +
533
+ `sudo apt-get install -y /tmp/google-chrome-stable.deb`,
534
+ requiresCurl: true,
541
535
  env: { DEBIAN_FRONTEND: 'noninteractive' }
542
536
  };
543
537
  }
544
538
  if (mgr === 'dnf') {
545
539
  return {
546
540
  pkgMgrLabel: 'dnf',
547
- installCommand: 'dnf install -y chromium',
548
- manualCommand: 'sudo dnf install -y chromium'
549
- };
550
- }
551
- if (mgr === 'pacman') {
552
- return {
553
- pkgMgrLabel: 'pacman',
554
- installCommand: 'pacman -S --noconfirm chromium',
555
- manualCommand: 'sudo pacman -S --noconfirm chromium'
556
- };
557
- }
558
- if (mgr === 'apk') {
559
- return {
560
- pkgMgrLabel: 'apk',
561
- installCommand: 'apk add --no-cache chromium',
562
- manualCommand: 'sudo apk add --no-cache chromium'
541
+ installCommand: `dnf install -y ${GOOGLE_CHROME_RPM_URL}`,
542
+ manualCommand: `sudo dnf install -y ${GOOGLE_CHROME_RPM_URL}`
563
543
  };
564
544
  }
565
545
  if (mgr === 'zypper') {
566
546
  return {
567
547
  pkgMgrLabel: 'zypper',
568
- installCommand: 'zypper --non-interactive install chromium',
569
- manualCommand: 'sudo zypper install chromium'
548
+ installCommand: `zypper --non-interactive --gpg-auto-import-keys install ${GOOGLE_CHROME_RPM_URL}`,
549
+ manualCommand: `sudo zypper install ${GOOGLE_CHROME_RPM_URL}`
570
550
  };
571
551
  }
572
552
  return null;
573
553
  }
574
554
 
555
+ // ─────────────────────────────────────────────────────────────────────────────
556
+ // Cloudflared recipe — downloads the Cloudflare-signed binary into ~/.clopen/bin
557
+ // ─────────────────────────────────────────────────────────────────────────────
558
+
559
+ const CLOUDFLARED_RELEASE_BASE = 'https://github.com/cloudflare/cloudflared/releases/latest/download';
560
+ const CLOUDFLARED_DOCS = 'https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/';
561
+
562
+ const CLOUDFLARED_LINUX_ARCH: Record<string, string> = {
563
+ x64: 'amd64',
564
+ arm64: 'arm64',
565
+ arm: 'arm',
566
+ ia32: '386'
567
+ };
568
+
569
+ async function resolveCloudflaredRecipe(): Promise<Recipe> {
570
+ const base: Recipe = {
571
+ tool: 'cloudflared',
572
+ autoInstallable: false,
573
+ missingPrereqs: [],
574
+ manualInstructions: []
575
+ };
576
+
577
+ const binDir = join(getClopenDir(), 'bin');
578
+
579
+ if (process.platform === 'darwin') {
580
+ const archKey = process.arch === 'arm64' ? 'arm64' : 'amd64';
581
+ const file = `cloudflared-darwin-${archKey}.tgz`;
582
+ const url = `${CLOUDFLARED_RELEASE_BASE}/${file}`;
583
+ const cmd =
584
+ `mkdir -p "${binDir}" && ` +
585
+ `curl -fsSL -o "${binDir}/${file}" "${url}" && ` +
586
+ `tar -xzf "${binDir}/${file}" -C "${binDir}" && ` +
587
+ `rm -f "${binDir}/${file}" && ` +
588
+ `chmod +x "${binDir}/cloudflared"`;
589
+
590
+ base.manualInstructions.push({
591
+ label: 'curl + tar',
592
+ command: cmd,
593
+ docs: CLOUDFLARED_DOCS
594
+ });
595
+ if (!attachCurlRequirement(base, 'Cloudflared')) return base;
596
+ base.autoInstallable = true;
597
+ base.shell = { program: 'bash', args: ['-c'] };
598
+ base.command = [cmd];
599
+ base.displayCommand = cmd;
600
+ return base;
601
+ }
602
+
603
+ if (process.platform === 'linux') {
604
+ const archKey = CLOUDFLARED_LINUX_ARCH[process.arch];
605
+ if (!archKey) {
606
+ base.unavailableReason = `Cloudflared has no published Linux build for ${process.arch}.`;
607
+ return base;
608
+ }
609
+ const file = `cloudflared-linux-${archKey}`;
610
+ const url = `${CLOUDFLARED_RELEASE_BASE}/${file}`;
611
+ const cmd =
612
+ `mkdir -p "${binDir}" && ` +
613
+ `curl -fsSL -o "${binDir}/cloudflared" "${url}" && ` +
614
+ `chmod +x "${binDir}/cloudflared"`;
615
+
616
+ base.manualInstructions.push({
617
+ label: 'curl',
618
+ command: cmd,
619
+ docs: CLOUDFLARED_DOCS
620
+ });
621
+ if (!attachCurlRequirement(base, 'Cloudflared')) return base;
622
+ base.autoInstallable = true;
623
+ base.shell = { program: 'bash', args: ['-c'] };
624
+ base.command = [cmd];
625
+ base.displayCommand = cmd;
626
+ return base;
627
+ }
628
+
629
+ if (process.platform === 'win32') {
630
+ const archKey = process.arch === 'ia32' ? '386' : 'amd64';
631
+ const file = `cloudflared-windows-${archKey}.exe`;
632
+ const url = `${CLOUDFLARED_RELEASE_BASE}/${file}`;
633
+ const psCmd =
634
+ `New-Item -ItemType Directory -Path "${binDir}" -Force | Out-Null; ` +
635
+ `Invoke-WebRequest -Uri "${url}" -OutFile "${binDir}\\cloudflared.exe"`;
636
+
637
+ base.manualInstructions.push({
638
+ label: 'PowerShell',
639
+ command: psCmd,
640
+ docs: CLOUDFLARED_DOCS
641
+ });
642
+ base.autoInstallable = true;
643
+ base.shell = { program: 'powershell.exe', args: ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command'] };
644
+ base.command = [psCmd];
645
+ base.displayCommand = psCmd;
646
+ return base;
647
+ }
648
+
649
+ base.unavailableReason = `Unsupported platform: ${process.platform}`;
650
+ return base;
651
+ }
652
+
575
653
  /**
576
654
  * Resolve the install recipe for a tool on the current platform.
577
655
  * Result is platform- and privilege-aware: recipes that would fail
@@ -582,6 +660,7 @@ export async function resolveRecipe(tool: ToolId): Promise<Recipe> {
582
660
  case 'git': return resolveGitRecipe();
583
661
  case 'claude': return resolveClaudeRecipe();
584
662
  case 'opencode': return resolveOpenCodeRecipe();
585
- case 'chromium': return resolveChromiumRecipe();
663
+ case 'chrome': return resolveChromeRecipe();
664
+ case 'cloudflared': return resolveCloudflaredRecipe();
586
665
  }
587
666
  }
@@ -17,6 +17,7 @@
17
17
  * may only pick a tool id; it cannot supply arbitrary command strings.
18
18
  */
19
19
 
20
+ import { freemem, totalmem } from 'node:os';
20
21
  import { debug } from '$shared/utils/logger';
21
22
  import { ws } from '$backend/utils/ws';
22
23
  import { getCleanSpawnEnv } from '$backend/utils/env';
@@ -191,6 +192,40 @@ async function runStreamedProcess(session: Session, proc: ReturnType<typeof Bun.
191
192
  return exitCode;
192
193
  }
193
194
 
195
+ function formatBytes(bytes: number): string {
196
+ const mb = bytes / (1024 * 1024);
197
+ if (mb < 1024) return `${mb.toFixed(0)} MB`;
198
+ return `${(mb / 1024).toFixed(1)} GB`;
199
+ }
200
+
201
+ /**
202
+ * Build a human-readable hint for non-zero exit codes that likely indicate
203
+ * an environmental problem (OOM kill, external termination) rather than a
204
+ * recipe bug. Returns null when no specific guidance applies.
205
+ *
206
+ * Shells propagate signals as `128 + signum`: 137 = SIGKILL (OOM killer on
207
+ * Linux), 143 = SIGTERM. On a cancelled session we skip the hint — the UI
208
+ * already labels the run as "Cancelled".
209
+ */
210
+ function explainFailure(exitCode: number, cancelled: boolean): string | null {
211
+ if (cancelled) return null;
212
+ if (exitCode === 137) {
213
+ const total = formatBytes(totalmem());
214
+ const free = formatBytes(freemem());
215
+ return [
216
+ '',
217
+ '⚠ Exit 137 — the process was killed (SIGKILL), almost always by the kernel out-of-memory killer.',
218
+ ` System memory: total=${total}, free=${free}.`,
219
+ ' Common causes: low-RAM VPS / container / WSL without enough swap. Installer subprocesses can briefly peak at several hundred MB of memory.',
220
+ ' Remedies: add swap, raise the container memory limit, or run the install command in a shell with more memory, then retry.'
221
+ ].join('\n');
222
+ }
223
+ if (exitCode === 143) {
224
+ return '\n⚠ Exit 143 — the process received SIGTERM (external termination). Possible causes: systemd/container shutdown, manual kill, or an orchestrator timeout.';
225
+ }
226
+ return null;
227
+ }
228
+
194
229
  async function runInstall(session: Session, env: Record<string, string>): Promise<void> {
195
230
  const { recipe } = session;
196
231
  let proc: ReturnType<typeof Bun.spawn>;
@@ -240,6 +275,10 @@ async function runInstall(session: Session, env: Record<string, string>): Promis
240
275
  session.proc = proc;
241
276
 
242
277
  const exitCode = await runStreamedProcess(session, proc);
278
+ if (exitCode !== 0) {
279
+ const hint = explainFailure(exitCode, session.status === 'cancelled');
280
+ if (hint) emitStream(session, 'stderr', hint + '\n');
281
+ }
243
282
  finalizeSession(session, exitCode === 0 ? 'success' : 'failed', exitCode);
244
283
  }
245
284
 
@@ -68,9 +68,9 @@ Automatically creates session. New tab is immediately active - no need to switch
68
68
 
69
69
  VIEWPORT MODES:
70
70
  - desktop: 1920x1080 (default rotation: landscape) - For testing full desktop layouts
71
- - laptop: 1280x800 (default, default rotation: landscape) - Most common desktop viewport
72
- - tablet: 820x1050 (default rotation: portrait) - iPad-like tablet viewport
73
- - mobile: 393x740 (default rotation: portrait) - Modern smartphone viewport
71
+ - laptop: 1440x900 (default, default rotation: landscape) - Modern 14" laptop viewport
72
+ - tablet: 834x1194 (default rotation: portrait) - iPad Pro 11" class viewport
73
+ - mobile: 402x874 (default rotation: portrait) - iPhone 16 / modern flagship viewport
74
74
 
75
75
  ROTATION:
76
76
  - portrait: Standard vertical orientation (default for tablet/mobile)
@@ -114,9 +114,9 @@ OUTPUT: Confirmation with tab ID and new viewport settings.
114
114
 
115
115
  VIEWPORT MODES:
116
116
  - desktop: 1920x1080 - For testing full desktop layouts
117
- - laptop: 1280x800 - Most common desktop viewport
118
- - tablet: 820x1050 - iPad-like tablet viewport
119
- - mobile: 393x740 - Modern smartphone viewport
117
+ - laptop: 1440x900 - Modern 14" laptop viewport
118
+ - tablet: 834x1194 - iPad Pro 11" class viewport
119
+ - mobile: 402x874 - iPhone 16 / modern flagship viewport
120
120
 
121
121
  ROTATION:
122
122
  - portrait: Standard vertical orientation