@jossuealcala/madre 1.0.5 → 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 (278) hide show
  1. package/ADDITIONAL-TERMS.md +7 -2
  2. package/CHANGELOG.en.md +47 -1
  3. package/CHANGELOG.md +47 -1
  4. package/CONTRIBUTING.md +2 -2
  5. package/LICENSE +111 -661
  6. package/NOTICE +28 -23
  7. package/README.en.md +30 -101
  8. package/README.md +30 -103
  9. package/SECURITY.md +1 -0
  10. package/TRADEMARKS.en.md +13 -14
  11. package/TRADEMARKS.md +24 -26
  12. package/bin/madre.cjs +2 -2
  13. package/bin/madre.mjs +112 -40
  14. package/docs/REFERENCE.md +52 -5
  15. package/docs/SDK.md +21 -3
  16. package/docs/en/REFERENCE.md +52 -5
  17. package/docs/en/SDK.md +22 -3
  18. package/docs/sdk/hello-module.mjs +3 -0
  19. package/package.json +3 -2
  20. package/public/abduction.js +6 -6
  21. package/public/activity.js +425 -0
  22. package/public/app.js +2468 -435
  23. package/public/assets/abduction-cat-blink.webp +0 -0
  24. package/public/assets/abduction-cat-control-left.webp +0 -0
  25. package/public/assets/abduction-cat-control-right.webp +0 -0
  26. package/public/assets/abduction-cat.webp +0 -0
  27. package/public/assets/manual/shots/en-agents.webp +0 -0
  28. package/public/assets/manual/shots/en-chats.webp +0 -0
  29. package/public/assets/manual/shots/en-code.webp +0 -0
  30. package/public/assets/manual/shots/en-composer.webp +0 -0
  31. package/public/assets/manual/shots/en-connectors.webp +0 -0
  32. package/public/assets/manual/shots/en-continuity.webp +0 -0
  33. package/public/assets/manual/shots/en-coordinator.webp +0 -0
  34. package/public/assets/manual/shots/en-copilot.webp +0 -0
  35. package/public/assets/manual/shots/en-diagnostics.webp +0 -0
  36. package/public/assets/manual/shots/en-home.webp +0 -0
  37. package/public/assets/manual/shots/en-local.webp +0 -0
  38. package/public/assets/manual/shots/en-market.webp +0 -0
  39. package/public/assets/manual/shots/en-memory.webp +0 -0
  40. package/public/assets/manual/shots/en-modes.webp +0 -0
  41. package/public/assets/manual/shots/en-notes.webp +0 -0
  42. package/public/assets/manual/shots/en-settings.webp +0 -0
  43. package/public/assets/manual/shots/en-welcome.webp +0 -0
  44. package/public/assets/manual/shots/en-windows.webp +0 -0
  45. package/public/assets/manual/shots/es-agents.webp +0 -0
  46. package/public/assets/manual/shots/es-chats.webp +0 -0
  47. package/public/assets/manual/shots/es-code.webp +0 -0
  48. package/public/assets/manual/shots/es-composer.webp +0 -0
  49. package/public/assets/manual/shots/es-connectors.webp +0 -0
  50. package/public/assets/manual/shots/es-continuity.webp +0 -0
  51. package/public/assets/manual/shots/es-coordinator.webp +0 -0
  52. package/public/assets/manual/shots/es-copilot.webp +0 -0
  53. package/public/assets/manual/shots/es-diagnostics.webp +0 -0
  54. package/public/assets/manual/shots/es-home.webp +0 -0
  55. package/public/assets/manual/shots/es-local.webp +0 -0
  56. package/public/assets/manual/shots/es-market.webp +0 -0
  57. package/public/assets/manual/shots/es-memory.webp +0 -0
  58. package/public/assets/manual/shots/es-modes.webp +0 -0
  59. package/public/assets/manual/shots/es-notes.webp +0 -0
  60. package/public/assets/manual/shots/es-settings.webp +0 -0
  61. package/public/assets/manual/shots/es-welcome.webp +0 -0
  62. package/public/assets/manual/shots/es-windows.webp +0 -0
  63. package/public/assets/news/1.1/en/chats.webp +0 -0
  64. package/public/assets/news/1.1/en/home.webp +0 -0
  65. package/public/assets/news/1.1/en/maps.webp +0 -0
  66. package/public/assets/news/1.1/en/market.webp +0 -0
  67. package/public/assets/news/1.1/en/permissions.webp +0 -0
  68. package/public/assets/news/1.1/en/privacy.webp +0 -0
  69. package/public/assets/news/1.1/en/welcome.webp +0 -0
  70. package/public/assets/news/1.1/es/chats.webp +0 -0
  71. package/public/assets/news/1.1/es/home.webp +0 -0
  72. package/public/assets/news/1.1/es/maps.webp +0 -0
  73. package/public/assets/news/1.1/es/market.webp +0 -0
  74. package/public/assets/news/1.1/es/permissions.webp +0 -0
  75. package/public/assets/news/1.1/es/privacy.webp +0 -0
  76. package/public/assets/news/1.1/es/welcome.webp +0 -0
  77. package/public/attribution.js +15 -16
  78. package/public/brands.js +2 -2
  79. package/public/code-tools.js +2 -2
  80. package/public/editor.js +13 -13
  81. package/public/en.js +413 -4
  82. package/public/es.js +1345 -483
  83. package/public/hardware.js +2 -2
  84. package/public/i18n.js +2 -2
  85. package/public/icons.js +158 -0
  86. package/public/index.html +66 -48
  87. package/public/inquiry.js +2 -2
  88. package/public/loader.js +271 -2
  89. package/public/macroverso.js +60 -21
  90. package/public/manual-content.js +412 -169
  91. package/public/manual-shots.js +38 -34
  92. package/public/manual.css +20 -2
  93. package/public/manual.html +1 -1
  94. package/public/manual.js +54 -25
  95. package/public/market-art.js +47 -45
  96. package/public/market-view.js +111 -33
  97. package/public/market.js +132 -30
  98. package/public/mcp-catalog.js +2 -2
  99. package/public/neural.js +64 -8
  100. package/public/nostromo-engine.js +709 -40
  101. package/public/page-errors.js +29 -0
  102. package/public/power.js +350 -11
  103. package/public/remedy.js +89 -0
  104. package/public/resay.js +3 -2
  105. package/public/review-ask.js +12 -7
  106. package/public/routing.js +3 -3
  107. package/public/salas-mac.css +703 -24
  108. package/public/salas-mac.html +26 -14
  109. package/public/salas-mac.js +1254 -289
  110. package/public/salas.css +2 -2
  111. package/public/salas.html +3 -3
  112. package/public/salas.js +3 -3
  113. package/public/styles.css +2404 -291
  114. package/public/syntax.js +2 -2
  115. package/public/terms.js +152 -0
  116. package/public/touch.js +2 -2
  117. package/public/tour-chapters.js +10 -10
  118. package/public/tour.js +56 -8
  119. package/public/troubleshooting.js +182 -11
  120. package/public/wallpaper.js +4 -3
  121. package/public/welcome.js +923 -0
  122. package/src/activity.mjs +85 -0
  123. package/src/adapters/claude.mjs +61 -35
  124. package/src/adapters/codex.mjs +18 -5
  125. package/src/adapters/cursor.mjs +5 -3
  126. package/src/adapters/gemini.mjs +5 -3
  127. package/src/adapters/madre.mjs +3 -3
  128. package/src/adapters/opencode.mjs +73 -10
  129. package/src/adapters/process.mjs +14 -13
  130. package/src/adapters/subagents.mjs +159 -0
  131. package/src/asking.mjs +8 -2
  132. package/src/auth-probe.mjs +27 -10
  133. package/src/bridge/devices.mjs +2 -2
  134. package/src/bridge/handoff.mjs +2 -2
  135. package/src/bridge/host.mjs +2 -2
  136. package/src/bridge/network.mjs +2 -2
  137. package/src/bridge/policy.mjs +3 -3
  138. package/src/bridge/qr.mjs +2 -2
  139. package/src/bridge/server.mjs +2 -2
  140. package/src/builtin-updates.mjs +87 -0
  141. package/src/capabilities.mjs +2 -2
  142. package/src/chats.mjs +51 -2
  143. package/src/checkpoint.mjs +67 -9
  144. package/src/choices.mjs +2 -2
  145. package/src/cli-args.mjs +2 -2
  146. package/src/cold.mjs +2 -2
  147. package/src/commands.mjs +2 -2
  148. package/src/config.mjs +2 -2
  149. package/src/conversation-context.mjs +2 -2
  150. package/src/credentials.mjs +56 -16
  151. package/src/dataset.mjs +2 -2
  152. package/src/directives.mjs +2 -2
  153. package/src/distiller.mjs +2 -2
  154. package/src/embeddings.mjs +2 -2
  155. package/src/enlaces.mjs +2 -2
  156. package/src/environment.mjs +147 -0
  157. package/src/event-store.mjs +2 -2
  158. package/src/exam.mjs +2 -2
  159. package/src/extensions.mjs +2 -2
  160. package/src/eyecat-watch.mjs +2 -2
  161. package/src/eyecat.mjs +2 -2
  162. package/src/file-ops.mjs +2 -2
  163. package/src/files.mjs +2 -2
  164. package/src/github.mjs +2 -2
  165. package/src/heartbeat.mjs +2 -2
  166. package/src/history.mjs +2 -2
  167. package/src/i18n.mjs +9 -2
  168. package/src/image-studio.mjs +2 -2
  169. package/src/install-metrics.mjs +109 -0
  170. package/src/json-file.mjs +2 -2
  171. package/src/launch.mjs +2 -2
  172. package/src/lease.mjs +15 -4
  173. package/src/lobby-work.mjs +11 -4
  174. package/src/local-ai.mjs +2 -2
  175. package/src/looks.mjs +2 -2
  176. package/src/market-check.mjs +165 -0
  177. package/src/market-key.mjs +10 -2
  178. package/src/market-license.mjs +4 -4
  179. package/src/market-remote.mjs +54 -12
  180. package/src/maturity.mjs +2 -2
  181. package/src/mcp/connect.mjs +2 -2
  182. package/src/mcp/github-server.mjs +2 -2
  183. package/src/mcp/image-server.mjs +2 -2
  184. package/src/mcp/memory-server.mjs +2 -2
  185. package/src/mcp/proxy.mjs +2 -2
  186. package/src/mcp/smtp-server.mjs +2 -2
  187. package/src/memory-dashboard.mjs +2 -2
  188. package/src/memory-tools.mjs +2 -2
  189. package/src/memory.mjs +2 -2
  190. package/src/models.mjs +33 -3
  191. package/src/module-scope.mjs +2 -2
  192. package/src/modules/ahp.mjs +2 -2
  193. package/src/modules/ash-policy.mjs +2 -2
  194. package/src/modules/ash.mjs +2 -2
  195. package/src/modules/bishop-exam.mjs +2 -2
  196. package/src/modules/bishop-plan.mjs +2 -2
  197. package/src/modules/bishop.mjs +9 -3
  198. package/src/modules/choices.mjs +2 -2
  199. package/src/modules/correo.mjs +2 -2
  200. package/src/modules/enlaces.mjs +2 -2
  201. package/src/modules/git-pulse.mjs +2 -2
  202. package/src/modules/github.mjs +2 -2
  203. package/src/modules/helpers.mjs +2 -2
  204. package/src/modules/image-studio.mjs +2 -2
  205. package/src/modules/index.mjs +90 -5
  206. package/src/modules/intents-calibration.mjs +2 -2
  207. package/src/modules/intents-desk.mjs +4 -3
  208. package/src/modules/intents-observe.mjs +2 -2
  209. package/src/modules/intents-policy.mjs +2 -2
  210. package/src/modules/intents-try.mjs +2 -2
  211. package/src/modules/intents.mjs +2 -2
  212. package/src/modules/local-models.mjs +14 -11
  213. package/src/modules/mcp-connect.mjs +2 -2
  214. package/src/modules/notes.mjs +159 -20
  215. package/src/modules/ollama.mjs +9 -3
  216. package/src/modules/playwright.mjs +2 -2
  217. package/src/modules/reminders.mjs +356 -37
  218. package/src/modules/ripley.mjs +3 -3
  219. package/src/modules/runs.mjs +2 -2
  220. package/src/modules/sdk.mjs +38 -6
  221. package/src/modules/updates.mjs +2 -2
  222. package/src/mother.mjs +2 -2
  223. package/src/npm-launch.mjs +2 -2
  224. package/src/ollama.mjs +6 -4
  225. package/src/opencode-health.mjs +26 -6
  226. package/src/outbound.mjs +10 -2
  227. package/src/override.mjs +27 -22
  228. package/src/ports.mjs +2 -2
  229. package/src/prices.mjs +2 -2
  230. package/src/privacy.mjs +2 -2
  231. package/src/quota-monitor.mjs +2 -2
  232. package/src/quota-sources.mjs +2 -2
  233. package/src/request-guard.mjs +2 -2
  234. package/src/review-ask.mjs +4 -3
  235. package/src/room/archivist.mjs +2 -2
  236. package/src/room/attachments.mjs +2 -2
  237. package/src/room/budget.mjs +2 -2
  238. package/src/room/context.mjs +2 -2
  239. package/src/room/control.mjs +2 -2
  240. package/src/room/copilot.mjs +2 -2
  241. package/src/room/economy.mjs +2 -2
  242. package/src/room/escalation.mjs +2 -2
  243. package/src/room/ghost.mjs +2 -2
  244. package/src/room/guard.mjs +6 -4
  245. package/src/room/prompt.mjs +3 -3
  246. package/src/room/returns.mjs +2 -2
  247. package/src/room/runs.mjs +6 -4
  248. package/src/room/vectors.mjs +2 -2
  249. package/src/room.mjs +127 -31
  250. package/src/router.mjs +2 -2
  251. package/src/runs.mjs +2 -2
  252. package/src/runtime-detection.mjs +31 -5
  253. package/src/salas.mjs +31 -6
  254. package/src/sentinel-errors.mjs +13 -4
  255. package/src/server-sentinel.mjs +2 -2
  256. package/src/server.mjs +689 -80
  257. package/src/setup-trouble.mjs +33 -0
  258. package/src/setup.mjs +4 -4
  259. package/src/smtp.mjs +2 -2
  260. package/src/telemetry.mjs +266 -0
  261. package/src/terms.mjs +43 -0
  262. package/src/tour.mjs +39 -5
  263. package/src/uninstall.mjs +225 -0
  264. package/src/updates.mjs +2 -2
  265. package/src/usage-sentinel.mjs +2 -2
  266. package/src/vault.mjs +2 -2
  267. package/src/verdict.mjs +13 -10
  268. package/src/whats-new.mjs +97 -3
  269. package/public/assets/abduction-cat-blink.png +0 -0
  270. package/public/assets/abduction-cat-control-left.png +0 -0
  271. package/public/assets/abduction-cat-control-right.png +0 -0
  272. package/public/assets/abduction-cat.png +0 -0
  273. package/public/assets/manual/madre-manual-en.pdf +0 -0
  274. package/public/assets/manual/madre-manual-es.pdf +0 -0
  275. package/public/assets/manual/shots/en-modules.webp +0 -0
  276. package/public/assets/manual/shots/es-modules.webp +0 -0
  277. package/src/mcp/notes-server.mjs +0 -120
  278. package/src/reminder-time.mjs +0 -127
package/src/room.mjs CHANGED
@@ -1,8 +1,9 @@
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 { invokeCodex, buildCodexArgs } from './adapters/codex.mjs';
4
4
  import { t } from './i18n.mjs';
5
5
  import { invokeClaude, buildClaudeArgs } from './adapters/claude.mjs';
6
+ import { keptSubagents } from './adapters/subagents.mjs';
6
7
  import { invokeGemini, buildGeminiArgs } from './adapters/gemini.mjs';
7
8
  import { invokeOpenCode, buildOpenCodeArgs } from './adapters/opencode.mjs';
8
9
  import { invokeCursor, buildCursorArgs } from './adapters/cursor.mjs';
@@ -11,7 +12,7 @@ import { randomUUID } from 'node:crypto';
11
12
  import { basename } from 'node:path';
12
13
  import { homedir } from 'node:os';
13
14
  import { UsageSentinel } from './usage-sentinel.mjs';
14
- import { BLOCK_SOURCES, buildPrompt, promptParts, sparedChars } from './room/prompt.mjs';
15
+ import { BLOCK_SOURCES, buildPrompt, promptParts, sparedChars, wantsModule } from './room/prompt.mjs';
15
16
  import { turnCost, observedRate } from './room/economy.mjs';
16
17
  import { contextFor } from './room/context.mjs';
17
18
  import { VERDICTS, travels } from './memory.mjs';
@@ -34,8 +35,9 @@ import { parseDirectives } from './directives.mjs';
34
35
  import { isValidModelName, isValidEffort, belongsElsewhere, MODEL_NOT_FOUND, codexTakes, readCodexEfforts } from './models.mjs';
35
36
  import { withListPrice } from './prices.mjs';
36
37
  import { MODES, SCOPES, SCOPE_LABELS, capabilitySummary, normalizeMode, resolveScopes } from './capabilities.mjs';
37
- import { createLease, diffSnapshots, namedPaths, snapshot } from './lease.mjs';
38
- import { stat as statFile, readdir, copyFile, readFile as readFileBytes } from 'node:fs/promises';
38
+ import { clip } from './activity.mjs';
39
+ import { createLease, diffSnapshots, namedPaths, snapshot, subagentsAllowed } from './lease.mjs';
40
+ import { stat as statFile, readdir, copyFile, mkdir as mkdirPath, readFile as readFileBytes } from 'node:fs/promises';
39
41
  import { basename as baseName, join as joinPath } from 'node:path';
40
42
  import { declaredTypeFor, filesChangedSince } from './files.mjs';
41
43
  import { isModuleFile, sdkPaths } from './modules/index.mjs';
@@ -351,6 +353,13 @@ export class Room {
351
353
  return event;
352
354
  }
353
355
 
356
+ // What the server learns outside a turn and the page must hear now, never written down: which
357
+ // agents have a session, once the probe that runs at start comes back (QA 1.1.0, NUE-11).
358
+ announce(type, payload) {
359
+ if (!['sessions.updated'].includes(type)) throw new Error(`Not a live announcement: ${type}`);
360
+ return this.#say(type, payload);
361
+ }
362
+
354
363
  // Whoever is watching the room right now. Separate from the ghost channel, which carries turns
355
364
  // that happened off the record: these never happened at all, they are only being reported.
356
365
  subscribeLive(listener) {
@@ -618,7 +627,7 @@ export class Room {
618
627
  }
619
628
  if (which === 'match') {
620
629
  const invoke = this.#invokers[MADRE_ADAPTER];
621
- if (!invoke) return { error: 'The local model is not running. Start Ollama, or open Ollama in Modules.' };
630
+ if (!invoke) return { error: 'The local model is not running. Start Ollama, or set up Local AI in Settings.' };
622
631
  this.#examRunning = 'match';
623
632
  this.#examProgress = { done: 0, total: 0 };
624
633
  // Answered in the background: the human keeps the room while it runs.
@@ -925,7 +934,7 @@ export class Room {
925
934
  // answers the press at once and keeps running; its output card comes when it is stopped.
926
935
  let opened = () => {};
927
936
  const serving = new Promise((resolve) => { opened = resolve; });
928
- const finished = this.#runDesk.run({ id: `${responseMessageId}:${index}`, argv: expandHome(command), cwd: this.#projectRoot, onServing: (where) => opened(where) })
937
+ const finished = this.#runDesk.run({ id: `${responseMessageId}:${index}`, argv: expandHome(command), cwd: this.#projectRoot, onServing: (where) => opened(where), meta: { line: command.line, agent: request.agent, responseMessageId, index } })
929
938
  .then(async (result) => {
930
939
  const changes = checkpoint ? await this.#controlDesk.changesSince(checkpoint).catch(() => null) : null;
931
940
  // What git cannot see — a folder the project ignores — found by its time on disk.
@@ -1176,7 +1185,7 @@ export class Room {
1176
1185
  return { messageId: accepted?.messageId ?? null, responseMessageId: accepted?.responseMessageId ?? null, text: reply?.text ?? null, error: reply ? null : failed?.error ?? 'The turn ended without a reply.' };
1177
1186
  }
1178
1187
 
1179
- async #accept({ text, target, model = null, effort = null, attachments = [], create = false, ash = false, mode = undefined, draft = false, via = null, followUp = null, copilot = false }, order) {
1188
+ async #accept({ text, target, model = null, effort = null, attachments = [], create = false, ash = false, mode = undefined, draft = false, via = null, followUp = null, copilot = false, together = null }, order) {
1180
1189
  const parsed = parseMessage(text, target);
1181
1190
  const requestedMode = normalizeMode(mode, create === true ? 2 : 1);
1182
1191
  // This is the decision the human made when pressing Send. Capture it before modeCheck() —
@@ -1249,6 +1258,9 @@ export class Room {
1249
1258
  auto: followUp?.kind ?? undefined,
1250
1259
  returns: followUp?.returns ?? undefined,
1251
1260
  copilot: asCopilot || undefined,
1261
+ // One question to several agents at once (2026-10-29): each gets its own turn, and the page
1262
+ // shows the question once, with every agent it went to (app.js, renderUserMessage).
1263
+ together: typeof together === 'string' && /^[A-Za-z0-9_-]{6,40}$/.test(together) ? together : undefined,
1252
1264
  });
1253
1265
  // The human may say what they like; the room only says so, because every agent will read it.
1254
1266
  const exposed = this.#privacy?.hits(text2) ?? 0;
@@ -1280,9 +1292,21 @@ export class Room {
1280
1292
  } else {
1281
1293
  // `/module` asks for less than #2: one file in its own draft folder. Only a #2 message can
1282
1294
  // narrow itself this way; a default-#2 lease stays what it is.
1283
- lease = draft === true && create === true
1284
- ? await this.#draftLease({ leaseId: randomUUID(), messageId })
1285
- : await this.#projectLease({ leaseId: randomUUID(), messageId });
1295
+ // The folder it writes in could not be made (a project folder left read-only, a full disk):
1296
+ // the message says so, instead of being accepted and then answered by nothing (2026-10-28).
1297
+ try {
1298
+ lease = draft === true && create === true
1299
+ ? await this.#draftLease({ leaseId: randomUUID(), messageId })
1300
+ : await this.#projectLease({ leaseId: randomUUID(), messageId });
1301
+ } catch (error) {
1302
+ const said = String(error?.message ?? error ?? '').split('\n')[0].slice(0, 300);
1303
+ const text = t('MADRE could not prepare the folder where @{agent} writes, so nothing was started: {error}', { agent: parsed.target, error: said });
1304
+ await this.#emit('message.failed', { messageId, target: parsed.target, error: this.#privacy ? this.#privacy.redact(text).text : text });
1305
+ return { messageId, responseMessageId: null };
1306
+ }
1307
+ // A module asked for, with any #2 lease (the draft folder or the project): the guide goes
1308
+ // inside the project for the agent to read.
1309
+ if (draft === true || wantsModule(text2)) lease.sdk = await this.#sdkInProject();
1286
1310
  // CREATE authorizes the plan to use each delegate's enabled creation
1287
1311
  // scopes; a default-#2 lease authorizes files only.
1288
1312
  lease.scopeCeiling = { write: true, imageGen: !standing, web: true };
@@ -1336,6 +1360,23 @@ export class Room {
1336
1360
  const draft = await createLease({ projectRoot: this.#projectRoot, leaseId });
1337
1361
  return { ...draft, messageId, draft: true };
1338
1362
  }
1363
+ // The SDK guide `/module` asks the agent to read, copied inside the project (.pulse/sdk/): a CLI
1364
+ // that may read only its project — OpenCode denies any other directory — refused to write a module
1365
+ // it could not read the guide for (2026-10-29). MADRE's own copy is the fallback.
1366
+ async #sdkInProject() {
1367
+ const from = sdkPaths();
1368
+ const dir = joinPath(this.#projectRoot, '.pulse', 'sdk');
1369
+ try {
1370
+ await mkdirPath(dir, { recursive: true });
1371
+ const copied = {};
1372
+ for (const [key, path] of Object.entries(from)) {
1373
+ const target = joinPath(dir, baseName(path));
1374
+ await copyFile(path, target);
1375
+ copied[key] = target;
1376
+ }
1377
+ return copied;
1378
+ } catch { return from; }
1379
+ }
1339
1380
 
1340
1381
  // Artifacts from a #2 turn: the files the checkpoint saw appear, as the room shows them.
1341
1382
  // Said once, when a writing turn has to wait for the one already writing in the project.
@@ -1406,6 +1447,22 @@ export class Room {
1406
1447
  return [...this.#turns.entries()].map(([messageId, turn]) => ({ messageId, agent: turn.agent, planId: turn.planId, startedAt: turn.startedAt }));
1407
1448
  }
1408
1449
 
1450
+ // What this room is doing now, for «En marcha» (2026-10-30): each turn with what it was asked,
1451
+ // its limit and its subagents; each plan with its steps; each command it keeps alive. Read only.
1452
+ activity() {
1453
+ const turns = [...this.#turns.entries()].map(([messageId, turn]) => ({
1454
+ kind: 'turn', messageId, agent: turn.agent, planId: turn.planId ?? null, startedAt: turn.startedAt,
1455
+ timeoutMs: turn.timeoutMs ?? null, text: turn.text ?? '', mode: turn.mode ?? null,
1456
+ subagents: (turn.subagents ?? []).map(({ kind, task, status, seconds }) => ({ kind, task, status, seconds })),
1457
+ }));
1458
+ const plans = [...this.#plans.values()].map((plan) => ({
1459
+ kind: 'plan', planId: plan.planId, orchestrator: plan.orchestrator, step: plan.step, total: plan.steps.length + (plan.closing ? 1 : 0),
1460
+ startedAt: plan.startedAt, steps: plan.steps.map((one) => ({ agent: one.agent, text: clip(one.text, 160) })),
1461
+ }));
1462
+ const runs = this.#runDesk.live().map((one) => ({ kind: 'run', ...one }));
1463
+ return [...plans, ...turns, ...runs];
1464
+ }
1465
+
1409
1466
  // Master brake: every plan and every in-flight turn, recorded as one event.
1410
1467
  async stopAll(reason = t('STOPALL by the human')) {
1411
1468
  const plans = this.#plans.size;
@@ -1473,7 +1530,7 @@ export class Room {
1473
1530
  // @madre is not a CLI to install: it is the room's local agent, here while Ollama runs with a
1474
1531
  // chat model. Saying "not installed" sent people to install something that does not exist.
1475
1532
  const error = agent?.local || targetId === 'madre'
1476
- ? `@${targetId} left the project: Ollama is not running. Start Ollama, or open Local AI in Modules.`
1533
+ ? `@${targetId} left the project: Ollama is not running. Start Ollama, or set up Local AI in Settings.`
1477
1534
  : `${targetId} is not installed on this computer.`;
1478
1535
  await this.#emit('message.failed', { messageId, target: targetId, planId, error });
1479
1536
  return null;
@@ -1527,11 +1584,15 @@ export class Room {
1527
1584
  }
1528
1585
  // The limit this turn will be held to, said with its start so the room counts down from the
1529
1586
  // real number and not from a default it guessed.
1530
- await this.#emit('agent.started', { messageId, agent: agent.id, handoffId, planId, timeoutMs: this.timeoutFor(agent.id, { writing: Number(mode) >= 2 || Boolean(lease) }) });
1587
+ const timeoutMs = this.timeoutFor(agent.id, { writing: Number(mode) >= 2 || Boolean(lease) || subagentsAllowed(agent.id, { airlock: Number(mode) === 4 }) });
1588
+ await this.#emit('agent.started', { messageId, agent: agent.id, handoffId, planId, timeoutMs });
1531
1589
  const controller = new AbortController();
1532
- const turn = { controller, promise: null, planId, agent: agent.id, startedAt: Date.now() };
1533
- turn.promise = this.#runTurn({ messageId, agent, text, requester, depth, planId, allowDelegation, context, recall, memories, handoffId, signal: controller.signal, model, effort, attachments, references, lease, ash, mode, escalation, returned, copilot });
1590
+ // What it was asked and its limit ride with it, for «En marcha» (activity, below).
1591
+ const turn = { controller, promise: null, planId, agent: agent.id, startedAt: Date.now(), timeoutMs, text: clip(text, 200), mode: Number(mode), subagents: [] };
1592
+ // Held before it starts: with nothing to wait for, a turn reaches its CLI before this line runs
1593
+ // again, and what the CLI reports at once (its subagents) found no turn to ride on.
1534
1594
  this.#turns.set(messageId, turn);
1595
+ turn.promise = this.#runTurn({ messageId, agent, text, requester, depth, planId, allowDelegation, context, recall, memories, handoffId, signal: controller.signal, model, effort, attachments, references, lease, ash, mode, escalation, returned, copilot });
1535
1596
  let outcome = null;
1536
1597
  try {
1537
1598
  outcome = await turn.promise;
@@ -1643,25 +1704,25 @@ export class Room {
1643
1704
  const scopes = this.scopesFor(agent.id);
1644
1705
  const ceiling = Math.min(mode, scopes.maxMode ?? 0);
1645
1706
  const mcpServers = this.#toolsForTurn ? await this.#toolsForTurn({ agent: agent.id, mode: ceiling, lease: null, scratchDir: null }).catch(() => []) : [];
1646
- const prompt = '<the briefing above>';
1707
+ const prompt = t('<the briefing above>');
1647
1708
  const shared = { projectRoot: this.#projectRoot, prompt, model: null, attachments: [], lease: null, scopes: { web: scopes.web.enabled && scopes.web.wired, imageGen: scopes.imageGen.enabled && scopes.imageGen.wired }, memoryServer: this.#memoryServer, mcpServers };
1648
1709
  const args = agent.id === 'codex' ? buildCodexArgs(shared)
1649
1710
  : agent.id === 'claude' ? buildClaudeArgs({ ...shared, attachmentsDir: null, imageStudio: null })
1650
- : agent.id === 'gemini' ? buildGeminiArgs({ ...shared, policyPath: '<written for this turn, deleted after it>', attachmentsDir: null })
1711
+ : agent.id === 'gemini' ? buildGeminiArgs({ ...shared, policyPath: t('<written for this turn, deleted after it>'), attachmentsDir: null })
1651
1712
  : agent.id === 'opencode' ? buildOpenCodeArgs(shared)
1652
1713
  : agent.id === 'cursor' ? buildCursorArgs(shared)
1653
1714
  : null;
1654
- if (!args) return { agent: agent.id, label: agent.label, local: false, says: `MADRE has no adapter for @${agent.id}.`, mcpServers: [], env: [], isolation: [] };
1715
+ if (!args) return { agent: agent.id, label: agent.label, local: false, says: t('MADRE has no adapter for @{agent}.', { agent: agent.id }), mcpServers: [], env: [], isolation: [] };
1655
1716
  const isolation = {
1656
- codex: ['--ephemeral: the run keeps no session of its own, so nothing said here reaches another project.'],
1657
- claude: ['--no-session-persistence: the run keeps no session of its own.', 'Only the project\'s own CLAUDE.md and MADRE\'s briefing are read; hooks, plugins and outside MCP servers are not.'],
1658
- gemini: ['GEMINI_CLI_HOME points at a temporary home made for this turn and removed after it, so settings, hooks and extensions come from there and not from yours.', 'GEMINI_CLI_NO_RELAUNCH keeps the launcher from spawning a second process MADRE could not stop.'],
1659
- opencode: ['The run is given the model you chose and nothing else of your session.'],
1660
- cursor: ['#0 and #1: --mode ask, Cursor\'s read-only mode, whatever its own settings say; no edits and no commands. #2 and #3: its agent mode with --force, writing allowed and every command denied. #4: commands allowed too. The places nobody writes stay denied at every mode, and MADRE locks and puts them back itself.', 'CURSOR_CONFIG_DIR points at a configuration made for this turn and removed after it, with only what the mode you chose allows. The sign-in stays in the system keychain.'],
1717
+ codex: [t('--ephemeral: the run keeps no session of its own, so nothing said here reaches another project.')],
1718
+ claude: [t('--no-session-persistence: the run keeps no session of its own.'), t('Only the project\'s own CLAUDE.md and MADRE\'s briefing are read; hooks, plugins and outside MCP servers are not.')],
1719
+ gemini: [t('GEMINI_CLI_HOME points at a temporary home made for this turn and removed after it, so settings, hooks and extensions come from there and not from yours.'), t('GEMINI_CLI_NO_RELAUNCH keeps the launcher from spawning a second process MADRE could not stop.')],
1720
+ opencode: [t('The run is given the model you chose and nothing else of your session.')],
1721
+ cursor: [t('#0 and #1: --mode ask, Cursor\'s read-only mode, whatever its own settings say; no edits and no commands. #2 and #3: its agent mode with --force, writing allowed and every command denied. #4: commands allowed too. The places nobody writes stay denied at every mode, and MADRE locks and puts them back itself.'), t('CURSOR_CONFIG_DIR points at a configuration made for this turn and removed after it, with only what the mode you chose allows. The sign-in stays in the system keychain.')],
1661
1722
  }[agent.id] ?? [];
1662
1723
  const env = {
1663
- gemini: [{ name: 'GEMINI_CLI_HOME', note: 'the temporary home for this turn' }, { name: 'GEMINI_CLI_NO_RELAUNCH', note: 'so the launcher stays killable' }],
1664
- cursor: [{ name: 'CURSOR_CONFIG_DIR', note: 'the configuration for this turn, from the mode you chose' }, { name: 'NO_OPEN_BROWSER', note: 'a turn never opens a page' }],
1724
+ gemini: [{ name: 'GEMINI_CLI_HOME', note: t('the temporary home for this turn') }, { name: 'GEMINI_CLI_NO_RELAUNCH', note: t('so the launcher stays killable') }],
1725
+ cursor: [{ name: 'CURSOR_CONFIG_DIR', note: t('the configuration for this turn, from the mode you chose') }, { name: 'NO_OPEN_BROWSER', note: t('a turn never opens a page') }],
1665
1726
  }[agent.id] ?? [];
1666
1727
  return {
1667
1728
  agent: agent.id, label: agent.label, local: false,
@@ -1700,11 +1761,21 @@ export class Room {
1700
1761
  memoryServer: this.#memoryServer,
1701
1762
  controlHolder: this.#controlDesk.holder?.agent ?? null,
1702
1763
  privacyMarker: this.#privacy?.marker ?? '[ENTIDAD-ORG]',
1703
- sdk: sdkPaths(),
1764
+ sdk: input.lease?.sdk ?? sdkPaths(),
1704
1765
  madreModel: this.#agents.find((agent) => agent.id === 'madre' && agent.ready)?.version ?? null,
1705
1766
  });
1706
1767
  }
1707
1768
 
1769
+ // The photograph before writing could not be taken (2026-10-28: a project with a broken .git
1770
+ // folder). Nothing was written: the turn says so and ends, instead of waiting forever above the
1771
+ // try that reports failures, with the room showing «writing…» until MADRE was closed.
1772
+ async #couldNotSeat({ messageId, agent, planId, error }) {
1773
+ const said = String(error?.message ?? error ?? '').split('\n').filter(Boolean).slice(0, 2).join(' ').slice(0, 300);
1774
+ const text = t('MADRE could not take the restore point before @{agent} writes, so nothing was changed: {error}', { agent: agent.id, error: said });
1775
+ await this.#emit('message.failed', { messageId, target: agent.id, planId, error: this.#privacy ? this.#privacy.redact(text).text : text });
1776
+ return null;
1777
+ }
1778
+
1708
1779
  async #runTurn({ messageId, agent, text, requester, depth, planId, allowDelegation, context, recall = null, memories = null, handoffId, signal, model = null, effort = null, attachments = [], references = [], lease: sharedLease = null, ash = false, mode = 1, escalation = null, returned = null, copilot = false }) {
1709
1780
  // The lease is the human's; what each agent may do inside it is that
1710
1781
  // agent's own enabled scopes. A delegate without file creation runs
@@ -1728,8 +1799,9 @@ export class Room {
1728
1799
  await this.#alert('control-busy', `@${this.#controlDesk.holder.agent} still holds EDIT; @${agent.id} answers read-only this turn.`, `control-busy:${agent.id}`);
1729
1800
  } else {
1730
1801
  await this.#sayWaitingToWrite({ messageId, agent });
1731
- const seat = await this.#controlDesk.begin({ agent, messageId, enabledScopes: enabled, mode, signal }).catch((error) => (error?.code === 'ABORT_ERR' ? null : Promise.reject(error)));
1802
+ const seat = await this.#controlDesk.begin({ agent, messageId, enabledScopes: enabled, mode, signal }).catch((error) => (error?.code === 'ABORT_ERR' ? null : { failed: error }));
1732
1803
  if (!seat) { await this.#emit('message.failed', { messageId, target: agent.id, planId, error: `Stopped while waiting for the project: another turn was writing in it.`, stopped: true }); return null; }
1804
+ if (seat.failed) return this.#couldNotSeat({ messageId, agent, planId, error: seat.failed });
1733
1805
  controlRun = seat.run;
1734
1806
  // A copilot does not delete: what it removes is put back when the turn settles.
1735
1807
  if (asCopilot) controlRun.noDeletes = true;
@@ -1763,8 +1835,9 @@ export class Room {
1763
1835
  // CREATE: photograph the project now; after the turn only what appeared stays. Another turn
1764
1836
  // writing in the project, in this conversation or another, is waited for first.
1765
1837
  await this.#sayWaitingToWrite({ messageId, agent });
1766
- const seat = await this.#controlDesk.begin({ agent, messageId, enabledScopes: enabled, mode: 2, signal }).catch((error) => (error?.code === 'ABORT_ERR' ? null : Promise.reject(error)));
1838
+ const seat = await this.#controlDesk.begin({ agent, messageId, enabledScopes: enabled, mode: 2, signal }).catch((error) => (error?.code === 'ABORT_ERR' ? null : { failed: error }));
1767
1839
  if (!seat) { await this.#emit('message.failed', { messageId, target: agent.id, planId, error: `Stopped while waiting for the project: another turn was writing in it.`, stopped: true }); return null; }
1840
+ if (seat.failed) return this.#couldNotSeat({ messageId, agent, planId, error: seat.failed });
1768
1841
  createRun = seat.run;
1769
1842
  // The folder this turn was told to draft in, so settling it does not undo what it was
1770
1843
  // invited to write. Only this turn's own folder; every other `.pulse` path stays forbidden.
@@ -1793,6 +1866,11 @@ export class Room {
1793
1866
  : null;
1794
1867
  // The turn's effective mode: #0 for ghosts, #3 in control, #2 only while it holds a lease.
1795
1868
  const turnMode = mode === 0 ? 0 : controlRun ? controlRun.mode : lease ? 2 : 1;
1869
+ // A turn whose agent may hand work to its own subagents gets the longer clock (QA 1.1.0,
1870
+ // NUE-23): OpenCode on its free models with two subagents took three minutes in #1 and was cut
1871
+ // at 180 s with nothing kept. What the subagents reported is kept for the failure too.
1872
+ const helperClock = Boolean(lease) || subagentsAllowed(agent.id, { airlock: Number(turnMode) === 4 });
1873
+ let helpersSeen = null;
1796
1874
  try {
1797
1875
  const invoke = this.#invokers[agent.adapter];
1798
1876
  if (!invoke) throw new Error(`${agent.label} does not have a supported MADRE adapter.`);
@@ -1825,7 +1903,22 @@ export class Room {
1825
1903
  // around it, so a CLI that hands over one blob at the end honestly reports nothing until
1826
1904
  // then rather than a number that means the shape of its own output format.
1827
1905
  let told = 0;
1828
- const onProgress = ({ chars }) => {
1906
+ // And its own subagents, as the CLI reports them (src/adapters/subagents.mjs): said again only
1907
+ // when what they are doing changes, through the same privacy guard as the answer.
1908
+ let helpersSaid = '';
1909
+ const keepHelpers = (list) => keptSubagents(list, { redact: (said) => (this.#privacy ? this.#privacy.redact(said).text : said) });
1910
+ const onProgress = ({ chars, subagents }) => {
1911
+ if (Array.isArray(subagents) && subagents.length) {
1912
+ const kept = keepHelpers(subagents);
1913
+ const key = JSON.stringify(kept);
1914
+ if (key !== helpersSaid) {
1915
+ helpersSaid = key;
1916
+ helpersSeen = kept;
1917
+ const held = this.#turns.get(messageId);
1918
+ if (held) held.subagents = kept;
1919
+ this.#say('turn.subagents', { messageId, agent: agent.id, mode: turnMode, subagents: kept });
1920
+ }
1921
+ }
1829
1922
  if (!Number.isFinite(chars) || chars <= told) return;
1830
1923
  told = chars;
1831
1924
  this.#say('turn.reading', { messageId, agent: agent.id, ...reading, out: chars, outTokens: this.#rate ? Math.round(chars / this.#rate) : null });
@@ -1836,7 +1929,7 @@ export class Room {
1836
1929
  projectRoot: this.#projectRoot,
1837
1930
  text,
1838
1931
  prompt: shaped.text,
1839
- timeoutMs: this.timeoutFor(agent.id, { writing: Boolean(lease) }),
1932
+ timeoutMs: this.timeoutFor(agent.id, { writing: helperClock }),
1840
1933
  signal,
1841
1934
  model,
1842
1935
  effort,
@@ -1943,6 +2036,8 @@ export class Room {
1943
2036
  leaseId: lease?.leaseId,
1944
2037
  artifacts: artifacts.length ? artifacts : undefined,
1945
2038
  delegates: directives.steps.length ? directives.steps.map((step) => step.agent) : undefined,
2039
+ // Who helped, from the CLI's own subagents: folded under the answer («Helped by…»).
2040
+ subagents: keepHelpers(result.subagents),
1946
2041
  });
1947
2042
  if (ash && turnMode !== 0) {
1948
2043
  const validation = validateAshReply({ request: text, response: result.text });
@@ -2030,8 +2125,9 @@ export class Room {
2030
2125
  ...(this.#turns.get(messageId)?.stoppedByHuman ? { stopped: true } : {}),
2031
2126
  // Cut because MADRE is closing: nothing went wrong in the turn, so nobody files it as a fault.
2032
2127
  ...(this.#shuttingDown ? { closing: true } : {}),
2033
- ...(cutByClock ? { timeout: { ms: this.timeoutFor(agent.id, { writing: Boolean(lease) }), writing: Boolean(lease), idle: error.code === 'IDLE' } } : {}),
2128
+ ...(cutByClock ? { timeout: { ms: this.timeoutFor(agent.id, { writing: helperClock }), writing: Boolean(lease), idle: error.code === 'IDLE' } } : {}),
2034
2129
  ...(partial ? { partial } : {}),
2130
+ ...(helpersSeen?.length ? { subagents: helpersSeen } : {}),
2035
2131
  });
2036
2132
  return null;
2037
2133
  } finally {
package/src/router.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
  const supported = new Set(['codex', 'claude', 'gemini', 'opencode', 'cursor']);
4
4
 
5
5
  export function parseMessage(text, fallbackTarget = null) {
package/src/runs.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 run a command.
4
4
  //
5
5
  // Below #4 AIRLOCK no agent runs anything: it reads, it writes where its mode allows, and that is
@@ -1,8 +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 { constants } from 'node:fs';
4
- import { access } from 'node:fs/promises';
5
- import { homedir, userInfo } from 'node:os';
4
+ import { access, readFile, realpath, stat, writeFile, rename } from 'node:fs/promises';
5
+ import { homedir, tmpdir, userInfo } from 'node:os';
6
6
  import { delimiter, join } from 'node:path';
7
7
  import { execFile } from 'node:child_process';
8
8
  import { promisify } from 'node:util';
@@ -117,6 +117,11 @@ const extensions = (env = process.env) => (process.platform === 'win32'
117
117
  ? (env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean).map((extension) => extension.toLowerCase())
118
118
  : ['']);
119
119
 
120
+ // Inside WSL the PATH also carries Windows' own folders (/mnt/c/…/AppData/Roaming/npm): every file
121
+ // there looks runnable, so a CLI installed on Windows counted as installed here, «install» said it
122
+ // already was, and every turn failed for want of the Linux one. Those folders are Windows', not WSL's.
123
+ const windowsSide = (directory, env) => process.platform === 'linux' && Boolean(env.WSL_DISTRO_NAME || env.WSL_INTEROP) && /^\/mnt\/[a-z]\//i.test(directory);
124
+
120
125
  export async function findExecutable(candidates, envPath = process.env.PATH ?? '', env = process.env) {
121
126
  const suffixes = extensions(env);
122
127
  const runnable = async (path) => (process.platform === 'win32' ? access(path).then(() => true, () => false) : executable(path));
@@ -126,6 +131,7 @@ export async function findExecutable(candidates, envPath = process.env.PATH ?? '
126
131
  continue;
127
132
  }
128
133
  for (const directory of envPath.split(delimiter).filter(Boolean)) {
134
+ if (windowsSide(directory, env)) continue;
129
135
  for (const suffix of suffixes) {
130
136
  const path = join(directory, `${candidate}${suffix}`);
131
137
  if (await runnable(path)) return path;
@@ -135,10 +141,30 @@ export async function findExecutable(candidates, envPath = process.env.PATH ?? '
135
141
  return null;
136
142
  }
137
143
 
144
+ // What each CLI answered to --version, kept per binary (its real path, size and date) for every
145
+ // MADRE of this user (QA 1.1.0, ACT-15): each project used to run `gemini --version` as it came up,
146
+ // and several coming up together left Gemini's half-written projects.json.<uuid>.tmp behind in
147
+ // ~/.gemini. A binary that changes is asked again.
148
+ const versionsFile = () => join(tmpdir(), `madre-versions-${process.getuid?.() ?? 'user'}.json`);
149
+ async function rememberedVersions() { try { return JSON.parse(await readFile(versionsFile(), 'utf8')) ?? {}; } catch { return {}; } }
138
150
  async function readVersion(path, args) {
151
+ let key = null;
152
+ try {
153
+ const real = await realpath(path);
154
+ const found = await stat(real);
155
+ key = `${real}:${found.size}:${Math.round(found.mtimeMs)}:${args.join(' ')}`;
156
+ const kept = (await rememberedVersions())[key];
157
+ if (typeof kept === 'string' && kept) return kept;
158
+ } catch { /* asked below */ }
139
159
  try {
140
160
  const { stdout, stderr } = await execFileAsync(path, args, { timeout: 3000 });
141
- return (stdout || stderr).trim().split('\n')[0] || null;
161
+ const version = (stdout || stderr).trim().split('\n')[0] || null;
162
+ if (version && key) {
163
+ const all = { ...(await rememberedVersions()), [key]: version };
164
+ const temp = `${versionsFile()}.${process.pid}.tmp`;
165
+ await writeFile(temp, JSON.stringify(Object.fromEntries(Object.entries(all).slice(-40)))).then(() => rename(temp, versionsFile())).catch(() => {});
166
+ }
167
+ return version;
142
168
  } catch {
143
169
  return null;
144
170
  }
package/src/salas.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
  // Salas on the Mac (docs/MACROVERSO.md, phase 1): every room this Mac knows, open or asleep, and
4
4
  // what one room may ask of another — to open, to close. The list is read from what each room
5
5
  // leaves beside its record; nothing here touches a room's ledger or its memory.
@@ -14,6 +14,7 @@ import { spawn } from 'node:child_process';
14
14
  import { createHash } from 'node:crypto';
15
15
  import { closeSync, openSync, realpathSync } from 'node:fs';
16
16
  import { mkdir, readdir, readFile, rename, stat } from 'node:fs/promises';
17
+ import * as nodePath from 'node:path';
17
18
  import { basename, dirname, join, resolve } from 'node:path';
18
19
  import { fileURLToPath } from 'node:url';
19
20
  import { oneAtATime, writeWhole } from './json-file.mjs';
@@ -108,7 +109,17 @@ const NOT_PROJECTS = new Set(['node_modules', 'Library', 'Applications', 'Pictur
108
109
  // Escritorio).
109
110
  export const PROJECT_HOMES = ['', 'Projects', 'projects', 'Proyectos', 'proyectos', 'Developer', 'dev', 'Dev', 'code', 'Code', 'src', 'repos', 'Repos', 'GitHub', 'git', 'work', 'Work', 'Sites', 'Documents', 'Documentos', 'Desktop', 'Escritorio'];
110
111
 
111
- const inside = (child, parent) => child === parent || child.startsWith(parent.endsWith('/') ? parent : `${parent}/`);
112
+ // Whether a folder is the other one or inside it (WIN-028, 2026-10-28). Asked of the path module of
113
+ // the system it runs on, not of a '/': on Windows a path is written with '\' and its letters' case
114
+ // does not tell two folders apart, and comparing text with '/' refused every folder there, the
115
+ // home's own included («Only folders inside your home folder»). `path` is a parameter so the
116
+ // Windows rule can be checked anywhere.
117
+ export function insideFolder(child, parent, path = nodePath) {
118
+ const rel = path.relative(parent, child);
119
+ return rel === '' || (rel !== '..' && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel));
120
+ }
121
+ export const sameFolder = (one, other, path = nodePath) => path.relative(one, other) === '';
122
+ const inside = (child, parent) => insideFolder(child, parent);
112
123
  async function looksLikeProject(folder) {
113
124
  for (const mark of PROJECT_MARKS) if (await stat(join(folder, mark)).then(() => true, () => false)) return true;
114
125
  return false;
@@ -140,7 +151,7 @@ export async function listFolders({ path = null, home, stateRoot }) {
140
151
  entries.push({ name: entry.name, path: full, project: await looksLikeProject(full), known: known.has(full) });
141
152
  }
142
153
  entries.sort((a, b) => Number(b.project) - Number(a.project) || a.name.localeCompare(b.name));
143
- return { path: here, home: top, parent: here === top ? null : dirname(here), entries: entries.slice(0, 400) };
154
+ return { path: here, home: top, parent: sameFolder(here, top) ? null : dirname(here), entries: entries.slice(0, 400) };
144
155
  }
145
156
 
146
157
  // Folders that look like projects in the places people keep them, newest first, none already here.
@@ -173,7 +184,7 @@ export async function suggestProjects({ home, stateRoot, limit = 24 }) {
173
184
  export async function associateProject({ root, home, stateRoot, now = new Date() }) {
174
185
  const folder = realFolder(String(root ?? ''));
175
186
  const top = realFolder(home);
176
- if (!root || !inside(folder, top) || folder === top) return { error: 'outside' };
187
+ if (!root || !inside(folder, top) || sameFolder(folder, top)) return { error: 'outside' };
177
188
  if (inside(folder, realFolder(stateRoot))) return { error: 'madre' };
178
189
  const info = await stat(folder).catch(() => null);
179
190
  if (!info?.isDirectory()) return { error: 'missing' };
@@ -201,11 +212,22 @@ export function projectNameProblem(name) {
201
212
  if (/[<>:"/\\|?*\u0000-\u001f]/.test(text) || text !== text.trim() || /[. ]$/.test(text) || text.startsWith('.') || DEVICE_NAMES.test(text)) return 'name';
202
213
  return null;
203
214
  }
215
+ // Where a new project goes when nobody chose (QA 1.1.0, NUE-09): the folder this person already
216
+ // keeps projects in, when there is one, rather than the top of their home folder.
217
+ const NEW_PROJECT_HOMES = ['Proyectos', 'Projects', 'proyectos', 'projects', 'Developer', 'Code', 'code', 'dev', 'src'];
218
+ export async function defaultProjectsFolder(home) {
219
+ for (const name of NEW_PROJECT_HOMES) {
220
+ const found = await stat(join(home, name)).catch(() => null);
221
+ if (found?.isDirectory()) return join(home, name);
222
+ }
223
+ return home;
224
+ }
225
+
204
226
  export async function createProject({ name, parent = null, home, stateRoot, now = new Date() }) {
205
227
  const problem = projectNameProblem(name);
206
228
  if (problem) return { error: problem };
207
229
  const top = realFolder(home);
208
- const place = realFolder(parent || home);
230
+ const place = realFolder(parent || await defaultProjectsFolder(home));
209
231
  if (!inside(place, top)) return { error: 'outside' };
210
232
  if (inside(place, realFolder(stateRoot))) return { error: 'madre' };
211
233
  if (!(await stat(place).catch(() => null))?.isDirectory()) return { error: 'missing' };
@@ -299,6 +321,7 @@ export async function roomComesUp(stateRoot, id, { timeoutMs = 60000, everyMs =
299
321
  // `full`, no memory's words leave their room: a far universe is drawn from kinds, zones, how much
300
322
  // ledger each memory covers, how often it was reached for, and the links between them. Only the
301
323
  // chosen universe asks for the words, and only the Mac may ask (the route refuses a phone).
324
+ const wordCount = (text) => (typeof text === 'string' ? (text.match(/\S+/g) ?? []).length : 0);
302
325
  export function universeOf(research, { full = false } = {}) {
303
326
  const memories = (research?.memories ?? []).map((memory) => ({
304
327
  id: memory.id,
@@ -307,6 +330,8 @@ export function universeOf(research, { full = false } = {}) {
307
330
  fromSequence: memory.fromSequence ?? 0,
308
331
  throughSequence: memory.throughSequence ?? 0,
309
332
  sourcesCount: Array.isArray(memory.sources) ? memory.sources.length : 0,
333
+ // How much it holds, as a count: its size on the map (2026-10-28). The words stay in their room.
334
+ words: wordCount(memory.text),
310
335
  recalled: memory.recalled ?? 0,
311
336
  lastRecalled: memory.lastRecalled ?? null,
312
337
  cold: memory.cold ?? null,
@@ -1,12 +1,12 @@
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 error sentinel: what MADRE tells its author when something goes wrong
4
4
  // that MU/TH/UR cannot explain. A failure that matches no known condition, or a
5
5
  // crash of the process, becomes a report: the error redacted (no home paths,
6
6
  // no user names, no keys, no emails), the versions involved, the platform.
7
7
  // Reports stay in the room ledger (sentinel.report) and can be sent two ways:
8
8
  // by hand as a prefilled GitHub issue, or automatically to a collector the
9
- // author runs, only when the human switched AUTO-REPORT on. Off by default.
9
+ // author runs, while AUTO-REPORT is on: on by default since 1.1.0, with the anonymous diagnostics, and the human turns it off.
10
10
  // Nothing leaves the machine otherwise.
11
11
 
12
12
  import { createHash } from 'node:crypto';
@@ -69,14 +69,17 @@ export class ErrorSentinel {
69
69
  #fetch;
70
70
  #emit;
71
71
  #save;
72
+ #told;
72
73
 
73
- constructor({ pkg = {}, agents = [], settings = {}, fetchImpl = globalThis.fetch, emit = async () => {}, save = async () => {} } = {}) {
74
+ // `told`: every failure, known or not, for the anonymous diagnostics (src/telemetry.mjs).
75
+ constructor({ pkg = {}, agents = [], settings = {}, fetchImpl = globalThis.fetch, emit = async () => {}, save = async () => {}, told = () => {} } = {}) {
74
76
  this.#pkg = pkg;
75
77
  this.#agents = agents;
76
78
  this.#settings = { autoReport: Boolean(settings.autoReport), reportUrl: String(settings.reportUrl ?? '').trim() };
77
79
  this.#fetch = fetchImpl;
78
80
  this.#emit = emit;
79
81
  this.#save = save;
82
+ this.#told = told;
80
83
  }
81
84
 
82
85
  settings() { return { ...this.#settings, canSend: Boolean(this.#settings.reportUrl), repo: repoFromPackage(this.#pkg), home: HOME_SITE }; }
@@ -110,6 +113,11 @@ export class ErrorSentinel {
110
113
  // closing is the same: every room closed mid-turn filed «MADRE is shutting down» (2026-10-21).
111
114
  if (stopped || closing) return null;
112
115
  const known = diagnose(error, target ?? null);
116
+ const agentVersion = this.#agents.find((one) => one.id === target)?.version ?? null;
117
+ // Known or not, the author hears of it (2026-10-28): how often each known condition happens is
118
+ // as useful as the conditions nobody catalogued.
119
+ // A known one goes by its code alone: the agent's own words can repeat what the person wrote.
120
+ try { this.#told({ kind: 'agent', code: known[0]?.code ?? null, agent: target ?? null, agentVersion, message: known.length ? '' : error }); } catch { /* never in the way */ }
113
121
  if (known.length) return null;
114
122
  return this.record({ kind: 'unknown', agent: target ?? null, error, at: event.timestamp });
115
123
  }
@@ -117,6 +125,7 @@ export class ErrorSentinel {
117
125
  // The process itself failed somewhere the room did not catch.
118
126
  async crash(error, origin = 'uncaughtException') {
119
127
  const text = error instanceof Error ? `${error.stack ?? error.message}` : String(error);
128
+ try { this.#told({ kind: 'crash', where: origin, message: error instanceof Error ? error.message : text, stack: error instanceof Error ? error.stack : null }); } catch { /* never in the way */ }
120
129
  return this.record({ kind: 'crash', agent: null, error: `${origin}: ${text}` });
121
130
  }
122
131
 
@@ -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 servers sentinel: what this project has listening, kept watch over while the room is open.
4
4
  //
5
5
  // RIPLEY opens a project's own dev server; this is what knows which servers those are. Only the