|
| 1 | +# Web Browser Extension for AgentOS |
| 2 | + |
| 3 | +Browser automation capabilities for AgentOS agents - navigate pages, scrape content, click elements, and capture screenshots. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Navigate**: Go to any URL and get page content |
| 8 | +- **Scrape**: Extract content using CSS selectors |
| 9 | +- **Click**: Interact with page elements |
| 10 | +- **Type**: Fill in forms and input fields |
| 11 | +- **Screenshot**: Capture visual snapshots |
| 12 | +- **Page Snapshot**: Get accessibility tree for intelligent interaction |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +```bash |
| 17 | +npm install @framers/agentos-research-web-browser |
| 18 | +``` |
| 19 | + |
| 20 | +## Quick Start |
| 21 | + |
| 22 | +```typescript |
| 23 | +import { createExtensionPack } from '@framers/agentos-research-web-browser'; |
| 24 | +import { ExtensionManager } from '@framers/agentos'; |
| 25 | + |
| 26 | +const extensionManager = new ExtensionManager(); |
| 27 | + |
| 28 | +// Register the browser extension |
| 29 | +extensionManager.register(createExtensionPack({ |
| 30 | + options: { |
| 31 | + headless: true, |
| 32 | + timeout: 30000, |
| 33 | + viewport: { width: 1920, height: 1080 } |
| 34 | + }, |
| 35 | + logger: console |
| 36 | +})); |
| 37 | +``` |
| 38 | + |
| 39 | +## Tools |
| 40 | + |
| 41 | +### browserNavigate |
| 42 | + |
| 43 | +Navigate to a URL and retrieve page content. |
| 44 | + |
| 45 | +```typescript |
| 46 | +const result = await gmi.executeTool('browserNavigate', { |
| 47 | + url: 'https://example.com', |
| 48 | + waitFor: 'networkidle2', |
| 49 | + returnText: true |
| 50 | +}); |
| 51 | +// Returns: { url, status, title, text, loadTime } |
| 52 | +``` |
| 53 | + |
| 54 | +### browserScrape |
| 55 | + |
| 56 | +Extract content using CSS selectors. |
| 57 | + |
| 58 | +```typescript |
| 59 | +const result = await gmi.executeTool('browserScrape', { |
| 60 | + selector: 'article h2', |
| 61 | + limit: 10 |
| 62 | +}); |
| 63 | +// Returns: { selector, count, elements: [{ tag, text, html, attributes }] } |
| 64 | +``` |
| 65 | + |
| 66 | +### browserClick |
| 67 | + |
| 68 | +Click on an element. |
| 69 | + |
| 70 | +```typescript |
| 71 | +const result = await gmi.executeTool('browserClick', { |
| 72 | + selector: 'button.submit', |
| 73 | + waitForNavigation: true |
| 74 | +}); |
| 75 | +// Returns: { success, element, newUrl } |
| 76 | +``` |
| 77 | + |
| 78 | +### browserType |
| 79 | + |
| 80 | +Type text into an input field. |
| 81 | + |
| 82 | +```typescript |
| 83 | +const result = await gmi.executeTool('browserType', { |
| 84 | + selector: 'input[name="search"]', |
| 85 | + text: 'AgentOS documentation', |
| 86 | + clear: true |
| 87 | +}); |
| 88 | +// Returns: { success, element, text } |
| 89 | +``` |
| 90 | + |
| 91 | +### browserScreenshot |
| 92 | + |
| 93 | +Capture a screenshot. |
| 94 | + |
| 95 | +```typescript |
| 96 | +const result = await gmi.executeTool('browserScreenshot', { |
| 97 | + fullPage: true, |
| 98 | + format: 'png' |
| 99 | +}); |
| 100 | +// Returns: { data (base64), format, width, height, size } |
| 101 | +``` |
| 102 | + |
| 103 | +### browserSnapshot |
| 104 | + |
| 105 | +Get accessibility tree for intelligent interaction. |
| 106 | + |
| 107 | +```typescript |
| 108 | +const result = await gmi.executeTool('browserSnapshot', {}); |
| 109 | +// Returns: { url, title, elements, links, forms, interactable } |
| 110 | +``` |
| 111 | + |
| 112 | +## Configuration |
| 113 | + |
| 114 | +| Option | Type | Default | Description | |
| 115 | +|--------|------|---------|-------------| |
| 116 | +| `headless` | boolean | `true` | Run browser in headless mode | |
| 117 | +| `timeout` | number | `30000` | Default timeout (ms) | |
| 118 | +| `userAgent` | string | - | Custom user agent | |
| 119 | +| `viewport.width` | number | `1920` | Viewport width | |
| 120 | +| `viewport.height` | number | `1080` | Viewport height | |
| 121 | +| `executablePath` | string | auto | Path to Chrome executable | |
| 122 | + |
| 123 | +## Use Cases |
| 124 | + |
| 125 | +### Web Research Agent |
| 126 | + |
| 127 | +```typescript |
| 128 | +// Search and scrape information |
| 129 | +await gmi.executeTool('browserNavigate', { url: 'https://google.com' }); |
| 130 | +await gmi.executeTool('browserType', { selector: 'input[name="q"]', text: 'AI agents 2024' }); |
| 131 | +await gmi.executeTool('browserClick', { selector: 'input[type="submit"]', waitForNavigation: true }); |
| 132 | +const results = await gmi.executeTool('browserScrape', { selector: '.g h3' }); |
| 133 | +``` |
| 134 | + |
| 135 | +### Form Automation |
| 136 | + |
| 137 | +```typescript |
| 138 | +await gmi.executeTool('browserNavigate', { url: 'https://signup.example.com' }); |
| 139 | +await gmi.executeTool('browserType', { selector: '#email', text: 'user@example.com' }); |
| 140 | +await gmi.executeTool('browserType', { selector: '#password', text: 'securepass123' }); |
| 141 | +await gmi.executeTool('browserClick', { selector: 'button[type="submit"]' }); |
| 142 | +``` |
| 143 | + |
| 144 | +### Visual Verification |
| 145 | + |
| 146 | +```typescript |
| 147 | +await gmi.executeTool('browserNavigate', { url: 'https://myapp.com' }); |
| 148 | +const screenshot = await gmi.executeTool('browserScreenshot', { fullPage: true }); |
| 149 | +// Send screenshot to vision model for analysis |
| 150 | +``` |
| 151 | + |
| 152 | +## Dependencies |
| 153 | + |
| 154 | +This extension requires Chrome/Chromium to be installed on the system. It uses `puppeteer-core` which does not bundle a browser. |
| 155 | + |
| 156 | +## License |
| 157 | + |
| 158 | +MIT © Frame.dev |
| 159 | + |
0 commit comments