import { apiGetWrapped, apiPostWrapped } from './api' export type AccountSnapshotItem = { id: string tags: string[] risk_score: number enabled: boolean available: boolean cooldown_remaining_s: number cooldown_until: string | null last_error_kind: string | null last_error_at: string | null } export type AccountPoolSnapshotResponse = { now: string accounts: AccountSnapshotItem[] seed: number } export type SessionLightReport = { id: string account_id: string | null has_cookie: boolean has_storage_state: boolean cookie_ok: boolean storage_state_ok: boolean cookie_reason: string | null storage_state_reason: string | null checked_at: string } export type SessionPoolLightCheckResponse = { now: string sessions: SessionLightReport[] } export type ProxyPoolSnapshotResponse = { available_count: number avg_score: number ejected_total: number failures_total_by_reason: Record recent_failures_by_reason: Record last_fail_reasons_by_reason: Record } export async function getResourceAccounts() { return apiGetWrapped('resources/accounts') } export async function getResourceSessions() { return apiGetWrapped('resources/sessions') } export async function getResourceProxies() { return apiGetWrapped('resources/proxies') } export async function cooldownAccount(accountId: string, seconds: number) { return apiPostWrapped<{ account_id: string, cooldown_seconds: number }, { seconds: number }>( `resources/accounts/${encodeURIComponent(accountId)}/cooldown`, { seconds } ) } export async function disableAccount(accountId: string) { return apiPostWrapped<{ account_id: string, disabled: boolean }, {}>( `resources/accounts/${encodeURIComponent(accountId)}/disable`, {} ) }