(session: StoredSession, directory: Path | None = None)
| 17 | |
| 18 | |
| 19 | def save_session(session: StoredSession, directory: Path | None = None) -> Path: |
| 20 | target_dir = directory or DEFAULT_SESSION_DIR |
| 21 | target_dir.mkdir(parents=True, exist_ok=True) |
| 22 | path = target_dir / f'{session.session_id}.json' |
| 23 | path.write_text(json.dumps(asdict(session), indent=2)) |
| 24 | return path |
| 25 | |
| 26 | |
| 27 | def load_session(session_id: str, directory: Path | None = None) -> StoredSession: |