import json def parse_json_lines(output: str) -> list[dict]: """Parse NDJSON mixed with human-readable log lines: each line that starts with '{' is treated as a JSON object, everything else is ignored. Used to pull the structured candidate lines out of a pipeline script's stdout.""" out = [] for line in output.splitlines(): line = line.strip() if not line.startswith("{"): continue try: out.append(json.loads(line)) except json.JSONDecodeError: continue return out