replace sb_browser_tool with stagehand_browser_tool

This commit is contained in:
Krishav Raj Singh 2025-08-05 17:04:10 +05:30
parent ba13fa21b6
commit 796f1ef9f4
12 changed files with 53 additions and 92 deletions

View File

@ -76,7 +76,7 @@ Schedule automatic execution:
### 🔧 **AgentPress Core Tools**
- **`sb_shell_tool`**: Execute commands, run scripts, system operations, development tasks
- **`sb_files_tool`**: Create/edit files, manage documents, process text, generate reports
- **`sb_browser_tool`**: Navigate websites, scrape content, interact with web apps, monitor pages
- **`stagehand_browser_tool`**: Navigate websites, scrape content, interact with web apps, monitor pages using local Stagehand
- **`sb_vision_tool`**: Process images, analyze screenshots, extract text from images
- **`sb_deploy_tool`**: Deploy applications, manage containers, CI/CD workflows
- **`sb_expose_tool`**: Expose local services, create public URLs for testing
@ -91,7 +91,7 @@ Schedule automatic execution:
- Integrations: Google Sheets, databases, analytics platforms
**🔍 Research & Information Gathering**
- Required: `web_search_tool`, `sb_files_tool`, `sb_browser_tool`
- Required: `web_search_tool`, `sb_files_tool`, `stagehand_browser_tool`
- Optional: `sb_vision_tool` (for image analysis)
- Integrations: Academic databases, news APIs, note-taking tools
@ -106,7 +106,7 @@ Schedule automatic execution:
- Integrations: GitHub, GitLab, CI/CD platforms
**🌐 Web Monitoring & Automation**
- Required: `sb_browser_tool`, `web_search_tool`
- Required: `stagehand_browser_tool`, `web_search_tool`
- Optional: `sb_files_tool`, `data_providers_tool`
- Integrations: Website monitoring services, notification platforms
@ -207,7 +207,7 @@ Perfect! Let me help you build a workflow automation agent.
Excellent choice! Let me build you a comprehensive research agent.
**My Analysis:**
- **Core Tools**: `web_search_tool` (internet research), `sb_files_tool` (document creation), `sb_browser_tool` (website analysis)
- **Core Tools**: `web_search_tool` (internet research), `sb_files_tool` (document creation), `stagehand_browser_tool` (website analysis)
- **Recommended Integrations**: Academic databases, news APIs, note-taking tools (Notion/Obsidian)
- **Workflow**: Research Analysis Report Generation Storage
- **Scheduling**: Optional triggers for regular research updates

View File

@ -16,7 +16,6 @@ from agentpress.thread_manager import ThreadManager
from agentpress.response_processor import ProcessorConfig
from agent.tools.sb_shell_tool import SandboxShellTool
from agent.tools.sb_files_tool import SandboxFilesTool
from agent.tools.sb_browser_tool import SandboxBrowserTool
from agent.tools.data_providers_tool import DataProvidersTool
from agent.tools.expand_msg_tool import ExpandMessageTool
from agent.prompt import get_system_prompt
@ -66,7 +65,6 @@ class ToolManager:
self.thread_manager.add_tool(SandboxShellTool, project_id=self.project_id, thread_manager=self.thread_manager)
self.thread_manager.add_tool(SandboxFilesTool, project_id=self.project_id, thread_manager=self.thread_manager)
self.thread_manager.add_tool(SandboxBrowserTool, project_id=self.project_id, thread_id=self.thread_id, thread_manager=self.thread_manager)
self.thread_manager.add_tool(SandboxDeployTool, project_id=self.project_id, thread_manager=self.thread_manager)
self.thread_manager.add_tool(SandboxExposeTool, project_id=self.project_id, thread_manager=self.thread_manager)
self.thread_manager.add_tool(SandboxWebSearchTool, project_id=self.project_id, thread_manager=self.thread_manager)
@ -76,6 +74,12 @@ class ToolManager:
self.thread_manager.add_tool(SandboxSheetsTool, project_id=self.project_id, thread_manager=self.thread_manager)
if config.RAPID_API_KEY:
self.thread_manager.add_tool(DataProvidersTool)
# Add Stagehand Browser Tool (replaces sandbox browser tool)
from agent.tools.stagehand_browser_tool import StagehandBrowserTool
self.thread_manager.add_tool(StagehandBrowserTool, project_id=self.project_id, thread_id=self.thread_id, thread_manager=self.thread_manager)
def register_agent_builder_tools(self, agent_id: str):
from agent.tools.agent_builder_tools.agent_config_tool import AgentConfigTool
@ -112,8 +116,6 @@ class ToolManager:
self.thread_manager.add_tool(SandboxShellTool, project_id=self.project_id, thread_manager=self.thread_manager)
if safe_tool_check('sb_files_tool'):
self.thread_manager.add_tool(SandboxFilesTool, project_id=self.project_id, thread_manager=self.thread_manager)
if safe_tool_check('sb_browser_tool'):
self.thread_manager.add_tool(SandboxBrowserTool, project_id=self.project_id, thread_id=self.thread_id, thread_manager=self.thread_manager)
if safe_tool_check('sb_deploy_tool'):
self.thread_manager.add_tool(SandboxDeployTool, project_id=self.project_id, thread_manager=self.thread_manager)
if safe_tool_check('sb_expose_tool'):
@ -127,6 +129,11 @@ class ToolManager:
if config.RAPID_API_KEY and safe_tool_check('data_providers_tool'):
self.thread_manager.add_tool(DataProvidersTool)
if safe_tool_check('stagehand_browser_tool'):
from agent.tools.stagehand_browser_tool import StagehandBrowserTool
self.thread_manager.add_tool(StagehandBrowserTool, project_id=self.project_id, thread_id=self.thread_id, thread_manager=self.thread_manager)
class MCPManager:
def __init__(self, thread_manager: ThreadManager, account_id: str):

View File

@ -11,8 +11,7 @@ class SunaConfig:
DEFAULT_TOOLS = {
"sb_shell_tool": True,
"sb_files_tool": True,
"sb_browser_tool": True,
"stagehand_browser_tool": True,
"sb_deploy_tool": True,
"sb_expose_tool": True,
"web_search_tool": True,

View File

@ -42,7 +42,7 @@ class WorkflowTool(AgentBuilderBaseTool):
tool_mapping = {
'sb_shell_tool': ['execute_command'],
'sb_files_tool': ['create_file', 'edit_file', 'str_replace', 'full_file_rewrite', 'delete_file'],
'sb_browser_tool': ['browser_navigate_to', 'browser_take_screenshot'],
'stagehand_browser_tool': ['browser_navigate_to', 'browser_screenshot'],
'sb_vision_tool': ['see_image'],
'sb_deploy_tool': ['deploy'],
'sb_expose_tool': ['expose_port'],

View File

@ -459,7 +459,7 @@ class WorkflowExecutor:
tool_mapping = {
'sb_shell_tool': ['execute_command'],
'sb_files_tool': ['create_file', 'str_replace', 'full_file_rewrite', 'delete_file'],
'sb_browser_tool': ['browser_navigate_to', 'browser_take_screenshot'],
'stagehand_browser_tool': ['browser_navigate_to', 'browser_screenshot'],
'sb_vision_tool': ['see_image'],
'sb_deploy_tool': ['deploy'],
'sb_expose_tool': ['expose_port'],

View File

@ -1,7 +1,7 @@
export const AGENTPRESS_TOOL_DEFINITIONS: Record<string, { enabled: boolean; description: string; icon: string; color: string }> = {
'sb_shell_tool': { enabled: true, description: 'Execute shell commands in tmux sessions for terminal operations, CLI tools, and system management', icon: '💻', color: 'bg-slate-100 dark:bg-slate-800' },
'sb_files_tool': { enabled: true, description: 'Create, read, update, and delete files in the workspace with comprehensive file management', icon: '📁', color: 'bg-blue-100 dark:bg-blue-800/50' },
'sb_browser_tool': { enabled: true, description: 'Browser automation for web navigation, clicking, form filling, and page interaction', icon: '🌐', color: 'bg-indigo-100 dark:bg-indigo-800/50' },
'stagehand_browser_tool': { enabled: true, description: 'Browser automation for web navigation, clicking, form filling, and page interaction using local Stagehand', icon: '🌐', color: 'bg-indigo-100 dark:bg-indigo-800/50' },
'sb_deploy_tool': { enabled: true, description: 'Deploy applications and services with automated deployment capabilities', icon: '🚀', color: 'bg-green-100 dark:bg-green-800/50' },
'sb_expose_tool': { enabled: true, description: 'Expose services and manage ports for application accessibility', icon: '🔌', color: 'bg-orange-100 dark:bg-orange-800/20' },
'web_search_tool': { enabled: true, description: 'Search the web using Tavily API and scrape webpages with Firecrawl for research', icon: '🔍', color: 'bg-yellow-100 dark:bg-yellow-800/50' },
@ -19,7 +19,7 @@ export const getToolDisplayName = (toolName: string): string => {
const displayNames: Record<string, string> = {
'sb_shell_tool': 'Terminal',
'sb_files_tool': 'File Manager',
'sb_browser_tool': 'Browser Automation',
'stagehand_browser_tool': 'Browser Automation',
'sb_deploy_tool': 'Deploy Tool',
'sb_expose_tool': 'Port Exposure',
'web_search_tool': 'Web Search',

View File

@ -50,7 +50,7 @@ const normalizeToolName = (toolName: string, toolType: 'agentpress' | 'mcp') =>
const agentPressMapping: Record<string, string> = {
'sb_shell_tool': 'Shell Tool',
'sb_files_tool': 'Files Tool',
'sb_browser_tool': 'Browser Tool',
'stagehand_browser_tool': 'Browser Tool',
'sb_deploy_tool': 'Deploy Tool',
'sb_expose_tool': 'Expose Tool',
'web_search_tool': 'Web Search',

View File

@ -43,11 +43,11 @@ export function getToolTitle(toolName: string): string {
'web-search': 'Web Search',
'crawl-webpage': 'Web Crawl',
'scrape-webpage': 'Web Scrape',
'browser-navigate': 'Browser Navigate',
'browser-click': 'Browser Click',
'browser-extract': 'Browser Extract',
'browser-fill': 'Browser Fill',
'browser-wait': 'Browser Wait',
'browser-navigate-to': 'Browser Navigate',
'browser-act': 'Browser Action',
'browser-extract-content': 'Browser Extract',
'browser-screenshot': 'Browser Screenshot',
'browser-observe': 'Browser Observe',
'see-image': 'View Image',
'ask': 'Ask',
'complete': 'Task Complete',
@ -73,8 +73,8 @@ export function getToolTitle(toolName: string): string {
}
// For browser tools not explicitly mapped
if (normalizedName.startsWith('browser-')) {
const operation = normalizedName.replace('browser-', '').replace(/-/g, ' ');
if (normalizedName.startsWith('browser_')) {
const operation = normalizedName.replace('browser_', '').replace(/_/g, ' ');
return 'Browser ' + operation.charAt(0).toUpperCase() + operation.slice(1);
}
@ -593,7 +593,7 @@ export function extractBrowserUrl(content: string | object | undefined | null):
export function extractBrowserOperation(toolName: string | undefined): string {
if (!toolName) return 'Browser Operation';
const operation = toolName.replace('browser-', '').replace(/-/g, ' ');
const operation = toolName.replace('browser_', '').replace(/_/g, ' ');
return operation.charAt(0).toUpperCase() + operation.slice(1);
}
@ -1228,12 +1228,10 @@ export function getToolComponent(toolName: string): string {
// Map specific tool names to their respective components
switch (normalizedName) {
// Browser tools
case 'browser-navigate':
case 'browser-click':
case 'browser-extract':
case 'browser-fill':
case 'browser-wait':
case 'browser-screenshot':
case 'browser_navigate_to':
case 'browser_act':
case 'browser_extract_content':
case 'browser_screenshot':
return 'BrowserToolView';
// Command execution

View File

@ -37,20 +37,10 @@ type ToolViewRegistryType = Record<string, ToolViewComponent>;
const defaultRegistry: ToolViewRegistryType = {
'browser-navigate-to': BrowserToolView,
'browser-go-back': BrowserToolView,
'browser-wait': BrowserToolView,
'browser-click-element': BrowserToolView,
'browser-input-text': BrowserToolView,
'browser-send-keys': BrowserToolView,
'browser-switch-tab': BrowserToolView,
'browser-close-tab': BrowserToolView,
'browser-scroll-down': BrowserToolView,
'browser-scroll-up': BrowserToolView,
'browser-scroll-to-text': BrowserToolView,
'browser-get-dropdown-options': BrowserToolView,
'browser-select-dropdown-option': BrowserToolView,
'browser-drag-drop': BrowserToolView,
'browser-click-coordinates': BrowserToolView,
'browser-act': BrowserToolView,
'browser-extract-content': BrowserToolView,
'browser-observe': BrowserToolView,
'browser-screenshot': BrowserToolView,
'execute-command': CommandToolView,
'check-command-output': CheckCommandOutputToolView,

View File

@ -82,22 +82,11 @@ export function safeJsonParse<T>(
// Helper function to get an icon based on tool name
export const getToolIcon = (toolName: string): ElementType => {
switch (toolName?.toLowerCase()) {
case 'web-browser-takeover':
case 'browser-navigate-to':
case 'browser-click-element':
case 'browser-input-text':
case 'browser-scroll-down':
case 'browser-scroll-up':
case 'browser-click-coordinates':
case 'browser-send-keys':
case 'browser-switch-tab':
case 'browser-go-back':
case 'browser-close-tab':
case 'browser-drag-drop':
case 'browser-get-dropdown-options':
case 'browser-select-dropdown-option':
case 'browser-scroll-to-text':
case 'browser-wait':
case 'browser-act':
case 'browser-extract-content':
case 'browser-observe':
case 'browser-screenshot':
return Globe;
// File operations
@ -207,7 +196,7 @@ export const extractPrimaryParam = (
try {
// Handle browser tools with a prefix check
if (toolName?.toLowerCase().startsWith('browser-')) {
if (toolName?.toLowerCase().startsWith('browser_')) {
// Try to extract URL for navigation
const urlMatch = content.match(/url=(?:"|')([^"|']+)(?:"|')/);
if (urlMatch) return urlMatch[1];
@ -322,21 +311,10 @@ const TOOL_DISPLAY_NAMES = new Map([
['create-tasks', 'Creating Tasks'],
['update-tasks', 'Updating Tasks'],
['browser-click-element', 'Clicking Element'],
['browser-close-tab', 'Closing Tab'],
['browser-drag-drop', 'Dragging Element'],
['browser-get-dropdown-options', 'Getting Options'],
['browser-go-back', 'Going Back'],
['browser-input-text', 'Entering Text'],
['browser-navigate-to', 'Navigating to Page'],
['browser-scroll-down', 'Scrolling Down'],
['browser-scroll-to-text', 'Scrolling to Text'],
['browser-scroll-up', 'Scrolling Up'],
['browser-select-dropdown-option', 'Selecting Option'],
['browser-click-coordinates', 'Clicking Coordinates'],
['browser-send-keys', 'Pressing Keys'],
['browser-switch-tab', 'Switching Tab'],
['browser-wait', 'Waiting'],
['browser_navigate_to', 'Navigating to Page'],
['browser_act', 'Performing Action'],
['browser_extract_content', 'Extracting Content'],
['browser_screenshot', 'Taking Screenshot'],
['execute-data-provider-call', 'Calling data provider'],
['execute_data-provider_call', 'Calling data provider'],
@ -381,21 +359,10 @@ const TOOL_DISPLAY_NAMES = new Map([
['str_replace', 'Editing Text'],
['edit_file', 'Editing File'],
['browser_click_element', 'Clicking Element'],
['browser_close_tab', 'Closing Tab'],
['browser_drag_drop', 'Dragging Element'],
['browser_get_dropdown_options', 'Getting Options'],
['browser_go_back', 'Going Back'],
['browser_input_text', 'Entering Text'],
['browser_navigate_to', 'Navigating to Page'],
['browser_scroll_down', 'Scrolling Down'],
['browser_scroll_to_text', 'Scrolling to Text'],
['browser_scroll_up', 'Scrolling Up'],
['browser_select_dropdown_option', 'Selecting Option'],
['browser_click_coordinates', 'Clicking Coordinates'],
['browser_send_keys', 'Pressing Keys'],
['browser_switch_tab', 'Switching Tab'],
['browser_wait', 'Waiting'],
['browser_act', 'Performing Action'],
['browser_extract_content', 'Extracting Content'],
['browser_screenshot', 'Taking Screenshot'],
['execute_data_provider_call', 'Calling data provider'],
['get_data_provider_endpoints', 'Getting endpoints'],

View File

@ -23,7 +23,7 @@ export const TOOL_ICONS: Record<string, any> = {
'sb_deploy_tool': Rocket,
'sb_expose_tool': Computer,
'sb_vision_tool': Eye,
'sb_browser_tool': MonitorPlay,
'stagehand_browser_tool': MonitorPlay,
'web_search_tool': Search,
'data_providers_tool': Globe,
'sb_sheets_tool': Table2,
@ -36,7 +36,7 @@ export const TOOL_COLORS: Record<string, string> = {
'sb_deploy_tool': 'from-orange-500/20 to-orange-600/10 border-orange-500/20 text-orange-500',
'sb_expose_tool': 'from-green-500/20 to-green-600/10 border-green-500/20 text-green-500',
'sb_vision_tool': 'from-blue-500/20 to-blue-600/10 border-blue-500/20 text-blue-500',
'sb_browser_tool': 'from-purple-500/20 to-purple-600/10 border-purple-500/20 text-purple-500',
'stagehand_browser_tool': 'from-purple-500/20 to-purple-600/10 border-purple-500/20 text-purple-500',
'web_search_tool': 'from-blue-500/20 to-blue-600/10 border-blue-500/20 text-blue-500',
'data_providers_tool': 'from-blue-500/20 to-blue-600/10 border-blue-500/20 text-blue-500',
'sb_sheets_tool': 'from-purple-500/20 to-purple-600/10 border-purple-500/20 text-purple-500',

View File

@ -35,7 +35,7 @@ _AgentPressTools_descriptions = {
"sb_deploy_tool": "Deploy web applications",
"sb_expose_tool": "Expose local services to the internet",
"sb_vision_tool": "Analyze and understand images",
"sb_browser_tool": "Browse websites and interact with web pages",
"stagehand_browser_tool": "Browse websites and interact with web pages using local Stagehand",
"web_search_tool": "Search the web for information",
"sb_image_edit_tool": "Edit and manipulate images",
"data_providers_tool": "Access structured data from various providers",
@ -48,7 +48,7 @@ class AgentPressTools(str, Enum):
SB_DEPLOY_TOOL = "sb_deploy_tool"
SB_EXPOSE_TOOL = "sb_expose_tool"
SB_VISION_TOOL = "sb_vision_tool"
SB_BROWSER_TOOL = "sb_browser_tool"
STAGEHAND_BROWSER_TOOL = "stagehand_browser_tool"
WEB_SEARCH_TOOL = "web_search_tool"
DATA_PROVIDERS_TOOL = "data_providers_tool"