|
|
@@ -15,6 +15,12 @@ Native Browser-Use Tools Adapter
|
|
|
1. 在 Agent 初始化时调用 init_browser_session()
|
|
|
2. 使用各个工具函数执行浏览器操作
|
|
|
3. 任务结束时调用 cleanup_browser_session()
|
|
|
+
|
|
|
+文件操作说明:
|
|
|
+- 浏览器专用文件目录:.browser_use_files/ (在当前工作目录下)
|
|
|
+ 用于存储浏览器会话产生的临时文件(下载、上传、截图等)
|
|
|
+- 一般文件操作:请使用 agent.tools.builtin 中的文件工具 (read_file, write_file, edit_file)
|
|
|
+ 这些工具功能更完善,支持diff预览、智能匹配、分页读取等
|
|
|
"""
|
|
|
|
|
|
import sys
|
|
|
@@ -119,7 +125,9 @@ async def init_browser_session(
|
|
|
# 创建工具实例
|
|
|
_browser_tools = Tools()
|
|
|
|
|
|
- # 创建文件系统实例(用于文件操作)
|
|
|
+ # 创建文件系统实例(用于浏览器会话产生的文件)
|
|
|
+ # 注意:这个目录仅用于浏览器操作相关的临时文件(下载、上传、截图等)
|
|
|
+ # 对于一般文件读写操作,请使用 agent.tools.builtin 中的文件工具
|
|
|
base_dir = Path.cwd() / ".browser_use_files"
|
|
|
base_dir.mkdir(parents=True, exist_ok=True)
|
|
|
_file_system = FileSystem(base_dir=str(base_dir))
|
|
|
@@ -315,7 +323,7 @@ def _fetch_profile_id(cookie_type: str) -> Optional[str]:
|
|
|
# ============================================================
|
|
|
|
|
|
@tool()
|
|
|
-async def navigate_to_url(url: str, new_tab: bool = False, uid: str = "") -> ToolResult:
|
|
|
+async def navigate_to_url(url: str, new_tab: bool = False) -> ToolResult:
|
|
|
"""
|
|
|
导航到指定的 URL
|
|
|
Navigate to a specific URL
|
|
|
@@ -325,7 +333,6 @@ async def navigate_to_url(url: str, new_tab: bool = False, uid: str = "") -> Too
|
|
|
Args:
|
|
|
url: 要访问的 URL 地址
|
|
|
new_tab: 是否在新标签页中打开(默认 False)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含导航结果的工具返回对象
|
|
|
@@ -356,7 +363,7 @@ async def navigate_to_url(url: str, new_tab: bool = False, uid: str = "") -> Too
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def search_web(query: str, engine: str = "google", uid: str = "") -> ToolResult:
|
|
|
+async def search_web(query: str, engine: str = "google") -> ToolResult:
|
|
|
"""
|
|
|
使用搜索引擎搜索
|
|
|
Search the web using a search engine
|
|
|
@@ -364,7 +371,6 @@ async def search_web(query: str, engine: str = "google", uid: str = "") -> ToolR
|
|
|
Args:
|
|
|
query: 搜索关键词
|
|
|
engine: 搜索引擎 (google, duckduckgo, bing) - 默认: google
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 搜索结果
|
|
|
@@ -394,16 +400,13 @@ async def search_web(query: str, engine: str = "google", uid: str = "") -> ToolR
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def go_back(uid: str = "") -> ToolResult:
|
|
|
+async def go_back() -> ToolResult:
|
|
|
"""
|
|
|
返回到上一个页面
|
|
|
Go back to the previous page
|
|
|
|
|
|
模拟浏览器的"后退"按钮功能。
|
|
|
|
|
|
- Args:
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
-
|
|
|
Returns:
|
|
|
ToolResult: 包含返回操作结果的工具返回对象
|
|
|
"""
|
|
|
@@ -424,7 +427,7 @@ async def go_back(uid: str = "") -> ToolResult:
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def wait(seconds: int = 3, uid: str = "") -> ToolResult:
|
|
|
+async def wait(seconds: int = 3) -> ToolResult:
|
|
|
"""
|
|
|
等待指定的秒数
|
|
|
Wait for a specified number of seconds
|
|
|
@@ -433,7 +436,6 @@ async def wait(seconds: int = 3, uid: str = "") -> ToolResult:
|
|
|
|
|
|
Args:
|
|
|
seconds: 等待时间(秒),最大30秒
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含等待操作结果的工具返回对象
|
|
|
@@ -462,14 +464,13 @@ async def wait(seconds: int = 3, uid: str = "") -> ToolResult:
|
|
|
# ============================================================
|
|
|
|
|
|
@tool()
|
|
|
-async def click_element(index: int, uid: str = "") -> ToolResult:
|
|
|
+async def click_element(index: int) -> ToolResult:
|
|
|
"""
|
|
|
通过索引点击页面元素
|
|
|
Click an element by index
|
|
|
|
|
|
Args:
|
|
|
index: 元素索引(从浏览器状态中获取)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含点击操作结果的工具返回对象
|
|
|
@@ -500,7 +501,7 @@ async def click_element(index: int, uid: str = "") -> ToolResult:
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def input_text(index: int, text: str, clear: bool = True, uid: str = "") -> ToolResult:
|
|
|
+async def input_text(index: int, text: str, clear: bool = True) -> ToolResult:
|
|
|
"""
|
|
|
在指定元素中输入文本
|
|
|
Input text into an element
|
|
|
@@ -509,7 +510,6 @@ async def input_text(index: int, text: str, clear: bool = True, uid: str = "") -
|
|
|
index: 元素索引(从浏览器状态中获取)
|
|
|
text: 要输入的文本内容
|
|
|
clear: 是否先清除现有文本(默认 True)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含输入操作结果的工具返回对象
|
|
|
@@ -539,7 +539,7 @@ async def input_text(index: int, text: str, clear: bool = True, uid: str = "") -
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def send_keys(keys: str, uid: str = "") -> ToolResult:
|
|
|
+async def send_keys(keys: str) -> ToolResult:
|
|
|
"""
|
|
|
发送键盘按键或快捷键
|
|
|
Send keyboard keys or shortcuts
|
|
|
@@ -551,7 +551,6 @@ async def send_keys(keys: str, uid: str = "") -> ToolResult:
|
|
|
- 单个按键: "Enter", "Escape", "PageDown", "Tab"
|
|
|
- 组合键: "Control+o", "Shift+Tab", "Alt+F4"
|
|
|
- 功能键: "F1", "F2", ..., "F12"
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含按键操作结果的工具返回对象
|
|
|
@@ -580,7 +579,7 @@ async def send_keys(keys: str, uid: str = "") -> ToolResult:
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def upload_file(index: int, path: str, uid: str = "") -> ToolResult:
|
|
|
+async def upload_file(index: int, path: str) -> ToolResult:
|
|
|
"""
|
|
|
上传文件到文件输入元素
|
|
|
Upload a file to a file input element
|
|
|
@@ -588,7 +587,6 @@ async def upload_file(index: int, path: str, uid: str = "") -> ToolResult:
|
|
|
Args:
|
|
|
index: 文件输入框的元素索引
|
|
|
path: 要上传的文件路径(绝对路径)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含上传操作结果的工具返回对象
|
|
|
@@ -627,7 +625,7 @@ async def upload_file(index: int, path: str, uid: str = "") -> ToolResult:
|
|
|
|
|
|
@tool()
|
|
|
async def scroll_page(down: bool = True, pages: float = 1.0,
|
|
|
- index: Optional[int] = None, uid: str = "") -> ToolResult:
|
|
|
+ index: Optional[int] = None) -> ToolResult:
|
|
|
"""
|
|
|
滚动页面或元素
|
|
|
Scroll the page or a specific element
|
|
|
@@ -636,7 +634,6 @@ async def scroll_page(down: bool = True, pages: float = 1.0,
|
|
|
down: True 向下滚动,False 向上滚动
|
|
|
pages: 滚动页数(0.5=半页,1=全页,10=滚动到底部/顶部)
|
|
|
index: 可选,滚动特定元素(如下拉框内部)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 滚动结果
|
|
|
@@ -668,7 +665,7 @@ async def scroll_page(down: bool = True, pages: float = 1.0,
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def find_text(text: str, uid: str = "") -> ToolResult:
|
|
|
+async def find_text(text: str) -> ToolResult:
|
|
|
"""
|
|
|
查找页面中的文本并滚动到该位置
|
|
|
Find text on the page and scroll to it
|
|
|
@@ -677,7 +674,6 @@ async def find_text(text: str, uid: str = "") -> ToolResult:
|
|
|
|
|
|
Args:
|
|
|
text: 要查找的文本内容
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含查找结果的工具返回对象
|
|
|
@@ -705,16 +701,13 @@ async def find_text(text: str, uid: str = "") -> ToolResult:
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def screenshot(uid: str = "") -> ToolResult:
|
|
|
+async def screenshot() -> ToolResult:
|
|
|
"""
|
|
|
请求在下次观察中包含页面截图
|
|
|
Request a screenshot to be included in the next observation
|
|
|
|
|
|
用于视觉检查页面状态,帮助理解页面布局和内容。
|
|
|
|
|
|
- Args:
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
-
|
|
|
Returns:
|
|
|
ToolResult: 包含截图请求结果的工具返回对象
|
|
|
|
|
|
@@ -745,14 +738,13 @@ async def screenshot(uid: str = "") -> ToolResult:
|
|
|
# ============================================================
|
|
|
|
|
|
@tool()
|
|
|
-async def switch_tab(tab_id: str, uid: str = "") -> ToolResult:
|
|
|
+async def switch_tab(tab_id: str) -> ToolResult:
|
|
|
"""
|
|
|
切换到指定标签页
|
|
|
Switch to a different browser tab
|
|
|
|
|
|
Args:
|
|
|
tab_id: 4字符标签ID(target_id 的最后4位)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 切换结果
|
|
|
@@ -781,14 +773,13 @@ async def switch_tab(tab_id: str, uid: str = "") -> ToolResult:
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def close_tab(tab_id: str, uid: str = "") -> ToolResult:
|
|
|
+async def close_tab(tab_id: str) -> ToolResult:
|
|
|
"""
|
|
|
关闭指定标签页
|
|
|
Close a browser tab
|
|
|
|
|
|
Args:
|
|
|
tab_id: 4字符标签ID
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 关闭结果
|
|
|
@@ -821,14 +812,13 @@ async def close_tab(tab_id: str, uid: str = "") -> ToolResult:
|
|
|
# ============================================================
|
|
|
|
|
|
@tool()
|
|
|
-async def get_dropdown_options(index: int, uid: str = "") -> ToolResult:
|
|
|
+async def get_dropdown_options(index: int) -> ToolResult:
|
|
|
"""
|
|
|
获取下拉框的所有选项
|
|
|
Get options from a dropdown element
|
|
|
|
|
|
Args:
|
|
|
index: 下拉框的元素索引
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含所有选项的结果
|
|
|
@@ -856,7 +846,7 @@ async def get_dropdown_options(index: int, uid: str = "") -> ToolResult:
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def select_dropdown_option(index: int, text: str, uid: str = "") -> ToolResult:
|
|
|
+async def select_dropdown_option(index: int, text: str) -> ToolResult:
|
|
|
"""
|
|
|
选择下拉框选项
|
|
|
Select an option from a dropdown
|
|
|
@@ -864,7 +854,6 @@ async def select_dropdown_option(index: int, text: str, uid: str = "") -> ToolRe
|
|
|
Args:
|
|
|
index: 下拉框的元素索引
|
|
|
text: 要选择的选项文本(精确匹配)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 选择结果
|
|
|
@@ -898,7 +887,7 @@ async def select_dropdown_option(index: int, text: str, uid: str = "") -> ToolRe
|
|
|
|
|
|
@tool()
|
|
|
async def extract_content(query: str, extract_links: bool = False,
|
|
|
- start_from_char: int = 0, uid: str = "") -> ToolResult:
|
|
|
+ start_from_char: int = 0) -> ToolResult:
|
|
|
"""
|
|
|
使用 LLM 从页面提取结构化数据
|
|
|
Extract content from the current page using LLM
|
|
|
@@ -907,7 +896,6 @@ async def extract_content(query: str, extract_links: bool = False,
|
|
|
query: 提取查询(告诉 LLM 要提取什么内容)
|
|
|
extract_links: 是否提取链接(默认 False,节省 token)
|
|
|
start_from_char: 从哪个字符开始提取(用于分页提取大内容)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 提取的内容
|
|
|
@@ -946,16 +934,13 @@ async def extract_content(query: str, extract_links: bool = False,
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def get_page_html(uid: str = "") -> ToolResult:
|
|
|
+async def get_page_html() -> ToolResult:
|
|
|
"""
|
|
|
获取当前页面的完整 HTML
|
|
|
Get the full HTML of the current page
|
|
|
|
|
|
返回当前页面的完整 HTML 源代码。
|
|
|
|
|
|
- Args:
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
-
|
|
|
Returns:
|
|
|
ToolResult: 包含页面 HTML 的工具返回对象
|
|
|
|
|
|
@@ -1011,16 +996,13 @@ async def get_page_html(uid: str = "") -> ToolResult:
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def get_selector_map(uid: str = "") -> ToolResult:
|
|
|
+async def get_selector_map() -> ToolResult:
|
|
|
"""
|
|
|
获取当前页面的元素索引映射
|
|
|
Get the selector map of interactive elements on the current page
|
|
|
|
|
|
返回页面所有可交互元素的索引字典,用于后续的元素操作。
|
|
|
|
|
|
- Args:
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
-
|
|
|
Returns:
|
|
|
ToolResult: 包含元素映射的工具返回对象
|
|
|
|
|
|
@@ -1070,7 +1052,7 @@ async def get_selector_map(uid: str = "") -> ToolResult:
|
|
|
# ============================================================
|
|
|
|
|
|
@tool()
|
|
|
-async def evaluate(code: str, uid: str = "") -> ToolResult:
|
|
|
+async def evaluate(code: str) -> ToolResult:
|
|
|
"""
|
|
|
在页面中执行 JavaScript 代码
|
|
|
Execute JavaScript code in the page context
|
|
|
@@ -1079,7 +1061,6 @@ async def evaluate(code: str, uid: str = "") -> ToolResult:
|
|
|
|
|
|
Args:
|
|
|
code: 要执行的 JavaScript 代码字符串
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含执行结果的工具返回对象
|
|
|
@@ -1113,7 +1094,7 @@ async def evaluate(code: str, uid: str = "") -> ToolResult:
|
|
|
|
|
|
|
|
|
@tool()
|
|
|
-async def ensure_login_with_cookies(cookie_type: str, url: str = "https://www.xiaohongshu.com", uid: str = "") -> ToolResult:
|
|
|
+async def ensure_login_with_cookies(cookie_type: str, url: str = "https://www.xiaohongshu.com") -> ToolResult:
|
|
|
"""
|
|
|
检查登录状态并在需要时注入 cookies
|
|
|
"""
|
|
|
@@ -1204,149 +1185,13 @@ async def ensure_login_with_cookies(cookie_type: str, url: str = "https://www.xi
|
|
|
)
|
|
|
|
|
|
|
|
|
-# ============================================================
|
|
|
-# 文件系统工具 (File System Tools)
|
|
|
-# ============================================================
|
|
|
-
|
|
|
-@tool()
|
|
|
-async def write_file(file_name: str, content: str, append: bool = False, uid: str = "") -> ToolResult:
|
|
|
- """
|
|
|
- 写入文件到本地文件系统
|
|
|
- Write content to a local file
|
|
|
-
|
|
|
- 支持多种文件格式的写入操作。
|
|
|
-
|
|
|
- Args:
|
|
|
- file_name: 文件名(包含扩展名)
|
|
|
- content: 要写入的文件内容
|
|
|
- append: 是否追加模式(默认 False,覆盖写入)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
-
|
|
|
- Returns:
|
|
|
- ToolResult: 包含写入结果的工具返回对象
|
|
|
-
|
|
|
- Example:
|
|
|
- write_file("output.txt", "Hello World")
|
|
|
- write_file("data.json", '{"key": "value"}')
|
|
|
-
|
|
|
- Note:
|
|
|
- 支持的文件格式: .txt, .md, .json, .jsonl, .csv, .pdf
|
|
|
- """
|
|
|
- try:
|
|
|
- browser, tools = await get_browser_session()
|
|
|
-
|
|
|
- result = await tools.write_file(
|
|
|
- file_name=file_name,
|
|
|
- content=content,
|
|
|
- append=append,
|
|
|
- file_system=_file_system
|
|
|
- )
|
|
|
-
|
|
|
- return action_result_to_tool_result(result, f"写入文件: {file_name}")
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- return ToolResult(
|
|
|
- title="写入文件失败",
|
|
|
- output="",
|
|
|
- error=f"Failed to write file: {str(e)}",
|
|
|
- long_term_memory=f"写入文件 {file_name} 失败"
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-@tool()
|
|
|
-async def read_file(file_name: str, uid: str = "") -> ToolResult:
|
|
|
- """
|
|
|
- 读取文件内容
|
|
|
- Read content from a local file
|
|
|
-
|
|
|
- 支持多种文件格式的读取操作。
|
|
|
-
|
|
|
- Args:
|
|
|
- file_name: 文件名(包含扩展名)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
-
|
|
|
- Returns:
|
|
|
- ToolResult: 包含文件内容的工具返回对象
|
|
|
-
|
|
|
- Example:
|
|
|
- read_file("input.txt")
|
|
|
- read_file("data.json")
|
|
|
-
|
|
|
- Note:
|
|
|
- 支持的文件格式: 文本文件、PDF、DOCX、图片等
|
|
|
- """
|
|
|
- try:
|
|
|
- browser, tools = await get_browser_session()
|
|
|
-
|
|
|
- result = await tools.read_file(
|
|
|
- file_name=file_name,
|
|
|
- available_file_paths=[],
|
|
|
- file_system=_file_system
|
|
|
- )
|
|
|
-
|
|
|
- return action_result_to_tool_result(result, f"读取文件: {file_name}")
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- return ToolResult(
|
|
|
- title="读取文件失败",
|
|
|
- output="",
|
|
|
- error=f"Failed to read file: {str(e)}",
|
|
|
- long_term_memory=f"读取文件 {file_name} 失败"
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-@tool()
|
|
|
-async def replace_file(file_name: str, old_str: str, new_str: str, uid: str = "") -> ToolResult:
|
|
|
- """
|
|
|
- 替换文件中的特定文本
|
|
|
- Replace specific text in a file
|
|
|
-
|
|
|
- 在文件中查找并替换指定的文本内容。
|
|
|
-
|
|
|
- Args:
|
|
|
- file_name: 文件名(包含扩展名)
|
|
|
- old_str: 要替换的文本
|
|
|
- new_str: 新文本
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
-
|
|
|
- Returns:
|
|
|
- ToolResult: 包含替换结果的工具返回对象
|
|
|
-
|
|
|
- Example:
|
|
|
- replace_file("config.txt", "old_value", "new_value")
|
|
|
-
|
|
|
- Note:
|
|
|
- - 会替换文件中所有匹配的文本
|
|
|
- - 如果找不到要替换的文本,会返回警告
|
|
|
- """
|
|
|
- try:
|
|
|
- browser, tools = await get_browser_session()
|
|
|
-
|
|
|
- result = await tools.replace_file(
|
|
|
- file_name=file_name,
|
|
|
- old_str=old_str,
|
|
|
- new_str=new_str,
|
|
|
- file_system=_file_system
|
|
|
- )
|
|
|
-
|
|
|
- return action_result_to_tool_result(result, f"替换文件内容: {file_name}")
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- return ToolResult(
|
|
|
- title="替换文件失败",
|
|
|
- output="",
|
|
|
- error=f"Failed to replace file content: {str(e)}",
|
|
|
- long_term_memory=f"替换文件 {file_name} 失败"
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
# ============================================================
|
|
|
# 等待用户操作工具 (Wait for User Action)
|
|
|
# ============================================================
|
|
|
|
|
|
@tool()
|
|
|
async def wait_for_user_action(message: str = "Please complete the action in browser",
|
|
|
- timeout: int = 300, uid: str = "") -> ToolResult:
|
|
|
+ timeout: int = 300) -> ToolResult:
|
|
|
"""
|
|
|
等待用户在浏览器中完成操作(如登录)
|
|
|
Wait for user to complete an action in the browser (e.g., login)
|
|
|
@@ -1356,7 +1201,6 @@ async def wait_for_user_action(message: str = "Please complete the action in bro
|
|
|
Args:
|
|
|
message: 提示用户需要完成的操作
|
|
|
timeout: 最大等待时间(秒),默认 300 秒(5 分钟)
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 包含等待结果的工具返回对象
|
|
|
@@ -1419,7 +1263,7 @@ async def wait_for_user_action(message: str = "Please complete the action in bro
|
|
|
|
|
|
@tool()
|
|
|
async def done(text: str, success: bool = True,
|
|
|
- files_to_display: Optional[List[str]] = None, uid: str = "") -> ToolResult:
|
|
|
+ files_to_display: Optional[List[str]] = None) -> ToolResult:
|
|
|
"""
|
|
|
标记任务完成并返回最终消息
|
|
|
Mark the task as complete and return final message to user
|
|
|
@@ -1428,7 +1272,6 @@ async def done(text: str, success: bool = True,
|
|
|
text: 给用户的最终消息
|
|
|
success: 任务是否成功完成
|
|
|
files_to_display: 可选的要显示的文件路径列表
|
|
|
- uid: 用户 ID(由框架自动注入)
|
|
|
|
|
|
Returns:
|
|
|
ToolResult: 完成结果
|
|
|
@@ -1634,11 +1477,6 @@ __all__ = [
|
|
|
'evaluate',
|
|
|
'ensure_login_with_cookies',
|
|
|
|
|
|
- # 文件系统工具
|
|
|
- 'write_file',
|
|
|
- 'read_file',
|
|
|
- 'replace_file',
|
|
|
-
|
|
|
# 等待用户操作
|
|
|
'wait_for_user_action',
|
|
|
|