// [nexus] Hardware detection and nexus settings API client
import { api } from "./client";

export type HardwareTier = "gpu" | "apple_silicon" | "cpu_only";

export interface HardwareInfo {
  totalGb: number;
  freeGb: number;
  usableGb: number;
  platform: string;
  gpuName: string | null;
  gpuVramGb: number | null;
  unifiedMemory: boolean;
  hardwareTier: HardwareTier;
  cpuModel: string | null;
}

export type NexusMode = "personal_ai" | "project_builder" | "both";

export interface NexusSettings {
  mode: NexusMode;
}

export function fetchHardwareInfo(): Promise<HardwareInfo> {
  return api.get<HardwareInfo>("/system/providers");
}

export function fetchNexusSettings(): Promise<NexusSettings> {
  return api.get<NexusSettings>("/nexus/settings");
}

export function updateNexusSettings(settings: Partial<NexusSettings>): Promise<NexusSettings> {
  return api.patch<NexusSettings>("/nexus/settings", settings);
}
