@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/history.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
|
// A project's history over a period, for modules (docs/SDK.md, `ctx.services.history`): what the
|
|
4
4
|
// human asked and to whom, how each agent answered, what it cost, which files a turn changed and
|
|
5
5
|
// whether that was undone, and the decisions the memory kept. Read from the ledgers as they are
|
package/src/i18n.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
|
// The room's language, on this side of the wire.
|
|
4
4
|
//
|
|
5
5
|
// The catalogue is the page's: public/es.js, one file for the whole product, because a sentence
|
|
@@ -86,6 +86,13 @@ const PROSE = new Set(['summary', 'detail', 'note', 'says', 'brief', 'what', 'wh
|
|
|
86
86
|
// other when it only wrote one. Anything else comes back as it was.
|
|
87
87
|
export const isBilingual = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => key === 'es' || key === 'en') && Object.values(value).every((one) => typeof one === 'string');
|
|
88
88
|
export const inRoomLanguage = (value) => (isBilingual(value) ? value[current] ?? value.es ?? value.en : value);
|
|
89
|
+
// What a module says, as ctx.t (SDK 2, 2026-10-25): an English sentence MADRE's catalogue knows,
|
|
90
|
+
// or the module's own { es, en } — the way to bring a sentence MADRE has not learned yet.
|
|
91
|
+
export function say(text, vars = null) {
|
|
92
|
+
if (!isBilingual(text)) return t(text, vars);
|
|
93
|
+
const said = hostWords(String(inRoomLanguage(text) ?? ''));
|
|
94
|
+
return vars ? said.replace(/\{(\w+)\}/g, (whole, name) => (Object.hasOwn(vars, name) ? String(vars[name]) : whole)) : said;
|
|
95
|
+
}
|
|
89
96
|
|
|
90
97
|
export function translate(value, key = null) {
|
|
91
98
|
if (isBilingual(value)) return value[current] ?? value.es ?? value.en;
|
package/src/image-studio.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
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { resolveGeminiKey } from './mcp/image-server.mjs';
|
|
5
5
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
// MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
|
|
3
|
+
// WHAT THE AUTHOR LEARNS OF EACH COPY (2026-10-30), never of the person: how the copy runs and where,
|
|
4
|
+
// whether it was installed, updated or uninstalled, and whether it is on right now. Three things,
|
|
5
|
+
// all inside the anonymous diagnostics (src/telemetry.mjs) and off with it (Settings › Version and
|
|
6
|
+
// reports, or PULSE_TELEMETRY=0):
|
|
7
|
+
//
|
|
8
|
+
// · the environment — numbers and names of MADRE's own parts, written as the diagnostics' gauges:
|
|
9
|
+
// cores and memory (GB), the language MADRE speaks, how it was installed (npx, global, project,
|
|
10
|
+
// source), the shell's name, whether Ollama is there and on, which agents are installed and ready,
|
|
11
|
+
// how many projects and how many open, which of MADRE's own modules are on, and how many days the
|
|
12
|
+
// copy has. No path, no project name, no file, nothing a person wrote; a module the person wrote
|
|
13
|
+
// only counts as «another».
|
|
14
|
+
// · its life — counts: installed (a copy that never had an identifier), updated (a new version
|
|
15
|
+
// first opened), uninstalled (Settings › Uninstall, sent before anything is removed), and each
|
|
16
|
+
// time Home starts.
|
|
17
|
+
// · its presence — every few minutes while MADRE is open, the random id, the version and the system
|
|
18
|
+
// to madre.run/api/presence, so the author knows how many copies are on now. One process of the
|
|
19
|
+
// copy says it; the others see it was said.
|
|
20
|
+
//
|
|
21
|
+
// docs/REFERENCE.md › «Lo que sale de la máquina» says all of it; madre.run's privacy page too.
|
|
22
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
23
|
+
import { basename, join } from 'node:path';
|
|
24
|
+
import { installId } from './heartbeat.mjs';
|
|
25
|
+
import { compareVersions } from './updates.mjs';
|
|
26
|
+
|
|
27
|
+
export const PRESENCE_URL = 'https://madre.run/api/presence';
|
|
28
|
+
export const PRESENCE_EVERY_MS = 5 * 60 * 1000;
|
|
29
|
+
const KEY_PART = /^[a-z0-9][a-z0-9-]{0,30}$/;
|
|
30
|
+
const CHANNELS = new Set(['npx', 'global', 'project', 'source']);
|
|
31
|
+
const SHELLS = new Set(['zsh', 'bash', 'fish', 'sh', 'pwsh', 'powershell', 'nu', 'dash', 'ksh', 'tcsh']);
|
|
32
|
+
const GB = 1024 ** 3;
|
|
33
|
+
|
|
34
|
+
// The environment as gauges: only keys made of MADRE's own words, only numbers.
|
|
35
|
+
export function environmentGauges({ cores = 0, ramBytes = 0, language = null, install = null, shell = '', ollama = {}, agents = [], projects = {}, modules = [], ownModules = new Set(), ageDays = null } = {}) {
|
|
36
|
+
const out = {};
|
|
37
|
+
if (cores > 0) out['env.cores'] = Math.round(cores);
|
|
38
|
+
if (ramBytes > 0) out['env.ram'] = Math.max(1, Math.round(ramBytes / GB));
|
|
39
|
+
if (language === 'es' || language === 'en') out[`env.lang.${language}`] = 1;
|
|
40
|
+
if (CHANNELS.has(install)) out[`env.channel.${install}`] = 1;
|
|
41
|
+
const shellName = basename(String(shell ?? '')).toLowerCase().replace(/\.exe$/, '');
|
|
42
|
+
if (shellName) out[`env.shell.${SHELLS.has(shellName) ? shellName : 'other'}`] = 1;
|
|
43
|
+
if (ollama.installed || ollama.running) out['env.ollama'] = 1;
|
|
44
|
+
if (ollama.running) out['env.ollama.on'] = 1;
|
|
45
|
+
if (Number.isFinite(ollama.models)) out['env.ollama.models'] = ollama.models;
|
|
46
|
+
for (const one of agents) {
|
|
47
|
+
if (!KEY_PART.test(String(one?.id ?? ''))) continue;
|
|
48
|
+
if (one.detected) out[`agent.${one.id}`] = 1;
|
|
49
|
+
if (one.ready) out[`agent.${one.id}.ready`] = 1;
|
|
50
|
+
}
|
|
51
|
+
out['agents.ready'] = agents.filter((one) => one?.ready).length;
|
|
52
|
+
if (Number.isFinite(projects.total)) out['projects.total'] = projects.total;
|
|
53
|
+
if (Number.isFinite(projects.open)) out['projects.open'] = projects.open;
|
|
54
|
+
let others = 0;
|
|
55
|
+
for (const id of modules) {
|
|
56
|
+
if (ownModules.has(id) && KEY_PART.test(id)) out[`module.${id}`] = 1;
|
|
57
|
+
else others += 1;
|
|
58
|
+
}
|
|
59
|
+
out['modules.on'] = modules.length;
|
|
60
|
+
if (others) out['modules.other'] = others;
|
|
61
|
+
if (Number.isFinite(ageDays) && ageDays >= 0) out['install.age'] = Math.floor(ageDays);
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Installed, updated or neither, said once per change: ~/.pulse/lifecycle.json keeps the version this
|
|
66
|
+
// copy last opened. A copy with no record and no identifier is new; with an identifier but no record
|
|
67
|
+
// it was there before 1.1.0 and is counted as updated. A version older than the last one counts as
|
|
68
|
+
// neither (someone went back on purpose).
|
|
69
|
+
export async function noteLifecycle({ root, version, hadId, now = new Date() }) {
|
|
70
|
+
const file = join(root, 'lifecycle.json');
|
|
71
|
+
let kept = null;
|
|
72
|
+
try { kept = JSON.parse(await readFile(file, 'utf8')); } catch { /* none yet */ }
|
|
73
|
+
let event = null;
|
|
74
|
+
if (!kept?.version) event = hadId ? 'update' : 'install';
|
|
75
|
+
else if (kept.version !== version && compareVersions(version, kept.version) > 0) event = 'update';
|
|
76
|
+
if (!kept?.version || kept.version !== version) {
|
|
77
|
+
// `before`: this copy was in use before 1.1.0 (src/terms.mjs tells it what changed).
|
|
78
|
+
const before = kept ? kept.before === true : Boolean(hadId);
|
|
79
|
+
await writeFile(file, `${JSON.stringify({ first: kept?.first ?? now.toISOString(), version, at: now.toISOString(), ...(before ? { before: true } : {}) })}\n`).catch(() => null);
|
|
80
|
+
}
|
|
81
|
+
return { event, first: kept?.first ?? now.toISOString() };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Where the presence goes: a copy that sends its diagnostics elsewhere (tests, QA houses) sends its
|
|
85
|
+
// presence beside them, never to madre.run.
|
|
86
|
+
export function presenceUrl(env = process.env) {
|
|
87
|
+
if (env.PULSE_PRESENCE_URL) return env.PULSE_PRESENCE_URL;
|
|
88
|
+
if (env.PULSE_TELEMETRY_URL) return env.PULSE_TELEMETRY_URL.replace(/\/telemetry\/?$/, '/presence');
|
|
89
|
+
return PRESENCE_URL;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const presenceBody = ({ id, version, platform = process.platform }) => ({
|
|
93
|
+
id, version, os: ['darwin', 'linux', 'win32'].includes(platform) ? platform : 'other',
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// «Still here», at most once every few minutes per copy, whichever of its processes gets there first.
|
|
97
|
+
export async function sayPresent({ root, version, fetchImpl = globalThis.fetch, url = presenceUrl(), now = Date.now() }) {
|
|
98
|
+
const mark = join(root, 'presence-at');
|
|
99
|
+
const last = Number((await readFile(mark, 'utf8').catch(() => '')).trim()) || 0;
|
|
100
|
+
if (now - last < PRESENCE_EVERY_MS - 30_000) return { sent: false, reason: 'recent' };
|
|
101
|
+
await writeFile(mark, String(now)).catch(() => null);
|
|
102
|
+
try {
|
|
103
|
+
const body = presenceBody({ id: await installId(root), version });
|
|
104
|
+
const response = await fetchImpl(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body), signal: AbortSignal.timeout(5000) });
|
|
105
|
+
return response.ok ? { sent: true, body } : { sent: false, reason: `HTTP ${response.status}` };
|
|
106
|
+
} catch (error) {
|
|
107
|
+
return { sent: false, reason: error?.message ?? 'unreachable' };
|
|
108
|
+
}
|
|
109
|
+
}
|
package/src/json-file.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
|
// Small files that more than one thing changes at once (2026-10-12, Lote 2 of the 1.0 review): the
|
|
4
4
|
// tour, the review ask, a project's record of where it is, the list of a room's conversations.
|
|
5
5
|
// Each was read, changed and written with nothing between two changes, so the second one wrote
|
package/src/launch.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
|
// What is shown of a command, and what is never shown.
|
|
4
4
|
//
|
|
5
5
|
// THE LAUNCH floor in the core prints the exact command MADRE would run, because a person who is
|
package/src/lease.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
|
import { mkdir, readdir, realpath, stat } from 'node:fs/promises';
|
|
4
4
|
import { join, relative, sep } from 'node:path';
|
|
5
5
|
import { declaredTypeFor } from './files.mjs';
|
|
@@ -99,6 +99,12 @@ export function diffSnapshots(before, after, { relativeDir }) {
|
|
|
99
99
|
return artifacts.sort((a, b) => a.path.localeCompare(b.path));
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
// Which agents may use their own CLI's subagents in a turn that writes (2026-10-29): from #1 to #3,
|
|
103
|
+
// the ones whose adapter hands a subagent exactly the turn's permissions (src/adapters/claude.mjs,
|
|
104
|
+
// opencode.mjs; Codex's subagents inherit its sandbox). Never in #4.
|
|
105
|
+
export const SUBAGENT_AGENTS = new Set(['claude', 'opencode', 'codex']);
|
|
106
|
+
export const subagentsAllowed = (agentId, { airlock = false } = {}) => !airlock && SUBAGENT_AGENTS.has(agentId);
|
|
107
|
+
|
|
102
108
|
export function leaseInstructions({ outDir, agentId, scopes = { write: true, imageGen: agentId === 'codex' }, capable = null, imageStudio = null, control = false, create = false, airlock = false, scratchDir = null }) {
|
|
103
109
|
const canImage = Boolean(scopes.imageGen);
|
|
104
110
|
const couldImage = capable ? Boolean(capable.imageGen?.capable) : canImage;
|
|
@@ -122,8 +128,13 @@ export function leaseInstructions({ outDir, agentId, scopes = { write: true, ima
|
|
|
122
128
|
: couldImage ? 'Image generation is switched off for this request; if asked for an image, say so and do not attempt it.'
|
|
123
129
|
: 'You cannot generate images from this CLI; if asked for one, say so plainly instead of attempting it.',
|
|
124
130
|
// «Do not hand it to another agent» read as «do not plan»: with a lease, agents stopped proposing
|
|
125
|
-
// pulse plans altogether (2026-10-14). What is
|
|
126
|
-
|
|
131
|
+
// pulse plans altogether (2026-10-14). What this line is about is the CLI's own subagents, not
|
|
132
|
+
// the room's. From #1 to #3 (2026-10-29) Claude, OpenCode and Codex may use theirs: each adapter
|
|
133
|
+
// gives them exactly this turn's permissions, and what they change is in the same checkpoint. In
|
|
134
|
+
// #4, and for the others, only the agent itself works.
|
|
135
|
+
subagentsAllowed(agentId, { airlock })
|
|
136
|
+
? 'Your CLI\'s own subagents may help with this: they work with exactly this permission, and whatever they change is in the same checkpoint, listed to the human and undoable. Write each subagent\'s task in the language of this conversation and ask it to report in that language, since the human reads its report. If you used subagents, say in your answer what you handed to each one; if you did not, do not mention them. A pulse plan that puts the room\'s other agents to work is different and still allowed.'
|
|
137
|
+
: `Do this work yourself rather than through your CLI's own subagents or spawned agents: ${airlock ? 'in AIRLOCK (#4) only you work, because what leaves the machine does not come back' : 'a subagent would work outside the permission MADRE controls'}, and the tools for it are blocked, which can leave you waiting instead of answering. A pulse plan that puts the room's other agents to work is different and still allowed.`,
|
|
127
138
|
'List the files you created (or "none") before any plan block; nothing may follow a plan block.',
|
|
128
139
|
].filter(Boolean).join('\n');
|
|
129
140
|
}
|
package/src/lobby-work.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
|
// What was worked on last on this Mac, for the lobby (2026-10-10): the newest conversations of
|
|
4
4
|
// every room the lobby knows, open or asleep, each with its last few lines, and the summary MADRE
|
|
5
5
|
// writes of them with its local model. Everything here READS: a room's list of conversations
|
|
@@ -61,8 +61,15 @@ export async function recentWork({ stateRoot, rooms, now = Date.now(), days = 14
|
|
|
61
61
|
for (const chat of fresh) found.push({ room: room.id, name: room.name, chat: chat.id, title: chat.title, at: chat.updatedAt, messages: chat.messages });
|
|
62
62
|
}
|
|
63
63
|
found.sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
// A conversation where nobody answered (a question whose turn failed) is not work done: summarised,
|
|
65
|
+
// it read «Se preguntó cuántos proyectos se tenían» (QA 1.1.0, ACT-15).
|
|
66
|
+
const newest = [];
|
|
67
|
+
for (const item of found) {
|
|
68
|
+
if (newest.length >= limit) break;
|
|
69
|
+
item.said = await lastMessages(chatLedger(join(stateRoot, 'rooms', item.room), item.chat));
|
|
70
|
+
if (!item.said.some((one) => one.who !== 'person')) continue;
|
|
71
|
+
newest.push(item);
|
|
72
|
+
}
|
|
66
73
|
return newest;
|
|
67
74
|
}
|
|
68
75
|
|
package/src/local-ai.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
|
// Which projects use the local AI (Ollama), decided from Home (2026-10-13).
|
|
4
4
|
//
|
|
5
5
|
// Ollama is one per computer and its switches live in ~/.pulse/config.json, which every project
|
package/src/looks.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
|
// How the person wants MADRE to look, once for every page (2026-10-12). Each project is its own
|
|
4
4
|
// origin — another port — and Home is one more, so what a browser keeps for one is invisible to
|
|
5
5
|
// the others: the dark theme chosen in Home left every project light. The choices live here, in
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
// MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
|
|
3
|
+
// THE COMMUNITY MARKET'S CHECK (2026-10-28, docs/private/MODULOS-MERCADO-1.0.6.md, stage 3). A module
|
|
4
|
+
// somebody sends to the Market — a pull request to the public `madre-mercado` repository, curated: the
|
|
5
|
+
// author of MADRE reads it, signs it and publishes it — is checked here first, the same way on the
|
|
6
|
+
// sender's computer («Send to the Market» in a module's card), in the repository's CI and in
|
|
7
|
+
// scripts/market-publish.mjs before it is signed:
|
|
8
|
+
// · it loads alone, as MADRE loads any module before installing it (verifyModuleText), says it is
|
|
9
|
+
// the module its entry names, at the same version, and speaks a contract this MADRE knows;
|
|
10
|
+
// · its entry says what the Market shows (name, line and summary in Spanish and English, a shelf,
|
|
11
|
+
// its author and the license of its code) and is free — paid community modules come later (D-M4);
|
|
12
|
+
// · and what it declares, next to what its code reaches for (commands, the network, files, the
|
|
13
|
+
// environment, code built at run time), is written out so reviewing it takes minutes.
|
|
14
|
+
// Nothing here runs the module beyond loading it: what a module does when it is used is for the
|
|
15
|
+
// reviewer to read, which is why the summary says what it reaches for.
|
|
16
|
+
|
|
17
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { t } from './i18n.mjs';
|
|
20
|
+
import { verifyModuleText } from './modules/index.mjs';
|
|
21
|
+
|
|
22
|
+
// Where community modules are sent: a pull request adding modulos/<id>/ to this repository.
|
|
23
|
+
export const MARKET_REPO = 'jossuealcacao-exe/madre-mercado';
|
|
24
|
+
// GitHub's own page to add files to that folder: for whoever cannot write in the repository it makes
|
|
25
|
+
// the fork and the pull request itself, so sending a module needs no terminal.
|
|
26
|
+
export const uploadUrl = (id) => `https://github.com/${MARKET_REPO}/upload/main/modulos/${id}`;
|
|
27
|
+
|
|
28
|
+
export const COMMUNITY_ID = /^[a-z][a-z0-9-]{1,39}$/;
|
|
29
|
+
const SEMVER = /^\d+\.\d+\.\d+$/;
|
|
30
|
+
const GITHUB = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
|
|
31
|
+
const COLOR = /^#[0-9a-f]{6}$/i;
|
|
32
|
+
// The shelves of the Market (public/market.js, MARKET_SHELVES).
|
|
33
|
+
export const COMMUNITY_SHELVES = ['no-terminal', 'create', 'organize', 'save', 'connect'];
|
|
34
|
+
// Licenses a community module's code may carry: open ones a person can read, share and reuse.
|
|
35
|
+
// The author of MADRE decides this list with the terms for whoever publishes (D-M3, a draft).
|
|
36
|
+
export const COMMUNITY_LICENSES = ['AGPL-3.0-only', 'AGPL-3.0-or-later', 'GPL-3.0-only', 'GPL-3.0-or-later', 'MIT', 'Apache-2.0', 'BSD-2-Clause', 'BSD-3-Clause', 'ISC', 'MPL-2.0'];
|
|
37
|
+
|
|
38
|
+
// What the code reaches for, read from its text: what a reviewer looks at first.
|
|
39
|
+
const REACHES = [
|
|
40
|
+
['commands', 'runs commands on the computer', /child_process|\bspawn(?:Sync)?\s*\(|\bexec(?:File)?(?:Sync)?\s*\(|\bfork\s*\(/],
|
|
41
|
+
['network', 'talks to the network', /\bfetch\s*\(|node:https?|\bWebSocket\b|node:net|node:dgram|node:tls/],
|
|
42
|
+
['files', 'reads or writes files', /node:fs|\breadFile|\bwriteFile|\bappendFile|\bunlink|\brmSync|\brm\s*\(|\bmkdir/],
|
|
43
|
+
['environment', 'reads environment variables', /process\.env/],
|
|
44
|
+
['dynamic', 'builds or loads code at run time', /\beval\s*\(|new\s+Function\s*\(|\bimport\s*\(|\brequire\s*\(/],
|
|
45
|
+
['process', 'touches the MADRE process', /process\.(?:exit|kill|chdir|on\s*\()/],
|
|
46
|
+
];
|
|
47
|
+
export function reachesOf(text) {
|
|
48
|
+
return REACHES.filter(([, , pattern]) => pattern.test(String(text ?? ''))).map(([id, words]) => ({ id, words: t(words) }));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const words = (value, max) => typeof value === 'string' && value.trim() && value.length <= max;
|
|
52
|
+
const both = (value, max) => value && typeof value === 'object' && words(value.es, max) && words(value.en, max);
|
|
53
|
+
|
|
54
|
+
// The entry the Market shows, as the sender wrote it: what is missing or wrong, in plain words, each
|
|
55
|
+
// with the field it is about (the form in a module's card marks that field).
|
|
56
|
+
export const entryProblems = (entry, module = null) => entryFaults(entry, module).map((one) => one.words);
|
|
57
|
+
export function entryFaults(entry, module = null) {
|
|
58
|
+
const wrong = [];
|
|
59
|
+
const say = (field, words) => wrong.push({ field, words });
|
|
60
|
+
if (!entry || typeof entry !== 'object') return [{ field: 'entry', words: t('The entry is missing: entrada.json, beside the module.') }];
|
|
61
|
+
if (!COMMUNITY_ID.test(entry.id ?? '')) say('id', t('id: lowercase letters, numbers and dashes, 2 to 40, starting with a letter.'));
|
|
62
|
+
if (module && entry.id !== module.id) say('id', t('id: the entry says "{entry}" and the module says "{module}".', { entry: entry.id, module: module.id }));
|
|
63
|
+
if (!SEMVER.test(entry.version ?? '')) say('version', t('version: like 1.0.0.'));
|
|
64
|
+
if (module && entry.version !== module.version) say('version', t('version: the entry says {entry} and the module says {module}.', { entry: entry.version, module: module.version ?? t('nothing') }));
|
|
65
|
+
if (!both(entry.name, 60)) say('name', t('name: in Spanish and English (es, en), up to 60 characters each.'));
|
|
66
|
+
if (!both(entry.line, 140)) say('line', t('line: what it does in one line, in Spanish and English, up to 140 characters.'));
|
|
67
|
+
if (!both(entry.summary, 1200)) say('summary', t('summary: what it does and when to use it, in Spanish and English, up to 1200 characters.'));
|
|
68
|
+
if (!COMMUNITY_SHELVES.includes(entry.shelf)) say('shelf', t('shelf: one of {list}.', { list: COMMUNITY_SHELVES.join(', ') }));
|
|
69
|
+
if (entry.price !== undefined && entry.price !== 0) say('price', t('price: community modules are free for now (0).'));
|
|
70
|
+
if (!SEMVER.test(entry.minMadre ?? '')) say('minMadre', t('minMadre: the oldest MADRE it works with, like 1.1.0.'));
|
|
71
|
+
if (!words(entry.author?.name, 60) || !GITHUB.test(entry.author?.github ?? '')) say('author', t('author: { "name": your name, "github": your GitHub user }.'));
|
|
72
|
+
if (!COMMUNITY_LICENSES.includes(entry.spdx)) say('spdx', t('spdx: the license of its code, one of {list}.', { list: COMMUNITY_LICENSES.join(', ') }));
|
|
73
|
+
if (entry.changes !== undefined && !both(entry.changes, 400)) say('changes', t('changes: what changed in this version, in Spanish and English, up to 400 characters.'));
|
|
74
|
+
if (entry.hue !== undefined && !(Array.isArray(entry.hue) && entry.hue.length === 2 && entry.hue.every((one) => COLOR.test(one)))) say('hue', t('hue: two colors like ["#60a5fa", "#1d4ed8"].'));
|
|
75
|
+
if (entry.icon !== undefined) {
|
|
76
|
+
if (typeof entry.icon !== 'string' || entry.icon.length > 8000) say('icon', t('icon: the shapes of a 20×20 drawing, up to 8000 characters.'));
|
|
77
|
+
else if (/<script|\son\w+\s*=|javascript:|<foreignObject|href\s*=/i.test(entry.icon)) say('icon', t('icon: only shapes; no scripts, events or links.'));
|
|
78
|
+
}
|
|
79
|
+
return wrong;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Everything at once: the module, its entry and what it reaches for, and the summary for a person.
|
|
83
|
+
export async function checkSubmission({ text, entry, name = null }) {
|
|
84
|
+
const faults = [];
|
|
85
|
+
let module = null;
|
|
86
|
+
try {
|
|
87
|
+
module = await verifyModuleText({ text, name: name ?? `${entry?.id ?? 'module'}.mjs`, replace: true });
|
|
88
|
+
} catch (error) {
|
|
89
|
+
faults.push({ field: 'module', words: t('The module does not load as MADRE loads one: {error}', { error: error.message }) });
|
|
90
|
+
}
|
|
91
|
+
faults.push(...entryFaults(entry, module));
|
|
92
|
+
const problems = faults.map((one) => one.words);
|
|
93
|
+
const reaches = reachesOf(text);
|
|
94
|
+
const declares = module?.declares ?? null;
|
|
95
|
+
// What the code reaches for and the module never declared: the first thing to ask its author.
|
|
96
|
+
const undeclared = [];
|
|
97
|
+
if (reaches.some((one) => one.id === 'network') && !(declares?.reaches ?? []).length) undeclared.push(t('It talks to the network but declares no `reaches`: say where it goes and why.'));
|
|
98
|
+
const result = { ok: problems.length === 0, problems, faults, fields: [...new Set(faults.map((one) => one.field))], undeclared, module: module ? { id: module.id, name: module.name, version: module.version, unknown: module.unknown ?? [] } : null, declares, reaches };
|
|
99
|
+
return { ...result, markdown: submissionMarkdown(result, entry) };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// The summary a reviewer reads in the pull request (the CI writes it to the job's summary).
|
|
103
|
+
export function submissionMarkdown(result, entry = {}) {
|
|
104
|
+
const lines = [];
|
|
105
|
+
const title = entry?.name?.es ?? result.module?.name ?? entry?.id ?? 'module';
|
|
106
|
+
lines.push(`## ${result.ok ? '✅' : '❌'} ${title} ${result.module?.version ?? entry?.version ?? ''}`.trim());
|
|
107
|
+
if (entry?.author?.github) lines.push(t('By **{name}** (@{github}) · {license} · shelf `{shelf}`', { name: entry.author.name ?? entry.author.github, github: entry.author.github, license: entry.spdx ?? t('no license'), shelf: entry.shelf ?? '—' }));
|
|
108
|
+
if (result.problems.length) {
|
|
109
|
+
lines.push('', `### ${t('To fix before it can be reviewed')}`);
|
|
110
|
+
for (const one of result.problems) lines.push(`- ${one}`);
|
|
111
|
+
}
|
|
112
|
+
const declares = result.declares;
|
|
113
|
+
if (declares) {
|
|
114
|
+
const yes = (value) => (value ? t('yes') : t('no'));
|
|
115
|
+
lines.push('', `### ${t('What it declares')}`);
|
|
116
|
+
lines.push(`- ${t('Reaches: {list}', { list: declares.reaches.length ? declares.reaches.map((one) => `${one.host ?? one.to ?? '?'}${one.what ? ` (${one.what})` : ''}`).join(', ') : t('nothing') })}`);
|
|
117
|
+
lines.push(`- ${t('Keys it asks for: {list}', { list: declares.secrets.length ? declares.secrets.map((one) => one.label).join(', ') : t('nothing') })}`);
|
|
118
|
+
lines.push(`- ${t('Tools for the agents: {tools} · reads the conversations: {reads} · pages: {pages} · writes in the project: {writes}', { tools: yes(declares.tools), reads: yes(declares.reads), pages: declares.pages, writes: yes(declares.writes) })}`);
|
|
119
|
+
lines.push(`- ${t('Commands: {list}', { list: declares.commands.length ? declares.commands.join(', ') : t('nothing') })}`);
|
|
120
|
+
}
|
|
121
|
+
lines.push('', `### ${t('What its code reaches for')}`);
|
|
122
|
+
lines.push(result.reaches.length ? result.reaches.map((one) => `- ${one.words}`).join('\n') : `- ${t('Nothing beyond what MADRE hands every module.')}`);
|
|
123
|
+
for (const one of result.undeclared) lines.push(`- ⚠️ ${one}`);
|
|
124
|
+
if (result.module?.unknown?.length) lines.push(`- ⚠️ ${t('Fields MADRE does not know: {list}', { list: result.module.unknown.join(', ') })}`);
|
|
125
|
+
lines.push('', `_${t('Checked by MADRE (src/market-check.mjs). A person still reads the code before it is signed: a module runs with the permissions of whoever opens MADRE.')}_`);
|
|
126
|
+
return lines.join('\n');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// SENDING ONE'S OWN MODULE («Send to the Market» in its card). The entry starts from what the module
|
|
130
|
+
// already says — its id, version, name and what it does, in both languages when it wrote both — and
|
|
131
|
+
// from what the person wrote the last time; the rest (the shelf, who they are on GitHub, the license
|
|
132
|
+
// of their code) is theirs to say. Ready, the module and its entry are written to a folder of their
|
|
133
|
+
// own, the two files the repository asks for, to add with GitHub's page.
|
|
134
|
+
export const submissionFolder = (stateRoot, id) => join(stateRoot, 'market', 'submissions', id);
|
|
135
|
+
const bilingual = (value) => (value && typeof value === 'object' ? { es: value.es ?? value.en ?? '', en: value.en ?? value.es ?? '' } : { es: String(value ?? ''), en: String(value ?? '') });
|
|
136
|
+
const firstLine = (text) => String(text ?? '').split(/(?<=[.!?])\s/)[0].slice(0, 140);
|
|
137
|
+
export async function submissionDraft({ stateRoot, module, text, madre, entry = null }) {
|
|
138
|
+
const saved = entry ?? (await readFile(join(submissionFolder(stateRoot, module.id), 'entrada.json'), 'utf8').then(JSON.parse).catch(() => null)) ?? {};
|
|
139
|
+
let checked = null;
|
|
140
|
+
try { checked = await verifyModuleText({ text, name: `${module.id}.mjs`, replace: true }); } catch { /* said by the check */ }
|
|
141
|
+
const summary = bilingual(checked?.words?.summary ?? checked?.summary ?? module.summary ?? '');
|
|
142
|
+
const draft = {
|
|
143
|
+
id: module.id,
|
|
144
|
+
version: checked?.version ?? module.version ?? '',
|
|
145
|
+
name: bilingual(checked?.words?.name ?? checked?.name ?? module.name ?? module.id),
|
|
146
|
+
line: { es: firstLine(summary.es), en: firstLine(summary.en) },
|
|
147
|
+
summary,
|
|
148
|
+
shelf: '',
|
|
149
|
+
minMadre: madre ?? '',
|
|
150
|
+
author: { name: checked?.credit ?? '', github: '' },
|
|
151
|
+
spdx: '',
|
|
152
|
+
};
|
|
153
|
+
// What the person wrote wins, field by field; the id and the version are always the module's.
|
|
154
|
+
const merged = { ...draft, ...saved, id: draft.id, version: draft.version };
|
|
155
|
+
for (const key of ['name', 'line', 'summary']) merged[key] = { ...draft[key], ...(saved[key] ?? {}) };
|
|
156
|
+
merged.author = { ...draft.author, ...(saved.author ?? {}) };
|
|
157
|
+
return merged;
|
|
158
|
+
}
|
|
159
|
+
export async function writeSubmission({ stateRoot, text, entry }) {
|
|
160
|
+
const folder = submissionFolder(stateRoot, entry.id);
|
|
161
|
+
await mkdir(folder, { recursive: true });
|
|
162
|
+
await writeFile(join(folder, `${entry.id}.module.mjs`), text);
|
|
163
|
+
await writeFile(join(folder, 'entrada.json'), `${JSON.stringify(entry, null, 2)}\n`);
|
|
164
|
+
return { folder, files: [`${entry.id}.module.mjs`, 'entrada.json'], upload: uploadUrl(entry.id) };
|
|
165
|
+
}
|
package/src/market-key.mjs
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
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
|
// The public half of the Market's key (scripts/market-key.mjs). The catalog at madre.run/mercado/
|
|
4
4
|
// is signed with the private half, which lives only on the author's computer; a catalog this key
|
|
5
5
|
// does not verify is not read, and nothing in it is installed (src/market-remote.mjs).
|
|
6
6
|
export const MARKET_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
7
7
|
MCowBQYDK2VwAyEA4/DXYprFh2wfiOPpkJheWR0uEtJA+Wl3+AnJXE1YGt0=
|
|
8
8
|
-----END PUBLIC KEY-----`;
|
|
9
|
+
|
|
10
|
+
// The public half of the FACTORY key (2026-10-25, scripts/market-key.mjs --fabrica): a second key,
|
|
11
|
+
// kept apart from the Market's, that signs the newer files of MADRE's own modules. Those reach every
|
|
12
|
+
// MADRE on their own, so the Market's key alone must not be enough to replace one
|
|
13
|
+
// (src/builtin-updates.mjs). Were it null, no such file would ever run.
|
|
14
|
+
export const FACTORY_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
15
|
+
MCowBQYDK2VwAyEA6EMrbXJptG+Qc1Zzeiw2FrTDKBz63BXN6S/BlkI7tUQ=
|
|
16
|
+
-----END PUBLIC KEY-----`;
|
package/src/market-license.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
|
// THE MARKET'S PAID MODULES (2026-10-19). A paid module is bought at its checkout (Lemon Squeezy,
|
|
4
4
|
// the seller of record, which charges and handles each country's taxes), and the key the buyer
|
|
5
5
|
// gets by email is pasted in MADRE once. MADRE asks Lemon Squeezy, that one time and because the
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
// works offline from then on. «Release» gives the activation back, to use the key elsewhere.
|
|
10
10
|
//
|
|
11
11
|
// What travels: the key and a name for this computer made from MADRE's random install id
|
|
12
|
-
// («MADRE 1a2b3c4d»), never the computer's own name. The module's code
|
|
13
|
-
//
|
|
12
|
+
// («MADRE 1a2b3c4d»), never the computer's own name. The module's code stays readable: what is paid
|
|
13
|
+
// for is installing it from the Market, its updates and its support, not a lock on the code.
|
|
14
14
|
|
|
15
15
|
import { chmod, mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
16
16
|
import { join } from 'node:path';
|
package/src/market-remote.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
|
// THE MARKET, from madre.run (2026-10-18). What the Market shows and the modules it hands out do
|
|
4
4
|
// not wait for a new MADRE: they live in a catalog the author publishes at madre.run/mercado/,
|
|
5
5
|
// signed with a key only the author holds (scripts/market-key.mjs). MADRE reads it when it opens —
|
|
@@ -30,7 +30,7 @@ import { mayInstall } from './market-license.mjs';
|
|
|
30
30
|
export const MARKET_URL = 'https://madre.run/mercado/catalogo.json';
|
|
31
31
|
const MAX_CATALOG = 1024 * 1024;
|
|
32
32
|
const MAX_SIGNATURE = 1024;
|
|
33
|
-
const MAX_MODULE = 512 * 1024;
|
|
33
|
+
export const MAX_MODULE = 512 * 1024;
|
|
34
34
|
const FRESH_MS = 10 * 60 * 1000;
|
|
35
35
|
const TIMEOUT_MS = 8000;
|
|
36
36
|
const ID = /^[a-z][a-z0-9-]{1,40}$/;
|
|
@@ -39,8 +39,8 @@ const COLOR = /^#[0-9a-f]{6}$/i;
|
|
|
39
39
|
|
|
40
40
|
export const marketUrl = (env = process.env) => env.PULSE_MARKET_URL || MARKET_URL;
|
|
41
41
|
const folder = (stateRoot) => join(stateRoot, 'market');
|
|
42
|
-
const readJson = (file) => readFile(file, 'utf8').then((raw) => JSON.parse(raw)).catch(() => null);
|
|
43
|
-
async function writeAtomic(file, data) {
|
|
42
|
+
export const readJson = (file) => readFile(file, 'utf8').then((raw) => JSON.parse(raw)).catch(() => null);
|
|
43
|
+
export async function writeAtomic(file, data) {
|
|
44
44
|
const temp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
45
45
|
await writeFile(temp, data);
|
|
46
46
|
await rename(temp, file);
|
|
@@ -112,6 +112,13 @@ export function readCatalog(text, { url = MARKET_URL } = {}) {
|
|
|
112
112
|
// Where a paid module is bought (an https page) and whose license opens it (market-license.mjs).
|
|
113
113
|
checkout: null,
|
|
114
114
|
license: null,
|
|
115
|
+
// A module of the community (2026-10-28, scripts/market-publish.mjs --community): who made it,
|
|
116
|
+
// and the license of its code. Signed like every entry: the author of MADRE read it first.
|
|
117
|
+
community: raw.community === true,
|
|
118
|
+
author: raw.author && typeof raw.author === 'object' && typeof raw.author.name === 'string' && raw.author.name.trim()
|
|
119
|
+
? { name: raw.author.name.trim().slice(0, 60), github: /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/.test(raw.author.github ?? '') ? raw.author.github : null }
|
|
120
|
+
: null,
|
|
121
|
+
spdx: typeof raw.spdx === 'string' && /^[A-Za-z0-9.+-]{2,40}$/.test(raw.spdx) ? raw.spdx : null,
|
|
115
122
|
};
|
|
116
123
|
if (entry.price > 0) {
|
|
117
124
|
try { const page = new URL(raw.checkout); if (page.protocol === 'https:') entry.checkout = page.href; } catch { /* no page to buy it */ }
|
|
@@ -128,10 +135,25 @@ export function readCatalog(text, { url = MARKET_URL } = {}) {
|
|
|
128
135
|
// What the author has to say to everyone who opens MADRE: one line each, said once, and the
|
|
129
136
|
// module it is about when there is one.
|
|
130
137
|
const news = (Array.isArray(data.news) ? data.news : []).filter((one) => ID.test(one?.id ?? '')).map((one) => ({ id: one.id, text: words(one.text, 240), module: ID.test(one.module ?? '') ? one.module : null })).filter((one) => one.text).slice(0, 10);
|
|
131
|
-
|
|
138
|
+
// NEWER FILES FOR MADRE'S OWN MODULES (2026-10-25, R-2 of the 1.1 road map): Notes, Reminders…
|
|
139
|
+
// come with MADRE and are kept up to date from here. A list of their own, so a MADRE that does not
|
|
140
|
+
// know it (1.0.5 and before) never sees one as a module to install. Each file carries, besides its
|
|
141
|
+
// sha256, the signature of the FACTORY key (src/market-key.mjs): the Market's key alone cannot
|
|
142
|
+
// replace a module every MADRE runs (src/builtin-updates.mjs).
|
|
143
|
+
const builtins = [];
|
|
144
|
+
for (const raw of (Array.isArray(data.builtins) ? data.builtins : []).slice(0, 50)) {
|
|
145
|
+
if (!ID.test(raw?.id ?? '') || typeof raw.version !== 'string' || !/^\d+\.\d+\.\d+$/.test(raw.version) || !Number.isInteger(raw.sdk) || raw.sdk < 1) continue;
|
|
146
|
+
const href = fileUrl(raw.file?.url, url);
|
|
147
|
+
if (!href || !SHA.test(raw.file?.sha256 ?? '') || typeof raw.file?.factory !== 'string' || raw.file.factory.length > MAX_SIGNATURE) continue;
|
|
148
|
+
builtins.push({ id: raw.id, version: raw.version, sdk: raw.sdk, changes: words(raw.changes, 400), file: { url: href, sha256: raw.file.sha256, size: Number(raw.file.size) || null, factory: raw.file.factory.trim() } });
|
|
149
|
+
}
|
|
150
|
+
// TAKEN BACK: a module, or one version of it, that must not run anywhere any more. A module got
|
|
151
|
+
// from the Market is removed; a newer file of one of MADRE's own goes back to the one MADRE came with.
|
|
152
|
+
const revoked = (Array.isArray(data.revoked) ? data.revoked : []).filter((one) => ID.test(one?.id ?? '')).map((one) => ({ id: one.id, version: typeof one.version === 'string' && /^\d+\.\d+\.\d+$/.test(one.version) ? one.version : null, why: words(one.why, 240) })).slice(0, 100);
|
|
153
|
+
return { schema: 1, issued: new Date(issued).toISOString(), shelves, featured, modules, news, builtins, revoked };
|
|
132
154
|
}
|
|
133
155
|
|
|
134
|
-
async function bytesFrom(url, { fetchImpl, max }) {
|
|
156
|
+
export async function bytesFrom(url, { fetchImpl, max }) {
|
|
135
157
|
const controller = new AbortController();
|
|
136
158
|
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
137
159
|
try {
|
|
@@ -184,7 +206,11 @@ export const installedFromMarket = async (stateRoot) => (await readJson(join(fol
|
|
|
184
206
|
|
|
185
207
|
// One module from the catalog onto this computer, for every project (each one turns it on).
|
|
186
208
|
// `verify` and `install` are src/modules/index.mjs's own checks and writer.
|
|
187
|
-
|
|
209
|
+
// Two steps since 2026-10-25: asked with `review`, the file is fetched and checked but nothing is
|
|
210
|
+
// installed, and what it declares comes back with its sha256; installed only when the person
|
|
211
|
+
// accepted that very file (`accept` = its sha256), so what is installed is what was read.
|
|
212
|
+
// A module MADRE updates on its own later (updateFromMarket) was accepted once, by the person.
|
|
213
|
+
export async function installFromMarket({ stateRoot, projectRoot, id, catalog, madre, fetchImpl = globalThis.fetch, verifyText, installText, review = false, accept = null, accepted = false }) {
|
|
188
214
|
const entry = catalog?.modules.find((one) => one.id === id && one.file);
|
|
189
215
|
if (!entry) throw new Error(t('The Market has no module «{id}» to install.', { id }));
|
|
190
216
|
if (!fitsVersion(madre, entry.minMadre)) throw new Error(t('This module needs MADRE {version} or newer.', { version: entry.minMadre }));
|
|
@@ -194,6 +220,8 @@ export async function installFromMarket({ stateRoot, projectRoot, id, catalog, m
|
|
|
194
220
|
const text = bytes.toString('utf8');
|
|
195
221
|
const checked = await verifyText({ text, name: `${id}.mjs`, replace: true });
|
|
196
222
|
if (checked.id !== id) throw new Error(t('The file says it is «{found}», not «{id}», so MADRE did not install it.', { found: checked.id, id }));
|
|
223
|
+
if (review) return { review: true, id, name: checked.name, version: entry.version, sha256: entry.file.sha256, declares: checked.declares ?? null };
|
|
224
|
+
if (!accepted && accept !== entry.file.sha256) throw Object.assign(new Error(t('Read what {name} does before installing it.', { name: checked.name ?? id })), { code: 'REVIEW_FIRST' });
|
|
197
225
|
const done = await installText({ text, name: `${id}.mjs`, scope: 'user', stateRoot, projectRoot, source: { kind: 'market', from: entry.file.url }, replace: true });
|
|
198
226
|
const dir = folder(stateRoot);
|
|
199
227
|
await mkdir(dir, { recursive: true });
|
|
@@ -236,19 +264,33 @@ export async function marketNewsSeen(stateRoot) { await writeAtomic(join(folder(
|
|
|
236
264
|
|
|
237
265
|
// Every module got from the Market whose signed file changed: the new one, installed, and a line
|
|
238
266
|
// for the person. One that fails stays as it was and is tried again next time.
|
|
239
|
-
export async function updateFromMarket({ stateRoot, projectRoot, catalog, madre, fetchImpl = globalThis.fetch, verifyText, installText, names = {} }) {
|
|
267
|
+
export async function updateFromMarket({ stateRoot, projectRoot, catalog, madre, fetchImpl = globalThis.fetch, verifyText, installText, names = {}, remove = null }) {
|
|
240
268
|
const installed = await installedFromMarket(stateRoot);
|
|
241
269
|
const updated = [];
|
|
270
|
+
const removed = [];
|
|
271
|
+
// Taken back (2026-10-25): a module, or the version of it this computer has, that the catalog says
|
|
272
|
+
// must not run any more is removed and forgotten here, so no next catalog brings it back.
|
|
273
|
+
for (const [id, have] of Object.entries(installed)) {
|
|
274
|
+
const taken = (catalog?.revoked ?? []).find((one) => one.id === id && (!one.version || one.version === have.version));
|
|
275
|
+
if (!taken || typeof remove !== 'function') continue;
|
|
276
|
+
try { await remove(id); } catch { /* already gone by hand */ }
|
|
277
|
+
await forgetFromMarket(stateRoot, id);
|
|
278
|
+
delete installed[id];
|
|
279
|
+
// Its name as the Market says it, in both languages when it has them; the page picks the room's.
|
|
280
|
+
removed.push({ id, name: catalog?.modules?.find((one) => one.id === id)?.name ?? names[id] ?? id, kind: 'removed', version: have.version ?? null, why: taken.why ?? null, at: new Date().toISOString() });
|
|
281
|
+
}
|
|
242
282
|
for (const [id, have] of Object.entries(installed)) {
|
|
243
283
|
const entry = catalog?.modules.find((one) => one.id === id && one.file);
|
|
244
284
|
if (!entry || entry.file.sha256 === have.sha256 || !fitsVersion(madre, entry.minMadre)) continue;
|
|
245
285
|
try {
|
|
246
|
-
await installFromMarket({ stateRoot, projectRoot, id, catalog, madre, fetchImpl, verifyText, installText });
|
|
286
|
+
await installFromMarket({ stateRoot, projectRoot, id, catalog, madre, fetchImpl, verifyText, installText, accepted: true });
|
|
247
287
|
updated.push({ id, name: names[id] ?? (typeof entry.name === 'string' ? entry.name : entry.name?.en) ?? id, from: have.version ?? null, to: entry.version, changes: entry.changes ?? null, at: new Date().toISOString() });
|
|
248
288
|
} catch { /* tried again the next time MADRE opens */ }
|
|
249
289
|
}
|
|
250
|
-
|
|
251
|
-
|
|
290
|
+
// Said once each: what updated itself, and what was taken out of this computer and why.
|
|
291
|
+
const told = [...updated, ...removed];
|
|
292
|
+
if (told.length) {
|
|
293
|
+
const news = [...(await marketNews(stateRoot)).filter((one) => !told.some((fresh) => fresh.id === one.id)), ...told];
|
|
252
294
|
await writeAtomic(join(folder(stateRoot), 'updates.json'), JSON.stringify(news, null, 2));
|
|
253
295
|
}
|
|
254
296
|
return updated;
|
package/src/maturity.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
|
// How grown a room is, and how far from being worth training on.
|
|
4
4
|
//
|
|
5
5
|
// Pure functions. The room hands in what it has; nothing here reads a file or calls a model.
|
package/src/mcp/connect.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
|
// CONNECT MCP: the MCP servers a person adds to one project, for its agents (2026-10-14).
|
|
4
4
|
//
|
|
5
5
|
// Pure-ish helpers shared by the module (src/modules/mcp-connect.mjs), which owns the settings and
|