범인찾기 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:
EJClaw
2026-10-15 16:11:53 +09:00
parent 2ddba2e4e5
commit b8e76aba25
17 changed files with 88 additions and 600 deletions

4
app/package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "gvr-app",
"version": "1.3.1",
"version": "1.3.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gvr-app",
"version": "1.3.1",
"version": "1.3.2",
"license": "UNLICENSED",
"dependencies": {
"@discordjs/voice": "^0.19.2",

View File

@@ -1,7 +1,7 @@
{
"name": "gvr-app",
"productName": "겜녹이",
"version": "1.3.1",
"version": "1.3.2",
"description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록",
"private": true,
"main": "dist/main.cjs",

View File

@@ -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));

View File

@@ -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('# 경기 발로란트');

View File

@@ -173,7 +173,6 @@ export class Culprit {
character: p.character ?? null,
userId: userId ?? null,
voice: !!userId && speakers.has(userId),
...(p.tag ? { tag: p.tag } : {}),
...(ratings.get(p.puuid) ? { rating: ratings.get(p.puuid) } : {}),
hasExtraStats: !!p.stats,
};
@@ -334,12 +333,6 @@ export class Culprit {
refs,
players: players.map(({ hasExtraStats: _x, ...p }) => p),
stats: { utterances: utts.length, utterancesTotal: totalUtts, events: ei, chats: ci, rounds: rounds.length, basic },
lookup: {
riotMatchId: m.id.replace(/^(val|lol)-/, '') || null,
startedAt: realStart(m),
endedAt: m.ended_at ?? realStart(m),
durationSec: Math.round(((m.ended_at ?? realStart(m)) - realStart(m)) / 1000),
},
};
}
}
@@ -364,8 +357,8 @@ function ratingLines(game: string, players: CulpritPlayer[]): string[] {
if (!players.some((p) => p.rating)) return [];
const head =
game === 'valorant'
? '# 기록 점수 (0~10, OP.GG OP스코어 방식: 라운드 승률 · KAST · ACS · 피해 격차를 실제 OP.GG 점수에 맞춘 계산. 경기 순위/팀 순위, 경기 평균보다 점수를 올린 강점 · 깎은 약점)'
: '# 기록 점수 (0~10, OP.GG OP스코어 방식: 킬 관여 · 데스 · 딜/받은 피해 · 골드 · CS · 레벨 · CC · 와드를 실제 OP.GG 점수에 맞춘 계산. 경기 순위/팀 순위, 경기 평균보다 점수를 올린 강점 · 깎은 약점, 라인전 = LOL.PS 라인전 점수의 입력인 10 · 15분 맞라이너와의 CS · 골드 · 경험치 차)';
? '# 기록 점수 (0~10, OP.GG OP스코어 계산법: 라운드 승률 · KAST · ACS · 피해 격차로 계산. 경기 순위/팀 순위, 경기 평균보다 점수를 올린 강점 · 깎은 약점)'
: '# 기록 점수 (0~10, OP.GG OP스코어 계산법: 역할 · 킬 관여 · 데스 · 딜/받은 피해/골드 비중 · CS · 레벨 · CC · 와드로 계산. 경기 순위/팀 순위, 경기 평균보다 점수를 올린 강점 · 깎은 약점, 라인전 = LOL.PS 라인전 점수의 입력인 10 · 15분 맞라이너와의 CS · 골드 · 경험치 차)';
const out = [head];
if (players.some((p) => p.rating?.basic)) out.push('# (추가 지표가 없어 K/D/A · 골드 · CS 같은 기본 기록으로만 낸 점수다)');
const idOf = new Map(players.map((p) => [p.puuid, p.id]));

View File

@@ -56,8 +56,8 @@ test('범인찾기: 분석 가능 판정과 AI 자료', () => {
// 우리 팀이 P1~P5, 승한은 음성O, 디스코드 계정이 없는 상대는 음성X
const p1 = lines.find((l) => l.startsWith('P1 '))!;
assert.match(p1, /^P1 승한 우리 제트\(타격대\) \d+\/\d+\/\d+ ACS\d+ ADR\d+ KAST\d+% 피해격차[+-]\d+ 첫킬\d+\/첫데스\d+ HS\d+% 설치\d+\/해체\d+ .*음성O$/);
// 기록 점수 (OP.GG OP스코어 방식): 10명 모두, 이긴 팀 1등 MVP · 진 팀 1등 ACE
const head = lines.findIndex((l) => l.startsWith('# 기록 점수 (0~10, OP.GG OP스코어 방식'));
// 기록 점수 (OP.GG OP스코어 계산법): 10명 모두, 이긴 팀 1등 MVP · 진 팀 1등 ACE
const head = lines.findIndex((l) => l.startsWith('# 기록 점수 (0~10, OP.GG OP스코어 계산법'));
assert.ok(head > 0, '기록 점수 칸');
const rl = lines.slice(head + 1, head + 11);
assert.ok(rl.every((l, i) => new RegExp(`^P${i + 1} \\d+\\.\\d점 \\d+위/팀\\d위`).test(l)), rl.join('\n'));
@@ -68,7 +68,6 @@ test('범인찾기: 분석 가능 판정과 AI 자료', () => {
assert.ok(rp.every((r) => r && r.score >= 0 && r.score <= 10 && !r.basic));
assert.deepEqual(rp.map((r) => r.rank).sort((a, b) => a - b), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
assert.equal(rp.find((r) => r.rank === 1)!.score, Math.max(...rp.map((r) => r.score)));
assert.equal(input.lookup?.riotMatchId, 'demo');
assert.match(lines.find((l) => l.startsWith('P6 '))!, /상대 .*음성X$/);
assert.equal(input.players.find((p) => p.id === 'P2')!.voice, true, '민수는 대화가 있다');
assert.equal(input.players.find((p) => p.id === 'P3')!.voice, false);
@@ -139,7 +138,7 @@ test('범인찾기: 롤 포지션 · 시야 · 10/15분 지표와 골드 차', (
assert.match(input.text, /\n\[e\d+\] \d+:\d+ 킬 P\d+ → P\d+/);
assert.match(input.text, /\n\[e\d+\] \d+:\d+ 내셔 남작 처치 우리 팀 · P2\n/);
// 기록 점수 + LOL.PS 라인전 점수의 입력 (10 · 15분 맞라이너와 차)
assert.match(input.text, /\n# 기록 점수 \(0~10, OP\.GG OP스코어 방식/);
assert.match(input.text, /\n# 기록 점수 \(0~10, OP\.GG OP스코어 계산법/);
assert.match(input.text, /\nP1 \d+\.\d점 \d+위\/팀\d위.* · 라인전\(vs P6\) 10분 CS[+-][\d,]+ 골드[+-][\d,]+ 경험치[+-][\d,]+ 15분 CS[+-][\d,]+ 골드[+-][\d,]+ 경험치[+-][\d,]+\n/);
const p1 = input.players.find((p) => p.id === 'P1')!;
const p6 = input.players.find((p) => p.id === 'P6')!;
@@ -147,7 +146,6 @@ test('범인찾기: 롤 포지션 · 시야 · 10/15분 지표와 골드 차', (
assert.equal(p1.rating!.lane!.at10!.xp, -p6.rating!.lane!.at10!.xp);
assert.ok(p1.rating!.lane!.at10!.cs !== undefined && p1.rating!.lane!.at15!.gold !== undefined);
assert.equal(input.players.filter((p) => p.rating?.badge).length, 2);
assert.equal(p1.tag !== undefined, true);
});
test('범인찾기 API: 목록 · 상세 · 내부 전용 경로', async () => {