# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.unchecked_base_model import UncheckedBaseModel
from .dynamic_variable_assignment import DynamicVariableAssignment
from .pre_tool_speech_mode import PreToolSpeechMode
from .system_tool_config_output_params import SystemToolConfigOutputParams
from .tool_call_sound_behavior import ToolCallSoundBehavior
from .tool_call_sound_type import ToolCallSoundType
from .tool_error_handling_mode import ToolErrorHandlingMode
from .tool_interruption_mode import ToolInterruptionMode


class SystemToolConfigOutput(UncheckedBaseModel):
    """
    A system tool is a tool that is used to call a system method in the server
    """

    type: typing.Optional[typing.Literal["system"]] = pydantic.Field(default=None)
    """
    The type of tool
    """

    name: str
    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Description of when the tool should be used and what it does. Leave empty to use the default description that's optimized for the specific tool type.
    """

    response_timeout_secs: typing.Optional[int] = pydantic.Field(default=None)
    """
    The maximum time in seconds to wait for the tool call to complete.
    """

    disable_interruptions: typing.Optional[bool] = pydantic.Field(default=None)
    """
    DEPRECATED: use `interruption_mode` instead. If true, the user will not be able to interrupt the agent while this tool is running.
    """

    interruption_mode: typing.Optional[ToolInterruptionMode] = pydantic.Field(default=None)
    """
    Controls whether the user can interrupt the agent around this tool call. 'allow' (default) lets the user interrupt at any time, 'disable_during_tool' suppresses interruptions only while the tool is running, 'disable_during_tool_and_turn' suppresses interruptions while the tool runs and for the agent response that follows it.
    """

    force_pre_tool_speech: typing.Optional[bool] = pydantic.Field(default=None)
    """
    DEPRECATED: use `pre_tool_speech` instead. If true, the agent will speak before the tool call.
    """

    pre_tool_speech: typing.Optional[PreToolSpeechMode] = pydantic.Field(default=None)
    """
    Controls whether the agent speaks before this tool is called. 'auto' (default) decides based on recent tool latency, 'force' always asks the agent to speak, 'off' fully opts out regardless of latency.
    """

    assignments: typing.Optional[typing.List[DynamicVariableAssignment]] = pydantic.Field(default=None)
    """
    Configuration for extracting values from tool responses and assigning them to dynamic variables
    """

    tool_call_sound: typing.Optional[ToolCallSoundType] = pydantic.Field(default=None)
    """
    Predefined tool call sound type to play during tool execution. If not specified, no tool call sound will be played.
    """

    tool_call_sound_behavior: typing.Optional[ToolCallSoundBehavior] = pydantic.Field(default=None)
    """
    Determines when the tool call sound should play. 'auto' only plays when there's pre-tool speech, 'always' plays for every tool call.
    """

    tool_error_handling_mode: typing.Optional[ToolErrorHandlingMode] = pydantic.Field(default=None)
    """
    Controls how tool errors are processed before being shared with the agent. 'auto' determines handling based on tool type (summarized for native integrations, hide for others), 'summarized' sends an LLM-generated summary, 'passthrough' sends the raw error, 'hide' does not share the error with the agent.
    """

    params: SystemToolConfigOutputParams

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


update_forward_refs(SystemToolConfigOutput)
