Commit Graph

10 Commits

Author SHA1 Message Date
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
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
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
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
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
0c3bfede7d feat: add server selection and order flow after recommendation
- Add 'selecting' and 'ordering' status to ServerSession
- Add lastRecommendation field to store recommendation results
- Keep session alive after recommendation (don't delete immediately)
- Add selection pattern matching (1번, 첫번째, 1번 선택 등)
- Add order confirmation message with inline buttons
- Add server_order/server_cancel callback handlers
- Add ServerOrderKeyboardData type for button data

Flow: recommend → select number → confirm with buttons → order/cancel

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 10:45:04 +09:00
kappa
e4ccff9f87 feat: add Reddit search tool and security/performance improvements
New Features:
- Add reddit-tool.ts with search_reddit function (unofficial JSON API)

Security Fixes:
- Add timingSafeEqual for BOT_TOKEN/WEBHOOK_SECRET comparisons
- Add Optimistic Locking to domain registration balance deduction
- Add callback domain regex validation
- Sanitize error messages to prevent information disclosure
- Add timing-safe Bearer token comparison in api.ts

Performance Improvements:
- Parallelize Function Calling tool execution with Promise.all
- Parallelize domain registration API calls (check + price + balance)
- Parallelize domain info + nameserver queries

Reliability:
- Add in-memory fallback for KV rate limiting failures
- Add 10s timeout to Reddit API calls
- Add MAX_DEPOSIT_AMOUNT limit (100M KRW)

Testing:
- Skip stale test mocks pending vitest infrastructure update

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:20:17 +09:00
kappa
a2d05c82c3 feat: add Server Expert AI with search/docs tools for trend-aware recommendations
- Add server-agent.ts with 30-year senior architect persona
- Implement KV-based session management for multi-turn conversations
- Add search_trends (Brave Search) and lookup_framework_docs (Context7) tools
- Function Calling support with max 3 tool calls per request
- Auto-infer tech stack and expected users from use case/scale
- Prohibit competitor provider mentions (AWS, GCP, Azure, etc.)
- Simplify main AI system prompt, delegate complex logic to expert AI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 14:15:15 +09:00
kappa
87c92e1ed1 refactor: migrate server provisioning to Cloud Orchestrator service
- Remove Queue-based server provisioning (moved to cloud-orchestrator)
- Add manage_server tool with Service Binding to Cloud Orchestrator
- Add CDN cache hit rate estimation based on tech_stack
- Always display bandwidth info (show "포함 범위 내" when no overage)
- Add language auto-detection (ko, ja, zh, en)
- Update system prompt to always call tools fresh
- Add Server System documentation to CLAUDE.md

BREAKING: Server provisioning now requires cloud-orchestrator service

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:26:21 +09:00
kappa
6563ee0650 feat: add server ordering system with session-based flow
- Add server recommendation integration (SERVER_RECOMMEND worker)
- Implement KV-based session management for multi-step ordering
- Add Linode/Vultr API clients for server provisioning
- Add server-tool for Function Calling support

refactor: major code reorganization (Phase 1-3)

- Remove 443 lines of deprecated callback handlers
- Extract handlers to separate files (message-handler, callback-handler)
- Extract cloud-spec-service, server-recommend-service
- Centralize constants (OS_IMAGES, REGION_FLAGS, NUM_EMOJIS)
- webhook.ts reduced from 1,951 to 30 lines

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 21:01:38 +09:00