- Attach rejects handler before advancing timers (vitest 2.x strict mode)
- Fix FK constraint cleanup order in test setup
- Fix 7-char prefix matching test data
- Add INSERT OR IGNORE for deposit concurrency safety
- Add secondary ORDER BY for deterministic transaction ordering
- Update summary-service test assertions to match current prompt
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Session-based agent with OpenAI Function Calling (9 tools).
Follows ddos-agent pattern: execute tools inside loop, feed results back to AI.
Includes D1 migration, session routing in openai-service, and doc updates.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add verifyMiniAppAuth() for WebApp init data validation
- Support X-Telegram-Init-Data header
- Keep Bearer token support for web dashboard
- Fallback to user_id query param
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- POST /api/auth/telegram - Telegram Login Widget verification
- GET /api/dashboard - Dashboard stats (servers, domains, deposit)
- GET /api/servers - User's server list
- GET /api/domains - User's domain list
- GET /api/deposit/transactions - Transaction history
- POST /api/server/action - Server start/stop/reboot
CORS enabled for my.anvil.it.com
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove unused sendMessage import from openai-service.ts
- Mark chatIdStr as unused with underscore prefix
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add migration to remove server consultation sessions table.
Update schema.sql to remove table definition.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Removed:
- ServerSessionStatus type
- ServerSession interface
- Recommendation-related fields from ManageServerArgs (tech_stack, expected_users, use_case, etc.)
- Updated ManageServerArgs actions to server management only (order, start, stop, reboot, delete, list, info, images, rename)
Commented out (temporary):
- ServerSessionManager class in session-manager.ts
- Server consultation session cleanup code in server-tool.ts (2 locations)
- Server order confirmation handler in api/chat.ts
These commented sections will be fully removed in subsequent commits when server-agent and related code are removed.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove server recommendation consultation system:
- 30-year expert AI persona
- Session-based information gathering
- Brave Search / Context7 tool integration
- Automatic spec inference
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add archiveOldConversations to the daily cron job (UTC 15:00 / KST 00:00).
Archives conversations older than 180 days by:
- Batching user messages into summaries (100 messages each)
- Using OpenAI to generate context-preserving summaries
- Deleting archived messages to reduce database size
Uses dynamic import for bundle size optimization and try-catch
to prevent errors from affecting other cron tasks.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add /history [N] command to view recent conversation history
- Default 20 messages, max 100
- Shows date/time, role (user/bot), and message preview
- Add /search <keyword> command to search conversations
- Uses extractKeywords() for smart keyword extraction
- Shows up to 15 results with date and content preview
- Update /stats command to use new conversation-storage service
- Shows total message count, first/last message dates
- Shows archived summary count
- Links to /history and /search commands
- Update /start and /help commands to include new commands
- Import conversation-storage functions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Integrate new conversation-storage.ts system while maintaining backward
compatibility with existing message_buffer system:
- Import saveConversationMessage from conversation-storage.ts
- Save user messages to both new system (role: 'user') and old buffer
- Save assistant responses to both new system (role: 'assistant') and old buffer
- Preserve existing functionality during migration period
Changes:
- Add saveConversationMessage import
- Call saveConversationMessage before addToBuffer for user messages
- Call saveConversationMessage before addToBuffer for bot responses
- Updated step numbering in comments (1-7)
Note: Old buffer system will be removed after migration is complete.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add import for getSmartContext from conversation-storage service
- Modify generateAIResponse to use smart context (recent 20 + keyword-related 10 messages)
- Keep existing getAllSummaries for archived profile system
- Use smart context (max 30 messages) when available, fallback to legacy buffer (10 messages)
- Maintain backward compatibility with existing conversation system
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add archive-service.ts with 3 main functions:
1. generateArchiveSummary(): AI-powered conversation summarization
- Uses OpenAI for intelligent summaries
- Fallback to keyword-based simple summaries
- Format: [YYYY-MM-DD ~ YYYY-MM-DD archive] summary
2. archiveUserConversations(): Archive conversations per user
- Query messages older than 180 days (user messages only)
- Create summaries in batches of 100 messages
- Save to summaries table with incremented generation
- Delete original messages and update meta table
3. archiveOldConversations(): Archive all users (Cron job)
- Iterate through conversation_tables
- Call archiveUserConversations for each user
- Return ArchiveResult with stats
- Constants: ARCHIVE_DAYS=180, BATCH_SIZE=100
- Error handling: Comprehensive logging with structured errors
- Type safety: All functions use strict TypeScript types
- No breaking changes: Works with existing conversation storage
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- ensureConversationTable(): 사용자별 동적 테이블 생성/확인
- saveConversationMessage(): 메시지 저장 + 메타 테이블 업데이트
- getRecentConversations(): 최근 N개 메시지 조회 (시간순 정렬)
- searchConversations(): 키워드 검색 (LIKE OR 조건)
- extractKeywords(): 불용어 제거 키워드 추출 (최대 5개)
- getSmartContext(): 최근 20개 + 키워드 매칭 10개 (중복 제거)
- getConversationStats(): 통계 조회 (메시지 수, 첫/마지막 메시지 시간)
- getConversationHistory(): 히스토리 조회 (페이지네이션)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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>
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>
- 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>
- 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>