npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mos-agent

v1.2.0

Published

Mos — a lean personal assistant: agent + Zalo gateway + CLI. Install with npm, run with mos.

Readme

Mos

Mos is a personal assistant, written lean from scratch. Python stdlib only (+ Node for the Zalo sidecar), fast to run, easy to deploy for one person.

version tests CI license

Install

One command, on Windows, macOS, or Linux (needs Node.js 22+ and Python 3.11+ first):

npm install -g mos-agent
mos --version   # mos 1.2.0
mos onboard     # first-time setup: keys, channels, self-check
mos tui         # full-screen terminal UI (React + Ink, see docs/TUI.md)

That installs two commands: mos (the assistant) and mos-zalo (the Zalo sidecar server). No clone, no virtualenv: the package carries the whole Mos tree, and the mos launcher finds your Python and points Mos at the bundled skills from any directory. To try it without installing: npx -p mos-agent mos --version. Update with npm update -g mos-agent, remove with npm uninstall -g mos-agent. See docs/NPM.md and docs/DEPLOY.md (VPS/cloud with systemd). Releases and CI: docs/CI_CD.md.

What it does

  • Chats on your messaging apps — Telegram, Zalo, Discord, Slack, webhook and console, all through one supervisor process.
  • Answers with a model, with tools — fast/strong model routing, tool calls (files, web search, Zalo actions, cron, guild admin), long-term memory, and context compression so long sessions stay cheap.
  • Stays polite in groups — a two-layer policy gate (admission table + one model assessment) decides whether Mos speaks, watches, or stays quiet.
  • Never loses a reply — every reply is written to a durable outbox (SQLite) before it is sent, with retries, ordering per conversation, and a dead letter for failures.
  • Runs unattended — per-group fair queues, a worker pool, turn timeouts, a single-instance guard, and a self-check (mos doctor).

See docs/flows.html for step-by-step animated flows of how a message travels through Mos, each step citing the real code.

Architecture

%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#e8f5e9", "primaryBorderColor": "#15803D", "primaryTextColor": "#111111", "lineColor": "#15803D", "tertiaryColor": "#ffffff"}}}%%
flowchart LR
    subgraph Channels["Channels"]
        TG[Telegram]
        ZL[Zalo]
        DC[Discord]
        SL[Slack]
        WH[Webhook]
        CO[Console]
    end
    SUP[Supervisor<br/>gateway/supervisor.py]
    GATE[Policy gate + attention<br/>policy/gate.py]
    AG[Agent<br/>agent/core.py]
    ROUTE[Fast / strong routing<br/>agent/routing.py]
    MODEL[Model client<br/>agent/models.py]
    TOOLS[Tools<br/>tools/registry.py]
    OUT[Outbox + effects<br/>gateway/outbox.py<br/>effects.py]
    REPLY[Reply to user]

    TG --> SUP
    ZL --> SUP
    DC --> SUP
    SL --> SUP
    WH --> SUP
    CO --> SUP
    SUP --> GATE
    GATE --> AG
    AG --> ROUTE
    ROUTE --> MODEL
    AG --> TOOLS
    TOOLS --> AG
    MODEL --> AG
    AG --> OUT
    OUT --> REPLY

The supervisor polls each channel adapter in its own thread and hands events to a worker pool (Supervisor.submit / _take_next / _worker_loop in gateway/supervisor.py). One turn per thread runs at a time, so a group's history never interleaves. The gate runs before the agent; the outbox runs after it — the agent itself never sends directly.

Directory structure

agent/    — chat loop (core.py), model client (models.py),
                fast/strong routing (routing.py), streaming (streaming.py),
                context + memory (context.py, memory_session.py)
tools/    — tool registry (registry.py) + tools: files, web search,
                Zalo actions, cron, guild admin, MCP client
policy/   — two-layer gate (gate.py), admission table (admission.py),
                mode auto/observe/off (mode.py), assessment (assessment.py)
guild/    — group moderation + Join Guard (moderation.py),
                cases (cases.py), teams/attention (team.py)
memory/   — long-term memory store, scoring, graded read caps
session/  — per-thread agent sessions (platform:chat_id)
cron/     — interval cron scheduler + delivery queue
learning/ — turn journal, distill, consolidate, auto-verify
cli/      — the `mos` command (chat / supervisor / status / ...)
doctor.py — `mos doctor` self-check
onboard.py— `mos onboard` interactive setup
effects.py— durable SQLite effects queue (reply delivery, retries)
version.py— the release version (`__version__`)
skills/   — skill code (loader.py, curator.py, hub.py) + 7 bundled skills
plugins/  — plugin host (loader.py)
gateway/      — Supervisor (supervisor.py), outbox (outbox.py),
                fair queues (concurrent.py), channel adapters (platforms/)
sidecar/      — Node bridge Zalo (zca-js) <-> Python adapter, local only
                + Zalo MCP server (mcp_zalo_server.js, mock by default)
webui/        — dashboard server (server.py) + bundle (static/)
                + React source (src/, not shipped in the npm package)
config/       — config samples
scripts/      — sidecar runners
tests/        — stdlib tests (pytest)
docs/         — docs, incl. flows.html (animated message flows)

Quickstart

# Console chat (no API key needed: without a key it runs in mock mode)
PYTHONPATH=. python3 -m cli.main chat

# Status (never prints API keys)
PYTHONPATH=. python3 -m cli.main status

# First-time setup: answer one question at a time, then self-check
PYTHONPATH=. python3 -m cli.main onboard
PYTHONPATH=. python3 -m cli.main doctor
# (see docs/DOCTOR.md)

# Run all channels in parallel (Telegram, Zalo, Discord, Slack, webhook)
PYTHONPATH=. python3 -m cli.main supervisor --channels telegram,zalo
# (see docs/GATEWAY.md)

# Policy mode: auto | observe | off (live, no restart needed)
PYTHONPATH=. python3 -m cli.main policy mode observe

# List all tools / tail logs (no API key needed, read-only)
PYTHONPATH=. python3 -m cli.main tools
PYTHONPATH=. python3 -m cli.main logs --list
# (see docs/CLI.md)

Configure with environment variables: MOS_API_BASE_URL, MOS_API_KEY, MOS_FAST_MODEL, MOS_STRONG_MODEL, MOS_ZALO_ALLOW_FROM (see config/config.yaml.example for what each setting means). Since v0.56, MOS_* keys can also live in ./.env or ~/.mos/.env (loaded automatically, env already set wins) — that is where mos onboard stores the provider key; the key is never read from config.yaml.

Zalo gateway

  1. In sidecar/, if running for real: npm install zca-js (mock mode needs nothing).
  2. Start the sidecar: scripts/run-mos.sh (Windows: scripts/run-mos.bat). The sidecar runs at http://127.0.0.1:8787, local only, never exposed to the internet.
  3. Open http://127.0.0.1:8787/login/qr and scan the QR with the Zalo app. The session is saved at sidecar/data/zalo-credentials.json, so you don't need to scan again next time.
  4. In another terminal, run: mos supervisor --channels zalo (or mos gateway for the single-channel legacy gateway).

The Zalo MCP server (sidecar/mcp_zalo_server.js) runs in mock mode by default — tools only log in memory and return {ok: true, mode: "mock"}. Real mode needs ZALO_REAL=1 and one QR scan. See docs/flows.html (flow 9) and docs/ZALO.md.

Docs

Limits (stated plainly)

  • A dead channel doesn't spread: each adapter runs in its own thread; an exception in one channel only restarts that thread (backoff 1s → 30s) while the others keep running; failed sends go to dead letter data/dead_letter/<channel>.jsonl for later retry (Supervisor.replay_dead_letter).
  • Isolation is at thread level, not process level — if the whole process dies, every channel dies with it. One supervisor process only (single_instance.py flock guard).
  • Per-thread sessions: each platform:chat_id has its own agent and history file (data/sessions/); one session cannot read another session's history. Restarting the process starts the agent with empty history (the store still keeps old turns; resuming from the store is not done yet).
  • At-least-once delivery: if the process dies after adapter.send but before mark_sent, the message is sent again after restart. No adapter currently accepts an idempotency key.
  • Python cannot kill a thread: a turn timeout frees the worker and drops the late reply, but the in-flight model call itself keeps running until it finishes.
  • Moderation records decisions only — Mos has no kick/ban call on any adapter; human admins do the platform-side removal.
  • Text only (DM/groups). Long replies are split per platform limit (Telegram 4000 chars, gateway/platforms/telegram.py).
  • Groups must address Mos to invoke it (default); DMs/groups follow an allowlist (MOS_POLICY_ALLOWED_USERS, fail-closed).
  • Real-mode web search may still parse 0 results from DDG.
  • Not yet: voice/image, TUI, native Discord (websocket) Join Guard events; only 17 of 153 Zalo actions are ported (see docs/ZALO_ACTIONS.md).