========== YENİ KOMUT | 23.09.2026 13:28:18 ==========
def validate(request: Mapping[str, Any]) -> Dict[str, Any]:
if not isinstance(request, Mapping) or request.get("schema") != REQUEST_SCHEMA:
raise ValueError(f"request.schema must be {REQUEST_SCHEMA}")
unknown = set(request) - {"schema", "goal", "observation_id", "regions", "history", "candidates"}
if unknown:
raise ValueError(f"unsupported request fields: {sorted(unknown)}")
regions = request.get("regions") or []
if not isinstance(regions, list) or len(regions) > MAX_REGIONS:
raise ValueError(f"regions must be a list of at most {MAX_REGIONS}")
clean_regions: List[Dict[str, Any]] = []
for region in regions:
if not isinstance(region, Mapping) or not set(region) <= {"id", "role", "label", "interactive"}:
raise ValueError("a region may contain only id, role, label and interactive")
clean_regions.append({"id": _text(region.get("id"), "region id", 128),
"role": _text(region.get("role", "element"), "region role", 64),
"label": _text(region.get("label"), "region label", 300),
"interactive": bool(region.get("interactive", False))})
history = request.get("history") or []
if not isinstance(history, list) or len(history) > MAX_HISTORY:
raise ValueError(f"history must be a list of at most {MAX_HISTORY}")
clean_history = []
root@213-238-170-219:/home/hermes#