| from __future__ import annotations |
| from pathlib import Path |
| import json, shutil |
| from src.core.models import JobConfig, dataclass_to_dict |
|
|
| class OfflineExportAgent: |
| name = "export_agent" |
|
|
| def run(self, final_pdf: Path, job_config: JobConfig, stages: list, log_file: Path) -> tuple[Path, Path]: |
| out = job_config.output_dir |
| out.mkdir(parents=True, exist_ok=True) |
| dest = out / f"{job_config.input_pdf.stem}-final.pdf" |
| if final_pdf.resolve() != dest.resolve(): |
| shutil.copy2(final_pdf, dest) |
| manifest = { |
| "job_config": dataclass_to_dict(job_config), |
| "stages": stages, |
| "final_pdf": str(dest), |
| "log_file": str(log_file), |
| } |
| mf = out / "manifest.json" |
| with mf.open("w", encoding="utf-8") as f: |
| json.dump(manifest, f, indent=2) |
| return dest, mf |
|
|