技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
tools-and-actions【数据与研究】Build and debug Browser Use tools/actions: custom Tools/Controller actions, default browser/file actions, ActionResult returns, parameter injection, sensitive data, security guardrails, and validation.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the user needs Browser Use actions, custom tools, file operations, upload/download handling, sensitive data placeholders, or action validation. Prefer ChatBrowserUse in examples unless the user already chose another model.
@tools.action(...), Tools(), Controller, custom actions, action filters, 2FA helpers, human-in-the-loop actions, deterministic browser helpers, or direct tools.<action>() calls.ActionResult, extracted_content, long_term_memory, error, is_done, success, attachments/images, or completion semantics.available_file_paths, write_file, read_file, replace_file, upload_file, downloaded files, or file containment errors.sensitive_data works, how to use <secret>name</secret>, or how to keep secrets scoped to allowed domains.../agent-programming/SKILL.md.../browser-control/SKILL.md.../llm-and-output/SKILL.md.browser-use / bu CLI sessions and CLI upload commands: ../cli-and-sessions/SKILL.md.../production-integrations/SKILL.md.Tools, ActionResult, and BrowserSession from browser_use; Controller is a backwards-compatible alias for Tools.browser_session, page_extraction_llm, file_system, available_file_paths, page_url, cdp_client, has_sensitive_data, extraction_schema, or context.**kwargs on a custom action; the registry rejects it. Use explicit parameters or a Pydantic param_model.ActionResult when the agent needs reasoning context, memory, errors, completion status, files, or attachments; simple strings are accepted but less expressive.allowed_domains=[...] when possible.Tools(exclude_actions=[...]) or tools.exclude_action(name) to remove defaults that do not fit the task.Agent(..., available_file_paths=[...]); never invent local paths.sensitive_data placeholders instead of embedding passwords or API keys in tasks.from browser_use import ActionResult, Agent, BrowserSession, ChatBrowserUse, Tools
tools = Tools()
@tools.action('Ask the user for a one-line confirmation')
async def ask_user(question: str) -> ActionResult:
answer = input(f'{question} > ')
return ActionResult(extracted_content=f'User answered: {answer}')
agent = Agent(task='Ask for confirmation, then continue', llm=ChatBrowserUse(), tools=tools)
For browser-aware actions, use the exact injected name:
@tools.action('Read current page URL')
async def current_url(browser_session: BrowserSession) -> ActionResult:
url = await browser_session.get_current_page_url()
return ActionResult(extracted_content=url, long_term_memory=f'Current URL: {url}')
async def fill_field(index: int, text: str, browser_session: BrowserSession); Browser Use auto-generates a Pydantic model for non-special parameters.param_model=MyParams, then write async def action(params: MyParams, browser_session: BrowserSession).@tools.action('Use only on billing pages', allowed_domains=['https://billing.example.com']).terminates_sequence=True for navigation-like actions where queued multi-actions should stop after execution.await tools.read_file(file_name='x.md', browser_session=session, file_system=fs, available_file_paths=[]).See references/custom-tools.md for full patterns and validation rules.
Core defaults include:
search, navigate, go_back, wait, switch, close.click, input, upload_file, scroll, find_text, send_keys, dropdown actions.extract, search_page, find_elements, evaluate, screenshot, save_pdf.write_file, read_file, replace_file.done or structured done when output_model is configured.See references/default-actions.md for action parameters, when to exclude defaults, JavaScript evaluation cautions, and file-action behavior.
write_file supports text/document outputs such as .txt, .md, .json, .jsonl, .csv, .html, .xml, .pdf, and .docx; it rejects binary/image extensions such as .png and .jpg.replace_file requires exact old_str; read the file first when unsure.read_file can read managed files and user/downloaded files from available_file_paths; large content is summarized in memory but full content is returned for the current step.upload_file accepts paths from available_file_paths, Browser Use downloads, remote-browser paths, or managed FileSystem files; local uploads are checked for existence and nonzero size.sensitive_data and referenced as <secret>key</secret>; domain-specific secrets are only exposed on matching URLs.sensitive_data with Browser(..., allowed_domains=[...]) for prompt-injection resistance.See references/security-and-files.md for guardrail details and examples.
Run the bundled helper after editing tool code or snippets:
python skills/disco/browser-use/sub-skills/tools-and-actions/scripts/validate_custom_tool.py
The helper checks imports, registry schema generation, injected parameter names, validation errors, domain filtering, and ActionResult normalization without launching a browser or making network calls.
uv pip install browser-use; install Chromium separately when the task needs a live browser.requires browser_session but none provided: use the tool through Agent(..., tools=tools) or pass browser_session in direct tests.conflicts with special argument: rename the parameter or use the required special type, usually BrowserSession.validate_custom_tool.py.available_file_paths or write/read through the managed file system first.allowed_domains coverage.../browser-control/SKILL.md.See references/troubleshooting.md for symptom-to-fix tables.
available_file_paths, and structured status messages; route browser profile setup to ../browser-control/SKILL.md and output schema setup to ../llm-and-output/SKILL.md.browser instead of browser_session, has **kwargs, tries to upload ../note.md, and leaks a password in history; produce safe corrected code and validation steps.