This commit is contained in:
a2a-platform
2026-06-27 16:57:46 +00:00
parent 35739c9ab8
commit 6fa8ee19fa
3 changed files with 35 additions and 4 deletions

View File

@@ -129,7 +129,7 @@ class BrowserToApiAgent(A2AAgent[BrowserToApiConfig, NoAuth]):
"SeleniumBase-style browser agent that turns observed website traffic "
"into OpenAPI specs, coverage reports, samples, and a replay client."
)
version = "0.2.5"
version = "0.2.6"
config_model = BrowserToApiConfig
auth_model = NoAuth
@@ -1610,6 +1610,37 @@ def _parse_maybe_json(value: Any) -> Any:
return text[:100_000]
def _parse_json_object(value: Any) -> dict[str, Any] | None:
if isinstance(value, dict):
return value
if not isinstance(value, str):
return None
text = value.strip()
if not text:
return None
parsed = _try_json_object(text)
if parsed is not None:
return parsed
fenced = re.search(r"```(?:json)?\s*(\{.*?\})\s*```", text, flags=re.DOTALL | re.IGNORECASE)
if fenced:
parsed = _try_json_object(fenced.group(1))
if parsed is not None:
return parsed
start = text.find("{")
end = text.rfind("}")
if start >= 0 and end > start:
return _try_json_object(text[start : end + 1])
return None
def _try_json_object(text: str) -> dict[str, Any] | None:
try:
parsed = json.loads(text)
except Exception:
return None
return parsed if isinstance(parsed, dict) else None
def _json_loads(line: str) -> Any:
try:
return json.loads(line)