Commit Graph

143 Commits

Author SHA1 Message Date
kappa
a6d1c4ecd4 feat: add conversation_tables migration
Add migration for conversation_tables to support dynamic per-user conversation storage.

- CREATE TABLE conversation_tables with telegram_id, table_name, message_count
- Add indexes on last_message_at and message_count for query performance
- Tested successfully on local D1 database

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:35 +09:00
kappa
123b145bf9 feat: add conversation storage types
Add type definitions for the new conversation storage system:
- ConversationMessage: Individual message structure with tool calls/results
- ConversationTableMeta: Metadata for per-user conversation tables
- ConversationStats: Aggregated statistics per user
- ArchiveResult: Results from archiving operations

These types will be used by the upcoming conversation storage implementation
that replaces the message_buffer + summaries system with dynamic per-user
tables and automatic archiving.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:35 +09:00
kappa
02b18301a1 fix: resolve TypeScript errors after SessionManager refactoring
- Remove unused import types (*SessionStatus, OpenAIMessage)
- Replace deprecated session functions with SessionManager API
- Prefix unused base class parameters with underscore
- Update all session management calls across agents and tools

Files affected:
- src/agents/*.ts (removed unused imports)
- src/utils/session-manager.ts (unused param prefixes)
- src/tools/server-tool.ts (SessionManager migration)
- src/tools/troubleshoot-tool.ts (SessionManager migration)
- src/routes/api/chat.ts (SessionManager migration)
- src/routes/handlers/message-handler.ts (SessionManager migration)

Verification:
- TypeScript: compiles without errors
- Tests: 223 passed (10 pre-existing failures)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:35 +09:00
kappa
edf1bbc9a2 refactor: apply SessionManager to all agents
- domain-agent: use DomainSessionManager (handles target_domain)
- deposit-agent: use SessionManager<DepositSession>
- troubleshoot-agent: use SessionManager<TroubleshootSession>
- server-agent: use ServerSessionManager (handles last_recommendation)
- Remove ~760 lines of duplicated session CRUD code
- Use centralized constants from agent-config.ts
- Import OpenAI types from types.ts instead of local definitions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:35 +09:00
kappa
ffd310c903 feat: add OpenAI types and AI caller utility
- Consolidate OpenAI types to types.ts
- Create reusable callOpenAI() function
- Add tool call parsing and result handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
c8e1362375 feat: add centralized agent configuration
- Create src/constants/agent-config.ts
- Consolidate TTL, MAX_MESSAGES, AI settings
- Add type-safe getSessionConfig() helper

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
1160719a78 docs: add SessionManager usage guide
- Comprehensive API documentation
- Migration examples (before/after)
- Specialized manager patterns
- Next steps for agent refactoring

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
36fdc4fe3d feat: add SessionManager generic class for agent sessions
- Create reusable SessionManager<T> with CRUD operations
- Support for session expiry, message limits
- Specialized managers for Domain and Server agents
- Reduce code duplication across 4 agents

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
c6345a8f2f 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>
2026-02-05 12:47:34 +09:00
kappa
de36978de4 refactor: unify server-agent to new pattern
- Change field names to snake_case (user_id, collected_info, last_recommendation, created_at, updated_at, expires_at)
- Extract system prompts to constants (SERVER_EXPERT_PROMPT, SERVER_REVIEW_PROMPT)
- Add __PASSTHROUGH__/__SESSION_END__ marker support
- Change handler signature to match other agents (db, userId, userMessage, env, options)
- Add helper functions for consistency (createServerSession, isSessionExpired, addMessageToSession, hasServerSession)
- Update saveSe rverSession signature to not need userId separately
- Rename tools constant from serverExpertTools to serverExpertTools (camelCase)
- Change AI call parameter order for consistency
- Add performance logging
- Update openai-service.ts routing to use hasServerSession
- Update server-tool.ts to use new session creation helpers
- Update message-handler.ts and api/chat.ts field references

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
5d8150e67c refactor: migrate troubleshoot-agent from KV to D1
- Create troubleshoot_sessions table in D1
- Replace KV session storage with D1
- Unify field names to snake_case (user_id, collected_info, created_at, updated_at, expires_at)
- Add __PASSTHROUGH__/__SESSION_END__ marker support
- Change handler signature to match domain/deposit pattern
- Extract system prompt to constant TROUBLESHOOT_EXPERT_PROMPT
- Add hasTroubleshootSession() for routing
- Update openai-service.ts to use new D1-based functions
- Update troubleshoot-tool.ts to use D1 instead of KV
- Add TroubleshootSessionStatus type

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
2bd9bc4c2b feat: complete agent refactoring integration
- Add deposit session routing to openai-service.ts
- Convert deposit-tool to agent trigger (delegate to deposit-agent)
- Update CLAUDE.md with new agent architecture

Changes:
- openai-service.ts: Import and check hasDepositSession, route to processDepositConsultation
- deposit-tool.ts: Convert action → natural language → delegate to Deposit Agent
- CLAUDE.md: Update Core Services, Function Calling Tools, Data Layer, Deposit System sections

All tests passing (192/195), dev server starts successfully.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
f5c38ad909 refactor: move deposit-agent to agents/ and add session support
- Move deposit-agent.ts to src/agents/
- Add D1 session CRUD functions (getDepositSession, saveDepositSession, etc.)
- Add Deposit Expert AI with function calling
- Add processDepositConsultation handler for session-based flow
- Add deposit_sessions table migration (006_add_deposit_sessions.sql)
- Update import paths in deposit-tool.ts
- Add DEPOSIT_BANK_* environment variables to Env interface

Session flow: collecting_amount → collecting_name → confirming → completed
Smart parsing: "홍길동 5만원" → Go directly to confirming

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
cb2bd48ad6 refactor: convert domain-tool to agent trigger
- Modify executeManageDomain to delegate to domain agent
- Add buildDomainMessage helper for action-to-message conversion
- Keep internal functions for agent tool execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
d069e84efd feat: add domain session routing to openai-service
- Import domain agent functions
- Add domain session check before main AI processing
- Route to domain agent when session exists
- Handle __PASSTHROUGH__ for non-domain messages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
f9f577f25c feat: implement processDomainConsultation main handler
- Add full conversation flow with session management
- Handle tool call execution
- Support __PASSTHROUGH__ and __SESSION_END__ markers
- Add hasDomainSession helper for routing
- Export executeDomainAction from domain-tool.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
160569bf8c feat: add domain tool execution dispatcher
- Add executeDomainToolCall function
- Integrate with existing domain-tool.ts functions
- Map AI tool calls to domain actions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
69aac96daa feat: add domain agent AI call functions
- Add domain expert system prompt
- Add domain tools for function calling
- Add callDomainExpertAI function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
e463a88803 feat: create domain-agent basic structure
- Add D1 session CRUD functions (getDomainSession, saveDomainSession, deleteDomainSession)
- Add session helper functions (createDomainSession, isSessionExpired, addMessageToSession)
- Add placeholder for main consultation handler (processDomainConsultation)
- Fix server-agent import paths in server-tool.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
676f3866e8 feat: add DomainSession and DepositSession types
- Add type definitions for domain and deposit agent sessions
- Follow existing ServerSession pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
8f16de40cc refactor: move troubleshoot-agent to agents directory
- Move troubleshoot-agent.ts to src/agents/
- Update import paths in dependent files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
4642c1ff94 refactor: move server-agent to agents directory
- Create src/agents/ directory for agent modules
- Move server-agent.ts to new location
- Update import paths in all dependent files:
  - openai-service.ts
  - tools/server-tool.ts
  - routes/handlers/message-handler.ts
  - routes/api/chat.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kappa
f3596fb509 chore: add domain/deposit agent session tables migration
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:34 +09:00
kaffa
356eb6ccc8 Add Gitea Actions CI workflow 2026-02-03 11:39:08 +09:00
kaffa
94d615a3bf Add MIT LICENSE 2026-02-03 11:20:55 +09:00
kappa
619e952520 docs: restructure CLAUDE.md for better readability
- Add numbered sections (1-9) for clear navigation
- Remove verbose agent descriptions, keep concise
- Consolidate duplicate content
- Improve formatting consistency

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 23:47:20 +09:00
kappa
2b1bc6a371 feat: improve server management and refund display
Server Management:
- Fix /server command API auth (query param instead of header)
- Show server specs (vCPU/RAM/Bandwidth) in /server list
- Prevent AI from refusing server deletion based on expiration date
- Add explicit instructions in tool description and system prompt

Refund Display:
- Show before/after balance in server deletion refund message
- Format: 환불 전 잔액 → 환불 금액 → 환불 후 잔액

Other Changes:
- Add stopped status migration for server orders
- Clean up callback handler (remove deprecated code)
- Update constants and pattern utilities

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 05:30:59 +09:00
kappa
18e7d3ca6e test: add comprehensive unit tests for utils and security
- Add security.test.ts: 36 tests for webhook validation, rate limiting
- Add circuit-breaker.test.ts: 31 tests for state transitions
- Add retry.test.ts: 25 tests for exponential backoff
- Add api-helper.test.ts: 25 tests for API abstraction
- Add optimistic-lock.test.ts: 11 tests for concurrency control
- Add summary-service.test.ts: 29 tests for profile system

Total: 157 new test cases (222 passing overall)

- Fix setup.ts D1 schema initialization for Miniflare
- Update vitest.config.ts to exclude demo files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 11:38:49 +09:00
kappa
fbe696b88c refactor: complete P0-P1 improvements
Constants migration:
- server-agent.ts: SERVER_CONSULTATION_STATUS, LANGUAGE_CODE
- troubleshoot-agent.ts: TROUBLESHOOT_STATUS
- notification.ts: NOTIFICATION_TYPE

API improvements:
- search-tool.ts: Zod schema validation for Brave/Context7 APIs
- api-helper.ts: Centralized API call utility with retry/timeout

Testing:
- kv-cache.test.ts: 38 test cases for cache abstraction

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 11:02:27 +09:00
kappa
f304c6a7d4 refactor: apply new utilities and constants across codebase
P0 fixes:
- KV Cache migration: security.ts now delegates to kv-cache.ts (74% code reduction)
- Environment validation: index.ts validates env on first request
- Type safety: optimistic-lock.ts removes `as any` with proper interface

P1 improvements:
- Constants applied to deposit-agent.ts (TRANSACTION_STATUS, TRANSACTION_TYPE)
- Constants applied to callback-handler.ts (CALLBACK_PREFIXES)
- Constants applied to domain-tool.ts (MESSAGE_MARKERS)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:49:31 +09:00
kappa
699eed1530 refactor: add KV cache, env validation, logger types, constants
- Add KV cache abstraction layer (src/services/kv-cache.ts)
- Add Zod-based env validation (src/utils/env-validation.ts)
- Improve logger types: any → unknown for type safety
- Add centralized constants file (src/constants/index.ts)
- Fix security.ts unused import

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:40:51 +09:00
kappa
3a671a5707 refactor: add pattern utils and split api.ts into modules
1. Pattern Detection Utility (src/utils/patterns.ts)
- Centralize tool category patterns (domain, deposit, server, etc.)
- Add memory category patterns (company, tech, role)
- Add region detection (korea, japan, singapore, us)
- Add tech stack detection (postgres, redis, nodejs, etc.)
- Export detectToolCategories(), detectRegion(), detectTechStack()

2. API Route Modularization (src/routes/api/)
- deposit.ts: /balance, /deduct with apiKeyAuth middleware
- chat.ts: /test, /chat with session handling
- contact.ts: Contact form with CORS middleware
- metrics.ts: Circuit Breaker status endpoint

3. Updates
- tools/index.ts: Use detectToolCategories from patterns.ts
- api.ts: Compose sub-routers (899 → 53 lines, 94% reduction)

Benefits:
- Single source of truth for patterns
- Better code organization
- Easier maintenance and testing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:34:12 +09:00
kappa
40447952a9 refactor: migrate webhook to Hono router with auth middleware
webhook.ts:
- Convert handleWebhook() to Hono router pattern
- Create telegramAuth middleware with security validations:
  - HTTP method validation (POST only)
  - Content-Type validation (application/json)
  - Timing-safe secret token comparison
  - Timestamp validation (5-min replay attack prevention)
  - Request body structure validation
- Always return 200 to Telegram (prevents retry storms)
- Structured logging with context

index.ts:
- Import webhookRouter instead of handleWebhook
- Use app.route('/webhook', webhookRouter)

Benefits:
- Consistent Hono pattern across all routes
- Reusable auth middleware
- Better separation of concerns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:02:35 +09:00
kappa
3cfcb06f27 refactor: centralize auth middleware and standardize logging
1. API Key Middleware (api.ts)
- Create apiKeyAuth Hono middleware with timing-safe comparison
- Apply to /deposit/balance and /deposit/deduct routes
- Remove duplicate requireApiKey() calls from handlers
- Reduce ~15 lines of duplicated code

2. Logger Standardization (6 files, 27 replacements)
- webhook.ts: 2 console.error → logger
- message-handler.ts: 7 console → logger
- deposit-matcher.ts: 4 console → logger
- n8n-service.ts: 3 console.error → logger
- circuit-breaker.ts: 8 console → logger
- retry.ts: 3 console → logger

Benefits:
- Single point of auth change
- Structured logging with context
- Better observability in production

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:58:15 +09:00
kappa
86af187aa1 refactor: migrate API routes to Hono sub-router
- Create Hono router in api.ts
- Convert 6 API endpoints to Hono format:
  - GET /api/deposit/balance
  - POST /api/deposit/deduct
  - POST /api/test
  - POST /api/chat
  - POST /api/contact
  - GET /api/metrics
- Use Hono CORS middleware for /contact
- Remove manual handleApiRequest and handleContactPreflight
- Integrate with main app via app.route('/api', apiRouter)

Benefits:
- Cleaner declarative routing (44 insertions, 48 deletions)
- Built-in CORS middleware
- Better code organization

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:48:07 +09:00
kappa
2756dbe804 refactor: migrate HTTP routing to Hono framework
- Add hono dependency
- Replace if/else routing chain with Hono app
- Convert all HTTP routes to Hono format:
  - GET /health, /setup-webhook, /webhook-info
  - POST /webhook
  - ALL /api/*
  - GET /
- Keep email, scheduled, queue handlers unchanged
- Maintain 100% backward compatibility

Benefits:
- Cleaner declarative routing
- Type-safe Env bindings
- Ready for future middleware (CORS, rate limiting)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:40:38 +09:00
kappa
41f99334eb feat: implement server start/stop functionality
- Replace stub implementations with actual API calls
- POST /api/provision/orders/{order_id}/start
- POST /api/provision/orders/{order_id}/stop
- Add proper validation, logging, and error handling
- Follow existing code patterns (callProvisionAPI, __DIRECT__)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:46:05 +09:00
kappa
79b8555893 refactor: P3 low priority improvements
P3-1: Magic numbers to named constants
- SMS_CONTENT_MAX_LENGTH = 500 (bank-sms-parser.ts)
- DEFAULT_HISTORY_LIMIT = 10 (deposit-agent.ts)
- LOG_RESULT_MAX_LENGTH = 200 (deposit-tool.ts)

P3-2: Debug command admin-only access
- Add DEPOSIT_ADMIN_ID check for /debug command
- Return "관리자만 사용 가능" for non-admins

P3-3: Stats query null handling
- Replace || with ?? for COUNT results
- Prevents 0 being overwritten incorrectly

P3-4: Memory save error logging
- Add logger.debug for saveMemorySilently failures
- Non-critical but helps debug memory issues

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:43:00 +09:00
kappa
69e4dcc338 fix: P2 medium priority issues - validation and logging
P2-1: Tool selection fallback optimization
- Return only utility tools when no patterns match
- Reduces token usage by ~80% in fallback cases

P2-2: Minimum deposit amount validation
- Add MIN_DEPOSIT_AMOUNT = 1,000원
- Prevents spam with tiny deposits

P2-3: Standardize logging
- Replace console.log/error with structured logger
- bank-sms-parser.ts and security.ts

P2-4: Nameserver format validation
- Add validateNameservers() function
- Check minimum 2 NS, valid hostname format
- Clear error messages in Korean

P2-5: Optimistic lock error context
- Return specific error for version conflicts
- User-friendly message: "동시 요청으로 처리가 지연됨"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:40:41 +09:00
kappa
97b8f3c7f7 fix: add comprehensive error handling for P1 critical issues
P1-1: Callback query error handling
- Add try-catch around domain registration and server order
- Send user-friendly error messages on failure
- Use answerCallbackQuery to acknowledge button clicks
- Add structured logging with createLogger

P1-2: Queue DLQ monitoring
- Add admin notification when server provisioning fails
- Update order status to 'failed' in database
- Include detailed context in notifications
- Apply rate limiting (1 notification per hour)

P1-3: Email handler error recovery
- Add admin notification when SMS parsing fails
- Include email preview in notifications
- Mask email addresses for privacy
- Add structured logging with emailLogger

Also add 'failed' status to ServerOrder type.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:36:49 +09:00
kappa
9fc6820b77 chore: update package-lock.json
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:26:35 +09:00
kappa
e32e3c6a44 refactor: improve OpenAI service and tools
- Enhance OpenAI message types with tool_calls support
- Improve security validation and rate limiting
- Update utility tools and weather tool
- Minor fixes in deposit-agent and domain-register

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:26:31 +09:00
kappa
7ef0ec7594 chore: add server provisioning migrations
- 003_add_server_tables.sql: server_orders, server_instances tables
- 003_server_sessions.sql: KV-based session tracking
- 004_add_terminated_at.sql: track instance termination time

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:26:23 +09:00
kappa
5ba555864a feat: add server provisioning system with Queue
- Add server-provision.ts for async server creation
- Add SERVER_PROVISION_QUEUE with DLQ for reliability
- Add cron job for auto-cleanup of pending orders (5min)
- Add server delete confirmation with inline keyboard
- Update types for server orders, images, and provisioning
- Add server tables to schema (server_orders, server_instances)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:26:17 +09:00
kappa
d3b743c3c1 fix: server recommendation issues and __DIRECT__ tag visibility
- Fix USD price display: all prices now show in KRW (₩)
- Add Korea region auto-detection: extracts region preference from user messages
- Fix low-spec recommendation for high-performance requirements:
  - Add extractTechStack() to detect PostgreSQL, Redis, MongoDB keywords
  - Enhance inferExpectedUsers() to consider tech stack complexity
  - SaaS/B2B services now recommend 4GB+ RAM servers
- Fix __DIRECT__ tag appearing in output:
  - Reorder message concatenation in server-agent.ts
  - Add stripping logic in conversation-service.ts and api.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:24:54 +09:00
kappa
53547f097e chore: remove TODO.md
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 10:37:52 +09:00
kappa
23e3972fbb docs: add TODO for Anvil troubleshooting enhancement
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 14:31:42 +09:00
kappa
860e36a688 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>
2026-01-27 14:28:22 +09:00
kappa
6392a17d4f refactor: extract common bandwidth formatting utilities
- Add BandwidthInfo interface to types.ts (single source of truth)
- Create formatters.ts with formatTB() and formatTrafficInfo()
- Display CDN hit rate and gross/origin traffic in recommendations
- Fix floating point formatting (consistent decimal places)
- Fix undefined handling in toLocaleString() calls
- Unify overage detection logic (overage_tb > 0 && cost > 0)
- Add CDN hit rate range validation (0-100%)
- Extract CDN_CACHE_HIT_RATES constants

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 12:33:58 +09:00
kappa
0277f0539b fix: Reset session when user says "서버 추천" during active session
When user requests server recommendation while in an existing session
(e.g., selecting state), reset the session and start fresh instead of
continuing the old session context.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 11:59:44 +09:00