@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
package/src/mcp/proxy.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // SPDX-License-Identifier: AGPL-3.0-only
3
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
4
4
  // The one MCP server every CLI starts for a server a person connected (src/mcp/connect.mjs).
5
5
  //
6
6
  // node proxy.mjs --state <stateRoot> --project <projectRoot> --server <id> [--allow a,b,c]
@@ -114,18 +114,29 @@ async function viaHttp(server) {
114
114
  const reader = response.body.getReader();
115
115
  const decoder = new TextDecoder();
116
116
  let buffer = '';
117
- for (;;) {
117
+ // A server may keep the stream open after it answered (DeepWiki does, 2026-10-20): read until
118
+ // the answer to this request arrives, then let the stream go, or every message after it waits.
119
+ const asked = message.id !== undefined && message.id !== null;
120
+ let answered = false;
121
+ while (!answered) {
118
122
  const { value, done } = await reader.read();
119
123
  if (done) break;
120
- buffer += decoder.decode(value, { stream: true });
124
+ buffer += decoder.decode(value, { stream: true }).replace(/\r\n/g, '\n');
121
125
  for (let end = buffer.indexOf('\n\n'); end >= 0; end = buffer.indexOf('\n\n')) {
122
126
  const event = buffer.slice(0, end);
123
127
  buffer = buffer.slice(end + 2);
124
128
  const data = event.split('\n').filter((line) => line.startsWith('data:')).map((line) => line.slice(5).trimStart()).join('\n');
125
129
  if (!data) continue;
126
- try { const out = JSON.parse(data); for (const one of Array.isArray(out) ? out : [out]) deliver(one); } catch { /* not a message */ }
130
+ try {
131
+ const out = JSON.parse(data);
132
+ for (const one of Array.isArray(out) ? out : [out]) {
133
+ deliver(one);
134
+ if (asked && one?.id === message.id && ('result' in one || 'error' in one)) answered = true;
135
+ }
136
+ } catch { /* not a message */ }
127
137
  }
128
138
  }
139
+ if (answered) await reader.cancel().catch(() => {});
129
140
  return;
130
141
  }
131
142
  const out = await response.json().catch(() => null);
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // SPDX-License-Identifier: AGPL-3.0-only
3
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
4
4
  // MADRE CORREO: a tiny MCP server (stdio, JSON-RPC 2.0) exposing one tool, send_email, that
5
5
  // hands one message to the user's own mail provider over SMTP+TLS with the user's own app
6
6
  // password. There is no MADRE in the middle: this process talks to smtp.gmail.com (or whatever
@@ -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 the MEMORY dashboard draws, shaped from counts the archive already keeps.
4
4
  //
5
5
  // Pure functions. The room hands in `RoomMemory#activity()` and the stats it already reports;
@@ -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
  import { fileURLToPath } from 'node:url';
4
4
 
5
5
  // How MADRE attaches the room's memory to a CLI as an MCP server, every turn:
package/src/memory.mjs CHANGED
@@ -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
  // MADRE's durable room memory, two layers in one SQLite file next to the ledger.
4
4
  // entries everything ever said in the room outside GHOST, indexed for
5
5
  // full-text recall: exact quotes handed to a turn when they match.
package/src/models.mjs CHANGED
@@ -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
  import { readFile } from 'node:fs/promises';
4
4
  import { homedir } from 'node:os';
5
5
  import { join } from 'node:path';
@@ -10,26 +10,32 @@ import { OPENCODE_PROVIDERS } from './credentials.mjs';
10
10
  // list) plus the aliases each vendor documents. Users can add their own in
11
11
  // ~/.pulse/config.json under "models".
12
12
 
13
+ export const CURSOR_FREE_NOTE = 'Your Cursor plan answers only with Auto: the other models need a paid plan.';
13
14
  export const KNOWN_MODELS = {
14
15
  codex: {
15
16
  defaults: ['gpt-5.6-sol', 'gpt-5.6-luna', 'gpt-5.6-terra', 'gpt-5.5'],
16
- note: 'Names from ~/.codex/models_cache.json; the CLI default comes from ~/.codex/config.toml.',
17
+ note: 'The models your plan offers in Codex. «default» is the one Codex uses on its own.',
17
18
  },
18
19
  claude: {
19
20
  defaults: ['fable', 'opus', 'sonnet', 'haiku'],
20
- note: 'Aliases resolve to the latest model of each family (e.g. fable → claude-fable-5-1). Full names also work.',
21
+ note: 'Each name is the newest model of its family that your Claude plan offers. You can also write a full model name.',
21
22
  },
23
+ // Read from Google with the Gemini key when there is one (2026-10-21); these when there is not.
24
+ // No 2.5: Google no longer gives it to new accounts, and a name that fails is worse than none.
22
25
  gemini: {
23
- defaults: ['auto', 'gemini-3-pro-preview', 'gemini-3-flash-preview', 'gemini-2.5-pro', 'gemini-2.5-flash'],
24
- note: '"auto" lets Gemini CLI route between pro and flash.',
26
+ defaults: ['auto', 'gemini-3-pro-preview', 'gemini-3-flash-preview'],
27
+ note: '«auto» lets Gemini choose between its fast model and its strongest one. The others are the ones your Gemini key opens.',
28
+ unread: 'These are the usual ones. Signed in with a Gemini API key, MADRE shows the ones your account opens.',
25
29
  },
26
30
  opencode: {
27
31
  defaults: [],
28
32
  note: 'provider/model, from `opencode models`. The room default is PULSE_OPENCODE_MODEL.',
29
33
  },
34
+ // Read from the account itself (`cursor-agent --list-models`, 2026-10-21); «auto» alone when it
35
+ // cannot be read. The four names that stood here were long gone from Cursor's list.
30
36
  cursor: {
31
- defaults: ['auto', 'sonnet-4', 'sonnet-4-thinking', 'gpt-5'],
32
- note: '"auto" lets Cursor choose. `cursor-agent --list-models` names the ones your account has; the room default is PULSE_CURSOR_MODEL.',
37
+ defaults: ['auto'],
38
+ note: '«auto» lets Cursor choose. The others are the ones your Cursor account lists; a free plan answers only with Auto.',
33
39
  },
34
40
  };
35
41
 
@@ -121,6 +127,31 @@ export function parseCodexEfforts(json) {
121
127
  }
122
128
  }
123
129
 
130
+ // What each Codex model can do, from the same cache, for the line under its name in the chooser
131
+ // (2026-10-27): whether it reads images, how much it holds at once, and whether it has a fast tier.
132
+ // Only what the cache says; a model it does not describe gets nothing.
133
+ export function parseCodexAbout(json) {
134
+ try {
135
+ const data = JSON.parse(json);
136
+ const about = {};
137
+ const walk = (node) => {
138
+ if (!node || typeof node !== 'object') return;
139
+ if (typeof node.slug === 'string' && (Array.isArray(node.input_modalities) || Number.isFinite(node.context_window))) {
140
+ about[node.slug] = {
141
+ images: Array.isArray(node.input_modalities) && node.input_modalities.includes('image'),
142
+ ...(Number.isFinite(node.context_window) && node.context_window > 0 ? { context: node.context_window } : {}),
143
+ fast: Array.isArray(node.additional_speed_tiers) && node.additional_speed_tiers.includes('fast'),
144
+ };
145
+ }
146
+ for (const value of Object.values(node)) walk(value);
147
+ };
148
+ walk(data);
149
+ return about;
150
+ } catch {
151
+ return {};
152
+ }
153
+ }
154
+
124
155
  // The levels one Codex model takes: its own, from the cache; for a name the cache does not list,
125
156
  // the ones every listed model shares, so a model MADRE cannot read never meets a refusal.
126
157
  export function codexLevels(byModel, model) {
@@ -154,7 +185,42 @@ export function isValidModelName(name) {
154
185
 
155
186
  const unique = (list) => [...new Set(list.filter(isValidModelName))];
156
187
 
157
- export async function discoverModels({ agents = [], config = {}, home = homedir(), listOpenCode = async () => [] } = {}) {
188
+ // Google's list for a Gemini key (`GET v1beta/models`): the models that converse, by their short
189
+ // names, «auto» first — the Gemini CLI's own routing. Embedding, image, voice, live and the
190
+ // computer-use models are for other work and are left out.
191
+ const GEMINI_NOT_CHAT = /embedding|image|imagen|nano-banana|tts|audio|transcribe|live|computer-use|customtools|robotics|aqa|veo|gemma/i;
192
+ // The order a person looks for: the «latest» names, then newest first, and in each version the
193
+ // strongest first (pro, then flash, then lite).
194
+ const geminiRank = (name) => {
195
+ const version = /latest/.test(name) ? 999 : Number(name.match(/gemini-(\d+(?:\.\d+)?)/)?.[1] ?? 0);
196
+ const tier = /lite/.test(name) ? 2 : /flash/.test(name) ? 1 : 0;
197
+ return [version, tier];
198
+ };
199
+ export function parseGeminiModels(json) {
200
+ let data = json;
201
+ if (typeof json === 'string') { try { data = JSON.parse(json); } catch { return []; } }
202
+ const names = [];
203
+ for (const one of Array.isArray(data?.models) ? data.models : []) {
204
+ const name = String(one?.name ?? '').replace(/^models\//, '');
205
+ if (!/^gemini-/.test(name) || GEMINI_NOT_CHAT.test(name) || !isValidModelName(name)) continue;
206
+ if (Array.isArray(one.supportedGenerationMethods) && !one.supportedGenerationMethods.includes('generateContent')) continue;
207
+ if (!names.includes(name)) names.push(name);
208
+ }
209
+ names.sort((a, b) => { const [va, ta] = geminiRank(a); const [vb, tb] = geminiRank(b); return vb - va || ta - tb || a.localeCompare(b); });
210
+ return names.length ? ['auto', ...names] : [];
211
+ }
212
+
213
+ // `cursor-agent --list-models` prints «id - Label» a line, after a heading: the ids, «auto» first.
214
+ export function parseCursorModels(text) {
215
+ const ids = [];
216
+ for (const line of String(text ?? '').split('\n')) {
217
+ const found = line.match(/^\s*([A-Za-z0-9][\w.:[\]-]*)\s+-\s+\S/);
218
+ if (found && isValidModelName(found[1]) && !ids.includes(found[1])) ids.push(found[1]);
219
+ }
220
+ return ids.includes('auto') ? ['auto', ...ids.filter((id) => id !== 'auto')] : ids;
221
+ }
222
+
223
+ export async function discoverModels({ agents = [], config = {}, home = homedir(), listOpenCode = async () => [], listCursor = async () => [], cursorOnlyAuto = () => false, listGemini = async () => [] } = {}) {
158
224
  const result = {};
159
225
  for (const agent of agents) {
160
226
  const known = KNOWN_MODELS[agent.id] ?? { defaults: [], note: '' };
@@ -164,8 +230,12 @@ export async function discoverModels({ agents = [], config = {}, home = homedir(
164
230
  let efforts = EFFORTS[agent.id] ?? [];
165
231
  let effortsByModel;
166
232
  let effortsShared;
233
+ let about;
167
234
  if (agent.id === 'codex') {
168
- discovered = parseCodexModelCache(await readFile(join(home, '.codex', 'models_cache.json'), 'utf8').catch(() => ''));
235
+ const cache = await readFile(join(home, '.codex', 'models_cache.json'), 'utf8').catch(() => '');
236
+ discovered = parseCodexModelCache(cache);
237
+ about = parseCodexAbout(cache);
238
+ if (!Object.keys(about).length) about = undefined;
169
239
  const read = await readCodexEfforts({ home });
170
240
  cliDefault = read.model;
171
241
  effortDefault = read.effort;
@@ -197,6 +267,11 @@ export async function discoverModels({ agents = [], config = {}, home = homedir(
197
267
  }
198
268
  }
199
269
  }
270
+ if (agent.id === 'gemini' && agent.detected) discovered = await listGemini(agent).catch(() => []);
271
+ if (agent.id === 'cursor' && agent.detected) {
272
+ // A free plan refuses every named model (adapters/cursor.mjs): then Auto is all there is.
273
+ discovered = cursorOnlyAuto() ? ['auto'] : await listCursor(agent).catch(() => []);
274
+ }
200
275
  const custom = Array.isArray(config.models?.[agent.id]) ? config.models[agent.id] : [];
201
276
  // OpenCode speaks to many providers: what `opencode models` lists is already only the ones
202
277
  // signed in plus OpenCode's own. The person may hide a provider from the chooser (AJUSTES ›
@@ -207,15 +282,21 @@ export async function discoverModels({ agents = [], config = {}, home = homedir(
207
282
  discovered = discovered.filter((name) => !hidden.has(providerOf(name)));
208
283
  groups = groupOpenCode(unique([...custom, ...discovered]));
209
284
  }
285
+ if (agent.id === 'cursor' && discovered.length > 1) groups = groupCursor(unique([...custom, ...discovered]));
210
286
  result[agent.id] = {
211
287
  ...(groups ? { groups } : {}),
212
- models: unique([...custom, ...discovered, ...known.defaults]),
288
+ // What the account itself lists, when it can be read, is the whole choice: the names written
289
+ // here are only for a CLI that cannot say (2026-10-21). Added to it, they offered models the
290
+ // plan did not have, and a turn that failed on them.
291
+ models: unique([...custom, ...(discovered.length ? discovered : known.defaults)]),
213
292
  default: cliDefault,
214
- note: known.note,
293
+ note: agent.id === 'cursor' && cursorOnlyAuto() ? CURSOR_FREE_NOTE : !discovered.length && known.unread ? known.unread : known.note,
215
294
  efforts,
216
295
  effortDefault: isValidEffort(agent.id, effortDefault) ? effortDefault : null,
217
296
  ...(effortsByModel ? { effortsByModel, effortsShared } : {}),
297
+ ...(about ? { about } : {}),
218
298
  source: discovered.length ? 'discovered' : 'known',
299
+ ...(agent.id === 'cursor' && cursorOnlyAuto() ? { onlyAuto: true } : {}),
219
300
  };
220
301
  }
221
302
  return result;
@@ -256,6 +337,28 @@ export function providerLabel(id) {
256
337
  return id.split(/[-_.]/).map((part) => (part ? part[0].toUpperCase() + part.slice(1) : part)).join(' ');
257
338
  }
258
339
  // Groups in a steady order: the providers with a key first, by name; OpenCode's own models last.
340
+ // Cursor lists every model of every house, each in several speeds (265 on 2026-10-21): shown under
341
+ // the house it comes from, Cursor's own first, so the chooser can be read.
342
+ const CURSOR_HOUSES = [
343
+ ['cursor', 'Cursor', /^(auto|composer|cursor-small)/],
344
+ ['openai', 'OpenAI', /^(gpt|o\d|codex)/],
345
+ ['anthropic', 'Anthropic', /^claude/],
346
+ ['google', 'Google', /^gemini/],
347
+ ['xai', 'xAI', /^(cursor-)?grok/],
348
+ ['deepseek', 'DeepSeek', /^deepseek/],
349
+ ['moonshot', 'Moonshot', /^kimi/],
350
+ ];
351
+ export function groupCursor(names = []) {
352
+ const groups = new Map();
353
+ for (const name of names) {
354
+ const [id, label] = CURSOR_HOUSES.find(([, , test]) => test.test(name)) ?? ['other', 'Other'];
355
+ if (!groups.has(id)) groups.set(id, { id, label, own: id === 'cursor', models: [] });
356
+ groups.get(id).models.push(name);
357
+ }
358
+ const order = [...CURSOR_HOUSES.map(([id]) => id), 'other'];
359
+ return [...groups.values()].sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
360
+ }
361
+
259
362
  export function groupOpenCode(names = []) {
260
363
  const byProvider = new Map();
261
364
  for (const name of names) {
@@ -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
  // Which projects a module is on in (2026-10-18, with the Market).
4
4
  //
5
5
  // A module's switch lived in ~/.pulse/config.json, which every project reads, so turning one on in
@@ -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
  // AHP+: the one module that writes into the project, through a confirmed npx
4
4
  // command. Verified project state, checkpoints and handoffs in .ahp/.
5
5
 
@@ -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
  // Ash changes only the requested shape of an answer. This policy is pure and local: it neither
4
4
  // rewrites the human's request nor changes model, context, tools or permissions.
5
5
 
@@ -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
  // Ash: MADRE's token economy.
4
4
  //
5
5
  // It used to be a text compressor that rewrote the human's message before sending it. That was
@@ -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
  // D-S18 · the exam a local model passes before the Coordinator gives orders through it.
4
4
  //
5
5
  // With @madre the Coordinator only answered (S-030): a small local model invents and copies
@@ -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
  // BISHOP's plans, without the room around them (docs/MACROVERSO.md, fases 4b y 4c): the block a
4
4
  // reply ends with, what each of its lines means on this Mac, and the record the buttons act on.
5
5
  // Nothing here sends, signs or starts anything; src/modules/bishop.mjs does, after a human press
@@ -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
  // BISHOP lives in the room of Salas (docs/MACROVERSO.md). What it knows of the fleet — the
4
4
  // governance (contracts), the context (census) and the memories of the linked rooms — lives there,
5
5
  // in the Macroverso's room, and nowhere else:
@@ -643,7 +643,13 @@ export function formatBishop({ rooms, glances = new Map(), contracts = [], links
643
643
  `Órdenes: hasta 4, «@sala/agente #0-#2: tarea», solo a salas con órdenes${crew.length ? `; agentes: ${crew.join(', ')}` : ''}. Enlaces: hasta 2, «enlace A → B: tipos» (A entrega, B lee; ↔ las dos; «; órdenes #1» solo con salas). Si una pregunta necesita una sala sin enlace, propón el enlace. ${signer === 'bishop' ? 'Un enlace de solo lectura lo firmas tú al proponerlo (7 días como máximo); uno con órdenes lo firma el humano.' : 'Todo enlace lo firma el humano.'} Las órdenes son botones del humano salvo lo que su modo deja salir. #3/#4 solo como propuesta. ${never}`,
644
644
  ].join('\n');
645
645
  }
646
- const lines = [lead, 'Contratos vigentes:'];
646
+ // Said to the person in their words, and honest about what it cannot read (QA 1.1.0, NUE-32): with
647
+ // nothing linked, @madre answered «no se discutió ningún proyecto… no hay contratos vigentes»
648
+ // while the census counted two decisions.
649
+ const lines = [lead,
650
+ 'A la persona: «proyecto», no «sala»; «conexión», no «contrato».',
651
+ 'No niegues lo que no lees: si el censo cuenta decisiones de un proyecto sin conexión, dilo y propón conectarlo.',
652
+ 'Contratos vigentes:'];
647
653
  for (const contract of contracts) {
648
654
  const a = names.get(contract.rooms.a) ?? clean(contract.rooms.a, 40);
649
655
  const b = names.get(contract.rooms.b) ?? clean(contract.rooms.b, 40);
@@ -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
  // Choices: letting an agent put a decision to the human instead of taking it.
4
4
  //
5
5
  // An agent that has to pick between three or more real options has two honest ways out: name the
@@ -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
  // CORREO: MADRE's first connector. It gives a turn one tool, send_email, that hands a message to
4
4
  // the human's own mail account over SMTP+TLS, with the human's own app password.
5
5
  //
@@ -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
  // ENLACES (docs/MACROVERSO.md, fase 3c): what other rooms on this Mac know, when a signed link
4
4
  // lets this room read it. The link itself — the contract, the key of the channel, the room that
5
5
  // serves and its locks — lives in src/enlaces.mjs and in the ENLACES section of src/server.mjs.
@@ -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
  // Git Pulse: /git in the composer brings the repository's facts into the room.
4
4
  // Nothing to switch: it is on wherever the project is a git repository.
5
5
 
@@ -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
  // GITHUB: the GitHub side of this project, in the room. /gh reads the open pull requests, the CI of
4
4
  // the branch you are on and the open issues as a card everyone reads, agents included; and it
5
5
  // opens a pull request, an issue or a comment the way /git push sends commits — the first call
@@ -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
  import { execFile } from 'node:child_process';
4
4
  import { access, readFile, realpath } from 'node:fs/promises';
5
5
  import { delimiter, join } from 'node:path';
@@ -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
  // Image Studio: MADRE's own MCP image server on the Gemini image models, for
4
4
  // the CLIs that cannot draw natively. A switch and a model in config.json.
5
5
 
@@ -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
  // The registry. Order is the order MODULES shows. MADRE's own modules first; then the
4
4
  // human's, loaded from ~/.pulse/modules/*.mjs (every project) and <project>/.madre/modules/*.mjs
5
5
  // (this project). An external module is a file whose default export is a plain spec object
@@ -18,6 +18,8 @@ import gitPulse from './git-pulse.mjs';
18
18
  import ash from './ash.mjs';
19
19
  import intents from './intents.mjs';
20
20
  import choices from './choices.mjs';
21
+ import notes from './notes.mjs';
22
+ import reminders from './reminders.mjs';
21
23
  import runs from './runs.mjs';
22
24
  import ripley from './ripley.mjs';
23
25
  import ollama from './ollama.mjs';
@@ -28,7 +30,8 @@ import enlaces from './enlaces.mjs';
28
30
  import bishop from './bishop.mjs';
29
31
  import mcpConnect from './mcp-connect.mjs';
30
32
  import { isSalasRoom } from '../salas.mjs';
31
- import { defineModule, matchRoute } from './sdk.mjs';
33
+ import { defineModule, matchRoute, understandsSdk } from './sdk.mjs';
34
+ import { builtinFile, newer, readBuiltinRecord, trustedBytes } from '../builtin-updates.mjs';
32
35
 
33
36
  // The lab: modules that are built and tested but not offered yet, because they are not finished
34
37
  // to the standard of the rest. They stay out of MODULES and out of every prompt unless someone
@@ -36,8 +39,15 @@ import { defineModule, matchRoute } from './sdk.mjs';
36
39
  // so a module of somebody's own cannot take one and collide with it the day it comes out.
37
40
  export const LAB_MODULES = [correo];
38
41
  const labsAsked = new Set(String(process.env.PULSE_LABS ?? '').split(',').map((id) => id.trim()).filter(Boolean));
39
- export const MODULES = [ahp, imageStudio, gitPulse, ash, intents, choices, runs, ripley, ollama, playwright, github, enlaces, bishop, mcpConnect, ...LAB_MODULES.filter((module) => labsAsked.has(module.id))];
42
+ // A module of MADRE's own may be one file that imports nothing (SDK 2): it exports its plain spec,
43
+ // and the SDK is applied here, as it is to a module of anyone else's.
44
+ const own = (spec) => (typeof spec?.describe === 'function' ? spec : defineModule(spec));
45
+ export const MODULES = [ahp, imageStudio, gitPulse, ash, intents, choices, own(notes), own(reminders), runs, ripley, ollama, playwright, github, enlaces, bishop, mcpConnect, ...LAB_MODULES.filter((module) => labsAsked.has(module.id))];
40
46
  export const BUILTIN_IDS = new Set([...MODULES, ...LAB_MODULES].map((module) => module.id));
47
+ // MADRE's own modules as they came in the package, by id: what a newer file from the Market stands
48
+ // in for, and what comes back when that file fails, is taken back or is turned off.
49
+ const PACKAGED = new Map([...MODULES, ...LAB_MODULES].map((module) => [module.id, module]));
50
+ export const packagedVersions = () => Object.fromEntries([...PACKAGED].map(([id, module]) => [id, module.version ?? '0.0.0']));
41
51
  export const loadFailures = []; // { file, error } for MODULES to show
42
52
  export const moduleFolders = ({ stateRoot, projectRoot }) => ({ user: join(stateRoot, 'modules'), project: join(projectRoot, '.madre', 'modules') });
43
53
  // Where the SDK guide and the example live in this installation, for agents who build modules.
@@ -101,6 +111,47 @@ export async function loadExternalModules({ stateRoot, projectRoot }) {
101
111
  return { loaded: MODULES.filter((module) => module.external), failures: [...loadFailures], folders };
102
112
  }
103
113
 
114
+ // MADRE's OWN MODULES, NEWER FROM THE MARKET (src/builtin-updates.mjs). Each newer file kept on this
115
+ // computer is checked again here — its bytes against the sha256 and the factory signature it came
116
+ // with, its id, its contract, its version — and stands in for the one in the package. It keeps
117
+ // what MADRE's own have (its own routes, its card) and is never «yours»: it cannot be removed, only
118
+ // sent back. One that fails leaves the package's in place, and why is kept in builtinFailures.
119
+ // `enabled: false` (Look for new versions off) sends every one back to the package's.
120
+ // Why a newer file was not run, for Diagnostics and the log. Not among «your modules that did not
121
+ // load»: the module works, as the one MADRE came with, and it is not the person's to fix.
122
+ export const builtinFailures = [];
123
+ export async function adoptBuiltinUpdates({ stateRoot, enabled = true, factoryKey } = {}) {
124
+ const adopted = [];
125
+ builtinFailures.length = 0;
126
+ const record = enabled && stateRoot ? await readBuiltinRecord(stateRoot) : {};
127
+ for (const [id, packaged] of PACKAGED) {
128
+ const index = MODULES.findIndex((module) => module.id === id);
129
+ const kept = record[id];
130
+ let module = packaged;
131
+ if (kept && newer(kept.version, packaged.version ?? '0.0.0')) {
132
+ const file = builtinFile(stateRoot, id);
133
+ try {
134
+ const bytes = await readFile(file);
135
+ if (!trustedBytes(bytes, kept, ...(factoryKey ? [factoryKey] : []))) throw new Error('the file is not the one the factory key signed');
136
+ const loaded = await import(`${pathToFileURL(file).href}?sha=${kept.sha256}`);
137
+ const spec = loaded.default ?? null;
138
+ if (!spec || typeof spec !== 'object') throw new Error('the default export must be a module spec object');
139
+ const fresh = typeof spec.describe === 'function' ? spec : defineModule(spec);
140
+ if (fresh.id !== id) throw new Error(`the file says it is "${fresh.id}"`);
141
+ if (!understandsSdk(fresh.sdk)) throw new Error(`it needs contract ${fresh.sdk} of the SDK`);
142
+ if (fresh.version !== kept.version) throw new Error(`it says ${fresh.version}, the catalog said ${kept.version}`);
143
+ module = Object.freeze({ ...fresh, updated: { from: packaged.version ?? null, to: fresh.version }, file });
144
+ adopted.push({ id, from: packaged.version ?? null, to: fresh.version });
145
+ } catch (error) {
146
+ builtinFailures.push({ id, file, version: kept.version, error: error.message });
147
+ console.error(`MADRE modules: ${packaged.name} ${kept.version} from the Market did not load (${error.message}); MADRE uses the one it came with.`);
148
+ }
149
+ }
150
+ if (index >= 0 && MODULES[index] !== module) MODULES[index] = module;
151
+ }
152
+ return adopted;
153
+ }
154
+
104
155
  // The one door every module comes through, whoever wrote it and wherever the text came from: it
105
156
  // is written to a scratch copy, imported there and checked against the house rules. A module runs
106
157
  // inside MADRE with the human's own permissions, so the check is the point. Checking installs
@@ -123,7 +174,43 @@ export async function verifyModuleText({ text, name = null, replace = true }) {
123
174
  }
124
175
  throw error;
125
176
  }
126
- return { id: module.id, name: module.name, vendor: module.vendor, version: module.version ?? null, summary: module.summary ?? '', updates: module.updates ?? null, unknown: module.unknown ?? [] };
177
+ return { id: module.id, name: module.name, vendor: module.vendor, version: module.version ?? null, summary: module.summary ?? '', words: module.words ?? null, credit: module.credit ?? null, updates: module.updates ?? null, unknown: module.unknown ?? [], declares: declaredBy(module) };
178
+ } finally { await rm(scratch, { recursive: true, force: true, maxRetries: 6, retryDelay: 60 }); }
179
+ }
180
+
181
+ // WHAT A MODULE SAYS IT DOES, read from what it declares, for the person to read before it is
182
+ // installed (2026-10-25). Only what the file itself declares: where it reaches, the keys it asks
183
+ // for, whether it hands tools to the agents or reads the conversations, the pages and commands it
184
+ // adds, and whether it writes in the project. What the code does beyond that nobody can promise —
185
+ // which is why the page also says, every time, that a module runs with the person's permissions.
186
+ export function declaredBy(module) {
187
+ return {
188
+ reaches: (module.reaches ?? []).map(({ host, to, what, when }) => ({ host: host ?? null, to: to ?? null, what: what ?? null, when: when ?? null })),
189
+ secrets: (module.secrets ?? []).map(({ name, label }) => ({ name, label: label ?? name })),
190
+ tools: typeof module.toolsForTurn === 'function',
191
+ reads: typeof module.onEvent === 'function',
192
+ pages: (module.routes ?? []).length,
193
+ commands: (module.slash ?? []).map((command) => command.usage ?? `/${command.name}`),
194
+ writes: module.kind === 'installer',
195
+ creates: module.creates ?? [],
196
+ };
197
+ }
198
+
199
+ // The same door for a newer file of one of MADRE's own modules, before it is signed and published
200
+ // (scripts/market-publish.mjs): alone in a scratch folder, where nothing of MADRE resolves, it must
201
+ // load, say it is that module, speak a contract this MADRE knows and be newer than the package's.
202
+ export async function verifyBuiltinText({ text, id }) {
203
+ const packaged = PACKAGED.get(id);
204
+ if (!packaged) throw new Error(`"${id}" is not one of MADRE's own modules.`);
205
+ const scratch = await mkdtemp(join(tmpdir(), 'madre-builtin-check-'));
206
+ try {
207
+ const probe = join(scratch, `${id}.mjs`);
208
+ await writeFile(probe, text);
209
+ const module = await importModuleFile(probe);
210
+ if (module.id !== id) throw new Error(`The file says it is "${module.id}", not "${id}".`);
211
+ if (!understandsSdk(module.sdk)) throw new Error(`${id} needs contract ${module.sdk} of the SDK.`);
212
+ if (!module.version || !newer(module.version, packaged.version ?? '0.0.0')) throw new Error(`${id} ${module.version ?? '(no version)'} is not newer than the ${packaged.version} MADRE comes with.`);
213
+ return { id: module.id, version: module.version, sdk: module.sdk };
127
214
  } finally { await rm(scratch, { recursive: true, force: true, maxRetries: 6, retryDelay: 60 }); }
128
215
  }
129
216
 
@@ -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
  // The two tests behind Intenciones: is a cheaper rung enough for this project?
4
4
  //
5
5
  // A suggestion is only worth what it was measured against, and the room's ordinary use can never
@@ -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
  // The desk behind Intenciones: what this project has measured, what is being measured now, and
4
4
  // what that says about the message being written.
5
5
  //
@@ -364,7 +364,8 @@ export class IntentsDesk {
364
364
  }),
365
365
  };
366
366
  }),
367
- running: this.#run ? { ...this.#run } : null,
367
+ // With how far it got (2026-10-28): the window shows the share of the test already done.
368
+ running: this.#run ? { ...this.#run, step: this.#pendingAt?.step ?? 0, total: this.#pendingAt?.total ?? 0 } : null,
368
369
  // The pair on the table, with nothing in it that says which answer came from which rung.
369
370
  pending: this.#pending ? { step: this.#pending.step, total: this.#pending.total, intent: this.#pending.intent, question: this.#pending.question, first: this.#pending.first, second: this.#pending.second } : null,
370
371
  last: this.#last,
@@ -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, learned from real use: how each turn the human already paid for went.
4
4
  //
5
5
  // The calibration (intents-calibration.mjs) asks real questions again, at two rungs, and a judge
@@ -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 a turn needs to think, said before it is paid for.
4
4
  //
5
5
  // Pure functions. The room hands in the words, the thread they belong to and whatever the