🔒 限制 Agent OPFS 写操作至 workspace 并支持重命名与移动#1578
Draft
cyfung1031 wants to merge 1 commit into
Draft
Conversation
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.
Checklist / 检查清单
背景
Agent OPFS 浏览器此前从 OPFS 根目录开始浏览,并在任意目录提供上传和删除操作。这样会暴露 ScriptCat 的系统数据,用户也可能误修改或删除系统资源,导致扩展无法正常运行。
本次改动
agents/workspace/**设为唯一可修改范围;OPFS 根目录及其他系统目录保持只读。agents/workspace/**内都会拒绝。实现说明
UI 与底层文件系统操作共享同一套 workspace 路径判断。
writeFile、removeEntry、renameEntry和moveEntry都会在执行前验证可编辑路径和条目名称。重命名复用移动逻辑;移动通过递归复制后删除源条目实现,并在复制前检查目标是否已存在。源目录与目标目录都必须位于
agents/workspace/**,且不允许将目录移动到自身或其子目录中。验证
git diff --check通过。建议审查重点
agents/workspace/**。Closes #1572