@myrialabs/clopen 0.3.6 → 0.3.8
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 +4 -4
- package/backend/database/migrations/030_add_files_panel_state_to_user_projects.ts +34 -0
- package/backend/database/migrations/031_create_db_client_tables.ts +74 -0
- package/backend/database/migrations/index.ts +14 -0
- package/backend/database/queries/db-client-connection-queries.ts +237 -0
- package/backend/database/queries/db-client-query-history-queries.ts +113 -0
- package/backend/database/queries/index.ts +3 -1
- package/backend/database/queries/project-queries.ts +23 -0
- package/backend/db-client/connection-manager.ts +257 -0
- package/backend/db-client/drivers/bun-sql-helpers.ts +41 -0
- package/backend/db-client/drivers/mongodb.ts +358 -0
- package/backend/db-client/drivers/mysql.ts +385 -0
- package/backend/db-client/drivers/postgres.ts +446 -0
- package/backend/db-client/drivers/redis.ts +267 -0
- package/backend/db-client/drivers/sql-builders.ts +215 -0
- package/backend/db-client/drivers/sqlite.ts +346 -0
- package/backend/db-client/drivers/types.ts +92 -0
- package/backend/db-client/query-executor.ts +126 -0
- package/backend/db-client/ssh-tunnel.ts +122 -0
- package/backend/engine/install-recipes.ts +216 -137
- package/backend/engine/install-runner.ts +39 -0
- package/backend/git/git-service.ts +12 -0
- package/backend/mcp/servers/browser-automation/index.ts +6 -6
- package/backend/preview/browser/browser-pool.ts +10 -9
- package/backend/preview/browser/scripts/video-stream.ts +9 -3
- package/backend/tunnel/cloudflared/binary.ts +22 -4
- package/backend/tunnel/cloudflared/index.ts +2 -1
- package/backend/tunnel/cloudflared/tunnel.ts +17 -4
- package/backend/tunnel/global-tunnel-manager.ts +29 -51
- package/backend/tunnel/project-tunnel-manager.ts +14 -53
- package/backend/ws/db-client/connections.ts +180 -0
- package/backend/ws/db-client/index.ts +17 -0
- package/backend/ws/db-client/io.ts +458 -0
- package/backend/ws/db-client/query.ts +162 -0
- package/backend/ws/db-client/schema.ts +76 -0
- package/backend/ws/db-client/structure.ts +218 -0
- package/backend/ws/files/index.ts +5 -1
- package/backend/ws/files/read.ts +32 -0
- package/backend/ws/files/state.ts +39 -0
- package/backend/ws/index.ts +6 -2
- package/backend/ws/system-tools/install.ts +2 -1
- package/backend/ws/system-tools/status.ts +5 -4
- package/dist/assets/{index-BU8wB4Fg.js → index-DqAGCTFT.js} +2 -2
- package/dist/assets/{main-cQx6vfxB.js → main-DsED0rLr.js} +244 -192
- package/dist/assets/main-eWY9R8g9.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +4 -2
- package/shared/constants/preview.ts +48 -4
- package/shared/types/database/schema.ts +48 -1
- package/shared/types/db-client/connection.ts +60 -0
- package/shared/types/db-client/index.ts +6 -0
- package/shared/types/db-client/query.ts +77 -0
- package/shared/utils/logger.ts +1 -0
- package/dist/assets/main-B3tMwjjU.css +0 -1
|
@@ -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,
|
|
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 {
|
|
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' | '
|
|
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
|
-
//
|
|
101
|
+
// Chrome detection
|
|
103
102
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
104
103
|
|
|
105
104
|
/**
|
|
106
|
-
* Resolve the
|
|
107
|
-
* @puppeteer/browsers cache layout: <cache>/
|
|
108
|
-
* Only macOS and Windows install
|
|
109
|
-
*
|
|
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
|
|
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', '
|
|
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
|
-
|
|
124
|
-
|
|
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
|
-
|
|
127
|
-
|
|
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
|
|
144
|
+
function detectSystemChrome(): string | null {
|
|
137
145
|
if (process.platform === 'darwin') {
|
|
138
|
-
const
|
|
139
|
-
|
|
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
|
-
|
|
144
|
-
|
|
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:
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
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
|
|
154
|
-
* (macOS/Windows via @puppeteer/browsers
|
|
155
|
-
* bundled version stays consistent; on Linux
|
|
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
|
|
158
|
-
return
|
|
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 === '
|
|
180
|
-
const resolved =
|
|
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 =
|
|
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
|
-
//
|
|
413
|
+
// Chrome recipe — Puppeteer download (macOS/Windows) or Google Chrome (Linux)
|
|
388
414
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
389
415
|
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
427
|
-
|
|
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
|
|
425
|
+
async function resolveChromeRecipe(): Promise<Recipe> {
|
|
430
426
|
const cacheDir = join(getClopenDir(), 'bin');
|
|
431
|
-
const pptrArgs = ['bun', 'x', '@puppeteer/browsers', 'install', '
|
|
432
|
-
const pptrDisplay = `bun x @puppeteer/browsers install
|
|
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
|
|
430
|
+
// macOS / Windows: Puppeteer downloads Chrome for Testing, self-contained.
|
|
435
431
|
if (process.platform === 'darwin' || process.platform === 'win32') {
|
|
436
432
|
return {
|
|
437
|
-
tool: '
|
|
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:
|
|
439
|
+
docs: PPTR_CHROME_DOCS
|
|
444
440
|
}],
|
|
445
441
|
command: pptrArgs,
|
|
446
442
|
displayCommand: pptrDisplay
|
|
447
443
|
};
|
|
448
444
|
}
|
|
449
445
|
|
|
450
|
-
// Linux:
|
|
451
|
-
|
|
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
|
|
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
|
|
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:
|
|
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: '
|
|
479
|
+
tool: 'chrome',
|
|
493
480
|
autoInstallable: false,
|
|
494
481
|
missingPrereqs: [],
|
|
495
482
|
manualInstructions: manual
|
|
496
483
|
};
|
|
497
484
|
|
|
498
|
-
if (!
|
|
499
|
-
base.unavailableReason =
|
|
500
|
-
? `
|
|
501
|
-
:
|
|
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 (
|
|
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
|
|
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
|
|
510
|
+
function pickLinuxChromeStrategy(
|
|
525
511
|
mgr: LinuxPkgMgr | null,
|
|
526
|
-
|
|
527
|
-
):
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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:
|
|
540
|
-
manualCommand:
|
|
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:
|
|
548
|
-
manualCommand:
|
|
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:
|
|
569
|
-
manualCommand:
|
|
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 '
|
|
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
|
|
|
@@ -187,6 +187,18 @@ export class GitService {
|
|
|
187
187
|
return parseDiff(result.stdout);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Read a file's content at a specific git ref (e.g. HEAD).
|
|
192
|
+
* Returns null when the file does not exist at that ref (untracked / new file).
|
|
193
|
+
*/
|
|
194
|
+
async getFileAtRef(cwd: string, ref: string, filePath: string): Promise<string | null> {
|
|
195
|
+
const result = await execGit(['show', `${ref}:${filePath}`], cwd);
|
|
196
|
+
if (result.exitCode !== 0) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
return result.stdout;
|
|
200
|
+
}
|
|
201
|
+
|
|
190
202
|
// ============================================
|
|
191
203
|
// Branches
|
|
192
204
|
// ============================================
|
|
@@ -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:
|
|
72
|
-
- tablet:
|
|
73
|
-
- mobile:
|
|
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:
|
|
118
|
-
- tablet:
|
|
119
|
-
- mobile:
|
|
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
|