Coverage for app / router / app / tools / router.py: 100%
21 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-10-31 11:21 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-10-31 11:21 +0000
1"""
2Built-in tool discovery.
4svc-ai's registry is the only tool catalogue there is. There was once a `Tool`
5resource here too — a row naming a built-in or a webhook URL — but its entries
6never reached an invocation: every consumer required an ``implementation``
7prefixed ``builtin:`` or ``http``, and the only writer stored the bare name. So
8this router is a read-only proxy: built-ins are platform capabilities bound to
9every agent by svc-ai, and the one thing a user picks from them is which tool a
10skill-graph node calls.
11"""
13import logging
14from typing import Any
16from fastapi import APIRouter, HTTPException, status
17from pydantic import BaseModel
19from app.services.ai_client import AIServiceError, list_tools
21logger = logging.getLogger(__name__)
23tool_router = APIRouter(prefix="/tools", tags=["App - Tools"])
26class AvailableToolInfo(BaseModel):
27 name: str
28 description: str
29 schema: dict[str, Any]
32class AvailableToolsResponse(BaseModel):
33 tools: list[AvailableToolInfo]
36@tool_router.get("/available", response_model=AvailableToolsResponse)
37def get_available_tools():
38 """Return built-in tools available in svc-ai for selection."""
39 try:
40 raw = list_tools()
41 except AIServiceError as exc:
42 logger.error("Could not fetch tools from svc-ai: %s", exc)
43 raise HTTPException(
44 status_code=status.HTTP_502_BAD_GATEWAY,
45 detail="Could not reach svc-ai to list available tools.",
46 )
47 return AvailableToolsResponse(tools=[AvailableToolInfo(**t) for t in raw])