feat(workspace): 支持外部目录授权与多根文件访问 - #468
Open
yovinchen wants to merge 8 commits into
Open
Conversation
yovinchen
marked this pull request as ready for review
August 13, 2026 18:50
Contributor
Author
|
目前还有一个尚未确定的设计问题:在 Desktop 和 Web 端拖入文件夹时,应该采用怎样的处理方式。 当前拖入文件时,文件并不是直接发送给模型:如果文件原本位于工作空间内,就直接引用原文件;如果是工作空间外的文件或从 Web 端上传的文件,则会先进入应用管理的暂存目录,再把一个 Agent 可读取的路径提供给模型。基于这一现状,拖入文件夹大致有两种处理方式:
不知道采用平台差异化处理是否合理:Desktop 端在用户确认后,将文件夹添加为附加只读目录;Web 端则把文件夹内容导入到独立的暂存目录。还是说,在确定一个统一的跨平台语义之前,暂时继续不支持文件夹拖拽会更合适?希望听听大家的意见。 |
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.
Linked issue
Closes #408
Closes #459
Summary
Issue #408 的根因是文件工具只有单一工作区根目录:聊天中的文件导入只会把普通文件复制到上传作用域,目录既不会被挂载,也不会扩展结构化文件工具的可访问边界。因此 Agent 无法在保留当前项目归属的同时,安全地引用或修改另一个项目目录。
本 PR 增加项目级附加目录授权,并把入口统一到项目“三点菜单 → 配置”中:
root://<alias>/...路径语义和最长根匹配解析,结构化 Read/List/Glob/Grep 可访问只读根,Write/Edit/Delete 仅可访问读写根。本 PR 实现的是“在项目配置中显式添加并授权外部目录”。将文件夹直接拖入聊天并转化为授权根不在本次范围内,避免在未完成确认流程和浏览器目录句柄设计前隐式扩大权限。
Change scope
agent-ui/agent-gui/src-tauri/agent-gateway/ Gateway WebUIcrates/agent-ui/src/components/chat/WorkspaceProjectSettingsModal.tsxcrates/agent-gui/src/lib/tools/pathUtils.tscrates/agent-gui/src/lib/tools/fsTools.tscrates/agent-gui/src/lib/workspaceRootGrants.tscrates/agent-gui/src-tauri/src/commands/workspace/root_grants.rscrates/agent-gateway/proto/v2/gateway.protocrates/agent-gateway/web/src/agent-ui-adapters/directoryPicker.tsxScreenshots / preview
Draft 运行预览已完成:
Verification
cargo test --manifest-path crates/agent-gui/src-tauri/Cargo.toml root_grants --lib— 12 passedmise exec -- go -C crates/agent-gateway test ./internal/protocol/pbws— passedmise exec -- node --test crates/agent-gateway/web/test/gateway-v2-adapters.test.mjs— 9 passedmise exec -- node --test crates/agent-gui/test/tools/path-and-system-tools.test.mjs crates/agent-gui/test/chat/markdown-image-policy.test.mjs crates/agent-gui/test/subagents/agent-tool.test.mjs— 102 passedmise exec -- node --test crates/agent-gui/test/chat/sidebar-selection.test.mjs crates/agent-gui/test/settings/workspace-resource-settings.test.mjs— 12 passedmise exec -- pnpm build:gui— passedmise exec -- pnpm build:webui— passedgit diff --check origin/main...HEAD— passed覆盖的关键场景包括:macOS/POSIX 路径、Windows 盘符与 UNC 路径、
file://与root://、路径穿越、符号链接漂移、重叠根、只读写入拒绝、子 Agent 权限降级、Gateway 请求校验和项目删除撤权。Pre-submit checklist