// SPEC: PJ2026-010403 API契约 draft-2026-06-17-r0; PJ2026-010401 Web工作台 draft-2026-06-17-r0; PJ2026-010405 云端控制台 draft-2026-07-13-p0-cloud-console; PJ2026-01060505 Workbench Performance draft-2026-06-17-p0.
// Responsibility: 保存 store 与组件共享的 Cloud Web API、Workbench 和 HWPOD typed topology 类型合同。

export type Tone = "ok" | "pending" | "blocked" | "error" | "warn" | "dev-live" | "dry-run";
export type AuthState = "checking" | "login" | "authenticated";
export type ProviderProfile = string;
export type ChatRole = "user" | "agent" | "system";
export type ChatStatus = "pending" | "sent" | "running" | "completed" | "failed" | "blocked" | "timeout" | "canceled";
export type AccessUserRole = "admin" | "user";
export type AccessUserStatus = "active" | "disabled";
export type BillingUserStatus = AccessUserStatus | "pending";
export type AccessToolId = "hwpod" | "unidesk_ssh" | "trans_cmd" | "github_pr";

export interface AuthUser {
  id?: string;
  username?: string;
  displayName?: string;
  name?: string;
  role?: AccessUserRole;
  status?: AccessUserStatus;
}

export type AuthCapabilityStatus = "available" | "forbidden" | "unlinked" | "unavailable" | string;

export interface AuthCapabilities {
  web?: AuthCapabilityStatus;
  workbench?: AuthCapabilityStatus;
  codeAgent?: AuthCapabilityStatus;
  billing?: AuthCapabilityStatus;
  apiKeys?: AuthCapabilityStatus;
  admin?: AuthCapabilityStatus;
  [key: string]: AuthCapabilityStatus | undefined;
}

export interface AuthNavAccess {
  profileId?: string;
  allowedIds?: string[];
  valuesRedacted?: boolean;
}

export interface AuthAccess {
  nav?: AuthNavAccess;
  [key: string]: unknown;
}

export interface AuthSession {
  authenticated: boolean;
  mode: "server";
  authMethod?: string | null;
  identityAuthority?: string | null;
  sessionKind?: string | null;
  user?: AuthUser;
  actor?: AuthUser;
  capabilities?: AuthCapabilities;
  access?: AuthAccess;
  expiresAt?: string | null;
  valuesRedacted?: boolean;
}

export interface ApiResult<T> {
  ok: boolean;
  status: number;
  data: T | null;
  error: string | null;
  apiError?: ApiError | null;
  diagnostic?: ErrorDiagnostic | null;
}

export interface ErrorDiagnostic {
  contractVersion?: string | null;
  traceId?: string | null;
  requestId?: string | null;
  serviceId?: string | null;
  route?: string | null;
  layer?: string | null;
  category?: string | null;
  code?: string | number | null;
  httpStatus?: number | null;
  source?: "server" | "browser" | string | null;
  observedAt?: string | null;
  retryable?: boolean | null;
  valuesPrinted?: boolean;
  [key: string]: unknown;
}

export interface ApiError {
  message: string;
  userMessage?: string | null;
  code?: string | number | null;
  failureKind?: string | null;
  reason?: string | null;
  recoveryAction?: string | null;
  failureIdentity?: string | null;
  primaryPresentation?: "assistant-message" | string | null;
  admissionState?: string | null;
  retryable?: boolean | null;
  layer?: string | null;
  category?: string | null;
  route?: string | null;
  traceId?: string | null;
  upstreamTraceId?: string | null;
  runId?: string | null;
  commandId?: string | null;
  dispatchIntentId?: string | null;
  requestId?: string | null;
  source?: "server" | "browser" | string | null;
  diagnostic?: ErrorDiagnostic | null;
  valuesPrinted?: boolean;
  [key: string]: unknown;
}

export interface LiveProbePayload {
  status?: string;
  serviceId?: string;
  commitId?: string;
  revision?: string;
  runtime?: Record<string, unknown>;
  codeAgent?: CodeAgentAvailability;
  availability?: CodeAgentAvailability;
  [key: string]: unknown;
}

export interface LiveBuildsPayload {
  status?: string;
  observedAt?: string;
  builds?: Array<Record<string, unknown>>;
  [key: string]: unknown;
}

export interface LiveSurface {
  healthLive: ApiResult<LiveProbePayload>;
  health: ApiResult<LiveProbePayload>;
  restIndex: ApiResult<LiveProbePayload>;
  hwpodSpecs: ApiResult<HwpodSpecsResponse>;
  hwpodNodeOps: ApiResult<HwpodNodeOpsResponse>;
  liveBuilds: ApiResult<LiveBuildsPayload>;
  loadedAt: string;
}

export interface CodeAgentAvailability {
  status?: string;
  ready?: boolean;
  provider?: string;
  mode?: string;
  backend?: string;
  capabilityLevel?: string;
  sessionMode?: string;
  blockers?: Array<{ code?: string; message?: string }>;
  [key: string]: unknown;
}

export interface ProjectionBlocker {
  code?: string;
  message?: string | null;
  summary?: string | null;
  userMessage?: string | null;
  layer?: string | null;
  category?: string | null;
  retryable?: boolean | null;
  route?: string | null;
  traceId?: string | null;
  requestId?: string | null;
  source?: "server" | "browser" | string | null;
  httpStatus?: number | null;
  diagnostic?: ErrorDiagnostic | null;
  runId?: string | null;
  commandId?: string | null;
  timeoutMs?: number | null;
  [key: string]: unknown;
}

export interface ProjectionDiagnostic {
  projectionStatus?: string | null;
  projectionHealth?: "caught-up" | "degraded" | "stalled" | "unavailable" | "unknown" | string | null;
  lastProjectedSeq?: number | null;
  sourceRunId?: string | null;
  sourceCommandId?: string | null;
  staleMs?: number | null;
  blocker?: ProjectionBlocker | null;
  diagnostic?: ErrorDiagnostic | null;
  apiError?: ApiError | null;
  updatedAt?: string | null;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface WorkbenchTurnTimingProjection {
  startedAt?: string | null;
  lastEventAt?: string | null;
  finishedAt?: string | null;
  durationMs?: number | null;
  observedAt?: string | null;
  lastEventAgeMs?: number | null;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface WorkbenchSessionRecord {
  sessionId: string;
  threadId?: string | null;
  status?: string | null;
  updatedAt?: string | null;
  lastUserMessageAt?: string | null;
  startedAt?: string | null;
  lastTraceId?: string | null;
  messageCount?: number;
  firstUserMessagePreview?: string | null;
  title?: string | null;
  name?: string | null;
  snapshot?: Record<string, unknown> | null;
  userPreview?: string | null;
  messages?: ChatMessage[];
  projection?: ProjectionDiagnostic | null;
  timing?: WorkbenchTurnTimingProjection | null;
  lastEventAt?: string | null;
  finishedAt?: string | null;
  durationMs?: number | null;
  projectionStatus?: string | null;
  projectionHealth?: string | null;
  staleMs?: number | null;
  blocker?: ProjectionBlocker | null;
  [key: string]: unknown;
}

export interface TraceEvent {
  ts?: string;
  label?: string;
  kind?: string;
  type?: string;
  status?: string;
  message?: string;
  text?: string;
  outputSummary?: string;
  itemId?: string;
  toolName?: string;
  command?: string;
  exitCode?: number;
  stdoutSummary?: string;
  stderrSummary?: string;
  elapsedMs?: number;
  final?: boolean;
  terminal?: boolean;
  replyAuthority?: boolean;
  [key: string]: unknown;
}

export interface RunnerTrace {
  traceId?: string;
  status?: string;
  sessionId?: string;
  threadId?: string;
  runnerKind?: string;
  sessionMode?: string;
  events?: TraceEvent[];
  eventCount?: number;
  eventsCompacted?: boolean;
  fullTraceLoaded?: boolean;
  hasMore?: boolean;
  truncated?: boolean;
  nextProjectedSeq?: number | null;
  range?: { afterProjectedSeq?: number; fromProjectedSeq?: number | null; toProjectedSeq?: number | null; limit?: number; returned?: number; total?: number; [key: string]: unknown };
  lastEventLabel?: string;
  waitingFor?: string;
  timing?: WorkbenchTurnTimingProjection | null;
  startedAt?: string | null;
  lastEventAt?: string | null;
  finishedAt?: string | null;
  durationMs?: number | null;
  projection?: ProjectionDiagnostic | null;
  projectionStatus?: string | null;
  projectionHealth?: string | null;
  staleMs?: number | null;
  blocker?: ProjectionBlocker | null;
  [key: string]: unknown;
}

export interface ChatMessage {
  id: string;
  role: ChatRole;
  title: string;
  text: string;
  status: ChatStatus;
  createdAt: string;
  updatedAt?: string;
  traceId?: string | null;
  turnId?: string | null;
  messageId?: string | null;
  sessionId?: string | null;
  threadId?: string | null;
  retryInput?: string | null;
  runnerTrace?: RunnerTrace | null;
  traceEvents?: TraceEvent[];
  timing?: WorkbenchTurnTimingProjection | null;
  startedAt?: string | null;
  lastEventAt?: string | null;
  finishedAt?: string | null;
  durationMs?: number | null;
  error?: { code?: string | number | null; message?: string; userMessage?: string | null; category?: string | null; layer?: string | null; providerStatus?: number; retryable?: boolean | null; route?: string | null; traceId?: string | null; requestId?: string | null; source?: "server" | "browser" | string | null; diagnostic?: ErrorDiagnostic | null; [key: string]: unknown } | null;
  traceAutoLifecycle?: "running" | "terminal" | null;
  projection?: ProjectionDiagnostic | null;
  projectionStatus?: string | null;
  projectionHealth?: string | null;
  staleMs?: number | null;
  blocker?: ProjectionBlocker | null;
  [key: string]: unknown;
}

export interface AgentRunProvenance {
  adapter?: string;
  runId?: string;
  commandId?: string;
  attemptId?: string;
  runnerId?: string;
  jobName?: string;
  namespace?: string;
  backendProfile?: string;
  status?: string;
  commandState?: string;
  terminalStatus?: string;
  valuesPrinted?: boolean;
  [key: string]: unknown;
}

export interface AgentChatResponse {
  status?: string;
  reply?: string | AgentChatReply;
  text?: string;
  summary?: string;
  traceId?: string;
  turnId?: string | null;
  userMessageId?: string | null;
  assistantMessageId?: string | null;
  sessionId?: string;
  threadId?: string;
  sessionStatus?: string;
  availability?: CodeAgentAvailability;
  runnerTrace?: RunnerTrace;
  traceEvents?: TraceEvent[];
  assistantText?: string;
  agentRun?: AgentRunProvenance;
  resultUrl?: string;
  traceUrl?: string;
  turnUrl?: string;
  accepted?: boolean;
  shortConnection?: boolean;
  running?: boolean;
  terminal?: boolean;
  timing?: WorkbenchTurnTimingProjection | null;
  startedAt?: string | null;
  lastEventAt?: string | null;
  finishedAt?: string | null;
  durationMs?: number | null;
  updatedAt?: string;
  lastEventLabel?: string;
  waitingFor?: string;
  error?: string | { code?: string; message?: string; providerStatus?: number; [key: string]: unknown };
  projection?: ProjectionDiagnostic | null;
  projectionStatus?: string | null;
  projectionHealth?: string | null;
  staleMs?: number | null;
  blocker?: ProjectionBlocker | null;
  [key: string]: unknown;
}

export interface AgentChatReply {
  messageId?: string;
  role?: "assistant" | "user" | "system";
  content?: string;
  createdAt?: string;
  [key: string]: unknown;
}

export type AgentChatResultResponse = AgentChatResponse & {
  events?: TraceEvent[];
  eventCount?: number;
  fullTraceLoaded?: boolean;
  hasMore?: boolean;
  truncated?: boolean;
  nextProjectedSeq?: number | null;
  range?: { afterProjectedSeq?: number; fromProjectedSeq?: number | null; toProjectedSeq?: number | null; limit?: number; returned?: number; total?: number; [key: string]: unknown };
  traceStatus?: string;
  retention?: unknown;
  terminalEvidence?: unknown;
  finalResponse?: unknown;
  traceSummary?: unknown;
  lastEventLabel?: string;
};

export interface HwpodSpecsResponse { specs?: Array<Record<string, unknown>>; [key: string]: unknown }
export interface HwpodNodeOpsResponse { ok?: boolean; status?: string; events?: TraceEvent[]; groups?: Array<Record<string, unknown>>; [key: string]: unknown }

export type HwpodConnectionStatus = "online" | "offline";
export type HwpodReadinessStatus = "ready" | "blocked" | "unknown" | string;

export interface HwpodCapabilityCoverage {
  matched: number;
  declared: number;
  actual: number;
  missing: number;
  extra: number;
}

export interface HwpodBlocker {
  code: string;
  summary: string;
  retryable: boolean;
}

export interface HwpodOperationSummary {
  requestId: string | null;
  planId: string | null;
  hwpodId: string | null;
  status: string;
  opCount: number;
  startedAt: string | null;
  finishedAt: string | null;
  blockerCode: string | null;
}

export interface HwpodDiagnosticSummary {
  level: string;
  source: string;
  message: string;
  observedAt: string | null;
  valuesRedacted: true;
}

export interface HwpodElements {
  target: { label: string; mcu: string | null };
  workspace: { label: string; path: string | null; toolchain: string | null };
  debugProbe: { label: string; type: string | null };
  ioProbe: { label: string; kind: string };
}

export interface HwpodDeviceTopologyItem {
  resourceType: "hwpod";
  hwpodId: string;
  uid: string | null;
  name: string;
  nodeId: string;
  nodeName: string;
  status: HwpodConnectionStatus;
  online: boolean;
  available: boolean;
  busy: boolean;
  capabilityMismatch: boolean;
  declaredCapabilities: string[];
  actualCapabilities: string[];
  missingCapabilities: string[];
  capabilityCoverage: HwpodCapabilityCoverage;
  elements: HwpodElements;
  availability: { ok: boolean | null; status: string; checkedAt: string | null; blocker: HwpodBlocker | null };
  operation: HwpodOperationSummary | null;
  diagnostic: HwpodDiagnosticSummary | null;
  blockers: HwpodBlocker[];
  source: { authority: string; kind: string; specPath: string | null };
  observedAt: string;
}

export interface HwpodNodeReadinessStage {
  id: "downloaded" | "installed" | "desktop-visible" | "registered" | "workspace-ready" | "hwpod-ready" | string;
  label: string;
  status: HwpodReadinessStatus;
  authority: string;
  blocker: HwpodBlocker | null;
  nextAction: { label: string; entrypoint: string } | null;
}

export interface HwpodNodeTopologyItem {
  resourceType: "hwpod-node";
  nodeId: string;
  name: string;
  status: HwpodConnectionStatus;
  online: boolean;
  platform: string;
  version: string | null;
  runtimeKind: string | null;
  firstSeenAt: string | null;
  lastSeenAt: string | null;
  ageMs: number | null;
  deviceCount: number;
  hwpods: Array<{ hwpodId: string; name: string; status: HwpodConnectionStatus; busy: boolean; capabilityMismatch: boolean }>;
  declaredCapabilities: string[];
  actualCapabilities: string[];
  missingCapabilities: string[];
  capabilityCoverage: HwpodCapabilityCoverage;
  capabilityMismatch: boolean;
  inFlight: { count: number; max: number; busy: boolean };
  operation: HwpodOperationSummary | null;
  readinessProbe: HwpodOperationSummary | null;
  diagnostic: HwpodDiagnosticSummary | null;
  readiness: HwpodNodeReadinessStage[];
  blockers: HwpodBlocker[];
  observedAt: string;
}

export interface HwpodTopologyResponse<T extends HwpodDeviceTopologyItem | HwpodNodeTopologyItem> {
  ok: boolean;
  status: "ready" | "partial" | string;
  contractVersion: "hwpod-topology-v1" | string;
  route: string;
  owner: "cloud-api-hwpod-domain" | string;
  resource: "device" | "node";
  service: { ready: boolean; status: string; websocketMode: string; connectedNodeCount: number; pendingOperationCount: number; invalidSpecCount: number };
  summary: { nodeCount: number; onlineNodeCount: number; offlineNodeCount: number; unconfiguredNodeCount: number; deviceCount: number; availableDeviceCount: number; busyDeviceCount: number; capabilityMismatchCount: number; invalidSpecCount: number };
  items: T[];
  page: { limit: number; returned: number; total: number; cursor: string | null; previousCursor: string | null; nextCursor: string | null };
  invalidSpecs: Array<{ specPath: string | null; status: "invalid"; blocker: HwpodBlocker }>;
  valuesRedacted: true;
  observedAt: string;
}

export interface HwpodOperationResponse {
  ok: boolean;
  status: string;
  operationId: string;
  planId?: string | null;
  hwpodId?: string | null;
  workflowId?: string;
  workflowRunId?: string | null;
  authority?: string;
  result?: Record<string, unknown> | null;
  error?: { code?: string; message?: string } | null;
  valuesPrinted?: boolean;
}

export interface HwpodWorkspaceEntry {
  name: string;
  path: string;
  type: "dir" | "file" | "other";
  sizeBytes: number | null;
  modifiedAt: string | null;
}

export interface HwlabNodeUpdateMetadata {
  ok: boolean;
  contractVersion: "hwlab-node-update-v1" | string;
  channel: string;
  platform: string;
  currentVersion: string | null;
  latestVersion: string;
  updateAvailable: boolean;
  artifact: { version: string; fileName: string; sizeBytes: number; sha256: string | null; downloadUrl: string | null };
  releaseNotes: string[];
  releaseNotesUrl: string | null;
  installConditions: Array<{ id: string; label: string; required: boolean }>;
  readinessStages: Array<{ id: string; label: string; authority: string; nextAction: { label: string; entrypoint: string } }>;
  observedAt: string;
}
export interface CaseRunCaseSummary { caseId: string; title?: string; mode?: string; available?: boolean; hwpodSpec?: string; subject?: Record<string, unknown> | null; expected?: Record<string, unknown> | null; runtime?: Record<string, unknown> | null; [key: string]: unknown }
export interface CaseRunCasesResponse { ok?: boolean; mode?: string; contractVersion?: string; count?: number; cases?: CaseRunCaseSummary[]; caseAuthority?: Record<string, unknown>; [key: string]: unknown }
export interface CaseRunListItem { runId: string; caseId: string; workflowId?: string; workflowRunId?: string | null; status: string; stage: string; terminal: boolean; createdAt: string; updatedAt: string; artifactCount?: number; evidenceStatus?: string | null; artifactManifestSha256?: string | null; [key: string]: unknown }
export interface CaseRunRunsResponse { ok?: boolean; mode?: string; contractVersion?: string; count?: number; runs?: CaseRunListItem[]; nextCursor?: string | null; [key: string]: unknown }
export interface CaseRunEvent { id?: number; at?: string; createdAt?: string; status?: string; stage?: string; payload?: Record<string, unknown>; [key: string]: unknown }
export interface CaseRunBlocker { code: string; summary: string; layer?: string | null; details?: Record<string, unknown> | null }
export interface CaseRunReference { href?: string; ref?: string | null; sha256?: string | null; count?: number; relationship?: Record<string, unknown> | null; [key: string]: unknown }
export interface CaseRunArtifact { path?: string; name?: string; bytes?: number; sha256?: string; [key: string]: unknown }
export interface CaseRunResult { run?: { mode?: string; hardwareRequired?: boolean; [key: string]: unknown } | null; summary?: { mode?: string; status?: string; artifactCount?: number; artifacts?: CaseRunArtifact[]; [key: string]: unknown } | null; evidence?: { mode?: string; status?: string; artifacts?: CaseRunArtifact[]; [key: string]: unknown } | null; [key: string]: unknown }
export interface CaseRunRunResponse { ok?: boolean; mode?: string; contractVersion?: string; runId?: string; caseId?: string; workflowId?: string; workflowRunId?: string; status?: string; stage?: string; terminal?: boolean; blocker?: CaseRunBlocker | null; createdAt?: string; updatedAt?: string; caseRepo?: string; runDir?: string; result?: CaseRunResult | null; facts?: { jobId?: string | null; artifactCount?: number; evidenceStatus?: string | null }; references?: { status?: CaseRunReference; events?: CaseRunReference; aggregate?: CaseRunReference; manifest?: CaseRunReference | null; replay?: CaseRunReference | null; trace?: Record<string, unknown> | null; hwpod?: Record<string, unknown> | null }; sourceAuthority?: Record<string, unknown>; error?: { code?: string; message?: string } | null; statusUrl?: string; [key: string]: unknown }
export interface CaseRunEventsResponse { ok?: boolean; mode?: string; contractVersion?: string; runId?: string; caseId?: string; status?: string; stage?: string; terminal?: boolean; sourceAuthority?: Record<string, unknown>; events?: CaseRunEvent[]; [key: string]: unknown }
export interface CaseRunAggregateResponse { ok?: boolean; mode?: string; contractVersion?: string; runId?: string; caseId?: string; status?: string; stage?: string; terminal?: boolean; sourceAuthority?: Record<string, unknown>; sha256?: string | null; result?: CaseRunResult | null; summary?: CaseRunResult["summary"]; evidence?: CaseRunResult["evidence"]; run?: CaseRunResult["run"]; [key: string]: unknown }
export interface ProviderProfilesResponse { ok?: boolean; status?: string; profiles?: Array<Record<string, unknown>>; [key: string]: unknown }
export interface ProviderProfileCatalogItem {
  profile: string;
  backendProfile?: string;
  backendKind?: string;
  configured?: boolean;
  failureKind?: string | null;
  bridge?: Record<string, unknown>;
  valuesPrinted: false;
}
export interface ProviderProfileCatalogResponse {
  ok?: boolean;
  contractVersion?: string;
  count?: number;
  items: ProviderProfileCatalogItem[];
  data?: { items: ProviderProfileCatalogItem[]; count: number; valuesPrinted: false } | null;
  valuesPrinted: false;
}
export interface ProviderProfileValidation { validationId?: string; status?: string; [key: string]: unknown }
export type AdminSecretStatus = "SecretLeakBlocked" | "StoreUnavailable" | "SyncError" | "TargetMissing" | "RolloutPending" | "ValidationFailed" | "Ready" | "Unknown" | string;
export interface AdminSecretsTarget { node?: string; lane?: string; runtimeNamespace?: string; infraNamespace?: string; publicUrl?: string; source?: string; sourceRef?: string; upstreamSourceRef?: string; [key: string]: unknown }
export interface AdminSecretsStore { kind?: string; name?: string; namespace?: string; scope?: string; status?: AdminSecretStatus; reason?: string; valuesPrinted?: boolean; [key: string]: unknown }
export interface AdminSecretsTargetKey { key?: string; presence?: string; fingerprint?: string; valuesPrinted?: boolean; [key: string]: unknown }
export interface AdminSecretsRemoteRef { path?: string | null; property?: string | null; version?: string | null; fingerprint?: string | null; redacted?: boolean; [key: string]: unknown }
export interface AdminSecretsDataMapping { targetKey?: string; remoteRef?: AdminSecretsRemoteRef; [key: string]: unknown }
export interface AdminSecretsConsumer { serviceId?: string; kind?: string; injectAs?: string; envName?: string | null; status?: AdminSecretStatus; rollout?: string; revision?: string | null; valuesPrinted?: boolean; [key: string]: unknown }
export interface AdminSecretsPlanPermission { id?: string; allowed?: boolean; source?: string; valuesPrinted?: boolean; [key: string]: unknown }
export interface AdminSecretsPlanCheck { id?: string; label?: string; status?: string; code?: string; detail?: string; valuesPrinted?: boolean; [key: string]: unknown }
export interface AdminSecretsPlanRisk { code?: string; severity?: string; message?: string; valuesPrinted?: boolean; [key: string]: unknown }
export interface AdminSecretsPlanRequest {
  mode?: "create" | "edit" | string;
  target?: { node?: string; lane?: string; namespace?: string; runtimeNamespace?: string; [key: string]: unknown };
  externalSecretName?: string;
  targetSecretName?: string;
  store?: { kind?: "SecretStore" | "ClusterSecretStore" | string; name?: string; namespace?: string; [key: string]: unknown };
  data?: Array<{ targetKey?: string; sourceRef?: AdminSecretsRemoteRef; remoteRef?: AdminSecretsRemoteRef; [key: string]: unknown }>;
  refreshInterval?: string;
  consumerRollout?: { enabled?: boolean; intent?: string; [key: string]: unknown };
  [key: string]: unknown;
}
export interface AdminSecretsPlanResponse {
  ok?: boolean;
  status?: string;
  contractVersion?: string;
  generatedAt?: string;
  target?: AdminSecretsTarget;
  permission?: AdminSecretsPlanPermission;
  planId?: string | null;
  failureKind?: string | null;
  checks?: AdminSecretsPlanCheck[];
  risks?: AdminSecretsPlanRisk[];
  plan?: {
    operation?: string;
    mode?: string;
    dryRun?: boolean;
    writes?: boolean;
    target?: { node?: string; lane?: string; namespace?: string; [key: string]: unknown };
    externalSecret?: { name?: string; namespace?: string; refreshInterval?: string; [key: string]: unknown };
    targetSecret?: { name?: string; namespace?: string; presence?: string; valuesPrinted?: boolean; [key: string]: unknown };
    store?: AdminSecretsStore;
    data?: Array<{ targetKey?: string; sourceRef?: AdminSecretsRemoteRef; presence?: string; referenceFingerprint?: string | null; valuesPrinted?: boolean; [key: string]: unknown }>;
    affectedConsumers?: AdminSecretsConsumer[];
    consumerRollout?: { enabled?: boolean; intent?: string; marker?: string; valuesPrinted?: boolean; [key: string]: unknown };
    valuesPrinted?: boolean;
    secretMaterialStored?: boolean;
    [key: string]: unknown;
  };
  error?: Record<string, unknown>;
  valuesPrinted?: boolean;
  secretMaterialStored?: boolean;
  [key: string]: unknown;
}
export interface AdminSecretsExternalSecret {
  id?: string;
  name?: string;
  namespace?: string;
  cluster?: string;
  target?: AdminSecretsTarget;
  store?: AdminSecretsStore;
  status?: AdminSecretStatus;
  ready?: boolean;
  reason?: string;
  message?: string;
  refreshInterval?: string;
  createdAt?: string | null;
  lastUpdated?: string | null;
  ageSource?: string | null;
  lastRefreshTime?: string | null;
  targetSecret?: { name?: string; namespace?: string; keys?: AdminSecretsTargetKey[]; resourceVersion?: string | null; fingerprint?: string | null; valuesPrinted?: boolean; [key: string]: unknown };
  data?: AdminSecretsDataMapping[];
  consumers?: AdminSecretsConsumer[];
  conditions?: Array<{ type?: string; status?: string; reason?: string; lastTransitionTime?: string | null; valuesPrinted?: boolean; [key: string]: unknown }>;
  provenance?: Record<string, unknown>;
  valuesPrinted?: boolean;
  secretMaterialStored?: boolean;
  [key: string]: unknown;
}
export interface AdminSecretsEvent { status?: AdminSecretStatus; reason?: string; namespace?: string; resourceKind?: string; resourceName?: string; message?: string; observedAt?: string; traceId?: string | null; jobId?: string | null; source?: string; valuesPrinted?: boolean; [key: string]: unknown }
export interface AdminSecretsSummaryResponse { ok?: boolean; status?: string; contractVersion?: string; target?: AdminSecretsTarget; permissions?: Record<string, unknown>; source?: Record<string, unknown>; summary?: Record<string, unknown>; externalSecrets?: AdminSecretsExternalSecret[]; events?: AdminSecretsEvent[]; valuesPrinted?: boolean; secretMaterialStored?: boolean; generatedAt?: string; [key: string]: unknown }
export interface AdminSecretsListResponse { ok?: boolean; status?: string; contractVersion?: string; target?: AdminSecretsTarget; items?: AdminSecretsExternalSecret[]; count?: number; valuesPrinted?: boolean; secretMaterialStored?: boolean; generatedAt?: string; [key: string]: unknown }
export interface AdminSecretsDetailResponse { ok?: boolean; status?: string; contractVersion?: string; target?: AdminSecretsTarget; item?: AdminSecretsExternalSecret; events?: AdminSecretsEvent[]; eventCount?: number; valuesPrinted?: boolean; secretMaterialStored?: boolean; generatedAt?: string; [key: string]: unknown }
export interface AdminSecretsEventsResponse { ok?: boolean; status?: string; contractVersion?: string; target?: AdminSecretsTarget; events?: AdminSecretsEvent[]; count?: number; valuesPrinted?: boolean; secretMaterialStored?: boolean; generatedAt?: string; [key: string]: unknown }
export interface GateDiagnosticRow extends Record<string, unknown> {
  category?: string;
  check?: string;
  status?: string;
  statusKey?: string;
  owner?: string;
  detail?: string;
  evidence?: string | string[];
  updatedAt?: string;
  next?: string;
}

export interface GateDiagnosticsResponse {
  status?: string;
  route?: string;
  contractVersion?: string;
  sourceKind?: string;
  liveBackend?: boolean;
  observedAt?: string;
  rowCount?: number;
  rows?: GateDiagnosticRow[];
  safety?: Record<string, unknown>;
  [key: string]: unknown;
}

export interface WebPerformanceRow extends Record<string, unknown> {
  kind?: string;
  metric?: string;
  route?: string;
  method?: string;
  statusClass?: string;
  outcome?: string;
  count?: number;
  average?: number;
  p50?: number;
  p75?: number;
  p95?: number;
  unit?: "seconds" | "score" | string;
  sourceFamily?: string;
  windowFrom?: string | null;
  windowTo?: string;
  generatedAt?: string;
  sampleCount?: number;
  freshness?: "fresh" | "low-sample" | "empty" | string;
  aggregationKind?: "exact" | "histogram" | string;
  approximation?: "exact" | "bucketed" | string;
  bucketBoundaries?: number[];
  tone?: "ok" | "warn" | "blocked" | "pending" | string;
  problem?: string;
  lowSample?: boolean;
  sampleState?: "ok" | "low-sample" | "empty" | string;
  backend?: string;
  transport?: string;
  targetState?: string;
  cache?: string;
  source?: string;
  entry?: string;
  authState?: string;
  eventType?: string;
  phase?: string;
  backendEvidence?: {
    status?: "matched" | "missing" | "unavailable" | string;
    statusLabel?: string;
    diagnostic?: string;
    diagnosticLabel?: string;
    detail?: string;
    route?: string;
    method?: string;
    count?: number;
    p50?: number;
    p75?: number;
    p95?: number;
    responseBytesP95?: number | null;
    lastObservedAt?: string | null;
    phases?: Array<{ phase?: string; outcome?: string; count?: number; p95?: number }>;
  };
}

export type WebPerformanceWindow = "5m" | "15m" | "1h" | "6h" | "24h" | "all";

export interface WebPerformanceSampleWindow extends Record<string, unknown> {
  id?: WebPerformanceWindow | string;
  label?: string;
  seconds?: number | null;
  windowFrom?: string | null;
  windowTo?: string;
  generatedAt?: string;
  aggregationKind?: "exact" | "histogram" | string;
  approximation?: "exact" | "bucketed" | string;
}

export interface WebPerformanceDashboardPoint extends Record<string, unknown> {
  label?: string;
  detail?: string;
  value?: number;
  p50?: number;
  p75?: number;
  p95?: number;
  count?: number;
  tone?: string;
  sampleState?: string;
}

export interface WebPerformanceDashboardTrend extends Record<string, unknown> {
  id?: string;
  title?: string;
  subtitle?: string;
  unit?: string;
  points?: WebPerformanceDashboardPoint[];
}

export interface WebPerformanceDashboardDistributionBucket extends Record<string, unknown> {
  label?: string;
  count?: number;
  tone?: string;
}

export interface WebPerformanceDashboardDistribution extends Record<string, unknown> {
  id?: string;
  title?: string;
  subtitle?: string;
  unit?: string;
  buckets?: WebPerformanceDashboardDistributionBucket[];
}

export interface WebPerformanceDashboardTopRow extends Record<string, unknown> {
  label?: string;
  detail?: string;
  value?: number;
  unit?: string;
  count?: number;
  tone?: string;
}

export interface WebPerformanceDashboardTopN extends Record<string, unknown> {
  id?: string;
  title?: string;
  subtitle?: string;
  unit?: string;
  rows?: WebPerformanceDashboardTopRow[];
}

export interface WebPerformanceDashboardCard extends Record<string, unknown> {
  id?: string;
  label?: string;
  value?: string | number;
  unit?: string;
  tone?: string;
  detail?: string;
}

export interface WebPerformanceCollectionHealthDiagnostic extends Record<string, unknown> {
  code?: string;
  label?: string;
  tone?: string;
  detail?: string;
}

export interface WebPerformanceCollectionHealth extends Record<string, unknown> {
  schemaVersion?: string;
  status?: string;
  statusLabel?: string;
  reason?: string;
  reasonLabel?: string;
  sampleCount?: number;
  retainedSampleCount?: number;
  sampleSeries?: number;
  lowSampleThreshold?: number;
  firstSampleAt?: string | null;
  lastSampleAt?: string | null;
  lastRetainedSampleAt?: string | null;
  secondsSinceLastSample?: number | null;
  windowCoverageSeconds?: number | null;
  sourceFamilyCounts?: Array<{ sourceFamily?: string; rowCount?: number; sampleCount?: number; [key: string]: unknown }>;
  unknownAttribution?: { workbenchRows?: number; attributableRows?: number; rowsWithUnknown?: number; samplesWithUnknown?: number; backendUnknownRows?: number; transportUnknownRows?: number; [key: string]: unknown };
  diagnostics?: WebPerformanceCollectionHealthDiagnostic[];
}

export interface WebPerformanceDashboard extends Record<string, unknown> {
  schemaVersion?: string;
  generatedAt?: string;
  sampleWindow?: WebPerformanceSampleWindow & { buckets?: Array<Record<string, unknown>>; [key: string]: unknown };
  freshness?: { observedAt?: string; source?: string; namespace?: string; gitopsTarget?: string; status?: string; statusLabel?: string; lowSampleThreshold?: number; generatedAt?: string; windowFrom?: string | null; windowTo?: string; sampleCount?: number; sourceFamily?: string; [key: string]: unknown };
  collectionHealth?: WebPerformanceCollectionHealth;
  cards?: WebPerformanceDashboardCard[];
  trends?: WebPerformanceDashboardTrend[];
  distributions?: WebPerformanceDashboardDistribution[];
  topN?: WebPerformanceDashboardTopN[];
}

export interface WebPerformanceSummaryResponse {
  status?: string;
  source?: string;
  observedAt?: string;
  namespace?: string;
  gitopsTarget?: string;
  sampleWindow?: WebPerformanceSampleWindow;
  summary?: { sampleCount?: number; sampleSeries?: number; durationSeries?: number; clsSeries?: number; routeCount?: number; problemCount?: number; status?: string; lowSampleThreshold?: number; window?: WebPerformanceWindow | string; windowLabel?: string; windowSeconds?: number | null; windowFrom?: string | null; windowTo?: string; generatedAt?: string; aggregationKind?: "exact" | "histogram" | string; approximation?: "exact" | "bucketed" | string; [key: string]: unknown };
  backendEvidence?: { schemaVersion?: string; source?: string; observedAt?: string | null; sampleCount?: number; retainedSampleCount?: number; routeCount?: number; rows?: Array<Record<string, unknown>>; available?: boolean; valuesRedacted?: boolean; [key: string]: unknown };
  collectionHealth?: WebPerformanceCollectionHealth;
  dashboard?: WebPerformanceDashboard;
  apiRoutes?: WebPerformanceRow[];
  webVitals?: WebPerformanceRow[];
  longTasks?: WebPerformanceRow[];
  problems?: WebPerformanceRow[];
  workbenchJourneys?: WebPerformanceRow[];
  workbenchEventPhases?: WebPerformanceRow[];
  workbenchBackendEvents?: WebPerformanceRow[];
  workbenchCacheRows?: WebPerformanceRow[];
  workbenchRows?: WebPerformanceRow[];
  rows?: WebPerformanceRow[];
  [key: string]: unknown;
}

export interface SkillRecord extends Record<string, unknown> {
  id: string;
  source?: "preinstalled" | "uploaded" | string;
  name?: string;
  description?: string;
  version?: string | null;
  commitId?: string | null;
  rootDir?: string;
  manifestPath?: string | null;
  createdAt?: string | null;
  updatedAt?: string | null;
  fileCount?: number;
  sizeBytes?: number;
}

export interface SkillTreeEntry extends Record<string, unknown> { path: string; type?: "directory" | "file" | string; sizeBytes?: number | null }
export interface SkillFilePayload { path?: string; sizeBytes?: number; contentType?: string; content?: string }
export interface AgentRunResourceBundleSummary {
  kind: string;
  repoUrl: string;
  branch: string;
  commitId?: string | null;
  skillsDir: string;
}

export interface AgentRunBundleSummary { name: string; subpath: string; target_path: string }
export interface AgentRunPromptRefSummary { name: string; path: string; inject: string; required: boolean }
export interface AgentRunPromptAssemblyRef extends AgentRunPromptRefSummary { stage: string; source: string }
export interface AgentRunPromptAssemblySummary {
  status: string;
  count: number;
  requiredCount: number;
  injectStages: string[];
  refs: AgentRunPromptAssemblyRef[];
  valuesPrinted: false;
}

export interface AgentRunAssemblySummary {
  status: string;
  provider: string;
  namespace: string;
  managerUrl: string;
  resourceBundle: AgentRunResourceBundleSummary;
  counts: { bundles: number; promptRefs: number };
  bundles: AgentRunBundleSummary[];
  promptRefs: AgentRunPromptRefSummary[];
  promptAssembly: AgentRunPromptAssemblySummary;
  runtimeEnv: { assembledRuntime: string; skillsDirs: string };
  valuesPrinted: false;
}

export interface SkillsResponse { count?: number; skills?: SkillRecord[]; roots?: Record<string, string>; agentRunAssembly?: AgentRunAssemblySummary; [key: string]: unknown }
export interface SkillUploadResponse { accepted?: boolean; skill?: SkillRecord; [key: string]: unknown }
export interface SkillTreeResponse { skill?: SkillRecord; tree?: SkillTreeEntry[]; count?: number; [key: string]: unknown }
export interface SkillFileResponse { skill?: SkillRecord; file?: SkillFilePayload; content?: string; [key: string]: unknown }

export interface AdminAccessUser { id: string; username: string; displayName: string; role: AccessUserRole; status: AccessUserStatus }
export interface AdminAccessOpenFga { contractVersion: string; mode: "off" | "enforce"; configured: boolean; ready: boolean; status: "ready" | "disabled" | "degraded"; apiUrlConfigured: boolean; storeName: string; storeId: string; modelId: string; degradedReason: string | null; valuesRedacted: true }
export interface AdminAccessTuple { userId: string; relation: string; object: string; createdByAdminId: string; createdAt: string }
export interface AdminAccessUserSummary { user: AdminAccessUser; tupleCount: number; tools: Record<AccessToolId, boolean> }
export interface AdminAccessSummaryResponse { contractVersion: "admin-access-v1"; actor: AdminAccessUser; openfga: AdminAccessOpenFga; counts: { users: number; tuples: number; toolTuples: number }; supported: { toolIds: AccessToolId[] } }
export interface AdminAccessUsersResponse { contractVersion: "admin-access-v1"; actor: AdminAccessUser; openfga: AdminAccessOpenFga; users: AdminAccessUserSummary[]; count: number }
export interface AdminAccessMatrixResponse { contractVersion: "admin-access-v1"; actor: AdminAccessUser; user: AdminAccessUser; openfga: AdminAccessOpenFga; tools: Record<AccessToolId, boolean>; tuples: AdminAccessTuple[] }
export interface AdminAccessMutationResponse { ok?: boolean; changed?: boolean; updated?: boolean; user?: AdminAccessUser; access?: AdminAccessMatrixResponse }
export interface ApiKeyRecord { id: string; name?: string; prefix?: string; createdAt?: string; lastUsedAt?: string | null; revokedAt?: string | null; displaySecret?: string | null }
export interface UsageServiceSummary { serviceId: string; resourceType?: string; credits?: number; quantity?: number; recordCount?: number; lastUsedAt?: string }
export interface UsageLedgerRow { id: string; userId?: string; email?: string; username?: string; kind?: string; reason?: string; deltaCredits?: number; balanceBefore?: number; balanceAfter?: number; source?: string; status?: string; idempotencyKey?: string; operatorUserId?: string; operatorUsername?: string; metadata?: Record<string, unknown>; createdAt?: string }
export interface AdminUsageRow { id: string; reservationId?: string; userId?: string; email?: string; username?: string; apiKeyId?: string; serviceId?: string; resourceType?: string; unit?: string; quantity?: number; credits?: number; status?: string; idempotencyKey?: string; metadata?: Record<string, unknown>; createdAt?: string }
export interface UsageReservationRow { reservationId: string; serviceId?: string; resourceType?: string; estimatedCredits?: number; estimatedTokens?: number; status?: string; expiresAt?: string; createdAt?: string }
export interface BillingPlanSummary { id?: string; displayName?: string; status?: string; description?: string; metadata?: Record<string, unknown> }
export interface ResourceEntitlementSummary {
  id?: string;
  planId?: string;
  resourceType?: string;
  enabled?: boolean;
  monthlyQuotaCredits?: number;
  monthlyQuotaUnlimited?: boolean;
  monthlyUsageCredits?: number;
  monthlyRemainingCredits?: number;
  maxConcurrentReservations?: number;
  concurrencyUnlimited?: boolean;
  activeReservations?: number;
  rpmLimit?: number;
  rpmUnlimited?: boolean;
  rpmUsed?: number;
  limitSemantics?: string;
  metadata?: Record<string, unknown>;
}
export interface BillingPlanDetail { plan?: BillingPlanSummary; entitlements?: ResourceEntitlementSummary[] }
export interface UsageSummary {
  status?: string;
  contractVersion?: string;
  rows?: Array<Record<string, unknown>>;
  credits?: { balance?: number; reserved?: number; available?: number };
  planId?: string;
  plan?: BillingPlanSummary;
  entitlements?: ResourceEntitlementSummary[];
  usage?: { totalCredits?: number; totalQuantity?: number; recordCount?: number; byService?: UsageServiceSummary[] };
  ledger?: { count?: number; limit?: number; rows?: UsageLedgerRow[] };
  reservations?: { activeCount?: number; active?: UsageReservationRow[] };
  state?: { stateless?: boolean; stateAuthority?: string; database?: Record<string, unknown>; redis?: Record<string, unknown> };
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface AdminBillingUserSummary {
  user?: AuthUser & { email?: string; emailVerified?: boolean; createdAt?: string };
  planId?: string;
  plan?: BillingPlanSummary;
  entitlements?: ResourceEntitlementSummary[];
  credits?: { balance?: number; reserved?: number; available?: number };
  usage?: { totalCredits?: number; totalQuantity?: number; recordCount?: number; lastUsedAt?: string | null };
  apiKeys?: { activeCount?: number; totalCount?: number; lastUsedAt?: string | null };
  reservations?: { activeCount?: number; active?: UsageReservationRow[] };
}

export interface AdminBillingSummary {
  status?: string;
  contractVersion?: string;
  count?: number;
  limit?: number;
  totals?: Record<string, number>;
  users?: AdminBillingUserSummary[];
  state?: { stateless?: boolean; stateAuthority?: string; database?: Record<string, unknown>; redis?: Record<string, unknown> };
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface AdminBillingUsersResponse {
  status?: string;
  contractVersion?: string;
  count?: number;
  total?: number;
  users?: AdminBillingUserSummary[];
  pagination?: { page?: number; pageSize?: number; total?: number; totalPages?: number };
  state?: { stateless?: boolean; stateAuthority?: string; database?: Record<string, unknown>; redis?: Record<string, unknown> };
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface AdminBillingPlansResponse {
  status?: string;
  contractVersion?: string;
  count?: number;
  plans?: BillingPlanDetail[];
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface AdminBillingUserDetail {
  summary?: AdminBillingUserSummary;
  ledger?: { count?: number; rows?: UsageLedgerRow[] };
  apiKeys?: { count?: number; keys?: ApiKeyRecord[] };
  usageBy?: UsageServiceSummary[];
  reservations?: { count?: number; rows?: UsageReservationRow[]; active?: UsageReservationRow[] };
  [key: string]: unknown;
}

export interface AdminBillingUserDetailResponse {
  contractVersion?: string;
  detail?: AdminBillingUserDetail;
  actor?: AuthUser;
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface AdminAuditResponse<T> {
  contractVersion?: string;
  rows?: T[];
  count?: number;
  total?: number;
  pagination?: { page?: number; pageSize?: number; total?: number; totalPages?: number };
  filters?: Record<string, unknown>;
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface RedeemResult {
  redeemed?: boolean;
  idempotent?: boolean;
  redemptionId?: string;
  codeId?: string;
  codePrefix?: string;
  userId?: string;
  ledgerId?: string;
  creditAmount?: number;
  balanceBefore?: number;
  balanceAfter?: number;
  reason?: string;
  source?: string;
  status?: string;
  idempotencyKey?: string;
}

export interface RedeemResponse {
  contractVersion?: string;
  result?: RedeemResult;
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface RedeemCodeSummary {
  id?: string;
  codePrefix?: string;
  displayName?: string;
  status?: string;
  creditAmount?: number;
  reason?: string;
  maxRedemptions?: number;
  perUserLimit?: number;
  redeemedCount?: number;
  remainingCount?: number;
  expiresAt?: string | null;
  createdByUserId?: string;
  createdByUsername?: string;
  metadata?: Record<string, unknown>;
  createdAt?: string;
  updatedAt?: string;
  disabledAt?: string | null;
}

export interface RedeemRedemptionSummary {
  id?: string;
  codeId?: string;
  codePrefix?: string;
  userId?: string;
  ledgerId?: string;
  creditAmount?: number;
  status?: string;
  idempotencyKey?: string;
  metadata?: Record<string, unknown>;
  createdAt?: string;
}

export interface AdminRedeemCodesResponse {
  contractVersion?: string;
  codes?: RedeemCodeSummary[];
  code?: RedeemCodeSummary;
  redeemCode?: string;
  created?: boolean;
  updated?: boolean;
  count?: number;
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface AdminRedeemRedemptionsResponse {
  contractVersion?: string;
  redemptions?: RedeemRedemptionSummary[];
  count?: number;
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface SubscriptionSummaryResponse {
  contractVersion?: string;
  planId?: string;
  plan?: BillingPlanSummary;
  entitlements?: ResourceEntitlementSummary[];
  subscriptions?: BillingSubscriptionSummary[];
  payment?: PaymentProviderSummary;
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface PaymentSummaryResponse {
  contractVersion?: string;
  provider?: PaymentProviderSummary;
  orders?: PaymentOrderSummary[];
  count?: number;
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface PaymentProviderSummary {
  configured: boolean;
  status: string;
  provider: string;
  message: string;
  valuesRedacted: true;
}

export interface BillingSubscriptionSummary {
  id: string;
  planId: string;
  status: string;
  source: string;
  currentPeriodStart?: string;
  currentPeriodEnd?: string;
  metadata?: Record<string, unknown>;
  createdAt: string;
  updatedAt: string;
}

export interface PaymentOrderSummary {
  id: string;
  provider: string;
  status: string;
  creditAmount: number;
  amountMinor: number;
  currency: string;
  reason: string;
  metadata?: Record<string, unknown>;
  createdAt: string;
  updatedAt: string;
}

export type DashboardSourceState = "ready" | "partial" | "stale" | "unavailable" | "restricted";
export interface DashboardSourceStatus { id: "work" | "hwpod" | "billing"; label: string; authority: string; state: DashboardSourceState; observedAt: string | null; reason: string | null; href: string }
export interface DashboardTaskContinuation { taskRef: string; taskId: string; title: string; status: string; projectId: string | null; sourceId: string; fileRef: string; updatedAt: string | null; href: string }
export interface DashboardIssue { id: string; domain: DashboardSourceStatus["id"]; severity: "warning" | "error"; code: string; title: string; summary: string; count: number | null; action: { label: string; href: string } }
export interface DashboardSummaryResponse {
  ok: true;
  status: "ready" | "partial" | "stale";
  contractVersion: "cloud-dashboard-summary-v1";
  route: "/v1/dashboard/summary";
  observedAt: string;
  actor: { id: string; displayName: string; role: string };
  sources: DashboardSourceStatus[];
  work: { state: DashboardSourceState; authority: "hwlab-project-management"; observedAt: string | null; projectCount: number | null; projects: Array<{ projectId: string; title: string; status: string; href: string }>; taskCounts: { open: number | null; inProgress: number | null; blocked: number | null }; continuations: DashboardTaskContinuation[] };
  hwpod: { state: DashboardSourceState; authority: "cloud-api-hwpod-domain"; observedAt: string | null; nodeCount: number | null; onlineNodeCount: number | null; offlineNodeCount: number | null; deviceCount: number | null; availableDeviceCount: number | null; busyDeviceCount: number | null; capabilityMismatchCount: number | null; invalidSpecCount: number | null };
  billing: { state: DashboardSourceState; authority: "hwlab-user-billing"; observedAt: string | null; plan: { id: string | null; displayName: string | null; status: string | null } | null; credits: { balance: number | null; reserved: number | null; available: number | null } | null; entitlementCount: number | null; activeReservationCount: number | null };
  issues: DashboardIssue[];
  valuesRedacted: true;
}

export interface AdminBillingMutationResponse {
  ok?: boolean;
  userId?: string;
  status?: BillingUserStatus;
  user?: AuthUser;
  detail?: AdminBillingUserDetail;
  balance?: number;
  created?: boolean;
  updated?: boolean;
  actor?: AuthUser;
  proxy?: Record<string, unknown>;
  valuesRedacted?: boolean;
  [key: string]: unknown;
}

export interface Toast {
  id: string;
  type: "success" | "error" | "info" | "warning";
  message: string;
  duration?: number;
}
