Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
2.4 kB ยท 85 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import { z } from "zod";
import { listNotifications } from "../notification";import type { AgentTool } from "./types";
const PER_PAGE_DEFAULT = 50;const PER_PAGE_MAX = 200;
const ListNotificationsInputShape = z.object({ page: z .number() .int() .min(1) .default(1) .describe("1-indexed page number (default 1)."), perPage: z .number() .int() .min(1) .max(PER_PAGE_MAX) .default(PER_PAGE_DEFAULT) .describe( `Items per page (default ${PER_PAGE_DEFAULT}, max ${PER_PAGE_MAX}).`, ),});
// `data` (channel-config) is omitted โ it holds tokens, webhook URLs, phone numbers.const ListNotificationsOutput = z.object({ items: z.array( z.object({ id: z.number().int(), name: z.string(), provider: z.string(), monitorIds: z.array(z.number().int()), createdAt: z.string().nullable(), updatedAt: z.string().nullable(), }), ), pagination: z.object({ page: z.number().int(), perPage: z.number().int(), totalSize: z.number().int(), totalPages: z.number().int(), }),});
export const listNotificationsTool: AgentTool< z.infer<typeof ListNotificationsInputShape>, z.infer<typeof ListNotificationsOutput>> = { name: "list_notifications", description: "List notification channels (email/Slack/Discord/PagerDuty/Webhook/etc.) configured in this workspace, with the monitors each one is wired to. Read-only โ channel credentials/data are NOT exposed. Use to advise whether alerts will fire for a given monitor.", scope: "read", destructive: false, inputSchema: ListNotificationsInputShape, outputSchema: ListNotificationsOutput, async run({ ctx, input }) { const { page, perPage } = input; const result = await listNotifications({ ctx, input: { limit: perPage, offset: (page - 1) * perPage, order: "desc", }, }); return { items: result.items.map((n) => ({ id: n.id, name: n.name, provider: n.provider, monitorIds: n.monitors.map((m) => m.id), createdAt: n.createdAt?.toISOString() ?? null, updatedAt: n.updatedAt?.toISOString() ?? null, })), pagination: { page, perPage, totalSize: result.totalSize, totalPages: Math.max(1, Math.ceil(result.totalSize / perPage)), }, }; },};