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
| Event | Behaviour |
|---|---|
app_mention | Build full thread context, run _process_message(). |
message (DM only) | Same flow, filtered to non-bot DMs. |
Per-message flow
- Generate an 8-char
request_id. - Spawn
tail_logstask to monitor the agent log file for matchingrequest_idmarkers and update emoji status. - Download any file attachments via
download_slack_file()into$GHOST_SANDBOX_DIR; inject system notes about the new files. - POST to
$GHOST_API_URLwithX-Ghost-Key. - Strip image-markdown from the response and re-upload extracted images via
files_upload_v2(). - Cancel
tail_logson completion.
State
USER_CACHE— user_id → real_name mapping.BOT_USER_ID— cached bot identity.MAINTENANCE_MODE— flag to skip processing (set with--maintenanceCLI flag).LOG_FILE_PATH— agent log path (--log-file).
Slash command router
interface/slack_project_commands.py is a stateless shlex-based router for /project ... commands:
list [status]·new <title>·resume <pid>·switch <pid>·exit·statustask add <desc>·task done <tid> [summary]·events [limit]advance— async-only; the placeholder response triggersadvance_async()in the bot handler, which callscore.project_advancer.advance_once().
Environment
http://localhost:8000/api/chat./tmp/sandbox).