@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
@@ -1,22 +1,75 @@
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
  // Notes (0.1, 2026-10-20): colored notes on a project, each one a window of the room.
4
4
  //
5
5
  // A note is what a person writes for themself: no agent reads it, nothing is sent anywhere, and it
6
6
  // does not go into the project's folder. They are kept beside the project's conversations, in
7
- // ~/.pulse/rooms/<id>/notes.json, one file per project, written whole (src/json-file.mjs). The page
7
+ // ~/.pulse/rooms/<id>/notes.json, one file per project, written whole. The page
8
8
  // draws each open note as a window of its own — the same windows every module has, moved by their
9
9
  // head and sized by their edges — and remembers where it was left.
10
+ //
11
+ // ONE FILE (SDK 2, 2026-10-25): the notes, their file and the tool server an agent uses, with
12
+ // nothing imported from MADRE, so a newer Notes can come from the Market, signed, without waiting
13
+ // for a new MADRE (src/builtin-updates.mjs). Run with node, the same file is the tool server.
10
14
 
11
- import { readFile } from 'node:fs/promises';
12
- import { join } from 'node:path';
15
+ import { mkdir, open, readFile, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
16
+ import { dirname, join } from 'node:path';
13
17
  import { randomUUID } from 'node:crypto';
14
- import { defineModule } from './sdk.mjs';
15
- import { oneAtATime, writeWhole } from '../json-file.mjs';
16
18
  import { fileURLToPath } from 'node:url';
17
- import { t } from '../i18n.mjs';
18
19
 
19
- export const NOTES_SERVER = fileURLToPath(new URL('../mcp/notes-server.mjs', import.meta.url));
20
+ const SELF = fileURLToPath(import.meta.url);
21
+
22
+ // FILES THAT MORE THAN ONE THING CHANGES (the same rules as MADRE's src/json-file.mjs): written
23
+ // whole, through a draft renamed over the file, and one change at a time — in this process by a
24
+ // queue, and between the rooms of this computer and the tool server by a lock file beside it.
25
+ async function writeWhole(file, text, { mode } = {}) {
26
+ await mkdir(dirname(file), { recursive: true });
27
+ const draft = `${file}.${process.pid}.${randomUUID()}.tmp`;
28
+ try {
29
+ await writeFile(draft, text, mode ? { mode } : undefined);
30
+ await rename(draft, file);
31
+ } catch (error) {
32
+ await rm(draft, { force: true }).catch(() => {});
33
+ throw error;
34
+ }
35
+ }
36
+
37
+ const STALE_MS = 5000;
38
+ async function lockBeside(file) {
39
+ const lock = `${file}.lock`;
40
+ await mkdir(dirname(lock), { recursive: true });
41
+ for (let attempt = 0; attempt < 250; attempt += 1) {
42
+ try {
43
+ await (await open(lock, 'wx')).close();
44
+ return () => rm(lock, { force: true });
45
+ } catch (error) {
46
+ if (error.code !== 'EEXIST') throw error;
47
+ const since = await stat(lock).catch(() => null);
48
+ if (since && Date.now() - since.mtimeMs > STALE_MS) { await rm(lock, { force: true }); continue; }
49
+ await new Promise((resolve) => setTimeout(resolve, 20));
50
+ }
51
+ }
52
+ throw new Error(`${file} is being changed by another room; try again.`);
53
+ }
54
+
55
+ const queues = new Map();
56
+ function oneAtATime(file, work) {
57
+ const run = async () => {
58
+ const release = await lockBeside(file);
59
+ try {
60
+ return await work();
61
+ } finally {
62
+ await release();
63
+ }
64
+ };
65
+ const before = queues.get(file) ?? Promise.resolve();
66
+ const turn = before.then(run, run);
67
+ const settled = turn.catch(() => {});
68
+ queues.set(file, settled);
69
+ void settled.then(() => { if (queues.get(file) === settled) queues.delete(file); });
70
+ return turn;
71
+ }
72
+
20
73
  // A message that asks for a note (2026-10-20): «/notas …», «/notes …», «hazme una nota», «take a
21
74
  // note». Only then is the tool handed to the turn: a tool in every turn costs its description in
22
75
  // every prompt.
@@ -89,10 +142,13 @@ export function deleteNote(roomDir, id) {
89
142
  }
90
143
 
91
144
  const reply = (status, body) => ({ status, body });
92
- const on = (ctx) => Boolean(notes.settingsFrom(ctx.config, ctx.roomId).enabled);
93
- const door = (ctx) => (on(ctx) ? null : reply(412, { error: t('Notes is off in this project. Turn it on in Modules.') }));
145
+ // The room's words (ctx.t, SDK 2); outside a room — a test, the tool server — the English as written.
146
+ const say = (ctx, text, vars = null) => (typeof ctx?.t === 'function' ? ctx.t(text, vars) : String(text).replace(/\{(\w+)\}/g, (whole, name) => (vars && Object.hasOwn(vars, name) ? String(vars[name]) : whole)));
147
+ const on = (ctx) => Boolean(ctx.settings?.enabled);
148
+ const door = (ctx) => (on(ctx) ? null : reply(412, { error: say(ctx, 'Notes is off in this project. Turn it on in Modules.') }));
94
149
 
95
- const notes = defineModule({
150
+ export default {
151
+ sdk: 2,
96
152
  id: 'notes',
97
153
  name: 'Notes',
98
154
  vendor: 'MADRE',
@@ -104,18 +160,19 @@ const notes = defineModule({
104
160
  const list = await readNotes(ctx.roomDir);
105
161
  const enabled = Boolean(ctx.settings.enabled);
106
162
  return {
107
- status: { installed: enabled, detail: enabled ? t('{n} notes in this project', { n: list.length }) : t('off') },
163
+ status: { installed: enabled, detail: enabled ? (list.length === 1 ? say(ctx, '1 note in this project') : say(ctx, '{n} notes in this project', { n: list.length })) : say(ctx, 'off') },
108
164
  install: { display: enabled ? 'turn off Notes' : 'turn on Notes', platforms: [] },
109
165
  notes: list.length,
110
166
  };
111
167
  },
112
- // An agent makes a note when the person asks for one (src/mcp/notes-server.mjs): it can only add.
168
+ // An agent makes a note when the person asks for one (this same file, run as its tool server):
169
+ // it can only add.
113
170
  async toolsForTurn(ctx, turn) {
114
171
  if (!ctx.roomDir || (turn?.text !== undefined && !ASKS_FOR_NOTE.test(turn.text))) return [];
115
172
  return [{
116
173
  name: 'madre-notes',
117
174
  command: process.execPath,
118
- args: [NOTES_SERVER],
175
+ args: [SELF],
119
176
  env: { PULSE_NOTES_DIR: ctx.roomDir },
120
177
  tools: ['create_note'],
121
178
  brief: 'When the person asks for a note (they may write /notas or /notes), make it with the create_note tool of server madre-notes: short, clear, in their language. It opens on their screen as a colored note. You cannot read their other notes.',
@@ -127,16 +184,98 @@ const notes = defineModule({
127
184
  const closed = door(ctx);
128
185
  if (closed) return closed;
129
186
  const saved = await saveNote(ctx.roomDir, payload ?? {});
130
- if (saved.error === 'unknown') return reply(404, { error: t('That note is no longer here.') });
131
- if (saved.error === 'full') return reply(409, { error: t('This project already has {n} notes. Delete one to make room.', { n: NOTES_MAX }) });
187
+ if (saved.error === 'unknown') return reply(404, { error: say(ctx, 'That note is no longer here.') });
188
+ if (saved.error === 'full') return reply(409, { error: say(ctx, 'This project already has {n} notes. Delete one to make room.', { n: NOTES_MAX }) });
132
189
  return reply(200, saved);
133
190
  } },
134
191
  { method: 'POST', path: '/api/notes/delete', handler: async (ctx, { payload }) => {
135
192
  const closed = door(ctx);
136
193
  if (closed) return closed;
137
194
  const gone = await deleteNote(ctx.roomDir, String(payload?.id ?? ''));
138
- return gone.error ? reply(404, { error: t('That note is no longer here.') }) : reply(200, gone);
195
+ return gone.error ? reply(404, { error: say(ctx, 'That note is no longer here.') }) : reply(200, gone);
139
196
  } },
140
197
  ],
141
- });
142
- export default notes;
198
+ };
199
+
200
+ // THE TOOL SERVER (MCP over stdio, JSON-RPC 2.0), when an agent's turn runs this file with node:
201
+ // one tool, create_note. It only adds — it cannot read, change or delete the person's notes — and
202
+ // it writes the same file the page reads, beside the project's conversations.
203
+ //
204
+ // Environment:
205
+ // PULSE_NOTES_DIR the project's room folder (~/.pulse/rooms/<id>)
206
+ const SERVER_NAME = 'madre-notes';
207
+ const SERVER_VERSION = '2.0.0';
208
+ const NOTE_TOOL = {
209
+ name: 'create_note',
210
+ description: 'Make a note for the person: a colored note that opens as a window in their project. Use it when they ask for a note (they may write /notas or /notes). Write it for them, short and clear, in their language. You cannot read their other notes.',
211
+ inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'The note, as the person will read it.' }, color: { type: 'string', enum: NOTE_COLORS, description: 'Optional color.' } }, required: ['text'] },
212
+ };
213
+
214
+ async function createNote(args, env) {
215
+ const text = String(args.text ?? '').trim();
216
+ if (!text) throw new Error('The note needs its text.');
217
+ const saved = await saveNote(env.PULSE_NOTES_DIR, { text, color: NOTE_COLORS.includes(args.color) ? args.color : undefined });
218
+ if (saved.error === 'full') throw new Error('This project already has as many notes as it can keep. Ask the person to delete one.');
219
+ if (saved.error) throw new Error('The note was not saved.');
220
+ return `Note made (${saved.note.color}). It opens on the person's screen when your answer ends.`;
221
+ }
222
+
223
+ export function handleRequest(message, { env = process.env } = {}) {
224
+ const reply = (result) => ({ jsonrpc: '2.0', id: message.id, result });
225
+ const fail = (code, text) => ({ jsonrpc: '2.0', id: message.id, error: { code, message: text } });
226
+ const tools = env.PULSE_NOTES_DIR ? [NOTE_TOOL] : [];
227
+ switch (message.method) {
228
+ case 'initialize':
229
+ return Promise.resolve(reply({ protocolVersion: message.params?.protocolVersion ?? '2025-06-18', capabilities: { tools: {} }, serverInfo: { name: SERVER_NAME, version: SERVER_VERSION } }));
230
+ case 'notifications/initialized':
231
+ case 'initialized':
232
+ return Promise.resolve(null);
233
+ case 'ping':
234
+ return Promise.resolve(reply({}));
235
+ case 'tools/list':
236
+ return Promise.resolve(reply({ tools }));
237
+ case 'tools/call': {
238
+ const { name, arguments: args = {} } = message.params ?? {};
239
+ if (!tools.some((tool) => tool.name === name)) return Promise.resolve(fail(-32602, `Unknown tool: ${name}`));
240
+ return createNote(args, env)
241
+ .then((text) => reply({ content: [{ type: 'text', text }], isError: false }))
242
+ .catch((error) => reply({ content: [{ type: 'text', text: `Nothing was saved: ${error.message}` }], isError: true }));
243
+ }
244
+ default:
245
+ return Promise.resolve(message.id === undefined ? null : fail(-32601, `Method not found: ${message.method}`));
246
+ }
247
+ }
248
+
249
+ export function serve({ input = process.stdin, output = process.stdout, env = process.env } = {}) {
250
+ let buffer = '';
251
+ let pending = 0;
252
+ let ended = false;
253
+ const finish = () => { if (ended && pending === 0) process.exit(0); };
254
+ input.setEncoding('utf8');
255
+ input.on('data', (chunk) => {
256
+ buffer += chunk;
257
+ let index;
258
+ while ((index = buffer.indexOf('\n')) >= 0) {
259
+ const line = buffer.slice(0, index).trim();
260
+ buffer = buffer.slice(index + 1);
261
+ if (!line) continue;
262
+ let message;
263
+ try { message = JSON.parse(line); } catch { output.write(`${JSON.stringify({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } })}\n`); continue; }
264
+ pending += 1;
265
+ void handleRequest(message, { env })
266
+ .then((response) => { if (response) output.write(`${JSON.stringify(response)}\n`); })
267
+ .finally(() => { pending -= 1; finish(); });
268
+ }
269
+ });
270
+ input.on('end', () => { ended = true; finish(); });
271
+ }
272
+
273
+ // Both paths resolved before they are compared (WIN-004), as the other servers do.
274
+ const real = async (path) => (path ? realpath(path).catch(() => path) : null);
275
+ if (process.argv[1] && (await real(process.argv[1])) === (await real(SELF))) {
276
+ if (!process.env.PULSE_NOTES_DIR) {
277
+ process.stderr.write('PULSE_NOTES_DIR is required.\n');
278
+ process.exit(2);
279
+ }
280
+ serve();
281
+ }
@@ -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
  // OLLAMA: local intelligence. Embeddings and distillation on this machine when
4
4
  // Ollama runs. The server offers the wiring through ctx.services.ollama.
5
5
 
@@ -87,7 +87,7 @@ export async function ollamaView(probe, settings) {
87
87
  export default defineModule({
88
88
  id: 'ollama',
89
89
  name: 'Local AI',
90
- vendor: 'MADRE · LOCAL INTELLIGENCE',
90
+ vendor: 'MADRE · Local AI',
91
91
  tracks: { name: 'ollama', github: 'ollama/ollama' },
92
92
  summary: 'Searches and sums up the project\'s memory with local AI (Ollama): free, and nothing leaves your computer.',
93
93
  creates: ['nothing in the project', 'a block in ~/.pulse/config.json', 'models in Ollama\'s own store when you press PULL'],
@@ -157,6 +157,12 @@ export default defineModule({
157
157
  const started = await ctx.services.ollama.start();
158
158
  return started.ok ? { status: 200, body: { ollama: ctx.services.ollama.state() } } : { status: 412, body: { error: started.error } };
159
159
  } },
160
+ // Stops the download running now (the welcome's «Cancel»). What Ollama already wrote stays, and
161
+ // pulling the same model again goes on from there.
162
+ { method: 'POST', path: '/api/ollama/pull/cancel', handler: async (ctx, { payload }) => {
163
+ const stopped = ctx.services.ollama.cancelPull?.(typeof payload?.model === 'string' ? payload.model : null) ?? { ok: false };
164
+ return stopped.ok ? { status: 200, body: { cancelling: stopped.model } } : { status: 409, body: { error: stopped.error } };
165
+ } },
160
166
  { method: 'POST', path: '/api/ollama/pull', handler: async (ctx, { payload }) => {
161
167
  const model = String(payload.model ?? '').trim();
162
168
  if (!/^[a-z0-9][a-z0-9._:/-]{1,80}$/i.test(model)) return { status: 400, body: { error: 'Give a model name like nomic-embed-text or qwen2.5:3b.' } };
@@ -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
  // PLAYWRIGHT: a headless browser for the crew, pointed only at this MADRE. Agents open the
4
4
  // RIPLEY preview of project files, click, read the console and take screenshots into the turn's
5
5
  // scratch folder. Runs @playwright/mcp per turn, isolated, with allowed origins limited to the