File size: 1,616 Bytes
24480a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
backend/api/bootstrap_tools.py — Inizializza e registra i tool predefiniti all'avvio.
"""
import logging
from .tool_engine import tool_registry, ToolDescriptor

_logger = logging.getLogger("api.bootstrap_tools")

async def bootstrap_all_tools():
    """
    Registra i tool fondamentali nel ToolEngine.
    Questi tool diventano capability disponibili per il Brain.
    """
    tools = [
        ToolDescriptor(
            name="web_search",
            description="Cerca informazioni sul web in tempo reale",
            provider_id="hf-space-1",
            input_schema={"type": "object", "properties": {"query": {"type": "string"}}},
            tags=["search", "web"]
        ),
        ToolDescriptor(
            name="python_interpreter",
            description="Esegue codice Python in una sandbox sicura",
            provider_id="oracle-cloud-vm-01",
            input_schema={"type": "object", "properties": {"code": {"type": "string"}}},
            tags=["code", "sandbox"]
        ),
        ToolDescriptor(
            name="vision_analysis",
            description="Analizza immagini e screenshot tramite OCR e modelli Vision",
            provider_id="hf-space-2",
            input_schema={"type": "object", "properties": {"image_url": {"type": "string"}}},
            tags=["vision", "ocr"]
        )
    ]
    
    for tool in tools:
        try:
            await tool_registry.register(tool, force=True)
        except Exception as e:
            _logger.error(f"Errore registrazione tool {tool.name}: {e}")

    _logger.info(f"Bootstrap completato: {len(tools)} tool registrati.")