adding a wizard for setup

This commit is contained in:
Ace
2026-06-26 12:08:32 +02:00
parent a4d2ad143b
commit 5feb95187c
3 changed files with 605 additions and 54 deletions
+30
View File
@@ -1105,6 +1105,36 @@ Return a JSON array like ["yes","no","yes"] matching the order above."""
async def health():
return {"status": "ok"}
@app.get("/setup/profile")
async def setup_profile():
"""Auto-detect Firefox profile path."""
path = FX_PROFILE or find_firefox_profile()
return {"path": path, "detected": bool(path)}
@app.post("/setup/check-login")
async def setup_check_login(body: dict):
"""Check if Facebook is logged in using the given profile."""
profile_path = (body.get("profile_path") or "").strip() or FX_PROFILE or find_firefox_profile()
if not profile_path:
return {"logged_in": False, "reason": "no_profile", "error": "No Firefox profile found"}
try:
profile_dir = copy_firefox_profile(profile_path)
async with async_playwright() as pw:
context = await pw.firefox.launch_persistent_context(
user_data_dir=profile_dir, headless=True,
firefox_user_prefs={"dom.webdriver.enabled": False},
)
page = context.pages[0] if context.pages else await context.new_page()
await page.goto("https://www.facebook.com/", wait_until="domcontentloaded", timeout=30000)
await page.wait_for_timeout(3000)
logged_in = "/login" not in page.url.lower()
await context.close()
shutil.rmtree(profile_dir, ignore_errors=True)
return {"logged_in": logged_in, "reason": None if logged_in else "login_page"}
except Exception as e:
logger.error("Setup check-login failed: %s", e)
return {"logged_in": False, "reason": "error", "error": str(e)}
@app.post("/agent/run")
async def agent_run(task: str = Body(..., embed=True)):
"""Run a browser-use Agent with ChatOllama (free/local)."""