Skip to main content

Personal AI Gateway โ€” Pure Python, zero-dependency AI assistant with multi-model routing, web UI, and 67 built-in tools

Project description

๐Ÿ˜ˆ SalmAlm (์‚ถ์•Ž)

Your Entire AI Life in One pip install

PyPI Python License: MIT CI Tests Tools Coverage

ํ•œ๊ตญ์–ด README ยท Documentation


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, browser automation, sub-agents, and memory system.

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.

โš ๏ธ Don't run salmalm from inside a cloned repo directory โ€” Python will import the local source instead of the installed package. Run from ~ or any other directory.


Why SalmAlm?

Feature SalmAlm ChatGPT OpenClaw Open WebUI
๐Ÿ”ง Install complexity pip install N/A npm + config Docker
๐Ÿค– Multi-provider routing โœ… Auto 3-tier โŒ โœ… โœ…
๐Ÿง  Memory (2-layer + auto-recall) โœ… โŒ โœ… โŒ
๐Ÿค– Sub-agents (spawn/steer/notify) โœ… โŒ โœ… โŒ
๐ŸŒ Browser automation (Playwright) โœ… โŒ โœ… โŒ
๐Ÿง  Extended Thinking (4 levels) โœ… โŒ โœ… โŒ
๐Ÿ” Encrypted Vault (AES-256-GCM) โœ… โŒ โŒ โŒ
๐Ÿ“ฑ Telegram + Discord โœ… โŒ โœ… โŒ
๐Ÿงฉ MCP (Model Context Protocol) โœ… โŒ โŒ โœ…
๐Ÿฆ™ Local LLM (Ollama/LM Studio/vLLM) โœ… โŒ โœ… โœ…
๐Ÿ“ฆ Zero dependencies* โœ… N/A โŒ โŒ
๐Ÿ’ฐ Cost optimization (83% savings) โœ… โŒ โŒ โŒ

*stdlib-only core; optional cryptography for AES-256-GCM vault


โšก Quick Start (5๋ถ„์ด๋ฉด ์ถฉ๋ถ„ํ•ฉ๋‹ˆ๋‹ค)

Step 1: ์„ค์น˜ (30์ดˆ)

pip install salmalm

Step 2: ์‹คํ–‰ (10์ดˆ)

salmalm --open
# โ†’ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ž๋™์œผ๋กœ ์—ด๋ฆฝ๋‹ˆ๋‹ค (http://localhost:18800)

# ๋˜๋Š” (editable install์—์„œ console_script๊ฐ€ ์•ˆ ๋  ๋•Œ):
python3 -m salmalm --open

Step 3: API ํ‚ค ์ž…๋ ฅ (2๋ถ„)

  1. ์›น UI์˜ Setup Wizard๊ฐ€ ์ž๋™์œผ๋กœ ๋œน๋‹ˆ๋‹ค
  2. AI ์ œ๊ณต์‚ฌ์˜ API ํ‚ค๋ฅผ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•˜์„ธ์š”:
  3. "Save" ํด๋ฆญ โ†’ ๋!

Step 4: ๋Œ€ํ™” ์‹œ์ž‘ (๋ฐ”๋กœ!)

"์˜ค๋Š˜ ๋‚ ์”จ ์–ด๋•Œ?"          โ†’ ์›น ๊ฒ€์ƒ‰ + ๋‹ต๋ณ€
"์ด ์ฝ”๋“œ ๋ฆฌ๋ทฐํ•ด์ค˜"         โ†’ ํŒŒ์ผ ์ฝ๊ธฐ + ๋ถ„์„
"/model sonnet"            โ†’ ๋ชจ๋ธ ๋ณ€๊ฒฝ
"/help"                    โ†’ ์ „์ฒด ๋ช…๋ น์–ด ๋ณด๊ธฐ

๐Ÿ’ก ์ž์—ฐ์–ด๋กœ ๋งํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. 62๊ฐœ ๋„๊ตฌ๋ฅผ AI๊ฐ€ ์•Œ์•„์„œ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค. ๋ช…๋ น์–ด๋ฅผ ์™ธ์šธ ํ•„์š” ์—†์ด, ํ•˜๊ณ  ์‹ถ์€ ๊ฑธ ๊ทธ๋ƒฅ ๋งํ•˜์„ธ์š”.

๊ณ ๊ธ‰ ์˜ต์…˜

salmalm --shortcut          # ๋ฐ”ํƒ•ํ™”๋ฉด ๋ฐ”๋กœ๊ฐ€๊ธฐ ์ƒ์„ฑ
salmalm doctor              # ์ž๊ฐ€์ง„๋‹จ
salmalm --update            # ์ž๋™ ์—…๋ฐ์ดํŠธ
SALMALM_PORT=8080 salmalm   # ํฌํŠธ ๋ณ€๊ฒฝ

Supported Providers (Auto-Routing)

Provider Models Tier
Anthropic Claude Opus 4.6, Sonnet 4.6, Haiku 4.5 Complex / Moderate / Simple
OpenAI GPT-5.2, GPT-5, o4-mini Complex / Moderate
Google Gemini 3.1 Pro, 2.5 Flash Moderate / Simple
xAI Grok-4, Grok-3-mini Complex / Simple
DeepSeek R1, Chat Via OpenRouter
Local LLM Ollama / LM Studio / vLLM Auto-detected

๐Ÿง  Architecture

Browser โ”€โ”€WebSocketโ”€โ”€โ–บ SalmAlm โ”€โ”€โ–บ Anthropic / OpenAI / Google / xAI / Local
   โ”‚                     โ”‚
   โ””โ”€โ”€HTTP/SSEโ”€โ”€โ–บ       โ”œโ”€โ”€ Smart Model Router (3-tier: simple/moderate/complex)
                         โ”œโ”€โ”€ Engine Pipeline (classify โ†’ route โ†’ context โ†’ execute)
Telegram โ”€โ”€โ–บ             โ”œโ”€โ”€ Memory System (2-layer + auto-recall + TF-IDF RAG)
Discord  โ”€โ”€โ–บ             โ”œโ”€โ”€ Sub-Agent Manager (spawn/steer/kill/notify)
                         โ”œโ”€โ”€ Tool Registry (62 tools, risk-tiered)
                         โ”œโ”€โ”€ Browser Automation (Playwright subprocess)
                         โ”œโ”€โ”€ Security Middleware (auth/CSRF/CSP/rate-limit/audit)
                         โ”œโ”€โ”€ Vault (PBKDF2-200K + AES-256-GCM)
                         โ””โ”€โ”€ Cron / Backup / Self-Diagnostics

Codebase Metrics

Metric Value
Python files 192
Total lines ~52,450
Functions ~1,800
Max cyclomatic complexity 20 (all functions)
Largest file 778 lines
Files > 800 lines 0
Docstring coverage 99%
Return type hints 81%
Tests 1,878 passing

๐ŸŽฏ Feature Overview

Core AI Engine

  • 3-tier auto-routing โ€” simpleโ†’Haiku ($1/M), moderateโ†’Sonnet ($3/M), complexโ†’GPT-5.2/Sonnet ($2-3/M)
  • Extended Thinking โ€” 4 levels (low/medium/high/xhigh) with budget control
  • Cross-provider message sanitization โ€” seamless model switching mid-conversation
  • 5-stage context compaction โ€” strip binary โ†’ trim tools โ†’ drop old โ†’ truncate โ†’ LLM summarize
  • Prompt caching โ€” Anthropic cache_control for 90% cost reduction
  • Model failover โ€” exponential backoff + retry across providers
  • Infinite loop detection โ€” 3+ same (tool, args_hash) in last 6 iterations = auto-break

Memory System (OpenClaw-style)

  • 2-layer architecture โ€” MEMORY.md (curated long-term) + memory/YYYY-MM-DD.md (daily logs)
  • Auto-recall โ€” searches memory before each response, injects relevant context
  • Auto-curation โ€” promotes important daily entries to long-term memory
  • TF-IDF + cosine similarity search across all memory files
  • Memory scrubbing โ€” API keys/secrets auto-redacted before storage

Sub-Agent System

  • Spawn background AI workers with independent sessions
  • Thinking level per agent (low/medium/high/xhigh)
  • Labels for human-readable naming
  • Steer running agents with mid-task guidance
  • Auto-notify on completion (WebSocket + Telegram push)
  • Collect results (push-style, like OpenClaw)
/subagents spawn Review this PR --model sonnet --thinking high --label pr-review
/subagents list
/subagents steer abc123 Focus on security issues
/subagents kill abc123
/subagents collect

62 Built-in Tools

Web search (Brave), email (Gmail), calendar (Google), file I/O, shell exec, Python eval (opt-in), image generation (DALL-E/Aurora), TTS/STT, browser automation (Playwright), RAG search, QR codes, system monitor, OS-native sandbox, mesh networking, and more.

Web UI

  • Real-time streaming (SSE-first, WebSocket for typing indicators)
  • Embedding RAG โ€” hybrid vector search (OpenAI/Google embeddings + BM25 fallback)
  • Agent steer โ€” /agent steer <label> <message> to control running sub-agents
  • Browser aria-ref compression โ€” 10x token savings for browser automation
  • Thinking stream UI โ€” real-time collapsible thinking display
  • Session branching, rollback, search (Ctrl+K), command palette (Ctrl+Shift+P)
  • Dark/Light themes, EN/KR i18n
  • Image paste/drag-drop with vision, code syntax highlighting
  • Settings panels: Engine, Routing, Telegram, Discord, Memory, Cron, Backup
  • PWA installable

Channels

  • Web โ€” full SPA at localhost:18800
  • Telegram โ€” polling + webhook with inline buttons
  • Discord โ€” bot with thread support and mentions

โœจ Unique Features

Feature What it does
Self-Evolving Prompt AI auto-generates personality rules from conversations
Dead Man's Switch Emergency actions if you go inactive for N days
Shadow Mode AI learns your style, replies as you when away
Life Dashboard Unified health, finance, habits, calendar view
Mood-Aware Response Detects emotional state, adjusts tone
A/B Split Response Two model perspectives on the same question
Time Capsule Schedule messages to your future self
Thought Stream Private journaling with hashtag search and mood tracking

๐Ÿ’ฐ Cost Optimization

SalmAlm is designed to minimize API costs without sacrificing quality:

Feature Effect
Dynamic tool loading 62 tools โ†’ 0 (chat) or 7-12 (actions) per request
3-tier auto-routing Simpleโ†’$1/M, Moderateโ†’$3/M, Complexโ†’$3/M (no Opus needed)
Tool schema compression 7,749 โ†’ 693 tokens (91% reduction)
System prompt compression 762 โ†’ 310 tokens
Intent-based max_tokens Chat 512, search 1024, code 4096
Intent-based history trim Chat 10 turns, code 20 turns
Cache TTL Same question cached (30minโ€“24h, configurable)
Cross-provider failover Falls back to cheaper model on rate limit

Result: $7.09/day โ†’ $1.23/day (83% savings at 100 calls/day)


๐Ÿ”’ Security

Dangerous features default OFF โ€” everything requires explicit opt-in:

Feature Default Opt-in
Network bind 127.0.0.1 SALMALM_BIND=0.0.0.0
Shell operators Blocked SALMALM_ALLOW_SHELL=1
Python eval Disabled SALMALM_PYTHON_EVAL=1
Home dir file read Workspace only SALMALM_ALLOW_HOME_READ=1
Plugin system Disabled SALMALM_PLUGINS=1

Security Hardening

  • SSRF defense โ€” DNS pinning + private IP block on every redirect hop
  • Tool risk tiers โ€” Critical tools blocked on external bind without auth
  • CSRF โ€” Origin validation + X-Requested-With header
  • CSP โ€” Strict nonce mode available
  • Audit log โ€” secrets scrubbed before logging (9 pattern types)
  • Memory scrubbing โ€” API keys auto-redacted before storage
  • Path validation โ€” Path.is_relative_to() for all file operations
  • Session isolation โ€” user_id scoped, export restricted to own data
  • Node dispatch โ€” HMAC-SHA256 signed payloads
  • 150+ security regression tests in CI

See SECURITY.md for full threat model.


๐Ÿฆ™ Local LLM Setup

Server Endpoint Setup
Ollama http://localhost:11434/v1 ollama serve
LM Studio http://localhost:1234/v1 Start server in LM Studio
vLLM http://localhost:8000/v1 vllm serve <model>

Settings โ†’ Local LLM โ†’ paste endpoint โ†’ Save. Models auto-discovered.


๐Ÿ”ง Configuration

# Server
SALMALM_PORT=18800         # Web server port
SALMALM_BIND=127.0.0.1    # Bind address
SALMALM_HOME=~/SalmAlm    # Data directory

# AI
SALMALM_PLANNING=1         # Planning phase (opt-in)
SALMALM_REFLECT=1          # Reflection pass (opt-in)
SALMALM_MAX_TOOL_ITER=25   # Max tool iterations
SALMALM_COST_CAP=0         # Daily cost cap (0=unlimited)

# Security
SALMALM_PYTHON_EVAL=1       # Enable python_eval tool
SALMALM_PLUGINS=1           # Enable plugin system
SALMALM_ALLOW_SHELL=1       # Enable shell operators

All settings also available in Web UI โ†’ Settings.


๐Ÿค Contributing

git clone https://github.com/hyunjun6928-netizen/salmalm.git
cd salmalm
pip install -e ".[dev]"
python -m pytest tests/ -q --timeout=30 -x \
  --ignore=tests/test_multi_tenant.py \
  --ignore=tests/test_fresh_install_e2e.py

See CONTRIBUTING.md.


๐Ÿ“„ License

MIT


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

salmalm-0.19.92.tar.gz (816.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

salmalm-0.19.92-py3-none-any.whl (795.2 kB view details)

Uploaded Python 3

File details

Details for the file salmalm-0.19.92.tar.gz.

File metadata

  • Download URL: salmalm-0.19.92.tar.gz
  • Upload date:
  • Size: 816.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for salmalm-0.19.92.tar.gz
Algorithm Hash digest
SHA256 18f3c037e7473bd4ef3666732bcaa7a3885982cf766b8296261e388f925fbac0
MD5 93ed95511dfbfd766e9720221415be36
BLAKE2b-256 7e99f572c79c70f023eaff45cce7cec7ad179845c454f5c3176dc17c6c0caa60

See more details on using hashes here.

File details

Details for the file salmalm-0.19.92-py3-none-any.whl.

File metadata

  • Download URL: salmalm-0.19.92-py3-none-any.whl
  • Upload date:
  • Size: 795.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for salmalm-0.19.92-py3-none-any.whl
Algorithm Hash digest
SHA256 ec72dbf1793bb406904a6e88fe512bbda8245be82f5a563ac3e3852691b68a88
MD5 2a13d1b88c5bcefcac5e517e108ffa91
BLAKE2b-256 69c0f039b4fd041cb8af145918af4778675fd18921b1993fdda0fb770a216666

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page