Commit 7f1bb69
feat(slack-bot): Slack bot service — @bot mentions drive ComputerAgent
New file examples/slack-bot.ts. Two bots in one service:
POST /slack/claudebot/events → claude-agent-sdk + (optional) Lyzr proxy
POST /slack/gitagent/events → gitagent direct (Lyzr via GITCLAW_MODEL_BASE_URL)
Maps Slack threads to warm /sandboxes instances:
- First @bot mention in a thread creates a sandbox with autoSave to S3
+ sessionStore: mongo (cross-process conversation memory)
- Replies in the same thread reuse the warm sandbox via /sandboxes/:id/chat
- Sandbox idle TTL (30min) fires → autoSave snapshots to S3 →
next mention in the thread restores from snapshot transparently
- Mongo collection slack_threads tracks <bot>:<channel>:<thread_ts> →
{sandboxId, snapshotId, sessionId}
Live progress UX:
Bot posts "🤔 Working…" immediately, then edits the same message as the
agent works:
🔧 Running `Write`... (3 tools so far)
→ final answer
Edits debounced to 800ms (Slack rate-limits chat.update at ~1/sec).
Slack signature verification: HMAC-SHA256(v0:<ts>:<body>) compared timing-
safe to X-Slack-Signature. 5-min replay window. Wrong sig → 401.
Mounted into the main ComputerAgentServer via a new public mount() method,
so /slack/* shares the existing HTTP listener + TLS. Boots only when
SLACK_BOTS_ENABLED=1. Bots missing config (TOKEN/SIGNING_SECRET/SOURCE)
are skipped with a warning, not fatal.
When LYZR_PROXY_ENABLED=1 + LYZR_UPSTREAM_* are set, the claudebot's
sandboxes are auto-wired with ANTHROPIC_BASE_URL=<in-process proxy>, and
gitagent is auto-wired with GITCLAW_MODEL_BASE_URL + OPENAI_API_KEY +
model="openai:<lyzr-id>". So a single set of LYZR_* envs makes both
bots talk to Lyzr.
Verified locally:
/slack/health → {"ok":true,"bots":[...],"mongoConnected":true}
invalid signature → 401
unknown bot → 404
url_verification → echoes challenge correctly with valid HMAC
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 971d83e commit 7f1bb69
4 files changed
Lines changed: 629 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
611 | 611 | | |
612 | 612 | | |
613 | 613 | | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
614 | 623 | | |
615 | 624 | | |
616 | 625 | | |
| |||
2164 | 2173 | | |
2165 | 2174 | | |
2166 | 2175 | | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
2167 | 2210 | | |
2168 | 2211 | | |
2169 | 2212 | | |
| |||
2180 | 2223 | | |
2181 | 2224 | | |
2182 | 2225 | | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
2183 | 2233 | | |
2184 | 2234 | | |
2185 | 2235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
0 commit comments