Files
UHD_Media_Tool/packages/adapters/src/browser
rootandClaude Opus 5.5 838aea3ebd feat(browser): self-heal sessions after camofox restarts (BR-3)
- Any session operation that hits 404/410 (or finds no open tab) reconciles
  tabs; if none survive it re-injects the account cookies (BR-2), opens a new
  tab under the same userId/sessionKey, returns to the recorded URL (site home
  otherwise), marks old tabs lost and retries the operation once. Failure
  returns 503 browser_reconnect_failed with the reason, with a 10s backoff.
- Restart detection: umt plugin GET /umt/instance (fallback /health fields);
  a changed instance id marks every open session needsReconnect.
- POST /browser/sessions/{id}/reconnect (idempotent); session view exposes
  needsReconnect and reconnect {status, trigger, at, reason, humanNotice}.
- Controller and lease are kept; reconnecting during takeover asks the human
  to double-check the reloaded page.
- Web: screenshot and desktop modes show "reconnecting", auto-reconnect once,
  pause polling, offer a reconnect button with the reason on failure; desktop
  mode rebuilds the Selkies connection after a reconnect.
- Mock camofox restart(), tests, smoke step and runbook section 10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-29 17:29:11 +08:00
..

browser

BrowserProvider 合同(provider.ts)及其实现:业务侧访问浏览器服务只走这套接口。产品浏览器能力对接用户已有的 camofox-browser;Playwright 只用于前端截图测试,不是产品浏览器能力。设计说明见 docs/design/browser-provider.md。

  • camofox/:camofox-browser 适配器。按 jo-inc/camofox-browser v1.17.0 的 openapi.json、README 与 server.js 实现,2026-09-28 对真实容器逐项核验(docs/runbook/browser.md §7;核验表 camofox/capabilities.ts 的 CAMOFOX_VERIFIED_RELEASES),Authorization: Bearer <CAMOFOX_ACCESS_KEY>,凭据每次请求经 BrowserSecretResolver 解出,不缓存、不入日志。camofox userId = 本项目 profileKey(站点/账号隔离),sessionKey = browser_session.id。
  • none.ts:默认实现(未配置浏览器),能力全关,动作报 unavailable。
  • redact.ts:redactSnapshot / redactBrowserUrl,快照与地址进入模型前遮蔽密码框值、Cookie 值、含 passkey/token 的 URL。
  • profile-lock.ts:同一 profile 串行锁(进程内内存实现;多进程部署换持久化实现,接口不变)。
  • budget.ts:导航域名白名单(含子域),非 http(s) 拒绝。

已实现(C1-E;BR-1 对 v1.17.0 真机核验并修正实测差异)

  • 会话:openSession(POST /tabs)、closeSession(DELETE /sessions/{userId})、listSessions(内存镜像;服务层以数据库为准)、restoreSession(重启后按 DB 恢复,旧引用失效)。
  • 标签页:openTab、closeTab(DELETE /tabs/{id})、reconcileTabs(GET /tabs?userId,上游已回收的标 lost)。
  • 导航:navigate(白名单 / 超时 / 预算内重试 5xx·超时·网络)、history(/back /forward /refresh)。
  • 读取:snapshot(字节预算截断 + 脱敏)、screenshot(JSON base64 或 image/*;登录页 / 含凭据地址 modelSafe: false)、extract(POST /extract,需先快照)。
  • 交互:click(ref / selector / 视口坐标)、type(明文或凭证引用,凭证经 BrowserSecretResolver 解出后直接下发)、select、scroll、press。
  • 下载:waitForDownload 轮询 GET /tabs/{id}/downloads?includeData&consume&maxBytes,字节交 DownloadSink 暂存、算 sha256,只返回引用。
  • 控制权:TabRef.as 标明发起方(automation / human),与会话 controller 不符报 control_conflict;setController 任何变更都让旧 eN 引用失效(stale_ref);acquireControl / releaseControl 为内存版,服务层用 browser_control_lease 持久化。

未核验的上游行为(坐标点击、无目标输入、scroll / press / back 等端点、downloads 字段形状)见 docs/runbook/browser.md 第 6 节。