Skip to content

Add action logging for script generation #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link

Action Logging for Script Generation

This PR implements a mechanism to log browser actions in browser-use and convert them to either BrowserQL or BaaS V2 scripts.

Features

  • Action Logging: Captures successful browser actions in the Agent.multi_act() method
  • Script Generation: Converts logged actions to BrowserQL or BaaS V2 scripts
  • Multiple Format Support:
    • BrowserQL (GraphQL mutations)
    • BaaS V2 JavaScript (Puppeteer)
    • BaaS V2 Python (Playwright)
  • Selective Logging: Only successful actions are included in the generated scripts
  • Comprehensive Selector Information: Captures XPath, tag name, attributes, and other selector details

Implementation Details

  1. Added action_log to Agent class to track successful actions
  2. Created ScriptGenerator class to convert action logs to scripts
  3. Added methods to Agent class to expose script generation functionality:
    • get_action_log()
    • clear_action_log()
    • set_script_format()
    • get_script()
  4. Added unit tests to verify script generation works correctly

Usage Example

# Get the action log
action_log = agent.get_action_log()

# Generate BrowserQL script
browserql_script = agent.get_script("browserql")

# Generate BaaS V2 script (JavaScript)
baas_js_script = agent.get_script("baas_v2", language="javascript")

# Generate BaaS V2 script (Python)
baas_py_script = agent.get_script("baas_v2", language="python")

Link to Devin run

https://app.devin.ai/sessions/f82c182e982f410c8a6fd08f5ad2f0ae

Requested by

Sean Yang (sean@browserless.io)

devin-ai-integration bot and others added 2 commits May 1, 2025 18:31
This commit implements:
1. Action logging in Agent.multi_act() to track successful browser actions
2. ScriptGenerator class to convert action logs to BrowserQL or BaaS V2 scripts
3. Methods in Agent class to expose script generation functionality
4. Unit tests to verify script generation works correctly

The implementation only logs successful actions and supports both BrowserQL and
BaaS V2 formats (JavaScript and Python).

Co-Authored-By: Sean Yang <sean@browserless.io>
Co-Authored-By: Sean Yang <sean@browserless.io>
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: Sean Yang <sean@browserless.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants