From ce70191d49313b08f647db80dacd75eb1334559d Mon Sep 17 00:00:00 2001 From: tk Date: Fri, 27 Jun 2025 22:01:59 +0900 Subject: [PATCH 1/3] =?UTF-8?q?microsoft=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 33 ----------------------- .sensitive.example.json | 22 --------------- lib/llm/prompt/Microsoft.py | 53 +++++++++++++++++++++++++++++++++++++ lib/llm/prompt/__init__.py | 4 +++ 4 files changed, 57 insertions(+), 55 deletions(-) delete mode 100644 .env.example delete mode 100644 .sensitive.example.json create mode 100644 lib/llm/prompt/Microsoft.py diff --git a/.env.example b/.env.example deleted file mode 100644 index 7a97499..0000000 --- a/.env.example +++ /dev/null @@ -1,33 +0,0 @@ -ANONYMIZED_TELEMETRY=false - -# ========== LLM ========== - -GOOGLE_API_KEY= -# 권장 (다른 모델로 교체 가능) [다른 모델로 교체시 성능 보장 불가] -GOOGLE_MODEL=gemini-2.5-flash -#GOOGLE_PLANNER_MODEL=gemini-2.5-flash # 왜 비활성화 되었나요? // Planner 모델이 오히려 문제를 일으키는 경우가 있어 비활성화했습니다. 필요시 활성화하세요. - -# min(INITIAL_BACKOFF * (2 ** try_cnt), MAX_BACKOFF)만큼 API가 실패시 대기합니다. -INITIAL_BACKOFF=60 -MAX_BACKOFF=600 - -# ========== Monitoring ========== - -# 선택 -PROXY_HOST=127.0.0.1 -PROXY_PORT=11080 -BACKEND_URL=http://localhost:11081 - -# https://docs.browser-use.com/development/observability -# Lmnr 계정이 필요합니다. -# https://lmnr.ai/ -LMNR_PROJECT_API_KEY= - -# 브라우저 언어 설정 -LANG=en_US - -# ========= Account ========== - -# 필수 뒤에 있는 이메일 주소는 Google 계정의 로그인 힌트로 사용됩니다. -# 이메일의 전체를 입력해주세요 -GOOGLE_ID=whs.imnya.ng@gmail.com diff --git a/.sensitive.example.json b/.sensitive.example.json deleted file mode 100644 index cfcb7a8..0000000 --- a/.sensitive.example.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "google.com": { - "x_username": "whs.imnya.ng@gmail.com", - "x_password": "Vb1Mz9pgjY8JVs" - }, - "accounts.google.com": { - "x_username": "whs.imnya.ng@gmail.com", - "x_password": "Vb1Mz9pgjY8JVs" - }, - "naver.com": { - "x_username": "oauth-j93es", - "x_password": "whs31234" - }, - "nid.naver.com": { - "x_username": "oauth-j93es", - "x_password": "whs31234" - }, - "github.com": { - "x_username": "imnyang-bot", - "x_password": "6PuVXCH9tpQLNm" - } -} \ No newline at end of file diff --git a/lib/llm/prompt/Microsoft.py b/lib/llm/prompt/Microsoft.py new file mode 100644 index 0000000..09ec78e --- /dev/null +++ b/lib/llm/prompt/Microsoft.py @@ -0,0 +1,53 @@ +# Extended planner prompt +extend_planner_system_message = f""" + +# 목적 : Microsoft OAuth 로그인 + +## ✅ Step 1 : Step 3에서 + +만약에 Microsoft에 로그인 되어 있는 계정(oauth test)가 없을 경우 +- Microosoft.sensitive.json에서 sign in with your username(email) x_username and password is x_password + - 반드시 이 과정에서 username을 먼저 입력하고 다음 과정에서 암호 사용을 누른 후 password를 입력해야 한다. + + +쿠키 삭제 방법: +chrome://settings/clearBrowserData에 들어가서 삭제해주세요. + +🛑 절대 아래와 같이 해석하지 말 것: +- ❌ 버튼 클릭 후 페이지 로딩만 기다리고 돌아가기 +- ❌ URL 저장 없이 go_back() 호출 + +--- + + + + +### ✨ 추가 안전 장치: "뒤로가기(go_back) 호출 조건" 제한 + +```text +🛑 뒤로가기(go_back)은 다음 조건이 모두 충족될 때만 사용 => 다만 로그인 실패 시, 뒤로가기 수행: +- ✅ 로그인 흐름이 완료됨 (예: redirect back to app, or callback URL) +- ✅ 현재 리디렉션 URL이 수집됨 +- ✅ 결과에 저장 후 다음 버튼 탐색을 위해 복귀 필요할 때 +``` + +--- + +## 🚫 Step 2: 버튼 없음 또는 예외 발생 시 + +* 유효한 SSO 버튼이 **전혀 없을 경우** +* 예외, 오류 등 발생 시 + +-> 즉시 중단 + +--- + +## 📎 중요 규칙 요약 + +* 🔁 단계는 반드시 순서대로 진행 +* 🔐 로그인은 쿠키/세션으로 유지된 상태에서 수행 +* 👀 직접 OAuth Providor ID/PW를 입력하여도 됨 가지고 있다면 +* ⛔ 추측한 URL은 접속하지 않음 + +--- +""" diff --git a/lib/llm/prompt/__init__.py b/lib/llm/prompt/__init__.py index 5fa38d2..a0d6d3e 100644 --- a/lib/llm/prompt/__init__.py +++ b/lib/llm/prompt/__init__.py @@ -12,6 +12,10 @@ def get_prompt(type:str) -> str: if type.lower() == "auth": from lib.llm.prompt.auth_list import extract_oauth_list_prompt return extract_oauth_list_prompt + + elif type.lower() == "microsoft" and type.lower() == "microsoftonline": + from lib.llm.prompt.Microsoft import extend_planner_system_message + return extend_planner_system_message else: from lib.llm.prompt.fallback import extend_planner_system_message From e1c07c4a1e3573d010442c2e246f7866eb07e966 Mon Sep 17 00:00:00 2001 From: tk Date: Sun, 29 Jun 2025 21:05:07 +0900 Subject: [PATCH 2/3] =?UTF-8?q?microsoft=20=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 36 -------- src/lib/llm/prompt/__init__.py | 2 +- src/lib/llm/prompt/get_oauth/prompt.py | 82 ++++++++++++------- .../microsoft/{microsoft.py => prompt.py} | 6 +- 4 files changed, 57 insertions(+), 69 deletions(-) delete mode 100644 .env.example rename src/lib/llm/prompt/microsoft/{microsoft.py => prompt.py} (96%) diff --git a/.env.example b/.env.example deleted file mode 100644 index 99f4232..0000000 --- a/.env.example +++ /dev/null @@ -1,36 +0,0 @@ -ANONYMIZED_TELEMETRY=false - -# ========== LLM ========== - -GOOGLE_API_KEY= -# 권장 (다른 모델로 교체 가능) [다른 모델로 교체시 성능 보장 불가] -GOOGLE_MODEL=gemini-2.5-flash -#GOOGLE_PLANNER_MODEL=gemini-2.5-flash # 왜 비활성화 되었나요? // Planner 모델이 오히려 문제를 일으키는 경우가 있어 비활성화했습니다. 필요시 활성화하세요. - -# min(INITIAL_BACKOFF * (2 ** try_cnt), MAX_BACKOFF)만큼 API가 실패시 대기합니다. -INITIAL_BACKOFF=60 -MAX_BACKOFF=600 - -#ENABLE_PLANNER_MODEL_OAUTH_LOGIN=true # OAuth 로그인 시 Planner 모델을 활성화합니다. -#ENABLE_PLANNER_MODEL_OAUTH_LIST=true # OAuth List를 찾을 때 Planner 모델을 활성화합니다. - -# ========== Monitoring ========== - -# 선택 -PROXY_HOST=127.0.0.1 -PROXY_PORT=11080 -BACKEND_URL=http://localhost:11081 - -# https://docs.browser-use.com/development/observability -# Lmnr 계정이 필요합니다. -# https://lmnr.ai/ -LMNR_PROJECT_API_KEY= - -# 브라우저 언어 설정 -LANG=en_US - -# ========= Account ========== - -# 필수 뒤에 있는 이메일 주소는 Google 계정의 로그인 힌트로 사용됩니다. -# 이메일의 전체를 입력해주세요 -GOOGLE_ID=whs.imnya.ng@gmail.com diff --git a/src/lib/llm/prompt/__init__.py b/src/lib/llm/prompt/__init__.py index 76b6de3..1f9e97b 100644 --- a/src/lib/llm/prompt/__init__.py +++ b/src/lib/llm/prompt/__init__.py @@ -16,7 +16,7 @@ def get_prompt(type: str) -> tuple[str, Type[BaseModel]] | str: from lib.llm.prompt.google import prompt, model return prompt, model - elif type.lower() in ["microsoft", "microsoftonline"]: + elif type.lower() in ["microsoft", "microsoftonline"]: from lib.llm.prompt.microsoft import prompt, model return prompt, model diff --git a/src/lib/llm/prompt/get_oauth/prompt.py b/src/lib/llm/prompt/get_oauth/prompt.py index 3761fdd..42685fd 100644 --- a/src/lib/llm/prompt/get_oauth/prompt.py +++ b/src/lib/llm/prompt/get_oauth/prompt.py @@ -1,37 +1,61 @@ prompt = """ -🎯 목적: 주어진 초기 URL 내에서 **OAuth 로그인 Provider**를 찾아 아래 형식의 JSON으로 정리합니다. +You are an expert in finding login pages. -📌 작업 목표: -- Google, GitHub, Discord, Facebook, Apple, Microsoft, Twitter, LinkedIn 등 **OAuth 인증을 사용하는 외부 로그인 링크**에서 Provider 이름만 모두 수집합니다. -- 로그인 버튼, 링크 클릭 등을 통해 탐색을 진행할 수 있습니다. -- **같은 provider가 여러 번 나와도 하나만 저장**합니다. +Your task is to navigate to the login page of the given URL. Follow the steps below strictly and return results only in the specified format. -🛑 제한 사항: -- ❌ 로그인 입력창이나 이메일/비밀번호 입력 방식은 제외합니다. -- ❌ 검색 엔진, 사이트 외부 탐색은 금지합니다. -- ❌ URL 추측이나 직접 입력은 금지합니다. -- ❌ OAuth가 없는 경우 빈 배열 `[]`로 반환합니다. -- ❌ OAuth가 아닌 일반 로그인은 무시합니다. +※ You are NOT allowed to navigate to URLs that are not directly discoverable within the initial domain. Do NOT use search engines or guess external login URLs. -🔍 탐색 방법: -1. 초기 URL에 접속하여 **클라이언트용 로그인 페이지**로 진입합니다. -2. 페이지가 정상적으로 로드되었다고 가정합니다. -3. 'Continue with X', 'Continue with Google'... 등의 버튼이나 링크를 식별합니다. +0. INITIAL BLOCK CHECK +- If the browser is blocked when trying to access the page — due to firewall, CAPTCHA, regional restrictions, or other access denials — immediately terminate the process and return the following JSON: + ```json + { + "msg": "Blocked", + "url": "", + "sso_list": [] + } + ``` +- Do NOT proceed to further steps in this case. +1. LOGIN PAGE NAVIGATION +- Navigate only to a **client-side (non-enterprise)** login page within the provided domain. +- Do NOT rely on external tools, search engines, or links not directly found on the site. +- If a consent popup (e.g. for privacy/cookies) appears, you MUST dismiss or close it before proceeding. +- Since step 0 confirmed access, assume the page now loads properly. -🧾 출력 형식 (예시): +2. SSO BUTTON IDENTIFICATION +- On the login page, look for the following social login (SSO) buttons: + - Google, GitHub, Facebook, LinkedIn, Microsoft, Naver, Slack, Etc. +- ✅ Proceed only if it is clearly an **actual SSO button**. +- ❌ Exclude the following: + - Passkey-related buttons + - Username/password fields + - Email-based login + - Non-OAuth methods such as certificate or phone verification -```json -{{ - "oauth_providers": [ - "Google", - "GitHub", - "Discord" - ] -}} -``` - -📌 주의: - 결과가 없는 경우 빈 배열 `[]`로 반환합니다. - 정확한 provider 이름을 포함해 주세요. +3. RETURN FORMAT +- If the login page is successfully found, return: + ```json + { + "msg": "Login page found", + "url": "https://example.com/login", + "sso_list": ["Google", "GitHub"] + } + ``` +- If the login page cannot be found, return: + ```json + { + "msg": "Login page not found", + "url": "", + "sso_list": [] + } + ``` +- If blocked (as in step 0), return: + ```json + { + "msg": "Blocked", + "url": "", + "sso_list": [] + } + ``` +- Return ONLY the JSON object. Do NOT include any explanation, logging, or extra output. """ diff --git a/src/lib/llm/prompt/microsoft/microsoft.py b/src/lib/llm/prompt/microsoft/prompt.py similarity index 96% rename from src/lib/llm/prompt/microsoft/microsoft.py rename to src/lib/llm/prompt/microsoft/prompt.py index 690287b..e093b63 100644 --- a/src/lib/llm/prompt/microsoft/microsoft.py +++ b/src/lib/llm/prompt/microsoft/prompt.py @@ -14,9 +14,9 @@ prompt = f""" 2. 사이트의 UI를 탐색하여 **로그인 또는 로그인 페이지**(예: "로그인", "Sign In", "Get Started"와 같은 버튼)를 찾으세요. - 동일한 도메인 내의 링크만 따라가세요. 3. 로그인 페이지에서 명확하게 표시된 **Microsoft SSO 버튼**을 찾으세요. 일반적으로 다음과 같이 표시됩니다: - - "Microsoft로 계속" - - "Microsoft로 로그인" - - 또는 Microsoft 'M' 아이콘이 있는 버튼 + - "Continue with Microsoft" + - "Sign in with Microsoft" + - or a button with the Microsoft logo (usually four squares) 4. **Microsoft 로그인 버튼**을 클릭하세요. - ⚠️ Microsoft 로그인 플로우는 반드시 **새 브라우저 탭**에서 열려야 합니다 (새 창이나 팝업이 아님). - ❌ 로그인이 새 **창**이나 **팝업**에서 열리면, 즉시 중단하고 적절한 상태를 반환하세요. From fe003013f419dd2bdbf30c97339fcc8e1354cfb0 Mon Sep 17 00:00:00 2001 From: tk Date: Mon, 30 Jun 2025 17:38:13 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/llm/prompt/__init__.py | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 lib/llm/prompt/__init__.py diff --git a/lib/llm/prompt/__init__.py b/lib/llm/prompt/__init__.py deleted file mode 100644 index a0d6d3e..0000000 --- a/lib/llm/prompt/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# why this is isn't index -# 이 파일을 __init__.py로 만든 이유는 -# 굳이 이 짧은 코드를 파일을 하나 더 만드는게 코드의 가독성을 떨어뜨린다고 판단했기 때문입니다. - -def get_prompt(type:str) -> str: - """ - Prompt를 반환합니다. - - :param type: 'auth' {Auth List} 또는 'google' {OAuth Provider}, 'meta' {OAuth Provider}을 지정합니다. - :return: 해당하는 프롬프트 문자열 - """ - if type.lower() == "auth": - from lib.llm.prompt.auth_list import extract_oauth_list_prompt - return extract_oauth_list_prompt - - elif type.lower() == "microsoft" and type.lower() == "microsoftonline": - from lib.llm.prompt.Microsoft import extend_planner_system_message - return extend_planner_system_message - - else: - from lib.llm.prompt.fallback import extend_planner_system_message - return extend_planner_system_message