"""Node output models — Pydantic SSOT for every node's return shape.

ALL PYDANTIC. No dict[str, Any]. No Any.
Every field is typed with JSONValue, JsonObject, ToolArgValue, or a concrete model.
"""

from pydantic import BaseModel, Field

from core.common import JsonObject, JSONValue
from core.pathways.models.io import NodeOutputs

# =============================================================================
# PER-NODE OUTPUT MODELS (extend NodeOutputs)
# =============================================================================


class ToolExecutionResultItem(BaseModel):
    """Result of a single tool call inside LLMNode."""

    tool: str
    success: bool
    output: JSONValue = None
    error: str | None = None


class PathwayExecutionOutput(NodeOutputs):
    """Output from PathwayNode (sub-pathway execution)."""

    success: bool
    pathway_id: str
    result: JSONValue = None
    outputs: JsonObject = Field(default_factory=dict)
    error: str | None = None


class InputSignature(BaseModel):
    """Signature returned by InputNode.get_signature()."""

    inputs: JsonObject = Field(default_factory=dict)
    defaults: JsonObject = Field(default_factory=dict)
    description: str = ""


class OutputSignature(BaseModel):
    """Signature returned by OutputNode.get_signature()."""

    outputs: JsonObject = Field(default_factory=dict)
    mapping: JsonObject = Field(default_factory=dict)
    description: str = ""


__all__ = [
    "InputSignature",
    "OutputSignature",
    "PathwayExecutionOutput",
    "ToolExecutionResultItem",
]
