Personal AI Gateway โ Pure Python, zero-dependency AI assistant with multi-model routing, web UI, and 56+ built-in tools
Project description
What is SalmAlm?
SalmAlm is a personal AI gateway โ one Python package that gives you a full-featured AI assistant with a web UI, Telegram/Discord bots, 62 tools, and 10 features you won't find anywhere else.
No Docker. No Node.js. No config files. Just:
pip install salmalm
salmalm
# โ http://localhost:18800
First launch opens a Setup Wizard โ paste an API key, pick a model, done.
Why SalmAlm?
| Feature | SalmAlm | ChatGPT | OpenClaw | Open WebUI | |
|---|---|---|---|---|---|
| ๐ง | Install complexity | pip install |
N/A | npm + config | Docker |
| ๐ค | Multi-provider routing | โ | โ | โ | โ |
| ๐ง | Self-Evolving Prompt | โ | โ | โ | โ |
| ๐ป | Shadow Mode | โ | โ | โ | โ |
| ๐ | Dead Man's Switch | โ | โ | โ | โ |
| ๐ | Encrypted Vault | โ | โ | โ | โ |
| ๐ฑ | Telegram + Discord | โ | โ | โ | โ |
| ๐งฉ | MCP Marketplace | โ | โ | โ | โ |
| ๐ฆ | Zero dependencies* | โ | N/A | โ | โ |
*stdlib-only core; optional cryptography for vault, otherwise pure Python HMAC-CTR fallback
โก Quick Start
# Install
pip install salmalm
# Start (web UI at http://localhost:18800)
salmalm
# Auto-open browser on start
salmalm --open
# Create desktop shortcut (double-click to launch!)
salmalm --shortcut
# Self-update to latest version
salmalm --update
# Custom port / external access
SALMALM_PORT=8080 salmalm
SALMALM_BIND=0.0.0.0 salmalm # expose to LAN (see Security section)
Desktop Shortcut
Run salmalm --shortcut once to create a desktop icon:
| Platform | What's created | How to use |
|---|---|---|
| Windows | SalmAlm.bat on Desktop |
Double-click โ server starts + browser opens |
| Linux | salmalm.desktop on Desktop |
Double-click โ server starts + browser opens |
| macOS | SalmAlm.command on Desktop |
Double-click โ server starts + browser opens |
The shortcut is version-independent โ update SalmAlm anytime, the shortcut keeps working.
Supported Providers
| Provider | Models | Env Variable |
|---|---|---|
| Anthropic | Claude Opus 4, Sonnet 4, Haiku 4.5 | ANTHROPIC_API_KEY |
| OpenAI | GPT-5.2, GPT-4.1, o3, o4-mini | OPENAI_API_KEY |
| Gemini 2.5 Pro/Flash | GOOGLE_API_KEY |
|
| xAI | Grok-4, Grok-3 | XAI_API_KEY |
| Ollama | Any local model | OLLAMA_URL |
Set keys via environment variables or the web UI Settings โ API Keys.
๐ฏ Feature Overview
Core AI
- Intelligent model routing โ auto-selects model by complexity (simpleโHaiku, moderateโSonnet, complexโOpus), extracted to dedicated
model_selectionmodule with user-configurable routing - Extended Thinking โ deep reasoning mode with budget control
- 5-stage context compaction โ strip binary โ trim tools โ drop old โ truncate โ LLM summarize, with cross-session continuity via
compaction_summariesDB table - Prompt caching โ Anthropic cache_control for 90% cost reduction on system prompts
- Model failover โ exponential backoff + transient error retry (timeout/5xx/429) with 1.5s delay across providers
- Message queue โ offline message queuing with FIFO ordering, 3-stage retry backoff, and dead letter handling; auto-drain on model recovery
- Sub-agent system โ spawn/steer/collect background AI workers with isolated sessions; 8 actions (spawn, stop, list, log, info, steer, collect, status)
- Streaming stability โ partial content preservation on abort;
AbortControlleraccumulates tokens and freezes on cancel - Cache-aware session pruning โ respects Anthropic prompt cache TTL (5min) with 60s cooldown
62 Built-in Tools
Web search (Brave), email (Gmail), calendar (Google), file I/O, shell exec, Python eval, image generation (DALL-E), TTS/STT, browser automation (Playwright), RAG search, QR codes, system monitor, OS-native sandbox, mesh networking, canvas preview, and more.
Web UI
- Real-time streaming (WebSocket + SSE fallback)
- WebSocket reconnect with session resume (buffered message flush)
- Session branching, rollback, search (
Ctrl+K) - Command palette (
Ctrl+Shift+P) - Message edit/delete/regenerate
- Image paste/drag-drop with vision
- Code syntax highlighting
- Dark/Light themes (light default), EN/KR i18n
- PWA installable
- CSP-compatible โ all JS in external
app.js, no inline event handlers - Compaction progress indicator (โจ Compacting context...)
Infrastructure
- OS-native sandbox โ bubblewrap (Linux) / sandbox-exec (macOS) / rlimit fallback; auto-detects strongest tier
- Mesh networking โ P2P between SalmAlm instances (task delegation, clipboard sharing, LAN UDP discovery, HMAC auth)
- Canvas โ local HTML/code/chart preview server at
:18803 - Browser automation โ Playwright snapshot/act pattern (
pip install salmalm[browser])
Channels
- Web โ full-featured SPA at
localhost:18800 - Telegram โ polling + webhook with inline buttons
- Discord โ bot with thread support
Admin Panels
- ๐ Dashboard โ token usage, cost tracking, daily trends with date filters
- ๐ Sessions โ full session management with search, delete, branch indicators
- โฐ Cron Jobs โ scheduled AI tasks with CRUD management
- ๐ง Memory โ file browser for agent memory/personality files
- ๐ฌ Debug โ real-time system diagnostics (5 cards, auto-refresh)
- ๐ Logs โ server log viewer with level filter
- ๐ Docs โ built-in reference for all 32 commands and 10 unique features
โจ 10 Unique Features
These are SalmAlm-only โ not found in ChatGPT, OpenClaw, Open WebUI, or any other gateway:
| # | Feature | What it does |
|---|---|---|
| 1 | Self-Evolving Prompt | AI auto-generates personality rules from your conversations (FIFO, max 20) |
| 2 | Dead Man's Switch | Automated emergency actions if you go inactive for N days |
| 3 | Shadow Mode | AI silently learns your communication style, replies as you when away |
| 4 | Life Dashboard | Unified view of health, finance, habits, calendar in one command |
| 5 | Mood-Aware Response | Detects emotional state and adjusts tone automatically |
| 6 | Encrypted Vault | PBKDF2-200K + HMAC-authenticated stream cipher for private conversations |
| 7 | Agent-to-Agent Protocol | HMAC-SHA256 signed communication between SalmAlm instances |
| 8 | A/B Split Response | Get two different model perspectives on the same question |
| 9 | Time Capsule | Schedule messages to your future self |
| 10 | Thought Stream | Private journaling timeline with hashtag search and mood tracking |
๐ Commands (32)
Click to expand full command list
| Command | Description |
|---|---|
/help |
Show all commands |
/status |
Session status |
/model <name> |
Switch model (opus/sonnet/haiku/gpt/auto) |
/think [level] |
Extended thinking (low/medium/high) |
/compact |
Compress context |
/context |
Token count breakdown |
/usage |
Token & cost tracking |
/persona <name> |
Switch persona |
/branch |
Branch conversation |
/rollback [n] |
Undo last n messages |
/remind <time> <msg> |
Set reminder |
/expense <amt> <desc> |
Track expense |
/pomodoro |
Focus timer |
/note <text> |
Quick note |
/link <url> |
Save link |
/routine |
Daily routines |
/shadow |
Shadow mode |
/vault |
Encrypted vault |
/capsule |
Time capsule |
/deadman |
Dead man's switch |
/a2a |
Agent-to-agent |
/workflow |
Workflow engine |
/mcp |
MCP management |
/subagents |
Sub-agents (spawn, steer, collect, list, stop, log, info, status) |
/evolve |
Self-evolving prompt |
/mood |
Mood detection |
/split |
A/B split response |
/cron |
Cron jobs |
/bash <cmd> |
Shell command |
/screen |
Browser control |
/life |
Life dashboard |
/briefing |
Daily briefing |
๐ Security
SalmAlm follows a dangerous features default OFF policy:
| Feature | Default | Opt-in |
|---|---|---|
| Network bind | 127.0.0.1 (loopback only) |
SALMALM_BIND=0.0.0.0 |
| Shell operators (pipe, redirect, chain) | Blocked | SALMALM_ALLOW_SHELL=1 |
| Home directory file read | Workspace only | SALMALM_ALLOW_HOME_READ=1 |
Vault (without cryptography) |
Disabled | SALMALM_VAULT_FALLBACK=1 for HMAC-CTR |
| Interpreters in exec | Blocked | Use /bash or python_eval tool instead |
| HTTP request headers | Allowlist only | SALMALM_HEADER_PERMISSIVE=1 for blocklist mode |
Header Security
HTTP request tool uses allowlist mode by default โ only safe headers (Accept, Content-Type, Authorization, User-Agent, etc.) are permitted. Unknown headers are rejected.
Set SALMALM_HEADER_PERMISSIVE=1 to switch to blocklist mode (blocks only dangerous headers like Proxy-Authorization, X-Forwarded-For).
Route Security Middleware
Every HTTP route has a security policy (auth, audit, CSRF, rate limit) enforced automatically via web/middleware.py:
- Public routes (
/,/setup,/static/*) โ no auth required - API routes (
/api/*) โ auth required, writes audited, CSRF enforced on POST - Sensitive routes (
/api/vault/*,/api/admin/*) โ always require auth + CSRF
Developers can't accidentally skip auth โ the middleware chain enforces it structurally.
Tool Risk Tiers
Tools are classified by risk level, and critical tools are blocked on external network exposure without authentication:
| Tier | Tools | External (0.0.0.0) |
|---|---|---|
| ๐ด Critical | exec, bash, file_write, file_delete, python_eval, browser_action, sandbox_exec | Auth required |
| ๐ก High | http_request, send_email, file_read, mesh_task | Allowed with warning |
| ๐ข Normal | web_search, calendar, QR, etc. | Allowed |
External Exposure Safety
When binding to 0.0.0.0, SalmAlm automatically:
- โ ๏ธ Warns if no admin password is set
- โ ๏ธ Warns about dangerous tools being accessible
- Blocks critical tools for unauthenticated sessions
Additional Hardening
- SSRF defense โ private IP blocklist on every redirect hop, scheme allowlist, userinfo block, decimal IP normalization
- Shell operator blocking โ pipe (
|), redirect (>), chain (&&,||,;) blocked by default in exec - Token security โ JWT with
kidkey rotation,jtirevocation, PBKDF2-200K password hashing - Login lockout โ persistent DB-backed brute-force protection with auto-cleanup
- Audit trail โ append-only checkpoint log with automated cron (every 6 hours) + cleanup (30 days)
- Rate limiting โ in-memory per-IP rate limiter (60 req/min) for API routes
- WebSocket origin validation โ prevents cross-site WebSocket hijacking
- CSP-compatible UI โ no inline scripts or event handlers; external
app.jswith ETag caching; optional strict CSP viaSALMALM_CSP_NONCE=1 - Exec resource limits โ foreground exec: CPU timeout+5s, 1GB RAM, 100 fd, 50MB fsize (Linux/macOS)
- Tool timeouts โ per-tool wall-clock limits (exec 120s, browser 90s, default 60s)
- Tool result truncation โ per-tool output limits (exec 20K, browser 10K, HTTP 15K chars)
- SQLite hardening โ WAL journal mode + 5s busy_timeout (prevents "database is locked")
- 46 security regression tests โ SSRF bypass, header injection, exec bypass, tool tiers, route policies
See SECURITY.md for full details.
๐ง Configuration
# Server
SALMALM_PORT=18800 # Web server port
SALMALM_BIND=127.0.0.1 # Bind address (default: loopback only)
SALMALM_WS_PORT=18801 # WebSocket port
SALMALM_HOME=~/SalmAlm # Data directory (DB, vault, logs, memory)
# AI
SALMALM_LLM_TIMEOUT=30 # LLM request timeout (seconds)
SALMALM_COST_CAP=0 # Monthly cost cap (0=unlimited)
# Security
SALMALM_VAULT_PW=... # Auto-unlock vault on start
SALMALM_ALLOW_SHELL=1 # Enable shell operators in exec
SALMALM_ALLOW_HOME_READ=1 # Allow file read outside workspace
SALMALM_VAULT_FALLBACK=1 # Allow HMAC-CTR vault without cryptography
SALMALM_HEADER_PERMISSIVE=1 # HTTP headers: blocklist mode instead of allowlist
SALMALM_CSP_NONCE=1 # Strict CSP with nonce-based script-src
SALMALM_OPEN_BROWSER=1 # Auto-open browser on server start
# Mesh
SALMALM_MESH_SECRET=... # HMAC secret for mesh peer authentication
All configuration is also available through the web UI.
๐๏ธ Architecture
Browser โโWebSocketโโโบ SalmAlm โโโบ Anthropic / OpenAI / Google / xAI / Ollama
โ โ
โโโHTTP/SSEโโโบ โโโ SQLite (sessions, usage, memory, audit)
โโโ Model Selection (complexity-based routing)
Telegram โโโบ โโโ Tool Registry (62 tools)
Discord โโโบ โโโ Cron Scheduler + Audit Cron
โโโ Sub-Agent Manager (spawn/steer/collect)
Mesh Peers โโโบ โโโ Message Queue (offline + retry + dead letter)
โโโ RAG Engine (TF-IDF + cosine similarity)
โโโ OS-native Sandbox (bwrap/unshare/rlimit)
โโโ Canvas Server (:18803)
โโโ Security Middleware (auth/audit/rate/CSRF per route)
โโโ Plugin System
โโโ Vault (PBKDF2 encrypted)
- 231 modules, 45K+ lines, 82 test files, 1,709 tests
- Pure Python 3.10+ stdlib โ no frameworks, no heavy dependencies
- Route-table architecture (59 GET + 63 POST registered handlers)
- Default bind
127.0.0.1โ explicit opt-in for network exposure - Runtime data under
~/SalmAlm(configurable viaSALMALM_HOME) - Cost estimation unified in
core/cost.pywith per-model pricing - Slash commands extracted to
core/slash_commands.py(engine.py: 2007โ1221 lines) - Model selection extracted to
core/model_selection.py - Web UI JS extracted to external
static/app.js(index.html: 3016โ661 lines)
Version Management
# Bump version across all source files (pyproject.toml + __init__.py)
python scripts/bump_version.py 0.17.0
# CI automatically checks version consistency
๐ณ Docker (Optional)
git clone https://github.com/hyunjun6928-netizen/salmalm.git
cd salmalm
docker compose up -d
๐ Plugins
Drop a .py file in the plugins/ directory โ auto-discovered on startup:
# plugins/my_plugin.py
TOOLS = [{
'name': 'my_tool',
'description': 'Says hello',
'input_schema': {'type': 'object', 'properties': {'name': {'type': 'string'}}}
}]
def handle_my_tool(args):
return f"Hello, {args.get('name', 'world')}!"
๐ค Contributing
See CONTRIBUTING.md for full guide including test execution, code style, and architecture overview.
git clone https://github.com/hyunjun6928-netizen/salmalm.git
cd salmalm
pip install -e ".[dev]"
# Run tests (per-file, CI-style)
for f in tests/test_*.py; do python -m pytest "$f" -q --timeout=30; done
๐ License
SalmAlm = ์ถ(Life) + ์(Knowledge)
Your life, understood by AI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file salmalm-0.17.0.tar.gz.
File metadata
- Download URL: salmalm-0.17.0.tar.gz
- Upload date:
- Size: 601.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7e12d4c6cf908692a0f09acb9f3314e020b56e0032c568bad2888d4b027b8cb
|
|
| MD5 |
fe47b72cd5c8580f38da34ab5f7f116f
|
|
| BLAKE2b-256 |
106455742429531d72f31b6534d437c215618080057388a7f9b5867bcfc9559d
|
File details
Details for the file salmalm-0.17.0-py3-none-any.whl.
File metadata
- Download URL: salmalm-0.17.0-py3-none-any.whl
- Upload date:
- Size: 573.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a9d1f5c3c9b094b804ef3b144f9f46a97083c52c0e6c3f06575f7ef63527dc2
|
|
| MD5 |
ad0a52352506a2e5a81d4e735ccd0954
|
|
| BLAKE2b-256 |
e4b984d407374e3e362b83a1124e88b891968a58b70b5b819bd78d2ae49a4751
|