feat: add memory system and troubleshoot agent

Memory System:
- Add category-based memory storage (company, tech, role, location, server)
- Silent background saving via saveMemorySilently()
- Category-based overwrite (same category replaces old memory)
- Server-related pattern detection (AWS, GCP, k8s, traffic info)
- Memory management tool (list, delete)

Troubleshoot Agent:
- Session-based troubleshooting conversation (KV, 1h TTL)
- 20-year DevOps/SRE expert persona
- Support for server/infra, domain/DNS, code/deploy, network, database issues
- Internal tools: search_solution (Brave), lookup_docs (Context7)
- Auto-trigger on error-related keywords
- Session completion and cancellation support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-27 14:28:22 +09:00
parent 6392a17d4f
commit 860e36a688
13 changed files with 1328 additions and 58 deletions

View File

@@ -21,14 +21,19 @@ export async function handleCommand(
<b>명령어:</b>
/profile - 내 프로필 보기
/reset - 대화 초기화
/help - 도움말`;
/help - 도움말
💡 중요한 정보는 "기억해줘"로 저장하세요!`;
case '/help':
return `📖 <b>도움말</b>
/profile - 내 프로필 보기
/reset - 대화 초기화
<b>기억 기능:</b>
• "OOO 기억해줘" - 정보 저장
• "내 기억 보여줘" - 저장 목록
• "OOO 잊어줘" - 삭제
대화할수록 당신을 더 잘 이해합니다 💡`;
@@ -78,46 +83,6 @@ ${summary.summary}
버퍼 대기: ${ctx.recentMessages.length}`;
}
case '/reset': {
const ctx = await getConversationContext(env.DB, userId, chatId);
const msgCount = ctx.totalMessages;
const profileGen = ctx.previousSummary?.generation || 0;
if (msgCount === 0 && profileGen === 0) {
return '📭 삭제할 데이터가 없습니다.';
}
return `⚠️ <b>정말 초기화할까요?</b>
삭제될 데이터:
• 메시지 버퍼: ${ctx.recentMessages.length}
• 프로필: v${profileGen}
• 총 메시지 기록: ${msgCount}
<b>이 작업은 되돌릴 수 없습니다!</b>
확인하려면 /reset-confirm 을 입력하세요.
취소하려면 아무 메시지나 보내세요.`;
}
case '/reset-confirm': {
const result = await env.DB.batch([
env.DB.prepare('DELETE FROM message_buffer WHERE user_id = ?').bind(userId),
env.DB.prepare('DELETE FROM summaries WHERE user_id = ?').bind(userId),
]);
const deletedMessages = result[0].meta.changes || 0;
const deletedSummaries = result[1].meta.changes || 0;
return `🗑️ 초기화 완료!
삭제됨:
• 메시지: ${deletedMessages}
• 프로필: ${deletedSummaries}
새로운 대화를 시작하세요!`;
}
case '/debug': {
// 디버그용 명령어 (개발 시 유용)
const ctx = await getConversationContext(env.DB, userId, chatId);