컴퓨터 플레이어 + GPU 로컬 모델(gemma3:4b): 생각 중/입력 중 표시, 성격대로 채팅·도발·심리전, 바퀴벌레 포커 블러핑, 마피아 대사

- ai/llm.ts: Ollama 클라이언트(동시 2개·대기열·시간 제한·연속 실패 시 쉬기), 꺼져 있으면 예전처럼 조용히 둔다
- ai/lines.ts: 성격 5가지(도발·허세·차분·수다·소심)×말투(존댓말/반말), 한 줄 정리(외국어·AI 말·욕·링크 거르기)
- ai/brain.ts: 수 두기 전 생각 중… → 가끔 입력 중…(타자 시간) → 채팅 → 수, 사람 수에 반응, 이름 부르면 대답, 시작·끝 한마디
  바퀴벌레 포커: 진실/블러핑과 건네는 말을 모델이 정함. 마피아: 계획한 대사를 모델이 자기 말로(직업 주장은 버림)
- RoomView.botActivity + 화면 표시(상태 줄, 채팅 칸), AI_URL/AI_MODEL 설정, /healthz에 ai 통계
- 테스트: 클라이언트·정리·방 동작(가짜 모델), 실제 GPU 모델 브라우저 E2E(e2e/ai.e2e.ts)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-11 03:37:04 +09:00
parent 65a0f34d93
commit 13974181e7
17 changed files with 1030 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
import type { RoomView } from '@bg/shared/lite';
/**
* What the computers are doing right now (docs/06 §12.1): "🤖 컴퓨터 1 생각 중…", "💬 컴퓨터 2 입력 중…".
* Not announced to screen readers: the chat line or the move that follows is.
*/
export function BotActivity({ room, only }: { room: RoomView; only?: 'typing' }) {
const entries = Object.entries(room.botActivity ?? {}).filter(([, a]) => !only || a === only);
if (!entries.length) return null;
const name = (id: string) => room.seats.find((s) => s?.user.id === id)?.user.nickname ?? '컴퓨터';
return (
<div className="bot-activity small" aria-hidden>
{entries.map(([id, a]) => (
<span key={id} data-activity={a}>
{a === 'typing' ? '💬' : '🤖'} {name(id)} {a === 'typing' ? '입력 중' : '생각 중'}
<span className="bot-dots" />
</span>
))}
</div>
);
}

View File

@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react';
import { CHAT_MAX, EMOTE_LABEL, EMOTES, type PublicUser, type RoomView } from '@bg/shared/lite';
import { create } from 'zustand';
import { socket, useRoom } from '../net/socket';
import { BotActivity } from './BotActivity';
export const useChatSeen = create<{ seen: number }>(() => ({ seen: 0 }));
@@ -52,6 +53,7 @@ export function ChatPanel({ room, me, title = true }: { room: RoomView; me: Publ
</div>
))}
</div>
<BotActivity room={room} only="typing" />
<div className="emote-row">
{EMOTES.map((id) => (
<button key={id} type="button" onClick={() => socket.send({ t: 'emote', id })}>

View File

@@ -14,6 +14,7 @@ import { loadGameUI } from '../games/registry';
import type { GameUI } from '../games/types';
import { sounds } from '../lib/feedback';
import { ChatPanel, EmoteBubbles, useChatSeen } from '../components/ChatPanel';
import { BotActivity } from '../components/BotActivity';
import { useWide } from '../lib/media';
import { GameHelp } from '../components/GameHelp';
import { PlayerName } from '../components/PlayerCard';
@@ -653,6 +654,7 @@ function GameView({ room, ui, me, players, pending, slow }: { room: RoomView; ui
{status}
<GameHelp room={room} ui={ui} title={gameName(room.gameId)} me={me.id} players={players} />
</div>
<BotActivity room={room} />
{room.status === 'paused' && room.hostId === me.id && (
<button className="btn btn-danger btn-block" onClick={() => socket.send({ t: 'void' })}>
⏹ 게임 끝내기(무효)

View File

@@ -1523,3 +1523,10 @@ button.header-user {
min-height: 40px;
}
}
/* Computers' visible activity (docs/06 §12.1) */
.bot-activity { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text-sub); padding: 2px 4px; }
.bot-activity > span { display: inline-flex; align-items: center; gap: 4px; }
.bot-dots::after { content: '…'; display: inline-block; width: 1.2em; animation: bot-dots 1.2s steps(4, end) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes bot-dots { 0% { width: 0; } 100% { width: 1.2em; } }
@media (prefers-reduced-motion: reduce) { .bot-dots::after { animation: none; } }