초기 커밋 — 협상 AI 에이전트 정본: 엔진·데모 콘솔·측정 인프라·증빙

- server/: FastAPI 협상 엔진 (5라운드, Q-Table/UCB, 페르소나 계측, :53117)
- frontend/: 데모 콘솔 (React+Tailwind → nginx, /api 프록시)
- eval/·testdata/: 지표 8종 측정 하네스 + 재현 가능 테스트셋
- results/: 측정 증빙 (지표별 result+provenance, raw 원본 동결+SHA256)
  ① 86.0 · ② 76.0 · ③ 5.99% · ⑥ p95 3.61ms · ⑦ 611만/년 · ⑧ 91/100 · ⑨ 99.71 · ⑩ 97.99
- docker-compose.yml + run.sh: backend+frontend 일괄 기동

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0112XUWF4bc3gGrEt8vsYCzy
This commit is contained in:
민헌andClaude Fable 5 committed 2026-08-31 13:09:52 +09:00
commit dfb9ad6e66
268 files changed
+164241

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
// NEGO_AGENT 서버 API — /api → :53117 (vite proxy)
import type { CardData, DemoCase } from '../content/cases'
export interface ChatMetadata {
card_id: string | null
q_value: number | null
indicator_value: number | null
indicator_range: 'PZ1' | 'PZ2' | 'PZ3' | null
tension: number | null
persona: string | null
price: number | null
iteration: number
}
export interface ChatResponse {
index: number
script: string
chat_end: boolean
next_input_mode: 'confirm' | 'yes_no' | 'price' | 'null' | 'delivery_type'
input_options: string[] | null
step: string
client_step: string | null
chat_metadata: ChatMetadata | null
}
export interface ChatBody {
rq_type: string
session_id: string
step: string
index: number
user_input?: string | null
item_price?: number
revenue?: number
dist?: string
partners_yn?: string
partners?: number
anchor?: number
target?: number
initial?: number | null
input?: number | null
iteration?: number
is_new_quote?: boolean
profiling?: boolean
card_data?: CardData
}
export async function chat(body: ChatBody): Promise<ChatResponse> {
const res = await fetch('/api/v1/nego/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
})
if (!res.ok) throw new Error(`서버 응답 오류 (${res.status})`)
return res.json()
}
export async function invalidateSession(sessionId: string): Promise<void> {
await fetch('/api/v1/nego/session/invalidate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ session_id: sessionId, reason: '데모 재시작' }),
})
}
export async function serverAlive(): Promise<boolean> {
try {
const res = await fetch('/api/health')
return res.ok
} catch {
return false
}
}
// 카드 변수 동적 산식 (하네스 build_card_data 계승):
// 경쟁사가격반영 = max(100 × (1 − 앵커/입력가), 1)
export function buildCardData(demoCase: DemoCase, price: number | null): CardData {
const cd = { ...demoCase.card_data, anchoring_price: demoCase.anchor }
if (price && price > 0) {
cd.competitor_price_diff = Math.max(
Math.round((100 * (1 - demoCase.anchor / price)) * 10) / 10, 1)
}
return cd
}