export interface ToolSupportItem { name: string description: string category: string config_key: string status: "enabled" | "disabled" | "blocked" reason_code?: string } interface ToolsResponse { tools: ToolSupportItem[] } interface ToolActionResponse { status: string } async function request(path: string, options?: RequestInit): Promise { const res = await fetch(path, options) if (!res.ok) { let message = `API error: ${res.status} ${res.statusText}` try { const body = (await res.json()) as { error?: string errors?: string[] } if (Array.isArray(body.errors) && body.errors.length > 0) { message = body.errors.join("; ") } else if (typeof body.error === "string" && body.error.trim() !== "") { message = body.error } } catch { // ignore invalid body } throw new Error(message) } return res.json() as Promise } export async function getTools(): Promise { return request("/api/tools") } export async function setToolEnabled( name: string, enabled: boolean, ): Promise { return request( `/api/tools/${encodeURIComponent(name)}/state`, { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ enabled }), }, ) }