범인찾기 v1.3.2: 외부 전적 사이트 접속 제거 — OP.GG · LOL.PS 는 계산법만 참고
- 사용자 결정: 실제 OP.GG 연결이 아니라 계산법 참고 → 분석 때 OP.GG 를 찾아보던 opgg.ts · 결과의 OP.GG 점수 · 조회 상태 · 지시문 줄 · Riot 태그/경기 찾기 정보 제거 - 남은 것: 기록 점수(OP.GG OP스코어 계산법, 앱이 경기 기록으로 계산) · 10/15분 라인전(LOL.PS 정의) - 실제 E2E (Claude Opus 5.5 high, 외부 접속 없음): 발로란트 33초 $0.138, 롤 36초 $0.123 - 테스트: 앱 40 · 서버 16 통과 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,119 +1,53 @@
|
||||
// 범인찾기 실제 E2E: 실제 앱 코어 + 실제 사이트 서버 + 실제 Claude API(Opus 5.5, 생각 high) + 실제 OP.GG MCP + 헤드리스 브라우저.
|
||||
// 1) 발로란트 시연 경기 (22라운드 · 대화) → OP.GG 에 없는 경기 → 기록 점수만으로 분석
|
||||
// 2) 롤: OP.GG 에서 받은 실제 랭크 경기(10명 실제 스탯)에 우리 팀 2명의 대화를 붙인 경기 → OP.GG 실제 OP스코어를 찾아 같이 분석
|
||||
// 비용이 든다 (경기당 약 $0.4). API 키는 secrets.json 에서 읽어 이 프로세스 안에서만 쓴다.
|
||||
// 범인찾기 실제 E2E: 실제 앱 코어 + 실제 사이트 서버 + 실제 Claude API(Opus 5.5, 생각 high) + 헤드리스 브라우저.
|
||||
// 외부 전적 사이트에는 접속하지 않는다 (기록 점수는 OP.GG 계산법을 따라 경기 기록으로 계산).
|
||||
// 1) 발로란트 시연 경기 (22라운드 · 대화) 2) 롤 시연 경기 (10 · 15분 라인전 · 대화)
|
||||
// 비용이 든다 (경기당 약 $0.1~0.4). API 키는 secrets.json 에서 읽어 이 프로세스 안에서만 쓴다.
|
||||
// node --import tsx scripts/culprit-real-e2e.mts [결과 폴더]
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import type { CulpritInput, CulpritMatchInfo, MatchPlayer } from '@gvr/shared';
|
||||
import type { CulpritInput, CulpritMatchInfo } from '@gvr/shared';
|
||||
import { makeDemoLol } from '../test/fixtures/demo-matches.ts';
|
||||
import { culpritApi, MIN, seedValorant, setup } from '../test/fixtures/culprit-seed.ts';
|
||||
|
||||
const outDir = process.argv[2] || path.join(os.homedir(), '.tmp', 'culprit-real');
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
const root = path.resolve(import.meta.dirname, '..', '..');
|
||||
const apiKey = JSON.parse(fs.readFileSync(path.join(os.homedir(), '.config/ejclaw/secrets.json'), 'utf8')).credentials['anthropic.api/game-voice-recorder'].token as string;
|
||||
const { opggCaller } = await import('../../site/server/src/opgg.ts');
|
||||
const opgg = opggCaller();
|
||||
|
||||
const core = setup();
|
||||
await core.assets.refresh(true).catch(() => undefined);
|
||||
const { id: valId } = seedValorant(core);
|
||||
|
||||
// ---------------------------------------------------------------- 롤: OP.GG 의 실제 랭크 경기
|
||||
const POS: Record<string, string> = { TOP: '탑', JUNGLE: '정글', MID: '미드', ADC: '원딜', SUPPORT: '서폿' };
|
||||
const listOf = async (name: string, tag: string) =>
|
||||
((await opgg('lol_list_summoner_matches', { game_name: name, tag_line: tag, region: 'KR', limit: 10, desired_output_fields: ['data.game_history[].{created_at,game_length_second,game_type,id}'] })) as any).data.game_history as any[];
|
||||
const detailOf = async (g: any) =>
|
||||
((await opgg('lol_get_summoner_game_detail', {
|
||||
region: 'KR',
|
||||
game_id: g.id,
|
||||
created_at: g.created_at,
|
||||
desired_output_fields: [
|
||||
'data.game_detail.teams[].participants[].stats.{assist,champion_level,death,gold_earned,kill,minion_kill,neutral_minion_kill,op_score,time_ccing_others,total_damage_dealt_to_champions,total_damage_taken,vision_wards_bought_in_game,ward_place}',
|
||||
'data.game_detail.teams[].participants[].{position,team_key,champion_id,champion_name}',
|
||||
'data.game_detail.teams[].participants[].summoner.{puuid,game_name,tagline,player}',
|
||||
'data.game_detail.teams[].game_stat.{champion_kill,is_win}',
|
||||
],
|
||||
})) as any).data.game_detail;
|
||||
// 프로 선수가 아닌 사람의 최근 솔로 랭크 (15분 이상)
|
||||
const seedGame = (await listOf('Hide on bush', 'KR1')).find((g) => g.game_type === 'SOLORANKED')!;
|
||||
const seedDet = await detailOf(seedGame);
|
||||
const pick = seedDet.teams.flatMap((t: any) => t.participants).find((p: any) => !p.summoner.player && p.summoner.game_name !== 'Hide on bush');
|
||||
const g = (await listOf(pick.summoner.game_name, pick.summoner.tagline)).find((x) => x.game_type === 'SOLORANKED' && x.game_length_second > 1200)!;
|
||||
const det = await detailOf(g);
|
||||
const all = det.teams.flatMap((t: any) => t.participants.map((p: any) => ({ ...p, win: t.game_stat.is_win, teamKills: t.game_stat.champion_kill })));
|
||||
const selfP = all.find((p: any) => p.summoner.puuid === pick.summoner.puuid) ?? all[0];
|
||||
const opggTruth = new Map<string, number>(all.map((p: any) => [p.summoner.puuid, p.stats.op_score]));
|
||||
const players: MatchPlayer[] = all.map((p: any) => ({
|
||||
puuid: p.summoner.puuid,
|
||||
name: p.summoner.game_name,
|
||||
tag: p.summoner.tagline,
|
||||
team: p.team_key,
|
||||
ally: p.team_key === selfP.team_key,
|
||||
character: { id: String(p.champion_id), name: p.champion_name, icon: null },
|
||||
kills: p.stats.kill,
|
||||
deaths: p.stats.death,
|
||||
assists: p.stats.assist,
|
||||
cs: (p.stats.minion_kill ?? 0) + (p.stats.neutral_minion_kill ?? 0),
|
||||
gold: p.stats.gold_earned,
|
||||
level: p.stats.champion_level,
|
||||
stats: {
|
||||
role: POS[p.position],
|
||||
damage: p.stats.total_damage_dealt_to_champions,
|
||||
damageTaken: p.stats.total_damage_taken,
|
||||
ccSeconds: p.stats.time_ccing_others ?? 0,
|
||||
wardsPlaced: p.stats.ward_place ?? 0,
|
||||
controlWards: p.stats.vision_wards_bought_in_game ?? 0,
|
||||
},
|
||||
}));
|
||||
const LS = Date.parse(g.created_at) + 60000;
|
||||
const LEN = g.game_length_second * 1000;
|
||||
const allyWin = !!selfP.win;
|
||||
const allyKills = all.filter((p: any) => p.team_key === selfP.team_key)[0].teamKills;
|
||||
const enemyKills = all.filter((p: any) => p.team_key !== selfP.team_key)[0].teamKills;
|
||||
const lolId = `lol-${g.id.replace(/[^\w]/g, '').slice(0, 20)}`;
|
||||
core.store.upsertMatch({
|
||||
id: lolId,
|
||||
game: 'lol',
|
||||
started_at: LS,
|
||||
ended_at: LS + LEN,
|
||||
status: 'complete',
|
||||
map: 'Map11',
|
||||
mode: 'CLASSIC',
|
||||
queue: '420',
|
||||
result: JSON.stringify({ win: allyWin, score: { ally: allyKills, enemy: enemyKills } }),
|
||||
detail: JSON.stringify({ live: false, players, goldDiff: [], self: selfP.summoner.puuid }),
|
||||
});
|
||||
// 우리 팀 두 명이 음성채널에 있었다고 하고 대화를 붙인다 (실제 경기 기록 + 시험용 대화)
|
||||
const mates = players.filter((p) => p.ally);
|
||||
const [a, b] = [mates.find((p) => p.puuid === selfP.summoner.puuid)!, mates.find((p) => p.puuid !== selfP.summoner.puuid)!];
|
||||
core.store.upsertUser({ id: 'ua', name: '승한', avatar: null });
|
||||
core.store.upsertUser({ id: 'ub', name: '민수', avatar: null });
|
||||
core.store.setAccounts('ua', [{ puuid: a.puuid, riotId: `${a.name}#${a.tag}` }]);
|
||||
core.store.setAccounts('ub', [{ puuid: b.puuid, riotId: `${b.name}#${b.tag}` }]);
|
||||
// ---------------------------------------------------------------- 롤 시연 경기 + 우리 팀 2명 대화
|
||||
const LS = Date.now() - 80 * MIN;
|
||||
const lol = makeDemoLol();
|
||||
const lolId = 'lol-demo';
|
||||
core.store.setMeta('riot_self_puuid', 'l-sh');
|
||||
core.store.setAccounts('u1', [{ puuid: 'p-sh', riotId: '승한#V' }, { puuid: 'l-sh', riotId: '승한#L' }]);
|
||||
core.store.setAccounts('u2', [{ puuid: 'p-ms', riotId: '민수#V' }, { puuid: 'l-ms', riotId: '민수#L' }]);
|
||||
core.store.startSession('s-lol', 'g', 'c', '음성', LS - MIN);
|
||||
core.games.matchStarted({ id: lolId, game: 'lol', startedAt: LS, map: 'Map11', mode: 'CLASSIC', queue: '420', detail: { live: true } });
|
||||
core.games.matchEnded(lolId, LS + lol.durationMs);
|
||||
(core.games.adapters[1] as any).applyHistory(lolId, lol.game, lol.timeline, LS);
|
||||
const talk: [string, number, string][] = [
|
||||
['ua', 2.5, '정글 위쪽에서 시작했어 바텀 조심해'],
|
||||
['ub', 6.2, '용 앞에 와드 박아 줘 시야 없어'],
|
||||
['ua', 6.5, '알았어 지금 갈게'],
|
||||
['ub', 11.0, '미드 미아 미드 미아 내려간다'],
|
||||
['ua', 14.8, '용 한타 열지 마 아직 우리 텔 없어'],
|
||||
['ub', 15.1, '아 들어갔다 아 죽었다 미안'],
|
||||
['ua', 19.5, '바론 시야 먼저 잡고 하자 혼자 가지 마'],
|
||||
['ub', 24.0, allyWin ? '좋아 한타 이겼다 미드 밀자' : '아 또 잡혔네 이거 그냥 서렌 치자'],
|
||||
['ua', 24.3, allyWin ? '억제기 깨고 바로 빠지자' : '아직 안 끝났어 수비하자'],
|
||||
['u1', 2.5, '정글 위쪽에서 시작했어 바텀 조심해'],
|
||||
['u2', 6.2, '용 앞에 와드 박아 줘 시야 없어'],
|
||||
['u1', 8.1, '용 같이 하자 바텀 밀었어'],
|
||||
['u2', 8.3, '아니 탑 갱 각이야 잠깐만'],
|
||||
['u1', 14.8, '용 한타 열지 마 아직 우리 텔 없어'],
|
||||
['u2', 15.1, '아 들어갔다 아 죽었다 미안'],
|
||||
['u1', 19.5, '바론 시야 먼저 잡고 하자 혼자 가지 마'],
|
||||
];
|
||||
for (const [uid, min, text] of talk) {
|
||||
if (min * MIN > LEN) continue;
|
||||
const ts = LS + min * MIN;
|
||||
const id = `lol-${uid}-${min}`;
|
||||
core.store.insertUtterance({ id, session_id: 's-lol', user_id: uid, started_at: ts, ended_at: ts + 1800, audio_path: null, match_id: lolId });
|
||||
core.store.updateUtteranceResult(id, { text, raw_text: text, words: [], noise: false, noise_reason: null, confidence: 0.9, lufs: -20, gain_db: 0, model: 'large-v3', status: 'precise' });
|
||||
}
|
||||
core.store.endSession('s-lol', LS + LEN + MIN);
|
||||
core.store.endSession('s-lol', LS + lol.durationMs + MIN);
|
||||
|
||||
// ---------------------------------------------------------------- 사이트 서버 (실제 Claude · 실제 OP.GG)
|
||||
// ---------------------------------------------------------------- 사이트 서버 (실제 Claude)
|
||||
const local = await culpritApi(core);
|
||||
const { buildServer } = await import('../../site/server/src/app.ts');
|
||||
const port = 18961;
|
||||
@@ -121,7 +55,7 @@ const site = await buildServer({
|
||||
port, host: '127.0.0.1', publicUrl: `http://127.0.0.1:${port}`, clientId: 'x', clientSecret: 'x', botToken: 'x', allowedGuilds: [], owners: ['u1'], superAdmins: ['u1'],
|
||||
sessionSecret: 'real-e2e-secret-'.repeat(3), dataDir: fs.mkdtempSync(path.join(os.tmpdir(), 'gvr-real-')), webDir: path.join(root, 'site', 'web', 'dist'), version: 't', discordApi: 'http://127.0.0.1:1',
|
||||
assetUpstream: { valmedia: 'https://media.valorant-api.com/', ddragon: 'https://ddragon.leagueoflegends.com/', cdragon: 'https://raw.communitydragon.org/' },
|
||||
culprit: { apiKey, model: 'claude-opus-5-5', effort: 'high', monthLimitUsd: 100, dailyLimit: 20, tone: 'medium', opgg: true },
|
||||
culprit: { apiKey, model: 'claude-opus-5-5', effort: 'high', monthLimitUsd: 100, dailyLimit: 20, tone: 'medium' },
|
||||
});
|
||||
site.app.log.level = 'info';
|
||||
await site.app.listen({ host: '127.0.0.1', port });
|
||||
@@ -171,9 +105,9 @@ for (const id of [valId, lolId]) {
|
||||
const ref = (pid: string) => a.players.find((p) => p.id === pid)!;
|
||||
const rows = a.result.players.map((p) => {
|
||||
const pl = ref(p.id);
|
||||
return { id: p.id, team: pl.team, ai: p.score, rating: pl.rating?.score ?? null, opgg: pl.opgg?.score ?? null, truth: opggTruth.get(pl.puuid) ?? null, tag: p.tag, comment: p.comment };
|
||||
return { id: p.id, team: pl.team, ai: p.score, rating: pl.rating?.score ?? null, lane: pl.rating?.lane ?? null, tag: p.tag, comment: p.comment };
|
||||
});
|
||||
const teamLowest = (team: string, key: 'rating' | 'opgg') => {
|
||||
const teamLowest = (team: string, key: 'rating') => {
|
||||
const ps = rows.filter((r) => r.team === team && r[key] !== null);
|
||||
return ps.length ? ps.reduce((x, y) => ((x[key] as number) <= (y[key] as number) ? x : y)).id : null;
|
||||
};
|
||||
@@ -182,11 +116,10 @@ for (const id of [valId, lolId]) {
|
||||
model: a.model,
|
||||
costUsd: a.meta.costUsd,
|
||||
usage: a.meta.usage,
|
||||
opgg: a.meta.opgg,
|
||||
stages: stages[id],
|
||||
summary: a.result.summary,
|
||||
confidence: a.result.confidence,
|
||||
culprits: a.result.teams.map((t) => ({ team: t.team, culprit: t.culprit, reason: t.reason, evidence: t.evidence.map((e) => e.ref), lowestRating: teamLowest(t.team, 'rating'), lowestOpgg: teamLowest(t.team, 'opgg') })),
|
||||
culprits: a.result.teams.map((t) => ({ team: t.team, culprit: t.culprit, reason: t.reason, evidence: t.evidence.map((e) => e.ref), lowestRating: teamLowest(t.team, 'rating') })),
|
||||
players: rows,
|
||||
};
|
||||
console.log(JSON.stringify(report[id], null, 1));
|
||||
|
||||
@@ -60,13 +60,6 @@ const site = await buildServer(
|
||||
},
|
||||
{
|
||||
culpritKnowledge: new KnowledgeAuto(async () => { throw new Error('offline'); }),
|
||||
// OP.GG: 발로란트 시연 경기는 "찾음"(가짜 점수), 롤 시연 경기는 "없음"
|
||||
culpritOpgg: async (name: string, args: any) => {
|
||||
if (name !== 'valorant_list_player_matches') return {};
|
||||
const input = (await local.inject({ url: `/api/culprit/internal/${valId}/input`, headers: { 'x-gvr-internal': '1' } })).json().input as CulpritInput;
|
||||
const p = input.players.find((x) => x.name === args.game_name)!;
|
||||
return [{ matchId: 'demo', puuid: p.puuid, opScore: Math.round((p.rating?.score ?? 5) * 100 + 30) }];
|
||||
},
|
||||
culpritCall: async (req) => {
|
||||
await new Promise((r) => setTimeout(r, 2500));
|
||||
const isVal = req.user.includes('# 경기 발로란트');
|
||||
|
||||
Reference in New Issue
Block a user