@jossuealcala/madre 1.0.4 → 1.1.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 (273) hide show
  1. package/ADDITIONAL-TERMS.md +7 -2
  2. package/CHANGELOG.en.md +152 -1
  3. package/CHANGELOG.md +152 -1
  4. package/CONTRIBUTING.md +2 -2
  5. package/LICENSE +111 -661
  6. package/NOTICE +59 -24
  7. package/README.en.md +36 -204
  8. package/README.md +36 -210
  9. package/SECURITY.md +1 -0
  10. package/TRADEMARKS.en.md +13 -14
  11. package/TRADEMARKS.md +42 -26
  12. package/bin/madre.cjs +2 -2
  13. package/bin/madre.mjs +114 -42
  14. package/docs/REFERENCE.md +53 -6
  15. package/docs/SDK.md +44 -5
  16. package/docs/en/REFERENCE.md +53 -6
  17. package/docs/en/SDK.md +43 -4
  18. package/docs/madre-banner.png +0 -0
  19. package/docs/sdk/hello-module.mjs +3 -0
  20. package/package.json +3 -2
  21. package/public/abduction.js +6 -6
  22. package/public/activity.js +425 -0
  23. package/public/app.js +3519 -647
  24. package/public/assets/abduction-cat-blink.webp +0 -0
  25. package/public/assets/abduction-cat-control-left.webp +0 -0
  26. package/public/assets/abduction-cat-control-right.webp +0 -0
  27. package/public/assets/abduction-cat.webp +0 -0
  28. package/public/assets/manual/shots/en-agents.webp +0 -0
  29. package/public/assets/manual/shots/en-chats.webp +0 -0
  30. package/public/assets/manual/shots/en-code.webp +0 -0
  31. package/public/assets/manual/shots/en-composer.webp +0 -0
  32. package/public/assets/manual/shots/en-connectors.webp +0 -0
  33. package/public/assets/manual/shots/en-continuity.webp +0 -0
  34. package/public/assets/manual/shots/en-coordinator.webp +0 -0
  35. package/public/assets/manual/shots/en-copilot.webp +0 -0
  36. package/public/assets/manual/shots/en-diagnostics.webp +0 -0
  37. package/public/assets/manual/shots/en-home.webp +0 -0
  38. package/public/assets/manual/shots/en-local.webp +0 -0
  39. package/public/assets/manual/shots/en-market.webp +0 -0
  40. package/public/assets/manual/shots/en-memory.webp +0 -0
  41. package/public/assets/manual/shots/en-modes.webp +0 -0
  42. package/public/assets/manual/shots/en-notes.webp +0 -0
  43. package/public/assets/manual/shots/en-settings.webp +0 -0
  44. package/public/assets/manual/shots/en-welcome.webp +0 -0
  45. package/public/assets/manual/shots/en-windows.webp +0 -0
  46. package/public/assets/manual/shots/es-agents.webp +0 -0
  47. package/public/assets/manual/shots/es-chats.webp +0 -0
  48. package/public/assets/manual/shots/es-code.webp +0 -0
  49. package/public/assets/manual/shots/es-composer.webp +0 -0
  50. package/public/assets/manual/shots/es-connectors.webp +0 -0
  51. package/public/assets/manual/shots/es-continuity.webp +0 -0
  52. package/public/assets/manual/shots/es-coordinator.webp +0 -0
  53. package/public/assets/manual/shots/es-copilot.webp +0 -0
  54. package/public/assets/manual/shots/es-diagnostics.webp +0 -0
  55. package/public/assets/manual/shots/es-home.webp +0 -0
  56. package/public/assets/manual/shots/es-local.webp +0 -0
  57. package/public/assets/manual/shots/es-market.webp +0 -0
  58. package/public/assets/manual/shots/es-memory.webp +0 -0
  59. package/public/assets/manual/shots/es-modes.webp +0 -0
  60. package/public/assets/manual/shots/es-notes.webp +0 -0
  61. package/public/assets/manual/shots/es-settings.webp +0 -0
  62. package/public/assets/manual/shots/es-welcome.webp +0 -0
  63. package/public/assets/manual/shots/es-windows.webp +0 -0
  64. package/public/assets/news/1.1/en/chats.webp +0 -0
  65. package/public/assets/news/1.1/en/home.webp +0 -0
  66. package/public/assets/news/1.1/en/maps.webp +0 -0
  67. package/public/assets/news/1.1/en/market.webp +0 -0
  68. package/public/assets/news/1.1/en/permissions.webp +0 -0
  69. package/public/assets/news/1.1/en/privacy.webp +0 -0
  70. package/public/assets/news/1.1/en/welcome.webp +0 -0
  71. package/public/assets/news/1.1/es/chats.webp +0 -0
  72. package/public/assets/news/1.1/es/home.webp +0 -0
  73. package/public/assets/news/1.1/es/maps.webp +0 -0
  74. package/public/assets/news/1.1/es/market.webp +0 -0
  75. package/public/assets/news/1.1/es/permissions.webp +0 -0
  76. package/public/assets/news/1.1/es/privacy.webp +0 -0
  77. package/public/assets/news/1.1/es/welcome.webp +0 -0
  78. package/public/attribution.js +15 -16
  79. package/public/brands.js +2 -2
  80. package/public/code-tools.js +2 -2
  81. package/public/editor.js +13 -13
  82. package/public/en.js +483 -0
  83. package/public/es.js +1817 -598
  84. package/public/hardware.js +2 -2
  85. package/public/i18n.js +47 -9
  86. package/public/icons.js +158 -0
  87. package/public/index.html +68 -51
  88. package/public/inquiry.js +2 -2
  89. package/public/loader.js +271 -2
  90. package/public/macroverso.js +60 -21
  91. package/public/manual-content.js +900 -0
  92. package/public/manual-shots.js +47 -0
  93. package/public/manual.css +246 -0
  94. package/public/manual.html +15 -0
  95. package/public/manual.js +427 -0
  96. package/public/market-art.js +99 -41
  97. package/public/market-view.js +243 -47
  98. package/public/market.js +139 -26
  99. package/public/mcp-catalog.js +62 -0
  100. package/public/neural.js +64 -8
  101. package/public/nostromo-engine.js +709 -40
  102. package/public/page-errors.js +29 -0
  103. package/public/power.js +350 -11
  104. package/public/remedy.js +89 -0
  105. package/public/resay.js +4 -2
  106. package/public/review-ask.js +12 -7
  107. package/public/routing.js +3 -3
  108. package/public/salas-mac.css +875 -48
  109. package/public/salas-mac.html +27 -15
  110. package/public/salas-mac.js +1668 -338
  111. package/public/salas.css +2 -2
  112. package/public/salas.html +3 -3
  113. package/public/salas.js +3 -3
  114. package/public/styles.css +2694 -323
  115. package/public/syntax.js +2 -2
  116. package/public/terms.js +152 -0
  117. package/public/touch.js +2 -2
  118. package/public/tour-chapters.js +100 -92
  119. package/public/tour.js +118 -28
  120. package/public/troubleshooting.js +327 -21
  121. package/public/wallpaper.js +4 -3
  122. package/public/welcome.js +923 -0
  123. package/src/activity.mjs +85 -0
  124. package/src/adapters/claude.mjs +61 -35
  125. package/src/adapters/codex.mjs +18 -5
  126. package/src/adapters/cursor.mjs +60 -9
  127. package/src/adapters/gemini.mjs +17 -4
  128. package/src/adapters/madre.mjs +30 -9
  129. package/src/adapters/opencode.mjs +73 -10
  130. package/src/adapters/process.mjs +19 -15
  131. package/src/adapters/subagents.mjs +159 -0
  132. package/src/asking.mjs +8 -2
  133. package/src/auth-probe.mjs +47 -11
  134. package/src/bridge/devices.mjs +2 -2
  135. package/src/bridge/handoff.mjs +2 -2
  136. package/src/bridge/host.mjs +2 -2
  137. package/src/bridge/network.mjs +2 -2
  138. package/src/bridge/policy.mjs +3 -3
  139. package/src/bridge/qr.mjs +2 -2
  140. package/src/bridge/server.mjs +3 -3
  141. package/src/builtin-updates.mjs +87 -0
  142. package/src/capabilities.mjs +5 -5
  143. package/src/chats.mjs +51 -2
  144. package/src/checkpoint.mjs +67 -9
  145. package/src/choices.mjs +2 -2
  146. package/src/cli-args.mjs +2 -2
  147. package/src/cold.mjs +2 -2
  148. package/src/commands.mjs +2 -2
  149. package/src/config.mjs +2 -2
  150. package/src/conversation-context.mjs +2 -2
  151. package/src/credentials.mjs +80 -18
  152. package/src/dataset.mjs +2 -2
  153. package/src/directives.mjs +2 -2
  154. package/src/distiller.mjs +2 -2
  155. package/src/embeddings.mjs +2 -2
  156. package/src/enlaces.mjs +2 -2
  157. package/src/environment.mjs +147 -0
  158. package/src/event-store.mjs +2 -2
  159. package/src/exam.mjs +2 -2
  160. package/src/extensions.mjs +2 -2
  161. package/src/eyecat-watch.mjs +2 -2
  162. package/src/eyecat.mjs +2 -2
  163. package/src/file-ops.mjs +2 -2
  164. package/src/files.mjs +2 -2
  165. package/src/github.mjs +2 -2
  166. package/src/heartbeat.mjs +2 -2
  167. package/src/history.mjs +76 -0
  168. package/src/i18n.mjs +32 -3
  169. package/src/image-studio.mjs +2 -2
  170. package/src/install-metrics.mjs +109 -0
  171. package/src/json-file.mjs +2 -2
  172. package/src/launch.mjs +2 -2
  173. package/src/lease.mjs +15 -4
  174. package/src/lobby-work.mjs +11 -4
  175. package/src/local-ai.mjs +12 -4
  176. package/src/looks.mjs +19 -7
  177. package/src/market-check.mjs +165 -0
  178. package/src/market-key.mjs +10 -2
  179. package/src/market-license.mjs +104 -0
  180. package/src/market-remote.mjs +71 -13
  181. package/src/maturity.mjs +2 -2
  182. package/src/mcp/connect.mjs +2 -2
  183. package/src/mcp/github-server.mjs +2 -2
  184. package/src/mcp/image-server.mjs +2 -2
  185. package/src/mcp/memory-server.mjs +2 -2
  186. package/src/mcp/proxy.mjs +16 -5
  187. package/src/mcp/smtp-server.mjs +2 -2
  188. package/src/memory-dashboard.mjs +2 -2
  189. package/src/memory-tools.mjs +2 -2
  190. package/src/memory.mjs +2 -2
  191. package/src/models.mjs +115 -12
  192. package/src/module-scope.mjs +2 -2
  193. package/src/modules/ahp.mjs +2 -2
  194. package/src/modules/ash-policy.mjs +2 -2
  195. package/src/modules/ash.mjs +2 -2
  196. package/src/modules/bishop-exam.mjs +2 -2
  197. package/src/modules/bishop-plan.mjs +2 -2
  198. package/src/modules/bishop.mjs +9 -3
  199. package/src/modules/choices.mjs +2 -2
  200. package/src/modules/correo.mjs +2 -2
  201. package/src/modules/enlaces.mjs +2 -2
  202. package/src/modules/git-pulse.mjs +2 -2
  203. package/src/modules/github.mjs +2 -2
  204. package/src/modules/helpers.mjs +2 -2
  205. package/src/modules/image-studio.mjs +2 -2
  206. package/src/modules/index.mjs +92 -5
  207. package/src/modules/intents-calibration.mjs +2 -2
  208. package/src/modules/intents-desk.mjs +4 -3
  209. package/src/modules/intents-observe.mjs +2 -2
  210. package/src/modules/intents-policy.mjs +2 -2
  211. package/src/modules/intents-try.mjs +2 -2
  212. package/src/modules/intents.mjs +2 -2
  213. package/src/modules/local-models.mjs +41 -10
  214. package/src/modules/mcp-connect.mjs +2 -2
  215. package/src/modules/notes.mjs +281 -0
  216. package/src/modules/ollama.mjs +48 -13
  217. package/src/modules/playwright.mjs +16 -5
  218. package/src/modules/reminders.mjs +664 -0
  219. package/src/modules/ripley.mjs +3 -3
  220. package/src/modules/runs.mjs +2 -2
  221. package/src/modules/sdk.mjs +57 -9
  222. package/src/modules/updates.mjs +2 -2
  223. package/src/mother.mjs +13 -3
  224. package/src/npm-launch.mjs +2 -2
  225. package/src/ollama.mjs +8 -6
  226. package/src/opencode-health.mjs +83 -0
  227. package/src/outbound.mjs +35 -3
  228. package/src/override.mjs +27 -22
  229. package/src/ports.mjs +2 -2
  230. package/src/prices.mjs +2 -2
  231. package/src/privacy.mjs +2 -2
  232. package/src/quota-monitor.mjs +2 -2
  233. package/src/quota-sources.mjs +2 -2
  234. package/src/request-guard.mjs +2 -2
  235. package/src/review-ask.mjs +4 -3
  236. package/src/room/archivist.mjs +2 -2
  237. package/src/room/attachments.mjs +2 -2
  238. package/src/room/budget.mjs +2 -2
  239. package/src/room/context.mjs +2 -2
  240. package/src/room/control.mjs +2 -2
  241. package/src/room/copilot.mjs +2 -2
  242. package/src/room/economy.mjs +2 -2
  243. package/src/room/escalation.mjs +2 -2
  244. package/src/room/ghost.mjs +2 -2
  245. package/src/room/guard.mjs +6 -4
  246. package/src/room/prompt.mjs +3 -3
  247. package/src/room/returns.mjs +2 -2
  248. package/src/room/runs.mjs +6 -4
  249. package/src/room/vectors.mjs +2 -2
  250. package/src/room.mjs +144 -36
  251. package/src/router.mjs +2 -2
  252. package/src/runs.mjs +2 -2
  253. package/src/runtime-detection.mjs +36 -6
  254. package/src/salas.mjs +31 -6
  255. package/src/sentinel-errors.mjs +17 -7
  256. package/src/server-sentinel.mjs +2 -2
  257. package/src/server.mjs +980 -139
  258. package/src/setup-trouble.mjs +33 -0
  259. package/src/setup.mjs +4 -4
  260. package/src/smtp.mjs +2 -2
  261. package/src/telemetry.mjs +266 -0
  262. package/src/terms.mjs +43 -0
  263. package/src/tour.mjs +60 -7
  264. package/src/uninstall.mjs +225 -0
  265. package/src/updates.mjs +2 -2
  266. package/src/usage-sentinel.mjs +2 -2
  267. package/src/vault.mjs +2 -2
  268. package/src/verdict.mjs +13 -10
  269. package/src/whats-new.mjs +97 -3
  270. package/public/assets/abduction-cat-blink.png +0 -0
  271. package/public/assets/abduction-cat-control-left.png +0 -0
  272. package/public/assets/abduction-cat-control-right.png +0 -0
  273. package/public/assets/abduction-cat.png +0 -0
@@ -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
  // Intenciones, trying a cheaper rung on one message.
4
4
  //
5
5
  // Real use (intents-observe.mjs) can only vouch for the rungs the human actually uses. Somebody who
@@ -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
  // Intenciones: how hard each agent should think for the message being written.
4
4
  //
5
5
  // It reads the request, the conversation it belongs to and what this project has measured, and
@@ -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
  // What this computer can do with a local AI, measured and not assumed (2026-10-16).
4
4
  //
5
5
  // The local AI was sized for one machine: a 16 GB Mac ran a 3B model and trained a 1.5B one, and
@@ -24,14 +24,29 @@ const GB = 1024 ** 3;
24
24
  // One family, every size, so a recommendation is a step up or down a single ladder and a model
25
25
  // trained at one size is the same model at another. Qwen2.5 Instruct: multilingual (it answers in
26
26
  // the human's language), open weights, an Ollama tag and an MLX 4-bit build at every size.
27
+ // `sizeGb`: what Ollama downloads for it, as its library lists it (the welcome says it before).
27
28
  export const MODEL_TIERS = [
28
- { id: '0.5b', params: 0.5, label: 'Qwen2.5 0.5B', ollama: 'qwen2.5:0.5b', base: 'Qwen/Qwen2.5-0.5B-Instruct', runGb: 4, trainGb: 8 },
29
- { id: '1.5b', params: 1.5, label: 'Qwen2.5 1.5B', ollama: 'qwen2.5:1.5b', base: 'Qwen/Qwen2.5-1.5B-Instruct', runGb: 6, trainGb: 12 },
30
- { id: '3b', params: 3, label: 'Qwen2.5 3B', ollama: 'qwen2.5:3b', base: 'mlx-community/Qwen2.5-3B-Instruct-4bit', quantized: true, runGb: 8, trainGb: 16 },
31
- { id: '7b', params: 7, label: 'Qwen2.5 7B', ollama: 'qwen2.5:7b', base: 'mlx-community/Qwen2.5-7B-Instruct-4bit', quantized: true, runGb: 12, trainGb: 24 },
32
- { id: '14b', params: 14, label: 'Qwen2.5 14B', ollama: 'qwen2.5:14b', base: 'mlx-community/Qwen2.5-14B-Instruct-4bit', quantized: true, runGb: 20, trainGb: 36 },
33
- { id: '32b', params: 32, label: 'Qwen2.5 32B', ollama: 'qwen2.5:32b', base: 'mlx-community/Qwen2.5-32B-Instruct-4bit', quantized: true, runGb: 36, trainGb: 64 },
34
- { id: '72b', params: 72, label: 'Qwen2.5 72B', ollama: 'qwen2.5:72b', base: 'mlx-community/Qwen2.5-72B-Instruct-4bit', quantized: true, runGb: 64, trainGb: 128 },
29
+ { id: '0.5b', sizeGb: 0.4, params: 0.5, label: 'Qwen2.5 0.5B', ollama: 'qwen2.5:0.5b', base: 'Qwen/Qwen2.5-0.5B-Instruct', runGb: 4, trainGb: 8 },
30
+ { id: '1.5b', sizeGb: 1, params: 1.5, label: 'Qwen2.5 1.5B', ollama: 'qwen2.5:1.5b', base: 'Qwen/Qwen2.5-1.5B-Instruct', runGb: 6, trainGb: 12 },
31
+ { id: '3b', sizeGb: 1.9, params: 3, label: 'Qwen2.5 3B', ollama: 'qwen2.5:3b', base: 'mlx-community/Qwen2.5-3B-Instruct-4bit', quantized: true, runGb: 8, trainGb: 16 },
32
+ { id: '7b', sizeGb: 4.7, params: 7, label: 'Qwen2.5 7B', ollama: 'qwen2.5:7b', base: 'mlx-community/Qwen2.5-7B-Instruct-4bit', quantized: true, runGb: 12, trainGb: 24 },
33
+ { id: '14b', sizeGb: 9, params: 14, label: 'Qwen2.5 14B', ollama: 'qwen2.5:14b', base: 'mlx-community/Qwen2.5-14B-Instruct-4bit', quantized: true, runGb: 20, trainGb: 36 },
34
+ { id: '32b', sizeGb: 20, params: 32, label: 'Qwen2.5 32B', ollama: 'qwen2.5:32b', base: 'mlx-community/Qwen2.5-32B-Instruct-4bit', quantized: true, runGb: 36, trainGb: 64 },
35
+ { id: '72b', sizeGb: 47, params: 72, label: 'Qwen2.5 72B', ollama: 'qwen2.5:72b', base: 'mlx-community/Qwen2.5-72B-Instruct-4bit', quantized: true, runGb: 64, trainGb: 128 },
36
+ ];
37
+
38
+ // Other families a person may choose instead (2026-10-20). Qwen2.5 stays the ladder MADRE
39
+ // recommends and trains on; these run in Ollama with the same minimums and are only offered where
40
+ // they load. Their notes are said to a person, so they stay in plain words.
41
+ export const OTHER_MODELS = [
42
+ { ollama: 'llama3.2:1b', label: 'Llama 3.2 1B', maker: 'Meta', params: 1, runGb: 4, note: 'The smallest. For a computer with little memory.' },
43
+ { ollama: 'llama3.2:3b', label: 'Llama 3.2 3B', maker: 'Meta', params: 3, runGb: 8, note: 'Quick. Strongest in English.' },
44
+ { ollama: 'gemma3:4b', label: 'Gemma 3 4B', maker: 'Google', params: 4, runGb: 8, note: 'Quick, and good in many languages.' },
45
+ { ollama: 'mistral:7b', label: 'Mistral 7B', maker: 'Mistral AI', params: 7, runGb: 12, note: 'Balanced, for everyday work.' },
46
+ { ollama: 'llama3.1:8b', label: 'Llama 3.1 8B', maker: 'Meta', params: 8, runGb: 12, note: 'Balanced. Strongest in English.' },
47
+ { ollama: 'gemma3:12b', label: 'Gemma 3 12B', maker: 'Google', params: 12, runGb: 16, note: 'Careful answers in many languages.' },
48
+ { ollama: 'phi4:14b', label: 'Phi-4 14B', maker: 'Microsoft', params: 14, runGb: 20, note: 'Reasons well for its size.' },
49
+ { ollama: 'gemma3:27b', label: 'Gemma 3 27B', maker: 'Google', params: 27, runGb: 32, note: 'The largest of its family. Needs a lot of memory.' },
35
50
  ];
36
51
 
37
52
  // What the local AI does in MADRE, and the smallest model each one is worth turning on with. Below
@@ -60,7 +75,9 @@ export function parseNvidia(output) {
60
75
  export async function detectHardware({ platform = osPlatform(), arch = osArch(), totalmem = osTotalmem(), cpus = osCpus(), exec = execFile } = {}) {
61
76
  const memoryGb = Math.round(totalmem / GB);
62
77
  const cores = Array.isArray(cpus) ? cpus.length : 0;
63
- let chip = Array.isArray(cpus) && cpus[0]?.model ? String(cpus[0].model).trim() : null;
78
+ // On Linux ARM (a container, a Raspberry Pi) Node names the processor «unknown»: no name is better
79
+ // than a word in English the person cannot use (QA 1.1.0, NUE-02); the page then says the cores.
80
+ let chip = Array.isArray(cpus) && cpus[0]?.model && !/^unknown$/i.test(String(cpus[0].model).trim()) ? String(cpus[0].model).trim() : null;
64
81
  if (platform === 'darwin') {
65
82
  const brand = await run('sysctl', ['-n', 'machdep.cpu.brand_string'], { exec });
66
83
  if (brand?.trim()) chip = brand.trim();
@@ -116,6 +133,20 @@ export function hardwareFit(hardware) {
116
133
  return { hardware, usableGb: usable, accelerated, models, recommended: { run, train, largestRun }, features };
117
134
  }
118
135
 
136
+ // Every model a person may choose, each with whether it runs on this computer and which one MADRE
137
+ // recommends here: the Qwen2.5 ladder first, then the other families, smallest first.
138
+ export function modelCatalog(fit) {
139
+ const usable = fit?.usableGb ?? 0;
140
+ const accelerated = Boolean(fit?.accelerated);
141
+ const best = fit?.recommended?.run?.ollama ?? null;
142
+ const qwen = MODEL_TIERS.map((tier) => ({ ollama: tier.ollama, label: tier.label, maker: 'Alibaba', params: tier.params, runGb: tier.runGb, sizeGb: tier.sizeGb, note: 'Good in many languages. The family MADRE recommends and trains.' }));
143
+ return [...qwen, ...OTHER_MODELS].map((model) => ({
144
+ ...model,
145
+ run: usable >= model.runGb ? (accelerated ? 'yes' : 'slow') : 'no',
146
+ recommended: model.ollama === best,
147
+ }));
148
+ }
149
+
119
150
  let measured = null;
120
151
  // Read once per process: the hardware does not change under a running room.
121
152
  export function hardwareOnce(options) {
@@ -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
  // CONNECT MCP: MCP servers a person adds to one project, for its agents (2026-10-14).
4
4
  //
5
5
  // The settings live in the project's Settings › Connect MCP, and only there: this module has no
@@ -0,0 +1,281 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // Notes (0.1, 2026-10-20): colored notes on a project, each one a window of the room.
4
+ //
5
+ // A note is what a person writes for themself: no agent reads it, nothing is sent anywhere, and it
6
+ // does not go into the project's folder. They are kept beside the project's conversations, in
7
+ // ~/.pulse/rooms/<id>/notes.json, one file per project, written whole. The page
8
+ // draws each open note as a window of its own — the same windows every module has, moved by their
9
+ // head and sized by their edges — and remembers where it was left.
10
+ //
11
+ // ONE FILE (SDK 2, 2026-10-25): the notes, their file and the tool server an agent uses, with
12
+ // nothing imported from MADRE, so a newer Notes can come from the Market, signed, without waiting
13
+ // for a new MADRE (src/builtin-updates.mjs). Run with node, the same file is the tool server.
14
+
15
+ import { mkdir, open, readFile, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
16
+ import { dirname, join } from 'node:path';
17
+ import { randomUUID } from 'node:crypto';
18
+ import { fileURLToPath } from 'node:url';
19
+
20
+ const SELF = fileURLToPath(import.meta.url);
21
+
22
+ // FILES THAT MORE THAN ONE THING CHANGES (the same rules as MADRE's src/json-file.mjs): written
23
+ // whole, through a draft renamed over the file, and one change at a time — in this process by a
24
+ // queue, and between the rooms of this computer and the tool server by a lock file beside it.
25
+ async function writeWhole(file, text, { mode } = {}) {
26
+ await mkdir(dirname(file), { recursive: true });
27
+ const draft = `${file}.${process.pid}.${randomUUID()}.tmp`;
28
+ try {
29
+ await writeFile(draft, text, mode ? { mode } : undefined);
30
+ await rename(draft, file);
31
+ } catch (error) {
32
+ await rm(draft, { force: true }).catch(() => {});
33
+ throw error;
34
+ }
35
+ }
36
+
37
+ const STALE_MS = 5000;
38
+ async function lockBeside(file) {
39
+ const lock = `${file}.lock`;
40
+ await mkdir(dirname(lock), { recursive: true });
41
+ for (let attempt = 0; attempt < 250; attempt += 1) {
42
+ try {
43
+ await (await open(lock, 'wx')).close();
44
+ return () => rm(lock, { force: true });
45
+ } catch (error) {
46
+ if (error.code !== 'EEXIST') throw error;
47
+ const since = await stat(lock).catch(() => null);
48
+ if (since && Date.now() - since.mtimeMs > STALE_MS) { await rm(lock, { force: true }); continue; }
49
+ await new Promise((resolve) => setTimeout(resolve, 20));
50
+ }
51
+ }
52
+ throw new Error(`${file} is being changed by another room; try again.`);
53
+ }
54
+
55
+ const queues = new Map();
56
+ function oneAtATime(file, work) {
57
+ const run = async () => {
58
+ const release = await lockBeside(file);
59
+ try {
60
+ return await work();
61
+ } finally {
62
+ await release();
63
+ }
64
+ };
65
+ const before = queues.get(file) ?? Promise.resolve();
66
+ const turn = before.then(run, run);
67
+ const settled = turn.catch(() => {});
68
+ queues.set(file, settled);
69
+ void settled.then(() => { if (queues.get(file) === settled) queues.delete(file); });
70
+ return turn;
71
+ }
72
+
73
+ // A message that asks for a note (2026-10-20): «/notas …», «/notes …», «hazme una nota», «take a
74
+ // note». Only then is the tool handed to the turn: a tool in every turn costs its description in
75
+ // every prompt.
76
+ export const ASKS_FOR_NOTE = /(^|\s)\/(notas?|notes?)\b|\b(nota|notas|apunta|anota|note|notes|jot)\b/i;
77
+
78
+ export const NOTE_COLORS = ['yellow', 'green', 'blue', 'pink', 'purple', 'orange'];
79
+ export const NOTES_MAX = 200;
80
+ export const NOTE_TEXT_MAX = 20000;
81
+ const ID = /^[a-z0-9-]{6,64}$/i;
82
+ const notesFile = (roomDir) => join(roomDir, 'notes.json');
83
+ const number = (value, low, high) => (Number.isFinite(Number(value)) ? Math.round(Math.min(high, Math.max(low, Number(value)))) : null);
84
+
85
+ // Where a note was left on the page, as numbers that can be trusted, or nothing.
86
+ function boxOf(raw) {
87
+ if (!raw || typeof raw !== 'object') return null;
88
+ const box = { x: number(raw.x, -4000, 8000), y: number(raw.y, 0, 8000), w: number(raw.w, 160, 4000), h: number(raw.h, 120, 4000) };
89
+ return Object.values(box).every((value) => value !== null) ? box : null;
90
+ }
91
+ // One note read field by field: a file written by hand is read for what it says correctly.
92
+ function noteOf(raw) {
93
+ if (!raw || typeof raw !== 'object' || !ID.test(String(raw.id ?? ''))) return null;
94
+ const iso = (value) => (typeof value === 'string' && !Number.isNaN(Date.parse(value)) ? value : null);
95
+ return {
96
+ id: raw.id,
97
+ text: String(raw.text ?? '').slice(0, NOTE_TEXT_MAX),
98
+ color: NOTE_COLORS.includes(raw.color) ? raw.color : NOTE_COLORS[0],
99
+ open: raw.open !== false,
100
+ box: boxOf(raw.box),
101
+ at: iso(raw.at) ?? new Date(0).toISOString(),
102
+ };
103
+ }
104
+
105
+ export async function readNotes(roomDir) {
106
+ if (!roomDir) return [];
107
+ const raw = await readFile(notesFile(roomDir), 'utf8').then((text) => JSON.parse(text)).catch(() => null);
108
+ return (Array.isArray(raw?.notes) ? raw.notes : []).map(noteOf).filter(Boolean).slice(0, NOTES_MAX);
109
+ }
110
+ const writeNotes = (roomDir, notes) => writeWhole(notesFile(roomDir), `${JSON.stringify({ notes }, null, 2)}\n`);
111
+
112
+ // A new note, or a change to one: only what the change names moves.
113
+ export function saveNote(roomDir, change, now = new Date()) {
114
+ return oneAtATime(notesFile(roomDir), async () => {
115
+ const notes = await readNotes(roomDir);
116
+ const at = new Date(now).toISOString();
117
+ let note = change?.id ? notes.find((one) => one.id === change.id) : null;
118
+ if (change?.id && !note) return { error: 'unknown' };
119
+ if (!note) {
120
+ if (notes.length >= NOTES_MAX) return { error: 'full' };
121
+ note = { id: randomUUID(), text: '', color: NOTE_COLORS.includes(change?.color) ? change.color : NOTE_COLORS[0], open: true, box: null, at };
122
+ notes.push(note);
123
+ }
124
+ if (typeof change?.text === 'string') note.text = change.text.slice(0, NOTE_TEXT_MAX);
125
+ if (NOTE_COLORS.includes(change?.color)) note.color = change.color;
126
+ if (typeof change?.open === 'boolean') note.open = change.open;
127
+ if (change?.box !== undefined) note.box = boxOf(change.box);
128
+ note.at = at;
129
+ await writeNotes(roomDir, notes);
130
+ return { note };
131
+ });
132
+ }
133
+
134
+ export function deleteNote(roomDir, id) {
135
+ return oneAtATime(notesFile(roomDir), async () => {
136
+ const notes = await readNotes(roomDir);
137
+ const kept = notes.filter((one) => one.id !== id);
138
+ if (kept.length === notes.length) return { error: 'unknown' };
139
+ await writeNotes(roomDir, kept);
140
+ return { deleted: id };
141
+ });
142
+ }
143
+
144
+ const reply = (status, body) => ({ status, body });
145
+ // The room's words (ctx.t, SDK 2); outside a room — a test, the tool server — the English as written.
146
+ const say = (ctx, text, vars = null) => (typeof ctx?.t === 'function' ? ctx.t(text, vars) : String(text).replace(/\{(\w+)\}/g, (whole, name) => (vars && Object.hasOwn(vars, name) ? String(vars[name]) : whole)));
147
+ const on = (ctx) => Boolean(ctx.settings?.enabled);
148
+ const door = (ctx) => (on(ctx) ? null : reply(412, { error: say(ctx, 'Notes is off in this project. Turn it on in Modules.') }));
149
+
150
+ export default {
151
+ sdk: 2,
152
+ id: 'notes',
153
+ name: 'Notes',
154
+ vendor: 'MADRE',
155
+ version: '0.1.0',
156
+ summary: 'Colored notes on the project, each in a window you move and size as you like. Only you read them: no agent sees them and nothing leaves your computer.',
157
+ creates: ['nothing in the project', 'a notes.json file beside the project’s conversations, in ~/.pulse'],
158
+ settings: { enabled: false },
159
+ async status(ctx) {
160
+ const list = await readNotes(ctx.roomDir);
161
+ const enabled = Boolean(ctx.settings.enabled);
162
+ return {
163
+ status: { installed: enabled, detail: enabled ? (list.length === 1 ? say(ctx, '1 note in this project') : say(ctx, '{n} notes in this project', { n: list.length })) : say(ctx, 'off') },
164
+ install: { display: enabled ? 'turn off Notes' : 'turn on Notes', platforms: [] },
165
+ notes: list.length,
166
+ };
167
+ },
168
+ // An agent makes a note when the person asks for one (this same file, run as its tool server):
169
+ // it can only add.
170
+ async toolsForTurn(ctx, turn) {
171
+ if (!ctx.roomDir || (turn?.text !== undefined && !ASKS_FOR_NOTE.test(turn.text))) return [];
172
+ return [{
173
+ name: 'madre-notes',
174
+ command: process.execPath,
175
+ args: [SELF],
176
+ env: { PULSE_NOTES_DIR: ctx.roomDir },
177
+ tools: ['create_note'],
178
+ brief: 'When the person asks for a note (they may write /notas or /notes), make it with the create_note tool of server madre-notes: short, clear, in their language. It opens on their screen as a colored note. You cannot read their other notes.',
179
+ }];
180
+ },
181
+ routes: [
182
+ { method: 'GET', path: '/api/notes', handler: async (ctx) => door(ctx) ?? reply(200, { notes: await readNotes(ctx.roomDir), colors: NOTE_COLORS }) },
183
+ { method: 'POST', path: '/api/notes', handler: async (ctx, { payload }) => {
184
+ const closed = door(ctx);
185
+ if (closed) return closed;
186
+ const saved = await saveNote(ctx.roomDir, payload ?? {});
187
+ if (saved.error === 'unknown') return reply(404, { error: say(ctx, 'That note is no longer here.') });
188
+ if (saved.error === 'full') return reply(409, { error: say(ctx, 'This project already has {n} notes. Delete one to make room.', { n: NOTES_MAX }) });
189
+ return reply(200, saved);
190
+ } },
191
+ { method: 'POST', path: '/api/notes/delete', handler: async (ctx, { payload }) => {
192
+ const closed = door(ctx);
193
+ if (closed) return closed;
194
+ const gone = await deleteNote(ctx.roomDir, String(payload?.id ?? ''));
195
+ return gone.error ? reply(404, { error: say(ctx, 'That note is no longer here.') }) : reply(200, gone);
196
+ } },
197
+ ],
198
+ };
199
+
200
+ // THE TOOL SERVER (MCP over stdio, JSON-RPC 2.0), when an agent's turn runs this file with node:
201
+ // one tool, create_note. It only adds — it cannot read, change or delete the person's notes — and
202
+ // it writes the same file the page reads, beside the project's conversations.
203
+ //
204
+ // Environment:
205
+ // PULSE_NOTES_DIR the project's room folder (~/.pulse/rooms/<id>)
206
+ const SERVER_NAME = 'madre-notes';
207
+ const SERVER_VERSION = '2.0.0';
208
+ const NOTE_TOOL = {
209
+ name: 'create_note',
210
+ description: 'Make a note for the person: a colored note that opens as a window in their project. Use it when they ask for a note (they may write /notas or /notes). Write it for them, short and clear, in their language. You cannot read their other notes.',
211
+ inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'The note, as the person will read it.' }, color: { type: 'string', enum: NOTE_COLORS, description: 'Optional color.' } }, required: ['text'] },
212
+ };
213
+
214
+ async function createNote(args, env) {
215
+ const text = String(args.text ?? '').trim();
216
+ if (!text) throw new Error('The note needs its text.');
217
+ const saved = await saveNote(env.PULSE_NOTES_DIR, { text, color: NOTE_COLORS.includes(args.color) ? args.color : undefined });
218
+ if (saved.error === 'full') throw new Error('This project already has as many notes as it can keep. Ask the person to delete one.');
219
+ if (saved.error) throw new Error('The note was not saved.');
220
+ return `Note made (${saved.note.color}). It opens on the person's screen when your answer ends.`;
221
+ }
222
+
223
+ export function handleRequest(message, { env = process.env } = {}) {
224
+ const reply = (result) => ({ jsonrpc: '2.0', id: message.id, result });
225
+ const fail = (code, text) => ({ jsonrpc: '2.0', id: message.id, error: { code, message: text } });
226
+ const tools = env.PULSE_NOTES_DIR ? [NOTE_TOOL] : [];
227
+ switch (message.method) {
228
+ case 'initialize':
229
+ return Promise.resolve(reply({ protocolVersion: message.params?.protocolVersion ?? '2025-06-18', capabilities: { tools: {} }, serverInfo: { name: SERVER_NAME, version: SERVER_VERSION } }));
230
+ case 'notifications/initialized':
231
+ case 'initialized':
232
+ return Promise.resolve(null);
233
+ case 'ping':
234
+ return Promise.resolve(reply({}));
235
+ case 'tools/list':
236
+ return Promise.resolve(reply({ tools }));
237
+ case 'tools/call': {
238
+ const { name, arguments: args = {} } = message.params ?? {};
239
+ if (!tools.some((tool) => tool.name === name)) return Promise.resolve(fail(-32602, `Unknown tool: ${name}`));
240
+ return createNote(args, env)
241
+ .then((text) => reply({ content: [{ type: 'text', text }], isError: false }))
242
+ .catch((error) => reply({ content: [{ type: 'text', text: `Nothing was saved: ${error.message}` }], isError: true }));
243
+ }
244
+ default:
245
+ return Promise.resolve(message.id === undefined ? null : fail(-32601, `Method not found: ${message.method}`));
246
+ }
247
+ }
248
+
249
+ export function serve({ input = process.stdin, output = process.stdout, env = process.env } = {}) {
250
+ let buffer = '';
251
+ let pending = 0;
252
+ let ended = false;
253
+ const finish = () => { if (ended && pending === 0) process.exit(0); };
254
+ input.setEncoding('utf8');
255
+ input.on('data', (chunk) => {
256
+ buffer += chunk;
257
+ let index;
258
+ while ((index = buffer.indexOf('\n')) >= 0) {
259
+ const line = buffer.slice(0, index).trim();
260
+ buffer = buffer.slice(index + 1);
261
+ if (!line) continue;
262
+ let message;
263
+ try { message = JSON.parse(line); } catch { output.write(`${JSON.stringify({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } })}\n`); continue; }
264
+ pending += 1;
265
+ void handleRequest(message, { env })
266
+ .then((response) => { if (response) output.write(`${JSON.stringify(response)}\n`); })
267
+ .finally(() => { pending -= 1; finish(); });
268
+ }
269
+ });
270
+ input.on('end', () => { ended = true; finish(); });
271
+ }
272
+
273
+ // Both paths resolved before they are compared (WIN-004), as the other servers do.
274
+ const real = async (path) => (path ? realpath(path).catch(() => path) : null);
275
+ if (process.argv[1] && (await real(process.argv[1])) === (await real(SELF))) {
276
+ if (!process.env.PULSE_NOTES_DIR) {
277
+ process.stderr.write('PULSE_NOTES_DIR is required.\n');
278
+ process.exit(2);
279
+ }
280
+ serve();
281
+ }
@@ -1,46 +1,73 @@
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
  // OLLAMA: local intelligence. Embeddings and distillation on this machine when
4
4
  // Ollama runs. The server offers the wiring through ctx.services.ollama.
5
5
 
6
+ import { execFile } from 'node:child_process';
6
7
  import { defineModule } from './sdk.mjs';
7
8
  import { t } from '../i18n.mjs';
8
9
  import { findOnPath } from './helpers.mjs';
9
10
  import { RECOMMENDED } from '../ollama.mjs';
10
- import { hardwareOnce } from './local-models.mjs';
11
+ import { hardwareOnce, modelCatalog } from './local-models.mjs';
11
12
 
12
13
  // The chat model to pull is the one this computer runs well (local-models.mjs), not one size for
13
14
  // every machine; the embedding model is small enough for all of them. With the hardware, the page
14
15
  // says which sizes run here and which features of the local AI are worth turning on.
15
16
  export async function recommendedHere() {
16
17
  const fit = await hardwareOnce();
17
- return { ...RECOMMENDED, chat: fit.recommended.run?.ollama ?? RECOMMENDED.chat, hardware: fit };
18
+ return { ...RECOMMENDED, chat: fit.recommended.run?.ollama ?? RECOMMENDED.chat, hardware: fit, catalog: modelCatalog(fit) };
19
+ }
20
+
21
+ // On Linux the official script writes /usr/local and a systemd service, and when it is not root it
22
+ // asks sudo for both. MADRE runs it with no terminal, where sudo cannot ask for a password: it fails
23
+ // for a user who needs one and always for one who is not an administrator. So it runs here only as
24
+ // root or with sudo that needs no password; otherwise the command is handed over for a terminal.
25
+ // (Installing without root into ~/.local from Ollama's archive was weighed and left out: the archive
26
+ // changes format and size with each release, needs the GPU libraries beside it and a PATH the
27
+ // running MADRE does not see, and gives no service. One person keeps this; the script keeps itself.)
28
+ const LINUX_SCRIPT = 'curl -fsSL https://ollama.com/install.sh | sh';
29
+ const NEEDS_PASSWORD = "Ollama's install script needs the administrator password, and MADRE cannot ask for it. Run the command in a terminal, then press RECHECK.";
30
+
31
+ // `sudo -n true` answers at once: 0 when no password is needed, an error when one is (or when this
32
+ // user cannot use sudo at all). Asked once per run of MADRE; never with a terminal attached.
33
+ let sudoOnce = null;
34
+ export const sudoWithoutPassword = () => (sudoOnce ??= new Promise((resolve) => {
35
+ execFile('sudo', ['-n', 'true'], { timeout: 5000 }, (error) => resolve(!error));
36
+ }));
37
+
38
+ // Whether the Linux script can run from here. Elsewhere the question does not arise.
39
+ export async function adminHere({ platform = process.platform, uid = process.getuid?.() ?? null, sudo = sudoWithoutPassword } = {}) {
40
+ if (platform !== 'linux') return true;
41
+ if (uid === 0) return true;
42
+ return Boolean(await sudo());
18
43
  }
19
44
 
20
45
  // Ollama is not an npm package, so each system has its own way in. Where MADRE can run it, the
21
46
  // command is shown on the button before it runs; where it cannot, it hands over the download.
22
- export function ollamaInstallPlan({ platform = process.platform, brew = null } = {}) {
47
+ export function ollamaInstallPlan({ platform = process.platform, brew = null, admin = true } = {}) {
23
48
  if (platform === 'darwin') {
24
49
  return brew
25
50
  ? { command: brew, args: ['install', 'ollama'], display: 'brew install ollama', note: 'Installs Ollama with Homebrew, the package manager already on this computer.' }
26
51
  : { command: null, download: 'https://ollama.com/download', display: null, note: 'Homebrew is not on this computer. Download Ollama from ollama.com, open it once, and press RECHECK.' };
27
52
  }
28
53
  if (platform === 'linux') {
29
- return { command: 'sh', args: ['-c', 'curl -fsSL https://ollama.com/install.sh | sh'], display: 'curl -fsSL https://ollama.com/install.sh | sh', note: "Ollama's own install script, downloaded from ollama.com and run on this computer." };
54
+ if (!admin) return { command: null, manual: true, display: LINUX_SCRIPT, note: t(NEEDS_PASSWORD) };
55
+ return { command: 'sh', args: ['-c', LINUX_SCRIPT], display: LINUX_SCRIPT, note: "Ollama's own install script, downloaded from ollama.com and run on this computer." };
30
56
  }
31
57
  return { command: null, download: 'https://ollama.com/download', display: null, note: 'Download the Ollama installer from ollama.com, run it, and press RECHECK.' };
32
58
  }
33
59
 
34
60
  // A newer Ollama. Where MADRE can do it, the command is shown before it runs; where it cannot,
35
61
  // it hands over the download rather than pretending.
36
- export function ollamaUpdatePlan({ platform = process.platform, brew = null } = {}) {
62
+ export function ollamaUpdatePlan({ platform = process.platform, brew = null, admin = true } = {}) {
37
63
  if (platform === 'darwin') {
38
64
  return brew
39
65
  ? { command: brew, args: ['upgrade', 'ollama'], display: 'brew upgrade ollama', note: 'Upgrades Ollama with Homebrew. Your models stay where they are.' }
40
66
  : { command: null, download: 'https://ollama.com/download', display: null, note: 'Ollama was not installed with Homebrew. Download the newer one from ollama.com, open it once, and press RECHECK. Your models stay where they are.' };
41
67
  }
42
68
  if (platform === 'linux') {
43
- return { command: 'sh', args: ['-c', 'curl -fsSL https://ollama.com/install.sh | sh'], display: 'curl -fsSL https://ollama.com/install.sh | sh', note: "Ollama's own install script upgrades in place. Your models stay where they are." };
69
+ if (!admin) return { command: null, manual: true, display: LINUX_SCRIPT, note: `${t(NEEDS_PASSWORD)} ${t('Your models stay where they are.')}` };
70
+ return { command: 'sh', args: ['-c', LINUX_SCRIPT], display: LINUX_SCRIPT, note: "Ollama's own install script upgrades in place. Your models stay where they are." };
44
71
  }
45
72
  return { command: null, download: 'https://ollama.com/download', display: null, note: 'Download the newer Ollama from ollama.com and run it. Your models stay where they are.' };
46
73
  }
@@ -52,13 +79,15 @@ export const ollamaStartPlan = () => ({ command: 'ollama', args: ['serve'], disp
52
79
  // computer, and the one step that moves it forward. The card and the routes share this.
53
80
  export async function ollamaView(probe, settings) {
54
81
  const binary = await findOnPath('ollama');
55
- return { ...probe, settings, binary, install: ollamaInstallPlan({ brew: await findOnPath('brew') }), start: ollamaStartPlan() };
82
+ // The sudo question is only worth asking while there is something to install.
83
+ const admin = binary ? true : await adminHere();
84
+ return { ...probe, settings, binary, install: ollamaInstallPlan({ brew: await findOnPath('brew'), admin }), start: ollamaStartPlan() };
56
85
  }
57
86
 
58
87
  export default defineModule({
59
88
  id: 'ollama',
60
89
  name: 'Local AI',
61
- vendor: 'MADRE · LOCAL INTELLIGENCE',
90
+ vendor: 'MADRE · Local AI',
62
91
  tracks: { name: 'ollama', github: 'ollama/ollama' },
63
92
  summary: 'Searches and sums up the project\'s memory with local AI (Ollama): free, and nothing leaves your computer.',
64
93
  creates: ['nothing in the project', 'a block in ~/.pulse/config.json', 'models in Ollama\'s own store when you press PULL'],
@@ -83,13 +112,13 @@ export default defineModule({
83
112
  status: { installed: settings.enabled && project.on && probe.running && roles.length > 0, detail },
84
113
  ollama: { ...view, project },
85
114
  recommended: await recommendedHere(),
86
- preflight: probe.running ? { ok: true, problems: [] } : { ok: false, problems: ['Ollama is not running: open the Ollama app or run `ollama serve`, then RECHECK.'] },
115
+ preflight: probe.running ? { ok: true, problems: [] } : { ok: false, problems: ['Ollama is not running: open the Ollama app or run `ollama serve`, then check again.'] },
87
116
  install: { display: settings.enabled ? 'disable Ollama' : 'enable Ollama (config.json)', platforms: [] },
88
117
  };
89
118
  },
90
119
  async updatePlan(ctx) {
91
120
  const { findOnPath } = await import('./helpers.mjs');
92
- const plan = ollamaUpdatePlan({ brew: await findOnPath('brew') });
121
+ const plan = ollamaUpdatePlan({ brew: await findOnPath('brew'), admin: await adminHere() });
93
122
  if (!plan.command) return plan;
94
123
  // Upgrading replaces the binary, not the server already running: until it restarts, the old
95
124
  // version keeps answering. Said before the button is pressed, done after the command.
@@ -122,12 +151,18 @@ export default defineModule({
122
151
  } },
123
152
  { method: 'POST', path: '/api/ollama/install', handler: async (ctx) => {
124
153
  const started = await ctx.services.ollama.install();
125
- return started.ok ? { status: 202, body: { installing: true, command: started.command } } : { status: started.download ? 412 : 409, body: { error: started.error, download: started.download ?? null } };
154
+ return started.ok ? { status: 202, body: { installing: true, command: started.command } } : { status: started.download || started.manual ? 412 : 409, body: { error: started.error, download: started.download ?? null, manual: started.manual ?? null } };
126
155
  } },
127
156
  { method: 'POST', path: '/api/ollama/start', handler: async (ctx) => {
128
157
  const started = await ctx.services.ollama.start();
129
158
  return started.ok ? { status: 200, body: { ollama: ctx.services.ollama.state() } } : { status: 412, body: { error: started.error } };
130
159
  } },
160
+ // Stops the download running now (the welcome's «Cancel»). What Ollama already wrote stays, and
161
+ // pulling the same model again goes on from there.
162
+ { method: 'POST', path: '/api/ollama/pull/cancel', handler: async (ctx, { payload }) => {
163
+ const stopped = ctx.services.ollama.cancelPull?.(typeof payload?.model === 'string' ? payload.model : null) ?? { ok: false };
164
+ return stopped.ok ? { status: 200, body: { cancelling: stopped.model } } : { status: 409, body: { error: stopped.error } };
165
+ } },
131
166
  { method: 'POST', path: '/api/ollama/pull', handler: async (ctx, { payload }) => {
132
167
  const model = String(payload.model ?? '').trim();
133
168
  if (!/^[a-z0-9][a-z0-9._:/-]{1,80}$/i.test(model)) return { status: 400, body: { error: 'Give a model name like nomic-embed-text or qwen2.5:3b.' } };
@@ -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
  // PLAYWRIGHT: a headless browser for the crew, pointed only at this MADRE. Agents open the
4
4
  // RIPLEY preview of project files, click, read the console and take screenshots into the turn's
5
5
  // scratch folder. Runs @playwright/mcp per turn, isolated, with allowed origins limited to the
@@ -219,7 +219,16 @@ export default defineModule({
219
219
  card: 'switch',
220
220
  controls: [
221
221
  { key: 'browser', label: 'BROWSER', type: 'select', options: PLAYWRIGHT_BROWSERS, note: 'Which browser engine the agents drive.' },
222
- { key: 'headless', label: 'SHOW THE WINDOW', type: 'switch', invert: true, note: 'Off, the browser runs headless. On, it opens on this screen so you can watch.' },
222
+ // Nothing opens the moment it is switched on: the window comes with the next agent that opens
223
+ // the page, and the person is told so, and how to try it (2026-10-20).
224
+ {
225
+ key: 'headless', label: 'SHOW THE WINDOW', type: 'switch', invert: true,
226
+ note: 'Off, the browser works without a window. On, the next time an agent opens your page, you see its window on this screen.',
227
+ said: {
228
+ on: 'Done. The next time an agent opens your page, its window opens on this screen. To try it, ask: «open the page and tell me what you see».',
229
+ off: 'Done. The browser works without a window again.',
230
+ },
231
+ },
223
232
  ],
224
233
  async status(ctx) {
225
234
  const version = await playwrightVersion({ env: ctx.env, projectRoot: ctx.projectRoot });
@@ -227,8 +236,10 @@ export default defineModule({
227
236
  return {
228
237
  runs: [{ name: PLAYWRIGHT_PACKAGE, version }],
229
238
  settings: { browser: ctx.settings.browser ?? 'chromium', headless: ctx.settings.headless !== false },
230
- status: { installed: Boolean(ctx.settings.enabled), detail: ctx.settings.enabled ? (!version ? t('on · the browser server is not installed') : health?.ok === false ? t('on · the browser does not start: {problem}. Turn it off and on again: MADRE downloads what is missing.', { problem: String(health.problem).replace(/[.\s]+$/, '').slice(0, 160) }) : `${t('on')} · ${ctx.settings.browser}`) : version ? t('off') : t('off · the browser server is not installed') },
231
- preflight: version ? { ok: true, problems: [] } : { ok: false, problems: [`Install the browser server first: npm install -g @playwright/mcp, then its browser: ${installBrowserLine(ctx.settings.browser)}`] },
239
+ status: { installed: Boolean(ctx.settings.enabled), detail: ctx.settings.enabled ? (!version ? t('on · the browser server is not installed') : health?.ok === false ? t('on · the browser does not start: {problem}. Turn it off and on again: MADRE downloads what is missing.', { problem: String(health.problem).replace(/[.\s]+$/, '').slice(0, 160) }) : `${t('on')} · ${ctx.settings.browser}`) : version ? t('off') : process.platform === 'win32' ? t('off · the browser server is not installed') : t('off · turn it on and MADRE installs its browser; it takes a few minutes') },
240
+ // Missing is not a reason to refuse the switch: turning it on installs what is missing
241
+ // (playwrightReady) everywhere but Windows (2026-10-20). Only there does the person install it.
242
+ preflight: version || process.platform !== 'win32' ? { ok: true, problems: [] } : { ok: false, problems: [t('Install the browser server first: {server}, then its browser: {browser}', { server: 'npm install -g @playwright/mcp', browser: installBrowserLine(ctx.settings.browser) })] },
232
243
  install: { display: ctx.settings.enabled ? 'disable PLAYWRIGHT' : 'enable PLAYWRIGHT (config.json)', platforms: ['codex', 'claude', 'gemini', 'opencode'] },
233
244
  };
234
245
  },