# generated by datamodel-codegen:
#   filename:  openapi.models.json
#   timestamp: 2025-12-24T08:06:10+00:00

from __future__ import annotations

from datetime import datetime
from enum import Enum
from typing import Any, Dict, List

from pydantic import (
    AnyUrl,
    BaseModel,
    ConfigDict,
    Field,
    RootModel,
    StrictBool,
    StrictStr,
    conint,
)


class EndpointLocator(RootModel[AnyUrl]):
    root: 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 Extensions(BaseModel):
    pass
    model_config = ConfigDict(
        extra='allow',
    )


class Overrides(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    args: List[StrictStr] | None = None
    env: Dict[str, StrictStr] | None = None
    tool_registry_url: EndpointLocator | None = None


class InstanceState(Enum):
    starting = 'starting'
    ready = 'ready'
    busy = 'busy'
    stopping = 'stopping'
    stopped = 'stopped'
    error = 'error'


class Level(Enum):
    debug = 'debug'
    info = 'info'
    warn = 'warn'
    error = 'error'


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 Pagination(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    next_page_token: StrictStr | None = None
    page_size: conint(ge=1, le=1000, strict=True) | None = None


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


class Input(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    context: Dict[str, Any] | None = None
    data: Dict[str, Any] | None = None
    goal: StrictStr


class Limits(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    max_steps: conint(ge=1, strict=True) | None = None
    max_tokens: conint(ge=1, strict=True) | None = None
    timeout_ms: conint(ge=0, strict=True) | None = None


class RuntimeSelector(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    instance_id: StrictStr | None = None
    runtime_api_endpoint: EndpointLocator | None = None
    runtime_name: StrictStr | None = None
    runtime_profile: StrictStr | None = None


class ToolPolicy(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    allow_tool_ids: List[StrictStr] | None = None
    deny_tool_ids: List[StrictStr] | None = None


class RunRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    input: Input
    limits: Limits | None = None
    metadata: Metadata | None = None
    run_id: StrictStr | None = None
    runtime_selector: RuntimeSelector | None = None
    tool_policy: ToolPolicy | None = None


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


class RunStatus(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    ended_at: datetime | None = None
    extensions: Extensions | None = None
    run_id: StrictStr
    runtime_instance_id: StrictStr | None = None
    started_at: datetime | None = None
    state: RunState


class RuntimeInstance(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    instance_id: StrictStr
    managed: StrictBool | None = True
    metadata: Metadata | None = None
    runtime_api_endpoint: EndpointLocator
    runtime_name: StrictStr | None = None
    runtime_profile: StrictStr | None = None
    runtime_version: StrictStr | None = None
    state: InstanceState


class Defaults(Overrides):
    pass


class RuntimeProfile(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    defaults: Defaults | None = None
    description: StrictStr | None = None
    extensions: Extensions | None = None
    metadata: Metadata | None = None
    runtime_name: StrictStr | None = None
    runtime_profile: StrictStr


class RuntimeProfileListResponse(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    pagination: Pagination | None = None
    profiles: List[RuntimeProfile]


class RuntimeProfileUpsertRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    defaults: Defaults | None = None
    description: StrictStr | None = None
    extensions: Extensions | None = None
    metadata: Metadata | None = None
    runtime_name: StrictStr | None = None


class Source(Enum):
    registry_local = 'registry_local'
    remote = 'remote'


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


class ToolDefinition(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    description: StrictStr | None = None
    extensions: Extensions | None = None
    input_schema: Dict[str, Any]
    metadata: Metadata | None = None
    name: StrictStr
    output_schema: Dict[str, Any] | None = None
    source: Source
    tool_id: StrictStr


class ToolInvocationRequest1(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    args: Dict[str, Any]
    caller: ResourceRef | None = None
    context: Dict[str, Any] | None = None
    extensions: Extensions | None = None
    invocation_id: StrictStr
    tool_id: StrictStr
    tool_name: StrictStr | None = None


class ToolInvocationRequest2(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    args: Dict[str, Any]
    caller: ResourceRef | None = None
    context: Dict[str, Any] | None = None
    extensions: Extensions | None = None
    invocation_id: StrictStr
    tool_id: StrictStr | None = None
    tool_name: StrictStr


class ToolInvocationRequest(RootModel[ToolInvocationRequest1 | ToolInvocationRequest2]):
    root: ToolInvocationRequest1 | ToolInvocationRequest2 = Field(
        ..., title='ToolInvocationRequest'
    )


class TraceEvent(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    data: Dict[str, Any] | None = None
    extensions: Extensions | None = None
    level: Level
    run_id: StrictStr
    seq: conint(ge=0, strict=True)
    time: datetime
    type: StrictStr


class TraceResponse(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    events: List[TraceEvent] | None = None
    extensions: Extensions | None = None
    trace_uri: AnyUrl | None = None


class Type(Enum):
    token = 'token'
    step = 'step'
    tool_call = 'tool_call'
    tool_result = 'tool_result'
    final = 'final'
    error = 'error'


class Build(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    built_at: datetime | 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: List[StrictStr] = Field(..., min_length=1)


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 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: datetime


class InstanceCreateRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    count: conint(ge=1, strict=True) | None = 1
    extensions: Extensions | None = None
    metadata: Metadata | None = None
    overrides: Overrides | None = None
    runtime_profile: StrictStr


class InstanceCreateResponse(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    instances: List[RuntimeInstance]


class InstanceListResponse(InstanceCreateResponse):
    pass


class InstanceRegisterRequest(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    metadata: Metadata | None = None
    runtime_api_endpoint: EndpointLocator
    runtime_name: StrictStr | None = None
    runtime_profile: StrictStr | None = None


class InstanceRegisterResponse(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    instance: RuntimeInstance


class RunEvent(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    data: Dict[str, Any] | None = None
    extensions: Extensions | None = None
    run_id: StrictStr
    seq: conint(ge=0, strict=True)
    time: datetime
    type: Type


class RunListResponse(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    extensions: Extensions | None = None
    pagination: Pagination | None = None
    runs: List[RunStatus]


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 RunResult(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    artifacts: List[ResourceRef] | None = None
    error: Error | None = None
    extensions: Extensions | None = None
    ok: StrictBool
    output: Dict[str, Any] | None = None
    run_id: StrictStr
    usage: Dict[str, Any] | None = None


class ToolInvocationResult(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    duration_ms: conint(ge=0, strict=True) | None = None
    error: Error | None = None
    extensions: Extensions | None = None
    invocation_id: StrictStr
    ok: StrictBool
    result: Dict[str, Any] | None = None
