@myrialabs/clopen 0.3.4 → 0.3.6
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 +1 -1
- package/backend/engine/install-recipes.ts +259 -65
- package/backend/engine/install-runner.ts +32 -60
- package/backend/preview/browser/browser-pool.ts +12 -11
- package/backend/utils/static-curl.ts +228 -0
- package/backend/ws/index.ts +1 -1
- package/backend/ws/system-tools/install.ts +1 -1
- package/backend/ws/system-tools/status.ts +12 -5
- package/dist/assets/{index-D4V47e9n.js → index-BU8wB4Fg.js} +2 -2
- package/dist/assets/main-B3tMwjjU.css +1 -0
- package/dist/assets/{main-Be2TrEVr.js → main-cQx6vfxB.js} +147 -149
- package/dist/index.html +2 -2
- package/package.json +3 -2
- package/dist/assets/main-C184xHqk.css +0 -1
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
|
|
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
|
|
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
|
|
|
@@ -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, Chromium 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
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { homedir } from 'node:os';
|
|
17
|
-
import { existsSync, readdirSync } from 'node:fs';
|
|
17
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
18
18
|
import { join } from 'node:path';
|
|
19
19
|
import { isElevated } from '$backend/utils/privilege';
|
|
20
20
|
import { getClopenDir } from '$backend/utils/paths';
|
|
21
21
|
import { resolveBinary, resolveBinaryWithRefresh } from '$backend/utils/cli';
|
|
22
|
+
import { resolveStaticCurlAsset } from '$backend/utils/static-curl';
|
|
22
23
|
|
|
23
|
-
export type ToolId = 'git' | 'claude' | 'opencode' | '
|
|
24
|
+
export type ToolId = 'git' | 'claude' | 'opencode' | 'chromium';
|
|
24
25
|
|
|
25
26
|
export interface ManualInstruction {
|
|
26
27
|
label: string;
|
|
@@ -38,12 +39,20 @@ export interface Recipe {
|
|
|
38
39
|
/** Optional shell to wrap command (e.g. sh -c for pipe chains). */
|
|
39
40
|
shell?: { program: string; args: string[] };
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* True when the install command (or script it downloads) shells out
|
|
43
|
+
* to `curl`. When set, the runner ensures curl is on PATH —
|
|
44
|
+
* downloading a SHA-pinned static curl from stunnel/static-curl if
|
|
45
|
+
* the system lacks one.
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
requiresCurl?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* When requiresCurl is true and the system has no curl, this carries
|
|
50
|
+
* the pinned asset metadata so the frontend can surface URL + SHA256
|
|
51
|
+
* in the install confirmation dialog for explicit user consent.
|
|
52
|
+
* Undefined when system curl is already present or no asset covers
|
|
53
|
+
* the current platform/arch.
|
|
54
|
+
*/
|
|
55
|
+
pendingCurlDownload?: { version: string; url: string; sha256: string; archKey: string };
|
|
47
56
|
/** Human-readable command string for confirmation dialog preview. */
|
|
48
57
|
displayCommand?: string;
|
|
49
58
|
/** Extra env vars for the install subprocess. */
|
|
@@ -90,16 +99,19 @@ function detectMacPkgMgr(): 'brew' | null {
|
|
|
90
99
|
}
|
|
91
100
|
|
|
92
101
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
93
|
-
//
|
|
102
|
+
// Chromium detection
|
|
94
103
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
95
104
|
|
|
96
105
|
/**
|
|
97
|
-
* Resolve the
|
|
98
|
-
* @puppeteer/browsers cache layout
|
|
99
|
-
*
|
|
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.
|
|
100
110
|
*/
|
|
101
|
-
export function
|
|
102
|
-
|
|
111
|
+
export function resolveClopenChromiumPath(): string | null {
|
|
112
|
+
if (process.platform !== 'darwin' && process.platform !== 'win32') return null;
|
|
113
|
+
|
|
114
|
+
const cacheDir = join(getClopenDir(), 'bin', 'chromium');
|
|
103
115
|
if (!existsSync(cacheDir)) return null;
|
|
104
116
|
|
|
105
117
|
try {
|
|
@@ -108,17 +120,10 @@ export function resolveClopenChromePath(): string | null {
|
|
|
108
120
|
const buildDir = join(cacheDir, entry);
|
|
109
121
|
let candidate: string;
|
|
110
122
|
if (process.platform === 'darwin') {
|
|
111
|
-
candidate = join(buildDir, 'chrome-mac
|
|
112
|
-
if (existsSync(candidate)) return candidate;
|
|
113
|
-
candidate = join(buildDir, 'chrome-mac-x64', 'Google Chrome for Testing.app', 'Contents', 'MacOS', 'Google Chrome for Testing');
|
|
114
|
-
if (existsSync(candidate)) return candidate;
|
|
115
|
-
} else if (process.platform === 'win32') {
|
|
116
|
-
candidate = join(buildDir, 'chrome-win64', 'chrome.exe');
|
|
117
|
-
if (existsSync(candidate)) return candidate;
|
|
118
|
-
candidate = join(buildDir, 'chrome-win32', 'chrome.exe');
|
|
123
|
+
candidate = join(buildDir, 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium');
|
|
119
124
|
if (existsSync(candidate)) return candidate;
|
|
120
125
|
} else {
|
|
121
|
-
candidate = join(buildDir, 'chrome-
|
|
126
|
+
candidate = join(buildDir, 'chrome-win', 'chrome.exe');
|
|
122
127
|
if (existsSync(candidate)) return candidate;
|
|
123
128
|
}
|
|
124
129
|
}
|
|
@@ -128,40 +133,29 @@ export function resolveClopenChromePath(): string | null {
|
|
|
128
133
|
return null;
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
function
|
|
136
|
+
function detectSystemChromium(): string | null {
|
|
132
137
|
if (process.platform === 'darwin') {
|
|
133
|
-
const paths = [
|
|
134
|
-
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
135
|
-
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
|
|
136
|
-
'/Applications/Chromium.app/Contents/MacOS/Chromium'
|
|
137
|
-
];
|
|
138
|
+
const paths = ['/Applications/Chromium.app/Contents/MacOS/Chromium'];
|
|
138
139
|
for (const p of paths) if (existsSync(p)) return p;
|
|
139
140
|
return null;
|
|
140
141
|
}
|
|
141
142
|
if (process.platform === 'win32') {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const localAppData = process.env['LOCALAPPDATA'] ?? join(homedir(), 'AppData', 'Local');
|
|
145
|
-
const paths = [
|
|
146
|
-
join(programFiles, 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
|
147
|
-
join(programFilesX86, 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
|
148
|
-
join(localAppData, 'Google', 'Chrome', 'Application', 'chrome.exe')
|
|
149
|
-
];
|
|
150
|
-
for (const p of paths) if (existsSync(p)) return p;
|
|
151
|
-
return null;
|
|
143
|
+
// Chromium has no canonical Windows install location; rely on PATH.
|
|
144
|
+
return resolveBinary('chromium');
|
|
152
145
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
150
|
}
|
|
158
151
|
|
|
159
152
|
/**
|
|
160
|
-
* Preferred executable path for puppeteer. Clopen-managed install
|
|
161
|
-
* over system
|
|
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.
|
|
162
156
|
*/
|
|
163
|
-
export function
|
|
164
|
-
return
|
|
157
|
+
export function getChromiumExecutablePath(): string | null {
|
|
158
|
+
return resolveClopenChromiumPath() ?? detectSystemChromium();
|
|
165
159
|
}
|
|
166
160
|
|
|
167
161
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -182,11 +176,11 @@ async function runVersion(binary: string, versionFlag = '--version'): Promise<st
|
|
|
182
176
|
}
|
|
183
177
|
|
|
184
178
|
export async function getToolStatus(tool: ToolId): Promise<ToolStatus> {
|
|
185
|
-
if (tool === '
|
|
186
|
-
const resolved =
|
|
179
|
+
if (tool === 'chromium') {
|
|
180
|
+
const resolved = getChromiumExecutablePath();
|
|
187
181
|
if (!resolved) return { tool, installed: false, version: null, source: null };
|
|
188
182
|
const version = await runVersion(resolved);
|
|
189
|
-
const source =
|
|
183
|
+
const source = resolveClopenChromiumPath() ? 'clopen' : 'system';
|
|
190
184
|
return { tool, installed: true, version, source };
|
|
191
185
|
}
|
|
192
186
|
|
|
@@ -304,6 +298,29 @@ async function resolveGitRecipe(): Promise<Recipe> {
|
|
|
304
298
|
return base;
|
|
305
299
|
}
|
|
306
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Populate `requiresCurl` and (when the system lacks curl) the pending
|
|
303
|
+
* static-curl download metadata. Returns false when this platform/arch
|
|
304
|
+
* has no pinned asset — caller should mark the recipe unavailable.
|
|
305
|
+
*/
|
|
306
|
+
function attachCurlRequirement(base: Recipe, toolLabel: string): boolean {
|
|
307
|
+
base.requiresCurl = true;
|
|
308
|
+
if (resolveBinary('curl')) return true;
|
|
309
|
+
|
|
310
|
+
const asset = resolveStaticCurlAsset();
|
|
311
|
+
if (!asset) {
|
|
312
|
+
base.unavailableReason = `curl is required by the ${toolLabel} installer, and no static curl is available for ${process.platform}/${process.arch}.`;
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
base.pendingCurlDownload = {
|
|
316
|
+
version: asset.version,
|
|
317
|
+
url: asset.url,
|
|
318
|
+
sha256: asset.sha256,
|
|
319
|
+
archKey: asset.archKey
|
|
320
|
+
};
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
|
|
307
324
|
async function resolveClaudeRecipe(): Promise<Recipe> {
|
|
308
325
|
const base: Recipe = {
|
|
309
326
|
tool: 'claude',
|
|
@@ -325,15 +342,17 @@ async function resolveClaudeRecipe(): Promise<Recipe> {
|
|
|
325
342
|
return base;
|
|
326
343
|
}
|
|
327
344
|
|
|
328
|
-
// macOS / Linux
|
|
329
|
-
// so curl does not need to be installed.
|
|
345
|
+
// macOS / Linux
|
|
330
346
|
base.manualInstructions.push({
|
|
331
347
|
label: 'curl + bash',
|
|
332
348
|
command: 'curl -fsSL https://claude.ai/install.sh | bash',
|
|
333
349
|
docs: 'https://docs.claude.com/en/docs/claude-code/overview'
|
|
334
350
|
});
|
|
351
|
+
if (!attachCurlRequirement(base, 'Claude Code')) return base;
|
|
352
|
+
|
|
335
353
|
base.autoInstallable = true;
|
|
336
|
-
base.
|
|
354
|
+
base.shell = { program: 'bash', args: ['-c'] };
|
|
355
|
+
base.command = ['curl -fsSL https://claude.ai/install.sh | bash'];
|
|
337
356
|
base.displayCommand = 'curl -fsSL https://claude.ai/install.sh | bash';
|
|
338
357
|
return base;
|
|
339
358
|
}
|
|
@@ -355,29 +374,204 @@ async function resolveOpenCodeRecipe(): Promise<Recipe> {
|
|
|
355
374
|
return base;
|
|
356
375
|
}
|
|
357
376
|
|
|
377
|
+
if (!attachCurlRequirement(base, 'OpenCode')) return base;
|
|
378
|
+
|
|
358
379
|
base.autoInstallable = true;
|
|
359
|
-
base.
|
|
380
|
+
base.shell = { program: 'bash', args: ['-c'] };
|
|
381
|
+
base.command = ['curl -fsSL https://opencode.ai/install | bash'];
|
|
360
382
|
base.displayCommand = 'curl -fsSL https://opencode.ai/install | bash';
|
|
361
383
|
return base;
|
|
362
384
|
}
|
|
363
385
|
|
|
364
|
-
|
|
386
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
387
|
+
// Linux distro detection (apt sub-flavour: Debian vs Ubuntu)
|
|
388
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
389
|
+
|
|
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
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
425
|
+
|
|
426
|
+
const PPTR_CHROMIUM_DOCS = 'https://pptr.dev/browsers-api';
|
|
427
|
+
const PPTR_LINUX_DOCS = 'https://pptr.dev/troubleshooting#chrome-doesnt-launch-on-linux';
|
|
428
|
+
|
|
429
|
+
async function resolveChromiumRecipe(): Promise<Recipe> {
|
|
365
430
|
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}"`;
|
|
433
|
+
|
|
434
|
+
// macOS / Windows: Puppeteer download is self-contained.
|
|
435
|
+
if (process.platform === 'darwin' || process.platform === 'win32') {
|
|
436
|
+
return {
|
|
437
|
+
tool: 'chromium',
|
|
438
|
+
autoInstallable: true,
|
|
439
|
+
missingPrereqs: [],
|
|
440
|
+
manualInstructions: [{
|
|
441
|
+
label: 'Puppeteer browsers CLI',
|
|
442
|
+
command: pptrDisplay,
|
|
443
|
+
docs: PPTR_CHROMIUM_DOCS
|
|
444
|
+
}],
|
|
445
|
+
command: pptrArgs,
|
|
446
|
+
displayCommand: pptrDisplay
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// Linux: delegate to distro package manager so deps auto-resolve.
|
|
451
|
+
return resolveLinuxChromiumRecipe();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
interface LinuxChromiumStrategy {
|
|
455
|
+
pkgMgrLabel: string;
|
|
456
|
+
/** Argv-form command to spawn (sh -c <string>). */
|
|
457
|
+
installCommand: string;
|
|
458
|
+
/** User-facing display command (with sudo prefix if interactive). */
|
|
459
|
+
manualCommand: string;
|
|
460
|
+
/** Extra env to inject into the spawn. */
|
|
461
|
+
env?: Record<string, string>;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
async function resolveLinuxChromiumRecipe(): Promise<Recipe> {
|
|
465
|
+
const distro = readLinuxDistro();
|
|
466
|
+
const ubuntuLike = isUbuntuLike(distro);
|
|
467
|
+
const mgr = detectLinuxPkgMgr();
|
|
468
|
+
|
|
469
|
+
const manual: ManualInstruction[] = [];
|
|
470
|
+
|
|
471
|
+
// Always surface the recommended manual command(s) for this platform.
|
|
472
|
+
const strategy = pickLinuxChromiumStrategy(mgr, ubuntuLike);
|
|
473
|
+
|
|
474
|
+
if (strategy) {
|
|
475
|
+
manual.push({
|
|
476
|
+
label: `${strategy.pkgMgrLabel} (recommended)`,
|
|
477
|
+
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'
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
|
|
366
491
|
const base: Recipe = {
|
|
367
|
-
tool: '
|
|
368
|
-
autoInstallable:
|
|
492
|
+
tool: 'chromium',
|
|
493
|
+
autoInstallable: false,
|
|
369
494
|
missingPrereqs: [],
|
|
370
|
-
manualInstructions:
|
|
371
|
-
label: 'Puppeteer browsers CLI',
|
|
372
|
-
command: `bun x @puppeteer/browsers install chrome@stable --path "${cacheDir}"`,
|
|
373
|
-
docs: 'https://pptr.dev/browsers-api'
|
|
374
|
-
}],
|
|
375
|
-
command: ['bun', 'x', '@puppeteer/browsers', 'install', 'chrome@stable', '--path', cacheDir],
|
|
376
|
-
displayCommand: `bun x @puppeteer/browsers install chrome@stable --path ${cacheDir}`
|
|
495
|
+
manualInstructions: manual
|
|
377
496
|
};
|
|
497
|
+
|
|
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.';
|
|
502
|
+
return base;
|
|
503
|
+
}
|
|
504
|
+
|
|
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.';
|
|
507
|
+
return base;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const elevated = await isElevated();
|
|
511
|
+
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.`;
|
|
513
|
+
return base;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
base.autoInstallable = true;
|
|
517
|
+
base.shell = { program: 'sh', args: ['-c'] };
|
|
518
|
+
base.command = [strategy.installCommand];
|
|
519
|
+
base.displayCommand = strategy.manualCommand;
|
|
520
|
+
if (strategy.env) base.env = strategy.env;
|
|
378
521
|
return base;
|
|
379
522
|
}
|
|
380
523
|
|
|
524
|
+
function pickLinuxChromiumStrategy(
|
|
525
|
+
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
|
+
}
|
|
536
|
+
if (mgr === 'apt') {
|
|
537
|
+
return {
|
|
538
|
+
pkgMgrLabel: 'apt',
|
|
539
|
+
installCommand: 'apt-get update && apt-get install -y chromium',
|
|
540
|
+
manualCommand: 'sudo apt-get update && sudo apt-get install -y chromium',
|
|
541
|
+
env: { DEBIAN_FRONTEND: 'noninteractive' }
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
if (mgr === 'dnf') {
|
|
545
|
+
return {
|
|
546
|
+
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'
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
if (mgr === 'zypper') {
|
|
566
|
+
return {
|
|
567
|
+
pkgMgrLabel: 'zypper',
|
|
568
|
+
installCommand: 'zypper --non-interactive install chromium',
|
|
569
|
+
manualCommand: 'sudo zypper install chromium'
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
|
|
381
575
|
/**
|
|
382
576
|
* Resolve the install recipe for a tool on the current platform.
|
|
383
577
|
* Result is platform- and privilege-aware: recipes that would fail
|
|
@@ -388,6 +582,6 @@ export async function resolveRecipe(tool: ToolId): Promise<Recipe> {
|
|
|
388
582
|
case 'git': return resolveGitRecipe();
|
|
389
583
|
case 'claude': return resolveClaudeRecipe();
|
|
390
584
|
case 'opencode': return resolveOpenCodeRecipe();
|
|
391
|
-
case '
|
|
585
|
+
case 'chromium': return resolveChromiumRecipe();
|
|
392
586
|
}
|
|
393
587
|
}
|
|
@@ -21,6 +21,7 @@ import { debug } from '$shared/utils/logger';
|
|
|
21
21
|
import { ws } from '$backend/utils/ws';
|
|
22
22
|
import { getCleanSpawnEnv } from '$backend/utils/env';
|
|
23
23
|
import { refreshProcessPath } from '$backend/utils/path-enrich';
|
|
24
|
+
import { ensureCurlAvailable } from '$backend/utils/static-curl';
|
|
24
25
|
import type { Recipe, ToolId } from './install-recipes';
|
|
25
26
|
import { resolveRecipe } from './install-recipes';
|
|
26
27
|
|
|
@@ -194,78 +195,50 @@ async function runInstall(session: Session, env: Record<string, string>): Promis
|
|
|
194
195
|
const { recipe } = session;
|
|
195
196
|
let proc: ReturnType<typeof Bun.spawn>;
|
|
196
197
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
let body: string;
|
|
198
|
+
// Ensure curl is available when the recipe shells out to it. Prepends
|
|
199
|
+
// the static-curl directory to PATH when a managed binary is staged.
|
|
200
|
+
if (recipe.requiresCurl) {
|
|
202
201
|
try {
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
const curlDir = await ensureCurlAvailable((event) => {
|
|
203
|
+
emitStream(session, 'stdout', `» curl: ${event.message}\n`);
|
|
204
|
+
});
|
|
205
|
+
if (curlDir) {
|
|
206
|
+
env.PATH = `${curlDir}${process.platform === 'win32' ? ';' : ':'}${env.PATH ?? ''}`;
|
|
208
207
|
}
|
|
209
|
-
body = await response.text();
|
|
210
208
|
} catch (err) {
|
|
211
|
-
emitStream(session, 'stderr', `
|
|
209
|
+
emitStream(session, 'stderr', `curl setup failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
212
210
|
finalizeSession(session, 'failed', -1);
|
|
213
211
|
return;
|
|
214
212
|
}
|
|
215
213
|
|
|
216
|
-
// Cancel may have fired while
|
|
214
|
+
// Cancel may have fired while curl was being staged.
|
|
217
215
|
if (session.status !== 'running') {
|
|
218
216
|
finalizeSession(session, session.status, -1);
|
|
219
217
|
return;
|
|
220
218
|
}
|
|
219
|
+
}
|
|
221
220
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
proc = Bun.spawn(interpreter, {
|
|
226
|
-
stdout: 'pipe',
|
|
227
|
-
stderr: 'pipe',
|
|
228
|
-
stdin: 'pipe',
|
|
229
|
-
env
|
|
230
|
-
});
|
|
231
|
-
} catch (err) {
|
|
232
|
-
emitStream(session, 'stderr', `spawn failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
233
|
-
finalizeSession(session, 'failed', -1);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
session.proc = proc;
|
|
238
|
-
|
|
239
|
-
try {
|
|
240
|
-
const stdin = proc.stdin as import('bun').FileSink;
|
|
241
|
-
stdin.write(body);
|
|
242
|
-
stdin.end();
|
|
243
|
-
} catch (err) {
|
|
244
|
-
debug.warn('path', `[install:${session.id}] stdin write error:`, err);
|
|
245
|
-
}
|
|
246
|
-
} else {
|
|
247
|
-
const spawnArgs = recipe.shell
|
|
248
|
-
? [recipe.shell.program, ...recipe.shell.args, ...recipe.command!]
|
|
249
|
-
: recipe.command!;
|
|
250
|
-
|
|
251
|
-
debug.log('path', `[install:${session.id}] Spawning: ${spawnArgs.join(' ')}`);
|
|
221
|
+
const spawnArgs = recipe.shell
|
|
222
|
+
? [recipe.shell.program, ...recipe.shell.args, ...recipe.command!]
|
|
223
|
+
: recipe.command!;
|
|
252
224
|
|
|
253
|
-
|
|
254
|
-
proc = Bun.spawn(spawnArgs, {
|
|
255
|
-
stdout: 'pipe',
|
|
256
|
-
stderr: 'pipe',
|
|
257
|
-
stdin: 'ignore',
|
|
258
|
-
env
|
|
259
|
-
});
|
|
260
|
-
} catch (err) {
|
|
261
|
-
emitStream(session, 'stderr', `spawn failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
262
|
-
finalizeSession(session, 'failed', -1);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
225
|
+
debug.log('path', `[install:${session.id}] Spawning: ${spawnArgs.join(' ')}`);
|
|
265
226
|
|
|
266
|
-
|
|
227
|
+
try {
|
|
228
|
+
proc = Bun.spawn(spawnArgs, {
|
|
229
|
+
stdout: 'pipe',
|
|
230
|
+
stderr: 'pipe',
|
|
231
|
+
stdin: 'ignore',
|
|
232
|
+
env
|
|
233
|
+
});
|
|
234
|
+
} catch (err) {
|
|
235
|
+
emitStream(session, 'stderr', `spawn failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
236
|
+
finalizeSession(session, 'failed', -1);
|
|
237
|
+
return;
|
|
267
238
|
}
|
|
268
239
|
|
|
240
|
+
session.proc = proc;
|
|
241
|
+
|
|
269
242
|
const exitCode = await runStreamedProcess(session, proc);
|
|
270
243
|
finalizeSession(session, exitCode === 0 ? 'success' : 'failed', exitCode);
|
|
271
244
|
}
|
|
@@ -282,8 +255,7 @@ export async function startInstall(tool: ToolId, userId: string): Promise<Sessio
|
|
|
282
255
|
}
|
|
283
256
|
|
|
284
257
|
const recipe = await resolveRecipe(tool);
|
|
285
|
-
|
|
286
|
-
if (!hasExecutable) {
|
|
258
|
+
if (!recipe.autoInstallable || !recipe.command) {
|
|
287
259
|
throw new InstallNotAutoInstallableError(tool, recipe.unavailableReason ?? 'Not auto-installable on this platform');
|
|
288
260
|
}
|
|
289
261
|
|
|
@@ -333,8 +305,8 @@ export function cancelInstall(sessionId: string): boolean {
|
|
|
333
305
|
const session = sessions.get(sessionId);
|
|
334
306
|
if (!session || session.status !== 'running') return false;
|
|
335
307
|
session.status = 'cancelled';
|
|
336
|
-
// `proc` may be null during the
|
|
337
|
-
// re-checks status after
|
|
308
|
+
// `proc` may be null during the static-curl download phase; runInstall
|
|
309
|
+
// re-checks status after each await and finalizes accordingly.
|
|
338
310
|
if (session.proc) {
|
|
339
311
|
try {
|
|
340
312
|
session.proc.kill();
|
|
@@ -19,7 +19,7 @@ import type { Browser, BrowserContext, Page } from 'puppeteer';
|
|
|
19
19
|
import { debug } from '$shared/utils/logger';
|
|
20
20
|
import puppeteer from 'puppeteer-extra';
|
|
21
21
|
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
|
|
22
|
-
import {
|
|
22
|
+
import { getChromiumExecutablePath } from '$backend/engine/install-recipes';
|
|
23
23
|
|
|
24
24
|
puppeteer.use(StealthPlugin());
|
|
25
25
|
|
|
@@ -99,18 +99,19 @@ class BrowserPool {
|
|
|
99
99
|
private async launchBrowser(): Promise<Browser> {
|
|
100
100
|
debug.log('preview', '🚀 Launching browser with puppeteer-extra + StealthPlugin...');
|
|
101
101
|
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
const executablePath =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
: { headless: true, channel: 'chrome', args: CHROMIUM_ARGS };
|
|
108
|
-
|
|
109
|
-
if (executablePath) {
|
|
110
|
-
debug.log('preview', ` using Chrome at: ${executablePath}`);
|
|
102
|
+
// Use the clopen-managed Chromium under ~/.clopen/bin (macOS/Windows)
|
|
103
|
+
// or the system Chromium installed via the distro package manager (Linux).
|
|
104
|
+
const executablePath = getChromiumExecutablePath();
|
|
105
|
+
if (!executablePath) {
|
|
106
|
+
throw new Error('Chromium not installed. Go to Settings → System Tools and click Install.');
|
|
111
107
|
}
|
|
108
|
+
debug.log('preview', ` using Chromium at: ${executablePath}`);
|
|
112
109
|
|
|
113
|
-
const browser = await puppeteer.launch(
|
|
110
|
+
const browser = await puppeteer.launch({
|
|
111
|
+
headless: true,
|
|
112
|
+
executablePath,
|
|
113
|
+
args: CHROMIUM_ARGS
|
|
114
|
+
}) as unknown as Browser;
|
|
114
115
|
|
|
115
116
|
debug.log('preview', '✅ Browser launched successfully');
|
|
116
117
|
|