import { OAuthTokenStorage } from '../oauth/store'; /** * Generic OAuth-bearer client factory — dùng cho các provider không có * fingerprint phức tạp (Qwen / Kimi / iFlow / xAI). Caller cung cấp: * - defaultBase: URL gốc * - userAgent * - refreshFn: async fn nhận token cũ → token mới * - extraHeaders (optional): static headers cần thêm * * Trả về 2 hàm: call + stream + getValidToken. */ export interface GenericClientOpts { providerKey: string; defaultBase: string; userAgent: string; refresh: (current: OAuthTokenStorage) => Promise; /** Static headers cần thêm trên mỗi request. */ extraHeaders?: Record; /** Refresh grace before expiry (ms). */ refreshGraceMs?: number; } export interface ProviderRequestInput { path: string; method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; body?: unknown; headers?: Record; account?: string; } export interface ProviderResponse { status: number; headers: Record; body: unknown; errorType?: string; account: string; } export declare function createGenericClient(opts: GenericClientOpts): { call: (input: ProviderRequestInput) => Promise; stream: (input: ProviderRequestInput) => AsyncGenerator<{ chunk: string; }, { status: number; account: string; }, void>; getValidToken: (account?: string) => Promise; };