fix: optimize browser install cli and fix vision prompt

This commit is contained in:
zhayujie
2026-03-29 15:19:59 +08:00
parent 184634e4e7
commit e06925ab85
2 changed files with 38 additions and 2 deletions

View File

@@ -171,6 +171,7 @@ def _build_tooling_section(tools: List[Any], language: str) -> List[str]:
"env_config": "管理API密钥和技能配置", "env_config": "管理API密钥和技能配置",
"scheduler": "管理定时任务和提醒", "scheduler": "管理定时任务和提醒",
"send": "发送本地文件给用户仅限本地文件URL直接放在回复文本中", "send": "发送本地文件给用户仅限本地文件URL直接放在回复文本中",
"vision": "分析图片内容识别、描述、OCR文字提取等",
} }
# Preferred display order # Preferred display order
@@ -179,7 +180,7 @@ def _build_tooling_section(tools: List[Any], language: str) -> List[str]:
"bash", "terminal", "bash", "terminal",
"web_search", "web_fetch", "browser", "web_search", "web_fetch", "browser",
"memory_search", "memory_get", "memory_search", "memory_get",
"env_config", "scheduler", "send", "env_config", "scheduler", "send", "vision",
] ]
# Build name -> summary mapping for available tools # Build name -> summary mapping for available tools

View File

@@ -7,6 +7,7 @@ import subprocess
import click import click
MIN_PLAYWRIGHT_VERSION = "1.49.0" MIN_PLAYWRIGHT_VERSION = "1.49.0"
MIN_GLIBC_VERSION = (2, 28)
def _has_display() -> bool: def _has_display() -> bool:
@@ -40,11 +41,45 @@ def _version_tuple(v: str):
return (0, 0, 0) return (0, 0, 0)
def _get_glibc_version():
"""Return glibc version as (major, minor) tuple, or None if unavailable."""
if sys.platform != "linux":
return None
try:
import ctypes
libc = ctypes.CDLL("libc.so.6")
gnu_get_libc_version = libc.gnu_get_libc_version
gnu_get_libc_version.restype = ctypes.c_char_p
ver = gnu_get_libc_version().decode()
parts = ver.split(".")
return (int(parts[0]), int(parts[1]))
except Exception:
return None
@click.command("install-browser") @click.command("install-browser")
def install_browser(): def install_browser():
"""Install browser tool dependencies (Playwright + Chromium).""" """Install browser tool dependencies (Playwright + Chromium)."""
python = sys.executable python = sys.executable
# Pre-check: glibc version on Linux
if sys.platform == "linux":
glibc = _get_glibc_version()
if glibc and glibc < MIN_GLIBC_VERSION:
glibc_str = f"{glibc[0]}.{glibc[1]}"
click.echo(click.style(
f"Your system glibc version is {glibc_str}, "
f"but Playwright requires glibc >= {MIN_GLIBC_VERSION[0]}.{MIN_GLIBC_VERSION[1]}.\n"
f"(e.g. Ubuntu 18.04 ships glibc 2.27, CentOS 7 ships glibc 2.17)\n\n"
f"Options:\n"
f" 1. Upgrade your OS (e.g. Ubuntu 20.04+, Debian 10+, CentOS 8+)\n"
f" 2. Use Docker with a newer Linux image\n"
f" 3. Install an older playwright version manually (not recommended):\n"
f" pip install playwright==1.30.0 && playwright install chromium",
fg="red",
))
raise SystemExit(1)
# Step 1: Install / upgrade playwright package # Step 1: Install / upgrade playwright package
click.echo(click.style("[1/3] Installing playwright Python package...", fg="yellow")) click.echo(click.style("[1/3] Installing playwright Python package...", fg="yellow"))
ret = subprocess.call([python, "-m", "pip", "install", f"playwright>={MIN_PLAYWRIGHT_VERSION}"]) ret = subprocess.call([python, "-m", "pip", "install", f"playwright>={MIN_PLAYWRIGHT_VERSION}"])
@@ -84,7 +119,7 @@ def install_browser():
cmd.append("--only-shell") cmd.append("--only-shell")
click.echo(" (headless shell for Linux server)") click.echo(" (headless shell for Linux server)")
else: else:
click.echo(" (full Chromium - upgrade to playwright>=1.57 for headless-only shell)") click.echo(" (full Chromium - upgrade to playwright>=1.57 for smaller headless-only install)")
elif sys.platform == "linux": elif sys.platform == "linux":
click.echo(" (full browser for Linux desktop)") click.echo(" (full browser for Linux desktop)")