agent-browser 0.8.7 → 0.8.10
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/bin/agent-browser-darwin-arm64 +0 -0
- package/bin/agent-browser-darwin-x64 +0 -0
- package/bin/agent-browser-linux-arm64 +0 -0
- package/bin/agent-browser-linux-x64 +0 -0
- package/bin/agent-browser-win32-x64.exe +0 -0
- package/bin/agent-browser.js +18 -1
- package/package.json +1 -1
- package/skills/agent-browser/SKILL.md +102 -277
- package/skills/agent-browser/references/authentication.md +15 -1
- package/skills/agent-browser/references/commands.md +259 -0
- package/skills/agent-browser/references/proxy-support.md +14 -1
- package/skills/agent-browser/references/session-management.md +13 -1
- package/skills/agent-browser/references/snapshot-refs.md +19 -11
- package/skills/agent-browser/references/video-recording.md +12 -1
- package/skills/agent-browser/templates/authenticated-session.sh +34 -28
- package/skills/agent-browser/templates/capture-workflow.sh +36 -35
- package/skills/agent-browser/templates/form-automation.sh +40 -42
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/SKILL.md +356 -0
- package/skills/skill-creator/references/output-patterns.md +82 -0
- package/skills/skill-creator/references/workflows.md +28 -0
- package/skills/skill-creator/scripts/init_skill.py +303 -0
- package/skills/skill-creator/scripts/package_skill.py +113 -0
- package/skills/skill-creator/scripts/quick_validate.py +95 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Command Reference
|
|
2
|
+
|
|
3
|
+
Complete reference for all agent-browser commands. For quick start and common patterns, see SKILL.md.
|
|
4
|
+
|
|
5
|
+
## Navigation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
agent-browser open <url> # Navigate to URL (aliases: goto, navigate)
|
|
9
|
+
# Supports: https://, http://, file://, about:, data://
|
|
10
|
+
# Auto-prepends https:// if no protocol given
|
|
11
|
+
agent-browser back # Go back
|
|
12
|
+
agent-browser forward # Go forward
|
|
13
|
+
agent-browser reload # Reload page
|
|
14
|
+
agent-browser close # Close browser (aliases: quit, exit)
|
|
15
|
+
agent-browser connect 9222 # Connect to browser via CDP port
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Snapshot (page analysis)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
agent-browser snapshot # Full accessibility tree
|
|
22
|
+
agent-browser snapshot -i # Interactive elements only (recommended)
|
|
23
|
+
agent-browser snapshot -c # Compact output
|
|
24
|
+
agent-browser snapshot -d 3 # Limit depth to 3
|
|
25
|
+
agent-browser snapshot -s "#main" # Scope to CSS selector
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Interactions (use @refs from snapshot)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
agent-browser click @e1 # Click
|
|
32
|
+
agent-browser dblclick @e1 # Double-click
|
|
33
|
+
agent-browser focus @e1 # Focus element
|
|
34
|
+
agent-browser fill @e2 "text" # Clear and type
|
|
35
|
+
agent-browser type @e2 "text" # Type without clearing
|
|
36
|
+
agent-browser press Enter # Press key (alias: key)
|
|
37
|
+
agent-browser press Control+a # Key combination
|
|
38
|
+
agent-browser keydown Shift # Hold key down
|
|
39
|
+
agent-browser keyup Shift # Release key
|
|
40
|
+
agent-browser hover @e1 # Hover
|
|
41
|
+
agent-browser check @e1 # Check checkbox
|
|
42
|
+
agent-browser uncheck @e1 # Uncheck checkbox
|
|
43
|
+
agent-browser select @e1 "value" # Select dropdown option
|
|
44
|
+
agent-browser select @e1 "a" "b" # Select multiple options
|
|
45
|
+
agent-browser scroll down 500 # Scroll page (default: down 300px)
|
|
46
|
+
agent-browser scrollintoview @e1 # Scroll element into view (alias: scrollinto)
|
|
47
|
+
agent-browser drag @e1 @e2 # Drag and drop
|
|
48
|
+
agent-browser upload @e1 file.pdf # Upload files
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Get Information
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
agent-browser get text @e1 # Get element text
|
|
55
|
+
agent-browser get html @e1 # Get innerHTML
|
|
56
|
+
agent-browser get value @e1 # Get input value
|
|
57
|
+
agent-browser get attr @e1 href # Get attribute
|
|
58
|
+
agent-browser get title # Get page title
|
|
59
|
+
agent-browser get url # Get current URL
|
|
60
|
+
agent-browser get count ".item" # Count matching elements
|
|
61
|
+
agent-browser get box @e1 # Get bounding box
|
|
62
|
+
agent-browser get styles @e1 # Get computed styles (font, color, bg, etc.)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Check State
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
agent-browser is visible @e1 # Check if visible
|
|
69
|
+
agent-browser is enabled @e1 # Check if enabled
|
|
70
|
+
agent-browser is checked @e1 # Check if checked
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Screenshots and PDF
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
agent-browser screenshot # Save to temporary directory
|
|
77
|
+
agent-browser screenshot path.png # Save to specific path
|
|
78
|
+
agent-browser screenshot --full # Full page
|
|
79
|
+
agent-browser pdf output.pdf # Save as PDF
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Video Recording
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
agent-browser record start ./demo.webm # Start recording
|
|
86
|
+
agent-browser click @e1 # Perform actions
|
|
87
|
+
agent-browser record stop # Stop and save video
|
|
88
|
+
agent-browser record restart ./take2.webm # Stop current + start new
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Wait
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
agent-browser wait @e1 # Wait for element
|
|
95
|
+
agent-browser wait 2000 # Wait milliseconds
|
|
96
|
+
agent-browser wait --text "Success" # Wait for text (or -t)
|
|
97
|
+
agent-browser wait --url "**/dashboard" # Wait for URL pattern (or -u)
|
|
98
|
+
agent-browser wait --load networkidle # Wait for network idle (or -l)
|
|
99
|
+
agent-browser wait --fn "window.ready" # Wait for JS condition (or -f)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Mouse Control
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
agent-browser mouse move 100 200 # Move mouse
|
|
106
|
+
agent-browser mouse down left # Press button
|
|
107
|
+
agent-browser mouse up left # Release button
|
|
108
|
+
agent-browser mouse wheel 100 # Scroll wheel
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Semantic Locators (alternative to refs)
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
agent-browser find role button click --name "Submit"
|
|
115
|
+
agent-browser find text "Sign In" click
|
|
116
|
+
agent-browser find text "Sign In" click --exact # Exact match only
|
|
117
|
+
agent-browser find label "Email" fill "user@test.com"
|
|
118
|
+
agent-browser find placeholder "Search" type "query"
|
|
119
|
+
agent-browser find alt "Logo" click
|
|
120
|
+
agent-browser find title "Close" click
|
|
121
|
+
agent-browser find testid "submit-btn" click
|
|
122
|
+
agent-browser find first ".item" click
|
|
123
|
+
agent-browser find last ".item" click
|
|
124
|
+
agent-browser find nth 2 "a" hover
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Browser Settings
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
agent-browser set viewport 1920 1080 # Set viewport size
|
|
131
|
+
agent-browser set device "iPhone 14" # Emulate device
|
|
132
|
+
agent-browser set geo 37.7749 -122.4194 # Set geolocation (alias: geolocation)
|
|
133
|
+
agent-browser set offline on # Toggle offline mode
|
|
134
|
+
agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
|
|
135
|
+
agent-browser set credentials user pass # HTTP basic auth (alias: auth)
|
|
136
|
+
agent-browser set media dark # Emulate color scheme
|
|
137
|
+
agent-browser set media light reduced-motion # Light mode + reduced motion
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Cookies and Storage
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
agent-browser cookies # Get all cookies
|
|
144
|
+
agent-browser cookies set name value # Set cookie
|
|
145
|
+
agent-browser cookies clear # Clear cookies
|
|
146
|
+
agent-browser storage local # Get all localStorage
|
|
147
|
+
agent-browser storage local key # Get specific key
|
|
148
|
+
agent-browser storage local set k v # Set value
|
|
149
|
+
agent-browser storage local clear # Clear all
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Network
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
agent-browser network route <url> # Intercept requests
|
|
156
|
+
agent-browser network route <url> --abort # Block requests
|
|
157
|
+
agent-browser network route <url> --body '{}' # Mock response
|
|
158
|
+
agent-browser network unroute [url] # Remove routes
|
|
159
|
+
agent-browser network requests # View tracked requests
|
|
160
|
+
agent-browser network requests --filter api # Filter requests
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Tabs and Windows
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
agent-browser tab # List tabs
|
|
167
|
+
agent-browser tab new [url] # New tab
|
|
168
|
+
agent-browser tab 2 # Switch to tab by index
|
|
169
|
+
agent-browser tab close # Close current tab
|
|
170
|
+
agent-browser tab close 2 # Close tab by index
|
|
171
|
+
agent-browser window new # New window
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Frames
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
agent-browser frame "#iframe" # Switch to iframe
|
|
178
|
+
agent-browser frame main # Back to main frame
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Dialogs
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
agent-browser dialog accept [text] # Accept dialog
|
|
185
|
+
agent-browser dialog dismiss # Dismiss dialog
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## JavaScript
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
agent-browser eval "document.title" # Simple expressions only
|
|
192
|
+
agent-browser eval -b "<base64>" # Any JavaScript (base64 encoded)
|
|
193
|
+
agent-browser eval --stdin # Read script from stdin
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Use `-b`/`--base64` or `--stdin` for reliable execution. Shell escaping with nested quotes and special characters is error-prone.
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Base64 encode your script, then:
|
|
200
|
+
agent-browser eval -b "ZG9jdW1lbnQucXVlcnlTZWxlY3RvcignW3NyYyo9Il9uZXh0Il0nKQ=="
|
|
201
|
+
|
|
202
|
+
# Or use stdin with heredoc for multiline scripts:
|
|
203
|
+
cat <<'EOF' | agent-browser eval --stdin
|
|
204
|
+
const links = document.querySelectorAll('a');
|
|
205
|
+
Array.from(links).map(a => a.href);
|
|
206
|
+
EOF
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## State Management
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
agent-browser state save auth.json # Save cookies, storage, auth state
|
|
213
|
+
agent-browser state load auth.json # Restore saved state
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Global Options
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
agent-browser --session <name> ... # Isolated browser session
|
|
220
|
+
agent-browser --json ... # JSON output for parsing
|
|
221
|
+
agent-browser --headed ... # Show browser window (not headless)
|
|
222
|
+
agent-browser --full ... # Full page screenshot (-f)
|
|
223
|
+
agent-browser --cdp <port> ... # Connect via Chrome DevTools Protocol
|
|
224
|
+
agent-browser -p <provider> ... # Cloud browser provider (--provider)
|
|
225
|
+
agent-browser --proxy <url> ... # Use proxy server
|
|
226
|
+
agent-browser --headers <json> ... # HTTP headers scoped to URL's origin
|
|
227
|
+
agent-browser --executable-path <p> # Custom browser executable
|
|
228
|
+
agent-browser --extension <path> ... # Load browser extension (repeatable)
|
|
229
|
+
agent-browser --ignore-https-errors # Ignore SSL certificate errors
|
|
230
|
+
agent-browser --help # Show help (-h)
|
|
231
|
+
agent-browser --version # Show version (-V)
|
|
232
|
+
agent-browser <command> --help # Show detailed help for a command
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Debugging
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
agent-browser --headed open example.com # Show browser window
|
|
239
|
+
agent-browser --cdp 9222 snapshot # Connect via CDP port
|
|
240
|
+
agent-browser connect 9222 # Alternative: connect command
|
|
241
|
+
agent-browser console # View console messages
|
|
242
|
+
agent-browser console --clear # Clear console
|
|
243
|
+
agent-browser errors # View page errors
|
|
244
|
+
agent-browser errors --clear # Clear errors
|
|
245
|
+
agent-browser highlight @e1 # Highlight element
|
|
246
|
+
agent-browser trace start # Start recording trace
|
|
247
|
+
agent-browser trace stop trace.zip # Stop and save trace
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Environment Variables
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
AGENT_BROWSER_SESSION="mysession" # Default session name
|
|
254
|
+
AGENT_BROWSER_EXECUTABLE_PATH="/path/chrome" # Custom browser path
|
|
255
|
+
AGENT_BROWSER_EXTENSIONS="/ext1,/ext2" # Comma-separated extension paths
|
|
256
|
+
AGENT_BROWSER_PROVIDER="browserbase" # Cloud browser provider
|
|
257
|
+
AGENT_BROWSER_STREAM_PORT="9223" # WebSocket streaming port
|
|
258
|
+
AGENT_BROWSER_HOME="/path/to/agent-browser" # Custom install location
|
|
259
|
+
```
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Proxy Support
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Proxy configuration for geo-testing, rate limiting avoidance, and corporate environments.
|
|
4
|
+
|
|
5
|
+
**Related**: [commands.md](commands.md) for global options, [SKILL.md](../SKILL.md) for quick start.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Basic Proxy Configuration](#basic-proxy-configuration)
|
|
10
|
+
- [Authenticated Proxy](#authenticated-proxy)
|
|
11
|
+
- [SOCKS Proxy](#socks-proxy)
|
|
12
|
+
- [Proxy Bypass](#proxy-bypass)
|
|
13
|
+
- [Common Use Cases](#common-use-cases)
|
|
14
|
+
- [Verifying Proxy Connection](#verifying-proxy-connection)
|
|
15
|
+
- [Troubleshooting](#troubleshooting)
|
|
16
|
+
- [Best Practices](#best-practices)
|
|
4
17
|
|
|
5
18
|
## Basic Proxy Configuration
|
|
6
19
|
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Session Management
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Multiple isolated browser sessions with state persistence and concurrent browsing.
|
|
4
|
+
|
|
5
|
+
**Related**: [authentication.md](authentication.md) for login patterns, [SKILL.md](../SKILL.md) for quick start.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Named Sessions](#named-sessions)
|
|
10
|
+
- [Session Isolation Properties](#session-isolation-properties)
|
|
11
|
+
- [Session State Persistence](#session-state-persistence)
|
|
12
|
+
- [Common Patterns](#common-patterns)
|
|
13
|
+
- [Default Session](#default-session)
|
|
14
|
+
- [Session Cleanup](#session-cleanup)
|
|
15
|
+
- [Best Practices](#best-practices)
|
|
4
16
|
|
|
5
17
|
## Named Sessions
|
|
6
18
|
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
# Snapshot
|
|
1
|
+
# Snapshot and Refs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Compact element references that reduce context usage dramatically for AI agents.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Related**: [commands.md](commands.md) for full command reference, [SKILL.md](../SKILL.md) for quick start.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [How Refs Work](#how-refs-work)
|
|
10
|
+
- [Snapshot Command](#the-snapshot-command)
|
|
11
|
+
- [Using Refs](#using-refs)
|
|
12
|
+
- [Ref Lifecycle](#ref-lifecycle)
|
|
13
|
+
- [Best Practices](#best-practices)
|
|
14
|
+
- [Ref Notation Details](#ref-notation-details)
|
|
15
|
+
- [Troubleshooting](#troubleshooting)
|
|
16
|
+
|
|
17
|
+
## How Refs Work
|
|
18
|
+
|
|
19
|
+
Traditional approach:
|
|
9
20
|
```
|
|
10
|
-
Full DOM/HTML
|
|
11
|
-
~3000-5000 tokens per interaction
|
|
21
|
+
Full DOM/HTML → AI parses → CSS selector → Action (~3000-5000 tokens)
|
|
12
22
|
```
|
|
13
23
|
|
|
14
|
-
|
|
15
|
-
agent-browser uses compact snapshots with refs:
|
|
24
|
+
agent-browser approach:
|
|
16
25
|
```
|
|
17
|
-
Compact snapshot → @refs assigned → Direct
|
|
18
|
-
~200-400 tokens per interaction
|
|
26
|
+
Compact snapshot → @refs assigned → Direct interaction (~200-400 tokens)
|
|
19
27
|
```
|
|
20
28
|
|
|
21
29
|
## The Snapshot Command
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Video Recording
|
|
2
2
|
|
|
3
|
-
Capture browser automation
|
|
3
|
+
Capture browser automation as video for debugging, documentation, or verification.
|
|
4
|
+
|
|
5
|
+
**Related**: [commands.md](commands.md) for full command reference, [SKILL.md](../SKILL.md) for quick start.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Basic Recording](#basic-recording)
|
|
10
|
+
- [Recording Commands](#recording-commands)
|
|
11
|
+
- [Use Cases](#use-cases)
|
|
12
|
+
- [Best Practices](#best-practices)
|
|
13
|
+
- [Output Format](#output-format)
|
|
14
|
+
- [Limitations](#limitations)
|
|
4
15
|
|
|
5
16
|
## Basic Recording
|
|
6
17
|
|
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# Template: Authenticated Session Workflow
|
|
3
|
-
# Login once, save state, reuse for subsequent runs
|
|
3
|
+
# Purpose: Login once, save state, reuse for subsequent runs
|
|
4
|
+
# Usage: ./authenticated-session.sh <login-url> [state-file]
|
|
4
5
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
6
|
+
# Environment variables:
|
|
7
|
+
# APP_USERNAME - Login username/email
|
|
8
|
+
# APP_PASSWORD - Login password
|
|
7
9
|
#
|
|
8
|
-
#
|
|
9
|
-
# 1.
|
|
10
|
-
# 2.
|
|
11
|
-
#
|
|
10
|
+
# Two modes:
|
|
11
|
+
# 1. Discovery mode (default): Shows form structure so you can identify refs
|
|
12
|
+
# 2. Login mode: Performs actual login after you update the refs
|
|
13
|
+
#
|
|
14
|
+
# Setup steps:
|
|
15
|
+
# 1. Run once to see form structure (discovery mode)
|
|
16
|
+
# 2. Update refs in LOGIN FLOW section below
|
|
17
|
+
# 3. Set APP_USERNAME and APP_PASSWORD
|
|
18
|
+
# 4. Delete the DISCOVERY section
|
|
12
19
|
|
|
13
20
|
set -euo pipefail
|
|
14
21
|
|
|
15
22
|
LOGIN_URL="${1:?Usage: $0 <login-url> [state-file]}"
|
|
16
23
|
STATE_FILE="${2:-./auth-state.json}"
|
|
17
24
|
|
|
18
|
-
echo "Authentication workflow
|
|
25
|
+
echo "Authentication workflow: $LOGIN_URL"
|
|
19
26
|
|
|
20
|
-
#
|
|
21
|
-
# SAVED STATE: Skip login if
|
|
22
|
-
#
|
|
27
|
+
# ================================================================
|
|
28
|
+
# SAVED STATE: Skip login if valid saved state exists
|
|
29
|
+
# ================================================================
|
|
23
30
|
if [[ -f "$STATE_FILE" ]]; then
|
|
24
|
-
echo "Loading saved
|
|
31
|
+
echo "Loading saved state from $STATE_FILE..."
|
|
25
32
|
agent-browser state load "$STATE_FILE"
|
|
26
33
|
agent-browser open "$LOGIN_URL"
|
|
27
34
|
agent-browser wait --load networkidle
|
|
28
35
|
|
|
29
36
|
CURRENT_URL=$(agent-browser get url)
|
|
30
37
|
if [[ "$CURRENT_URL" != *"login"* ]] && [[ "$CURRENT_URL" != *"signin"* ]]; then
|
|
31
|
-
echo "Session restored successfully
|
|
38
|
+
echo "Session restored successfully"
|
|
32
39
|
agent-browser snapshot -i
|
|
33
40
|
exit 0
|
|
34
41
|
fi
|
|
@@ -36,32 +43,31 @@ if [[ -f "$STATE_FILE" ]]; then
|
|
|
36
43
|
rm -f "$STATE_FILE"
|
|
37
44
|
fi
|
|
38
45
|
|
|
39
|
-
#
|
|
40
|
-
# DISCOVERY MODE:
|
|
41
|
-
#
|
|
46
|
+
# ================================================================
|
|
47
|
+
# DISCOVERY MODE: Shows form structure (delete after setup)
|
|
48
|
+
# ================================================================
|
|
42
49
|
echo "Opening login page..."
|
|
43
50
|
agent-browser open "$LOGIN_URL"
|
|
44
51
|
agent-browser wait --load networkidle
|
|
45
52
|
|
|
46
53
|
echo ""
|
|
47
|
-
echo "
|
|
48
|
-
echo "
|
|
49
|
-
echo "├─────────────────────────────────────────────────────────┤"
|
|
54
|
+
echo "Login form structure:"
|
|
55
|
+
echo "---"
|
|
50
56
|
agent-browser snapshot -i
|
|
51
|
-
echo "
|
|
57
|
+
echo "---"
|
|
52
58
|
echo ""
|
|
53
59
|
echo "Next steps:"
|
|
54
|
-
echo " 1. Note refs:
|
|
55
|
-
echo " 2.
|
|
56
|
-
echo " 3.
|
|
60
|
+
echo " 1. Note the refs: username=@e?, password=@e?, submit=@e?"
|
|
61
|
+
echo " 2. Update the LOGIN FLOW section below with your refs"
|
|
62
|
+
echo " 3. Set: export APP_USERNAME='...' APP_PASSWORD='...'"
|
|
57
63
|
echo " 4. Delete this DISCOVERY MODE section"
|
|
58
64
|
echo ""
|
|
59
65
|
agent-browser close
|
|
60
66
|
exit 0
|
|
61
67
|
|
|
62
|
-
#
|
|
68
|
+
# ================================================================
|
|
63
69
|
# LOGIN FLOW: Uncomment and customize after discovery
|
|
64
|
-
#
|
|
70
|
+
# ================================================================
|
|
65
71
|
# : "${APP_USERNAME:?Set APP_USERNAME environment variable}"
|
|
66
72
|
# : "${APP_PASSWORD:?Set APP_PASSWORD environment variable}"
|
|
67
73
|
#
|
|
@@ -78,14 +84,14 @@ exit 0
|
|
|
78
84
|
# # Verify login succeeded
|
|
79
85
|
# FINAL_URL=$(agent-browser get url)
|
|
80
86
|
# if [[ "$FINAL_URL" == *"login"* ]] || [[ "$FINAL_URL" == *"signin"* ]]; then
|
|
81
|
-
# echo "
|
|
87
|
+
# echo "Login failed - still on login page"
|
|
82
88
|
# agent-browser screenshot /tmp/login-failed.png
|
|
83
89
|
# agent-browser close
|
|
84
90
|
# exit 1
|
|
85
91
|
# fi
|
|
86
92
|
#
|
|
87
93
|
# # Save state for future runs
|
|
88
|
-
# echo "Saving
|
|
94
|
+
# echo "Saving state to $STATE_FILE"
|
|
89
95
|
# agent-browser state save "$STATE_FILE"
|
|
90
|
-
# echo "Login successful
|
|
96
|
+
# echo "Login successful"
|
|
91
97
|
# agent-browser snapshot -i
|
|
@@ -1,68 +1,69 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# Template: Content Capture Workflow
|
|
3
|
-
# Extract content from web pages
|
|
3
|
+
# Purpose: Extract content from web pages (text, screenshots, PDF)
|
|
4
|
+
# Usage: ./capture-workflow.sh <url> [output-dir]
|
|
5
|
+
#
|
|
6
|
+
# Outputs:
|
|
7
|
+
# - page-full.png: Full page screenshot
|
|
8
|
+
# - page-structure.txt: Page element structure with refs
|
|
9
|
+
# - page-text.txt: All text content
|
|
10
|
+
# - page.pdf: PDF version
|
|
11
|
+
#
|
|
12
|
+
# Optional: Load auth state for protected pages
|
|
4
13
|
|
|
5
14
|
set -euo pipefail
|
|
6
15
|
|
|
7
16
|
TARGET_URL="${1:?Usage: $0 <url> [output-dir]}"
|
|
8
17
|
OUTPUT_DIR="${2:-.}"
|
|
9
18
|
|
|
10
|
-
echo "Capturing
|
|
19
|
+
echo "Capturing: $TARGET_URL"
|
|
11
20
|
mkdir -p "$OUTPUT_DIR"
|
|
12
21
|
|
|
13
|
-
# Optional: Load authentication state
|
|
22
|
+
# Optional: Load authentication state
|
|
14
23
|
# if [[ -f "./auth-state.json" ]]; then
|
|
24
|
+
# echo "Loading authentication state..."
|
|
15
25
|
# agent-browser state load "./auth-state.json"
|
|
16
26
|
# fi
|
|
17
27
|
|
|
18
|
-
# Navigate to target
|
|
28
|
+
# Navigate to target
|
|
19
29
|
agent-browser open "$TARGET_URL"
|
|
20
30
|
agent-browser wait --load networkidle
|
|
21
31
|
|
|
22
|
-
# Get
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
# Get metadata
|
|
33
|
+
TITLE=$(agent-browser get title)
|
|
34
|
+
URL=$(agent-browser get url)
|
|
35
|
+
echo "Title: $TITLE"
|
|
36
|
+
echo "URL: $URL"
|
|
25
37
|
|
|
26
38
|
# Capture full page screenshot
|
|
27
39
|
agent-browser screenshot --full "$OUTPUT_DIR/page-full.png"
|
|
28
|
-
echo "
|
|
40
|
+
echo "Saved: $OUTPUT_DIR/page-full.png"
|
|
29
41
|
|
|
30
|
-
# Get page structure
|
|
42
|
+
# Get page structure with refs
|
|
31
43
|
agent-browser snapshot -i > "$OUTPUT_DIR/page-structure.txt"
|
|
32
|
-
echo "
|
|
44
|
+
echo "Saved: $OUTPUT_DIR/page-structure.txt"
|
|
33
45
|
|
|
34
|
-
# Extract
|
|
35
|
-
# Adjust selector based on target site structure
|
|
36
|
-
# agent-browser get text @e1 > "$OUTPUT_DIR/main-content.txt"
|
|
37
|
-
|
|
38
|
-
# Extract specific elements (uncomment as needed)
|
|
39
|
-
# agent-browser get text "article" > "$OUTPUT_DIR/article.txt"
|
|
40
|
-
# agent-browser get text "main" > "$OUTPUT_DIR/main.txt"
|
|
41
|
-
# agent-browser get text ".content" > "$OUTPUT_DIR/content.txt"
|
|
42
|
-
|
|
43
|
-
# Get full page text
|
|
46
|
+
# Extract all text content
|
|
44
47
|
agent-browser get text body > "$OUTPUT_DIR/page-text.txt"
|
|
45
|
-
echo "
|
|
48
|
+
echo "Saved: $OUTPUT_DIR/page-text.txt"
|
|
46
49
|
|
|
47
|
-
#
|
|
50
|
+
# Save as PDF
|
|
48
51
|
agent-browser pdf "$OUTPUT_DIR/page.pdf"
|
|
49
|
-
echo "
|
|
52
|
+
echo "Saved: $OUTPUT_DIR/page.pdf"
|
|
53
|
+
|
|
54
|
+
# Optional: Extract specific elements using refs from structure
|
|
55
|
+
# agent-browser get text @e5 > "$OUTPUT_DIR/main-content.txt"
|
|
50
56
|
|
|
51
|
-
# Optional:
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
# ((count++))
|
|
58
|
-
# done
|
|
59
|
-
# agent-browser screenshot --full "$OUTPUT_DIR/page-scrolled.png"
|
|
60
|
-
# }
|
|
61
|
-
# scroll_and_capture
|
|
57
|
+
# Optional: Handle infinite scroll pages
|
|
58
|
+
# for i in {1..5}; do
|
|
59
|
+
# agent-browser scroll down 1000
|
|
60
|
+
# agent-browser wait 1000
|
|
61
|
+
# done
|
|
62
|
+
# agent-browser screenshot --full "$OUTPUT_DIR/page-scrolled.png"
|
|
62
63
|
|
|
63
64
|
# Cleanup
|
|
64
65
|
agent-browser close
|
|
65
66
|
|
|
66
67
|
echo ""
|
|
67
|
-
echo "Capture complete
|
|
68
|
+
echo "Capture complete:"
|
|
68
69
|
ls -la "$OUTPUT_DIR"
|