feat: support Discord file attachments#165
Closed
DrVictorChen wants to merge 1 commit intoopenabdev:mainfrom
Closed
feat: support Discord file attachments#165DrVictorChen wants to merge 1 commit intoopenabdev:mainfrom
DrVictorChen wants to merge 1 commit intoopenabdev:mainfrom
Conversation
Discord users can now send files (PDFs, images, code, etc.) alongside
their messages. The handler downloads attachments to a local temp
directory and appends the file paths to the prompt text, so any ACP
backend agent can read them with its native file tools.
Details:
- Download attachments to /tmp/openab_attachments/{thread_id}/
- Sanitize filenames to prevent path traversal
- Skip files >25 MB, limit 5 attachments per message
- Graceful fallback: on download failure, include the Discord CDN URL
- Allow attachment-only messages (no text required)
- Clean up temp files when sessions are garbage-collected
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
/tmp/openab_attachments/{thread_id}/and file paths are appended to the prompt text, so any ACP backend agent can read them with its native file tools — no ACP protocol changes neededRelated: #161 (feature request for multimodal support), #158 (image-only via ACP ImageContent blocks). This PR takes a complementary approach — downloading all file types to disk and injecting paths into the prompt, which works for PDFs, code files, and other non-image attachments without requiring ACP protocol changes. The two approaches (#158 for images, this PR for general files) could coexist.
How it works
Changes
Cargo.tomlreqwest(rustls-tls, matching serenity's TLS backend)src/discord.rsdownload_attachments(), inject paths into prompt, allow attachment-only messagessrc/acp/pool.rsSafety
.,-,_)Test plan
cargo build --releasepasses/tmp/openab_attachments/{thread_id}/removed🤖 Generated with Claude Code