Overview
The SDK supports file attachments in user messages using<vibe-work-attachment> tags. The framework automatically reads and processes attached files.
Basic Usage
- Detect the attachment tag
- Read the file at the specified path
- Create a multi-block user message with both text and file content
Multiple Attachments
Supported File Types
| Type | Behavior |
|---|---|
| Text files | Read as UTF-8 with line numbers (max 2000 lines) |
| Images (PNG, JPEG, GIF, WebP) | Base64-encoded for vision API (max 5MB) |
| PDFs | Base64-encoded for document API (max 32MB) |
| Directories | Lists contents with type, size, and name |
How It Works
- Framework detects
<vibe-work-attachment>tags in user input - Extracts file paths and deduplicates (same file referenced twice is only read once)
- Reads each file in order
- Creates multi-block user message with original text + content blocks
- If a file cannot be read, inserts an error message block instead
Message Structure
Deduplication
Duplicate file references are detected by resolved absolute path:Path Resolution
- Absolute paths: Used as-is
- Relative paths: Resolved from the current working directory
Error Handling
Individual attachment failures do not block the message:Frontend Integration
Tags are preserved in the message text, allowing frontends to parse and display attachment badges. A typical flow:- User types
@main.rsor drags a file - Frontend converts to
<vibe-work-attachment>./main.rs</vibe-work-attachment> - Backend processes automatically via
handle.send_input(&message).await?
Programmatic Access
Next Steps
Image & PDF Support
Details on image and PDF processing
Tauri Integration
Building file attachment UI