Multi-channel AI gateway with extensible messaging integrations
Project description
Maysii
Multi-channel AI Gateway โ Connect your AI Agent to 28+ messaging platforms through a unified gateway.
Maysii is a Python rewrite of openclaw/openclaw, featuring MCP tool integration, 20+ built-in tools, cross-platform UI (Web/Desktop/Mobile), and an OpenAI-compatible HTTP API.
Documentation โ Quick Start, Installation Guide, Configuration, Concepts, Troubleshooting.
Features
๐ Agent Harness Architecture (v5.0)
Six-component production-grade agent runtime based on the Agent Harness Design Guide:
| Component | Module | Description |
|---|---|---|
| E Execution Loop | harness/loop.py |
Observe-think-act cycle with dual-mode tool resolution, provider fallback, hard termination |
| T Tool Registry | harness/tool_registry.py |
9-field ToolMetadata, JSON Schema validation, RBAC, RAG-powered ToolIndex, auto-indexing |
| C Context Manager | harness/context_manager.py |
Hybrid injection, layered compression, token budget, Anthropic cache control |
| S State Store | harness/state_store.py |
3-tier storage (Working/Session/Persistent), checkpoint/recovery, execution log |
| L Lifecycle Hooks | harness/hooks.py |
6 hook points: permission, rate-limit, audit, danger-block, mask, policy |
| V Evaluation | harness/evaluation.py |
Component eval, trajectory analysis, LLM-as-Judge, VerifierSubAgent |
Plus Multi-Agent Orchestration (5 engines), Deep Research Engine, Event Bus, EncryptedText, Incremental Migrations, and Skills Self-Repair System.
๐ Context Engine Plugins (v5.0)
Pluggable context management architecture โ swap compression strategies without touching core code:
| Plugin | Strategy | Description |
|---|---|---|
| DefaultContextPlugin | summarize + truncate | LLM-powered summarization with structured templates, truncate fallback |
| DagCompressorPlugin | 4-layer DAG | critical (keep) / important (summarize) / contextual (extract facts) / transient (drop) |
from maysii.agents.context.plugins import ContextEnginePluginRegistry, DagCompressorPlugin
registry = ContextEnginePluginRegistry.get_instance()
registry.register(DagCompressorPlugin(), set_default=True)
See Context Engine Plugin Guide for custom plugin development.
๐งญ Agent Routing (v5.0)
Channel-aware agent routing with 7-tier priority matching and persistent thread bindings:
from maysii.routing import AgentRouter, RoutingRule
router = AgentRouter(default_agent_id="main")
router.register_rule(RoutingRule(channel_type="telegram", agent_id="telegram-bot"))
agent = router.match("telegram", sender_id="VIP123") # โ "telegram-bot"
| Component | Description |
|---|---|
| AgentRouter | Rule-based routing with channel/peer/guild/team priority tiers |
| ThreadBindingManager | SQLite-backed persistent agent-to-thread bindings with TTL |
| RouteAndBind | One-step resolve: check cache โ router โ persist binding |
๐ค Agent Runtime
- Multi-provider LLM streaming (OpenAI, Anthropic, Google Gemini, Ollama, and 25+ more)
- Provider resilience: dead-host cooldown, auto-fallback, shared connection pool, auto-detection
- Anthropic prompt caching with ephemeral markers โ ~85% cache hit rate
- Reasoning model support: 7 thinking model patterns (Qwen3, DeepSeek-R1, DeepSeek-V3, etc.)
- 20+ built-in tools: file I/O, grep, find, exec, web search/fetch, browser, memory, cron, TTS
- MCP (Model Context Protocol) โ stdio, HTTP, and Streamable HTTP transports + OAuth
- Docker sandbox for isolated tool execution (CPU/memory limits, network isolation)
- Task planner with multi-step Plan/Step decomposition
- Meta-Tool system:
invoke_skill,invoke_channel,invoke_memory,invoke_mcp - User interrupt system (cancel/append mid-generation)
- Sub-agent orchestration (spawn, steer, kill)
- SKILL.md-based skill injection
- Skills self-repair via SkillLearner teacher-escalation loop
- Deep Research engine โ searchโreadโsynthesizeโreport pipeline
๐ง Memory System
- Context compaction with LLM-based summarization
- Cross-session context recovery via ContextStore (SQLite-persisted)
- Hybrid search: SQLite FTS5 + LanceDB vector search
- Active memory with auto-recall and auto-capture hooks
- Daily summary service for session consolidation
- Wiki System (Claim/Evidence model with contradiction detection, GitLab-compatible)
- Dreaming System โ 3-phase memory consolidation (LIGHT/DEEP/REM) with 6-dimensional scoring
- Recall cache with TTL-based session isolation
๐ฌ 28+ Messaging Channels
Telegram, Discord, Slack, WhatsApp, Signal, iMessage, Feishu/Lark, DingTalk, QQ, MS Teams, Matrix, IRC, LINE, Twitch, Nostr, X (Twitter), BlueBubbles, Google Chat, Mattermost, Nextcloud Talk, Synology Chat, Tlon/Urbit, Zalo, OneBot, Web Chat, Voice Call, and more.
Unified ChannelPlugin interface โ each channel is a self-contained module with DM/group policy, allowFrom whitelists, mention gating, and agent routing.
๐ช Gateway
- FastAPI + WebSocket v3 bidirectional protocol
- OpenAI-compatible HTTP API (
/v1/chat/completions,/v1/responses,/v1/models) - 30+ RPC methods: chat, sessions, agents, channels, config, models, browser, cron, plan, backup, tools
- REST API for auth, devices, webhooks, usage, logs, plans, cron, skills
- Config hot-reload, channel health monitoring
- MkDocs documentation site mounted on gateway
๐ฅ Cross-Platform UI
- Next.js 15 Web Application
- Tauri 2.x Desktop App โ Rust shell wrapping the Web app (no native frontend; macOS, Linux, Windows)
- Expo React Native Mobile App (iOS, Android)
- 17+ pages: Chat, Agents, Channels, Sessions, Usage, Cron, Plans, Skills, Nodes, Voice, Logs, Debug, Config, System, Settings
๐ก Security
- Command exec approval rules
- Workspace sandbox boundary
- SSRF prevention
- Plaintext secret scanning
- Configuration security audit
- EncryptedText (SQLAlchemy TypeDecorator with Fernet encryption)
- Internal token authentication (loopback-only bypass)
Quick Start
Requirements
- Python >= 3.10
- An LLM API key (OpenAI, Anthropic, Google Gemini, Ollama, or any OpenAI-compatible provider)
Install
# One-line install (macOS / Linux)
curl -fsSL https://raw.githubusercontent.com/maythyai/maysii/master/scripts/install.sh | bash
# From PyPI (recommended)
pip install maysii
# Or via pipx (isolated environment)
pipx install maysii
# macOS via Homebrew
brew install maythyai/tap/maysii
# From source (development)
pip install -e ".[dev,ui]"
# Docker
docker run -it --rm -e OPENAI_API_KEY="sk-..." ghcr.io/maythyai/maysii:latest maysii agent "Hello"
Optional Extras
| Extra | What it adds |
|---|---|
ui |
TypeScript client (Web/Desktop/Mobile) |
matrix |
Matrix channel (matrix-nio) |
whatsapp |
WhatsApp channel (neonize) |
voice |
Voice TTS (edge-tts) |
dev |
Testing + linting (pytest, ruff, mypy) |
First Run
# 1. Interactive setup
maysii setup --wizard
# 2. Chat with the agent
maysii agent "What is the weather in Tokyo?"
# 3. Start the gateway
maysii gateway
# 4. Launch the desktop UI
maysii ui
# 5. Or launch as a web app
maysii ui --web --port 18776
CLI Reference
Setup & Run
| Command | Description |
|---|---|
maysii setup --wizard |
Interactive setup wizard |
maysii agent <message> |
Run a single agent turn |
maysii gateway |
Start the gateway server |
maysii node |
Start a headless node host |
maysii status [--deep] |
Show status / probe health |
maysii doctor |
Run diagnostics |
Configuration
| Command | Description |
|---|---|
maysii config list |
Show all config |
maysii config get <key> |
Get a config value |
maysii config set <key> <value> |
Set a config value |
Agents & Routing
| Command | Description |
|---|---|
maysii agents list |
List agents |
maysii agents add <name> --model <model> |
Add an agent |
maysii mode status |
Show active collaboration mode |
maysii mode switch <mode> |
Switch orchestration mode |
maysii skills list |
List available skills |
maysii exec-policy show|allow|deny |
Manage tool execution policies |
Channels & Messages
| Command | Description |
|---|---|
maysii channels list |
List channels |
maysii channels status |
Connection status |
maysii message send <channel> <text> |
Send a message through a channel |
Auth, MCP & Devices
| Command | Description |
|---|---|
maysii auth login --provider <name> |
Add API key profile |
maysii auth status |
Show auth profiles |
maysii mcp status |
Show MCP servers and tools |
maysii mcp list-tools |
List available MCP tools |
maysii devices list |
List paired devices |
Sessions & Models
| Command | Description |
|---|---|
maysii sessions list |
List agent sessions |
maysii models list |
Show available models |
maysii import chatgpt <path> |
Import ChatGPT export |
Security & System
| Command | Description |
|---|---|
maysii security audit |
Run security audit |
maysii service install |
Install as system service |
maysii logs [--follow] |
Tail runtime logs |
maysii health |
Quick health check (Docker HEALTHCHECK) |
Memory & Knowledge
| Command | Description |
|---|---|
maysii active-memory on|off |
Toggle Active Memory |
maysii wiki init |
Initialize Wiki Vault |
maysii token-aware init|scan|status |
Token optimization tools |
Supported Channels
| Channel | Library | Type |
|---|---|---|
| Telegram | aiogram | Core |
| Discord | discord.py | Core |
| Slack | slack-bolt (Socket Mode) | Core |
| neonize (Baileys) | Core | |
| Signal | signal-cli JSON-RPC | Core |
| iMessage | imsg JSON-RPC | Core |
| X (Twitter) | X API v2 | Core |
| Web | Built-in | Core |
| Feishu / Lark | Open Platform API | Extension |
| DingTalk | Stream Mode | Extension |
| QQ Bot | Extension | |
| MS Teams | Bot Framework | Extension |
| Matrix | matrix-nio | Extension |
| IRC | Native TCP/TLS | Extension |
| LINE | Messaging API | Extension |
| Twitch | IRC/TLS | Extension |
| Nostr | NIP-04 relay | Extension |
| BlueBubbles | REST webhook | Extension |
| Google Chat | OAuth webhook | Extension |
| Mattermost | REST + WebSocket | Extension |
| Nextcloud Talk | REST webhook | Extension |
| Synology Chat | Incoming webhook | Extension |
| Tlon / Urbit | HTTP API | Extension |
| Zalo | Official API | Extension |
| Voice Call | Twilio | Extension |
Supported LLM Providers
Core Providers
| Provider | Models |
|---|---|
| OpenAI | GPT-4o, GPT-4o-mini, o1, o3-mini |
| Anthropic | Claude Opus 4.8, Claude Sonnet, Claude Haiku |
| Google Gemini | Gemini 2.0 Flash, Gemini Pro |
| Ollama | Any locally hosted model |
OpenAI-Compatible Providers
OpenRouter, Together AI, Groq, Fireworks AI, Perplexity, and 15+ more.
Chinese Providers
DeepSeek, Moonshot/Kimi, Zhipu/GLM, Qwen/DashScope, Volcengine/Doubao, MiniMax, Qianfan/ERNIE.
MCP (Model Context Protocol)
Connect external tool servers via MCP. Config format is compatible with Claude Desktop and Cursor.
Add to ~/.maysii/maysii.json:
{
"tools": {
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
},
"remote-api": {
"url": "https://example.com/mcp/",
"transportType": "streamable-http",
"headers": { "Authorization": "Bearer xxx" }
}
}
}
}
Supports stdio, HTTP, and Streamable HTTP (SSE+POST) transports. Built-in MCP servers include Memory, RAG, and Image Generation.
Configuration
Maysii stores its state in ~/.maysii/:
~/.maysii/
โโโ maysii.json # Main config (JSON5 with comments)
โโโ auth-profiles.json # API keys and OAuth credentials
โโโ data/ # ContextStore, ThreadBindings, Webhooks (SQLite)
โโโ sessions/ # Agent session transcripts (JSONL)
โโโ workspace/ # Workspace files (AGENTS.md, HEARTBEAT.md, etc.)
Example Config
{
"models": {
"providers": {
"openai": { "apiKey": "sk-..." },
"anthropic": { "apiKey": "sk-ant-..." }
}
},
"agents": {
"defaults": { "model": "claude-sonnet-4-20250514", "provider": "anthropic" }
},
"channels": {
"defaults": { "agentId": "main" },
"telegram": { "token": "123:ABC", "agentId": "assistant" },
"discord": { "token": "xyz" }
},
"auth": {
"profiles": {
"openai-work": { "provider": "openai", "apiKey": "${OPENAI_WORK_KEY}" }
}
},
"context": {
"engine": {
"plugin": "dag-compressor",
"compaction": { "maxTokens": 128000, "strategy": "dag" }
}
},
"routing": {
"rules": [
{ "channel": "telegram", "sender": "VIP123", "agent": "vip-assistant" }
]
}
}
Environment Variables
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
ANTHROPIC_API_KEY |
Anthropic API key |
GOOGLE_API_KEY |
Google AI API key |
TELEGRAM_BOT_TOKEN |
Telegram bot token |
MAYSII_GATEWAY_PORT |
Gateway port (default: 18777) |
Architecture
maysii/
โโโ src/maysii/ # Python backend (755+ files)
โ โโโ agents/ # Agent runtime
โ โ โโโ harness/ # Agent Harness 6-component (25 modules)
โ โ โ โโโ loop.py # E: ExecutionLoop
โ โ โ โโโ tool_registry.py # T: Tool Registry + ToolIndex
โ โ โ โโโ context_manager.py # C: Context Manager
โ โ โ โโโ state_store.py # S: State Store
โ โ โ โโโ hooks.py # L: Lifecycle Hooks
โ โ โ โโโ evaluation.py # V: Evaluation + VerifierSubAgent
โ โ โ โโโ verifier.py # Independent task verification
โ โ โโโ context/ # Context engines + plugins (v5.0)
โ โ โ โโโ engine.py # ContextEngine ABC
โ โ โ โโโ engines/ # SummarizeEngine, TruncateEngine
โ โ โ โโโ plugins/ # ContextEnginePlugin ABC + Registry + DAG
โ โ โโโ multiagent/ # 5 engine implementations
โ โ
โ โโโ routing/ # Message routing (v5.0)
โ โ โโโ router.py # AgentRouter + RoutingRule
โ โ โโโ thread_bindings.py # ThreadBindingManager
โ โ โโโ integration.py # RouteAndBind + config-driven router
โ โ โโโ bindings.py # AgentBindings (7-tier priority)
โ โ โโโ dispatch.py # MessageDispatcher
โ โ
โ โโโ channels/ # 28 messaging channels
โ โ โโโ base.py # ChannelPlugin interface
โ โ โโโ ... # telegram/, discord/, slack/, signal/, x/, ...
โ โ
โ โโโ gateway/ # Gateway server (FastAPI + WebSocket v3)
โ โโโ config/ # Pydantic configuration system
โ โโโ memory/ # SQLite + LanceDB memory with ContextStore (v5.0)
โ โโโ mcp/ # MCP client (stdio + HTTP + Streamable HTTP + OAuth)
โ โโโ security/ # Security: EncryptedText, audit, CSP
โ โโโ cron/ # APScheduler + TaskChainRunner + WebhookTrigger
โ โโโ cli/ # 30+ Typer commands
โ
โโโ apps/ # TypeScript clients
โ โโโ web/ # Next.js 15 Web app
โ โโโ desktop/ # Tauri 2.x Desktop app
โ โโโ mobile/ # Expo React Native app
โ
โโโ packages/ # Shared packages (types, API client, UI)
โโโ tests/ # 6125 tests (6125 passed, 1 skipped)
โโโ docs/ # MkDocs documentation
Tech Stack
| Layer | Technology |
|---|---|
| Language | Python 3.10+ |
| Type checking | mypy strict (0 errors) |
| Linting | ruff (clean) |
| Web framework | FastAPI + Uvicorn |
| WebSocket | websockets |
| CLI | Typer + Rich |
| Config format | JSON5 (Pydantic v2) |
| Database | SQLite + aiosqlite (WAL mode) |
| Vector search | LanceDB |
| UI (Web) | Next.js 15 |
| UI (Desktop) | Tauri 2.x |
| UI (Mobile) | Expo React Native |
| Testing | pytest + pytest-asyncio |
| Build | Hatch |
Project Stats
| Metric | Value |
|---|---|
| Source files | 755+ Python files |
| Tests | 6,125 (6,125 passed, 1 skipped) |
| Code coverage | 66% |
| Type safety | mypy strict: 0 errors |
| Channels | 28 |
| LLM providers | 25+ |
| Built-in tools | 20+ |
| CLI commands | 30+ |
| Gateway RPC methods | 30+ |
| MCP transports | 3 (stdio, HTTP, Streamable HTTP) |
| MCP built-in servers | 3 (Memory, RAG, Image Gen) |
| Context engine plugins | 2 builtin + custom API |
| Multi-agent engines | 5 |
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run specific test suites
pytest tests/maysii/routing/
pytest tests/maysii/agents/context/
pytest tests/maysii/channels/
# Type check (0 errors expected)
mypy --strict src/maysii/
# Lint & format
ruff check src/ tests/
ruff format src/ tests/
Contributing
Pull requests welcome. The project follows standard Python conventions:
- Code style enforced by
ruff - Type annotations enforced by
mypy --strict - Async-first architecture throughout
- All new features should include tests (80%+ coverage target)
- See CLAUDE.md for project conventions
Documentation
| Document | Description |
|---|---|
| Quick Start | Getting started guide |
| Architecture | System architecture (v5.0) |
| Configuration | Full config reference |
| Context Engine Plugin | Plugin development guide (v5.0) |
| API Reference | Gateway RPC + HTTP API |
| Channel Setup | Per-channel configuration |
| v5.1 ROADMAP | Next milestone plan |
Acknowledgements
This project is inspired by Maysii (originally built with TypeScript). Maysii is a ground-up rewrite using Python + TypeScript, with additional features including context engine plugins, agent routing, DAG compression, and mypy strict enforcement.
Thanks to Next.js, Tauri, Expo, and the open-source AI community.
License
MIT โ Copyright (c) 2026 CHEN SAI
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 maysii-1.2.0.tar.gz.
File metadata
- Download URL: maysii-1.2.0.tar.gz
- Upload date:
- Size: 39.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
404d1d2fb21a5704f95a5173f0f154b49da4e933ba811b01ab66e0f37efca713
|
|
| MD5 |
ab87ad6c59608e5e44989c815ae2ee04
|
|
| BLAKE2b-256 |
7937cac3977552a359034ad284dbf5259e37668d2763a3dcf4008a14d7d66cb4
|
Provenance
The following attestation bundles were made for maysii-1.2.0.tar.gz:
Publisher:
release.yml on maythyai/maysii
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
maysii-1.2.0.tar.gz -
Subject digest:
404d1d2fb21a5704f95a5173f0f154b49da4e933ba811b01ab66e0f37efca713 - Sigstore transparency entry: 2204673808
- Sigstore integration time:
-
Permalink:
maythyai/maysii@9dc912c43e6f3e97d38c5143f7ef18b861c965f2 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/maythyai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9dc912c43e6f3e97d38c5143f7ef18b861c965f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file maysii-1.2.0-py3-none-any.whl.
File metadata
- Download URL: maysii-1.2.0-py3-none-any.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a09b2498d3bbd7edefae79500a250ff2a5a33adedd4a3648cc7e7a6463bcdb7a
|
|
| MD5 |
48b4bc9d4ebe974ecb45f4848126a373
|
|
| BLAKE2b-256 |
932256c84a9b834dc54abad537505d1e19618975a80a72b2c0bf66b23bee5122
|
Provenance
The following attestation bundles were made for maysii-1.2.0-py3-none-any.whl:
Publisher:
release.yml on maythyai/maysii
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
maysii-1.2.0-py3-none-any.whl -
Subject digest:
a09b2498d3bbd7edefae79500a250ff2a5a33adedd4a3648cc7e7a6463bcdb7a - Sigstore transparency entry: 2204673820
- Sigstore integration time:
-
Permalink:
maythyai/maysii@9dc912c43e6f3e97d38c5143f7ef18b861c965f2 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/maythyai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9dc912c43e6f3e97d38c5143f7ef18b861c965f2 -
Trigger Event:
push
-
Statement type: