bet / src /engine /scoutPrompt.js
eznd's picture
Hydrogen high thinking with concurrency=2, UCL xG-mismatch fix, and Day/Week/Month/Interval history view
3365da7
Raw History Blame Contribute Delete
16.4 kB
/**
* Blind Data Scout prompts & strict JSON Schema for Gemini Interactions API
* (gemini-4-hydrogen + Google Search grounding, deep-research-preview-04-2026, and manual web import).
*/
export const SCOUT_JSON_SCHEMA = {
type: 'object',
properties: {
slateDate: { type: 'string' },
generatedAtEAT: { type: 'string' },
bookmaker: { type: 'string' },
matches: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string' },
espnEventId: { type: ['string', 'null'] },
espnLeague: { type: ['string', 'null'] },
kickoffEAT: { type: 'string' },
league: { type: 'string' },
tier: { type: 'integer' },
isReserveOrYouth: { type: 'boolean' },
isPostIntlBreak: { type: 'boolean' },
hasVerifiedTeamNews: { type: 'boolean' },
home: {
type: 'object',
properties: {
name: { type: 'string' },
gp: { type: 'integer' },
gf: { type: ['number', 'null'] },
ga: { type: ['number', 'null'] },
xg: { type: ['number', 'null'] },
xga: { type: ['number', 'null'] },
venueGfPerGame: { type: ['number', 'null'] },
venueGaPerGame: { type: ['number', 'null'] },
managerGamesInCharge: { type: 'integer' },
newManagerTightenedDefense: { type: 'boolean' },
confirmedOut: {
type: 'object',
properties: {
gk: { type: 'integer' },
startingCB: { type: 'integer' },
otherDef: { type: 'integer' },
mid: { type: 'integer' },
topScorer: { type: 'integer' },
otherAtt: { type: 'integer' },
names: { type: 'array', items: { type: 'string' } },
},
required: ['gk', 'startingCB', 'otherDef', 'mid', 'topScorer', 'otherAtt', 'names'],
},
doubts5050: {
type: 'object',
properties: {
gk: { type: 'integer' },
startingCB: { type: 'integer' },
otherDef: { type: 'integer' },
topScorer: { type: 'integer' },
otherAtt: { type: 'integer' },
names: { type: 'array', items: { type: 'string' } },
},
required: ['gk', 'startingCB', 'otherDef', 'topScorer', 'otherAtt', 'names'],
},
keyStartersToConfirm: { type: 'array', items: { type: 'string' } },
},
required: ['name', 'gp', 'managerGamesInCharge', 'newManagerTightenedDefense', 'confirmedOut', 'doubts5050'],
},
away: {
type: 'object',
properties: {
name: { type: 'string' },
gp: { type: 'integer' },
gf: { type: ['number', 'null'] },
ga: { type: ['number', 'null'] },
xg: { type: ['number', 'null'] },
xga: { type: ['number', 'null'] },
venueGfPerGame: { type: ['number', 'null'] },
venueGaPerGame: { type: ['number', 'null'] },
managerGamesInCharge: { type: 'integer' },
newManagerTightenedDefense: { type: 'boolean' },
confirmedOut: {
type: 'object',
properties: {
gk: { type: 'integer' },
startingCB: { type: 'integer' },
otherDef: { type: 'integer' },
mid: { type: 'integer' },
topScorer: { type: 'integer' },
otherAtt: { type: 'integer' },
names: { type: 'array', items: { type: 'string' } },
},
required: ['gk', 'startingCB', 'otherDef', 'mid', 'topScorer', 'otherAtt', 'names'],
},
doubts5050: {
type: 'object',
properties: {
gk: { type: 'integer' },
startingCB: { type: 'integer' },
otherDef: { type: 'integer' },
topScorer: { type: 'integer' },
otherAtt: { type: 'integer' },
names: { type: 'array', items: { type: 'string' } },
},
required: ['gk', 'startingCB', 'otherDef', 'topScorer', 'otherAtt', 'names'],
},
keyStartersToConfirm: { type: 'array', items: { type: 'string' } },
},
required: ['name', 'gp', 'managerGamesInCharge', 'newManagerTightenedDefense', 'confirmedOut', 'doubts5050'],
},
moneyline: {
type: 'object',
properties: {
home: { type: ['number', 'null'] },
draw: { type: ['number', 'null'] },
away: { type: ['number', 'null'] },
},
},
totals: {
type: 'object',
properties: {
'1.5': {
type: ['object', 'null'],
properties: {
over: { type: ['number', 'null'] },
under: { type: ['number', 'null'] },
sportybetOver: { type: ['number', 'null'] },
sportybetUnder: { type: ['number', 'null'] },
openOver: { type: ['number', 'null'] },
openUnder: { type: ['number', 'null'] },
simOverProb: { type: ['number', 'null'] },
simUnderProb: { type: ['number', 'null'] },
},
},
'2.5': {
type: ['object', 'null'],
properties: {
over: { type: ['number', 'null'] },
under: { type: ['number', 'null'] },
sportybetOver: { type: ['number', 'null'] },
sportybetUnder: { type: ['number', 'null'] },
openOver: { type: ['number', 'null'] },
openUnder: { type: ['number', 'null'] },
simOverProb: { type: ['number', 'null'] },
simUnderProb: { type: ['number', 'null'] },
},
},
'3.5': {
type: ['object', 'null'],
properties: {
over: { type: ['number', 'null'] },
under: { type: ['number', 'null'] },
sportybetOver: { type: ['number', 'null'] },
sportybetUnder: { type: ['number', 'null'] },
openOver: { type: ['number', 'null'] },
openUnder: { type: ['number', 'null'] },
simOverProb: { type: ['number', 'null'] },
simUnderProb: { type: ['number', 'null'] },
},
},
'4.5': {
type: ['object', 'null'],
properties: {
over: { type: ['number', 'null'] },
under: { type: ['number', 'null'] },
sportybetOver: { type: ['number', 'null'] },
sportybetUnder: { type: ['number', 'null'] },
openOver: { type: ['number', 'null'] },
openUnder: { type: ['number', 'null'] },
simOverProb: { type: ['number', 'null'] },
simUnderProb: { type: ['number', 'null'] },
},
},
},
},
weather: {
type: 'object',
properties: {
tempC: { type: 'number' },
windKmh: { type: 'number' },
precipType: { type: 'string', enum: ['none', 'drizzle', 'rain', 'snow'] },
},
required: ['tempC', 'windKmh', 'precipType'],
},
notes: { type: 'string' },
},
required: [
'id',
'kickoffEAT',
'league',
'tier',
'isReserveOrYouth',
'isPostIntlBreak',
'hasVerifiedTeamNews',
'home',
'away',
'moneyline',
'totals',
'weather',
],
},
},
},
required: ['slateDate', 'bookmaker', 'matches'],
};
const CORE_RULES = `ROLE: You are a football data scout ONLY. Do NOT pick a betting slip, do NOT calculate EV, do NOT invent custom probabilities, and do NOT recommend Overs or Unders. Your sole job is to gather accurate, verified pre-match data via live web search and return strictly valid JSON.
SEARCH BUDGET DISCIPLINE (IMPORTANT):
- Be fast and focused: run at most 2–4 concise Google searches per match (1 for mainstream Over/Under 1.5/2.5/3.5 & 1X2 odds, 1 for FotMob/FBref season stats + injuries/suspensions/lineup news, 1 for matchday weather if needed).
- Do NOT loop endlessly chasing optional fields (sportybetOver/Under, openOver/Under, OddAlerts sim probs) β€” populate them ONLY if readily visible, otherwise set them to null and move on.
DATA COLLECTION RULES (STRICT):
1. Odds (90-minute regular time ONLY): Collect decimal 1X2 moneyline odds AND two-way half-goal Over/Under consensus odds (from bet365, Pinnacle, Oddschecker, Oddsportal, Flashscore, Betway, SportyBet, or major bookmakers) under exact string keys "1.5", "2.5", "3.5", and "4.5" inside "totals" (NEVER include whole-number Asian lines like 2.0 or 3.0). Put mainstream consensus in "over" and "under"; optional "sportybetOver"/"sportybetUnder", "openOver"/"openUnder", and "simOverProb"/"simUnderProb" can be null if not immediately found.
2. Season xG & xGA (SAME-COMPETITION SAMPLE RULE β€” CRITICAL): Pull verified current-season gp, gf, ga, xg, and xga for both teams from FotMob / Understat / FBref. ALL FIVE numbers (gp, gf, ga, xg, xga) MUST come from the EXACT SAME competition and exact same games-played sample (gp). For UEFA Champions League, Europa League, Conference League, or domestic cup ties, pull each team's current DOMESTIC LEAGUE season totals (gp >= 8) for all five fields so gf/ga and xg/xga match 1-to-1 β€” NEVER mix 10–13 game domestic league gf/ga with 4-game European xg/xga. NEVER fabricate xG β€” use null only if genuinely unavailable on FotMob/FBref/Understat.
3. Confirmed Injuries, Suspensions & 50/50 Doubts: Cross-check FotMob, Sports Mole, WhoScored, and club team news. Count absent regular starters accurately by position:
- gk (0 or 1), startingCB, otherDef, mid, topScorer (#1/#2 scorer out), otherAtt.
Record 50/50 late fitness doubts separately under "doubts5050", and include exact player names in "names".
4. Manager Status: Record "managerGamesInCharge" (integer). Set "newManagerTightenedDefense": true ONLY if hired within the last 1-3 games AND already visibly tightened defense.
5. Honesty Check: Set "hasVerifiedTeamNews": true ONLY if you found actual current pre-match injury/team-news reporting for both teams. Otherwise set false.
6. Weather: Stadium kickoff forecast ("tempC", "windKmh", "precipType": "none" | "drizzle" | "rain" | "snow").
7. International Break: Set "isPostIntlBreak": true only if this is the first club fixture immediately following a FIFA international break.`;
const COMPACT_MATCH_EXAMPLE = `{
"id": "arsenal_dortmund",
"espnEventId": "401915380",
"espnLeague": "uefa.champions",
"kickoffEAT": "23:00 EAT",
"league": "UEFA Champions League",
"tier": 1,
"isReserveOrYouth": false,
"isPostIntlBreak": false,
"hasVerifiedTeamNews": true,
"home": {
"name": "Arsenal",
"gp": 12, "gf": 22, "ga": 10, "xg": 21.5, "xga": 11.2,
"venueGfPerGame": 2.0, "venueGaPerGame": 0.8,
"managerGamesInCharge": 100, "newManagerTightenedDefense": false,
"confirmedOut": { "gk": 0, "startingCB": 0, "otherDef": 0, "mid": 0, "topScorer": 0, "otherAtt": 0, "names": [] },
"doubts5050": { "gk": 0, "startingCB": 0, "otherDef": 0, "topScorer": 0, "otherAtt": 0, "names": [] },
"keyStartersToConfirm": ["Bukayo Saka"]
},
"away": {
"name": "Borussia Dortmund",
"gp": 12, "gf": 21, "ga": 15, "xg": 20.1, "xga": 14.8,
"venueGfPerGame": 1.6, "venueGaPerGame": 1.4,
"managerGamesInCharge": 30, "newManagerTightenedDefense": false,
"confirmedOut": { "gk": 0, "startingCB": 1, "otherDef": 0, "mid": 0, "topScorer": 0, "otherAtt": 0, "names": ["Nico Schlotterbeck"] },
"doubts5050": { "gk": 0, "startingCB": 0, "otherDef": 0, "topScorer": 0, "otherAtt": 0, "names": [] },
"keyStartersToConfirm": ["Serhou Guirassy"]
},
"moneyline": { "home": 1.65, "draw": 4.0, "away": 4.9 },
"totals": {
"1.5": { "over": 1.22, "under": 4.2, "sportybetOver": null, "sportybetUnder": null, "openOver": null, "openUnder": null, "simOverProb": null, "simUnderProb": null },
"2.5": { "over": 1.68, "under": 2.2, "sportybetOver": null, "sportybetUnder": null, "openOver": null, "openUnder": null, "simOverProb": null, "simUnderProb": null },
"3.5": { "over": 2.75, "under": 1.45, "sportybetOver": null, "sportybetUnder": null, "openOver": null, "openUnder": null, "simOverProb": null, "simUnderProb": null }
},
"weather": { "tempC": 9, "windKmh": 12, "precipType": "none" },
"notes": "Brief factual note."
}`;
export function buildHydrogenBatchPrompt(fixtures, windowInfo) {
const fixtureLines = fixtures
.map(
(f, idx) =>
`${idx + 1}. [espnEventId=${f.eventId} | espnLeague=${f.league} | tier=${f.tier}] ${f.homeTeam} vs ${f.awayTeam} β€” ${f.leagueName} β€” Kickoff: ${f.kickoffEAT}`
)
.join('\n');
return `${CORE_RULES}
TODAY'S DATE & SLATE WINDOW (EAT / UTC+3):
- Date: ${windowInfo.slateDate}
- Scout time: ${windowInfo.generatedAtEAT}
- Finish deadline: Matches ending no later than ${windowInfo.finishDeadlineEAT}
- Bookmaker target: SportyBet TZ
EXACT FIXTURES TO RESEARCH IN THIS BATCH (preserve espnEventId and espnLeague verbatim):
${fixtureLines}
EXACT REQUIRED MATCH OBJECT SHAPE:
${COMPACT_MATCH_EXAMPLE}
OUTPUT REQUIREMENT:
Return ONLY ONE valid \`\`\`json code block containing { "slateDate": "${windowInfo.slateDate}", "generatedAtEAT": "${windowInfo.generatedAtEAT}", "bookmaker": "SportyBet TZ", "matches": [ ... ] } with every fixture listed above. Use exact string keys "1.5", "2.5", "3.5", "4.5" inside "totals". Do not fabricate odds or xG; use null where verified data is absent and set hasVerifiedTeamNews: false if team news could not be verified.`;
}
export function buildDeepResearchPrompt(fixtures, windowInfo) {
const fixtureSection =
fixtures && fixtures.length > 0
? `SHORTLISTED FIXTURES FROM ESPN (${fixtures.length} matches, preserve espnEventId & espnLeague verbatim):\n` +
fixtures
.map(
(f, idx) =>
`${idx + 1}. [espnEventId=${f.eventId} | espnLeague=${f.league} | tier=${f.tier}] ${f.homeTeam} vs ${f.awayTeam} β€” ${f.leagueName} β€” Kickoff: ${f.kickoffEAT}`
)
.join('\n')
: `Discover 10 to 25 of the most liquid senior Tier-1 and reputable senior Tier-2 European/International matches starting at least 75 minutes after ${windowInfo.generatedAtEAT} and finishing no later than ${windowInfo.finishDeadlineEAT}. Exclude youth/U19/U21/reserve teams.`;
return `${CORE_RULES}
SLATE WINDOW (EAT / UTC+3):
- Slate date: ${windowInfo.slateDate}
- Scout time: ${windowInfo.generatedAtEAT}
- Window: Starting >= ${windowInfo.minLeadMinutes} min from now, finishing no later than ${windowInfo.finishDeadlineEAT}
- Bookmaker: SportyBet TZ
${fixtureSection}
OUTPUT REQUIREMENT:
Return ONLY ONE valid \`\`\`json code block matching { "slateDate", "generatedAtEAT", "bookmaker": "SportyBet TZ", "matches": [ { "id", "espnEventId", "espnLeague", "kickoffEAT", "league", "tier", "isReserveOrYouth", "isPostIntlBreak", "hasVerifiedTeamNews", "home": { "name", "gp", "gf", "ga", "xg", "xga", "venueGfPerGame", "venueGaPerGame", "managerGamesInCharge", "newManagerTightenedDefense", "confirmedOut": { "gk", "startingCB", "otherDef", "mid", "topScorer", "otherAtt", "names" }, "doubts5050": { "gk", "startingCB", "otherDef", "topScorer", "otherAtt", "names" }, "keyStartersToConfirm" }, "away": { ... }, "moneyline": { "home", "draw", "away" }, "totals": { "1.5": { "over", "under", "sportybetOver", "sportybetUnder", "openOver", "openUnder", "simOverProb", "simUnderProb" }, "2.5": {...}, "3.5": {...}, "4.5": {...} }, "weather": { "tempC", "windKmh", "precipType" }, "notes" } ] }.`;
}