Repository navigation
SB1: the Slack bot on Workers - #2
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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