chore: clean up unused code and fix test imports
- Remove unused config in commands.ts - Remove deprecated formatDepositResult function in deposit-tool.ts - Remove unused type imports in deposit-tool.ts - Fix import path in deposit-agent.test.ts (src/deposit-agent → src/agents/deposit-agent) This is a cleanup commit following the agent pattern unification work. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,10 +8,6 @@ export async function handleCommand(
|
||||
command: string,
|
||||
_args: string
|
||||
): Promise<string> {
|
||||
const config = {
|
||||
threshold: parseInt(env.SUMMARY_THRESHOLD || '20', 10),
|
||||
maxSummaries: parseInt(env.MAX_SUMMARIES_PER_USER || '3', 10),
|
||||
};
|
||||
|
||||
switch (command) {
|
||||
case '/start':
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
import { processDepositConsultation } from '../agents/deposit-agent';
|
||||
import type {
|
||||
Env,
|
||||
DepositFunctionResult,
|
||||
DepositTransaction,
|
||||
DepositPendingItem,
|
||||
ManageDepositArgs
|
||||
} from '../types';
|
||||
import type { Env } from '../types';
|
||||
import { createLogger, maskUserId } from '../utils/logger';
|
||||
|
||||
const logger = createLogger('deposit-tool');
|
||||
|
||||
const LOG_RESULT_MAX_LENGTH = 200;
|
||||
|
||||
export const manageDepositTool = {
|
||||
type: 'function',
|
||||
function: {
|
||||
@@ -47,108 +39,8 @@ export const manageDepositTool = {
|
||||
},
|
||||
};
|
||||
|
||||
// 예치금 결과 포맷팅 (고정 형식)
|
||||
function formatDepositResult(action: string, result: DepositFunctionResult): string {
|
||||
if ('error' in result) {
|
||||
return `🚫 ${result.error}`;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case 'balance':
|
||||
if ('formatted' in result) {
|
||||
return `💰 현재 잔액: ${result.formatted}`;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'account':
|
||||
if ('bank' in result && 'account' in result && 'holder' in result && 'instruction' in result) {
|
||||
return `💳 입금 계좌 안내
|
||||
|
||||
• 은행: ${result.bank}
|
||||
• 계좌번호: ${result.account}
|
||||
• 예금주: ${result.holder}
|
||||
|
||||
📌 ${result.instruction}`;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'request':
|
||||
if ('auto_matched' in result && 'amount' in result && 'depositor_name' in result) {
|
||||
if (result.auto_matched && 'new_balance' in result && result.new_balance !== undefined) {
|
||||
return `✅ 입금 확인 완료!
|
||||
|
||||
• 입금액: ${result.amount.toLocaleString()}원
|
||||
• 입금자: ${result.depositor_name}
|
||||
• 현재 잔액: ${result.new_balance.toLocaleString()}원
|
||||
|
||||
${result.message}`;
|
||||
} else if ('account_info' in result && result.account_info) {
|
||||
return `📋 입금 요청 등록 (#${result.transaction_id})
|
||||
|
||||
• 입금액: ${result.amount.toLocaleString()}원
|
||||
• 입금자: ${result.depositor_name}
|
||||
|
||||
💳 입금 계좌
|
||||
${result.account_info.bank} ${result.account_info.account}
|
||||
(${result.account_info.holder})
|
||||
|
||||
📌 ${result.message}`;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'history': {
|
||||
if ('transactions' in result) {
|
||||
if (result.message && !result.transactions?.length) {
|
||||
return `📋 ${result.message}`;
|
||||
}
|
||||
const statusIcon = (s: string) => s === 'confirmed' ? '✓' : s === 'pending' ? '⏳' : '✗';
|
||||
const typeLabel = (t: string) => t === 'deposit' ? '입금' : t === 'withdrawal' ? '출금' : t === 'refund' ? '환불' : t;
|
||||
const txList = result.transactions.map((tx: DepositTransaction) => {
|
||||
const date = tx.confirmed_at || tx.created_at;
|
||||
const dateStr = date ? new Date(date).toLocaleDateString('ko-KR', { month: '2-digit', day: '2-digit' }) : '';
|
||||
const desc = tx.description ? ` - ${tx.description}` : '';
|
||||
return `#${tx.id}: ${typeLabel(tx.type)} ${tx.amount.toLocaleString()}원 ${statusIcon(tx.status)} (${dateStr})${desc}`;
|
||||
}).join('\n');
|
||||
return `📋 거래 내역\n\n${txList}`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'cancel':
|
||||
if ('transaction_id' in result && 'success' in result) {
|
||||
return `✅ 거래 #${result.transaction_id} 취소 완료`;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pending': {
|
||||
if ('pending' in result) {
|
||||
if (result.message && !result.pending?.length) {
|
||||
return `📋 ${result.message}`;
|
||||
}
|
||||
const pendingList = result.pending.map((p: DepositPendingItem) =>
|
||||
`#${p.id}: ${p.depositor_name} ${p.amount.toLocaleString()}원 (${p.user})`
|
||||
).join('\n');
|
||||
return `📋 대기 중인 입금 요청\n\n${pendingList}`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'confirm':
|
||||
if ('transaction_id' in result && 'amount' in result) {
|
||||
return `✅ 입금 확인 완료 (#${result.transaction_id}, ${result.amount.toLocaleString()}원)`;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'reject':
|
||||
if ('transaction_id' in result) {
|
||||
return `❌ 입금 거절 완료 (#${result.transaction_id})`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return `💰 ${JSON.stringify(result)}`;
|
||||
}
|
||||
// DEPRECATED: Agent에서 포맷팅 처리 (하위 호환성 유지)
|
||||
// 이 함수는 더 이상 사용되지 않지만 리팩토링 완료 전까지 유지
|
||||
|
||||
export async function executeManageDeposit(
|
||||
args: { action: string; depositor_name?: string; amount?: number; transaction_id?: number; limit?: number },
|
||||
@@ -156,7 +48,7 @@ export async function executeManageDeposit(
|
||||
telegramUserId?: string,
|
||||
db?: D1Database
|
||||
): Promise<string> {
|
||||
const { action, depositor_name, amount, transaction_id, limit } = args;
|
||||
const { action, depositor_name, amount } = args;
|
||||
logger.info('시작', { action, depositor_name, amount, userId: maskUserId(telegramUserId) });
|
||||
|
||||
if (!telegramUserId || !db || !env) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* 7. 거래 상태 검증
|
||||
*/
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { executeDepositFunction, DepositContext } from '../src/deposit-agent';
|
||||
import { executeDepositFunction, DepositContext } from '../src/agents/deposit-agent';
|
||||
import {
|
||||
createTestUser,
|
||||
createBankNotification,
|
||||
|
||||
Reference in New Issue
Block a user