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

from ..core.pydantic_utilities import UniversalBaseModel
import pydantic
import typing
from .run_engine import RunEngine
from .proxy_location import ProxyLocation
from .task_run_request_data_extraction_schema import TaskRunRequestDataExtractionSchema
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class TaskRunRequest(UniversalBaseModel):
    prompt: str = pydantic.Field()
    """
    The goal or task description for Skyvern to accomplish
    """

    url: typing.Optional[str] = pydantic.Field(default=None)
    """
    The starting URL for the task. If not provided, Skyvern will attempt to determine an appropriate URL
    """

    title: typing.Optional[str] = pydantic.Field(default=None)
    """
    Optional title for the task
    """

    engine: typing.Optional[RunEngine] = pydantic.Field(default=None)
    """
    The Skyvern engine version to use for this task
    """

    proxy_location: typing.Optional[ProxyLocation] = pydantic.Field(default=None)
    """
    Geographic Proxy location to route the browser traffic through
    """

    data_extraction_schema: typing.Optional[TaskRunRequestDataExtractionSchema] = pydantic.Field(default=None)
    """
    Schema defining what data should be extracted from the webpage
    """

    error_code_mapping: typing.Optional[typing.Dict[str, typing.Optional[str]]] = pydantic.Field(default=None)
    """
    Custom mapping of error codes to error messages if Skyvern encounters an error
    """

    max_steps: typing.Optional[int] = pydantic.Field(default=None)
    """
    Maximum number of steps the task can take before timing out
    """

    webhook_url: typing.Optional[str] = pydantic.Field(default=None)
    """
    URL to send task status updates to after a run is finished
    """

    totp_identifier: typing.Optional[str] = pydantic.Field(default=None)
    """
    Identifier for TOTP (Time-based One-Time Password) authentication if codes are being pushed to Skyvern
    """

    totp_url: typing.Optional[str] = pydantic.Field(default=None)
    """
    URL for TOTP authentication setup if Skyvern should be polling endpoint for 2FA codes
    """

    browser_session_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of an existing browser session to reuse, having it continue from the current screen state
    """

    publish_workflow: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether to publish this task as a reusable workflow. 
    """

    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
