@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,147 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // Where MADRE runs (2026-10-28, docs/private/BIENVENIDA-1.0.6.md). `process.platform` was all MADRE
4
+ // knew of its place, and three real places were not what it assumed: Linux inside Windows (WSL), a
5
+ // virtual machine, and a computer reached from another one over SSH. In each, the browser did not
6
+ // open and nothing said why; a virtual machine ran the local AI slowly without a word. What is read
7
+ // here is what the system says of itself — files, variables, its own tools —, never guessed, and
8
+ // each reading that fails leaves its answer empty rather than wrong. The welcome adapts its steps to
9
+ // it, and the terminal says what to do when the browser cannot be opened from here.
10
+
11
+ import { execFile } from 'node:child_process';
12
+ import { access, readFile, statfs } from 'node:fs/promises';
13
+ import { homedir, userInfo } from 'node:os';
14
+
15
+ const quiet = (command, args, { timeout = 2500, cwd } = {}) => new Promise((resolve) => {
16
+ try { execFile(command, args, { timeout, cwd, windowsHide: true }, (error, stdout) => resolve(error ? null : String(stdout))); } catch { resolve(null); }
17
+ });
18
+ const exists = (file) => access(file).then(() => true, () => false);
19
+ const gb = (bytes) => Math.round((bytes / 1e9) * 10) / 10;
20
+
21
+ // The names a virtual machine gives itself, as the firmware or systemd write them.
22
+ const VM_NAMES = [
23
+ [/virtualbox|innotek/i, 'VirtualBox'], [/vmware/i, 'VMware'], [/parallels/i, 'Parallels'], [/qemu|kvm|bochs/i, 'QEMU/KVM'],
24
+ [/utm/i, 'UTM'], [/xen/i, 'Xen'], [/hyper-v|virtual machine/i, 'Hyper-V'], [/amazon ec2|google compute|droplet|openstack/i, 'Cloud'],
25
+ ];
26
+ const VIRT_WORDS = { oracle: 'VirtualBox', vmware: 'VMware', parallels: 'Parallels', kvm: 'QEMU/KVM', qemu: 'QEMU/KVM', microsoft: 'Hyper-V', xen: 'Xen', bochs: 'QEMU/KVM', amazon: 'Cloud', apple: 'Apple' };
27
+
28
+ export async function detectEnvironment({ platform = process.platform, env = process.env, read = (file) => readFile(file, 'utf8'), run = quiet, has = exists, space = statfs, home = homedir() } = {}) {
29
+ const os = platform === 'darwin' ? 'macos' : platform === 'win32' ? 'windows' : platform === 'linux' ? 'linux' : platform;
30
+ // Linux inside Windows: the kernel says so, and WSL names its distribution.
31
+ let wsl = null;
32
+ if (platform === 'linux') {
33
+ const kernel = await read('/proc/version').catch(() => '');
34
+ if (env.WSL_DISTRO_NAME || /microsoft/i.test(kernel)) wsl = { distro: env.WSL_DISTRO_NAME || null, version: /wsl2|microsoft-standard/i.test(kernel) ? 2 : 1 };
35
+ // Where Windows answers from inside WSL 2 (NAT, the default): the way out of the virtual network,
36
+ // read from the routing table. The nameserver WSL writes was the same address until DNS tunneling
37
+ // (WSL 2.2) made it 10.255.255.254, which is not Windows; it is only the fallback now. The welcome
38
+ // offers this as the address of an Ollama installed in Windows.
39
+ if (wsl) {
40
+ const route = String(await read('/proc/net/route').catch(() => ''));
41
+ const hex = route.split('\n').map((line) => line.trim().split(/\s+/)).find((cols) => cols[1] === '00000000' && /^[0-9A-F]{8}$/i.test(cols[2] ?? '') && cols[2] !== '00000000')?.[2];
42
+ const gateway = hex ? hex.match(/../g).reverse().map((byte) => parseInt(byte, 16)).join('.') : null;
43
+ const nameserver = String(await read('/etc/resolv.conf').catch(() => '')).match(/^nameserver\s+(\d+\.\d+\.\d+\.\d+)\s*$/m)?.[1] ?? null;
44
+ wsl.windowsHost = gateway ?? (nameserver && nameserver !== '10.255.255.254' ? nameserver : null);
45
+ }
46
+ }
47
+ // The system's own name for itself, as a person would read it: «Ubuntu 24.04.1 LTS», «macOS 26.0».
48
+ let name = null;
49
+ if (platform === 'linux') name = String(await read('/etc/os-release').catch(() => '')).match(/^PRETTY_NAME="?([^"\n]+)"?$/m)?.[1] ?? null;
50
+ else if (platform === 'darwin') { const version = (await run('sw_vers', ['-productVersion']))?.trim(); name = version ? `macOS ${version}` : 'macOS'; }
51
+ // Reached from another computer: the variables sshd leaves in every session.
52
+ const pair = String(env.SSH_CONNECTION ?? '').trim().split(/\s+/);
53
+ let user = null;
54
+ try { user = userInfo().username; } catch { /* no user to name */ }
55
+ const ssh = env.SSH_CONNECTION || env.SSH_CLIENT || env.SSH_TTY ? { from: pair[0] || String(env.SSH_CLIENT ?? '').split(/\s+/)[0] || null, host: pair[2] || null, user } : null;
56
+ // A virtual machine, by what systemd or the firmware call it; WSL is not counted as one here.
57
+ let vm = null;
58
+ if (platform === 'linux' && !wsl) {
59
+ const virt = (await run('systemd-detect-virt', ['--vm']))?.trim();
60
+ if (virt && virt !== 'none') vm = VIRT_WORDS[virt] ?? virt;
61
+ else {
62
+ const firmware = `${await read('/sys/class/dmi/id/product_name').catch(() => '')} ${await read('/sys/class/dmi/id/sys_vendor').catch(() => '')}`;
63
+ vm = VM_NAMES.find(([pattern]) => pattern.test(firmware))?.[1] ?? null;
64
+ }
65
+ } else if (platform === 'darwin') {
66
+ if ((await run('sysctl', ['-n', 'kern.hv_vmm_present']))?.trim() === '1') vm = 'macOS';
67
+ }
68
+ const container = platform === 'linux' && !wsl && (await has('/.dockerenv') || /docker|containerd|kubepods|lxc/.test(await read('/proc/1/cgroup').catch(() => '')));
69
+ // A screen to open a browser on: a Linux without one, or anything reached over SSH, has none here.
70
+ // WSL has Windows' own.
71
+ const display = platform === 'linux' ? Boolean(wsl || env.DISPLAY || env.WAYLAND_DISPLAY) : true;
72
+ const disk = await space(home).then((info) => ({ freeGb: gb(Number(info.bavail) * Number(info.bsize)), totalGb: gb(Number(info.blocks) * Number(info.bsize)) })).catch(() => null);
73
+ // One word for the place, the one that changes most what the person has to do.
74
+ const place = ssh ? 'ssh' : wsl ? 'wsl' : container ? 'container' : vm ? 'vm' : 'local';
75
+ return { os, platform, name, place, wsl, vm, container: Boolean(container), ssh, display: ssh ? false : display, disk };
76
+ }
77
+
78
+ let measured = null;
79
+ // Read once per process for what does not change under a running MADRE; the free space is read again.
80
+ export async function environmentOnce(options) {
81
+ measured ??= detectEnvironment(options).catch(() => null);
82
+ const once = await measured;
83
+ if (!once) return null;
84
+ const disk = await statfs(homedir()).then((info) => ({ freeGb: gb(Number(info.bavail) * Number(info.bsize)), totalGb: gb(Number(info.blocks) * Number(info.bsize)) })).catch(() => once.disk);
85
+ return { ...once, disk };
86
+ }
87
+
88
+ // How this computer opens a page in its browser, or null when it cannot from here: over SSH the
89
+ // browser is on the other computer; a Linux with no screen has none. In WSL, Windows' own browser,
90
+ // by wslview when it is installed or by Windows' `cmd.exe` (run from a Windows folder, which it asks for).
91
+ export function browserWays(environment, { platform = process.platform } = {}) {
92
+ if (environment?.place === 'ssh') return [];
93
+ if (platform === 'darwin') return [{ command: 'open', args: (url) => [url] }];
94
+ if (platform === 'win32') return [{ command: 'cmd', args: (url) => ['/c', 'start', '', url] }];
95
+ if (environment?.wsl) return [
96
+ { command: 'wslview', args: (url) => [url] },
97
+ { command: 'cmd.exe', args: (url) => ['/c', 'start', '', url], cwd: '/mnt/c', windows: true },
98
+ { command: 'explorer.exe', args: (url) => [url], anyExit: true, windows: true },
99
+ ];
100
+ if (environment && !environment.display) return [];
101
+ return [{ command: 'xdg-open', args: (url) => [url] }];
102
+ }
103
+
104
+ // Opens the page, trying each way in turn. Answers whether one of them did: a missing program or one
105
+ // that failed moves on to the next, and none left is said by the caller, in the terminal.
106
+ export async function openBrowser(url, environment, { run = execFile, platform = process.platform } = {}) {
107
+ // A folder, not a page, handed to Windows from WSL goes by its Windows name (\\wsl.localhost\…):
108
+ // its Linux path meant nothing to cmd.exe or explorer.exe. wslpath says it; wslview needs no help.
109
+ let windowsName = null;
110
+ const asWindows = async () => {
111
+ if (windowsName !== null || /^[a-z][a-z0-9+.-]*:\/\//i.test(url)) return windowsName ?? url;
112
+ windowsName = await new Promise((resolve) => {
113
+ try { run('wslpath', ['-w', url], { timeout: 3000 }, (error, stdout) => resolve(error ? url : String(stdout ?? '').trim() || url)); } catch { resolve(url); }
114
+ });
115
+ return windowsName;
116
+ };
117
+ for (const way of browserWays(environment, { platform })) {
118
+ const target = way.windows ? await asWindows() : url;
119
+ const opened = await new Promise((resolve) => {
120
+ try {
121
+ run(way.command, way.args(target), { timeout: 8000, windowsHide: true, ...(way.cwd ? { cwd: way.cwd } : {}) }, (error) => resolve(!error || (way.anyExit && error.code !== 'ENOENT')));
122
+ } catch { resolve(false); }
123
+ });
124
+ if (opened) return true;
125
+ }
126
+ return false;
127
+ }
128
+
129
+ // What the terminal says when no browser opened: where to open MADRE, and over SSH the one command
130
+ // to run on the person's own computer, with this session's own user, address and ports.
131
+ export function tunnelCommand(environment, ports, { user = environment?.ssh?.user, host = environment?.ssh?.host } = {}) {
132
+ const forwards = [...new Set(ports.filter((port) => Number.isInteger(port) && port > 0))].map((port) => `-L ${port}:127.0.0.1:${port}`).join(' ');
133
+ return `ssh ${forwards} ${user ? `${user}@` : ''}${host ?? 'your-server'}`;
134
+ }
135
+ export function browserAdvice(environment, address, { t = (text, vars = {}) => text.replace(/\{(\w+)\}/g, (_, key) => vars[key] ?? '') } = {}) {
136
+ const port = Number(new URL(address).port) || 80;
137
+ if (environment?.place === 'ssh') {
138
+ return [
139
+ t('You are connected to this computer from another one (SSH), so the browser is over there.'),
140
+ t('On your own computer, open another terminal and paste:'),
141
+ ` ${tunnelCommand(environment, [port])}`,
142
+ t('Then open {address} in your browser.', { address }),
143
+ ];
144
+ }
145
+ if (environment?.wsl) return [t('Open this address in your Windows browser:'), ` ${address.replace('127.0.0.1', 'localhost')}`];
146
+ return [t('Open this address in a browser on this computer:'), ` ${address}`];
147
+ }
@@ -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 { mkdir, open, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';
4
4
  import { dirname, join } from 'node:path';
5
5
  import { randomUUID } from 'node:crypto';
package/src/exam.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 three tests that answer "is this room ready to be developed with?"
4
4
  //
5
5
  // The maturity reading counts what the archive is made of. It cannot tell you whether the archive
@@ -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 { spawn } from 'node:child_process';
4
4
  import { MODULES, moduleById, describeModules } from './modules/index.mjs';
5
5
  export { gitToplevel, findOnPath } from './modules/helpers.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
  // EYECAT, as the room runs it. The judgement lives in eyecat.mjs; this schedules it, picks who
4
4
  // may answer, and puts what comes back in front of the human.
5
5
  //
package/src/eyecat.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
  // EYECAT: the watcher that asks whether the room still believes what it wrote down.
4
4
  //
5
5
  // Pure functions here. Nothing in this file talks to a model, reads a file or touches the room;
package/src/file-ops.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
  // Copying and moving a file, from the human's own hands.
4
4
  //
5
5
  // Everything else in MADRE that writes into a project is an agent under a permission mode. This
package/src/files.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 { createHash, randomUUID } from 'node:crypto';
4
4
  import { mkdir, readdir, readFile, realpath, stat, writeFile } from 'node:fs/promises';
5
5
  import { dirname, extname, join, resolve, sep } from 'node:path';
package/src/github.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
  // GitHub, as the GITHUB module and its MCP server both speak to it.
4
4
  //
5
5
  // Two ways in, and the order matters. First the `gh` CLI, if this computer has it and it is
package/src/heartbeat.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
  // «Still in use»: once a day, every copy of MADRE tells madre.run it is on (2026-10-13).
4
4
  //
5
5
  // What goes, and nothing else: a random identifier this copy made for itself once
@@ -0,0 +1,76 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // A project's history over a period, for modules (docs/SDK.md, `ctx.services.history`): what the
4
+ // human asked and to whom, how each agent answered, what it cost, which files a turn changed and
5
+ // whether that was undone, and the decisions the memory kept. Read from the ledgers as they are
6
+ // on disk, never written. GHOST turns are not here: what was said off the record stays off it.
7
+ // Built for the Market's first paid module (Informe de trabajo, 2026-10-19), and for any module
8
+ // that reports on the work: one documented shape instead of each one parsing the ledgers.
9
+
10
+ const TEXT_MAX = 600;
11
+ const at = (event) => String(event?.timestamp ?? '');
12
+ const inside = (when, since, until) => (!since || when >= since) && (!until || when < until);
13
+ const money = (value) => (Number.isFinite(value) && value > 0 ? value : 0);
14
+
15
+ // `chats`: [{ id, title, events }], each conversation's ledger already parsed, oldest first.
16
+ // `memories`: the archive's notes ({ created, kind, text, agent }). `since`/`until`: ISO strings.
17
+ export function summarizeHistory({ chats = [], memories = [], since = null, until = null } = {}) {
18
+ const requests = [];
19
+ const answers = [];
20
+ const changes = [];
21
+ const agents = {};
22
+ const conversations = [];
23
+ const agent = (id) => (agents[id] ??= { turns: 0, failed: 0, tokens: 0, costUsd: 0, local: false });
24
+ for (const chat of chats) {
25
+ let asked = 0;
26
+ const reverted = new Set();
27
+ for (const event of chat.events ?? []) if (event?.type === 'control.reverted' && event.payload?.checkpointId) reverted.add(event.payload.checkpointId);
28
+ for (const event of chat.events ?? []) {
29
+ if (!event || event.ghost || !inside(at(event), since, until)) continue;
30
+ const p = event.payload ?? {};
31
+ if (event.type === 'message.created' && p.role === 'user' && p.sender === 'you') {
32
+ asked += 1;
33
+ requests.push({ at: at(event), chat: chat.id, to: p.target ?? null, mode: Number.isFinite(p.mode) ? p.mode : null, text: String(p.text ?? '').slice(0, TEXT_MAX) });
34
+ } else if (event.type === 'message.created' && p.role === 'assistant' && p.sender && p.sender !== 'you') {
35
+ agent(p.sender).turns += 1;
36
+ answers.push({ at: at(event), chat: chat.id, agent: p.sender, text: String(p.text ?? '').slice(0, TEXT_MAX) });
37
+ } else if (event.type === 'message.failed') {
38
+ if (p.target) agent(p.target).failed += 1;
39
+ } else if (event.type === 'usage.recorded' && p.agent) {
40
+ const one = agent(p.agent);
41
+ one.tokens += Number.isFinite(p.usage?.totalTokens) ? p.usage.totalTokens : 0;
42
+ one.costUsd += money(p.usage?.costUsd);
43
+ if (p.usage?.local) one.local = true;
44
+ } else if (event.type === 'control.changed') {
45
+ changes.push({
46
+ at: at(event), chat: chat.id, agent: p.agent ?? null, mode: p.mode ?? null,
47
+ files: (p.files ?? []).filter((file) => file?.path).map((file) => ({ status: String(file.status ?? 'M'), path: String(file.path) })),
48
+ undone: reverted.has(p.checkpointId),
49
+ });
50
+ }
51
+ }
52
+ if (asked) conversations.push({ id: chat.id, title: chat.title ?? null, requests: asked });
53
+ }
54
+ const decisions = memories
55
+ .filter((note) => note?.kind === 'decision' && inside(String(note.created ?? ''), since, until))
56
+ .map((note) => ({ at: String(note.created), text: String(note.text ?? '').slice(0, TEXT_MAX), agent: note.agent ?? null }));
57
+ const byTime = (a, b) => a.at.localeCompare(b.at);
58
+ const files = new Map();
59
+ for (const change of changes) if (!change.undone) for (const file of change.files) files.set(file.path, file.status);
60
+ return {
61
+ since, until,
62
+ requests: requests.sort(byTime),
63
+ answers: answers.sort(byTime),
64
+ changes: changes.sort(byTime),
65
+ files: [...files].map(([path, status]) => ({ path, status })).sort((a, b) => a.path.localeCompare(b.path)),
66
+ decisions: decisions.sort(byTime),
67
+ agents,
68
+ conversations,
69
+ totals: {
70
+ requests: requests.length,
71
+ answers: answers.length,
72
+ tokens: Object.values(agents).reduce((sum, one) => sum + one.tokens, 0),
73
+ costUsd: Math.round(Object.values(agents).reduce((sum, one) => sum + one.costUsd, 0) * 10000) / 10000,
74
+ },
75
+ };
76
+ }
package/src/i18n.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 room's language, on this side of the wire.
4
4
  //
5
5
  // The catalogue is the page's: public/es.js, one file for the whole product, because a sentence
@@ -15,9 +15,11 @@
15
15
  // what a reading means. Same rule as the page: the key is the English sentence, and a sentence
16
16
  // nobody has translated comes back in English, whole.
17
17
 
18
+ import { hostname } from 'node:os';
18
19
  import { ES } from '../public/es.js';
20
+ import { EN } from '../public/en.js';
19
21
 
20
- const CATALOGUES = { es: ES, en: {} };
22
+ const CATALOGUES = { es: ES, en: EN };
21
23
  let current = 'es';
22
24
 
23
25
  export const language = () => current;
@@ -30,9 +32,23 @@ export function setLanguage(id) {
30
32
  // it runs on says «computer» there. Same rule as public/i18n.js (hostWords); hardware named on
31
33
  // purpose («a Mac with an M chip») has no article in front and is left alone.
32
34
  let hostIsMac = process.platform === 'darwin';
35
+ // The machine's own name, said instead of «this computer» where it is not a Mac (2026-10-20).
36
+ const ownName = () => { try { return hostname().replace(/\.local$/i, '').trim().slice(0, 64) || null; } catch { return null; } };
37
+ let hostName = ownName();
33
38
  export const setHostIsMac = (value) => { hostIsMac = Boolean(value); return hostIsMac; };
39
+ export const setHostName = (value) => { hostName = typeof value === 'string' && value.trim() ? value.trim().slice(0, 64) : null; return hostName; };
40
+ // What the page is told about the machine it is served by (src/server.mjs puts it in a <meta>).
41
+ export const hostFacts = () => ({ os: process.platform, name: hostName });
34
42
  export function hostWords(text) {
35
43
  if (hostIsMac || typeof text !== 'string' || !text.includes('Mac')) return text;
44
+ // With the machine's own name (2026-10-20) a sentence about it names it: «Found on cotizapp2».
45
+ if (hostName) {
46
+ return text
47
+ .replace(/\b(on|in|from|to) (this|your|the) Mac\b/g, `$1 ${hostName}`)
48
+ .replace(/\b(this|your|the|This|Your|The) Mac\b/g, hostName)
49
+ .replace(/(^|[^\p{L}])(en|de|a|desde) (esta|tu|la) Mac\b/gu, `$1$2 ${hostName}`)
50
+ .replace(/(^|[^\p{L}])(esta|tu|la|Esta|Tu|La) Mac\b/gu, `$1${hostName}`);
51
+ }
36
52
  return text
37
53
  .replace(/\b(this|your|the|This|Your|The) Mac\b/g, '$1 computer')
38
54
  .replace(/(^|[^\p{L}])(esta|tu|la|Esta|Tu|La) Mac\b/gu, '$1$2 computadora');
@@ -66,7 +82,20 @@ export function t(text, vars = null) {
66
82
  // because those are not sentences and a translated id is a bug.
67
83
  const PROSE = new Set(['summary', 'detail', 'note', 'says', 'brief', 'what', 'when', 'where', 'why', 'hint', 'title', 'label', 'remedy', 'diagnosis', 'creates', 'requires']);
68
84
 
85
+ // A module's words in both languages, { es, en } (SDK, 2026-10-20): the one the room speaks, or the
86
+ // other when it only wrote one. Anything else comes back as it was.
87
+ export const isBilingual = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => key === 'es' || key === 'en') && Object.values(value).every((one) => typeof one === 'string');
88
+ export const inRoomLanguage = (value) => (isBilingual(value) ? value[current] ?? value.es ?? value.en : value);
89
+ // What a module says, as ctx.t (SDK 2, 2026-10-25): an English sentence MADRE's catalogue knows,
90
+ // or the module's own { es, en } — the way to bring a sentence MADRE has not learned yet.
91
+ export function say(text, vars = null) {
92
+ if (!isBilingual(text)) return t(text, vars);
93
+ const said = hostWords(String(inRoomLanguage(text) ?? ''));
94
+ return vars ? said.replace(/\{(\w+)\}/g, (whole, name) => (Object.hasOwn(vars, name) ? String(vars[name]) : whole)) : said;
95
+ }
96
+
69
97
  export function translate(value, key = null) {
98
+ if (isBilingual(value)) return value[current] ?? value.es ?? value.en;
70
99
  if (Array.isArray(value)) return value.map((one) => translate(one, key));
71
100
  if (value && typeof value === 'object') {
72
101
  const out = {};
@@ -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
  import { resolveGeminiKey } from './mcp/image-server.mjs';
5
5
 
@@ -0,0 +1,109 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // WHAT THE AUTHOR LEARNS OF EACH COPY (2026-10-30), never of the person: how the copy runs and where,
4
+ // whether it was installed, updated or uninstalled, and whether it is on right now. Three things,
5
+ // all inside the anonymous diagnostics (src/telemetry.mjs) and off with it (Settings › Version and
6
+ // reports, or PULSE_TELEMETRY=0):
7
+ //
8
+ // · the environment — numbers and names of MADRE's own parts, written as the diagnostics' gauges:
9
+ // cores and memory (GB), the language MADRE speaks, how it was installed (npx, global, project,
10
+ // source), the shell's name, whether Ollama is there and on, which agents are installed and ready,
11
+ // how many projects and how many open, which of MADRE's own modules are on, and how many days the
12
+ // copy has. No path, no project name, no file, nothing a person wrote; a module the person wrote
13
+ // only counts as «another».
14
+ // · its life — counts: installed (a copy that never had an identifier), updated (a new version
15
+ // first opened), uninstalled (Settings › Uninstall, sent before anything is removed), and each
16
+ // time Home starts.
17
+ // · its presence — every few minutes while MADRE is open, the random id, the version and the system
18
+ // to madre.run/api/presence, so the author knows how many copies are on now. One process of the
19
+ // copy says it; the others see it was said.
20
+ //
21
+ // docs/REFERENCE.md › «Lo que sale de la máquina» says all of it; madre.run's privacy page too.
22
+ import { readFile, writeFile } from 'node:fs/promises';
23
+ import { basename, join } from 'node:path';
24
+ import { installId } from './heartbeat.mjs';
25
+ import { compareVersions } from './updates.mjs';
26
+
27
+ export const PRESENCE_URL = 'https://madre.run/api/presence';
28
+ export const PRESENCE_EVERY_MS = 5 * 60 * 1000;
29
+ const KEY_PART = /^[a-z0-9][a-z0-9-]{0,30}$/;
30
+ const CHANNELS = new Set(['npx', 'global', 'project', 'source']);
31
+ const SHELLS = new Set(['zsh', 'bash', 'fish', 'sh', 'pwsh', 'powershell', 'nu', 'dash', 'ksh', 'tcsh']);
32
+ const GB = 1024 ** 3;
33
+
34
+ // The environment as gauges: only keys made of MADRE's own words, only numbers.
35
+ export function environmentGauges({ cores = 0, ramBytes = 0, language = null, install = null, shell = '', ollama = {}, agents = [], projects = {}, modules = [], ownModules = new Set(), ageDays = null } = {}) {
36
+ const out = {};
37
+ if (cores > 0) out['env.cores'] = Math.round(cores);
38
+ if (ramBytes > 0) out['env.ram'] = Math.max(1, Math.round(ramBytes / GB));
39
+ if (language === 'es' || language === 'en') out[`env.lang.${language}`] = 1;
40
+ if (CHANNELS.has(install)) out[`env.channel.${install}`] = 1;
41
+ const shellName = basename(String(shell ?? '')).toLowerCase().replace(/\.exe$/, '');
42
+ if (shellName) out[`env.shell.${SHELLS.has(shellName) ? shellName : 'other'}`] = 1;
43
+ if (ollama.installed || ollama.running) out['env.ollama'] = 1;
44
+ if (ollama.running) out['env.ollama.on'] = 1;
45
+ if (Number.isFinite(ollama.models)) out['env.ollama.models'] = ollama.models;
46
+ for (const one of agents) {
47
+ if (!KEY_PART.test(String(one?.id ?? ''))) continue;
48
+ if (one.detected) out[`agent.${one.id}`] = 1;
49
+ if (one.ready) out[`agent.${one.id}.ready`] = 1;
50
+ }
51
+ out['agents.ready'] = agents.filter((one) => one?.ready).length;
52
+ if (Number.isFinite(projects.total)) out['projects.total'] = projects.total;
53
+ if (Number.isFinite(projects.open)) out['projects.open'] = projects.open;
54
+ let others = 0;
55
+ for (const id of modules) {
56
+ if (ownModules.has(id) && KEY_PART.test(id)) out[`module.${id}`] = 1;
57
+ else others += 1;
58
+ }
59
+ out['modules.on'] = modules.length;
60
+ if (others) out['modules.other'] = others;
61
+ if (Number.isFinite(ageDays) && ageDays >= 0) out['install.age'] = Math.floor(ageDays);
62
+ return out;
63
+ }
64
+
65
+ // Installed, updated or neither, said once per change: ~/.pulse/lifecycle.json keeps the version this
66
+ // copy last opened. A copy with no record and no identifier is new; with an identifier but no record
67
+ // it was there before 1.1.0 and is counted as updated. A version older than the last one counts as
68
+ // neither (someone went back on purpose).
69
+ export async function noteLifecycle({ root, version, hadId, now = new Date() }) {
70
+ const file = join(root, 'lifecycle.json');
71
+ let kept = null;
72
+ try { kept = JSON.parse(await readFile(file, 'utf8')); } catch { /* none yet */ }
73
+ let event = null;
74
+ if (!kept?.version) event = hadId ? 'update' : 'install';
75
+ else if (kept.version !== version && compareVersions(version, kept.version) > 0) event = 'update';
76
+ if (!kept?.version || kept.version !== version) {
77
+ // `before`: this copy was in use before 1.1.0 (src/terms.mjs tells it what changed).
78
+ const before = kept ? kept.before === true : Boolean(hadId);
79
+ await writeFile(file, `${JSON.stringify({ first: kept?.first ?? now.toISOString(), version, at: now.toISOString(), ...(before ? { before: true } : {}) })}\n`).catch(() => null);
80
+ }
81
+ return { event, first: kept?.first ?? now.toISOString() };
82
+ }
83
+
84
+ // Where the presence goes: a copy that sends its diagnostics elsewhere (tests, QA houses) sends its
85
+ // presence beside them, never to madre.run.
86
+ export function presenceUrl(env = process.env) {
87
+ if (env.PULSE_PRESENCE_URL) return env.PULSE_PRESENCE_URL;
88
+ if (env.PULSE_TELEMETRY_URL) return env.PULSE_TELEMETRY_URL.replace(/\/telemetry\/?$/, '/presence');
89
+ return PRESENCE_URL;
90
+ }
91
+
92
+ export const presenceBody = ({ id, version, platform = process.platform }) => ({
93
+ id, version, os: ['darwin', 'linux', 'win32'].includes(platform) ? platform : 'other',
94
+ });
95
+
96
+ // «Still here», at most once every few minutes per copy, whichever of its processes gets there first.
97
+ export async function sayPresent({ root, version, fetchImpl = globalThis.fetch, url = presenceUrl(), now = Date.now() }) {
98
+ const mark = join(root, 'presence-at');
99
+ const last = Number((await readFile(mark, 'utf8').catch(() => '')).trim()) || 0;
100
+ if (now - last < PRESENCE_EVERY_MS - 30_000) return { sent: false, reason: 'recent' };
101
+ await writeFile(mark, String(now)).catch(() => null);
102
+ try {
103
+ const body = presenceBody({ id: await installId(root), version });
104
+ const response = await fetchImpl(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body), signal: AbortSignal.timeout(5000) });
105
+ return response.ok ? { sent: true, body } : { sent: false, reason: `HTTP ${response.status}` };
106
+ } catch (error) {
107
+ return { sent: false, reason: error?.message ?? 'unreachable' };
108
+ }
109
+ }
package/src/json-file.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
  // Small files that more than one thing changes at once (2026-10-12, Lote 2 of the 1.0 review): the
4
4
  // tour, the review ask, a project's record of where it is, the list of a room's conversations.
5
5
  // Each was read, changed and written with nothing between two changes, so the second one wrote
package/src/launch.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
  // What is shown of a command, and what is never shown.
4
4
  //
5
5
  // THE LAUNCH floor in the core prints the exact command MADRE would run, because a person who is
package/src/lease.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 { mkdir, readdir, realpath, stat } from 'node:fs/promises';
4
4
  import { join, relative, sep } from 'node:path';
5
5
  import { declaredTypeFor } from './files.mjs';
@@ -99,6 +99,12 @@ export function diffSnapshots(before, after, { relativeDir }) {
99
99
  return artifacts.sort((a, b) => a.path.localeCompare(b.path));
100
100
  }
101
101
 
102
+ // Which agents may use their own CLI's subagents in a turn that writes (2026-10-29): from #1 to #3,
103
+ // the ones whose adapter hands a subagent exactly the turn's permissions (src/adapters/claude.mjs,
104
+ // opencode.mjs; Codex's subagents inherit its sandbox). Never in #4.
105
+ export const SUBAGENT_AGENTS = new Set(['claude', 'opencode', 'codex']);
106
+ export const subagentsAllowed = (agentId, { airlock = false } = {}) => !airlock && SUBAGENT_AGENTS.has(agentId);
107
+
102
108
  export function leaseInstructions({ outDir, agentId, scopes = { write: true, imageGen: agentId === 'codex' }, capable = null, imageStudio = null, control = false, create = false, airlock = false, scratchDir = null }) {
103
109
  const canImage = Boolean(scopes.imageGen);
104
110
  const couldImage = capable ? Boolean(capable.imageGen?.capable) : canImage;
@@ -122,8 +128,13 @@ export function leaseInstructions({ outDir, agentId, scopes = { write: true, ima
122
128
  : couldImage ? 'Image generation is switched off for this request; if asked for an image, say so and do not attempt it.'
123
129
  : 'You cannot generate images from this CLI; if asked for one, say so plainly instead of attempting it.',
124
130
  // «Do not hand it to another agent» read as «do not plan»: with a lease, agents stopped proposing
125
- // pulse plans altogether (2026-10-14). What is barred is the CLI's own subagents, not the room's.
126
- 'Do this work yourself rather than through your CLI\'s own subagents or spawned agents: a subagent writes outside this lease, so nothing it did would be checked, shown to the human or undoable — and the tools for it are blocked, which can leave you waiting instead of answering. A pulse plan that puts the room\'s other agents to work is different and still allowed.',
131
+ // pulse plans altogether (2026-10-14). What this line is about is the CLI's own subagents, not
132
+ // the room's. From #1 to #3 (2026-10-29) Claude, OpenCode and Codex may use theirs: each adapter
133
+ // gives them exactly this turn's permissions, and what they change is in the same checkpoint. In
134
+ // #4, and for the others, only the agent itself works.
135
+ subagentsAllowed(agentId, { airlock })
136
+ ? 'Your CLI\'s own subagents may help with this: they work with exactly this permission, and whatever they change is in the same checkpoint, listed to the human and undoable. Write each subagent\'s task in the language of this conversation and ask it to report in that language, since the human reads its report. If you used subagents, say in your answer what you handed to each one; if you did not, do not mention them. A pulse plan that puts the room\'s other agents to work is different and still allowed.'
137
+ : `Do this work yourself rather than through your CLI's own subagents or spawned agents: ${airlock ? 'in AIRLOCK (#4) only you work, because what leaves the machine does not come back' : 'a subagent would work outside the permission MADRE controls'}, and the tools for it are blocked, which can leave you waiting instead of answering. A pulse plan that puts the room's other agents to work is different and still allowed.`,
127
138
  'List the files you created (or "none") before any plan block; nothing may follow a plan block.',
128
139
  ].filter(Boolean).join('\n');
129
140
  }
@@ -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 was worked on last on this Mac, for the lobby (2026-10-10): the newest conversations of
4
4
  // every room the lobby knows, open or asleep, each with its last few lines, and the summary MADRE
5
5
  // writes of them with its local model. Everything here READS: a room's list of conversations
@@ -61,8 +61,15 @@ export async function recentWork({ stateRoot, rooms, now = Date.now(), days = 14
61
61
  for (const chat of fresh) found.push({ room: room.id, name: room.name, chat: chat.id, title: chat.title, at: chat.updatedAt, messages: chat.messages });
62
62
  }
63
63
  found.sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
64
- const newest = found.slice(0, limit);
65
- for (const item of newest) item.said = await lastMessages(chatLedger(join(stateRoot, 'rooms', item.room), item.chat));
64
+ // A conversation where nobody answered (a question whose turn failed) is not work done: summarised,
65
+ // it read «Se preguntó cuántos proyectos se tenían» (QA 1.1.0, ACT-15).
66
+ const newest = [];
67
+ for (const item of found) {
68
+ if (newest.length >= limit) break;
69
+ item.said = await lastMessages(chatLedger(join(stateRoot, 'rooms', item.room), item.chat));
70
+ if (!item.said.some((one) => one.who !== 'person')) continue;
71
+ newest.push(item);
72
+ }
66
73
  return newest;
67
74
  }
68
75