M0: 기술 검증 - 구조 설계, STT 워커, 앱 코어, 게임 PC 진단
- docs/dev/ARCHITECTURE.md: 코어-워커-사이트 인터페이스 계약 - worker/: faster-whisper 한국어 STT, 음량 정규화, 4단계 잡음 판정, 사전 교정, GPU 감지·모델/CUDA 다운로드, 롤 채팅 OCR·r3dlog, 파인튜닝 파이프라인 (39 tests) - app/src/core: 디스코드 DAVE 음성 녹음(Ogg Opus), STT 대기열, 발로란트/롤 로컬 API 어댑터, 타임라인·기록 API, 사이트 중계, 7일 음성 삭제, 진단 - tools/gen-dictionary.mjs: 공식 게임 데이터 기반 기본 단어사전 (1993단어) - M0 결과: DAVE 연결 1.06s Ready, CPU tiny STT 3.6s→0.31s, 가짜 Riot 서버 통합 테스트 통과 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
226
packages/shared/src/protocol.ts
Normal file
226
packages/shared/src/protocol.ts
Normal file
@@ -0,0 +1,226 @@
|
||||
// 앱 코어 · 사이트 서버 · 사이트 프런트엔드가 같이 쓰는 타입. docs/dev/ARCHITECTURE.md 4~6장.
|
||||
|
||||
export type GameType = 'valorant' | 'lol';
|
||||
|
||||
export interface TimeLabel {
|
||||
/** 발로란트 "R7 · 0:42" / 롤 "21:14" / 경기 밖 "21:08:44" */
|
||||
primary: string;
|
||||
/** 발로란트 경기 경과 시간 "12:18" */
|
||||
secondary?: string;
|
||||
/** 현실 시각 (unix ms) */
|
||||
real: number;
|
||||
}
|
||||
|
||||
export interface Word {
|
||||
w: string;
|
||||
/** 발화 시작 기준 초 */
|
||||
s: number;
|
||||
e: number;
|
||||
p?: number;
|
||||
}
|
||||
|
||||
export interface User {
|
||||
id: string;
|
||||
name: string;
|
||||
color: string;
|
||||
avatar: string | null;
|
||||
excluded: boolean;
|
||||
riot: { puuid: string; riotId: string }[];
|
||||
}
|
||||
|
||||
export type UtteranceStatus = 'pending' | 'realtime' | 'precise' | 'failed';
|
||||
|
||||
export interface UtteranceItem {
|
||||
kind: 'utterance';
|
||||
id: string;
|
||||
ts: number;
|
||||
endTs: number;
|
||||
userId: string;
|
||||
text: string | null;
|
||||
words: Word[];
|
||||
noise: boolean;
|
||||
status: UtteranceStatus;
|
||||
corrected: boolean;
|
||||
confidence: number | null;
|
||||
model: string | null;
|
||||
audio: { url: string; durationMs: number; gainDb: number } | null;
|
||||
game: { type: GameType; matchId: string; round?: number } | null;
|
||||
time: TimeLabel;
|
||||
}
|
||||
|
||||
export type EventType =
|
||||
| 'kill'
|
||||
| 'chat'
|
||||
| 'object'
|
||||
| 'spike'
|
||||
| 'round_end'
|
||||
| 'match_start'
|
||||
| 'match_end'
|
||||
| 'multikill'
|
||||
| 'ace';
|
||||
|
||||
export interface PlayerRef {
|
||||
puuid?: string;
|
||||
name: string;
|
||||
team?: string;
|
||||
/** 발로란트 요원 / 롤 챔피언 */
|
||||
character?: { id: string; name: string; icon: string | null };
|
||||
userId?: string;
|
||||
}
|
||||
|
||||
export interface KillData {
|
||||
killer: PlayerRef | null;
|
||||
victim: PlayerRef;
|
||||
assists: PlayerRef[];
|
||||
weapon: { id: string; name: string; icon: string | null } | null;
|
||||
headshot?: boolean;
|
||||
location?: { x: number; y: number } | null;
|
||||
ally?: boolean;
|
||||
}
|
||||
export interface ChatData {
|
||||
sender: PlayerRef;
|
||||
channel: 'team' | 'all' | 'party' | 'system';
|
||||
text: string;
|
||||
source: 'api' | 'ocr' | 'lcu' | 'log';
|
||||
}
|
||||
export interface ObjectData {
|
||||
object: 'dragon' | 'baron' | 'herald' | 'grub' | 'tower' | 'inhibitor' | 'atakhan';
|
||||
subtype?: string;
|
||||
team?: string;
|
||||
killer?: PlayerRef | null;
|
||||
ally?: boolean;
|
||||
}
|
||||
export interface RoundEndData {
|
||||
round: number;
|
||||
win: boolean;
|
||||
result: string;
|
||||
score: { ally: number; enemy: number };
|
||||
}
|
||||
|
||||
export interface EventItem {
|
||||
kind: 'event';
|
||||
id: string;
|
||||
ts: number;
|
||||
game: GameType;
|
||||
matchId: string;
|
||||
type: EventType;
|
||||
data: any;
|
||||
time: TimeLabel;
|
||||
userId?: string;
|
||||
}
|
||||
|
||||
export type TimelineItem = UtteranceItem | EventItem;
|
||||
|
||||
export interface TimelinePage {
|
||||
items: TimelineItem[];
|
||||
next: string | null;
|
||||
}
|
||||
|
||||
export interface MatchSummary {
|
||||
id: string;
|
||||
game: GameType;
|
||||
startedAt: number;
|
||||
endedAt: number | null;
|
||||
map: { id: string; name: string; image: string | null };
|
||||
mode: string;
|
||||
win: boolean | null;
|
||||
score: { ally: number; enemy: number } | null;
|
||||
status: 'live' | 'pending_detail' | 'complete';
|
||||
participants: string[];
|
||||
}
|
||||
|
||||
export interface MatchPlayer {
|
||||
puuid: string;
|
||||
name: string;
|
||||
tag?: string;
|
||||
team: string;
|
||||
ally: boolean;
|
||||
character: { id: string; name: string; icon: string | null };
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
score?: number;
|
||||
cs?: number;
|
||||
gold?: number;
|
||||
level?: number;
|
||||
items?: { id: number; name: string; icon: string | null }[];
|
||||
rank?: string | null;
|
||||
userId?: string;
|
||||
}
|
||||
|
||||
export interface MatchRound {
|
||||
num: number;
|
||||
startedAt: number;
|
||||
endedAt: number;
|
||||
win: boolean;
|
||||
result: string;
|
||||
score: { ally: number; enemy: number };
|
||||
economy?: Record<string, { spent: number; remaining: number; weapon?: string }>;
|
||||
}
|
||||
|
||||
export interface MatchDetail extends MatchSummary {
|
||||
players: MatchPlayer[];
|
||||
rounds?: MatchRound[];
|
||||
goldDiff?: { t: number; diff: number }[];
|
||||
events: EventItem[];
|
||||
utterances: UtteranceItem[];
|
||||
mapTransform:
|
||||
| { valorant: { xMultiplier: number; yMultiplier: number; xScalarToAdd: number; yScalarToAdd: number } }
|
||||
| { lol: { minX: number; minY: number; maxX: number; maxY: number } }
|
||||
| null;
|
||||
}
|
||||
|
||||
export interface Overview {
|
||||
guild: { id: string; name: string; icon: string | null } | null;
|
||||
recording: { active: boolean; channel: string | null; since: number | null; participants: string[] };
|
||||
users: User[];
|
||||
games: { valorant: { connected: boolean; inMatch: boolean }; lol: { connected: boolean; inMatch: boolean } };
|
||||
counts: { utterances: number; matches: number };
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface UserProfile {
|
||||
user: User;
|
||||
stats: { talkMs: number; count: number; topWords: { w: string; n: number }[] };
|
||||
matches: MatchSummary[];
|
||||
}
|
||||
|
||||
export type LiveEvent =
|
||||
| { type: 'utterance.created' | 'utterance.updated'; data: UtteranceItem }
|
||||
| { type: 'event.created'; data: EventItem }
|
||||
| { type: 'match.updated'; data: MatchSummary }
|
||||
| { type: 'recording.state'; data: Overview['recording'] }
|
||||
| { type: 'users.updated'; data: User[] };
|
||||
|
||||
export interface DeviceStatus {
|
||||
registered: boolean;
|
||||
online: boolean;
|
||||
name: string | null;
|
||||
lastSeen: number | null;
|
||||
version: string | null;
|
||||
}
|
||||
|
||||
export type BrowserMessage = { type: 'status'; data: { device: DeviceStatus } } | LiveEvent;
|
||||
|
||||
// 사이트 서버 ↔ 앱 WebSocket
|
||||
export type RelayToDevice =
|
||||
| {
|
||||
t: 'req';
|
||||
id: string;
|
||||
method: string;
|
||||
path: string;
|
||||
headers: Record<string, string>;
|
||||
user: { id: string; name: string; avatar: string | null } | null;
|
||||
body: string | null;
|
||||
}
|
||||
| { t: 'cancel'; id: string }
|
||||
| { t: 'pong'; ts: number }
|
||||
| { t: 'welcome'; deviceId: string };
|
||||
|
||||
export type RelayFromDevice =
|
||||
| { t: 'hello'; name: string; version: string }
|
||||
| { t: 'ping'; ts: number }
|
||||
| { t: 'res'; id: string; status: number; headers: Record<string, string>; body: string | null }
|
||||
| { t: 'res_head'; id: string; status: number; headers: Record<string, string> }
|
||||
| { t: 'res_end'; id: string }
|
||||
| { t: 'event'; event: LiveEvent };
|
||||
Reference in New Issue
Block a user