# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
# DO NOT EDIT: Generated by `generate_schema_typing` from `genkit-schema.json`.

"""Schema types module defining the core data models for Genkit."""

from __future__ import annotations

import warnings
from typing import Any, ClassVar, Literal

from pydantic import ConfigDict, Field, RootModel
from pydantic.alias_generators import to_camel

from genkit._core._base import GenkitModel
from genkit._core._compat import StrEnum

warnings.filterwarnings(
    'ignore', message='Field name "schema" in "OutputConfig" shadows an attribute in parent', category=UserWarning
)


class AgentFinishReason(StrEnum):
    """AgentFinishReason data type class."""

    STOP = 'stop'
    LENGTH = 'length'
    BLOCKED = 'blocked'
    INTERRUPTED = 'interrupted'
    OTHER = 'other'
    UNKNOWN = 'unknown'
    ABORTED = 'aborted'
    DETACHED = 'detached'
    FAILED = 'failed'


class AgentStateManagement(StrEnum):
    """AgentStateManagement data type class."""

    SERVER = 'server'
    CLIENT = 'client'


class JsonPatchOp(StrEnum):
    """JsonPatchOp data type class."""

    ADD = 'add'
    REMOVE = 'remove'
    REPLACE = 'replace'
    MOVE = 'move'
    COPY = 'copy'
    TEST = 'test'


class SnapshotStatus(StrEnum):
    """SnapshotStatus data type class."""

    PENDING = 'pending'
    COMPLETED = 'completed'
    ABORTED = 'aborted'
    FAILED = 'failed'
    EXPIRED = 'expired'


class EvalStatusEnum(StrEnum):
    """EvalStatusEnum data type class."""

    UNKNOWN = 'UNKNOWN'
    PASS = 'PASS'
    FAIL = 'FAIL'


class FinishReason(StrEnum):
    """FinishReason data type class."""

    STOP = 'stop'
    LENGTH = 'length'
    BLOCKED = 'blocked'
    INTERRUPTED = 'interrupted'
    OTHER = 'other'
    UNKNOWN = 'unknown'


class Role(StrEnum):
    """Role data type class."""

    SYSTEM = 'system'
    USER = 'user'
    MODEL = 'model'
    TOOL = 'tool'


class Schema(GenkitModel):
    """Model for schema data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)


class ConfigSchema(GenkitModel):
    """Model for configschema data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)


Metadata = dict[str, Any]  # type alias for flexible metadata

Custom = dict[str, Any]  # type alias for flexible custom data


class AgentAbortRequest(GenkitModel):
    """Model for agentabortrequest data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    snapshot_id: str = Field(...)


class AgentAbortResponse(GenkitModel):
    """Model for agentabortresponse data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    snapshot_id: str = Field(...)
    status: SnapshotStatus | None = None


class AgentInit(GenkitModel):
    """Model for agentinit data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    session_id: str | None = None
    snapshot_id: str | None = None
    state: SessionState | None = None


class AgentInput(GenkitModel):
    """Model for agentinput data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    detach: bool | None = None
    message: MessageData | None = None
    resume: Resume | None = None


class AgentMetadata(GenkitModel):
    """Model for agentmetadata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    state_management: AgentStateManagement = Field(...)
    abortable: bool = Field(...)
    state_schema: StateSchema | None = None


class AgentOutput(GenkitModel):
    """Model for agentoutput data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    session_id: str | None = None
    snapshot_id: str | None = None
    state: SessionState | None = None
    message: MessageData | None = None
    artifacts: list[Artifact] | None = None
    finish_reason: AgentFinishReason | None = None
    error: GenkitRuntimeError | None = None


class AgentResult(GenkitModel):
    """Model for agentresult data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    message: MessageData | None = None
    artifacts: list[Artifact] | None = None
    finish_reason: AgentFinishReason | None = None


class AgentStreamChunk(GenkitModel):
    """Model for agentstreamchunk data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    model_chunk: ModelResponseChunk | None = None
    custom_patch: JsonPatch | None = None
    artifact: Artifact | None = None
    turn_end: TurnEnd | None = None


class Artifact(GenkitModel):
    """Model for artifact data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    name: str | None = None
    parts: list[Part] = Field(...)
    metadata: Metadata | None = None


class GetSnapshotRequest(GenkitModel):
    """Model for getsnapshotrequest data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    snapshot_id: str | None = None
    session_id: str | None = None


class JsonPatchOperation(GenkitModel):
    """Model for jsonpatchoperation data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    op: JsonPatchOp = Field(...)
    path: str = Field(...)
    from_: str | None = Field(default=None, alias='from')
    value: Any | None = Field(default=None)


class SessionSnapshot(GenkitModel):
    """Model for sessionsnapshot data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    snapshot_id: str = Field(...)
    session_id: str | None = None
    parent_id: str | None = None
    created_at: str = Field(...)
    updated_at: str | None = None
    heartbeat_at: str | None = None
    status: SnapshotStatus | None = None
    finish_reason: AgentFinishReason | None = None
    error: GenkitRuntimeError | None = None
    state: SessionState | None = None


class SessionState(GenkitModel):
    """Model for sessionstate data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    session_id: str | None = None
    messages: list[MessageData] | None = None
    custom: Any | None = Field(default=None)
    artifacts: list[Artifact] | None = None


class TurnEnd(GenkitModel):
    """Model for turnend data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    snapshot_id: str | None = None
    finish_reason: AgentFinishReason | None = None


class DocumentData(GenkitModel):
    """Model for documentdata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    content: list[DocumentPart] = Field(...)
    metadata: Metadata | None = None


class EmbedRequest(GenkitModel):
    """Model for embedrequest data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    input: list[DocumentData] = Field(...)
    options: Any | None = Field(default=None)


class EmbedResponse(GenkitModel):
    """Model for embedresponse data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    embeddings: list[Embedding] = Field(...)


class Embedding(GenkitModel):
    """Model for embedding data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    embedding: list[float] = Field(...)
    metadata: Metadata | None = None


class BaseDataPoint(GenkitModel):
    """Model for basedatapoint data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    input: Any | None = Field(default=None)
    output: Any | None = Field(default=None)
    context: list[Any] | None = None
    reference: Any | None = Field(default=None)
    test_case_id: str | None = None
    trace_ids: list[str] | None = None


class BaseEvalDataPoint(GenkitModel):
    """Model for baseevaldatapoint data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    input: Any | None = Field(default=None)
    output: Any | None = Field(default=None)
    context: list[Any] | None = None
    reference: Any | None = Field(default=None)
    test_case_id: str = Field(...)
    trace_ids: list[str] | None = None


class EvalFnResponse(GenkitModel):
    """Model for evalfnresponse data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    sample_index: float | None = None
    test_case_id: str = Field(...)
    trace_id: str | None = None
    span_id: str | None = None
    evaluation: Score = Field(...)


class EvalRequest(GenkitModel):
    """Model for evalrequest data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    dataset: list[BaseDataPoint] = Field(...)
    eval_run_id: str = Field(...)
    options: Any | None = Field(default=None)


class Score(GenkitModel):
    """Model for score data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    id: str | None = None
    score: bool | float | str | None = Field(default=None)
    status: EvalStatusEnum | None = None
    error: str | None = None
    details: Details | None = None


class GenkitError(GenkitModel):
    """Model for genkiterror data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    message: str = Field(...)
    stack: str | None = None
    details: Any | None = Field(default=None)
    data: Data | None = None


class GenkitRuntimeError(GenkitModel):
    """Model for genkitruntimeerror data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    status: str | None = None
    message: str = Field(...)
    details: Any | None = Field(default=None)


class MiddlewareDesc(GenkitModel):
    """Model for middlewaredesc data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    name: str = Field(...)
    description: str | None = None
    config_schema: Any | ConfigSchema | None = Field(default=None)
    metadata: Metadata | None = None


class MiddlewareRef(GenkitModel):
    """Model for middlewareref data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    name: str = Field(...)
    config: Any | None = Field(default=None)


class CandidateError(GenkitModel):
    """Model for candidateerror data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    index: float = Field(...)
    code: Literal['blocked', 'other', 'unknown'] = Field(...)
    message: str | None = None


class Candidate(GenkitModel):
    """Model for candidate data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    index: float = Field(...)
    message: MessageData = Field(...)
    usage: GenerationUsage | None = None
    finish_reason: FinishReason = Field(...)
    finish_message: str | None = None
    custom: Any | None = Field(default=None)


class CustomPart(GenkitModel):
    """Model for custompart data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    text: Any | None = Field(default=None)
    media: Any | None = Field(default=None)
    tool_request: Any | None = Field(default=None)
    tool_response: Any | None = Field(default=None)
    data: Any | None = Field(default=None)
    metadata: Metadata | None = None
    custom: Custom = Field(...)
    reasoning: Any | None = Field(default=None)
    resource: Any | None = Field(default=None)


class DataPart(GenkitModel):
    """Model for datapart data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    text: Any | None = Field(default=None)
    media: Any | None = Field(default=None)
    tool_request: Any | None = Field(default=None)
    tool_response: Any | None = Field(default=None)
    data: Any | None = Field(default=None)
    metadata: Metadata | None = None
    custom: Custom | None = None
    reasoning: Any | None = Field(default=None)
    resource: Any | None = Field(default=None)


class GenerateActionOptionsData(GenkitModel):
    """Model for generateactionoptionsdata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    model: str | None = None
    docs: list[DocumentData] | None = None
    tools: list[str] | None = None
    resources: list[str] | None = None
    tool_choice: ToolChoice | None = None
    config: Any | None = Field(default=None)
    output: GenerateActionOutputConfig | None = None
    resume: Resume | None = None
    return_tool_requests: bool | None = None
    max_turns: float | None = None
    step_name: str | None = None
    use: list[MiddlewareRef] | None = None


class GenerateActionOutputConfig(GenkitModel):
    """Model for generateactionoutputconfig data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    format: str | None = None
    content_type: str | None = None
    instructions: bool | str | None = Field(default=None)
    json_schema: Any | None = Field(default=None)
    constrained: bool | None = None
    # Store Pydantic type for runtime validation (excluded from JSON)
    schema_type: Any = Field(default=None, exclude=True)


class GenerateResponseChunk(GenkitModel):
    """Model for generateresponsechunk data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    role: Role | None = None
    index: float | None = None
    content: list[Part] = Field(...)
    custom: Any | None = Field(default=None)
    aggregated: bool | None = None


class GenerationCommonConfig(GenkitModel):
    """Model for generationcommonconfig data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='allow', populate_by_name=True)
    version: str | None = None
    temperature: float | None = None
    max_output_tokens: float | None = None
    top_k: float | None = None
    top_p: float | None = None
    stop_sequences: list[str] | None = None
    api_key: str | None = None


class GenerationUsage(GenkitModel):
    """Model for generationusage data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    input_tokens: float | None = None
    output_tokens: float | None = None
    total_tokens: float | None = None
    input_characters: float | None = None
    output_characters: float | None = None
    input_images: float | None = None
    output_images: float | None = None
    input_videos: float | None = None
    output_videos: float | None = None
    input_audio_files: float | None = None
    output_audio_files: float | None = None
    custom: Custom | None = None
    thoughts_tokens: float | None = None
    cached_content_tokens: float | None = None


class MediaPart(GenkitModel):
    """Model for mediapart data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    text: Any | None = Field(default=None)
    media: Media = Field(...)
    tool_request: Any | None = Field(default=None)
    tool_response: Any | None = Field(default=None)
    data: Any | None = Field(default=None)
    metadata: Metadata | None = None
    custom: Custom | None = None
    reasoning: Any | None = Field(default=None)
    resource: Any | None = Field(default=None)


class MessageData(GenkitModel):
    """Model for messagedata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    role: Role | str = Field(...)
    content: list[Part] = Field(...)
    metadata: Metadata | None = None


class ModelInfo(GenkitModel):
    """Model for modelinfo data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    versions: list[str] | None = None
    label: str | None = None
    config_schema: ConfigSchema | None = None
    supports: Supports | None = None
    stage: Stage | None = None


class ModelReference(GenkitModel):
    """Model for modelreference data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    name: str = Field(...)
    config: Any | None = Field(default=None)


class ModelResponseChunk(GenkitModel):
    """Model for modelresponsechunk data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    role: Any | None = Field(default=None)
    index: float | None = None
    content: list[Part] = Field(...)
    custom: Any | None = Field(default=None)
    aggregated: bool | None = None


class MultipartToolResponse(GenkitModel):
    """Model for multiparttoolresponse data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    output: Any | None = Field(default=None)
    content: list[Part] | None = None
    metadata: Metadata | None = None


class Operation(GenkitModel):
    """Model for operation data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    action: str | None = None
    id: str = Field(...)
    done: bool | None = None
    output: Any | None = Field(default=None)
    error: Error | None = None
    metadata: Metadata | None = None


class OutputConfig(GenkitModel):
    """Model for outputconfig data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(
        alias_generator=to_camel, extra='forbid', populate_by_name=True, protected_namespaces=()
    )
    format: str | None = None
    schema_: dict[str, Any] | None = None
    constrained: bool | None = None
    content_type: str | None = None


class ReasoningPart(GenkitModel):
    """Model for reasoningpart data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    text: Any | None = Field(default=None)
    media: Any | None = Field(default=None)
    tool_request: Any | None = Field(default=None)
    tool_response: Any | None = Field(default=None)
    data: Any | None = Field(default=None)
    metadata: Metadata | None = None
    custom: Custom | None = None
    reasoning: str = Field(...)
    resource: Any | None = Field(default=None)


class ResourcePart(GenkitModel):
    """Model for resourcepart data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    text: Any | None = Field(default=None)
    media: Any | None = Field(default=None)
    tool_request: Any | None = Field(default=None)
    tool_response: Any | None = Field(default=None)
    data: Any | None = Field(default=None)
    metadata: Metadata | None = None
    custom: Custom | None = None
    reasoning: Any | None = Field(default=None)
    resource: Resource = Field(...)


class TextPart(GenkitModel):
    """Model for textpart data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    text: str = Field(...)
    media: Any | None = Field(default=None)
    tool_request: Any | None = Field(default=None)
    tool_response: Any | None = Field(default=None)
    data: Any | None = Field(default=None)
    metadata: Metadata | None = None
    custom: Custom | None = None
    reasoning: Any | None = Field(default=None)
    resource: Any | None = Field(default=None)


class ToolDefinition(GenkitModel):
    """Model for tooldefinition data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    name: str = Field(...)
    key: str | None = None
    description: str = Field(...)
    input_schema: Any | dict[str, Any] | None = Field(
        default=None, description='Valid JSON Schema representing the input of the tool.'
    )
    output_schema: Any | dict[str, Any] | None = Field(
        default=None, description='Valid JSON Schema describing the output of the tool.'
    )
    metadata: Metadata | None = None


class ToolRequestPart(GenkitModel):
    """Model for toolrequestpart data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    text: Any | None = Field(default=None)
    media: Any | None = Field(default=None)
    tool_request: ToolRequest = Field(...)
    tool_response: Any | None = Field(default=None)
    data: Any | None = Field(default=None)
    metadata: Metadata | None = None
    custom: Custom | None = None
    reasoning: Any | None = Field(default=None)
    resource: Any | None = Field(default=None)


class ToolResponsePart(GenkitModel):
    """Model for toolresponsepart data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    text: Any | None = Field(default=None)
    media: Any | None = Field(default=None)
    tool_request: Any | None = Field(default=None)
    tool_response: ToolResponse = Field(...)
    data: Any | None = Field(default=None)
    metadata: Metadata | None = None
    custom: Custom | None = None
    reasoning: Any | None = Field(default=None)
    resource: Any | None = Field(default=None)


class Media(GenkitModel):
    """Model for media data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    content_type: str | None = None
    url: str = Field(...)


class ToolRequest(GenkitModel):
    """Model for toolrequest data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    ref: str | None = None
    name: str = Field(...)
    input: Any | None = Field(default=None)
    partial: bool | None = None


class ToolResponse(GenkitModel):
    """Model for toolresponse data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    ref: str | None = None
    name: str = Field(...)
    output: Any | None = Field(default=None)
    content: list[Any] | None = None


class ActionMetadata(GenkitModel):
    """Model for actionmetadata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    key: str | None = None
    action_type: str | None = None
    name: str = Field(...)
    description: str | None = None
    input_schema: Any | None = Field(default=None)
    input_json_schema: Any | dict[str, Any] | None = Field(
        default=None, description='A JSON Schema Draft 7 (http://json-schema.org/draft-07/schema) object.'
    )
    output_schema: Any | None = Field(default=None)
    output_json_schema: Any | None = Field(
        default=None, description='A JSON Schema Draft 7 (http://json-schema.org/draft-07/schema) object.'
    )
    stream_schema: Any | None = Field(default=None)
    metadata: Metadata | None = None


class ReflectionCancelActionParams(GenkitModel):
    """Model for reflectioncancelactionparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    trace_id: str = Field(...)


class ReflectionCancelActionResponse(GenkitModel):
    """Model for reflectioncancelactionresponse data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    message: str = Field(...)


class ReflectionConfigureParams(GenkitModel):
    """Model for reflectionconfigureparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    telemetry_server_url: str | None = None


class ReflectionEndInputStreamParams(GenkitModel):
    """Model for reflectionendinputstreamparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    request_id: str = Field(...)


class ReflectionListActionsResponse(GenkitModel):
    """Model for reflectionlistactionsresponse data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    actions: Actions = Field(...)


class ReflectionListValuesParams(GenkitModel):
    """Model for reflectionlistvaluesparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    type: str = Field(...)


class ReflectionListValuesResponse(GenkitModel):
    """Model for reflectionlistvaluesresponse data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    values: Values = Field(...)


class ReflectionRegisterParams(GenkitModel):
    """Model for reflectionregisterparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    id: str = Field(...)
    pid: float = Field(...)
    name: str | None = None
    genkit_version: str | None = None
    reflection_api_spec_version: float | None = None
    envs: list[str] | None = None


class ReflectionRunActionParams(GenkitModel):
    """Model for reflectionrunactionparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    runtime_id: str | None = None
    key: str = Field(..., description='Action key that consists of the action type and ID.')
    input: Any | None = Field(default=None, description='An input with the type that this action expects.')
    init: Any | None = Field(
        default=None, description='Initialization parameters to establish long running session states.'
    )
    context: Any | None = Field(default=None, description='Additional runtime context data (ex. auth context data).')
    telemetry_labels: TelemetryLabels | None = None
    stream: bool | None = None
    stream_input: bool | None = None


class ReflectionRunActionStateParams(GenkitModel):
    """Model for reflectionrunactionstateparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    request_id: str = Field(...)
    state: State | None = None


class ReflectionSendInputStreamChunkParams(GenkitModel):
    """Model for reflectionsendinputstreamchunkparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    request_id: str = Field(...)
    chunk: Any | None = Field(default=None)


class ReflectionStreamChunkParams(GenkitModel):
    """Model for reflectionstreamchunkparams data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    request_id: str = Field(...)
    chunk: Any | None = Field(default=None)


class InstrumentationLibrary(GenkitModel):
    """Model for instrumentationlibrary data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    name: str = Field(...)
    version: str | None = None
    schema_url: str | None = None


class Link(GenkitModel):
    """Model for link data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    context: SpanContext | None = None
    attributes: Attributes | None = None
    dropped_attributes_count: float | None = None


class PathMetadata(GenkitModel):
    """Model for pathmetadata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(
        alias_generator=to_camel, extra='forbid', populate_by_name=True, frozen=True
    )
    path: str = Field(...)
    status: str = Field(...)
    error: str | None = None
    latency: float = Field(...)


class SpanContext(GenkitModel):
    """Model for spancontext data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    trace_id: str = Field(...)
    span_id: str = Field(...)
    is_remote: bool | None = None
    trace_flags: float = Field(...)


class SpanData(GenkitModel):
    """Model for spandata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    span_id: str = Field(...)
    trace_id: str = Field(...)
    parent_span_id: str | None = None
    start_time: float = Field(...)
    end_time: float = Field(...)
    attributes: Attributes = Field(...)
    display_name: str = Field(...)
    links: list[Link] | None = None
    instrumentation_library: InstrumentationLibrary = Field(...)
    span_kind: str = Field(...)
    same_process_as_parent_span: SameProcessAsParentSpan | None = None
    status: SpanStatus | None = None
    time_events: TimeEvents | None = None
    truncated: bool | None = None


class SpanEndEvent(GenkitModel):
    """Model for spanendevent data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    trace_id: str = Field(...)
    span: SpanData = Field(...)
    type: str = Field(...)


class SpanStartEvent(GenkitModel):
    """Model for spanstartevent data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    trace_id: str = Field(...)
    span: SpanData = Field(...)
    type: str = Field(...)


class SpanStatus(GenkitModel):
    """Model for spanstatus data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    code: float = Field(...)
    message: str | None = None


class SpantEventBase(GenkitModel):
    """Model for spanteventbase data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    trace_id: str = Field(...)
    span: SpanData = Field(...)


class TimeEvent(GenkitModel):
    """Model for timeevent data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    time: float = Field(...)
    annotation: Annotation = Field(...)


class TraceData(GenkitModel):
    """Model for tracedata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    trace_id: str = Field(...)
    display_name: str | None = None
    start_time: float | None = None
    end_time: float | None = None
    spans: Spans = Field(...)


class TraceMetadata(GenkitModel):
    """Model for tracemetadata data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    feature_name: str | None = None
    paths: list[PathMetadata] | None = None
    timestamp: float = Field(...)


class Resume(GenkitModel):
    """Model for resume data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    respond: list[ToolResponsePart] | None = None
    restart: list[ToolRequestPart] | None = None
    metadata: Metadata | None = None


class StateSchema(GenkitModel):
    """Model for stateschema data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)


class Details(GenkitModel):
    """Model for details data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='allow', populate_by_name=True)
    reasoning: str | None = None


class Data(GenkitModel):
    """Model for data data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    genkit_error_message: str | None = None
    genkit_error_details: GenkitErrorDetails | None = None


class GenkitErrorDetails(GenkitModel):
    """Model for genkiterrordetails data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    stack: str | None = None
    trace_id: str = Field(...)


class Supports(GenkitModel):
    """Model for supports data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    multiturn: bool | None = None
    media: bool | None = None
    tools: bool | None = None
    system_role: bool | None = None
    output: list[str] | None = None
    content_type: list[str] | None = None
    context: bool | None = None
    constrained: Constrained | None = None
    tool_choice: bool | None = None
    long_running: bool | None = None


class Error(GenkitModel):
    """Model for error data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='allow', populate_by_name=True)
    message: str = Field(...)


class Resource(GenkitModel):
    """Model for resource data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    uri: str = Field(...)


class Actions(GenkitModel):
    """Model for actions data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)


class Values(GenkitModel):
    """Model for values data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)


TelemetryLabels = dict[str, str]  # type alias for telemetrylabels (typed string map)


class State(GenkitModel):
    """Model for state data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    trace_id: str | None = None


class Attributes(GenkitModel):
    """Model for attributes data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)


class SameProcessAsParentSpan(GenkitModel):
    """Model for sameprocessasparentspan data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    value: bool = Field(...)


class TimeEvents(GenkitModel):
    """Model for timeevents data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    time_event: list[TimeEvent] | None = None


class Annotation(GenkitModel):
    """Model for annotation data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)
    attributes: Attributes = Field(...)
    description: str = Field(...)


class Spans(GenkitModel):
    """Model for spans data."""

    model_config: ClassVar[ConfigDict] = ConfigDict(alias_generator=to_camel, extra='forbid', populate_by_name=True)


class DocumentPart(RootModel[TextPart | MediaPart]):
    """Root model for DocumentPart union (Part(root=X), DocumentPart(root=X))."""


class Part(
    RootModel[
        TextPart | MediaPart | ToolRequestPart | ToolResponsePart | DataPart | CustomPart | ReasoningPart | ResourcePart
    ]
):
    """Root model for Part union (Part(root=X), DocumentPart(root=X))."""


TraceEvent = SpanStartEvent | SpanEndEvent


class JsonPatch(RootModel[list[JsonPatchOperation]]):
    """Root model for jsonpatch."""

    root: list[JsonPatchOperation]


class EvalResponse(RootModel[list[EvalFnResponse]]):
    """Root model for evalresponse."""

    root: list[EvalFnResponse]


class Constrained(StrEnum):
    """Constrained generation support (none, all, no-tools)."""

    NONE = 'none'
    ALL = 'all'
    NO_TOOLS = 'no-tools'


class Stage(StrEnum):
    """Model stage (featured, stable, unstable, legacy, deprecated)."""

    FEATURED = 'featured'
    STABLE = 'stable'
    UNSTABLE = 'unstable'
    LEGACY = 'legacy'
    DEPRECATED = 'deprecated'


class ToolChoice(StrEnum):
    """Tool choice for generation (auto, required, none)."""

    AUTO = 'auto'
    REQUIRED = 'required'
    NONE = 'none'


class MediaModel(RootModel[Any]):
    """Wrapper for media content (flexible structure)."""


class Text(RootModel[str]):
    """Plain text content."""


Resource1 = Resource  # alias for Resource (resource with uri)
