from __future__ import annotations import json from pathlib import Path from typing import Any def write_run_artifact(output_dir: str | Path, artifact: dict[str, Any]) -> Path: destination = Path(output_dir) destination.mkdir(parents=True, exist_ok=True) artifact_path = destination / "run-artifact.json" artifact_path.write_text( json.dumps(artifact, ensure_ascii=False, indent=2), encoding="utf-8", ) return artifact_path