create-modern-react 2.1.2 → 2.3.1
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 +50 -0
- package/lib/prompts.js +8 -0
- package/lib/setup.js +18 -1
- package/package.json +1 -1
- package/templates/base/.claude/skills/agent-browser/SKILL.md +356 -0
- package/templates/base/.claude/skills/agent-browser/references/authentication.md +188 -0
- package/templates/base/.claude/skills/agent-browser/references/proxy-support.md +175 -0
- package/templates/base/.claude/skills/agent-browser/references/session-management.md +181 -0
- package/templates/base/.claude/skills/agent-browser/references/snapshot-refs.md +186 -0
- package/templates/base/.claude/skills/agent-browser/references/video-recording.md +162 -0
- package/templates/base/.claude/skills/agent-browser/templates/authenticated-session.sh +91 -0
- package/templates/base/.claude/skills/agent-browser/templates/capture-workflow.sh +68 -0
- package/templates/base/.claude/skills/agent-browser/templates/form-automation.sh +64 -0
- package/templates/base/.claude/skills/autoskill/skill.md +134 -0
- package/templates/base/.claude/skills/design-principles/skill.md +237 -0
- package/templates/base/.claude/skills/frontend-design/skill.md +42 -0
- package/templates/base/.claude/skills/learn-together/skill.md +448 -0
- package/templates/base/.claude/skills/question-me/skill.md +175 -0
- package/templates/base/.claude/skills/react-best-practices/AGENTS.md +2410 -0
- package/templates/base/.claude/skills/react-best-practices/README.md +123 -0
- package/templates/base/.claude/skills/react-best-practices/SKILL.md +135 -0
- package/templates/base/.claude/skills/react-best-practices/metadata.json +15 -0
- package/templates/base/.claude/skills/react-best-practices/rules/_sections.md +46 -0
- package/templates/base/.claude/skills/react-best-practices/rules/_template.md +28 -0
- package/templates/base/.claude/skills/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/templates/base/.claude/skills/react-best-practices/rules/advanced-use-latest.md +49 -0
- package/templates/base/.claude/skills/react-best-practices/rules/async-api-routes.md +38 -0
- package/templates/base/.claude/skills/react-best-practices/rules/async-defer-await.md +80 -0
- package/templates/base/.claude/skills/react-best-practices/rules/async-dependencies.md +36 -0
- package/templates/base/.claude/skills/react-best-practices/rules/async-parallel.md +28 -0
- package/templates/base/.claude/skills/react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/templates/base/.claude/skills/react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/templates/base/.claude/skills/react-best-practices/rules/bundle-conditional.md +31 -0
- package/templates/base/.claude/skills/react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/templates/base/.claude/skills/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/templates/base/.claude/skills/react-best-practices/rules/bundle-preload.md +50 -0
- package/templates/base/.claude/skills/react-best-practices/rules/client-event-listeners.md +74 -0
- package/templates/base/.claude/skills/react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/templates/base/.claude/skills/react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/templates/base/.claude/skills/react-best-practices/rules/client-swr-dedup.md +56 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-batch-dom-css.md +57 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-cache-function-results.md +80 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-cache-property-access.md +28 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-cache-storage.md +70 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-combine-iterations.md +32 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-early-exit.md +50 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-index-maps.md +37 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-length-check-first.md +49 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-min-max-loop.md +82 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/templates/base/.claude/skills/react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rendering-activity.md +26 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rerender-dependencies.md +45 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rerender-derived-state.md +29 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rerender-memo.md +44 -0
- package/templates/base/.claude/skills/react-best-practices/rules/rerender-transitions.md +40 -0
- package/templates/base/.claude/skills/react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/templates/base/.claude/skills/react-best-practices/rules/server-cache-lru.md +41 -0
- package/templates/base/.claude/skills/react-best-practices/rules/server-cache-react.md +76 -0
- package/templates/base/.claude/skills/react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/templates/base/.claude/skills/react-best-practices/rules/server-serialization.md +38 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/SKILL.md +377 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/react-native.csv +53 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/templates/base/.claude/skills/ui-ux-pro-max/scripts/search.py +106 -0
- package/templates/base/public/robots.txt +2 -0
- package/templates/base/public/screenshots/healthmug.png +0 -0
- package/templates/base/public/screenshots/resumefreepro.png +0 -0
- package/templates/base/public/vite.svg +1 -0
- package/templates/base/src/screens/home/index.tsx +113 -14
- package/templates/optional/forms/index.ts +2 -0
- package/templates/optional/forms/types.ts +39 -0
- package/templates/optional/forms/use-zod-form.ts +59 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Authentication Patterns
|
|
2
|
+
|
|
3
|
+
Patterns for handling login flows, session persistence, and authenticated browsing.
|
|
4
|
+
|
|
5
|
+
## Basic Login Flow
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Navigate to login page
|
|
9
|
+
agent-browser open https://app.example.com/login
|
|
10
|
+
agent-browser wait --load networkidle
|
|
11
|
+
|
|
12
|
+
# Get form elements
|
|
13
|
+
agent-browser snapshot -i
|
|
14
|
+
# Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Sign In"
|
|
15
|
+
|
|
16
|
+
# Fill credentials
|
|
17
|
+
agent-browser fill @e1 "user@example.com"
|
|
18
|
+
agent-browser fill @e2 "password123"
|
|
19
|
+
|
|
20
|
+
# Submit
|
|
21
|
+
agent-browser click @e3
|
|
22
|
+
agent-browser wait --load networkidle
|
|
23
|
+
|
|
24
|
+
# Verify login succeeded
|
|
25
|
+
agent-browser get url # Should be dashboard, not login
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Saving Authentication State
|
|
29
|
+
|
|
30
|
+
After logging in, save state for reuse:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Login first (see above)
|
|
34
|
+
agent-browser open https://app.example.com/login
|
|
35
|
+
agent-browser snapshot -i
|
|
36
|
+
agent-browser fill @e1 "user@example.com"
|
|
37
|
+
agent-browser fill @e2 "password123"
|
|
38
|
+
agent-browser click @e3
|
|
39
|
+
agent-browser wait --url "**/dashboard"
|
|
40
|
+
|
|
41
|
+
# Save authenticated state
|
|
42
|
+
agent-browser state save ./auth-state.json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Restoring Authentication
|
|
46
|
+
|
|
47
|
+
Skip login by loading saved state:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Load saved auth state
|
|
51
|
+
agent-browser state load ./auth-state.json
|
|
52
|
+
|
|
53
|
+
# Navigate directly to protected page
|
|
54
|
+
agent-browser open https://app.example.com/dashboard
|
|
55
|
+
|
|
56
|
+
# Verify authenticated
|
|
57
|
+
agent-browser snapshot -i
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## OAuth / SSO Flows
|
|
61
|
+
|
|
62
|
+
For OAuth redirects:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Start OAuth flow
|
|
66
|
+
agent-browser open https://app.example.com/auth/google
|
|
67
|
+
|
|
68
|
+
# Handle redirects automatically
|
|
69
|
+
agent-browser wait --url "**/accounts.google.com**"
|
|
70
|
+
agent-browser snapshot -i
|
|
71
|
+
|
|
72
|
+
# Fill Google credentials
|
|
73
|
+
agent-browser fill @e1 "user@gmail.com"
|
|
74
|
+
agent-browser click @e2 # Next button
|
|
75
|
+
agent-browser wait 2000
|
|
76
|
+
agent-browser snapshot -i
|
|
77
|
+
agent-browser fill @e3 "password"
|
|
78
|
+
agent-browser click @e4 # Sign in
|
|
79
|
+
|
|
80
|
+
# Wait for redirect back
|
|
81
|
+
agent-browser wait --url "**/app.example.com**"
|
|
82
|
+
agent-browser state save ./oauth-state.json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Two-Factor Authentication
|
|
86
|
+
|
|
87
|
+
Handle 2FA with manual intervention:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Login with credentials
|
|
91
|
+
agent-browser open https://app.example.com/login --headed # Show browser
|
|
92
|
+
agent-browser snapshot -i
|
|
93
|
+
agent-browser fill @e1 "user@example.com"
|
|
94
|
+
agent-browser fill @e2 "password123"
|
|
95
|
+
agent-browser click @e3
|
|
96
|
+
|
|
97
|
+
# Wait for user to complete 2FA manually
|
|
98
|
+
echo "Complete 2FA in the browser window..."
|
|
99
|
+
agent-browser wait --url "**/dashboard" --timeout 120000
|
|
100
|
+
|
|
101
|
+
# Save state after 2FA
|
|
102
|
+
agent-browser state save ./2fa-state.json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## HTTP Basic Auth
|
|
106
|
+
|
|
107
|
+
For sites using HTTP Basic Authentication:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Set credentials before navigation
|
|
111
|
+
agent-browser set credentials username password
|
|
112
|
+
|
|
113
|
+
# Navigate to protected resource
|
|
114
|
+
agent-browser open https://protected.example.com/api
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Cookie-Based Auth
|
|
118
|
+
|
|
119
|
+
Manually set authentication cookies:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Set auth cookie
|
|
123
|
+
agent-browser cookies set session_token "abc123xyz"
|
|
124
|
+
|
|
125
|
+
# Navigate to protected page
|
|
126
|
+
agent-browser open https://app.example.com/dashboard
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Token Refresh Handling
|
|
130
|
+
|
|
131
|
+
For sessions with expiring tokens:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
#!/bin/bash
|
|
135
|
+
# Wrapper that handles token refresh
|
|
136
|
+
|
|
137
|
+
STATE_FILE="./auth-state.json"
|
|
138
|
+
|
|
139
|
+
# Try loading existing state
|
|
140
|
+
if [[ -f "$STATE_FILE" ]]; then
|
|
141
|
+
agent-browser state load "$STATE_FILE"
|
|
142
|
+
agent-browser open https://app.example.com/dashboard
|
|
143
|
+
|
|
144
|
+
# Check if session is still valid
|
|
145
|
+
URL=$(agent-browser get url)
|
|
146
|
+
if [[ "$URL" == *"/login"* ]]; then
|
|
147
|
+
echo "Session expired, re-authenticating..."
|
|
148
|
+
# Perform fresh login
|
|
149
|
+
agent-browser snapshot -i
|
|
150
|
+
agent-browser fill @e1 "$USERNAME"
|
|
151
|
+
agent-browser fill @e2 "$PASSWORD"
|
|
152
|
+
agent-browser click @e3
|
|
153
|
+
agent-browser wait --url "**/dashboard"
|
|
154
|
+
agent-browser state save "$STATE_FILE"
|
|
155
|
+
fi
|
|
156
|
+
else
|
|
157
|
+
# First-time login
|
|
158
|
+
agent-browser open https://app.example.com/login
|
|
159
|
+
# ... login flow ...
|
|
160
|
+
fi
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Security Best Practices
|
|
164
|
+
|
|
165
|
+
1. **Never commit state files** - They contain session tokens
|
|
166
|
+
```bash
|
|
167
|
+
echo "*.auth-state.json" >> .gitignore
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
2. **Use environment variables for credentials**
|
|
171
|
+
```bash
|
|
172
|
+
agent-browser fill @e1 "$APP_USERNAME"
|
|
173
|
+
agent-browser fill @e2 "$APP_PASSWORD"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
3. **Clean up after automation**
|
|
177
|
+
```bash
|
|
178
|
+
agent-browser cookies clear
|
|
179
|
+
rm -f ./auth-state.json
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
4. **Use short-lived sessions for CI/CD**
|
|
183
|
+
```bash
|
|
184
|
+
# Don't persist state in CI
|
|
185
|
+
agent-browser open https://app.example.com/login
|
|
186
|
+
# ... login and perform actions ...
|
|
187
|
+
agent-browser close # Session ends, nothing persisted
|
|
188
|
+
```
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Proxy Support
|
|
2
|
+
|
|
3
|
+
Configure proxy servers for browser automation, useful for geo-testing, rate limiting avoidance, and corporate environments.
|
|
4
|
+
|
|
5
|
+
## Basic Proxy Configuration
|
|
6
|
+
|
|
7
|
+
Set proxy via environment variable before starting:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# HTTP proxy
|
|
11
|
+
export HTTP_PROXY="http://proxy.example.com:8080"
|
|
12
|
+
agent-browser open https://example.com
|
|
13
|
+
|
|
14
|
+
# HTTPS proxy
|
|
15
|
+
export HTTPS_PROXY="https://proxy.example.com:8080"
|
|
16
|
+
agent-browser open https://example.com
|
|
17
|
+
|
|
18
|
+
# Both
|
|
19
|
+
export HTTP_PROXY="http://proxy.example.com:8080"
|
|
20
|
+
export HTTPS_PROXY="http://proxy.example.com:8080"
|
|
21
|
+
agent-browser open https://example.com
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Authenticated Proxy
|
|
25
|
+
|
|
26
|
+
For proxies requiring authentication:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Include credentials in URL
|
|
30
|
+
export HTTP_PROXY="http://username:password@proxy.example.com:8080"
|
|
31
|
+
agent-browser open https://example.com
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## SOCKS Proxy
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# SOCKS5 proxy
|
|
38
|
+
export ALL_PROXY="socks5://proxy.example.com:1080"
|
|
39
|
+
agent-browser open https://example.com
|
|
40
|
+
|
|
41
|
+
# SOCKS5 with auth
|
|
42
|
+
export ALL_PROXY="socks5://user:pass@proxy.example.com:1080"
|
|
43
|
+
agent-browser open https://example.com
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Proxy Bypass
|
|
47
|
+
|
|
48
|
+
Skip proxy for specific domains:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Bypass proxy for local addresses
|
|
52
|
+
export NO_PROXY="localhost,127.0.0.1,.internal.company.com"
|
|
53
|
+
agent-browser open https://internal.company.com # Direct connection
|
|
54
|
+
agent-browser open https://external.com # Via proxy
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Common Use Cases
|
|
58
|
+
|
|
59
|
+
### Geo-Location Testing
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
#!/bin/bash
|
|
63
|
+
# Test site from different regions using geo-located proxies
|
|
64
|
+
|
|
65
|
+
PROXIES=(
|
|
66
|
+
"http://us-proxy.example.com:8080"
|
|
67
|
+
"http://eu-proxy.example.com:8080"
|
|
68
|
+
"http://asia-proxy.example.com:8080"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
for proxy in "${PROXIES[@]}"; do
|
|
72
|
+
export HTTP_PROXY="$proxy"
|
|
73
|
+
export HTTPS_PROXY="$proxy"
|
|
74
|
+
|
|
75
|
+
region=$(echo "$proxy" | grep -oP '^\w+-\w+')
|
|
76
|
+
echo "Testing from: $region"
|
|
77
|
+
|
|
78
|
+
agent-browser --session "$region" open https://example.com
|
|
79
|
+
agent-browser --session "$region" screenshot "./screenshots/$region.png"
|
|
80
|
+
agent-browser --session "$region" close
|
|
81
|
+
done
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Rotating Proxies for Scraping
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
#!/bin/bash
|
|
88
|
+
# Rotate through proxy list to avoid rate limiting
|
|
89
|
+
|
|
90
|
+
PROXY_LIST=(
|
|
91
|
+
"http://proxy1.example.com:8080"
|
|
92
|
+
"http://proxy2.example.com:8080"
|
|
93
|
+
"http://proxy3.example.com:8080"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
URLS=(
|
|
97
|
+
"https://site.com/page1"
|
|
98
|
+
"https://site.com/page2"
|
|
99
|
+
"https://site.com/page3"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
for i in "${!URLS[@]}"; do
|
|
103
|
+
proxy_index=$((i % ${#PROXY_LIST[@]}))
|
|
104
|
+
export HTTP_PROXY="${PROXY_LIST[$proxy_index]}"
|
|
105
|
+
export HTTPS_PROXY="${PROXY_LIST[$proxy_index]}"
|
|
106
|
+
|
|
107
|
+
agent-browser open "${URLS[$i]}"
|
|
108
|
+
agent-browser get text body > "output-$i.txt"
|
|
109
|
+
agent-browser close
|
|
110
|
+
|
|
111
|
+
sleep 1 # Polite delay
|
|
112
|
+
done
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Corporate Network Access
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
#!/bin/bash
|
|
119
|
+
# Access internal sites via corporate proxy
|
|
120
|
+
|
|
121
|
+
export HTTP_PROXY="http://corpproxy.company.com:8080"
|
|
122
|
+
export HTTPS_PROXY="http://corpproxy.company.com:8080"
|
|
123
|
+
export NO_PROXY="localhost,127.0.0.1,.company.com"
|
|
124
|
+
|
|
125
|
+
# External sites go through proxy
|
|
126
|
+
agent-browser open https://external-vendor.com
|
|
127
|
+
|
|
128
|
+
# Internal sites bypass proxy
|
|
129
|
+
agent-browser open https://intranet.company.com
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Verifying Proxy Connection
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Check your apparent IP
|
|
136
|
+
agent-browser open https://httpbin.org/ip
|
|
137
|
+
agent-browser get text body
|
|
138
|
+
# Should show proxy's IP, not your real IP
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Troubleshooting
|
|
142
|
+
|
|
143
|
+
### Proxy Connection Failed
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Test proxy connectivity first
|
|
147
|
+
curl -x http://proxy.example.com:8080 https://httpbin.org/ip
|
|
148
|
+
|
|
149
|
+
# Check if proxy requires auth
|
|
150
|
+
export HTTP_PROXY="http://user:pass@proxy.example.com:8080"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### SSL/TLS Errors Through Proxy
|
|
154
|
+
|
|
155
|
+
Some proxies perform SSL inspection. If you encounter certificate errors:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# For testing only - not recommended for production
|
|
159
|
+
agent-browser open https://example.com --ignore-https-errors
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Slow Performance
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Use proxy only when necessary
|
|
166
|
+
export NO_PROXY="*.cdn.com,*.static.com" # Direct CDN access
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Best Practices
|
|
170
|
+
|
|
171
|
+
1. **Use environment variables** - Don't hardcode proxy credentials
|
|
172
|
+
2. **Set NO_PROXY appropriately** - Avoid routing local traffic through proxy
|
|
173
|
+
3. **Test proxy before automation** - Verify connectivity with simple requests
|
|
174
|
+
4. **Handle proxy failures gracefully** - Implement retry logic for unstable proxies
|
|
175
|
+
5. **Rotate proxies for large scraping jobs** - Distribute load and avoid bans
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Session Management
|
|
2
|
+
|
|
3
|
+
Run multiple isolated browser sessions concurrently with state persistence.
|
|
4
|
+
|
|
5
|
+
## Named Sessions
|
|
6
|
+
|
|
7
|
+
Use `--session` flag to isolate browser contexts:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Session 1: Authentication flow
|
|
11
|
+
agent-browser --session auth open https://app.example.com/login
|
|
12
|
+
|
|
13
|
+
# Session 2: Public browsing (separate cookies, storage)
|
|
14
|
+
agent-browser --session public open https://example.com
|
|
15
|
+
|
|
16
|
+
# Commands are isolated by session
|
|
17
|
+
agent-browser --session auth fill @e1 "user@example.com"
|
|
18
|
+
agent-browser --session public get text body
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Session Isolation Properties
|
|
22
|
+
|
|
23
|
+
Each session has independent:
|
|
24
|
+
- Cookies
|
|
25
|
+
- LocalStorage / SessionStorage
|
|
26
|
+
- IndexedDB
|
|
27
|
+
- Cache
|
|
28
|
+
- Browsing history
|
|
29
|
+
- Open tabs
|
|
30
|
+
|
|
31
|
+
## Session State Persistence
|
|
32
|
+
|
|
33
|
+
### Save Session State
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Save cookies, storage, and auth state
|
|
37
|
+
agent-browser state save /path/to/auth-state.json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Load Session State
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Restore saved state
|
|
44
|
+
agent-browser state load /path/to/auth-state.json
|
|
45
|
+
|
|
46
|
+
# Continue with authenticated session
|
|
47
|
+
agent-browser open https://app.example.com/dashboard
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### State File Contents
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"cookies": [...],
|
|
55
|
+
"localStorage": {...},
|
|
56
|
+
"sessionStorage": {...},
|
|
57
|
+
"origins": [...]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Common Patterns
|
|
62
|
+
|
|
63
|
+
### Authenticated Session Reuse
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
#!/bin/bash
|
|
67
|
+
# Save login state once, reuse many times
|
|
68
|
+
|
|
69
|
+
STATE_FILE="/tmp/auth-state.json"
|
|
70
|
+
|
|
71
|
+
# Check if we have saved state
|
|
72
|
+
if [[ -f "$STATE_FILE" ]]; then
|
|
73
|
+
agent-browser state load "$STATE_FILE"
|
|
74
|
+
agent-browser open https://app.example.com/dashboard
|
|
75
|
+
else
|
|
76
|
+
# Perform login
|
|
77
|
+
agent-browser open https://app.example.com/login
|
|
78
|
+
agent-browser snapshot -i
|
|
79
|
+
agent-browser fill @e1 "$USERNAME"
|
|
80
|
+
agent-browser fill @e2 "$PASSWORD"
|
|
81
|
+
agent-browser click @e3
|
|
82
|
+
agent-browser wait --load networkidle
|
|
83
|
+
|
|
84
|
+
# Save for future use
|
|
85
|
+
agent-browser state save "$STATE_FILE"
|
|
86
|
+
fi
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Concurrent Scraping
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
#!/bin/bash
|
|
93
|
+
# Scrape multiple sites concurrently
|
|
94
|
+
|
|
95
|
+
# Start all sessions
|
|
96
|
+
agent-browser --session site1 open https://site1.com &
|
|
97
|
+
agent-browser --session site2 open https://site2.com &
|
|
98
|
+
agent-browser --session site3 open https://site3.com &
|
|
99
|
+
wait
|
|
100
|
+
|
|
101
|
+
# Extract from each
|
|
102
|
+
agent-browser --session site1 get text body > site1.txt
|
|
103
|
+
agent-browser --session site2 get text body > site2.txt
|
|
104
|
+
agent-browser --session site3 get text body > site3.txt
|
|
105
|
+
|
|
106
|
+
# Cleanup
|
|
107
|
+
agent-browser --session site1 close
|
|
108
|
+
agent-browser --session site2 close
|
|
109
|
+
agent-browser --session site3 close
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### A/B Testing Sessions
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Test different user experiences
|
|
116
|
+
agent-browser --session variant-a open "https://app.com?variant=a"
|
|
117
|
+
agent-browser --session variant-b open "https://app.com?variant=b"
|
|
118
|
+
|
|
119
|
+
# Compare
|
|
120
|
+
agent-browser --session variant-a screenshot /tmp/variant-a.png
|
|
121
|
+
agent-browser --session variant-b screenshot /tmp/variant-b.png
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Default Session
|
|
125
|
+
|
|
126
|
+
When `--session` is omitted, commands use the default session:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# These use the same default session
|
|
130
|
+
agent-browser open https://example.com
|
|
131
|
+
agent-browser snapshot -i
|
|
132
|
+
agent-browser close # Closes default session
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Session Cleanup
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Close specific session
|
|
139
|
+
agent-browser --session auth close
|
|
140
|
+
|
|
141
|
+
# List active sessions
|
|
142
|
+
agent-browser session list
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Best Practices
|
|
146
|
+
|
|
147
|
+
### 1. Name Sessions Semantically
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# GOOD: Clear purpose
|
|
151
|
+
agent-browser --session github-auth open https://github.com
|
|
152
|
+
agent-browser --session docs-scrape open https://docs.example.com
|
|
153
|
+
|
|
154
|
+
# AVOID: Generic names
|
|
155
|
+
agent-browser --session s1 open https://github.com
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 2. Always Clean Up
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Close sessions when done
|
|
162
|
+
agent-browser --session auth close
|
|
163
|
+
agent-browser --session scrape close
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 3. Handle State Files Securely
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Don't commit state files (contain auth tokens!)
|
|
170
|
+
echo "*.auth-state.json" >> .gitignore
|
|
171
|
+
|
|
172
|
+
# Delete after use
|
|
173
|
+
rm /tmp/auth-state.json
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 4. Timeout Long Sessions
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Set timeout for automated scripts
|
|
180
|
+
timeout 60 agent-browser --session long-task get text body
|
|
181
|
+
```
|