@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/sdk.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
|
// MADRE's module SDK. A module is one file: what it is, the settings it keeps
|
|
4
4
|
// in ~/.pulse/config.json, how it describes itself to MODULES, what its switch
|
|
5
5
|
// does, the routes it serves and the events it listens to. The server builds a
|
|
@@ -69,7 +69,20 @@ export function dependencies(runs) {
|
|
|
69
69
|
return list.filter((dep) => dep && dep.name).map((dep) => ({ name: String(dep.name), version: dep.version ?? null, target: dep.target ?? null }));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
//
|
|
72
|
+
// The contracts this MADRE understands (2026-10-25). A module says which one it was written for
|
|
73
|
+
// with `sdk`, a whole number; without it, it is 1, the contract of 1.0.5 and before. A number
|
|
74
|
+
// counts what MADRE hands a module, not MADRE's version: a new MADRE keeps every contract it can,
|
|
75
|
+
// so a module does not have to be published again for it, and the Market offers a module to a
|
|
76
|
+
// MADRE that understands its contract, whatever its release (src/market-remote.mjs).
|
|
77
|
+
// 1 everything up to 1.0.5
|
|
78
|
+
// 2 ctx.t for words in the room's language, ctx.services.ollama.generate, and a module that is
|
|
79
|
+
// one file: its own logic and its own tool server, nothing imported from MADRE
|
|
80
|
+
export const SDK_LEVELS = Object.freeze([1, 2]);
|
|
81
|
+
export const SDK_LEVEL = SDK_LEVELS.at(-1);
|
|
82
|
+
export const sdkOf = (spec) => (spec?.sdk === undefined ? 1 : spec.sdk);
|
|
83
|
+
export const understandsSdk = (level) => SDK_LEVELS.includes(level);
|
|
84
|
+
|
|
85
|
+
// Every field this contract answers to. Forty-one of them and all but two optional, which is
|
|
73
86
|
// generous until you misspell one: `sumary` used to install without a word and leave a card with
|
|
74
87
|
// an empty summary. A key MADRE does not know is not fatal — a module written for a newer MADRE
|
|
75
88
|
// may carry fields this one has not learned yet — so it is said out loud instead of refused.
|
|
@@ -78,7 +91,7 @@ export const MODULE_FIELDS = new Set([
|
|
|
78
91
|
'requires', 'models', 'commands', 'card', 'configKey', 'settings', 'controls', 'routes', 'reaches',
|
|
79
92
|
'conditions', 'slash', 'status', 'preflight', 'detect', 'confirm', 'installCommand', 'secrets',
|
|
80
93
|
'updatePlan', 'toolsForTurn', 'toggle', 'onToggle', 'onSettings', 'onEvent', 'toggledEvent',
|
|
81
|
-
'toggledBody', 'describe', 'ready', 'footer', 'credit',
|
|
94
|
+
'toggledBody', 'describe', 'ready', 'footer', 'credit', 'sdk', 'icon',
|
|
82
95
|
]);
|
|
83
96
|
export const unknownFields = (spec) => Object.keys(spec ?? {}).filter((key) => !MODULE_FIELDS.has(key));
|
|
84
97
|
|
|
@@ -103,9 +116,24 @@ function footerKeys(spec) {
|
|
|
103
116
|
});
|
|
104
117
|
}
|
|
105
118
|
|
|
119
|
+
// A module's own icon (2026-10-27): a drawing and the color of its tile. MADRE fits the drawing to
|
|
120
|
+
// its tile, draws it in one color and picks the nearest of its own tile colors, so a module somebody
|
|
121
|
+
// wrote sits beside MADRE's own without looking like another app (public/market.js, moduleFace).
|
|
122
|
+
// Here it is only kept to its size: the page cleans the drawing before it shows it.
|
|
123
|
+
const ICON_COLOR = /^#[0-9a-f]{6}$/i;
|
|
124
|
+
function moduleIconOf(spec) {
|
|
125
|
+
const given = typeof spec.icon === 'string' ? { svg: spec.icon } : spec.icon;
|
|
126
|
+
if (!given || typeof given !== 'object' || typeof given.svg !== 'string' || !given.svg.trim()) return null;
|
|
127
|
+
if (given.svg.length > 8000) throw new Error(`Module ${spec.id}: its icon is a drawing of 8000 characters at most.`);
|
|
128
|
+
return { svg: given.svg.trim(), color: typeof given.color === 'string' && ICON_COLOR.test(given.color) ? given.color.toLowerCase() : null };
|
|
129
|
+
}
|
|
130
|
+
|
|
106
131
|
export function defineModule(spec) {
|
|
107
132
|
if (!spec?.id || !/^[a-z][a-z0-9-]*$/.test(spec.id)) throw new Error(`Module id must be kebab-case: ${spec?.id}`);
|
|
108
133
|
if (!spec.name) throw new Error(`Module ${spec.id} needs a name.`);
|
|
134
|
+
const sdk = sdkOf(spec);
|
|
135
|
+
if (!Number.isInteger(sdk) || sdk < 1) throw new Error(`Module ${spec.id}: sdk is a whole number, the contract it was written for.`);
|
|
136
|
+
if (!understandsSdk(sdk)) throw new Error(`Module ${spec.id} was written for contract ${sdk} of the SDK, and this MADRE understands up to ${SDK_LEVEL}. Update MADRE to use it.`);
|
|
109
137
|
const kind = spec.kind ?? 'builtin';
|
|
110
138
|
const configKey = spec.configKey ?? camel(spec.id);
|
|
111
139
|
// Its name and what it does may come in both languages, { es, en } (2026-10-20): MADRE keeps one
|
|
@@ -114,7 +142,7 @@ export function defineModule(spec) {
|
|
|
114
142
|
const nameText = oneWord(spec.name);
|
|
115
143
|
const defaults = { ...(kind === 'builtin' ? { enabled: false } : {}), ...(spec.settings ?? {}) };
|
|
116
144
|
const base = {
|
|
117
|
-
id: spec.id, kind, name: nameText, vendor: spec.vendor ?? 'MADRE', package: spec.package ?? null, version: spec.version ?? null,
|
|
145
|
+
id: spec.id, sdk, kind, name: nameText, vendor: spec.vendor ?? 'MADRE', package: spec.package ?? null, version: spec.version ?? null,
|
|
118
146
|
words: { name: isBilingual(spec.name) ? spec.name : null, summary: isBilingual(spec.summary) ? spec.summary : null },
|
|
119
147
|
// Keys this contract does not answer to. Carried so whoever installs the module is told.
|
|
120
148
|
unknown: unknownFields(spec),
|
|
@@ -127,6 +155,8 @@ export function defineModule(spec) {
|
|
|
127
155
|
updates: spec.updates?.url && /^https:\/\//.test(String(spec.updates.url)) ? { url: String(spec.updates.url) } : null,
|
|
128
156
|
// Keys beside MADRE's version, drawn by MADRE while the module is on (footerKeys).
|
|
129
157
|
footer: footerKeys(spec),
|
|
158
|
+
// Its own icon, kept to its size (moduleIconOf).
|
|
159
|
+
icon: moduleIconOf(spec),
|
|
130
160
|
// Whose idea it was (2026-10-20, Reminders): said on its card and in the Market.
|
|
131
161
|
credit: typeof spec.credit === 'string' && spec.credit.trim() ? spec.credit.trim().slice(0, 80) : null,
|
|
132
162
|
summary: oneWord(spec.summary) ?? '', creates: spec.creates ?? [], requires: spec.requires ?? [], models: spec.models ?? [], commands: spec.commands ?? (spec.slash?.length ? spec.slash.map((command) => command.usage ?? `/${command.name}`) : undefined),
|
|
@@ -183,7 +213,9 @@ export function defineModule(spec) {
|
|
|
183
213
|
configKey,
|
|
184
214
|
defaults,
|
|
185
215
|
settingsFrom,
|
|
186
|
-
|
|
216
|
+
// A route is handed the module's own settings and vault, as every other hook is (SDK 2): a module
|
|
217
|
+
// that is one file has no other way to read them.
|
|
218
|
+
routes: (spec.routes ?? []).map((route) => ({ ...route, method: route.method.toUpperCase(), handler: typeof route.handler === 'function' ? (ctx, request) => route.handler(mine(ctx ?? {}, settingsFrom(ctx?.config, ctx?.roomId)), request) : route.handler })),
|
|
187
219
|
onEvent: spec.onEvent ?? null,
|
|
188
220
|
conditions: spec.conditions ?? [],
|
|
189
221
|
// Slash commands the human types in the composer; they run on the server with the module's
|
package/src/modules/updates.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
|
// Is there a newer version of what a module is? Two kinds of answer, because there are two kinds
|
|
4
4
|
// of module.
|
|
5
5
|
//
|
package/src/mother.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
|
// MU/TH/UR's private channel. When someone strikes at her memory core, MOTHER
|
|
4
4
|
// tells her children (the agents) in a code the console cannot read; the room
|
|
5
5
|
// shows the code, the agents get the words. The channel lives in
|
package/src/npm-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 `npx` leaves in MADRE's environment about the call that started it, taken away before MADRE
|
|
4
4
|
// runs anything (2026-10-18).
|
|
5
5
|
//
|
package/src/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: the local intelligence MADRE leans on when it is there. Embeddings
|
|
4
4
|
// for recall by meaning and a model to distil memories, both on this machine,
|
|
5
5
|
// so remembering costs no tokens elsewhere and nothing leaves. Nothing here is
|
|
@@ -121,8 +121,10 @@ export function ollamaInvoker({ host = ollamaHost(), model, fetchImpl = globalTh
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// Pulls a model, reporting progress lines as Ollama streams them.
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
// `signal` stops it halfway (the welcome's «Cancel»): what Ollama already wrote stays in its own
|
|
125
|
+
// folder, and the next pull of the same model goes on from there.
|
|
126
|
+
export async function pullModel({ host = ollamaHost(), model, fetchImpl = globalThis.fetch, onLine = () => {}, timeoutMs = 30 * 60 * 1000, signal = null } = {}) {
|
|
127
|
+
const response = await fetchImpl(`${host}/api/pull`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ model, stream: true }), signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs) });
|
|
126
128
|
if (!response.ok) throw new Error(`Ollama pull HTTP ${response.status}: ${(await response.text().catch(() => '')).slice(0, 200)}`);
|
|
127
129
|
const reader = response.body.getReader();
|
|
128
130
|
const decoder = new TextDecoder();
|
package/src/opencode-health.mjs
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
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 OpenCode can answer with on this computer (2026-10-19). OpenCode sends each turn to the
|
|
4
4
|
// provider of its model, and a provider can stop answering on its own: an API key with no credit
|
|
5
5
|
// left, or one that is no longer valid. A person met it as a red card in English on every turn,
|
|
6
6
|
// and had to find out alone which model would work and where to change it. MADRE now remembers,
|
|
7
|
-
// per person (~/.pulse/opencode.json), the last model that answered and the providers that failed
|
|
7
|
+
// per person (~/.pulse/opencode-health.json), the last model that answered and the providers that failed
|
|
8
8
|
// and why, so the failure itself can offer the way out: retry on a model that works, or keep it.
|
|
9
9
|
// A provider's mark goes away the next time a turn on it answers.
|
|
10
10
|
|
|
11
|
-
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
11
|
+
import { mkdir, readFile, rename, unlink, writeFile } from 'node:fs/promises';
|
|
12
12
|
import { join } from 'node:path';
|
|
13
13
|
import { diagnose } from '../public/troubleshooting.js';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// Not `opencode.json` (QA 1.1.0, ACT-01): OpenCode reads a file by that name in the folder it runs
|
|
16
|
+
// in and every folder above it as its own configuration. Home runs in ~/.pulse/salas, so OpenCode
|
|
17
|
+
// found MADRE's notes, refused them («Unrecognized key: problems») and would not start: the
|
|
18
|
+
// Coordinator failed every turn and Home called a free-model OpenCode signed out.
|
|
19
|
+
const file = (stateRoot) => join(stateRoot, 'opencode-health.json');
|
|
20
|
+
const LEGACY = (stateRoot) => join(stateRoot, 'opencode.json');
|
|
21
|
+
const OURS = new Set(['problems', 'worked']);
|
|
22
|
+
// What 1.0.5 to 1.1.0 wrote under the old name moves to the new one, and the old file goes, but only
|
|
23
|
+
// when it is MADRE's (nothing in it but its two keys): an opencode.json someone put there is theirs.
|
|
24
|
+
async function migrate(stateRoot) {
|
|
25
|
+
let old;
|
|
26
|
+
try { old = JSON.parse(await readFile(LEGACY(stateRoot), 'utf8')); } catch { return null; }
|
|
27
|
+
if (!old || typeof old !== 'object' || Array.isArray(old) || !Object.keys(old).every((key) => OURS.has(key))) return null;
|
|
28
|
+
try { await readFile(file(stateRoot), 'utf8'); } catch { await keep(stateRoot, old); }
|
|
29
|
+
await unlink(LEGACY(stateRoot)).catch(() => {});
|
|
30
|
+
return old;
|
|
31
|
+
}
|
|
32
|
+
export const migrateOpenCodeHealth = migrate;
|
|
33
|
+
const read = async (stateRoot) => {
|
|
34
|
+
try { return JSON.parse(await readFile(file(stateRoot), 'utf8')) ?? {}; } catch { /* first time, or still under the old name */ }
|
|
35
|
+
return (await migrate(stateRoot)) ?? {};
|
|
36
|
+
};
|
|
17
37
|
async function keep(stateRoot, data) {
|
|
18
38
|
await mkdir(stateRoot, { recursive: true });
|
|
19
39
|
const temp = `${file(stateRoot)}.${process.pid}.${Date.now()}.tmp`;
|
package/src/outbound.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 left this machine.
|
|
4
4
|
//
|
|
5
5
|
// MADRE runs on your computer and keeps everything it knows in a file you own, and that sentence
|
|
@@ -96,6 +96,14 @@ export const DESTINATIONS = [
|
|
|
96
96
|
where: 'Always on: it is how the author knows how many people use MADRE',
|
|
97
97
|
inside: true,
|
|
98
98
|
},
|
|
99
|
+
{
|
|
100
|
+
// Anonymous diagnostics (src/telemetry.mjs, 2026-10-28): on unless turned off.
|
|
101
|
+
id: 'diagnostics', host: 'madre.run', match: (url) => url.pathname === '/api/telemetry', to: 'madre.run · anonymous diagnostics',
|
|
102
|
+
what: 'Errors with private details removed (no paths, names, keys or emails) and counts of turns, modes and features, with this copy\'s random identifier, version and system. Never what you write, your projects or your files.',
|
|
103
|
+
when: 'once a day, and soon after an error never seen before',
|
|
104
|
+
where: 'Settings › Version and reports › Send anonymous diagnostics · or PULSE_TELEMETRY=0',
|
|
105
|
+
inside: true,
|
|
106
|
+
},
|
|
99
107
|
{
|
|
100
108
|
// The Market (src/market-remote.mjs): a signed catalog, and the file of a module you get from it.
|
|
101
109
|
id: 'market', host: 'madre.run', match: (url) => url.pathname.startsWith('/mercado/'), to: "madre.run · the Market",
|
package/src/override.mjs
CHANGED
|
@@ -1,28 +1,35 @@
|
|
|
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 { createHash, timingSafeEqual } from 'node:crypto';
|
|
4
4
|
|
|
5
5
|
// How #3 CONTROL and #4 AIRLOCK are unlocked, as the person chose it in AJUSTES › Permissions.
|
|
6
6
|
//
|
|
7
7
|
// The key is checked here, by the project, since 2026-10-12 (SRV-01 of the 1.0 review): before,
|
|
8
8
|
// only the browser checked it, and two POSTs from any process on the Mac opened #4 with no key.
|
|
9
|
-
// The page asks for the key and sends what was typed; `keyHolds` decides.
|
|
10
|
-
//
|
|
11
|
-
//
|
|
9
|
+
// The page asks for the key and sends what was typed; `keyHolds` decides.
|
|
10
|
+
//
|
|
11
|
+
// Since 2026-10-28 (the person's decision) nothing has to be typed to unlock: #3 is one
|
|
12
|
+
// confirmation and #4 two, or the person's own phrase (once for #3, twice for #4) for whoever wants
|
|
13
|
+
// a key a program cannot know. The project's name, typed, is gone as a key: any process can read a
|
|
14
|
+
// folder's name, so it stopped a slip, not a program, and the confirmation stops the slip as well.
|
|
15
|
+
// The rules that never move, whatever the file says:
|
|
16
|
+
// · #4 is never opened by one press: two confirmations, or the phrase twice;
|
|
12
17
|
// · a personal phrase is never stored, only its salted SHA-256; the phrase typed to unlock is
|
|
13
18
|
// compared here and forgotten, and the fingerprint never leaves the project (`publicOverride`);
|
|
14
|
-
// · the grace
|
|
15
|
-
// · the project name stops a slip, not a program: any process can read a folder's name. The
|
|
16
|
-
// phrase is the key a program on the Mac cannot know.
|
|
19
|
+
// · the grace has a limit: #3 up to 8 hours, #4 up to 1, and off unless chosen.
|
|
17
20
|
export const OVERRIDE_KEYS = Object.freeze({
|
|
18
|
-
3: Object.freeze(['
|
|
19
|
-
4: Object.freeze(['
|
|
21
|
+
3: Object.freeze(['confirm', 'phrase']),
|
|
22
|
+
4: Object.freeze(['confirm-airlock', 'phrase-airlock']),
|
|
20
23
|
});
|
|
24
|
+
// What the page sends for each press of a confirmation.
|
|
25
|
+
export const CONFIRMED = 'confirm';
|
|
26
|
+
// How long a confirmed mode stays open (2026-10-28, more room, as Claude's and Codex's auto modes
|
|
27
|
+
// give): #3 up to a working day, #4 up to an hour, and off unless chosen.
|
|
21
28
|
export const OVERRIDE_GRACE = Object.freeze({
|
|
22
|
-
3: Object.freeze([0, 5, 15, 30]),
|
|
23
|
-
4: Object.freeze([0, 5]),
|
|
29
|
+
3: Object.freeze([0, 5, 15, 30, 60, 240, 480]),
|
|
30
|
+
4: Object.freeze([0, 5, 15, 30, 60]),
|
|
24
31
|
});
|
|
25
|
-
const DEFAULT_KEYS = { 3: '
|
|
32
|
+
const DEFAULT_KEYS = { 3: 'confirm', 4: 'confirm-airlock' };
|
|
26
33
|
|
|
27
34
|
const HEX = (length) => new RegExp(`^[0-9a-f]{${length}}$`);
|
|
28
35
|
function cleanPhrase(phrase) {
|
|
@@ -76,20 +83,18 @@ export function phraseHash(salt, phrase) {
|
|
|
76
83
|
}
|
|
77
84
|
const same = (a, b) => a.length === b.length && timingSafeEqual(Buffer.from(a), Buffer.from(b));
|
|
78
85
|
|
|
79
|
-
// Whether what was
|
|
80
|
-
//
|
|
81
|
-
export function keyHolds(stored, { mode, words = []
|
|
86
|
+
// Whether what was sent opens this mode with the key chosen for it. `words` holds one entry per
|
|
87
|
+
// press or phrase: «confirm» for a confirmation, the phrase as typed for a phrase; #4 sends two.
|
|
88
|
+
export function keyHolds(stored, { mode, words = [] } = {}) {
|
|
82
89
|
if (mode !== 3 && mode !== 4) return false;
|
|
83
90
|
const settings = overrideSettings(stored);
|
|
84
91
|
const typed = (Array.isArray(words) ? words : []).map((word) => (typeof word === 'string' ? word.trim() : ''));
|
|
85
|
-
const isProject = (word) => Boolean(word) && Boolean(designation) && word.toLowerCase() === String(designation).toLowerCase();
|
|
86
92
|
const isPhrase = (word) => Boolean(word) && Boolean(settings.phrase) && same(phraseHash(settings.phrase.salt, word), settings.phrase.hash);
|
|
87
93
|
switch (settings.keys[mode]) {
|
|
88
|
-
case 'confirm': return mode === 3;
|
|
89
|
-
case '
|
|
90
|
-
case '
|
|
91
|
-
case '
|
|
92
|
-
case 'phrase-airlock': return isPhrase(typed[0]) && isPhrase(typed[1]);
|
|
94
|
+
case 'confirm': return mode === 3 && typed[0] === CONFIRMED;
|
|
95
|
+
case 'phrase': return mode === 3 && isPhrase(typed[0]);
|
|
96
|
+
case 'confirm-airlock': return mode === 4 && typed[0] === CONFIRMED && typed[1] === CONFIRMED;
|
|
97
|
+
case 'phrase-airlock': return mode === 4 && isPhrase(typed[0]) && isPhrase(typed[1]);
|
|
93
98
|
default: return false;
|
|
94
99
|
}
|
|
95
100
|
}
|
package/src/ports.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 listening on this computer, so RIPLEY can look at it.
|
|
4
4
|
//
|
|
5
5
|
// A room that renders a project's files but cannot open the project's own dev server is half a
|
package/src/prices.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 a turn would cost at the provider's API list price, for the CLIs that do not say it
|
|
4
4
|
// themselves. Claude Code reports its own figure (`total_cost_usd`); Codex and Gemini report only
|
|
5
5
|
// tokens, and OpenCode reports 0 when the model runs on a subscription. So the room prices those
|
package/src/privacy.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
|
// Privacy: terms that must never travel through a room. ERROR-001 in a real room
|
|
4
4
|
// showed the channel: an agent's own configuration (organisation instructions,
|
|
5
5
|
// the account it runs under) leaks into its reply, the reply enters the shared
|
package/src/quota-monitor.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
|
export class QuotaMonitor {
|
|
4
4
|
#sources;
|
|
5
5
|
#onReport;
|
package/src/quota-sources.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 { execFile } from 'node:child_process';
|
|
4
4
|
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
5
5
|
import { homedir } from 'node:os';
|
package/src/request-guard.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 listens on 127.0.0.1, which keeps other computers out but not other web pages: any
|
|
4
4
|
// site open in this browser can send a request to 127.0.0.1:4317, and an uploaded module is code
|
|
5
5
|
// MADRE runs with your permissions. Two checks, before any route, close that door.
|
package/src/review-ask.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
|
// Asking for a star or a review (2026-10-10): three times at most, and never again once answered.
|
|
4
4
|
//
|
|
5
5
|
// After twenty minutes of MADRE in use, and on the second and the seventh day after it was first
|
|
@@ -25,7 +25,8 @@ export const ASK_MOMENTS = [
|
|
|
25
25
|
{ id: 'd2', reached: (state, now) => now - Date.parse(state.first) >= 2 * DAY },
|
|
26
26
|
{ id: 'd7', reached: (state, now) => now - Date.parse(state.first) >= 7 * DAY },
|
|
27
27
|
];
|
|
28
|
-
|
|
28
|
+
// A donation on GitHub Sponsors is an answer too (2026-10-30): whoever gave is not asked again.
|
|
29
|
+
export const ASK_ANSWERS = ['later', 'star', 'review', 'donate', 'never'];
|
|
29
30
|
// One minute of use is counted at most once a minute, whichever page says it.
|
|
30
31
|
const TICK_MS = 55 * 1000;
|
|
31
32
|
// Never asked twice within this long, whatever moments have come.
|
package/src/room/archivist.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 archivist: every so often the cheapest allowed agent reads what nobody
|
|
4
4
|
// has distilled and keeps the few notes worth remembering. Scheduling by count
|
|
5
5
|
// or by quiet, one batch per run, a bench for whoever fails, a report to the
|
package/src/room/attachments.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
|
// Human uploads, stored under the room (never in the project). Registered
|
|
4
4
|
// here so a message can reference them by id; the ledger lets a restarted
|
|
5
5
|
// room rebuild the registry.
|
package/src/room/budget.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 local token budget: a rolling window per agent (five hours, like the
|
|
4
4
|
// providers' short windows), raw totals for the record, and the seeding of the
|
|
5
5
|
// usage sentinel from the ledger on start.
|
package/src/room/context.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 context an agent gets: the recent transcript verbatim and, when the
|
|
4
4
|
// room is longer than that window, the older exchanges that match this
|
|
5
5
|
// request, recalled from memory inside the same character budget.
|
package/src/room/control.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
|
// CONTROL: one agent holds the project itself for one turn. A git checkpoint
|
|
4
4
|
// is taken before, the diff is read after, writes into forbidden zones are
|
|
5
5
|
// restored on the spot, and the checkpoint stays for UNDO. One holder at a time.
|
package/src/room/copilot.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
|
// COPILOT: the human hands one project to whichever agent they write to, for a while (2026-10-14).
|
|
4
4
|
//
|
|
5
5
|
// Turned on with the #3 key, once, for up to 24 hours. While it lasts, a message sent at #3 needs no
|
package/src/room/economy.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 { freshInput } from './budget.mjs';
|
|
4
4
|
|
|
5
5
|
// What a turn actually costs, and where it went.
|
package/src/room/escalation.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
|
// Waiting for the human: a plan step wants a mode it does not have. One clock
|
|
4
4
|
// per request, a decision from the room, and a way to settle everything at
|
|
5
5
|
// once when a plan stops or the room shuts down.
|
package/src/room/ghost.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
|
// GHOST turns: they happen, listeners see them, the ledger never does. A turn
|
|
4
4
|
// is remembered as ghost for a while so its late events stay off the record.
|
|
5
5
|
|
package/src/room/guard.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
|
// Prevention before restoration: while an agent holds CONTROL, the forbidden
|
|
4
4
|
// zones that can be made read-only are made read-only. .env files and MADRE's
|
|
5
5
|
// own folders lose their write bits for the turn and get them back after;
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
import { chmod, readdir, readFile, rm, stat } from 'node:fs/promises';
|
|
11
11
|
import { join, relative } from 'node:path';
|
|
12
|
+
import { isForbidden } from '../checkpoint.mjs';
|
|
12
13
|
import { writeWhole } from '../json-file.mjs';
|
|
13
14
|
|
|
14
15
|
const SKIP = new Set(['node_modules', '.git', 'dist', 'build', 'coverage']);
|
|
15
16
|
|
|
16
|
-
// Files and folders to lock: every .env / .env.* up to four levels deep
|
|
17
|
+
// Files and folders to lock: every .env / .env.* up to four levels deep (not its templates:
|
|
18
|
+
// .env.example and the like, src/checkpoint.mjs isForbidden), .pulse/, .madre/ and .claude/settings.local.json.
|
|
17
19
|
export async function forbiddenTargets(projectRoot, { maxDepth = 4 } = {}) {
|
|
18
20
|
const targets = [];
|
|
19
21
|
const walk = async (dir, depth) => {
|
|
@@ -26,7 +28,7 @@ export async function forbiddenTargets(projectRoot, { maxDepth = 4 } = {}) {
|
|
|
26
28
|
if (rel === '.pulse' || rel === '.madre') { targets.push({ path, kind: 'dir' }); continue; }
|
|
27
29
|
if (SKIP.has(entry.name) || depth >= maxDepth) continue;
|
|
28
30
|
await walk(path, depth + 1);
|
|
29
|
-
} else if (
|
|
31
|
+
} else if (isForbidden(rel) || rel === '.claude/settings.local.json') {
|
|
30
32
|
targets.push({ path, kind: 'file' });
|
|
31
33
|
}
|
|
32
34
|
}
|
package/src/room/prompt.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 words an agent reads at the start of a turn. Pure: everything the room
|
|
4
4
|
// knows is handed in, nothing is looked up. Order matters: who you are, what
|
|
5
5
|
// you may do, what the room remembers, what was said, what is asked.
|
|
@@ -124,7 +124,7 @@ export function promptParts({
|
|
|
124
124
|
? `Tools from MADRE's modules, attached to this turn as MCP servers:\n${mcpServers.map((server) => `- ${server.name}: ${server.brief ?? (server.tools?.length ? server.tools.join(', ') : 'see its tool list')}`).join('\n')}`
|
|
125
125
|
: null },
|
|
126
126
|
{ id: 'bishop', text: bishop },
|
|
127
|
-
{ id: 'sdk', text: lease && sdk && wantsModule(text) ? `Building a MADRE module: MADRE is modular and the human may ask you for a module (a slash command, a tool for the agents, an integration). Read the SDK guide at ${sdk.guide} and the complete example at ${sdk.example}. If it talks to a service outside this machine, read ${sdk.connector} too: a connector is ONE file that is both the module and the MCP server it spawns, and that shape is not guessable. Then write ONE file named <id>.module.mjs (default export a plain spec object) in ${lease.scratchDir ? `${lease.outDir}/${lease.scratchDir}` : lease.outDir}. Do not touch ~/.pulse/modules or .madre/modules: MADRE shows the human an INSTALL card and they decide. A module runs inside MADRE with the human's permissions, so keep it small and honest about what it reaches. Never hardcode a credential or invent somewhere to keep one: declare 'secrets' and read them back with ctx.vault, which is where MADRE keeps them and the only place that is safe.` : null },
|
|
127
|
+
{ id: 'sdk', text: lease && sdk && wantsModule(text) ? `Building a MADRE module: MADRE is modular and the human may ask you for a module (a slash command, a tool for the agents, an integration). Read the SDK guide at ${sdk.guide} and the complete example at ${sdk.example}. If it talks to a service outside this machine, read ${sdk.connector} too: a connector is ONE file that is both the module and the MCP server it spawns, and that shape is not guessable. Then write ONE file named <id>.module.mjs (default export a plain spec object) in ${lease.scratchDir ? `${lease.outDir}/${lease.scratchDir}` : lease.outDir}. Do not touch ~/.pulse/modules or .madre/modules: MADRE shows the human an INSTALL card and they decide. A module runs inside MADRE with the human's permissions, so keep it small and honest about what it reaches. Never hardcode a credential or invent somewhere to keep one: declare 'secrets' and read them back with ctx.vault, which is where MADRE keeps them and the only place that is safe. Give it its own icon, as part of the module: 'icon: { svg, color }', a simple drawing of what it does (lines or shapes, any grid) and a #rrggbb color; MADRE fits it to its tile and draws it in one color, so keep it to one clear idea.` : null },
|
|
128
128
|
{ id: 'lease', text: lease ? leaseInstructions({ outDir: lease.outDir, agentId: agent.id, scopes: lease.scopes, capable: scopesFor(agent.id), imageStudio, control: Boolean(lease.control), create: Boolean(lease.create), airlock: Boolean(lease.airlock), scratchDir: lease.scratchDir ?? null }) : null },
|
|
129
129
|
{ id: 'copilot', text: copilot },
|
|
130
130
|
{ id: 'control-held', text: !lease?.control && controlHolder && controlHolder !== agent.id ? `Heads-up: @${controlHolder} currently holds CONTROL and may be changing project files while you work; cite the state you actually read.` : null },
|
package/src/room/returns.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
|
// When the commands an agent asked for have run, the agent hears how they went (2026-10-14).
|
|
4
4
|
//
|
|
5
5
|
// Before this a ```pulse-run card ran its lines and the room stopped there: each output went into
|
package/src/room/runs.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 human's hands for a command an agent asked for, in the project root, with no shell: the
|
|
4
4
|
// argv the parser split is the argv that runs (see src/runs.mjs).
|
|
5
5
|
//
|
|
@@ -62,12 +62,14 @@ export class RunDesk {
|
|
|
62
62
|
// Busy is a command still working toward its answer; a server that is serving is not in the way.
|
|
63
63
|
get busy() { return [...this.#runs.values()].some((run) => !run.serving); }
|
|
64
64
|
serving() { return [...this.#runs.entries()].filter(([, run]) => run.serving).map(([id, run]) => ({ id, ...run.serving })); }
|
|
65
|
+
// Every run alive, with what it is and since when (the room's «En marcha»).
|
|
66
|
+
live() { return [...this.#runs.entries()].map(([id, run]) => ({ id, ...(run.meta ?? {}), startedAt: run.startedAt, serving: run.serving ?? null })); }
|
|
65
67
|
// Whether a line whose id starts this way is still working toward its answer.
|
|
66
68
|
runningFor(prefix) { return [...this.#runs.entries()].some(([id, run]) => id.startsWith(prefix) && !run.serving); }
|
|
67
69
|
|
|
68
70
|
// Resolves with what happened when the process ends; never rejects. A program that could not
|
|
69
71
|
// start is an answer too. `onServing` hears, once, that the run opened a port.
|
|
70
|
-
run({ id = 'run', argv, cwd, timeoutMs = RUN_TIMEOUT_MS, env = process.env, onServing = null }) {
|
|
72
|
+
run({ id = 'run', argv, cwd, timeoutMs = RUN_TIMEOUT_MS, env = process.env, onServing = null, meta = null }) {
|
|
71
73
|
return new Promise((resolve) => {
|
|
72
74
|
const started = Date.now();
|
|
73
75
|
// 'error' and 'close' can both arrive for one failed spawn; the first one is the answer.
|
|
@@ -95,7 +97,7 @@ export class RunDesk {
|
|
|
95
97
|
done({ ok: false, exitCode: null, text: couldNotRun(argv[0], error) });
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
|
-
const record = { child, stoppedBy: null, serving: null };
|
|
100
|
+
const record = { child, stoppedBy: null, serving: null, meta, startedAt: started };
|
|
99
101
|
this.#runs.set(id, record);
|
|
100
102
|
let output = '';
|
|
101
103
|
// Bounded while it runs, not only at the end: a program that prints without stopping must
|
package/src/room/vectors.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
|
// Vectors are filled shortly after indexing, one batch at a time, never on a
|
|
4
4
|
// turn's critical path. A backlog drains batch by batch; a failing embedder
|
|
5
5
|
// pauses and tries again later. The room does not depend on vectors.
|