.memstack/skills/vnc-browser-launcher/SKILL.md
在沙箱 VNC 远程桌面上启动可见的浏览器窗口
npx skillsauth add s1366560/agi-demos vnc-browser-launcherInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
在沙箱远程桌面 (VNC/KasmVNC) 上启动可见的浏览器窗口。
xvfb-run 创建独立的虚拟 X 服务器 (:99 或动态分配)VNC 服务器使用 /root/.Xauthority 进行授权,但:
xauth 命令会连不上 X 服务器XAUTHORITY=/root/.Xauthority 环境变量访问/usr/local/bin/firefox 是 Playwright 的包装脚本headless=False 显示在真实 X 服务器上⚠️ 【关键】环境变量必须在 import Playwright 之前设置!
import os
# ⚠️ 关键:在 import 之前设置环境变量!
os.environ['DISPLAY'] = ':1'
os.environ['XAUTHORITY'] = '/root/.Xauthority'
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(
headless=False, # 有头模式!
args=['--no-sandbox', '--disable-dev-shm-usage', '--disable-gpu']
)
page = browser.new_page()
page.goto("https://www.google.com")
page.wait_for_timeout(5000) # 等待页面加载
browser.close()
如果需要浏览器持续显示在 VNC 桌面上:
import os
import time
import signal
# ⚠️ 环境变量必须在 import 之前设置!
os.environ['DISPLAY'] = ':1'
os.environ['XAUTHORITY'] = '/root/.Xauthority'
from playwright.sync_api import sync_playwright
def cleanup():
try:
browser.close()
except:
pass
signal.signal(signal.SIGINT, lambda s,f: cleanup())
signal.signal(signal.SIGTERM, lambda s,f: cleanup())
with sync_playwright() as p:
browser = p.chromium.launch(
headless=False,
args=['--no-sandbox', '--disable-dev-shm-usage', '--disable-gpu']
)
page = browser.new_page()
page.goto("https://www.google.com", timeout=30000)
print("✅ 浏览器已在 VNC 桌面上运行!")
print("用户可在 http://localhost:6080 查看")
time.sleep(3600) # 保持运行 1 小时
# 1. 设置正确的环境变量
export DISPLAY=:1
export XAUTHORITY=/root/.Xauthority
# 2. 验证 X 连接
$DISPLAY xdpyinfo
# 3. 启动浏览器
chromium-browser --new-window https://www.google.com &
如果浏览器启动后立即退出:
export DISPLAY=:1
export XAUTHORITY=/root/.Xauthority
# 后台启动,不等待
nohup chromium-browser --new-window https://www.google.com > /tmp/browser.log 2>&1 &
# 验证进程
ps aux | grep chromium
| 项目 | 值 | |------|-----| | VNC 端口 | 5900 | | Web 访问 | http://localhost:6080 | | 显示编号 | :1 | | X Authority | /root/.Xauthority | | 窗口管理器 | Openbox | | 桌面环境 | KDE Plasma (plasmashell) |
| 浏览器 | 路径 | 可用性 | |--------|------|--------| | Chromium | /usr/bin/chromium-browser | ✅ 推荐 | | Chrome | /usr/bin/google-chrome | ✅ | | Firefox | /usr/local/bin/firefox | ❌ Playwright 包装,不可用 |
# 检查 VNC 状态
vncserver -list
# 检查 X 显示
w
# 输出示例:
# 15:40:13 2:01 0.00s 0.00s -bash
# 15:40:15 0:18 0.07s 0.07s xterm
# 15:40:27 1:01 0.00s 0.00s chromium-browser
# 检查 X 服务器
DISPLAY=:1 XAUTHORITY=/root/.Xauthority xdpyinfo
# 检查进程和显示对应关系
ps aux | grep -E 'chromium|firefox|Xvnc'
# 从 X 服务器截图(验证窗口是否存在)
DISPLAY=:1 XAUTHORITY=/root/.Xauthority scrot /tmp/screenshot.png
A: 可能是窗口在屏幕外。尝试:
DISPLAY=:1 wmctrl -l # 列出所有窗口
DISPLAY=:1 wmctrl -r "Chromium" -e 0,0,0,1280,800 # 移动到可见位置
A: 总是使用完整的命令前缀:
DISPLAY=:1 XAUTHORITY=/root/.Xauthority <command>
A: 可能需要重启 VNC 服务:
# 停止
vncserver -kill :1
# 启动
vncserver :1 -geometry 1920x1080 -depth 24
w 命令显示的进程不一定在正确的 DISPLAY 上tools
Sandbox MCP Server 是一个隔离的代码执行环境,提供完整的文件系统操作、命令执行、 代码分析、测试运行和远程桌面能力。当你需要执行代码、操作文件、运行测试、 分析代码结构、或需要图形界面操作时使用此技能。支持 Python、Node.js、Java 等多语言环境。
tools
Replace with description of the skill and when Claude should use it.
development
Generate high-quality images using ModelScope's Z-Image API. Use this skill when the user wants to generate images using the specific Z-Image model or ModelScope API they provided. Trigger words: 'Zimage', 'ModelScope', 'generate zimage'.
tools
No-code automation democratizes workflow building. Zapier and Make (formerly Integromat) let non-developers automate business processes without writing code. But no-code doesn't mean no-complexity ...