feat(frontend): contract types + REST client (MSW-tested)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { apiFetch } from "./client";
|
||||
import type { SessionSummary, UiResponse } from "./types";
|
||||
|
||||
export const createSession = (i: {
|
||||
workspace: string;
|
||||
question: string;
|
||||
provider?: string;
|
||||
model?: string;
|
||||
thinking?: string;
|
||||
name?: string;
|
||||
}) => apiFetch<{ id: string }>("/sessions", { method: "POST", body: JSON.stringify(i) });
|
||||
|
||||
export const listSessions = () => apiFetch<SessionSummary[]>("/sessions");
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const getSession = (id: string) => apiFetch<any>(`/sessions/${id}`);
|
||||
|
||||
export const postResponse = (id: string, uiResponse: UiResponse) =>
|
||||
apiFetch<void>(`/sessions/${id}/response`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ ui_response: uiResponse }),
|
||||
});
|
||||
|
||||
export const postSteer = (id: string, text: string) =>
|
||||
apiFetch<void>(`/sessions/${id}/steer`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ text }),
|
||||
});
|
||||
|
||||
export const closeSession = (id: string) =>
|
||||
apiFetch<void>(`/sessions/${id}/close`, { method: "POST" });
|
||||
|
||||
export const resumeSession = (id: string) =>
|
||||
apiFetch<void>(`/sessions/${id}/resume`, { method: "POST" });
|
||||
Reference in New Issue
Block a user