"""Response contracts without imposing new assumptions on upstream JSON. Only fields constructed by this service have concrete types. Upstream-owned values remain Any, and unknown fields remain allowed at every modeled level. Responses are validated but serialized from their original payloads so omitted fields, numeric representations, key order, and unknown values stay unchanged. """ from typing import Any, Literal from pydantic import BaseModel, ConfigDict, RootModel class OpenResponse(BaseModel): model_config = ConfigDict(extra="allow", strict=True) class ConfigResponse(OpenResponse): mcp: bool = False search: bool lb: bool allowDirect: bool s2sUrl: str primaryPrompt: str reasoningType: Literal["PROXY", "OPENAI"] injectProfile: bool debugPrompt: bool startSessionMode: str theme: str class SearchResult(OpenResponse): # Serper values have historically passed through, including nulls, numbers, # and objects. The service guarantees these keys, not their value types. title: Any snippet: Any url: Any class SearchResponse(OpenResponse): query: str answer: Any results: list[SearchResult] class ReportEntry(OpenResponse): sourceScheduleLabel: Any date: Any class ReportsResponse(OpenResponse): count: int wrappedLen: int hints: list[str] entries: list[ReportEntry] rawCount: int | None = None cap: int | None = None skipped: bool | None = None reason: str | None = None truncated: bool | None = None note: str | None = None class ReasoningResponse(OpenResponse): answer: str class AllocationResponse(OpenResponse): """LB-owned object: no new required fields or value-type restrictions.""" state: Any = None session_id: Any = None connect_url: Any = None pending_timeout_s: Any = None queue_id: Any = None position: Any = None poll_interval_s: Any = None class UserProfileResponse(RootModel[Any]): """The profile endpoint relays objects, arrays, scalars, and null verbatim.""" class QueueCancellationResponse(OpenResponse): ok: bool