Something went wrong. Try again.
The atchess bot. Monitors the firehose, indexes games, plays via Stockfish.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111// 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<string, unknown>; 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; };}