import type { ExecutionView, RunSummary, TaskDetail } from "@/lib/types"; const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? "http://127.0.0.1:8788"; async function getJson(path: string, signal?: AbortSignal): Promise { const response = await fetch(`${API_BASE}${path}`, { signal, cache: "no-store" }); if (!response.ok) throw new Error(`可视化后端返回 ${response.status}`); return response.json() as Promise; } export function fetchRuns(signal?: AbortSignal) { return getJson("/api/runs", signal); } export function fetchExecution(scriptBuildId: number, signal?: AbortSignal) { return getJson(`/api/runs/${scriptBuildId}/execution`, signal); } export function fetchTaskDetail(scriptBuildId: number, taskId: string, signal?: AbortSignal) { return getJson(`/api/runs/${scriptBuildId}/tasks/${taskId}`, signal); }