Ubuntu Browser Session
Use the Ubuntu host browser like a long-lived local browser for the agent.
The primary model is site-centric:
- - each important site keeps one default primary identity
- agent tasks reuse that default identity automatically
- non-default identities are allowed only when the user explicitly names a different INLINECODE0
- user help is only for first login, expired sessions, or unrecoverable challenges
When To Use
- - Open, inspect, or interact with a protected site from the Ubuntu Server host
- Reuse an already logged-in site session such as GitHub or Google
- Recover an expired or challenge-blocked session with one bounded round of user help
- Continue browser work on the host without re-authenticating every task
Representative requests:
- - "Use the Ubuntu host browser and open this dashboard."
- "Reuse the existing GitHub login on the server."
- "Continue from the same Google session."
- "Recover this protected page with the least user help."
Do Not Use
- - General web research that only needs HTTP fetch or web search
- Local desktop browsing outside the Ubuntu Server host
- Cases where an API token or non-browser auth flow is enough
Core Rules
- - Default to one primary identity per site
- Do not guess between multiple accounts automatically
- Only use a non-default identity when the user explicitly names a different INLINECODE1
- Prefer local recovery before asking the user to take over
- Treat wrong-page drift as recoverable: first navigate back to the requested site in the same profile, then ask for help only if the target still lands on a login wall or challenge
- Finish the host-browser workflow before switching tools: if
open-protected-page.sh returns ready, keep working from this skill's host browser context and do not switch to OpenClaw's generic browser profile or other browser tools unless this workflow is exhausted or the task explicitly requires a different browser stack
Preferred Entry Point
Use the wrapper first:
CODEBLOCK0
The wrapper is responsible for:
- - site-centric profile lookup
- session reuse
- target-page verification
- one automatic recovery attempt when the browser drifted to the wrong page
- bounded escalation to noVNC when user help is actually needed
- keeping work inside the host browser workflow by default instead of mixing in unrelated browser profiles
Site Session Model
Durable default identities are tracked by canonical site, not just exact origin.
Examples:
- -
github.com -> default GitHub browser identity - INLINECODE6 -> default Google browser identity, including INLINECODE7
Persistent state is split across:
- - exact manifests for the live runtime and captured browser state
- a site session registry for default per-site reuse
- compatibility identity aliases for Google-family hosts
Important files:
- - INLINECODE8
- INLINECODE9
- INLINECODE10
Manual Login Recovery
When the wrapper cannot recover locally, it starts the assisted browser overlay and returns:
- - a loopback noVNC URL for SSH tunnel usage
- a LAN noVNC URL when the host IP is known and noVNC is exposed on INLINECODE11
Typical outputs:
CODEBLOCK1
Use the loopback URL if you are forwarding ports over SSH from Windows or another remote machine.
Use the LAN URL only when the host firewall and network allow direct access.
Typical Workflow
- 1. Try
open-protected-page.sh with the requested URL and desired INLINECODE13 - Let the wrapper resolve the default site identity
- If the browser is already logged in but sitting on the wrong page, let the wrapper navigate back to the requested site automatically
- If the target page is ready, continue the task from this host browser workflow first
- If the target page still shows a login wall or challenge, open the returned noVNC URL
- After the user finishes the login and leaves the final page loaded, run:
CODEBLOCK2
That finalizes the wrapper-managed session state and updates the site session registry for later reuse.
Do not use assisted-session.sh start as a normal entrypoint. Start with open-protected-page.sh so site-centric profile resolution and wrong-page recovery stay in effect.
Only reach for unrelated browser tooling after this workflow fails to complete the task and you have a concrete reason the host browser workflow is insufficient.
Environment Checks
CODEBLOCK3
Key Files
- -
scripts/open-protected-page.sh: main protected-site wrapper - INLINECODE17 : bounded manual takeover and capture
- INLINECODE18 : canonical per-site default session registry
- INLINECODE19 : site-first profile selection with compatibility fallback
- INLINECODE20 : runtime manifest storage and verification support
- INLINECODE21 : browser runtime, target selection, and page checks
- INLINECODE22 : CDP evaluation, page checks, and navigation
- INLINECODE23 : structured page content extraction via CDP
CDP Tools
INLINECODE24 and cdp-snapshot.py stay generic by default.
Forum/search-result helpers are optional enhancements; read references/forum-enhancements.md only when the current page is a forum topic list, category page, or search results page and you need structured topic/result links or text-based clicking.
cdp-eval.py
Evaluate page state or run JavaScript over the Chrome DevTools Protocol.
CODEBLOCK4
Parameters:
- -
--port PORT (required): CDP HTTP/WebSocket port - INLINECODE28 : specific target from INLINECODE29
- INLINECODE30 : built-in page state checks
- INLINECODE31 : arbitrary JavaScript for INLINECODE32
- INLINECODE33 : navigate to URL via INLINECODE34
- INLINECODE35 : click the first visible matching anchor; when combined with
--navigate, pair it with --wait-navigation or --wait-for so the destination DOM is ready before clicking - INLINECODE39 : wait for
Page.loadEventFired after INLINECODE41 - INLINECODE42 : poll for CSS selector to appear (timeout 10s)
cdp-snapshot.py
Capture structured page content in generic formats by default, plus an optional forum/search-result helper format.
CODEBLOCK5
Output: JSON to stdout INLINECODE43
Parameters:
- -
--port PORT (required): CDP HTTP/WebSocket port - INLINECODE45 : specific target from INLINECODE46
- INLINECODE47 : output format (default:
markdown) - INLINECODE49 : truncate content to N chars (default: 8000, 0=unlimited)
For topic-links, meta is best-effort surrounding text truncated to 400 characters.
See also:
- - INLINECODE52
- INLINECODE53
- INLINECODE54
- INLINECODE55
- INLINECODE56
- INLINECODE57
- INLINECODE58
Ubuntu 浏览器会话
使用Ubuntu主机浏览器,为代理提供类似长期本地浏览器的体验。
主要模型以站点为中心:
- - 每个重要站点保留一个默认主身份
- 代理任务自动复用该默认身份
- 仅当用户明确指定不同的session-key时才允许使用非默认身份
- 用户帮助仅限于首次登录、会话过期或无法恢复的挑战
使用场景
- - 从Ubuntu服务器主机打开、检查或与受保护站点交互
- 复用已登录的站点会话,如GitHub或Google
- 通过一轮有限的用户帮助恢复过期或受挑战阻止的会话
- 在主机上继续浏览器工作,无需为每个任务重新认证
典型请求:
- - 使用Ubuntu主机浏览器打开此仪表板。
- 复用服务器上现有的GitHub登录。
- 从同一个Google会话继续。
- 以最少的用户帮助恢复此受保护页面。
不使用场景
- - 仅需HTTP获取或网络搜索的通用网络研究
- Ubuntu服务器主机之外的本地桌面浏览
- 使用API令牌或非浏览器认证流程即可满足的情况
核心规则
- - 每个站点默认使用一个主身份
- 不要自动在多个账户之间猜测
- 仅当用户明确指定不同的session-key时才使用非默认身份
- 在要求用户接管之前优先尝试本地恢复
- 将错误页面漂移视为可恢复:首先在同一配置文件中导航回请求的站点,仅当目标页面仍显示登录墙或挑战时才请求帮助
- 在切换工具前完成主机浏览器工作流程:如果open-protected-page.sh返回ready,则继续使用此技能的主机浏览器上下文,不要切换到OpenClaw的通用browser配置文件或其他浏览器工具,除非此工作流程已用尽或任务明确要求不同的浏览器栈
首选入口点
首先使用包装脚本:
bash
{baseDir}/scripts/open-protected-page.sh --url https://target.example --session-key default
包装脚本负责:
- - 以站点为中心的配置文件查找
- 会话复用
- 目标页面验证
- 浏览器漂移到错误页面时的一次自动恢复尝试
- 在真正需要用户帮助时有限度地升级到noVNC
- 默认将工作保持在主机浏览器工作流程内,而不是混入不相关的浏览器配置文件
站点会话模型
持久的默认身份按规范站点跟踪,而不仅仅是精确来源。
示例:
- - github.com -> 默认GitHub浏览器身份
- google.com -> 默认Google浏览器身份,包括myaccount.google.com
持久状态分布在:
- - 实时运行时和捕获浏览器状态的精确清单
- 用于默认按站点复用的站点会话注册表
- Google系列主机的兼容性身份别名
重要文件:
- - ~/.agent-browser/index/site-sessions.json
- ~/.agent-browser/sessions/...
- ~/.agent-browser/index/identity-profiles.json
手动登录恢复
当包装脚本无法本地恢复时,它会启动辅助浏览器覆盖层并返回:
- - 用于SSH隧道使用的回环noVNC URL
- 当主机IP已知且noVNC暴露在0.0.0.0上时的LAN noVNC URL
典型输出:
text
http://127.0.0.1:6084/vnc.html?autoconnect=1&resize=remote
http://192.168.0.200:6084/vnc.html?autoconnect=1&resize=remote
如果从Windows或其他远程机器通过SSH转发端口,请使用回环URL。
仅当主机防火墙和网络允许直接访问时才使用LAN URL。
典型工作流程
- 1. 使用请求的URL和所需的session-key尝试open-protected-page.sh
- 让包装脚本解析默认站点身份
- 如果浏览器已登录但停留在错误页面,让包装脚本自动导航回请求的站点
- 如果目标页面已就绪,首先从此主机浏览器工作流程继续任务
- 如果目标页面仍显示登录墙或挑战,打开返回的noVNC URL
- 用户完成登录并保持最终页面加载后,运行:
bash
{baseDir}/scripts/assisted-session.sh capture --origin https://target.example --session-key default
这将最终确定包装脚本管理的会话状态,并更新站点会话注册表以供后续复用。
不要将assisted-session.sh start作为正常入口点使用。从open-protected-page.sh开始,以便保持以站点为中心的配置文件解析和错误页面恢复功能。
仅在此工作流程未能完成任务,并且您有具体理由认为主机浏览器工作流程不足时,才使用不相关的浏览器工具。
环境检查
bash
command -v python3
command -v curl
command -v jq
command -v Xvfb
command -v x11vnc
command -v websockify
command -v google-chrome || command -v chromium || command -v chromium-browser
关键文件
- - scripts/open-protected-page.sh:主要受保护站点包装脚本
- scripts/assisted-session.sh:有限的手动接管和捕获
- scripts/site-session-registry.sh:规范按站点默认会话注册表
- scripts/profile-resolution.sh:以站点为先的配置文件选择,带兼容性回退
- scripts/session-manifest.sh:运行时清单存储和验证支持
- scripts/browser-runtime.sh:浏览器运行时、目标选择和页面检查
- scripts/cdp-eval.py:CDP评估、页面检查和导航
- scripts/cdp-snapshot.py:通过CDP提取结构化页面内容
CDP工具
cdp-eval.py和cdp-snapshot.py默认保持通用。
论坛/搜索结果辅助工具是可选的增强功能;仅当当前页面是论坛主题列表、分类页面或搜索结果页面,且需要结构化主题/结果链接或基于文本的点击时,才阅读references/forum-enhancements.md。
cdp-eval.py
通过Chrome DevTools协议评估页面状态或运行JavaScript。
bash
检查挑战页面
python3 {baseDir}/scripts/cdp-eval.py --port PORT --check challenge
检查登录墙
python3 {baseDir}/scripts/cdp-eval.py --port PORT --check login-wall
获取页面信息(标题、URL、内容片段)
python3 {baseDir}/scripts/cdp-eval.py --port PORT --check page-info
运行任意JavaScript
python3 {baseDir}/scripts/cdp-eval.py --port PORT --eval document.title
点击第一个可见且文本匹配或包含给定短语的链接
python3 {baseDir}/scripts/cdp-eval.py --port PORT --click-link-text Pricing
导航到URL并等待加载
python3 {baseDir}/scripts/cdp-eval.py --port PORT --navigate https://example.com --wait-navigation
导航、等待加载,然后检查页面状态
python3 {baseDir}/scripts/cdp-eval.py --port PORT --navigate https://example.com --wait-navigation --check page-info
导航并等待特定元素出现(10秒超时)
python3 {baseDir}/scripts/cdp-eval.py --port PORT --navigate https://example.com --wait-for #main-content
参数:
- - --port PORT(必需):CDP HTTP/WebSocket端口
- --target-id ID:来自/json/list的特定目标
- --check {challenge,login-wall,page-info}:内置页面状态检查
- --eval EXPRESSION:用于Runtime.evaluate的任意JavaScript
- --navigate URL:通过Page.navigate导航到URL
- --click-link-text TEXT:点击第一个可见的匹配锚点;与--navigate结合使用时,搭配--wait-navigation或--wait-for,以便在点击前目标DOM已就绪
- --wait-navigation:在--navigate后等待Page.loadEventFired
- --wait-for SELECTOR:轮询CSS选择器出现(超时10秒)
cdp-snapshot.py
默认以通用格式捕获结构化页面内容,外加可选的论坛/搜索结果辅助格式。
bash
简化markdown(默认)
python3 {baseDir}/scripts/cdp-snapshot.py --port PORT
纯文本提取
python3 {baseDir}/scripts/cdp-snapshot.py --port PORT --format text
提取所有链接为标题+href对
python3 {baseDir}/scripts/cdp-snapshot.py --port PORT --format links
从主要内容区域提取主题/结果链接(在论坛/搜索页面上有用)
python3 {baseDir}/scripts/cdp-snapshot.py --port PORT --format topic-links
带字符限制
python3 {baseDir}/scripts/cdp-snapshot.py --port PORT --max-chars