"""Generate base64 of the WatchdogAlertsSection component.""" import base64, sys BT = chr(96) BULLET = "\xb7" lines = [ "\n", "// WatchdogAlertsSection\n", "\n", 'type WdogStatus = "active" | "acknowledged" | "resolved";\n', "\n", "function wdogStatus(alert: WatchdogAlert): WdogStatus {\n", ' if (alert.resolved_at) return "resolved";\n', ' if (alert.acknowledged_at) return "acknowledged";\n', ' return "active";\n', "}\n", "\n", "function WatchdogAlertsSection() {\n", " const queryClient = useQueryClient();\n", " const { toast } = useToast();\n", " const [showAll, setShowAll] = useState(false);\n", " const [expandedLogId, setExpandedLogId] = useState(null);\n", "\n", " const { data: allAlerts = [], isLoading } = useQuery({\n", ' queryKey: ["watchdog-alerts"],\n', " queryFn: () => watchdogAlertsApi.list().then((r) => r.data),\n", " refetchInterval: 30000,\n", " });\n", "\n", " const alerts = showAll ? allAlerts : allAlerts.filter((a) => !a.resolved_at);\n", "\n", " const acknowledgeMutation = useMutation({\n", " mutationFn: (id: string) => watchdogAlertsApi.acknowledge(id),\n", " onSuccess: () => {\n", ' queryClient.invalidateQueries({ queryKey: ["watchdog-alerts"] });\n', ' toast({ type: "success", title: "Alert acknowledged" });\n', " },\n", " onError: (err: Error) =>\n", ' toast({ type: "error", title: "Could not acknowledge", message: err.message }),\n', " });\n", "\n", " const resolveMutation = useMutation({\n", " mutationFn: (id: string) => watchdogAlertsApi.resolve(id),\n", " onSuccess: () => {\n", ' queryClient.invalidateQueries({ queryKey: ["watchdog-alerts"] });\n', ' toast({ type: "success", title: "Alert resolved" });\n', " },\n", " onError: (err: Error) =>\n", ' toast({ type: "error", title: "Could not resolve", message: err.message }),\n', " });\n", "\n", " const deleteMutation = useMutation({\n", " mutationFn: (id: string) => watchdogAlertsApi.delete(id),\n", " onSuccess: () => {\n", ' queryClient.invalidateQueries({ queryKey: ["watchdog-alerts"] });\n', ' toast({ type: "success", title: "Alert deleted" });\n', " },\n", " onError: (err: Error) =>\n", ' toast({ type: "error", title: "Could not delete", message: err.message }),\n', " });\n", "\n", " const isMutating =\n", " acknowledgeMutation.isPending ||\n", " resolveMutation.isPending ||\n", " deleteMutation.isPending;\n", "\n", ' const activeCount = allAlerts.filter((a) => wdogStatus(a) === "active").length;\n', "\n", " return (\n", " \n", " \n", '
\n', ' \n', ' \n', " Watchdog Alerts\n", " {activeCount > 0 && (\n", ' \n', " {activeCount} active\n", " \n", " )}\n", " \n", " setShowAll((v) => !v)}\n", " >\n", ' {showAll ? "Active only" : "Show all"}\n', " \n", "
\n", "
\n", " \n", " {isLoading && (\n", '

Loading...

\n', " )}\n", " {!isLoading && alerts.length === 0 && (\n", '

\n', ' {showAll ? "No watchdog alerts recorded." : "No active watchdog alerts."}\n', "

\n", " )}\n", '
\n', " {alerts.map((alert) => {\n", " const status = wdogStatus(alert);\n", " const logExpanded = expandedLogId === alert.id;\n", " const statusColor =\n", ' status === "active"\n', ' ? "text-red-600 dark:text-red-400"\n', ' : status === "acknowledged"\n', ' ? "text-amber-600 dark:text-amber-400"\n', ' : "text-[hsl(var(--muted-foreground))]";\n', "\n", " return (\n", " \n", '
\n', '
\n', '
\n', " \n", " {status}\n", " \n", ' \n', " " + BULLET + " {alert.restart_attempts} restart attempt\n", ' {alert.restart_attempts !== 1 ? "s" : ""}\n', " \n", "
\n", '

\n', ' Agent ID:{" "}\n', ' \n', " {alert.agent_id.slice(0, 8)}…\n", " \n", ' {" "}' + BULLET + '{" "}\n', " Triggered: {formatRelative(alert.triggered_at)}\n", " {alert.acknowledged_at && (\n", ' <>{" "}' + BULLET + '{" "}Ack: {formatRelative(alert.acknowledged_at)}\n', " )}\n", " {alert.resolved_at && (\n", ' <>{" "}' + BULLET + '{" "}Resolved: {formatRelative(alert.resolved_at)}\n', " )}\n", "

\n", " {alert.last_error && (\n", '

\n', ' Error: {alert.last_error}\n', "

\n", " )}\n", "
\n", "\n", '
\n', ' {status === "active" && (\n', ' \n", " )}\n", ' {status !== "resolved" && (\n', ' \n", " )}\n", ' \n", "
\n", "
\n", "\n", " {alert.log_tail && (\n", "
\n", " setExpandedLogId(logExpanded ? null : alert.id)}\n", " >\n", ' {logExpanded ? : }\n', " Agent log tail\n", " \n", " {logExpanded && (\n", '
\n',
    "                        {alert.log_tail}\n",
    "                      
\n", " )}\n", "
\n", " )}\n", "
\n", " );\n", " })}\n", " \n", "
\n", "
\n", " );\n", "}\n", "\n", ] component = "".join(lines) b64 = base64.b64encode(component.encode("utf-8")).decode("ascii") with open("D:/claudetools/.claude/scripts/component.b64", "w") as f: f.write(b64) print(f"Component: {len(component)} chars") print(f"Base64: {len(b64)} chars") print("Written to component.b64")