2025-05-02 21:34:56 -07:00
from __future__ import annotations
2025-03-24 22:08:37 -07:00
from datetime import datetime
2025-03-24 15:15:21 -07:00
from enum import StrEnum
2025-03-30 21:14:52 -07:00
from typing import Annotated , Any , Literal , Union
2025-03-24 15:15:21 -07:00
from zoneinfo import ZoneInfo
2025-03-30 21:14:52 -07:00
from pydantic import BaseModel , Field , field_validator
2025-03-24 23:16:10 -07:00
2025-04-01 15:52:35 -04:00
from skyvern . forge . sdk . schemas . files import FileInfo
2025-05-24 23:46:31 -07:00
from skyvern . schemas . docs . doc_examples import (
BROWSER_SESSION_ID_EXAMPLES ,
ERROR_CODE_MAPPING_EXAMPLES ,
TASK_PROMPT_EXAMPLES ,
TASK_URL_EXAMPLES ,
TOTP_IDENTIFIER_EXAMPLES ,
TOTP_URL_EXAMPLES ,
)
from skyvern . schemas . docs . doc_strings import (
BROWSER_SESSION_ID_DOC_STRING ,
DATA_EXTRACTION_SCHEMA_DOC_STRING ,
ERROR_CODE_MAPPING_DOC_STRING ,
MAX_STEPS_DOC_STRING ,
2025-05-30 20:07:12 -07:00
MODEL_CONFIG ,
2025-05-24 23:46:31 -07:00
PROXY_LOCATION_DOC_STRING ,
TASK_ENGINE_DOC_STRING ,
TASK_PROMPT_DOC_STRING ,
TASK_URL_DOC_STRING ,
TOTP_IDENTIFIER_DOC_STRING ,
TOTP_URL_DOC_STRING ,
WEBHOOK_URL_DOC_STRING ,
)
2025-03-24 23:33:20 -07:00
from skyvern . utils . url_validators import validate_url
2025-03-24 22:08:37 -07:00
2025-03-24 15:15:21 -07:00
class ProxyLocation ( StrEnum ) :
2025-03-30 23:57:54 -07:00
RESIDENTIAL = " RESIDENTIAL "
2025-03-24 15:15:21 -07:00
US_CA = " US-CA "
US_NY = " US-NY "
US_TX = " US-TX "
US_FL = " US-FL "
US_WA = " US-WA "
RESIDENTIAL_ES = " RESIDENTIAL_ES "
RESIDENTIAL_IE = " RESIDENTIAL_IE "
RESIDENTIAL_GB = " RESIDENTIAL_GB "
RESIDENTIAL_IN = " RESIDENTIAL_IN "
RESIDENTIAL_JP = " RESIDENTIAL_JP "
RESIDENTIAL_FR = " RESIDENTIAL_FR "
RESIDENTIAL_DE = " RESIDENTIAL_DE "
RESIDENTIAL_NZ = " RESIDENTIAL_NZ "
RESIDENTIAL_ZA = " RESIDENTIAL_ZA "
RESIDENTIAL_AR = " RESIDENTIAL_AR "
2025-06-27 09:41:38 +09:00
RESIDENTIAL_AU = " RESIDENTIAL_AU "
2025-10-02 11:12:06 -04:00
RESIDENTIAL_BR = " RESIDENTIAL_BR "
RESIDENTIAL_TR = " RESIDENTIAL_TR "
RESIDENTIAL_CA = " RESIDENTIAL_CA "
RESIDENTIAL_MX = " RESIDENTIAL_MX "
RESIDENTIAL_IT = " RESIDENTIAL_IT "
RESIDENTIAL_NL = " RESIDENTIAL_NL "
2025-03-24 15:15:21 -07:00
RESIDENTIAL_ISP = " RESIDENTIAL_ISP "
NONE = " NONE "
2025-05-02 21:34:56 -07:00
@staticmethod
def get_zone ( proxy_location : ProxyLocation ) - > str :
zone_mapping = {
ProxyLocation . US_CA : " california " ,
ProxyLocation . US_NY : " newyork " ,
ProxyLocation . US_TX : " texas " ,
ProxyLocation . US_FL : " florida " ,
ProxyLocation . US_WA : " washington " ,
ProxyLocation . RESIDENTIAL : " residential_long-country-us " ,
}
if proxy_location in zone_mapping :
return zone_mapping [ proxy_location ]
raise ValueError ( f " No zone mapping for proxy location: { proxy_location } " )
@classmethod
def residential_country_locations ( cls ) - > set [ ProxyLocation ] :
return {
cls . RESIDENTIAL ,
cls . RESIDENTIAL_ES ,
cls . RESIDENTIAL_IE ,
cls . RESIDENTIAL_GB ,
cls . RESIDENTIAL_IN ,
cls . RESIDENTIAL_JP ,
cls . RESIDENTIAL_FR ,
cls . RESIDENTIAL_DE ,
cls . RESIDENTIAL_NZ ,
cls . RESIDENTIAL_ZA ,
cls . RESIDENTIAL_AR ,
2025-06-27 09:41:38 +09:00
cls . RESIDENTIAL_AU ,
2025-10-02 11:12:06 -04:00
cls . RESIDENTIAL_BR ,
cls . RESIDENTIAL_TR ,
cls . RESIDENTIAL_CA ,
cls . RESIDENTIAL_MX ,
cls . RESIDENTIAL_IT ,
cls . RESIDENTIAL_NL ,
2025-05-02 21:34:56 -07:00
}
@staticmethod
def get_proxy_count ( proxy_location : ProxyLocation ) - > int :
counts = {
ProxyLocation . RESIDENTIAL : 10000 ,
ProxyLocation . RESIDENTIAL_ES : 2000 ,
ProxyLocation . RESIDENTIAL_IE : 2000 ,
ProxyLocation . RESIDENTIAL_GB : 2000 ,
ProxyLocation . RESIDENTIAL_IN : 2000 ,
ProxyLocation . RESIDENTIAL_JP : 2000 ,
ProxyLocation . RESIDENTIAL_FR : 2000 ,
ProxyLocation . RESIDENTIAL_DE : 2000 ,
ProxyLocation . RESIDENTIAL_NZ : 2000 ,
ProxyLocation . RESIDENTIAL_ZA : 2000 ,
ProxyLocation . RESIDENTIAL_AR : 2000 ,
2025-06-27 09:41:38 +09:00
ProxyLocation . RESIDENTIAL_AU : 2000 ,
2025-10-02 11:12:06 -04:00
ProxyLocation . RESIDENTIAL_BR : 2000 ,
ProxyLocation . RESIDENTIAL_TR : 2000 ,
ProxyLocation . RESIDENTIAL_CA : 2000 ,
ProxyLocation . RESIDENTIAL_MX : 2000 ,
ProxyLocation . RESIDENTIAL_IT : 2000 ,
ProxyLocation . RESIDENTIAL_NL : 2000 ,
2025-05-02 21:34:56 -07:00
}
return counts . get ( proxy_location , 10000 )
@staticmethod
def get_country_code ( proxy_location : ProxyLocation ) - > str :
mapping = {
ProxyLocation . RESIDENTIAL : " US " ,
ProxyLocation . RESIDENTIAL_ES : " ES " ,
ProxyLocation . RESIDENTIAL_IE : " IE " ,
ProxyLocation . RESIDENTIAL_GB : " GB " ,
ProxyLocation . RESIDENTIAL_IN : " IN " ,
ProxyLocation . RESIDENTIAL_JP : " JP " ,
ProxyLocation . RESIDENTIAL_FR : " FR " ,
ProxyLocation . RESIDENTIAL_DE : " DE " ,
ProxyLocation . RESIDENTIAL_NZ : " NZ " ,
ProxyLocation . RESIDENTIAL_ZA : " ZA " ,
ProxyLocation . RESIDENTIAL_AR : " AR " ,
2025-06-27 09:41:38 +09:00
ProxyLocation . RESIDENTIAL_AU : " AU " ,
2025-10-02 11:12:06 -04:00
ProxyLocation . RESIDENTIAL_BR : " BR " ,
ProxyLocation . RESIDENTIAL_TR : " TR " ,
ProxyLocation . RESIDENTIAL_CA : " CA " ,
ProxyLocation . RESIDENTIAL_MX : " MX " ,
ProxyLocation . RESIDENTIAL_IT : " IT " ,
ProxyLocation . RESIDENTIAL_NL : " NL " ,
2025-05-02 21:34:56 -07:00
}
return mapping . get ( proxy_location , " US " )
2025-03-24 15:15:21 -07:00
def get_tzinfo_from_proxy ( proxy_location : ProxyLocation ) - > ZoneInfo | None :
if proxy_location == ProxyLocation . NONE :
return None
if proxy_location == ProxyLocation . US_CA :
return ZoneInfo ( " America/Los_Angeles " )
if proxy_location == ProxyLocation . US_NY :
return ZoneInfo ( " America/New_York " )
if proxy_location == ProxyLocation . US_TX :
return ZoneInfo ( " America/Chicago " )
if proxy_location == ProxyLocation . US_FL :
return ZoneInfo ( " America/New_York " )
if proxy_location == ProxyLocation . US_WA :
return ZoneInfo ( " America/New_York " )
if proxy_location == ProxyLocation . RESIDENTIAL :
return ZoneInfo ( " America/New_York " )
if proxy_location == ProxyLocation . RESIDENTIAL_ES :
return ZoneInfo ( " Europe/Madrid " )
if proxy_location == ProxyLocation . RESIDENTIAL_IE :
return ZoneInfo ( " Europe/Dublin " )
if proxy_location == ProxyLocation . RESIDENTIAL_GB :
return ZoneInfo ( " Europe/London " )
if proxy_location == ProxyLocation . RESIDENTIAL_IN :
return ZoneInfo ( " Asia/Kolkata " )
if proxy_location == ProxyLocation . RESIDENTIAL_JP :
return ZoneInfo ( " Asia/Tokyo " )
if proxy_location == ProxyLocation . RESIDENTIAL_FR :
return ZoneInfo ( " Europe/Paris " )
if proxy_location == ProxyLocation . RESIDENTIAL_DE :
return ZoneInfo ( " Europe/Berlin " )
if proxy_location == ProxyLocation . RESIDENTIAL_NZ :
return ZoneInfo ( " Pacific/Auckland " )
if proxy_location == ProxyLocation . RESIDENTIAL_ZA :
return ZoneInfo ( " Africa/Johannesburg " )
if proxy_location == ProxyLocation . RESIDENTIAL_AR :
return ZoneInfo ( " America/Argentina/Buenos_Aires " )
2025-06-27 09:41:38 +09:00
if proxy_location == ProxyLocation . RESIDENTIAL_AU :
return ZoneInfo ( " Australia/Sydney " )
2025-10-02 11:12:06 -04:00
if proxy_location == ProxyLocation . RESIDENTIAL_BR :
return ZoneInfo ( " America/Sao_Paulo " )
if proxy_location == ProxyLocation . RESIDENTIAL_TR :
return ZoneInfo ( " Europe/Istanbul " )
if proxy_location == ProxyLocation . RESIDENTIAL_CA :
return ZoneInfo ( " America/Toronto " )
if proxy_location == ProxyLocation . RESIDENTIAL_MX :
return ZoneInfo ( " America/Mexico_City " )
if proxy_location == ProxyLocation . RESIDENTIAL_IT :
return ZoneInfo ( " Europe/Rome " )
if proxy_location == ProxyLocation . RESIDENTIAL_NL :
return ZoneInfo ( " Europe/Amsterdam " )
2025-03-24 15:15:21 -07:00
if proxy_location == ProxyLocation . RESIDENTIAL_ISP :
return ZoneInfo ( " America/New_York " )
return None
2025-03-24 22:08:37 -07:00
2025-03-30 18:34:48 -07:00
class RunType ( StrEnum ) :
task_v1 = " task_v1 "
task_v2 = " task_v2 "
workflow_run = " workflow_run "
2025-04-11 11:18:53 -07:00
openai_cua = " openai_cua "
2025-04-28 09:49:44 +08:00
anthropic_cua = " anthropic_cua "
2025-06-13 01:23:39 -04:00
ui_tars = " ui_tars "
2025-03-30 18:34:48 -07:00
2025-03-24 22:08:37 -07:00
class RunEngine ( StrEnum ) :
skyvern_v1 = " skyvern-1.0 "
skyvern_v2 = " skyvern-2.0 "
2025-04-11 11:18:53 -07:00
openai_cua = " openai-cua "
2025-04-28 09:49:44 +08:00
anthropic_cua = " anthropic-cua "
2025-06-13 01:23:39 -04:00
ui_tars = " ui-tars "
2025-04-28 09:49:44 +08:00
2025-06-13 01:23:39 -04:00
CUA_ENGINES = [ RunEngine . openai_cua , RunEngine . anthropic_cua , RunEngine . ui_tars ]
CUA_RUN_TYPES = [ RunType . openai_cua , RunType . anthropic_cua , RunType . ui_tars ]
2025-03-24 22:08:37 -07:00
2025-03-30 18:43:24 -07:00
class RunStatus ( StrEnum ) :
2025-03-24 22:08:37 -07:00
created = " created "
queued = " queued "
running = " running "
timed_out = " timed_out "
failed = " failed "
terminated = " terminated "
completed = " completed "
canceled = " canceled "
2025-03-30 18:34:48 -07:00
def is_final ( self ) - > bool :
return self in [ self . failed , self . terminated , self . canceled , self . timed_out , self . completed ]
2025-03-24 22:08:37 -07:00
class TaskRunRequest ( BaseModel ) :
2025-05-24 23:46:31 -07:00
prompt : str = Field (
description = TASK_PROMPT_DOC_STRING ,
examples = TASK_PROMPT_EXAMPLES ,
)
2025-03-30 23:57:54 -07:00
url : str | None = Field (
default = None ,
2025-05-24 23:46:31 -07:00
description = TASK_URL_DOC_STRING ,
examples = TASK_URL_EXAMPLES ,
2025-03-30 23:57:54 -07:00
)
engine : RunEngine = Field (
2025-05-16 16:11:22 -07:00
default = RunEngine . skyvern_v2 ,
2025-05-24 23:46:31 -07:00
description = TASK_ENGINE_DOC_STRING ,
)
title : str | None = Field (
default = None , description = " The title for the task " , examples = [ " The title of my first skyvern task " ]
2025-03-30 23:57:54 -07:00
)
2025-03-31 10:16:33 -07:00
proxy_location : ProxyLocation | None = Field (
2025-05-24 23:46:31 -07:00
default = ProxyLocation . RESIDENTIAL ,
description = PROXY_LOCATION_DOC_STRING ,
2025-03-30 23:57:54 -07:00
)
data_extraction_schema : dict | list | str | None = Field (
2025-05-24 23:46:31 -07:00
default = None ,
description = DATA_EXTRACTION_SCHEMA_DOC_STRING ,
2025-03-30 23:57:54 -07:00
)
error_code_mapping : dict [ str , str ] | None = Field (
2025-05-24 23:46:31 -07:00
default = None ,
description = ERROR_CODE_MAPPING_DOC_STRING ,
examples = ERROR_CODE_MAPPING_EXAMPLES ,
2025-03-30 23:57:54 -07:00
)
max_steps : int | None = Field (
2025-05-24 23:46:31 -07:00
default = None ,
description = MAX_STEPS_DOC_STRING ,
examples = [ 10 , 25 ] ,
2025-03-30 23:57:54 -07:00
)
webhook_url : str | None = Field (
2025-05-24 23:46:31 -07:00
default = None ,
description = WEBHOOK_URL_DOC_STRING ,
examples = [ " https://my-site.com/webhook " ] ,
2025-03-30 23:57:54 -07:00
)
totp_identifier : str | None = Field (
default = None ,
2025-05-24 23:46:31 -07:00
description = TOTP_IDENTIFIER_DOC_STRING ,
examples = TOTP_IDENTIFIER_EXAMPLES ,
2025-03-30 23:57:54 -07:00
)
totp_url : str | None = Field (
default = None ,
2025-05-24 23:46:31 -07:00
description = TOTP_URL_DOC_STRING ,
examples = TOTP_URL_EXAMPLES ,
2025-03-30 23:57:54 -07:00
)
browser_session_id : str | None = Field (
default = None ,
2025-05-24 23:46:31 -07:00
description = BROWSER_SESSION_ID_DOC_STRING ,
examples = BROWSER_SESSION_ID_EXAMPLES ,
2025-03-30 23:57:54 -07:00
)
2025-05-30 20:07:12 -07:00
model : dict [ str , Any ] | None = Field (
default = None ,
description = MODEL_CONFIG ,
examples = None ,
)
2025-06-19 00:42:34 -07:00
extra_http_headers : dict [ str , str ] | None = Field (
default = None ,
description = " The extra HTTP headers for the requests in browser. " ,
)
2025-05-16 16:11:22 -07:00
publish_workflow : bool = Field (
default = False ,
description = " Whether to publish this task as a reusable workflow. Only available for skyvern-2.0. " ,
)
include_action_history_in_verification : bool | None = Field (
2025-05-15 08:18:24 -07:00
default = False , description = " Whether to include action history when verifying that the task is complete "
)
2025-07-03 02:03:01 -07:00
max_screenshot_scrolls : int | None = Field (
2025-06-13 23:59:50 -07:00
default = None ,
2025-07-03 02:03:01 -07:00
description = " The maximum number of scrolls for the post action screenshot. When it ' s None or 0, it takes the current viewpoint screenshot. " ,
2025-06-13 23:59:50 -07:00
)
2025-08-21 11:16:22 +08:00
browser_address : str | None = Field (
default = None ,
description = " The CDP address for the task. " ,
examples = [ " http://127.0.0.1:9222 " , " ws://127.0.0.1:9222/devtools/browser/1234567890 " ] ,
)
2025-03-24 23:16:10 -07:00
@field_validator ( " url " , " webhook_url " , " totp_url " )
@classmethod
def validate_urls ( cls , url : str | None ) - > str | None :
2025-03-30 23:57:54 -07:00
"""
Validates that URLs provided to Skyvern are properly formatted .
Args :
url : The URL for Skyvern to validate
Returns :
The validated URL or None if no URL was provided
"""
2025-03-24 23:16:10 -07:00
if url is None :
return None
return validate_url ( url )
2025-03-24 22:08:37 -07:00
2025-03-30 21:14:52 -07:00
class WorkflowRunRequest ( BaseModel ) :
2025-05-16 16:11:22 -07:00
workflow_id : str = Field (
description = " ID of the workflow to run. Workflow ID starts with `wpid_`. " , examples = [ " wpid_123 " ]
)
2025-07-18 12:02:32 -07:00
parameters : dict [ str , Any ] | None = Field ( default = None , description = " Parameters to pass to the workflow " )
2025-05-16 17:55:46 -07:00
title : str | None = Field ( default = None , description = " The title for this workflow run " )
proxy_location : ProxyLocation | None = Field (
2025-05-24 23:46:31 -07:00
default = ProxyLocation . RESIDENTIAL ,
description = PROXY_LOCATION_DOC_STRING ,
2025-03-30 23:57:54 -07:00
)
webhook_url : str | None = Field (
2025-05-16 16:11:22 -07:00
default = None ,
description = " URL to send workflow status updates to after a run is finished. Refer to https://docs.skyvern.com/running-tasks/webhooks-faq for webhook questions. " ,
2025-03-30 23:57:54 -07:00
)
totp_url : str | None = Field (
default = None ,
2025-05-24 23:46:31 -07:00
description = TOTP_URL_DOC_STRING ,
examples = TOTP_URL_EXAMPLES ,
2025-03-30 23:57:54 -07:00
)
totp_identifier : str | None = Field (
default = None ,
2025-05-24 23:46:31 -07:00
description = TOTP_IDENTIFIER_DOC_STRING ,
examples = TOTP_IDENTIFIER_EXAMPLES ,
2025-03-30 23:57:54 -07:00
)
browser_session_id : str | None = Field (
default = None ,
2025-05-16 16:11:22 -07:00
description = " ID of a Skyvern browser session to reuse, having it continue from the current screen state " ,
2025-03-30 23:57:54 -07:00
)
2025-07-03 02:03:01 -07:00
max_screenshot_scrolls : int | None = Field (
2025-06-13 23:59:50 -07:00
default = None ,
2025-07-03 02:03:01 -07:00
description = " The maximum number of scrolls for the post action screenshot. When it ' s None or 0, it takes the current viewpoint screenshot. " ,
2025-06-13 23:59:50 -07:00
)
2025-06-19 00:42:34 -07:00
extra_http_headers : dict [ str , str ] | None = Field (
default = None ,
description = " The extra HTTP headers for the requests in browser. " ,
)
2025-08-21 11:16:22 +08:00
browser_address : str | None = Field (
default = None ,
description = " The CDP address for the workflow run. " ,
examples = [ " http://127.0.0.1:9222 " , " ws://127.0.0.1:9222/devtools/browser/1234567890 " ] ,
)
2025-10-01 14:13:56 -07:00
ai_fallback : bool | None = Field (
default = None ,
description = " Whether to fallback to AI if the workflow run fails. " ,
)
run_with : str | None = Field (
default = None ,
description = " Whether to run the workflow with agent or code. " ,
)
2025-03-30 21:14:52 -07:00
@field_validator ( " webhook_url " , " totp_url " )
@classmethod
def validate_urls ( cls , url : str | None ) - > str | None :
if url is None :
return None
return validate_url ( url )
2025-07-04 15:34:15 -04:00
class BlockRunRequest ( WorkflowRunRequest ) :
block_labels : list [ str ] = Field (
description = " Labels of the blocks to execute " ,
examples = [ " block_1 " , " block_2 " ] ,
)
2025-08-28 20:05:24 -04:00
block_outputs : dict [ str , Any ] | None = Field (
default = None ,
# NOTE(jdo): this is either the last output of the block for a given
# org_id/user_id, or an override supplied by the user
description = " Any active outputs of blocks in a workflow being debugged " ,
)
2025-10-01 13:52:42 -04:00
code_gen : bool | None = Field (
default = False ,
description = " Whether to generate colde for blocks that support it " ,
)
2025-10-01 07:21:08 -04:00
debug_session_id : str | None = Field (
default = None ,
description = " ID of the debug session to use for this block run " ,
)
2025-07-04 15:34:15 -04:00
2025-09-14 22:53:52 -07:00
class ScriptRunResponse ( BaseModel ) :
ai_fallback_triggered : bool = False
2025-03-30 21:14:52 -07:00
class BaseRunResponse ( BaseModel ) :
2025-05-16 16:11:22 -07:00
run_id : str = Field (
description = " Unique identifier for this run. Run ID starts with `tsk_` for task runs and `wr_` for workflow runs. " ,
examples = [ " tsk_123 " , " tsk_v2_123 " , " wr_123 " ] ,
)
status : RunStatus = Field (
description = " Current status of the run " ,
examples = [ " created " , " queued " , " running " , " timed_out " , " failed " , " terminated " , " completed " , " canceled " ] ,
)
2025-03-30 23:57:54 -07:00
output : dict | list | str | None = Field (
2025-05-16 16:11:22 -07:00
default = None ,
description = " Output data from the run, if any. Format/schema depends on the data extracted by the run. " ,
2025-03-30 23:57:54 -07:00
)
2025-04-01 15:52:35 -04:00
downloaded_files : list [ FileInfo ] | None = Field ( default = None , description = " List of files downloaded during the run " )
recording_url : str | None = Field ( default = None , description = " URL to the recording of the run " )
2025-05-21 15:25:29 -07:00
screenshot_urls : list [ str ] | None = Field (
default = None ,
description = " List of last n screenshot URLs in reverse chronological order - the first one the list is the latest screenshot. " ,
)
2025-05-16 16:11:22 -07:00
failure_reason : str | None = Field ( default = None , description = " Reason for failure if the run failed or terminated " )
created_at : datetime = Field ( description = " Timestamp when this run was created " , examples = [ " 2025-01-01T00:00:00Z " ] )
modified_at : datetime = Field (
description = " Timestamp when this run was last modified " , examples = [ " 2025-01-01T00:05:00Z " ]
)
2025-06-11 23:36:49 -04:00
queued_at : datetime | None = Field ( default = None , description = " Timestamp when this run was queued " )
started_at : datetime | None = Field ( default = None , description = " Timestamp when this run started execution " )
finished_at : datetime | None = Field ( default = None , description = " Timestamp when this run finished " )
2025-05-16 16:11:22 -07:00
app_url : str | None = Field (
default = None ,
description = " URL to the application UI where the run can be viewed " ,
examples = [ " https://app.skyvern.com/tasks/tsk_123 " , " https://app.skyvern.com/workflows/wpid_123/wr_123 " ] ,
)
2025-06-12 13:39:16 -07:00
browser_session_id : str | None = Field (
2025-06-13 23:59:50 -07:00
default = None , description = " ID of the Skyvern persistent browser session used for this run " , examples = [ " pbs_123 " ]
)
2025-07-03 02:03:01 -07:00
max_screenshot_scrolls : int | None = Field (
2025-06-12 13:39:16 -07:00
default = None ,
2025-07-03 02:03:01 -07:00
description = " The maximum number of scrolls for the post action screenshot. When it ' s None or 0, it takes the current viewpoint screenshot " ,
2025-06-12 13:39:16 -07:00
)
2025-09-14 22:53:52 -07:00
script_run : ScriptRunResponse | None = Field (
default = None ,
description = " The script run result " ,
)
2025-09-24 14:49:20 +08:00
errors : list [ dict [ str , Any ] ] | None = Field (
default = None ,
description = " The errors for the run " ,
)
2025-03-30 21:14:52 -07:00
class TaskRunResponse ( BaseRunResponse ) :
2025-06-13 01:23:39 -04:00
run_type : Literal [ RunType . task_v1 , RunType . task_v2 , RunType . openai_cua , RunType . anthropic_cua , RunType . ui_tars ] = (
Field ( description = " Types of a task run - task_v1, task_v2, openai_cua, anthropic_cua, ui_tars " )
2025-03-30 23:57:54 -07:00
)
run_request : TaskRunRequest | None = Field (
default = None , description = " The original request parameters used to start this task run "
)
2025-03-30 21:14:52 -07:00
class WorkflowRunResponse ( BaseRunResponse ) :
2025-03-30 23:57:54 -07:00
run_type : Literal [ RunType . workflow_run ] = Field ( description = " Type of run - always workflow_run for workflow runs " )
run_request : WorkflowRunRequest | None = Field (
default = None , description = " The original request parameters used to start this workflow run "
)
2025-03-30 21:14:52 -07:00
RunResponse = Annotated [ Union [ TaskRunResponse , WorkflowRunResponse ] , Field ( discriminator = " run_type " ) ]
2025-07-04 15:34:15 -04:00
class BlockRunResponse ( WorkflowRunResponse ) :
block_labels : list [ str ] = Field ( description = " A whitelist of block labels; only these blocks will execute " )