mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-28 01:25:54 +00:00
update ui and optimize
This commit is contained in:
parent
b0123d3d5a
commit
b30e73be5c
3 changed files with 18 additions and 27 deletions
|
|
@ -239,9 +239,7 @@ class ExtensionTabPoolManager:
|
|||
logger.error(f"Failed to close tab {tab_id}: {e}")
|
||||
|
||||
if released:
|
||||
logger.info(
|
||||
f"Released {len(released)} tab(s) for task {task_id}"
|
||||
)
|
||||
logger.info(f"Released {len(released)} tab(s) for task {task_id}")
|
||||
return [t for t, _ in released]
|
||||
|
||||
|
||||
|
|
@ -288,9 +286,7 @@ def browser_agent(options: Chat):
|
|||
if extension_proxy_browser:
|
||||
# Extension proxy mode: use plugin exclusively, no CDP fallback
|
||||
use_extension_proxy = True
|
||||
extension_proxy_port = int(
|
||||
extension_proxy_browser.get("port", 8765)
|
||||
)
|
||||
extension_proxy_port = int(extension_proxy_browser.get("port", 8765))
|
||||
selected_is_external = True
|
||||
logger.info(
|
||||
f"Using extension proxy mode (exclusive): "
|
||||
|
|
@ -299,7 +295,8 @@ def browser_agent(options: Chat):
|
|||
else:
|
||||
# No extension proxy — use CDP browsers
|
||||
cdp_only_browsers = [
|
||||
b for b in (options.cdp_browsers or [])
|
||||
b
|
||||
for b in (options.cdp_browsers or [])
|
||||
if not b.get("isExtensionProxy", False)
|
||||
]
|
||||
if cdp_only_browsers:
|
||||
|
|
@ -501,16 +498,12 @@ def browser_agent(options: Chat):
|
|||
try:
|
||||
loop = asyncio.get_event_loop()
|
||||
tab_id = loop.run_until_complete(
|
||||
_tab_pool_manager.acquire_tab(
|
||||
session_id, options.task_id
|
||||
)
|
||||
_tab_pool_manager.acquire_tab(session_id, options.task_id)
|
||||
)
|
||||
except RuntimeError:
|
||||
# If no event loop, create one
|
||||
tab_id = asyncio.run(
|
||||
_tab_pool_manager.acquire_tab(
|
||||
session_id, options.task_id
|
||||
)
|
||||
_tab_pool_manager.acquire_tab(session_id, options.task_id)
|
||||
)
|
||||
agent_instance._extension_tab_id = tab_id
|
||||
agent_instance._cdp_session_id = session_id
|
||||
|
|
@ -552,7 +545,8 @@ def browser_agent(options: Chat):
|
|||
def acquire_cdp_for_agent(agent_instance):
|
||||
"""Acquire a CDP browser from pool for a cloned agent."""
|
||||
cdp_only = [
|
||||
b for b in (options.cdp_browsers or [])
|
||||
b
|
||||
for b in (options.cdp_browsers or [])
|
||||
if not b.get("isExtensionProxy", False)
|
||||
]
|
||||
if not cdp_only:
|
||||
|
|
@ -564,9 +558,7 @@ def browser_agent(options: Chat):
|
|||
if selected:
|
||||
agent_instance._cdp_port = _get_browser_port(selected)
|
||||
else:
|
||||
agent_instance._cdp_port = _get_browser_port(
|
||||
cdp_only[0]
|
||||
)
|
||||
agent_instance._cdp_port = _get_browser_port(cdp_only[0])
|
||||
agent_instance._cdp_session_id = session_id
|
||||
logger.info(
|
||||
f"Acquired CDP for cloned agent {agent_instance.agent_id}: "
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter
|
||||
from pydantic import BaseModel
|
||||
|
|
@ -31,15 +30,17 @@ router = APIRouter()
|
|||
class StartProxyRequest(BaseModel):
|
||||
host: str = "localhost"
|
||||
port: int = 8765
|
||||
model_platform: Optional[str] = None
|
||||
model_type: Optional[str] = None
|
||||
api_key: Optional[str] = None
|
||||
api_url: Optional[str] = None
|
||||
extra_params: Optional[dict] = None
|
||||
model_platform: str | None = None
|
||||
model_type: str | None = None
|
||||
api_key: str | None = None
|
||||
api_url: str | None = None
|
||||
extra_params: dict | None = None
|
||||
|
||||
|
||||
@router.post("/extension-proxy/start", name="start extension proxy")
|
||||
async def start_proxy(req: StartProxyRequest = StartProxyRequest()):
|
||||
async def start_proxy(req: StartProxyRequest = None):
|
||||
if req is None:
|
||||
req = StartProxyRequest()
|
||||
# Build model config if provided
|
||||
model_config = None
|
||||
if req.model_platform and req.model_type and req.api_key:
|
||||
|
|
|
|||
|
|
@ -106,9 +106,7 @@ async def _watch_connection():
|
|||
"Timed out waiting for extension reconnection"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"Error waiting for reconnection: {e}"
|
||||
)
|
||||
logger.error(f"Error waiting for reconnection: {e}")
|
||||
break
|
||||
else:
|
||||
logger.warning("Timed out waiting for extension connection")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue