File size: 668 Bytes
cc15101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from .search import search
from .calculator import calculate
from .code_runner import run_code
from .files import file_op
from server.safety.toolguard import screen_tool_call

TOOLS = {
    "search": search,
    "calc":   calculate,
    "code":   run_code,
    "file":   file_op,
}


def dispatch(tool_name: str, args: str) -> str:
    # Phase W: screen + audit every tool call before it runs.
    allowed, message = screen_tool_call(tool_name, args)
    if not allowed:
        return message
    fn = TOOLS.get(tool_name.lower())
    if fn is None:
        return f"Unknown tool '{tool_name}'. Available: {', '.join(TOOLS)}"
    return fn(args)