from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any


@dataclass(frozen=True)
class ToolCall:
    subject: str
    action: str
    resource: str
    arguments: dict[str, Any] = field(default_factory=dict)
    context: dict[str, Any] = field(default_factory=dict)
    call_id: str = ""

    def as_dict(self) -> dict[str, Any]:
        return {
            "subject": self.subject,
            "action": self.action,
            "resource": self.resource,
            "arguments": self.arguments,
            "context": self.context,
            "call_id": self.call_id,
        }


@dataclass(frozen=True)
class PolicyDecision:
    effect: str
    rule_id: str
    reason: str
    evidence: dict[str, Any] = field(default_factory=dict)

    @property
    def allowed(self) -> bool:
        return self.effect == "allow"


@dataclass(frozen=True)
class ToolProposal:
    name: str
    arguments: dict[str, Any]
    call_id: str


@dataclass(frozen=True)
class ProviderResponse:
    provider: str
    model: str
    text: str
    proposals: tuple[ToolProposal, ...]
    input_tokens: int
    output_tokens: int
    raw_stop_reason: str = ""

