@jossuealcala/madre 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/ADDITIONAL-TERMS.md +7 -2
  2. package/CHANGELOG.en.md +152 -1
  3. package/CHANGELOG.md +152 -1
  4. package/CONTRIBUTING.md +2 -2
  5. package/LICENSE +111 -661
  6. package/NOTICE +59 -24
  7. package/README.en.md +36 -204
  8. package/README.md +36 -210
  9. package/SECURITY.md +1 -0
  10. package/TRADEMARKS.en.md +13 -14
  11. package/TRADEMARKS.md +42 -26
  12. package/bin/madre.cjs +2 -2
  13. package/bin/madre.mjs +114 -42
  14. package/docs/REFERENCE.md +53 -6
  15. package/docs/SDK.md +44 -5
  16. package/docs/en/REFERENCE.md +53 -6
  17. package/docs/en/SDK.md +43 -4
  18. package/docs/madre-banner.png +0 -0
  19. package/docs/sdk/hello-module.mjs +3 -0
  20. package/package.json +3 -2
  21. package/public/abduction.js +6 -6
  22. package/public/activity.js +425 -0
  23. package/public/app.js +3519 -647
  24. package/public/assets/abduction-cat-blink.webp +0 -0
  25. package/public/assets/abduction-cat-control-left.webp +0 -0
  26. package/public/assets/abduction-cat-control-right.webp +0 -0
  27. package/public/assets/abduction-cat.webp +0 -0
  28. package/public/assets/manual/shots/en-agents.webp +0 -0
  29. package/public/assets/manual/shots/en-chats.webp +0 -0
  30. package/public/assets/manual/shots/en-code.webp +0 -0
  31. package/public/assets/manual/shots/en-composer.webp +0 -0
  32. package/public/assets/manual/shots/en-connectors.webp +0 -0
  33. package/public/assets/manual/shots/en-continuity.webp +0 -0
  34. package/public/assets/manual/shots/en-coordinator.webp +0 -0
  35. package/public/assets/manual/shots/en-copilot.webp +0 -0
  36. package/public/assets/manual/shots/en-diagnostics.webp +0 -0
  37. package/public/assets/manual/shots/en-home.webp +0 -0
  38. package/public/assets/manual/shots/en-local.webp +0 -0
  39. package/public/assets/manual/shots/en-market.webp +0 -0
  40. package/public/assets/manual/shots/en-memory.webp +0 -0
  41. package/public/assets/manual/shots/en-modes.webp +0 -0
  42. package/public/assets/manual/shots/en-notes.webp +0 -0
  43. package/public/assets/manual/shots/en-settings.webp +0 -0
  44. package/public/assets/manual/shots/en-welcome.webp +0 -0
  45. package/public/assets/manual/shots/en-windows.webp +0 -0
  46. package/public/assets/manual/shots/es-agents.webp +0 -0
  47. package/public/assets/manual/shots/es-chats.webp +0 -0
  48. package/public/assets/manual/shots/es-code.webp +0 -0
  49. package/public/assets/manual/shots/es-composer.webp +0 -0
  50. package/public/assets/manual/shots/es-connectors.webp +0 -0
  51. package/public/assets/manual/shots/es-continuity.webp +0 -0
  52. package/public/assets/manual/shots/es-coordinator.webp +0 -0
  53. package/public/assets/manual/shots/es-copilot.webp +0 -0
  54. package/public/assets/manual/shots/es-diagnostics.webp +0 -0
  55. package/public/assets/manual/shots/es-home.webp +0 -0
  56. package/public/assets/manual/shots/es-local.webp +0 -0
  57. package/public/assets/manual/shots/es-market.webp +0 -0
  58. package/public/assets/manual/shots/es-memory.webp +0 -0
  59. package/public/assets/manual/shots/es-modes.webp +0 -0
  60. package/public/assets/manual/shots/es-notes.webp +0 -0
  61. package/public/assets/manual/shots/es-settings.webp +0 -0
  62. package/public/assets/manual/shots/es-welcome.webp +0 -0
  63. package/public/assets/manual/shots/es-windows.webp +0 -0
  64. package/public/assets/news/1.1/en/chats.webp +0 -0
  65. package/public/assets/news/1.1/en/home.webp +0 -0
  66. package/public/assets/news/1.1/en/maps.webp +0 -0
  67. package/public/assets/news/1.1/en/market.webp +0 -0
  68. package/public/assets/news/1.1/en/permissions.webp +0 -0
  69. package/public/assets/news/1.1/en/privacy.webp +0 -0
  70. package/public/assets/news/1.1/en/welcome.webp +0 -0
  71. package/public/assets/news/1.1/es/chats.webp +0 -0
  72. package/public/assets/news/1.1/es/home.webp +0 -0
  73. package/public/assets/news/1.1/es/maps.webp +0 -0
  74. package/public/assets/news/1.1/es/market.webp +0 -0
  75. package/public/assets/news/1.1/es/permissions.webp +0 -0
  76. package/public/assets/news/1.1/es/privacy.webp +0 -0
  77. package/public/assets/news/1.1/es/welcome.webp +0 -0
  78. package/public/attribution.js +15 -16
  79. package/public/brands.js +2 -2
  80. package/public/code-tools.js +2 -2
  81. package/public/editor.js +13 -13
  82. package/public/en.js +483 -0
  83. package/public/es.js +1817 -598
  84. package/public/hardware.js +2 -2
  85. package/public/i18n.js +47 -9
  86. package/public/icons.js +158 -0
  87. package/public/index.html +68 -51
  88. package/public/inquiry.js +2 -2
  89. package/public/loader.js +271 -2
  90. package/public/macroverso.js +60 -21
  91. package/public/manual-content.js +900 -0
  92. package/public/manual-shots.js +47 -0
  93. package/public/manual.css +246 -0
  94. package/public/manual.html +15 -0
  95. package/public/manual.js +427 -0
  96. package/public/market-art.js +99 -41
  97. package/public/market-view.js +243 -47
  98. package/public/market.js +139 -26
  99. package/public/mcp-catalog.js +62 -0
  100. package/public/neural.js +64 -8
  101. package/public/nostromo-engine.js +709 -40
  102. package/public/page-errors.js +29 -0
  103. package/public/power.js +350 -11
  104. package/public/remedy.js +89 -0
  105. package/public/resay.js +4 -2
  106. package/public/review-ask.js +12 -7
  107. package/public/routing.js +3 -3
  108. package/public/salas-mac.css +875 -48
  109. package/public/salas-mac.html +27 -15
  110. package/public/salas-mac.js +1668 -338
  111. package/public/salas.css +2 -2
  112. package/public/salas.html +3 -3
  113. package/public/salas.js +3 -3
  114. package/public/styles.css +2694 -323
  115. package/public/syntax.js +2 -2
  116. package/public/terms.js +152 -0
  117. package/public/touch.js +2 -2
  118. package/public/tour-chapters.js +100 -92
  119. package/public/tour.js +118 -28
  120. package/public/troubleshooting.js +327 -21
  121. package/public/wallpaper.js +4 -3
  122. package/public/welcome.js +923 -0
  123. package/src/activity.mjs +85 -0
  124. package/src/adapters/claude.mjs +61 -35
  125. package/src/adapters/codex.mjs +18 -5
  126. package/src/adapters/cursor.mjs +60 -9
  127. package/src/adapters/gemini.mjs +17 -4
  128. package/src/adapters/madre.mjs +30 -9
  129. package/src/adapters/opencode.mjs +73 -10
  130. package/src/adapters/process.mjs +19 -15
  131. package/src/adapters/subagents.mjs +159 -0
  132. package/src/asking.mjs +8 -2
  133. package/src/auth-probe.mjs +47 -11
  134. package/src/bridge/devices.mjs +2 -2
  135. package/src/bridge/handoff.mjs +2 -2
  136. package/src/bridge/host.mjs +2 -2
  137. package/src/bridge/network.mjs +2 -2
  138. package/src/bridge/policy.mjs +3 -3
  139. package/src/bridge/qr.mjs +2 -2
  140. package/src/bridge/server.mjs +3 -3
  141. package/src/builtin-updates.mjs +87 -0
  142. package/src/capabilities.mjs +5 -5
  143. package/src/chats.mjs +51 -2
  144. package/src/checkpoint.mjs +67 -9
  145. package/src/choices.mjs +2 -2
  146. package/src/cli-args.mjs +2 -2
  147. package/src/cold.mjs +2 -2
  148. package/src/commands.mjs +2 -2
  149. package/src/config.mjs +2 -2
  150. package/src/conversation-context.mjs +2 -2
  151. package/src/credentials.mjs +80 -18
  152. package/src/dataset.mjs +2 -2
  153. package/src/directives.mjs +2 -2
  154. package/src/distiller.mjs +2 -2
  155. package/src/embeddings.mjs +2 -2
  156. package/src/enlaces.mjs +2 -2
  157. package/src/environment.mjs +147 -0
  158. package/src/event-store.mjs +2 -2
  159. package/src/exam.mjs +2 -2
  160. package/src/extensions.mjs +2 -2
  161. package/src/eyecat-watch.mjs +2 -2
  162. package/src/eyecat.mjs +2 -2
  163. package/src/file-ops.mjs +2 -2
  164. package/src/files.mjs +2 -2
  165. package/src/github.mjs +2 -2
  166. package/src/heartbeat.mjs +2 -2
  167. package/src/history.mjs +76 -0
  168. package/src/i18n.mjs +32 -3
  169. package/src/image-studio.mjs +2 -2
  170. package/src/install-metrics.mjs +109 -0
  171. package/src/json-file.mjs +2 -2
  172. package/src/launch.mjs +2 -2
  173. package/src/lease.mjs +15 -4
  174. package/src/lobby-work.mjs +11 -4
  175. package/src/local-ai.mjs +12 -4
  176. package/src/looks.mjs +19 -7
  177. package/src/market-check.mjs +165 -0
  178. package/src/market-key.mjs +10 -2
  179. package/src/market-license.mjs +104 -0
  180. package/src/market-remote.mjs +71 -13
  181. package/src/maturity.mjs +2 -2
  182. package/src/mcp/connect.mjs +2 -2
  183. package/src/mcp/github-server.mjs +2 -2
  184. package/src/mcp/image-server.mjs +2 -2
  185. package/src/mcp/memory-server.mjs +2 -2
  186. package/src/mcp/proxy.mjs +16 -5
  187. package/src/mcp/smtp-server.mjs +2 -2
  188. package/src/memory-dashboard.mjs +2 -2
  189. package/src/memory-tools.mjs +2 -2
  190. package/src/memory.mjs +2 -2
  191. package/src/models.mjs +115 -12
  192. package/src/module-scope.mjs +2 -2
  193. package/src/modules/ahp.mjs +2 -2
  194. package/src/modules/ash-policy.mjs +2 -2
  195. package/src/modules/ash.mjs +2 -2
  196. package/src/modules/bishop-exam.mjs +2 -2
  197. package/src/modules/bishop-plan.mjs +2 -2
  198. package/src/modules/bishop.mjs +9 -3
  199. package/src/modules/choices.mjs +2 -2
  200. package/src/modules/correo.mjs +2 -2
  201. package/src/modules/enlaces.mjs +2 -2
  202. package/src/modules/git-pulse.mjs +2 -2
  203. package/src/modules/github.mjs +2 -2
  204. package/src/modules/helpers.mjs +2 -2
  205. package/src/modules/image-studio.mjs +2 -2
  206. package/src/modules/index.mjs +92 -5
  207. package/src/modules/intents-calibration.mjs +2 -2
  208. package/src/modules/intents-desk.mjs +4 -3
  209. package/src/modules/intents-observe.mjs +2 -2
  210. package/src/modules/intents-policy.mjs +2 -2
  211. package/src/modules/intents-try.mjs +2 -2
  212. package/src/modules/intents.mjs +2 -2
  213. package/src/modules/local-models.mjs +41 -10
  214. package/src/modules/mcp-connect.mjs +2 -2
  215. package/src/modules/notes.mjs +281 -0
  216. package/src/modules/ollama.mjs +48 -13
  217. package/src/modules/playwright.mjs +16 -5
  218. package/src/modules/reminders.mjs +664 -0
  219. package/src/modules/ripley.mjs +3 -3
  220. package/src/modules/runs.mjs +2 -2
  221. package/src/modules/sdk.mjs +57 -9
  222. package/src/modules/updates.mjs +2 -2
  223. package/src/mother.mjs +13 -3
  224. package/src/npm-launch.mjs +2 -2
  225. package/src/ollama.mjs +8 -6
  226. package/src/opencode-health.mjs +83 -0
  227. package/src/outbound.mjs +35 -3
  228. package/src/override.mjs +27 -22
  229. package/src/ports.mjs +2 -2
  230. package/src/prices.mjs +2 -2
  231. package/src/privacy.mjs +2 -2
  232. package/src/quota-monitor.mjs +2 -2
  233. package/src/quota-sources.mjs +2 -2
  234. package/src/request-guard.mjs +2 -2
  235. package/src/review-ask.mjs +4 -3
  236. package/src/room/archivist.mjs +2 -2
  237. package/src/room/attachments.mjs +2 -2
  238. package/src/room/budget.mjs +2 -2
  239. package/src/room/context.mjs +2 -2
  240. package/src/room/control.mjs +2 -2
  241. package/src/room/copilot.mjs +2 -2
  242. package/src/room/economy.mjs +2 -2
  243. package/src/room/escalation.mjs +2 -2
  244. package/src/room/ghost.mjs +2 -2
  245. package/src/room/guard.mjs +6 -4
  246. package/src/room/prompt.mjs +3 -3
  247. package/src/room/returns.mjs +2 -2
  248. package/src/room/runs.mjs +6 -4
  249. package/src/room/vectors.mjs +2 -2
  250. package/src/room.mjs +144 -36
  251. package/src/router.mjs +2 -2
  252. package/src/runs.mjs +2 -2
  253. package/src/runtime-detection.mjs +36 -6
  254. package/src/salas.mjs +31 -6
  255. package/src/sentinel-errors.mjs +17 -7
  256. package/src/server-sentinel.mjs +2 -2
  257. package/src/server.mjs +980 -139
  258. package/src/setup-trouble.mjs +33 -0
  259. package/src/setup.mjs +4 -4
  260. package/src/smtp.mjs +2 -2
  261. package/src/telemetry.mjs +266 -0
  262. package/src/terms.mjs +43 -0
  263. package/src/tour.mjs +60 -7
  264. package/src/uninstall.mjs +225 -0
  265. package/src/updates.mjs +2 -2
  266. package/src/usage-sentinel.mjs +2 -2
  267. package/src/vault.mjs +2 -2
  268. package/src/verdict.mjs +13 -10
  269. package/src/whats-new.mjs +97 -3
  270. package/public/assets/abduction-cat-blink.png +0 -0
  271. package/public/assets/abduction-cat-control-left.png +0 -0
  272. package/public/assets/abduction-cat-control-right.png +0 -0
  273. package/public/assets/abduction-cat.png +0 -0
@@ -1,6 +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
+ import { ENV_TEMPLATES } from '../checkpoint.mjs';
4
+ import { t } from '../i18n.mjs';
3
5
  import { runReadonlyProcess } from './process.mjs';
6
+ import { jsonLines, openCodeSubagents } from './subagents.mjs';
4
7
 
5
8
  const readonlyConfig = {
6
9
  share: 'disabled',
@@ -28,6 +31,10 @@ export function buildOpenCodeArgs({ projectRoot, prompt, model = process.env.PUL
28
31
  '--pure',
29
32
  'run',
30
33
  '--format', 'json',
34
+ // Its errors on stderr (QA 1.1.0, ACT-02): when the free models' limit is reached OpenCode
35
+ // retries in silence and writes nothing on stdout, so MADRE waited the whole clock to say «did
36
+ // not respond». The log line says why at once (see watchOpenCodeErrors).
37
+ '--print-logs', '--log-level', 'ERROR',
31
38
  '--agent', 'pulse-readonly',
32
39
  ...(model ? ['--model', model] : []),
33
40
  // The model's reasoning rung, as OpenCode names it (`--variant`, 1.18).
@@ -43,8 +50,10 @@ export function buildOpenCodeArgs({ projectRoot, prompt, model = process.env.PUL
43
50
  // Verified against opencode 1.18.4: absolute patterns never match, so the lease is named by
44
51
  // its directory relative to the project.
45
52
  export const FORBIDDEN_GLOBS = ['.git/**', '.pulse/**', '.madre/**', '.env', '.env.*', '**/.env', '**/.env.*', '.claude/settings.local.json'];
53
+ // OpenCode's last matching rule wins, so the templates of .env are allowed after the deny (NUE-21).
54
+ const ENV_TEMPLATE_GLOBS = ENV_TEMPLATES.flatMap((name) => [name, `**/${name}`]);
46
55
  export function writeRules(relativeDir, { control = false, create = false } = {}) {
47
- if (control || create) return { '*': 'allow', ...Object.fromEntries(FORBIDDEN_GLOBS.map((glob) => [glob, 'deny'])) };
56
+ if (control || create) return { '*': 'allow', ...Object.fromEntries(FORBIDDEN_GLOBS.map((glob) => [glob, 'deny'])), ...Object.fromEntries(ENV_TEMPLATE_GLOBS.map((glob) => [glob, 'allow'])) };
48
57
  const dir = String(relativeDir ?? '.').replace(/^\.\/+/, '').replace(/\/+$/, '');
49
58
  return { '*': 'deny', [dir && dir !== '.' ? `${dir}/**` : '**']: 'allow' };
50
59
  }
@@ -113,7 +122,32 @@ export function openCodeConfig({ lease = null, scopes = null, imageStudio = null
113
122
  },
114
123
  };
115
124
  }
116
- return config;
125
+ return withSubagents(config, lease);
126
+ }
127
+
128
+ // OpenCode's own subagents, from #1 to #3 (2026-10-29). A subagent does not inherit the permissions
129
+ // of the agent that calls it: it has its own, and OpenCode's `general` writes and runs commands out
130
+ // of the box (verified with the real CLI: told it was allowed, it wrote a file in #1). So only
131
+ // `explore` and `general` may be called, each with exactly the permissions of this run, and neither
132
+ // may call another. In #4 only the agent itself works.
133
+ export const SUBAGENTS = ['explore', 'general'];
134
+ const SUBAGENT_LINE = 'launch subagents other than explore and general, which work with exactly your permissions';
135
+ export function withSubagents(config, lease = null) {
136
+ if (lease?.airlock) return config;
137
+ const main = config.agent['pulse-readonly'];
138
+ const own = { ...main.permission, task: 'deny' };
139
+ return {
140
+ ...config,
141
+ agent: {
142
+ ...config.agent,
143
+ 'pulse-readonly': {
144
+ ...main,
145
+ prompt: main.prompt.replace('launch subagents', SUBAGENT_LINE),
146
+ permission: { ...main.permission, task: { '*': 'deny', ...Object.fromEntries(SUBAGENTS.map((name) => [name, 'allow'])) } },
147
+ },
148
+ ...Object.fromEntries(SUBAGENTS.map((name) => [name, { permission: own }])),
149
+ },
150
+ };
117
151
  }
118
152
 
119
153
  export function openCodeEnvironment(environment = process.env, { lease = null, scopes = null, imageStudio = null, memoryServer = null, mcpServers = [] } = {}) {
@@ -125,8 +159,21 @@ export function openCodeEnvironment(environment = process.env, { lease = null, s
125
159
  };
126
160
  }
127
161
 
128
- export function parseOpenCodeOutput(output) {
129
- const text = [];
162
+ // The answer is what OpenCode says in its last step. A step before a tool call is narration
163
+ // («I'll take a look at the project to answer accurately.»), and glued to the answer with nothing
164
+ // between them it opened the bubble in English and left «## Qué es» as a literal line (QA 1.1.0,
165
+ // NUE-17). Short narration goes; anything longer than the answer stays, a paragraph apart.
166
+ const NARRATION_LIMIT = 400;
167
+ export function answerOfSteps(steps) {
168
+ const said = steps.map((parts) => parts.join('').replace(/^[\s\u200b]+|[\s\u200b]+$/g, '')).filter(Boolean);
169
+ if (said.length < 2) return said[0] ?? '';
170
+ const last = said.at(-1);
171
+ const before = said.slice(0, -1).join('\n\n');
172
+ return before.length <= NARRATION_LIMIT && last.length >= before.length ? last : said.join('\n\n');
173
+ }
174
+
175
+ export function parseOpenCodeOutput(output, { root = null } = {}) {
176
+ const steps = [[]];
130
177
  let usage = null;
131
178
  let error = null;
132
179
  for (const line of output.split('\n').filter(Boolean)) {
@@ -136,8 +183,9 @@ export function parseOpenCodeOutput(output) {
136
183
  const detail = event.error.data?.message ?? event.error.message ?? '';
137
184
  error = [event.error.name, detail].filter(Boolean).join(': ') || 'OpenCode returned an error.';
138
185
  }
186
+ if (event.type === 'step_start' && steps.at(-1).length) steps.push([]);
139
187
  if (event.type === 'text' && typeof event.part?.text === 'string') {
140
- text.push(event.part.text);
188
+ steps.at(-1).push(event.part.text);
141
189
  }
142
190
  if (event.type === 'step_finish' && event.part?.tokens) {
143
191
  const tokens = event.part.tokens;
@@ -155,12 +203,26 @@ export function parseOpenCodeOutput(output) {
155
203
  // Ignore non-event diagnostic lines; stderr is reported when the process fails.
156
204
  }
157
205
  }
158
- return { text: text.join('').trim(), usage, ...(error ? { error } : {}) };
206
+ // What its subagents did (src/adapters/subagents.mjs): each `task` call, said once it is over.
207
+ const subagents = openCodeSubagents(jsonLines(output), { root });
208
+ return { text: answerOfSteps(steps), usage, ...(error ? { error } : {}), ...(subagents.length ? { subagents } : {}) };
209
+ }
210
+
211
+ // What in OpenCode's error log ends a turn that will never answer. Only a limit that does not pass
212
+ // by retrying: a rate limit of a few seconds OpenCode rides out on its own and still answers.
213
+ export function watchOpenCodeErrors(stderr) {
214
+ if (/Free usage limit reached/i.test(String(stderr ?? ''))) {
215
+ const error = new Error(t('The free use of OpenCode ran out for now: its own free models have a limit and OpenCode stopped answering. Connect a provider of yours in Settings › Agents › OpenCode, or ask @madre or another agent.'));
216
+ error.code = 'FREE_LIMIT';
217
+ return error;
218
+ }
219
+ return null;
159
220
  }
160
221
 
161
222
  export function invokeOpenCode({ executable, projectRoot, prompt, timeoutMs = 120000, signal, model = null, effort = null, attachments = [], lease = null, scopes = null, imageStudio = null, memoryServer = null, mcpServers = [], onProgress = null }) {
162
223
  return runReadonlyProcess({
163
- onProgress: onProgress ? (out) => onProgress({ chars: out.length }) : null,
224
+ // The answer written so far and its subagents, not the length of the protocol around them.
225
+ onProgress: onProgress ? (out) => { const said = parseOpenCodeOutput(out, { root: projectRoot }); onProgress({ chars: said.text.length, subagents: said.subagents ?? [] }); } : null,
164
226
  executable,
165
227
  args: buildOpenCodeArgs({ projectRoot, prompt, attachments, effort, ...(model ? { model } : {}) }),
166
228
  cwd: projectRoot,
@@ -168,6 +230,7 @@ export function invokeOpenCode({ executable, projectRoot, prompt, timeoutMs = 12
168
230
  timeoutMs,
169
231
  signal,
170
232
  label: 'OpenCode',
171
- parse: parseOpenCodeOutput,
233
+ watchStderr: watchOpenCodeErrors,
234
+ parse: (out) => parseOpenCodeOutput(out, { root: projectRoot }),
172
235
  });
173
236
  }
@@ -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 { t } from '../i18n.mjs';
5
5
 
@@ -32,17 +32,18 @@ export function terminateProcessTree(child, { graceMs = 2000 } = {}) {
32
32
  // and both used to surface as a bare `exited with code 143`, which reads like a crash and is not
33
33
  // one: something STOPPED it. Naming the signal is the difference between looking for a bug in the
34
34
  // agent and looking for whoever pulled the plug.
35
+ // In the room's language (QA 1.1.0, ACT-11): «OpenCode exited with code 1. Última salida: …» mixed two.
35
36
  const SIGNAL_MEANING = {
36
- SIGTERM: 'was stopped (SIGTERM) — something asked it to quit: STOP ALL, a timeout, or the room shutting down',
37
- SIGKILL: 'was killed outright (SIGKILL) — usually this machine running out of memory',
38
- SIGINT: 'was interrupted (SIGINT) — a Ctrl+C reached it',
39
- SIGHUP: 'lost its terminal (SIGHUP)',
37
+ SIGTERM: '{label} was stopped (SIGTERM) — something asked it to quit: STOP ALL, a timeout, or the room shutting down.',
38
+ SIGKILL: '{label} was killed outright (SIGKILL) — usually this machine running out of memory.',
39
+ SIGINT: '{label} was interrupted (SIGINT) — a Ctrl+C reached it.',
40
+ SIGHUP: '{label} lost its terminal (SIGHUP).',
40
41
  };
41
- function endedBy(code, closedBy) {
42
+ function endedBy(code, closedBy, label) {
42
43
  const name = closedBy ?? (Number.isInteger(code) && code > 128 ? Object.keys(SIGNAL_MEANING).find((key) => code === 128 + { SIGHUP: 1, SIGINT: 2, SIGKILL: 9, SIGTERM: 15 }[key]) : null);
43
- if (name && SIGNAL_MEANING[name]) return `${SIGNAL_MEANING[name]}.`;
44
- if (name) return `ended on ${name}.`;
45
- return `exited with code ${code}.`;
44
+ if (name && SIGNAL_MEANING[name]) return t(SIGNAL_MEANING[name], { label });
45
+ if (name) return t('{label} ended on {signal}.', { label, signal: name });
46
+ return t('{label} exited with code {code}.', { label, code });
46
47
  }
47
48
 
48
49
  // One explanation for a process that never ran, whichever way spawn refused. ENOENT is the
@@ -149,17 +150,20 @@ export function runReadonlyProcess({
149
150
  const armIdle = () => {
150
151
  if (!idleTimeoutMs) return;
151
152
  clearTimeout(idleTimer);
152
- idleTimer = setTimeout(() => {
153
+ // The verdict waits one turn of the loop, after the pipes are read: a timer that fires late,
154
+ // because the loop was busy, used to judge before the lines already waiting in the pipe were
155
+ // heard, and stopped a process that had been talking all along (2026-10-21).
156
+ idleTimer = setTimeout(() => setImmediate(() => {
153
157
  if (settled) return;
154
158
  if (Date.now() - lastActivity < idleTimeoutMs) { armIdle(); return; }
155
159
  terminateProcessTree(child, { graceMs: killGraceMs });
156
160
  const lastLine = lastWords(stdout) ?? lastWords(stderr);
157
- const error = new Error(`${label} went silent for ${Math.round(idleTimeoutMs / 1000)}s and was stopped.${lastLine ? ` Last output: ${lastLine.slice(0, 200)}` : ''}`);
161
+ const error = new Error(t('{label} went silent for {seconds}s and was stopped.', { label, seconds: Math.round(idleTimeoutMs / 1000) }) + (lastLine ? t(' Last output: {output}', { output: lastLine.slice(0, 200) }) : ''));
158
162
  error.code = 'IDLE';
159
163
  error.partialOutput = stdout;
160
164
  error.partialStderr = stderr.slice(-2000);
161
165
  finish(() => reject(error));
162
- }, idleTimeoutMs);
166
+ }), idleTimeoutMs);
163
167
  idleTimer.unref?.();
164
168
  };
165
169
 
@@ -225,8 +229,8 @@ export function runReadonlyProcess({
225
229
  // labelled as output, the way a timeout carries it, and never as the cause.
226
230
  const lastLine = printed.split('\n').map((line) => line.trim()).filter(Boolean).at(-1);
227
231
  const why = response.error ?? ((code === 0
228
- ? `${label} exited cleanly without an answer.`
229
- : `${label} ${endedBy(code, closedBy)}`) + (lastLine ? t(' Last output: {output}', { output: lastLine.slice(0, 200) }) : ''));
232
+ ? t('{label} exited cleanly without an answer.', { label })
233
+ : endedBy(code, closedBy, label)) + (lastLine ? t(' Last output: {output}', { output: lastLine.slice(0, 200) }) : ''));
230
234
  const error = new Error(printed ? `${why}\n\n${label} printed:\n${printed.slice(-600)}` : why);
231
235
  error.partialStderr = printed.slice(-2000);
232
236
  error.exitCode = code;
@@ -0,0 +1,159 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // WHAT THE SUBAGENTS DID (2026-10-29). Claude, OpenCode and Codex may hand part of a turn to their
4
+ // own subagents from #1 to #3 (src/lease.mjs, subagentsAllowed). Each CLI says so in its own way;
5
+ // these readers turn what it said into one list the room shows the same way for all three: a chip
6
+ // per subagent while the turn runs, and «Helped by N subagents» folded under the answer.
7
+ //
8
+ // One entry: { id, kind, task, status: 'running' | 'done' | 'failed', seconds, reads, searches,
9
+ // changed: [paths], report }. A field the CLI does not say is null, never a guess:
10
+ // · Claude says everything — when each one starts, each tool it uses, when it ends and what it
11
+ // reported (stream-json: task_started, task_progress, task_notification, and the subagent's
12
+ // own tool calls carry its parent_tool_use_id).
13
+ // · OpenCode says each one once, when it ends: its kind, its task, how long and what it reported.
14
+ // · Codex says only that it is waiting on its subagents: no task, no report (exec --json, 0.161).
15
+
16
+ const KIND_LIMIT = 40;
17
+ const TASK_LIMIT = 160;
18
+ const REPORT_LIMIT = 2400;
19
+ const FILES_LIMIT = 20;
20
+ const clip = (text, limit) => {
21
+ const said = String(text ?? '').replace(/\u200b/g, '').replace(/\s+/g, ' ').trim();
22
+ return said.length > limit ? `${said.slice(0, limit - 1)}…` : said || null;
23
+ };
24
+ // A report keeps its lines (it is markdown, shown as markdown); only its length is bounded.
25
+ const clipBlock = (text, limit) => {
26
+ // A report that opens with a zero-width space (OpenCode's) read as «​# Review», not as a heading.
27
+ const said = String(text ?? '').replace(/\u200b/g, '').replace(/\r/g, '').replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
28
+ return said.length > limit ? `${said.slice(0, limit - 1).trimEnd()}…` : said || null;
29
+ };
30
+ const relative = (path, root) => {
31
+ const said = String(path ?? '');
32
+ if (!root) return said;
33
+ const base = String(root).replace(/\/+$/, '');
34
+ return said.startsWith(`${base}/`) ? said.slice(base.length + 1) : said;
35
+ };
36
+ // The project's own paths said from the project, as the rest of the room says them.
37
+ const inProject = (text, root) => {
38
+ if (!root || !text) return text;
39
+ const base = String(root).replace(/\/+$/, '');
40
+ return String(text).split(`${base}/`).join('').split(base).join('.');
41
+ };
42
+ const READ_TOOLS = new Set(['Read', 'NotebookRead']);
43
+ const SEARCH_TOOLS = new Set(['Grep', 'Glob', 'LS', 'WebSearch', 'WebFetch']);
44
+ const WRITE_TOOLS = new Set(['Write', 'Edit', 'MultiEdit', 'NotebookEdit']);
45
+
46
+ // Claude, from its stream (one JSON object per line). `root` makes the changed paths the project's.
47
+ export function claudeSubagents(events, { root = null } = {}) {
48
+ const byTool = new Map();
49
+ const byTask = new Map();
50
+ const of = (toolId) => byTool.get(toolId) ?? null;
51
+ for (const event of events) {
52
+ if (event?.type === 'assistant') {
53
+ for (const part of event.message?.content ?? []) {
54
+ if (part?.type !== 'tool_use') continue;
55
+ if (part.name === 'Agent' || part.name === 'Task') {
56
+ if (byTool.has(part.id)) continue;
57
+ byTool.set(part.id, { id: part.id, kind: clip(part.input?.subagent_type ?? 'general-purpose', KIND_LIMIT), task: clip(part.input?.description ?? part.input?.prompt, TASK_LIMIT), status: 'running', seconds: null, reads: 0, searches: 0, changed: [], report: null, parent: event.parent_tool_use_id ?? null });
58
+ continue;
59
+ }
60
+ const owner = of(event.parent_tool_use_id);
61
+ if (!owner) continue;
62
+ if (READ_TOOLS.has(part.name)) owner.reads += 1;
63
+ else if (SEARCH_TOOLS.has(part.name)) owner.searches += 1;
64
+ else if (WRITE_TOOLS.has(part.name)) {
65
+ const file = relative(part.input?.file_path ?? part.input?.notebook_path, root);
66
+ if (file && !owner.changed.includes(file) && owner.changed.length < FILES_LIMIT) owner.changed.push(file);
67
+ }
68
+ }
69
+ continue;
70
+ }
71
+ if (event?.type !== 'system') continue;
72
+ if (event.subtype === 'task_started' && event.tool_use_id) {
73
+ byTask.set(event.task_id, event.tool_use_id);
74
+ const owner = of(event.tool_use_id);
75
+ if (owner && !owner.task) owner.task = clip(event.description, TASK_LIMIT);
76
+ }
77
+ const owner = of(event.tool_use_id ?? byTask.get(event.task_id));
78
+ if (!owner) continue;
79
+ const ms = Number(event.usage?.duration_ms);
80
+ if (Number.isFinite(ms) && ms > 0) owner.seconds = Math.round(ms / 1000);
81
+ if (event.subtype === 'task_notification' || (event.subtype === 'task_updated' && event.patch?.status)) {
82
+ const status = event.status ?? event.patch?.status;
83
+ if (status) owner.status = status === 'completed' ? 'done' : status === 'running' ? 'running' : 'failed';
84
+ if (event.summary) owner.report = clipBlock(inProject(event.summary, root), REPORT_LIMIT);
85
+ }
86
+ }
87
+ // A subagent of a subagent is still the turn's: listed, after the one that called it.
88
+ return [...byTool.values()].map(({ parent, ...entry }) => entry);
89
+ }
90
+
91
+ // OpenCode, from its --format json events: a `task` tool call, said once it is over.
92
+ export function openCodeSubagents(events, { root = null } = {}) {
93
+ const out = [];
94
+ for (const event of events) {
95
+ const part = event?.part;
96
+ if (event?.type !== 'tool_use' || part?.tool !== 'task') continue;
97
+ const state = part.state ?? {};
98
+ const took = Number(state.time?.end) - Number(state.time?.start);
99
+ const said = String(state.output ?? '').replace(/<\/?task[^>]*>|<\/?task_result>/g, '').trim();
100
+ out.push({
101
+ id: part.callID ?? part.id ?? `task-${out.length}`,
102
+ kind: clip(state.input?.subagent_type ?? 'general', KIND_LIMIT),
103
+ task: clip(state.input?.description ?? state.title ?? state.input?.prompt, TASK_LIMIT),
104
+ status: state.status === 'completed' ? 'done' : state.status === 'error' ? 'failed' : 'running',
105
+ seconds: Number.isFinite(took) && took > 0 ? Math.round(took / 1000) : null,
106
+ reads: null,
107
+ searches: null,
108
+ changed: [],
109
+ report: clipBlock(inProject(state.status === 'error' ? state.error ?? said : said, root), REPORT_LIMIT),
110
+ });
111
+ }
112
+ return out;
113
+ }
114
+
115
+ // Codex, from its exec --json events: its collaboration calls. It names no task and hands back no
116
+ // report, so the room can only say it is working with subagents, and while it waits on them.
117
+ export function codexSubagents(events) {
118
+ const calls = new Map();
119
+ for (const event of events) {
120
+ const item = event?.item;
121
+ if (item?.type !== 'collab_tool_call') continue;
122
+ calls.set(item.id, { tool: item.tool, done: event.type === 'item.completed' || item.status === 'completed', failed: item.status === 'failed', threads: item.receiver_thread_ids ?? [], prompt: item.prompt ?? null });
123
+ }
124
+ if (!calls.size) return [];
125
+ const threads = new Set();
126
+ for (const call of calls.values()) for (const id of call.threads) threads.add(id);
127
+ const running = [...calls.values()].some((call) => !call.done);
128
+ const failed = [...calls.values()].every((call) => call.failed);
129
+ const asked = [...calls.values()].map((call) => call.prompt).find(Boolean) ?? null;
130
+ return [{ id: 'codex-subagents', kind: null, task: clip(asked, TASK_LIMIT), status: running ? 'running' : failed ? 'failed' : 'done', seconds: null, reads: null, searches: null, changed: [], report: null, count: threads.size || null }];
131
+ }
132
+
133
+ // What the room keeps and shows of a list: bounded, and each text through the room's privacy guard.
134
+ export function keptSubagents(list, { redact = (text) => text } = {}) {
135
+ if (!Array.isArray(list) || !list.length) return undefined;
136
+ return list.slice(0, 12).map((one) => ({
137
+ id: String(one.id ?? '').slice(0, 80),
138
+ kind: one.kind ? clip(redact(one.kind), KIND_LIMIT) : null,
139
+ task: one.task ? clip(redact(one.task), TASK_LIMIT) : null,
140
+ status: ['running', 'done', 'failed'].includes(one.status) ? one.status : 'done',
141
+ seconds: Number.isFinite(one.seconds) ? one.seconds : null,
142
+ reads: Number.isFinite(one.reads) ? one.reads : null,
143
+ searches: Number.isFinite(one.searches) ? one.searches : null,
144
+ changed: Array.isArray(one.changed) ? one.changed.slice(0, FILES_LIMIT).map((file) => String(file).slice(0, 200)) : [],
145
+ report: one.report ? clipBlock(redact(one.report), REPORT_LIMIT) : null,
146
+ ...(Number.isFinite(one.count) ? { count: one.count } : {}),
147
+ }));
148
+ }
149
+
150
+ // One JSON object per line; a line that is not one (a CLI's own note) is stepped over.
151
+ export function jsonLines(output) {
152
+ const events = [];
153
+ for (const line of String(output ?? '').split('\n')) {
154
+ const text = line.trim();
155
+ if (!text.startsWith('{')) continue;
156
+ try { events.push(JSON.parse(text)); } catch { /* not an event */ }
157
+ }
158
+ return events;
159
+ }
package/src/asking.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 the room should ask next.
4
4
  //
5
5
  // The maturity reading says where the archive is thin; it does not say what to do about it on a
@@ -76,6 +76,8 @@ export function questionsFor({ notes = [], cold = new Map(), dismissed = [], lim
76
76
  why: Number(note.recalled ?? 0) > 0
77
77
  ? `the room has carried this open question into ${note.recalled} turn${Number(note.recalled) === 1 ? '' : 's'} and still has no answer`
78
78
  : 'the archivist recorded this as open and nothing has answered it',
79
+ // The why as the page says it, in the person's language (2026-10-28).
80
+ reason: Number(note.recalled ?? 0) > 0 ? { key: 'carried', n: Number(note.recalled) } : { key: 'recorded' },
79
81
  weight: 100 + Number(note.recalled ?? 0),
80
82
  });
81
83
  }
@@ -90,6 +92,8 @@ export function questionsFor({ notes = [], cold = new Map(), dismissed = [], lim
90
92
  memoryId: note.id,
91
93
  text: `Is this still true, and does it still matter here? ${quote(note.text)}`,
92
94
  why: `the archive has been opened ${chill.chances} times since this was written and never once carried it`,
95
+ reason: { key: 'cold', n: chill.chances },
96
+ subject: String(note.text ?? '').replace(/\s+/g, ' ').trim(),
93
97
  weight: 50 + chill.chances,
94
98
  });
95
99
  }
@@ -107,6 +111,8 @@ export function questionsFor({ notes = [], cold = new Map(), dismissed = [], lim
107
111
  memoryId: null,
108
112
  text: KIND_ASK[kind],
109
113
  why: `${count} of ${standing.length} notes are ${KIND_WHY[kind]}`,
114
+ reason: { key: 'thin', count, of: standing.length },
115
+ kind,
110
116
  weight: 40 - count,
111
117
  });
112
118
  }
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  import { execFile } from 'node:child_process';
4
4
  import { t } from './i18n.mjs';
5
5
  import { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
@@ -45,6 +45,13 @@ export function parseOpenCodeAuthList({ stdout = '' }) {
45
45
  return { state: 'signed-out', detail: 'no providers configured', providers: [] };
46
46
  }
47
47
 
48
+ // `opencode models opencode`: the models OpenCode serves itself, one `opencode/<model>` per line.
49
+ export function openCodeOwnModels({ stdout = '', code = 0 }) {
50
+ const models = stripAnsi(stdout).split('\n').map((line) => line.trim()).filter((line) => /^opencode\/[\w.:-]+$/.test(line));
51
+ if (code !== 0 || !models.length) return null;
52
+ return { state: 'signed-in', detail: `OpenCode's own free models, no account (${models.length})`, providers: [], own: models.length };
53
+ }
54
+
48
55
  // `cursor-agent status` says «Not logged in», or who is signed in («Logged in as …»). A key in the
49
56
  // environment (CURSOR_API_KEY) signs every run in on its own, so it counts too.
50
57
  export function parseCursorStatus({ stdout = '', stderr = '' }, env = process.env) {
@@ -71,9 +78,12 @@ async function run(path, args, timeout = 6000) {
71
78
  const { stdout, stderr } = await execFileAsync(path, args, { timeout, env: { ...process.env, NO_COLOR: '1' } });
72
79
  return { stdout, stderr, code: 0 };
73
80
  } catch (error) {
74
- return { stdout: error.stdout ?? '', stderr: error.stderr ?? error.message, code: error.code ?? 1 };
81
+ // A CLI that did not answer in time is not a CLI without a session (QA 1.1.0, ACT-08): with
82
+ // several projects starting at once `opencode models` took 5 to 22 s and was read as signed out.
83
+ return { stdout: error.stdout ?? '', stderr: error.stderr ?? error.message, code: error.code ?? 1, timedOut: Boolean(error.killed) };
75
84
  }
76
85
  }
86
+ const UNANSWERED = { state: 'unknown', detail: 'no answer in time', timedOut: true };
77
87
 
78
88
  const exists = (path) => access(path).then(() => true, () => false);
79
89
 
@@ -108,6 +118,12 @@ export const AGENT_SETUP = {
108
118
  login: ['login'],
109
119
  loginNote: 'Opens your browser to sign in with ChatGPT.',
110
120
  browser: true,
121
+ // Two doors (2026-10-28): the browser, which comes back to this computer, and a code typed on
122
+ // OpenAI's page from any device — the one that works when MADRE runs on another computer (SSH).
123
+ methods: [
124
+ { id: 'chatgpt', label: 'ChatGPT account', args: ['login'], note: 'Opens your browser to sign in with your ChatGPT account.' },
125
+ { id: 'device', label: 'With a code', args: ['login', '--device-auth'], note: 'Gives you a code to type on OpenAI\'s page, from this or any other device. Use it when MADRE runs on another computer.', room: { deviceCode: true } },
126
+ ],
111
127
  // What a newcomer needs to know before choosing this door: which account, and whether
112
128
  // there is a way in without paying. `paid: null` means it depends on the provider you pick.
113
129
  vendor: 'OpenAI',
@@ -206,7 +222,7 @@ export const AGENT_SETUP = {
206
222
  browser: true,
207
223
  terminal: 'cursor-agent login',
208
224
  vendor: 'Cursor',
209
- account: 'Signs in with your Cursor account and uses its plan. For now it reads and answers; it does not write in your project.',
225
+ account: 'Signs in with your Cursor account and uses its plan. A free plan answers only with Auto, and only while it has use left.',
210
226
  paid: true,
211
227
  },
212
228
  };
@@ -222,7 +238,7 @@ export const AGENT_PACKAGE = {
222
238
  };
223
239
  // One honest line per agent about the account it needs, for the bridge and for Settings › Agents.
224
240
  // Which agents take a pasted key instead of a browser flow.
225
- export const TAKES_KEY = new Set(['claude', 'gemini', 'opencode']);
241
+ export const TAKES_KEY = new Set(['codex', 'claude', 'gemini', 'opencode']);
226
242
 
227
243
  // A CLI that signs in through a page and then waits for the code that page gives back. The room
228
244
  // reads its output for both: the address to open, and the moment it starts waiting.
@@ -232,7 +248,10 @@ export const looksLikeCodePrompt = (line) => CODE_PROMPT.test(String(line ?? '')
232
248
  // The other way round: a device sign-in shows a code to type on the provider's page
233
249
  // ("Enter code: 3475-C193"), and the room has to show it, not ask for one.
234
250
  export const DEVICE_CODE = /enter\s+(?:the\s+|this\s+)?code:?\s+([A-Z0-9]{4,}(?:-[A-Z0-9]{4,})+)/i;
235
- export const deviceCodeIn = (line) => String(line ?? '').match(DEVICE_CODE)?.[1] ?? null;
251
+ // Codex prints its code alone on the line under «Enter this one-time code» (2026-10-28): a line that is
252
+ // nothing but a code counts too. Read only from a sign-in that gives a code to type, never elsewhere.
253
+ const CODE_ALONE = /^\s*([A-Z0-9]{4,}(?:-[A-Z0-9]{4,})+)\s*$/;
254
+ export const deviceCodeIn = (line) => String(line ?? '').match(DEVICE_CODE)?.[1] ?? String(line ?? '').match(CODE_ALONE)?.[1] ?? null;
236
255
 
237
256
  export function accountNoteFor(id) {
238
257
  // Said in the room's language when it is asked for, not when this file is imported.
@@ -249,7 +268,12 @@ export const looksLikeAdminProblem = (output) => NEEDS_ADMIN.test(String(output
249
268
 
250
269
  export function installPlanFor(agent, { prefix = null } = {}) {
251
270
  const name = AGENT_PACKAGE[agent?.id];
252
- if (!name) return null;
271
+ // An agent with no npm package (Cursor) installs with its own installer, a script from its site:
272
+ // MADRE does not fetch and run that on its own; it says the command, to copy into a terminal.
273
+ if (!name) {
274
+ const own = AGENT_SETUP[agent?.id]?.install ?? [];
275
+ return own.length ? { package: null, command: null, args: [], display: own[0], fallback: null, alternatives: own.slice(1), terminal: true } : null;
276
+ }
253
277
  return {
254
278
  package: name,
255
279
  command: 'npm',
@@ -343,11 +367,23 @@ export function geminiSignIn({ env = process.env, verifyMs = 30000 } = {}) {
343
367
  export async function probeAgentAuth(agent) {
344
368
  if (agent.id === 'madre') return agent.ready ? { state: 'signed-in', detail: `local · ${agent.version ?? 'Ollama'}` } : { state: 'signed-out', detail: 'Ollama is not running or has no chat model' };
345
369
  if (!agent.detected || !agent.path) return { state: 'not-installed', detail: 'not found on this computer' };
370
+ const answered = (result, read) => (result.timedOut ? UNANSWERED : read(result));
346
371
  switch (agent.id) {
347
- case 'codex': return parseCodexLoginStatus(await run(agent.path, ['login', 'status']));
348
- case 'claude': return parseClaudeAuthStatus(await run(agent.path, ['auth', 'status', '--json']));
349
- case 'opencode': return parseOpenCodeAuthList(await run(agent.path, ['auth', 'list']));
350
- case 'cursor': return parseCursorStatus(await run(agent.path, ['status']));
372
+ case 'codex': return answered(await run(agent.path, ['login', 'status']), parseCodexLoginStatus);
373
+ case 'claude': return answered(await run(agent.path, ['auth', 'status', '--json']), parseClaudeAuthStatus);
374
+ case 'opencode': {
375
+ const asked = await run(agent.path, ['auth', 'list']);
376
+ if (asked.timedOut) return UNANSWERED;
377
+ const listed = parseOpenCodeAuthList(asked);
378
+ if (listed.state === 'signed-in') return listed;
379
+ // No provider of its own, and still it answers: OpenCode brings free models that need no account
380
+ // (opencode/big-pickle by default). Called signed out, the one agent a newcomer could use
381
+ // without signing in anywhere was the one MADRE would not let them write to (2026-10-19).
382
+ const own = await run(agent.path, ['models', 'opencode'], 15000);
383
+ if (own.timedOut) return UNANSWERED;
384
+ return openCodeOwnModels(own) ?? listed;
385
+ }
386
+ case 'cursor': return answered(await run(agent.path, ['status']), parseCursorStatus);
351
387
  case 'gemini': return probeGemini();
352
388
  default: return { state: 'unknown', detail: 'no probe for this agent' };
353
389
  }
@@ -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 phones that may reach this Mac, and the networks where they may.
4
4
  //
5
5
  // One file, `~/.pulse/devices.json`, owner-only, shared by every room on this Mac: any of them can
@@ -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
  // Where the person was, on the Mac and on the phone (docs/MOBILE.md, MOV-005).
4
4
  //
5
5
  // One small file for the whole Mac, `~/.pulse/handoff.json`, owner-only: the last place each side
@@ -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
  // Who keeps the bridge up. Every room on this Mac offers to; the port decides.
4
4
  //
5
5
  // No process of its own and nothing to start: each room, every few seconds, asks whether a phone
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // Which network this Mac is on, and how a phone on it reaches the Mac.
4
4
  //
5
5
  // A network is known by its router: the hardware address of the default gateway, hashed. Two
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // What a phone may do in a room (docs/MOBILE.md, section 4).
4
4
  //
5
5
  // A list of what passes, not of what does not: a route the room grows tomorrow stays on the Mac
@@ -17,7 +17,7 @@ import { t } from '../i18n.mjs';
17
17
 
18
18
  // Every file the room's page loads: one missing here and app.js cannot import it, so the whole page
19
19
  // stops on the phone (test/phone-bridge.test.mjs reads app.js's imports to keep this whole).
20
- const STATIC = new Set(['/', '/app.js', '/nostromo-engine.js', '/brands.js', '/troubleshooting.js', '/inquiry.js', '/i18n.js', '/es.js', '/resay.js', '/syntax.js', '/editor.js', '/routing.js', '/abduction.js', '/styles.css', '/review-ask.js', '/loader.js', '/tour.js', '/tour-chapters.js', '/touch.js', '/attribution.js', '/power.js', '/wallpaper.js', '/neural.js', '/hardware.js', '/code-tools.js', '/market.js', '/market-view.js', '/market-art.js']);
20
+ const STATIC = new Set(['/', '/app.js', '/icons.js', '/page-errors.js', '/activity.js', '/terms.js', '/nostromo-engine.js', '/brands.js', '/troubleshooting.js', '/inquiry.js', '/i18n.js', '/es.js', '/en.js', '/resay.js', '/syntax.js', '/editor.js', '/routing.js', '/abduction.js', '/styles.css', '/review-ask.js', '/loader.js', '/tour.js', '/tour-chapters.js', '/touch.js', '/attribution.js', '/power.js', '/wallpaper.js', '/neural.js', '/hardware.js', '/code-tools.js', '/market.js', '/market-view.js', '/market-art.js', '/mcp-catalog.js']);
21
21
 
22
22
  const READ = new Set([
23
23
  '/api/state', '/api/events', '/api/chats', '/api/version', '/api/whats-new', '/api/glance', '/api/handoff',
package/src/bridge/qr.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 QR a phone scans to pair with this Mac: text in, a grid of dark and light modules out, and
4
4
  // an SVG of that grid the room sizes and colours with CSS.
5
5
  //
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // The bridge: the one thing on this Mac a phone can reach (docs/MOBILE.md, MOV-001).
4
4
  //
5
5
  // Rooms keep listening on 127.0.0.1 and keep refusing anything that does not call them by that
@@ -31,7 +31,7 @@ const MESSAGE_LIMIT = 1024 * 1024;
31
31
 
32
32
  const MIME = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.svg': 'image/svg+xml', '.webp': 'image/webp', '.png': 'image/png', '.woff2': 'font/woff2', '.txt': 'text/plain; charset=utf-8', '.webmanifest': 'application/manifest+json' };
33
33
  // The bridge's own files, served from the package of the room that hosts it.
34
- const OWN = { '/salas': 'salas.html', '/bridge/salas.js': 'salas.js', '/bridge/salas.css': 'salas.css', '/bridge/styles.css': 'styles.css', '/bridge/i18n.js': 'i18n.js', '/bridge/es.js': 'es.js', '/bridge/touch.js': 'touch.js', '/bridge/manifest.webmanifest': 'manifest.webmanifest' };
34
+ const OWN = { '/salas': 'salas.html', '/bridge/salas.js': 'salas.js', '/bridge/salas.css': 'salas.css', '/bridge/styles.css': 'styles.css', '/bridge/i18n.js': 'i18n.js', '/bridge/es.js': 'es.js', '/bridge/en.js': 'en.js', '/bridge/touch.js': 'touch.js', '/bridge/manifest.webmanifest': 'manifest.webmanifest' };
35
35
  const HOP = new Set(['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'transfer-encoding', 'upgrade', 'host', 'cookie', 'origin', 'referer']);
36
36
 
37
37
  const alive = (pid) => { try { process.kill(pid, 0); return true; } catch (error) { return error.code === 'EPERM'; } };