Architecture¶
μν€ν μ²¶
Project Structure / νλ‘μ νΈ κ΅¬μ‘°¶
SalmAlm is organized into several subpackages, each responsible for a specific domain.
SalmAlmμ μ¬λ¬ μλΈν¨ν€μ§λ‘ ꡬμ±λμ΄ μμΌλ©°, κ°κ° νΉμ λλ©μΈμ λ΄λΉν©λλ€.
salmalm/
βββ __init__.py # Package init, version
βββ __main__.py # Entry point (python -m salmalm)
βββ cli.py # CLI argument parser
βββ constants.py # Global constants
β
βββ core/ # Core engine modules / μ½μ΄ μμ§ λͺ¨λ
β βββ core.py # Central SalmAlm class
β βββ engine.py # LLM orchestration engine
β βββ llm.py # LLM provider abstraction
β βββ llm_loop.py # Conversation loop handler
β βββ llm_task.py # Async LLM task runner
β βββ prompt.py # System prompt builder
β βββ session_manager.py # Session lifecycle
β βββ memory.py # Memory management
β βββ health.py # Health check endpoints
β βββ shutdown.py # Graceful shutdown
β βββ export.py # Session export (JSON/Markdown)
β βββ image_resize.py # Image preprocessing
β βββ plugin_watcher.py # Plugin hot-reload
β βββ exceptions.py # Custom exceptions
β
βββ tools/ # Tool system / λꡬ μμ€ν
β βββ tool_registry.py # Decorator-based tool dispatch
β βββ tools.py # Tool definitions (58+ schemas)
β βββ tools_file.py # File operations
β βββ tools_web.py # Web search & fetch
β βββ tools_exec.py # Shell execution
β βββ tools_memory.py # Memory tools
β βββ tools_system.py # System monitoring
β βββ tools_personal.py # Personal assistant tools
β βββ tools_calendar.py # Calendar tools
β βββ tools_email.py # Email tools
β βββ tools_google.py # Google integration
β βββ tools_media.py # Image/audio tools
β βββ tools_browser.py # Browser automation
β βββ tools_agent.py # Sub-agent spawning
β βββ tools_misc.py # Miscellaneous utilities
β βββ tools_patch.py # Patch/diff tools
β βββ tools_common.py # Shared tool utilities
β βββ tools_reaction.py # Reaction tools
β βββ tools_reminder.py # Reminder tools
β βββ tools_util.py # Utility tools
β
βββ features/ # Feature modules / κΈ°λ₯ λͺ¨λ
β βββ commands.py # Slash command handler (30+)
β βββ rag.py # RAG vector search
β βββ mcp.py # MCP server/client
β βββ mcp_marketplace.py # MCP marketplace
β βββ a2a.py # Agent-to-agent protocol
β βββ agents.py # Multi-agent management
β βββ briefing.py # Daily briefing
β βββ bookmarks.py # Session bookmarks
β βββ compare.py # Response comparison
β βββ dashboard_life.py # Life dashboard
β βββ deadman.py # Dead man switch
β βββ doctor.py # System diagnostics
β βββ heartbeat.py # Heartbeat monitoring
β βββ hooks.py # Event hooks
β βββ mood.py # Mood tracking
β βββ nodes.py # Node management
β βββ plugin_manager.py # Plugin lifecycle
β βββ presence.py # Online presence
β βββ self_evolve.py # Self-evolution
β βββ shadow.py # Shadow mode
β βββ sla.py # SLA monitoring
β βββ stt.py # Speech-to-text
β βββ stability.py # Stability features
β βββ thoughts.py # Thought tracking
β βββ timecapsule.py # Time capsule
β βββ transcript_hygiene.py # Transcript cleanup
β βββ tray.py # System tray
β βββ users.py # User management
β βββ vault_chat.py # Vault chat
β βββ watcher.py # File watcher
β βββ workflow.py # Workflow engine
β
βββ channels/ # Chat channels / μ±ν
μ±λ
β βββ channel_router.py # Multi-channel routing
β βββ telegram.py # Telegram bot
β βββ discord_bot.py # Discord bot
β βββ slack_bot.py # Slack bot (experimental)
β
βββ security/ # Security layer / 보μ λ μ΄μ΄
β βββ security.py # OWASP protection
β βββ crypto.py # AES-256-GCM encryption
β βββ sandbox.py # Sandboxed execution
β βββ container.py # Container isolation
β βββ exec_approvals.py # Dangerous command approval
β
βββ web/ # Web server / μΉ μλ²
β βββ web.py # HTTP request handler
β βββ ws.py # WebSocket handler
β βββ auth.py # Web authentication
β βββ oauth.py # Google OAuth flow
β βββ templates.py # HTML templates
β
βββ utils/ # Utilities / μ νΈλ¦¬ν°
β βββ async_http.py # Async HTTP client
β βββ browser.py # Browser utilities
β βββ chunker.py # Message chunking
β βββ dedup.py # Deduplication
β βββ file_logger.py # File-based logging
β βββ logging_ext.py # Logging extensions
β βββ markdown_ir.py # Markdown IR processor
β βββ migration.py # Data migration
β βββ queue.py # Async queue
β βββ retry.py # Retry with backoff
β βββ tls.py # TLS certificate generation
β
βββ infra/ # Infrastructure / μΈνλΌ
βββ integrations/ # External integrations / μΈλΆ ν΅ν©
βββ plugins/ # Plugin directory / νλ¬κ·ΈμΈ λλ ν 리
βββ static/ # Static assets (HTML, CSS, JS)
βββ frontend/ # Frontend assets
βββ default_skills/ # Built-in skill definitions
Data Flow / λ°μ΄ν° ν릶
User Input β Channel (Web/Telegram/Discord)
β channel_router β core.engine
β prompt builder β LLM API
β tool_registry (if tool call) β tool_handler
β response β channel β User
Key Design Decisions / μ£Όμ μ€κ³ κ²°μ ¶
- Zero dependencies β stdlib only for core;
cryptographyoptional for vault / μ½μ΄λ νμ€ λΌμ΄λΈλ¬λ¦¬λ§ μ¬μ© - Decorator-based tool registry β
@register("tool_name")pattern / λ°μ½λ μ΄ν° κΈ°λ° λꡬ λ±λ‘ - Lazy module loading β tools loaded on first use / 첫 μ¬μ© μ λͺ¨λ λ‘λ©
- Multi-channel abstraction β single engine, multiple frontends / λ¨μΌ μμ§, λ€μ€ νλ‘ νΈμλ
- Feature isolation β each feature is a standalone module / κ° κΈ°λ₯μ λ 립 λͺ¨λ
- SSE-first transport β SSE is the primary message delivery channel (tab-switch-safe); WebSocket demoted to typing indicators only / SSEκ° κΈ°λ³Έ μ μ‘ μ±λ (ν μ ν μμ ); WebSocketμ νμ΄ν νμλ§
- Embedding RAG β hybrid vector search with OpenAI/Google embeddings + BM25 fallback for memory recall / νμ΄λΈλ¦¬λ λ²‘ν° κ²μ (μλ² λ© + BM25 ν΄λ°±)