초기 커밋 — 협상 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

+2
View File
@@ -0,0 +1,2 @@
node_modules
dist
+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+8
View File
@@ -0,0 +1,8 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["react", "typescript", "oxc"],
"rules": {
"react/rules-of-hooks": "error",
"react/only-export-components": ["warn", { "allowConstantExport": true }]
}
}
+12
View File
@@ -0,0 +1,12 @@
# 데모 콘솔 — 빌드(node) 후 nginx 정적 서빙 + /api 프록시(backend:53117)
FROM node:20-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:1.27-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
+28
View File
@@ -0,0 +1,28 @@
# NEGO 협상 콘솔 (frontend)
React + Vite + Tailwind v4 데모 페이지 — 사람이 공급사 역할로 협상 엔진(MD 챗봇)과 직접 협상하는 시연 콘솔.
## 실행
```bash
# 1) 엔진 기동 (별도 터미널)
cd ../server && .venv/bin/python web_main.py # :53117
# 2) 데모 페이지
npm install
npm run dev # → http://localhost:5317
```
`/api`는 vite 프록시로 :53117에 연결된다 (vite.config.ts).
## 구성
- 좌: 협상 케이스 4종(공급 유형별, testset 발췌) + 공급사 정보
- 중앙: 협상 채팅 — 버튼(확인/예·아니오)·가격 제안 입력
- 우: **엔진 계기판** — 가격 트랙(앵커·목표·기존가·현재 제안), 진행 플로우,
협상 카드·가격 지표(1~99)·긴장도·적용 페르소나, 구매측 내부 기준(시연용 공개)
## 참고
- profiling(LLM 톤 재작성)은 off로 호출한다 (App.tsx `profiling: false`) — 켜려면 true + 서버에 OpenAI 키
- `is_new_quote: false`라 UCB 에피소드가 활성 — 라운드마다 다른 협상 카드가 나온다
+23
View File
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NEGO 협상 콘솔</title>
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+17
View File
@@ -0,0 +1,17 @@
server {
listen 80;
# /api/* → backend (프리픽스 제거: /api/v1/... → /v1/...) — vite dev proxy 와 동일 규칙
location /api/ {
proxy_pass http://backend:53117/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# SPA 정적 서빙
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
+1942
View File
File diff suppressed because it is too large. Load diff
+27
View File
@@ -0,0 +1,27 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "oxlint",
"preview": "vite preview"
},
"dependencies": {
"@tailwindcss/vite": "^4.3.3",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"tailwindcss": "^4.3.3"
},
"devDependencies": {
"@types/node": "^24.13.3",
"@types/react": "^19.2.18",
"@types/react-dom": "^19.2.4",
"@vitejs/plugin-react": "^6.1.0",
"oxlint": "^1.79.0",
"typescript": "~6.0.2",
"vite": "^8.2.2"
}
}
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="46" fill="none" viewBox="0 0 48 46"><path fill="#863bff" d="M25.946 44.938c-.664.845-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.287c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.497 0-3.578-1.842-3.578H1.237c-.92 0-1.456-1.04-.92-1.788L10.013.474c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.579 1.842 3.579h11.377c.943 0 1.473 1.088.89 1.83L25.947 44.94z" style="fill:#863bff;fill:color(display-p3 .5252 .23 1);fill-opacity:1"/><mask id="a" width="48" height="46" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M25.842 44.938c-.664.844-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.183c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.498 0-3.579-1.842-3.579H1.133c-.92 0-1.456-1.04-.92-1.787L9.91.473c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.578 1.842 3.578h11.377c.943 0 1.473 1.088.89 1.832L25.843 44.94z" style="fill:#000;fill-opacity:1"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#ede6ff" rx="5.508" ry="14.704" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -4.47 31.516)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#ede6ff" rx="10.399" ry="29.851" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -39.328 7.883)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#7e14ff" rx="5.508" ry="30.487" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.814 -25.913 -14.639)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#7e14ff" rx="5.508" ry="30.599" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.814 -32.644 -3.334)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#7e14ff" rx="5.508" ry="30.599" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -34.34 30.47)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#ede6ff" rx="14.072" ry="22.078" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="rotate(93.35 24.506 48.493)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#7e14ff" rx="3.47" ry="21.501" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.009 28.708 47.59)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#7e14ff" rx="3.47" ry="21.501" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.009 28.708 47.59)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx=".387" cy="8.972" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(39.51 .387 8.972)"/></g><g filter="url(#k)"><ellipse cx="47.523" cy="-6.092" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 47.523 -6.092)"/></g><g filter="url(#l)"><ellipse cx="41.412" cy="6.333" fill="#47bfff" rx="5.971" ry="9.665" style="fill:#47bfff;fill:color(display-p3 .2799 .748 1);fill-opacity:1" transform="rotate(37.892 41.412 6.333)"/></g><g filter="url(#m)"><ellipse cx="-1.879" cy="38.332" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 -1.88 38.332)"/></g><g filter="url(#n)"><ellipse cx="-1.879" cy="38.332" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 -1.88 38.332)"/></g><g filter="url(#o)"><ellipse cx="35.651" cy="29.907" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 35.651 29.907)"/></g><g filter="url(#p)"><ellipse cx="38.418" cy="32.4" fill="#47bfff" rx="5.971" ry="15.297" style="fill:#47bfff;fill:color(display-p3 .2799 .748 1);fill-opacity:1" transform="rotate(37.892 38.418 32.4)"/></g></g><defs><filter id="b" width="60.045" height="41.654" x="-19.77" y="16.149" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-54.613" y="-7.533" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filtLine truncated

After

Width:  |  Height:  |  Size: 9.3 KiB

+24
View File
@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg">
<symbol id="bluesky-icon" viewBox="0 0 16 17">
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
</symbol>
<symbol id="discord-icon" viewBox="0 0 20 19">
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
</symbol>
<symbol id="documentation-icon" viewBox="0 0 21 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
</symbol>
<symbol id="github-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
</symbol>
<symbol id="social-icon" viewBox="0 0 20 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
</symbol>
<symbol id="x-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
</symbol>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

+155
View File
@@ -0,0 +1,155 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { DEMO_CASES, type DemoCase } from './content/cases'
import { buildCardData, chat, invalidateSession, serverAlive, type ChatMetadata } from './lib/api'
import { CasePanel } from './components/CasePanel'
import { ChatPanel, type Msg } from './components/ChatPanel'
import { Dashboard } from './components/Dashboard'
export interface NegoState {
step: string
index: number
iteration: number
price: number | null
initial: number | null
mode: string
options: string[]
done: boolean
}
const IDLE: NegoState = {
step: '시작', index: 0, iteration: 0, price: null, initial: null,
mode: 'null', options: [], done: false,
}
export default function App() {
const [demoCase, setDemoCase] = useState<DemoCase>(DEMO_CASES[0])
const [nego, setNego] = useState<NegoState>(IDLE)
const [messages, setMessages] = useState<Msg[]>([])
const [meta, setMeta] = useState<ChatMetadata | null>(null)
const [finalPrice, setFinalPrice] = useState<number | null>(null)
const [priceTrail, setPriceTrail] = useState<number[]>([])
const [busy, setBusy] = useState(false)
const [started, setStarted] = useState(false)
const [runId, setRunId] = useState(0)
const [alive, setAlive] = useState<boolean | null>(null)
const [error, setError] = useState<string | null>(null)
const session = useRef(`DEMO-${Date.now()}`)
useEffect(() => {
serverAlive().then(setAlive)
const t = setInterval(() => serverAlive().then(setAlive), 15000)
return () => clearInterval(t)
}, [])
const send = useCallback(
async (userInput: string | null, state: NegoState, userLabel?: string) => {
setBusy(true)
setError(null)
if (userLabel) setMessages((m) => [...m, { role: 'user', text: userLabel }])
try {
const res = await chat({
rq_type: '재협상',
session_id: session.current,
step: state.step,
index: state.index,
user_input: userInput,
item_price: demoCase.item_price,
revenue: demoCase.revenue,
dist: demoCase.dist,
partners_yn: demoCase.partners_yn,
partners: demoCase.partners,
anchor: demoCase.anchor,
target: demoCase.target,
initial: state.initial,
input: state.price,
iteration: state.iteration,
is_new_quote: false, // UCB 에피소드 활성 — 라운드마다 다른 카드 (시연 다양성)
profiling: false,
card_data: buildCardData(demoCase, state.price),
})
setMessages((m) => [...m, { role: 'bot', text: res.script, step: res.step, meta: res.chat_metadata }])
if (res.chat_metadata?.card_id || res.chat_metadata?.tension != null) setMeta(res.chat_metadata)
if (res.step === '협상완료' && res.chat_metadata?.price != null) setFinalPrice(res.chat_metadata.price)
setNego({
...state,
step: res.step,
index: res.index,
mode: res.chat_end ? 'null' : res.next_input_mode,
options: res.input_options ?? [],
done: res.chat_end,
})
} catch (e) {
setError(e instanceof Error ? e.message : '요청 실패')
} finally {
setBusy(false)
}
},
[demoCase],
)
const start = useCallback(async (c: DemoCase) => {
session.current = `DEMO-${Date.now()}`
await invalidateSession(session.current).catch(() => {})
setDemoCase(c)
setMessages([])
setMeta(null)
setFinalPrice(null)
setPriceTrail([])
setStarted(true)
setNego(IDLE)
setRunId((r) => r + 1)
}, [])
// 케이스 확정 후 첫 요청 (같은 케이스 재시작 포함 — runId로 항상 발사)
useEffect(() => {
if (started) send(null, IDLE)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [runId])
const answer = (label: string) => send(label, nego, label)
const offer = (v: number) => {
const next = { ...nego, price: v }
if (next.initial == null) next.initial = v
else next.iteration = nego.iteration + 1
setPriceTrail((t) => [...t, v])
send(null, next, `${v.toLocaleString()}원 제안`)
}
return (
<div className="flex min-h-dvh flex-col min-[960px]:h-dvh">
<header className="flex items-center justify-between border-b border-line bg-panel px-6 py-3">
<div className="flex items-baseline gap-3">
<h1 className="text-lg font-extrabold tracking-tight">NEGO 협상 콘솔</h1>
<span className="text-sm text-muted">구매 협상 에이전트 시연 — 당신은 공급사입니다</span>
</div>
<div className="flex items-center gap-2 text-sm">
<span
className={`inline-block size-2 rounded-full ${
alive == null ? 'bg-line' : alive ? 'bg-green' : 'bg-amber'
}`}
aria-hidden
/>
<span className="text-muted">{alive == null ? '확인 중' : alive ? '엔진 연결됨' : '엔진 응답 없음 (:53117)'}</span>
</div>
</header>
<main className="mx-auto grid w-full max-w-screen-2xl flex-1 grid-cols-1 gap-4 p-4 min-[960px]:min-h-0 min-[960px]:grid-cols-[250px_minmax(0,1fr)_320px]">
<CasePanel cases={DEMO_CASES} selected={demoCase} started={started} busy={busy} onStart={start} />
<ChatPanel
messages={messages}
nego={nego}
busy={busy}
started={started}
error={error}
demoCase={demoCase}
finalPrice={finalPrice}
onAnswer={answer}
onOffer={offer}
onRestart={() => start(demoCase)}
/>
<Dashboard demoCase={demoCase} nego={nego} meta={meta} priceTrail={priceTrail} started={started} />
</main>
</div>
)
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="77" height="47" fill="none" aria-labelledby="vite-logo-title" viewBox="0 0 77 47"><title id="vite-logo-title">Vite</title><style>.parenthesis{fill:#000}@media (prefers-color-scheme:dark){.parenthesis{fill:#fff}}</style><path fill="#9135ff" d="M40.151 45.71c-.663.844-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.493c-.92 0-1.457-1.04-.92-1.788l7.479-10.471c1.07-1.498 0-3.578-1.842-3.578H15.443c-.92 0-1.456-1.04-.92-1.788l9.696-13.576c.213-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.472c-1.07 1.497 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.087.89 1.83L40.153 45.712z"/><mask id="a" width="48" height="47" x="14" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M40.047 45.71c-.663.843-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.389c-.92 0-1.457-1.04-.92-1.788l7.479-10.472c1.07-1.497 0-3.578-1.842-3.578H15.34c-.92 0-1.456-1.04-.92-1.788l9.696-13.575c.213-.297.556-.474.92-.474H53.93c.92 0 1.456 1.04.92 1.788L47.37 13.03c-1.07 1.498 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.088.89 1.831L40.049 45.712z"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#eee6ff" rx="5.508" ry="14.704" transform="rotate(269.814 20.96 11.29)scale(-1 1)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#eee6ff" rx="10.399" ry="29.851" transform="rotate(89.814 -16.902 -8.275)scale(1 -1)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#8900ff" rx="5.508" ry="30.487" transform="rotate(89.814 -19.197 -7.127)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.928 4.177)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.738 5.52)scale(1 -1)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#eee6ff" rx="14.072" ry="22.078" transform="rotate(93.35 31.245 55.578)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx="14.592" cy="9.743" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(39.51 14.592 9.743)"/></g><g filter="url(#k)"><ellipse cx="61.728" cy="-5.321" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 61.728 -5.32)"/></g><g filter="url(#l)"><ellipse cx="55.618" cy="7.104" fill="#00c2ff" rx="5.971" ry="9.665" transform="rotate(37.892 55.618 7.104)"/></g><g filter="url(#m)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#n)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#o)"><ellipse cx="49.857" cy="30.678" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 49.857 30.678)"/></g><g filter="url(#p)"><ellipse cx="52.623" cy="33.171" fill="#00c2ff" rx="5.971" ry="15.297" transform="rotate(37.892 52.623 33.17)"/></g></g><path d="M6.919 0c-9.198 13.166-9.252 33.575 0 46.789h6.215c-9.25-13.214-9.196-33.623 0-46.789zm62.424 0h-6.215c9.198 13.166 9.252 33.575 0 46.789h6.215c9.25-13.214 9.196-33.623 0-46.789" class="parenthesis"/><defs><filter id="b" width="60.045" height="41.654" x="-5.564" y="16.92" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-40.407" y="-6.762" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-35.435" y="2.801" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-30.84" y="20.8" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-29.307" y="21.949" color-interpolation-filters="sRGB" filterUnits="usLine truncated

After

Width:  |  Height:  |  Size: 8.5 KiB

+62
View File
@@ -0,0 +1,62 @@
import { DIST_LABEL, type DemoCase } from '../content/cases'
export function CasePanel({
cases, selected, started, busy, onStart,
}: {
cases: DemoCase[]
selected: DemoCase
started: boolean
busy: boolean
onStart: (c: DemoCase) => void
}) {
return (
<aside className="flex flex-col gap-3 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<section className="rounded-xl border border-line bg-panel p-4">
<h2 className="text-xs font-semibold uppercase tracking-wider text-muted">협상 케이스</h2>
<ul className="mt-3 flex flex-col gap-2">
{cases.map((c) => {
const active = started && c.id === selected.id
return (
<li key={c.id}>
<button
type="button"
disabled={busy}
onClick={() => onStart(c)}
className={`w-full rounded-lg border px-3 py-2.5 text-left transition-colors focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none ${
active
? 'border-blue bg-blue-soft'
: 'border-line bg-panel hover:border-muted'
} ${busy ? 'opacity-60' : ''}`}
>
<div className="flex items-center justify-between gap-2">
<span className="text-sm font-semibold">{c.item_name}</span>
<span className="shrink-0 rounded bg-paper px-1.5 py-0.5 text-[11px] text-muted">{c.label}</span>
</div>
<div className="mt-1 font-mono text-xs text-muted">
기존 공급가 {c.item_price.toLocaleString()}원
</div>
{active && (
<dl className="mt-2 grid grid-cols-2 gap-x-2 gap-y-1 border-t border-line pt-2 text-[11px]">
<dt className="text-muted">공급 유형</dt>
<dd className="text-right">{DIST_LABEL[c.dist]} · {c.partners_yn}</dd>
<dt className="text-muted">거래 기간</dt>
<dd className="text-right font-mono">{c.card_data.trading_period}년</dd>
<dt className="text-muted">응답률 / VOC</dt>
<dd className="text-right font-mono">{c.card_data.response_rate}% / {c.card_data.voc_count}건</dd>
</dl>
)}
</button>
</li>
)
})}
</ul>
{!started && (
<p className="mt-3 text-xs leading-relaxed text-muted">
케이스를 선택하면 협상이 시작됩니다. 챗봇은 구매 담당자(MD) 역할이고,
당신은 공급사로서 가격 제안에 응답합니다.
</p>
)}
</section>
</aside>
)
}
+184
View File
@@ -0,0 +1,184 @@
import { useEffect, useRef, useState } from 'react'
import type { ChatMetadata } from '../lib/api'
import type { DemoCase } from '../content/cases'
import type { NegoState } from '../App'
export interface Msg {
role: 'bot' | 'user'
text: string
step?: string
meta?: ChatMetadata | null
}
// 내부 스텝 ID → 관람자용 라벨 (엔진 내부명 노출 방지)
const STEP_LABELS: Record<string, string> = {
wild_card_1pct: '1% 추가 제안',
wild_card_budget: '재원부족 제안',
가격협상_확인_버짓: '가격협상 확인',
}
const stepLabel = (s: string) => STEP_LABELS[s] ?? s
export function ChatPanel({
messages, nego, busy, started, error, demoCase, finalPrice, onAnswer, onOffer, onRestart,
}: {
messages: Msg[]
nego: NegoState
busy: boolean
started: boolean
error: string | null
demoCase: DemoCase
finalPrice: number | null
onAnswer: (label: string) => void
onOffer: (v: number) => void
onRestart: () => void
}) {
const [priceInput, setPriceInput] = useState('')
const scroller = useRef<HTMLDivElement>(null)
useEffect(() => {
scroller.current?.scrollTo({ top: scroller.current.scrollHeight, behavior: 'smooth' })
}, [messages, busy])
useEffect(() => setPriceInput(''), [nego.step])
const submitPrice = () => {
const v = Number(priceInput.replaceAll(',', ''))
if (!Number.isFinite(v) || v <= 0) return
onOffer(Math.round(v))
}
const savedPct = finalPrice != null
? Math.round(((demoCase.item_price - finalPrice) / demoCase.item_price) * 1000) / 10
: null
return (
<section className="flex min-h-[70vh] flex-col rounded-xl border border-line bg-panel min-[960px]:h-full min-[960px]:min-h-0">
{started && (
<div className="flex items-center justify-between gap-3 border-b border-line px-4 py-2.5">
<span className="truncate text-sm font-semibold">{demoCase.item_name}</span>
{!nego.done && (
<button
type="button"
onClick={onRestart}
disabled={busy}
className="shrink-0 rounded-md border border-line px-2.5 py-1 text-xs text-muted hover:border-muted hover:text-ink disabled:opacity-40 focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none"
>
다시 시작
</button>
)}
</div>
)}
<div ref={scroller} className="flex-1 overflow-y-auto p-4">
{!started && (
<div className="flex h-full flex-col items-center justify-center gap-2 text-center text-muted">
<p className="text-base font-medium text-ink">협상 준비 완료</p>
<p className="max-w-sm text-sm leading-relaxed">
왼쪽에서 협상 케이스를 선택하세요. 협상 카드·가격 지표·긴장도가
오른쪽 계기판에 실시간으로 표시됩니다.
</p>
</div>
)}
<ol className="flex flex-col gap-3">
{messages.map((m, i) => (
<li key={i} className={`msg-in flex ${m.role === 'user' ? 'justify-end' : 'justify-start'}`}>
<div
className={`max-w-[min(82%,34rem)] rounded-2xl px-4 py-3 text-[15px] leading-relaxed whitespace-pre-line ${
m.role === 'user'
? 'rounded-br-md bg-blue text-white'
: 'rounded-bl-md bg-bot'
}`}
>
{m.role === 'bot' && m.step && (
<div className="mb-1 flex items-center gap-2 text-[11px] font-semibold text-muted">
<span>{stepLabel(m.step)}</span>
{m.meta?.card_id && (
<span className="rounded bg-blue-soft px-1.5 py-px font-mono text-blue">{m.meta.card_id}</span>
)}
</div>
)}
{m.text}
</div>
</li>
))}
{busy && (
<li className="flex justify-start">
<div className="rounded-2xl rounded-bl-md bg-bot px-4 py-3 text-sm text-muted">협상 중…</div>
</li>
)}
</ol>
{error && (
<p className="mt-3 rounded-lg bg-amber-soft px-3 py-2 text-sm text-amber">
{error} — 서버(:53117)가 켜져 있는지 확인한 뒤 다시 시도하세요.
</p>
)}
</div>
<div className="border-t border-line p-3">
{nego.done ? (
<div className="flex flex-wrap items-center justify-between gap-3">
{finalPrice != null ? (
<span className="text-sm">
<span className="font-semibold text-green">협상 완료</span>
<span className="text-muted"> — 최종 합의가 </span>
<span className="font-mono font-semibold">{finalPrice.toLocaleString()}원</span>
<span className="font-mono text-blue"> (기존가 대비 −{savedPct}%)</span>
</span>
) : (
<span className="text-sm font-semibold">협상이 종료되었습니다</span>
)}
<button
type="button"
onClick={onRestart}
className="rounded-lg bg-ink px-4 py-2 text-sm font-semibold text-white hover:bg-ink/85 focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none"
>
같은 케이스로 다시 협상
</button>
</div>
) : nego.mode === 'price' ? (
<form
className="flex gap-2"
onSubmit={(e) => { e.preventDefault(); submitPrice() }}
>
<label htmlFor="price" className="sr-only">공급 제안가 (원)</label>
<input
id="price"
inputMode="numeric"
autoComplete="off"
placeholder={`공급 제안가 입력 (기존가 ${demoCase.item_price.toLocaleString()}원)`}
value={priceInput}
onChange={(e) => setPriceInput(e.target.value)}
disabled={busy}
className="min-w-0 flex-1 rounded-lg border border-line bg-paper px-3 py-2.5 font-mono text-sm focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none"
/>
<button
type="submit"
disabled={busy || !priceInput.trim()}
className="shrink-0 rounded-lg bg-blue px-5 py-2.5 text-sm font-semibold text-white disabled:opacity-40 hover:bg-blue/90 focus-visible:ring-2 focus-visible:ring-ink focus-visible:outline-none"
>
제안
</button>
</form>
) : nego.options.length > 0 ? (
<div className="flex flex-wrap gap-2">
{nego.options.map((opt) => (
<button
key={opt}
type="button"
disabled={busy}
onClick={() => onAnswer(opt)}
className="rounded-lg border border-line bg-paper px-4 py-2.5 text-sm font-medium hover:border-blue hover:text-blue disabled:opacity-40 focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none"
>
{opt}
</button>
))}
</div>
) : (
<p className="py-1 text-center text-sm text-muted">
{started ? '응답을 기다리는 중…' : '케이스를 선택하면 입력이 열립니다'}
</p>
)}
</div>
</section>
)
}
+140
View File
@@ -0,0 +1,140 @@
import type { ChatMetadata } from '../lib/api'
import type { DemoCase } from '../content/cases'
import type { NegoState } from '../App'
import { PriceTrack } from './PriceTrack'
const FLOW = ['서비스안내', '담당자확인', '협상품목안내', '가격협상', '협상종료']
function flowIndex(step: string): number {
if (step.includes('종료') || step.includes('완료') || step.includes('실패')) return 4
if (step.includes('가격') || step.startsWith('wild_')) return 3
const i = FLOW.indexOf(step)
return i >= 0 ? i : 0
}
function Panel({ title, children }: { title: string; children: React.ReactNode }) {
return (
<section className="rounded-xl border border-line bg-panel p-4">
<h2 className="text-xs font-semibold uppercase tracking-wider text-muted">{title}</h2>
<div className="mt-3">{children}</div>
</section>
)
}
export function Dashboard({
demoCase, nego, meta, priceTrail, started,
}: {
demoCase: DemoCase
nego: NegoState
meta: ChatMetadata | null
priceTrail: number[]
started: boolean
}) {
const fi = started ? flowIndex(nego.step) : -1
const tension = meta?.tension ?? null
const indicator = meta?.indicator_value ?? null
return (
<aside className="flex flex-col gap-3 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<Panel title="가격 트랙">
<PriceTrack demoCase={demoCase} priceTrail={priceTrail} />
<dl className="mt-3 flex items-center justify-between border-t border-line pt-2.5 text-xs">
<div className="flex items-center gap-1.5">
<dt className="text-muted">시나리오</dt>
<dd className="font-mono font-medium">{demoCase.scenario.replace('Scenario_', '')}</dd>
</div>
<div className="flex items-center gap-1.5">
<dt className="text-muted">인터넷 최저가</dt>
<dd className="font-mono font-medium">{demoCase.card_data.internet_min_price.toLocaleString()}원</dd>
</div>
</dl>
<p className="mt-2 text-[11px] leading-relaxed text-muted">
앵커가·목표가는 실제 협상에서 공급사에게 보이지 않는 구매측 내부 기준입니다.
</p>
</Panel>
<Panel title="협상 진행">
<ol className="flex items-center gap-1">
{FLOW.map((s, i) => (
<li key={s} className="flex flex-1 flex-col items-center gap-1.5">
<div
className={`h-1.5 w-full rounded-full ${
i < fi ? 'bg-blue/40' : i === fi ? 'bg-blue' : 'bg-line'
}`}
/>
<span className={`text-[10px] ${i === fi ? 'font-semibold text-ink' : 'text-muted'}`}>{s}</span>
</li>
))}
</ol>
<div className="mt-3 flex items-center justify-between text-sm">
<span className="text-muted">가격 라운드</span>
<span className="font-mono font-medium">{Math.min(nego.iteration + (nego.initial ? 1 : 0), 5)} / 5</span>
</div>
</Panel>
<Panel title="엔진 판단">
{meta ? (
<dl className="flex flex-col gap-3 text-sm">
<div className="flex items-center justify-between gap-2">
<dt className="text-muted">협상 카드</dt>
<dd className="rounded bg-blue-soft px-2 py-0.5 font-mono text-[13px] font-medium text-blue">
{meta.card_id ?? '—'}
</dd>
</div>
<div>
<div className="flex items-center justify-between">
<dt className="text-muted">가격 지표</dt>
<dd className="font-mono text-[13px]">
{indicator != null ? (
<>
{indicator} <span className="text-muted">/ 99 · {meta.indicator_range}</span>
</>
) : '—'}
</dd>
</div>
<div className="mt-1.5 h-1.5 rounded-full bg-paper">
<div
className="h-full rounded-full bg-blue transition-[width] duration-500"
style={{ width: `${indicator ?? 0}%` }}
/>
</div>
</div>
<div>
<div className="flex items-center justify-between">
<dt className="text-muted">협상 긴장도</dt>
<dd className="font-mono text-[13px]">{tension != null ? tension.toFixed(2) : '—'}</dd>
</div>
<div className="mt-1.5 h-1.5 rounded-full bg-paper">
<div
className="h-full rounded-full bg-amber transition-[width] duration-500"
style={{ width: `${(tension ?? 0) * 100}%` }}
/>
</div>
</div>
<div className="flex items-center justify-between gap-2">
<dt className="text-muted">적용 페르소나</dt>
<dd>
{meta.persona ? (
<span className="rounded bg-amber-soft px-2 py-0.5 text-[13px] font-medium text-amber">
{meta.persona}
</span>
) : (
<span className="text-muted">—</span>
)}
</dd>
</div>
</dl>
) : (
<p className="text-xs leading-relaxed text-muted">
{nego.done
? '카드 라운드 없이 조기 합의됐습니다 — 첫 제안가가 앵커가 이하면 협상 카드 없이 종료됩니다.'
: '가격 협상이 시작되면 선택된 협상 카드와 가격 지표·긴장도·페르소나가 여기에 표시됩니다.'}
</p>
)}
</Panel>
</aside>
)
}
+72
View File
@@ -0,0 +1,72 @@
import type { DemoCase } from '../content/cases'
/**
* 가격 트랙 — 이 페이지의 시그니처.
* 앵커가·목표가·기존 공급가를 한 수평 트랙에 놓고, 제안가가 내려오는 과정을 마커로 보여준다.
* 파랑 구간(앵커 이하) = 구매측 최적 · 앰버 구간(목표가 초과) = 협상 여지.
*/
export function PriceTrack({ demoCase, priceTrail }: { demoCase: DemoCase; priceTrail: number[] }) {
const { anchor, target, item_price } = demoCase
const current = priceTrail.length ? priceTrail[priceTrail.length - 1] : null
// 트랙 범위: min(앵커, 최저 제안가) 아래 여유 3% ~ max(기존가, 최고 제안가) 위 여유 3%
// (제안가가 앵커보다 낮아도 마커가 트랙 밖으로 클리핑되지 않도록 동적 확장)
const hi = Math.max(item_price, ...(priceTrail.length ? priceTrail : [item_price])) * 1.03
const lo = Math.min(anchor, ...(priceTrail.length ? priceTrail : [anchor])) * 0.97
const pos = (v: number) => Math.min(Math.max(((v - lo) / (hi - lo)) * 100, 0), 100)
const Tick = ({ value, label, cls }: { value: number; label: string; cls: string }) => (
<div className="absolute top-0 h-full" style={{ left: `${pos(value)}%` }}>
<div className={`h-full w-px ${cls}`} />
<div className="absolute top-full mt-1 -translate-x-1/2 text-center">
<div className="text-[10px] leading-tight text-muted">{label}</div>
<div className="font-mono text-[11px] font-medium leading-tight">{value.toLocaleString()}</div>
</div>
</div>
)
return (
<div>
<div className="relative mb-9 mt-6 h-3 rounded-full bg-paper">
{/* 구간 채색: [lo~anchor]=파랑(최적) · [anchor~target]=연파랑(합의권) · [target~hi]=앰버(초과) */}
<div className="absolute inset-y-0 left-0 rounded-l-full bg-blue/70" style={{ width: `${pos(anchor)}%` }} />
<div
className="absolute inset-y-0 bg-blue-soft"
style={{ left: `${pos(anchor)}%`, width: `${pos(target) - pos(anchor)}%` }}
/>
<div
className="absolute inset-y-0 rounded-r-full bg-amber-soft"
style={{ left: `${pos(target)}%`, width: `${100 - pos(target)}%` }}
/>
<Tick value={anchor} label="앵커가" cls="bg-blue" />
<Tick value={target} label="목표가" cls="bg-ink/50" />
<Tick value={item_price} label="기존가" cls="bg-muted/60" />
{/* 과거 제안 흔적 */}
{priceTrail.slice(0, -1).map((p, i) => (
<div
key={i}
className="absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-ink/25"
style={{ left: `${pos(p)}%` }}
/>
))}
{/* 현재 제안가 마커 */}
{current != null && (
<div
className="track-marker absolute top-1/2 -translate-x-1/2 -translate-y-1/2"
style={{ left: `${pos(current)}%` }}
>
<div className="size-4 rounded-full border-[3px] border-ink bg-white shadow-sm" />
<div className="absolute bottom-full left-1/2 mb-1.5 -translate-x-1/2 whitespace-nowrap rounded bg-ink px-1.5 py-0.5 font-mono text-[11px] font-semibold text-white">
{current.toLocaleString()}
</div>
</div>
)}
</div>
{current == null && (
<p className="text-xs text-muted">첫 제안가를 입력하면 트랙 위에 표시됩니다.</p>
)}
</div>
)
}
+74
View File
@@ -0,0 +1,74 @@
// 시연용 프리셋 케이스 — testdata/testset_1000.json에서 공급 유형별로 발췌.
// 사용자는 공급사 역할, 서버(MD 챗봇)는 구매측이다.
export interface CardData {
internet_min_price: number
anchoring_price: number
competitor_price_diff: number
trading_period: number
cumulative_amount: number
supplier_ranking: number
item_amount: number
item_ratio: number
voc_count: number
response_rate: number
product_sales_period: string
payment_terms: string
alternative_supplier_count: number
}
export interface DemoCase {
id: string
label: string // 공급 유형 설명
item_name: string
item_price: number // 기존 공급가
revenue: number
dist: 'R' | 'W' | 'M'
partners_yn: '다수' | '단독' | '없음'
partners: number
anchor: number // 앵커가 (구매측 내부 — 계기판에만 표시)
target: number // 목표가 (구매측 내부 — 계기판에만 표시)
scenario: string
card_data: CardData
}
export const DEMO_CASES: DemoCase[] = [
{
id: 'preset-1',
label: '유통 (Type A)',
item_name: 'NAS용 HDD 8T',
item_price: 20920, revenue: 26968712,
dist: 'R', partners_yn: '없음', partners: 0,
anchor: 19366, target: 20173, scenario: 'Scenario_B',
card_data: { internet_min_price: 20865, anchoring_price: 19366, competitor_price_diff: 2.3, trading_period: 8, cumulative_amount: 67659794, supplier_ranking: 11.3, item_amount: 4665587, item_ratio: 17.3, voc_count: 0, response_rate: 75.3, product_sales_period: '5년', payment_terms: '입고 후 30일 이내 현금 지급', alternative_supplier_count: 9 },
},
{
id: 'preset-2',
label: '총판·다수 (Type B)',
item_name: '키보드',
item_price: 34010, revenue: 25679490,
dist: 'W', partners_yn: '다수', partners: 3,
anchor: 31424, target: 33078, scenario: 'Scenario_A',
card_data: { internet_min_price: 33716, anchoring_price: 31424, competitor_price_diff: 2.8, trading_period: 3, cumulative_amount: 34900205, supplier_ranking: 18.8, item_amount: 1643487, item_ratio: 6.4, voc_count: 1, response_rate: 74.5, product_sales_period: '2년', payment_terms: '월 2회 정산 (15일·말일 마감)', alternative_supplier_count: 7 },
},
{
id: 'preset-3',
label: '총판·단독 (Type C)',
item_name: '콤부차 피치',
item_price: 61390, revenue: 4536820,
dist: 'W', partners_yn: '단독', partners: 1,
anchor: 57071, target: 60075, scenario: 'Scenario_D',
card_data: { internet_min_price: 59650, anchoring_price: 57071, competitor_price_diff: 3.7, trading_period: 1, cumulative_amount: 4942292, supplier_ranking: 42.1, item_amount: 199620, item_ratio: 4.4, voc_count: 0, response_rate: 69.5, product_sales_period: '5년', payment_terms: '월 2회 정산 (15일·말일 마감)', alternative_supplier_count: 10 },
},
{
id: 'preset-4',
label: '제조 (Type C)',
item_name: '광감쇄기(SC Type)',
item_price: 10600, revenue: 9014608,
dist: 'M', partners_yn: '없음', partners: 0,
anchor: 9862, target: 10492, scenario: 'Scenario_C',
card_data: { internet_min_price: 10819, anchoring_price: 9862, competitor_price_diff: 3.9, trading_period: 3, cumulative_amount: 26421260, supplier_ranking: 50.5, item_amount: 2767484, item_ratio: 30.7, voc_count: 0, response_rate: 91.9, product_sales_period: '4년', payment_terms: '입고 완료 월 익월 15일 지급', alternative_supplier_count: 4 },
},
]
export const DIST_LABEL: Record<string, string> = { R: '유통', W: '총판', M: '제조' }
+48
View File
@@ -0,0 +1,48 @@
@import "tailwindcss";
@theme {
/* 콘솔 팔레트 — 파랑 = 인하/성공 (국내 시장 컨벤션: 파랑=하락) */
--color-paper: #f5f6f8;
--color-panel: #ffffff;
--color-ink: #171b26;
--color-muted: #68707f;
--color-line: #e2e5eb;
--color-blue: #1d4ed8; /* 인하·성공·주요 액션 */
--color-blue-soft: #eef2ff;
--color-amber: #b45309; /* 긴장도·주의 */
--color-amber-soft: #fef3e2;
--color-green: #067647; /* 협상완료 */
--color-green-soft: #e7f6ee;
--color-bot: #f0f2f6; /* 봇 말풍선 */
--font-body: "Pretendard Variable", Pretendard, ui-sans-serif, system-ui, sans-serif;
--font-mono: "IBM Plex Mono", ui-monospace, monospace;
}
html, body, #root {
height: 100%;
}
body {
background: var(--color-paper);
color: var(--color-ink);
font-family: var(--font-body);
-webkit-font-smoothing: antialiased;
word-break: keep-all;
}
/* 봇 응답 등장 */
@keyframes rise {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: none; }
}
.msg-in { animation: rise 0.25s ease-out both; }
@media (prefers-reduced-motion: reduce) {
.msg-in { animation: none; }
}
/* 가격 트랙 마커 이동 */
.track-marker { transition: left 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
@media (prefers-reduced-motion: reduce) {
.track-marker { transition: none; }
}
+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
}
+10
View File
@@ -0,0 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "es2023",
"lib": ["ES2023", "DOM"],
"module": "esnext",
"types": ["vite/client"],
"allowArbitraryExtensions": true,
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "es2023",
"lib": ["ES2023"],
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"module": "nodenext",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
+18
View File
@@ -0,0 +1,18 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [react(), tailwindcss()],
server: {
port: 5317,
proxy: {
// NEGO_AGENT 서버 (:53117) — 데모는 항상 프록시 경유(/api)로 호출한다
'/api': {
target: 'http://127.0.0.1:53117',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
})