Repository navigation
feat(workspaces): open conversation workspaces by sandbox with agent-owned Git - #947
Conversation
… git - workbench_workspace_open only takes sandboxProfileId; the workspace starts empty and the agent clones, branches, commits, pushes and opens PRs itself. Switching environment resumes the conversation's own workspace there. - Workspace-mode CLI gets the turn speaker's Git token (askpass limited to GitHub and Gongfeng), GH_TOKEN, host-scoped SSH keys and commit identity. - Conversation workspaces accept native sandboxes (bwrap on Linux) with the same HOME/cwd layout and read-only approval hooks; seatbelt is refused. - Remove the self-built workbench_github_* tools, workspace tree/read/write/command/submit_mr/sop and attachment_read; add workbench_delivery_register to link PR/MR links to the requirement. - Update prompts, chatbot activity labels, docs and tests. Co-Authored-By: Claude Code <noreply@anthropic.com>
- internal/dockerproxy: filtering Docker API proxy per workspace. Labels created containers/networks/volumes, scopes lists/events/prune, refuses foreign objects and host escapes (privileged, caps, devices, host namespaces, masked paths, out-of-workspace binds, foreign volumes). - Workspace CLIs get DOCKER_HOST pointing at the proxy socket in a short per-conversation /tmp dir mounted into Docker and bwrap workspaces; bwrap masks host docker/containerd/podman sockets. Running containers are stopped when the CLI exits. AGENTFLOW_WORKSPACE_DOCKER=off disables it. - workbench_workspace_attach leaves the catalog; workbench_publish_artifact takes a workspace path (and keeps content publishing in spaces). - Drop clarification streams/jobs and runs_logs_download from agent catalogs. Co-Authored-By: Claude Code <noreply@anthropic.com>
- Deleting a workspace directory (run delete, conversation delete, idle reclaim) first removes the containers, networks and volumes labelled for it; stale /tmp/lf-docker-* socket dirs of deleted conversations are reaped. - Images built or committed through the proxy carry the workspace label; only those may be deleted or have their name overwritten (build -t, tag, commit, import). docker load is refused. - Bind sources are handed to the daemon as resolved real paths. Co-Authored-By: Claude Code <noreply@anthropic.com>
- Binds below a workspace or HOME root become subpath mounts of a proxy-owned local volume bound to that root (Docker 26+ / API 1.45), so a directory swapped for a symlink after the check cannot redirect the mount. Bind propagation and SELinux options are dropped; unknown options refused. - buildx's raw /grpc channel is refused for now; workspaces get DOCKER_BUILDKIT=0 so docker build goes through the checked /build. - Checkpointed reclaims keep the workspace's Docker volumes; destroying the run removes them, even after the directory is gone. - Built-in GitHub SSH host keys (github.com, ssh.github.com:443), combined with AGENTFLOW_GIT_SSH_KNOWN_HOSTS for other hosts. Co-Authored-By: Claude Code <noreply@anthropic.com>
The proxy now terminates the /grpc h2c upgrade on both sides and relays BuildKit calls. Control.Solve gets the classic /build rules (no entitlements, default/none network only, no cgroup parent, image names only where -t may write) and the workspace label; daemon-wide calls (prune, other builds' history) and unknown services are refused. DOCKER_BUILDKIT=0 is no longer forced in workspaces. Adds opt-in live tests for real bwrap and Docker-driver conversation workspaces and for buildx through the proxy. Co-Authored-By: Claude Code <noreply@anthropic.com>
… queries ListenBuildHistory without a ref lists every build on the daemon; only following a build by its (random) ref is relayed. DiskUsage is refused like system df. Co-Authored-By: Claude Code <noreply@anthropic.com>
- JSON field names: the daemon matches them case-insensitively (with
Unicode folding), the checks looked them up exactly, so
{"hostconfig":{"privileged":true}} passed. Keys that fold to a field the
proxy reads are renamed to the canonical name before checking; keys
differing only in case are refused. A test keeps the field list in sync
with the lookups in proxy.go.
- Form bodies: the daemon's FormValue prefers a urlencoded/multipart body
over the checked query (tag, build, image create). Refused.
- Links (HostConfig and endpoint) must point at own containers.
- Networks: bridge only, no driver options, custom IPAM/subnets or
config-from (host interface names, route shadowing).
- Root binds drop propagation options; --mount BindOptions.Propagation too.
- An unknown daemon version refuses subdirectory binds and retries instead
of falling back to plain binds for the proxy's lifetime.
- Docs: build-time URL fetches on the host network and daemon-wide BuildKit
cache mounts are deployment-level limits.
Co-Authored-By: Claude Code <noreply@anthropic.com>
docker pull rewrites the local name; pulling "myapp:dev" from a registry would swap an image another workspace built. Pulls of public names and own images still pass. Co-Authored-By: Claude Code <noreply@anthropic.com>
Labels and options are decoded with exact keys, so keys there that differ only in case are legitimate and are no longer refused. Co-Authored-By: Claude Code <noreply@anthropic.com>
- Container create: the daemon still reads deprecated HostConfig fields at the top level of the body; only container.Config fields plus HostConfig/NetworkingConfig are accepted there. - Form bodies are matched by Content-Type prefix: Go's ParseForm parses a body whose media parameters are malformed. - images/create follows the daemon: fromImage means pull, whatever else is set. - Classic /build outputs: image names get the -t rule. - An endpoint's explicit NetworkID (preferred by the daemon over the name) must be an own network, on create and on connect. Co-Authored-By: Claude Code <noreply@anthropic.com>
The fake server dropped the TCP connection right after exit-status, which raced the git client's own channel close and failed the push with "send disconnect: Broken pipe" under load. Co-Authored-By: Claude Code <noreply@anthropic.com>
From the third review pass: - Objects named json/create/prune/search/get were taken for collection routes whatever the method, so DELETE /volumes/create removed another workspace's volume named "create" (verified on Docker 26). Collection routes now require their own method; everything else is an object and gets the ownership check. - After the check, the daemon receives the full ID that was checked (path object, commit container, network connect container, container: modes, endpoint NetworkID), so a name is not resolved a second time (ID-prefix ambiguity, swapping an object between check and action). - The forwarded path is the cleaned, decoded path that was checked. - commit --change cannot set the workspace label; container update cannot set a cgroup parent. Co-Authored-By: Claude Code <noreply@anthropic.com>
- Remove Gongfeng from the workspace feature: askpass answers only github.com, delivery registration accepts GitHub PR links only (domain.IsGitHubPRURL), prompts and docs no longer mention Gongfeng. Tokens with an oauth2:/private: prefix are not injected. - askpass parses the host from the prompt URL and compares it exactly; the substring match handed the token to github.com.evil.example. - Compose: workspace Docker proxy sockets live under /tmp/lf-docker, shared with the host at the same path. Sibling workspace containers bind the socket directory on the host, so a directory in the platform container's own /tmp reached them empty and docker could not connect. The base directory must be owned by the platform user, 0700, not a symlink. - bwrap masks only resolved host Docker socket paths: it cannot mount over a path with a symlinked parent (/var/run -> /run in Debian images), which kept native workspaces from starting. - Docs: Compose deployments use Docker sandboxes; the native sandbox needs namespaces the unprivileged platform container cannot create. - Stale reminders/comments updated; dead review branch for removed workspace tools dropped; assistant_mcp.go back to main. Verified on a local Compose deployment (colima, Docker 29.5.2): Docker and native (privileged test override) workspaces, HTTPS/SSH clone and push, PR creation with GH_TOKEN, delivery registration, proxy denials, switching environments and back. Co-authored-by: Cursor <cursoragent@cursor.com>
…istration - Remove the workspace Docker proxy. Workspaces use the host daemon socket directly; the CLI keeps <root>/ws as its cwd so native sessions resume across mode switches, and a read-only docker shim rewrites <root>/ws paths to the workspace's host path. The conversation HOME's login files put the shim back on PATH after login shells reset it. - Sandbox-internal commands and files run without approval. Commands that write to outside systems (git push, gh/GitHub API writes, HTTP writes, publishing, image pushes, cluster changes) follow the approval mode: confirm shows an approval card, assisted asks the reviewer, auto runs. Card input is redacted per JSON string so it stays valid JSON. - Drop workbench_delivery_register; new GitHub PRs from the workspace are detected at the end of each turn and registered, creating an issue when needed. - Each phase may restart once when a native journal cannot be resumed, and the restart prompt states the current mode. Co-authored-by: Cursor <cursoragent@cursor.com>
- Stop mounting the host Docker socket into Docker conversation workspaces; remove conversation_docker.go, the workspace-bin/docker path-rewriting shim, conversation HOME profile PATH injection, and the duplicate host-path workspace mount. - Keep bwrap conversation workspaces unchanged with natural read-only host filesystem access (no /dev/null socket masking). - Restore scriptview alias validation (/ws suffix) and protocol v3, compose.yaml, go.mod/go.sum, and workspace artifact path handling; update docs accordingly.
Yanami-2K
left a comment
There was a problem hiding this comment.
这个 PR 改了 99 个文件(+2791/−6079),把对话工作区改成“按沙箱打开、Agent 自己管 Git”。审查结论是要求修改,主要问题如下:
- 和 main 有冲突(mergeableState=dirty):请先 rebase 到最新 main。打开的 PR 里 #946 也改了
internal/runner/workspace.go,#902(同一作者)也改了 assistant 相关代码,rebase 时请一并处理。 - CI 没有真正跑过:本 PR 只有开源扫描一项检查,platform / e2e / validate 都没有触发;描述里也写明没跑
go test -p=2 ./...、python3 scripts/check-public.py、scripts/scan-secrets.sh。这次删了大量代码和测试,又新加了沙箱、凭据注入、审批钩子,至少需要完整 CI 和密钥扫描全绿。 - 描述和 diff 不一致:Compatibility 写着 “Includes manual migration
migrations/020_conversation_workspaces.sql”,但 99 个改动文件里没有任何migrations/下的文件。请补上迁移,或者删掉这句描述。另外编号 020 看起来早于现有迁移(比如 #894 已经用到 033),请确认编号不会和已有文件冲突。 - 删掉了现有能力,需要维护者拍板(属于产品和架构取舍):PR 删除了
workbench_github_*(internal/httpapi/agent_tool_github*.go约 1340 行和对应测试)、workbench_workspace_submit_mr(包括mode=direct直推共享分支)、workbench_workspace_sop(接管 SOP 工作区)、workbench_attachment_read,以及按issueId/workspaceRunId切换工作区的语义。平台提示词、定时任务(例如本审查任务就依赖workbench_github_pr_review)和文档目前都依赖这些工具。请在描述里列出迁移路径(哪些调用方要改、旧提示词怎么办),或者拆成“先加新能力,再在后续 PR 下线旧工具”两步。 - 外部写入审批只是护栏:
docs/conversation-native-cli.md自己也写了“这是防误操作的护栏,不是安全边界:脚本自己联网写入不会被识别”。原来由平台代理 GitHub 写操作时可以审计、可以审批,现在把GH_TOKEN和GIT_ASKPASS直接交给沙箱里的 CLI,权限面变大了。请说明“完全权限 / 帮我批准”以外的模式下,令牌被脚本直接使用的风险是否可以接受,或者把令牌限制到具体仓库或更小的 scope。
说明:diff 中 internal/httpapi/assistant_workspace_open.go、assistant_workspace_mr.go、assistant_native_approval.go、assistant_native_external.go、internal/runtime/sandbox_process.go、command_binding.go、conversation_sandbox.go 等主要文件的 patch 被省略或截断,我没有逐行看到这些实现。上面的意见基于能看到的部分(gitwork/ssh.go、gitwork/checkouts.go、domain、chatbot、文档)和 PR 描述。建议把这个 PR 拆小,方便逐块审查。
…cret scan core failed at scripts/scan-secrets.sh: gitleaks' curl-auth-header rule flagged the literal "Authorization: token ghp_secretvalue" in TestNativeApprovalCardInputStaysValidJSONWhenRedacted. The fixture now uses "$GH_TOKEN", the form an agent writes in a workspace where GH_TOKEN is set. The test still proves the same thing: text redaction of the encoded JSON breaks it, while redactNativeApprovalInput keeps valid JSON and replaces the header value with [redacted]. Co-Authored-By: Claude Code <noreply@anthropic.com>
处理 Yanami-2K 07:07Z 审查意见 + 本地部署验证(head
|
| # | 意见 | 处理 |
|---|---|---|
| 1 | 与 main 冲突 | 已由 80bc046 合并最新 main(#810)。我独立合并了一遍,结果树与 80bc046 完全一致:assistant_unfinished.go 的 currentGeneration 保留 main 的 readGeneration(不收割本进程仍在跑的轮次),同时保留本分支删掉的 settleLegacyWorkspaceNativeApprovals;补回分支仍需要的 time import;main 新测试 TestGenerationRecordsTheWorkspaceLeaseItsToolTakes 改用本分支的 workspaceTestEdit(同样占用本轮租约)。#946 还没合入,等它合入后如有冲突再处理。 |
| 2 | CI 没真正跑过 / 未跑 scan-secrets | 合并后 CI 已全量触发。core 唯一失败是 scripts/scan-secrets.sh:gitleaks curl-auth-header 命中测试夹具 Authorization: token ghp_secretvalue。81b1015 把夹具改成 $GH_TOKEN(工作区里 Agent 的实际写法),测试仍然证明「按文本脱敏会破坏 JSON、redactNativeApprovalInput 保持合法 JSON 并替换成 [redacted]」。本地 gitleaks 8.30.1:no leaks;check-public.py 通过。 |
| 3 | 描述说包含迁移 020,但 diff 没有 | 核实:本 PR 没有任何 schema 变更,migrations/020_conversation_workspaces.sql 自 #65 起就在 main 上,文档引用的是它。已改描述,不再说「包含迁移」。 |
| 4 | 删除旧工具需维护者拍板 | 已在描述里补「Migration path for removed tools」表,逐个列出替代方式;仓库内提示词、定时任务提示词和文档已无对旧工具的正向依赖(剩下的引用都是断言「不再出现」的测试)。是否在本 PR 下线、还是拆成两步,需要维护者决定。 |
| 5 | GH_TOKEN / askpass 交给沙箱的风险 | 属于安全取舍,需要维护者决定。现状:令牌是本轮发言人自己的;askpass 只对 github.com 应答;平台自己的令牌不进沙箱;「请求批准」模式下 git push、gh 写操作、curl 写请求会暂停等批准,但脚本自行联网写入识别不了(文档已注明是护栏)。如果要收窄,可以改用按仓库授权的 fine-grained token,这需要改凭据模型,建议另开 issue。 |
CI(81b1015)
core、browser、first-run、platform-required、secrets、tcmcp、validate (3.12)、三组 python 3.12 e2e 全部通过。剩下 validate (3.8)、e2e (python 3.8)、e2e-browser、e2e-required 失败,日志是 The version '3.8' ... was not found for Ubuntu 26.04 和 Playwright does not support chromium on ubuntu26.04-x64,和 #902 一样是 runner 镜像问题,修复在 #886。
本地部署验证(Linux,MySQL 8.4.7,agentflow -role all,本 PR 构建)
- 手动执行
020、032迁移和 seed 成功;/api/health200;日志无 panic。 - CLI 用本地替身。容器不能建命名空间,所以 native 沙箱用一个只做 chdir 的 bwrap 替身,不是隔离验证。
- 平台模式下网关只给出
workbench_workspace_open和浏览器工具,workbench_github_*为 0 个。 - 审批卡片:往运行中的轮次写入一条待批准的
git push(直接写库模拟,不是 CLI 钩子产生的)。Chrome 里出现「批准外部写入:git push」卡片,点「批准本次操作」后库里decision=allow,卡片消失,轮次 completed。 workbench_workspace_open(sandboxProfileId=native-local)返回handoff=true。轮次运行中assistant_generations.workspace_run_id/workspace_lease已记录,且与run_workspace_checkpoints的租约一致(fix(assistant): keep a live generation through a slow heartbeat #810 合入后的行为)。交接后 CLI 在工作区续接并完成,结束后租约已释放。- 工作区内再发一轮:CLI 环境里
GH_TOKEN是本人配置的令牌(40 位),GIT_ASKPASS已设置;新租约记录后也在结束时释放。 go test -p=4 ./...:只有internal/runtime的 5 个 Docker 镜像用例和internal/scriptview的 capability 用例失败,在同一容器里未改动的 main 上同样失败(环境限制)。chatbot 370 个测试通过。
截图
本地部署验证(head
|
| 场景 | 结果 |
|---|---|
| 平台工具列表 | 55 个工具,含 workbench_workspace_open,workbench_github_* 为 0 个 |
workbench_workspace_open(sandboxProfileId=native-local) |
created=true, handoff=true,工作区记录创建,日志 ok=1 |
| 工作区内第二轮 | GH_TOKEN=set, GIT_ASKPASS=set,工具数降为 9(工作区内工具集) |
截图(01 平台工具、02 工作区开启后、03 工作区内轮次):
- https://gist.github.com/crispinhu27/854337f10a69d97b41e1de492be3fad0
- https://gist.github.com/crispinhu27/17f2a4e5c30ce1b2bbb0d81ede9da135
本地测试
go build ./...、go vet ./...通过go test ./internal/httpapi ./internal/repo ./internal/engine ./cmd/agentflow -count=1ok(Docker/runtime/browser 用例因容器环境在 main 上同样失败)npm run build+ 370 个 vitest 通过scan-secrets.sh无泄漏,check-public.py通过/api/health200,日志无 panic
剩余阻塞
- Yanami-2K 需要重新复审(本轮推送后 CI 全绿)
- 审查第 4 条(是否在本 PR 下线旧工具)和第 5 条(GH_TOKEN 交给沙箱的风险)仍需维护者拍板
Robert0622
left a comment
There was a problem hiding this comment.
实测结论:Approve(附几条非阻塞建议)
在 head 51dc7bb 上本地构建并部署(agentflow -role all + MySQL 8,e2e/local.sh 起环境),CLI 用真实 CodeBuddy(deepseek-v4.1-flash),Linux 上安装了 bubblewrap 0.4.0 跑真实 native 沙箱。
实测通过的场景
| 场景 | 结果 |
|---|---|
| 平台模式工具目录 | 只剩 workbench_workspace_open、浏览器工具和 workbench_tool_schema,workbench_github_* / attachment_read 为 0 |
旧参数 issueId 调 workspace_open |
被 schema 拒绝(additionalProperties) |
| native(bwrap)工作区:clone → 建分支 → 修 bug → commit → push | 正常;「请求批准」模式下只有 git push 一条命令弹审批,批准前远端没有分支,批准后推送成功 |
| 拒绝审批 | 不推送,Agent 不换方式重试,审批不残留 |
| 「完全权限」模式 | push 不弹审批直接成功 |
| 审批等待中停止生成 | 审批被释放、未推送,无 bwrap/CLI 残留进程 |
| Docker 工作区(node 镜像) | 提交身份 <login>@users.noreply.loopforge.invalid 生效;GH_TOKEN 注入、GIT_ASKPASS 指向 /workspace/.agentflow/runtime/git-askpass-hosts;容器内无 /var/run/docker.sock |
| 同一对话 native → Docker → native 切换 | 切回 native 时复用原工作区,本地未推送的提交还在 |
| Chatbot 审批卡片(Playwright 真浏览器) | 卡片显示「批准外部写入:git push」+ 命令,点「批准本次操作」后卡片消失、推送成功 |
| askpass 脚本 | 只对 https://github.com 应答;github.com.evil.io、github.com@evil.io、evil.io/github.com、http://、带端口等都不给令牌 |
测试套件
go vet ./internal/...通过;internal/{domain,engine,runner,gitwork}全过。internal/runtime的TestLightweightSandboxSmoke、TestManagedMCPRuntimeInstallsAndLaunchesInAvailableProcessSandbox失败,在 main 上同样失败(测试 TempDir 在/tmp,被 bwrap 的--tmpfs /tmp盖住);TestMainBotBrowserStartsAndDrivesRunBrowser并发跑时偶发失败,单独跑通过。- chatbot
npm run build+ vitest 370/370 通过。 - e2e(真实模型 + Docker):API 176 个,169 过 / 4 跳过 / 1 失败(schedule job「workflow not found」,新库里没有通用 SOP 模板,本 PR 未改相关代码);UI 21 个,20 过,剩余 1 个是重跑时遗留 SOP 导致的选项重复(strict mode)。
非阻塞建议
- 「帮我批准」对原生外部写入基本会退化成手动确认。
assistant_native_approval.go里给审查只留了context.WithTimeout(ctx, 15*time.Second),而approvalReviewer自己的预算是 60s。实测审查 15s 到点后显示「自动审批已取消或超时,请手动确认后执行」,然后转成人工卡片。结果是安全的(不会放行),但这个模式名不副实。可以考虑首次轮询时在后台起审查、先返回pending,后续轮询读结果,这样不受 hook 单次请求 20s 的限制。 - bwrap 下
GIT_ASKPASS/GIT_CONFIG_SYSTEM用的是工作区的宿主路径。工作区根目录在/tmp下时(比如e2e/local.sh),--bind root root之后的--tmpfs /tmp会把它盖住:git 读不到身份(Author identity unknown),askpass 也找不到。默认根目录~/.agentflow/workspace不受影响,改用沙箱内的<conversation>/ws/.agentflow/runtime/...路径会更稳。 - 默认镜像里没有
gh。IsolatedDockerfile(generic-docker)不带gh,而 PR 管理现在完全交给工作区内的gh(定时 PR 审查任务也是),每个新工作区都要先装一遍。建议在默认镜像里加上gh。 - 旧的 Gongfeng HTTPS 推送 / MR 路径没有了(askpass 只认 github.com,轮次结束只登记 GitHub PR)。Gongfeng 在 main 上已经标为 legacy,在 Compatibility 里提一句会更清楚。
删除旧工具和令牌进沙箱这两个取舍,之前的 review 已经提出来交给维护者决定;从实测看,迁移路径可用,审批护栏的行为也和文档一致。
|
帮我批准 应当只有同意 以及 拒绝,不应该出现人工确认;默认镜像没有gh符合预期,此项交由agent自行处理 |
Yanami-2K
left a comment
There was a problem hiding this comment.
复审 head 51dc7bb。CI 已全绿、与 main 无冲突,上轮第 1、2 条已处理。下列问题仍阻塞合入:
-
个人 Token 以明文环境变量进入沙箱(
internal/runtime/command_binding.go的BindGitWorkspace,文档docs/conversation-workspaces.md「Git 凭据」)。GIT_ASKPASS只对https://github.com应答的限制是对的,但同一个令牌又以GH_TOKEN注入 CLI 进程环境,沙箱内任何子进程(clone 下来的仓库脚本、npm install的 postinstall、被提示注入的命令)都能读到并外发,askpass 的主机限制因此失效。文档也承认外部写入识别「不是安全边界」。建议:默认不注入GH_TOKEN,改为由平台侧代理 / 短时效、最小权限的令牌;至少要在沙箱配置中显式开启,并在文档和 UI 里写明风险。这是上轮第 5 条,PR 描述里仍标为待维护者拍板。 -
移除旧工具会直接破坏存量用法(删除
internal/httpapi/agent_tool_github.go、agent_tool_github_pr.go、assistant_workspace_sop.go,以及agent_tool_catalog.go中的mainBotGitHubTools/workbench_attachment_read)。已保存的定时任务和角色 prompt(例如调用workbench_github_pr_review的自动审查任务)会在升级后无声失效;而且无人值守任务在「请求批准」模式下走gh pr review会卡在没人点的审批卡上,9 分钟后被拒绝。建议拆成两步:本 PR 只加新路径,旧工具保留并标记弃用;下线放到后续 PR,并附存量 prompt 的迁移或兼容提示。 -
「帮我批准」的行为与作者最新要求不一致。
docs/conversation-native-cli.md写的是「未通过时转为人工批准」,但 08:54 的评论要求「帮我批准应当只有同意以及拒绝,不应该出现人工确认」,当前 head 还没有对应改动。请在internal/httpapi/assistant_native_approval.go里把审查未通过(含 15 秒超时)改为直接拒绝并返回原因,同步更新文档和design.md,并补一条「帮我批准 + 审查拒绝」不产生native-approvals卡片的测试。 -
internal/gitwork/checkouts.go的Checkouts对沙箱用户可控的仓库使用-c safe.directory=*执行 git。如果它运行在平台或执行机宿主进程里(RunnerWorkspaceOperationCheckouts),就等于关掉了 git 针对「他人拥有的仓库配置」的保护。建议同时传-c core.fsmonitor= -c core.hooksPath=/dev/null并设GIT_CONFIG_NOSYSTEM=1,或改为直接解析.git/config与 refs,并补一条「仓库配置了 fsmonitor 不会被执行」的测试。 -
与其他打开的 PR 冲突:#946 修改工作区组合 diff(平台和 runner 两侧),#938 / #941 修改聊天工作区变更面板,与本 PR 重写的
assistant_workspace*.go和 runner workspace 有重叠。这些小修复已获批且范围小,建议先合入它们,本 PR 再 rebase。
未看全的文件:internal/httpapi/*、internal/repo/*、internal/runner/*、internal/runtime/* 的 patch 均被省略(包括 assistant_native_external.go、assistant_workspace_open.go、assistant_workspace_mr.go、sandbox_process.go、conversation_sandbox.go),chatbot/src/NativeApprovalPanel.jsx、internal/gitwork/ssh.go 和两份 docs 也被截断;以上意见根据可见部分和 PR 描述得出。
|
个人Token问题将在之后的Git处理相关PR进行处理;不考虑存量用法,上个版本为rc版本;帮我批准行为确定存在问题 |
In assisted mode a native external write (git push, gh pr ...) fell back to the speaker's approval card whenever the reviewer refused or did not answer within 15 seconds. The reviewer itself has a 60-second budget and a CLI cold start rarely fits in 15 seconds, so the mode mostly turned into a manual confirmation. The hook now starts the review in the background on its first poll and answers pending until the verdict is in; each hook request waits at most 10 seconds, below its 20-second request timeout. The same invocation is reviewed once. An allowed review runs the command; a refused, failed or timed-out review denies it with the reason and never creates a native-approvals card. Request-approval mode keeps the card. Docs, design.md and the approval picker describe the new behavior. Co-Authored-By: Claude Code <noreply@anthropic.com>
Checkouts runs git with safe.directory=* on the platform or runner host against repositories the sandbox user controls. Their config could then make the host run programs (core.fsmonitor, hooks, pager, askpass, credential helpers). The scan now pins the repository to <dir>/.git, ignores the system config, clears the keys git executes, reads only the local config without includes, and skips a .git file or symlink that could point outside the workspace. A test configures all of those keys and checks none of them runs. Co-Authored-By: Claude Code <noreply@anthropic.com>
17:00 轮:按作者 08:54 / 09:07 评论和 Yanami-2K 09:04 复审修复(head
|
| 场景(Chrome CDP 操作 chatbot) | 结果 |
|---|---|
| 帮我批准 + 审查 25 秒后批准 | hook 等 25.1 秒后 allow,原因「用户明确要求推送该分支」,0 张卡片 |
| 帮我批准 + 审查拒绝 | deny,原因带审查理由,GET native-approvals 为 [] |
| 帮我批准 + 审查不可用(超时) | 30.1 秒后 deny「自动审查暂不可用,已拒绝本次外部写入」,0 张卡片 |
| 请求批准(回归) | 出现「批准外部写入:git push」卡片,点「批准本次操作」后 allow |
截图:
| 审批模式说明 | 帮我批准:审查通过 |
|---|---|
![]() |
![]() |
| 帮我批准:审查拒绝 | 请求批准:卡片仍在 |
![]() |
![]() |
CI(7a98714)
全部通过:browser、core、curl-install、e2e(4 组)、e2e-browser、e2e-required、first-run、platform-required、secrets、tcmcp、validate 3.8、validate 3.12。
仍需
- Yanami-2K 复审(当前 CHANGES_REQUESTED);Robert0622 的 Approve 在新推送后需要重新确认。
Robert0622
left a comment
There was a problem hiding this comment.
二次复审通过 ✅(head 7a987149)
上轮的问题都已处理:
- 帮我批准:改为后台审查,结论只有允许或拒绝,不再弹卡;审查不可用或超时一律拒绝。
- checkout 扫描加固:改用
--git-dir、GIT_CONFIG_NOSYSTEM,禁用可执行的配置项,跳过.git软链接和文件。
验证情况:
- CI 15/15 通过。
internal/httpapi、internal/gitwork相关用例加-race通过;chatbot vitest 370/370 通过。- 本地部署实测(native bwrap 沙箱 + 本地 git http 远端,模型 deepseek-v4.1-flash):
- 帮我批准、操作正常:约 10s 自动放行,没有卡片,push 成功。
- 帮我批准、审查模型不可用:拒绝外部写入,没有卡片,远端没有新分支,agent 如实告知用户原因。
- 请求批准:照常弹卡,批准后 push 成功。
非阻塞的小问题:审查不可用时,状态栏文案仍是平台草稿那套"请手动确认后执行",和"已拒绝"不太一致,后续可以顺手改一下。
…dbox # Conflicts: # internal/runtime/sandbox_process.go
Robert0622
left a comment
There was a problem hiding this comment.
合并 main 解决冲突之后复核通过,重新 approve ✅(head 2015e47a)
- 冲突只出现在
internal/runtime/sandbox_process.go:保留了本 PR 的 conversation guard 规则和bwrapChdir,按 #953 去掉了 agent 配置屏蔽(maskAgentConfig、discoverProjectAgentPaths),处理得没问题,也没有残留冲突标记。 - 本地验证:
go build ./...、go vet通过。internal/gitwork加-race通过,internal/httpapi通过,internal/runtime不加-race通过,chatbot vitest 370/370 通过。 internal/runtime加-race时TestDevServerPipeScriptRelaysHTTP会报 data race,但 main(c1fa0f7b)上也一样复现,本 PR 没改相关文件,跟本 PR 无关。- CI 15/15 通过。






What changed
workbench_workspace_opentakessandboxProfileId), letting agents clone, branch, commit, push, and open/manage PRs with their owngit/ghusing the turn speaker's scoped credentials (GIT_ASKPASSrestricted tohttps://github.com,GH_TOKEN, and per-host:portssh-agentwith pinned host keys).workbench_github_*,workbench_workspace_tree/read/write/command/attach/submit_mr/sop,workbench_attachment_read); retainedworkbench_platform_mode,workbench_browser_*, andworkbench_publish_artifact(including host workspace absolute paths under/<runID>/...).git push,ghwrites,curl/wgetwrites, package/image/infra pushes) with ChatbotNativeApprovalPaneland automatic end-of-turn GitHub PR registration onto requirements.nativesandboxes (bwrapon Linux,seatbelton macOS with last-match-wins SBPL write protection for approval hooks and parent directories) for conversation workspaces, droppeddocker.sockmounting and shims from Docker sandboxes, and forwarded host Docker context endpoints asDOCKER_HOSTto isolated-HOMEprocessSandboxcommands without sharing registryauths.EnsureSandboxBrowser'sunwrapSandboxto unwrapinterface{ Unwrap() Sandbox }wrappers (including*engine.runEnvironment) so local SOP agent nodes receiveagentflow-browserMCP.Scope
Compatibility
docker.sock; usenative(bwrapon Linux,seatbelton macOS) when container/Docker daemon access is needed from a conversation workspace.docs/conversation-workspaces.mdrefers tomigrations/020_conversation_workspaces.sql, which has been on main since feat: sync chat home, conversation workspaces and delivery tracking #65; deployments that already ran it have nothing to run for this PR.Migration path for removed tools
workbench_github_*(PR/Issue list, view, review, comment, merge)gh/ the GitHub API with the turn speaker'sGH_TOKEN. The system prompt and the scheduled-task prompt (scheduledAssistantPrompt) already say so.workbench_workspace_tree/read/write/commandtreestays internal for workspace preparation).workbench_workspace_submit_mr(incl.mode=direct)git push/gh pr createitself; in 「请求批准」 mode they wait for the speaker's approval card. PRs opened in the turn are registered on the requirement when the turn ends.workbench_workspace_sopruns_pause/runs_cancelthe SOP first, thenworkbench_workspace_open.workbench_workspace_attachworkbench_publish_artifactwith a workspacepath.workbench_attachment_readissueId/workspaceRunId/newonworkbench_workspace_opensandboxProfileId; returning to a sandbox the conversation used before reuses that workspace.Stored prompts written by users (for example a scheduled task that names
workbench_github_pr_review) are not rewritten: the CLI no longer sees that tool, and the system prompt points it to the workspace +ghpath instead. Whether to ship removal in this PR or split "add new path" / "remove old tools" is a maintainer decision.Validation
Ran after final commit
b46f730:go vet ./...— passed on macOS.go test -v -count=1 ./internal/runtime -run 'TestEnsureSandboxBrowser|TestConfigureProcessConversationSandbox|TestSeatbeltProfile|TestEnsureConversationCLI|TestConversationProcessSeatbelt|TestProcessSandboxResolvesHostDockerContextWhenHomeIsolated|TestScriptViewsPreserveProcessSandboxBoundaries') — passed (including livesandbox-exec+ Colimadocker psanddocker run --rm alpine true).bubblewrap 0.8.0,AGENTFLOW_SANDBOX_SMOKE=1) targeted tests (internal/runtimesmoke/bwrap/docker-context tests,TestRunEnvironmentUnwrapsForEnsureSandboxBrowser,TestMainBotAttachesWorkspaceFilesToReply) — all passed.Ran prior to final
b46f730commit (on9648ad1/24a3e06):go test -count=1 ./internal/domain ./internal/repo,go test ./internal/httpapi,go test -count=1 -parallel 4 ./internal/engine ./internal/runner— passed on macOS (./internal/runtimefull package on macOS has 4 pre-existing Linux/host baseline failures unrelated to this PR).9648ad1), local macOSseatbelt(24a3e06), and privileged Linuxbwrap(24a3e06) with real CodeBuddy, browser MCP, and conversation workspaces — passed.After merging main (
80bc046) and the secret-scan fixture fix (81b1015), on Linux:go build ./...,go vet ./...,go test -p=4 ./...(onlyinternal/runtimeDocker-image cases andinternal/scriptviewcapability drop fail, identically on unchanged main in the same container),internal/repoagainst MySQL 8.4.7, chatbotnpm run build+ 370 vitest tests,python3 scripts/check-public.pyandbash scripts/scan-secrets.sh(no leaks) — all passed. CI on the PR runs the full platform / e2e / validate set.Not run:
local/scripts/validate.sh,local/scripts/smoke-install.sh,local/scripts/e2e.sh.Safety