from abc import ABC, abstractmethod from dataclasses import dataclass, field from models import RunStatus @dataclass class RunContext: work_dir: str # path inside container task_prompt: str # full task description for the agent success_cmd: str # command to verify success time_limit_s: int = 300 token_limit: int = 200000 repo_url: str = "" # repo URL for host-side adapters (e.g. ClaudeCode) repo_ref: str = "main" # git branch/tag to clone @dataclass class RunResult: status: RunStatus duration_s: float = 0.0 tokens_input: int = 0 tokens_output: int = 0 cost_usd: float = 0.0 tests_total: int = 0 tests_passed: int = 0 diff_text: str = "" trajectory: list = field(default_factory=list) errors_count: int = 0 tool_calls: int = 0 raw_output: str = "" class AgentAdapter(ABC): def __init__(self, config: dict = None): self.config = config or {} @abstractmethod def name(self) -> str: ... @abstractmethod async def run(self, ctx: RunContext, sandbox) -> RunResult: """Run the agent in the given sandbox. sandbox is a core.sandbox.Sandbox instance.""" ... @abstractmethod def is_available(self) -> bool: ...