Agents save a message's attachment to the downloads folder #57

Merged
merge-queue merged 1 commit from save-attachment into main 2026-11-24 19:49:41 -08:00
Owner

Work package: https://openproject.home.romaine.life/wp/TUI-18

Adds save_attachment to tuimail's agent interface (tuimail mcp). Until now agents saw attachments' names only and nothing could hand a file to an agent.

Added

  • save_attachment { id, index }: saves one attachment of a message (from search_messages) or an archived one (from search_archive) the way s does: into the downloads folder through tools::save_new (never over a file, a new name instead, marked as downloaded), checked to be the one listed, never opened. Answers saved (the path), name, size.
  • read_message / read_archived now give each attachment its index.
  • A message not yet downloaded is fetched once, as reads are (AgentRead.wants), within the existing download limits.
  • Each save shows on the status line and as a notification (AppEvent::AgentSaved). At most 50 saves an hour; refused in the demo.

Choice: a save changes no mail, so it isn't put to the user's y the way changes are; it's visible instead. The server instructions tell agents to save only a file the user asked for.

Unchanged: no tool opens, sends or deletes anything; mail itself isn't touched.

Docs: README's AI agents section, CLAUDE.md's security notes, mcp::INSTRUCTIONS (1,588 of 2,048 characters).

Tested: agents_save_an_attachment_read_message_lists (index listed, saved to the downloads folder, a second save gets a new name, a wrong index and the demo save nothing, status line shows it); ci-check passes (fmt, clippy, 276 tests).

🤖 Generated with Claude Code

Work package: https://openproject.home.romaine.life/wp/TUI-18 Adds `save_attachment` to tuimail's agent interface (`tuimail mcp`). Until now agents saw attachments' names only and nothing could hand a file to an agent. **Added** - `save_attachment { id, index }`: saves one attachment of a message (from `search_messages`) or an archived one (from `search_archive`) the way `s` does: into the downloads folder through `tools::save_new` (never over a file, a new name instead, marked as downloaded), checked to be the one listed, never opened. Answers `saved` (the path), `name`, `size`. - `read_message` / `read_archived` now give each attachment its `index`. - A message not yet downloaded is fetched once, as reads are (`AgentRead.wants`), within the existing download limits. - Each save shows on the status line and as a notification (`AppEvent::AgentSaved`). At most 50 saves an hour; refused in the demo. **Choice:** a save changes no mail, so it isn't put to the user's `y` the way changes are; it's visible instead. The server instructions tell agents to save only a file the user asked for. **Unchanged:** no tool opens, sends or deletes anything; mail itself isn't touched. **Docs:** README's AI agents section, CLAUDE.md's security notes, `mcp::INSTRUCTIONS` (1,588 of 2,048 characters). **Tested:** `agents_save_an_attachment_read_message_lists` (index listed, saved to the downloads folder, a second save gets a new name, a wrong index and the demo save nothing, status line shows it); `ci-check` passes (fmt, clippy, 276 tests). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Agents save a message's attachment to the downloads folder (TUI-18)
All checks were successful
Suite rust / check-services (pull_request) Successful in 1m45s
Suite rust / reused-checks (pull_request) Successful in 5s
Suite release / check-build (rust, x86_64-pc-windows-msvc) (, rust-x86_64-pc-windows-msvc, x86_64-pc-windows-msvc, false, windows-latest, x86_64-pc-windows-msvc, rust) (pull_request) Successful in 2m7s
Suite rust / check-format (pull_request) Successful in 9s
Suite rust / check-audit (pull_request) Has been skipped
Suite release / publish (pull_request) Has been skipped
Suite default / reused-checks (pull_request) Successful in 7s
Suite cluster-service / reused-checks (pull_request) Successful in 6s
Suite release / check-build (rust, x86_64-unknown-linux-gnu) (, rust-x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu, false, ubuntu-latest, x86_64-unknown-linux-gnu, rust) (pull_request) Successful in 1m14s
Suite rust / check-test-windows (pull_request) Successful in 1m54s
Suite rust / check-typos (pull_request) Has been skipped
Suite rust / check-machete (pull_request) Has been skipped
Suite cluster-service / publish (pull_request) Has been skipped
Suite release / module (pull_request) Has been skipped
Suite release / reserve (pull_request) Has been skipped
Suite release / build (rust, aarch64-pc-windows-msvc) (, rust-aarch64-pc-windows-msvc, aarch64-pc-windows-msvc, false, windows-latest, aarch64-pc-windows-msvc, rust) (pull_request) Has been skipped
Suite release / build (rust, aarch64-unknown-linux-gnu) (, rust-aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu, false, ubuntu-latest, aarch64-unknown-linux-gnu, rust) (pull_request) Has been skipped
Suite release / build (rust, x86_64-pc-windows-msvc) (, rust-x86_64-pc-windows-msvc, x86_64-pc-windows-msvc, false, windows-latest, x86_64-pc-windows-msvc, rust) (pull_request) Has been skipped
Suite release / build (rust, x86_64-unknown-linux-gnu) (, rust-x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu, false, ubuntu-latest, x86_64-unknown-linux-gnu, rust) (pull_request) Has been skipped
Suite release / home-sync (pull_request) Has been skipped
Suite release / dispatch (pull_request) Has been skipped
Suite release / deploy-image (pull_request) Has been skipped
Suite release / check-build (rust, aarch64-unknown-linux-gnu) (, rust-aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu, false, ubuntu-latest, aarch64-unknown-linux-gnu, rust) (pull_request) Successful in 2m9s
Suite cluster-service / check-manifests (pull_request) Has been skipped
Suite cluster-service / check-image (pull_request) Has been skipped
Suite release / finalize (pull_request) Has been skipped
Suite release / reused-checks (pull_request) Successful in 4s
merge-queue landed on main
Suite release / check-build (rust, aarch64-pc-windows-msvc) (, rust-aarch64-pc-windows-msvc, aarch64-pc-windows-msvc, false, windows-latest, aarch64-pc-windows-msvc, rust) (pull_request) Successful in 4m0s
Suite release / check-package (pull_request) Successful in 2m52s
829221c0b1
save_attachment saves one attachment, by its index in read_message's
(or read_archived's) list, as `s` does: into the downloads folder,
never over a file there, marked as downloaded, never opened. It changes
no mail, so it isn't asked about; each save is said on the status line
and in a notification. At most 50 an hour; refused in the demo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First-time contributor

merge-queue stopped this at 829221c: CI failed: Suite release / check-build (rust, aarch64-pc-windows-msvc) (, rust-aarch64-pc-windows-msvc, aarch64-pc-windows-msvc, false, windows-latest, aarch64-pc-windows-msvc, rust) (pull_request). Push a fix, or once it is fixed outside this pull request, remove and re-add the queue label.

merge-queue stopped this at 829221c: CI failed: Suite release / check-build (rust, aarch64-pc-windows-msvc) (, rust-aarch64-pc-windows-msvc, aarch64-pc-windows-msvc, false, windows-latest, aarch64-pc-windows-msvc, rust) (pull_request). Push a fix, or once it is fixed outside this pull request, remove and re-add the `queue` label.
merge-queue deleted branch save-attachment 2026-11-24 19:49:41 -08:00
Sign in to join this conversation.
No description provided.