story-kit: merge 324_story_slack_bot_integration_for_bot_commands

This commit is contained in:
Dave
2026-03-20 01:09:55 +00:00
parent 4fe61c643b
commit 09890b5ea4
7 changed files with 1380 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ mod state;
mod store;
pub mod transport;
mod workflow;
pub mod slack;
pub mod whatsapp;
mod worktree;
@@ -228,7 +229,38 @@ async fn main() -> Result<(), std::io::Error> {
})
});
let app = build_routes(ctx, whatsapp_ctx);
// Build Slack webhook context if bot.toml configures transport = "slack".
let slack_ctx: Option<Arc<slack::SlackWebhookContext>> = startup_root
.as_ref()
.and_then(|root| matrix::BotConfig::load(root))
.filter(|cfg| cfg.transport == "slack")
.map(|cfg| {
let transport = Arc::new(slack::SlackTransport::new(
cfg.slack_bot_token.clone().unwrap_or_default(),
));
let bot_name = cfg
.display_name
.clone()
.unwrap_or_else(|| "Assistant".to_string());
let root = startup_root.clone().unwrap();
let history = slack::load_slack_history(&root);
let channel_ids: std::collections::HashSet<String> =
cfg.slack_channel_ids.iter().cloned().collect();
Arc::new(slack::SlackWebhookContext {
signing_secret: cfg.slack_signing_secret.clone().unwrap_or_default(),
transport,
project_root: root,
agents: Arc::clone(&startup_agents),
bot_name,
bot_user_id: "slack-bot".to_string(),
ambient_rooms: Arc::new(std::sync::Mutex::new(std::collections::HashSet::new())),
history: std::sync::Arc::new(tokio::sync::Mutex::new(history)),
history_size: cfg.history_size,
channel_ids,
})
});
let app = build_routes(ctx, whatsapp_ctx, slack_ctx);
// Optional Matrix bot: connect to the homeserver and start listening for