This commit is contained in:
Chris Tate
2026-01-10 23:47:30 -06:00
parent aff8a056c6
commit a7e5de5e4f
6 changed files with 36 additions and 5 deletions
+4 -2
View File
@@ -15,7 +15,8 @@
"format": "prettier --write 'src/**/*.ts'",
"format:check": "prettier --check 'src/**/*.ts'",
"test": "vitest run",
"test:watch": "vitest"
"test:watch": "vitest",
"postinstall": "node scripts/postinstall.js"
},
"keywords": [
"browser",
@@ -28,11 +29,12 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"playwright": "^1.40.0",
"playwright-core": "^1.40.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^20.10.0",
"playwright": "^1.40.0",
"prettier": "^3.7.4",
"tsx": "^4.6.0",
"typescript": "^5.3.0",
+13
View File
@@ -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
View File
@@ -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 {
Command,
+1 -1
View File
@@ -10,7 +10,7 @@ import {
type Dialog,
type Request,
type Route,
} from 'playwright';
} from 'playwright-core';
import type { LaunchCommand } from './types.js';
interface TrackedRequest {
+16
View File
@@ -2,6 +2,7 @@
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { execSync } from 'child_process';
import { send, setDebug, setSession, getSession } from './client.js';
import type { Response } from './types.js';
@@ -109,6 +110,9 @@ ${c('yellow', 'Debug:')}
${c('cyan', 'console')} View console logs
${c('cyan', 'errors')} View page errors
${c('yellow', 'Setup:')}
${c('cyan', 'install')} Install browser binaries
${c('yellow', 'Options:')}
--session <name> Isolated session (or AGENT_BROWSER_SESSION env)
--json JSON output
@@ -946,6 +950,18 @@ async function main(): Promise<void> {
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 ===
case 'url':
cmd = { id, action: 'url' };
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Page, Browser, BrowserContext } from 'playwright';
import type { Page, Browser, BrowserContext } from 'playwright-core';
// Base command structure
export interface BaseCommand {