Commit Graph

52 Commits

Author SHA1 Message Date
Gregor Žunič 4693997efc feat(agent): add native raw CDP code mode 2026-07-10 00:47:32 -07:00
Saurav Panda 73d64d7bb5 remove read long content action 2026-03-12 12:44:10 -07:00
Saurav Panda 2552caeca4 fixed code styling issue 2026-02-25 12:26:10 -08:00
Saurav Panda 8270346ccf improved csv file generation 2026-02-25 11:45:05 -08:00
Laith Weinberger 799e714c2b mitigate injection; don't drop overbudget pages
- restricted read_long_content file access to only paths in available_file_paths or browser_session.download_files to mitigate injection
- made PDF page selection truncate pages that exceed char budget instead of dropping them entirely
- fixed truncation hint in file_system.py to reference read_long_context instead of search_page
2026-02-03 17:42:02 -05:00
Laith Weinberger 38fb5b12df Merge remote-tracking branch 'origin/main' into feat/smart-pdf-reading 2026-02-03 14:15:49 -05:00
Laith Weinberger bce2951178 fixed bug where small remaining char budgets caused neg slice indices 2026-01-31 19:10:45 -05:00
Laith Weinberger 7a1b76a5f0 bug fixes + lint 2026-01-31 19:03:23 -05:00
Laith Weinberger 556ecd93ab search_content and read_long_content actions for long webpages and files
Made read_file smarter for PDFs - instead of just reading the first 20 pgs, it reads up to 60k chars and uses IDF scoring to prioritize pgs w unique content
2026-01-31 18:50:44 -05:00
Saurav Panda a7c2144cd1 added normalize the filename 2026-01-31 11:50:54 -08:00
Saurav Panda 39291298f8 lint fix 2026-01-31 11:21:17 -08:00
Saurav Panda a4380060b9 improved filename sanitization 2026-01-31 11:14:11 -08:00
laithrw 372bf822c2 Merge branch 'main' into fix-write-file-issues 2026-01-30 21:51:27 -05:00
Magnus Müller e072135590 fix: add file validation for uploads and dynamic text extension list
- Add 0-byte file check in upload_file handler to catch empty files early
  with a clear error message instead of silently passing them to websites
- Add 0-byte file check in CDP upload watchdog before setFileInputFiles
  to prevent uploading empty files that cause cascading failures
- Replace hardcoded text extension list in read_file_structured() with
  dynamic derivation from _file_types, so new text-based file types
  are automatically supported for external file reading

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 00:25:36 -08:00
Magnus Müller 5e25d92bef style: fix linter issues from CI
- Fix f-string quote style (double→single) in _build_filename_error_message
- Remove unused XmlFile import from test file
- Add missing blank lines before DEFAULT_FILE_SYSTEM_PATH

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 00:16:53 -08:00
Magnus Müller a2fce46245 fix(filesystem): improve write_file filename handling and error messages
- Allow dots, spaces, and parentheses in filenames (e.g. report.v2.md, my file.csv)
- Auto-sanitize invalid filenames instead of rejecting them (spaces→hyphens, strip bad chars)
- Add specific error messages for binary extensions (.png, .jpg, etc.) to stop infinite retry loops
- Add specific error messages for unsupported extensions explaining which ones are valid
- Add .html and .xml as supported file types
- Improve write_file tool description with explicit filename rules and append behavior
- Add HtmlFile and XmlFile classes
- Add comprehensive tests for sanitization, new file types, and error messages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 00:04:26 -08:00
hacking-racoon 38703d5ad7 perf: lazy import for openai and reportlab to reduce startup latency
- agent/views.py: Move RateLimitError import inside format_error() function
  to avoid loading openai SDK (~800ms) at module level
- llm/messages.py: Replace openai.BaseModel with pydantic.BaseModel directly
  to remove unnecessary openai dependency
- filesystem/file_system.py: Move reportlab imports inside sync_to_disk_sync()
  to avoid ~40ms startup cost when PDF generation is not used
- utils.py: Convert OpenAIBadRequestError and GroqBadRequestError to lazy
  loaders to avoid loading SDKs at module level

This improves import time for users who don't use OpenAI provider,
especially when using Anthropic, Google, or other providers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 01:48:47 +09:00
mertunsall 03c9e94dc6 allow reading images such as jpg/png, as well as docx, fixes to the flash system prompt 2025-11-03 16:41:27 -08:00
lidongbo 3e5dc0b6f7 fix: adjust import order to pass ruff check 2025-10-30 19:16:14 +08:00
lidongbo 44d9c96cb5 Support unicode characters in filenames and improve path handling, and fixed path validation failures in Windows OS environments. 2025-10-30 19:01:54 +08:00
lidongbo 23ade5e497 Support unicode characters in filenames and improve path handling, and fixed path validation failures in Windows OS environments. 2025-10-30 17:53:51 +08:00
Magnus Müller e86182e11c feat(filesystem): add JSONL (JSON Lines) file support
Adds support for .jsonl file extension in the FileSystem class to enable
code-use mode to work with JSON Lines files (where each line is a valid
JSON object).

Changes:
- Added JsonlFile class implementing BaseFile interface
- Registered 'jsonl' extension in _file_types dictionary
- Updated external file reading to include .jsonl files
- Added state restoration support for JsonlFile
- Added comprehensive test coverage for JSONL file operations

Fixes issue where code agent rejected filenames like 'WebVoyager_data.jsonl'
with error "Invalid filename format. Must be alphanumeric with supported
extension."

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 10:07:07 -07:00
Magnus Müller 301fab0726 Reduce tokens for extract 2025-10-12 13:08:44 -07:00
mertunsall 3c41727b55 track session pdf urls and redownload if URL changes or if the file was left from previous session.
dispatch navigation complete even when switching tabs. this ensure auto pdf downloads work

increase max pdf pages to 20 so that it works better :)
2025-09-23 02:54:25 +02:00
Louis f89d497fd1 style: Run pre-commit --all-files to fix formatting
Addressed @pirate's feedback to fix lint errors by running pre-commit.
This reformatted 242 files across the codebase for consistency.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 20:04:51 +02:00
Louis 26628d96c6 Fix #2610: Replace markdown-pdf with reportlab to resolve AGPL license conflict
The markdown-pdf dependency had a transitive dependency on pymupdf (AGPL-3.0),
which conflicts with browser-use's MIT license and could require commercial
users to open-source their entire application.

This change:
- Replaces markdown-pdf==1.5 with reportlab>=4.0.0 (BSD licensed)
- Updates PdfFile.sync_to_disk_sync() to use reportlab for PDF generation
- Maintains the same API surface with no breaking changes
- Supports basic markdown formatting (headers, paragraphs)
- All existing tests continue to pass

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 19:44:00 +02:00
mertunsall 4f18bf8cc8 catch small issue 2025-07-11 18:14:03 +02:00
mertunsall d1f532b45d - remove append_file and instead merge it into write_file
- new replace_file_str
- add trailing new lines and leading_newline parameters to writing into file for robustness
- adapt system prompts accordingly
2025-07-11 17:58:01 +02:00
mertunsall 709569e3ab pdf file creation supported. 2025-07-09 13:02:15 +02:00
mertunsall e951c4fe98 increase max pdf length to 10 pages 2025-07-08 11:25:54 +02:00
mertunsall 304b065d59 more security 2025-07-05 02:07:11 +02:00
mertunsall f3e1a59642 improve 2025-07-05 01:51:00 +02:00
mertunsall 550a2a2552 feat: enhance file handling capabilities with JSON and CSV support
- Added new file types: JsonFile and CsvFile to the file system.
- Updated read_file method to handle external files with .json and .csv extensions.
- Modified write_file action to allow .json and .csv file extensions in addition to .md and .txt.
- Introduced pypdf dependency for PDF file handling.

This update improves the flexibility of file operations within the application.
2025-07-05 01:36:04 +02:00
mertunsall 35120fc253 dont use fs for short tasks, dont initialize results.md 2025-07-01 10:29:11 +02:00
mertunsall c7ef21535e fix more 2025-06-26 01:12:27 +02:00
mertunsall c717271f50 fix linter 2025-06-26 01:06:55 +02:00
mertunsall 47b2b7f2fa fix more 2025-06-26 01:02:50 +02:00
mertunsall 1b7cc0abd5 fix more 2025-06-26 00:55:49 +02:00
mertunsall 17ac82e655 fix 2025-06-26 00:54:58 +02:00
mertunsall 6b4953e922 rewrite file system 2025-06-26 00:41:56 +02:00
mertunsall 58c25af1a1 Implement data directory cleanup in FileSystem class
- Added functionality to remove existing data directory before creating a new one, ensuring a clean state for operations.
- Introduced `shutil` for directory removal.
2025-06-25 16:26:05 +02:00
mertunsall b2b95b086a tell allowed extensions to the model 2025-06-25 09:33:42 +02:00
mertunsall adb73b9d30 more fixes and simplify 2025-06-24 23:22:09 +02:00
mertunsall fa60e747d9 mr cloudrunner 2025-06-24 23:02:08 +02:00
mertunsall ce61e4e2f8 hotfix 2025-06-23 14:19:01 +02:00
mertunsall fde5e09c6a improve file system descriptions and memory 2025-06-23 13:54:28 +02:00
mertunsall bbc8d26f63 - Updated ActionResult to include an attachments field for displaying files in the done message.
- Enhanced logging in the Agent class to inform users about available attachments after task completion.
- Revised system prompt guidelines to clarify the use of text and files_to_display in the done action.
2025-06-18 14:24:27 +02:00
Magnus Müller 0871e4cf28 Refactor file appending logic in file_system.py to use a dedicated function for writing content, improving readability and maintainability. Enhanced error handling to include exception messages for better debugging. 2025-06-09 21:03:26 +02:00
mertunsall 1e549d72f3 now the model can display files to the users 2025-06-03 18:07:47 +02:00
Magnus Müller f75d3e0fac Refactor file appending logic in FileSystem class to improve performance and readability by using a dedicated function for file operations. 2025-06-02 15:16:12 +02:00