diff --git a/src/pages/agent-office/canvas/SpriteSheet.js b/src/pages/agent-office/canvas/SpriteSheet.js
deleted file mode 100644
index 5b84986..0000000
--- a/src/pages/agent-office/canvas/SpriteSheet.js
+++ /dev/null
@@ -1,121 +0,0 @@
-const PIXEL_CHARS = {
- stock: { body: '#4488cc', accent: '#cc4444', label: '주식', hair: '#332222' },
- music: { body: '#44aa88', accent: '#ffaa00', label: '음악', hair: '#443322' },
- blog: { body: '#d97706', accent: '#fde68a', label: '블로그', hair: '#3b2a1a' },
- realestate: { body: '#c026d3', accent: '#86efac', label: '청약', hair: '#2a2a3a' },
- claude: { body: '#8855cc', accent: '#cc88ff', label: 'Claude', hair: '#554466' },
-};
-
-const ANIM_FRAMES = {
- idle: { frames: 2, speed: 800 },
- working: { frames: 4, speed: 200 },
- waiting: { frames: 2, speed: 400 },
- break: { frames: 2, speed: 1000 },
- walk: { frames: 4, speed: 150 },
-};
-
-export function drawAgent(ctx, agentId, x, y, state, frameIndex, scale = 2) {
- const char = PIXEL_CHARS[agentId] || PIXEL_CHARS.claude;
- const s = scale;
- const anim = ANIM_FRAMES[state] || ANIM_FRAMES.idle;
- const frame = frameIndex % anim.frames;
-
- ctx.save();
- ctx.translate(x, y);
-
- // Shadow
- ctx.fillStyle = 'rgba(0,0,0,0.2)';
- ctx.fillRect(-4 * s, 14 * s, 8 * s, 2 * s);
-
- // Body
- ctx.fillStyle = char.body;
- ctx.fillRect(-3 * s, 2 * s, 6 * s, 8 * s);
-
- // Head
- ctx.fillStyle = '#ffcc99';
- ctx.fillRect(-3 * s, -4 * s, 6 * s, 6 * s);
-
- // Hair
- ctx.fillStyle = char.hair;
- ctx.fillRect(-3 * s, -5 * s, 6 * s, 2 * s);
-
- // Eyes
- ctx.fillStyle = '#222';
- const eyeOffset = state === 'break' && frame === 1 ? 0 : 1;
- ctx.fillRect(-2 * s, -1 * s, 1 * s, eyeOffset * s);
- ctx.fillRect(1 * s, -1 * s, 1 * s, eyeOffset * s);
-
- // Legs
- ctx.fillStyle = '#335';
- const legSpread = state === 'walk' ? (frame % 2 === 0 ? 1 : -1) : 0;
- ctx.fillRect(-2 * s, 10 * s, 2 * s, 4 * s);
- ctx.fillRect(0 + legSpread * s, 10 * s, 2 * s, 4 * s);
-
- // Accent
- ctx.fillStyle = char.accent;
- if (agentId === 'stock') {
- ctx.fillRect(0, 2 * s, 1 * s, 5 * s);
- } else if (agentId === 'music') {
- ctx.fillRect(-4 * s, -4 * s, 1 * s, 4 * s);
- ctx.fillRect(3 * s, -4 * s, 1 * s, 4 * s);
- ctx.fillRect(-4 * s, -5 * s, 8 * s, 1 * s);
- } else if (agentId === 'blog') {
- // 노트북 액센트 (무릎 위)
- ctx.fillRect(-3 * s, 6 * s, 6 * s, 1 * s);
- ctx.fillRect(-3 * s, 7 * s, 6 * s, 2 * s);
- } else if (agentId === 'realestate') {
- // 서류 가방 액센트 (손 옆)
- ctx.fillRect(3 * s, 4 * s, 2 * s, 3 * s);
- ctx.fillRect(3 * s, 3 * s, 2 * s, 1 * s);
- } else if (agentId === 'claude') {
- ctx.globalAlpha = 0.3 + 0.2 * Math.sin(Date.now() / 500);
- ctx.fillRect(-4 * s, -6 * s, 8 * s, 1 * s);
- ctx.globalAlpha = 1;
- }
-
- // Working: typing hands
- if (state === 'working') {
- ctx.fillStyle = '#ffcc99';
- const handY = 6 * s + (frame % 2) * s;
- ctx.fillRect(-4 * s, handY, 1 * s, 2 * s);
- ctx.fillRect(3 * s, handY, 1 * s, 2 * s);
- }
-
- // Waiting wobble
- if (state === 'waiting') {
- const wobble = Math.sin(Date.now() / 200) * s;
- ctx.translate(wobble, 0);
- }
-
- ctx.restore();
-}
-
-export function getAnimSpeed(state) {
- return (ANIM_FRAMES[state] || ANIM_FRAMES.idle).speed;
-}
-
-export function getCharLabel(agentId) {
- return (PIXEL_CHARS[agentId] || {}).label || agentId;
-}
-
-export function drawNotificationBadge(ctx, x, y, count, scale = 2) {
- const s = scale;
- const badgeX = x + 5 * s;
- const badgeY = y - 8 * s;
- const radius = 5 * s;
-
- ctx.beginPath();
- ctx.arc(badgeX, badgeY, radius, 0, Math.PI * 2);
- ctx.fillStyle = '#f43f5e';
- ctx.fill();
-
- ctx.strokeStyle = '#fff';
- ctx.lineWidth = 1;
- ctx.stroke();
-
- ctx.fillStyle = '#fff';
- ctx.font = `bold ${7 * s}px monospace`;
- ctx.textAlign = 'center';
- ctx.textBaseline = 'middle';
- ctx.fillText('!', badgeX, badgeY);
-}
diff --git a/src/pages/agent-office/components/AgentColumn.jsx b/src/pages/agent-office/components/AgentColumn.jsx
deleted file mode 100644
index 3893d10..0000000
--- a/src/pages/agent-office/components/AgentColumn.jsx
+++ /dev/null
@@ -1,203 +0,0 @@
-import React, { useState, useEffect } from 'react';
-import { getAgentTasks, getAgentTokenUsage } from '../../../api';
-
-const STATUS_BADGE = {
- pending: { label: '대기', bg: '#92400e' },
- approved: { label: '승인됨', bg: '#1e40af' },
- working: { label: '진행중', bg: '#3730a3' },
- succeeded: { label: '완료', bg: '#065f46' },
- failed: { label: '실패', bg: '#7f1d1d' },
- rejected: { label: '거절됨', bg: '#9a3412' },
-};
-
-const AGENT_COMMANDS = {
- stock: [
- { action: 'fetch_news', label: '뉴스 수집', icon: '📰' },
- { action: 'list_alerts', label: '알람 목록', icon: '🔔' },
- { action: 'test_telegram', label: 'TG 테스트', icon: '📨' },
- ],
- music: [
- { action: 'compose', label: '작곡 시작', icon: '🎵', needsInput: true },
- { action: 'credits', label: '크레딧', icon: '💳' },
- ],
- blog: [
- { action: 'research', label: '키워드 리서치', icon: '🔍', needsInput: true },
- { action: 'list_trend_keywords', label: '트렌드 목록', icon: '📋' },
- ],
- realestate: [
- { action: 'fetch_matches', label: '매칭 리포트', icon: '🏢' },
- { action: 'dashboard', label: '대시보드', icon: '📊' },
- ],
-};
-
-const AgentColumn = ({ agentId, meta, agentState, notification, onCommand, onApproval, onClearNotification }) => {
- const [tasks, setTasks] = useState([]);
- const [input, setInput] = useState('');
- const [activeCommand, setActiveCommand] = useState(null);
- const [tokenUsage, setTokenUsage] = useState(null);
- const [expanded, setExpanded] = useState(false);
-
- const state = agentState || { state: 'offline' };
- const commands = AGENT_COMMANDS[agentId] || [];
- const needsAttention = state.state === 'waiting' || notification > 0;
- const isOpen = expanded || needsAttention;
-
- useEffect(() => {
- getAgentTasks(agentId, 10)
- .then(d => setTasks(d.tasks || []))
- .catch(() => setTasks([]));
- }, [agentId]);
-
- // Refresh tasks when state changes to idle (task likely completed)
- useEffect(() => {
- if (state.state === 'idle' && state.detail) {
- getAgentTasks(agentId, 10)
- .then(d => setTasks(d.tasks || []))
- .catch(() => {});
- }
- }, [agentId, state.state, state.detail]);
-
- // 오늘자 AI 토큰 사용량 폴링 (30초 간격 + 작업 완료 시 즉시 갱신)
- useEffect(() => {
- let cancelled = false;
- const fetchUsage = () => {
- getAgentTokenUsage(agentId, 1)
- .then(d => { if (!cancelled) setTokenUsage(d); })
- .catch(() => {});
- };
- fetchUsage();
- const interval = setInterval(fetchUsage, 30000);
- return () => {
- cancelled = true;
- clearInterval(interval);
- };
- }, [agentId, state.state, state.detail]);
-
- const handleQuickAction = (cmd) => {
- if (cmd.needsInput) {
- setActiveCommand(cmd.action);
- } else {
- onCommand(agentId, cmd.action, {});
- }
- onClearNotification();
- };
-
- const handleSend = () => {
- if (!input.trim() || !activeCommand) return;
- const params = activeCommand === 'compose' ? { prompt: input }
- : activeCommand === 'research' ? { keyword: input }
- : { message: input };
- onCommand(agentId, activeCommand, params);
- setInput('');
- setActiveCommand(null);
- };
-
- const formatTaskTime = (task) => {
- const iso = task.completed_at || task.created_at;
- if (!iso) return '';
- const d = new Date(iso);
- if (isNaN(d.getTime())) return '';
- const now = new Date();
- const pad = (n) => String(n).padStart(2, '0');
- const hm = `${pad(d.getHours())}:${pad(d.getMinutes())}`;
- const sameDay = d.toDateString() === now.toDateString();
- const yesterday = new Date(now); yesterday.setDate(now.getDate() - 1);
- const isYesterday = d.toDateString() === yesterday.toDateString();
- if (sameDay) return `오늘 ${hm}`;
- if (isYesterday) return `어제 ${hm}`;
- return `${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${hm}`;
- };
-
- const handleHeaderClick = (e) => {
- e.stopPropagation();
- setExpanded(v => !v);
- onClearNotification();
- };
-
- return (
-
-
- {meta.name}
- {tokenUsage && tokenUsage.total_tokens > 0 && (
-
- 🧮 {tokenUsage.total_tokens.toLocaleString()}
-
- )}
- {state.state}
- {notification > 0 && {notification}}
- {isOpen ? '▾' : '▸'}
-
-
-
-
-
- {state.detail && (
-
{state.detail}
- )}
-
- {state.state === 'waiting' && state.taskId && (
-
- 승인 대기
-
-
-
- )}
-
-
- {commands.map(cmd => (
-
- ))}
-
-
- {activeCommand && (
-
- setInput(e.target.value)}
- onKeyDown={e => e.key === 'Enter' && handleSend()}
- placeholder="입력..."
- autoFocus
- />
-
-
- )}
-
-
-
최근 작업
- {tasks.length === 0 &&
이력 없음
}
- {tasks.map(task => {
- const badge = STATUS_BADGE[task.status] || STATUS_BADGE.pending;
- return (
-
-
- {task.task_type}
- {badge.label}
-
-
- {formatTaskTime(task)}
- {task.result_data?.telegram_sent !== undefined && (
- {task.result_data.telegram_sent ? ' TG OK' : ' TG Fail'}
- )}
-
- {task.result_data && (
-
- 결과
- {JSON.stringify(task.result_data, null, 2)}
-
- )}
-
- );
- })}
-
-
-
- );
-};
-
-export default AgentColumn;
diff --git a/src/pages/agent-office/components/ChatPanel.jsx b/src/pages/agent-office/components/ChatPanel.jsx
deleted file mode 100644
index d9e5642..0000000
--- a/src/pages/agent-office/components/ChatPanel.jsx
+++ /dev/null
@@ -1,125 +0,0 @@
-import React, { useState } from 'react';
-
-const AGENT_COMMANDS = {
- stock: [
- { action: 'fetch_news', label: '뉴스 수집', icon: '📰' },
- { action: 'list_alerts', label: '알람 목록', icon: '🔔' },
- { action: 'test_telegram', label: '텔레그램 테스트', icon: '📨' },
- ],
- music: [
- { action: 'compose', label: '작곡 시작', icon: '🎵', needsInput: true },
- { action: 'credits', label: '크레딧 확인', icon: '💳' },
- ],
- blog: [
- { action: 'research', label: '키워드 리서치', icon: '🔍', needsInput: true },
- { action: 'list_trend_keywords', label: '트렌드 목록', icon: '📋' },
- ],
- realestate: [
- { action: 'fetch_matches', label: '매칭 리포트', icon: '🏢' },
- { action: 'dashboard', label: '대시보드', icon: '📊' },
- ],
-};
-
-const AGENT_NAMES = {
- stock: '주식 트레이더',
- music: '음악 프로듀서',
- blog: '블로그 마케터',
- realestate: '청약 애널리스트',
-};
-
-const ChatPanel = ({ agentId, agentState, onCommand, onApproval, onClose }) => {
- const [input, setInput] = useState('');
- const [activeCommand, setActiveCommand] = useState(null);
-
- const commands = AGENT_COMMANDS[agentId] || [];
- const state = agentState || {};
-
- const handleSend = () => {
- if (!input.trim() || !activeCommand) return;
- const params = activeCommand === 'compose' ? { prompt: input }
- : activeCommand === 'research' ? { keyword: input }
- : { message: input };
- onCommand(agentId, activeCommand, params);
- setInput('');
- setActiveCommand(null);
- };
-
- const handleQuickAction = (cmd) => {
- if (cmd.needsInput) {
- setActiveCommand(cmd.action);
- } else {
- onCommand(agentId, cmd.action, {});
- }
- };
-
- return (
-
-
-
- {AGENT_NAMES[agentId] || agentId}
-
-
- {state.state || 'idle'}
-
-
-
-
- {state.detail && (
-
{state.detail}
- )}
-
- {state.state === 'waiting' && state.taskId && (
-
-
승인 대기 중인 작업이 있습니다
-
-
-
-
-
- )}
-
-
- {commands.map(cmd => (
-
- ))}
-
-
- {activeCommand && (
-
- setInput(e.target.value)}
- onKeyDown={e => e.key === 'Enter' && handleSend()}
- placeholder={
- activeCommand === 'compose' ? '프롬프트 입력...'
- : activeCommand === 'research' ? '키워드 입력...'
- : '메시지 입력...'
- }
- autoFocus
- />
-
-
- )}
-
- {state.lastResult && (
-
-
최근 결과
-
{JSON.stringify(state.lastResult, null, 2)}
-
- )}
-
- );
-};
-
-export default ChatPanel;
diff --git a/src/pages/agent-office/components/CommandColumn.jsx b/src/pages/agent-office/components/CommandColumn.jsx
deleted file mode 100644
index 647edbe..0000000
--- a/src/pages/agent-office/components/CommandColumn.jsx
+++ /dev/null
@@ -1,115 +0,0 @@
-import React, { useState } from 'react';
-
-const TARGETS = [
- { id: 'stock', name: '주식 트레이더' },
- { id: 'music', name: '음악 프로듀서' },
- { id: 'blog', name: '블로그 마케터' },
- { id: 'realestate', name: '청약 애널리스트' },
-];
-
-const TARGET_ICONS = {
- stock: '📈',
- music: '🎵',
- blog: '✍️',
- realestate: '🏢',
-};
-
-const QUICK_COMMANDS = [
- { target: 'stock', action: 'fetch_news', label: '뉴스 수집' },
- { target: 'stock', action: 'test_telegram', label: 'TG 테스트' },
- { target: 'music', action: 'credits', label: '크레딧 확인' },
- { target: 'blog', action: 'list_trend_keywords', label: '트렌드 목록' },
- { target: 'realestate', action: 'fetch_matches', label: '매칭 리포트' },
- { target: 'realestate', action: 'dashboard', label: '청약 대시보드' },
-];
-
-const CommandColumn = ({ agents, onCommand }) => {
- const [target, setTarget] = useState('stock');
- const [action, setAction] = useState('');
- const [params, setParams] = useState('');
- const [history, setHistory] = useState([]);
-
- const handleSend = () => {
- if (!action.trim()) return;
- let parsedParams = {};
- if (params.trim()) {
- try { parsedParams = JSON.parse(params); }
- catch { parsedParams = { message: params }; }
- }
- onCommand(target, action, parsedParams);
- setHistory(prev => [{
- time: new Date().toLocaleTimeString(),
- target,
- action,
- params: parsedParams,
- }, ...prev].slice(0, 20));
- setAction('');
- setParams('');
- };
-
- const handleQuick = (cmd) => {
- onCommand(cmd.target, cmd.action, {});
- setHistory(prev => [{
- time: new Date().toLocaleTimeString(),
- target: cmd.target,
- action: cmd.action,
- params: {},
- }, ...prev].slice(0, 20));
- };
-
- return (
-
-
- CEO 명령
-
-
-
-
-
-
-
setAction(e.target.value)}
- onKeyDown={e => e.key === 'Enter' && handleSend()}
- placeholder="명령어 (fetch_news, compose...)"
- />
-
setParams(e.target.value)}
- onKeyDown={e => e.key === 'Enter' && handleSend()}
- placeholder="파라미터 (JSON 또는 텍스트)"
- />
-
-
-
-
- {QUICK_COMMANDS.map((cmd, i) => (
-
- ))}
-
-
-
-
명령 이력
- {history.length === 0 &&
이력 없음
}
- {history.map((h, i) => (
-
-
- {h.target}.{h.action}
- {h.time}
-
-
- ))}
-
-
- );
-};
-
-export default CommandColumn;
diff --git a/src/pages/agent-office/components/DocumentPanel.jsx b/src/pages/agent-office/components/DocumentPanel.jsx
deleted file mode 100644
index e9c0ff3..0000000
--- a/src/pages/agent-office/components/DocumentPanel.jsx
+++ /dev/null
@@ -1,195 +0,0 @@
-import React, { useState, useEffect, useCallback } from 'react';
-import { getActivityFeed, getAgentTasks, getAgentLogs } from '../../../api';
-
-const STATUS_BADGE = {
- pending: { label: '대기', color: '#fbbf24' },
- approved: { label: '승인됨', color: '#60a5fa' },
- working: { label: '진행중', color: '#818cf8' },
- succeeded: { label: '완료', color: '#34d399' },
- failed: { label: '실패', color: '#f87171' },
- rejected: { label: '거절됨', color: '#fb923c' },
-};
-
-const LOG_LEVEL_COLOR = {
- info: '#60a5fa',
- warning: '#fbbf24',
- error: '#f87171',
-};
-
-const DocumentPanel = ({ onClose }) => {
- const [tab, setTab] = useState('feed');
- const [feed, setFeed] = useState([]);
- const [feedLoading, setFeedLoading] = useState(false);
-
- const [selectedAgent, setSelectedAgent] = useState('stock');
- const [detailTab, setDetailTab] = useState('tasks');
- const [tasks, setTasks] = useState([]);
- const [logs, setLogs] = useState([]);
- const [detailLoading, setDetailLoading] = useState(false);
-
- const loadFeed = useCallback(() => {
- setFeedLoading(true);
- getActivityFeed(80)
- .then(data => setFeed(data.items || []))
- .catch(() => setFeed([]))
- .finally(() => setFeedLoading(false));
- }, []);
-
- const loadDetail = useCallback(() => {
- setDetailLoading(true);
- Promise.all([
- getAgentTasks(selectedAgent, 30).then(d => d.tasks || []).catch(() => []),
- getAgentLogs(selectedAgent, 50).then(d => d.logs || []).catch(() => []),
- ]).then(([t, l]) => {
- setTasks(t);
- setLogs(l);
- }).finally(() => setDetailLoading(false));
- }, [selectedAgent]);
-
- useEffect(() => {
- if (tab === 'feed') loadFeed();
- else loadDetail();
- }, [tab, loadFeed, loadDetail]);
-
- const formatTime = (t) => t ? t.replace('T', ' ').slice(0, 19) : '';
-
- return (
-
-
- CEO 보고서
-
-
-
-
-
-
-
-
- {tab === 'feed' && (
-
-
-
-
- {feedLoading &&
로딩 중...
}
- {!feedLoading && feed.length === 0 &&
활동 없음
}
- {feed.map((item, i) => (
-
-
-
- {item.agent_id}
-
- {item.type === 'task' ? (
-
- {(STATUS_BADGE[item.status] || STATUS_BADGE.pending).label}
-
- ) : (
-
- [{item.level}]
-
- )}
- {item.telegram_sent !== undefined && (
- {item.telegram_sent ? 'TG OK' : 'TG Fail'}
- )}
-
-
{item.message}
-
- {formatTime(item.created_at)}
- {item.duration_seconds != null && ` · ${item.duration_seconds}s`}
-
-
- ))}
-
- )}
-
- {tab === 'detail' && (
-
-
- {[
- { id: 'stock', name: '주식 트레이더' },
- { id: 'music', name: '음악 프로듀서' },
- { id: 'blog', name: '블로그 마케터' },
- { id: 'realestate', name: '청약 애널리스트' },
- ].map(a => (
-
- ))}
-
-
-
-
-
-
-
- {detailLoading &&
로딩 중...
}
-
- {!detailLoading && detailTab === 'tasks' && (
-
- {tasks.length === 0 &&
이력 없음
}
- {tasks.map(task => {
- const badge = STATUS_BADGE[task.status] || STATUS_BADGE.pending;
- return (
-
-
- {task.task_type}
-
- {badge.label}
-
-
-
- {formatTime(task.created_at)}
- {task.completed_at && ` → ${formatTime(task.completed_at)}`}
-
- {task.result_data && (
-
-
- 결과 보기
- {task.result_data.telegram_sent !== undefined && (
-
- {task.result_data.telegram_sent ? ' TG OK' : ' TG Fail'}
-
- )}
-
- {JSON.stringify(task.result_data, null, 2)}
-
- )}
-
- );
- })}
-
- )}
-
- {!detailLoading && detailTab === 'logs' && (
-
- {logs.length === 0 &&
로그 없음
}
- {logs.map(log => (
-
-
- [{log.level}]
-
- {log.message}
- {formatTime(log.created_at)}
-
- ))}
-
- )}
-
- )}
-
- );
-};
-
-export default DocumentPanel;