remotion-claude-agent-demo 0.1.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.
- package/README.md +160 -0
- package/apps/web/README.md +36 -0
- package/apps/web/env.example +20 -0
- package/apps/web/eslint.config.mjs +18 -0
- package/apps/web/next.config.ts +7 -0
- package/apps/web/package-lock.json +10348 -0
- package/apps/web/package.json +35 -0
- package/apps/web/postcss.config.mjs +7 -0
- package/apps/web/public/file.svg +1 -0
- package/apps/web/public/globe.svg +1 -0
- package/apps/web/public/next.svg +1 -0
- package/apps/web/public/vercel.svg +1 -0
- package/apps/web/public/window.svg +1 -0
- package/apps/web/src/app/.well-known/agent-card.json/route.ts +50 -0
- package/apps/web/src/app/background-tasks/[jobId]/cancel/route.ts +29 -0
- package/apps/web/src/app/events/stream/route.ts +58 -0
- package/apps/web/src/app/favicon.ico +0 -0
- package/apps/web/src/app/globals.css +174 -0
- package/apps/web/src/app/layout.tsx +34 -0
- package/apps/web/src/app/messages/answer/route.ts +57 -0
- package/apps/web/src/app/messages/stream/route.ts +381 -0
- package/apps/web/src/app/page.tsx +358 -0
- package/apps/web/src/app/tasks/[taskId]/cancel/route.ts +24 -0
- package/apps/web/src/app/tasks/[taskId]/route.ts +24 -0
- package/apps/web/src/app/tasks/route.ts +13 -0
- package/apps/web/src/components/chat/agent-blocks.tsx +111 -0
- package/apps/web/src/components/chat/ask-user-question-panel.tsx +172 -0
- package/apps/web/src/components/chat/session-sidebar.tsx +222 -0
- package/apps/web/src/components/chat/subagent-activity-sidebar.tsx +248 -0
- package/apps/web/src/components/chat/tool-blocks.tsx +550 -0
- package/apps/web/src/lib/a2a/activity-store.ts +150 -0
- package/apps/web/src/lib/a2a/client.ts +357 -0
- package/apps/web/src/lib/a2a/sse.ts +19 -0
- package/apps/web/src/lib/a2a/task-store.ts +111 -0
- package/apps/web/src/lib/a2a/types.ts +216 -0
- package/apps/web/src/lib/agent/answer-store.ts +109 -0
- package/apps/web/src/lib/agent/background-delivery.ts +343 -0
- package/apps/web/src/lib/agent/background-tool.ts +78 -0
- package/apps/web/src/lib/agent/background.ts +452 -0
- package/apps/web/src/lib/agent/chat.ts +543 -0
- package/apps/web/src/lib/agent/session-store.ts +26 -0
- package/apps/web/src/lib/chat/types.ts +44 -0
- package/apps/web/src/lib/env.ts +31 -0
- package/apps/web/src/lib/hooks/useA2AChat.ts +863 -0
- package/apps/web/src/lib/state/chat-atoms.ts +52 -0
- package/apps/web/src/lib/workspace.ts +9 -0
- package/apps/web/tsconfig.json +35 -0
- package/bin/remotion-agent.js +451 -0
- package/package.json +34 -0
- package/templates/.claude/CLAUDE.md +95 -0
- package/templates/.claude/README.md +129 -0
- package/templates/.claude/agents/composer-agent.md +188 -0
- package/templates/.claude/agents/crafter.md +181 -0
- package/templates/.claude/agents/creator.md +134 -0
- package/templates/.claude/agents/perceiver.md +92 -0
- package/templates/.claude/settings.json +36 -0
- package/templates/.claude/settings.local.json +39 -0
- package/templates/.claude/skills/agent-browser/SKILL.md +349 -0
- package/templates/.claude/skills/agent-browser/references/authentication.md +188 -0
- package/templates/.claude/skills/agent-browser/references/proxy-support.md +175 -0
- package/templates/.claude/skills/agent-browser/references/session-management.md +181 -0
- package/templates/.claude/skills/agent-browser/references/snapshot-refs.md +186 -0
- package/templates/.claude/skills/agent-browser/references/video-recording.md +162 -0
- package/templates/.claude/skills/agent-browser/templates/authenticated-session.sh +91 -0
- package/templates/.claude/skills/agent-browser/templates/capture-workflow.sh +68 -0
- package/templates/.claude/skills/agent-browser/templates/form-automation.sh +64 -0
- package/templates/.claude/skills/algorithmic-art/LICENSE.txt +202 -0
- package/templates/.claude/skills/algorithmic-art/SKILL.md +405 -0
- package/templates/.claude/skills/algorithmic-art/templates/generator_template.js +223 -0
- package/templates/.claude/skills/algorithmic-art/templates/viewer.html +599 -0
- package/templates/.claude/skills/asset-validator/SKILL.md +376 -0
- package/templates/.claude/skills/audio-video-sync/SKILL.md +219 -0
- package/templates/.claude/skills/bgm-manager/SKILL.md +334 -0
- package/templates/.claude/skills/remotion-best-practices/SKILL.md +45 -0
- package/templates/.claude/skills/remotion-best-practices/rules/3d.md +86 -0
- package/templates/.claude/skills/remotion-best-practices/rules/animations.md +29 -0
- package/templates/.claude/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
- package/templates/.claude/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
- package/templates/.claude/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
- package/templates/.claude/skills/remotion-best-practices/rules/assets.md +78 -0
- package/templates/.claude/skills/remotion-best-practices/rules/audio.md +172 -0
- package/templates/.claude/skills/remotion-best-practices/rules/calculate-metadata.md +104 -0
- package/templates/.claude/skills/remotion-best-practices/rules/can-decode.md +75 -0
- package/templates/.claude/skills/remotion-best-practices/rules/charts.md +58 -0
- package/templates/.claude/skills/remotion-best-practices/rules/compositions.md +141 -0
- package/templates/.claude/skills/remotion-best-practices/rules/display-captions.md +126 -0
- package/templates/.claude/skills/remotion-best-practices/rules/extract-frames.md +229 -0
- package/templates/.claude/skills/remotion-best-practices/rules/fonts.md +152 -0
- package/templates/.claude/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
- package/templates/.claude/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
- package/templates/.claude/skills/remotion-best-practices/rules/get-video-duration.md +58 -0
- package/templates/.claude/skills/remotion-best-practices/rules/gifs.md +138 -0
- package/templates/.claude/skills/remotion-best-practices/rules/images.md +130 -0
- package/templates/.claude/skills/remotion-best-practices/rules/import-srt-captions.md +67 -0
- package/templates/.claude/skills/remotion-best-practices/rules/lottie.md +68 -0
- package/templates/.claude/skills/remotion-best-practices/rules/maps.md +403 -0
- package/templates/.claude/skills/remotion-best-practices/rules/measuring-dom-nodes.md +35 -0
- package/templates/.claude/skills/remotion-best-practices/rules/measuring-text.md +143 -0
- package/templates/.claude/skills/remotion-best-practices/rules/parameters.md +98 -0
- package/templates/.claude/skills/remotion-best-practices/rules/sequencing.md +118 -0
- package/templates/.claude/skills/remotion-best-practices/rules/tailwind.md +11 -0
- package/templates/.claude/skills/remotion-best-practices/rules/text-animations.md +20 -0
- package/templates/.claude/skills/remotion-best-practices/rules/timing.md +179 -0
- package/templates/.claude/skills/remotion-best-practices/rules/transcribe-captions.md +19 -0
- package/templates/.claude/skills/remotion-best-practices/rules/transitions.md +122 -0
- package/templates/.claude/skills/remotion-best-practices/rules/trimming.md +53 -0
- package/templates/.claude/skills/remotion-best-practices/rules/videos.md +171 -0
- package/templates/.claude/skills/remotion-components/SKILL.md +453 -0
- package/templates/.claude/skills/render-config/SKILL.md +290 -0
- package/templates/.claude/skills/script-writer/SKILL.md +59 -0
- package/templates/.claude/skills/style-director/script-writer/SKILL.md +82 -0
- package/templates/.claude/skills/style-director/style-director/SKILL.md +287 -0
- package/templates/.claude/skills/style-director/style-director/references/audience-and-scenarios.md +43 -0
- package/templates/.claude/skills/style-director/style-director/references/interaction-innovation.md +26 -0
- package/templates/.claude/skills/style-director/style-director/references/motion-grammar.md +66 -0
- package/templates/.claude/skills/style-director/style-director/references/quality-checklist.md +29 -0
- package/templates/.claude/skills/style-director/style-director/references/scene-recipes.md +38 -0
- package/templates/.claude/skills/style-director/style-director/references/visual-style-system.md +148 -0
- package/templates/.claude/skills/subtitle-composer/SKILL.md +304 -0
- package/templates/.claude/skills/subtitle-processor/SKILL.md +308 -0
- package/templates/.claude/skills/timeline-generator/SKILL.md +253 -0
- package/templates/.claude/skills/video-preflight-check/SKILL.md +353 -0
- package/templates/.claude/skills/voice-synthesizer/SKILL.md +296 -0
- package/templates/.claude/skills/voice-synthesizer/scripts/synthesize_voice.py +315 -0
- package/templates/.claude/skills/voice-synthesizer/scripts/tts_cli.py +142 -0
- package/templates/.claude/skills/web-design-guidelines/SKILL.md +36 -0
- package/templates/.claude/skills/youtube-downloader/SKILL.md +99 -0
- package/templates/.claude/skills/youtube-downloader/scripts/download_video.py +145 -0
|
@@ -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
|
+
```
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Snapshot + Refs Workflow
|
|
2
|
+
|
|
3
|
+
The core innovation of agent-browser: compact element references that reduce context usage dramatically for AI agents.
|
|
4
|
+
|
|
5
|
+
## How It Works
|
|
6
|
+
|
|
7
|
+
### The Problem
|
|
8
|
+
Traditional browser automation sends full DOM to AI agents:
|
|
9
|
+
```
|
|
10
|
+
Full DOM/HTML sent → AI parses → Generates CSS selector → Executes action
|
|
11
|
+
~3000-5000 tokens per interaction
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### The Solution
|
|
15
|
+
agent-browser uses compact snapshots with refs:
|
|
16
|
+
```
|
|
17
|
+
Compact snapshot → @refs assigned → Direct ref interaction
|
|
18
|
+
~200-400 tokens per interaction
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## The Snapshot Command
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Basic snapshot (shows page structure)
|
|
25
|
+
agent-browser snapshot
|
|
26
|
+
|
|
27
|
+
# Interactive snapshot (-i flag) - RECOMMENDED
|
|
28
|
+
agent-browser snapshot -i
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Snapshot Output Format
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Page: Example Site - Home
|
|
35
|
+
URL: https://example.com
|
|
36
|
+
|
|
37
|
+
@e1 [header]
|
|
38
|
+
@e2 [nav]
|
|
39
|
+
@e3 [a] "Home"
|
|
40
|
+
@e4 [a] "Products"
|
|
41
|
+
@e5 [a] "About"
|
|
42
|
+
@e6 [button] "Sign In"
|
|
43
|
+
|
|
44
|
+
@e7 [main]
|
|
45
|
+
@e8 [h1] "Welcome"
|
|
46
|
+
@e9 [form]
|
|
47
|
+
@e10 [input type="email"] placeholder="Email"
|
|
48
|
+
@e11 [input type="password"] placeholder="Password"
|
|
49
|
+
@e12 [button type="submit"] "Log In"
|
|
50
|
+
|
|
51
|
+
@e13 [footer]
|
|
52
|
+
@e14 [a] "Privacy Policy"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Using Refs
|
|
56
|
+
|
|
57
|
+
Once you have refs, interact directly:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Click the "Sign In" button
|
|
61
|
+
agent-browser click @e6
|
|
62
|
+
|
|
63
|
+
# Fill email input
|
|
64
|
+
agent-browser fill @e10 "user@example.com"
|
|
65
|
+
|
|
66
|
+
# Fill password
|
|
67
|
+
agent-browser fill @e11 "password123"
|
|
68
|
+
|
|
69
|
+
# Submit the form
|
|
70
|
+
agent-browser click @e12
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Ref Lifecycle
|
|
74
|
+
|
|
75
|
+
**IMPORTANT**: Refs are invalidated when the page changes!
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Get initial snapshot
|
|
79
|
+
agent-browser snapshot -i
|
|
80
|
+
# @e1 [button] "Next"
|
|
81
|
+
|
|
82
|
+
# Click triggers page change
|
|
83
|
+
agent-browser click @e1
|
|
84
|
+
|
|
85
|
+
# MUST re-snapshot to get new refs!
|
|
86
|
+
agent-browser snapshot -i
|
|
87
|
+
# @e1 [h1] "Page 2" ← Different element now!
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Best Practices
|
|
91
|
+
|
|
92
|
+
### 1. Always Snapshot Before Interacting
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# CORRECT
|
|
96
|
+
agent-browser open https://example.com
|
|
97
|
+
agent-browser snapshot -i # Get refs first
|
|
98
|
+
agent-browser click @e1 # Use ref
|
|
99
|
+
|
|
100
|
+
# WRONG
|
|
101
|
+
agent-browser open https://example.com
|
|
102
|
+
agent-browser click @e1 # Ref doesn't exist yet!
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 2. Re-Snapshot After Navigation
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
agent-browser click @e5 # Navigates to new page
|
|
109
|
+
agent-browser snapshot -i # Get new refs
|
|
110
|
+
agent-browser click @e1 # Use new refs
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 3. Re-Snapshot After Dynamic Changes
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
agent-browser click @e1 # Opens dropdown
|
|
117
|
+
agent-browser snapshot -i # See dropdown items
|
|
118
|
+
agent-browser click @e7 # Select item
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 4. Snapshot Specific Regions
|
|
122
|
+
|
|
123
|
+
For complex pages, snapshot specific areas:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Snapshot just the form
|
|
127
|
+
agent-browser snapshot @e9
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Ref Notation Details
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
@e1 [tag type="value"] "text content" placeholder="hint"
|
|
134
|
+
│ │ │ │ │
|
|
135
|
+
│ │ │ │ └─ Additional attributes
|
|
136
|
+
│ │ │ └─ Visible text
|
|
137
|
+
│ │ └─ Key attributes shown
|
|
138
|
+
│ └─ HTML tag name
|
|
139
|
+
└─ Unique ref ID
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Common Patterns
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
@e1 [button] "Submit" # Button with text
|
|
146
|
+
@e2 [input type="email"] # Email input
|
|
147
|
+
@e3 [input type="password"] # Password input
|
|
148
|
+
@e4 [a href="/page"] "Link Text" # Anchor link
|
|
149
|
+
@e5 [select] # Dropdown
|
|
150
|
+
@e6 [textarea] placeholder="Message" # Text area
|
|
151
|
+
@e7 [div class="modal"] # Container (when relevant)
|
|
152
|
+
@e8 [img alt="Logo"] # Image
|
|
153
|
+
@e9 [checkbox] checked # Checked checkbox
|
|
154
|
+
@e10 [radio] selected # Selected radio
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Troubleshooting
|
|
158
|
+
|
|
159
|
+
### "Ref not found" Error
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Ref may have changed - re-snapshot
|
|
163
|
+
agent-browser snapshot -i
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Element Not Visible in Snapshot
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Scroll to reveal element
|
|
170
|
+
agent-browser scroll --bottom
|
|
171
|
+
agent-browser snapshot -i
|
|
172
|
+
|
|
173
|
+
# Or wait for dynamic content
|
|
174
|
+
agent-browser wait 1000
|
|
175
|
+
agent-browser snapshot -i
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Too Many Elements
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Snapshot specific container
|
|
182
|
+
agent-browser snapshot @e5
|
|
183
|
+
|
|
184
|
+
# Or use get text for content-only extraction
|
|
185
|
+
agent-browser get text @e5
|
|
186
|
+
```
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Video Recording
|
|
2
|
+
|
|
3
|
+
Capture browser automation sessions as video for debugging, documentation, or verification.
|
|
4
|
+
|
|
5
|
+
## Basic Recording
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Start recording
|
|
9
|
+
agent-browser record start ./demo.webm
|
|
10
|
+
|
|
11
|
+
# Perform actions
|
|
12
|
+
agent-browser open https://example.com
|
|
13
|
+
agent-browser snapshot -i
|
|
14
|
+
agent-browser click @e1
|
|
15
|
+
agent-browser fill @e2 "test input"
|
|
16
|
+
|
|
17
|
+
# Stop and save
|
|
18
|
+
agent-browser record stop
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Recording Commands
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Start recording to file
|
|
25
|
+
agent-browser record start ./output.webm
|
|
26
|
+
|
|
27
|
+
# Stop current recording
|
|
28
|
+
agent-browser record stop
|
|
29
|
+
|
|
30
|
+
# Restart with new file (stops current + starts new)
|
|
31
|
+
agent-browser record restart ./take2.webm
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Use Cases
|
|
35
|
+
|
|
36
|
+
### Debugging Failed Automation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
#!/bin/bash
|
|
40
|
+
# Record automation for debugging
|
|
41
|
+
|
|
42
|
+
agent-browser record start ./debug-$(date +%Y%m%d-%H%M%S).webm
|
|
43
|
+
|
|
44
|
+
# Run your automation
|
|
45
|
+
agent-browser open https://app.example.com
|
|
46
|
+
agent-browser snapshot -i
|
|
47
|
+
agent-browser click @e1 || {
|
|
48
|
+
echo "Click failed - check recording"
|
|
49
|
+
agent-browser record stop
|
|
50
|
+
exit 1
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
agent-browser record stop
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Documentation Generation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
#!/bin/bash
|
|
60
|
+
# Record workflow for documentation
|
|
61
|
+
|
|
62
|
+
agent-browser record start ./docs/how-to-login.webm
|
|
63
|
+
|
|
64
|
+
agent-browser open https://app.example.com/login
|
|
65
|
+
agent-browser wait 1000 # Pause for visibility
|
|
66
|
+
|
|
67
|
+
agent-browser snapshot -i
|
|
68
|
+
agent-browser fill @e1 "demo@example.com"
|
|
69
|
+
agent-browser wait 500
|
|
70
|
+
|
|
71
|
+
agent-browser fill @e2 "password"
|
|
72
|
+
agent-browser wait 500
|
|
73
|
+
|
|
74
|
+
agent-browser click @e3
|
|
75
|
+
agent-browser wait --load networkidle
|
|
76
|
+
agent-browser wait 1000 # Show result
|
|
77
|
+
|
|
78
|
+
agent-browser record stop
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### CI/CD Test Evidence
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
#!/bin/bash
|
|
85
|
+
# Record E2E test runs for CI artifacts
|
|
86
|
+
|
|
87
|
+
TEST_NAME="${1:-e2e-test}"
|
|
88
|
+
RECORDING_DIR="./test-recordings"
|
|
89
|
+
mkdir -p "$RECORDING_DIR"
|
|
90
|
+
|
|
91
|
+
agent-browser record start "$RECORDING_DIR/$TEST_NAME-$(date +%s).webm"
|
|
92
|
+
|
|
93
|
+
# Run test
|
|
94
|
+
if run_e2e_test; then
|
|
95
|
+
echo "Test passed"
|
|
96
|
+
else
|
|
97
|
+
echo "Test failed - recording saved"
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
agent-browser record stop
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Best Practices
|
|
104
|
+
|
|
105
|
+
### 1. Add Pauses for Clarity
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Slow down for human viewing
|
|
109
|
+
agent-browser click @e1
|
|
110
|
+
agent-browser wait 500 # Let viewer see result
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 2. Use Descriptive Filenames
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Include context in filename
|
|
117
|
+
agent-browser record start ./recordings/login-flow-2024-01-15.webm
|
|
118
|
+
agent-browser record start ./recordings/checkout-test-run-42.webm
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 3. Handle Recording in Error Cases
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
#!/bin/bash
|
|
125
|
+
set -e
|
|
126
|
+
|
|
127
|
+
cleanup() {
|
|
128
|
+
agent-browser record stop 2>/dev/null || true
|
|
129
|
+
agent-browser close 2>/dev/null || true
|
|
130
|
+
}
|
|
131
|
+
trap cleanup EXIT
|
|
132
|
+
|
|
133
|
+
agent-browser record start ./automation.webm
|
|
134
|
+
# ... automation steps ...
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 4. Combine with Screenshots
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Record video AND capture key frames
|
|
141
|
+
agent-browser record start ./flow.webm
|
|
142
|
+
|
|
143
|
+
agent-browser open https://example.com
|
|
144
|
+
agent-browser screenshot ./screenshots/step1-homepage.png
|
|
145
|
+
|
|
146
|
+
agent-browser click @e1
|
|
147
|
+
agent-browser screenshot ./screenshots/step2-after-click.png
|
|
148
|
+
|
|
149
|
+
agent-browser record stop
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Output Format
|
|
153
|
+
|
|
154
|
+
- Default format: WebM (VP8/VP9 codec)
|
|
155
|
+
- Compatible with all modern browsers and video players
|
|
156
|
+
- Compressed but high quality
|
|
157
|
+
|
|
158
|
+
## Limitations
|
|
159
|
+
|
|
160
|
+
- Recording adds slight overhead to automation
|
|
161
|
+
- Large recordings can consume significant disk space
|
|
162
|
+
- Some headless environments may have codec limitations
|