import os import json import zipfile def generate_course_zip(plan, sources, out_dir="/tmp/course_agent"): """Generate a zip package containing the course plan and sources.""" os.makedirs(out_dir, exist_ok=True) plan_path = os.path.join(out_dir, "plan.txt") with open(plan_path, "w") as f: f.write(plan) sources_path = os.path.join(out_dir, "sources.json") with open(sources_path, "w") as f: json.dump(sources, f) zip_path = os.path.join(out_dir, "course.zip") with zipfile.ZipFile(zip_path, "w") as zf: zf.write(plan_path, arcname="plan.txt") zf.write(sources_path, arcname="sources.json") return zip_path