from __future__ import annotations

from datetime import datetime
from typing import Any

from pydantic import BaseModel, Field

from ai_orchestrator.schemas.task_state import utc_now
from ai_orchestrator.schemas.workflow_models import StructuredError


class ToolResult(BaseModel):
    success: bool
    stdout: str = ""
    stderr: str = ""
    exit_code: int | None = None
    command: str | None = None
    timed_out: bool = False
    started_at: datetime = Field(default_factory=utc_now)
    completed_at: datetime = Field(default_factory=utc_now)
    data: dict[str, Any] = Field(default_factory=dict)
    structured_errors: list[StructuredError] = Field(default_factory=list)
