// fetch wrappers for the /api endpoints (SCHEMAS.md HTTP contracts) async function post(path, body) { const resp = await fetch(path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body || {}), }); if (!resp.ok) { const detail = await resp.json().catch(() => ({})); const err = new Error(detail.detail || `http ${resp.status}`); err.status = resp.status; throw err; } return resp.json(); } export const warm = () => post("/api/warm"); export const newGame = () => post("/api/new_game"); export const nextEvent = (sid) => post("/api/next_event", { session_id: sid }); export const respond = (sid, response_type, text) => post("/api/respond", { session_id: sid, response_type, text: text || "" }); export const presentationRound = (sid, response_type, text) => post("/api/presentation_round", { session_id: sid, response_type: response_type || "custom", text: text || "" }); export const gift = (sid, npc_id, tier) => post("/api/gift", { session_id: sid, npc_id, tier }); export const review = (sid) => post("/api/review", { session_id: sid }); export const chat = (sid, npc_id, text) => post("/api/chat", { session_id: sid, npc_id, text: text || "" }); export const idle = (sid) => post("/api/idle", { session_id: sid }); export const readEmail = (sid) => post("/api/read_email", { session_id: sid }); export const comic = (sid, image_prompt) => post("/api/comic", { session_id: sid, image_prompt: image_prompt || "" });