Skip to content

feat: Slack inbound file sharing — images via vision, text files via container (#222) - #235

Merged
vybe merged 3 commits into
mainfrom
feature/222-slack-file-sharing
Mar 31, 2026
Merged

vybe merged 3 commits into
mainfrom
feature/222-slack-file-sharing

Conversation

@pavshulin

Copy link
Copy Markdown
Contributor

Summary

  • Slack users can upload files to agents via DM, @mention, or thread reply
  • Images (PNG, JPEG, GIF, WebP): embedded as base64 data URIs — Claude sees them via vision
  • Text files (CSV, JSON, TXT, MD, etc.): copied into agent container, agent reads them with Read tool
  • Unsupported formats (PDF, ZIP, video, audio): rejected with user-friendly message

Security

  • Filename sanitization: os.path.basename + regex strip + hidden file rejection (prevents ../../.env traversal)
  • File upload rate limit: 5 files/minute per user (separate from message rate limit)
  • Size caps: 5MB/image, 10MB/file, 10MB total inline, max 10 files/message
  • Per-session upload directories with cleanup on all exit paths
  • files:read OAuth scope added (requires Slack app reinstall)

Architecture

  • FileAttachment model + files field on NormalizedMessage — channel-agnostic
  • ChannelAdapter.download_file() — each channel implements own download auth
  • SlackAdapter: extracts files from all 3 event types (DM, mention, thread)
  • container_put_archive() async Docker wrapper for file injection
  • Task execution service: added observability logging (timeout, HTTP status, elapsed)

Technical findings

  • Claude Code crashes (zombie process, hung pipe) when --allowedTools Read and agent reads a PNG → API returns 400 "Could not process image". Workaround: images go base64 inline, Read only added for non-image files.
  • Slack url_private_download returns HTML without files:read scope — discovered during testing.

Test plan

  • 36 unit tests (sanitization, type routing, size limits, extraction, rate limiting, session dirs)
  • API test: text file read via /api/task with allowed_tools: [Read]
  • API test: image base64 inline via /api/task — Claude describes image content
  • Slack end-to-end: image upload → agent describes screenshot
  • Slack end-to-end: text message without file → works unchanged

Fixes #222 (Phase 1 — inbound only)

🤖 Generated with Claude Code

 Pavlo and others added 2 commits March 31, 2026 11:51
Enable Slack users to upload files that agents can process. Images are
embedded as base64 data URIs for Claude vision. Text files (CSV, JSON,
TXT, etc.) are copied into per-session container directories via Docker
put_archive API.

Security:
- Filename sanitization (path traversal prevention, hidden file rejection)
- Per-user file upload rate limiting (5 files/min)
- Size caps: 5MB per image, 10MB per file, 10MB total inline images
- Max 10 files per message
- Unsupported formats rejected with user message (PDF, archives, video, audio)
- Per-session upload dirs cleaned up after execution (all exit paths)

Architecture:
- FileAttachment model + files field on NormalizedMessage (channel-agnostic)
- adapter.download_file() — each channel implements its own download auth
- files:read OAuth scope added for Slack workspace installs
- container_put_archive() async wrapper in docker_utils
- Task execution logging: timeout, HTTP status, elapsed time

Tests: 36 unit tests covering sanitization, type routing, size limits,
       extraction, rate limiting, session directories

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- requirements.md: Added SLACK-FILES requirement (§15.1b-iii)
- feature-flows/slack-file-sharing.md: Full flow document
- feature-flows.md: Index updated with new flow
- task_execution_service.py: Move start_time before try block (review item #3)
- message_router.py: Sanitize session_id in upload path (review item #4)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — approved. Branch has merge conflicts with main; please rebase before merging:

git fetch origin main && git rebase origin/main && git push --force-with-lease

Non-blocking suggestions from validation:

  • Update docs/memory/architecture.md line ~200 to include FileAttachment in the base.py models list
  • Clarify issue #222 lifecycle: remove Fixes #222 if Phase 2 outbound work should stay tracked there
  • Replace datetime.utcnow() with datetime.now(timezone.utc) in the 3 new logging lines in task_execution_service.py (deprecated in Python 3.12+)

…container (#222)

Merge of feature/222-slack-file-sharing into main.

Conflict resolution:
- feature-flows.md: kept both SLACK-FILES and TELEGRAM-001/FANOUT-001 changelog entries
- message_router.py: retained _cleanup_uploads call + updated DONE log to [ROUTER:{channel}]
  format; dropped _get_bot_token and _build_session_identifier helpers (replaced by
  adapter.get_bot_token/get_session_identifier in the Telegram channel-agnostic refactor)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.

feat: Bidirectional file sharing via Slack (SLACK-FILES)

2 participants