import { loadConfig } from "../config"; import { hasPassiveAccountQuota } from "../providers/quota"; import { closeSync, openSync, readSync } from "node:fs"; import { MAX_ACCOUNT_PRIORITY, MIN_ACCOUNT_PRIORITY, normalizeAccountPriority, parseAccountPriority, } from "../codex/pool-rotation"; import { apiError, apiJson, classifyAccount, fetchCodexRows, fetchProviderQuotaReport, fetchRows, proxyUnreachable, resolveBaseUrl, type AccountDeps, type AccountStdin, type FamilyRows, type ProviderQuotaDto, type ProviderQuotaReportDto, } from "./account-api"; import { codexCatalogRefreshPending, warnIfCodexCatalogRefreshPending, } from "./account-catalog-refresh"; import { ACCOUNT_IMPORT_DEADLINE_MS, ACCOUNT_IMPORT_FORMAT, ACCOUNT_IMPORT_MAX_BYTES, ACCOUNT_IMPORT_PROVIDER, type AccountImportCode, type AccountImportRecordResult, type AccountImportResult, type AccountImportStatus, } from "../oauth/account-import"; const MAIN_ID = "__main__"; const AUTO_NOTE = "auto (no pin — lowest-usage account is selected per request)"; const EXTENDED_USAGE = `Usage: ocx account refresh [--json] ocx account auto-switch > [--json] ocx account alias [--json] ocx account priority [<-100..100|first|earlier|normal|later|last|reset>] [--json] ocx account pause [--json] ocx account resume [--json] ocx account pause-exhausted [--json] ocx account strategy [] [--json] ocx account sticky [<1-100>] [--json] ocx account remove --yes [--json] ocx account clear-cooldown [--json] ocx account add-key [--label