@jossuealcala/madre 1.1.3 → 1.1.4
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/CHANGELOG.en.md +20 -1
- package/CHANGELOG.md +20 -1
- package/TRADEMARKS.md +6 -2
- package/bin/madre.mjs +4 -2
- package/docs/REFERENCE.md +3 -3
- package/docs/SDK.md +28 -1
- package/docs/en/REFERENCE.md +2 -2
- package/docs/en/SDK.md +26 -0
- package/docs/sdk/hello-module.mjs +38 -3
- package/habilidades/explicamelo-facil/HABILIDAD.md +19 -0
- package/habilidades/hojas-de-calculo/HABILIDAD.md +18 -0
- package/habilidades/mensajes-a-clientes/HABILIDAD.md +19 -0
- package/habilidades/publicaciones-para-redes/HABILIDAD.md +19 -0
- package/habilidades/resumen-y-pendientes/HABILIDAD.md +18 -0
- package/habilidades/tu-pagina-paso-a-paso/HABILIDAD.md +19 -0
- package/package.json +4 -3
- package/public/activity.js +57 -22
- package/public/app.js +3998 -762
- package/public/assets/brand/OFL-SpaceGrotesk.txt +93 -0
- package/public/assets/brand/SpaceGrotesk-latin-ext.woff2 +0 -0
- package/public/assets/brand/SpaceGrotesk-latin.woff2 +0 -0
- package/public/assets/brand/madre-app-180.png +0 -0
- package/public/assets/brand/madre-app-192.png +0 -0
- package/public/assets/brand/madre-app-512.png +0 -0
- package/public/assets/brand/madre-app.svg +1 -1
- package/public/assets/brand/madre-favicon.svg +1 -1
- package/public/attribution.js +28 -27
- package/public/auto-open.js +102 -0
- package/public/brands.js +9 -6
- package/public/changes.js +63 -0
- package/public/en.js +1085 -101
- package/public/es.js +2395 -1688
- package/public/i18n.js +11 -0
- package/public/index.html +28 -27
- package/public/loader.js +322 -117
- package/public/macroverso.js +33 -350
- package/public/manual-content.js +37 -7
- package/public/manual.js +21 -6
- package/public/market-view.js +212 -105
- package/public/market.js +10 -2
- package/public/mcp-catalog.js +7 -2
- package/public/missions.js +169 -0
- package/public/news-scenes.js +110 -3
- package/public/nostromo-engine.js +935 -654
- package/public/notices.js +14 -2
- package/public/notifications.js +119 -0
- package/public/provider-marks.js +170 -0
- package/public/provider-pick.js +147 -0
- package/public/resay.js +1 -0
- package/public/review-ask.js +16 -13
- package/public/routing.js +29 -3
- package/public/salas-mac.css +257 -40
- package/public/salas-mac.html +5 -5
- package/public/salas-mac.js +376 -97
- package/public/salas.css +2 -2
- package/public/salas.html +2 -2
- package/public/salas.js +1 -1
- package/public/starters.js +128 -0
- package/public/styles.css +2656 -336
- package/public/subscription.js +303 -0
- package/public/terms-field.js +170 -0
- package/public/terms.js +117 -19
- package/public/tips.js +41 -7
- package/public/tour-chapters.js +35 -35
- package/public/tour.js +333 -43
- package/public/troubleshooting.js +100 -7
- package/public/welcome-scene.js +117 -29
- package/public/welcome.js +364 -60
- package/src/adapters/claude.mjs +2 -1
- package/src/adapters/codex.mjs +2 -1
- package/src/adapters/cursor.mjs +9 -6
- package/src/adapters/gemini.mjs +4 -0
- package/src/adapters/grok.mjs +6 -4
- package/src/adapters/madre.mjs +71 -23
- package/src/adapters/opencode.mjs +15 -2
- package/src/adapters/steps.mjs +176 -0
- package/src/app-invite.mjs +90 -0
- package/src/billing-key.mjs +8 -0
- package/src/billing.mjs +317 -0
- package/src/bridge/policy.mjs +1 -1
- package/src/capabilities.mjs +17 -11
- package/src/chats.mjs +44 -2
- package/src/checkpoint.mjs +5 -1
- package/src/commands.mjs +5 -2
- package/src/directives.mjs +1 -0
- package/src/event-store.mjs +15 -0
- package/src/extensions.mjs +5 -1
- package/src/ficha.mjs +16 -0
- package/src/image-studio.mjs +13 -3
- package/src/install-metrics.mjs +9 -3
- package/src/lease.mjs +1 -1
- package/src/looks.mjs +4 -1
- package/src/mcp/image-server.mjs +59 -90
- package/src/modules/ahp.mjs +2 -1
- package/src/modules/github.mjs +6 -2
- package/src/modules/image-providers.mjs +281 -0
- package/src/modules/image-studio.mjs +100 -19
- package/src/modules/index.mjs +7 -1
- package/src/modules/intents-observe.mjs +3 -1
- package/src/modules/playwright.mjs +33 -4
- package/src/modules/reminders.mjs +42 -2
- package/src/modules/ripley.mjs +2 -1
- package/src/modules/sdk.mjs +6 -1
- package/src/opencode-health.mjs +1 -1
- package/src/outbound.mjs +80 -6
- package/src/quota-sources.mjs +148 -3
- package/src/review-ask.mjs +55 -31
- package/src/room/changes.mjs +79 -0
- package/src/room/economy.mjs +1 -1
- package/src/room/guard.mjs +8 -1
- package/src/room/prompt.mjs +20 -4
- package/src/room.mjs +87 -21
- package/src/salas.mjs +30 -3
- package/src/server.mjs +545 -59
- package/src/setup.mjs +1 -1
- package/src/skills.mjs +10 -0
- package/src/terms.mjs +23 -5
- package/src/tour.mjs +18 -3
- package/src/updates.mjs +47 -4
- package/src/web-preview.mjs +181 -0
- package/src/whats-new.mjs +76 -4
package/src/setup.mjs
CHANGED
|
@@ -27,7 +27,7 @@ export function makePalette({ colors = stdout.isTTY && !process.env.NO_COLOR, de
|
|
|
27
27
|
};
|
|
28
28
|
const wrap = (open) => (text) => `${open}${text}[0m`;
|
|
29
29
|
return {
|
|
30
|
-
phosphor: wrap(fg('#
|
|
30
|
+
phosphor: wrap(fg('#34d399')),
|
|
31
31
|
dim: wrap('[2m'),
|
|
32
32
|
bold: wrap('[1m'),
|
|
33
33
|
danger: wrap(truecolor ? fg('#ff7b72') : '[31m'),
|
package/src/skills.mjs
CHANGED
|
@@ -74,7 +74,14 @@ export const safePath = (path) => {
|
|
|
74
74
|
return said.split(/[\\/]/).every((part) => part && !part.startsWith('.'));
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
// Three folders, read in this order so the later one wins: the skills that come with MADRE (1.1.4,
|
|
78
|
+
// D-H8: for whoever is starting out with AI), every project's, and this project's. MADRE's own are
|
|
79
|
+
// never written or removed from here: a person turns one off, or keeps a copy of their own with
|
|
80
|
+
// the same id, which stands in for it.
|
|
81
|
+
// PULSE_MADRE_SKILLS points elsewhere (the suite points it at nothing, test/setup.mjs).
|
|
82
|
+
export const MADRE_SKILLS = fileURLToPath(new URL('../habilidades', import.meta.url));
|
|
77
83
|
export const skillFolders = ({ stateRoot, projectRoot }) => ({
|
|
84
|
+
madre: process.env.PULSE_MADRE_SKILLS || MADRE_SKILLS,
|
|
78
85
|
user: join(stateRoot, 'habilidades'),
|
|
79
86
|
project: join(projectRoot, '.madre', 'habilidades'),
|
|
80
87
|
});
|
|
@@ -142,6 +149,8 @@ const KEYS = {
|
|
|
142
149
|
credit: ['credit', 'credito', 'crédito'], license: ['license', 'licencia'],
|
|
143
150
|
line: ['line', 'linea', 'línea'], summary: ['summary', 'resumen'], shelf: ['shelf', 'estante'],
|
|
144
151
|
author: ['author', 'autor', 'autora'],
|
|
152
|
+
// Its drawing on the shelf of skills: the name of one of MADRE's Trazo icons (public/icons.js).
|
|
153
|
+
icon: ['icon', 'icono', 'ícono'],
|
|
145
154
|
};
|
|
146
155
|
export const KNOWN = new Set(Object.values(KEYS).flat());
|
|
147
156
|
const field = (fields, key) => KEYS[key].map((name) => fields[name]).find((value) => String(value ?? '').trim());
|
|
@@ -174,6 +183,7 @@ export function readSkillText(text, { id = null } = {}) {
|
|
|
174
183
|
line: words(field(fields, 'line'), 140),
|
|
175
184
|
summary: words(field(fields, 'summary'), 1200),
|
|
176
185
|
shelf: unquote(field(fields, 'shelf') ?? '') || null,
|
|
186
|
+
icon: /^[a-z][a-z0-9-]{1,30}$/.test(unquote(field(fields, 'icon') ?? '')) ? unquote(field(fields, 'icon')) : null,
|
|
177
187
|
author: author(field(fields, 'author')),
|
|
178
188
|
body,
|
|
179
189
|
// Said, never ignored in silence, as a module's unknown fields are said when it is installed.
|
package/src/terms.mjs
CHANGED
|
@@ -18,20 +18,38 @@ export const TERMS_LINKS = {
|
|
|
18
18
|
privacy: { es: 'https://madre.run/privacidad/', en: 'https://madre.run/en/privacy/' },
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
// THE DESKTOP APP HAS ITS OWN LICENSE (2026-11-11, the author): MADRE for Mac and Linux, the app
|
|
22
|
+
// (~/madre-app, private), is closed code, so inside it the person accepts the app's license of use —
|
|
23
|
+
// not the source code's. The MADRE on GitHub and npm keeps the Business Source License, unchanged. A
|
|
24
|
+
// text of its own is a version of its own: whoever accepted the source's in a browser is asked again
|
|
25
|
+
// the first time MADRE opens inside the app, and the other way round.
|
|
26
|
+
// 2026-11-13: the personal license (free for a person, not for organizations; ~/madre-app/LICENCIA-DE-USO.md).
|
|
27
|
+
export const APP_TERMS_VERSION = 'app-2026-11-13';
|
|
28
|
+
export const APP_TERMS_LINKS = {
|
|
29
|
+
license: { es: 'https://madre.run/app/licencia/', en: 'https://madre.run/en/app/license/' },
|
|
30
|
+
privacy: TERMS_LINKS.privacy,
|
|
31
|
+
};
|
|
32
|
+
export const inApp = (env = process.env) => env.MADRE_APP === '1';
|
|
33
|
+
export const termsVersion = (env = process.env) => (inApp(env) ? APP_TERMS_VERSION : TERMS_VERSION);
|
|
34
|
+
export const termsLinks = (env = process.env) => (inApp(env) ? APP_TERMS_LINKS : TERMS_LINKS);
|
|
35
|
+
export const termsKind = (env = process.env) => (inApp(env) ? 'app' : 'source');
|
|
36
|
+
|
|
21
37
|
export const termsWaived = (env = process.env) => env.PULSE_TEST_MODE === '1' || env.PULSE_TERMS === 'accepted';
|
|
22
38
|
|
|
23
39
|
export async function readTerms(root, { env = process.env } = {}) {
|
|
24
|
-
|
|
40
|
+
const version = termsVersion(env);
|
|
41
|
+
const kind = termsKind(env);
|
|
42
|
+
if (termsWaived(env)) return { accepted: true, version, kind, at: null, waived: true };
|
|
25
43
|
try {
|
|
26
44
|
const kept = JSON.parse(await readFile(join(root, 'terms.json'), 'utf8'));
|
|
27
|
-
return { accepted: kept?.version ===
|
|
45
|
+
return { accepted: kept?.version === version, version, kind, at: typeof kept?.at === 'string' ? kept.at : null, previous: kept?.version ?? null };
|
|
28
46
|
} catch {
|
|
29
|
-
return { accepted: false, version
|
|
47
|
+
return { accepted: false, version, kind, at: null, previous: null };
|
|
30
48
|
}
|
|
31
49
|
}
|
|
32
50
|
|
|
33
|
-
export async function acceptTerms(root, { now = new Date() } = {}) {
|
|
34
|
-
const kept = { version:
|
|
51
|
+
export async function acceptTerms(root, { now = new Date(), env = process.env } = {}) {
|
|
52
|
+
const kept = { version: termsVersion(env), at: now.toISOString() };
|
|
35
53
|
await writeFile(join(root, 'terms.json'), `${JSON.stringify(kept)}\n`);
|
|
36
54
|
return { accepted: true, ...kept };
|
|
37
55
|
}
|
package/src/tour.mjs
CHANGED
|
@@ -37,7 +37,7 @@ export const CHAPTERS = ['moved', 'home', 'renamed', 'board', 'widgets', 'projec
|
|
|
37
37
|
// one port, and a project takes the first free port when it opens: the cards came back whenever it
|
|
38
38
|
// got another one, and the project that got the old port inherited them (2026-10-19).)
|
|
39
39
|
export const HINTS = ['switch', 'links', 'key4',
|
|
40
|
-
'home-links', 'home-map', 'home-settings', 'home-add', 'new-add-widgets',
|
|
40
|
+
'home-links', 'home-map', 'home-settings', 'home-add', 'new-add-widgets', 'home-widgets',
|
|
41
41
|
'w-system', 'w-servers', 'w-memory', 'w-coordinator', 'w-models', 'w-usage', 'w-agenda',
|
|
42
42
|
// The author's own widgets (2026-10-30): their first-time card came back on every start, never kept.
|
|
43
43
|
'w-errors', 'w-live', 'w-installs', 'w-environments', 'w-rumbo',
|
|
@@ -71,9 +71,16 @@ const BEFORE = ['1.0'];
|
|
|
71
71
|
// greeting and the memory into the local AI; «what it is for» comes in, and is kept as `profile`, so
|
|
72
72
|
// the examples MADRE gives are this person's and not a programmer's.
|
|
73
73
|
export const WELCOME_STEPS = ['hello', 'use', 'agents', 'project', 'ai', 'ready'];
|
|
74
|
-
export const WELCOME_PROFILES = ['business', 'numbers', '
|
|
74
|
+
export const WELCOME_PROFILES = ['business', 'social', 'numbers', 'office', 'study', 'notes', 'code', 'curious'];
|
|
75
75
|
const freshWelcome = () => ({ at: null, done: [], skipped: [], finished: null, profile: [] });
|
|
76
|
-
|
|
76
|
+
// THE FIRST WEEK'S MISSIONS (2026-11-11, the author: «missions instead of a tour»): five things to do,
|
|
77
|
+
// each with a result the person sees, each teaching a piece of MADRE on the way. Kept here with the
|
|
78
|
+
// tour, one person's, whichever project or port a mission was done in: the day it was done, or
|
|
79
|
+
// nothing. `missionsHidden` is the person putting them away.
|
|
80
|
+
// The fifth was «install a skill» until the author tried it with none left to install (2026-11-11):
|
|
81
|
+
// now it is anything got from the Market — a module, a skill, a connector.
|
|
82
|
+
export const MISSIONS = ['page', 'two-ais', 'undo', 'local-ai', 'market'];
|
|
83
|
+
const fresh = (before = null) => ({ version: TOUR_VERSION, path: null, bonjourAt: null, done: [], at: null, closed: false, finished: null, hints: {}, held: null, before, met: null, welcome: freshWelcome(), missions: {}, missionsHidden: null });
|
|
77
84
|
// A tab that shows the bonjour or the chapters says so every few seconds; another tab that finds it
|
|
78
85
|
// said within this long tells the person it is open there, instead of a second bonjour.
|
|
79
86
|
export const HELD_MS = 45 * 1000;
|
|
@@ -108,6 +115,8 @@ export async function readTour(stateRoot) {
|
|
|
108
115
|
finished: iso(raw.welcome?.finished),
|
|
109
116
|
profile: Array.isArray(raw.welcome?.profile) ? WELCOME_PROFILES.filter((id) => raw.welcome.profile.includes(id)) : [],
|
|
110
117
|
},
|
|
118
|
+
missions: Object.fromEntries(MISSIONS.filter((id) => iso(raw.missions?.[id])).map((id) => [id, raw.missions[id]])),
|
|
119
|
+
missionsHidden: iso(raw.missionsHidden),
|
|
111
120
|
};
|
|
112
121
|
}
|
|
113
122
|
|
|
@@ -157,6 +166,12 @@ async function applyChange(stateRoot, change, now) {
|
|
|
157
166
|
}
|
|
158
167
|
// The welcome: where the person is, a step done or left for later (one undoes the other), done
|
|
159
168
|
// with it, or from the start again (Settings › «See the welcome again»).
|
|
169
|
+
// A mission done (the first time counts), or all of them put away or back.
|
|
170
|
+
if (change.mission !== undefined) {
|
|
171
|
+
if (!MISSIONS.includes(change.mission)) return { error: 'mission' };
|
|
172
|
+
state.missions[change.mission] ??= at;
|
|
173
|
+
}
|
|
174
|
+
if (change.missionsHidden !== undefined) state.missionsHidden = change.missionsHidden === true ? at : null;
|
|
160
175
|
if (change.welcome !== undefined) {
|
|
161
176
|
const said = change.welcome;
|
|
162
177
|
if (!said || typeof said !== 'object') return { error: 'welcome' };
|
package/src/updates.mjs
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// MADRE never updates itself: the room is in use and the process belongs to the human. It
|
|
7
7
|
// shows the exact command for how this copy was launched.
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { constants, realpathSync } from 'node:fs';
|
|
10
|
+
import { access, readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
10
11
|
import { dirname } from 'node:path';
|
|
11
12
|
|
|
12
13
|
export const REGISTRY = 'https://registry.npmjs.org';
|
|
@@ -43,9 +44,15 @@ export function compareVersions(a, b) {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
// How this copy runs, from the path of the script Node started: npx cache, the project's own
|
|
46
|
-
// node_modules, a global install, or the source tree.
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
// node_modules, a global install, or the source tree. Or inside MADRE.app (Tauri), which
|
|
48
|
+
// says so and updates itself from madre.run: never by npm or git from here.
|
|
49
|
+
export function detectInstall({ script = process.argv[1] ?? '', projectRoot = process.cwd(), env = process.env } = {}) {
|
|
50
|
+
if (env.MADRE_APP === '1') return 'app';
|
|
51
|
+
// Followed to where it leads (Q-22): npm -g leaves `madre` as a link in a bin folder, and Node
|
|
52
|
+
// keeps that path; read as written, a global copy looked like one run from source.
|
|
53
|
+
let real = String(script);
|
|
54
|
+
try { real = realpathSync(real); } catch { /* read as written */ }
|
|
55
|
+
const path = real.replace(/\\/g, '/');
|
|
49
56
|
if (/\/_npx\//.test(path)) return 'npx';
|
|
50
57
|
if (projectRoot && path.startsWith(`${String(projectRoot).replace(/\\/g, '/').replace(/\/$/, '')}/node_modules/`)) return 'project';
|
|
51
58
|
if (/\/node_modules\//.test(path)) return 'global';
|
|
@@ -64,6 +71,7 @@ export function updateCommand(install, name, version = 'latest') {
|
|
|
64
71
|
case 'npx': return `npx ${name}@${version} start`;
|
|
65
72
|
case 'project': return `npm install ${name}@${version}`;
|
|
66
73
|
case 'global': return `npm install -g ${name}@${version}`;
|
|
74
|
+
case 'app': return null;
|
|
67
75
|
default: return 'git pull';
|
|
68
76
|
}
|
|
69
77
|
}
|
|
@@ -93,6 +101,41 @@ export function applyCommand({ install, name, version, port, projectRoot }) {
|
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
103
|
|
|
104
|
+
// Whether npm -g can put the new version where this one is (Q-22, 2026-11-10): a copy installed with
|
|
105
|
+
// sudo lives in a folder of root's, and `npm install -g` without sudo failed there after MADRE had
|
|
106
|
+
// already closed. Asked before closing anything.
|
|
107
|
+
export async function canReplace(packageRoot) {
|
|
108
|
+
try { await access(dirname(packageRoot), constants.W_OK); return true; } catch { return false; }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// TAKING ITS OWN PLACE (Q-23, 2026-11-10). Restarting or updating used to start a new MADRE and end
|
|
112
|
+
// this process. Whoever waits on this process saw MADRE end: the terminal gave its prompt back, and
|
|
113
|
+
// in WSL the Windows shortcut's wsl.exe ended with it, after which WSL put the distribution away
|
|
114
|
+
// (~15 s), with the new MADRE — and a half-done npm install — inside. On Linux the new one now takes
|
|
115
|
+
// this process's place (process.execve, Node 22.15 and later), with the same PID; elsewhere, or on
|
|
116
|
+
// an older Node, as before.
|
|
117
|
+
export const takesItsPlace = ({ platform, execve } = { platform: process.platform, execve: process.execve }) => platform === 'linux' && typeof execve === 'function';
|
|
118
|
+
|
|
119
|
+
// What takes its place: `file args…`, as is when a terminal shows what MADRE says (the new address
|
|
120
|
+
// with its ficha too), else through /bin/sh with everything it says going to `log`, the witness a
|
|
121
|
+
// restart or an update always had (restart.log, update.log). Returns [program, argv] for execve.
|
|
122
|
+
export function nextProcess({ file, args = [], log = null, terminal = false }) {
|
|
123
|
+
if (terminal || !log) return [file, [file, ...args]];
|
|
124
|
+
return ['/bin/sh', ['/bin/sh', '-c', 'exec >>"$1" 2>&1; shift; exec "$@"', 'madre', log, file, ...args]];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Q-21 (2026-11-10): MADRE before 1.1.3 had no ficha, so a tab open on it has no cookie, and the start
|
|
128
|
+
// an update makes (PULSE_UPDATE_RESTART, without the browser) left that tab on «This tab needs to be
|
|
129
|
+
// opened from MADRE» with nobody to give it the address. The start that comes from an update and
|
|
130
|
+
// finds no ficha on file opens the browser at the address that carries it.
|
|
131
|
+
export const opensBrowser = ({ asked = false, env = process.env, hadFicha = true } = {}) => Boolean(asked) || (env.PULSE_UPDATE_RESTART === '1' && !hadFicha);
|
|
132
|
+
|
|
133
|
+
// L-13 (Carlos's server, 2026-11-10): an update restarted only the room it was pressed in, and Home
|
|
134
|
+
// and the other projects stayed on the older MADRE. The rooms an update still has to bring to this
|
|
135
|
+
// version: every other open one that says an older version, or none (a mark written before rooms
|
|
136
|
+
// said theirs).
|
|
137
|
+
export const roomsBehind = (rooms, { here, version }) => rooms.filter((one) => one.open && one.id !== here && (!isVersion(one.open.version) || compareVersions(one.open.version, version) < 0));
|
|
138
|
+
|
|
96
139
|
// Where a person reads what a version brought. The product's own house, in the language the room
|
|
97
140
|
// is speaking — a release page on a code host is written for people who already work there, and
|
|
98
141
|
// whoever pressed this button only wanted to know what changed. The repository stays the fallback
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
// MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
|
|
3
|
+
// The picture and the title of a link an agent gave, asked for by the person (2026-11-14).
|
|
4
|
+
//
|
|
5
|
+
// An answer that lists apartments, products or articles reads better as cards: a photo, a title and
|
|
6
|
+
// the site it is on. The photo lives on that site, and fetching it tells that site that someone
|
|
7
|
+
// looked; so nothing is fetched while an answer is drawn. The person presses «Show photos», and only
|
|
8
|
+
// then does MADRE ask each page for its preview (og:image, og:title, og:site_name) and the picture
|
|
9
|
+
// itself, which travels back to the page as a data: address — the page's own rules forbid pictures
|
|
10
|
+
// from anywhere else, and that stays so.
|
|
11
|
+
//
|
|
12
|
+
// Two locks. Only http and https, and never an address on this computer or its network: a link
|
|
13
|
+
// in an answer must not become a way to read the router's page or a port on the Mac. And what comes
|
|
14
|
+
// back is bounded: so much of a page, so big a picture, so long a wait.
|
|
15
|
+
|
|
16
|
+
import { lookup } from 'node:dns/promises';
|
|
17
|
+
import { isIP } from 'node:net';
|
|
18
|
+
|
|
19
|
+
const PAGE_BYTES = 768 * 1024;
|
|
20
|
+
const IMAGE_BYTES = 4 * 1024 * 1024;
|
|
21
|
+
const WAIT_MS = 9000;
|
|
22
|
+
const HOPS = 4;
|
|
23
|
+
const IMAGE_TYPES = /^image\/(png|jpe?g|gif|webp|avif)\b/i;
|
|
24
|
+
// A browser's way of asking: many sites answer a plain script with an error page.
|
|
25
|
+
const HEADERS = {
|
|
26
|
+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15',
|
|
27
|
+
accept: 'text/html,application/xhtml+xml,image/avif,image/webp,image/*;q=0.9,*/*;q=0.8',
|
|
28
|
+
'accept-language': 'es-MX,es;q=0.9,en;q=0.8',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// The addresses asked for by a person's press, so the log of what left the Mac names them as
|
|
32
|
+
// that and not as an address nobody declared (outbound.mjs, «web-page»). Held a minute.
|
|
33
|
+
const asked = new Map();
|
|
34
|
+
export function askedByPerson(rawUrl) {
|
|
35
|
+
try {
|
|
36
|
+
const href = new URL(rawUrl).href;
|
|
37
|
+
const until = asked.get(href);
|
|
38
|
+
if (!until) return false;
|
|
39
|
+
if (until < Date.now()) { asked.delete(href); return false; }
|
|
40
|
+
return true;
|
|
41
|
+
} catch { return false; }
|
|
42
|
+
}
|
|
43
|
+
function markAsked(href) {
|
|
44
|
+
asked.set(href, Date.now() + 60_000);
|
|
45
|
+
if (asked.size > 400) for (const [key, until] of asked) if (until < Date.now()) asked.delete(key);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// This computer and its network, in both families.
|
|
49
|
+
export function privateAddress(address) {
|
|
50
|
+
const ip = String(address ?? '').replace(/^\[|\]$/g, '').toLowerCase();
|
|
51
|
+
const v4 = ip.startsWith('::ffff:') ? ip.slice(7) : ip;
|
|
52
|
+
if (isIP(v4) === 4) {
|
|
53
|
+
const [a, b] = v4.split('.').map(Number);
|
|
54
|
+
return a === 0 || a === 10 || a === 127 || (a === 100 && b >= 64 && b <= 127) || (a === 169 && b === 254)
|
|
55
|
+
|| (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 198 && (b === 18 || b === 19)) || a >= 224;
|
|
56
|
+
}
|
|
57
|
+
if (isIP(ip) === 6) return ip === '::' || ip === '::1' || /^f[cd]/.test(ip) || /^fe[89ab]/.test(ip) || ip.startsWith('ff');
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function publicUrl(raw, resolve = lookup) {
|
|
62
|
+
let url;
|
|
63
|
+
try { url = new URL(raw); } catch { return { error: 'bad-url' }; }
|
|
64
|
+
if (!/^https?:$/.test(url.protocol) || url.username || url.password) return { error: 'bad-url' };
|
|
65
|
+
const host = url.hostname.replace(/^\[|\]$/g, '');
|
|
66
|
+
if (!host || /(^|\.)(localhost|local|internal|home|lan)$/i.test(host)) return { error: 'private' };
|
|
67
|
+
const addresses = isIP(host) ? [{ address: host }] : await resolve(host, { all: true }).catch(() => []);
|
|
68
|
+
if (!addresses.length) return { error: 'unreachable' };
|
|
69
|
+
if (addresses.some((one) => privateAddress(one.address))) return { error: 'private' };
|
|
70
|
+
return { url };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// One request, following redirects by hand so every hop passes the same lock.
|
|
74
|
+
async function fetchPublic(raw, { fetchImpl, resolve }) {
|
|
75
|
+
let next = raw;
|
|
76
|
+
for (let hop = 0; hop <= HOPS; hop += 1) {
|
|
77
|
+
const checked = await publicUrl(next, resolve);
|
|
78
|
+
if (checked.error) return checked;
|
|
79
|
+
markAsked(checked.url.href);
|
|
80
|
+
const response = await fetchImpl(checked.url.href, { headers: HEADERS, redirect: 'manual', signal: AbortSignal.timeout(WAIT_MS) });
|
|
81
|
+
if (response.status >= 300 && response.status < 400 && response.headers.get('location')) {
|
|
82
|
+
next = new URL(response.headers.get('location'), checked.url).href;
|
|
83
|
+
await response.body?.cancel?.().catch(() => {});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
return { response, url: checked.url };
|
|
87
|
+
}
|
|
88
|
+
return { error: 'redirects' };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function readCapped(response, cap) {
|
|
92
|
+
const declared = Number(response.headers.get('content-length'));
|
|
93
|
+
if (Number.isFinite(declared) && declared > cap) { await response.body?.cancel?.().catch(() => {}); return null; }
|
|
94
|
+
const reader = response.body?.getReader?.();
|
|
95
|
+
if (!reader) return Buffer.from(await response.arrayBuffer()).subarray(0, cap);
|
|
96
|
+
const chunks = [];
|
|
97
|
+
let size = 0;
|
|
98
|
+
for (;;) {
|
|
99
|
+
const { done, value } = await reader.read();
|
|
100
|
+
if (done) break;
|
|
101
|
+
size += value.byteLength;
|
|
102
|
+
if (size > cap) { await reader.cancel().catch(() => {}); return chunks.length ? Buffer.concat(chunks) : null; }
|
|
103
|
+
chunks.push(Buffer.from(value));
|
|
104
|
+
}
|
|
105
|
+
return Buffer.concat(chunks);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };
|
|
109
|
+
function decode(text) {
|
|
110
|
+
return String(text ?? '')
|
|
111
|
+
.replace(/&#x([0-9a-f]+);/gi, (_, hex) => String.fromCodePoint(Number.parseInt(hex, 16)))
|
|
112
|
+
.replace(/&#(\d+);/g, (_, dec) => String.fromCodePoint(Number(dec)))
|
|
113
|
+
.replace(/&([a-z]+);/gi, (whole, name) => ENTITIES[name.toLowerCase()] ?? whole)
|
|
114
|
+
.replace(/\s+/g, ' ')
|
|
115
|
+
.trim();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// What a page says about itself in its head: the preview tags, then its title.
|
|
119
|
+
export function readPreview(html, base) {
|
|
120
|
+
const head = String(html ?? '').slice(0, PAGE_BYTES);
|
|
121
|
+
const meta = new Map();
|
|
122
|
+
for (const [tag] of head.matchAll(/<meta\b[^>]*>/gi)) {
|
|
123
|
+
const key = tag.match(/\b(?:property|name)\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase();
|
|
124
|
+
const value = tag.match(/\bcontent\s*=\s*["']([^"']*)["']/i)?.[1];
|
|
125
|
+
if (key && value !== undefined && !meta.has(key)) meta.set(key, decode(value));
|
|
126
|
+
}
|
|
127
|
+
const title = meta.get('og:title') || meta.get('twitter:title') || decode(head.match(/<title[^>]*>([\s\S]*?)<\/title>/i)?.[1]);
|
|
128
|
+
let image = meta.get('og:image:secure_url') || meta.get('og:image') || meta.get('og:image:url') || meta.get('twitter:image') || meta.get('twitter:image:src') || null;
|
|
129
|
+
try { image = image ? new URL(image, base).href : null; } catch { image = null; }
|
|
130
|
+
return {
|
|
131
|
+
title: title ? title.slice(0, 200) : null,
|
|
132
|
+
site: (meta.get('og:site_name') || '').slice(0, 80) || null,
|
|
133
|
+
description: (meta.get('og:description') || meta.get('description') || '').slice(0, 300) || null,
|
|
134
|
+
image,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function imageData(raw, options) {
|
|
139
|
+
const got = await fetchPublic(raw, options);
|
|
140
|
+
if (got.error || !got.response.ok) { await got.response?.body?.cancel?.().catch(() => {}); return null; }
|
|
141
|
+
const type = got.response.headers.get('content-type') ?? '';
|
|
142
|
+
if (!IMAGE_TYPES.test(type)) { await got.response.body?.cancel?.().catch(() => {}); return null; }
|
|
143
|
+
const bytes = await readCapped(got.response, IMAGE_BYTES);
|
|
144
|
+
return bytes?.length ? `data:${type.split(';')[0].trim().toLowerCase()};base64,${bytes.toString('base64')}` : null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const cache = new Map();
|
|
148
|
+
// The preview of one link: its picture as a data: address, its title and its site. A link that is
|
|
149
|
+
// itself a picture comes back as one. Never throws: a page that does not answer is a card without
|
|
150
|
+
// a photo, said so.
|
|
151
|
+
export async function webPreview(raw, { fetchImpl = globalThis.fetch, resolve = lookup } = {}) {
|
|
152
|
+
const key = String(raw ?? '');
|
|
153
|
+
if (cache.has(key)) return cache.get(key);
|
|
154
|
+
const options = { fetchImpl, resolve };
|
|
155
|
+
let result;
|
|
156
|
+
try {
|
|
157
|
+
const got = await fetchPublic(key, options);
|
|
158
|
+
if (got.error) result = { ok: false, error: got.error };
|
|
159
|
+
else if (!got.response.ok) { await got.response.body?.cancel?.().catch(() => {}); result = { ok: false, error: 'refused', status: got.response.status }; }
|
|
160
|
+
else {
|
|
161
|
+
const type = got.response.headers.get('content-type') ?? '';
|
|
162
|
+
if (IMAGE_TYPES.test(type)) {
|
|
163
|
+
const bytes = await readCapped(got.response, IMAGE_BYTES);
|
|
164
|
+
result = bytes?.length ? { ok: true, image: `data:${type.split(';')[0].trim().toLowerCase()};base64,${bytes.toString('base64')}`, title: null, site: null } : { ok: false, error: 'too-big' };
|
|
165
|
+
} else if (/html|xml/i.test(type)) {
|
|
166
|
+
const page = await readCapped(got.response, PAGE_BYTES);
|
|
167
|
+
const preview = readPreview(page?.toString('utf8') ?? '', got.url);
|
|
168
|
+
const image = preview.image ? await imageData(preview.image, options).catch(() => null) : null;
|
|
169
|
+
result = { ok: true, title: preview.title, site: preview.site, description: preview.description, image };
|
|
170
|
+
} else { await got.response.body?.cancel?.().catch(() => {}); result = { ok: false, error: 'not-a-page' }; }
|
|
171
|
+
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
result = { ok: false, error: error?.name === 'TimeoutError' ? 'slow' : 'unreachable' };
|
|
174
|
+
}
|
|
175
|
+
// A page that did not answer may answer the next press; only what came back is kept.
|
|
176
|
+
if (result.ok) {
|
|
177
|
+
cache.set(key, result);
|
|
178
|
+
if (cache.size > 300) cache.delete(cache.keys().next().value);
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
package/src/whats-new.mjs
CHANGED
|
@@ -31,6 +31,67 @@ const FILE = 'whats-new.json';
|
|
|
31
31
|
export const NEWS_ACTIONS = ['settings', 'errors', 'mother', 'intents', 'permissions', 'github', 'bar', 'modules', 'nostromo', 'room', 'looks', 'finder'];
|
|
32
32
|
|
|
33
33
|
export const NOTES = {
|
|
34
|
+
// 1.1.4 (2026-11-13, the first beta of the app): said to whoever comes from 1.1.3 — MADRE is an app
|
|
35
|
+
// now, and two things that change how an answer is read and how MADRE is learned. Whoever already
|
|
36
|
+
// reads it inside the app (`inApp`, and `introApp`) is told what the app gives them instead of being
|
|
37
|
+
// asked to get it. After the board, in the browser, Home asks whether to stay or download the app
|
|
38
|
+
// (salas-mac.js, offerApp).
|
|
39
|
+
'1.1.4': {
|
|
40
|
+
title: { es: 'MADRE ya es una app', en: 'MADRE is an app now' },
|
|
41
|
+
intro: {
|
|
42
|
+
es: 'Desde hoy MADRE se abre como cualquier app de tu computadora. Y trae dos cosas nuevas para que trabajes con tus IAs sin perderte.',
|
|
43
|
+
en: 'From today MADRE opens like any other app on your computer. And it brings two new things so you can work with your AIs without getting lost.',
|
|
44
|
+
},
|
|
45
|
+
introApp: {
|
|
46
|
+
es: 'Ya la abres como cualquier app de tu computadora. Y trae dos cosas nuevas para que trabajes con tus IAs sin perderte.',
|
|
47
|
+
en: 'You now open it like any other app on your computer. And it brings two new things so you can work with your AIs without getting lost.',
|
|
48
|
+
},
|
|
49
|
+
items: [
|
|
50
|
+
{
|
|
51
|
+
id: 'app',
|
|
52
|
+
icon: 'home',
|
|
53
|
+
scene: 'desktopapp',
|
|
54
|
+
title: { es: 'Ábrela como cualquier app', en: 'Open it like any other app' },
|
|
55
|
+
body: {
|
|
56
|
+
es: 'Sin terminal ni pestañas: la app se abre desde tus aplicaciones, te avisa cuando una IA termina y trae su propio navegador y su terminal. Así aprovechas mejor lo que MADRE puede hacer en tu sistema, y tus proyectos llegan tal como están.',
|
|
57
|
+
en: 'No terminal, no tabs: the app opens from your applications, tells you when an AI finishes and brings its own browser and terminal. That way you get more out of what MADRE can do on your system, and your projects come along as they are.',
|
|
58
|
+
},
|
|
59
|
+
inApp: {
|
|
60
|
+
title: { es: 'Ya estás en la app', en: 'You are in the app' },
|
|
61
|
+
body: {
|
|
62
|
+
es: 'La abres desde tus aplicaciones, sin terminal. Te avisa cuando una IA termina, trae su propio navegador y su terminal, y te dice cuando hay una versión nueva.',
|
|
63
|
+
en: 'You open it from your applications, with no terminal. It tells you when an AI finishes, brings its own browser and terminal, and tells you when there is a new version.',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
where: { es: 'madre.run/app', en: 'madre.run/app' },
|
|
67
|
+
action: null,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: 'changes',
|
|
71
|
+
icon: 'list',
|
|
72
|
+
scene: 'changes',
|
|
73
|
+
title: { es: 'Ves qué cambió en cada respuesta', en: 'You see what changed in every answer' },
|
|
74
|
+
body: {
|
|
75
|
+
es: 'Bajo cada respuesta que toca tu proyecto, una tarjeta te dice en palabras simples qué cambió, con «Ver» y «Deshacer». Y lo que una IA crea, una página, una imagen o un PDF, se abre solo al lado.',
|
|
76
|
+
en: 'Under every answer that touches your project, a card tells you in plain words what changed, with «View» and «Undo». And what an AI makes, a page, an image or a PDF, opens by itself beside it.',
|
|
77
|
+
},
|
|
78
|
+
where: { es: 'En cada respuesta', en: 'Under every answer' },
|
|
79
|
+
action: null,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: 'steps',
|
|
83
|
+
icon: 'check',
|
|
84
|
+
scene: 'missions',
|
|
85
|
+
title: { es: 'Aprende haciendo', en: 'Learn by doing' },
|
|
86
|
+
body: {
|
|
87
|
+
es: 'Primeros pasos te propone cinco cosas cortas, como crear tu primera página o preguntarle lo mismo a dos IAs. Cada una toma un par de minutos y te enseña algo de verdad.',
|
|
88
|
+
en: 'First steps offers you five short things, like making your first page or asking two AIs the same question. Each takes a couple of minutes and teaches you something real.',
|
|
89
|
+
},
|
|
90
|
+
where: { es: 'Primeros pasos, en la barra de arriba', en: 'First steps, in the top bar' },
|
|
91
|
+
action: null,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
34
95
|
// 1.1.3 (borrador del 2026-11-08, por aprobar): said as a person would to someone who comes back,
|
|
35
96
|
// with the three things that change their day, each with its own moving picture (`scene`, drawn by
|
|
36
97
|
// public/welcome-scene.js) instead of a screenshot.
|
|
@@ -59,10 +120,10 @@ export const NOTES = {
|
|
|
59
120
|
scene: 'newagent',
|
|
60
121
|
title: { es: 'Grok, ahora entre tus IAs', en: 'Grok, now among your AIs' },
|
|
61
122
|
body: {
|
|
62
|
-
es: 'Si pagas SuperGrok, ya lo usas en tus proyectos: se conecta desde Ajustes ›
|
|
63
|
-
en: 'If you pay for SuperGrok, you can now use it in your projects: it connects from Settings ›
|
|
123
|
+
es: 'Si pagas SuperGrok, ya lo usas en tus proyectos: se conecta desde Ajustes › Tus IAs con tu cuenta, y lee, escribe, busca en internet y hace imágenes.',
|
|
124
|
+
en: 'If you pay for SuperGrok, you can now use it in your projects: it connects from Settings › Your AIs with your account, and it reads, writes, looks things up on the internet and makes images.',
|
|
64
125
|
},
|
|
65
|
-
where: { es: 'Ajustes ›
|
|
126
|
+
where: { es: 'Ajustes › Tus IAs', en: 'Settings › Your AIs' },
|
|
66
127
|
action: 'settings',
|
|
67
128
|
},
|
|
68
129
|
{
|
|
@@ -398,6 +459,17 @@ export const NOTES = {
|
|
|
398
459
|
};
|
|
399
460
|
|
|
400
461
|
export const notesFor = (version) => NOTES[version] ?? null;
|
|
462
|
+
// The notes as read inside the desktop app (1.1.4): its own intro and, for an item that has them, its
|
|
463
|
+
// own words; read anywhere else, those are left out.
|
|
464
|
+
export function notesWhere(notes, app = false) {
|
|
465
|
+
if (!notes || (!notes.introApp && !(notes.items ?? []).some((item) => item.inApp))) return notes;
|
|
466
|
+
const { introApp, ...rest } = notes;
|
|
467
|
+
return {
|
|
468
|
+
...rest,
|
|
469
|
+
intro: app && introApp ? introApp : rest.intro,
|
|
470
|
+
items: (rest.items ?? []).map(({ inApp, ...item }) => (app && inApp ? { ...item, ...inApp } : item)),
|
|
471
|
+
};
|
|
472
|
+
}
|
|
401
473
|
// The newest version that has a sheet: what a preview opens on a copy whose own version has none.
|
|
402
474
|
export const newestNotes = () => Object.keys(NOTES).sort(compareVersions).at(-1) ?? null;
|
|
403
475
|
|
|
@@ -463,5 +535,5 @@ export const INVITE_ANSWERS = ['shown', 'picked', 'sample', 'later'];
|
|
|
463
535
|
export async function whatsNew({ root, version, returning, any = false }) {
|
|
464
536
|
const seen = await readSeen(root);
|
|
465
537
|
const show = shouldShow({ version, seen, returning });
|
|
466
|
-
return { version, show, notes: show || any ? notesFor(version) : null };
|
|
538
|
+
return { version, show, notes: show || any ? notesWhere(notesFor(version), process.env.MADRE_APP === '1') : null };
|
|
467
539
|
}
|