@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.
- package/ADDITIONAL-TERMS.md +7 -2
- package/CHANGELOG.en.md +47 -1
- package/CHANGELOG.md +47 -1
- package/CONTRIBUTING.md +2 -2
- package/LICENSE +111 -661
- package/NOTICE +28 -23
- package/README.en.md +30 -101
- package/README.md +30 -103
- 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 +112 -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 +2468 -435
- 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 +1345 -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 +60 -21
- package/public/manual-content.js +412 -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 +29 -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 +1254 -289
- 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 +182 -11
- 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 +9 -3
- 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 +13 -4
- package/src/server-sentinel.mjs +2 -2
- package/src/server.mjs +689 -80
- package/src/setup-trouble.mjs +33 -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
|
|
|
@@ -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 ·
|
|
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:
|
|
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
|