@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
@@ -0,0 +1,87 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // MADRE'S OWN MODULES, KEPT UP TO DATE BY THE MARKET (2026-10-25, R-2 of the 1.1 road map).
4
+ //
5
+ // Notes, Reminders and the rest come with MADRE and work from the first day, without internet. A
6
+ // fix to one of them used to wait for a new MADRE on npm. Now the signed catalog can carry a newer
7
+ // file for it (`builtins`, src/market-remote.mjs), and MADRE runs that one instead of its own.
8
+ //
9
+ // Because such a file reaches every MADRE on its own — nobody chose to install it — it must pass
10
+ // more than a Market module does:
11
+ // · the catalog is signed with the Market's key, as always;
12
+ // · the file is the one the catalog pins (sha256), and
13
+ // · the file itself is signed with the FACTORY key (src/market-key.mjs), a second key kept apart
14
+ // from the Market's: whoever got the Market's key could still not replace Reminders anywhere;
15
+ // · it is written for a contract of the SDK this MADRE understands (`sdk`), says it is the same
16
+ // module, and is newer than the one MADRE came with.
17
+ // It is checked again every time it is loaded (src/modules/index.mjs, adoptBuiltinUpdates), and a
18
+ // file that fails to load leaves MADRE's own in place. A catalog that takes a version back
19
+ // (`revoked`) sends MADRE back to its own. Turning off «Look for new versions» does too.
20
+ //
21
+ // ~/.pulse/market/builtin/<id>.mjs the newer file
22
+ // ~/.pulse/market/builtin/builtin.json what each one is: version, sha256, factory signature
23
+
24
+ import { mkdir, rm } from 'node:fs/promises';
25
+ import { join } from 'node:path';
26
+ import { FACTORY_PUBLIC_KEY } from './market-key.mjs';
27
+ import { bytesFrom, fitsVersion, MAX_MODULE, marketNews, readJson, sha256, verifySigned, writeAtomic } from './market-remote.mjs';
28
+
29
+ export const builtinFolder = (stateRoot) => join(stateRoot, 'market', 'builtin');
30
+ const recordFile = (stateRoot) => join(builtinFolder(stateRoot), 'builtin.json');
31
+ export const builtinFile = (stateRoot, id) => join(builtinFolder(stateRoot), `${id}.mjs`);
32
+ export const readBuiltinRecord = async (stateRoot) => (await readJson(recordFile(stateRoot))) ?? {};
33
+
34
+ // «0.2.0» is newer than «0.1.0»; the same version is not.
35
+ export const newer = (have, than) => fitsVersion(have, than) && !fitsVersion(than, have);
36
+
37
+ // What the catalog offers for MADRE's own modules, fetched and kept when it passes. `packaged` is
38
+ // { id: version } of the modules this MADRE came with; `understands(sdk)` says whether a contract
39
+ // is one this MADRE speaks. Answers what changed: updated (with what the author wrote) and taken back.
40
+ export async function updateBuiltins({ stateRoot, catalog, packaged = {}, understands = () => false, fetchImpl = globalThis.fetch, factoryKey = FACTORY_PUBLIC_KEY, names = {}, now = () => new Date() }) {
41
+ if (!catalog || !factoryKey) return { updated: [], revoked: [] };
42
+ const record = await readBuiltinRecord(stateRoot);
43
+ const updated = [];
44
+ const revoked = [];
45
+ await mkdir(builtinFolder(stateRoot), { recursive: true });
46
+
47
+ for (const [id, have] of Object.entries(record)) {
48
+ const taken = (catalog.revoked ?? []).find((one) => one.id === id && (!one.version || one.version === have.version));
49
+ if (!taken) continue;
50
+ await rm(builtinFile(stateRoot, id), { force: true });
51
+ delete record[id];
52
+ revoked.push({ id, name: names[id] ?? id, kind: 'returned', version: have.version, why: taken.why ?? null, at: now().toISOString() });
53
+ }
54
+
55
+ for (const entry of catalog.builtins ?? []) {
56
+ const mine = packaged[entry.id];
57
+ if (!mine || !understands(entry.sdk) || !newer(entry.version, mine)) continue;
58
+ if ((catalog.revoked ?? []).some((one) => one.id === entry.id && (!one.version || one.version === entry.version))) continue;
59
+ if (record[entry.id]?.sha256 === entry.file.sha256) continue;
60
+ if (record[entry.id] && !newer(entry.version, record[entry.id].version)) continue;
61
+ try {
62
+ const bytes = await bytesFrom(entry.file.url, { fetchImpl, max: MAX_MODULE });
63
+ if (sha256(bytes) !== entry.file.sha256) continue;
64
+ if (!verifySigned(bytes, entry.file.factory, factoryKey)) continue;
65
+ await writeAtomic(builtinFile(stateRoot, entry.id), bytes);
66
+ const from = record[entry.id]?.version ?? mine;
67
+ record[entry.id] = { version: entry.version, sdk: entry.sdk, sha256: entry.file.sha256, factory: entry.file.factory, at: now().toISOString() };
68
+ updated.push({ id: entry.id, name: names[entry.id] ?? entry.id, from, to: entry.version, changes: entry.changes ?? null, at: now().toISOString() });
69
+ } catch { /* tried again the next time MADRE opens */ }
70
+ }
71
+
72
+ if (updated.length || revoked.length) {
73
+ await writeAtomic(recordFile(stateRoot), JSON.stringify(record, null, 2));
74
+ // Said once, the way a Market module's update is (market/updates.json): what came, and what
75
+ // went back to the one MADRE came with, and why.
76
+ const told = [...updated, ...revoked];
77
+ const news = [...(await marketNews(stateRoot)).filter((one) => !told.some((fresh) => fresh.id === one.id)), ...told];
78
+ await writeAtomic(join(stateRoot, 'market', 'updates.json'), JSON.stringify(news, null, 2));
79
+ }
80
+ return { updated, revoked };
81
+ }
82
+
83
+ // The file kept for one of MADRE's own modules, if it is still the one that was signed: its bytes
84
+ // against the sha256 and the factory signature recorded when it came. Anything else is not run.
85
+ export function trustedBytes(bytes, kept, factoryKey = FACTORY_PUBLIC_KEY) {
86
+ return Boolean(bytes && kept && factoryKey && sha256(bytes) === kept.sha256 && verifySigned(bytes, kept.factory, factoryKey));
87
+ }
@@ -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 each CLI can do from MADRE, verified against the installed versions on
4
4
  // 2026-09-16 (Codex 0.153, Claude Code 2.1, Gemini CLI 0.60, OpenCode 1.18).
5
5
  // The room shows this so a human knows whom to ask for what, and an
@@ -35,12 +35,12 @@ export const CAPABILITIES = {
35
35
  imageGen: false,
36
36
  web: { how: 'policy: allow google_web_search, web_fetch', note: 'Off until turned on in Settings › Agents › Web access.' },
37
37
  },
38
- // Cursor (2026-10-17) reads only, in its own ask mode: writing waits until its confinement has
39
- // been tried against the real CLI, as OpenCode's was. Attachments are named in the briefing.
38
+ // Cursor reads in its own ask mode and, from 2026-10-21, writes and runs commands at the modes
39
+ // that allow it (adapters/cursor.mjs). Attachments are named in the briefing.
40
40
  cursor: {
41
41
  read: true,
42
42
  imageIn: false,
43
- write: false,
43
+ write: { how: 'agent mode with --force under a configuration made for the turn', note: 'Writes where the turn allows; commands only at #4. MADRE locks and puts back .env, .git and its own folders, and at #2 what existed.' },
44
44
  imageGen: false,
45
45
  web: false,
46
46
  },
package/src/chats.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
  // A project has one memory and many conversations.
4
4
  //
5
5
  // The archive, the crew, the modules and the privacy list belong to the project: they are what
@@ -230,3 +230,52 @@ export async function projectFloor(roomDir, { except = null } = {}) {
230
230
  }
231
231
  return floor;
232
232
  }
233
+
234
+ // SEARCH (2026-10-30): the conversations of a project, by their name and by what was said in them,
235
+ // without regard to accents or capitals, so «envio» finds «Envío». Each record is read from its
236
+ // end, a few megabytes at most: what a person looks for is almost always recent.
237
+ const SEARCH_READ = 4 * 1024 * 1024;
238
+ export const searchWords = (text) => String(text ?? '').normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
239
+ // The end of one record, `bytes` at most, from a whole line on (also «En marcha», src/activity.mjs).
240
+ export async function tailOf(file, bytes = SEARCH_READ) {
241
+ const found = await stat(file).catch(() => null);
242
+ if (!found?.isFile()) return '';
243
+ const start = Math.max(0, found.size - bytes);
244
+ const handle = await open(file, 'r');
245
+ try {
246
+ const buffer = Buffer.alloc(found.size - start);
247
+ await handle.read(buffer, 0, buffer.length, start);
248
+ const text = buffer.toString('utf8');
249
+ return start ? text.slice(text.indexOf('\n') + 1) : text;
250
+ } finally { await handle.close(); }
251
+ }
252
+ function snippetAround(text, at, length) {
253
+ const from = Math.max(0, at - 50);
254
+ const to = Math.min(text.length, at + length + 90);
255
+ return { text: `${from ? '…' : ''}${text.slice(from, to).replace(/\s+/g, ' ')}${to < text.length ? '…' : ''}`, mark: [at - from + (from ? 1 : 0), length] };
256
+ }
257
+ export async function searchChats(roomDir, query, { limit = 40, perChat = 3 } = {}) {
258
+ const wanted = searchWords(query).trim();
259
+ if (wanted.length < 2) return { query: String(query ?? ''), results: [] };
260
+ const { chats } = await listChats(roomDir);
261
+ const results = [];
262
+ for (const chat of chats) {
263
+ const hits = [];
264
+ const titleAt = searchWords(chat.title).indexOf(wanted);
265
+ for (const line of (await tailOf(chatLedger(roomDir, chat.id))).split('\n').reverse()) {
266
+ if (hits.length >= perChat) break;
267
+ if (!line.includes('"message.created"')) continue;
268
+ let event;
269
+ try { event = JSON.parse(line); } catch { continue; }
270
+ const payload = event?.payload ?? {};
271
+ const said = typeof payload.text === 'string' ? payload.text : '';
272
+ const at = searchWords(said).indexOf(wanted);
273
+ if (at < 0) continue;
274
+ hits.push({ messageId: payload.messageId ?? null, sequence: event.sequence ?? null, who: payload.role === 'user' ? 'you' : String(payload.sender ?? ''), at: event.timestamp ?? null, ...snippetAround(said, at, wanted.length) });
275
+ }
276
+ if (titleAt < 0 && !hits.length) continue;
277
+ results.push({ id: chat.id, title: chat.title, updatedAt: chat.updatedAt ?? null, titleMatch: titleAt >= 0, hits });
278
+ if (results.length >= limit) break;
279
+ }
280
+ return { query: String(query ?? ''), results };
281
+ }
@@ -1,7 +1,8 @@
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
- import { access, mkdir, mkdtemp, readFile, readdir, rm, rmdir, stat, unlink, writeFile } from 'node:fs/promises';
4
+ import { constants as fsConstants } from 'node:fs';
5
+ import { access, chmod, cp, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, stat, unlink, writeFile } from 'node:fs/promises';
5
6
  import { tmpdir } from 'node:os';
6
7
  import { dirname, join, resolve, sep } from 'node:path';
7
8
  import { createHash } from 'node:crypto';
@@ -24,24 +25,77 @@ export const CHECKPOINT_REF = 'refs/madre/checkpoints';
24
25
  export const FORBIDDEN = [
25
26
  /^\.git(\/|$)/i,
26
27
  /^\.pulse(\/|$)/i,
27
- /(^|\/)\.env(\.|$)/i,
28
+ // A template that documents the variables and holds no secret is not one (QA 1.1.0, NUE-21):
29
+ // .env.example, .env.sample, .env.template and .env.dist are meant to be written and shared.
30
+ /(^|\/)\.env(?:$|\.(?!(?:example|sample|template|dist)$))/i,
28
31
  /(^|\/)\.madre(\/|$)/i,
29
32
  /(^|\/)\.claude\/settings\.local\.json$/i,
30
33
  ];
34
+ // The same rule said as globs, for the CLIs that take a list of paths (src/adapters/*): every
35
+ // secret-bearing variant by name, since a deny there cannot be undone by an allow.
36
+ export const ENV_TEMPLATES = ['.env.example', '.env.sample', '.env.template', '.env.dist'];
37
+ export const ENV_SECRETS = ['.env', '.env.local', '.env.*.local', '.env.development', '.env.dev', '.env.production', '.env.prod', '.env.staging', '.env.test', '.env.preview'];
31
38
  export const isForbidden = (path) => FORBIDDEN.some((pattern) => pattern.test(path));
32
39
 
40
+ // A repository is a `.git` file (a worktree, a submodule) or a `.git` folder with its HEAD. A
41
+ // `.git` folder left half-made (2026-10-28, a copied project: hooks, objects and no HEAD) is not
42
+ // one: git refuses it, so the project is photographed with a shadow like any other.
33
43
  export async function isGitRepo(root) {
34
- return access(join(root, '.git')).then(() => true, () => false);
44
+ const found = await stat(join(root, '.git')).catch(() => null);
45
+ if (!found) return false;
46
+ if (found.isFile()) return true;
47
+ return access(join(root, '.git', 'HEAD')).then(() => true, () => false);
35
48
  }
36
49
 
37
50
  // A project that is not a git repository still gets photographs: MADRE keeps a shadow
38
51
  // repository of its own outside the project (one per project path) and runs git with the
39
52
  // project as work tree. Nothing appears inside the project; UNDO and diffs work the same.
40
53
  const shadows = new Map();
54
+ // The shadows hold a copy of the project, .env included: on Linux the temporary folder is shared by
55
+ // every user of the computer (a lent server, a VM), so they live in a folder only this user can open
56
+ // (0700, theirs, not a link). One that someone else made first is never used: a fresh one is.
57
+ let shadowBase = null;
58
+ async function shadowHome() {
59
+ if (shadowBase) return shadowBase;
60
+ const uid = process.getuid?.();
61
+ const base = join(tmpdir(), uid === undefined ? 'madre-shadow' : `madre-shadow-${uid}`);
62
+ await mkdir(base, { recursive: true, mode: 0o700 });
63
+ const found = await lstat(base).catch(() => null);
64
+ const ours = found?.isDirectory() && !found.isSymbolicLink() && (uid === undefined || found.uid === uid);
65
+ if (ours && (found.mode & 0o077)) await chmod(base, 0o700).catch(() => null);
66
+ shadowBase = ours ? base : await mkdtemp(join(tmpdir(), 'madre-shadow-'));
67
+ return shadowBase;
68
+ }
69
+ // Where a project's shadow would be, without making it (src/uninstall.mjs takes it away). Only the
70
+ // folder of this user's own: a fresh one made beside someone else's lasts as long as the process.
71
+ export function shadowFolderFor(root) {
72
+ const uid = process.getuid?.();
73
+ return join(tmpdir(), uid === undefined ? 'madre-shadow' : `madre-shadow-${uid}`, createHash('sha1').update(resolve(root)).digest('hex').slice(0, 16));
74
+ }
75
+ // Where 1.0.x kept it (QA 1.1.0, ACT-04): one folder for everyone, madre-shadow/<hash>. Read so an
76
+ // update keeps the restore points made before it, and so uninstalling takes it away too.
77
+ export function legacyShadowFolderFor(root) {
78
+ if (process.getuid?.() === undefined) return null;
79
+ return join(tmpdir(), 'madre-shadow', createHash('sha1').update(resolve(root)).digest('hex').slice(0, 16));
80
+ }
81
+ // The first time a project is photographed after the update, its old shadow moves into this user's
82
+ // own folder, if it is this user's and nothing is there yet; the old one, a copy of the project
83
+ // with its .env in a folder others can open, does not stay behind.
84
+ async function adoptLegacyShadow(root, dir) {
85
+ const old = legacyShadowFolderFor(root);
86
+ if (!old || resolve(old) === resolve(dir)) return;
87
+ const found = await lstat(old).catch(() => null);
88
+ if (!found?.isDirectory() || found.isSymbolicLink() || found.uid !== process.getuid?.()) return;
89
+ if (await access(join(dir, 'HEAD')).then(() => true, () => false)) return;
90
+ await rm(dir, { recursive: true, force: true }).catch(() => {});
91
+ await rename(old, dir).catch(async () => { await cp(old, dir, { recursive: true }); await rm(old, { recursive: true, force: true }); });
92
+ await chmod(dir, 0o700).catch(() => null);
93
+ }
41
94
  async function shadowFor(root) {
42
95
  const canonical = resolve(root);
43
96
  if (!shadows.has(canonical)) {
44
- const dir = join(tmpdir(), 'madre-shadow', createHash('sha1').update(canonical).digest('hex').slice(0, 16));
97
+ const dir = join(await shadowHome(), createHash('sha1').update(canonical).digest('hex').slice(0, 16));
98
+ await adoptLegacyShadow(canonical, dir).catch(() => {});
45
99
  await mkdir(dir, { recursive: true });
46
100
  const isRepo = await access(join(dir, 'HEAD')).then(() => true, () => false);
47
101
  if (!isRepo) await execFileAsync('git', ['init', '-q', '--bare', dir]);
@@ -69,8 +123,9 @@ async function gitArgs(root, via) {
69
123
  // next time MADRE photographed the project. Hooks, external diffs and text conversions are named
70
124
  // the same way; none of them is needed to take or compare a photograph.
71
125
  const SAFE = ['-c', 'core.quotepath=off', '-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=/dev/null', '-c', 'diff.external='];
126
+ // Paths are paths, never patterns: restoring «app/[id]/page.tsx» restored «app/i/page.tsx» too.
72
127
  async function git(root, args, { env = {}, via } = {}) {
73
- const { stdout } = await execFileAsync('git', [...SAFE, ...(await gitArgs(root, via)), ...args], { cwd: root, env: { ...process.env, GIT_PAGER: 'cat', ...env }, maxBuffer: 16 * 1024 * 1024 });
128
+ const { stdout } = await execFileAsync('git', [...SAFE, ...(await gitArgs(root, via)), ...args], { cwd: root, env: { ...process.env, GIT_PAGER: 'cat', GIT_LITERAL_PATHSPECS: '1', ...env }, maxBuffer: 16 * 1024 * 1024 });
74
129
  return stdout;
75
130
  }
76
131
 
@@ -137,12 +192,15 @@ export async function worktreeTree(root, { exclude = [], via } = {}) {
137
192
  // --remove: a file that vanished since the listing is dropped instead of aborting the photograph.
138
193
  const index_ = (list) => new Promise((resolvePromise, reject) => {
139
194
  const child = execFile('git', [...SAFE, ...extra, 'update-index', '--add', '--remove', '-z', '--stdin'], { cwd: root, env: { ...process.env, GIT_PAGER: 'cat', ...env }, maxBuffer: 64 * 1024 * 1024 }, (error) => (error ? reject(error) : resolvePromise()));
195
+ // git may stop reading before the list ends (a path it refuses): that is its error, not a crash.
196
+ child.stdin.on('error', () => {});
140
197
  child.stdin.end(list.join('\0') + '\0');
141
198
  });
142
199
  try { await index_(files); } catch {
143
- // Something still raced us: photograph what exists right now.
200
+ // Something still raced us, or a file cannot be read by this user (one a container left owned
201
+ // by root): photograph what exists and can be read right now.
144
202
  const alive = [];
145
- for (const path of files) if (await access(join(root, path)).then(() => true, () => false)) alive.push(path);
203
+ for (const path of files) if (await access(join(root, path), fsConstants.R_OK).then(() => true, () => false)) alive.push(path);
146
204
  if (alive.length) await index_(alive);
147
205
  }
148
206
  }
package/src/choices.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
  // An agent asking the human to choose.
4
4
  //
5
5
  // The room already has one fenced channel, ```pulse, and it puts other agents to work. This is
package/src/cli-args.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
  // Tiny argv reader for the MADRE CLI. Accepts `--name value` and
4
4
  // `--name=value`, and remembers which options the user set explicitly so the
5
5
  // room can choose sensible defaults (like the next free port) only when they
package/src/cold.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
  // Cold zones: the part of the archive nothing has ever reached for.
4
4
  //
5
5
  // A memory is cold when three things are true at once, and the three together are what make the
package/src/commands.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 { execFile } from 'node:child_process';
4
4
  import { access } from 'node:fs/promises';
5
5
  import { join } from 'node:path';
package/src/config.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 { randomUUID } from 'node:crypto';
4
4
  import { copyFile, mkdir, open, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';
5
5
  import { homedir } from 'node:os';
@@ -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 a command's output may weigh in the shared window, and which part of it. It used to be the
4
4
  // first 6000 characters: five outputs filled the 16 000 of the window, the request that asked for
5
5
  // them went out of it, and the agent lost the thread (2026-10-14). Now it is the start and the end
@@ -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
  // Handing a provider key to a CLI that signs in from its own prompt.
4
4
  //
5
5
  // MADRE keeps its promise: it never stores a credential of its own. The key the human pastes is
@@ -11,11 +11,12 @@
11
11
  // signed in now. If it is not, the previous files are put back, so a format MADRE guessed wrong
12
12
  // leaves nothing behind.
13
13
 
14
- import { execFile } from 'node:child_process';
14
+ import { execFile, spawn } from 'node:child_process';
15
15
  import { chmod, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
16
16
  import { homedir } from 'node:os';
17
17
  import { join } from 'node:path';
18
18
  import { promisify } from 'node:util';
19
+ import { t } from './i18n.mjs';
19
20
 
20
21
  const execFileAsync = promisify(execFile);
21
22
  const OWNER_ONLY = 0o600;
@@ -23,9 +24,9 @@ const OWNER_ONLY = 0o600;
23
24
  // A key is one opaque token: no spaces, no newlines, and long enough to be one.
24
25
  export function normalizeKey(value) {
25
26
  const key = String(value ?? '').trim();
26
- if (!key) return { ok: false, error: 'Paste the key first.' };
27
- if (/\s/.test(key)) return { ok: false, error: 'That does not look like a key: it has spaces or line breaks.' };
28
- if (key.length < 12 || key.length > 400) return { ok: false, error: 'That does not look like a key: check you copied all of it and nothing else.' };
27
+ if (!key) return { ok: false, error: t('Paste the key first.') };
28
+ if (/\s/.test(key)) return { ok: false, error: t('That does not look like a key: it has spaces or line breaks.') };
29
+ if (key.length < 12 || key.length > 400) return { ok: false, error: t('That does not look like a key: check you copied all of it and nothing else.') };
29
30
  return { ok: true, key };
30
31
  }
31
32
 
@@ -54,10 +55,32 @@ export async function readOpenCodeCatalog({ home = homedir(), env = process.env
54
55
  }
55
56
  return out;
56
57
  }
58
+ // OpenCode writes its catalogue the first time it runs. A person who has just installed it has none
59
+ // yet, and was offered only MADRE's four (2026-10-20): until the catalogue is there, the popular
60
+ // ones a single key opens are offered from this copy of it (models.dev, 2026-10-20), each with the
61
+ // page of its own documentation the catalogue gives.
62
+ export const OPENCODE_BUNDLED = [
63
+ { id: 'groq', label: 'Groq', docUrl: 'https://console.groq.com/docs/models' },
64
+ { id: 'deepseek', label: 'DeepSeek', docUrl: 'https://api-docs.deepseek.com/quick_start/pricing' },
65
+ { id: 'mistral', label: 'Mistral', docUrl: 'https://docs.mistral.ai/getting-started/models/' },
66
+ { id: 'xai', label: 'xAI', docUrl: 'https://docs.x.ai/docs/models' },
67
+ { id: 'togetherai', label: 'Together AI', docUrl: 'https://docs.together.ai/docs/serverless-models' },
68
+ { id: 'fireworks-ai', label: 'Fireworks AI', docUrl: 'https://fireworks.ai/docs/' },
69
+ { id: 'cerebras', label: 'Cerebras', docUrl: 'https://inference-docs.cerebras.ai/models/overview' },
70
+ { id: 'perplexity', label: 'Perplexity', docUrl: 'https://docs.perplexity.ai' },
71
+ { id: 'huggingface', label: 'Hugging Face', docUrl: 'https://huggingface.co/docs/inference-providers' },
72
+ { id: 'deepinfra', label: 'Deep Infra', docUrl: 'https://deepinfra.com/models' },
73
+ { id: 'moonshotai', label: 'Moonshot AI', docUrl: 'https://platform.moonshot.ai/docs/api/chat' },
74
+ { id: 'zai', label: 'Z.AI', docUrl: 'https://docs.z.ai/guides/overview/pricing' },
75
+ { id: 'cohere', label: 'Cohere', docUrl: 'https://docs.cohere.com/docs/models' },
76
+ { id: 'vercel', label: 'Vercel AI Gateway', docUrl: null },
77
+ ];
57
78
  // Every provider a key can be pasted for: MADRE's own four first (their key pages), then the
58
- // catalogue's, each once, the popular ones marked.
79
+ // catalogue's — or, before OpenCode has written one, the copy above — each once, the popular ones
80
+ // marked.
59
81
  export async function openCodeKeyProviders({ home = homedir(), env = process.env } = {}) {
60
- const catalog = await readOpenCodeCatalog({ home, env });
82
+ const read = await readOpenCodeCatalog({ home, env });
83
+ const catalog = read.length ? read : OPENCODE_BUNDLED;
61
84
  const byId = new Map(OPENCODE_PROVIDERS.map((one) => [one.id, { ...one, featured: true }]));
62
85
  for (const one of catalog) if (!byId.has(one.id)) byId.set(one.id, { id: one.id, label: one.label, keyUrl: one.docUrl, featured: OPENCODE_FEATURED.includes(one.id) });
63
86
  const rank = (one) => { const at = OPENCODE_FEATURED.indexOf(one.id); return at < 0 ? Infinity : at; };
@@ -66,6 +89,18 @@ export async function openCodeKeyProviders({ home = homedir(), env = process.env
66
89
 
67
90
  // What the room offers for each agent that cannot be signed in with a click.
68
91
  export function keyPlanFor(id) {
92
+ // Codex takes its key through its own login (2026-10-28): `codex login --with-api-key`, the key on
93
+ // its input, so the file it lands in is Codex's own and written by Codex.
94
+ if (id === 'codex') {
95
+ return {
96
+ agent: 'codex',
97
+ label: 'OpenAI API key',
98
+ keyUrl: 'https://platform.openai.com/api-keys',
99
+ writesTo: '~/.codex/auth.json',
100
+ note: 'The key is handed to Codex itself, which keeps it in its own file, readable only by you. MADRE keeps no copy. It replaces the account Codex was signed in with, here and in your own terminal.',
101
+ providers: null,
102
+ };
103
+ }
69
104
  if (id === 'claude') {
70
105
  return {
71
106
  agent: 'claude',
@@ -132,13 +167,13 @@ async function applyGeminiKey(key, { home, probe }) {
132
167
  if (state?.state !== 'signed-in') {
133
168
  await restore(envFile, beforeEnv);
134
169
  await restore(settingsFile, beforeSettings);
135
- return { ok: false, error: `The key was written but Gemini still reads as ${state?.state ?? 'unknown'}${state?.detail ? ` (${state.detail})` : ''}. Nothing was changed.` };
170
+ return { ok: false, error: t('The key was written but {agent} still reads as {state}. Nothing was changed.', { agent: 'Gemini', state: `${state?.state ?? 'unknown'}${state?.detail ? ` (${state.detail})` : ''}` }) };
136
171
  }
137
172
  return { ok: true, detail: state.detail ?? 'via API key' };
138
173
  } catch (error) {
139
174
  await restore(envFile, beforeEnv);
140
175
  await restore(settingsFile, beforeSettings);
141
- return { ok: false, error: `The key could not be written: ${error.message}` };
176
+ return { ok: false, error: t('The key could not be written: {error}', { error: error.message }) };
142
177
  }
143
178
  }
144
179
 
@@ -160,19 +195,45 @@ async function applyClaudeKey(key, { home, probe }) {
160
195
  const state = await probe();
161
196
  if (state?.state !== 'signed-in') {
162
197
  await restore(file, before);
163
- return { ok: false, error: `The key was written but Claude still reads as ${state?.state ?? 'unknown'}${state?.detail ? ` (${state.detail})` : ''}. Nothing was changed.` };
198
+ return { ok: false, error: t('The key was written but {agent} still reads as {state}. Nothing was changed.', { agent: 'Claude', state: `${state?.state ?? 'unknown'}${state?.detail ? ` (${state.detail})` : ''}` }) };
164
199
  }
165
200
  return { ok: true, detail: state.detail ?? 'via API key' };
166
201
  } catch (error) {
167
202
  await restore(file, before);
168
- return { ok: false, error: `The key could not be written: ${error.message}` };
203
+ return { ok: false, error: t('The key could not be written: {error}', { error: error.message }) };
169
204
  }
170
205
  }
171
206
 
207
+ // ---- Codex: its own login, with the key on its input (never in its arguments, where `ps` shows
208
+ // them), confirmed by asking Codex again. Its sign-in file is kept first and put back if the key is
209
+ // refused, so a wrong key never signs out an account that worked.
210
+ const runWithInput = (command, args, input, { timeoutMs = 30000 } = {}) => new Promise((resolve) => {
211
+ let child;
212
+ try { child = spawn(command, args, { stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true, env: { ...process.env, NO_COLOR: '1' } }); } catch (error) { resolve({ code: null, out: error.message }); return; }
213
+ let out = '';
214
+ child.stdout.on('data', (chunk) => { out += chunk; });
215
+ child.stderr.on('data', (chunk) => { out += chunk; });
216
+ const timer = setTimeout(() => child.kill('SIGTERM'), timeoutMs);
217
+ child.on('error', (error) => { clearTimeout(timer); resolve({ code: null, out: error.message }); });
218
+ child.on('close', (code) => { clearTimeout(timer); resolve({ code, out }); });
219
+ child.stdin.on('error', () => {});
220
+ child.stdin.end(`${input}\n`);
221
+ });
222
+ async function applyCodexKey(key, { home, probe, executable = 'codex', run = runWithInput }) {
223
+ const file = join(process.env.CODEX_HOME || join(home, '.codex'), 'auth.json');
224
+ const before = await readIfThere(file);
225
+ const said = await run(executable, ['login', '--with-api-key'], key);
226
+ const state = said.code === 0 ? await probe() : null;
227
+ if (state?.state === 'signed-in') return { ok: true, detail: state.detail ?? 'via API key' };
228
+ await restore(file, before);
229
+ const why = String(said.out ?? '').trim().split('\n').filter(Boolean).at(-1);
230
+ return { ok: false, error: why ? t('Codex did not take the key ({why}). Nothing was changed.', { why: why.slice(0, 160) }) : t('Codex did not take the key. Nothing was changed.') };
231
+ }
232
+
172
233
  // ---- OpenCode: an entry in its auth.json, confirmed by asking `opencode auth list`.
173
234
  async function applyOpenCodeKey(key, { home, provider, executable, run }) {
174
235
  const known = typeof provider === 'string' ? (await openCodeKeyProviders({ home })).find((item) => item.id === provider) : null;
175
- if (!known) return { ok: false, error: 'Pick the provider this key belongs to.' };
236
+ if (!known) return { ok: false, error: t('Pick the provider this key belongs to.') };
176
237
  const file = join(home, '.local', 'share', 'opencode', 'auth.json');
177
238
  await mkdir(join(home, '.local', 'share', 'opencode'), { recursive: true });
178
239
  const before = await readIfThere(file);
@@ -188,12 +249,12 @@ async function applyOpenCodeKey(key, { home, provider, executable, run }) {
188
249
  const listed = String(await run(executable, ['auth', 'list'])).toLowerCase();
189
250
  if (!listed.includes(provider.toLowerCase()) && !listed.includes(String(known.label).toLowerCase())) {
190
251
  await restore(file, before);
191
- return { ok: false, error: `OpenCode does not list ${provider} after the key was written, so MADRE put the file back. Run \`opencode auth login\` in a terminal for this one.` };
252
+ return { ok: false, error: t('OpenCode does not list {provider} after the key was written, so MADRE put the file back. Run `opencode auth login` in a terminal for this one.', { provider }) };
192
253
  }
193
254
  return { ok: true, detail: `${provider} (api)` };
194
255
  } catch (error) {
195
256
  await restore(file, before);
196
- return { ok: false, error: `The key could not be written: ${error.message}` };
257
+ return { ok: false, error: t('The key could not be written: {error}', { error: error.message }) };
197
258
  }
198
259
  }
199
260
 
@@ -207,13 +268,14 @@ const runOpenCode = async (executable, args) => {
207
268
  };
208
269
 
209
270
  // Writes the key for one agent and answers whether that agent is signed in now.
210
- export async function applyKey({ agent, key, provider = null, home = homedir(), probe, executable = 'opencode', run = runOpenCode }) {
271
+ export async function applyKey({ agent, key, provider = null, home = homedir(), probe, executable = null, run = null }) {
211
272
  const checked = normalizeKey(key);
212
273
  if (!checked.ok) return checked;
274
+ if (agent === 'codex') return applyCodexKey(checked.key, { home, probe, executable: executable ?? 'codex', run: run ?? runWithInput });
213
275
  if (agent === 'claude') return applyClaudeKey(checked.key, { home, probe });
214
276
  if (agent === 'gemini') return applyGeminiKey(checked.key, { home, probe });
215
- if (agent === 'opencode') return applyOpenCodeKey(checked.key, { home, provider, executable, run });
216
- return { ok: false, error: `${agent} does not take a key here: it signs in with a click.` };
277
+ if (agent === 'opencode') return applyOpenCodeKey(checked.key, { home, provider, executable: executable ?? 'opencode', run: run ?? runOpenCode });
278
+ return { ok: false, error: t('{agent} does not take a key here: it signs in with a click.', { agent }) };
217
279
  }
218
280
 
219
281
  // ---- OpenCode's providers, as its auth.json says them: who is signed in and how, never the key.
package/src/dataset.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
  // The dataset behind MADRE AI: every exchange the room kept (never GHOST),
4
4
  // redacted, as chat pairs a small model can learn from, plus the distilled
5
5
  // notes. Written next to the room's ledger in the format mlx-lm and most
@@ -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
  // Agent-to-agent delegation. An agent answering in the room may end its reply
4
4
  // with a fenced block that puts other agents to work, in order:
5
5
  //
package/src/distiller.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
  // The archivist's turn: every so often the cheapest agent in the room reads
4
4
  // the exchanges nobody has distilled yet and writes the few notes worth
5
5
  // keeping for every later turn. Pure functions here; the room schedules 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
  // Embeddings for the room memory: meaning-aware recall on top of the lexical
4
4
  // index. Gemini's embedding model through the user's own key (the same key
5
5
  // Image Studio and the Gemini CLI use); no key, no embeddings, and recall stays
package/src/enlaces.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
  // Links between rooms (docs/MACROVERSO.md, phase 3b): the contract two rooms sign, the key that
4
4
  // proves a caller is a MADRE process on this Mac, the side that asks, and the counters of what
5
5
  // crossed. A link reads; nothing here writes in another room.