lib
Trainer types
Wire types for the ranges API as the trainer reads it: games, positions, nodes, actions and hand classes.
Installation
$ npx shadcn@latest add https://www.pokerstudy.ai/r/trainer-types.jsonSource
lib/trainer/types.ts
/**
* Wire types for the ranges API as the trainer consumes it.
*
* Ported from the mobile app (`mobile/src/lib/api/types.ts`) — the trainer UI
* that used to live only in Expo now runs here too, and both clients read the
* same `/api/ranges/*` payloads. Keep the two in sync.
*/
export type Game = "nl" | "plo" | "plo6hu" | "plo5";
export type Position = "UTG" | "MP" | "LJ" | "HJ" | "CO" | "BTN" | "SB" | "BB";
export type ActionKind = "fold" | "call" | "raise" | "allin" | "other";
/** NL: a 169-grid class ("AKs"). PLO: a MonkerSolver hand string ("(KA)(KA)"). */
export type HandClass = string;
export interface Manifest {
game: Game;
generatedAt: string;
bundleCount: number;
stacks: number[];
positions: Position[];
}
export interface NodeAction {
action: string;
kind: ActionKind;
/** hand → frequency in [0, 1] for this action. */
weights: Record<HandClass, number>;
// NL-only
sizePct?: number;
combos?: number;
// PLO-only
raiseDepth?: number;
sizeCode?: number;
hands?: number;
/**
* hand → EV in small blinds. Present for PLO, and for NL via the v2 bundles
* (`/api/ranges/nl/v2/*`). Only hands that actually take this action are
* keyed — an unplayed action carries no EV for the hand, which is why
* `gradeAction` has an estimated-basis fallback.
*/
evs?: Record<HandClass, number>;
/**
* hand → the export's EV source tag, keyed only where the EV is an estimate
* (HydraSolver PLO5, and NLH via `/api/ranges/nlh8-hydra`). An exact EV has no entry.
*/
evSources?: Record<HandClass, string>;
/**
* hand → standard error of that hand's estimated EV, in big blinds. When it
* is above `EV_UNCERTAIN_STDERR_BB` the grader ignores the EV.
*/
evStdErrs?: Record<HandClass, number>;
}
export interface NodeResponse {
game: Game;
stack: number;
history: string;
actor: Position;
actions: NodeAction[];
/** NL: weighted combos continuing. */
continuingCombos?: number;
/** PLO: count of hand classes continuing. */
continuingHands?: number;
hand?: HandClass;
strategy?: Record<string, number>;
}
export interface SpotIndexEntry {
history: string;
depth: 1 | 2 | 3 | 4;
}
export interface SpotIndex {
game: Game;
stack: number;
generatedAt: string;
spots: SpotIndexEntry[];
}