187 Commits

Author SHA1 Message Date
9c334d8550 chore: anvil.it.com → inouter.com
All checks were successful
TypeScript CI / build (push) Successful in 50s
2026-03-27 16:17:03 +00:00
4bc50911c0 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:17:01 +00:00
90d2f96ae9 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:16:38 +00:00
0062dc1f4c chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:16:27 +00:00
f1f9b3028e chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:16:25 +00:00
1afcff76f4 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:16:23 +00:00
07a5d4230a chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:16:21 +00:00
4e246aad22 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:16:18 +00:00
b418de1550 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:16:15 +00:00
bf6bf2af88 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:16:08 +00:00
245cbf46de chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:15:49 +00:00
e1add97f0d chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:15:47 +00:00
e2dce1119b chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:15:45 +00:00
32e804a37c chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:15:44 +00:00
8fe866c545 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:15:42 +00:00
bdbee82b30 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:15:41 +00:00
fd73f3adb3 chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:15:40 +00:00
e569f1c0cb chore: anvil.it.com → inouter.com
Some checks failed
TypeScript CI / build (push) Has been cancelled
2026-03-27 16:15:36 +00:00
kappa
0b68516def fix: add Pages preview deployment CORS and init-data header
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 19:41:17 +09:00
kappa
bd25316fd3 fix: resolve all test failures after vitest 2.x upgrade
- 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>
2026-02-07 19:41:11 +09:00
kappa
fa7d8b2d1a chore: upgrade wrangler 4.63.0, vitest 2.1.9, vitest-pool-workers 0.12.10
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 19:41:04 +09:00
kappa
ab314b10c4 feat: recreate Server Agent for premium VM management
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>
2026-02-07 19:40:58 +09:00
kappa
4c1f2f3852 feat: support Telegram Mini App authentication
- 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>
2026-02-05 19:12:02 +09:00
kappa
0b24cbdad0 feat: add dashboard API endpoints
- 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>
2026-02-05 19:08:54 +09:00
kappa
ec2d4da517 feat: add server page link to /server command
- Show "신청 가능한 서버보기" link when no servers
- Show link at bottom of server list

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:59:21 +09:00
kappa
6417dfec13 fix: remove remaining server recommendation references
- Remove start_consultation instruction from system prompt
- Clean ManageServerArgsSchema (remove recommend/consultation actions)
- Update SERVER_ACTION constant (remove RECOMMEND, add REBOOT/RENAME)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:51:13 +09:00
kappa
a774235244 refactor: fix unused imports after server recommendation removal
- 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>
2026-02-05 18:37:58 +09:00
kappa
7e3b4a10ab refactor: drop server_sessions table
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>
2026-02-05 18:36:44 +09:00
kappa
1935d8bb5b refactor: update /server command to remove recommendation guide
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:35:36 +09:00
kappa
30b7a85ab0 refactor: remove SERVER_CONSULTATION_STATUS from constants
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:34:39 +09:00
kappa
648df55a0b refactor: remove ServerSession types from types.ts
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>
2026-02-05 18:33:39 +09:00
kappa
98002473f9 refactor: remove recommendation actions from server-tool
Removed:
- start_consultation, continue_consultation, cancel_consultation, recommend actions
- getRecommendationData(), formatRecommendations()
- CDN cache hit rate estimation (CDN_CACHE_HIT_RATES, estimateCdnCacheHitRate)
- Language detection (detectLanguage)
- callCloudOrchestratorApi() function
- isErrorResult() type guard
- Recommendation-related parameters (tech_stack, expected_users, use_case, traffic_pattern, region_preference, budget_limit, lang, message)
- RecommendResponse type import
- formatTrafficInfo import

Retained:
- order, list, info, delete, images, start, stop, reboot, rename actions
- callProvisionAPI() for provision operations
- Server management core functionality

File size reduced from 1484 to 1057 lines (427 lines removed).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:30:08 +09:00
kappa
7d43db3054 refactor: delete server-agent.ts (905 lines)
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>
2026-02-05 18:25:36 +09:00
kappa
6e3e8d8abb refactor: remove server order confirmation from message-handler
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:12:45 +09:00
kappa
fd20282f4e refactor: remove server consultation session routing from openai-service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:11:13 +09:00
kappa
8a25fa02da style: add emojis to /security command
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:35 +09:00
kappa
f8d195325c feat: migrate existing message_buffer data to conversation tables
Migrated 2 users:
- 7265981403: 18 messages
- 821596605: 46 messages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:35 +09:00
kappa
5ec224b53f feat: add migration script for existing conversations
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:35 +09:00
kappa
23785c9e5f feat: add conversation archive to daily cron
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>
2026-02-05 12:47:35 +09:00
kappa
e764dd683e feat: add /history and /search commands
- 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>
2026-02-05 12:47:35 +09:00
kappa
92ddc239ef feat: save messages to new conversation storage
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>
2026-02-05 12:47:35 +09:00
kappa
1ecbf19f66 feat: integrate smart context in AI response generation
- 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>
2026-02-05 12:47:35 +09:00
kappa
a14e640db9 feat: implement archive service for old conversations
- 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>
2026-02-05 12:47:35 +09:00
kappa
2a84f12d46 feat: implement conversation storage service
- ensureConversationTable(): 사용자별 동적 테이블 생성/확인
- saveConversationMessage(): 메시지 저장 + 메타 테이블 업데이트
- getRecentConversations(): 최근 N개 메시지 조회 (시간순 정렬)
- searchConversations(): 키워드 검색 (LIKE OR 조건)
- extractKeywords(): 불용어 제거 키워드 추출 (최대 5개)
- getSmartContext(): 최근 20개 + 키워드 매칭 10개 (중복 제거)
- getConversationStats(): 통계 조회 (메시지 수, 첫/마지막 메시지 시간)
- getConversationHistory(): 히스토리 조회 (페이지네이션)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:47:35 +09:00
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