export { fetchJson, fetchText, type ActivityRef, type ActivityRefSource, type ApiRequestOptions } from "./client";
export { authAPI, HWLAB_WEB_SESSION_COOKIE } from "./auth";
export { workbenchAPI } from "./workbench";
export { connectWorkbenchEvents, type WorkbenchEventStream, type WorkbenchRealtimeEvent } from "./workbench-events";
export { agentAPI } from "./agent";
export { hwpodAPI } from "./hwpod";
export { accessAPI } from "./access";
export { providerProfilesAPI } from "./providerProfiles";
export { apiKeysAPI } from "./apiKeys";
export { usageAPI } from "./usage";
export { billingAPI } from "./billing";
export { systemAPI, type SkillUploadFileInput } from "./system";

import { fetchJson } from "./client";
import { accessAPI } from "./access";
import { agentAPI } from "./agent";
import { apiKeysAPI } from "./apiKeys";
import { authAPI } from "./auth";
import { hwpodAPI } from "./hwpod";
import { providerProfilesAPI } from "./providerProfiles";
import { usageAPI } from "./usage";
import { billingAPI } from "./billing";
import { workbenchAPI } from "./workbench";
import { systemAPI } from "./system";
import type { ApiResult, LiveBuildsPayload, LiveProbePayload, SkillsResponse } from "@/types";

export const api = {
  auth: authAPI,
  workbench: workbenchAPI,
  agent: agentAPI,
  hwpod: hwpodAPI,
  access: accessAPI,
  providerProfiles: providerProfilesAPI,
  apiKeys: apiKeysAPI,
  usage: usageAPI,
  billing: billingAPI,
  system: systemAPI,
  healthLive: (): Promise<ApiResult<LiveProbePayload>> => fetchJson("/health/live", { timeoutMs: 12000, timeoutName: "health/live" }),
  health: (): Promise<ApiResult<LiveProbePayload>> => fetchJson("/health", { timeoutMs: 12000, timeoutName: "health" }),
  restIndex: (): Promise<ApiResult<LiveProbePayload>> => fetchJson("/v1", { timeoutMs: 12000, timeoutName: "REST index" }),
  liveBuilds: (): Promise<ApiResult<LiveBuildsPayload>> => fetchJson("/v1/live-builds", { timeoutMs: 12000, timeoutName: "live builds" }),
  skills: (): Promise<ApiResult<SkillsResponse>> => fetchJson("/v1/skills", { timeoutMs: 12000, timeoutName: "skills" })
};
