// SPEC: PJ2026-010404 项目管理 draft-2026-06-25-p0-project-management-mdtodo; draft-2026-06-26-p1-mdtodo-web-operable.
// Responsibility: Cloud Web API barrel, including project-management public API exports.

export { fetchJson, fetchText, type ActivityRef, type ActivityRefSource, type ApiRequestOptions } from "./client";
export { authAPI, HWLAB_WEB_SESSION_COOKIE } from "./auth";
export { workbenchAPI } from "./workbench";
export { workbenchDebugAPI, connectWorkbenchDebugFakeSse, connectWorkbenchKafkaSseDebug, workbenchKafkaSseDebugCorrelationIds, type WorkbenchDebugFakeSseQueue, type WorkbenchDebugFakeSseResponse, type WorkbenchDebugFakeSseSequence, type WorkbenchDebugFakeSseStream, type WorkbenchKafkaSseDebugEvent, type WorkbenchKafkaSseDebugStream, type WorkbenchKafkaSseDebugStreamName } from "./workbench-debug";
export { connectWorkbenchEvents, type WorkbenchEventStream, type WorkbenchRealtimeEvent } from "./workbench-events";
export { agentAPI } from "./agent";
export { hwpodAPI } from "./hwpod";
export { caserunAPI } from "./caserun";
export { accessAPI } from "./access";
export { adminSecretsAPI } from "./adminSecrets";
export { providerProfilesAPI } from "./providerProfiles";
export { apiKeysAPI } from "./apiKeys";
export { usageAPI } from "./usage";
export { billingAPI } from "./billing";
export { systemAPI, type SkillUploadFileInput } from "./system";
export { projectManagementAPI, type MdtodoExecutionContext, type MdtodoFileRecord, type MdtodoLaunchContextResponse, type MdtodoReportPreviewRecord, type MdtodoTaskDetailAuthority, type MdtodoTaskDetailRecord, type MdtodoTaskLinkRecord, type MdtodoTaskMutationInput, type MdtodoTaskMutationResponse, type MdtodoTaskPage, type MdtodoTaskRecord, type MdtodoTaskStatus, type ProjectNavigationResponse, type ProjectRecord, type ProjectSource, type ProjectSourceInput, type ProjectWorkbenchLinkRecord } from "./projectManagement";
export { tasktreeAPI, type TaskTreeGroup, type TaskTreeGroupOverview, type TaskTreeMilestone, type TaskTreeReport, type TaskTreeTask, type TaskTreeTimeline } from "./tasktree";

import { fetchJson } from "./client";
import { accessAPI } from "./access";
import { adminSecretsAPI } from "./adminSecrets";
import { agentAPI } from "./agent";
import { apiKeysAPI } from "./apiKeys";
import { authAPI } from "./auth";
import { caserunAPI } from "./caserun";
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 { projectManagementAPI } from "./projectManagement";
import { tasktreeAPI } from "./tasktree";
import type { ApiResult, LiveBuildsPayload, LiveProbePayload, SkillsResponse } from "@/types";

export const api = {
  auth: authAPI,
  workbench: workbenchAPI,
  agent: agentAPI,
  hwpod: hwpodAPI,
  caserun: caserunAPI,
  access: accessAPI,
  adminSecrets: adminSecretsAPI,
  providerProfiles: providerProfilesAPI,
  apiKeys: apiKeysAPI,
  usage: usageAPI,
  billing: billingAPI,
  projectManagement: projectManagementAPI,
  tasktree: tasktreeAPI,
  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" })
};
