Files
deerflow-code/frontend-web/src/core/admin/skill-view-diagnostics.ts
T

73 lines
1.7 KiB
TypeScript

import { apiFetch } from "@/core/api";
import { getBackendBaseURL } from "@/core/config";
/** One completed sandbox call. Written only after that call returns. */
export interface SkillViewEvent {
at: string;
status: string;
total_ms: number;
lock_wait_ms: number;
refresh_ms: number;
source_entries: number;
target_entries: number;
enabled_count: number;
path_count: number;
tool: string;
command: string;
skill_names: string[];
tool_ms: number;
explanation: {
level: string;
headline: string;
look_at: string;
cause: string;
};
}
export interface SkillViewCheck {
id: string;
title: string;
result: string;
level: string;
look_at: string;
cause: string;
command: string;
skill_names: string[];
}
export interface SkillViewDiagnostics {
cache_enabled: boolean;
reuse_enabled: boolean;
level: string;
conclusion: string;
checks: SkillViewCheck[];
events: SkillViewEvent[];
total: number;
page: number;
page_size: number;
sort: "time" | "duration" | "check";
order: "asc" | "desc";
}
export interface SkillViewQuery {
page: number;
pageSize: number;
sort: "time" | "duration" | "check";
order: "asc" | "desc";
}
/** Polled by the admin timing page. Not an operation log. */
export async function loadSkillViewDiagnostics(query: SkillViewQuery): Promise<SkillViewDiagnostics> {
const params = new URLSearchParams({
page: String(query.page),
page_size: String(query.pageSize),
sort: query.sort,
order: query.order,
});
const response = await apiFetch(`${getBackendBaseURL()}/api/admin/skill-view-diagnostics?${params}`);
if (!response.ok) {
throw new Error("技能耗时记录读取失败");
}
return (await response.json()) as SkillViewDiagnostics;
}