# generated by datamodel-codegen:
#   filename:  openapi.json

from __future__ import annotations

from enum import Enum
from typing import Any, Dict, List, Literal
from uuid import UUID

from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel


class AccountNotFoundError(BaseModel):
    detail: str | None = Field('Account not found', title='Detail')


class BrowserSessionStatus(Enum):
    active = 'active'
    stopped = 'stopped'


class BrowserSessionUpdateAction(Enum):
    stop = 'stop'


class BrowserSessionView(BaseModel):
    model_config = ConfigDict(
        regex_engine="python-re",
    )
    id: UUID = Field(..., description='Unique identifier for the session', title='ID')
    status: BrowserSessionStatus = Field(
        ...,
        description='Current status of the session (active/stopped)',
        title='Status',
    )
    live_url: str | None = Field(
        None,
        alias='liveUrl',
        description='URL where the browser can be viewed live in real-time',
        title='Live URL',
    )
    cdp_url: str | None = Field(
        None,
        alias='cdpUrl',
        description='Chrome DevTools Protocol URL for browser automation',
        title='CDP URL',
    )
    timeout_at: AwareDatetime = Field(
        ...,
        alias='timeoutAt',
        description='Timestamp when the session will timeout',
        title='Timeout At',
    )
    started_at: AwareDatetime = Field(
        ...,
        alias='startedAt',
        description='Timestamp when the session was created and started',
        title='Started At',
    )
    finished_at: AwareDatetime | None = Field(
        None,
        alias='finishedAt',
        description='Timestamp when the session was stopped (None if still active)',
        title='Finished At',
    )
    proxy_used_mb: str | None = Field(
        '0',
        alias='proxyUsedMb',
        description='Amount of proxy data used in MB',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Proxy Used MB',
    )
    proxy_cost: str | None = Field(
        '0',
        alias='proxyCost',
        description='Cost of proxy usage in USD',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Proxy Cost',
    )
    browser_cost: str | None = Field(
        '0',
        alias='browserCost',
        description='Cost of browser session hosting in USD',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Browser Cost',
    )
    agent_session_id: UUID | None = Field(
        None,
        alias='agentSessionId',
        description='ID of the agent session that created this browser (None for standalone BaaS sessions)',
        title='Agent Session ID',
    )
    recording_url: str | None = Field(
        None,
        alias='recordingUrl',
        description='Presigned URL to download the session recording (available after session ends, if recording was enabled)',
        title='Recording URL',
    )


class CannotDeleteSkillWhileGeneratingError(BaseModel):
    detail: str | None = Field(
        'Cannot delete skill while it is still generating', title='Detail'
    )


class CannotRollbackPublicSkillError(BaseModel):
    detail: str | None = Field(
        'Cannot rollback a public skill. Please make the skill private first.',
        title='Detail',
    )


class ConcurrentSkillCreationsError(BaseModel):
    detail: str | None = Field(
        'Concurrent skill creations are not allowed. Please wait for the current skill creation to finish or cancel it.',
        title='Detail',
    )


class BrowserScreenWidth(RootModel[int]):
    root: int = Field(
        ...,
        description='Custom screen width in pixels for the browser.',
        ge=320,
        le=6144,
        title='Browser Screen Width',
    )


class BrowserScreenHeight(RootModel[int]):
    root: int = Field(
        ...,
        description='Custom screen height in pixels for the browser.',
        ge=320,
        le=3456,
        title='Browser Screen Height',
    )


class Title(RootModel[str]):
    root: str = Field(
        ...,
        description='Optional title for the skill (will be generated if not provided)',
        max_length=100,
        title='Title',
    )


class Description(RootModel[str]):
    root: str = Field(
        ...,
        description='Optional description for the skill (will be generated if not provided)',
        max_length=1000,
        title='Description',
    )


class CreateSkillRequest(BaseModel):
    title: Title | None = Field(
        None,
        description='Optional title for the skill (will be generated if not provided)',
        title='Title',
    )
    description: Description | None = Field(
        None,
        description='Optional description for the skill (will be generated if not provided)',
        title='Description',
    )
    goal: str = Field(
        ...,
        description='Goal of the skill (description of what the skill does and what the user should expect from it)',
        max_length=1000,
        title='Goal',
    )
    agent_prompt: str = Field(
        ...,
        alias='agentPrompt',
        description='Prompt for the agent to use when generating the skill automatically',
        min_length=10,
        title='Agentprompt',
    )


class CreateSkillResponse(BaseModel):
    id: UUID = Field(
        ..., description='Unique identifier for the created skill', title='ID'
    )


class JudgeGroundTruth(RootModel[str]):
    root: str = Field(
        ...,
        description='Expected answer for judge evaluation.',
        max_length=10000,
        title='Judge Ground Truth',
    )


class Username(RootModel[str]):
    root: str = Field(
        ...,
        description='Username for proxy authentication.',
        max_length=255,
        min_length=1,
        title='Username',
    )


class Password(RootModel[str]):
    root: str = Field(
        ...,
        description='Password for proxy authentication.',
        max_length=255,
        min_length=1,
        title='Password',
    )


class CustomProxy(BaseModel):
    host: str = Field(
        ...,
        description='Host of the proxy.',
        max_length=255,
        min_length=1,
        title='Host',
    )
    port: int = Field(
        ..., description='Port of the proxy.', ge=1, le=65535, title='Port'
    )
    username: Username | None = Field(
        None, description='Username for proxy authentication.', title='Username'
    )
    password: Password | None = Field(
        None, description='Password for proxy authentication.', title='Password'
    )


class DownloadUrlGenerationError(BaseModel):
    detail: str | None = Field('Failed to generate download URL', title='Detail')


class EnabledSkillsLimitExceededError(BaseModel):
    detail: str | None = Field(
        'Enabled skills limit exceeded for your plan', title='Detail'
    )


class ExecuteSkillRequest(BaseModel):
    parameters: Dict[str, Any] | None = Field(
        None, description='Parameters to pass to the skill handler', title='Parameters'
    )
    session_id: UUID | None = Field(
        None,
        alias='sessionId',
        description='Optional session ID (UUID) for IP persistence.',
        title='Sessionid',
    )


class ExecuteSkillResponse(BaseModel):
    success: bool = Field(
        ..., description='Whether the skill execution was successful', title='Success'
    )
    result: Any = Field(
        None, description='Output of the skill execution', title='Result'
    )
    error: str | None = Field(
        None, description='Error message if the skill execution failed', title='Error'
    )
    stderr: str | None = Field(
        None, description='Standard error output of the skill execution', title='Stderr'
    )
    latency_ms: int | None = Field(
        None,
        alias='latencyMs',
        description='Latency of the skill execution in milliseconds',
        title='Latency in ms',
    )


class FileView(BaseModel):
    id: UUID = Field(
        ..., description='Unique identifier for the output file', title='ID'
    )
    file_name: str = Field(
        ..., alias='fileName', description='Name of the output file', title='File Name'
    )


class GenerationNotCancellableError(BaseModel):
    detail: str | None = Field('Generation is not cancellable', title='Detail')


class InsufficientCreditsError(BaseModel):
    detail: str | None = Field('Insufficient credits', title='Detail')


class InternalServerError(BaseModel):
    detail: str | None = Field('An internal server error occurred', title='Detail')


class OutputFileNotFoundError(BaseModel):
    detail: str | None = Field('Output file not found', title='Detail')


class ParameterType(Enum):
    string = 'string'
    number = 'number'
    boolean = 'boolean'
    object = 'object'
    array = 'array'
    cookie = 'cookie'


class PlanInfo(BaseModel):
    plan_name: str = Field(
        ..., alias='planName', description='The name of the plan', title='Plan Name'
    )
    subscription_status: str | None = Field(
        ...,
        alias='subscriptionStatus',
        description='The status of the subscription',
        title='Subscription Status',
    )
    subscription_id: str | None = Field(
        ...,
        alias='subscriptionId',
        description='The ID of the subscription',
        title='Subscription ID',
    )
    subscription_current_period_end: str | None = Field(
        ...,
        alias='subscriptionCurrentPeriodEnd',
        description='The end of the current period',
        title='Subscription Current Period End',
    )
    subscription_canceled_at: str | None = Field(
        ...,
        alias='subscriptionCanceledAt',
        description='The date the subscription was canceled',
        title='Subscription Canceled At',
    )


class Name(RootModel[str]):
    root: str = Field(
        ..., description='Optional name for the profile', max_length=100, title='Name'
    )


class UserId(RootModel[str]):
    root: str = Field(
        ...,
        description='Your internal user identifier for this profile. Use this to associate a profile with a user in your system.',
        max_length=255,
        title='User ID',
    )


class ProfileCreateRequest(BaseModel):
    name: Name | None = Field(
        None, description='Optional name for the profile', title='Name'
    )
    user_id: UserId | None = Field(
        None,
        alias='userId',
        description='Your internal user identifier for this profile. Use this to associate a profile with a user in your system.',
        title='User ID',
    )


class ProfileNotFoundError(BaseModel):
    detail: str | None = Field('Profile not found', title='Detail')


class ProfileUpdateRequest(BaseModel):
    name: Name | None = Field(
        None, description='Optional name for the profile', title='Name'
    )
    user_id: UserId | None = Field(
        None,
        alias='userId',
        description='Your internal user identifier for this profile. Use this to associate a profile with a user in your system.',
        title='User ID',
    )


class ProfileView(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the profile', title='ID')
    user_id: str | None = Field(
        None,
        alias='userId',
        description='Your internal user identifier for this profile. Use this to associate a profile with a user in your system.',
        title='User ID',
    )
    name: str | None = Field(
        None, description='Optional name for the profile', title='Name'
    )
    last_used_at: AwareDatetime | None = Field(
        None,
        alias='lastUsedAt',
        description='Timestamp when the profile was last used',
        title='Last Used At',
    )
    created_at: AwareDatetime = Field(
        ...,
        alias='createdAt',
        description='Timestamp when the profile was created',
        title='Created At',
    )
    updated_at: AwareDatetime = Field(
        ...,
        alias='updatedAt',
        description='Timestamp when the profile was last updated',
        title='Updated At',
    )
    cookie_domains: List[str] | None = Field(
        None,
        alias='cookieDomains',
        description='List of domain URLs that have cookies stored for this profile',
        title='Cookie Domains',
    )


class ProxyCountryCode(Enum):
    ad = 'ad'
    ae = 'ae'
    af = 'af'
    ag = 'ag'
    ai = 'ai'
    al = 'al'
    am = 'am'
    an = 'an'
    ao = 'ao'
    aq = 'aq'
    ar = 'ar'
    as_ = 'as'
    at = 'at'
    au = 'au'
    aw = 'aw'
    az = 'az'
    ba = 'ba'
    bb = 'bb'
    bd = 'bd'
    be = 'be'
    bf = 'bf'
    bg = 'bg'
    bh = 'bh'
    bi = 'bi'
    bj = 'bj'
    bl = 'bl'
    bm = 'bm'
    bn = 'bn'
    bo = 'bo'
    bq = 'bq'
    br = 'br'
    bs = 'bs'
    bt = 'bt'
    bv = 'bv'
    bw = 'bw'
    by = 'by'
    bz = 'bz'
    ca = 'ca'
    cc = 'cc'
    cd = 'cd'
    cf = 'cf'
    cg = 'cg'
    ch = 'ch'
    ck = 'ck'
    cl = 'cl'
    cm = 'cm'
    co = 'co'
    cr = 'cr'
    cs = 'cs'
    cu = 'cu'
    cv = 'cv'
    cw = 'cw'
    cx = 'cx'
    cy = 'cy'
    cz = 'cz'
    de = 'de'
    dj = 'dj'
    dk = 'dk'
    dm = 'dm'
    do = 'do'
    dz = 'dz'
    ec = 'ec'
    ee = 'ee'
    eg = 'eg'
    eh = 'eh'
    er = 'er'
    es = 'es'
    et = 'et'
    fi = 'fi'
    fj = 'fj'
    fk = 'fk'
    fm = 'fm'
    fo = 'fo'
    fr = 'fr'
    ga = 'ga'
    gd = 'gd'
    ge = 'ge'
    gf = 'gf'
    gg = 'gg'
    gh = 'gh'
    gi = 'gi'
    gl = 'gl'
    gm = 'gm'
    gn = 'gn'
    gp = 'gp'
    gq = 'gq'
    gr = 'gr'
    gs = 'gs'
    gt = 'gt'
    gu = 'gu'
    gw = 'gw'
    gy = 'gy'
    hk = 'hk'
    hm = 'hm'
    hn = 'hn'
    hr = 'hr'
    ht = 'ht'
    hu = 'hu'
    id = 'id'
    ie = 'ie'
    il = 'il'
    im = 'im'
    in_ = 'in'
    iq = 'iq'
    ir = 'ir'
    is_ = 'is'
    it = 'it'
    je = 'je'
    jm = 'jm'
    jo = 'jo'
    jp = 'jp'
    ke = 'ke'
    kg = 'kg'
    kh = 'kh'
    ki = 'ki'
    km = 'km'
    kn = 'kn'
    kp = 'kp'
    kr = 'kr'
    kw = 'kw'
    ky = 'ky'
    kz = 'kz'
    la = 'la'
    lb = 'lb'
    lc = 'lc'
    li = 'li'
    lk = 'lk'
    lr = 'lr'
    ls = 'ls'
    lt = 'lt'
    lu = 'lu'
    lv = 'lv'
    ly = 'ly'
    ma = 'ma'
    mc = 'mc'
    md = 'md'
    me = 'me'
    mf = 'mf'
    mg = 'mg'
    mh = 'mh'
    mk = 'mk'
    ml = 'ml'
    mm = 'mm'
    mn = 'mn'
    mo = 'mo'
    mp = 'mp'
    mq = 'mq'
    mr = 'mr'
    ms = 'ms'
    mt = 'mt'
    mu = 'mu'
    mv = 'mv'
    mw = 'mw'
    mx = 'mx'
    my = 'my'
    mz = 'mz'
    na = 'na'
    nc = 'nc'
    ne = 'ne'
    nf = 'nf'
    ng = 'ng'
    ni = 'ni'
    nl = 'nl'
    no = 'no'
    np = 'np'
    nr = 'nr'
    nu = 'nu'
    nz = 'nz'
    om = 'om'
    pa = 'pa'
    pe = 'pe'
    pf = 'pf'
    pg = 'pg'
    ph = 'ph'
    pk = 'pk'
    pl = 'pl'
    pm = 'pm'
    pn = 'pn'
    pr = 'pr'
    ps = 'ps'
    pt = 'pt'
    pw = 'pw'
    py = 'py'
    qa = 'qa'
    re = 're'
    ro = 'ro'
    rs = 'rs'
    ru = 'ru'
    rw = 'rw'
    sa = 'sa'
    sb = 'sb'
    sc = 'sc'
    sd = 'sd'
    se = 'se'
    sg = 'sg'
    sh = 'sh'
    si = 'si'
    sj = 'sj'
    sk = 'sk'
    sl = 'sl'
    sm = 'sm'
    sn = 'sn'
    so = 'so'
    sr = 'sr'
    ss = 'ss'
    st = 'st'
    sv = 'sv'
    sx = 'sx'
    sy = 'sy'
    sz = 'sz'
    tc = 'tc'
    td = 'td'
    tf = 'tf'
    tg = 'tg'
    th = 'th'
    tj = 'tj'
    tk = 'tk'
    tl = 'tl'
    tm = 'tm'
    tn = 'tn'
    to = 'to'
    tr = 'tr'
    tt = 'tt'
    tv = 'tv'
    tw = 'tw'
    tz = 'tz'
    ua = 'ua'
    ug = 'ug'
    uk = 'uk'
    us = 'us'
    uy = 'uy'
    uz = 'uz'
    va = 'va'
    vc = 'vc'
    ve = 've'
    vg = 'vg'
    vi = 'vi'
    vn = 'vn'
    vu = 'vu'
    wf = 'wf'
    ws = 'ws'
    xk = 'xk'
    ye = 'ye'
    yt = 'yt'
    za = 'za'
    zm = 'zm'
    zw = 'zw'


class RefineSkillRequest(BaseModel):
    feedback: str = Field(
        ...,
        description='Feedback describing what to improve',
        min_length=10,
        title='Feedback',
    )
    test_output: str | None = Field(
        None,
        alias='testOutput',
        description='Last skill test output to include in refinement context',
        title='Testoutput',
    )
    test_logs: str | None = Field(
        None,
        alias='testLogs',
        description='Last skill test logs to include in refinement context',
        title='Testlogs',
    )


class RefineSkillResponse(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the skill', title='ID')


class SessionHasRunningTaskError(BaseModel):
    detail: str | None = Field(
        'Agent session already has a running task. Please wait for it to finish or stop it manually.',
        title='Detail',
    )


class SessionNotFoundError(BaseModel):
    detail: str | None = Field('Session not found', title='Detail')


class SessionSettings(BaseModel):
    profile_id: UUID | None = Field(
        None,
        alias='profileId',
        description='Browser profile ID for persistent browser state (cookies, local storage, etc.).',
        title='Profile ID',
    )
    proxy_country_code: ProxyCountryCode | None = Field(
        ProxyCountryCode.us,
        alias='proxyCountryCode',
        description='Proxy country code for geo-targeted browsing. Defaults to US. Set to null to disable proxy.',
        title='Proxy Country Code',
    )
    browser_screen_width: BrowserScreenWidth | None = Field(
        None,
        alias='browserScreenWidth',
        description='Custom screen width in pixels for the browser.',
        title='Browser Screen Width',
    )
    browser_screen_height: BrowserScreenHeight | None = Field(
        None,
        alias='browserScreenHeight',
        description='Custom screen height in pixels for the browser.',
        title='Browser Screen Height',
    )
    enable_recording: bool | None = Field(
        False,
        alias='enableRecording',
        description='If True, enables session recording. Defaults to False.',
        title='Enable Recording',
    )


class SessionStatus(Enum):
    active = 'active'
    stopped = 'stopped'


class SessionStoppedError(BaseModel):
    detail: str | None = Field(
        'Browser session is stopped. Please start a new session and try again.',
        title='Detail',
    )


class SessionTimeoutLimitExceededError(BaseModel):
    detail: str | None = Field(
        'Maximum session timeout is 4 hours (240 minutes).', title='Detail'
    )


class SessionUpdateAction(Enum):
    stop = 'stop'


class ShareNotFoundError(BaseModel):
    detail: str | None = Field('Public share not found', title='Detail')


class ShareView(BaseModel):
    share_token: str = Field(
        ...,
        alias='shareToken',
        description='Token to access the public share',
        title='Share Token',
    )
    share_url: str = Field(
        ...,
        alias='shareUrl',
        description='URL to access the public share',
        title='Share URL',
    )
    view_count: int = Field(
        ...,
        alias='viewCount',
        description='Number of times the public share has been viewed',
        title='View Count',
    )
    last_viewed_at: AwareDatetime | None = Field(
        None,
        alias='lastViewedAt',
        description='Timestamp of the last time the public share was viewed (None if never viewed)',
        title='Last Viewed At',
    )


class SkillCategory(Enum):
    search = 'search'
    e_commerce = 'e_commerce'
    financial = 'financial'
    news = 'news'
    real_estate = 'real_estate'
    social_media = 'social_media'
    travel = 'travel'
    marketplace = 'marketplace'
    lead_generation = 'lead_generation'
    seo = 'seo'
    jobs = 'jobs'
    developer = 'developer'
    media = 'media'
    automation = 'automation'
    integration = 'integration'
    other = 'other'


class SkillExecutionOutputResponse(BaseModel):
    download_url: str = Field(
        ...,
        alias='downloadUrl',
        description='Presigned URL for downloading the execution output (valid for 5 minutes)',
        title='Downloadurl',
    )


class SkillExecutionView(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the execution', title='Id')
    skill_id: UUID = Field(
        ...,
        alias='skillId',
        description='ID of the skill that was executed',
        title='Skillid',
    )
    status: str = Field(
        ..., description='Execution status (running, completed, failed)', title='Status'
    )
    success: bool = Field(
        ..., description='Whether the execution succeeded', title='Success'
    )
    started_at: AwareDatetime = Field(
        ...,
        alias='startedAt',
        description='When the execution started',
        title='Startedat',
    )
    finished_at: AwareDatetime | None = Field(
        ...,
        alias='finishedAt',
        description='When the execution finished',
        title='Finishedat',
    )
    latency_ms: int | None = Field(
        ...,
        alias='latencyMs',
        description='Execution latency in milliseconds',
        title='Latencyms',
    )
    has_output: bool = Field(
        ...,
        alias='hasOutput',
        description='Whether output is available for download',
        title='Hasoutput',
    )


class SkillNotFinishedError(BaseModel):
    detail: str | None = Field('Skill is not finished', title='Detail')


class SkillNotFoundError(BaseModel):
    detail: str | None = Field('Skill not found', title='Detail')


class SkillsGenerationStatus(Enum):
    recording = 'recording'
    generating = 'generating'
    failed = 'failed'
    finished = 'finished'
    cancelled = 'cancelled'
    timed_out = 'timed_out'


class SupportedLLMs(Enum):
    browser_use_llm = 'browser-use-llm'
    browser_use_2_0 = 'browser-use-2.0'
    gpt_4_1 = 'gpt-4.1'
    gpt_4_1_mini = 'gpt-4.1-mini'
    o4_mini = 'o4-mini'
    o3 = 'o3'
    gemini_2_5_flash = 'gemini-2.5-flash'
    gemini_2_5_pro = 'gemini-2.5-pro'
    gemini_3_pro_preview = 'gemini-3-pro-preview'
    gemini_3_flash_preview = 'gemini-3-flash-preview'
    gemini_flash_latest = 'gemini-flash-latest'
    gemini_flash_lite_latest = 'gemini-flash-lite-latest'
    claude_sonnet_4_20250514 = 'claude-sonnet-4-20250514'
    claude_sonnet_4_5_20250929 = 'claude-sonnet-4-5-20250929'
    claude_sonnet_4_6 = 'claude-sonnet-4-6'
    claude_opus_4_5_20251101 = 'claude-opus-4-5-20251101'
    llama_4_maverick_17b_128e_instruct = 'llama-4-maverick-17b-128e-instruct'
    claude_3_7_sonnet_20250219 = 'claude-3-7-sonnet-20250219'


class TaskCreatedResponse(BaseModel):
    id: UUID = Field(
        ..., description='Unique identifier for the created task', title='ID'
    )
    session_id: UUID = Field(
        ...,
        alias='sessionId',
        description='Session ID where the task was created',
        title='Session ID',
    )


class Cost(RootModel[str]):
    model_config = ConfigDict(
        regex_engine="python-re",
    )
    root: str = Field(
        ...,
        description='Total cost of the task in USD. This is the sum of all step costs incurred during task execution.',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Cost',
    )


class TaskLogFileResponse(BaseModel):
    download_url: str = Field(
        ...,
        alias='downloadUrl',
        description='URL to download the log file',
        title='Download URL',
    )


class TaskNotFoundError(BaseModel):
    detail: str | None = Field('Task not found', title='Detail')


class TaskOutputFileResponse(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the file', title='ID')
    file_name: str = Field(
        ..., alias='fileName', description='Name of the file', title='File Name'
    )
    download_url: str = Field(
        ...,
        alias='downloadUrl',
        description='URL to download the file',
        title='Download URL',
    )


class TaskStatus(Enum):
    created = 'created'
    started = 'started'
    finished = 'finished'
    failed = 'failed'
    stopped = 'stopped'


class Cost1(RootModel[str]):
    model_config = ConfigDict(
        regex_engine="python-re",
    )
    root: str = Field(
        ...,
        description='Total cost of the task in USD',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Cost',
    )


class TaskStatusView(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the task', title='ID')
    status: TaskStatus = Field(
        ..., description='Current status of the task', title='Status'
    )
    output: str | None = Field(
        None,
        description='Final output/result of the task (null while running)',
        title='Output',
    )
    finished_at: AwareDatetime | None = Field(
        None,
        alias='finishedAt',
        description='Naive UTC timestamp when the task completed (null if still running)',
        title='Finished At',
    )
    is_success: bool | None = Field(
        None,
        alias='isSuccess',
        description="Whether the task was successful based on the agent's self-reported output",
        title='Is Success',
    )
    cost: Cost1 | None = Field(
        None, description='Total cost of the task in USD', title='Cost'
    )


class TaskStepView(BaseModel):
    number: int = Field(
        ..., description='Sequential step number within the task', title='Number'
    )
    memory: str = Field(..., description="Agent's memory at this step", title='Memory')
    evaluation_previous_goal: str = Field(
        ...,
        alias='evaluationPreviousGoal',
        description="Agent's evaluation of the previous goal completion",
        title='Evaluation Previous Goal',
    )
    next_goal: str = Field(
        ...,
        alias='nextGoal',
        description='The goal for the next step',
        title='Next Goal',
    )
    url: str = Field(
        ..., description='Current URL the browser is on for this step', title='URL'
    )
    screenshot_url: str | None = Field(
        None,
        alias='screenshotUrl',
        description='Optional URL to the screenshot taken at this step',
        title='Screenshot URL',
    )
    actions: List[str] = Field(
        ...,
        description='List of stringified json actions performed by the agent in this step',
        title='Actions',
    )
    duration: float | None = Field(
        None,
        description='Duration of the step in seconds. Calculated as the time elapsed from the previous step completion (or task start for the first step) to this step completion.',
        title='Duration',
    )


class TaskUpdateAction(Enum):
    stop = 'stop'
    stop_task_and_session = 'stop_task_and_session'


class Cost2(RootModel[str]):
    model_config = ConfigDict(
        regex_engine="python-re",
    )
    root: str = Field(
        ...,
        description='Total cost of the task in USD. This is the sum of all step costs incurred during task execution.',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Cost',
    )


class TaskView(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the task', title='ID')
    session_id: UUID = Field(..., alias='sessionId', title='Sessionid')
    llm: str = Field(
        ...,
        description='The LLM model used for this task represented as a string',
        title='LLM',
    )
    task: str = Field(
        ..., description='The task prompt/instruction given to the agent', title='Task'
    )
    status: TaskStatus = Field(
        ..., description='Current status of the task execution', title='Status'
    )
    created_at: AwareDatetime = Field(
        ...,
        alias='createdAt',
        description='Naive UTC timestamp when the task was created',
        title='Created At',
    )
    started_at: AwareDatetime | None = Field(
        None,
        alias='startedAt',
        description='Naive UTC timestamp when the task was started (None if task has not started yet)',
        title='Started At',
    )
    finished_at: AwareDatetime | None = Field(
        None,
        alias='finishedAt',
        description='Naive UTC timestamp when the task completed (None if still running)',
        title='Finished At',
    )
    metadata: Dict[str, Any] | None = Field(
        {},
        description='Optional additional metadata associated with the task set by the user',
        title='Metadata',
    )
    steps: List[TaskStepView] = Field(..., title='Steps')
    output: str | None = Field(
        None, description='Final output/result of the task', title='Output'
    )
    output_files: List[FileView] = Field(..., alias='outputFiles', title='Outputfiles')
    browser_use_version: str | None = Field(
        None,
        alias='browserUseVersion',
        description='Version of browser-use used for this task (older tasks may not have this set)',
        title='Browser Use Version',
    )
    is_success: bool | None = Field(
        None,
        alias='isSuccess',
        description="Whether the task was successful based on the agent's self-reported output (less reliable than the judge)",
        title='Is Success',
    )
    judgement: str | None = Field(
        None,
        description='Stringified JSON object containing the full report from the judge',
        title='Judgement',
    )
    judge_verdict: bool | None = Field(
        None,
        alias='judgeVerdict',
        description='Judge verdict - True if the judge found the task to be successful, False otherwise (None if judge is not enabled)',
        title='Judge Verdict',
    )
    cost: Cost2 | None = Field(
        None,
        description='Total cost of the task in USD. This is the sum of all step costs incurred during task execution.',
        title='Cost',
    )
    suggestions: List[Dict[str, Any]] | None = Field(
        None,
        description='List of actionable suggestions for improving task configuration based on detected issues during execution.',
        title='Suggestions',
    )


class TooManyConcurrentActiveSessionsError(BaseModel):
    detail: str | None = Field(
        'Too many concurrent active sessions. Please wait for one to finish, kill one, or upgrade your plan.',
        title='Detail',
    )


class UnsupportedContentTypeError(BaseModel):
    detail: str | None = Field('Unsupported content type', title='Detail')


class UpdateBrowserSessionRequest(BaseModel):
    action: BrowserSessionUpdateAction = Field(
        ..., description='The action to perform on the session', title='Action'
    )


class UpdateSessionRequest(BaseModel):
    action: SessionUpdateAction = Field(
        ..., description='The action to perform on the session', title='Action'
    )


class Title1(RootModel[str]):
    root: str = Field(
        ...,
        description='Display name for the skill (shows up in the public view)',
        max_length=100,
        title='Title',
    )


class Description1(RootModel[str]):
    root: str = Field(
        ...,
        description='Description of what the skill does (shows up in the public view)',
        max_length=1000,
        title='Description',
    )


class UpdateSkillRequest(BaseModel):
    title: Title1 | None = Field(
        None,
        description='Display name for the skill (shows up in the public view)',
        title='Title',
    )
    description: Description1 | None = Field(
        None,
        description='Description of what the skill does (shows up in the public view)',
        title='Description',
    )
    categories: List[SkillCategory] | None = Field(
        None, description='Categories to assign to the skill', title='Categories'
    )
    domains: List[str] | None = Field(
        None, description='Domains/websites this skill interacts with', title='Domains'
    )
    is_enabled: bool | None = Field(
        None,
        alias='isEnabled',
        description='Whether the skill is enabled for execution',
        title='Isenabled',
    )


class UpdateTaskRequest(BaseModel):
    action: TaskUpdateAction = Field(
        ..., description='The action to perform on the task', title='Action'
    )


class UploadFilePresignedUrlResponse(BaseModel):
    url: str = Field(..., description='The URL to upload the file to.', title='URL')
    method: Literal['POST'] = Field(
        ..., description='The HTTP method to use for the upload.', title='Method'
    )
    fields: Dict[str, str] = Field(
        ...,
        description='The form fields to include in the upload request.',
        title='Fields',
    )
    file_name: str = Field(
        ...,
        alias='fileName',
        description='The name of the file to upload (should be referenced when user wants to use the file in a task).',
        title='File Name',
    )
    expires_in: int = Field(
        ...,
        alias='expiresIn',
        description='The number of seconds until the presigned URL expires.',
        title='Expires In',
    )


class ContentType(Enum):
    image_jpg = 'image/jpg'
    image_jpeg = 'image/jpeg'
    image_png = 'image/png'
    image_gif = 'image/gif'
    image_webp = 'image/webp'
    image_svg_xml = 'image/svg+xml'
    application_pdf = 'application/pdf'
    application_msword = 'application/msword'
    application_vnd_openxmlformats_officedocument_wordprocessingml_document = (
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
    )
    application_vnd_ms_excel = 'application/vnd.ms-excel'
    application_vnd_openxmlformats_officedocument_spreadsheetml_sheet = (
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    )
    text_plain = 'text/plain'
    text_csv = 'text/csv'
    text_markdown = 'text/markdown'


class UploadFileRequest(BaseModel):
    file_name: str = Field(
        ...,
        alias='fileName',
        description='The name of the file to upload',
        max_length=255,
        min_length=1,
        title='File Name',
    )
    content_type: ContentType = Field(
        ...,
        alias='contentType',
        description='The content type of the file to upload',
        title='Content Type',
    )
    size_bytes: int = Field(
        ..., alias='sizeBytes', ge=1, le=10485760, title='Sizebytes'
    )


class ValidationError(BaseModel):
    loc: List[str | int] = Field(..., title='Location')
    msg: str = Field(..., title='Message')
    type: str = Field(..., title='Error Type')


class AccountView(BaseModel):
    name: str | None = Field(None, description='The name of the user', title='Name')
    total_credits_balance_usd: float = Field(
        ...,
        alias='totalCreditsBalanceUsd',
        description='The total credits balance in USD',
        title='Credits Balance USD',
    )
    monthly_credits_balance_usd: float = Field(
        ...,
        alias='monthlyCreditsBalanceUsd',
        description='Monthly subscription credits balance in USD',
        title='Monthly Credits Balance USD',
    )
    additional_credits_balance_usd: float = Field(
        ...,
        alias='additionalCreditsBalanceUsd',
        description='Additional top-up credits balance in USD',
        title='Additional Credits Balance USD',
    )
    rate_limit: int = Field(
        ...,
        alias='rateLimit',
        description='The rate limit for the account',
        title='Rate Limit',
    )
    plan_info: PlanInfo = Field(
        ..., alias='planInfo', description='The plan information', title='Plan Info'
    )
    project_id: UUID = Field(
        ..., alias='projectId', description='The ID of the project', title='Project ID'
    )


class BrowserSessionItemView(BaseModel):
    model_config = ConfigDict(
        regex_engine="python-re",
    )
    id: UUID = Field(..., description='Unique identifier for the session', title='ID')
    status: BrowserSessionStatus = Field(
        ...,
        description='Current status of the session (active/stopped)',
        title='Status',
    )
    live_url: str | None = Field(
        None,
        alias='liveUrl',
        description='URL where the browser can be viewed live in real-time',
        title='Live URL',
    )
    cdp_url: str | None = Field(
        None,
        alias='cdpUrl',
        description='Chrome DevTools Protocol URL for browser automation',
        title='CDP URL',
    )
    timeout_at: AwareDatetime = Field(
        ...,
        alias='timeoutAt',
        description='Timestamp when the session will timeout',
        title='Timeout At',
    )
    started_at: AwareDatetime = Field(
        ...,
        alias='startedAt',
        description='Timestamp when the session was created and started',
        title='Started At',
    )
    finished_at: AwareDatetime | None = Field(
        None,
        alias='finishedAt',
        description='Timestamp when the session was stopped (None if still active)',
        title='Finished At',
    )
    proxy_used_mb: str | None = Field(
        '0',
        alias='proxyUsedMb',
        description='Amount of proxy data used in MB',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Proxy Used MB',
    )
    proxy_cost: str | None = Field(
        '0',
        alias='proxyCost',
        description='Cost of proxy usage in USD',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Proxy Cost',
    )
    browser_cost: str | None = Field(
        '0',
        alias='browserCost',
        description='Cost of browser session hosting in USD',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Browser Cost',
    )
    agent_session_id: UUID | None = Field(
        None,
        alias='agentSessionId',
        description='ID of the agent session that created this browser (None for standalone BaaS sessions)',
        title='Agent Session ID',
    )
    recording_url: str | None = Field(
        None,
        alias='recordingUrl',
        description='Presigned URL to download the session recording (available after session ends, if recording was enabled)',
        title='Recording URL',
    )


class BrowserSessionListResponse(BaseModel):
    items: List[BrowserSessionItemView] = Field(
        ...,
        description='List of browser session views for the current page',
        title='Items',
    )
    total_items: int = Field(
        ...,
        alias='totalItems',
        description='Total number of items in the list',
        title='Total Items',
    )
    page_number: int = Field(
        ..., alias='pageNumber', description='Page number', title='Page Number'
    )
    page_size: int = Field(
        ..., alias='pageSize', description='Number of items per page', title='Page Size'
    )


class CreateBrowserSessionRequest(BaseModel):
    profile_id: UUID | None = Field(
        None,
        alias='profileId',
        description='The ID of the profile to use for the session',
        title='Profile ID',
    )
    proxy_country_code: ProxyCountryCode | None = Field(
        ProxyCountryCode.us,
        alias='proxyCountryCode',
        description='Country code for proxy location. Defaults to US. Set to null to disable proxy.',
        title='Proxy Country Code',
    )
    timeout: int | None = Field(
        60,
        description='The timeout for the session in minutes. All users can use up to 240 minutes (4 hours). Pay As You Go users are charged $0.06/hour, subscribers get 50% off.',
        title='Timeout',
    )
    browser_screen_width: BrowserScreenWidth | None = Field(
        None,
        alias='browserScreenWidth',
        description='Custom screen width in pixels for the browser.',
        title='Browser Screen Width',
    )
    browser_screen_height: BrowserScreenHeight | None = Field(
        None,
        alias='browserScreenHeight',
        description='Custom screen height in pixels for the browser.',
        title='Browser Screen Height',
    )
    allow_resizing: bool | None = Field(
        False,
        alias='allowResizing',
        description='Whether to allow the browser to be resized during the session (not recommended since it reduces stealthiness).',
        title='Allow Resizing',
    )
    custom_proxy: CustomProxy | None = Field(
        None,
        alias='customProxy',
        description='Custom proxy settings to use for the session. If not provided, our proxies will be used. Custom proxies are available on any active subscription.',
        title='Custom Proxy',
    )
    enable_recording: bool | None = Field(
        False,
        alias='enableRecording',
        description='If True, enables session recording. Defaults to False.',
        title='Enable Recording',
    )


class CreateSessionRequest(BaseModel):
    profile_id: UUID | None = Field(
        None,
        alias='profileId',
        description='The ID of the profile to use for the session',
        title='Profile ID',
    )
    proxy_country_code: ProxyCountryCode | None = Field(
        ProxyCountryCode.us,
        alias='proxyCountryCode',
        description='Country code for proxy location. Defaults to US. Set to null to disable proxy.',
        title='Proxy Country Code',
    )
    start_url: str | None = Field(
        None,
        alias='startUrl',
        description='URL to navigate to when the session starts.',
        title='Start URL',
    )
    browser_screen_width: BrowserScreenWidth | None = Field(
        None,
        alias='browserScreenWidth',
        description='Custom screen width in pixels for the browser.',
        title='Browser Screen Width',
    )
    browser_screen_height: BrowserScreenHeight | None = Field(
        None,
        alias='browserScreenHeight',
        description='Custom screen height in pixels for the browser.',
        title='Browser Screen Height',
    )
    persist_memory: bool | None = Field(
        True,
        alias='persistMemory',
        description='If True (default), tasks in this session share memory and history with each other, allowing follow-up tasks to continue from previous context. If False, each task runs as a standalone task without any previous task context.',
        title='Persist Memory',
    )
    keep_alive: bool | None = Field(
        True,
        alias='keepAlive',
        description='If True (default), the browser session stays alive after tasks complete, allowing follow-up tasks. If False, the session is closed immediately after task completion. Set to False for simple one-off tasks to reduce session idle time.',
        title='Keep Alive',
    )
    custom_proxy: CustomProxy | None = Field(
        None,
        alias='customProxy',
        description='Custom proxy settings to use for the session. If not provided, our proxies will be used. Custom proxies are available on any active subscription.',
        title='Custom Proxy',
    )
    enable_recording: bool | None = Field(
        False,
        alias='enableRecording',
        description='If True, enables session recording. Defaults to False.',
        title='Enable Recording',
    )


class CreateTaskRequest(BaseModel):
    task: str = Field(
        ...,
        description='The task prompt/instruction for the agent.',
        max_length=50000,
        min_length=1,
        title='Task',
    )
    llm: SupportedLLMs | None = Field(
        SupportedLLMs.browser_use_2_0,
        description='The LLM model to use for the agent.',
        title='LLM',
    )
    start_url: str | None = Field(
        None,
        alias='startUrl',
        description='The URL to start the task from.',
        title='Start URL',
    )
    max_steps: int | None = Field(
        100,
        alias='maxSteps',
        description='Maximum number of steps the agent can take before stopping.',
        ge=1,
        le=10000,
        title='Max Steps',
    )
    structured_output: str | None = Field(
        None,
        alias='structuredOutput',
        description='The stringified JSON schema for the structured output.',
        title='Structured Output',
    )
    session_id: UUID | None = Field(
        None,
        alias='sessionId',
        description='The ID of the session where the task will run.',
        title='Session ID',
    )
    metadata: Dict[str, str] | None = Field(
        None,
        description='The metadata for the task. Up to 10 key-value pairs.',
        title='Metadata',
    )
    secrets: Dict[str, str] | None = Field(
        None,
        description='The secrets for the task. Allowed domains are not required for secrets to be injected, but are recommended.',
        title='Secrets',
    )
    allowed_domains: List[str] | None = Field(
        None,
        alias='allowedDomains',
        description='The allowed domains for the task.',
        title='Allowed Domains',
    )
    op_vault_id: str | None = Field(
        None,
        alias='opVaultId',
        description='The ID of the 1Password vault to use for the task. This is used to inject secrets into the task.',
        title='1Password Vault ID',
    )
    session_settings: SessionSettings | None = Field(
        None,
        alias='sessionSettings',
        description='Session configuration for auto-created sessions. Only applies when session_id is not provided. Ignored when using an existing session.',
        title='Session Settings',
    )
    highlight_elements: bool | None = Field(
        False,
        alias='highlightElements',
        description='Tells the agent to highlight interactive elements on the page.',
        title='Highlight Elements',
    )
    flash_mode: bool | None = Field(
        False,
        alias='flashMode',
        description='Whether agent flash mode is enabled.',
        title='Flash Mode',
    )
    thinking: bool | None = Field(
        False, description='Whether agent thinking mode is enabled.', title='Thinking'
    )
    vision: bool | str | None = Field(
        True,
        description="Whether agent vision capabilities are enabled. Set to 'auto' to let the agent decide based on the model capabilities.",
        title='Vision',
    )
    system_prompt_extension: str | None = Field(
        '',
        alias='systemPromptExtension',
        description='Optional extension to the agent system prompt.',
        max_length=2000,
        title='System Prompt Extension',
    )
    judge: bool | None = Field(
        False,
        description='Enable judge mode to evaluate task completion against ground truth.',
        title='Judge',
    )
    judge_ground_truth: JudgeGroundTruth | None = Field(
        None,
        alias='judgeGroundTruth',
        description='Expected answer for judge evaluation.',
        title='Judge Ground Truth',
    )
    judge_llm: SupportedLLMs | None = Field(
        None,
        alias='judgeLlm',
        description='The LLM model to use for judging. If not provided, uses the default judge LLM.',
        title='Judge LLM',
    )
    skill_ids: List[str] | None = Field(
        None,
        alias='skillIds',
        description="List of skill IDs to enable for this task. Use ['*'] to enable all available skills for the project.",
        title='Skill IDs',
    )


class HTTPValidationError(BaseModel):
    detail: List[ValidationError] | None = Field(None, title='Detail')


class ParameterSchema(BaseModel):
    name: str = Field(..., title='Name')
    type: ParameterType
    required: bool | None = Field(True, title='Required')
    description: str | None = Field(None, title='Description')
    default: Any = Field(None, title='Default')
    cookie_domain: str | None = Field(None, alias='cookieDomain', title='Cookiedomain')


class ProfileListResponse(BaseModel):
    items: List[ProfileView] = Field(
        ..., description='List of profile views for the current page', title='Items'
    )
    total_items: int = Field(
        ...,
        alias='totalItems',
        description='Total number of items in the list',
        title='Total Items',
    )
    page_number: int = Field(
        ..., alias='pageNumber', description='Page number', title='Page Number'
    )
    page_size: int = Field(
        ..., alias='pageSize', description='Number of items per page', title='Page Size'
    )


class SessionItemView(BaseModel):
    model_config = ConfigDict(
        regex_engine="python-re",
    )
    id: UUID = Field(..., description='Unique identifier for the session', title='ID')
    status: SessionStatus = Field(
        ...,
        description='Current status of the session (active/stopped)',
        title='Status',
    )
    live_url: str | None = Field(
        None,
        alias='liveUrl',
        description='URL where the browser can be viewed live in real-time',
        title='Live URL',
    )
    recording_url: str | None = Field(
        None,
        alias='recordingUrl',
        description='Presigned URL to download the session recording (available after session ends, if recording was enabled)',
        title='Recording URL',
    )
    started_at: AwareDatetime = Field(
        ...,
        alias='startedAt',
        description='Timestamp when the session was created and started',
        title='Started At',
    )
    finished_at: AwareDatetime | None = Field(
        None,
        alias='finishedAt',
        description='Timestamp when the session was stopped (None if still active)',
        title='Finished At',
    )
    persist_memory: bool = Field(
        ...,
        alias='persistMemory',
        description='Whether tasks in this session share memory and history with each other',
        title='Persist Memory',
    )
    keep_alive: bool = Field(
        ...,
        alias='keepAlive',
        description='Whether the browser session stays alive after tasks complete',
        title='Keep Alive',
    )
    proxy_used_mb: str | None = Field(
        '0',
        alias='proxyUsedMb',
        description='Amount of proxy data used in MB',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Proxy Used MB',
    )
    proxy_cost: str | None = Field(
        '0',
        alias='proxyCost',
        description='Cost of proxy usage in USD',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Proxy Cost',
    )


class SessionListResponse(BaseModel):
    items: List[SessionItemView] = Field(
        ..., description='List of session views for the current page', title='Items'
    )
    total_items: int = Field(
        ...,
        alias='totalItems',
        description='Total number of items in the list',
        title='Total Items',
    )
    page_number: int = Field(
        ..., alias='pageNumber', description='Page number', title='Page Number'
    )
    page_size: int = Field(
        ..., alias='pageSize', description='Number of items per page', title='Page Size'
    )


class SkillExecutionListResponse(BaseModel):
    items: List[SkillExecutionView] = Field(
        ..., description='List of executions', title='Items'
    )
    total_items: int = Field(
        ...,
        alias='totalItems',
        description='Total number of items in the list',
        title='Total Items',
    )
    page_number: int = Field(
        ..., alias='pageNumber', description='Page number', title='Page Number'
    )
    page_size: int = Field(
        ..., alias='pageSize', description='Number of items per page', title='Page Size'
    )


class SkillResponse(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the skill', title='ID')
    slug: str | None = Field(
        None, description='URL-friendly slug for the skill', title='Slug'
    )
    title: str = Field(
        ...,
        description='Title of the skill (shows up in the public view)',
        title='Title',
    )
    description: str = Field(
        ...,
        description='Description of the skill (shows up in the public view)',
        title='Description',
    )
    categories: List[SkillCategory] = Field(
        ..., description='Categories of the skill', title='Categories'
    )
    domains: List[str] = Field(
        ..., description='Domains/websites this skill interacts with', title='Domains'
    )
    goal: str | None = Field(
        None,
        description='Goal of the skill (not shown in the public view)',
        title='Goal',
    )
    agent_prompt: str | None = Field(
        None,
        alias='agentPrompt',
        description='Prompt for the agent to use when generating the skill automatically (not shown in the public view)',
        title='Agent Prompt',
    )
    status: SkillsGenerationStatus = Field(
        ..., description='Status of the skill', title='Status'
    )
    parameters: List[ParameterSchema] = Field(
        ..., description='Input parameters of the skill', title='Parameters'
    )
    output_schema: Dict[str, Any] = Field(
        ...,
        alias='outputSchema',
        description='Output schema of the skill',
        title='Output Schema',
    )
    is_enabled: bool = Field(
        ...,
        alias='isEnabled',
        description='Whether the skill is enabled',
        title='Enabled',
    )
    is_public: bool = Field(
        ...,
        alias='isPublic',
        description='Whether the skill is publicly available',
        title='Is Public',
    )
    icon_url: str | None = Field(
        None,
        alias='iconUrl',
        description='URL of the custom skill icon',
        title='Icon URL',
    )
    first_published_at: AwareDatetime | None = Field(
        None,
        alias='firstPublishedAt',
        description='When the skill was first published',
        title='First Published At',
    )
    last_published_at: AwareDatetime | None = Field(
        None,
        alias='lastPublishedAt',
        description='When the skill was last published',
        title='Last Published At',
    )
    current_version: int | None = Field(
        ...,
        alias='currentVersion',
        description='Current version of the skill',
        title='Current Version',
    )
    current_version_started_at: AwareDatetime | None = Field(
        None,
        alias='currentVersionStartedAt',
        description='When the current version started generating',
        title='Current Version Started At',
    )
    current_version_finished_at: AwareDatetime | None = Field(
        None,
        alias='currentVersionFinishedAt',
        description='When the current version finished generating',
        title='Current Version Finished At',
    )
    code: str | None = Field(
        None,
        description='Base64 encoded generated code (contact support@browser-use.com to get access) - ENTERPRISE ONLY',
        title='Code (base64 encoded) - ENTERPRISE ONLY',
    )
    cloned_from_skill_id: UUID | None = Field(
        None,
        alias='clonedFromSkillId',
        description='Unique identifier for the skill this skill was cloned from',
        title='Cloned From Skill ID',
    )
    created_at: AwareDatetime = Field(
        ..., alias='createdAt', description='Creation timestamp', title='Created At'
    )
    updated_at: AwareDatetime = Field(
        ..., alias='updatedAt', description='Last update timestamp', title='Updated At'
    )


class TaskItemView(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the task', title='ID')
    session_id: UUID = Field(
        ...,
        alias='sessionId',
        description='ID of the session this task belongs to',
        title='Session ID',
    )
    llm: str = Field(
        ...,
        description='The LLM model used for this task represented as a string',
        title='LLM',
    )
    task: str = Field(
        ..., description='The task prompt/instruction given to the agent', title='Task'
    )
    status: TaskStatus
    created_at: AwareDatetime = Field(
        ...,
        alias='createdAt',
        description='Naive UTC timestamp when the task was created',
        title='Created At',
    )
    started_at: AwareDatetime | None = Field(
        None,
        alias='startedAt',
        description='Naive UTC timestamp when the task was started (None if task has not started yet)',
        title='Started At',
    )
    finished_at: AwareDatetime | None = Field(
        None,
        alias='finishedAt',
        description='Naive UTC timestamp when the task completed (None if still running)',
        title='Finished At',
    )
    metadata: Dict[str, Any] | None = Field(
        {},
        description='Optional additional metadata associated with the task set by the user',
        title='Metadata',
    )
    output: str | None = Field(
        None, description='Final output/result of the task', title='Output'
    )
    browser_use_version: str | None = Field(
        None,
        alias='browserUseVersion',
        description='Version of browser-use used for this task (older tasks may not have this set)',
        title='Browser Use Version',
    )
    is_success: bool | None = Field(
        None,
        alias='isSuccess',
        description='Whether the task was successful (self-reported by the agent)',
        title='Is Success',
    )
    judgement: str | None = Field(
        None,
        description='Stringified JSON object containing the full report from the judge',
        title='Judgement',
    )
    judge_verdict: bool | None = Field(
        None,
        alias='judgeVerdict',
        description='Judge verdict - True if the judge found the task to be successful, False otherwise (None if judge is not enabled)',
        title='Judge Verdict',
    )
    cost: Cost | None = Field(
        None,
        description='Total cost of the task in USD. This is the sum of all step costs incurred during task execution.',
        title='Cost',
    )
    suggestions: List[Dict[str, Any]] | None = Field(
        None,
        description='List of actionable suggestions for improving task configuration based on detected issues during execution.',
        title='Suggestions',
    )


class TaskListResponse(BaseModel):
    items: List[TaskItemView] = Field(
        ..., description='List of task views for the current page', title='Items'
    )
    total_items: int = Field(
        ...,
        alias='totalItems',
        description='Total number of items in the list',
        title='Total Items',
    )
    page_number: int = Field(
        ..., alias='pageNumber', description='Page number', title='Page Number'
    )
    page_size: int = Field(
        ..., alias='pageSize', description='Number of items per page', title='Page Size'
    )


class MarketplaceSkillResponse(BaseModel):
    id: UUID = Field(..., description='Unique identifier for the skill', title='ID')
    slug: str = Field(..., description='URL-friendly slug for the skill', title='Slug')
    title: str = Field(
        ...,
        description='Title of the skill (shows up in the public view)',
        title='Title',
    )
    description: str = Field(
        ...,
        description='Description of the skill (shows up in the public view)',
        title='Description',
    )
    categories: List[SkillCategory] = Field(
        ..., description='Categories of the skill', title='Categories'
    )
    domains: List[str] = Field(
        ..., description='Domains/websites this skill interacts with', title='Domains'
    )
    parameters: List[ParameterSchema] = Field(
        ..., description='Input parameters of the skill', title='Parameters'
    )
    output_schema: Dict[str, Any] = Field(
        ...,
        alias='outputSchema',
        description='Output schema of the skill',
        title='Output Schema',
    )
    current_version: int | None = Field(
        ...,
        alias='currentVersion',
        description='Current version of the skill',
        title='Current Version',
    )
    is_official: bool = Field(
        ...,
        alias='isOfficial',
        description='Whether the skill is official (verified by Browser Use)',
        title='Is Official',
    )
    clone_count: int = Field(
        ...,
        alias='cloneCount',
        description='Number of times this skill has been cloned',
        title='Clone Count',
    )
    icon_url: str | None = Field(
        None,
        alias='iconUrl',
        description='URL of the custom skill icon',
        title='Icon URL',
    )
    first_published_at: AwareDatetime = Field(
        ...,
        alias='firstPublishedAt',
        description='When the skill was first published',
        title='First Published At',
    )
    last_published_at: AwareDatetime = Field(
        ...,
        alias='lastPublishedAt',
        description='When the skill was last published',
        title='Last Published At',
    )
    created_at: AwareDatetime = Field(
        ..., alias='createdAt', description='Creation timestamp', title='Created At'
    )
    updated_at: AwareDatetime = Field(
        ..., alias='updatedAt', description='Last update timestamp', title='Updated At'
    )


class SessionView(BaseModel):
    model_config = ConfigDict(
        regex_engine="python-re",
    )
    id: UUID = Field(..., description='Unique identifier for the session', title='ID')
    status: SessionStatus = Field(
        ...,
        description='Current status of the session (active/stopped)',
        title='Status',
    )
    live_url: str | None = Field(
        None,
        alias='liveUrl',
        description='URL where the browser can be viewed live in real-time',
        title='Live URL',
    )
    recording_url: str | None = Field(
        None,
        alias='recordingUrl',
        description='Presigned URL to download the session recording (available after session ends, if recording was enabled)',
        title='Recording URL',
    )
    started_at: AwareDatetime = Field(
        ...,
        alias='startedAt',
        description='Timestamp when the session was created and started',
        title='Started At',
    )
    finished_at: AwareDatetime | None = Field(
        None,
        alias='finishedAt',
        description='Timestamp when the session was stopped (None if still active)',
        title='Finished At',
    )
    tasks: List[TaskItemView] = Field(
        ..., description='List of tasks associated with this session', title='Tasks'
    )
    public_share_url: str | None = Field(
        None,
        alias='publicShareUrl',
        description='Optional URL to access the public share of the session',
        title='Public Share URL',
    )
    persist_memory: bool | None = Field(
        True,
        alias='persistMemory',
        description='Whether tasks in this session share memory and history with each other',
        title='Persist Memory',
    )
    keep_alive: bool | None = Field(
        True,
        alias='keepAlive',
        description='Whether the browser session stays alive after tasks complete',
        title='Keep Alive',
    )
    proxy_used_mb: str | None = Field(
        '0',
        alias='proxyUsedMb',
        description='Amount of proxy data used in MB',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Proxy Used MB',
    )
    proxy_cost: str | None = Field(
        '0',
        alias='proxyCost',
        description='Cost of proxy usage in USD',
        pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
        title='Proxy Cost',
    )


class SkillListResponse(BaseModel):
    items: List[SkillResponse] = Field(..., description='List of skills', title='Items')
    total_items: int = Field(
        ...,
        alias='totalItems',
        description='Total number of items in the list',
        title='Total Items',
    )
    page_number: int = Field(
        ..., alias='pageNumber', description='Page number', title='Page Number'
    )
    page_size: int = Field(
        ..., alias='pageSize', description='Number of items per page', title='Page Size'
    )


class MarketplaceSkillListResponse(BaseModel):
    items: List[MarketplaceSkillResponse] = Field(
        ..., description='List of skills', title='Items'
    )
    total_items: int = Field(
        ...,
        alias='totalItems',
        description='Total number of items in the list',
        title='Total Items',
    )
    page_number: int = Field(
        ..., alias='pageNumber', description='Page number', title='Page Number'
    )
    page_size: int = Field(
        ..., alias='pageSize', description='Number of items per page', title='Page Size'
    )
