@every-env/compound-plugin 2.36.5 → 2.37.0

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.
@@ -0,0 +1,194 @@
1
+ # Proxy Support
2
+
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)
17
+
18
+ ## Basic Proxy Configuration
19
+
20
+ Use the `--proxy` flag or set proxy via environment variable:
21
+
22
+ ```bash
23
+ # Via CLI flag
24
+ agent-browser --proxy "http://proxy.example.com:8080" open https://example.com
25
+
26
+ # Via environment variable
27
+ export HTTP_PROXY="http://proxy.example.com:8080"
28
+ agent-browser open https://example.com
29
+
30
+ # HTTPS proxy
31
+ export HTTPS_PROXY="https://proxy.example.com:8080"
32
+ agent-browser open https://example.com
33
+
34
+ # Both
35
+ export HTTP_PROXY="http://proxy.example.com:8080"
36
+ export HTTPS_PROXY="http://proxy.example.com:8080"
37
+ agent-browser open https://example.com
38
+ ```
39
+
40
+ ## Authenticated Proxy
41
+
42
+ For proxies requiring authentication:
43
+
44
+ ```bash
45
+ # Include credentials in URL
46
+ export HTTP_PROXY="http://username:password@proxy.example.com:8080"
47
+ agent-browser open https://example.com
48
+ ```
49
+
50
+ ## SOCKS Proxy
51
+
52
+ ```bash
53
+ # SOCKS5 proxy
54
+ export ALL_PROXY="socks5://proxy.example.com:1080"
55
+ agent-browser open https://example.com
56
+
57
+ # SOCKS5 with auth
58
+ export ALL_PROXY="socks5://user:pass@proxy.example.com:1080"
59
+ agent-browser open https://example.com
60
+ ```
61
+
62
+ ## Proxy Bypass
63
+
64
+ Skip proxy for specific domains using `--proxy-bypass` or `NO_PROXY`:
65
+
66
+ ```bash
67
+ # Via CLI flag
68
+ agent-browser --proxy "http://proxy.example.com:8080" --proxy-bypass "localhost,*.internal.com" open https://example.com
69
+
70
+ # Via environment variable
71
+ export NO_PROXY="localhost,127.0.0.1,.internal.company.com"
72
+ agent-browser open https://internal.company.com # Direct connection
73
+ agent-browser open https://external.com # Via proxy
74
+ ```
75
+
76
+ ## Common Use Cases
77
+
78
+ ### Geo-Location Testing
79
+
80
+ ```bash
81
+ #!/bin/bash
82
+ # Test site from different regions using geo-located proxies
83
+
84
+ PROXIES=(
85
+ "http://us-proxy.example.com:8080"
86
+ "http://eu-proxy.example.com:8080"
87
+ "http://asia-proxy.example.com:8080"
88
+ )
89
+
90
+ for proxy in "${PROXIES[@]}"; do
91
+ export HTTP_PROXY="$proxy"
92
+ export HTTPS_PROXY="$proxy"
93
+
94
+ region=$(echo "$proxy" | grep -oP '^\w+-\w+')
95
+ echo "Testing from: $region"
96
+
97
+ agent-browser --session "$region" open https://example.com
98
+ agent-browser --session "$region" screenshot "./screenshots/$region.png"
99
+ agent-browser --session "$region" close
100
+ done
101
+ ```
102
+
103
+ ### Rotating Proxies for Scraping
104
+
105
+ ```bash
106
+ #!/bin/bash
107
+ # Rotate through proxy list to avoid rate limiting
108
+
109
+ PROXY_LIST=(
110
+ "http://proxy1.example.com:8080"
111
+ "http://proxy2.example.com:8080"
112
+ "http://proxy3.example.com:8080"
113
+ )
114
+
115
+ URLS=(
116
+ "https://site.com/page1"
117
+ "https://site.com/page2"
118
+ "https://site.com/page3"
119
+ )
120
+
121
+ for i in "${!URLS[@]}"; do
122
+ proxy_index=$((i % ${#PROXY_LIST[@]}))
123
+ export HTTP_PROXY="${PROXY_LIST[$proxy_index]}"
124
+ export HTTPS_PROXY="${PROXY_LIST[$proxy_index]}"
125
+
126
+ agent-browser open "${URLS[$i]}"
127
+ agent-browser get text body > "output-$i.txt"
128
+ agent-browser close
129
+
130
+ sleep 1 # Polite delay
131
+ done
132
+ ```
133
+
134
+ ### Corporate Network Access
135
+
136
+ ```bash
137
+ #!/bin/bash
138
+ # Access internal sites via corporate proxy
139
+
140
+ export HTTP_PROXY="http://corpproxy.company.com:8080"
141
+ export HTTPS_PROXY="http://corpproxy.company.com:8080"
142
+ export NO_PROXY="localhost,127.0.0.1,.company.com"
143
+
144
+ # External sites go through proxy
145
+ agent-browser open https://external-vendor.com
146
+
147
+ # Internal sites bypass proxy
148
+ agent-browser open https://intranet.company.com
149
+ ```
150
+
151
+ ## Verifying Proxy Connection
152
+
153
+ ```bash
154
+ # Check your apparent IP
155
+ agent-browser open https://httpbin.org/ip
156
+ agent-browser get text body
157
+ # Should show proxy's IP, not your real IP
158
+ ```
159
+
160
+ ## Troubleshooting
161
+
162
+ ### Proxy Connection Failed
163
+
164
+ ```bash
165
+ # Test proxy connectivity first
166
+ curl -x http://proxy.example.com:8080 https://httpbin.org/ip
167
+
168
+ # Check if proxy requires auth
169
+ export HTTP_PROXY="http://user:pass@proxy.example.com:8080"
170
+ ```
171
+
172
+ ### SSL/TLS Errors Through Proxy
173
+
174
+ Some proxies perform SSL inspection. If you encounter certificate errors:
175
+
176
+ ```bash
177
+ # For testing only - not recommended for production
178
+ agent-browser open https://example.com --ignore-https-errors
179
+ ```
180
+
181
+ ### Slow Performance
182
+
183
+ ```bash
184
+ # Use proxy only when necessary
185
+ export NO_PROXY="*.cdn.com,*.static.com" # Direct CDN access
186
+ ```
187
+
188
+ ## Best Practices
189
+
190
+ 1. **Use environment variables** - Don't hardcode proxy credentials
191
+ 2. **Set NO_PROXY appropriately** - Avoid routing local traffic through proxy
192
+ 3. **Test proxy before automation** - Verify connectivity with simple requests
193
+ 4. **Handle proxy failures gracefully** - Implement retry logic for unstable proxies
194
+ 5. **Rotate proxies for large scraping jobs** - Distribute load and avoid bans
@@ -0,0 +1,193 @@
1
+ # Session Management
2
+
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)
16
+
17
+ ## Named Sessions
18
+
19
+ Use `--session` flag to isolate browser contexts:
20
+
21
+ ```bash
22
+ # Session 1: Authentication flow
23
+ agent-browser --session auth open https://app.example.com/login
24
+
25
+ # Session 2: Public browsing (separate cookies, storage)
26
+ agent-browser --session public open https://example.com
27
+
28
+ # Commands are isolated by session
29
+ agent-browser --session auth fill @e1 "user@example.com"
30
+ agent-browser --session public get text body
31
+ ```
32
+
33
+ ## Session Isolation Properties
34
+
35
+ Each session has independent:
36
+ - Cookies
37
+ - LocalStorage / SessionStorage
38
+ - IndexedDB
39
+ - Cache
40
+ - Browsing history
41
+ - Open tabs
42
+
43
+ ## Session State Persistence
44
+
45
+ ### Save Session State
46
+
47
+ ```bash
48
+ # Save cookies, storage, and auth state
49
+ agent-browser state save /path/to/auth-state.json
50
+ ```
51
+
52
+ ### Load Session State
53
+
54
+ ```bash
55
+ # Restore saved state
56
+ agent-browser state load /path/to/auth-state.json
57
+
58
+ # Continue with authenticated session
59
+ agent-browser open https://app.example.com/dashboard
60
+ ```
61
+
62
+ ### State File Contents
63
+
64
+ ```json
65
+ {
66
+ "cookies": [...],
67
+ "localStorage": {...},
68
+ "sessionStorage": {...},
69
+ "origins": [...]
70
+ }
71
+ ```
72
+
73
+ ## Common Patterns
74
+
75
+ ### Authenticated Session Reuse
76
+
77
+ ```bash
78
+ #!/bin/bash
79
+ # Save login state once, reuse many times
80
+
81
+ STATE_FILE="/tmp/auth-state.json"
82
+
83
+ # Check if we have saved state
84
+ if [[ -f "$STATE_FILE" ]]; then
85
+ agent-browser state load "$STATE_FILE"
86
+ agent-browser open https://app.example.com/dashboard
87
+ else
88
+ # Perform login
89
+ agent-browser open https://app.example.com/login
90
+ agent-browser snapshot -i
91
+ agent-browser fill @e1 "$USERNAME"
92
+ agent-browser fill @e2 "$PASSWORD"
93
+ agent-browser click @e3
94
+ agent-browser wait --load networkidle
95
+
96
+ # Save for future use
97
+ agent-browser state save "$STATE_FILE"
98
+ fi
99
+ ```
100
+
101
+ ### Concurrent Scraping
102
+
103
+ ```bash
104
+ #!/bin/bash
105
+ # Scrape multiple sites concurrently
106
+
107
+ # Start all sessions
108
+ agent-browser --session site1 open https://site1.com &
109
+ agent-browser --session site2 open https://site2.com &
110
+ agent-browser --session site3 open https://site3.com &
111
+ wait
112
+
113
+ # Extract from each
114
+ agent-browser --session site1 get text body > site1.txt
115
+ agent-browser --session site2 get text body > site2.txt
116
+ agent-browser --session site3 get text body > site3.txt
117
+
118
+ # Cleanup
119
+ agent-browser --session site1 close
120
+ agent-browser --session site2 close
121
+ agent-browser --session site3 close
122
+ ```
123
+
124
+ ### A/B Testing Sessions
125
+
126
+ ```bash
127
+ # Test different user experiences
128
+ agent-browser --session variant-a open "https://app.com?variant=a"
129
+ agent-browser --session variant-b open "https://app.com?variant=b"
130
+
131
+ # Compare
132
+ agent-browser --session variant-a screenshot /tmp/variant-a.png
133
+ agent-browser --session variant-b screenshot /tmp/variant-b.png
134
+ ```
135
+
136
+ ## Default Session
137
+
138
+ When `--session` is omitted, commands use the default session:
139
+
140
+ ```bash
141
+ # These use the same default session
142
+ agent-browser open https://example.com
143
+ agent-browser snapshot -i
144
+ agent-browser close # Closes default session
145
+ ```
146
+
147
+ ## Session Cleanup
148
+
149
+ ```bash
150
+ # Close specific session
151
+ agent-browser --session auth close
152
+
153
+ # List active sessions
154
+ agent-browser session list
155
+ ```
156
+
157
+ ## Best Practices
158
+
159
+ ### 1. Name Sessions Semantically
160
+
161
+ ```bash
162
+ # GOOD: Clear purpose
163
+ agent-browser --session github-auth open https://github.com
164
+ agent-browser --session docs-scrape open https://docs.example.com
165
+
166
+ # AVOID: Generic names
167
+ agent-browser --session s1 open https://github.com
168
+ ```
169
+
170
+ ### 2. Always Clean Up
171
+
172
+ ```bash
173
+ # Close sessions when done
174
+ agent-browser --session auth close
175
+ agent-browser --session scrape close
176
+ ```
177
+
178
+ ### 3. Handle State Files Securely
179
+
180
+ ```bash
181
+ # Don't commit state files (contain auth tokens!)
182
+ echo "*.auth-state.json" >> .gitignore
183
+
184
+ # Delete after use
185
+ rm /tmp/auth-state.json
186
+ ```
187
+
188
+ ### 4. Timeout Long Sessions
189
+
190
+ ```bash
191
+ # Set timeout for automated scripts
192
+ timeout 60 agent-browser --session long-task get text body
193
+ ```
@@ -0,0 +1,194 @@
1
+ # Snapshot and Refs
2
+
3
+ Compact element references that reduce context usage dramatically for AI agents.
4
+
5
+ **Related**: [commands.md](commands.md) for full command reference, [SKILL.md](../SKILL.md) for quick start.
6
+
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:
20
+ ```
21
+ Full DOM/HTML -> AI parses -> CSS selector -> Action (~3000-5000 tokens)
22
+ ```
23
+
24
+ agent-browser approach:
25
+ ```
26
+ Compact snapshot -> @refs assigned -> Direct interaction (~200-400 tokens)
27
+ ```
28
+
29
+ ## The Snapshot Command
30
+
31
+ ```bash
32
+ # Basic snapshot (shows page structure)
33
+ agent-browser snapshot
34
+
35
+ # Interactive snapshot (-i flag) - RECOMMENDED
36
+ agent-browser snapshot -i
37
+ ```
38
+
39
+ ### Snapshot Output Format
40
+
41
+ ```
42
+ Page: Example Site - Home
43
+ URL: https://example.com
44
+
45
+ @e1 [header]
46
+ @e2 [nav]
47
+ @e3 [a] "Home"
48
+ @e4 [a] "Products"
49
+ @e5 [a] "About"
50
+ @e6 [button] "Sign In"
51
+
52
+ @e7 [main]
53
+ @e8 [h1] "Welcome"
54
+ @e9 [form]
55
+ @e10 [input type="email"] placeholder="Email"
56
+ @e11 [input type="password"] placeholder="Password"
57
+ @e12 [button type="submit"] "Log In"
58
+
59
+ @e13 [footer]
60
+ @e14 [a] "Privacy Policy"
61
+ ```
62
+
63
+ ## Using Refs
64
+
65
+ Once you have refs, interact directly:
66
+
67
+ ```bash
68
+ # Click the "Sign In" button
69
+ agent-browser click @e6
70
+
71
+ # Fill email input
72
+ agent-browser fill @e10 "user@example.com"
73
+
74
+ # Fill password
75
+ agent-browser fill @e11 "password123"
76
+
77
+ # Submit the form
78
+ agent-browser click @e12
79
+ ```
80
+
81
+ ## Ref Lifecycle
82
+
83
+ **IMPORTANT**: Refs are invalidated when the page changes!
84
+
85
+ ```bash
86
+ # Get initial snapshot
87
+ agent-browser snapshot -i
88
+ # @e1 [button] "Next"
89
+
90
+ # Click triggers page change
91
+ agent-browser click @e1
92
+
93
+ # MUST re-snapshot to get new refs!
94
+ agent-browser snapshot -i
95
+ # @e1 [h1] "Page 2" <- Different element now!
96
+ ```
97
+
98
+ ## Best Practices
99
+
100
+ ### 1. Always Snapshot Before Interacting
101
+
102
+ ```bash
103
+ # CORRECT
104
+ agent-browser open https://example.com
105
+ agent-browser snapshot -i # Get refs first
106
+ agent-browser click @e1 # Use ref
107
+
108
+ # WRONG
109
+ agent-browser open https://example.com
110
+ agent-browser click @e1 # Ref doesn't exist yet!
111
+ ```
112
+
113
+ ### 2. Re-Snapshot After Navigation
114
+
115
+ ```bash
116
+ agent-browser click @e5 # Navigates to new page
117
+ agent-browser snapshot -i # Get new refs
118
+ agent-browser click @e1 # Use new refs
119
+ ```
120
+
121
+ ### 3. Re-Snapshot After Dynamic Changes
122
+
123
+ ```bash
124
+ agent-browser click @e1 # Opens dropdown
125
+ agent-browser snapshot -i # See dropdown items
126
+ agent-browser click @e7 # Select item
127
+ ```
128
+
129
+ ### 4. Snapshot Specific Regions
130
+
131
+ For complex pages, snapshot specific areas:
132
+
133
+ ```bash
134
+ # Snapshot just the form
135
+ agent-browser snapshot @e9
136
+ ```
137
+
138
+ ## Ref Notation Details
139
+
140
+ ```
141
+ @e1 [tag type="value"] "text content" placeholder="hint"
142
+ | | | | |
143
+ | | | | +- Additional attributes
144
+ | | | +- Visible text
145
+ | | +- Key attributes shown
146
+ | +- HTML tag name
147
+ +- Unique ref ID
148
+ ```
149
+
150
+ ### Common Patterns
151
+
152
+ ```
153
+ @e1 [button] "Submit" # Button with text
154
+ @e2 [input type="email"] # Email input
155
+ @e3 [input type="password"] # Password input
156
+ @e4 [a href="/page"] "Link Text" # Anchor link
157
+ @e5 [select] # Dropdown
158
+ @e6 [textarea] placeholder="Message" # Text area
159
+ @e7 [div class="modal"] # Container (when relevant)
160
+ @e8 [img alt="Logo"] # Image
161
+ @e9 [checkbox] checked # Checked checkbox
162
+ @e10 [radio] selected # Selected radio
163
+ ```
164
+
165
+ ## Troubleshooting
166
+
167
+ ### "Ref not found" Error
168
+
169
+ ```bash
170
+ # Ref may have changed - re-snapshot
171
+ agent-browser snapshot -i
172
+ ```
173
+
174
+ ### Element Not Visible in Snapshot
175
+
176
+ ```bash
177
+ # Scroll down to reveal element
178
+ agent-browser scroll down 1000
179
+ agent-browser snapshot -i
180
+
181
+ # Or wait for dynamic content
182
+ agent-browser wait 1000
183
+ agent-browser snapshot -i
184
+ ```
185
+
186
+ ### Too Many Elements
187
+
188
+ ```bash
189
+ # Snapshot specific container
190
+ agent-browser snapshot @e5
191
+
192
+ # Or use get text for content-only extraction
193
+ agent-browser get text @e5
194
+ ```