Skip to content

geminixiang/mama

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

mama

npm version License: MIT

A multi-platform AI agent bot for Slack, Telegram, and Discord β€” based on pi-mom, with the goal of merging improvements back upstream.

πŸ“œ Attribution & Origins

This project is a forked and extended version of the mom package from badlogic/pi-mono by Mario Zechner, licensed under MIT.

  • Original project: pi-mom (22K+ stars)
  • Base version: forked from pi-mom v0.57.1 (synchronized with @mariozechner/* packages)
  • Primary motivation: Internal services urgently needed a multi-platform bot β€” this fork enables rapid iteration while preparing changes to contribute back upstream

🎯 Positioning & Roadmap

Aspect Description
Current Status Temporary standalone fork for urgent internal deployment
Ultimate Goal Merge all improvements back into pi-mono monorepo
Unique Value Multi-platform support (Slack + Telegram + Discord) to be contributed upstream

Why a temporary fork?

Our internal services urgently needed a multi-platform bot, and we couldn't wait for upstream release cycles. This fork allows us to:

  1. Ship fast: Deploy to production immediately while internal demand is high
  2. Iterate freely: Test multi-platform adapters (Slack, Telegram, Discord) without monorepo constraints
  3. Contribute back: All work here is intended to be merged into pi-mono β€” mama is not a replacement for mom

Contribution Philosophy πŸ”„

"This is not a separate product β€” it's a temporary fork for urgent internal needs, and all improvements will be contributed back to pi-mono."

We actively track the upstream pi-mom and plan to:

  • βœ… Submit PRs for platform adapters (Telegram, Discord)
  • βœ… Contribute cross-platform abstractions
  • βœ… Keep dependencies synchronized with pi-mono releases
  • βœ… Document what we learn from production use

Features

  • Multi-platform β€” Slack, Telegram, and Discord adapters out of the box
  • Thread sessions β€” each thread / reply chain gets its own isolated conversation context
  • Concurrent threads β€” multiple threads in the same channel run independently
  • Sandbox execution β€” run agent commands on host or inside a Docker container
  • Persistent memory β€” workspace-level and channel-level MEMORY.md files
  • Skills β€” drop custom CLI tools into skills/ directories
  • Event system β€” schedule one-shot or recurring tasks via JSON files
  • Multi-provider β€” configure any provider/model supported by pi-ai

Requirements

  • Node.js >= 20
  • One of the platform integrations below

Installation

npm install -g @geminixiang/mama

Or run directly after cloning:

npm install
npm run build

Quick Start

Slack

  1. Create a Slack app with Socket Mode enabled (setup guide).
  2. Add the app_mentions:read, chat:write, files:write, and im:history OAuth scopes.
  3. Enable the Home Tab:
    • App Home β†’ Show Tabs β€” toggle Home Tab on
    • App Home β†’ Agents & AI Apps β€” toggle Agent or Assistant on
    • Event Subscriptions β†’ Subscribe to bot events β€” add app_home_opened
  4. Copy the App-Level Token (xapp-…) and Bot Token (xoxb-…).
export MOM_SLACK_APP_TOKEN=xapp-...
export MOM_SLACK_BOT_TOKEN=xoxb-...

mama [--sandbox=host|docker:<container>] <working-directory>

The bot responds when @mentioned in any channel or via DM. Each Slack thread is a separate session.


Telegram

  1. Message @BotFather β†’ /newbot to create a bot and get the Bot Token.
  2. Optionally disable privacy mode (/setprivacy β†’ Disable) so the bot can read group messages without being @mentioned.
export MOM_TELEGRAM_BOT_TOKEN=123456:ABC-...

mama [--sandbox=host|docker:<container>] <working-directory>
  • Private chats β€” every message is forwarded to the bot automatically.
  • Group chats β€” the bot only responds when @mentioned by username.
  • Reply chains β€” replying to a previous message continues the same session.
  • Say stop or /stop to cancel a running task.

Discord

  1. Go to the Discord Developer Portal β†’ New Application.
  2. Under Bot, enable Message Content Intent (required to read message text).
  3. Under OAuth2 β†’ URL Generator, select scopes bot + permissions Send Messages, Read Message History, Attach Files. Invite the bot to your server with the generated URL.
  4. Copy the Bot Token.
export MOM_DISCORD_BOT_TOKEN=MTI...

mama [--sandbox=host|docker:<container>] <working-directory>
  • Server channels β€” the bot responds when @mentioned.
  • DMs β€” every message is forwarded automatically.
  • Threads β€” messages inside a Discord thread share a single session.
  • Reply chains β€” replying to a message continues that session.
  • Say stop or /stop to cancel a running task.

Options

Option Default Description
--sandbox=host βœ“ Run commands directly on host
--sandbox=docker:<name> Run commands inside a Docker container
--download <channel-id> Download channel history to stdout and exit (Slack only)

Download channel history (Slack)

mama --download C0123456789

Configuration

Create settings.json in your working directory to override defaults:

{
  "provider": "anthropic",
  "model": "claude-sonnet-4-5",
  "thinkingLevel": "off",
  "sessionScope": "thread"
}
Field Default Description
provider anthropic AI provider (env: MOM_AI_PROVIDER)
model claude-sonnet-4-5 Model name (env: MOM_AI_MODEL)
thinkingLevel off off / low / medium / high
sessionScope thread thread (per thread/reply chain) or channel

Working Directory Layout

<working-directory>/
β”œβ”€β”€ settings.json          # AI provider/model config
β”œβ”€β”€ MEMORY.md              # Global memory (all channels)
β”œβ”€β”€ SYSTEM.md              # Installed packages / env changes log
β”œβ”€β”€ skills/                # Global skills (CLI tools)
β”œβ”€β”€ events/                # Scheduled event files
└── <channel-id>/
    β”œβ”€β”€ MEMORY.md          # Channel-specific memory
    β”œβ”€β”€ log.jsonl          # Full message history
    β”œβ”€β”€ attachments/       # Downloaded user files
    β”œβ”€β”€ scratch/           # Agent working directory
    β”œβ”€β”€ skills/            # Channel-specific skills
    └── sessions/
        └── <thread-ts>/
            └── context.jsonl   # LLM conversation context

Docker Sandbox

# Create a container (mount your working directory to /workspace)
docker run -d --name mama-sandbox \
  -v /path/to/workspace:/workspace \
  alpine:latest sleep infinity

# Start mama with Docker sandbox
mama --sandbox=docker:mama-sandbox /path/to/workspace

Events

Drop JSON files into <working-directory>/events/ to trigger the agent:

// Immediate β€” triggers as soon as mama sees the file
{"type": "immediate", "channelId": "C0123456789", "text": "New deployment finished"}

// One-shot β€” triggers once at a specific time
{"type": "one-shot", "channelId": "C0123456789", "text": "Daily standup reminder", "at": "2025-12-15T09:00:00+08:00"}

// Periodic β€” triggers on a cron schedule
{"type": "periodic", "channelId": "C0123456789", "text": "Check inbox", "schedule": "0 9 * * 1-5", "timezone": "Asia/Taipei"}

Skills

Create reusable CLI tools by adding a directory with a SKILL.md:

skills/
└── my-tool/
    β”œβ”€β”€ SKILL.md    # name + description frontmatter, usage docs
    └── run.sh      # the actual script

SKILL.md frontmatter:

---
name: my-tool
description: Does something useful
---

Usage: {baseDir}/run.sh <args>

Development

npm run dev     # watch mode
npm test        # run tests
npm run build   # production build

πŸ“¦ Dependencies & Versions

Package mama Version pi-mom Synced Version
@mariozechner/pi-agent-core ^0.57.1 βœ… Synchronized
@mariozechner/pi-ai ^0.57.1 βœ… Synchronized
@mariozechner/pi-coding-agent ^0.57.1 βœ… Synchronized
@anthropic-ai/sandbox-runtime ^0.0.40 ⚠️ Newer (pi-mom uses 0.0.16)

License

MIT β€” see LICENSE.

Note: This project inherits the MIT license from pi-mom and aims to keep its contributions compatible with the upstream ecosystem.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors