Spaces:
Sleeping
Sleeping
Philippe commited on
Commit ·
39b89ab
1
Parent(s): d76a30d
ƒñû Ajout Browser MCP - Navigation web intelligente
Browse files309 unmodified lines31031131231331431531617 unmodified lines33433533633733833934034134240 unmodified lines3833843853863873883893903913923933943953961 unmodified line398399400401402403404309 unmodified linesreturn# 🤖 Détecter les commandes Browser MCPif text.startswith("/browse ") or text.startswith("/web "):await handle_browser_command(sid, room, name, text)return17 unmodified linesargs = parts[2] if len(parts) > 2 else ""try:if command.startswith("http"):# Navigation vers URLresult = await browser_mcp.call_tool("navigate_to_url", {"url": command})# Auto-capture d'écran après navigationif "✅" in result:40 unmodified lineselif command == "help":result = """🌐 **Commandes Browser MCP disponibles:**• `/browse <url>` - Naviguer vers une URL• `/web screenshot` - Capture d'écran• `/web text [selector]` - Extraire le texte• `/web click <selector>` - Cliquer sur un élément• `/web fill <selector>=<value>` - Remplir un champ• `/web info` - Infos de la page• `/web search <text>` - Rechercher du texte• `/web links` - Extraire les liens• `/web wait <selector>` - Attendre un élément• `/web help` - Cette aide"""1 unmodified lineresult = f"❌ Commande inconnue: {command}. Tapez '/web help' pour l'aide."except Exception as e:result = f"❌ Erreur Browser MCP: {str(e)}"# Envoyer la réponseresponse_msg = {"type": "message", "name": "🤖 Browser", "text": result, "ts": time.time()}309 unmodified lines31031131231331431531617 unmodified lines33433533633733833934034134234340 unmodified lines3843853863873883893903913923933943953963971 unmodified line399400401402403404405406407408309 unmodified linesreturn# 🤖 Détecter les commandes Browser MCPif text.startswith("/browse ") or text.startswith("/browser ") or text.startswith("/web "):await handle_browser_command(sid, room, name, text)return17 unmodified linesargs = parts[2] if len(parts) > 2 else ""try:if command.startswith("http") or text.startswith("/browser "):# Navigation vers URL (supporter /browser et /browse)url = command if command.startswith("http") else commandresult = await browser_mcp.call_tool("navigate_to_url", {"url": url})# Auto-capture d'écran après navigationif "✅" in result:40 unmodified lineselif command == "help":result = """🌐 **Commandes Browser MCP disponibles:**• `/browse <url>` ou `/browser <url>` - Naviguer vers une URL• `/web screenshot` - Capture d'écran• `/web text [selector]` - Extraire le texte• `/web click <selector>` - Cliquer sur un élément• `/web fill <selector>=<value>` - Remplir un champ• `/web info` - Infos de la page• `/web search <text>` - Rechercher du texte• `/web links` - Extrairer les liens• `/web wait <selector>` - Attendre un élément• `/web help` - Cette aide"""1 unmodified lineresult = f"❌ Commande inconnue: {command}. Tapez '/web help' pour l'aide."except Exception as e:import tracebackerror_details = traceback.format_exc()print(f"❌ Browser MCP Error: {error_details}")result = f"❌ Erreur lors de l'appel MCP: {str(e)}"# Envoyer la réponseresponse_msg = {"type": "message", "name": "🤖 Browser", "text": result, "ts": time.time()}
app.py+11-7