@jossuealcala/madre 1.0.5 → 1.1.1
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.
- package/ADDITIONAL-TERMS.md +7 -2
- package/CHANGELOG.en.md +62 -1
- package/CHANGELOG.md +62 -1
- package/CONTRIBUTING.md +2 -2
- package/LICENSE +111 -661
- package/NOTICE +28 -23
- package/README.en.md +27 -102
- package/README.md +27 -104
- package/SECURITY.md +1 -0
- package/TRADEMARKS.en.md +13 -14
- package/TRADEMARKS.md +24 -26
- package/bin/madre.cjs +2 -2
- package/bin/madre.mjs +111 -40
- package/docs/REFERENCE.md +52 -5
- package/docs/SDK.md +21 -3
- package/docs/en/REFERENCE.md +52 -5
- package/docs/en/SDK.md +22 -3
- package/docs/sdk/hello-module.mjs +3 -0
- package/package.json +3 -2
- package/public/abduction.js +6 -6
- package/public/activity.js +425 -0
- package/public/app.js +2477 -438
- package/public/assets/abduction-cat-blink.webp +0 -0
- package/public/assets/abduction-cat-control-left.webp +0 -0
- package/public/assets/abduction-cat-control-right.webp +0 -0
- package/public/assets/abduction-cat.webp +0 -0
- package/public/assets/manual/shots/en-agents.webp +0 -0
- package/public/assets/manual/shots/en-chats.webp +0 -0
- package/public/assets/manual/shots/en-code.webp +0 -0
- package/public/assets/manual/shots/en-composer.webp +0 -0
- package/public/assets/manual/shots/en-connectors.webp +0 -0
- package/public/assets/manual/shots/en-continuity.webp +0 -0
- package/public/assets/manual/shots/en-coordinator.webp +0 -0
- package/public/assets/manual/shots/en-copilot.webp +0 -0
- package/public/assets/manual/shots/en-diagnostics.webp +0 -0
- package/public/assets/manual/shots/en-home.webp +0 -0
- package/public/assets/manual/shots/en-local.webp +0 -0
- package/public/assets/manual/shots/en-market.webp +0 -0
- package/public/assets/manual/shots/en-memory.webp +0 -0
- package/public/assets/manual/shots/en-modes.webp +0 -0
- package/public/assets/manual/shots/en-notes.webp +0 -0
- package/public/assets/manual/shots/en-settings.webp +0 -0
- package/public/assets/manual/shots/en-welcome.webp +0 -0
- package/public/assets/manual/shots/en-windows.webp +0 -0
- package/public/assets/manual/shots/es-agents.webp +0 -0
- package/public/assets/manual/shots/es-chats.webp +0 -0
- package/public/assets/manual/shots/es-code.webp +0 -0
- package/public/assets/manual/shots/es-composer.webp +0 -0
- package/public/assets/manual/shots/es-connectors.webp +0 -0
- package/public/assets/manual/shots/es-continuity.webp +0 -0
- package/public/assets/manual/shots/es-coordinator.webp +0 -0
- package/public/assets/manual/shots/es-copilot.webp +0 -0
- package/public/assets/manual/shots/es-diagnostics.webp +0 -0
- package/public/assets/manual/shots/es-home.webp +0 -0
- package/public/assets/manual/shots/es-local.webp +0 -0
- package/public/assets/manual/shots/es-market.webp +0 -0
- package/public/assets/manual/shots/es-memory.webp +0 -0
- package/public/assets/manual/shots/es-modes.webp +0 -0
- package/public/assets/manual/shots/es-notes.webp +0 -0
- package/public/assets/manual/shots/es-settings.webp +0 -0
- package/public/assets/manual/shots/es-welcome.webp +0 -0
- package/public/assets/manual/shots/es-windows.webp +0 -0
- package/public/assets/news/1.1/en/chats.webp +0 -0
- package/public/assets/news/1.1/en/home.webp +0 -0
- package/public/assets/news/1.1/en/maps.webp +0 -0
- package/public/assets/news/1.1/en/market.webp +0 -0
- package/public/assets/news/1.1/en/permissions.webp +0 -0
- package/public/assets/news/1.1/en/privacy.webp +0 -0
- package/public/assets/news/1.1/en/welcome.webp +0 -0
- package/public/assets/news/1.1/es/chats.webp +0 -0
- package/public/assets/news/1.1/es/home.webp +0 -0
- package/public/assets/news/1.1/es/maps.webp +0 -0
- package/public/assets/news/1.1/es/market.webp +0 -0
- package/public/assets/news/1.1/es/permissions.webp +0 -0
- package/public/assets/news/1.1/es/privacy.webp +0 -0
- package/public/assets/news/1.1/es/welcome.webp +0 -0
- package/public/attribution.js +15 -16
- package/public/brands.js +2 -2
- package/public/code-tools.js +2 -2
- package/public/editor.js +13 -13
- package/public/en.js +413 -4
- package/public/es.js +1354 -483
- package/public/hardware.js +2 -2
- package/public/i18n.js +2 -2
- package/public/icons.js +158 -0
- package/public/index.html +66 -48
- package/public/inquiry.js +2 -2
- package/public/loader.js +271 -2
- package/public/macroverso.js +64 -22
- package/public/manual-content.js +416 -169
- package/public/manual-shots.js +38 -34
- package/public/manual.css +20 -2
- package/public/manual.html +1 -1
- package/public/manual.js +54 -25
- package/public/market-art.js +47 -45
- package/public/market-view.js +111 -33
- package/public/market.js +132 -30
- package/public/mcp-catalog.js +2 -2
- package/public/neural.js +64 -8
- package/public/nostromo-engine.js +709 -40
- package/public/page-errors.js +31 -0
- package/public/power.js +350 -11
- package/public/remedy.js +89 -0
- package/public/resay.js +3 -2
- package/public/review-ask.js +12 -7
- package/public/routing.js +3 -3
- package/public/salas-mac.css +703 -24
- package/public/salas-mac.html +26 -14
- package/public/salas-mac.js +1261 -291
- package/public/salas.css +2 -2
- package/public/salas.html +3 -3
- package/public/salas.js +3 -3
- package/public/styles.css +2404 -291
- package/public/syntax.js +2 -2
- package/public/terms.js +152 -0
- package/public/touch.js +2 -2
- package/public/tour-chapters.js +10 -10
- package/public/tour.js +56 -8
- package/public/troubleshooting.js +200 -13
- package/public/wallpaper.js +4 -3
- package/public/welcome.js +923 -0
- package/src/activity.mjs +85 -0
- package/src/adapters/claude.mjs +61 -35
- package/src/adapters/codex.mjs +18 -5
- package/src/adapters/cursor.mjs +5 -3
- package/src/adapters/gemini.mjs +5 -3
- package/src/adapters/madre.mjs +3 -3
- package/src/adapters/opencode.mjs +73 -10
- package/src/adapters/process.mjs +14 -13
- package/src/adapters/subagents.mjs +159 -0
- package/src/asking.mjs +8 -2
- package/src/auth-probe.mjs +27 -10
- package/src/bridge/devices.mjs +2 -2
- package/src/bridge/handoff.mjs +2 -2
- package/src/bridge/host.mjs +2 -2
- package/src/bridge/network.mjs +2 -2
- package/src/bridge/policy.mjs +3 -3
- package/src/bridge/qr.mjs +2 -2
- package/src/bridge/server.mjs +2 -2
- package/src/builtin-updates.mjs +87 -0
- package/src/capabilities.mjs +2 -2
- package/src/chats.mjs +51 -2
- package/src/checkpoint.mjs +67 -9
- package/src/choices.mjs +2 -2
- package/src/cli-args.mjs +2 -2
- package/src/cold.mjs +2 -2
- package/src/commands.mjs +2 -2
- package/src/config.mjs +2 -2
- package/src/conversation-context.mjs +2 -2
- package/src/credentials.mjs +56 -16
- package/src/dataset.mjs +2 -2
- package/src/directives.mjs +2 -2
- package/src/distiller.mjs +2 -2
- package/src/embeddings.mjs +2 -2
- package/src/enlaces.mjs +2 -2
- package/src/environment.mjs +147 -0
- package/src/event-store.mjs +2 -2
- package/src/exam.mjs +2 -2
- package/src/extensions.mjs +2 -2
- package/src/eyecat-watch.mjs +2 -2
- package/src/eyecat.mjs +2 -2
- package/src/file-ops.mjs +2 -2
- package/src/files.mjs +2 -2
- package/src/github.mjs +2 -2
- package/src/heartbeat.mjs +2 -2
- package/src/history.mjs +2 -2
- package/src/i18n.mjs +9 -2
- package/src/image-studio.mjs +2 -2
- package/src/install-metrics.mjs +109 -0
- package/src/json-file.mjs +2 -2
- package/src/launch.mjs +2 -2
- package/src/lease.mjs +15 -4
- package/src/lobby-work.mjs +11 -4
- package/src/local-ai.mjs +2 -2
- package/src/looks.mjs +2 -2
- package/src/market-check.mjs +165 -0
- package/src/market-key.mjs +10 -2
- package/src/market-license.mjs +4 -4
- package/src/market-remote.mjs +54 -12
- package/src/maturity.mjs +2 -2
- package/src/mcp/connect.mjs +2 -2
- package/src/mcp/github-server.mjs +2 -2
- package/src/mcp/image-server.mjs +2 -2
- package/src/mcp/memory-server.mjs +2 -2
- package/src/mcp/proxy.mjs +2 -2
- package/src/mcp/smtp-server.mjs +2 -2
- package/src/memory-dashboard.mjs +2 -2
- package/src/memory-tools.mjs +2 -2
- package/src/memory.mjs +2 -2
- package/src/models.mjs +33 -3
- package/src/module-scope.mjs +2 -2
- package/src/modules/ahp.mjs +2 -2
- package/src/modules/ash-policy.mjs +2 -2
- package/src/modules/ash.mjs +2 -2
- package/src/modules/bishop-exam.mjs +2 -2
- package/src/modules/bishop-plan.mjs +2 -2
- package/src/modules/bishop.mjs +9 -3
- package/src/modules/choices.mjs +2 -2
- package/src/modules/correo.mjs +2 -2
- package/src/modules/enlaces.mjs +2 -2
- package/src/modules/git-pulse.mjs +2 -2
- package/src/modules/github.mjs +2 -2
- package/src/modules/helpers.mjs +2 -2
- package/src/modules/image-studio.mjs +2 -2
- package/src/modules/index.mjs +90 -5
- package/src/modules/intents-calibration.mjs +2 -2
- package/src/modules/intents-desk.mjs +4 -3
- package/src/modules/intents-observe.mjs +2 -2
- package/src/modules/intents-policy.mjs +2 -2
- package/src/modules/intents-try.mjs +2 -2
- package/src/modules/intents.mjs +2 -2
- package/src/modules/local-models.mjs +14 -11
- package/src/modules/mcp-connect.mjs +2 -2
- package/src/modules/notes.mjs +159 -20
- package/src/modules/ollama.mjs +23 -11
- package/src/modules/playwright.mjs +2 -2
- package/src/modules/reminders.mjs +356 -37
- package/src/modules/ripley.mjs +3 -3
- package/src/modules/runs.mjs +2 -2
- package/src/modules/sdk.mjs +38 -6
- package/src/modules/updates.mjs +2 -2
- package/src/mother.mjs +2 -2
- package/src/npm-launch.mjs +2 -2
- package/src/ollama.mjs +6 -4
- package/src/opencode-health.mjs +26 -6
- package/src/outbound.mjs +10 -2
- package/src/override.mjs +27 -22
- package/src/ports.mjs +2 -2
- package/src/prices.mjs +2 -2
- package/src/privacy.mjs +2 -2
- package/src/quota-monitor.mjs +2 -2
- package/src/quota-sources.mjs +2 -2
- package/src/request-guard.mjs +2 -2
- package/src/review-ask.mjs +4 -3
- package/src/room/archivist.mjs +2 -2
- package/src/room/attachments.mjs +2 -2
- package/src/room/budget.mjs +2 -2
- package/src/room/context.mjs +2 -2
- package/src/room/control.mjs +2 -2
- package/src/room/copilot.mjs +2 -2
- package/src/room/economy.mjs +2 -2
- package/src/room/escalation.mjs +2 -2
- package/src/room/ghost.mjs +2 -2
- package/src/room/guard.mjs +6 -4
- package/src/room/prompt.mjs +3 -3
- package/src/room/returns.mjs +2 -2
- package/src/room/runs.mjs +6 -4
- package/src/room/vectors.mjs +2 -2
- package/src/room.mjs +127 -31
- package/src/router.mjs +2 -2
- package/src/runs.mjs +2 -2
- package/src/runtime-detection.mjs +31 -5
- package/src/salas.mjs +31 -6
- package/src/sentinel-errors.mjs +17 -5
- package/src/server-sentinel.mjs +2 -2
- package/src/server.mjs +706 -84
- package/src/setup-trouble.mjs +35 -0
- package/src/setup.mjs +4 -4
- package/src/smtp.mjs +2 -2
- package/src/telemetry.mjs +266 -0
- package/src/terms.mjs +43 -0
- package/src/tour.mjs +39 -5
- package/src/uninstall.mjs +225 -0
- package/src/updates.mjs +2 -2
- package/src/usage-sentinel.mjs +2 -2
- package/src/vault.mjs +2 -2
- package/src/verdict.mjs +13 -10
- package/src/whats-new.mjs +97 -3
- package/public/assets/abduction-cat-blink.png +0 -0
- package/public/assets/abduction-cat-control-left.png +0 -0
- package/public/assets/abduction-cat-control-right.png +0 -0
- package/public/assets/abduction-cat.png +0 -0
- package/public/assets/manual/madre-manual-en.pdf +0 -0
- package/public/assets/manual/madre-manual-es.pdf +0 -0
- package/public/assets/manual/shots/en-modules.webp +0 -0
- package/public/assets/manual/shots/es-modules.webp +0 -0
- package/src/mcp/notes-server.mjs +0 -120
- package/src/reminder-time.mjs +0 -127
package/src/modules/notes.mjs
CHANGED
|
@@ -1,22 +1,75 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
2
|
-
// MADRE · © 2026 Jossue Alcalá ·
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
93
|
-
const
|
|
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
|
-
|
|
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 ?
|
|
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 (
|
|
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: [
|
|
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:
|
|
131
|
-
if (saved.error === 'full') return reply(409, { error:
|
|
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:
|
|
195
|
+
return gone.error ? reply(404, { error: say(ctx, 'That note is no longer here.') }) : reply(200, gone);
|
|
139
196
|
} },
|
|
140
197
|
],
|
|
141
|
-
}
|
|
142
|
-
|
|
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
|
+
}
|
package/src/modules/ollama.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
2
|
-
// MADRE · © 2026 Jossue Alcalá ·
|
|
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
|
|
|
@@ -26,6 +26,10 @@ export async function recommendedHere() {
|
|
|
26
26
|
// changes format and size with each release, needs the GPU libraries beside it and a PATH the
|
|
27
27
|
// running MADRE does not see, and gives no service. One person keeps this; the script keeps itself.)
|
|
28
28
|
const LINUX_SCRIPT = 'curl -fsSL https://ollama.com/install.sh | sh';
|
|
29
|
+
// Ollama's script now unpacks a .zst archive and stops with «requires zstd» when the tool is
|
|
30
|
+
// missing, which a fresh Ubuntu (WSL included) is (WIN-029: 8 copies in 1.1.0's diagnostics). On a
|
|
31
|
+
// system with apt, the line that runs, or the one handed over, installs zstd first.
|
|
32
|
+
const withZstd = (script, zstd, apt) => (zstd || !apt ? script : `sudo -n apt-get install -y zstd && ${script}`);
|
|
29
33
|
const NEEDS_PASSWORD = "Ollama's install script needs the administrator password, and MADRE cannot ask for it. Run the command in a terminal, then press RECHECK.";
|
|
30
34
|
|
|
31
35
|
// `sudo -n true` answers at once: 0 when no password is needed, an error when one is (or when this
|
|
@@ -44,30 +48,32 @@ export async function adminHere({ platform = process.platform, uid = process.get
|
|
|
44
48
|
|
|
45
49
|
// Ollama is not an npm package, so each system has its own way in. Where MADRE can run it, the
|
|
46
50
|
// command is shown on the button before it runs; where it cannot, it hands over the download.
|
|
47
|
-
export function ollamaInstallPlan({ platform = process.platform, brew = null, admin = true } = {}) {
|
|
51
|
+
export function ollamaInstallPlan({ platform = process.platform, brew = null, admin = true, zstd = true, apt = false } = {}) {
|
|
52
|
+
const script = withZstd(LINUX_SCRIPT, zstd, apt);
|
|
48
53
|
if (platform === 'darwin') {
|
|
49
54
|
return brew
|
|
50
55
|
? { command: brew, args: ['install', 'ollama'], display: 'brew install ollama', note: 'Installs Ollama with Homebrew, the package manager already on this computer.' }
|
|
51
56
|
: { command: null, download: 'https://ollama.com/download', display: null, note: 'Homebrew is not on this computer. Download Ollama from ollama.com, open it once, and press RECHECK.' };
|
|
52
57
|
}
|
|
53
58
|
if (platform === 'linux') {
|
|
54
|
-
if (!admin) return { command: null, manual: true, display:
|
|
55
|
-
return { command: 'sh', args: ['-c',
|
|
59
|
+
if (!admin) return { command: null, manual: true, display: script.replace('sudo -n ', 'sudo '), note: t(NEEDS_PASSWORD) };
|
|
60
|
+
return { command: 'sh', args: ['-c', script], display: script, note: "Ollama's own install script, downloaded from ollama.com and run on this computer." };
|
|
56
61
|
}
|
|
57
62
|
return { command: null, download: 'https://ollama.com/download', display: null, note: 'Download the Ollama installer from ollama.com, run it, and press RECHECK.' };
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
// A newer Ollama. Where MADRE can do it, the command is shown before it runs; where it cannot,
|
|
61
66
|
// it hands over the download rather than pretending.
|
|
62
|
-
export function ollamaUpdatePlan({ platform = process.platform, brew = null, admin = true } = {}) {
|
|
67
|
+
export function ollamaUpdatePlan({ platform = process.platform, brew = null, admin = true, zstd = true, apt = false } = {}) {
|
|
68
|
+
const script = withZstd(LINUX_SCRIPT, zstd, apt);
|
|
63
69
|
if (platform === 'darwin') {
|
|
64
70
|
return brew
|
|
65
71
|
? { command: brew, args: ['upgrade', 'ollama'], display: 'brew upgrade ollama', note: 'Upgrades Ollama with Homebrew. Your models stay where they are.' }
|
|
66
72
|
: { command: null, download: 'https://ollama.com/download', display: null, note: 'Ollama was not installed with Homebrew. Download the newer one from ollama.com, open it once, and press RECHECK. Your models stay where they are.' };
|
|
67
73
|
}
|
|
68
74
|
if (platform === 'linux') {
|
|
69
|
-
if (!admin) return { command: null, manual: true, display:
|
|
70
|
-
return { command: 'sh', args: ['-c',
|
|
75
|
+
if (!admin) return { command: null, manual: true, display: script.replace('sudo -n ', 'sudo '), note: `${t(NEEDS_PASSWORD)} ${t('Your models stay where they are.')}` };
|
|
76
|
+
return { command: 'sh', args: ['-c', script], display: script, note: "Ollama's own install script upgrades in place. Your models stay where they are." };
|
|
71
77
|
}
|
|
72
78
|
return { command: null, download: 'https://ollama.com/download', display: null, note: 'Download the newer Ollama from ollama.com and run it. Your models stay where they are.' };
|
|
73
79
|
}
|
|
@@ -81,13 +87,13 @@ export async function ollamaView(probe, settings) {
|
|
|
81
87
|
const binary = await findOnPath('ollama');
|
|
82
88
|
// The sudo question is only worth asking while there is something to install.
|
|
83
89
|
const admin = binary ? true : await adminHere();
|
|
84
|
-
return { ...probe, settings, binary, install: ollamaInstallPlan({ brew: await findOnPath('brew'), admin }), start: ollamaStartPlan() };
|
|
90
|
+
return { ...probe, settings, binary, install: ollamaInstallPlan({ brew: await findOnPath('brew'), admin, zstd: Boolean(await findOnPath('zstd')), apt: Boolean(await findOnPath('apt-get')) }), start: ollamaStartPlan() };
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
export default defineModule({
|
|
88
94
|
id: 'ollama',
|
|
89
95
|
name: 'Local AI',
|
|
90
|
-
vendor: 'MADRE ·
|
|
96
|
+
vendor: 'MADRE · Local AI',
|
|
91
97
|
tracks: { name: 'ollama', github: 'ollama/ollama' },
|
|
92
98
|
summary: 'Searches and sums up the project\'s memory with local AI (Ollama): free, and nothing leaves your computer.',
|
|
93
99
|
creates: ['nothing in the project', 'a block in ~/.pulse/config.json', 'models in Ollama\'s own store when you press PULL'],
|
|
@@ -118,7 +124,7 @@ export default defineModule({
|
|
|
118
124
|
},
|
|
119
125
|
async updatePlan(ctx) {
|
|
120
126
|
const { findOnPath } = await import('./helpers.mjs');
|
|
121
|
-
const plan = ollamaUpdatePlan({ brew: await findOnPath('brew'), admin: await adminHere() });
|
|
127
|
+
const plan = ollamaUpdatePlan({ brew: await findOnPath('brew'), admin: await adminHere(), zstd: Boolean(await findOnPath('zstd')), apt: Boolean(await findOnPath('apt-get')) });
|
|
122
128
|
if (!plan.command) return plan;
|
|
123
129
|
// Upgrading replaces the binary, not the server already running: until it restarts, the old
|
|
124
130
|
// version keeps answering. Said before the button is pressed, done after the command.
|
|
@@ -157,6 +163,12 @@ export default defineModule({
|
|
|
157
163
|
const started = await ctx.services.ollama.start();
|
|
158
164
|
return started.ok ? { status: 200, body: { ollama: ctx.services.ollama.state() } } : { status: 412, body: { error: started.error } };
|
|
159
165
|
} },
|
|
166
|
+
// Stops the download running now (the welcome's «Cancel»). What Ollama already wrote stays, and
|
|
167
|
+
// pulling the same model again goes on from there.
|
|
168
|
+
{ method: 'POST', path: '/api/ollama/pull/cancel', handler: async (ctx, { payload }) => {
|
|
169
|
+
const stopped = ctx.services.ollama.cancelPull?.(typeof payload?.model === 'string' ? payload.model : null) ?? { ok: false };
|
|
170
|
+
return stopped.ok ? { status: 200, body: { cancelling: stopped.model } } : { status: 409, body: { error: stopped.error } };
|
|
171
|
+
} },
|
|
160
172
|
{ method: 'POST', path: '/api/ollama/pull', handler: async (ctx, { payload }) => {
|
|
161
173
|
const model = String(payload.model ?? '').trim();
|
|
162
174
|
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:
|
|
2
|
-
// MADRE · © 2026 Jossue Alcalá ·
|
|
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
|