Load session from disk.
(cls, session_id: str)
| 80 | |
| 81 | @classmethod |
| 82 | def load(cls, session_id: str) -> Optional['Session']: |
| 83 | """Load session from disk.""" |
| 84 | session_file = Path.home() / ".clawcodex" / "sessions" / f"{session_id}.json" |
| 85 | |
| 86 | if not session_file.exists(): |
| 87 | return None |
| 88 | |
| 89 | with open(session_file, 'r') as f: |
| 90 | data = json.load(f) |
| 91 | |
| 92 | return cls( |
| 93 | session_id=data["session_id"], |
| 94 | provider=data["provider"], |
| 95 | model=data["model"], |
| 96 | conversation=Conversation.from_dict(data["conversation"]), |
| 97 | created_at=data["created_at"], |
| 98 | updated_at=data["updated_at"] |
| 99 | ) |
| 100 | |
| 101 | @classmethod |
| 102 | def create(cls, provider: str, model: str) -> 'Session': |