Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat: anthropic status bot (#5293)

Eric Hayes7490f418a3c5
diff --git a/bun.lock b/bun.lock
index 14b23fce97..fe1b13ae36 100644
--- a/bun.lock
+++ b/bun.lock
@@ -312,6 +312,19 @@
"wrangler": "^4.103.0",
},
},
+ "services/bots/anthropic-status-bot": {
+ "name": "anthropic-status-bot",
+ "version": "0.0.1",
+ "dependencies": {
+ "hono": "^4.6.20",
+ "zod": "^4.4.3",
+ },
+ "devDependencies": {
+ "@types/node": "^25.9.3",
+ "bun-types": "^1.3.14",
+ "wrangler": "^4.110.0",
+ },
+ },
"services/lexical-service": {
"name": "lexical-service",
"version": "0.0.1",
@@ -1672,6 +1685,8 @@
"ansi-styles": ["[email protected]", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
+ "anthropic-status-bot": ["anthropic-status-bot@workspace:services/bots/anthropic-status-bot"],
+
"any-base": ["[email protected]", "", {}, "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg=="],
"argparse": ["[email protected]", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
@@ -3414,6 +3429,8 @@
"ai-editing-worker/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-OScDchr2fwuUmWdf4kZ9h7PcJiYDVInhJizG/biAq3cAvqwYktuy/TYGGdZNMtNTFUP7rnb0NU4TUdm82kt4Rg=="],
+ "anthropic-status-bot/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-OScDchr2fwuUmWdf4kZ9h7PcJiYDVInhJizG/biAq3cAvqwYktuy/TYGGdZNMtNTFUP7rnb0NU4TUdm82kt4Rg=="],
+
"axios/https-proxy-agent": ["[email protected]", "", { "dependencies": { "agent-base": "6", "debug": "4" } }, "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA=="],
"babel-plugin-jsx-dom-expressions/@babel/helper-module-imports": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.18.6" } }, "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA=="],
@@ -3742,6 +3759,8 @@
"ai-editing-worker/@types/node/undici-types": ["[email protected]", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
+ "anthropic-status-bot/@types/node/undici-types": ["[email protected]", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
+
"axios/https-proxy-agent/agent-base": ["[email protected]", "", { "dependencies": { "debug": "4" } }, "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ=="],
"buffer-image-size/@types/node/undici-types": ["[email protected]", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
diff --git a/package.json b/package.json
index 4dc01acaba..845dbc71ef 100644
--- a/package.json
+++ b/package.json
@@ -68,6 +68,7 @@
"packages/loro-mirror",
"packages/lexical-core",
"services/ai-editing-worker",
+ "services/bots/anthropic-status-bot",
"services/lexical-service"
],
"catalog": {
diff --git a/services/bots/anthropic-status-bot/README.md b/services/bots/anthropic-status-bot/README.md
new file mode 100644
index 0000000000..1a876ad4b0
--- /dev/null
+++ b/services/bots/anthropic-status-bot/README.md
@@ -0,0 +1,81 @@
+# anthropic-status-bot
+
+Posts Anthropic status page updates to a Macro channel.
+
+[status.claude.com](https://status.claude.com) (formerly status.anthropic.com)
+is powered by Atlassian Statuspage. This service receives Statuspage webhook
+notifications, formats them, and forwards them to a channel via the channel
+bot webhook (`crates/bots`), the same mechanism the old SNS deployment-failure
+lambda used.
+
+## How it works
+
+```
+Statuspage webhook ──POST──> /webhook/{WEBHOOK_SECRET}
+ │ parse + format (incident | component)
+ ▼
+ @macro/sdk → POST /channels/{CHANNEL_ID}/webhook
+ headers: x-macro-bot-token: BOT_TOKEN, x-macro-bot-scope: user
+ body: {"content": "🟡 [Anthropic Status] ..."}
+```
+
+Channel delivery uses the [Macro SDK](../../../packages/sdk)
+(`Macro._client.storage.postChannelBotWebhook`) with bot auth
+(`x-macro-bot-token`, user scope) — the endpoint's preferred auth. The bot
+must be a participant of `CHANNEL_ID`.
+
+Statuspage webhooks carry one of two payload shapes (verified against the
+[official docs](https://support.atlassian.com/statuspage/docs/enable-webhook-notifications/)):
+
+- **Incident update** — `incident` object with `name`, `status`, `impact`,
+ `shortlink`, and `incident_updates[]` (the newest update is posted).
+- **Component update** — `component_update` (`old_status` → `new_status`)
+ plus the affected `component` (e.g. `Claude API (api.anthropic.com)`).
+
+Notes on the Statuspage side:
+
+- Webhooks are HTTP POSTs and expect a **2xx response within 30s**.
+- There is **no request signing**, and Statuspage source IPs change, so the
+ webhook URL itself carries the shared secret: `POST /webhook/{WEBHOOK_SECRET}`.
+- Unrecognized payloads are acknowledged (`200 {ok, ignored: true}`) so the
+ subscription is never disabled by retries.
+- A failed channel post returns `502` so Statuspage retries the delivery.
+
+## Setup
+
+Deployed as a single prod Cloudflare Worker (`anthropic-status-bot`, no dev
+environment):
+
+```bash
+bun run deploy # wrangler deploy
+printf '%s' '<token>' | wrangler secret put BOT_TOKEN
+printf '%s' '<secret>' | wrangler secret put WEBHOOK_SECRET
+```
+
+The bot must be a participant of `CHANNEL_ID` or the channel webhook returns
+401. Local dev: copy `.env.example` to `.env` and `just dev`.
+
+Subscribe on status.claude.com with webhook URL:
+`https://anthropic-status-bot.macroverse.workers.dev/webhook/<WEBHOOK_SECRET>`
+
+## Environment variables
+
+| Variable | Required | Default | Description |
+| ---------------- | -------- | ---------------------------------- | -------------------------------------------- |
+| Variable | Required | Default | Description |
+| ---------------- | -------- | ------- | ---------------------------------------- |
+| `BOT_TOKEN` | yes | | Bot API key (`mbot_...`, sent as `x-macro-bot-token`) |
+| `CHANNEL_ID` | yes | | Channel UUID to post to |
+| `WEBHOOK_SECRET` | yes | | Secret path segment for the webhook URL |
+| `MACRO_ENV` | no | `prod` | SDK environment (`prod`/`dev`/`local`) |
+| `PORT` | no | `8088` | Listen port (local Bun server only) |
+
+## Development
+
+```bash
+just dev # bun run --watch src/server.ts
+just test # bun test
+just check # tsc --noEmit
+```
+
+Tests replay the exact example payloads from the Atlassian docs.
diff --git a/services/bots/anthropic-status-bot/biome.jsonc b/services/bots/anthropic-status-bot/biome.jsonc
new file mode 100644
index 0000000000..82a0f443c4
--- /dev/null
+++ b/services/bots/anthropic-status-bot/biome.jsonc
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.4.12/schema.json",
+ "root": true,
+ "extends": ["../../../biome.base.jsonc"],
+ "vcs": {
+ "root": "../../.."
+ },
+ "files": {
+ "includes": ["**/*.{ts,tsx,js,jsx}", "!**/*.d.ts", "!**/node_modules"]
+ }
+}
diff --git a/services/bots/anthropic-status-bot/justfile b/services/bots/anthropic-status-bot/justfile
new file mode 100644
index 0000000000..44103f8db1
--- /dev/null
+++ b/services/bots/anthropic-status-bot/justfile
@@ -0,0 +1,8 @@
+dev:
+ bun run --watch src/server.ts
+
+test:
+ bun test
+
+check:
+ bunx tsc --noEmit --project tsconfig.json
diff --git a/services/bots/anthropic-status-bot/package.json b/services/bots/anthropic-status-bot/package.json
new file mode 100644
index 0000000000..2fd89b1b3b
--- /dev/null
+++ b/services/bots/anthropic-status-bot/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "anthropic-status-bot",
+ "version": "0.0.1",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "bun run --watch src/server.ts",
+ "start": "bun run src/server.ts",
+ "test": "bun test",
+ "check": "tsc --noEmit --project tsconfig.json",
+ "deploy": "wrangler deploy"
+ },
+ "dependencies": {
+ "hono": "^4.6.20",
+ "zod": "^4.4.3"
+ },
+ "devDependencies": {
+ "@types/node": "^25.9.3",
+ "bun-types": "^1.3.14",
+ "wrangler": "^4.110.0"
+ }
+}
diff --git a/services/bots/anthropic-status-bot/src/channel.ts b/services/bots/anthropic-status-bot/src/channel.ts
new file mode 100644
index 0000000000..7dfa07d6dc
--- /dev/null
+++ b/services/bots/anthropic-status-bot/src/channel.ts
@@ -0,0 +1,39 @@
+import type { Env } from '../../../../packages/sdk/src/config';
+import { Macro } from '../../../../packages/sdk/src/macro';
+import { unwrap } from '../../../../packages/sdk/src/utils';
+
+export type ChannelConfig = {
+ /** UUID of the channel the bot posts to. */
+ channelId: string;
+ /** Bot API key (mbot_...), sent as x-macro-bot-token. */
+ botToken: string;
+ /** Macro environment. Defaults to prod. */
+ env?: Env;
+};
+
+/** Posts a message to the configured channel. Throws on failure. */
+export type ChannelPoster = (content: string) => Promise<void>;
+
+/**
+ * Post channel messages via the Macro SDK's channel bot webhook.
+ *
+ * Uses bot auth (x-macro-bot-token, user scope) — the preferred auth for
+ * POST /channels/{channel_id}/webhook. The bot must be a participant of the
+ * channel; the user scope requires no acting user for this endpoint.
+ */
+export function createChannelPoster(config: ChannelConfig): ChannelPoster {
+ const macro = new Macro({
+ env: config.env ?? 'prod',
+ auth: { type: 'bot', token: config.botToken, scope: 'user' },
+ });
+
+ return async (content) => {
+ const { message_id } = unwrap(
+ await macro._client.storage.postChannelBotWebhook({
+ path: { channel_id: config.channelId },
+ body: { content },
+ })
+ );
+ console.log('Posted channel message', { message_id });
+ };
+}
diff --git a/services/bots/anthropic-status-bot/src/format.ts b/services/bots/anthropic-status-bot/src/format.ts
new file mode 100644
index 0000000000..2da650f2b7
--- /dev/null
+++ b/services/bots/anthropic-status-bot/src/format.ts
@@ -0,0 +1,72 @@
+import type { ComponentWebhook, IncidentWebhook } from './statuspage';
+
+const INCIDENT_STATUS_EMOJI: Record<string, string> = {
+ investigating: '🔴',
+ identified: '🔴',
+ monitoring: '🟡',
+ resolved: '✅',
+ postmortem: '📝',
+ scheduled: '🗓️',
+ in_progress: '🛠️',
+ verifying: '🛠️',
+ completed: '✅',
+ canceled: '❌',
+};
+
+function humanize(status: string): string {
+ return status.replace(/_/g, ' ');
+}
+
+/** Statuspage returns incident_updates newest-first, but sort defensively. */
+function latestUpdate(incident: IncidentWebhook['incident']) {
+ return incident.incident_updates.reduce<
+ IncidentWebhook['incident']['incident_updates'][number] | undefined
+ >((latest, update) => {
+ if (!latest) return update;
+ return Date.parse(update.created_at) > Date.parse(latest.created_at)
+ ? update
+ : latest;
+ }, undefined);
+}
+
+export function formatIncidentMessage(payload: IncidentWebhook): string {
+ const { incident, page } = payload;
+ const emoji = INCIDENT_STATUS_EMOJI[incident.status] ?? '⚠️';
+ const lines = [`${emoji} [Anthropic Status] ${incident.name}`];
+
+ let statusLine = `Status: ${humanize(incident.status)}`;
+ if (incident.impact) {
+ statusLine += ` · Impact: ${humanize(incident.impact)}`;
+ }
+ lines.push(statusLine);
+
+ const latest = latestUpdate(incident);
+ if (latest?.body) {
+ lines.push(`Latest update: ${latest.body}`);
+ }
+
+ if (page.status_description) {
+ lines.push(`Page status: ${page.status_description}`);
+ }
+
+ if (incident.shortlink) {
+ lines.push(incident.shortlink);
+ }
+
+ return lines.join('\n');
+}
+
+export function formatComponentMessage(payload: ComponentWebhook): string {
+ const { component_update, component, page } = payload;
+ const emoji =
+ component_update.new_status === 'operational'
+ ? '✅'
+ : component_update.new_status === 'major_outage'
+ ? '🔴'
+ : '⚠️';
+
+ return [
+ `${emoji} [Anthropic Status] Component "${component.name}": ${humanize(component_update.old_status)} → ${humanize(component_update.new_status)}`,
+ `Page status: ${page.status_description}`,
+ ].join('\n');
+}
diff --git a/services/bots/anthropic-status-bot/src/index.ts b/services/bots/anthropic-status-bot/src/index.ts
new file mode 100644
index 0000000000..d8afed0761
--- /dev/null
+++ b/services/bots/anthropic-status-bot/src/index.ts
@@ -0,0 +1,63 @@
+import { Hono } from 'hono';
+import type { ChannelPoster } from './channel';
+import { formatComponentMessage, formatIncidentMessage } from './format';
+import { parseWebhookPayload } from './statuspage';
+
+export type AppConfig = {
+ /** Shared secret embedded in the webhook URL path. */
+ webhookSecret: string;
+ /** Delivers a formatted message to the Macro channel. */
+ postToChannel: ChannelPoster;
+};
+
+/**
+ * Anthropic (Claude) status page → Macro channel bot.
+ *
+ * status.claude.com is powered by Atlassian Statuspage, which supports
+ * webhook subscriptions but provides no request signing, so the webhook URL
+ * carries a shared secret: POST /webhook/{WEBHOOK_SECRET}.
+ *
+ * Statuspage requires a 2xx response within 30s; unrecognized payloads are
+ * acknowledged and ignored rather than retried.
+ */
+export function createApp(config: AppConfig) {
+ const app = new Hono();
+
+ app.get('/health', (c) => c.json({ ok: true }));
+
+ app.post('/webhook/:secret', async (c) => {
+ if (c.req.param('secret') !== config.webhookSecret) {
+ return c.json({ error: 'unauthorized' }, 401);
+ }
+
+ let body: unknown;
+ try {
+ body = await c.req.json();
+ } catch {
+ return c.json({ error: 'invalid JSON body' }, 400);
+ }
+
+ const parsed = parseWebhookPayload(body);
+ if (!parsed.ok) {
+ console.warn('Ignoring unrecognized statuspage webhook payload');
+ return c.json({ ok: true, ignored: true });
+ }
+
+ const content =
+ parsed.kind === 'incident'
+ ? formatIncidentMessage(parsed.payload)
+ : formatComponentMessage(parsed.payload);
+
+ try {
+ await config.postToChannel(content);
+ } catch (err) {
+ console.error('Failed to post status update to channel', err);
+ return c.json({ error: 'failed to deliver message' }, 502);
+ }
+
+ console.log('Posted status update to channel', { kind: parsed.kind });
+ return c.json({ ok: true });
+ });
+
+ return app;
+}
diff --git a/services/bots/anthropic-status-bot/src/server.ts b/services/bots/anthropic-status-bot/src/server.ts
new file mode 100644
index 0000000000..ac35820724
--- /dev/null
+++ b/services/bots/anthropic-status-bot/src/server.ts
@@ -0,0 +1,30 @@
+import { createChannelPoster } from './channel';
+import { createApp } from './index';
+
+const PORT = parseInt(process.env.PORT || '8088', 10);
+
+const requiredVars = ['BOT_TOKEN', 'CHANNEL_ID', 'WEBHOOK_SECRET'] as const;
+for (const varName of requiredVars) {
+ if (!process.env[varName]) {
+ console.error(`Missing required environment variable: ${varName}`);
+ process.exit(1);
+ }
+}
+
+const app = createApp({
+ webhookSecret: process.env.WEBHOOK_SECRET!,
+ postToChannel: createChannelPoster({
+ channelId: process.env.CHANNEL_ID!,
+ botToken: process.env.BOT_TOKEN!,
+ env: (process.env.MACRO_ENV as 'prod' | 'dev' | 'local') || 'prod',
+ }),
+});
+
+const server = Bun.serve({
+ port: PORT,
+ fetch: app.fetch,
+});
+
+console.log(
+ `anthropic-status-bot listening on http://localhost:${server.port}`
+);
diff --git a/services/bots/anthropic-status-bot/src/statuspage.ts b/services/bots/anthropic-status-bot/src/statuspage.ts
new file mode 100644
index 0000000000..3f733e0e94
--- /dev/null
+++ b/services/bots/anthropic-status-bot/src/statuspage.ts
@@ -0,0 +1,102 @@
+import { z } from 'zod';
+
+/**
+ * Atlassian Statuspage webhook payloads.
+ *
+ * Shape verified against the official docs:
+ * https://support.atlassian.com/statuspage/docs/enable-webhook-notifications/
+ *
+ * status.claude.com (formerly status.anthropic.com) is powered by Atlassian
+ * Statuspage. Two payload kinds exist: incident updates and component updates.
+ * Schemas are "loose" because Statuspage may add fields over time.
+ */
+
+const pageSchema = z.looseObject({
+ id: z.string(),
+ status_indicator: z.string(),
+ status_description: z.string(),
+});
+
+const metaSchema = z.looseObject({
+ unsubscribe: z.string().optional(),
+ documentation: z.string().optional(),
+});
+
+const incidentUpdateSchema = z.looseObject({
+ id: z.string(),
+ body: z.string(),
+ status: z.string(),
+ created_at: z.string(),
+ display_at: z.string().optional(),
+ incident_id: z.string().optional(),
+});
+
+const incidentWebhookSchema = z.looseObject({
+ meta: metaSchema.optional(),
+ page: pageSchema,
+ incident: z.looseObject({
+ id: z.string(),
+ name: z.string(),
+ status: z.string(),
+ impact: z.string().nullable(),
+ shortlink: z.string().nullable(),
+ created_at: z.string(),
+ updated_at: z.string(),
+ resolved_at: z.string().nullable().optional(),
+ incident_updates: z.array(incidentUpdateSchema),
+ }),
+});
+
+const componentWebhookSchema = z.looseObject({
+ meta: metaSchema.optional(),
+ page: pageSchema,
+ component_update: z.looseObject({
+ id: z.string(),
+ component_id: z.string(),
+ old_status: z.string(),
+ new_status: z.string(),
+ created_at: z.string(),
+ }),
+ component: z.looseObject({
+ id: z.string(),
+ name: z.string(),
+ status: z.string(),
+ created_at: z.string().optional(),
+ }),
+});
+
+export type IncidentWebhook = z.infer<typeof incidentWebhookSchema>;
+export type ComponentWebhook = z.infer<typeof componentWebhookSchema>;
+
+export type ParsedWebhook =
+ | { ok: true; kind: 'incident'; payload: IncidentWebhook }
+ | { ok: true; kind: 'component'; payload: ComponentWebhook }
+ | { ok: false };
+
+/**
+ * Parse a raw webhook body into a known Statuspage payload kind.
+ * Returns { ok: false } for anything unrecognized so the caller can
+ * acknowledge (2xx) and ignore it.
+ */
+export function parseWebhookPayload(body: unknown): ParsedWebhook {
+ if (typeof body !== 'object' || body === null) {
+ return { ok: false };
+ }
+ const record = body as Record<string, unknown>;
+
+ if (record.incident && typeof record.incident === 'object') {
+ const result = incidentWebhookSchema.safeParse(body);
+ return result.success
+ ? { ok: true, kind: 'incident', payload: result.data }
+ : { ok: false };
+ }
+
+ if (record.component_update && typeof record.component_update === 'object') {
+ const result = componentWebhookSchema.safeParse(body);
+ return result.success
+ ? { ok: true, kind: 'component', payload: result.data }
+ : { ok: false };
+ }
+
+ return { ok: false };
+}
diff --git a/services/bots/anthropic-status-bot/src/worker.ts b/services/bots/anthropic-status-bot/src/worker.ts
new file mode 100644
index 0000000000..903af8de70
--- /dev/null
+++ b/services/bots/anthropic-status-bot/src/worker.ts
@@ -0,0 +1,42 @@
+import { createChannelPoster } from './channel';
+import { createApp } from './index';
+
+/**
+ * Cloudflare Worker entrypoint. Config comes from worker bindings
+ * (vars + secrets); see wrangler.jsonc. For local development outside
+ * wrangler, src/server.ts provides the same app under Bun.
+ */
+type Env = {
+ BOT_TOKEN: string;
+ CHANNEL_ID: string;
+ WEBHOOK_SECRET: string;
+};
+
+const REQUIRED: readonly (keyof Env)[] = [
+ 'BOT_TOKEN',
+ 'CHANNEL_ID',
+ 'WEBHOOK_SECRET',
+];
+
+export default {
+ fetch(request: Request, env: Env): Response | Promise<Response> {
+ const missing = REQUIRED.filter((key) => !env[key]);
+ if (missing.length > 0) {
+ return Response.json(
+ { error: `missing worker bindings: ${missing.join(', ')}` },
+ { status: 500 }
+ );
+ }
+
+ const app = createApp({
+ webhookSecret: env.WEBHOOK_SECRET!,
+ postToChannel: createChannelPoster({
+ channelId: env.CHANNEL_ID!,
+ botToken: env.BOT_TOKEN!,
+ env: 'prod',
+ }),
+ });
+
+ return app.fetch(request, env);
+ },
+};
diff --git a/services/bots/anthropic-status-bot/test/webhook.test.ts b/services/bots/anthropic-status-bot/test/webhook.test.ts
new file mode 100644
index 0000000000..1e9dfdca98
--- /dev/null
+++ b/services/bots/anthropic-status-bot/test/webhook.test.ts
@@ -0,0 +1,204 @@
+import { describe, expect, mock, test } from 'bun:test';
+import { createApp } from '../src/index';
+
+// Exact example payloads from the Atlassian Statuspage webhook docs:
+// https://support.atlassian.com/statuspage/docs/enable-webhook-notifications/
+const INCIDENT_PAYLOAD = {
+ meta: {
+ unsubscribe:
+ 'http://statustest.flyingkleinbrothers.com:5000/?unsubscribe=j0vqr9kl3513',
+ documentation:
+ 'http://doers.statuspage.io/customer-notifications/webhooks/',
+ },
+ page: {
+ id: 'j2mfxwj97wnj',
+ status_indicator: 'critical',
+ status_description: 'Major System Outage',
+ },
+ incident: {
+ backfilled: false,
+ created_at: '2013-05-29T15:08:51-06:00',
+ impact: 'critical',
+ impact_override: null,
+ monitoring_at: '2013-05-29T16:07:53-06:00',
+ postmortem_body: null,
+ postmortem_body_last_updated_at: null,
+ postmortem_ignored: false,
+ postmortem_notified_subscribers: false,
+ postmortem_notified_twitter: false,
+ postmortem_published_at: null,
+ resolved_at: null,
+ scheduled_auto_transition: false,
+ scheduled_for: null,
+ scheduled_remind_prior: false,
+ scheduled_reminded_at: null,
+ scheduled_until: null,
+ shortlink: 'http://j.mp/18zyDQx',
+ status: 'monitoring',
+ updated_at: '2013-05-29T16:30:35-06:00',
+ id: 'lbkhbwn21v5q',
+ organization_id: 'j2mfxwj97wnj',
+ incident_updates: [
+ {
+ body: 'A fix has been implemented and we are monitoring the results.',
+ created_at: '2013-05-29T16:07:53-06:00',
+ display_at: '2013-05-29T16:07:53-06:00',
+ status: 'monitoring',
+ twitter_updated_at: null,
+ updated_at: '2013-05-29T16:09:09-06:00',
+ wants_twitter_update: false,
+ id: 'drfcwbnpxnr6',
+ incident_id: 'lbkhbwn21v5q',
+ },
+ {
+ body: 'We are waiting for the cloud to come back online and will update when we have further information',
+ created_at: '2013-05-29T15:18:51-06:00',
+ display_at: '2013-05-29T15:18:51-06:00',
+ status: 'identified',
+ twitter_updated_at: null,
+ updated_at: '2013-05-29T15:28:51-06:00',
+ wants_twitter_update: false,
+ id: '2rryghr4qgrh',
+ incident_id: 'lbkhbwn21v5q',
+ },
+ {
+ body: 'The cloud, located in Norther Virginia, has once again gone the way of the dodo.',
+ created_at: '2013-05-29T15:08:51-06:00',
+ display_at: '2013-05-29T15:08:51-06:00',
+ status: 'investigating',
+ twitter_updated_at: null,
+ updated_at: '2013-05-29T15:28:51-06:00',
+ wants_twitter_update: false,
+ id: 'qbbsfhy5s9kk',
+ incident_id: 'lbkhbwn21v5q',
+ },
+ ],
+ name: 'Virginia Is Down',
+ },
+};
+
+const COMPONENT_PAYLOAD = {
+ meta: {
+ unsubscribe:
+ 'http://statustest.flyingkleinbrothers.com:5000/?unsubscribe=j0vqr9kl3513',
+ documentation:
+ 'http://doers.statuspage.io/customer-notifications/webhooks/',
+ },
+ page: {
+ id: 'j2mfxwj97wnj',
+ status_indicator: 'major',
+ status_description: 'Partial System Outage',
+ },
+ component_update: {
+ created_at: '2013-05-29T21:32:28Z',
+ new_status: 'operational',
+ old_status: 'major_outage',
+ id: 'k7730b5v92bv',
+ component_id: 'rb5wq1dczvbm',
+ },
+ component: {
+ created_at: '2013-05-29T21:32:28Z',
+ id: 'rb5wq1dczvbm',
+ name: 'Some Component',
+ status: 'operational',
+ },
+};
+
+function makeApp(postToChannel: (content: string) => Promise<void>) {
+ return createApp({ webhookSecret: 'test-secret', postToChannel });
+}
+
+function postWebhook(
+ app: ReturnType<typeof makeApp>,
+ body: unknown,
+ secret = 'test-secret'
+) {
+ return app.request(`/webhook/${secret}`, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: typeof body === 'string' ? body : JSON.stringify(body),
+ });
+}
+
+describe('anthropic-status-bot webhook', () => {
+ test('health check', async () => {
+ const app = makeApp(mock(async () => {}));
+ const res = await app.request('/health');
+ expect(res.status).toBe(200);
+ expect(await res.json()).toEqual({ ok: true });
+ });
+
+ test('rejects wrong secret without posting', async () => {
+ const poster = mock(async () => {});
+ const app = makeApp(poster);
+ const res = await postWebhook(app, INCIDENT_PAYLOAD, 'wrong-secret');
+ expect(res.status).toBe(401);
+ expect(poster).not.toHaveBeenCalled();
+ });
+
+ test('rejects invalid JSON', async () => {
+ const poster = mock(async () => {});
+ const app = makeApp(poster);
+ const res = await postWebhook(app, 'not json{');
+ expect(res.status).toBe(400);
+ expect(poster).not.toHaveBeenCalled();
+ });
+
+ test('acknowledges and ignores unrecognized payloads', async () => {
+ const poster = mock(async () => {});
+ const app = makeApp(poster);
+ const res = await postWebhook(app, {
+ page: {
+ id: 'x',
+ status_indicator: 'none',
+ status_description: 'All Systems Operational',
+ },
+ });
+ expect(res.status).toBe(200);
+ expect(await res.json()).toEqual({ ok: true, ignored: true });
+ expect(poster).not.toHaveBeenCalled();
+ });
+
+ test('formats incident updates and posts them to the channel', async () => {
+ const poster = mock(async () => {});
+ const app = makeApp(poster);
+
+ const res = await postWebhook(app, INCIDENT_PAYLOAD);
+ expect(res.status).toBe(200);
+
+ expect(poster).toHaveBeenCalledTimes(1);
+ const [content] = poster.mock.calls[0] as unknown as [string];
+ expect(content).toContain('[Anthropic Status] Virginia Is Down');
+ expect(content).toContain('Status: monitoring');
+ expect(content).toContain('Impact: critical');
+ // newest incident update wins
+ expect(content).toContain(
+ 'Latest update: A fix has been implemented and we are monitoring the results.'
+ );
+ expect(content).toContain('Page status: Major System Outage');
+ expect(content).toContain('http://j.mp/18zyDQx');
+ });
+
+ test('formats component updates and posts them to the channel', async () => {
+ const poster = mock(async () => {});
+ const app = makeApp(poster);
+
+ const res = await postWebhook(app, COMPONENT_PAYLOAD);
+ expect(res.status).toBe(200);
+
+ const [content] = poster.mock.calls[0] as unknown as [string];
+ expect(content).toContain(
+ 'Component "Some Component": major outage → operational'
+ );
+ expect(content).toContain('Page status: Partial System Outage');
+ });
+
+ test('returns 502 when the channel post fails', async () => {
+ const poster = mock(async () => {
+ throw new Error('channel webhook post failed (500)');
+ });
+ const app = makeApp(poster);
+ const res = await postWebhook(app, INCIDENT_PAYLOAD);
+ expect(res.status).toBe(502);
+ });
+});
diff --git a/services/bots/anthropic-status-bot/tsconfig.json b/services/bots/anthropic-status-bot/tsconfig.json
new file mode 100644
index 0000000000..d73c3dfc9a
--- /dev/null
+++ b/services/bots/anthropic-status-bot/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "compilerOptions": {
+ "esModuleInterop": true,
+ "skipLibCheck": true,
+ "forceConsistentCasingInFileNames": true,
+ "target": "es2022",
+ "module": "es2022",
+ "moduleResolution": "Bundler",
+ "resolveJsonModule": true,
+ "moduleDetection": "force",
+ "strict": true,
+ "noEmit": true,
+ "lib": ["es2022", "dom"],
+ "types": ["@types/node", "bun-types"]
+ },
+ "exclude": ["node_modules"],
+ "include": ["src", "test"]
+}
diff --git a/services/bots/anthropic-status-bot/wrangler.jsonc b/services/bots/anthropic-status-bot/wrangler.jsonc
new file mode 100644
index 0000000000..af33a84d5c
--- /dev/null
+++ b/services/bots/anthropic-status-bot/wrangler.jsonc
@@ -0,0 +1,22 @@
+/**
+ * For more details on how to configure Wrangler, refer to:
+ * https://developers.cloudflare.com/workers/wrangler/configuration/
+ *
+ * Single prod deployment only — there is no dev environment.
+ *
+ * Secrets (set with `wrangler secret put <NAME>`):
+ * BOT_TOKEN - channel-scoped bot token (x-macro-channel-bot-token)
+ * WEBHOOK_SECRET - shared secret embedded in the webhook URL path
+ */
+{
+ "$schema": "node_modules/wrangler/config-schema.json",
+ "name": "anthropic-status-bot",
+ "main": "src/worker.ts",
+ "compatibility_date": "2026-01-01",
+ "observability": {
+ "enabled": true
+ },
+ "vars": {
+ "CHANNEL_ID": "019f9058-ca27-7db5-9f1c-af1d97f09529"
+ }
+}