diff --git a/src/commands.ts b/src/commands.ts
index 627f79f..b4e3884 100644
--- a/src/commands.ts
+++ b/src/commands.ts
@@ -43,9 +43,9 @@ export async function handleCommand(
return `π νμ¬ μ»¨ν
μ€νΈ
-λΆμλ λ©μμ§: ${ctx.previousSummary?.message_count || 0}κ°
+λΆμλ λ©μμ§: ${ctx.previousSummary?.message_count ?? 0}κ°
λ²νΌ λ©μμ§: ${ctx.recentMessages.length}κ°
-νλ‘ν λ²μ : ${ctx.previousSummary?.generation || 0}
+νλ‘ν λ²μ : ${ctx.previousSummary?.generation ?? 0}
μ΄ λ©μμ§: ${ctx.totalMessages}κ°
π‘ ${remaining > 0 ? `${remaining}κ° λ©μμ§ ν νλ‘ν μ
λ°μ΄νΈ` : 'μ
λ°μ΄νΈ λκΈ° μ€'}`;
@@ -78,12 +78,18 @@ ${summary.summary}
return `π λν ν΅κ³
μ΄ λ©μμ§: ${ctx.totalMessages}κ°
-νλ‘ν λ²μ : ${ctx.previousSummary?.generation || 0}
-μ μ₯λ νλ‘ν: ${profileCount?.cnt || 0}κ°
+νλ‘ν λ²μ : ${ctx.previousSummary?.generation ?? 0}
+μ μ₯λ νλ‘ν: ${profileCount?.cnt ?? 0}κ°
λ²νΌ λκΈ°: ${ctx.recentMessages.length}κ°`;
}
case '/debug': {
+ // Admin only - exposes internal debug info
+ const adminId = env.DEPOSIT_ADMIN_ID ? parseInt(env.DEPOSIT_ADMIN_ID, 10) : null;
+ if (!adminId || userId !== adminId) {
+ return 'π μ΄ λͺ
λ Ήμ΄λ κ΄λ¦¬μλ§ μ¬μ©ν μ μμ΅λλ€.';
+ }
+
// λλ²κ·Έμ© λͺ
λ Ήμ΄ (κ°λ° μ μ μ©)
const ctx = await getConversationContext(env.DB, userId, chatId);
const recentMsgs = ctx.recentMessages.slice(-5).map((m, i) =>
@@ -95,7 +101,7 @@ ${summary.summary}
User ID: ${userId}
Chat ID: ${chatId}
Buffer Count: ${ctx.recentMessages.length}
-Summary Gen: ${ctx.previousSummary?.generation || 0}
+Summary Gen: ${ctx.previousSummary?.generation ?? 0}
μ΅κ·Ό λ²νΌ (5κ°):
${recentMsgs || '(λΉμ΄μμ)'}`;
diff --git a/src/deposit-agent.ts b/src/deposit-agent.ts
index 475b423..5058db2 100644
--- a/src/deposit-agent.ts
+++ b/src/deposit-agent.ts
@@ -20,6 +20,7 @@ const logger = createLogger('deposit-agent');
const MIN_DEPOSIT_AMOUNT = 1000; // 1,000μ
const MAX_DEPOSIT_AMOUNT = 100_000_000; // 1μ΅μ
+const DEFAULT_HISTORY_LIMIT = 10;
export interface DepositContext {
userId: number;
@@ -197,8 +198,8 @@ export async function executeDepositFunction(
}
case 'get_transactions': {
- // LIMIT κ° κ²μ¦: 1-100 λ²μ, κΈ°λ³Έκ° 10
- const limit = Math.min(Math.max(parseInt(String(funcArgs.limit)) || 10, 1), 100);
+ // LIMIT κ° κ²μ¦: 1-100 λ²μ
+ const limit = Math.min(Math.max(parseInt(String(funcArgs.limit)) || DEFAULT_HISTORY_LIMIT, 1), 100);
const transactions = await db.prepare(
`SELECT id, type, amount, status, depositor_name, description, created_at, confirmed_at
diff --git a/src/openai-service.ts b/src/openai-service.ts
index bc78266..cc9a5e8 100644
--- a/src/openai-service.ts
+++ b/src/openai-service.ts
@@ -413,7 +413,9 @@ export async function generateOpenAIResponse(
const saveableInfo = extractSaveableInfo(userMessage);
if (saveableInfo) {
// λΉλκΈ°λ‘ μ μ₯, μλ΅ μ§μ° μμ
- saveMemorySilently(db, telegramUserId, saveableInfo).catch(() => {});
+ saveMemorySilently(db, telegramUserId, saveableInfo).catch(err => {
+ logger.debug('Memory save failed (non-critical)', { error: (err as Error).message });
+ });
}
return finalResponse;
diff --git a/src/services/bank-sms-parser.ts b/src/services/bank-sms-parser.ts
index e91ad78..5cda688 100644
--- a/src/services/bank-sms-parser.ts
+++ b/src/services/bank-sms-parser.ts
@@ -4,6 +4,8 @@ import { createLogger } from '../utils/logger';
const logger = createLogger('bank-sms-parser');
+const SMS_CONTENT_MAX_LENGTH = 500;
+
/**
* μν SMS νμ± ν¨μ
*
@@ -52,7 +54,7 @@ function preprocessText(content: string): string {
// [Webλ°μ ] λλ μν ν€μλκ° μλ λΆλΆλ§ μΆμΆ
const smsStartMatch = text.match(/ \[Webλ°μ \]| \[νλμν\]| \[KB\]| \[μ ν\]| \[μ°λ¦¬\]| \[λν\]/);
if (smsStartMatch && smsStartMatch.index !== undefined) {
- text = text.slice(smsStartMatch.index, smsStartMatch.index + 500);
+ text = text.slice(smsStartMatch.index, smsStartMatch.index + SMS_CONTENT_MAX_LENGTH);
}
return text;
}
@@ -68,7 +70,7 @@ function parseWithRegex(text: string): BankNotification | null {
depositorName: depositor.trim(),
amount: parseInt(amountStr.replace(/,/g, '')),
transactionTime: parseDateTime(date, time),
- rawMessage: text.slice(0, 500),
+ rawMessage: text.slice(0, SMS_CONTENT_MAX_LENGTH),
};
}
@@ -83,7 +85,7 @@ function parseWithRegex(text: string): BankNotification | null {
amount: parseInt(amountStr.replace(/,/g, '')),
balanceAfter: balanceStr ? parseInt(balanceStr.replace(/,/g, '')) : undefined,
transactionTime: parseDateTime(date, time),
- rawMessage: text.slice(0, 500),
+ rawMessage: text.slice(0, SMS_CONTENT_MAX_LENGTH),
};
}
@@ -97,7 +99,7 @@ function parseWithRegex(text: string): BankNotification | null {
depositorName: depositor,
amount: parseInt(amountStr.replace(/,/g, '')),
transactionTime: date ? parseDateTime(date, time) : undefined,
- rawMessage: text.slice(0, 500),
+ rawMessage: text.slice(0, SMS_CONTENT_MAX_LENGTH),
};
}
@@ -111,7 +113,7 @@ function parseWithRegex(text: string): BankNotification | null {
depositorName: depositor,
amount: parseInt(amountStr.replace(/,/g, '')),
transactionTime: date ? parseDateTime(date) : undefined,
- rawMessage: text.slice(0, 500),
+ rawMessage: text.slice(0, SMS_CONTENT_MAX_LENGTH),
};
}
@@ -125,7 +127,7 @@ function parseWithRegex(text: string): BankNotification | null {
bankName: 'μμμμ',
depositorName: genericMatch1[2],
amount: parseInt(genericMatch1[1].replace(/,/g, '')),
- rawMessage: text.slice(0, 500),
+ rawMessage: text.slice(0, SMS_CONTENT_MAX_LENGTH),
};
}
@@ -135,7 +137,7 @@ function parseWithRegex(text: string): BankNotification | null {
bankName: 'μμμμ',
depositorName: genericMatch2[1],
amount: parseInt(genericMatch2[2].replace(/,/g, '')),
- rawMessage: text.slice(0, 500),
+ rawMessage: text.slice(0, SMS_CONTENT_MAX_LENGTH),
};
}
@@ -149,7 +151,7 @@ async function parseWithAI(text: string, env: Env): Promise