@jossuealcala/madre 1.1.0 → 1.1.2
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 +37 -1
- package/CHANGELOG.md +37 -1
- package/README.en.md +2 -6
- package/README.md +2 -6
- package/bin/madre.mjs +21 -22
- package/docs/REFERENCE.md +2 -1
- package/docs/en/REFERENCE.md +2 -1
- package/package.json +1 -1
- package/public/app.js +11 -5
- package/public/en.js +1 -1
- package/public/es.js +154 -12
- package/public/macroverso.js +4 -1
- package/public/manual-content.js +24 -20
- package/public/market.js +13 -2
- package/public/page-errors.js +2 -0
- package/public/salas-mac.css +69 -0
- package/public/salas-mac.js +313 -3
- package/public/troubleshooting.js +20 -4
- package/public/welcome.js +40 -12
- package/src/dataset.mjs +4 -2
- package/src/embeddings.mjs +2 -2
- package/src/file-ops.mjs +9 -3
- package/src/github.mjs +5 -3
- package/src/market-remote.mjs +35 -2
- package/src/mcp/memory-server.mjs +12 -3
- package/src/mcp/proxy.mjs +31 -8
- package/src/memory-tools.mjs +9 -2
- package/src/memory.mjs +16 -0
- package/src/modules/check-alone.mjs +25 -0
- package/src/modules/index.mjs +41 -7
- package/src/modules/ollama.mjs +14 -8
- package/src/mother.mjs +6 -1
- package/src/outbound.mjs +11 -3
- package/src/room/archivist.mjs +7 -1
- package/src/room/context.mjs +6 -3
- package/src/room/copilot.mjs +22 -28
- package/src/room.mjs +4 -4
- package/src/rumbo.mjs +337 -0
- package/src/salas.mjs +103 -1
- package/src/sentinel-errors.mjs +4 -1
- package/src/server.mjs +135 -20
- package/src/setup-trouble.mjs +2 -0
- package/src/tour.mjs +2 -2
- package/src/whats-new.mjs +23 -0
package/src/server.mjs
CHANGED
|
@@ -82,9 +82,9 @@ import { applyConfigToEnv, loadConfig as readConfig, updateConfig } from './conf
|
|
|
82
82
|
import { Privacy, normalizeTerms, privacySettings } from './privacy.mjs';
|
|
83
83
|
import { planView, removeMadre, uninstallPlan } from './uninstall.mjs';
|
|
84
84
|
import { checkForUpdate, detectInstall, updateCommand, releaseUrl, applyCommand, fetchCommand } from './updates.mjs';
|
|
85
|
-
import { bootWhatsNew, markSeen, newestNotes, notesFor, whatsNew } from './whats-new.mjs';
|
|
85
|
+
import { INVITE_ANSWERS, bootWhatsNew, cameFromOlder, invitedFor, markInvited, markSeen, newestNotes, notesFor, whatsNew } from './whats-new.mjs';
|
|
86
86
|
import { answerAsk, tickAsk } from './review-ask.mjs';
|
|
87
|
-
import { CHAPTERS, HINTS, NEWS_LEVEL, TOUR_VERSION, cameBefore, changeTour, readTour, recoverProject, roomsWithoutProject } from './tour.mjs';
|
|
87
|
+
import { CHAPTERS, HINTS, NEWS_LEVEL, TOUR_VERSION, WELCOME_STEPS, cameBefore, changeTour, readTour, recoverProject, roomsWithoutProject } from './tour.mjs';
|
|
88
88
|
|
|
89
89
|
// Where a person reads the module contract, in the language the room is speaking.
|
|
90
90
|
const SDK_PAGE = { es: 'https://madre.run/sdk/', en: 'https://madre.run/en/sdk/' };
|
|
@@ -134,9 +134,10 @@ import { forgetFromMarket, installFromMarket, installedFromMarket, keptCatalog,
|
|
|
134
134
|
const NOT_BY_PROJECT = new Set(['bishop', 'git-pulse', 'ollama']);
|
|
135
135
|
import { heartbeat, installId } from './heartbeat.mjs';
|
|
136
136
|
import { PRESENCE_EVERY_MS, environmentGauges, noteLifecycle, sayPresent } from './install-metrics.mjs';
|
|
137
|
+
import { keepHistory, readGithub, readHistory, readNpm, rumboModel } from './rumbo.mjs';
|
|
137
138
|
import { TERMS_LINKS, acceptTerms, cameFromBefore, readTerms } from './terms.mjs';
|
|
138
139
|
import { activateLicense, licensedIds, releaseLicense } from './market-license.mjs';
|
|
139
|
-
import { askRoom, associateProject, createProject, defaultProjectsFolder, ensureSalasProject, forgetProject, isSalasRoom, knownRooms, listFolders, markProject, projectRoomId, roomComesUp, salasRoomId, startRoom, suggestProjects, universeOf } from './salas.mjs';
|
|
140
|
+
import { askRoom, associateProject, createProject, createSampleProject, defaultProjectsFolder, ensureSalasProject, forgetProject, isSalasRoom, knownRooms, listFolders, markProject, projectRoomId, roomComesUp, salasRoomId, startRoom, suggestProjects, universeOf } from './salas.mjs';
|
|
140
141
|
import { parseWork, recentWork, WORK_SYSTEM, workPrompt } from './lobby-work.mjs';
|
|
141
142
|
import { CHANNEL_HEADER, CORPUS_MAX, CORPUS_PER_HOUR, DELIVER_MAX, MAX_LIMIT as ENLACE_MAX_LIMIT, NO_SUCH_LINK, NOTICES as ENLACE_NOTICES, activeContracts, allowContract, askCorpus, askEnlace, askState, channelKey, countRecent, decideDelivery, deliverable, deliverNotes, deliversTo, linkTraffic, mayServe, noteCrossing, noticeEnlace, readInbox, readsFrom, recallContract, receiveDelivery, revokeContract, sameKey, servingRooms, signContract, trainContract } from './enlaces.mjs';
|
|
142
143
|
import { readContinuity } from './modules/ahp.mjs';
|
|
@@ -153,7 +154,11 @@ const publicDirectory = join(sourceDirectory, '..', 'public');
|
|
|
153
154
|
// a client does not take gzip.
|
|
154
155
|
const assetCache = new Map();
|
|
155
156
|
async function sendAsset(request, response, file, type) {
|
|
156
|
-
|
|
157
|
+
// Its callers `return sendAsset(…)` without awaiting it, which is outside the handler's try: a file
|
|
158
|
+
// that is not there was an unhandled rejection and a request that never got an answer
|
|
159
|
+
// (diagnostics of 1.1.1, «stat … ENOENT» from sendAsset). It is a 404.
|
|
160
|
+
const info = await stat(file).catch(() => null);
|
|
161
|
+
if (!info?.isFile()) { response.writeHead(404, { 'content-type': 'text/plain; charset=utf-8' }); return response.end('Not found.'); }
|
|
157
162
|
const tag = `W/"${info.size.toString(36)}-${Math.floor(info.mtimeMs).toString(36)}"`;
|
|
158
163
|
const headers = { 'content-type': type, 'cache-control': 'no-cache', etag: tag, vary: 'accept-encoding' };
|
|
159
164
|
if (request.headers['if-none-match'] === tag) { response.writeHead(304, headers); return response.end(); }
|
|
@@ -532,6 +537,9 @@ export async function createPulseServer({
|
|
|
532
537
|
const widgetReadings = new Map();
|
|
533
538
|
// This copy's identifier once left out of the author's usage figures (the usage widget, below).
|
|
534
539
|
const usageExcluded = new Set();
|
|
540
|
+
// The three sources of the author's course (kind «rumbo», below), each with its last good reading.
|
|
541
|
+
const rumboSources = new Map();
|
|
542
|
+
let rumboStatus = 0;
|
|
535
543
|
let cpuSeen = null;
|
|
536
544
|
const cpuTimes = () => cpus().reduce((sum, one) => {
|
|
537
545
|
const times = one.times;
|
|
@@ -639,6 +647,34 @@ export async function createPulseServer({
|
|
|
639
647
|
reading = body?.ok ? { available: true, ...body } : { available: false, status: answer?.status ?? 0 };
|
|
640
648
|
widgetReadings.set('metrics', { at: Date.now(), reading });
|
|
641
649
|
return reading;
|
|
650
|
+
} else if (kind === 'rumbo') {
|
|
651
|
+
// MADRE's course (src/rumbo.mjs, 2026-11-01): the author's model of the variables that decide
|
|
652
|
+
// where the project goes, from madre.run's funnel, GitHub and npm. Each source keeps its own
|
|
653
|
+
// clock — the funnel a minute, GitHub ten (its visits move by the hour), npm thirty (by the
|
|
654
|
+
// day) — and a source that fails keeps its last good reading, said as old.
|
|
655
|
+
const token = FROM_SOURCE ? await readSecret(root, OWNER_VAULT, 'usage') : null;
|
|
656
|
+
if (!token) return null;
|
|
657
|
+
const source = async (name, ttl, read) => {
|
|
658
|
+
const kept = rumboSources.get(name);
|
|
659
|
+
if (kept && Date.now() - (kept.tried ?? kept.at) < ttl) return kept;
|
|
660
|
+
const value = await read().catch(() => null);
|
|
661
|
+
const next = value ? { at: Date.now(), value } : { ...(kept ?? { at: null, value: null }), tried: Date.now(), failed: true };
|
|
662
|
+
rumboSources.set(name, next);
|
|
663
|
+
return next;
|
|
664
|
+
};
|
|
665
|
+
const funnel = await source('madre', 60000, async () => {
|
|
666
|
+
const answer = await reportFetch(process.env.PULSE_RUMBO_URL ?? 'https://madre.run/api/rumbo', { headers: { authorization: `Bearer ${token}` }, signal: AbortSignal.timeout(10000) }).catch(() => null);
|
|
667
|
+
rumboStatus = answer?.status ?? 0;
|
|
668
|
+
const body = answer?.ok ? await answer.json().catch(() => null) : null;
|
|
669
|
+
return body?.ok ? body : null;
|
|
670
|
+
});
|
|
671
|
+
const github = await source('github', 600000, () => readGithub());
|
|
672
|
+
const npm = await source('npm', 1800000, () => readNpm({ name: PACKAGE.name ?? '@jossuealcala/madre', fetchImpl: reportFetch }));
|
|
673
|
+
const history = github.value && !github.failed && github.at > Date.now() - 1000 ? await keepHistory(root, github.value).catch(() => readHistory(root)) : await readHistory(root);
|
|
674
|
+
const said = (one) => ({ at: one.at ? new Date(one.at).toISOString() : null, failed: Boolean(one.failed) });
|
|
675
|
+
reading = funnel.value || github.value || npm.value
|
|
676
|
+
? { available: true, ...rumboModel({ madre: funnel.value, github: github.value, npm: npm.value, history }), sources: { madre: { ...said(funnel), status: rumboStatus }, github: said(github), npm: said(npm) } }
|
|
677
|
+
: { available: false, status: rumboStatus };
|
|
642
678
|
} else if (kind === 'coordinator' && !salasRoom) {
|
|
643
679
|
// Home's page is served by every project too: the Coordinator's record is its own room's.
|
|
644
680
|
const coordinator = (await knownRooms(root)).find((one) => one.id === salasRoomId(root));
|
|
@@ -1582,10 +1618,20 @@ export async function createPulseServer({
|
|
|
1582
1618
|
let unsubscribeModules = () => {};
|
|
1583
1619
|
// What the anonymous diagnostics count of a room (src/telemetry.mjs): which agent got a turn and at
|
|
1584
1620
|
// which mode, what ran, what failed to install. Names of MADRE's own parts and numbers, never words.
|
|
1621
|
+
// Whether this project was ever written to, in any of its chats: a mark in its room folder, set the
|
|
1622
|
+
// first time (or found true in the chat that opens, for a project from before the mark).
|
|
1623
|
+
const firstMark = join(roomDir, 'first-message');
|
|
1624
|
+
let firstSaid = await access(firstMark).then(() => true, () => false);
|
|
1625
|
+
if (!firstSaid && historicalEvents.some((one) => one.type === 'message.created' && one.payload?.role === 'user')) {
|
|
1626
|
+
firstSaid = true;
|
|
1627
|
+
await writeFile(firstMark, new Date().toISOString()).catch(() => {});
|
|
1628
|
+
}
|
|
1585
1629
|
function countForDiagnostics(event) {
|
|
1586
1630
|
const said = event?.payload ?? {};
|
|
1587
1631
|
if (event?.ghost) return;
|
|
1588
1632
|
if (event?.type === 'message.created' && said.role === 'user' && !said.auto) {
|
|
1633
|
+
// The first message a project ever got (2026-11-01): the step the welcome exists to reach.
|
|
1634
|
+
if (!salasRoom && !firstSaid) { firstSaid = true; diagnostics.count('project.first'); void writeFile(firstMark, new Date().toISOString()).catch(() => {}); }
|
|
1589
1635
|
if (said.target) diagnostics.count(`turn.${said.target}`);
|
|
1590
1636
|
if (Number.isInteger(said.mode)) diagnostics.count(`mode.${said.mode}`);
|
|
1591
1637
|
if (said.via) diagnostics.count(`via.${said.via}`);
|
|
@@ -1598,7 +1644,9 @@ export async function createPulseServer({
|
|
|
1598
1644
|
else if (event?.type === 'copilot.started') diagnostics.count('copilot.on');
|
|
1599
1645
|
else if (event?.type === 'extension.install.finished') {
|
|
1600
1646
|
if (said.ok) diagnostics.count(`install.${said.id ?? 'module'}`);
|
|
1601
|
-
|
|
1647
|
+
// What was installed and how it failed travel in the message too: madre.run keeps the message and
|
|
1648
|
+
// not `where`, and 10 copies of 1.1.x reported only «exit 1».
|
|
1649
|
+
else if (!said.cancelled) diagnostics.error({ kind: said.model ? 'model' : 'install', where: [said.id, said.trouble].filter(Boolean).join(' · ') || null, message: [said.detail ?? 'install failed', said.id, said.trouble].filter(Boolean).join(' · ') });
|
|
1602
1650
|
}
|
|
1603
1651
|
}
|
|
1604
1652
|
function wireRoom() {
|
|
@@ -2063,7 +2111,7 @@ export async function createPulseServer({
|
|
|
2063
2111
|
install: async () => {
|
|
2064
2112
|
if (installing) return { ok: false, error: t('Another install is running. Wait for it to finish and try again.') };
|
|
2065
2113
|
const { ollamaInstallPlan, adminHere } = await import('./modules/ollama.mjs');
|
|
2066
|
-
const plan = ollamaInstallPlan({ brew: await findOnPath('brew'), admin: await adminHere() });
|
|
2114
|
+
const plan = ollamaInstallPlan({ brew: await findOnPath('brew'), admin: await adminHere(), zstd: Boolean(await findOnPath('zstd')), apt: Boolean(await findOnPath('apt-get')) });
|
|
2067
2115
|
if (!plan.command) return { ok: false, error: plan.note, download: plan.download, manual: plan.manual ? plan.display : null };
|
|
2068
2116
|
installing = 'ollama'; installingSince = Date.now();
|
|
2069
2117
|
await room.record('extension.install.started', { id: 'ollama', name: 'OLLAMA', command: plan.display, platforms: [], alreadyInstalled: false });
|
|
@@ -2081,8 +2129,21 @@ export async function createPulseServer({
|
|
|
2081
2129
|
const binary = await findOnPath('ollama');
|
|
2082
2130
|
if (!binary) return { ok: false, error: t('Ollama is not on this computer yet.') };
|
|
2083
2131
|
await room.record('extension.install.started', { id: 'ollama', name: 'OLLAMA', command: 'ollama serve', platforms: [], alreadyInstalled: true });
|
|
2084
|
-
|
|
2085
|
-
|
|
2132
|
+
// A binary this user cannot run (EACCES: an install that stopped halfway, a file of another
|
|
2133
|
+
// user's) is said, not thrown: without a listener the error ended MADRE's process as an
|
|
2134
|
+
// uncaught exception (diagnostics of 1.1.1, 3 copies in WSL).
|
|
2135
|
+
const failed = new Promise((settle) => {
|
|
2136
|
+
const child = spawn(binary, ['serve'], { detached: process.platform !== 'win32', windowsHide: true, stdio: 'ignore' });
|
|
2137
|
+
child.on('error', (error) => settle(error));
|
|
2138
|
+
child.on('spawn', () => settle(null));
|
|
2139
|
+
child.unref();
|
|
2140
|
+
});
|
|
2141
|
+
const refused = await failed;
|
|
2142
|
+
if (refused) {
|
|
2143
|
+
const words = refused.code === 'EACCES' ? t('Ollama is at {path}, but this user cannot run it. Install it again, or give it permission to run.', { path: binary }) : t('Ollama did not start: {error}', { error: refused.message });
|
|
2144
|
+
await room.record('extension.install.finished', { id: 'ollama', name: 'OLLAMA', ok: false, installed: true, detail: refused.code === 'EACCES' ? `cannot run ${binary} (EACCES)` : refused.message, trouble: refused.code === 'EACCES' ? 'permission' : 'unknown', ollama });
|
|
2145
|
+
return { ok: false, error: words };
|
|
2146
|
+
}
|
|
2086
2147
|
// It answers in a moment or it does not: poll its own port rather than guess.
|
|
2087
2148
|
let status = ollama;
|
|
2088
2149
|
for (let attempt = 0; attempt < 20 && !status.running; attempt += 1) {
|
|
@@ -2228,6 +2289,15 @@ export async function createPulseServer({
|
|
|
2228
2289
|
// Which machine serves the page, written into it (public/i18n.js, hostWords): the browser that
|
|
2229
2290
|
// reads it may be on another one, a Mac looking at a Linux box, and must not say «Mac» there.
|
|
2230
2291
|
const withHost = (html) => html.replace('<head>', `<head>\n <meta name="madre-host" content="${JSON.stringify(hostFacts()).replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<')}">`);
|
|
2292
|
+
// A page of MADRE's own. Its files can vanish under a running copy (npx replaced its folder
|
|
2293
|
+
// with a newer version): then the page says so, instead of a failure (1.1.0 diagnostics).
|
|
2294
|
+
const pageHtml = async (name) => {
|
|
2295
|
+
try { return withHost(await readFile(join(publicDirectory, name), 'utf8')); }
|
|
2296
|
+
catch (error) {
|
|
2297
|
+
if (error?.code !== 'ENOENT') throw error;
|
|
2298
|
+
return `<!doctype html><meta charset="utf-8"><title>MADRE</title><body style="font:16px system-ui;background:#111;color:#eee;padding:48px"><p>${t('MADRE changed version while it was open. Close it and open it again.')}</p></body>`;
|
|
2299
|
+
}
|
|
2300
|
+
};
|
|
2231
2301
|
const designationOk = (given) => typeof given === 'string' && given.trim().toLowerCase() === basename(canonicalProjectRoot).toLowerCase();
|
|
2232
2302
|
// A request the bridge passed on from a paired phone. It reaches the room from 127.0.0.1 like
|
|
2233
2303
|
// anything on this Mac, so «only from this computer» has to ask this too.
|
|
@@ -2235,7 +2305,7 @@ export async function createPulseServer({
|
|
|
2235
2305
|
const phoneKind = viaPhone ? String(request.headers['x-madre-device-kind'] ?? 'other').slice(0, 20) : null;
|
|
2236
2306
|
try {
|
|
2237
2307
|
if (request.method === 'GET' && url.pathname === '/') {
|
|
2238
|
-
const html =
|
|
2308
|
+
const html = await pageHtml('index.html');
|
|
2239
2309
|
response.writeHead(200, { 'content-type': 'text/html; charset=utf-8', ...PAGE_GUARDS });
|
|
2240
2310
|
return response.end(html);
|
|
2241
2311
|
}
|
|
@@ -2248,7 +2318,7 @@ export async function createPulseServer({
|
|
|
2248
2318
|
// The user manual (public/manual.html, 1.0.5): read here, without a network, in the room's
|
|
2249
2319
|
// language; and the same manual printed, in both languages (scripts/manual-pdf.mjs).
|
|
2250
2320
|
if (request.method === 'GET' && url.pathname === '/manual') {
|
|
2251
|
-
const html =
|
|
2321
|
+
const html = await pageHtml('manual.html');
|
|
2252
2322
|
response.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache', ...PAGE_GUARDS });
|
|
2253
2323
|
return response.end(html);
|
|
2254
2324
|
}
|
|
@@ -2444,7 +2514,7 @@ export async function createPulseServer({
|
|
|
2444
2514
|
return response.end();
|
|
2445
2515
|
}
|
|
2446
2516
|
}
|
|
2447
|
-
const html =
|
|
2517
|
+
const html = await pageHtml('salas-mac.html');
|
|
2448
2518
|
response.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache', ...PAGE_GUARDS });
|
|
2449
2519
|
return response.end(html);
|
|
2450
2520
|
}
|
|
@@ -2595,6 +2665,7 @@ export async function createPulseServer({
|
|
|
2595
2665
|
// Where start.log stood before this try: only what this one wrote is read if it fails.
|
|
2596
2666
|
const logFrom = await stat(join(root, 'rooms', room.id, 'start.log')).then((info) => info.size, () => 0);
|
|
2597
2667
|
startRoom({ projectRoot: room.root, roomDir: join(root, 'rooms', room.id) });
|
|
2668
|
+
if (room.id !== salasRoomId(root)) diagnostics.count('project.opened');
|
|
2598
2669
|
const up = await roomComesUp(root, room.id);
|
|
2599
2670
|
if (!up) {
|
|
2600
2671
|
// The commonest reason, said as itself: another MADRE (another Home, `madre start`) already
|
|
@@ -2694,8 +2765,15 @@ export async function createPulseServer({
|
|
|
2694
2765
|
// A project from nothing: a new folder, named by the person, in the folder they were in.
|
|
2695
2766
|
if (request.method === 'POST' && url.pathname === '/api/salas/new') {
|
|
2696
2767
|
const payload = await body(request).catch(() => ({}));
|
|
2768
|
+
// A project to try MADRE with (src/salas.mjs, createSampleProject): from the welcome.
|
|
2769
|
+
if (payload.sample === true) {
|
|
2770
|
+
const sample = await createSampleProject({ home, stateRoot: root, language: payload.language === 'en' ? 'en' : 'es' });
|
|
2771
|
+
if (sample.error) return sendJson(response, 422, { error: t('The project to try MADRE could not be made.'), code: sample.error });
|
|
2772
|
+
diagnostics.count('project.sample');
|
|
2773
|
+
return sendJson(response, 200, { added: [sample] });
|
|
2774
|
+
}
|
|
2697
2775
|
const made = await createProject({ name: typeof payload.name === 'string' ? payload.name : '', parent: typeof payload.parent === 'string' ? payload.parent : null, home, stateRoot: root });
|
|
2698
|
-
if (!made.error) return sendJson(response, 200, { added: [made] });
|
|
2776
|
+
if (!made.error) { diagnostics.count('project.created'); return sendJson(response, 200, { added: [made] }); }
|
|
2699
2777
|
const said = {
|
|
2700
2778
|
empty: t('Write a name for the project.'),
|
|
2701
2779
|
long: t('That name is too long.'),
|
|
@@ -2717,6 +2795,7 @@ export async function createPulseServer({
|
|
|
2717
2795
|
if (result.error) refused.push({ root: one, error: result.error === 'madre' ? t('That folder is MADRE\'s own.') : result.error === 'outside' ? t('Only folders inside your home folder.') : t('That folder is not there.') });
|
|
2718
2796
|
else added.push(result);
|
|
2719
2797
|
}
|
|
2798
|
+
if (added.length) diagnostics.count('project.added', added.length);
|
|
2720
2799
|
return sendJson(response, added.length ? 200 : 422, { added, refused });
|
|
2721
2800
|
}
|
|
2722
2801
|
return sendJson(response, 405, { error: 'method' });
|
|
@@ -2770,7 +2849,15 @@ export async function createPulseServer({
|
|
|
2770
2849
|
const { stuck } = await closeOtherRooms();
|
|
2771
2850
|
if (stuck.length) return sendJson(response, 409, { error: t('These projects did not close, so nothing was removed: {list}. Close them from Home and try again.', { list: stuck.join(', ') }), stuck });
|
|
2772
2851
|
sendJson(response, 202, { uninstalling: true, ...planView(plan), madeGo: payload?.made === true });
|
|
2773
|
-
|
|
2852
|
+
// Said before anything goes (src/install-metrics.mjs): a copy uninstalled, with the
|
|
2853
|
+
// diagnostics. It travels with the event because startPulse cannot see this room's
|
|
2854
|
+
// diagnostics (1.1.0 read `testMode` there and crashed before removing anything).
|
|
2855
|
+
const farewell = async () => {
|
|
2856
|
+
if (testMode || !(await diagnosticsNow().catch(() => false))) return;
|
|
2857
|
+
diagnostics.count('life.uninstall');
|
|
2858
|
+
await diagnostics.flush({ fetchImpl: reportFetch }).catch(() => null);
|
|
2859
|
+
};
|
|
2860
|
+
setTimeout(() => server.emit('madre:uninstall', { plan, made: payload?.made === true, farewell }), 150);
|
|
2774
2861
|
return undefined;
|
|
2775
2862
|
}
|
|
2776
2863
|
// This room, asked to close by Salas: what is running stops and the room closes the way a
|
|
@@ -3686,6 +3773,9 @@ export async function createPulseServer({
|
|
|
3686
3773
|
pageErrors.push(now);
|
|
3687
3774
|
const payload = await body(request).catch(() => ({}));
|
|
3688
3775
|
const page = ['room', 'home', 'manual', 'phone'].includes(payload.page) ? payload.page : 'room';
|
|
3776
|
+
// The browser's resize notice is not a failure (public/page-errors.js drops it), but a tab
|
|
3777
|
+
// opened before that filter keeps its old script and still sends it: 3 copies of 1.1.1 did.
|
|
3778
|
+
if (/^ResizeObserver loop/.test(String(payload.message ?? ''))) return sendJson(response, 202, { kept: false });
|
|
3689
3779
|
diagnostics.error({ kind: 'page', where: page, message: String(payload.message ?? '').slice(0, 2000), stack: String(payload.stack ?? '').slice(0, 4000) });
|
|
3690
3780
|
return sendJson(response, 202, { kept: true });
|
|
3691
3781
|
}
|
|
@@ -3997,6 +4087,25 @@ export async function createPulseServer({
|
|
|
3997
4087
|
await markSeen(root, PACKAGE.version);
|
|
3998
4088
|
return sendJson(response, 200, { seen: PACKAGE.version });
|
|
3999
4089
|
}
|
|
4090
|
+
// The invitation to a first project (src/whats-new.mjs): due on Home to a copy that came from an
|
|
4091
|
+
// older MADRE and has no project, once per version. Never on a phone. Its answers are counted
|
|
4092
|
+
// with the anonymous diagnostics, and «shown» is what spends it.
|
|
4093
|
+
if (url.pathname === '/api/invite/project') {
|
|
4094
|
+
if (viaPhone) return sendJson(response, 200, { show: false });
|
|
4095
|
+
if (request.method === 'GET') {
|
|
4096
|
+
const projects = (await knownRooms(root)).filter((one) => one.id !== salasRoomId(root)).length;
|
|
4097
|
+
const show = cameFromOlder(novelty, PACKAGE.version) && projects === 0 && (await invitedFor(root)) !== PACKAGE.version;
|
|
4098
|
+
return sendJson(response, 200, { show, version: PACKAGE.version });
|
|
4099
|
+
}
|
|
4100
|
+
if (request.method === 'POST') {
|
|
4101
|
+
const payload = await body(request).catch(() => ({}));
|
|
4102
|
+
if (!INVITE_ANSWERS.includes(payload.answer)) return sendJson(response, 422, { error: 'answer' });
|
|
4103
|
+
if (payload.answer === 'shown') await markInvited(root, PACKAGE.version);
|
|
4104
|
+
diagnostics.count(`invite.project.${payload.answer}`);
|
|
4105
|
+
return sendJson(response, 200, { ok: true });
|
|
4106
|
+
}
|
|
4107
|
+
return sendJson(response, 405, { error: 'method' });
|
|
4108
|
+
}
|
|
4000
4109
|
// Asking for a star or a review (src/review-ask.mjs): a page in view says so once a minute and
|
|
4001
4110
|
// hears whether a moment is due; the answer ends the asking or lets that moment pass. A phone
|
|
4002
4111
|
// is never asked.
|
|
@@ -4030,8 +4139,18 @@ export async function createPulseServer({
|
|
|
4030
4139
|
}
|
|
4031
4140
|
if (viaPhone || !fromHere || (request.method === 'POST' && request.headers.origin !== `http://${host}`)) return sendJson(response, 403, { error: t('This is done on the Mac.') });
|
|
4032
4141
|
if (request.method === 'POST' && url.pathname === '/api/tour') {
|
|
4033
|
-
const
|
|
4142
|
+
const change = await body(request).catch(() => null);
|
|
4143
|
+
const changed = await changeTour(root, change);
|
|
4034
4144
|
if (changed.error) return sendJson(response, 422, { error: t('That is not a change to the tour.') });
|
|
4145
|
+
// How far people get in the welcome, and what they leave for later (2026-11-01): 90 of 147
|
|
4146
|
+
// copies never opened a project, and nothing said where they stopped. Step ids, nothing else.
|
|
4147
|
+
const step = change?.welcome;
|
|
4148
|
+
if (step && typeof step === 'object') {
|
|
4149
|
+
if (WELCOME_STEPS.includes(step.at)) diagnostics.count(`welcome.at.${step.at}`);
|
|
4150
|
+
if (WELCOME_STEPS.includes(step.done)) diagnostics.count(`welcome.done.${step.done}`);
|
|
4151
|
+
if (WELCOME_STEPS.includes(step.skipped)) diagnostics.count(`welcome.skip.${step.skipped}`);
|
|
4152
|
+
if (step.finished === true) diagnostics.count('welcome.finished');
|
|
4153
|
+
}
|
|
4035
4154
|
return sendJson(response, 200, { state: changed });
|
|
4036
4155
|
}
|
|
4037
4156
|
if (request.method === 'GET' && url.pathname === '/api/tour/projects') {
|
|
@@ -5038,12 +5157,8 @@ export async function startPulse({ port, projectRoot, openBrowser, openPath = ''
|
|
|
5038
5157
|
// Uninstalling (src/uninstall.mjs): the room closes as it does for a signal — every write done,
|
|
5039
5158
|
// the memory file closed — and only then is what the plan named taken away, last thing before the
|
|
5040
5159
|
// process ends, so nothing of MADRE's writes it back.
|
|
5041
|
-
server.once('madre:uninstall', ({ plan, made }) => server.close(async () => {
|
|
5042
|
-
|
|
5043
|
-
if (!testMode && await diagnosticsNow().catch(() => false)) {
|
|
5044
|
-
diagnostics.count('life.uninstall');
|
|
5045
|
-
await diagnostics.flush({ fetchImpl: reportFetch }).catch(() => null);
|
|
5046
|
-
}
|
|
5160
|
+
server.once('madre:uninstall', ({ plan, made, farewell }) => server.close(async () => {
|
|
5161
|
+
await farewell?.().catch(() => null);
|
|
5047
5162
|
const done = await removeMadre(plan, { made }).catch((error) => ({ removed: [], failed: [{ path: null, error: error.message }] }));
|
|
5048
5163
|
console.log(done.failed.length ? `\nMADRE was uninstalled, except:\n${done.failed.map((one) => ` ${one.path ?? ''} ${one.error}`).join('\n')}\n` : '\nMADRE was uninstalled.\n');
|
|
5049
5164
|
process.exit(0);
|
package/src/setup-trouble.mjs
CHANGED
|
@@ -11,11 +11,13 @@ const PERMISSION = /EACCES|EPERM|permission denied|operation not permitted|acces
|
|
|
11
11
|
const DISK = /ENOSPC|no space left/i;
|
|
12
12
|
const NO_NPM = /spawn npm(\.cmd)? ENOENT|npm(\.cmd)?: (command )?not found|'npm' is not recognized|command not found: npm/i;
|
|
13
13
|
const TIMEOUT = /timed out|timeout|ETIMEDOUT after|SIGTERM/i;
|
|
14
|
+
const NO_ZSTD = /requires zstd|install zstd/i;
|
|
14
15
|
const CANCELLED = /cancell?ed|aborted by the user/i;
|
|
15
16
|
|
|
16
17
|
export function installTrouble(text = '') {
|
|
17
18
|
const said = String(text);
|
|
18
19
|
if (NO_NPM.test(said)) return 'npm-missing';
|
|
20
|
+
if (NO_ZSTD.test(said)) return 'zstd-missing';
|
|
19
21
|
if (DISK.test(said)) return 'disk';
|
|
20
22
|
if (NETWORK.test(said)) return 'network';
|
|
21
23
|
if (PERMISSION.test(said)) return 'permission';
|
package/src/tour.mjs
CHANGED
|
@@ -40,7 +40,7 @@ export const HINTS = ['switch', 'links', 'key4',
|
|
|
40
40
|
'home-links', 'home-map', 'home-settings', 'home-add', 'new-add-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
|
-
'w-errors', 'w-live', 'w-installs', 'w-environments',
|
|
43
|
+
'w-errors', 'w-live', 'w-installs', 'w-environments', 'w-rumbo',
|
|
44
44
|
'touch-settings', 'touch-modules', 'touch-market', 'touch-mother', 'touch-memory', 'touch-crew', 'touch-steps', 'touch-browser', 'touch-tree', 'touch-chats', 'touch-code', 'touch-mcp',
|
|
45
45
|
'new-copilot', 'new-mcp', 'new-finder', 'new-memory-access', 'new-dots',
|
|
46
46
|
// 1.0.5: the way in for whoever is new (the box, the agent, the permission; Home's first step),
|
|
@@ -65,7 +65,7 @@ const BEFORE = ['1.0'];
|
|
|
65
65
|
// ready after `npx madre` — agents, local AI, memory, the first project — in their order. Where the
|
|
66
66
|
// person is, what they finished and what they left for later are kept here too, so closing the page
|
|
67
67
|
// halfway brings them back to the same step, from whichever project or port they open next.
|
|
68
|
-
export const WELCOME_STEPS = ['hello', 'machine', 'agents', '
|
|
68
|
+
export const WELCOME_STEPS = ['hello', 'machine', 'agents', 'project', 'ai', 'memory', 'ready'];
|
|
69
69
|
const freshWelcome = () => ({ at: null, done: [], skipped: [], finished: null });
|
|
70
70
|
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() });
|
|
71
71
|
// A tab that shows the bonjour or the chapters says so every few seconds; another tab that finds it
|
package/src/whats-new.mjs
CHANGED
|
@@ -388,6 +388,29 @@ export async function bootWhatsNew({ root, version }) {
|
|
|
388
388
|
return { seen: returning ? null : version, returning };
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
+
// A copy that ran an older MADRE before this one (2026-11-01): `novelty` as bootWhatsNew read it at
|
|
392
|
+
// start-up. A first install marks its own version as seen, so only an update makes this true; a copy
|
|
393
|
+
// from before the sheet existed has rooms and no mark, and came from an older one too.
|
|
394
|
+
export const cameFromOlder = (novelty, version) => (novelty?.seen ? compareVersions(version, novelty.seen) > 0 : Boolean(novelty?.returning));
|
|
395
|
+
|
|
396
|
+
// THE INVITATION TO A FIRST PROJECT (2026-11-01): whoever updates and has not added a project is
|
|
397
|
+
// asked once, on Home, to add one — 90 of 147 copies never opened a project. Once per version, in
|
|
398
|
+
// ~/.pulse/invites.json, for every port of this computer.
|
|
399
|
+
const INVITES = 'invites.json';
|
|
400
|
+
export async function invitedFor(root) {
|
|
401
|
+
try {
|
|
402
|
+
const value = JSON.parse(await readFile(join(root, INVITES), 'utf8'))?.project;
|
|
403
|
+
return typeof value === 'string' ? value : null;
|
|
404
|
+
} catch {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
export async function markInvited(root, version) {
|
|
409
|
+
await mkdir(root, { recursive: true });
|
|
410
|
+
await writeFile(join(root, INVITES), `${JSON.stringify({ project: version }, null, 2)}\n`);
|
|
411
|
+
}
|
|
412
|
+
export const INVITE_ANSWERS = ['shown', 'picked', 'sample', 'later'];
|
|
413
|
+
|
|
391
414
|
// `any`: the sheet for this version whether or not it was seen, for when it is asked for.
|
|
392
415
|
export async function whatsNew({ root, version, returning, any = false }) {
|
|
393
416
|
const seen = await readSeen(root);
|