interface / externals / slack_bot / main.py

Async Slack bot using slack_bolt Socket Mode. Maintains per-thread context, downloads user files into the sandbox, posts emoji status updates while streaming.

Event handlers

EventBehaviour
app_mentionBuild full thread context, run _process_message().
message (DM only)Same flow, filtered to non-bot DMs.

Per-message flow

  1. Generate an 8-char request_id.
  2. Spawn tail_logs task to monitor the agent log file for matching request_id markers and update emoji status.
  3. Download any file attachments via download_slack_file() into $GHOST_SANDBOX_DIR; inject system notes about the new files.
  4. POST to $GHOST_API_URL with X-Ghost-Key.
  5. Strip image-markdown from the response and re-upload extracted images via files_upload_v2().
  6. Cancel tail_logs on completion.

State

Slash command router

interface/slack_project_commands.py is a stateless shlex-based router for /project ... commands:

Environment

SLACK_BOT_TOKEN
bot token for API calls.
SLACK_APP_TOKEN
app-level token for Socket Mode.
GHOST_API_URL
Default http://localhost:8000/api/chat.
GHOST_API_KEY
Same value the agent expects.
GHOST_SANDBOX_DIR
Where uploads land (default /tmp/sandbox).