Spaces:
Runtime error
Runtime error
| """Data models for the Smart Contract Audit Environment.""" | |
| from typing import List, Dict, Optional | |
| from openenv.core.env_server.types import Action, Observation, State | |
| from pydantic import Field | |
| class AuditAction(Action): | |
| """What the agent sends to the environment""" | |
| analysis: str = Field(..., description="Full vulnerability report text") | |
| vulnerabilities: List[Dict] = Field(default_factory=list, description="[{type, line, severity, description}]") | |
| suggested_fixes: List[str] = Field(default_factory=list, description="Recommended code fixes") | |
| class AuditObservation(Observation): | |
| """What the environment returns to the agent""" | |
| contract_code: str = Field(..., description="Solidity source code to audit") | |
| contract_name: str = Field(..., description="Name of the contract") | |
| task_id: str = Field(..., description="easy_reentrancy / medium_multi_vuln / ...") | |
| task_description: str = Field(..., description="Human-readable task instructions") | |
| hint: str = Field(default="", description="Optional hint for the agent") | |
| feedback: str = Field(default="", description="Grader feedback from previous step") | |
| reward: float = Field(default=0.0, description="0.0 to 1.0") | |
| done: bool = Field(default=False, description="Episode complete?") | |
| class AuditState(State): | |
| """Episode metadata""" | |
| episode_id: str = Field(..., description="Unique episode identifier") | |
| step_count: int = Field(default=0, description="Current step number") | |
| current_task: str = Field(..., description="ID of the current task") | |
| max_steps: int = Field(default=5, description="Maximum allowed steps") | |
| total_reward: float = Field(default=0.0, description="Cumulative reward earned") | |