Kiến trúc
Bestie là runtime local-first, tự host được. Cùng một runtime core phục vụ terminal chat, Telegram, Zalo, UI local tương lai, MCP và các extension sau này.
User / Channel -> Channel Adapter -> Runtime Orchestrator -> Mode Detector -> Memory Router -> Prompt Builder -> LLM Adapter -> Safety / Permission Layer -> Tool / Plugin / MCP Router -> Response -> Logs + Memory UpdateCLI sở hữu các lệnh user-facing:
onboardchatstatuslogsdoctormemorytelegramzalotoolsmcp
Channel adapters
Phần tiêu đề “Channel adapters”Telegram là channel đầy đủ đầu tiên: polling local, owner-only, slash commands, typing indicators, progress edits, attachments, memory controls, Doctor summaries và approval prompts.
Zalo hiện là adapter text-only giai đoạn đầu: polling local, owner-only, slash commands, typing indicators, tách reply dài, memory controls, provider diagnostics, approval prompts, transcript logging và capture response shape để debug tích hợp. Attachments, voice, rich templates và webhook hosting chưa nằm trong adapter Zalo đầu tiên.
CLI nên gọi runtime services, không duplicate business logic.
Runtime
Phần tiêu đề “Runtime”Một turn đi qua các bước:
- Nhận message từ terminal, Telegram hoặc adapter khác.
- Load config, env, character files và memory context.
- Build prompt.
- Resolve LLM profile và model ref đang active, rồi gọi provider adapter đã cấu hình.
- Chạy tool loop nếu được phép.
- Gửi response.
- Lưu logs đã redact và memory updates được duyệt.
Character system
Phần tiêu đề “Character system”Bestie load character từ file local như character.json, system-prompt.md, style examples và safety boundaries.
Mục tiêu là một AI best friend có cá tính: hài, thẳng, biết quan tâm, có thể phản biện nhưng không hạ nhục người dùng.
Memory router
Phần tiêu đề “Memory router”Memory hiện tại dùng SQLite local. Nó lưu approved memories, pending memories, lifecycle metadata, terminal/Telegram messages, pause state và pending approvals.
Memory được tách thành 3 tầng:
- Core profile: rất ít memory luôn được inject, ví dụ ngôn ngữ ưu tiên, phong cách giao tiếp, identity rules và quyết định bền vững cực quan trọng.
- Working context: memory liên quan trực tiếp tới user, channel, project và query hiện tại; được retrieve theo lượt.
- Archive: record cũ, stale, superseded hoặc ít ưu tiên vẫn nằm trong SQLite để search/list/export/cleanup, nhưng không inject mặc định.
Prompt builder nên inject core profile, score và retrieve top working-context records, còn archive chỉ dùng khi có lệnh search, list, export hoặc cleanup rõ ràng. Lifecycle metadata như pinned, stale, superseded_by, last_accessed_at, access_count, confidence và expires_at giúp cleanup/consolidation có cơ sở thay vì đọc text rồi đoán.
Zep có thể được thêm sau như lớp memory nâng cao, nhưng không nên thay thế character files hoặc memory controls local.
Permissions và tools
Phần tiêu đề “Permissions và tools”Mọi hành động ngoài text reply nên được phân loại:
- read-only
- local write
- external write
- public action
- destructive
- money/payment
- unknown
Bestie bắt đầu với internal read tools và MCP read-only đã classify. Các hành động rủi ro hơn cần permission UX, logs và approval rõ ràng.
