milaidy 1.0.0

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.
Files changed (253) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +538 -0
  3. package/dist/argv-CfSowvEA.js +63 -0
  4. package/dist/config-B-mboG4v.js +4 -0
  5. package/dist/eliza-CPJjgw-e.js +1491 -0
  6. package/dist/eliza.js +2192 -0
  7. package/dist/entry.js +232 -0
  8. package/dist/index.js +209 -0
  9. package/dist/links-BFKlWqSe.js +15 -0
  10. package/dist/paths-D_yh1DEJ.js +69 -0
  11. package/dist/plugins-cli-B7kSre2c.js +134 -0
  12. package/dist/program-6KwWwKKh.js +510 -0
  13. package/dist/register.agents-CPVmSjMG.js +17 -0
  14. package/dist/register.browser-B2ooXxNx.js +15 -0
  15. package/dist/register.channels-CMYQ6K6Y.js +42 -0
  16. package/dist/register.cron-D91lY1_Y.js +9 -0
  17. package/dist/register.devices-rU5I5L_y.js +13 -0
  18. package/dist/register.gateway-82SLAvw3.js +22 -0
  19. package/dist/register.hooks-B_XTBEkt.js +9 -0
  20. package/dist/register.logs-BgEGcPd8.js +10 -0
  21. package/dist/register.models-BJt9eVgZ.js +26 -0
  22. package/dist/register.nodes-B5xY1s8a.js +9 -0
  23. package/dist/register.skills-SFQqYIhg.js +10 -0
  24. package/dist/register.subclis-uF_AsbWR.js +187 -0
  25. package/dist/run-main-XODklzS-.js +56 -0
  26. package/dist/theme-DBvtuGeq.js +36 -0
  27. package/dist/utils-C1AUpp_V.js +42 -0
  28. package/dist/version-Cpn3yr5D.js +26 -0
  29. package/dist/workspace-Co3Wul2D.js +206 -0
  30. package/dist/workspace-DCA6MNVK.js +350 -0
  31. package/docs/.i18n/README.md +31 -0
  32. package/docs/.i18n/glossary.zh-CN.json +210 -0
  33. package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
  34. package/docs/CNAME +1 -0
  35. package/docs/automation/cron-jobs.md +468 -0
  36. package/docs/automation/cron-vs-heartbeat.md +254 -0
  37. package/docs/automation/gmail-pubsub.md +256 -0
  38. package/docs/automation/poll.md +69 -0
  39. package/docs/automation/webhook.md +163 -0
  40. package/docs/bedrock.md +176 -0
  41. package/docs/brave-search.md +41 -0
  42. package/docs/broadcast-groups.md +442 -0
  43. package/docs/cli/acp.md +170 -0
  44. package/docs/cli/agent.md +24 -0
  45. package/docs/cli/agents.md +75 -0
  46. package/docs/cli/approvals.md +50 -0
  47. package/docs/cli/browser.md +107 -0
  48. package/docs/cli/channels.md +79 -0
  49. package/docs/cli/config.md +50 -0
  50. package/docs/cli/configure.md +33 -0
  51. package/docs/cli/cron.md +42 -0
  52. package/docs/cli/dashboard.md +16 -0
  53. package/docs/cli/devices.md +67 -0
  54. package/docs/cli/directory.md +63 -0
  55. package/docs/cli/dns.md +23 -0
  56. package/docs/cli/docs.md +15 -0
  57. package/docs/cli/doctor.md +41 -0
  58. package/docs/cli/gateway.md +199 -0
  59. package/docs/cli/health.md +21 -0
  60. package/docs/cli/hooks.md +291 -0
  61. package/docs/cli/index.md +1029 -0
  62. package/docs/cli/logs.md +24 -0
  63. package/docs/cli/memory.md +45 -0
  64. package/docs/cli/message.md +239 -0
  65. package/docs/cli/models.md +79 -0
  66. package/docs/cli/node.md +112 -0
  67. package/docs/cli/nodes.md +73 -0
  68. package/docs/cli/onboard.md +29 -0
  69. package/docs/cli/pairing.md +21 -0
  70. package/docs/cli/plugins.md +62 -0
  71. package/docs/cli/reset.md +17 -0
  72. package/docs/cli/sandbox.md +152 -0
  73. package/docs/cli/security.md +26 -0
  74. package/docs/cli/sessions.md +16 -0
  75. package/docs/cli/setup.md +29 -0
  76. package/docs/cli/skills.md +26 -0
  77. package/docs/cli/status.md +26 -0
  78. package/docs/cli/system.md +60 -0
  79. package/docs/cli/tui.md +23 -0
  80. package/docs/cli/uninstall.md +17 -0
  81. package/docs/cli/update.md +98 -0
  82. package/docs/cli/voicecall.md +34 -0
  83. package/docs/cli/webhooks.md +25 -0
  84. package/docs/concepts/agent-loop.md +146 -0
  85. package/docs/concepts/agent-workspace.md +229 -0
  86. package/docs/concepts/agent.md +122 -0
  87. package/docs/concepts/architecture.md +129 -0
  88. package/docs/concepts/channel-routing.md +114 -0
  89. package/docs/concepts/compaction.md +61 -0
  90. package/docs/concepts/context.md +159 -0
  91. package/docs/concepts/features.md +53 -0
  92. package/docs/concepts/group-messages.md +84 -0
  93. package/docs/concepts/groups.md +373 -0
  94. package/docs/concepts/markdown-formatting.md +130 -0
  95. package/docs/concepts/memory.md +546 -0
  96. package/docs/concepts/messages.md +154 -0
  97. package/docs/concepts/model-failover.md +149 -0
  98. package/docs/concepts/model-providers.md +315 -0
  99. package/docs/concepts/models.md +208 -0
  100. package/docs/concepts/multi-agent.md +376 -0
  101. package/docs/concepts/oauth.md +145 -0
  102. package/docs/concepts/plugins.md +454 -0
  103. package/docs/concepts/presence.md +102 -0
  104. package/docs/concepts/queue.md +89 -0
  105. package/docs/concepts/retry.md +69 -0
  106. package/docs/concepts/secrets.md +300 -0
  107. package/docs/concepts/session-pruning.md +122 -0
  108. package/docs/concepts/session-tool.md +193 -0
  109. package/docs/concepts/session.md +188 -0
  110. package/docs/concepts/sessions.md +10 -0
  111. package/docs/concepts/skills.md +392 -0
  112. package/docs/concepts/streaming.md +135 -0
  113. package/docs/concepts/system-prompt.md +114 -0
  114. package/docs/concepts/timezone.md +91 -0
  115. package/docs/concepts/typebox.md +289 -0
  116. package/docs/concepts/typing-indicators.md +68 -0
  117. package/docs/concepts/usage-tracking.md +35 -0
  118. package/docs/custom.css +4 -0
  119. package/docs/date-time.md +128 -0
  120. package/docs/debugging.md +162 -0
  121. package/docs/docs.json +1599 -0
  122. package/docs/environment.md +81 -0
  123. package/docs/hooks.md +876 -0
  124. package/docs/index.md +179 -0
  125. package/docs/install/ansible.md +208 -0
  126. package/docs/install/bun.md +59 -0
  127. package/docs/install/development-channels.md +75 -0
  128. package/docs/install/docker.md +567 -0
  129. package/docs/install/index.md +185 -0
  130. package/docs/install/installer.md +123 -0
  131. package/docs/install/migrating.md +192 -0
  132. package/docs/install/nix.md +96 -0
  133. package/docs/install/node.md +78 -0
  134. package/docs/install/uninstall.md +128 -0
  135. package/docs/install/updating.md +228 -0
  136. package/docs/logging.md +350 -0
  137. package/docs/multi-agent-sandbox-tools.md +395 -0
  138. package/docs/network.md +54 -0
  139. package/docs/nodes/audio.md +114 -0
  140. package/docs/nodes/camera.md +156 -0
  141. package/docs/nodes/images.md +72 -0
  142. package/docs/nodes/index.md +341 -0
  143. package/docs/nodes/location-command.md +113 -0
  144. package/docs/nodes/media-understanding.md +379 -0
  145. package/docs/nodes/talk.md +90 -0
  146. package/docs/nodes/voicewake.md +65 -0
  147. package/docs/northflank.mdx +53 -0
  148. package/docs/perplexity.md +80 -0
  149. package/docs/platforms/android.md +129 -0
  150. package/docs/platforms/digitalocean.md +262 -0
  151. package/docs/platforms/exe-dev.md +125 -0
  152. package/docs/platforms/fly.md +486 -0
  153. package/docs/platforms/gcp.md +503 -0
  154. package/docs/platforms/hetzner.md +330 -0
  155. package/docs/platforms/index.md +53 -0
  156. package/docs/platforms/ios.md +106 -0
  157. package/docs/platforms/linux.md +94 -0
  158. package/docs/platforms/mac/bundled-gateway.md +73 -0
  159. package/docs/platforms/mac/canvas.md +125 -0
  160. package/docs/platforms/mac/child-process.md +69 -0
  161. package/docs/platforms/mac/dev-setup.md +102 -0
  162. package/docs/platforms/mac/health.md +34 -0
  163. package/docs/platforms/mac/icon.md +31 -0
  164. package/docs/platforms/mac/logging.md +57 -0
  165. package/docs/platforms/mac/menu-bar.md +81 -0
  166. package/docs/platforms/mac/peekaboo.md +65 -0
  167. package/docs/platforms/mac/permissions.md +44 -0
  168. package/docs/platforms/mac/release.md +85 -0
  169. package/docs/platforms/mac/remote.md +83 -0
  170. package/docs/platforms/mac/signing.md +47 -0
  171. package/docs/platforms/mac/skills.md +33 -0
  172. package/docs/platforms/mac/voice-overlay.md +60 -0
  173. package/docs/platforms/mac/voicewake.md +67 -0
  174. package/docs/platforms/mac/webchat.md +41 -0
  175. package/docs/platforms/mac/xpc.md +61 -0
  176. package/docs/platforms/macos-vm.md +281 -0
  177. package/docs/platforms/macos.md +203 -0
  178. package/docs/platforms/oracle.md +303 -0
  179. package/docs/platforms/raspberry-pi.md +358 -0
  180. package/docs/platforms/windows.md +159 -0
  181. package/docs/plugin.md +651 -0
  182. package/docs/plugins/agent-tools.md +99 -0
  183. package/docs/plugins/manifest.md +71 -0
  184. package/docs/plugins/voice-call.md +273 -0
  185. package/docs/plugins/zalouser.md +70 -0
  186. package/docs/providers/anthropic.md +152 -0
  187. package/docs/providers/claude-max-api-proxy.md +148 -0
  188. package/docs/providers/cloudflare-ai-gateway.md +71 -0
  189. package/docs/providers/deepgram.md +93 -0
  190. package/docs/providers/glm.md +33 -0
  191. package/docs/providers/index.md +63 -0
  192. package/docs/providers/minimax.md +208 -0
  193. package/docs/providers/models.md +51 -0
  194. package/docs/providers/moonshot.md +142 -0
  195. package/docs/providers/ollama.md +223 -0
  196. package/docs/providers/openai.md +62 -0
  197. package/docs/providers/opencode.md +36 -0
  198. package/docs/providers/openrouter.md +37 -0
  199. package/docs/providers/qwen.md +53 -0
  200. package/docs/providers/synthetic.md +99 -0
  201. package/docs/providers/venice.md +267 -0
  202. package/docs/providers/vercel-ai-gateway.md +50 -0
  203. package/docs/providers/xiaomi.md +64 -0
  204. package/docs/providers/zai.md +36 -0
  205. package/docs/railway.mdx +99 -0
  206. package/docs/reference/templates/AGENTS.md +9 -0
  207. package/docs/reference/templates/BOOTSTRAP.md +3 -0
  208. package/docs/reference/templates/HEARTBEAT.md +3 -0
  209. package/docs/reference/templates/IDENTITY.md +3 -0
  210. package/docs/reference/templates/TOOLS.md +3 -0
  211. package/docs/reference/templates/USER.md +3 -0
  212. package/docs/render.mdx +165 -0
  213. package/docs/start/docs-directory.md +63 -0
  214. package/docs/start/getting-started.md +212 -0
  215. package/docs/start/milaidy.md +247 -0
  216. package/docs/start/onboarding.md +258 -0
  217. package/docs/start/pairing.md +86 -0
  218. package/docs/start/quickstart.md +81 -0
  219. package/docs/start/setup.md +149 -0
  220. package/docs/start/showcase.md +416 -0
  221. package/docs/start/wizard.md +418 -0
  222. package/docs/testing.md +368 -0
  223. package/docs/token-use.md +112 -0
  224. package/docs/tools/agent-send.md +53 -0
  225. package/docs/tools/apply-patch.md +50 -0
  226. package/docs/tools/browser-linux-troubleshooting.md +139 -0
  227. package/docs/tools/browser-login.md +68 -0
  228. package/docs/tools/browser.md +576 -0
  229. package/docs/tools/chrome-extension.md +178 -0
  230. package/docs/tools/clawhub.md +257 -0
  231. package/docs/tools/creating-skills.md +54 -0
  232. package/docs/tools/elevated.md +57 -0
  233. package/docs/tools/exec-approvals.md +246 -0
  234. package/docs/tools/exec.md +179 -0
  235. package/docs/tools/firecrawl.md +61 -0
  236. package/docs/tools/index.md +508 -0
  237. package/docs/tools/llm-task.md +115 -0
  238. package/docs/tools/reactions.md +22 -0
  239. package/docs/tools/skills-config.md +76 -0
  240. package/docs/tools/skills.md +300 -0
  241. package/docs/tools/slash-commands.md +196 -0
  242. package/docs/tools/subagents.md +151 -0
  243. package/docs/tools/thinking.md +73 -0
  244. package/docs/tools/web.md +261 -0
  245. package/docs/tui.md +159 -0
  246. package/docs/vps.md +43 -0
  247. package/docs/web/control-ui.md +221 -0
  248. package/docs/web/dashboard.md +46 -0
  249. package/docs/web/index.md +116 -0
  250. package/docs/web/webchat.md +49 -0
  251. package/milaidy.mjs +14 -0
  252. package/package.json +271 -0
  253. package/skills/.cache/catalog.json +88519 -0
@@ -0,0 +1,373 @@
1
+ ---
2
+ summary: "Group chat behavior across surfaces (WhatsApp/Telegram/Discord/Slack/Signal/iMessage/Microsoft Teams)"
3
+ read_when:
4
+ - Changing group chat behavior or mention gating
5
+ title: "Groups"
6
+ ---
7
+
8
+ # Groups
9
+
10
+ Milaidy treats group chats consistently across surfaces: WhatsApp, Telegram, Discord, Slack, Signal, iMessage, Microsoft Teams.
11
+
12
+ ## Beginner intro (2 minutes)
13
+
14
+ Milaidy “lives” on your own messaging accounts. There is no separate WhatsApp bot user.
15
+ If **you** are in a group, Milaidy can see that group and respond there.
16
+
17
+ Default behavior:
18
+
19
+ - Groups are restricted (`groupPolicy: "allowlist"`).
20
+ - Replies require a mention unless you explicitly disable mention gating.
21
+
22
+ Translation: allowlisted senders can trigger Milaidy by mentioning it.
23
+
24
+ > TL;DR
25
+ >
26
+ > - **DM access** is controlled by `*.allowFrom`.
27
+ > - **Group access** is controlled by `*.groupPolicy` + allowlists (`*.groups`, `*.groupAllowFrom`).
28
+ > - **Reply triggering** is controlled by mention gating (`requireMention`, `/activation`).
29
+
30
+ Quick flow (what happens to a group message):
31
+
32
+ ```
33
+ groupPolicy? disabled -> drop
34
+ groupPolicy? allowlist -> group allowed? no -> drop
35
+ requireMention? yes -> mentioned? no -> store for context only
36
+ otherwise -> reply
37
+ ```
38
+
39
+ ![Group message flow](/images/groups-flow.svg)
40
+
41
+ If you want...
42
+ | Goal | What to set |
43
+ |------|-------------|
44
+ | Allow all groups but only reply on @mentions | `groups: { "*": { requireMention: true } }` |
45
+ | Disable all group replies | `groupPolicy: "disabled"` |
46
+ | Only specific groups | `groups: { "<group-id>": { ... } }` (no `"*"` key) |
47
+ | Only you can trigger in groups | `groupPolicy: "allowlist"`, `groupAllowFrom: ["+1555..."]` |
48
+
49
+ ## Session keys
50
+
51
+ - Group sessions use `agent:<agentId>:<channel>:group:<id>` session keys (rooms/channels use `agent:<agentId>:<channel>:channel:<id>`).
52
+ - Telegram forum topics add `:topic:<threadId>` to the group id so each topic has its own session.
53
+ - Direct chats use the main session (or per-sender if configured).
54
+ - Heartbeats are skipped for group sessions.
55
+
56
+ ## Pattern: personal DMs + public groups (single agent)
57
+
58
+ Yes — this works well if your “personal” traffic is **DMs** and your “public” traffic is **groups**.
59
+
60
+ Why: in single-agent mode, DMs typically land in the **main** session key (`agent:main:main`), while groups always use **non-main** session keys (`agent:main:<channel>:group:<id>`). If you enable sandboxing with `mode: "non-main"`, those group sessions run in Docker while your main DM session stays on-host.
61
+
62
+ This gives you one agent “brain” (shared workspace + memory), but two execution postures:
63
+
64
+ - **DMs**: full tools (host)
65
+ - **Groups**: sandbox + restricted tools (Docker)
66
+
67
+ > If you need truly separate workspaces/personas (“personal” and “public” must never mix), use a second agent + bindings. See [Multi-Agent Routing](/concepts/multi-agent).
68
+
69
+ Example (DMs on host, groups sandboxed + messaging-only tools):
70
+
71
+ ```json5
72
+ {
73
+ agents: {
74
+ defaults: {
75
+ sandbox: {
76
+ mode: "non-main", // groups/channels are non-main -> sandboxed
77
+ scope: "session", // strongest isolation (one container per group/channel)
78
+ workspaceAccess: "none",
79
+ },
80
+ },
81
+ },
82
+ tools: {
83
+ sandbox: {
84
+ tools: {
85
+ // If allow is non-empty, everything else is blocked (deny still wins).
86
+ allow: ["group:messaging", "group:sessions"],
87
+ deny: ["group:runtime", "group:fs", "group:ui", "nodes", "cron", "gateway"],
88
+ },
89
+ },
90
+ },
91
+ }
92
+ ```
93
+
94
+ Want “groups can only see folder X” instead of “no host access”? Keep `workspaceAccess: "none"` and mount only allowlisted paths into the sandbox:
95
+
96
+ ```json5
97
+ {
98
+ agents: {
99
+ defaults: {
100
+ sandbox: {
101
+ mode: "non-main",
102
+ scope: "session",
103
+ workspaceAccess: "none",
104
+ docker: {
105
+ binds: [
106
+ // hostPath:containerPath:mode
107
+ "~/FriendsShared:/data:ro",
108
+ ],
109
+ },
110
+ },
111
+ },
112
+ },
113
+ }
114
+ ```
115
+
116
+ Related:
117
+
118
+ - Configuration keys and defaults: [Gateway configuration](/gateway/configuration#agentsdefaultssandbox)
119
+ - Debugging why a tool is blocked: [Sandbox vs Tool Policy vs Elevated](/gateway/sandbox-vs-tool-policy-vs-elevated)
120
+ - Bind mounts details: [Sandboxing](/gateway/sandboxing#custom-bind-mounts)
121
+
122
+ ## Display labels
123
+
124
+ - UI labels use `displayName` when available, formatted as `<channel>:<token>`.
125
+ - `#room` is reserved for rooms/channels; group chats use `g-<slug>` (lowercase, spaces -> `-`, keep `#@+._-`).
126
+
127
+ ## Group policy
128
+
129
+ Control how group/room messages are handled per channel:
130
+
131
+ ```json5
132
+ {
133
+ channels: {
134
+ whatsapp: {
135
+ groupPolicy: "disabled", // "open" | "disabled" | "allowlist"
136
+ groupAllowFrom: ["+15551234567"],
137
+ },
138
+ telegram: {
139
+ groupPolicy: "disabled",
140
+ groupAllowFrom: ["123456789", "@username"],
141
+ },
142
+ signal: {
143
+ groupPolicy: "disabled",
144
+ groupAllowFrom: ["+15551234567"],
145
+ },
146
+ imessage: {
147
+ groupPolicy: "disabled",
148
+ groupAllowFrom: ["chat_id:123"],
149
+ },
150
+ msteams: {
151
+ groupPolicy: "disabled",
152
+ groupAllowFrom: ["user@org.com"],
153
+ },
154
+ discord: {
155
+ groupPolicy: "allowlist",
156
+ guilds: {
157
+ GUILD_ID: { channels: { help: { allow: true } } },
158
+ },
159
+ },
160
+ slack: {
161
+ groupPolicy: "allowlist",
162
+ channels: { "#general": { allow: true } },
163
+ },
164
+ matrix: {
165
+ groupPolicy: "allowlist",
166
+ groupAllowFrom: ["@owner:example.org"],
167
+ groups: {
168
+ "!roomId:example.org": { allow: true },
169
+ "#alias:example.org": { allow: true },
170
+ },
171
+ },
172
+ },
173
+ }
174
+ ```
175
+
176
+ | Policy | Behavior |
177
+ | ------------- | ------------------------------------------------------------ |
178
+ | `"open"` | Groups bypass allowlists; mention-gating still applies. |
179
+ | `"disabled"` | Block all group messages entirely. |
180
+ | `"allowlist"` | Only allow groups/rooms that match the configured allowlist. |
181
+
182
+ Notes:
183
+
184
+ - `groupPolicy` is separate from mention-gating (which requires @mentions).
185
+ - WhatsApp/Telegram/Signal/iMessage/Microsoft Teams: use `groupAllowFrom` (fallback: explicit `allowFrom`).
186
+ - Discord: allowlist uses `channels.discord.guilds.<id>.channels`.
187
+ - Slack: allowlist uses `channels.slack.channels`.
188
+ - Matrix: allowlist uses `channels.matrix.groups` (room IDs, aliases, or names). Use `channels.matrix.groupAllowFrom` to restrict senders; per-room `users` allowlists are also supported.
189
+ - Group DMs are controlled separately (`channels.discord.dm.*`, `channels.slack.dm.*`).
190
+ - Telegram allowlist can match user IDs (`"123456789"`, `"telegram:123456789"`, `"tg:123456789"`) or usernames (`"@alice"` or `"alice"`); prefixes are case-insensitive.
191
+ - Default is `groupPolicy: "allowlist"`; if your group allowlist is empty, group messages are blocked.
192
+
193
+ Quick mental model (evaluation order for group messages):
194
+
195
+ 1. `groupPolicy` (open/disabled/allowlist)
196
+ 2. group allowlists (`*.groups`, `*.groupAllowFrom`, channel-specific allowlist)
197
+ 3. mention gating (`requireMention`, `/activation`)
198
+
199
+ ## Mention gating (default)
200
+
201
+ Group messages require a mention unless overridden per group. Defaults live per subsystem under `*.groups."*"`.
202
+
203
+ Replying to a bot message counts as an implicit mention (when the channel supports reply metadata). This applies to Telegram, WhatsApp, Slack, Discord, and Microsoft Teams.
204
+
205
+ ```json5
206
+ {
207
+ channels: {
208
+ whatsapp: {
209
+ groups: {
210
+ "*": { requireMention: true },
211
+ "123@g.us": { requireMention: false },
212
+ },
213
+ },
214
+ telegram: {
215
+ groups: {
216
+ "*": { requireMention: true },
217
+ "123456789": { requireMention: false },
218
+ },
219
+ },
220
+ imessage: {
221
+ groups: {
222
+ "*": { requireMention: true },
223
+ "123": { requireMention: false },
224
+ },
225
+ },
226
+ },
227
+ agents: {
228
+ list: [
229
+ {
230
+ id: "main",
231
+ groupChat: {
232
+ mentionPatterns: ["@milaidy", "milaidy", "\\+15555550123"],
233
+ historyLimit: 50,
234
+ },
235
+ },
236
+ ],
237
+ },
238
+ }
239
+ ```
240
+
241
+ Notes:
242
+
243
+ - `mentionPatterns` are case-insensitive regexes.
244
+ - Surfaces that provide explicit mentions still pass; patterns are a fallback.
245
+ - Per-agent override: `agents.list[].groupChat.mentionPatterns` (useful when multiple agents share a group).
246
+ - Mention gating is only enforced when mention detection is possible (native mentions or `mentionPatterns` are configured).
247
+ - Discord defaults live in `channels.discord.guilds."*"` (overridable per guild/channel).
248
+ - Group history context is wrapped uniformly across channels and is **pending-only** (messages skipped due to mention gating); use `messages.groupChat.historyLimit` for the global default and `channels.<channel>.historyLimit` (or `channels.<channel>.accounts.*.historyLimit`) for overrides. Set `0` to disable.
249
+
250
+ ## Group/channel tool restrictions (optional)
251
+
252
+ Some channel configs support restricting which tools are available **inside a specific group/room/channel**.
253
+
254
+ - `tools`: allow/deny tools for the whole group.
255
+ - `toolsBySender`: per-sender overrides within the group (keys are sender IDs/usernames/emails/phone numbers depending on the channel). Use `"*"` as a wildcard.
256
+
257
+ Resolution order (most specific wins):
258
+
259
+ 1. group/channel `toolsBySender` match
260
+ 2. group/channel `tools`
261
+ 3. default (`"*"`) `toolsBySender` match
262
+ 4. default (`"*"`) `tools`
263
+
264
+ Example (Telegram):
265
+
266
+ ```json5
267
+ {
268
+ channels: {
269
+ telegram: {
270
+ groups: {
271
+ "*": { tools: { deny: ["exec"] } },
272
+ "-1001234567890": {
273
+ tools: { deny: ["exec", "read", "write"] },
274
+ toolsBySender: {
275
+ "123456789": { alsoAllow: ["exec"] },
276
+ },
277
+ },
278
+ },
279
+ },
280
+ },
281
+ }
282
+ ```
283
+
284
+ Notes:
285
+
286
+ - Group/channel tool restrictions are applied in addition to global/agent tool policy (deny still wins).
287
+ - Some channels use different nesting for rooms/channels (e.g., Discord `guilds.*.channels.*`, Slack `channels.*`, MS Teams `teams.*.channels.*`).
288
+
289
+ ## Group allowlists
290
+
291
+ When `channels.whatsapp.groups`, `channels.telegram.groups`, or `channels.imessage.groups` is configured, the keys act as a group allowlist. Use `"*"` to allow all groups while still setting default mention behavior.
292
+
293
+ Common intents (copy/paste):
294
+
295
+ 1. Disable all group replies
296
+
297
+ ```json5
298
+ {
299
+ channels: { whatsapp: { groupPolicy: "disabled" } },
300
+ }
301
+ ```
302
+
303
+ 2. Allow only specific groups (WhatsApp)
304
+
305
+ ```json5
306
+ {
307
+ channels: {
308
+ whatsapp: {
309
+ groups: {
310
+ "123@g.us": { requireMention: true },
311
+ "456@g.us": { requireMention: false },
312
+ },
313
+ },
314
+ },
315
+ }
316
+ ```
317
+
318
+ 3. Allow all groups but require mention (explicit)
319
+
320
+ ```json5
321
+ {
322
+ channels: {
323
+ whatsapp: {
324
+ groups: { "*": { requireMention: true } },
325
+ },
326
+ },
327
+ }
328
+ ```
329
+
330
+ 4. Only the owner can trigger in groups (WhatsApp)
331
+
332
+ ```json5
333
+ {
334
+ channels: {
335
+ whatsapp: {
336
+ groupPolicy: "allowlist",
337
+ groupAllowFrom: ["+15551234567"],
338
+ groups: { "*": { requireMention: true } },
339
+ },
340
+ },
341
+ }
342
+ ```
343
+
344
+ ## Activation (owner-only)
345
+
346
+ Group owners can toggle per-group activation:
347
+
348
+ - `/activation mention`
349
+ - `/activation always`
350
+
351
+ Owner is determined by `channels.whatsapp.allowFrom` (or the bot’s self E.164 when unset). Send the command as a standalone message. Other surfaces currently ignore `/activation`.
352
+
353
+ ## Context fields
354
+
355
+ Group inbound payloads set:
356
+
357
+ - `ChatType=group`
358
+ - `GroupSubject` (if known)
359
+ - `GroupMembers` (if known)
360
+ - `WasMentioned` (mention gating result)
361
+ - Telegram forum topics also include `MessageThreadId` and `IsForum`.
362
+
363
+ The agent system prompt includes a group intro on the first turn of a new group session. It reminds the model to respond like a human, avoid Markdown tables, and avoid typing literal `\n` sequences.
364
+
365
+ ## iMessage specifics
366
+
367
+ - Prefer `chat_id:<id>` when routing or allowlisting.
368
+ - List chats: `imsg chats --limit 20`.
369
+ - Group replies always go back to the same `chat_id`.
370
+
371
+ ## WhatsApp specifics
372
+
373
+ See [Group messages](/concepts/group-messages) for WhatsApp-only behavior (history injection, mention handling details).
@@ -0,0 +1,130 @@
1
+ ---
2
+ summary: "Markdown formatting pipeline for outbound channels"
3
+ read_when:
4
+ - You are changing markdown formatting or chunking for outbound channels
5
+ - You are adding a new channel formatter or style mapping
6
+ - You are debugging formatting regressions across channels
7
+ title: "Markdown Formatting"
8
+ ---
9
+
10
+ # Markdown formatting
11
+
12
+ Milaidy formats outbound Markdown by converting it into a shared intermediate
13
+ representation (IR) before rendering channel-specific output. The IR keeps the
14
+ source text intact while carrying style/link spans so chunking and rendering can
15
+ stay consistent across channels.
16
+
17
+ ## Goals
18
+
19
+ - **Consistency:** one parse step, multiple renderers.
20
+ - **Safe chunking:** split text before rendering so inline formatting never
21
+ breaks across chunks.
22
+ - **Channel fit:** map the same IR to Slack mrkdwn, Telegram HTML, and Signal
23
+ style ranges without re-parsing Markdown.
24
+
25
+ ## Pipeline
26
+
27
+ 1. **Parse Markdown -> IR**
28
+ - IR is plain text plus style spans (bold/italic/strike/code/spoiler) and link spans.
29
+ - Offsets are UTF-16 code units so Signal style ranges align with its API.
30
+ - Tables are parsed only when a channel opts into table conversion.
31
+ 2. **Chunk IR (format-first)**
32
+ - Chunking happens on the IR text before rendering.
33
+ - Inline formatting does not split across chunks; spans are sliced per chunk.
34
+ 3. **Render per channel**
35
+ - **Slack:** mrkdwn tokens (bold/italic/strike/code), links as `<url|label>`.
36
+ - **Telegram:** HTML tags (`<b>`, `<i>`, `<s>`, `<code>`, `<pre><code>`, `<a href>`).
37
+ - **Signal:** plain text + `text-style` ranges; links become `label (url)` when label differs.
38
+
39
+ ## IR example
40
+
41
+ Input Markdown:
42
+
43
+ ```markdown
44
+ Hello **world** — see [docs](https://docs.milaidy.ai).
45
+ ```
46
+
47
+ IR (schematic):
48
+
49
+ ```json
50
+ {
51
+ "text": "Hello world — see docs.",
52
+ "styles": [{ "start": 6, "end": 11, "style": "bold" }],
53
+ "links": [{ "start": 19, "end": 23, "href": "https://docs.milaidy.ai" }]
54
+ }
55
+ ```
56
+
57
+ ## Where it is used
58
+
59
+ - Slack, Telegram, and Signal outbound adapters render from the IR.
60
+ - Other channels (WhatsApp, iMessage, MS Teams, Discord) still use plain text or
61
+ their own formatting rules, with Markdown table conversion applied before
62
+ chunking when enabled.
63
+
64
+ ## Table handling
65
+
66
+ Markdown tables are not consistently supported across chat clients. Use
67
+ `markdown.tables` to control conversion per channel (and per account).
68
+
69
+ - `code`: render tables as code blocks (default for most channels).
70
+ - `bullets`: convert each row into bullet points (default for Signal + WhatsApp).
71
+ - `off`: disable table parsing and conversion; raw table text passes through.
72
+
73
+ Config keys:
74
+
75
+ ```yaml
76
+ channels:
77
+ discord:
78
+ markdown:
79
+ tables: code
80
+ accounts:
81
+ work:
82
+ markdown:
83
+ tables: off
84
+ ```
85
+
86
+ ## Chunking rules
87
+
88
+ - Chunk limits come from channel adapters/config and are applied to the IR text.
89
+ - Code fences are preserved as a single block with a trailing newline so channels
90
+ render them correctly.
91
+ - List prefixes and blockquote prefixes are part of the IR text, so chunking
92
+ does not split mid-prefix.
93
+ - Inline styles (bold/italic/strike/inline-code/spoiler) are never split across
94
+ chunks; the renderer reopens styles inside each chunk.
95
+
96
+ If you need more on chunking behavior across channels, see
97
+ [Streaming + chunking](/concepts/streaming).
98
+
99
+ ## Link policy
100
+
101
+ - **Slack:** `[label](url)` -> `<url|label>`; bare URLs remain bare. Autolink
102
+ is disabled during parse to avoid double-linking.
103
+ - **Telegram:** `[label](url)` -> `<a href="url">label</a>` (HTML parse mode).
104
+ - **Signal:** `[label](url)` -> `label (url)` unless label matches the URL.
105
+
106
+ ## Spoilers
107
+
108
+ Spoiler markers (`||spoiler||`) are parsed only for Signal, where they map to
109
+ SPOILER style ranges. Other channels treat them as plain text.
110
+
111
+ ## How to add or update a channel formatter
112
+
113
+ 1. **Parse once:** use the shared `markdownToIR(...)` helper with channel-appropriate
114
+ options (autolink, heading style, blockquote prefix).
115
+ 2. **Render:** implement a renderer with `renderMarkdownWithMarkers(...)` and a
116
+ style marker map (or Signal style ranges).
117
+ 3. **Chunk:** call `chunkMarkdownIR(...)` before rendering; render each chunk.
118
+ 4. **Wire adapter:** update the channel outbound adapter to use the new chunker
119
+ and renderer.
120
+ 5. **Test:** add or update format tests and an outbound delivery test if the
121
+ channel uses chunking.
122
+
123
+ ## Common gotchas
124
+
125
+ - Slack angle-bracket tokens (`<@U123>`, `<#C123>`, `<https://...>`) must be
126
+ preserved; escape raw HTML safely.
127
+ - Telegram HTML requires escaping text outside tags to avoid broken markup.
128
+ - Signal style ranges depend on UTF-16 offsets; do not use code point offsets.
129
+ - Preserve trailing newlines for fenced code blocks so closing markers land on
130
+ their own line.