ai-agent-browser 0.2.2__tar.gz → 0.2.4__tar.gz

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.
Files changed (29) hide show
  1. {ai_agent_browser-0.2.2/src/ai_agent_browser.egg-info → ai_agent_browser-0.2.4}/PKG-INFO +19 -11
  2. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/README.md +18 -10
  3. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/pyproject.toml +7 -1
  4. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/cinematic/__init__.py +11 -5
  5. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/cinematic/annotations.py +22 -10
  6. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/cinematic/camera.py +40 -10
  7. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/cinematic/postproduction.py +384 -104
  8. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/cinematic/scripts.py +25 -28
  9. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4/src/ai_agent_browser.egg-info}/PKG-INFO +19 -11
  10. ai_agent_browser-0.2.4/tests/test_mcp.py +1345 -0
  11. ai_agent_browser-0.2.2/tests/test_mcp.py +0 -1472
  12. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/LICENSE +0 -0
  13. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/setup.cfg +0 -0
  14. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/__init__.py +0 -0
  15. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/cinematic/polish.py +0 -0
  16. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/cinematic/recording.py +0 -0
  17. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/cinematic/tts.py +0 -0
  18. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/driver.py +0 -0
  19. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/interactive.py +0 -0
  20. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/main.py +0 -0
  21. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/mcp.py +0 -0
  22. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/agent_browser/utils.py +0 -0
  23. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/ai_agent_browser.egg-info/SOURCES.txt +0 -0
  24. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/ai_agent_browser.egg-info/dependency_links.txt +0 -0
  25. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/ai_agent_browser.egg-info/entry_points.txt +0 -0
  26. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/ai_agent_browser.egg-info/requires.txt +0 -0
  27. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/src/ai_agent_browser.egg-info/top_level.txt +0 -0
  28. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/tests/test_driver.py +0 -0
  29. {ai_agent_browser-0.2.2 → ai_agent_browser-0.2.4}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-agent-browser
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: A robust browser automation tool for AI agents - control browsers via CLI or IPC
5
5
  Author: Agent Browser Contributors
6
6
  License: GPL-3.0-only
@@ -318,7 +318,7 @@ pip install ai-agent-browser[video]
318
318
  | **Annotations** | `annotate`, `clear_annotations` | Floating text callouts |
319
319
  | **Spotlight Effects** | `spotlight`, `clear_spotlight` | Ring highlights, spotlight dimming, focus effects |
320
320
  | **Camera** | `camera_zoom`, `camera_pan`, `camera_reset` | Ken Burns-style zoom/pan effects |
321
- | **Post-Production** | `merge_audio_video`, `add_background_music`, `add_text_overlay`, `concatenate_videos` | Audio mixing, titles, transitions |
321
+ | **Post-Production** | `convert_to_mp4`, `merge_audio_video`, `add_background_music`, `add_text_overlay`, `concatenate_videos` | Format conversion, audio mixing, titles, transitions |
322
322
  | **Stock Music** | `list_stock_music`, `download_stock_music` | Royalty-free music from Jamendo |
323
323
  | **Polish** | `smooth_scroll`, `type_human`, `set_presentation_mode` | Human-like interactions |
324
324
 
@@ -390,11 +390,15 @@ stop_result = stop_recording()
390
390
 
391
391
  raw_video = stop_result["data"]["path"]
392
392
 
393
- # Merge voiceover (starts at 1 second)
393
+ # Convert WebM to MP4 (recommended first step)
394
+ converted = convert_to_mp4(video=raw_video, quality="fast")
395
+
396
+ # Merge voiceover (starts at 1 second, with volume control)
394
397
  merge_audio_video(
395
- video=raw_video,
396
- audio_tracks=[{"path": vo["data"]["path"], "start_ms": 1000}],
397
- output="videos/with_voice.mp4"
398
+ video=converted["data"]["path"],
399
+ audio_tracks=[{"path": vo["data"]["path"], "start_ms": 1000, "volume": 1.2}],
400
+ output="videos/with_voice.mp4",
401
+ fast=True # Skip video re-encoding (much faster)
398
402
  )
399
403
 
400
404
  # Add background music (15% volume, auto-fades)
@@ -494,11 +498,15 @@ The cursor uses cubic-bezier easing for natural motion, not robotic linear movem
494
498
  ### Best Practices
495
499
 
496
500
  1. **Generate voiceover first** - Audio duration drives video pacing
497
- 2. **Use presentation mode** - Hides scrollbars for cleaner visuals
498
- 3. **Wait after effects** - Let animations complete before next action
499
- 4. **Layer effects** - Combine spotlight + annotation for maximum impact
500
- 5. **Keep music subtle** - 10-15% volume, let voice dominate
501
- 6. **Add titles in post** - Text overlays are more flexible than annotations
501
+ 2. **Convert WebM to MP4** - Use `convert_to_mp4()` after recording for faster processing
502
+ 3. **Use fast mode** - `merge_audio_video(fast=True)` skips video re-encoding (default)
503
+ 4. **Control per-track volume** - `audio_tracks=[{path, start_ms, volume: 1.2}]` (0.0-2.0)
504
+ 5. **Use presentation mode** - Hides scrollbars for cleaner visuals
505
+ 6. **Wait after effects** - Let animations complete before next action
506
+ 7. **Layer effects** - Combine spotlight + annotation for maximum impact
507
+ 8. **Keep music subtle** - 10-15% volume, let voice dominate
508
+ 9. **Silent videos work** - `add_background_music()` handles videos without audio
509
+ 10. **Add titles in post** - Text overlays are more flexible than annotations
502
510
 
503
511
  See `examples/cinematic_full_demo.py` for a complete working example.
504
512
 
@@ -278,7 +278,7 @@ pip install ai-agent-browser[video]
278
278
  | **Annotations** | `annotate`, `clear_annotations` | Floating text callouts |
279
279
  | **Spotlight Effects** | `spotlight`, `clear_spotlight` | Ring highlights, spotlight dimming, focus effects |
280
280
  | **Camera** | `camera_zoom`, `camera_pan`, `camera_reset` | Ken Burns-style zoom/pan effects |
281
- | **Post-Production** | `merge_audio_video`, `add_background_music`, `add_text_overlay`, `concatenate_videos` | Audio mixing, titles, transitions |
281
+ | **Post-Production** | `convert_to_mp4`, `merge_audio_video`, `add_background_music`, `add_text_overlay`, `concatenate_videos` | Format conversion, audio mixing, titles, transitions |
282
282
  | **Stock Music** | `list_stock_music`, `download_stock_music` | Royalty-free music from Jamendo |
283
283
  | **Polish** | `smooth_scroll`, `type_human`, `set_presentation_mode` | Human-like interactions |
284
284
 
@@ -350,11 +350,15 @@ stop_result = stop_recording()
350
350
 
351
351
  raw_video = stop_result["data"]["path"]
352
352
 
353
- # Merge voiceover (starts at 1 second)
353
+ # Convert WebM to MP4 (recommended first step)
354
+ converted = convert_to_mp4(video=raw_video, quality="fast")
355
+
356
+ # Merge voiceover (starts at 1 second, with volume control)
354
357
  merge_audio_video(
355
- video=raw_video,
356
- audio_tracks=[{"path": vo["data"]["path"], "start_ms": 1000}],
357
- output="videos/with_voice.mp4"
358
+ video=converted["data"]["path"],
359
+ audio_tracks=[{"path": vo["data"]["path"], "start_ms": 1000, "volume": 1.2}],
360
+ output="videos/with_voice.mp4",
361
+ fast=True # Skip video re-encoding (much faster)
358
362
  )
359
363
 
360
364
  # Add background music (15% volume, auto-fades)
@@ -454,11 +458,15 @@ The cursor uses cubic-bezier easing for natural motion, not robotic linear movem
454
458
  ### Best Practices
455
459
 
456
460
  1. **Generate voiceover first** - Audio duration drives video pacing
457
- 2. **Use presentation mode** - Hides scrollbars for cleaner visuals
458
- 3. **Wait after effects** - Let animations complete before next action
459
- 4. **Layer effects** - Combine spotlight + annotation for maximum impact
460
- 5. **Keep music subtle** - 10-15% volume, let voice dominate
461
- 6. **Add titles in post** - Text overlays are more flexible than annotations
461
+ 2. **Convert WebM to MP4** - Use `convert_to_mp4()` after recording for faster processing
462
+ 3. **Use fast mode** - `merge_audio_video(fast=True)` skips video re-encoding (default)
463
+ 4. **Control per-track volume** - `audio_tracks=[{path, start_ms, volume: 1.2}]` (0.0-2.0)
464
+ 5. **Use presentation mode** - Hides scrollbars for cleaner visuals
465
+ 6. **Wait after effects** - Let animations complete before next action
466
+ 7. **Layer effects** - Combine spotlight + annotation for maximum impact
467
+ 8. **Keep music subtle** - 10-15% volume, let voice dominate
468
+ 9. **Silent videos work** - `add_background_music()` handles videos without audio
469
+ 10. **Add titles in post** - Text overlays are more flexible than annotations
462
470
 
463
471
  See `examples/cinematic_full_demo.py` for a complete working example.
464
472
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ai-agent-browser"
7
- version = "0.2.2"
7
+ version = "0.2.4"
8
8
  description = "A robust browser automation tool for AI agents - control browsers via CLI or IPC"
9
9
  readme = "README.md"
10
10
  license = {text = "GPL-3.0-only"}
@@ -91,3 +91,9 @@ where = ["src"]
91
91
  testpaths = ["tests"]
92
92
  python_files = ["test_*.py"]
93
93
  python_functions = ["test_*"]
94
+ asyncio_mode = "auto"
95
+ asyncio_default_fixture_loop_scope = "session"
96
+ asyncio_default_test_loop_scope = "session"
97
+ markers = [
98
+ "no_browser: marks tests that don't need a browser (fast unit tests)",
99
+ ]
@@ -75,15 +75,20 @@ class CinematicMixin(TTSMixin, RecordingMixin, AnnotationMixin, CameraMixin, Pos
75
75
  10. stop_recording() - End capture, get video path
76
76
 
77
77
  ### Phase 3: POST-PRODUCTION
78
- 1. merge_audio_video() - Add voiceover at specific timestamps
79
- 2. add_background_music() - Layer music (15% volume, voice at 130%)
80
- 3. add_text_overlay() - Add titles, captions with fade effects
81
- 4. concatenate_videos() - Join multiple scenes with transitions
78
+ 1. convert_to_mp4() - Convert WebM to MP4 (recommended first step)
79
+ 2. merge_audio_video() - Add voiceover at specific timestamps (fast=True default)
80
+ 3. add_background_music() - Layer music (15% volume, voice at 130%)
81
+ 4. add_text_overlay() - Add titles, captions with fade effects
82
+ 5. concatenate_videos() - Join multiple scenes with transitions
82
83
 
83
84
  ## KEY BEST PRACTICES
84
85
  - Generate voiceover FIRST - audio duration determines video pacing
86
+ - Convert WebM to MP4 after recording for faster processing
87
+ - Use merge_audio_video(fast=True) to skip video re-encoding (default)
88
+ - Control per-track volume: audio_tracks=[{path, start_ms, volume: 1.2}]
85
89
  - Always wait() after effects - let animations complete
86
90
  - Keep music at 10-15% volume - voice should dominate
91
+ - Silent videos work - add_background_music() handles them gracefully
87
92
  - Use spotlight(style="focus") for maximum visual impact
88
93
  - Clear effects before switching to new ones
89
94
  - Use presentation_mode for cleaner visuals
@@ -95,7 +100,7 @@ class CinematicMixin(TTSMixin, RecordingMixin, AnnotationMixin, CameraMixin, Pos
95
100
  Annotations: annotate, clear_annotations
96
101
  Spotlight: spotlight, clear_spotlight (ring/spotlight/focus effects)
97
102
  Camera: camera_zoom, camera_pan, camera_reset
98
- Post-Production: merge_audio_video, add_background_music, add_text_overlay
103
+ Post-Production: convert_to_mp4, merge_audio_video, add_background_music, add_text_overlay
99
104
  Transitions: concatenate_videos (fade/wipe/slide/dissolve)
100
105
  Stock Music: list_stock_music, download_stock_music
101
106
  Polish: smooth_scroll, type_human, set_presentation_mode, freeze_time
@@ -184,6 +189,7 @@ class CinematicMixin(TTSMixin, RecordingMixin, AnnotationMixin, CameraMixin, Pos
184
189
 
185
190
  # Phase 4: Post-Production
186
191
  server.tool()(self.check_environment)
192
+ server.tool()(self.convert_to_mp4)
187
193
  server.tool()(self.merge_audio_video)
188
194
  server.tool()(self.add_background_music)
189
195
  server.tool()(self.get_video_duration)
@@ -191,21 +191,38 @@ class AnnotationMixin:
191
191
  async with self._lock:
192
192
  page = await self._ensure_page()
193
193
 
194
+ # Use Playwright's locator to find element and get bounding box
195
+ # This supports all Playwright selectors including :has-text()
196
+ try:
197
+ locator = page.locator(selector).first
198
+ box = await locator.bounding_box(timeout=5000)
199
+ except Exception:
200
+ box = None
201
+
202
+ if not box:
203
+ return {
204
+ "success": False,
205
+ "message": f"Element not found: {selector}",
206
+ }
207
+
194
208
  # Inject highlight script
195
209
  await page.evaluate(HIGHLIGHT_SCRIPT)
196
210
 
197
- # Apply the requested effect
211
+ # Pass bounding box to JavaScript (avoids selector escaping issues)
212
+ rect_json = f"{{x: {box['x']}, y: {box['y']}, width: {box['width']}, height: {box['height']}}}"
213
+
214
+ # Apply the requested effect using rect-based functions
198
215
  if style == "ring":
199
216
  success = await page.evaluate(
200
- f"window.__agentHighlight.ring('{selector}', '{color}', {pulse_ms})"
217
+ f"window.__agentHighlight.ringWithRect({rect_json}, '{color}', {pulse_ms})"
201
218
  )
202
219
  elif style == "spotlight":
203
220
  success = await page.evaluate(
204
- f"window.__agentHighlight.spotlight('{selector}', {dim_opacity})"
221
+ f"window.__agentHighlight.spotlightWithRect({rect_json}, {dim_opacity})"
205
222
  )
206
223
  elif style == "focus":
207
224
  success = await page.evaluate(
208
- f"window.__agentHighlight.focus('{selector}', '{color}', {dim_opacity}, {pulse_ms})"
225
+ f"window.__agentHighlight.focusWithRect({rect_json}, '{color}', {dim_opacity}, {pulse_ms})"
209
226
  )
210
227
  else:
211
228
  return {
@@ -213,12 +230,6 @@ class AnnotationMixin:
213
230
  "message": f"Unknown highlight style: {style}. Use 'ring', 'spotlight', or 'focus'.",
214
231
  }
215
232
 
216
- if not success:
217
- return {
218
- "success": False,
219
- "message": f"Element not found: {selector}",
220
- }
221
-
222
233
  return {
223
234
  "success": True,
224
235
  "message": f"Applied {style} highlight to {selector}",
@@ -226,6 +237,7 @@ class AnnotationMixin:
226
237
  "style": style,
227
238
  "selector": selector,
228
239
  "color": color,
240
+ "bounding_box": box,
229
241
  },
230
242
  }
231
243
 
@@ -64,15 +64,29 @@ class CameraMixin:
64
64
  async with self._lock:
65
65
  page = await self._ensure_page()
66
66
 
67
+ # Use Playwright's locator to find element and get bounding box
68
+ # This supports all Playwright selectors including :has-text()
69
+ try:
70
+ locator = page.locator(selector).first
71
+ box = await locator.bounding_box(timeout=5000)
72
+ except Exception:
73
+ box = None
74
+
75
+ if not box:
76
+ return {
77
+ "success": False,
78
+ "message": f"Element not found: {selector}",
79
+ }
80
+
67
81
  # Inject camera script
68
82
  await page.evaluate(CAMERA_SCRIPT)
69
83
 
70
- # Escape selector for JavaScript
71
- escaped_selector = selector.replace("\\", "\\\\").replace("'", "\\'")
84
+ # Pass bounding box to JavaScript (avoids selector escaping issues)
85
+ rect_json = f"{{x: {box['x']}, y: {box['y']}, width: {box['width']}, height: {box['height']}}}"
72
86
 
73
- # Execute zoom
87
+ # Execute zoom with rect
74
88
  success = await page.evaluate(
75
- f"window.__agentCamera.zoom('{escaped_selector}', {level}, {duration_ms})"
89
+ f"window.__agentCamera.zoomWithRect({rect_json}, {level}, {duration_ms})"
76
90
  )
77
91
 
78
92
  if success:
@@ -85,12 +99,13 @@ class CameraMixin:
85
99
  "level": level,
86
100
  "target": selector,
87
101
  "duration_ms": duration_ms,
102
+ "bounding_box": box,
88
103
  },
89
104
  }
90
105
  else:
91
106
  return {
92
107
  "success": False,
93
- "message": f"Element not found: {selector}",
108
+ "message": f"Zoom failed for: {selector}",
94
109
  }
95
110
 
96
111
  except Exception as exc: # pylint: disable=broad-except
@@ -121,15 +136,29 @@ class CameraMixin:
121
136
  async with self._lock:
122
137
  page = await self._ensure_page()
123
138
 
139
+ # Use Playwright's locator to find element and get bounding box
140
+ # This supports all Playwright selectors including :has-text()
141
+ try:
142
+ locator = page.locator(selector).first
143
+ box = await locator.bounding_box(timeout=5000)
144
+ except Exception:
145
+ box = None
146
+
147
+ if not box:
148
+ return {
149
+ "success": False,
150
+ "message": f"Element not found: {selector}",
151
+ }
152
+
124
153
  # Inject camera script
125
154
  await page.evaluate(CAMERA_SCRIPT)
126
155
 
127
- # Escape selector for JavaScript
128
- escaped_selector = selector.replace("\\", "\\\\").replace("'", "\\'")
156
+ # Pass bounding box to JavaScript (avoids selector escaping issues)
157
+ rect_json = f"{{x: {box['x']}, y: {box['y']}, width: {box['width']}, height: {box['height']}}}"
129
158
 
130
- # Execute pan
159
+ # Execute pan with rect
131
160
  success = await page.evaluate(
132
- f"window.__agentCamera.pan('{escaped_selector}', {duration_ms})"
161
+ f"window.__agentCamera.panWithRect({rect_json}, {duration_ms})"
133
162
  )
134
163
 
135
164
  if success:
@@ -141,12 +170,13 @@ class CameraMixin:
141
170
  "data": {
142
171
  "target": selector,
143
172
  "duration_ms": duration_ms,
173
+ "bounding_box": box,
144
174
  },
145
175
  }
146
176
  else:
147
177
  return {
148
178
  "success": False,
149
- "message": f"Element not found: {selector}",
179
+ "message": f"Pan failed for: {selector}",
150
180
  }
151
181
 
152
182
  except Exception as exc: # pylint: disable=broad-except