support magic link in CUA engine (#3780)
This commit is contained in:
@@ -6,11 +6,12 @@ Help the user decide what to do next based on the assistant's message. Here's th
|
||||
- solve_captcha: the task is blocked by captcha and the assistant is asking the user to solve the captcha
|
||||
- complete: the user goal has been achieved
|
||||
- get_verification_code: the assistant is asking the user to provide a verification code (2FA, MFA or TOTP code). At this point, the code should have been sent to the user. If code hasn't been sent, do not return get_verification_code action.
|
||||
- get_magic_link: the assistant is asking the user to verify the authorization by a magic link in the email. At this point, the link should have been sent to the user.
|
||||
- other: the assistant is asking the user to do something else
|
||||
|
||||
Return the action to take next in the following JSON format:
|
||||
{
|
||||
"action": str // complete, solve_captcha, get_verification_code, other
|
||||
"action": str // complete, solve_captcha, get_verification_code, get_magic_link, other
|
||||
"useful_information": str // If there is any useful information the assistant has provided that contributes to the user goal, put it here.
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ from skyvern.webeye.actions.actions import (
|
||||
CompleteAction,
|
||||
DownloadFileAction,
|
||||
DragAction,
|
||||
GotoUrlAction,
|
||||
InputOrSelectContext,
|
||||
InputTextAction,
|
||||
KeypressAction,
|
||||
@@ -799,6 +800,53 @@ async def generate_cua_fallback_actions(
|
||||
reasoning=reasoning,
|
||||
intention=reasoning,
|
||||
)
|
||||
elif skyvern_action_type == "get_magic_link":
|
||||
if (task.totp_verification_url or task.totp_identifier) and task.organization_id:
|
||||
LOG.info(
|
||||
"Getting magic link for CUA",
|
||||
task_id=task.task_id,
|
||||
organization_id=task.organization_id,
|
||||
workflow_run_id=task.workflow_run_id,
|
||||
totp_verification_url=task.totp_verification_url,
|
||||
totp_identifier=task.totp_identifier,
|
||||
)
|
||||
try:
|
||||
otp_value = await poll_otp_value(
|
||||
organization_id=task.organization_id,
|
||||
task_id=task.task_id,
|
||||
workflow_run_id=task.workflow_run_id,
|
||||
totp_verification_url=task.totp_verification_url,
|
||||
totp_identifier=task.totp_identifier,
|
||||
)
|
||||
if not otp_value or otp_value.get_otp_type() != OTPType.MAGIC_LINK:
|
||||
raise NoTOTPVerificationCodeFound()
|
||||
magic_link = otp_value.value
|
||||
reasoning = reasoning or "Received magic link. Navigating to the magic link URL to verify the login"
|
||||
action = GotoUrlAction(
|
||||
url=magic_link,
|
||||
reasoning=reasoning,
|
||||
intention=reasoning,
|
||||
)
|
||||
except NoTOTPVerificationCodeFound:
|
||||
reasoning_suffix = "No magic link found"
|
||||
reasoning = f"{reasoning}. {reasoning_suffix}" if reasoning else reasoning_suffix
|
||||
action = TerminateAction(
|
||||
reasoning=reasoning,
|
||||
intention=reasoning,
|
||||
)
|
||||
except FailedToGetTOTPVerificationCode as e:
|
||||
reasoning_suffix = f"Failed to get magic link. Reason: {e.reason}"
|
||||
reasoning = f"{reasoning}. {reasoning_suffix}" if reasoning else reasoning_suffix
|
||||
action = TerminateAction(
|
||||
reasoning=reasoning,
|
||||
intention=reasoning,
|
||||
)
|
||||
else:
|
||||
action = TerminateAction(
|
||||
reasoning=reasoning,
|
||||
intention=reasoning,
|
||||
)
|
||||
|
||||
elif skyvern_action_type == "get_verification_code":
|
||||
if (task.totp_verification_url or task.totp_identifier) and task.organization_id:
|
||||
LOG.info(
|
||||
|
||||
Reference in New Issue
Block a user