Vocero needs to query AquaPortal on behalf of the caller selected by the existing phone link. This adds server-owned conversations and MCP tool execution for voice and HTTP reasoning while leaving the speech pipeline unchanged. Release notes: - Added browser-bound conversations that keep backend credentials server-side and isolate callers. - Connected the eight-tool AquaPortal catalog through authenticated Streamable HTTP with full input schemas and structured results. - Added bounded multi-step tool execution with cancellation, expiry, and stale-result protection. - Updated browser bootstrap, tool progress, reasoning headers, and conversation cleanup. - Disabled legacy unscoped content preloads in MCP mode and documented configuration and deployment constraints. - Preserved disabled-mode contracts and added local SDK, WebSocket, and browser regression coverage. Reviewed-on: AquaPortal/s2s#1
22 lines
1.0 KiB
Python
22 lines
1.0 KiB
Python
"""Resolve the phone selector once, keeping the backend credential server-side."""
|
|
|
|
import httpx
|
|
from pydantic import ValidationError
|
|
|
|
from vocero_api.core import config as settings
|
|
from vocero_api.models.mcp import BackendLogin, IntegrationError
|
|
|
|
|
|
async def login(phone_number: str) -> BackendLogin:
|
|
if not settings.S2S_LOGIN_BY_PHONE:
|
|
raise IntegrationError(503, "El acceso por teléfono no está configurado.")
|
|
try:
|
|
async with httpx.AsyncClient(timeout=10, follow_redirects=False) as client:
|
|
response = await client.post(settings.S2S_LOGIN_BY_PHONE, json={"phoneNumber": phone_number})
|
|
if response.status_code in {401, 403, 404, 422}:
|
|
raise IntegrationError(401, "No se pudo iniciar sesión con este número de teléfono.")
|
|
response.raise_for_status()
|
|
return BackendLogin.model_validate(response.json())
|
|
except (httpx.HTTPError, ValidationError, ValueError) as exc:
|
|
raise IntegrationError(502, "No se pudo validar la sesión con AquaPortal.") from exc
|