"""Public data shapes for the Plan layer.""" from __future__ import annotations from dataclasses import dataclass, field from typing import Any @dataclass class PlanStep: analysis: str args: dict[str, Any] = field(default_factory=dict) why: str = "" @classmethod def from_dict(cls, raw: dict[str, Any]) -> "PlanStep": return cls( analysis=raw["analysis"], args=raw.get("args") or {}, why=raw.get("why", ""), ) def to_dict(self) -> dict[str, Any]: return {"analysis": self.analysis, "args": self.args, "why": self.why} @dataclass class Plan: rationale: str steps: list[PlanStep] @classmethod def from_dict(cls, raw: dict[str, Any]) -> "Plan": return cls( rationale=raw.get("rationale", ""), steps=[PlanStep.from_dict(s) for s in raw.get("steps", [])], )