@jossuealcala/madre 1.0.5 → 1.1.1

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 (278) hide show
  1. package/ADDITIONAL-TERMS.md +7 -2
  2. package/CHANGELOG.en.md +62 -1
  3. package/CHANGELOG.md +62 -1
  4. package/CONTRIBUTING.md +2 -2
  5. package/LICENSE +111 -661
  6. package/NOTICE +28 -23
  7. package/README.en.md +27 -102
  8. package/README.md +27 -104
  9. package/SECURITY.md +1 -0
  10. package/TRADEMARKS.en.md +13 -14
  11. package/TRADEMARKS.md +24 -26
  12. package/bin/madre.cjs +2 -2
  13. package/bin/madre.mjs +111 -40
  14. package/docs/REFERENCE.md +52 -5
  15. package/docs/SDK.md +21 -3
  16. package/docs/en/REFERENCE.md +52 -5
  17. package/docs/en/SDK.md +22 -3
  18. package/docs/sdk/hello-module.mjs +3 -0
  19. package/package.json +3 -2
  20. package/public/abduction.js +6 -6
  21. package/public/activity.js +425 -0
  22. package/public/app.js +2477 -438
  23. package/public/assets/abduction-cat-blink.webp +0 -0
  24. package/public/assets/abduction-cat-control-left.webp +0 -0
  25. package/public/assets/abduction-cat-control-right.webp +0 -0
  26. package/public/assets/abduction-cat.webp +0 -0
  27. package/public/assets/manual/shots/en-agents.webp +0 -0
  28. package/public/assets/manual/shots/en-chats.webp +0 -0
  29. package/public/assets/manual/shots/en-code.webp +0 -0
  30. package/public/assets/manual/shots/en-composer.webp +0 -0
  31. package/public/assets/manual/shots/en-connectors.webp +0 -0
  32. package/public/assets/manual/shots/en-continuity.webp +0 -0
  33. package/public/assets/manual/shots/en-coordinator.webp +0 -0
  34. package/public/assets/manual/shots/en-copilot.webp +0 -0
  35. package/public/assets/manual/shots/en-diagnostics.webp +0 -0
  36. package/public/assets/manual/shots/en-home.webp +0 -0
  37. package/public/assets/manual/shots/en-local.webp +0 -0
  38. package/public/assets/manual/shots/en-market.webp +0 -0
  39. package/public/assets/manual/shots/en-memory.webp +0 -0
  40. package/public/assets/manual/shots/en-modes.webp +0 -0
  41. package/public/assets/manual/shots/en-notes.webp +0 -0
  42. package/public/assets/manual/shots/en-settings.webp +0 -0
  43. package/public/assets/manual/shots/en-welcome.webp +0 -0
  44. package/public/assets/manual/shots/en-windows.webp +0 -0
  45. package/public/assets/manual/shots/es-agents.webp +0 -0
  46. package/public/assets/manual/shots/es-chats.webp +0 -0
  47. package/public/assets/manual/shots/es-code.webp +0 -0
  48. package/public/assets/manual/shots/es-composer.webp +0 -0
  49. package/public/assets/manual/shots/es-connectors.webp +0 -0
  50. package/public/assets/manual/shots/es-continuity.webp +0 -0
  51. package/public/assets/manual/shots/es-coordinator.webp +0 -0
  52. package/public/assets/manual/shots/es-copilot.webp +0 -0
  53. package/public/assets/manual/shots/es-diagnostics.webp +0 -0
  54. package/public/assets/manual/shots/es-home.webp +0 -0
  55. package/public/assets/manual/shots/es-local.webp +0 -0
  56. package/public/assets/manual/shots/es-market.webp +0 -0
  57. package/public/assets/manual/shots/es-memory.webp +0 -0
  58. package/public/assets/manual/shots/es-modes.webp +0 -0
  59. package/public/assets/manual/shots/es-notes.webp +0 -0
  60. package/public/assets/manual/shots/es-settings.webp +0 -0
  61. package/public/assets/manual/shots/es-welcome.webp +0 -0
  62. package/public/assets/manual/shots/es-windows.webp +0 -0
  63. package/public/assets/news/1.1/en/chats.webp +0 -0
  64. package/public/assets/news/1.1/en/home.webp +0 -0
  65. package/public/assets/news/1.1/en/maps.webp +0 -0
  66. package/public/assets/news/1.1/en/market.webp +0 -0
  67. package/public/assets/news/1.1/en/permissions.webp +0 -0
  68. package/public/assets/news/1.1/en/privacy.webp +0 -0
  69. package/public/assets/news/1.1/en/welcome.webp +0 -0
  70. package/public/assets/news/1.1/es/chats.webp +0 -0
  71. package/public/assets/news/1.1/es/home.webp +0 -0
  72. package/public/assets/news/1.1/es/maps.webp +0 -0
  73. package/public/assets/news/1.1/es/market.webp +0 -0
  74. package/public/assets/news/1.1/es/permissions.webp +0 -0
  75. package/public/assets/news/1.1/es/privacy.webp +0 -0
  76. package/public/assets/news/1.1/es/welcome.webp +0 -0
  77. package/public/attribution.js +15 -16
  78. package/public/brands.js +2 -2
  79. package/public/code-tools.js +2 -2
  80. package/public/editor.js +13 -13
  81. package/public/en.js +413 -4
  82. package/public/es.js +1354 -483
  83. package/public/hardware.js +2 -2
  84. package/public/i18n.js +2 -2
  85. package/public/icons.js +158 -0
  86. package/public/index.html +66 -48
  87. package/public/inquiry.js +2 -2
  88. package/public/loader.js +271 -2
  89. package/public/macroverso.js +64 -22
  90. package/public/manual-content.js +416 -169
  91. package/public/manual-shots.js +38 -34
  92. package/public/manual.css +20 -2
  93. package/public/manual.html +1 -1
  94. package/public/manual.js +54 -25
  95. package/public/market-art.js +47 -45
  96. package/public/market-view.js +111 -33
  97. package/public/market.js +132 -30
  98. package/public/mcp-catalog.js +2 -2
  99. package/public/neural.js +64 -8
  100. package/public/nostromo-engine.js +709 -40
  101. package/public/page-errors.js +31 -0
  102. package/public/power.js +350 -11
  103. package/public/remedy.js +89 -0
  104. package/public/resay.js +3 -2
  105. package/public/review-ask.js +12 -7
  106. package/public/routing.js +3 -3
  107. package/public/salas-mac.css +703 -24
  108. package/public/salas-mac.html +26 -14
  109. package/public/salas-mac.js +1261 -291
  110. package/public/salas.css +2 -2
  111. package/public/salas.html +3 -3
  112. package/public/salas.js +3 -3
  113. package/public/styles.css +2404 -291
  114. package/public/syntax.js +2 -2
  115. package/public/terms.js +152 -0
  116. package/public/touch.js +2 -2
  117. package/public/tour-chapters.js +10 -10
  118. package/public/tour.js +56 -8
  119. package/public/troubleshooting.js +200 -13
  120. package/public/wallpaper.js +4 -3
  121. package/public/welcome.js +923 -0
  122. package/src/activity.mjs +85 -0
  123. package/src/adapters/claude.mjs +61 -35
  124. package/src/adapters/codex.mjs +18 -5
  125. package/src/adapters/cursor.mjs +5 -3
  126. package/src/adapters/gemini.mjs +5 -3
  127. package/src/adapters/madre.mjs +3 -3
  128. package/src/adapters/opencode.mjs +73 -10
  129. package/src/adapters/process.mjs +14 -13
  130. package/src/adapters/subagents.mjs +159 -0
  131. package/src/asking.mjs +8 -2
  132. package/src/auth-probe.mjs +27 -10
  133. package/src/bridge/devices.mjs +2 -2
  134. package/src/bridge/handoff.mjs +2 -2
  135. package/src/bridge/host.mjs +2 -2
  136. package/src/bridge/network.mjs +2 -2
  137. package/src/bridge/policy.mjs +3 -3
  138. package/src/bridge/qr.mjs +2 -2
  139. package/src/bridge/server.mjs +2 -2
  140. package/src/builtin-updates.mjs +87 -0
  141. package/src/capabilities.mjs +2 -2
  142. package/src/chats.mjs +51 -2
  143. package/src/checkpoint.mjs +67 -9
  144. package/src/choices.mjs +2 -2
  145. package/src/cli-args.mjs +2 -2
  146. package/src/cold.mjs +2 -2
  147. package/src/commands.mjs +2 -2
  148. package/src/config.mjs +2 -2
  149. package/src/conversation-context.mjs +2 -2
  150. package/src/credentials.mjs +56 -16
  151. package/src/dataset.mjs +2 -2
  152. package/src/directives.mjs +2 -2
  153. package/src/distiller.mjs +2 -2
  154. package/src/embeddings.mjs +2 -2
  155. package/src/enlaces.mjs +2 -2
  156. package/src/environment.mjs +147 -0
  157. package/src/event-store.mjs +2 -2
  158. package/src/exam.mjs +2 -2
  159. package/src/extensions.mjs +2 -2
  160. package/src/eyecat-watch.mjs +2 -2
  161. package/src/eyecat.mjs +2 -2
  162. package/src/file-ops.mjs +2 -2
  163. package/src/files.mjs +2 -2
  164. package/src/github.mjs +2 -2
  165. package/src/heartbeat.mjs +2 -2
  166. package/src/history.mjs +2 -2
  167. package/src/i18n.mjs +9 -2
  168. package/src/image-studio.mjs +2 -2
  169. package/src/install-metrics.mjs +109 -0
  170. package/src/json-file.mjs +2 -2
  171. package/src/launch.mjs +2 -2
  172. package/src/lease.mjs +15 -4
  173. package/src/lobby-work.mjs +11 -4
  174. package/src/local-ai.mjs +2 -2
  175. package/src/looks.mjs +2 -2
  176. package/src/market-check.mjs +165 -0
  177. package/src/market-key.mjs +10 -2
  178. package/src/market-license.mjs +4 -4
  179. package/src/market-remote.mjs +54 -12
  180. package/src/maturity.mjs +2 -2
  181. package/src/mcp/connect.mjs +2 -2
  182. package/src/mcp/github-server.mjs +2 -2
  183. package/src/mcp/image-server.mjs +2 -2
  184. package/src/mcp/memory-server.mjs +2 -2
  185. package/src/mcp/proxy.mjs +2 -2
  186. package/src/mcp/smtp-server.mjs +2 -2
  187. package/src/memory-dashboard.mjs +2 -2
  188. package/src/memory-tools.mjs +2 -2
  189. package/src/memory.mjs +2 -2
  190. package/src/models.mjs +33 -3
  191. package/src/module-scope.mjs +2 -2
  192. package/src/modules/ahp.mjs +2 -2
  193. package/src/modules/ash-policy.mjs +2 -2
  194. package/src/modules/ash.mjs +2 -2
  195. package/src/modules/bishop-exam.mjs +2 -2
  196. package/src/modules/bishop-plan.mjs +2 -2
  197. package/src/modules/bishop.mjs +9 -3
  198. package/src/modules/choices.mjs +2 -2
  199. package/src/modules/correo.mjs +2 -2
  200. package/src/modules/enlaces.mjs +2 -2
  201. package/src/modules/git-pulse.mjs +2 -2
  202. package/src/modules/github.mjs +2 -2
  203. package/src/modules/helpers.mjs +2 -2
  204. package/src/modules/image-studio.mjs +2 -2
  205. package/src/modules/index.mjs +90 -5
  206. package/src/modules/intents-calibration.mjs +2 -2
  207. package/src/modules/intents-desk.mjs +4 -3
  208. package/src/modules/intents-observe.mjs +2 -2
  209. package/src/modules/intents-policy.mjs +2 -2
  210. package/src/modules/intents-try.mjs +2 -2
  211. package/src/modules/intents.mjs +2 -2
  212. package/src/modules/local-models.mjs +14 -11
  213. package/src/modules/mcp-connect.mjs +2 -2
  214. package/src/modules/notes.mjs +159 -20
  215. package/src/modules/ollama.mjs +23 -11
  216. package/src/modules/playwright.mjs +2 -2
  217. package/src/modules/reminders.mjs +356 -37
  218. package/src/modules/ripley.mjs +3 -3
  219. package/src/modules/runs.mjs +2 -2
  220. package/src/modules/sdk.mjs +38 -6
  221. package/src/modules/updates.mjs +2 -2
  222. package/src/mother.mjs +2 -2
  223. package/src/npm-launch.mjs +2 -2
  224. package/src/ollama.mjs +6 -4
  225. package/src/opencode-health.mjs +26 -6
  226. package/src/outbound.mjs +10 -2
  227. package/src/override.mjs +27 -22
  228. package/src/ports.mjs +2 -2
  229. package/src/prices.mjs +2 -2
  230. package/src/privacy.mjs +2 -2
  231. package/src/quota-monitor.mjs +2 -2
  232. package/src/quota-sources.mjs +2 -2
  233. package/src/request-guard.mjs +2 -2
  234. package/src/review-ask.mjs +4 -3
  235. package/src/room/archivist.mjs +2 -2
  236. package/src/room/attachments.mjs +2 -2
  237. package/src/room/budget.mjs +2 -2
  238. package/src/room/context.mjs +2 -2
  239. package/src/room/control.mjs +2 -2
  240. package/src/room/copilot.mjs +2 -2
  241. package/src/room/economy.mjs +2 -2
  242. package/src/room/escalation.mjs +2 -2
  243. package/src/room/ghost.mjs +2 -2
  244. package/src/room/guard.mjs +6 -4
  245. package/src/room/prompt.mjs +3 -3
  246. package/src/room/returns.mjs +2 -2
  247. package/src/room/runs.mjs +6 -4
  248. package/src/room/vectors.mjs +2 -2
  249. package/src/room.mjs +127 -31
  250. package/src/router.mjs +2 -2
  251. package/src/runs.mjs +2 -2
  252. package/src/runtime-detection.mjs +31 -5
  253. package/src/salas.mjs +31 -6
  254. package/src/sentinel-errors.mjs +17 -5
  255. package/src/server-sentinel.mjs +2 -2
  256. package/src/server.mjs +706 -84
  257. package/src/setup-trouble.mjs +35 -0
  258. package/src/setup.mjs +4 -4
  259. package/src/smtp.mjs +2 -2
  260. package/src/telemetry.mjs +266 -0
  261. package/src/terms.mjs +43 -0
  262. package/src/tour.mjs +39 -5
  263. package/src/uninstall.mjs +225 -0
  264. package/src/updates.mjs +2 -2
  265. package/src/usage-sentinel.mjs +2 -2
  266. package/src/vault.mjs +2 -2
  267. package/src/verdict.mjs +13 -10
  268. package/src/whats-new.mjs +97 -3
  269. package/public/assets/abduction-cat-blink.png +0 -0
  270. package/public/assets/abduction-cat-control-left.png +0 -0
  271. package/public/assets/abduction-cat-control-right.png +0 -0
  272. package/public/assets/abduction-cat.png +0 -0
  273. package/public/assets/manual/madre-manual-en.pdf +0 -0
  274. package/public/assets/manual/madre-manual-es.pdf +0 -0
  275. package/public/assets/manual/shots/en-modules.webp +0 -0
  276. package/public/assets/manual/shots/es-modules.webp +0 -0
  277. package/src/mcp/notes-server.mjs +0 -120
  278. package/src/reminder-time.mjs +0 -127
package/docs/en/SDK.md CHANGED
@@ -54,7 +54,7 @@ export default ({ defineModule }) => defineModule({
54
54
 
55
55
  ## What a module can declare
56
56
 
57
- This table is **the complete contract**: 38 fields, not one more. Any other field you write, MADRE
57
+ This table is **the complete contract**: 41 fields, not one more. Any other field you write, MADRE
58
58
  tells you about at install time ("I didn't understand these fields") instead of silently ignoring it. A test in
59
59
  the suite compares this table against the code, so if they ever drift apart, it's a failure.
60
60
 
@@ -63,6 +63,7 @@ the suite compares this table against the code, so if they ever drift apart, it'
63
63
  |---|---|
64
64
  | `id`, `name`, `vendor`, `summary`, `creates`, `requires` | Its page in MODULES. `summary` is one sentence: what it does. `creates` and `requires` are short lines, one idea each |
65
65
  | `version` | Yours, and it starts at `1.0.0`. If you don't declare it, the page shows the file's date |
66
+ | `sdk` | The SDK contract your module was written for, a whole number: `1` (up to MADRE 1.0.5) or `2` (`ctx.t`, `ctx.services.ollama.generate`, and a module that is one file importing nothing from MADRE). Without it, it is `1`. A MADRE that does not know your contract does not load it and tells you why; the Market only offers it to the ones that do. The number counts what MADRE hands a module, not MADRE's version: a new MADRE keeps understanding the earlier contracts |
66
67
  | `tracks` | If your module wraps something from outside, its version isn't yours: it's that thing's. Declare `{ name, npm }` or `{ name, github }` and return the version found in `status(ctx)` as `runs: [{ name, version }]`. MADRE shows that version and looks for a newer one on its own, once a day, with the page's ↻ button to check now |
67
68
  | `updatePlan(ctx, { latest })` | How that new version is brought to this computer: `{ command, args, display, note, after }`. MADRE shows `display` and runs nothing until the human has read it; the output lands in the room line by line. With no command, return `{ command: null, note, download }` and the page sends you to download it |
68
69
  | `updates` | An https `{ url }` where you publish **your own module**. With that, its page gets a button that fetches the file, verifies it the same way as an installation, and replaces it if it passes. If you installed it from a file, MADRE remembers which one and you don't need to declare anything: edit it and ask for a new copy |
@@ -73,6 +74,8 @@ the suite compares this table against the code, so if they ever drift apart, it'
73
74
  | `onToggle(ctx, enabled)` | Reacts to the switch |
74
75
  | `ready(ctx)` | What you ask before turning on, in one project or in all (from the Market too): `null` when ready, `{ status, body: { error } }` when not. Turning off never asks it |
75
76
  | `footer` | Up to two keys beside MADRE's version, bottom right, while your module is on: `[{ icon: 'heart' \| 'star' \| 'link', label, text, action, url }]`. Words can be one sentence or `{ en, es }`; `url` must be https and opens in a new tab. MADRE draws it: on hover it shows `text` and a button with `action` |
77
+ | `credit` | Whose idea it was, if it was not yours: a name. MADRE says it on the module's card and in the Market («Idea by …») |
78
+ | `icon` | Your module's icon: `{ svg, color }`. `svg` is the drawing — its shapes (`<path d="…"/>`) or a whole `<svg>`, on whatever grid you like — and `color` its tile's, `#rrggbb`. MADRE fits it on its own so it looks like MADRE's: centred and scaled to the same square, drawn in white in one color, on the MADRE color nearest to yours, with anything that is not drawing taken out (scripts, images, links, styles, gradients). Without `icon`, your module wears the grey puzzle piece. Up to 8000 characters |
76
79
  | `slash` | `/name` commands that run on the server with your `ctx` and return `{ ok, title, text, link }`. The room shows them as a card and the agents read them. `link` is optional: `{ href, label }` with a route of yours (`/api/x/<id>/…`), and the card offers it as a key that opens another tab; an address outside your routes is ignored |
77
80
  | `toolsForTurn(ctx, turn)` | MCP servers for an agent's turn: `[{ name, command, args, env, tools, sends, brief }]`. MADRE attaches them to the CLI in its isolated run and describes `brief` to the agent. `turn` carries the agent, the mode, the lease, the folder, the port, and `turn.turn`: the id of the reply that turn will write. If your server calls back to the room on behalf of the turn, send that id; `ctx.room.runningTurn(id)` tells you whether it is still running and for which agent |
78
81
  | `toolsForTurn` → `sends` | Which of your tools **send something outside**. The core withdraws them below `#4` AIRLOCK: the model isn't even told they exist. See below |
@@ -235,6 +238,19 @@ The page of a module of yours has **GET A NEWER FILE**: MADRE fetches the file
235
238
 
236
239
  And in the MODULES header there is **+ ADD A MODULE** to install someone else's `.mjs`. It goes through the same door as everything else. Said plainly, because it is what it is: a module runs **inside MADRE, with the permissions of whoever opens it**. MADRE checks that it loads and that it doesn't leave its pen —its own id, routes only under `/api/x/<id>/`, never on top of a MADRE module—; what the code *intends* is something nobody but you can check.
237
240
 
241
+ ### In the Market, for everyone
242
+
243
+ A module of yours can be in MADRE's Market, free, with your name on it. It is curated: the author of MADRE reads the code, signs it and publishes it; nothing reaches the Market without a person reading it.
244
+
245
+ 1. On your module's page, **Send to the Market › Prepare**. Write what the Market will show —name, one line and what it does, in Spanish and English—, the shelf, your name and GitHub user, and the license of your code.
246
+ 2. **Check** checks it the way the Market will: that it loads as any module loads, that the entry says the same id and version, and what its code reaches for (commands, the network, files, environment variables). If it talks to the network, declare `reaches`.
247
+ 3. **Prepare the files** leaves the two the repository asks for, `<id>.module.mjs` and `entrada.json`, in a folder of their own, and shows it to you.
248
+ 4. **Open GitHub** takes you to the `modulos/<id>/` folder of the public `madre-mercado` repository. Drag both files in and press *Propose changes*: GitHub makes the fork and the pull request for you, no terminal.
249
+
250
+ The same check runs on the pull request and leaves its summary for whoever reads it. Once signed, it shows in the Market tagged **Community** and **Developed by** your name; whoever installs it reads what it declares first. For a new version, raise `version` in the module and send it again.
251
+
252
+ From the terminal, the same check: `npx @jossuealcala/madre check-module --file <id>.module.mjs --entry entrada.json`.
253
+
238
254
  ## The module page
239
255
 
240
256
  You don't draw anything: you declare, and MADRE builds your module the same way as its own. In MODULES each module is a card on the board and, when you tap it, a page with the same blocks as SETTINGS. That's why yours reads the same as the ones MADRE ships.
@@ -263,7 +279,10 @@ ctx = {
263
279
  env, agents, room, // agentes detectados; la sala (room.capabilities(), room.record(...))
264
280
  readConfig(), updateConfig(patch),
265
281
  record(type, payload), // escribe un evento en el ledger; tipo "algo.algo", nunca message.* ni agent.*
266
- services: { history, imageKey, ollama, … }, // lo que el servidor ofrece
282
+ language, t(text, vars), // the room's language, 'es' or 'en', and your words in it (sdk: 2):
283
+ // an English sentence MADRE already knows, or your own { es, en }
284
+ services: { history, imageKey, ollama: { state, generate }, … }, // what the server offers;
285
+ // ollama.generate({ system, prompt, json }) answers with the local model (sdk: 2)
267
286
  vault: { get, held, keep, forget } // tus secretos, y solo los tuyos
268
287
  }
269
288
  ```
@@ -300,7 +319,7 @@ Texts come cut at 600 characters. It is the ground for a module that reports on
300
319
 
301
320
  ## Let your AI build it, in the room
302
321
 
303
- Type `/module <lo que debe hacer>` in the composer. It is the explicit entry point to the guided flow: if `#2 CREATE` isn't active, MADRE asks you to choose it and keeps your request intact. With `#2` active, it keeps the agent you chose and hands it the SDK contract and the example. The agent must write **a single file** named `<id>.module.mjs` in its scratch folder; it cannot install it on its own.
322
+ Type `/module <lo que debe hacer>` in the composer. It is the explicit entry point to the guided flow: if `#2 CREATE` isn't active, MADRE asks you to choose it and keeps your request intact. With `#2` active, it keeps the agent you chose and hands it the SDK contract and the example. The agent must write **a single file** named `<id>.module.mjs` in its scratch folder; it cannot install it on its own. That file carries its `icon`: the agent draws it with the rest of the module and MADRE fits it to the tile.
304
323
 
305
324
  MADRE recognizes that name and puts a card in the room: `INSTALL FOR EVERY ROOM` or `INSTALL FOR THIS PROJECT`. Read it, decide, one click. MADRE validates it in a copy, saves it as `<id>.mjs` in the folder you chose, and it appears in MODULES with the «Yours» tag. You can also ask for the same thing in natural language while you're in `#2` or higher; `/module` makes the format explicit and doesn't grant permissions on its own.
306
325
 
@@ -24,6 +24,9 @@ export default {
24
24
  creates: ['nothing in the project'],
25
25
  requires: [],
26
26
  settings: { enabled: false, greeting: 'hola' }, // defaults; the human changes them in config.json
27
+ // Its icon: the drawing and its tile's color. MADRE centres it, draws it in white and uses the
28
+ // nearest of its own tile colors, so draw it on any grid and do not worry about its size.
29
+ icon: { svg: '<path d="M4 10.5c0-3.3 2.7-6 6-6s6 2.7 6 6-2.7 6-6 6H4z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>', color: '#0f766e' },
27
30
 
28
31
  // What MODULES shows for this module. ctx.settings already has the defaults applied.
29
32
  async status(ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jossuealcala/madre",
3
- "version": "1.0.5",
3
+ "version": "1.1.1",
4
4
  "description": "MADRE · one local room where the AI coding agents already on your machine (Codex, Claude Code, Gemini CLI, OpenCode) work on your project together, share one memory you can see and explore, and answer to you. Read-only by default, with per-message permission modes and checkpoints you can undo. Nothing leaves your machine on its own.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -36,11 +36,12 @@
36
36
  "url": "https://jossuealcala.com/en/"
37
37
  },
38
38
  "type": "module",
39
- "license": "AGPL-3.0-only",
39
+ "license": "BUSL-1.1",
40
40
  "files": [
41
41
  "bin",
42
42
  "src",
43
43
  "public",
44
+ "!public/assets/manual/*.pdf",
44
45
  "README.md",
45
46
  "CHANGELOG.md",
46
47
  "LICENSE",
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // ABDUCTION — the one joke in the room, and the only thing here that is not work.
4
4
  //
5
5
  // Type MADRE into the box, alone, and send it. Not @madre: that is the local agent and it has a
@@ -18,10 +18,10 @@ export function calledByName(text, { attachments = 0 } = {}) {
18
18
 
19
19
  const PHASES = { arrive: 700, beam: 1050, lift: 2000, swallow: 2400, leave: 3000, done: 3400 };
20
20
  const SHIP_FRAMES = Object.freeze({
21
- idle: '/assets/abduction-cat.png',
22
- blink: '/assets/abduction-cat-blink.png',
23
- controlLeft: '/assets/abduction-cat-control-left.png',
24
- controlRight: '/assets/abduction-cat-control-right.png',
21
+ idle: '/assets/abduction-cat.webp',
22
+ blink: '/assets/abduction-cat-blink.webp',
23
+ controlLeft: '/assets/abduction-cat-control-left.webp',
24
+ controlRight: '/assets/abduction-cat-control-right.webp',
25
25
  });
26
26
  const ease = (t) => (t < 0 ? 0 : t > 1 ? 1 : t * t * (3 - 2 * t));
27
27
  const span = (now, from, to) => ease((now - from) / (to - from));
@@ -0,0 +1,425 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // «En marcha» (2026-10-30): a key on the bar with how many things MADRE is doing, and under it a
4
+ // panel with each one — the agents answering, the plans, the commands and servers, an install —
5
+ // in every project open on this computer, what ended a moment ago, and the reminders coming. A
6
+ // person sees and stops it all from there, without a terminal. The server says it (src/activity.mjs,
7
+ // GET /api/activity?everywhere=1); a project's page and Home's mount the same panel.
8
+ import { language, t } from './i18n.js';
9
+ import { brandOf } from './brands.js';
10
+ import { trazo } from './icons.js';
11
+
12
+ // How often it asks: often while the panel is open, seldom for the number on the key, never while
13
+ // the page is out of sight.
14
+ const OPEN_EVERY_MS = 1500;
15
+ const CLOSED_EVERY_MS = 5000;
16
+
17
+ const el = (tag, cls, text) => {
18
+ const node = document.createElement(tag);
19
+ if (cls) node.className = cls;
20
+ if (text != null) node.textContent = text;
21
+ return node;
22
+ };
23
+ const clock = (ms) => {
24
+ const s = Math.max(0, Math.round(ms / 1000));
25
+ const h = Math.floor(s / 3600);
26
+ const m = Math.floor((s % 3600) / 60);
27
+ return h ? `${h}:${String(m).padStart(2, '0')}:${String(s % 60).padStart(2, '0')}` : `${m}:${String(s % 60).padStart(2, '0')}`;
28
+ };
29
+ function ago(at, now = Date.now()) {
30
+ const minutes = Math.round((Date.parse(at) - now) / 60000);
31
+ if (Math.abs(minutes) < 1) return t('just now');
32
+ const words = new Intl.RelativeTimeFormat(language() === 'en' ? 'en' : 'es-MX', { numeric: 'auto', style: 'short' });
33
+ return Math.abs(minutes) < 60 ? words.format(minutes, 'minute') : words.format(Math.round(minutes / 60), 'hour');
34
+ }
35
+ // What a project is called in the panel: its folder's name, or the Coordinator for Home's own chats.
36
+ const whereOf = (project) => (project.home ? t('Coordinator') : project.name ?? project.room);
37
+ // What runs, counted for the key: a plan once (its steps are inside it), never an outdated project.
38
+ const counted = (one) => one.kind !== 'turn' || !one.planId;
39
+
40
+ function avatar(agent, { busy = false } = {}) {
41
+ const brand = brandOf(agent);
42
+ const face = el('span', `ap-av${busy ? ' busy' : ''}`);
43
+ face.style.setProperty('--ap-c', brand.color);
44
+ face.style.color = brand.ink;
45
+ face.innerHTML = brand.mark(); // trusted: the brands' own SVG
46
+ face.title = brand.label;
47
+ return face;
48
+ }
49
+ function sysAvatar(icon, { busy = false } = {}) {
50
+ const face = el('span', `ap-av sys${busy ? ' busy' : ''}`);
51
+ face.innerHTML = trazo(icon); // trusted: our own SVG
52
+ return face;
53
+ }
54
+
55
+ /**
56
+ * Mounts «En marcha» on a key of the bar.
57
+ * key: the button; badge: where the number goes; openChat({ project, chat, messageId }) opens a
58
+ * conversation of THIS page's project (a project elsewhere opens in its own tab); toast(words).
59
+ */
60
+ export function mountActivity({ key, badge, openChat, toast = () => {} }) {
61
+ if (!key) return null;
62
+ const state = { data: null, said: '', open: false, timer: 0, ticking: 0, opened: new Set(), confirmAll: 0, failing: 0, pressing: false, stale: false };
63
+ const panel = el('div', 'activity-panel');
64
+ panel.setAttribute('role', 'dialog');
65
+ panel.setAttribute('aria-label', t('Running now'));
66
+ panel.hidden = true;
67
+ document.body.append(panel);
68
+ key.setAttribute('aria-haspopup', 'dialog');
69
+ key.setAttribute('aria-expanded', 'false');
70
+
71
+ async function load() {
72
+ try {
73
+ const response = await fetch('/api/activity?everywhere=1', { cache: 'no-store' });
74
+ if (!response.ok) throw new Error(String(response.status));
75
+ const answer = await response.json();
76
+ // Drawn again only when something changed: a panel rebuilt every second and a half swallowed
77
+ // the click that landed between two drawings, and took the keyboard's place away. The clocks
78
+ // move on their own (the tickers).
79
+ const said = JSON.stringify({ projects: answer.projects, soon: answer.soon });
80
+ const changed = said !== state.said || state.failing > 0;
81
+ state.data = { ...answer, received: Date.now() };
82
+ state.said = said;
83
+ state.failing = 0;
84
+ paintKey();
85
+ if (state.open && changed) repaint();
86
+ return;
87
+ } catch {
88
+ state.failing += 1;
89
+ }
90
+ paintKey();
91
+ if (state.open) repaint();
92
+ }
93
+ // Never under a finger: what changed while the person presses waits until they let go.
94
+ function repaint() {
95
+ if (state.pressing) { state.stale = true; return; }
96
+ paint();
97
+ }
98
+ panel.addEventListener('pointerdown', () => { state.pressing = true; });
99
+ const letGo = () => { if (!state.pressing) return; state.pressing = false; if (state.stale) { state.stale = false; setTimeout(() => { if (state.open) paint(); }, 0); } };
100
+ document.addEventListener?.('pointerup', letGo, true);
101
+ document.addEventListener?.('pointercancel', letGo, true);
102
+ function schedule() {
103
+ clearTimeout(state.timer);
104
+ if (document.visibilityState === 'hidden') return;
105
+ state.timer = setTimeout(async () => { await load(); schedule(); }, state.open ? OPEN_EVERY_MS : CLOSED_EVERY_MS);
106
+ // Where timers can hold a process open (the tests run this page in Node), this one never does.
107
+ state.timer?.unref?.();
108
+ }
109
+ document.addEventListener?.('visibilitychange', () => { if (document.visibilityState === 'visible') { void load(); schedule(); } else clearTimeout(state.timer); });
110
+
111
+ const projects = () => (state.data?.projects ?? []).filter((one) => !one.outdated);
112
+ const running = () => projects().flatMap((project) => (project.now ?? []).filter(counted).map((one) => ({ project, one })));
113
+
114
+ function paintKey() {
115
+ const n = running().length;
116
+ key.classList.toggle('working', n > 0);
117
+ key.title = n ? t('Running now · {n}', { n }) : t('Running now · nothing at the moment');
118
+ key.setAttribute('aria-label', key.title);
119
+ if (badge) { badge.hidden = !n; badge.textContent = n ? String(n) : ''; }
120
+ }
121
+
122
+ // Where an action goes: the project it belongs to, through this page's own server.
123
+ async function stop(project, item) {
124
+ const body = { room: project.here ? null : project.room, kind: item.kind, chat: item.chat ?? null, messageId: item.messageId, planId: item.planId, id: item.id };
125
+ const response = await fetch('/api/activity/stop', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) }).catch(() => null);
126
+ const answer = await response?.json().catch(() => ({}));
127
+ if (!response?.ok) toast(answer?.error ?? t('It could not be stopped. Try again.'));
128
+ await load();
129
+ }
130
+ async function stopAll() {
131
+ const response = await fetch('/api/activity/stop-all', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' }).catch(() => null);
132
+ if (!response?.ok) toast(t('It could not be stopped. Try again.'));
133
+ state.confirmAll = 0;
134
+ await load();
135
+ }
136
+ function goTo(project, chat, messageId) {
137
+ if (!chat) return;
138
+ if (project.here) { close(); openChat?.({ chat, messageId }); return; }
139
+ window.open(`http://127.0.0.1:${project.port}/#chat=${encodeURIComponent(chat)}${messageId ? `:${encodeURIComponent(messageId)}` : ''}`, '_blank', 'noopener');
140
+ }
141
+
142
+ // One line of the panel, folded or open: what it is, where, how long, and what can be done.
143
+ function row({ id, face, title, sub, time, timeTone = '', progress = null, more = null, tint = null }) {
144
+ const open = state.opened.has(id);
145
+ const box = el('div', `ap-row${open ? ' open' : ''}`);
146
+ if (tint) box.style.setProperty('--ap-c', tint);
147
+ const line = el('button', 'ap-line');
148
+ line.type = 'button';
149
+ line.setAttribute('aria-expanded', String(open));
150
+ const words = el('span', 'ap-words');
151
+ words.append(el('b', null, title), el('span', null, sub));
152
+ const when = el('span', `ap-time${timeTone ? ` ${timeTone}` : ''}`);
153
+ if (typeof time === 'function') { when.dataset.tick = '1'; when.textContent = time(); state.tickers.push(() => { when.textContent = time(); }); } else when.textContent = time ?? '';
154
+ const chev = el('span', 'ap-chev');
155
+ chev.innerHTML = trazo('next'); // trusted: our own SVG
156
+ line.append(face, words, when, chev);
157
+ if (progress) {
158
+ const bar = el('span', 'ap-bar');
159
+ const fill = el('i');
160
+ const set = () => { fill.style.width = `${Math.round(Math.min(1, Math.max(0, progress())) * 100)}%`; };
161
+ set();
162
+ state.tickers.push(set);
163
+ bar.append(fill);
164
+ line.append(bar);
165
+ }
166
+ line.addEventListener('click', () => { if (state.opened.has(id)) state.opened.delete(id); else state.opened.add(id); paint(); });
167
+ box.append(line);
168
+ if (open && more) {
169
+ const inside = el('div', 'ap-more');
170
+ more(inside);
171
+ box.append(inside);
172
+ }
173
+ return box;
174
+ }
175
+ const actions = (...buttons) => {
176
+ const bar = el('div', 'ap-acts');
177
+ for (const [words, tone, act] of buttons) {
178
+ const button = el('button', tone || null, words);
179
+ button.type = 'button';
180
+ button.addEventListener('click', async (event) => {
181
+ event.stopPropagation();
182
+ button.disabled = true;
183
+ try { await act(); } finally { button.disabled = false; }
184
+ });
185
+ bar.append(button);
186
+ }
187
+ return bar;
188
+ };
189
+ const skew = () => (state.data?.at ? Date.parse(state.data.at) - (state.data.received ?? Date.now()) : 0);
190
+ const since = (at) => () => Date.now() + skew() - at;
191
+
192
+ // An AI's own subagents, one chip each: what it was given, and whether it is still at it.
193
+ function subChips(helpers) {
194
+ const chips = el('div', 'ap-subs');
195
+ for (const one of helpers) {
196
+ const chip = el('span', `ap-sub ${one.status}`);
197
+ chip.append(el('i'), el('b', null, one.kind ?? t('subagent')), document.createTextNode(` ${one.task ?? ''}`));
198
+ if (Number.isFinite(one.seconds)) chip.append(el('em', null, clock(one.seconds * 1000)));
199
+ chips.append(chip);
200
+ }
201
+ return chips;
202
+ }
203
+
204
+ function nowRow(project, item, steps) {
205
+ const where = [whereOf(project), item.chatTitle].filter(Boolean).join(' · ');
206
+ const uid = `${project.room}:${item.kind}:${item.messageId ?? item.planId ?? item.id ?? item.what}`;
207
+ if (item.kind === 'turn') {
208
+ const helpers = item.subagents ?? [];
209
+ const busy = helpers.filter((one) => one.status === 'running').length;
210
+ const doing = busy ? t('{n} subagents at work', { n: busy }) : t('Working on it…');
211
+ return row({
212
+ id: uid, face: avatar(item.agent, { busy: true }), tint: brandOf(item.agent).color,
213
+ title: item.text || t('A turn of {agent}', { agent: brandOf(item.agent).label }),
214
+ sub: `${where} · ${doing}`,
215
+ time: item.timeoutMs ? () => t('{now} of {limit}', { now: clock(since(item.startedAt)()), limit: clock(item.timeoutMs) }) : () => clock(since(item.startedAt)()),
216
+ progress: item.timeoutMs ? () => since(item.startedAt)() / item.timeoutMs : null,
217
+ more: (inside) => {
218
+ if (helpers.length) inside.append(subChips(helpers));
219
+ inside.append(el('p', 'ap-meta', item.timeoutMs ? t('With your permission #{mode} · the limit counts from when it started', { mode: item.mode ?? 1 }) : t('With your permission #{mode}', { mode: item.mode ?? 1 })));
220
+ inside.append(actions([t('Go to the chat'), 'go', () => goTo(project, item.chat, item.messageId)], [t('Stop'), 'stop', () => stop(project, item)]));
221
+ },
222
+ });
223
+ }
224
+ if (item.kind === 'plan') {
225
+ return row({
226
+ id: uid, face: avatar(item.orchestrator, { busy: true }), tint: brandOf(item.orchestrator).color,
227
+ title: t('Plan by {agent} · {n} steps', { agent: brandOf(item.orchestrator).label, n: item.total }),
228
+ sub: `${where} · ${t('Step {step} of {total}', { step: Math.max(1, item.step), total: item.total })}${steps.length ? ` · ${t('{agent} is answering', { agent: brandOf(steps[0].agent).label })}` : ''}`,
229
+ time: () => clock(since(item.startedAt)()),
230
+ progress: () => Math.max(0, item.step - 1) / Math.max(1, item.total),
231
+ more: (inside) => {
232
+ const list = el('ol', 'ap-steps');
233
+ (item.steps ?? []).forEach((step, index) => {
234
+ const li = el('li', index + 1 < item.step ? 'done' : index + 1 === item.step ? 'now' : '');
235
+ li.append(el('b', null, brandOf(step.agent).label), document.createTextNode(` ${step.text}`));
236
+ list.append(li);
237
+ });
238
+ // The last step is the one who made the plan reading the answers: counted, so it is listed.
239
+ const listed = item.steps?.length ?? 0;
240
+ if (item.total > listed) {
241
+ const li = el('li', item.step > listed ? 'now' : '');
242
+ li.append(el('b', null, brandOf(item.orchestrator).label), document.createTextNode(` ${t('reads the answers and closes the plan')}`));
243
+ list.append(li);
244
+ }
245
+ inside.append(list);
246
+ for (const turn of steps) {
247
+ const said = el('p', 'ap-meta', t('{agent} is answering step {step} · {time}', { agent: brandOf(turn.agent).label, step: item.step, time: clock(since(turn.startedAt)()) }));
248
+ state.tickers.push(() => { said.textContent = t('{agent} is answering step {step} · {time}', { agent: brandOf(turn.agent).label, step: item.step, time: clock(since(turn.startedAt)()) }); });
249
+ inside.append(said);
250
+ if (turn.subagents?.length) inside.append(subChips(turn.subagents));
251
+ }
252
+ inside.append(actions([t('Go to the chat'), 'go', () => goTo(project, item.chat)], [t('Stop the plan'), 'stop', () => stop(project, item)]));
253
+ },
254
+ });
255
+ }
256
+ if (item.kind === 'run') {
257
+ const serving = item.serving;
258
+ const host = serving ? (serving.host === '0.0.0.0' || serving.host === '::' ? '127.0.0.1' : serving.host) : null;
259
+ return row({
260
+ id: uid, face: sysAvatar(serving ? 'server' : 'mod-runs', { busy: !serving }),
261
+ title: `$ ${item.line ?? ''}`,
262
+ sub: `${where} · ${serving ? t('Listening on {host}:{port}', { host, port: serving.port }) : t('Running…')}`,
263
+ time: () => clock(since(item.startedAt)()),
264
+ more: (inside) => {
265
+ if (item.agent) inside.append(el('p', 'ap-meta', t('Asked by {agent}', { agent: brandOf(item.agent).label })));
266
+ const keys = [];
267
+ if (serving) keys.push([t('Open'), 'go', () => { window.open(`http://${host.includes(':') ? `[${host}]` : host}:${serving.port}/`, '_blank', 'noopener'); }]);
268
+ keys.push([t('Go to the chat'), '', () => goTo(project, item.chat, item.responseMessageId)]);
269
+ keys.push([serving ? t('Stop the server') : t('Stop'), 'stop', () => stop(project, item)]);
270
+ inside.append(actions(...keys));
271
+ },
272
+ });
273
+ }
274
+ // An install: an agent's program, Ollama or a model it downloads, or a module.
275
+ const what = String(item.what ?? '');
276
+ const title = what.startsWith('agent:') ? t('Installing {name}', { name: brandOf(what.slice(6)).label })
277
+ : what === 'ollama' ? (item.model ? t('Downloading {name}', { name: item.model }) : t('Installing {name}', { name: 'Ollama' }))
278
+ : t('Installing the module {name}', { name: what });
279
+ return row({
280
+ id: uid, face: sysAvatar('download', { busy: true }), title,
281
+ sub: `${project.home ? t('Home') : whereOf(project)} · ${t('It ends on its own; you can keep working.')}`,
282
+ time: item.startedAt ? () => clock(since(item.startedAt)()) : '',
283
+ });
284
+ }
285
+
286
+ function doneRow(project, item) {
287
+ const where = [whereOf(project), item.chatTitle].filter(Boolean).join(' · ');
288
+ const said = item.state === 'ok' ? (item.tookMs != null ? t('Answered in {time}', { time: clock(item.tookMs) }) : t('Answered'))
289
+ : item.state === 'stopped' ? t('You stopped it')
290
+ : item.timeout ? t('Ran out of time') : t('Could not answer');
291
+ const mark = { ok: '✓', failed: '✕', stopped: '■' }[item.state];
292
+ const face = avatar(item.agent);
293
+ face.classList.add('still');
294
+ return row({
295
+ id: `${project.room}:done:${item.messageId}:${item.at}`, face,
296
+ title: item.closing ? `${brandOf(item.agent).label} ${t('reads the answers and closes the plan')}` : item.text || t('A turn of {agent}', { agent: brandOf(item.agent).label }),
297
+ sub: `${where} · ${said}`,
298
+ time: `${mark} ${ago(item.at)}`,
299
+ timeTone: item.state === 'ok' ? 'ok' : item.state === 'failed' ? 'fail' : '',
300
+ more: (inside) => {
301
+ if (item.error) inside.append(el('pre', 'ap-out', item.error));
302
+ inside.append(actions([t('Go to the chat'), 'go', () => goTo(project, item.chat, item.messageId)]));
303
+ },
304
+ });
305
+ }
306
+
307
+ function section(title, rows, { quiet = false } = {}) {
308
+ if (!rows.length) return null;
309
+ const box = el('section', 'ap-sec');
310
+ box.append(el('h4', quiet ? 'quiet' : null, title));
311
+ box.append(...rows);
312
+ return box;
313
+ }
314
+
315
+ function paint() {
316
+ state.tickers = [];
317
+ // The key the keyboard was on comes back after the drawing, found by what it says and where.
318
+ const focused = panel.contains(document.activeElement) ? [...panel.querySelectorAll('button')].indexOf(document.activeElement) : -1;
319
+ const focusedWords = focused >= 0 ? document.activeElement.textContent : null;
320
+ const scroll = panel.querySelector('.ap-scroll');
321
+ const kept = scroll?.scrollTop ?? 0;
322
+ panel.replaceChildren();
323
+ const head = el('header', 'ap-head');
324
+ const name = el('h3', null, t('Running now'));
325
+ const count = running().length;
326
+ const shut = el('button', 'ap-x');
327
+ shut.type = 'button';
328
+ shut.setAttribute('aria-label', t('Close'));
329
+ shut.innerHTML = trazo('close'); // trusted: our own SVG
330
+ shut.addEventListener('click', close);
331
+ head.append(name, el('small', null, count ? t('{n} now', { n: count }) : ''), el('span', 'ap-grow'), shut);
332
+ panel.append(head);
333
+ const body = el('div', 'ap-scroll');
334
+ if (!state.data) {
335
+ body.append(el('p', 'ap-wait', state.failing ? t('MADRE did not answer. Trying again…') : t('Asking every open project…')));
336
+ } else {
337
+ const now = [];
338
+ const done = [];
339
+ const outdated = [];
340
+ for (const project of state.data.projects ?? []) {
341
+ if (project.outdated) { outdated.push(project); continue; }
342
+ const items = project.now ?? [];
343
+ for (const item of items.filter(counted)) now.push(nowRow(project, item, item.kind === 'plan' ? items.filter((one) => one.kind === 'turn' && one.planId === item.planId) : []));
344
+ for (const item of project.done ?? []) done.push({ at: item.at, node: () => doneRow(project, item) });
345
+ }
346
+ const soon = (state.data.soon ?? []).map((one) => row({
347
+ id: `soon:${one.id}`, face: sysAvatar('mod-reminders'), title: one.text,
348
+ sub: [one.project ?? t('Home'), new Intl.DateTimeFormat(language() === 'en' ? 'en-US' : 'es-MX', { hour: 'numeric', minute: '2-digit' }).format(new Date(one.due))].join(' · '),
349
+ time: ago(one.due),
350
+ }));
351
+ if (!now.length) {
352
+ const calm = el('div', 'ap-calm');
353
+ calm.innerHTML = trazo('check'); // trusted: our own SVG
354
+ calm.append(el('b', null, t('Nothing running')), el('span', null, t('When an agent answers, a command runs or something installs, you will see it here and can stop it.')));
355
+ body.append(calm);
356
+ }
357
+ for (const part of [
358
+ section(t('Now'), now),
359
+ section(t('Ended a moment ago'), done.sort((a, b) => String(b.at).localeCompare(String(a.at))).slice(0, 8).map((one) => one.node()), { quiet: true }),
360
+ section(t('Reminders coming up'), soon, { quiet: true }),
361
+ ]) if (part) body.append(part);
362
+ for (const project of outdated) body.append(el('p', 'ap-meta ap-old', t('{name} runs an older MADRE: update it to see here what it does.', { name: whereOf(project) })));
363
+ }
364
+ panel.append(body);
365
+ body.scrollTop = kept;
366
+ if (count) {
367
+ const foot = el('footer', 'ap-foot');
368
+ const places = new Set(running().map(({ project }) => project.room)).size;
369
+ foot.append(el('span', null, places > 1 ? t('In {n} projects', { n: places }) : ''));
370
+ const all = el('button', 'stop', state.confirmAll > Date.now() ? t('Stop everything? Yes') : t('Stop everything'));
371
+ all.type = 'button';
372
+ all.addEventListener('click', () => {
373
+ if (state.confirmAll > Date.now()) { void stopAll(); return; }
374
+ state.confirmAll = Date.now() + 4000;
375
+ paint();
376
+ setTimeout(() => { if (state.confirmAll && state.confirmAll <= Date.now()) { state.confirmAll = 0; if (state.open) paint(); } }, 4100);
377
+ });
378
+ foot.append(all);
379
+ panel.append(foot);
380
+ }
381
+ place();
382
+ if (focused >= 0) {
383
+ const buttons = [...panel.querySelectorAll('button')];
384
+ (buttons.find((one) => one.textContent === focusedWords) ?? buttons[Math.min(focused, buttons.length - 1)])?.focus({ preventScroll: true });
385
+ }
386
+ }
387
+
388
+ // Under its key on a wide window; a sheet from the bottom on a narrow one (styles.css).
389
+ function place() {
390
+ const box = key.getBoundingClientRect();
391
+ panel.style.setProperty('--ap-top', `${Math.round(box.bottom + 8)}px`);
392
+ panel.style.setProperty('--ap-right', `${Math.max(12, Math.round(window.innerWidth - box.right - 8))}px`);
393
+ }
394
+ function openPanel() {
395
+ state.open = true;
396
+ panel.hidden = false;
397
+ key.classList.add('on');
398
+ key.setAttribute('aria-expanded', 'true');
399
+ paint();
400
+ void load();
401
+ schedule();
402
+ clearInterval(state.ticking);
403
+ state.ticking = setInterval(() => { for (const tick of state.tickers ?? []) tick(); }, 1000);
404
+ state.ticking?.unref?.();
405
+ requestAnimationFrame(() => panel.classList.add('shown'));
406
+ }
407
+ function close() {
408
+ if (!state.open) return;
409
+ state.open = false;
410
+ panel.classList.remove('shown');
411
+ panel.hidden = true;
412
+ key.classList.remove('on');
413
+ key.setAttribute('aria-expanded', 'false');
414
+ clearInterval(state.ticking);
415
+ schedule();
416
+ }
417
+ key.addEventListener('click', () => (state.open ? close() : openPanel()));
418
+ document.addEventListener?.('keydown', (event) => { if (event.key === 'Escape' && state.open) { close(); key.focus(); } });
419
+ document.addEventListener?.('pointerdown', (event) => { if (state.open && !panel.contains(event.target) && !key.contains(event.target)) close(); }, true);
420
+ globalThis.addEventListener?.('resize', () => { if (state.open) place(); });
421
+
422
+ void load();
423
+ schedule();
424
+ return { open: openPanel, close, refresh: load };
425
+ }