# generated by datamodel-codegen:
#   filename:  openapi.models.json
#   timestamp: 2025-12-31T23:12:12+00:00

from __future__ import annotations

from enum import StrEnum
from typing import Annotated, Any

from pydantic import (
    AnyUrl,
    AwareDatetime,
    BaseModel,
    ConfigDict,
    Field,
    RootModel,
    StrictBool,
    StrictFloat,
    StrictInt,
    StrictStr,
)


class Budgets(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    max_cost: Annotated[StrictFloat | None, Field(ge=0.0)] = None
    max_external_calls: Annotated[StrictInt | None, Field(ge=0)] = None
    max_steps: Annotated[StrictInt | None, Field(ge=0)] = None
    max_wall_time_ms: Annotated[StrictInt | None, Field(ge=0)] = None


class Candidates(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    allowed_node_type_ids: list[StrictStr] | None = None
    denied_node_type_ids: list[StrictStr] | None = None
    max_candidates_per_subtask: Annotated[StrictInt | None, Field(ge=1)] = None


class Structural(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    max_children_per_composite: Annotated[StrictInt | None, Field(ge=0)] = None
    max_decomposition_rounds_per_node: Annotated[StrictInt | None, Field(ge=0)] = None
    max_depth: Annotated[StrictInt | None, Field(ge=0)] = None
    max_total_nodes_per_run: Annotated[StrictInt | None, Field(ge=0)] = None


class EndpointLocator(RootModel[AnyUrl]):
    root: Annotated[
        AnyUrl,
        Field(
            description='Transport-agnostic locator URI for an API endpoint (e.g. http://127.0.0.1:43120). Future deployments may use other URI schemes (e.g. unix://...).',
            title='EndpointLocator',
        ),
    ]


class EvaluationStatus(StrEnum):
    success = 'success'
    fail = 'fail'
    unknown = 'unknown'


class Extensions(BaseModel):
    model_config = ConfigDict(
        extra='allow',
    )


class Metadata(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    annotations: dict[str, StrictStr] | None = None
    extensions: Extensions | None = None
    labels: dict[str, StrictStr] | None = None


class NodeKind(StrEnum):
    atomic = 'atomic'
    composite = 'composite'


class NodeRunState(StrEnum):
    queued = 'queued'
    assigned = 'assigned'
    running = 'running'
    succeeded = 'succeeded'
    failed = 'failed'
    canceled = 'canceled'


class NodeRunTerminalState(StrEnum):
    succeeded = 'succeeded'
    failed = 'failed'
    canceled = 'canceled'


class NodeTypeRef(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    node_type_id: StrictStr
    version: StrictStr


class PolicyDecisionOutcome(StrEnum):
    allow = 'allow'
    deny = 'deny'
    require_approval = 'require_approval'


class RecoveryActionType(StrEnum):
    retry = 'retry'
    remap = 'remap'
    decompose_further = 'decompose_further'
    ask_user = 'ask_user'
    abort = 'abort'


class ResourceRef(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    id: StrictStr
    type: StrictStr
    uri: AnyUrl | None = None


class Trace(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    request_id: StrictStr | None = None
    span_id: StrictStr | None = None
    trace_id: StrictStr | None = None


class RunContext(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    actor: ResourceRef | None = None
    budgets: dict[str, Any] | None = None
    extensions: Extensions | None = None
    identity: dict[str, Any] | None = None
    policy: dict[str, Any] | None = None
    tenant_id: StrictStr | None = None
    trace: Trace | None = None


class RunState(StrEnum):
    queued = 'queued'
    running = 'running'
    succeeded = 'succeeded'
    failed = 'failed'
    canceled = 'canceled'


class SideEffectClass(StrEnum):
    read = 'read'
    write = 'write'
    irreversible = 'irreversible'


class Status(StrEnum):
    ok = 'ok'
    degraded = 'degraded'
    down = 'down'


class Build(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    built_at: AwareDatetime | None = None
    commit: StrictStr | None = None
    dirty: StrictBool | None = None


class VersionInfo(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    build: Build | None = None
    extensions: Extensions | None = None
    service_name: StrictStr
    service_version: StrictStr
    supported_api_versions: Annotated[list[StrictStr], Field(min_length=1)]


class ApprovalRef(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    approval_id: StrictStr
    extensions: Extensions | None = None
    uri: AnyUrl | None = None


class BindingDecision(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    candidate_set_id: StrictStr | None = None
    chosen_node_type_ref: NodeTypeRef
    extensions: Extensions | None = None
    rationale: StrictStr | None = None
    subtask_id: StrictStr


class CompositeBeginResponse(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    accepted: StrictBool
    extensions: Extensions | None = None
    message: StrictStr | None = None


class Gates(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    require_approval: StrictBool | None = None
    side_effect_class: SideEffectClass | None = None


class ConstraintEnvelope(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    budgets: Budgets | None = None
    candidates: Candidates | None = None
    extensions: Extensions | None = None
    gates: Gates | None = None
    structural: Structural | None = None


class ErrorCause(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    code: StrictStr | None = None
    details: dict[str, Any] | None = None
    extensions: Extensions | None = None
    message: StrictStr


class EvaluationResult(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    confidence: Annotated[StrictFloat | None, Field(ge=0.0, le=1.0)] = None
    details: dict[str, Any] | None = None
    extensions: Extensions | None = None
    message: StrictStr | None = None
    reason_code: StrictStr | None = None
    status: EvaluationStatus


class ExecutorBinding(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    audience: StrictStr | None = None
    endpoint: EndpointLocator
    executor_instance_id: StrictStr
    extensions: Extensions | None = None


class Check(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    details: dict[str, Any] | None = None
    message: StrictStr | None = None
    name: StrictStr
    status: Status


class Health(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    checks: list[Check] | None = None
    extensions: Extensions | None = None
    status: Status
    time: AwareDatetime


class NodeRunCreateSpec(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    binding_decision: BindingDecision | None = None
    candidate_set_id: StrictStr | None = None
    constraints: ConstraintEnvelope | None = None
    extensions: Extensions | None = None
    idempotency_key: StrictStr | None = None
    inputs: dict[str, Any]
    metadata: Metadata | None = None
    node_type_ref: NodeTypeRef
    requested_executor_instance_id: StrictStr | None = None


class NodeRunsCreateRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    node_runs: Annotated[list[NodeRunCreateSpec], Field(min_length=1)]
    parent_node_run_id: StrictStr
    run_id: StrictStr


class NodeType(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    constraints: ConstraintEnvelope | None = None
    description: StrictStr | None = None
    evaluation: dict[str, Any] | None = None
    extensions: Extensions | None = None
    input_schema: dict[str, Any] | None = None
    kind: NodeKind
    metadata: Metadata | None = None
    node_type_id: StrictStr
    output_schema: dict[str, Any] | None = None
    preferred_executor_types: list[StrictStr] | None = None
    version: StrictStr


class NodeTypePublishRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    node_type: NodeType


class PolicyDecision(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    approval_ref: ApprovalRef | None = None
    decision: PolicyDecisionOutcome
    extensions: Extensions | None = None
    message: StrictStr | None = None
    metadata: Metadata | None = None
    reason_code: StrictStr | None = None


class PolicyDecisionRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    action: StrictStr
    constraints: ConstraintEnvelope | None = None
    context: dict[str, Any] | None = None
    extensions: Extensions | None = None
    node_run_id: StrictStr | None = None
    node_type_ref: NodeTypeRef | None = None
    run_context: RunContext | None = None
    run_id: StrictStr | None = None


class RecoveryAction(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    message: StrictStr | None = None
    target_node_run_id: StrictStr | None = None
    target_node_type_ref: NodeTypeRef | None = None
    type: RecoveryActionType


class Run(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    ended_at: AwareDatetime | None = None
    extensions: Extensions | None = None
    root_node_run_id: StrictStr
    run_context: RunContext | None = None
    run_id: StrictStr
    started_at: AwareDatetime | None = None
    state: RunState


class RunStartRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    constraints: ConstraintEnvelope | None = None
    extensions: Extensions | None = None
    input: dict[str, Any]
    metadata: Metadata | None = None
    root_node_type_ref: NodeTypeRef
    run_context: RunContext | None = None
    run_id: StrictStr | None = None


class SubtaskSpec(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    constraints: ConstraintEnvelope | None = None
    expected_output_schema: dict[str, Any] | None = None
    extensions: Extensions | None = None
    goal: StrictStr
    metadata: Metadata | None = None
    subtask_id: StrictStr


class AtomicExecuteRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    constraints: ConstraintEnvelope | None = None
    extensions: Extensions | None = None
    inputs: dict[str, Any]
    node_run_id: StrictStr
    node_type_ref: NodeTypeRef
    run_context: RunContext | None = None
    run_id: StrictStr


class Candidate(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    constraints: ConstraintEnvelope | None = None
    extensions: Extensions | None = None
    metadata: Metadata | None = None
    node_type_ref: NodeTypeRef
    rationale: StrictStr | None = None
    score: StrictFloat | None = None


class CandidateSet(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    candidate_set_id: StrictStr
    candidates: list[Candidate]
    constraints: ConstraintEnvelope | None = None
    extensions: Extensions | None = None
    generated_at: AwareDatetime | None = None
    subtask_id: StrictStr
    top_k: Annotated[StrictInt | None, Field(ge=1)] = None


class CandidateSetRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    constraints: ConstraintEnvelope | None = None
    extensions: Extensions | None = None
    run_context: RunContext | None = None
    subtask_spec: SubtaskSpec


class CompositeBeginRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    assignment_token: StrictStr | None = None
    constraints: ConstraintEnvelope | None = None
    coordinator_endpoint: EndpointLocator
    extensions: Extensions | None = None
    inputs: dict[str, Any]
    node_run_id: StrictStr
    node_type_ref: NodeTypeRef
    run_context: RunContext | None = None
    run_id: StrictStr


class Error(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    cause: ErrorCause | None = None
    code: StrictStr
    details: dict[str, Any] | None = None
    extensions: Extensions | None = None
    message: StrictStr
    retryable: StrictBool | None = None


class ErrorEnvelope(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    error: Error
    extensions: Extensions | None = None


class NodeRun(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    created_at: AwareDatetime | None = None
    ended_at: AwareDatetime | None = None
    evaluation_result: EvaluationResult | None = None
    executor_binding: ExecutorBinding | None = None
    extensions: Extensions | None = None
    inputs: dict[str, Any] | None = None
    kind: NodeKind | None = None
    node_run_id: StrictStr
    node_type_ref: NodeTypeRef
    output_artifacts: list[ResourceRef] | None = None
    outputs: dict[str, Any] | None = None
    parent_node_run_id: StrictStr | None = None
    recovery_actions: list[RecoveryAction] | None = None
    run_id: StrictStr
    started_at: AwareDatetime | None = None
    state: NodeRunState


class NodeRunCompleteRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    error: Error | None = None
    extensions: Extensions | None = None
    output_artifacts: list[ResourceRef] | None = None
    outputs: dict[str, Any] | None = None
    state: NodeRunTerminalState


class NodeRunEvaluationReportRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    evaluation_result: EvaluationResult
    extensions: Extensions | None = None
    recovery_action: RecoveryAction | None = None


class NodeRunsCreateResponse(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    node_runs: list[NodeRun]


class AtomicExecuteResult(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    ended_at: AwareDatetime | None = None
    error: Error | None = None
    extensions: Extensions | None = None
    node_run_id: StrictStr
    output_artifacts: list[ResourceRef] | None = None
    outputs: dict[str, Any] | None = None
    started_at: AwareDatetime | None = None
    state: NodeRunState
