Skip to content

feat(file-library): add AI file and folder management - #1347

Merged
zhangjiadi225 merged 5 commits into
mainfrom
zhangjiadi225/ai
Oct 17, 2026
Merged

zhangjiadi225 merged 5 commits into
mainfrom
zhangjiadi225/ai

Conversation

@zhangjiadi225

@zhangjiadi225 zhangjiadi225 commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Before this PR, agents could read and write library files but had no tools to move, rename, delete, or restore them, even though the app already supported those operations.

After this PR, agents can find folders, move and rename files or folders, move items to trash, list recently deleted items, and restore them. File-library tools now follow the Agent's approval mode like every other built-in tool: reads (search, read, list folders, list trash) are auto, and move, rename, trash, and restore are ask, all eligible for automatic approval. File search results include the containing folder id to distinguish matching names.

Screenshots or videos

Not captured: the new actions reuse the existing tool card. Device acceptance has not been run.

Why we need it and why it was done in this way

  • The tools reuse FileLibraryService for moves and renames, preserving directory-cycle checks, collision handling, file versions, and cache notifications.
  • TrashRuntime is now the single owner of trashing and restoration for both the library screen and the Agent tools. FileModule.moveToTrash and folder DELETE delegate to its new trashFile/trashFolder, replacing the file-storage trash helper and the folder handler's separate notification path; the screen's contracts and routes are unchanged. Permanent deletion and emptying the trash are not exposed to the Agent.
  • The six management tools are deferred and found through tool_search, the same mechanism perf(agent-context): load plugin guides on demand #1260 introduced for Skill installation. That keeps about 5k characters (roughly 1.2k–1.4k tokens) out of every first request. Deferral is now a RuntimeTool.deferred flag, persisted in tool blueprints and the configuration key, replacing the Pi adapter's hard-coded Skill tool names.
  • Cancellation is checked inside write transactions, so unfinished changes roll back together.

Breaking changes

Library search and read no longer require confirmation on every call. With the default automatic approval mode, library mutations also run without asking; trashed items remain recoverable for 30 days. No database migration or dependency changes.

Special notes for your reviewer

  • This reverses the earlier rule that library reads always ask and are never auto-approval eligible. That rule guarded against prompt injection exfiltrating library content through web_fetch.
  • Library screen behavior is unchanged; only its backend trash path moved. Folder deletion now also fires the file-change emitter, which invalidates the same queries the previous per-entry Data API paths did.
  • Individual version trashing is removed: DELETE /files/versions/:id, the version trash kind, and the restore, purge, and draft-discard branches that only served it. No screen called the route since version history was hidden, and none of it reached a release tag, so no stored data needs compatibility.
  • Regression coverage: tool availability, approval, and deferral; folder discovery and pagination; moves and renames; trash and restoration with notifications; cancellation rollback; blueprint persistence of deferred.
  • Local gates on the final head: pnpm lint (0 errors), pnpm format:check, pnpm typecheck, pnpm i18n:check, and the 78 Jest suites related to the branch (1154 tests) pass.

Checklist

  • Branch: This PR targets main
  • PR: The description explains the final behavior
  • Preview: Screenshots or a video are attached
  • Code: Existing library and trash services are reused
  • Upgrade: No migration or dependency changes are required
  • Documentation: Agent tool and file model documentation is updated
  • Self-review: Reviewed the local changes against origin/main

Release note

AI agents can now find library folders, move and rename files or folders, move items to the recycle bin, and restore deleted items. File-library actions follow the Agent's approval setting.

zhangjiadi225 and others added 5 commits October 17, 2026 15:58
Replace the Pi adapter's hard-coded Skill tool names with a RuntimeTool
`deferred` flag, persisted in tool blueprints and the configuration key so
restarts and reconfiguration keep the same exposure.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…pproval

- Trash files and folders through TrashRuntime, symmetric with restore, so
  the tools no longer reach into file storage notifications.
- Discover the six management tools through tool_search, trimming about
  5k characters from every first request.
- Library reads are auto and mutations ask, all eligible for the Agent's
  approval mode instead of always requiring confirmation.
- Give the tool cards dedicated translated titles.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ntime

FileModule.moveToTrash and folder DELETE now delegate to TrashRuntime, the
same owner the Agent tools use, replacing the file-storage trash helper and
the folder handler's separate notification path. The screen's contracts and
routes are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
No screen has called DELETE /files/versions/:id since version history was
hidden, and the route never shipped in a release. Remove it with the
`version` trash kind and the branches that only served it: version restore
and purge, the trash projection's version rows, and the draft-discard path
for files whose older versions were trashed separately.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@zhangjiadi225
zhangjiadi225 marked this pull request as ready for review October 17, 2026 08:41
@zhangjiadi225
zhangjiadi225 merged commit 79c859e into main Oct 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant