support new tab magic link logic (#3797)
This commit is contained in:
@@ -17,6 +17,7 @@ class ActionType(StrEnum):
|
||||
TERMINATE = "terminate"
|
||||
COMPLETE = "complete"
|
||||
RELOAD_PAGE = "reload_page"
|
||||
CLOSE_PAGE = "close_page"
|
||||
|
||||
EXTRACT = "extract"
|
||||
VERIFICATION_CODE = "verification_code"
|
||||
|
||||
@@ -125,6 +125,10 @@ class Action(BaseModel):
|
||||
return SolveCaptchaAction.model_validate(value)
|
||||
elif action_type is ActionType.RELOAD_PAGE:
|
||||
return ReloadPageAction.model_validate(value)
|
||||
elif action_type is ActionType.GOTO_URL:
|
||||
return GotoUrlAction.model_validate(value)
|
||||
elif action_type is ActionType.CLOSE_PAGE:
|
||||
return ClosePageAction.model_validate(value)
|
||||
else:
|
||||
raise ValueError(f"Unsupported action type: {action_type}")
|
||||
else:
|
||||
@@ -153,6 +157,11 @@ class ReloadPageAction(Action):
|
||||
action_type: ActionType = ActionType.RELOAD_PAGE
|
||||
|
||||
|
||||
# TODO: right now, it's only enabled when there's magic link during login
|
||||
class ClosePageAction(Action):
|
||||
action_type: ActionType = ActionType.CLOSE_PAGE
|
||||
|
||||
|
||||
class ClickAction(WebAction):
|
||||
action_type: ActionType = ActionType.CLICK
|
||||
file_url: str | None = None
|
||||
@@ -263,6 +272,7 @@ class KeypressAction(Action):
|
||||
class GotoUrlAction(Action):
|
||||
action_type: ActionType = ActionType.GOTO_URL
|
||||
url: str
|
||||
is_magic_link: bool = False # if True, shouldn't go to url directly when replaying the cache
|
||||
|
||||
|
||||
class MoveAction(Action):
|
||||
|
||||
@@ -2180,6 +2180,18 @@ async def handle_goto_url_action(
|
||||
return [ActionSuccess()]
|
||||
|
||||
|
||||
@TraceManager.traced_async(ignore_inputs=["scraped_page", "page"])
|
||||
async def handle_close_page_action(
|
||||
action: actions.ClosePageAction,
|
||||
page: Page,
|
||||
scraped_page: ScrapedPage,
|
||||
task: Task,
|
||||
step: Step,
|
||||
) -> list[ActionResult]:
|
||||
await page.close(reason=action.reasoning)
|
||||
return [ActionSuccess()]
|
||||
|
||||
|
||||
ActionHandler.register_action_type(ActionType.SOLVE_CAPTCHA, handle_solve_captcha_action)
|
||||
ActionHandler.register_action_type(ActionType.CLICK, handle_click_action)
|
||||
ActionHandler.register_action_type(ActionType.INPUT_TEXT, handle_input_text_action)
|
||||
@@ -2198,6 +2210,7 @@ ActionHandler.register_action_type(ActionType.DRAG, handle_drag_action)
|
||||
ActionHandler.register_action_type(ActionType.VERIFICATION_CODE, handle_verification_code_action)
|
||||
ActionHandler.register_action_type(ActionType.LEFT_MOUSE, handle_left_mouse_action)
|
||||
ActionHandler.register_action_type(ActionType.GOTO_URL, handle_goto_url_action)
|
||||
ActionHandler.register_action_type(ActionType.CLOSE_PAGE, handle_close_page_action)
|
||||
|
||||
|
||||
async def get_actual_value_of_parameter_if_secret(task: Task, parameter: str) -> Any:
|
||||
|
||||
@@ -21,6 +21,7 @@ from skyvern.webeye.actions.actions import (
|
||||
Action,
|
||||
CheckboxAction,
|
||||
ClickAction,
|
||||
ClosePageAction,
|
||||
CompleteAction,
|
||||
DownloadFileAction,
|
||||
DragAction,
|
||||
@@ -168,6 +169,9 @@ def parse_action(
|
||||
if action_type == ActionType.SOLVE_CAPTCHA:
|
||||
return SolveCaptchaAction(**base_action_dict)
|
||||
|
||||
if action_type == ActionType.CLOSE_PAGE:
|
||||
return ClosePageAction(**base_action_dict)
|
||||
|
||||
raise UnsupportedActionType(action_type=action_type)
|
||||
|
||||
|
||||
@@ -826,6 +830,7 @@ async def generate_cua_fallback_actions(
|
||||
url=magic_link,
|
||||
reasoning=reasoning,
|
||||
intention=reasoning,
|
||||
is_magic_link=True,
|
||||
)
|
||||
except NoTOTPVerificationCodeFound:
|
||||
reasoning_suffix = "No magic link found"
|
||||
|
||||
Reference in New Issue
Block a user