@geminixiang/mama 0.2.0-beta.3 → 0.2.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -422
- package/dist/adapter.d.ts +9 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js.map +1 -1
- package/dist/adapters/discord/bot.d.ts +1 -0
- package/dist/adapters/discord/bot.d.ts.map +1 -1
- package/dist/adapters/discord/bot.js +62 -73
- package/dist/adapters/discord/bot.js.map +1 -1
- package/dist/adapters/discord/context.d.ts.map +1 -1
- package/dist/adapters/discord/context.js +9 -2
- package/dist/adapters/discord/context.js.map +1 -1
- package/dist/adapters/shared.d.ts +48 -0
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/adapters/shared.js +111 -0
- package/dist/adapters/shared.js.map +1 -1
- package/dist/adapters/slack/bot.d.ts +3 -19
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +58 -188
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/context.d.ts.map +1 -1
- package/dist/adapters/slack/context.js +13 -3
- package/dist/adapters/slack/context.js.map +1 -1
- package/dist/adapters/telegram/bot.d.ts.map +1 -1
- package/dist/adapters/telegram/bot.js +78 -100
- package/dist/adapters/telegram/bot.js.map +1 -1
- package/dist/adapters/telegram/context.d.ts.map +1 -1
- package/dist/adapters/telegram/context.js +9 -2
- package/dist/adapters/telegram/context.js.map +1 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +15 -5
- package/dist/agent.js.map +1 -1
- package/dist/bindings.d.ts +2 -1
- package/dist/bindings.d.ts.map +1 -1
- package/dist/bindings.js +3 -2
- package/dist/bindings.js.map +1 -1
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +8 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/login.d.ts +5 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +37 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/registry.d.ts +7 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +14 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/session-view.d.ts +5 -0
- package/dist/commands/session-view.d.ts.map +1 -0
- package/dist/commands/session-view.js +38 -0
- package/dist/commands/session-view.js.map +1 -0
- package/dist/commands/types.d.ts +41 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/utils.d.ts +5 -0
- package/dist/commands/utils.d.ts.map +1 -0
- package/dist/commands/utils.js +9 -0
- package/dist/commands/utils.js.map +1 -0
- package/dist/config.d.ts +4 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +37 -42
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +74 -68
- package/dist/context.js.map +1 -1
- package/dist/execution-resolver.d.ts +6 -3
- package/dist/execution-resolver.d.ts.map +1 -1
- package/dist/execution-resolver.js +47 -14
- package/dist/execution-resolver.js.map +1 -1
- package/dist/fs-atomic.d.ts +10 -0
- package/dist/fs-atomic.d.ts.map +1 -0
- package/dist/fs-atomic.js +45 -0
- package/dist/fs-atomic.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/instrument.d.ts.map +1 -1
- package/dist/instrument.js +2 -3
- package/dist/instrument.js.map +1 -1
- package/dist/login/index.d.ts.map +1 -1
- package/dist/login/index.js +19 -8
- package/dist/login/index.js.map +1 -1
- package/dist/login/portal.d.ts.map +1 -1
- package/dist/login/portal.js +7 -7
- package/dist/login/portal.js.map +1 -1
- package/dist/login/session.d.ts +3 -2
- package/dist/login/session.d.ts.map +1 -1
- package/dist/login/session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +63 -389
- package/dist/main.js.map +1 -1
- package/dist/provisioner.d.ts +11 -9
- package/dist/provisioner.d.ts.map +1 -1
- package/dist/provisioner.js +125 -87
- package/dist/provisioner.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/session-runtime.d.ts +26 -0
- package/dist/runtime/session-runtime.d.ts.map +1 -0
- package/dist/runtime/session-runtime.js +285 -0
- package/dist/runtime/session-runtime.js.map +1 -0
- package/dist/sandbox/cloudflare.d.ts +14 -0
- package/dist/sandbox/cloudflare.d.ts.map +1 -0
- package/dist/sandbox/cloudflare.js +131 -0
- package/dist/sandbox/cloudflare.js.map +1 -0
- package/dist/sandbox/index.d.ts +6 -4
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +6 -3
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/types.d.ts +5 -1
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sandbox/types.js.map +1 -1
- package/dist/session-store.d.ts +5 -1
- package/dist/session-store.d.ts.map +1 -1
- package/dist/session-store.js +14 -9
- package/dist/session-store.js.map +1 -1
- package/dist/session-view/portal.d.ts +2 -0
- package/dist/session-view/portal.d.ts.map +1 -1
- package/dist/session-view/portal.js +45 -7
- package/dist/session-view/portal.js.map +1 -1
- package/dist/session-view/service.d.ts.map +1 -1
- package/dist/session-view/service.js +94 -48
- package/dist/session-view/service.js.map +1 -1
- package/dist/session-view/store.d.ts +3 -2
- package/dist/session-view/store.d.ts.map +1 -1
- package/dist/session-view/store.js.map +1 -1
- package/dist/vault-routing.d.ts +3 -5
- package/dist/vault-routing.d.ts.map +1 -1
- package/dist/vault-routing.js +8 -20
- package/dist/vault-routing.js.map +1 -1
- package/dist/vault.d.ts +7 -5
- package/dist/vault.d.ts.map +1 -1
- package/dist/vault.js +111 -104
- package/dist/vault.js.map +1 -1
- package/package.json +7 -9
package/README.md
CHANGED
|
@@ -1,72 +1,35 @@
|
|
|
1
|
-
# mama
|
|
1
|
+
# mama (Multi-Agent Mischief Assistant)
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@geminixiang/mama)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
A multi-platform AI
|
|
6
|
+
A multi-platform AI assistant for Slack, Telegram, and Discord.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
This project is a **forked and extended version** of the `mom` package from [`badlogic/pi-mono`](https://github.com/badlogic/pi-mono) by Mario Zechner, licensed under MIT.
|
|
11
|
-
|
|
12
|
-
- **Original project**: [pi-mom](https://github.com/badlogic/pi-mono/tree/main/packages/mom) (22K+ stars)
|
|
13
|
-
- **Base version**: forked from pi-mom v0.57.1 (synchronized with `@mariozechner/*` packages)
|
|
14
|
-
- **Primary motivation**: Internal services urgently needed a multi-platform bot — this fork enables rapid iteration while preparing changes to contribute back upstream
|
|
15
|
-
|
|
16
|
-
## 🎯 Positioning & Roadmap
|
|
17
|
-
|
|
18
|
-
| Aspect | Description |
|
|
19
|
-
| ------------------ | ------------------------------------------------------------------------------ |
|
|
20
|
-
| **Current Status** | Temporary standalone fork for urgent internal deployment |
|
|
21
|
-
| **Ultimate Goal** | Merge all improvements back into pi-mono monorepo |
|
|
22
|
-
| **Unique Value** | Multi-platform support (Slack + Telegram + Discord) to be contributed upstream |
|
|
23
|
-
|
|
24
|
-
### Why a temporary fork?
|
|
25
|
-
|
|
26
|
-
Our internal services urgently needed a multi-platform bot, and we couldn't wait for upstream release cycles. This fork allows us to:
|
|
27
|
-
|
|
28
|
-
1. **Ship fast**: Deploy to production immediately while internal demand is high
|
|
29
|
-
2. **Iterate freely**: Test multi-platform adapters (Slack, Telegram, Discord) without monorepo constraints
|
|
30
|
-
3. **Contribute back**: All work here is intended to be merged into pi-mono — `mama` is not a replacement for `mom`
|
|
31
|
-
|
|
32
|
-
### Contribution Philosophy 🔄
|
|
33
|
-
|
|
34
|
-
> "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."
|
|
35
|
-
|
|
36
|
-
We actively track the upstream `pi-mom` and plan to:
|
|
37
|
-
|
|
38
|
-
- ✅ Submit PRs for platform adapters (Telegram, Discord)
|
|
39
|
-
- ✅ Contribute cross-platform abstractions
|
|
40
|
-
- ✅ Keep dependencies synchronized with pi-mono releases
|
|
41
|
-
- ✅ Document what we learn from production use
|
|
42
|
-
|
|
43
|
-
---
|
|
8
|
+
Forked from [`badlogic/pi-mono`](https://github.com/badlogic/pi-mono)'s `mom` package (MIT, by Mario Zechner) at v0.57.1. This fork adds Telegram and Discord adapters and exists to ship internally while we prepare changes to upstream.
|
|
44
9
|
|
|
45
10
|
## Features
|
|
46
11
|
|
|
47
|
-
- **Multi-platform** — Slack, Telegram,
|
|
48
|
-
- **
|
|
49
|
-
- **
|
|
50
|
-
- **
|
|
51
|
-
- **
|
|
52
|
-
- **
|
|
53
|
-
- **
|
|
54
|
-
- **
|
|
55
|
-
- **
|
|
56
|
-
- **Multi-provider** — configure any provider/model supported by `pi-ai`
|
|
12
|
+
- **Multi-platform** — Slack, Telegram, Discord adapters
|
|
13
|
+
- **Concurrent conversations** — Slack threads, Discord replies/threads, and Telegram reply chains run as independent sessions
|
|
14
|
+
- **Sandbox execution** — host, shared container, per-user managed container, Firecracker (alpha), or Cloudflare bridge (experimental)
|
|
15
|
+
- **Credential vaults** — `/login` stores credentials under `--state-dir` and injects env into sandbox runs
|
|
16
|
+
- **Web session viewer** — read-only web view of the current session via `session` / `/session`
|
|
17
|
+
- **Persistent memory** — workspace-level and channel-level `MEMORY.md`
|
|
18
|
+
- **Skills** — drop CLI tools into `skills/`
|
|
19
|
+
- **Events** — schedule one-shot or recurring tasks via JSON files
|
|
20
|
+
- **Multi-provider** — any provider/model supported by `pi-ai`
|
|
57
21
|
|
|
58
22
|
## Platform Session Model
|
|
59
23
|
|
|
60
|
-
| Platform |
|
|
61
|
-
| -------- |
|
|
62
|
-
| Slack |
|
|
63
|
-
| Discord |
|
|
64
|
-
| Telegram | private
|
|
24
|
+
| Platform | `sessionKey` Rule | Notes |
|
|
25
|
+
| -------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
|
26
|
+
| Slack | top-level / DM: `conversationId`; thread: `conversationId:threadTs` | thread inherits parent context at fork time only; branch changes do not merge back |
|
|
27
|
+
| Discord | DM: `channelId`; shared top-level: `channelId:messageId`; reply/thread: rooted id | replies in shared channels continue the root message session; DM replies do not fork |
|
|
28
|
+
| Telegram | private: `chatId`; shared top-level: `chatId:messageId`; reply chain: root reply | no native thread model; shared sessions are inferred from reply chains |
|
|
65
29
|
|
|
66
30
|
## Requirements
|
|
67
31
|
|
|
68
32
|
- Node.js >= 20
|
|
69
|
-
- One of the platform integrations below
|
|
70
33
|
|
|
71
34
|
## Installation
|
|
72
35
|
|
|
@@ -74,441 +37,162 @@ We actively track the upstream `pi-mom` and plan to:
|
|
|
74
37
|
npm install -g @geminixiang/mama
|
|
75
38
|
```
|
|
76
39
|
|
|
77
|
-
Or
|
|
40
|
+
Or from source:
|
|
78
41
|
|
|
79
42
|
```bash
|
|
80
|
-
npm install
|
|
81
|
-
npm run build
|
|
43
|
+
npm install && npm run build
|
|
82
44
|
```
|
|
83
45
|
|
|
84
|
-
---
|
|
85
|
-
|
|
86
46
|
## Quick Start
|
|
87
47
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
1. Create a Slack app with **Socket Mode** enabled ([setup guide](docs/slack-bot-minimal-guide.md)).
|
|
91
|
-
2. Add the following **OAuth Bot Token Scopes**:
|
|
92
|
-
- `app_mentions:read`, `channels:history`, `channels:read`, `chat:write`
|
|
93
|
-
- `files:read`, `files:write`, `groups:history`, `groups:read`
|
|
94
|
-
- `im:history`, `im:read`, `im:write`, `users:read`
|
|
95
|
-
- `assistant:write` — required for native "Thinking" status indicator
|
|
96
|
-
3. Enable the **Home Tab** and **Agent mode**:
|
|
97
|
-
- **App Home → Show Tabs** — toggle **Home Tab** on
|
|
98
|
-
- **App Home → Agents & AI Apps** — toggle **Agent or Assistant** on
|
|
99
|
-
4. Subscribe to **Bot Events**:
|
|
100
|
-
- `app_home_opened`, `app_mention`
|
|
101
|
-
- `assistant_thread_context_changed`, `assistant_thread_started`
|
|
102
|
-
- `message.channels`, `message.groups`, `message.im`
|
|
103
|
-
5. Enable **Interactivity** (Settings → Interactivity & Shortcuts → toggle on).
|
|
104
|
-
6. (Optional) Add **Slash Commands** such as `/pi-login` and `/pi-new` in the Slack app settings if you want dedicated commands with less naming conflict. `/pi-new` is intended for DM use only.
|
|
105
|
-
7. Copy the **App-Level Token** (`xapp-…`) and **Bot Token** (`xoxb-…`).
|
|
106
|
-
|
|
107
|
-
Or import this **App Manifest** directly (Settings → App Manifest → paste JSON):
|
|
108
|
-
|
|
109
|
-
<details>
|
|
110
|
-
<summary>Example App Manifest</summary>
|
|
48
|
+
All platforms share the same CLI:
|
|
111
49
|
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
"display_information": {
|
|
115
|
-
"name": "mama"
|
|
116
|
-
},
|
|
117
|
-
"features": {
|
|
118
|
-
"app_home": {
|
|
119
|
-
"home_tab_enabled": true,
|
|
120
|
-
"messages_tab_enabled": false,
|
|
121
|
-
"messages_tab_read_only_enabled": false
|
|
122
|
-
},
|
|
123
|
-
"bot_user": {
|
|
124
|
-
"display_name": "mama",
|
|
125
|
-
"always_online": false
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
"oauth_config": {
|
|
129
|
-
"scopes": {
|
|
130
|
-
"bot": [
|
|
131
|
-
"app_mentions:read",
|
|
132
|
-
"assistant:write",
|
|
133
|
-
"channels:history",
|
|
134
|
-
"channels:read",
|
|
135
|
-
"chat:write",
|
|
136
|
-
"files:read",
|
|
137
|
-
"files:write",
|
|
138
|
-
"groups:history",
|
|
139
|
-
"groups:read",
|
|
140
|
-
"im:history",
|
|
141
|
-
"im:read",
|
|
142
|
-
"im:write",
|
|
143
|
-
"users:read"
|
|
144
|
-
]
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
"settings": {
|
|
148
|
-
"event_subscriptions": {
|
|
149
|
-
"bot_events": [
|
|
150
|
-
"app_home_opened",
|
|
151
|
-
"app_mention",
|
|
152
|
-
"assistant_thread_context_changed",
|
|
153
|
-
"assistant_thread_started",
|
|
154
|
-
"message.channels",
|
|
155
|
-
"message.groups",
|
|
156
|
-
"message.im"
|
|
157
|
-
]
|
|
158
|
-
},
|
|
159
|
-
"interactivity": {
|
|
160
|
-
"is_enabled": true
|
|
161
|
-
},
|
|
162
|
-
"org_deploy_enabled": false,
|
|
163
|
-
"socket_mode_enabled": true,
|
|
164
|
-
"token_rotation_enabled": false
|
|
165
|
-
}
|
|
166
|
-
}
|
|
50
|
+
```bash
|
|
51
|
+
mama [--state-dir=~/.mama] [--sandbox=<mode>] <working-directory>
|
|
167
52
|
```
|
|
168
53
|
|
|
169
|
-
|
|
54
|
+
Set the platform tokens you need (you can run multiple platforms at once):
|
|
170
55
|
|
|
171
56
|
```bash
|
|
172
|
-
export
|
|
173
|
-
export
|
|
174
|
-
|
|
175
|
-
|
|
57
|
+
export MAMA_SLACK_APP_TOKEN=xapp-...
|
|
58
|
+
export MAMA_SLACK_BOT_TOKEN=xoxb-...
|
|
59
|
+
export MAMA_TELEGRAM_BOT_TOKEN=123456:ABC-...
|
|
60
|
+
export MAMA_DISCORD_BOT_TOKEN=MTI...
|
|
176
61
|
```
|
|
177
62
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
- **Top-level channel messages** — share one persistent channel session.
|
|
181
|
-
- **Thread replies** — fork from the channel session into an isolated thread session.
|
|
182
|
-
- **DM top-level messages** — share one persistent DM session.
|
|
183
|
-
- **DM thread replies** — fork from the DM session into an isolated thread session.
|
|
184
|
-
- **Thread memory** — inherited at fork time only; thread changes do not merge back into the parent session automatically.
|
|
63
|
+
### Slack
|
|
185
64
|
|
|
186
|
-
|
|
65
|
+
Create a Socket Mode app with the scopes and event subscriptions listed in [docs/slack-bot-minimal-guide.md](docs/slack-bot-minimal-guide.md). The bot responds when `@mentioned` in channels and to all DMs.
|
|
187
66
|
|
|
188
67
|
### Telegram
|
|
189
68
|
|
|
190
|
-
|
|
191
|
-
2. Optionally disable privacy mode (`/setprivacy → Disable`) so the bot can read group messages without being `@mentioned`.
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
export MOM_TELEGRAM_BOT_TOKEN=123456:ABC-...
|
|
195
|
-
|
|
196
|
-
mama [--state-dir=~/.mama] [--sandbox=host|container:<container>|image:<image>|firecracker:<vm-id>:<path>] <working-directory>
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
- **Private chats** — every message is forwarded to the bot automatically.
|
|
200
|
-
- **Group chats** — the bot only responds when `@mentioned` by username.
|
|
201
|
-
- **Private chat session** — one persistent session per DM.
|
|
202
|
-
- **Group top-level mentions** — each mentioned message starts its own scoped session.
|
|
203
|
-
- **Reply chains** — replying to a previous message continues that reply-root session.
|
|
204
|
-
- Say `stop` or `/stop` to cancel a running task.
|
|
205
|
-
|
|
206
|
-
---
|
|
69
|
+
Create a bot via [@BotFather](https://t.me/BotFather) and copy the token. The bot responds to all private messages, and to `@mention` or reply chains in groups. Say `stop` or `/stop` to cancel a running task.
|
|
207
70
|
|
|
208
71
|
### Discord
|
|
209
72
|
|
|
210
|
-
|
|
211
|
-
2. Under **Bot**, enable **Message Content Intent** (required to read message text).
|
|
212
|
-
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.
|
|
213
|
-
4. Copy the **Bot Token**.
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
export MOM_DISCORD_BOT_TOKEN=MTI...
|
|
217
|
-
|
|
218
|
-
mama [--state-dir=~/.mama] [--sandbox=host|container:<container>|image:<image>|firecracker:<vm-id>:<path>] <working-directory>
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
- **Server channels** — the bot responds when `@mentioned`.
|
|
222
|
-
- **DMs** — every message is forwarded automatically.
|
|
223
|
-
- **DM session** — one persistent session per DM channel.
|
|
224
|
-
- **Top-level mentions in shared channels** — each mentioned message starts its own scoped session.
|
|
225
|
-
- **Threads and reply chains** — messages inside the same thread or reply root share a session.
|
|
226
|
-
- Say `stop` or `/stop` to cancel a running task.
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## Options
|
|
73
|
+
Create an application in the [Discord Developer Portal](https://discord.com/developers/applications), enable **Message Content Intent**, and invite the bot with `Send Messages`, `Read Message History`, `Attach Files`. The bot responds to `@mentions` in servers and to all DMs.
|
|
231
74
|
|
|
232
|
-
|
|
233
|
-
| -------------------------------------- | --------- | ------------------------------------------------------------------ |
|
|
234
|
-
| `--state-dir=<dir>` | `~/.mama` | Store settings, credential vaults, and bindings outside workspace |
|
|
235
|
-
| `--sandbox=host` | ✓ | Run commands directly on host; vault env is not injected |
|
|
236
|
-
| `--sandbox=container:<name>` | | Run commands in an existing shared container |
|
|
237
|
-
| `--sandbox=image:<image>` | | Auto-provision one Docker container per platform user |
|
|
238
|
-
| `--sandbox=firecracker:<vm-id>:<path>` | | Experimental Firecracker microVM mode (alpha; not recommended yet) |
|
|
239
|
-
| `--download <channel-id>` | | Download channel history to stdout and exit (Slack only) |
|
|
75
|
+
## Sandbox Modes
|
|
240
76
|
|
|
241
|
-
|
|
77
|
+
| Mode | Description |
|
|
78
|
+
| ---------------------------- | ---------------------------------------------------------------------- |
|
|
79
|
+
| `host` (default) | Run on host; no vault env injection |
|
|
80
|
+
| `container:<name>` | Run in an existing shared container; uses vault key `container-<name>` |
|
|
81
|
+
| `image:<image>` | Auto-provision one Docker container per resolved vault/user |
|
|
82
|
+
| `firecracker:<vm-id>:<path>` | Firecracker microVM (alpha; not recommended) |
|
|
83
|
+
| `cloudflare:<sandbox-id>` | Cloudflare Worker bridge (experimental; no auto workspace sync) |
|
|
242
84
|
|
|
243
|
-
|
|
244
|
-
- `container:<name>`: one container maps to one shared vault key: `container-<name>`.
|
|
245
|
-
- `image:<image>`: mama creates one container per resolved vault/user and injects that vault's env and file mounts.
|
|
246
|
-
- `firecracker:*`: per-user vault routing via `bindings.json` first, then direct userId vault. This mode is still alpha and not recommended for normal deployments yet.
|
|
247
|
-
- `docker:*` is not supported; use `container:*` or `image:*`.
|
|
85
|
+
Vault routing: `image`, `firecracker`, and `cloudflare` look up `bindings.json` first, then fall back to the userId vault. See [docs/sandbox.md](docs/sandbox.md) for the full matrix.
|
|
248
86
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
### Download channel history (Slack)
|
|
87
|
+
### Managed per-user containers (`image:*`)
|
|
252
88
|
|
|
253
89
|
```bash
|
|
254
|
-
|
|
90
|
+
docker pull ghcr.io/geminixiang/mama-sandbox:tools
|
|
91
|
+
mama --sandbox=image:ghcr.io/geminixiang/mama-sandbox:tools /path/to/workspace
|
|
255
92
|
```
|
|
256
93
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
For normal deployments, set `MOM_LINK_URL` to the externally reachable base URL of the web credential onboarding flow:
|
|
94
|
+
Or build locally:
|
|
260
95
|
|
|
261
96
|
```bash
|
|
262
|
-
|
|
263
|
-
# optional; defaults to 8181 when MOM_LINK_URL is set
|
|
264
|
-
export MOM_LINK_PORT=8181
|
|
97
|
+
docker build -f docker/mama-sandbox.Dockerfile -t mama-sandbox:tools .
|
|
265
98
|
```
|
|
266
99
|
|
|
267
|
-
|
|
100
|
+
mama creates one container per vault, attaches each to its own bridge network, mounts the workspace at `/workspace`, injects vault env, mounts declared credential files, and stops idle containers.
|
|
268
101
|
|
|
269
|
-
|
|
102
|
+
### Firecracker / Cloudflare
|
|
270
103
|
|
|
271
|
-
|
|
104
|
+
See [docs/firecracker-setup.md](docs/firecracker-setup.md) and [examples/cloudflare-sandbox-bridge/README.md](examples/cloudflare-sandbox-bridge/README.md).
|
|
272
105
|
|
|
273
|
-
|
|
274
|
-
- `/pi-new` only works in a Slack DM and resets that DM session context.
|
|
106
|
+
## `/login` and Web Session Viewer
|
|
275
107
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
- Users can send `session`, `/session`, or `/pi-session` in a private conversation / DM.
|
|
281
|
-
- mama returns an expiring read-only link to `/session?token=...`.
|
|
282
|
-
- The page shows the current branch timeline, including user messages, assistant replies, tool results, and compaction / branch summary events.
|
|
283
|
-
- For now, session links are only issued from private conversations to avoid leaking shared-channel history.
|
|
284
|
-
|
|
285
|
-
This feature uses the same `MOM_LINK_URL` / `MOM_LINK_PORT` configuration as `/login`.
|
|
108
|
+
```bash
|
|
109
|
+
export MAMA_LINK_URL="https://mama.example.com" # public base URL
|
|
110
|
+
export MAMA_LINK_PORT=8181 # optional, defaults to 8181
|
|
111
|
+
```
|
|
286
112
|
|
|
287
|
-
|
|
113
|
+
For local testing you can set just `MAMA_LINK_PORT`; mama will use `http://localhost:<port>`.
|
|
288
114
|
|
|
289
|
-
- [GitHub
|
|
290
|
-
-
|
|
115
|
+
- `/login` (DM only) returns a 15-minute link to store API keys or run built-in OAuth flows ([GitHub](docs/oauth/github.md), [Google Workspace](docs/oauth/google-workspace.md)).
|
|
116
|
+
- `session` / `/session` (DM only) returns a read-only link showing the current session timeline.
|
|
117
|
+
- On Slack you can also register native commands like `/pi-login` and `/pi-new` (DM-only reset).
|
|
291
118
|
|
|
292
|
-
Credentials are stored under `<state-dir>/vaults` (default `~/.mama/vaults`).
|
|
119
|
+
Credentials are stored under `<state-dir>/vaults` (default `~/.mama/vaults`). Vault env is only injected in `container`, `image`, `firecracker`, and `cloudflare` modes.
|
|
293
120
|
|
|
294
121
|
## Configuration
|
|
295
122
|
|
|
296
|
-
mama
|
|
123
|
+
mama reads `<state-dir>/settings.json` (default `~/.mama/settings.json`, override via `--state-dir` or `MAMA_STATE_DIR`). Settings written via `/login` and friends are saved to the same file.
|
|
297
124
|
|
|
298
125
|
```json
|
|
299
126
|
{
|
|
300
127
|
"provider": "anthropic",
|
|
301
128
|
"model": "claude-sonnet-4-5",
|
|
302
129
|
"thinkingLevel": "off",
|
|
303
|
-
"sessionScope": "thread",
|
|
304
130
|
"logFormat": "console",
|
|
305
131
|
"logLevel": "info",
|
|
306
132
|
"sentryDsn": "https://examplePublicKey@o0.ingest.sentry.io/0"
|
|
307
133
|
}
|
|
308
134
|
```
|
|
309
135
|
|
|
310
|
-
| Field | Default | Description
|
|
311
|
-
| --------------- | ------------------- |
|
|
312
|
-
| `provider` | `anthropic` | AI provider (env: `
|
|
313
|
-
| `model` | `claude-sonnet-4-5` | Model name (env: `
|
|
314
|
-
| `thinkingLevel` | `off` | `off` / `low` / `medium` / `high`
|
|
315
|
-
| `
|
|
316
|
-
| `
|
|
317
|
-
| `
|
|
318
|
-
| `sentryDsn` | unset | Sentry DSN (preferred over env `SENTRY_DSN`) |
|
|
319
|
-
|
|
320
|
-
When `sentryDsn` is set, mama sends Sentry events with sensitive prompt/tool content redacted before upload.
|
|
321
|
-
|
|
322
|
-
### GCP Cloud Logging (Compute Engine)
|
|
323
|
-
|
|
324
|
-
Set `logFormat: "json"` to send structured logs directly to Cloud Logging via API — no Ops Agent or log file configuration needed.
|
|
325
|
-
|
|
326
|
-
**Requirements:**
|
|
327
|
-
|
|
328
|
-
1. VM service account has `roles/logging.logWriter`
|
|
329
|
-
2. `GOOGLE_CLOUD_PROJECT` env var is set
|
|
330
|
-
|
|
331
|
-
```bash
|
|
332
|
-
GOOGLE_CLOUD_PROJECT=<your-project-id> mama <working-directory>
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
In `<state-dir>/settings.json` (or `<working-directory>/settings.json` as a fallback):
|
|
336
|
-
|
|
337
|
-
```json
|
|
338
|
-
{
|
|
339
|
-
"logFormat": "json",
|
|
340
|
-
"logLevel": "info"
|
|
341
|
-
}
|
|
342
|
-
```
|
|
136
|
+
| Field | Default | Description |
|
|
137
|
+
| --------------- | ------------------- | -------------------------------------------------------- |
|
|
138
|
+
| `provider` | `anthropic` | AI provider (env: `MAMA_AI_PROVIDER`) |
|
|
139
|
+
| `model` | `claude-sonnet-4-5` | Model name (env: `MAMA_AI_MODEL`) |
|
|
140
|
+
| `thinkingLevel` | `off` | `off` / `low` / `medium` / `high` |
|
|
141
|
+
| `logFormat` | `console` | `console` (colored stdout) or `json` (GCP Cloud Logging) |
|
|
142
|
+
| `logLevel` | `info` | `trace` / `debug` / `info` / `warn` / `error` |
|
|
143
|
+
| `sentryDsn` | unset | Sentry DSN; sensitive prompt/tool content is redacted |
|
|
343
144
|
|
|
344
|
-
|
|
145
|
+
For GCP Cloud Logging, set `logFormat: "json"`, give the VM service account `roles/logging.logWriter`, and export `GOOGLE_CLOUD_PROJECT`. Logs land under log name `mama`.
|
|
345
146
|
|
|
346
|
-
##
|
|
147
|
+
## Layout
|
|
347
148
|
|
|
348
149
|
```
|
|
349
150
|
<state-dir>/
|
|
350
|
-
├── settings.json
|
|
151
|
+
├── settings.json
|
|
351
152
|
└── vaults/
|
|
352
|
-
├── bindings.json
|
|
353
|
-
├── vault.json
|
|
153
|
+
├── bindings.json # platform user -> vault mapping
|
|
154
|
+
├── vault.json
|
|
354
155
|
└── <vault-id>/
|
|
355
|
-
├── env
|
|
356
|
-
└── ...
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
## Working Directory Layout
|
|
156
|
+
├── env
|
|
157
|
+
└── ... # credential files
|
|
360
158
|
|
|
361
|
-
```
|
|
362
159
|
<working-directory>/
|
|
363
|
-
├──
|
|
364
|
-
├──
|
|
365
|
-
├──
|
|
366
|
-
├──
|
|
367
|
-
├── events/ # Scheduled event files
|
|
160
|
+
├── MEMORY.md # global memory
|
|
161
|
+
├── SYSTEM.md # installed packages / env log
|
|
162
|
+
├── skills/ # global skills
|
|
163
|
+
├── events/ # scheduled events
|
|
368
164
|
└── <conversation-id>/
|
|
369
|
-
├── MEMORY.md
|
|
370
|
-
├── log.jsonl
|
|
371
|
-
├── attachments/
|
|
372
|
-
├── scratch/
|
|
373
|
-
├── skills/
|
|
165
|
+
├── MEMORY.md
|
|
166
|
+
├── log.jsonl
|
|
167
|
+
├── attachments/
|
|
168
|
+
├── scratch/
|
|
169
|
+
├── skills/
|
|
374
170
|
└── sessions/
|
|
375
|
-
├── current # Pointer for the persistent top-level / direct session
|
|
376
|
-
├── 2026-04-05T18-04-31-010Z_1d92b3ad.jsonl
|
|
377
|
-
└── <session-suffix>.jsonl # Fixed-path scoped session (thread / reply root)
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
## Container Sandbox
|
|
381
|
-
|
|
382
|
-
```bash
|
|
383
|
-
# Create a container (mount your working directory to /workspace)
|
|
384
|
-
docker run -d --name mama-tools \
|
|
385
|
-
-v /path/to/workspace:/workspace \
|
|
386
|
-
alpine:latest sleep infinity
|
|
387
|
-
|
|
388
|
-
# Start mama with container sandbox
|
|
389
|
-
mama --sandbox=container:mama-tools /path/to/workspace
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
`container:mama-tools` uses vault key `container-mama-tools`. If multiple users share the same container, they share that container vault.
|
|
393
|
-
|
|
394
|
-
## Managed Per-User Container Sandbox
|
|
395
|
-
|
|
396
|
-
```bash
|
|
397
|
-
# Pull the prebuilt image from GHCR
|
|
398
|
-
# Release builds publish :tools, :<version>, and :latest / :beta
|
|
399
|
-
# Pushes to main also publish :edge
|
|
400
|
-
docker pull ghcr.io/geminixiang/mama-sandbox:tools
|
|
401
|
-
|
|
402
|
-
# Start mama with managed image sandboxes
|
|
403
|
-
mama --sandbox=image:ghcr.io/geminixiang/mama-sandbox:tools /path/to/workspace
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
Or build the bundled image locally:
|
|
407
|
-
|
|
408
|
-
```bash
|
|
409
|
-
docker build -f docker/mama-sandbox.Dockerfile -t mama-sandbox:tools .
|
|
410
|
-
mama --sandbox=image:mama-sandbox:tools /path/to/workspace
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
In this mode mama creates one Docker container per resolved vault/user, attaches each container to its own Docker bridge network for per-user network isolation, mounts the workspace at `/workspace`, injects vault env on execution, mounts any credential files declared in the vault, and stops idle containers automatically.
|
|
414
|
-
|
|
415
|
-
## Firecracker Sandbox
|
|
416
|
-
|
|
417
|
-
Warning: Firecracker support is still in very early alpha. It is useful for experimentation, but it is not yet the recommended sandbox mode for normal development or production use. Prefer `image:<image>` unless you are actively validating Firecracker behavior.
|
|
418
|
-
|
|
419
|
-
Firecracker provides lightweight VM isolation with the security benefits of a hypervisor. Unlike Docker containers, Firecracker runs a full Linux kernel, providing stronger isolation.
|
|
420
|
-
|
|
421
|
-
### Requirements
|
|
422
|
-
|
|
423
|
-
- SSH access to the Firecracker VM
|
|
424
|
-
- SSH key-based authentication configured
|
|
425
|
-
- Host workspace must be mounted at `/workspace` inside the VM
|
|
426
|
-
|
|
427
|
-
### Format
|
|
428
|
-
|
|
429
|
-
```
|
|
430
|
-
--sandbox=firecracker:<vm-id>:<host-path>[:<ssh-user>[:<ssh-port>]]
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
| Parameter | Default | Description |
|
|
434
|
-
| ----------- | ------- | ------------------------------ |
|
|
435
|
-
| `vm-id` | - | VM identifier (hostname or IP) |
|
|
436
|
-
| `host-path` | - | Working directory on the host |
|
|
437
|
-
| `ssh-user` | `root` | SSH username |
|
|
438
|
-
| `ssh-port` | `22` | SSH port |
|
|
439
|
-
|
|
440
|
-
### Examples
|
|
441
|
-
|
|
442
|
-
```bash
|
|
443
|
-
# Basic usage (VM at 192.168.1.100, default ssh user root:22)
|
|
444
|
-
mama --sandbox=firecracker:192.168.1.100:/home/user/workspace /home/user/workspace
|
|
445
|
-
|
|
446
|
-
# Custom SSH user
|
|
447
|
-
mama --sandbox=firecracker:192.168.1.100:/home/user/workspace:ubuntu /home/user/workspace
|
|
448
|
-
|
|
449
|
-
# Custom SSH port
|
|
450
|
-
mama --sandbox=firecracker:192.168.1.100:/home/user/workspace:root:2222 /home/user/workspace
|
|
451
171
|
```
|
|
452
172
|
|
|
453
|
-
### Setup
|
|
454
|
-
|
|
455
|
-
1. **Start a Firecracker VM** with your preferred method (fc-agent, firecracker-ctl, or manual)
|
|
456
|
-
|
|
457
|
-
2. **Configure SSH access** inside the VM:
|
|
458
|
-
|
|
459
|
-
```bash
|
|
460
|
-
# Inside the VM - allow password-less SSH for mama
|
|
461
|
-
sudo systemctl enable ssh
|
|
462
|
-
sudo sed -i 's/^#*PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
|
|
463
|
-
sudo sed -i 's/^#*PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
|
464
|
-
sudo systemctl restart ssh
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
3. **Mount your workspace** at `/workspace` inside the VM:
|
|
468
|
-
|
|
469
|
-
```bash
|
|
470
|
-
# Option A: 9pfs (recommended, from host)
|
|
471
|
-
sudo mount -t 9p -o trans=virtio,version=9p2000.L host0 /workspace
|
|
472
|
-
|
|
473
|
-
# Option B: NFS
|
|
474
|
-
sudo mount -t nfs <host-ip>:/path/to/workspace /workspace
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
4. **Test SSH connectivity** from host:
|
|
478
|
-
```bash
|
|
479
|
-
ssh root@192.168.1.100 "echo works"
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
The host path is mounted as `/workspace` inside the Firecracker VM. All bash commands will execute inside the VM.
|
|
483
|
-
|
|
484
173
|
## Events
|
|
485
174
|
|
|
486
|
-
Drop JSON files into `<working-directory>/events
|
|
175
|
+
Drop JSON files into `<working-directory>/events/`:
|
|
487
176
|
|
|
488
177
|
```json
|
|
489
|
-
// Immediate
|
|
490
|
-
{"type": "immediate", "platform": "slack", "conversationId": "C0123456789", "conversationKind": "shared", "text": "
|
|
178
|
+
// Immediate
|
|
179
|
+
{"type": "immediate", "platform": "slack", "conversationId": "C0123456789", "conversationKind": "shared", "text": "Deploy finished"}
|
|
491
180
|
|
|
492
|
-
// One-shot
|
|
493
|
-
{"type": "one-shot", "platform": "telegram", "conversationId": "574247312", "conversationKind": "direct", "text": "
|
|
181
|
+
// One-shot
|
|
182
|
+
{"type": "one-shot", "platform": "telegram", "conversationId": "574247312", "conversationKind": "direct", "text": "Standup", "at": "2025-12-15T09:00:00+08:00"}
|
|
494
183
|
|
|
495
|
-
// Periodic
|
|
184
|
+
// Periodic (cron)
|
|
496
185
|
{"type": "periodic", "platform": "discord", "conversationId": "1498975469343739948", "conversationKind": "shared", "text": "Check inbox", "schedule": "0 9 * * 1-5", "timezone": "Asia/Taipei"}
|
|
497
186
|
```
|
|
498
187
|
|
|
499
188
|
## Skills
|
|
500
189
|
|
|
501
|
-
Create reusable CLI tools by adding a directory with a `SKILL.md`:
|
|
502
|
-
|
|
503
190
|
```
|
|
504
|
-
skills/
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
└── run.sh # the actual script
|
|
191
|
+
skills/my-tool/
|
|
192
|
+
├── SKILL.md # name + description frontmatter, usage docs
|
|
193
|
+
└── run.sh
|
|
508
194
|
```
|
|
509
195
|
|
|
510
|
-
`SKILL.md` frontmatter:
|
|
511
|
-
|
|
512
196
|
```yaml
|
|
513
197
|
---
|
|
514
198
|
name: my-tool
|
|
@@ -518,25 +202,20 @@ description: Does something useful
|
|
|
518
202
|
Usage: {baseDir}/run.sh <args>
|
|
519
203
|
```
|
|
520
204
|
|
|
521
|
-
##
|
|
205
|
+
## Slack: Download channel history
|
|
522
206
|
|
|
523
207
|
```bash
|
|
524
|
-
|
|
525
|
-
npm test # run tests
|
|
526
|
-
npm run build # production build
|
|
208
|
+
mama --download C0123456789
|
|
527
209
|
```
|
|
528
210
|
|
|
529
|
-
##
|
|
211
|
+
## Development
|
|
530
212
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
| `@anthropic-ai/sandbox-runtime` | `^0.0.49` | ⚠️ Newer than original fork base |
|
|
213
|
+
```bash
|
|
214
|
+
npm run dev # watch mode
|
|
215
|
+
npm test
|
|
216
|
+
npm run build
|
|
217
|
+
```
|
|
537
218
|
|
|
538
219
|
## License
|
|
539
220
|
|
|
540
|
-
MIT — see [LICENSE](LICENSE).
|
|
541
|
-
|
|
542
|
-
**Note**: This project inherits the MIT license from pi-mom and aims to keep its contributions compatible with the upstream ecosystem.
|
|
221
|
+
MIT — see [LICENSE](LICENSE). Inherits from pi-mom.
|