feat(confidence-engine): use server investigation persistence

This commit is contained in:
2026-09-08 19:21:05 +01:00
parent 6dd447e56a
commit d6df1d210e
15 changed files with 425 additions and 114 deletions
+41
View File
@@ -0,0 +1,41 @@
async function request(path, options) {
const response = await fetch(path, options);
const body = await response.json().catch(() => ({}));
if (!response.ok) {
throw new Error(body.error || "Investigation persistence request failed");
}
return body;
}
export async function saveInvestigation(snapshot, id) {
const body = await request("/api/investigations", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id, snapshot }),
});
return body.snapshot ?? null;
}
export async function loadInvestigation(id) {
const url = `/api/investigations/${encodeURIComponent(id)}`;
const response = await fetch(url);
if (!response.ok) {
if (response.status === 404) return null;
const body = await response.json().catch(() => ({}));
throw new Error(body.error || "Investigation persistence request failed");
}
const body = await response.json();
return body.snapshot ?? null;
}
export async function listInvestigations() {
const body = await request("/api/investigations");
return body.investigations ?? [];
}
export async function restartInvestigation(id) {
const body = await request(`/api/investigations/${encodeURIComponent(id)}/restart`, {
method: "POST",
});
return body.snapshot ?? null;
}