| |
| |
| |
|
|
| const BASE = import.meta.env.VITE_API_BASE ?? 'http://localhost:8000' |
|
|
| async function _post(path, body) { |
| const res = await fetch(`${BASE}${path}`, { |
| method: 'POST', |
| headers: { 'Content-Type': 'application/json' }, |
| body: JSON.stringify(body), |
| }) |
| if (!res.ok) { |
| const text = await res.text().catch(() => '') |
| throw new Error(`${path} → ${res.status}: ${text}`) |
| } |
| return res.json() |
| } |
|
|
| |
| |
| |
| |
| |
| export async function apiReset(seed = 42) { |
| return _post('/game/reset', { seed }) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| export async function apiStep(decision, coalitionPitch = '') { |
| return _post('/game/step', { |
| decision, |
| coalition_pitch: coalitionPitch, |
| }) |
| } |
|
|
| |
| |
| |
| |
| export async function apiHealth() { |
| try { |
| const res = await fetch(`${BASE}/health`) |
| const data = await res.json() |
| return data.status === 'healthy' |
| } catch { |
| return false |
| } |
| } |
| |
| |
| |
| |
| |
| |
| export async function apiQwenDecide(obs) { |
| return _post('/qwen/decide', { |
| state: obs.state ?? {}, |
| event: obs.event ?? '', |
| options: obs.options ?? [], |
| npc_statements: obs.npc_statements ?? [], |
| round: obs.round ?? 1, |
| }) |
| } |
|
|