INNER CODE UNIT · Python
events
Fausto-404/js-reverse-automation--skill · js-reverse-automation/scripts/adversarial_diff.py:18
def events(value: dict) -> list[dict]:
state = value.get("state") if isinstance(value, dict) else {}
raw = state.get("events", []) if isinstance(state, dict) else []
return [item for item in raw if isinstance(item, dict)]
def summarize(items: list[dict]) -> dict:
types = Counter(str(item.get("type", "unknown")) for item in items)
paths = Counter(str(item.get("path")) for item in items if item.get("path"))
return {
"events": len(items),
"types": dict(sorted(types.items())),
"paths": dict(sorted(paths.items())),
"requests": sum(count for name, count in types.items() if name.startswith("network.")),
"errors": sum(count for name, count in types.items() if "error" in name or "reject" in name),
"interventions": sum(count for name, count in types.items() if name.startswith("intervention.")),
}