- POST /api/culprit/matches/:id/analyze: 등록된 앱 유저 이상(다시 분석은 관리자), 월 $100 · 하루 20회 · 중복 잠금 - Claude Opus 5.5 (생각 high, 구조화 출력, 출력 32k 상한, 거절 시 서버 측 fallback), 지시문 + 게임별 지식 묶음(자동 갱신 칸은 공식 데이터로 하루 한 번) - 결과 확인: 10명 · 0.5 단위 점수 · 태그 · 팀마다 범인 1명(팀 최저점) · 없는 근거 번호 제거, 범인 근거가 안 맞으면 한 번 다시 - 비용 장부(culprit-ledger.json)는 토큰 · 비용만, 진행 단계는 실시간 알림(culprit.progress) - 지시문 v1.1: 범인 = 가장 못함 + 가장 발목 + 결과의 원인 종합 판단, 자료 약어 설명 추가 - 배포: Dockerfile 에 prompt/ 복사, ANTHROPIC_API_KEY 넣는 스크립트 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
4.2 KiB
TypeScript
93 lines
4.2 KiB
TypeScript
// 범인찾기 테스트용: 앱 코어 일부(기록 DB · 타임라인 · 게임 관리 · 범인찾기)와 시연 경기 (앱 · 사이트 서버 테스트가 같이 쓴다)
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { Store } from '../../src/core/db/db.ts';
|
|
import { Timeline } from '../../src/core/timeline.ts';
|
|
import { GameAssets } from '../../src/core/games/assets.ts';
|
|
import { GameManager } from '../../src/core/games/manager.ts';
|
|
import { Culprit } from '../../src/core/culprit.ts';
|
|
import { buildApi } from '../../src/core/api/server.ts';
|
|
import { Bus } from '../../src/core/util/events.ts';
|
|
import { makeDemoValorant, AGENT } from './demo-matches.ts';
|
|
|
|
export const MIN = 60000;
|
|
|
|
export function setup() {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gvr-culprit-'));
|
|
const store = new Store(path.join(dir, 'db.sqlite'));
|
|
const timeline = new Timeline(store);
|
|
const assets = new GameAssets(path.join(dir, 'cache'));
|
|
// 네트워크 없이: 요원 이름 · 역할만 넣어 둔다
|
|
assets.val = {
|
|
at: Date.now(),
|
|
agents: {
|
|
[AGENT.jett]: { name: '제트', icon: '', role: '타격대', abilities: {} },
|
|
[AGENT.sage]: { name: '세이지', icon: '', role: '감시자', abilities: {} },
|
|
},
|
|
maps: {},
|
|
weapons: {},
|
|
tiers: {},
|
|
modes: {},
|
|
clientVersion: null,
|
|
} as any;
|
|
const bus = new Bus();
|
|
const stt: any = { onMatchStart: async () => undefined, onMatchEnd: async () => undefined };
|
|
const worker: any = { on: () => undefined, off: () => undefined };
|
|
const games = new GameManager(store, assets, worker, stt, timeline, bus, () => ({}) as any, () => null);
|
|
const culprit = new Culprit(store, timeline, games);
|
|
return { dir, store, timeline, assets, bus, games, culprit };
|
|
}
|
|
|
|
/** 발로란트 시연 경기 + 녹음 세션 + 대화 4문장 */
|
|
export function seedValorant(ctx: ReturnType<typeof setup>, opts: { sessionStartOffsetMs?: number; pending?: boolean } = {}) {
|
|
const { store, games } = ctx;
|
|
const VS = Date.now() - 3 * 3600_000;
|
|
const md = makeDemoValorant(VS);
|
|
const id = 'val-demo';
|
|
const users = [
|
|
{ id: 'u1', name: '승한', puuid: 'p-sh' },
|
|
{ id: 'u2', name: '민수', puuid: 'p-ms' },
|
|
{ id: 'u9', name: '도윤', puuid: null },
|
|
];
|
|
for (const u of users) {
|
|
store.upsertUser({ id: u.id, name: u.name, avatar: null });
|
|
if (u.puuid) store.setAccounts(u.id, [{ puuid: u.puuid, riotId: `${u.name}#X` }]);
|
|
}
|
|
store.startSession('s1', 'g', 'c', '음성', VS - 5 * MIN + (opts.sessionStartOffsetMs ?? 0));
|
|
games.matchStarted({ id, game: 'valorant', startedAt: VS, map: md.matchInfo.mapId, mode: 'competitive', queue: 'competitive', detail: { live: true } });
|
|
games.matchEnded(id, VS + md.matchInfo.gameLengthMillis);
|
|
(games.adapters[0] as any).applyDetails(id, md, 'p-sh', VS);
|
|
const rounds = store.rounds(id);
|
|
const say = (uid: string, round: number, sec: number, text: string, status = 'realtime') => {
|
|
const ts = rounds[round - 1].combat_at + sec * 1000;
|
|
const uid2 = `${uid}-${round}-${sec}`;
|
|
store.insertUtterance({ id: uid2, session_id: 's1', user_id: uid, started_at: ts, ended_at: ts + 1500, audio_path: null, match_id: id });
|
|
if (status !== 'pending')
|
|
store.updateUtteranceResult(uid2, { text, raw_text: text, words: [], noise: false, noise_reason: null, confidence: 0.9, lufs: -20, gain_db: 0, model: 'small', status: status as any });
|
|
};
|
|
say('u1', 3, 5, '현우야 같이 가 기다려 둘 있어');
|
|
say('u2', 3, 9, '아 그냥 간다 내가 뚫을게');
|
|
say('u9', 5, 2, '나 돈 없어 세이브할게');
|
|
say('u1', 7, 4, '스파이크 설치됐어 해체 들어가', opts.pending ? 'pending' : 'realtime');
|
|
store.endSession('s1', VS + md.matchInfo.gameLengthMillis + 5 * MIN);
|
|
return { id, VS, md };
|
|
}
|
|
|
|
|
|
/** 앱 로컬 API (사이트 서버가 중계로 부르는 것과 같은 Fastify) */
|
|
export function culpritApi(ctx: ReturnType<typeof setup>) {
|
|
return buildApi({
|
|
store: ctx.store,
|
|
timeline: ctx.timeline,
|
|
games: ctx.games,
|
|
dict: {} as any,
|
|
culprit: ctx.culprit,
|
|
bus: ctx.bus,
|
|
settings: () => ({}) as any,
|
|
trainingDir: () => ctx.dir,
|
|
overviewExtra: () => ({ guild: null, recording: { active: false, channel: null, since: null, participants: [] } }),
|
|
version: 'test',
|
|
});
|
|
}
|