// AT Protocol record types (mirrored from checkmate.blue) export interface TimeControl { type: 'untimed' | 'correspondence' | 'clock'; initialSeconds?: number; incrementSeconds?: number; moveTimeLimitSeconds?: number; } export interface GameRecord { $type: 'blue.checkmate.game'; pgn: string; createdAt: string; white?: string; black?: string; status: 'waiting' | 'active' | 'completed' | 'abandoned'; result?: '1-0' | '0-1' | '1/2-1/2'; resultReason?: 'checkmate' | 'resignation' | 'agreement' | 'stalemate' | 'insufficient' | 'repetition' | 'fifty_moves' | 'abandonment'; lastMoveAt?: string; parentGameUri?: string; drawOffered?: boolean; variant?: 'standard' | 'really-bad-chess' | 'chess960'; timeControl?: TimeControl; moveTimes?: number[]; } export interface ChallengeRecord { $type: 'blue.checkmate.challenge'; createdAt: string; opponent?: string; gameUri?: string; status: 'open' | 'accepted' | 'expired' | 'cancelled'; challengerColor?: 'white' | 'black'; variant?: 'standard' | 'really-bad-chess' | 'chess960'; } export type PlayerColor = 'white' | 'black'; export function extractFenFromPgn(pgn: string): string | undefined { const match = pgn.match(/\[FEN\s+"([^"]+)"\]/); return match?.[1]; } // Jetstream event types export interface JetstreamCommit { operation: 'create' | 'update' | 'delete'; collection: string; rkey: string; record?: Record; cid?: string; } export interface JetstreamEvent { kind: 'commit'; did: string; time_us: number; commit: JetstreamCommit; } // Config types export interface BotAccountConfig { handle: string; did: string; appPassword: string; } export interface EngineConfig extends BotAccountConfig { id: string; depth: number; skillLevel?: number; delayRange: [number, number]; maxConcurrentGames: number; } export interface AppConfig { bot: BotAccountConfig; engines: EngineConfig[]; mysql: { host: string; port: number; user: string; password: string; database: string; }; jetstream: { url: string; }; stockfish: { path: string; }; api: { port: number; }; posting: { minMoves: number; rateLimitMs: number; perPairCooldownHours: number; perPlayerMaxPostsPerDay: number; dryRun: boolean; }; games: { autoResignHours: number; }; logging: { level: string; file: string; }; }