Repository navigation
feat(browser): 接管模式 — 可见 headed 窗口承载会话级登录与人工处理(#491 P2) - #524
Merged
Merged
Conversation
…in and manual handling Issue #491 P2 (headed handoff) + the session-login story: the agent browser can now run as a visible window on the operator's desktop so a human can log in, complete 2FA/OAuth, or resolve waiting_user states manually. Login state persists in the session's disposable profile and dies with it at cleanup; the agent gains no extra authority and origin scope, interception, quarantine, and approvals are unchanged. - CYBERAGENT_BROWSER_HEADED=1|true at either composition root, or cyberagent api serve --browser-headed. - waiting_user status copy now points at the takeover mode. - Bilingual usage docs for the takeover and session-login semantics. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Qiyuanqiii
force-pushed
the
Qiyuanqiii/browser-takeover-mode
branch
from
October 29, 2026 22:56
9764541 to
bd34eba
Compare
… logins Completes the takeover-mode follow-up flagged in review: the browser session runtime deadline (30 minutes by default) wipes the disposable profile — including manual login state — right when a takeover session needs it most. Operators can now raise it with CYBERAGENT_BROWSER_SESSION_LIFETIME_MINUTES (5..1440, accepted at the same three composition roots; malformed or out-of-range values keep the default). Quarantine, approvals, and cleanup receipts are unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
… the takeover branch
…the takeover branch
This was referenced Nov 1, 2026
Merged
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机 / Motivation
#491 P2 的 headed 交接 + 会话级登录 v1:默认 headless 下,登录态(staging 预览、OAuth、2FA)与
waiting_user人工处理都不可达。Codex 用 Chrome 扩展解决身份;Universal-Code 是本地桌面产品,最自然的路径是把同一个隔离浏览器以可见窗口启动——人工在窗口内登录,登录态存续于会话一次性 profile,cleanup 时擦除(profile 生命周期既有语义,零新增清理面)。变更 / Changes
CYBERAGENT_BROWSER_HEADED=1|true(或 CLIcyberagent api serve --browser-headed)在组合根选择接管模式;三个组合根全部接线(api serve、前台 CLI run 的 DangerFullAccess 路径、桌面控制面)。waiting_user状态文案指向接管模式;usage.md 新增双语 "Browser takeover and session login" 小节(含会话 30 分钟 RuntimeDeadline 边界的如实说明——到期 profile 擦除、下次导航开新 profile)。docs/reviews/browser-takeover-mode/。验证 / Verification
gofmt/go vet/go build ./...全部干净;TestBrowserHeadedFromEnvironment覆盖取值矩阵(1/true/大小写/空白与 0/false/yes/on 的 fail-closed)。internal/desktop全量 ok;Headless 汇点、spec 参数两种变体校验、指纹链、文案一致性逐项核验。关联 #491、#520、#523。
评审跟进 / Review follow-up
外部评审对本 PR 的结论是"实现可以保留,但建议补一次真实 headed 浏览器验收,并在上游合并后重新检查差异"。本轮完成两件事:
1. 已吸收上游修复(merge commit
9e667a06)本 PR 的 base 是 #523(
Qiyuanqiii/browser-download-release),而 #523 的 base 是 #520。评审指出这三者必须按 #520 → #523 → #524 的顺序处理,不能因为各自 CI 成功就按普通独立 PR 合并。因此本轮先把 #520 的 P1 会话累计下载预算修复(2cd5cbb9)与 #523 的 P2 释放审批审计修复(fb1e3ae4)一并以 merge commit 并入本分支,保证本 PR 建立在已修复的上游之上。并入后本 PR 相对其 base 的有效差异仍只有接管模式本身的 12 个文件(+278/−8),没有把上游功能重复计入本 PR。
2. 合并前置条件
main;main后,本 PR 的 base 需从Qiyuanqiii/browser-download-release改为main并重新验证,再合入——否则直接 Merge 只会把提交合进上游功能分支,而不是main;真实 headed 浏览器验收清单 / Real headed browser acceptance checklist
外部评审指出:本 PR 的测试主要覆盖环境变量解析与三个组合根的接线,没有证明真实 headed 场景。人工 2FA 与真实站点的跨 origin OAuth 登录无法在无人值守环境完成,因此下面每一步都必须由具备可见桌面环境的维护者实跑确认;未跑之前,本 PR 不应视为已完成真实场景验收。
前置条件:以
CYBERAGENT_BROWSER_HEADED=1(或cyberagent api serve --browser-headed)启动,并用CYBERAGENT_BROWSER_SESSION_LIFETIME_MINUTES把会话时长设到足够覆盖整轮人工操作(上限 30 分钟 RuntimeDeadline,到期后 profile 擦除)。waiting_user状态下由人工在可见窗口内输入验证码,确认整个过程不会被 30 分钟 RuntimeDeadline 提前打断(必要时先提高会话时长上限再测)。docs/reviews/browser-takeover-mode/。说明:第 2 项(跨 origin OAuth 是否被现有拦截策略放行)与第 3 项(人工 2FA)无法在无人值守 CI 中自动化,必须人工实跑。本 PR 的 CI 全绿不等价于上述场景已验收;本清单是合并前的待办验收项,不是已完成项。
层叠栈同步:已携带 #520 / #523 的第二轮修复
第二轮外部复审在 #520 查出超限下载的
Browser.cancelDownload未携带browserContextId(取消打在默认 BrowserContext 上 → 取消失败 → 按既有策略关闭整个会话),在 #523 查出重复释放
响应回显请求方而非落盘审批、以及工件写失败留下半截文件导致该 GUID 永久无法重试。两处修复已
按层叠顺序并入本分支:
merge: carry the browser context cancel fix into the release branch→
fix(application): report the recorded release approval and roll back failed artifact writes→ 本分支的 merge commit(
0e21640f携带2dcf89ba),沿用本栈既有的 merge commit 传播方式,未做任何 force-push。
同步后的复测(Go 1.26.10 / windows-amd64,HEAD
0e21640f):go build ./...通过;go vet ./internal/browserruntime/ ./internal/application/ ./internal/httpapi/无告警。go test -count=1 ./internal/browserruntime/全通过(9.17s,含新增的 context 配对回归TestAgentBrowserDownloadCancelTargetsTheQuarantineContext);go test -count=1 -run "TestAgentBrowserDownload|TestAgentBrowserTakeover|TestAgentBrowserHeaded" ./internal/application/ ./internal/httpapi/通过(0.17s / 0.56s)。internal/httpapi全量,也没跑internal/application整包(后者本机跑不完,属既有环境限制);本 PR 的真实 headed 验收清单(上面 5 项)仍是待办,
上面这些绿只证明层叠合并没有破坏接线与单元测试面,不等于接管流程已验收。
main并重新验证。