deploy
This commit is contained in:
33
agent.py
33
agent.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user