update for mcp
This commit is contained in:
@@ -52,6 +52,39 @@ export interface AnalysisSSEMessage {
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export interface PerceptionNotification {
|
||||
id: number;
|
||||
event_id: string;
|
||||
kind: 'new' | 'changed';
|
||||
title: string;
|
||||
impact_level: string | null;
|
||||
summary: string | null;
|
||||
created_at: string;
|
||||
read: boolean;
|
||||
}
|
||||
|
||||
export interface NotificationListResponse {
|
||||
items: PerceptionNotification[];
|
||||
unread_count: number;
|
||||
}
|
||||
|
||||
/** Broadcast feed shared by every logged-in user; read state is per-caller. */
|
||||
export async function getNotifications(limit = 20): Promise<NotificationListResponse> {
|
||||
const res = await fetch(`${PERCEPTION_API_BASE}/perception/notifications?limit=${limit}`, { headers: authHeader() });
|
||||
if (!res.ok) throw new Error(`notifications failed: ${res.status}`);
|
||||
return res.json() as Promise<NotificationListResponse>;
|
||||
}
|
||||
|
||||
/** Marks every currently-unread notification read for the calling user. */
|
||||
export async function markNotificationsRead(): Promise<{ marked: number }> {
|
||||
const res = await fetch(`${PERCEPTION_API_BASE}/perception/notifications/read`, {
|
||||
method: 'POST',
|
||||
headers: authHeader(),
|
||||
});
|
||||
if (!res.ok) throw new Error(`mark read failed: ${res.status}`);
|
||||
return res.json() as Promise<{ marked: number }>;
|
||||
}
|
||||
|
||||
export async function getPerceptionStats(): Promise<PerceptionStats> {
|
||||
const res = await fetch(`${PERCEPTION_API_BASE}/perception/stats`, { headers: authHeader() });
|
||||
if (!res.ok) throw new Error(`stats failed: ${res.status}`);
|
||||
|
||||
Reference in New Issue
Block a user