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,188 @@
1
+ ---
2
+ summary: "Session management rules, keys, and persistence for chats"
3
+ read_when:
4
+ - Modifying session handling or storage
5
+ title: "Session Management"
6
+ ---
7
+
8
+ # Session Management
9
+
10
+ Milaidy treats **one direct-chat session per agent** as primary. Direct chats collapse to `agent:<agentId>:<mainKey>` (default `main`), while group/channel chats get their own keys. `session.mainKey` is honored.
11
+
12
+ Use `session.dmScope` to control how **direct messages** are grouped:
13
+
14
+ - `main` (default): all DMs share the main session for continuity.
15
+ - `per-peer`: isolate by sender id across channels.
16
+ - `per-channel-peer`: isolate by channel + sender (recommended for multi-user inboxes).
17
+ - `per-account-channel-peer`: isolate by account + channel + sender (recommended for multi-account inboxes).
18
+ Use `session.identityLinks` to map provider-prefixed peer ids to a canonical identity so the same person shares a DM session across channels when using `per-peer`, `per-channel-peer`, or `per-account-channel-peer`.
19
+
20
+ ### Secure DM mode (recommended)
21
+
22
+ If your agent can receive DMs from **multiple people** (pairing approvals for more than one sender, a DM allowlist with multiple entries, or `dmPolicy: "open"`), enable **secure DM mode** to avoid cross-user context leakage:
23
+
24
+ ```json5
25
+ // ~/.milaidy/milaidy.json
26
+ {
27
+ session: {
28
+ // Secure DM mode: isolate DM context per channel + sender.
29
+ dmScope: "per-channel-peer",
30
+ },
31
+ }
32
+ ```
33
+
34
+ Notes:
35
+
36
+ - Default is `dmScope: "main"` for continuity (all DMs share the main session).
37
+ - For multi-account inboxes on the same channel, prefer `per-account-channel-peer`.
38
+ - If the same person contacts you on multiple channels, use `session.identityLinks` to collapse their DM sessions into one canonical identity.
39
+
40
+ ## Gateway is the source of truth
41
+
42
+ All session state is **owned by the gateway** (the “master” Milaidy). UI clients (macOS app, WebChat, etc.) must query the gateway for session lists and token counts instead of reading local files.
43
+
44
+ - In **remote mode**, the session store you care about lives on the remote gateway host, not your Mac.
45
+ - Token counts shown in UIs come from the gateway’s store fields (`inputTokens`, `outputTokens`, `totalTokens`, `contextTokens`). Clients do not parse JSONL transcripts to “fix up” totals.
46
+
47
+ ## Where state lives
48
+
49
+ - On the **gateway host**:
50
+ - Store file: `~/.milaidy/agents/<agentId>/sessions/sessions.json` (per agent).
51
+ - Transcripts: `~/.milaidy/agents/<agentId>/sessions/<SessionId>.jsonl` (Telegram topic sessions use `.../<SessionId>-topic-<threadId>.jsonl`).
52
+ - The store is a map `sessionKey -> { sessionId, updatedAt, ... }`. Deleting entries is safe; they are recreated on demand.
53
+ - Group entries may include `displayName`, `channel`, `subject`, `room`, and `space` to label sessions in UIs.
54
+ - Session entries include `origin` metadata (label + routing hints) so UIs can explain where a session came from.
55
+ - Milaidy does **not** read legacy Pi/Tau session folders.
56
+
57
+ ## Session pruning
58
+
59
+ Milaidy trims **old tool results** from the in-memory context right before LLM calls by default.
60
+ This does **not** rewrite JSONL history. See [/concepts/session-pruning](/concepts/session-pruning).
61
+
62
+ ## Pre-compaction memory flush
63
+
64
+ When a session nears auto-compaction, Milaidy can run a **silent memory flush**
65
+ turn that reminds the model to write durable notes to disk. This only runs when
66
+ the workspace is writable. See [Memory](/concepts/memory) and
67
+ [Compaction](/concepts/compaction).
68
+
69
+ ## Mapping transports → session keys
70
+
71
+ - Direct chats follow `session.dmScope` (default `main`).
72
+ - `main`: `agent:<agentId>:<mainKey>` (continuity across devices/channels).
73
+ - Multiple phone numbers and channels can map to the same agent main key; they act as transports into one conversation.
74
+ - `per-peer`: `agent:<agentId>:dm:<peerId>`.
75
+ - `per-channel-peer`: `agent:<agentId>:<channel>:dm:<peerId>`.
76
+ - `per-account-channel-peer`: `agent:<agentId>:<channel>:<accountId>:dm:<peerId>` (accountId defaults to `default`).
77
+ - If `session.identityLinks` matches a provider-prefixed peer id (for example `telegram:123`), the canonical key replaces `<peerId>` so the same person shares a session across channels.
78
+ - Group chats isolate state: `agent:<agentId>:<channel>:group:<id>` (rooms/channels use `agent:<agentId>:<channel>:channel:<id>`).
79
+ - Telegram forum topics append `:topic:<threadId>` to the group id for isolation.
80
+ - Legacy `group:<id>` keys are still recognized for migration.
81
+ - Inbound contexts may still use `group:<id>`; the channel is inferred from `Provider` and normalized to the canonical `agent:<agentId>:<channel>:group:<id>` form.
82
+ - Other sources:
83
+ - Cron jobs: `cron:<job.id>`
84
+ - Webhooks: `hook:<uuid>` (unless explicitly set by the hook)
85
+ - Node runs: `node-<nodeId>`
86
+
87
+ ## Lifecycle
88
+
89
+ - Reset policy: sessions are reused until they expire, and expiry is evaluated on the next inbound message.
90
+ - Daily reset: defaults to **4:00 AM local time on the gateway host**. A session is stale once its last update is earlier than the most recent daily reset time.
91
+ - Idle reset (optional): `idleMinutes` adds a sliding idle window. When both daily and idle resets are configured, **whichever expires first** forces a new session.
92
+ - Legacy idle-only: if you set `session.idleMinutes` without any `session.reset`/`resetByType` config, Milaidy stays in idle-only mode for backward compatibility.
93
+ - Per-type overrides (optional): `resetByType` lets you override the policy for `dm`, `group`, and `thread` sessions (thread = Slack/Discord threads, Telegram topics, Matrix threads when provided by the connector).
94
+ - Per-channel overrides (optional): `resetByChannel` overrides the reset policy for a channel (applies to all session types for that channel and takes precedence over `reset`/`resetByType`).
95
+ - Reset triggers: exact `/new` or `/reset` (plus any extras in `resetTriggers`) start a fresh session id and pass the remainder of the message through. `/new <model>` accepts a model alias, `provider/model`, or provider name (fuzzy match) to set the new session model. If `/new` or `/reset` is sent alone, Milaidy runs a short “hello” greeting turn to confirm the reset.
96
+ - Manual reset: delete specific keys from the store or remove the JSONL transcript; the next message recreates them.
97
+ - Isolated cron jobs always mint a fresh `sessionId` per run (no idle reuse).
98
+
99
+ ## Send policy (optional)
100
+
101
+ Block delivery for specific session types without listing individual ids.
102
+
103
+ ```json5
104
+ {
105
+ session: {
106
+ sendPolicy: {
107
+ rules: [
108
+ { action: "deny", match: { channel: "discord", chatType: "group" } },
109
+ { action: "deny", match: { keyPrefix: "cron:" } },
110
+ ],
111
+ default: "allow",
112
+ },
113
+ },
114
+ }
115
+ ```
116
+
117
+ Runtime override (owner only):
118
+
119
+ - `/send on` → allow for this session
120
+ - `/send off` → deny for this session
121
+ - `/send inherit` → clear override and use config rules
122
+ Send these as standalone messages so they register.
123
+
124
+ ## Configuration (optional rename example)
125
+
126
+ ```json5
127
+ // ~/.milaidy/milaidy.json
128
+ {
129
+ session: {
130
+ scope: "per-sender", // keep group keys separate
131
+ dmScope: "main", // DM continuity (set per-channel-peer/per-account-channel-peer for shared inboxes)
132
+ identityLinks: {
133
+ alice: ["telegram:123456789", "discord:987654321012345678"],
134
+ },
135
+ reset: {
136
+ // Defaults: mode=daily, atHour=4 (gateway host local time).
137
+ // If you also set idleMinutes, whichever expires first wins.
138
+ mode: "daily",
139
+ atHour: 4,
140
+ idleMinutes: 120,
141
+ },
142
+ resetByType: {
143
+ thread: { mode: "daily", atHour: 4 },
144
+ dm: { mode: "idle", idleMinutes: 240 },
145
+ group: { mode: "idle", idleMinutes: 120 },
146
+ },
147
+ resetByChannel: {
148
+ discord: { mode: "idle", idleMinutes: 10080 },
149
+ },
150
+ resetTriggers: ["/new", "/reset"],
151
+ store: "~/.milaidy/agents/{agentId}/sessions/sessions.json",
152
+ mainKey: "main",
153
+ },
154
+ }
155
+ ```
156
+
157
+ ## Inspecting
158
+
159
+ - `milaidy status` — shows store path and recent sessions.
160
+ - `milaidy sessions --json` — dumps every entry (filter with `--active <minutes>`).
161
+ - `milaidy gateway call sessions.list --params '{}'` — fetch sessions from the running gateway (use `--url`/`--token` for remote gateway access).
162
+ - Send `/status` as a standalone message in chat to see whether the agent is reachable, how much of the session context is used, current thinking/verbose toggles, and when your WhatsApp web creds were last refreshed (helps spot relink needs).
163
+ - Send `/context list` or `/context detail` to see what’s in the system prompt and injected workspace files (and the biggest context contributors).
164
+ - Send `/stop` as a standalone message to abort the current run, clear queued followups for that session, and stop any sub-agent runs spawned from it (the reply includes the stopped count).
165
+ - Send `/compact` (optional instructions) as a standalone message to summarize older context and free up window space. See [/concepts/compaction](/concepts/compaction).
166
+ - JSONL transcripts can be opened directly to review full turns.
167
+
168
+ ## Tips
169
+
170
+ - Keep the primary key dedicated to 1:1 traffic; let groups keep their own keys.
171
+ - When automating cleanup, delete individual keys instead of the whole store to preserve context elsewhere.
172
+
173
+ ## Session origin metadata
174
+
175
+ Each session entry records where it came from (best-effort) in `origin`:
176
+
177
+ - `label`: human label (resolved from conversation label + group subject/channel)
178
+ - `provider`: normalized channel id (including extensions)
179
+ - `from`/`to`: raw routing ids from the inbound envelope
180
+ - `accountId`: provider account id (when multi-account)
181
+ - `threadId`: thread/topic id when the channel supports it
182
+ The origin fields are populated for direct messages, channels, and groups. If a
183
+ connector only updates delivery routing (for example, to keep a DM main session
184
+ fresh), it should still provide inbound context so the session keeps its
185
+ explainer metadata. Extensions can do this by sending `ConversationLabel`,
186
+ `GroupSubject`, `GroupChannel`, `GroupSpace`, and `SenderName` in the inbound
187
+ context and calling `recordSessionMetaFromInbound` (or passing the same context
188
+ to `updateLastRoute`).
@@ -0,0 +1,10 @@
1
+ ---
2
+ summary: "Alias for session management docs"
3
+ read_when:
4
+ - You looked for docs/sessions.md; canonical doc lives in docs/session.md
5
+ title: "Sessions"
6
+ ---
7
+
8
+ # Sessions
9
+
10
+ Canonical session management docs live in [Session management](/concepts/session).
@@ -0,0 +1,392 @@
1
+ ---
2
+ summary: "Skills: directories, precedence, eligibility, and configuration"
3
+ read_when:
4
+ - Adding or configuring skills
5
+ - Understanding skill loading and gating
6
+ - Creating custom skills
7
+ title: "Skills"
8
+ ---
9
+
10
+ # Skills
11
+
12
+ Skills teach Milaidy agents how to use tools. Each skill is a directory
13
+ containing a `SKILL.md` file with YAML frontmatter and instructions. Skills
14
+ are [AgentSkills](https://agentskills.io)-compatible.
15
+
16
+ ## Skill Locations and Precedence
17
+
18
+ Skills load from three locations (highest to lowest precedence):
19
+
20
+ | Location | Path | Scope |
21
+ |----------|------|-------|
22
+ | **Workspace** | `<workspace>/skills/` | Per-agent |
23
+ | **Managed/Local** | `~/.milaidy/skills/` | All agents |
24
+ | **Bundled** | Shipped with install | All agents |
25
+
26
+ If a skill name conflicts, the higher-precedence location wins.
27
+
28
+ ### Extra Directories
29
+
30
+ Add additional skill folders via config:
31
+
32
+ ```json
33
+ {
34
+ "skills": {
35
+ "load": {
36
+ "extraDirs": ["/path/to/shared/skills"]
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ Extra directories have the lowest precedence.
43
+
44
+ ## Skill Format
45
+
46
+ A minimal `SKILL.md`:
47
+
48
+ ```markdown
49
+ ---
50
+ name: my-skill
51
+ description: Does something useful
52
+ ---
53
+
54
+ ## Instructions
55
+
56
+ Use this skill when you need to do X...
57
+ ```
58
+
59
+ ### Required Frontmatter
60
+
61
+ | Field | Type | Description |
62
+ |-------|------|-------------|
63
+ | `name` | string | Skill identifier |
64
+ | `description` | string | Short description |
65
+
66
+ ### Optional Frontmatter
67
+
68
+ | Field | Type | Default | Description |
69
+ |-------|------|---------|-------------|
70
+ | `homepage` | string | - | Website URL |
71
+ | `user-invocable` | boolean | `true` | Expose as slash command |
72
+ | `disable-model-invocation` | boolean | `false` | Exclude from model prompt |
73
+ | `command-dispatch` | string | - | Set to `tool` for direct dispatch |
74
+ | `command-tool` | string | - | Tool to invoke |
75
+ | `command-arg-mode` | string | `raw` | Argument handling mode |
76
+
77
+ ## Eligibility Gating
78
+
79
+ Skills can specify requirements via `metadata`:
80
+
81
+ ```markdown
82
+ ---
83
+ name: my-skill
84
+ description: Requires specific tools
85
+ metadata: {"milaidy": {"requires": {"bins": ["uv"], "env": ["MY_API_KEY"], "config": ["browser.enabled"]}, "primaryEnv": "MY_API_KEY"}}
86
+ ---
87
+ ```
88
+
89
+ ### Gating Fields
90
+
91
+ | Field | Description |
92
+ |-------|-------------|
93
+ | `metadata.milaidy.always` | Always include (skip other gates) |
94
+ | `metadata.milaidy.os` | Platform filter (`darwin`, `linux`, `win32`) |
95
+ | `metadata.milaidy.requires.bins` | Required binaries on PATH |
96
+ | `metadata.milaidy.requires.anyBins` | At least one must exist |
97
+ | `metadata.milaidy.requires.env` | Required environment variables |
98
+ | `metadata.milaidy.requires.config` | Required config paths (truthy) |
99
+ | `metadata.milaidy.primaryEnv` | Associated API key name |
100
+ | `metadata.milaidy.emoji` | Display emoji |
101
+ | `metadata.milaidy.homepage` | Website URL |
102
+ | `metadata.milaidy.install` | Installer specifications |
103
+
104
+ ### Example with Full Metadata
105
+
106
+ ```markdown
107
+ ---
108
+ name: gemini-cli
109
+ description: Use Gemini CLI for coding assistance
110
+ metadata:
111
+ {
112
+ "milaidy":
113
+ {
114
+ "emoji": "♊️",
115
+ "requires": { "bins": ["gemini"] },
116
+ "install":
117
+ [
118
+ {
119
+ "id": "brew",
120
+ "kind": "brew",
121
+ "formula": "gemini-cli",
122
+ "bins": ["gemini"],
123
+ "label": "Install Gemini CLI (brew)",
124
+ },
125
+ ],
126
+ },
127
+ }
128
+ ---
129
+ ```
130
+
131
+ ## Configuration
132
+
133
+ ### Enable/Disable Skills
134
+
135
+ ```json
136
+ {
137
+ "skills": {
138
+ "entries": {
139
+ "my-skill": {
140
+ "enabled": true,
141
+ "apiKey": "MY_KEY_HERE",
142
+ "env": {
143
+ "MY_API_KEY": "MY_KEY_HERE"
144
+ },
145
+ "config": {
146
+ "endpoint": "https://api.example.com"
147
+ }
148
+ },
149
+ "disabled-skill": {
150
+ "enabled": false
151
+ }
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ ### Config Fields
158
+
159
+ | Field | Description |
160
+ |-------|-------------|
161
+ | `enabled` | Enable/disable the skill |
162
+ | `apiKey` | Convenience for `primaryEnv` |
163
+ | `env` | Environment variables to inject |
164
+ | `config` | Custom per-skill configuration |
165
+
166
+ ### Bundled Skills Allowlist
167
+
168
+ Restrict which bundled skills load:
169
+
170
+ ```json
171
+ {
172
+ "skills": {
173
+ "allowBundled": ["skill-a", "skill-b"]
174
+ }
175
+ }
176
+ ```
177
+
178
+ ## Environment Injection
179
+
180
+ When an agent run starts:
181
+
182
+ 1. Reads skill metadata
183
+ 2. Applies `skills.entries.<key>.env` and `apiKey` to `process.env`
184
+ 3. Builds system prompt with eligible skills
185
+ 4. Restores original environment after run
186
+
187
+ This is **scoped to the agent run**, not global.
188
+
189
+ ## Plugin Skills
190
+
191
+ Plugins can ship skills via their manifest:
192
+
193
+ ```json
194
+ {
195
+ "id": "my-plugin",
196
+ "skills": ["skills/tool-a", "skills/tool-b"]
197
+ }
198
+ ```
199
+
200
+ Plugin skills:
201
+ - Load when the plugin is enabled
202
+ - Participate in normal precedence rules
203
+ - Can be gated via plugin config
204
+
205
+ ## ClawHub
206
+
207
+ Browse and install skills from [ClawHub](https://clawhub.com):
208
+
209
+ ```bash
210
+ # Install a skill
211
+ clawhub install <skill-slug>
212
+
213
+ # Update all skills
214
+ clawhub update --all
215
+
216
+ # Sync (scan + publish)
217
+ clawhub sync --all
218
+ ```
219
+
220
+ Default install location: `./skills` (workspace skills).
221
+
222
+ ## Skills Watcher
223
+
224
+ Auto-reload skills when files change:
225
+
226
+ ```json
227
+ {
228
+ "skills": {
229
+ "load": {
230
+ "watch": true,
231
+ "watchDebounceMs": 250
232
+ }
233
+ }
234
+ }
235
+ ```
236
+
237
+ ## Session Snapshot
238
+
239
+ Skills are snapshotted when a session starts and reused for subsequent turns.
240
+ Changes take effect on the next new session (or via hot reload when watching).
241
+
242
+ ## Remote Nodes
243
+
244
+ If a Linux Gateway has a connected macOS node with `system.run` allowed,
245
+ macOS-only skills become eligible. The agent executes these via `nodes.run`.
246
+
247
+ ## Token Impact
248
+
249
+ Skills add to the system prompt:
250
+
251
+ - **Base overhead:** ~195 characters (when ≥1 skill)
252
+ - **Per skill:** ~97 characters + name + description + location
253
+
254
+ Rough estimate: ~24 tokens per skill plus field content.
255
+
256
+ ## Dependency Installation
257
+
258
+ ### Install Specifications
259
+
260
+ ```json
261
+ {
262
+ "install": [
263
+ {
264
+ "id": "brew",
265
+ "kind": "brew",
266
+ "formula": "tool-name",
267
+ "bins": ["tool-name"],
268
+ "label": "Install via Homebrew"
269
+ },
270
+ {
271
+ "id": "npm",
272
+ "kind": "node",
273
+ "package": "@scope/tool",
274
+ "bins": ["tool-name"],
275
+ "label": "Install via npm"
276
+ },
277
+ {
278
+ "id": "download",
279
+ "kind": "download",
280
+ "url": "https://example.com/tool.tar.gz",
281
+ "archive": "tar.gz",
282
+ "targetDir": "~/.milaidy/tools/tool-name"
283
+ }
284
+ ]
285
+ }
286
+ ```
287
+
288
+ ### Install Kinds
289
+
290
+ | Kind | Description |
291
+ |------|-------------|
292
+ | `brew` | Homebrew formula |
293
+ | `node` | npm/pnpm package |
294
+ | `go` | Go install |
295
+ | `uv` | Python uv |
296
+ | `download` | Direct download |
297
+
298
+ ### Node Manager
299
+
300
+ Set the node package manager for skill installs:
301
+
302
+ ```json
303
+ {
304
+ "skills": {
305
+ "install": {
306
+ "nodeManager": "pnpm"
307
+ }
308
+ }
309
+ }
310
+ ```
311
+
312
+ Options: `npm`, `pnpm`, `yarn`, `bun` (npm default)
313
+
314
+ ## Sandboxing Notes
315
+
316
+ Binary requirements (`requires.bins`) are checked on the **host** at load time.
317
+
318
+ For sandboxed agents, binaries must also exist **inside the container**:
319
+
320
+ ```json
321
+ {
322
+ "agents": {
323
+ "defaults": {
324
+ "sandbox": {
325
+ "docker": {
326
+ "setupCommand": "apt-get install -y tool-name"
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+ ```
333
+
334
+ ## Security
335
+
336
+ - **Treat third-party skills as untrusted code**
337
+ - Skills with `env` inject into the host process
338
+ - Use sandboxed runs for risky tools
339
+ - Keep secrets out of prompts and logs
340
+
341
+ ## Creating Skills
342
+
343
+ ### Basic Structure
344
+
345
+ ```
346
+ my-skill/
347
+ ├── SKILL.md # Required
348
+ ├── scripts/ # Optional helper scripts
349
+ └── templates/ # Optional templates
350
+ ```
351
+
352
+ ### SKILL.md Template
353
+
354
+ ```markdown
355
+ ---
356
+ name: my-skill
357
+ description: Short description of what this skill does
358
+ metadata: {"milaidy": {"requires": {"env": ["MY_API_KEY"]}, "primaryEnv": "MY_API_KEY"}}
359
+ ---
360
+
361
+ ## Overview
362
+
363
+ This skill enables the agent to...
364
+
365
+ ## Usage
366
+
367
+ Use this skill when you need to...
368
+
369
+ ## Examples
370
+
371
+ Example invocation:
372
+ - "Do X with Y"
373
+ - "Create Z for me"
374
+
375
+ ## Configuration
376
+
377
+ The skill requires the following:
378
+ - `MY_API_KEY`: API key for the service
379
+
380
+ ## Notes
381
+
382
+ - Additional notes about behavior
383
+ - Limitations or caveats
384
+ ```
385
+
386
+ ## Related Docs
387
+
388
+ - [Skills Config](/tools/skills-config) - Full configuration schema
389
+ - [ClawHub](/tools/clawhub) - Skills registry
390
+ - [Creating Skills](/tools/creating-skills) - Development guide
391
+ - [Plugins](/concepts/plugins) - Plugin-provided skills
392
+ - [Security](/gateway/security) - Security considerations