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.
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { z } from "zod";
import type { CreatedRecord } from "./confirmation-store";
const statusReportOutput = z.object({ statusReport: z.object({ id: z.number().int(), title: z.string() }),});const namedOutput = z.object({ id: z.number().int(), title: z.string() });
const KINDS: Record<string, CreatedRecord["kind"]> = { create_status_report: "status_report", add_status_report_update: "status_report", declare_incident: "incident", create_maintenance: "maintenance",};
export function createdRecordFrom( toolName: string, output: object,): CreatedRecord | undefined { const kind = KINDS[toolName]; if (!kind) return undefined; if (kind === "status_report") { const parsed = statusReportOutput.safeParse(output); return parsed.success ? { kind, id: parsed.data.statusReport.id, label: parsed.data.statusReport.title, } : undefined; } const parsed = namedOutput.safeParse(output); return parsed.success ? { kind, id: parsed.data.id, label: parsed.data.title } : undefined;}
const NOUNS: Record<CreatedRecord["kind"], string> = { status_report: "status report", incident: "managed incident", maintenance: "maintenance",};
export function createdNote(records: CreatedRecord[]): string | undefined { if (!records.length) return undefined; const items = records.map( // Titles are user-written: keep them out of the system prompt. (r) => `${NOUNS[r.kind]} #${r.id}`, ); return `Earlier in this thread, approved cards created or updated: ${items.join(", ")}. These exist now: use their ids only in subsequent tool calls, never show the ids in replies, and don't tell the user they don't exist.`;}