Skip to content

SB1: the Slack bot on Workers - #2

Merged
pullely merged 1 commit into
mainfrom
orun/SB-2-the-slack-bot-on-workers
Oct 28, 2026
Merged

pullely merged 1 commit into
mainfrom
orun/SB-2-the-slack-bot-on-workers

Conversation

@pullely

@pullely pullely commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

vercel-labs/ai-sdk-slackbot (7d84809) in apps/api as one plain Cloudflare Worker (cloudflare-worker-turbo). api/events.ts is a Hono route at the same path: every request is verified FIRST — Slack's signature, HMAC-SHA256 over v0:ts:body with WebCrypto, a constant-time compare and a five-minute window, the URL verification included (upstream answered the challenge first and dropped the check's result, so a forged event was handled); a refusal is a 400 before any work. An event is acknowledged at once and answered in waitUntil (auth.test, the thread, the model and the reply all after the ack); a retry (X-Slack-Retry-Num) is acknowledged with X-Slack-No-Retry and not answered again; before Slack's two keys are stored the door answers 503. The agent, its tools (getWeather, throwDice, bash/readFile/writeFile, searchWeb only with Exa's key) and the OPA policy are upstream's; the policy's WASM is imported as a WebAssembly.Module (a Worker cannot compile bytes at runtime), and just-bash resolves to its browser build (src/vendor/just-bash.js, a wrangler alias) because its Node build needs worker_threads and native addons. The model is Workers AI (@cf/moonshotai/kimi-k2.6, workers-ai-provider over the AI binding) with no key, OpenAI directly once OPENAI_API_KEY is stored; Ollama is not carried. AI SDK 7 canaries moved to their stable releases (ai 7.0.155, @ai-sdk/policy-opa 1.0.155, @ai-sdk/openai 4.0.104). component.yaml pushes the five optional keys as Worker secrets after each deploy (runtimeSecrets) and smoke-tests /health and the events door. tests/api (29 tests) drives the routes and every Slack event in-process against stand-ins for Slack's Web API and the AI binding, checks the signature against Node's HMAC and every rule of the shipped policy.wasm. The Worker is 1.03 MiB gzipped. typecheck, lint, test and build are green.

🤖 Generated with Claude Code

vercel-labs/ai-sdk-slackbot (7d84809) in apps/api as one plain Cloudflare Worker (cloudflare-worker-turbo). api/events.ts is a Hono route at the same path: every request is verified FIRST — Slack's signature, HMAC-SHA256 over v0:ts:body with WebCrypto, a constant-time compare and a five-minute window, the URL verification included (upstream answered the challenge first and dropped the check's result, so a forged event was handled); a refusal is a 400 before any work. An event is acknowledged at once and answered in waitUntil (auth.test, the thread, the model and the reply all after the ack); a retry (X-Slack-Retry-Num) is acknowledged with X-Slack-No-Retry and not answered again; before Slack's two keys are stored the door answers 503. The agent, its tools (getWeather, throwDice, bash/readFile/writeFile, searchWeb only with Exa's key) and the OPA policy are upstream's; the policy's WASM is imported as a WebAssembly.Module (a Worker cannot compile bytes at runtime), and just-bash resolves to its browser build (src/vendor/just-bash.js, a wrangler alias) because its Node build needs worker_threads and native addons. The model is Workers AI (@cf/moonshotai/kimi-k2.6, workers-ai-provider over the AI binding) with no key, OpenAI directly once OPENAI_API_KEY is stored; Ollama is not carried. AI SDK 7 canaries moved to their stable releases (ai 7.0.155, @ai-sdk/policy-opa 1.0.155, @ai-sdk/openai 4.0.104). component.yaml pushes the five optional keys as Worker secrets after each deploy (runtimeSecrets) and smoke-tests /health and the events door. tests/api (29 tests) drives the routes and every Slack event in-process against stand-ins for Slack's Web API and the AI binding, checks the signature against Node's HMAC and every rule of the shipped policy.wasm. The Worker is 1.03 MiB gzipped. typecheck, lint, test and build are green.

Co-Authored-By: Claude <noreply@anthropic.com>
Orun-Task: SB-2
@pullely
pullely merged commit ca98277 into main Oct 28, 2026
2 checks passed
@pullely
pullely deleted the orun/SB-2-the-slack-bot-on-workers branch October 28, 2026 15:04
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.

2 participants