install
This commit is contained in:
+4
-2
@@ -15,7 +15,8 @@
|
|||||||
"format": "prettier --write 'src/**/*.ts'",
|
"format": "prettier --write 'src/**/*.ts'",
|
||||||
"format:check": "prettier --check 'src/**/*.ts'",
|
"format:check": "prettier --check 'src/**/*.ts'",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest"
|
"test:watch": "vitest",
|
||||||
|
"postinstall": "node scripts/postinstall.js"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"browser",
|
"browser",
|
||||||
@@ -28,11 +29,12 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright": "^1.40.0",
|
"playwright-core": "^1.40.0",
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.10.0",
|
"@types/node": "^20.10.0",
|
||||||
|
"playwright": "^1.40.0",
|
||||||
"prettier": "^3.7.4",
|
"prettier": "^3.7.4",
|
||||||
"tsx": "^4.6.0",
|
"tsx": "^4.6.0",
|
||||||
"typescript": "^5.3.0",
|
"typescript": "^5.3.0",
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const message = `
|
||||||
|
╔═══════════════════════════════════════════════════════════════════════════╗
|
||||||
|
║ agent-browser was installed successfully! ║
|
||||||
|
║ Please run the following command to download browser binaries: ║
|
||||||
|
║ ║
|
||||||
|
║ npx agent-browser install ║
|
||||||
|
║ ║
|
||||||
|
╚═══════════════════════════════════════════════════════════════════════════╝
|
||||||
|
`;
|
||||||
|
|
||||||
|
console.log(message);
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import type { Page, Frame } from 'playwright';
|
import type { Page, Frame } from 'playwright-core';
|
||||||
import type { BrowserManager } from './browser.js';
|
import type { BrowserManager } from './browser.js';
|
||||||
import type {
|
import type {
|
||||||
Command,
|
Command,
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import {
|
|||||||
type Dialog,
|
type Dialog,
|
||||||
type Request,
|
type Request,
|
||||||
type Route,
|
type Route,
|
||||||
} from 'playwright';
|
} from 'playwright-core';
|
||||||
import type { LaunchCommand } from './types.js';
|
import type { LaunchCommand } from './types.js';
|
||||||
|
|
||||||
interface TrackedRequest {
|
interface TrackedRequest {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
import { send, setDebug, setSession, getSession } from './client.js';
|
import { send, setDebug, setSession, getSession } from './client.js';
|
||||||
import type { Response } from './types.js';
|
import type { Response } from './types.js';
|
||||||
|
|
||||||
@@ -109,6 +110,9 @@ ${c('yellow', 'Debug:')}
|
|||||||
${c('cyan', 'console')} View console logs
|
${c('cyan', 'console')} View console logs
|
||||||
${c('cyan', 'errors')} View page errors
|
${c('cyan', 'errors')} View page errors
|
||||||
|
|
||||||
|
${c('yellow', 'Setup:')}
|
||||||
|
${c('cyan', 'install')} Install browser binaries
|
||||||
|
|
||||||
${c('yellow', 'Options:')}
|
${c('yellow', 'Options:')}
|
||||||
--session <name> Isolated session (or AGENT_BROWSER_SESSION env)
|
--session <name> Isolated session (or AGENT_BROWSER_SESSION env)
|
||||||
--json JSON output
|
--json JSON output
|
||||||
@@ -946,6 +950,18 @@ async function main(): Promise<void> {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'install': {
|
||||||
|
console.log(c('cyan', 'Installing Playwright browsers...'));
|
||||||
|
try {
|
||||||
|
execSync('npx playwright install', { stdio: 'inherit' });
|
||||||
|
console.log(c('green', '✓'), 'Browsers installed successfully');
|
||||||
|
process.exit(0);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(c('red', '✗'), 'Failed to install browsers');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// === Legacy aliases for backwards compatibility ===
|
// === Legacy aliases for backwards compatibility ===
|
||||||
case 'url':
|
case 'url':
|
||||||
cmd = { id, action: 'url' };
|
cmd = { id, action: 'url' };
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import type { Page, Browser, BrowserContext } from 'playwright';
|
import type { Page, Browser, BrowserContext } from 'playwright-core';
|
||||||
|
|
||||||
// Base command structure
|
// Base command structure
|
||||||
export interface BaseCommand {
|
export interface BaseCommand {
|
||||||
|
|||||||
Reference in New Issue
Block a user