# 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 .dynamic_variables_config import DynamicVariablesConfig
from .tool_call_sound_behavior import ToolCallSoundBehavior
from .tool_call_sound_type import ToolCallSoundType
from .tool_execution_mode import ToolExecutionMode
from .webhook_tool_api_schema_config_input import WebhookToolApiSchemaConfigInput


class WebhookToolConfigInput(UncheckedBaseModel):
    """
    A webhook tool is a tool that calls an external webhook from our server
    """

    name: str
    description: str = pydantic.Field()
    """
    Description of when the tool should be used and what it does.
    """

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

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

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

    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.
    """

    dynamic_variables: typing.Optional[DynamicVariablesConfig] = pydantic.Field(default=None)
    """
    Configuration for dynamic variables
    """

    execution_mode: typing.Optional[ToolExecutionMode] = pydantic.Field(default=None)
    """
    Determines when and how the tool executes: 'immediate' executes the tool right away when requested by the LLM, 'post_tool_speech' waits for the agent to finish speaking before executing, 'async' runs the tool in the background without blocking - best for long-running operations.
    """

    api_schema: WebhookToolApiSchemaConfigInput = pydantic.Field()
    """
    The schema for the outgoing webhoook, including parameters and URL specification
    """

    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(WebhookToolConfigInput)
