From 20601cec768d3025ba69961931080467acf404c6 Mon Sep 17 00:00:00 2001 From: imnyang Date: Fri, 27 Jun 2025 20:31:19 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B5=AC=EA=B8=80=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=ED=94=84=EB=A1=AC=ED=94=84=ED=8A=B8=20=EB=B0=8F=20?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: James --- src/lib/llm/prompt/__init__.py | 4 ++ src/lib/llm/prompt/google/__init__.py | 2 + src/lib/llm/prompt/google/model.py | 6 +++ src/lib/llm/prompt/google/prompt.py | 58 +++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 src/lib/llm/prompt/google/__init__.py create mode 100644 src/lib/llm/prompt/google/model.py create mode 100644 src/lib/llm/prompt/google/prompt.py diff --git a/src/lib/llm/prompt/__init__.py b/src/lib/llm/prompt/__init__.py index 009f262..f051622 100644 --- a/src/lib/llm/prompt/__init__.py +++ b/src/lib/llm/prompt/__init__.py @@ -12,6 +12,10 @@ def get_prompt(type: str) -> tuple[str, Type[BaseModel]] | str: from lib.llm.prompt.get_oauth import prompt, model return prompt, model + elif type.lower() in ["google", "google account"]: + from lib.llm.prompt.google import prompt, model + return prompt, model + else: from lib.llm.prompt.fallback import model, prompt return prompt, model diff --git a/src/lib/llm/prompt/google/__init__.py b/src/lib/llm/prompt/google/__init__.py new file mode 100644 index 0000000..86311ab --- /dev/null +++ b/src/lib/llm/prompt/google/__init__.py @@ -0,0 +1,2 @@ +from lib.llm.prompt.google.prompt import prompt +from lib.llm.prompt.google.model import model diff --git a/src/lib/llm/prompt/google/model.py b/src/lib/llm/prompt/google/model.py new file mode 100644 index 0000000..d1322ba --- /dev/null +++ b/src/lib/llm/prompt/google/model.py @@ -0,0 +1,6 @@ +from pydantic import BaseModel + +class model(BaseModel): + msg: str | None = None + status: str | None = None # "success", "mfa_required", "google_blocked", "sso_not_found", "login_page_not_found", "invalid_credentials" + final_url: str | None = None diff --git a/src/lib/llm/prompt/google/prompt.py b/src/lib/llm/prompt/google/prompt.py new file mode 100644 index 0000000..d1dcd24 --- /dev/null +++ b/src/lib/llm/prompt/google/prompt.py @@ -0,0 +1,58 @@ +import os + +# Extended planner prompt +prompt = f""" +You are a web automation agent. + +Your task is to visit the given domain and perform a full login via the **Google SSO button**, following all steps strictly as described below. + +▶ Target: Find a login page inside this domain that allows "Sign in with Google", and use it to complete login via Google. + +Instructions: + +1. If any cookie or privacy popups appear, dismiss or accept them. +2. Navigate through the site's UI to find the **login or sign-in page** (e.g., via buttons like "Log In", "Sign In", "Get Started"). + - Only follow links within the same domain. +3. On the login page, look for a clearly labeled **Google SSO button** — typically labeled as: + - "Continue with Google" + - "Sign in with Google" + - or a button with the Google 'G' icon +4. Click the **Google login button**. + - ⚠️ The Google login flow MUST open in a **new browser tab** (not a new window or popup). + - ❌ If the login opens in a new **window** or **popup**, do NOT continue. Immediately stop and return the appropriate status. +5. Check if the user is **already logged in to Google and immediately redirected back to the original site** without showing a Google login screen. + - ✅ If so, treat the login as successful and return immediately. +6. If redirected to the Google login page: + - If a **CAPTCHA**, **MFA prompt**, or a request for **ID/password entry** appears, do NOT proceed. + - Immediately stop and return the appropriate status. +7. If login proceeds without interruptions, wait for redirection back to the original site and record the final URL. + +Credentials to use for Google login: +- Email: {os.getenv("GOOGLE_EMAIL", "")} +- Password: {os.getenv("GOOGLE_PASSWORD", "")} + +Constraints: +- Do NOT use search engines or guess URLs. +- Do NOT use autofill, saved sessions, or cookies. +- Do NOT proceed with login if: + - The login opens in a new window (only tabs are allowed) + - CAPTCHA or MFA appears + - ID/password input is required +- If the user is already logged in to Google and redirected back automatically, stop there and report success. +- If the login page cannot be found, return "login_page_not_found". +- If the Google login button is not found, return "sso_not_found". +- If a page such as a sign-up page appears, consider it a successful login and terminate immediately. + +Final Output: +Return the result in the following format only: + +```json +{{ + "msg": "Google login completed", + "status": "success" | "already_logged_in" | "mfa_required" | "captcha_triggered" | "window_blocked" | "idpw_required" | "google_blocked" | "sso_not_found" | "login_page_not_found", + "final_url": "" +}} +``` + +- Return ONLY the JSON object. Do NOT include any explanation, logging, or extra output. +""" \ No newline at end of file