yiyan-browser-agent 1.0.30 → 1.0.32
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/package.json +1 -1
- package/src/postinstall.js +12 -36
package/package.json
CHANGED
package/src/postinstall.js
CHANGED
|
@@ -1,50 +1,26 @@
|
|
|
1
|
-
// src/postinstall.js —
|
|
2
|
-
// Automatically downloads the Playwright Chromium browser.
|
|
1
|
+
// src/postinstall.js — Auto-install Playwright Chromium
|
|
3
2
|
'use strict';
|
|
4
3
|
|
|
5
4
|
const { execSync } = require('child_process');
|
|
6
|
-
const path
|
|
7
|
-
const os
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const os = require('os');
|
|
8
7
|
|
|
9
|
-
// Skip in CI
|
|
8
|
+
// Skip in CI
|
|
10
9
|
if (process.env.CI || process.env.SKIP_PLAYWRIGHT_INSTALL) {
|
|
11
|
-
console.log('[yiyan-agent] Skipping
|
|
10
|
+
console.log('[yiyan-agent] Skipping browser install (CI detected)');
|
|
12
11
|
process.exit(0);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
console.log('');
|
|
16
|
-
console.log('╔══════════════════════════════════════════════════╗');
|
|
17
|
-
console.log('║ 🤖 Yiyan Browser Agent (文心一言) — Setup ║');
|
|
18
|
-
console.log('╚══════════════════════════════════════════════════╝');
|
|
19
|
-
console.log('');
|
|
20
|
-
console.log(' Downloading Playwright Chromium browser...');
|
|
21
|
-
console.log(' (This only happens once — ~150 MB)\n');
|
|
14
|
+
console.log('\n[yiyan-agent] Installing Playwright Chromium...\n');
|
|
22
15
|
|
|
23
16
|
try {
|
|
24
|
-
// Use the playwright binary bundled in this package's node_modules
|
|
25
|
-
// On Windows, .bin files have .cmd extension; on Linux/macOS, they're shell scripts
|
|
26
17
|
const isWindows = process.platform === 'win32';
|
|
27
18
|
const playwrightBin = path.join(__dirname, '..', 'node_modules', '.bin',
|
|
28
19
|
isWindows ? 'playwright.cmd' : 'playwright');
|
|
29
20
|
|
|
30
|
-
execSync(`"${playwrightBin}" install chromium`, {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
console.log(' ✓ Browser installed successfully!');
|
|
37
|
-
console.log('');
|
|
38
|
-
console.log(' Get started:');
|
|
39
|
-
console.log(' yiyan-agent --interactive');
|
|
40
|
-
console.log(' yiyan-agent "build a REST API in Express"');
|
|
41
|
-
console.log('');
|
|
42
|
-
} catch (err) {
|
|
43
|
-
console.warn('');
|
|
44
|
-
console.warn(' ⚠ Could not auto-install Chromium.');
|
|
45
|
-
console.warn(' Run this manually to complete setup:');
|
|
46
|
-
console.warn('');
|
|
47
|
-
console.warn(' npx playwright install chromium');
|
|
48
|
-
console.warn('');
|
|
49
|
-
// Don't exit(1) — don't break the install if browser download fails
|
|
50
|
-
}
|
|
21
|
+
execSync(`"${playwrightBin}" install chromium`, { stdio: 'inherit' });
|
|
22
|
+
console.log('\n[yiyan-agent] ✓ Browser installed!\n');
|
|
23
|
+
} catch {
|
|
24
|
+
console.warn('\n[yiyan-agent] ⚠ Could not auto-install. Run manually:');
|
|
25
|
+
console.warn(' npx playwright install chromium\n');
|
|
26
|
+
}
|